From 177d43c30e4e0aea8e92fb9449ff7d80228720a3 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 22 Jun 2024 16:29:36 +1000 Subject: [PATCH] Redesign georeference calculator UI to show units and be explicit about local vs map (instead of input vs output) --- .../bim/module/georeference/__init__.py | 1 - .../bim/module/georeference/operator.py | 19 ++-------------- .../bim/module/georeference/prop.py | 8 +++++-- .../blenderbim/bim/module/georeference/ui.py | 10 +++++---- .../blenderbim/core/georeference.py | 18 ++++++--------- .../blenderbim/tool/georeference.py | 22 +++++++++---------- 6 files changed, 31 insertions(+), 47 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/georeference/__init__.py b/src/blenderbim/blenderbim/bim/module/georeference/__init__.py index 18578d5455..bf145af93c 100644 --- a/src/blenderbim/blenderbim/bim/module/georeference/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/georeference/__init__.py @@ -32,7 +32,6 @@ classes = ( operator.ConvertLocalToGlobal, operator.ConvertGlobalToLocal, operator.GetCursorLocation, - operator.SetCursorLocation, operator.ConvertAngleToCoordinates, operator.ImportPlot, prop.BIMGeoreferenceProperties, diff --git a/src/blenderbim/blenderbim/bim/module/georeference/operator.py b/src/blenderbim/blenderbim/bim/module/georeference/operator.py index ed6d96d7d8..3024e7c543 100644 --- a/src/blenderbim/blenderbim/bim/module/georeference/operator.py +++ b/src/blenderbim/blenderbim/bim/module/georeference/operator.py @@ -106,21 +106,6 @@ class GetCursorLocation(bpy.types.Operator, tool.Ifc.Operator): core.get_cursor_location(tool.Georeference) -class SetCursorLocation(bpy.types.Operator, tool.Ifc.Operator): - bl_idname = "bim.set_cursor_location" - bl_label = "Set Cursor Location" - bl_options = {"REGISTER", "UNDO"} - bl_description = "Move cursor location to the specified coordinates" - - @classmethod - def poll(cls, context): - props = context.scene.BIMGeoreferenceProperties - return tool.Ifc.get() and props.coordinate_output.count(",") == 2 - - def _execute(self, context): - core.set_cursor_location(tool.Georeference) - - class SetIfcTrueNorth(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.set_ifc_true_north" bl_label = "Set IFC True North" @@ -151,7 +136,7 @@ class ConvertLocalToGlobal(bpy.types.Operator, tool.Ifc.Operator): def poll(cls, context): file = tool.Ifc.get() props = context.scene.BIMGeoreferenceProperties - return file and props.coordinate_input.count(",") == 2 + return file and props.local_coordinates.count(",") == 2 def _execute(self, context): core.convert_local_to_global(tool.Georeference) @@ -167,7 +152,7 @@ class ConvertGlobalToLocal(bpy.types.Operator, tool.Ifc.Operator): def poll(cls, context): file = tool.Ifc.get() props = context.scene.BIMGeoreferenceProperties - return file and file.by_type("IfcUnitAssignment") and props.coordinate_input.count(",") == 2 + return file and file.by_type("IfcUnitAssignment") and props.local_coordinates.count(",") == 2 def _execute(self, context): core.convert_global_to_local(tool.Georeference) diff --git a/src/blenderbim/blenderbim/bim/module/georeference/prop.py b/src/blenderbim/blenderbim/bim/module/georeference/prop.py index d52bdde94f..9351945094 100644 --- a/src/blenderbim/blenderbim/bim/module/georeference/prop.py +++ b/src/blenderbim/blenderbim/bim/module/georeference/prop.py @@ -35,8 +35,12 @@ class BIMGeoreferenceProperties(PropertyGroup): is_editing: BoolProperty(name="Is Editing") map_conversion: CollectionProperty(name="Map Conversion", type=Attribute) projected_crs: CollectionProperty(name="Projected CRS", type=Attribute) - coordinate_input: StringProperty(name="Coordinate Input", description='Formatted "x,y,z" (without quotes)') - coordinate_output: StringProperty(name="Coordinate Output", description='Formatted "x,y,z" (without quotes)') + local_coordinates: StringProperty( + name="Local Coordinates", description='Formatted "x,y,z" (without quotes)', default="0,0,0" + ) + map_coordinates: StringProperty( + name="Map Coordinates", description='Formatted "x,y,z" (without quotes)', default="0,0,0" + ) angle_degree_input_x: FloatProperty(name="Angle Degree Input", description="Angle (in degrees) rel to Easting") angle_degree_input_y: FloatProperty(name="Angle Degree Input", description="Angle (in degrees) rel to +Y") x_axis_abscissa_output: StringProperty( diff --git a/src/blenderbim/blenderbim/bim/module/georeference/ui.py b/src/blenderbim/blenderbim/bim/module/georeference/ui.py index 5d0f364afd..2223b55fc4 100644 --- a/src/blenderbim/blenderbim/bim/module/georeference/ui.py +++ b/src/blenderbim/blenderbim/bim/module/georeference/ui.py @@ -164,14 +164,16 @@ class BIM_PT_gis_calculator(Panel): bl_parent_id = "BIM_PT_gis" def draw(self, context): + if not GeoreferenceData.is_loaded: + GeoreferenceData.load() + props = context.scene.BIMGeoreferenceProperties row = self.layout.row(align=True) - row.prop(props, "coordinate_input", text="Input") + row.prop(props, "local_coordinates", text=f"Local ({GeoreferenceData.data['local_unit_symbol']})") row.operator("bim.get_cursor_location", text="", icon="TRACKER") - row = self.layout.row(align=True) - row.prop(props, "coordinate_output", text="Output") - row.operator("bim.set_cursor_location", text="", icon="TRACKER") + row = self.layout.row() + row.prop(props, "map_coordinates", text=f"Map ({GeoreferenceData.data['map_unit_symbol']})") row = self.layout.row(align=True) row.operator("bim.convert_local_to_global", text="Local to Global") diff --git a/src/blenderbim/blenderbim/core/georeference.py b/src/blenderbim/blenderbim/core/georeference.py index 9c6e6de118..66b12b0259 100644 --- a/src/blenderbim/blenderbim/core/georeference.py +++ b/src/blenderbim/blenderbim/core/georeference.py @@ -63,23 +63,19 @@ def set_blender_true_north(georeference): def get_cursor_location(georeference): - georeference.set_coordinates("input", georeference.get_cursor_location()) - - -def set_cursor_location(georeference): - georeference.set_cursor_location(georeference.get_coordinates("output")) + georeference.set_coordinates("local", georeference.get_cursor_location()) def convert_local_to_global(georeference): - coordinates = georeference.xyz2enh(georeference.get_coordinates("input")) - georeference.set_coordinates("output", coordinates) - georeference.set_cursor_location(coordinates) + coordinates = georeference.xyz2enh(georeference.get_coordinates("local")) + georeference.set_coordinates("map", coordinates) + georeference.set_cursor_location() def convert_global_to_local(georeference): - coordinates = georeference.enh2xyz(georeference.get_coordinates("input")) - georeference.set_coordinates("output", coordinates) - georeference.set_cursor_location(coordinates) + coordinates = georeference.enh2xyz(georeference.get_coordinates("map")) + georeference.set_coordinates("local", coordinates) + georeference.set_cursor_location() def convert_angle_to_coord(georeference, type): vector_coordinates = georeference.angle2coords(georeference.get_angle(type), type) diff --git a/src/blenderbim/blenderbim/tool/georeference.py b/src/blenderbim/blenderbim/tool/georeference.py index 037b5c6645..459e29c2ab 100644 --- a/src/blenderbim/blenderbim/tool/georeference.py +++ b/src/blenderbim/blenderbim/tool/georeference.py @@ -135,26 +135,26 @@ class Georeference(blenderbim.core.tool.Georeference): @classmethod def set_coordinates(cls, io, coordinates): - if io == "input": - bpy.context.scene.BIMGeoreferenceProperties.coordinate_input = ",".join([str(o) for o in coordinates]) - elif io == "output": - bpy.context.scene.BIMGeoreferenceProperties.coordinate_output = ",".join([str(o) for o in coordinates]) + if io == "local": + bpy.context.scene.BIMGeoreferenceProperties.local_coordinates = ",".join([str(o) for o in coordinates]) + elif io == "map": + bpy.context.scene.BIMGeoreferenceProperties.map_coordinates = ",".join([str(o) for o in coordinates]) @classmethod def get_coordinates(cls, io): - if io == "input": - return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.coordinate_input.split(",")] - elif io == "output": - return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.coordinate_output.split(",")] + if io == "local": + return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.local_coordinates.split(",")] + elif io == "map": + return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.map_coordinates.split(",")] @classmethod def get_cursor_location(cls): - props = bpy.context.scene.BIMGeoreferenceProperties scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) return [o / scale for o in bpy.context.scene.cursor.location] @classmethod - def set_cursor_location(cls, coordinates): + def set_cursor_location(cls): + coordinates = cls.get_coordinates("local") scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) bpy.context.scene.cursor.location = [co * scale for co in coordinates] @@ -186,7 +186,6 @@ class Georeference(blenderbim.core.tool.Georeference): float(props.blender_orthogonal_height), float(props.blender_x_axis_abscissa), float(props.blender_x_axis_ordinate), - 1.0, ) return ifcopenshell.util.geolocation.auto_xyz2enh(tool.Ifc.get(), *coordinates) @@ -204,7 +203,6 @@ class Georeference(blenderbim.core.tool.Georeference): float(props.blender_orthogonal_height), float(props.blender_x_axis_abscissa), float(props.blender_x_axis_ordinate), - 1.0, ) return coordinates