Add option to change the size of the georeference decorator.

This commit is contained in:
Bruno Perdigão
2024-11-22 14:48:57 -03:00
parent 352a2e2eb8
commit 0267e2b5e0
3 changed files with 15 additions and 1 deletions
@@ -53,6 +53,8 @@ class GeoreferenceDecorator:
cls.is_installed = False
def draw_batch(self, shader_type, content_pos, color, indices=None):
self.scale = bpy.context.scene.BIMGeoreferenceProperties.visualization_scale
content_pos = [v * self.scale for v in content_pos]
shader = self.line_shader if shader_type == "LINES" else self.shader
batch = batch_for_shader(shader, shader_type, {"pos": content_pos}, indices=indices)
shader.uniform_float("color", color)
@@ -73,7 +75,8 @@ class GeoreferenceDecorator:
self.addon_prefs = tool.Blender.get_addon_preferences()
self.font_id = 0
blf.size(self.font_id, 12)
font_size = tool.Blender.scale_font_size(12 + (self.scale/8))
blf.size(self.font_id, font_size)
color = self.addon_prefs.decorations_colour
blf.color(self.font_id, *color)
blf.enable(self.font_id, blf.SHADOW)
@@ -157,6 +160,7 @@ class GeoreferenceDecorator:
blf.disable(self.font_id, blf.SHADOW)
def draw_text_at_position(self, context, text, position):
position = [v * self.scale for v in position]
coords_2d = location_3d_to_region_2d(context.region, context.region_data, position)
if not coords_2d:
return
@@ -228,6 +232,7 @@ class GeoreferenceDecorator:
pts=[arc_start, arc_mid, arc_end], num_verts=12, make_edges=True
)
verts, edges = arc_segments
verts = [Vector(v) for v in verts]
self.draw_batch("LINES", verts, decorator_color_selected, edges)
if GeoreferenceData.data["coordinate_operation"]:
@@ -257,6 +262,7 @@ class GeoreferenceDecorator:
pts=[arc_start, arc_mid, arc_end], num_verts=12, make_edges=True
)
verts, edges = arc_segments
verts = [Vector(v) for v in verts]
self.draw_batch("LINES", verts, decorator_color_special, edges)
if GeoreferenceData.data["true_north"]:
@@ -286,6 +292,7 @@ class GeoreferenceDecorator:
pts=[arc_start, arc_mid, arc_end], num_verts=12, make_edges=True
)
verts, edges = arc_segments
verts = [Vector(v) for v in verts]
self.draw_batch("LINES", verts, decorator_color_special, edges)
if (wcs := GeoreferenceData.data["world_coordinate_system"]) and wcs["has_transformation"]:
@@ -205,6 +205,7 @@ class BIMGeoreferenceProperties(PropertyGroup):
default=False,
update=update_should_visualise,
)
visualization_scale: IntProperty(name="Visualization Scale", description="Affects the georeference decorator size", default=1, min=1, max=20)
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_ordinate: StringProperty(name="X Axis Ordinate", update=update_grid_north_vector)
@@ -87,7 +87,10 @@ class BIM_PT_gis(Panel):
if not GeoreferenceData.data["projected_crs"]:
row = self.layout.row(align=True)
row.label(text="Not Georeferenced", icon="ERROR")
row = self.layout.row(align=True)
row.label(text="Visualise")
row.prop(props, "should_visualise", icon="HIDE_OFF", text="")
row.prop(props, "visualization_scale", text="Size")
if tool.Ifc.get_schema() != "IFC2X3":
row = self.layout.row(align=True)
row.prop(props, "coordinate_operation_class", text="")
@@ -96,7 +99,10 @@ class BIM_PT_gis(Panel):
if GeoreferenceData.data["projected_crs"]:
row = self.layout.row(align=True)
row.label(text="Projected CRS", icon="WORLD")
row = self.layout.row(align=True)
row.label(text="Visualise")
row.prop(props, "should_visualise", icon="HIDE_OFF", text="")
row.prop(props, "visualization_scale", text="Visualization Scale")
if tool.Ifc.get_schema() != "IFC2X3":
row.operator("bim.enable_editing_georeferencing", icon="GREASEPENCIL", text="")
row.operator("bim.remove_georeferencing", icon="X", text="")