mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
Do not scale georef WCS decorator if it is <1km (i.e. small site definition)
Previously it was scaled which misled users into thinking the point was in the wrong location.
This commit is contained in:
@@ -53,12 +53,13 @@ class GeoreferenceDecorator:
|
|||||||
pass
|
pass
|
||||||
cls.is_installed = False
|
cls.is_installed = False
|
||||||
|
|
||||||
def draw_batch(self, shader_type, content_pos, color, indices=None):
|
def draw_batch(self, shader_type, content_pos, color, indices=None, should_scale=True):
|
||||||
if not tool.Blender.validate_shader_batch_data(content_pos, indices):
|
if not tool.Blender.validate_shader_batch_data(content_pos, indices):
|
||||||
return
|
return
|
||||||
props = tool.Georeference.get_georeference_props()
|
props = tool.Georeference.get_georeference_props()
|
||||||
self.scale = props.visualization_scale
|
if should_scale:
|
||||||
content_pos = [v * self.scale for v in content_pos]
|
scale = tool.Georeference.get_georeference_props().visualization_scale
|
||||||
|
content_pos = [v * scale for v in content_pos]
|
||||||
shader = self.line_shader if shader_type == "LINES" else self.shader
|
shader = self.line_shader if shader_type == "LINES" else self.shader
|
||||||
batch = batch_for_shader(shader, shader_type, {"pos": content_pos}, indices=indices)
|
batch = batch_for_shader(shader, shader_type, {"pos": content_pos}, indices=indices)
|
||||||
shader.uniform_float("color", color)
|
shader.uniform_float("color", color)
|
||||||
@@ -141,12 +142,13 @@ class GeoreferenceDecorator:
|
|||||||
|
|
||||||
if wcs["blender_location"].length < 1000:
|
if wcs["blender_location"].length < 1000:
|
||||||
position = wcs["blender_location"].copy()
|
position = wcs["blender_location"].copy()
|
||||||
|
position -= Vector((0, 0.1, 0))
|
||||||
|
self.draw_text_at_position(context, text, position, should_scale=False)
|
||||||
else:
|
else:
|
||||||
position = wcs["blender_location"].normalized() * 3
|
position = wcs["blender_location"].normalized() * 3
|
||||||
text += "\n(Warning: Actual XYZ Not Shown)"
|
text += "\n(Warning: Actual XYZ Not Shown)"
|
||||||
position -= Vector((0, 0.1, 0))
|
position -= Vector((0, 0.1, 0))
|
||||||
|
self.draw_text_at_position(context, text, position)
|
||||||
self.draw_text_at_position(context, text, position)
|
|
||||||
|
|
||||||
if props.has_blender_offset:
|
if props.has_blender_offset:
|
||||||
text = "IFC Local Origin"
|
text = "IFC Local Origin"
|
||||||
@@ -165,8 +167,10 @@ class GeoreferenceDecorator:
|
|||||||
self.draw_text_at_position(context, text, location)
|
self.draw_text_at_position(context, text, location)
|
||||||
blf.disable(self.font_id, blf.SHADOW)
|
blf.disable(self.font_id, blf.SHADOW)
|
||||||
|
|
||||||
def draw_text_at_position(self, context, text, position):
|
def draw_text_at_position(self, context, text, position, should_scale=True):
|
||||||
position = [v * self.scale for v in position]
|
if should_scale:
|
||||||
|
scale = tool.Georeference.get_georeference_props().visualization_scale
|
||||||
|
position = [v * scale for v in position]
|
||||||
coords_2d = location_3d_to_region_2d(context.region, context.region_data, position)
|
coords_2d = location_3d_to_region_2d(context.region, context.region_data, position)
|
||||||
if not coords_2d:
|
if not coords_2d:
|
||||||
return
|
return
|
||||||
@@ -309,8 +313,8 @@ class GeoreferenceDecorator:
|
|||||||
if wcs["blender_location"].length < 1000:
|
if wcs["blender_location"].length < 1000:
|
||||||
verts = [Vector((0, 0, 0)), wcs["blender_location"]]
|
verts = [Vector((0, 0, 0)), wcs["blender_location"]]
|
||||||
edges = [[0, 1]]
|
edges = [[0, 1]]
|
||||||
self.draw_batch("LINES", verts, decorator_color_special, edges)
|
self.draw_batch("LINES", verts, decorator_color_special, edges, should_scale=False)
|
||||||
self.draw_batch("POINTS", verts[1:], decorator_color_special)
|
self.draw_batch("POINTS", verts[1:], decorator_color_special, should_scale=False)
|
||||||
else:
|
else:
|
||||||
location = wcs["blender_location"].normalized()
|
location = wcs["blender_location"].normalized()
|
||||||
edges = [[0, 1]]
|
edges = [[0, 1]]
|
||||||
@@ -332,7 +336,7 @@ class GeoreferenceDecorator:
|
|||||||
self.draw_batch("LINES", verts, decorator_color_special, edges)
|
self.draw_batch("LINES", verts, decorator_color_special, edges)
|
||||||
self.draw_dashed_line(location * 3, location * 6, decorator_color_error)
|
self.draw_dashed_line(location * 3, location * 6, decorator_color_error)
|
||||||
|
|
||||||
def draw_dashed_line(self, start, end, colour):
|
def draw_dashed_line(self, start, end, colour, should_scale=True):
|
||||||
direction = (end - start).normalized()
|
direction = (end - start).normalized()
|
||||||
distance = (end - start).length
|
distance = (end - start).length
|
||||||
current_distance = Vector((0, 0, 0))
|
current_distance = Vector((0, 0, 0))
|
||||||
@@ -347,7 +351,7 @@ class GeoreferenceDecorator:
|
|||||||
|
|
||||||
edges = [[i, i + 1] for i in range(0, len(points), 2)]
|
edges = [[i, i + 1] for i in range(0, len(points), 2)]
|
||||||
verts = points
|
verts = points
|
||||||
self.draw_batch("LINES", verts, colour, edges)
|
self.draw_batch("LINES", verts, colour, edges, should_scale=should_scale)
|
||||||
|
|
||||||
def calculate_angles(self, context):
|
def calculate_angles(self, context):
|
||||||
self.pn_angle = 0.0
|
self.pn_angle = 0.0
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ class BIMGeoreferenceProperties(PropertyGroup):
|
|||||||
description="Affects the georeference decorator size",
|
description="Affects the georeference decorator size",
|
||||||
default=1,
|
default=1,
|
||||||
soft_min=0.1,
|
soft_min=0.1,
|
||||||
soft_max=50,
|
soft_max=100,
|
||||||
)
|
)
|
||||||
grid_north_angle: StringProperty(name="Grid North Angle", update=update_grid_north_angle)
|
grid_north_angle: StringProperty(name="Grid North Angle", update=update_grid_north_angle)
|
||||||
x_axis_abscissa: StringProperty(name="X Axis Abscissa", update=update_grid_north_vector)
|
x_axis_abscissa: StringProperty(name="X Axis Abscissa", update=update_grid_north_vector)
|
||||||
|
|||||||
Reference in New Issue
Block a user