mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Redesign georeference calculator UI to show units and be explicit about local vs map (instead of input vs output)
This commit is contained in:
@@ -32,7 +32,6 @@ classes = (
|
||||
operator.ConvertLocalToGlobal,
|
||||
operator.ConvertGlobalToLocal,
|
||||
operator.GetCursorLocation,
|
||||
operator.SetCursorLocation,
|
||||
operator.ConvertAngleToCoordinates,
|
||||
operator.ImportPlot,
|
||||
prop.BIMGeoreferenceProperties,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user