mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +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.ConvertLocalToGlobal,
|
||||||
operator.ConvertGlobalToLocal,
|
operator.ConvertGlobalToLocal,
|
||||||
operator.GetCursorLocation,
|
operator.GetCursorLocation,
|
||||||
operator.SetCursorLocation,
|
|
||||||
operator.ConvertAngleToCoordinates,
|
operator.ConvertAngleToCoordinates,
|
||||||
operator.ImportPlot,
|
operator.ImportPlot,
|
||||||
prop.BIMGeoreferenceProperties,
|
prop.BIMGeoreferenceProperties,
|
||||||
|
|||||||
@@ -106,21 +106,6 @@ class GetCursorLocation(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
core.get_cursor_location(tool.Georeference)
|
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):
|
class SetIfcTrueNorth(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.set_ifc_true_north"
|
bl_idname = "bim.set_ifc_true_north"
|
||||||
bl_label = "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):
|
def poll(cls, context):
|
||||||
file = tool.Ifc.get()
|
file = tool.Ifc.get()
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
return file and props.coordinate_input.count(",") == 2
|
return file and props.local_coordinates.count(",") == 2
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
core.convert_local_to_global(tool.Georeference)
|
core.convert_local_to_global(tool.Georeference)
|
||||||
@@ -167,7 +152,7 @@ class ConvertGlobalToLocal(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
file = tool.Ifc.get()
|
file = tool.Ifc.get()
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
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):
|
def _execute(self, context):
|
||||||
core.convert_global_to_local(tool.Georeference)
|
core.convert_global_to_local(tool.Georeference)
|
||||||
|
|||||||
@@ -35,8 +35,12 @@ class BIMGeoreferenceProperties(PropertyGroup):
|
|||||||
is_editing: BoolProperty(name="Is Editing")
|
is_editing: BoolProperty(name="Is Editing")
|
||||||
map_conversion: CollectionProperty(name="Map Conversion", type=Attribute)
|
map_conversion: CollectionProperty(name="Map Conversion", type=Attribute)
|
||||||
projected_crs: CollectionProperty(name="Projected CRS", type=Attribute)
|
projected_crs: CollectionProperty(name="Projected CRS", type=Attribute)
|
||||||
coordinate_input: StringProperty(name="Coordinate Input", description='Formatted "x,y,z" (without quotes)')
|
local_coordinates: StringProperty(
|
||||||
coordinate_output: StringProperty(name="Coordinate Output", description='Formatted "x,y,z" (without quotes)')
|
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_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")
|
angle_degree_input_y: FloatProperty(name="Angle Degree Input", description="Angle (in degrees) rel to +Y")
|
||||||
x_axis_abscissa_output: StringProperty(
|
x_axis_abscissa_output: StringProperty(
|
||||||
|
|||||||
@@ -164,14 +164,16 @@ class BIM_PT_gis_calculator(Panel):
|
|||||||
bl_parent_id = "BIM_PT_gis"
|
bl_parent_id = "BIM_PT_gis"
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
if not GeoreferenceData.is_loaded:
|
||||||
|
GeoreferenceData.load()
|
||||||
|
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
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.operator("bim.get_cursor_location", text="", icon="TRACKER")
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row()
|
||||||
row.prop(props, "coordinate_output", text="Output")
|
row.prop(props, "map_coordinates", text=f"Map ({GeoreferenceData.data['map_unit_symbol']})")
|
||||||
row.operator("bim.set_cursor_location", text="", icon="TRACKER")
|
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.convert_local_to_global", text="Local to Global")
|
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):
|
def get_cursor_location(georeference):
|
||||||
georeference.set_coordinates("input", georeference.get_cursor_location())
|
georeference.set_coordinates("local", georeference.get_cursor_location())
|
||||||
|
|
||||||
|
|
||||||
def set_cursor_location(georeference):
|
|
||||||
georeference.set_cursor_location(georeference.get_coordinates("output"))
|
|
||||||
|
|
||||||
|
|
||||||
def convert_local_to_global(georeference):
|
def convert_local_to_global(georeference):
|
||||||
coordinates = georeference.xyz2enh(georeference.get_coordinates("input"))
|
coordinates = georeference.xyz2enh(georeference.get_coordinates("local"))
|
||||||
georeference.set_coordinates("output", coordinates)
|
georeference.set_coordinates("map", coordinates)
|
||||||
georeference.set_cursor_location(coordinates)
|
georeference.set_cursor_location()
|
||||||
|
|
||||||
|
|
||||||
def convert_global_to_local(georeference):
|
def convert_global_to_local(georeference):
|
||||||
coordinates = georeference.enh2xyz(georeference.get_coordinates("input"))
|
coordinates = georeference.enh2xyz(georeference.get_coordinates("map"))
|
||||||
georeference.set_coordinates("output", coordinates)
|
georeference.set_coordinates("local", coordinates)
|
||||||
georeference.set_cursor_location(coordinates)
|
georeference.set_cursor_location()
|
||||||
|
|
||||||
def convert_angle_to_coord(georeference, type):
|
def convert_angle_to_coord(georeference, type):
|
||||||
vector_coordinates = georeference.angle2coords(georeference.get_angle(type), type)
|
vector_coordinates = georeference.angle2coords(georeference.get_angle(type), type)
|
||||||
|
|||||||
@@ -135,26 +135,26 @@ class Georeference(blenderbim.core.tool.Georeference):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_coordinates(cls, io, coordinates):
|
def set_coordinates(cls, io, coordinates):
|
||||||
if io == "input":
|
if io == "local":
|
||||||
bpy.context.scene.BIMGeoreferenceProperties.coordinate_input = ",".join([str(o) for o in coordinates])
|
bpy.context.scene.BIMGeoreferenceProperties.local_coordinates = ",".join([str(o) for o in coordinates])
|
||||||
elif io == "output":
|
elif io == "map":
|
||||||
bpy.context.scene.BIMGeoreferenceProperties.coordinate_output = ",".join([str(o) for o in coordinates])
|
bpy.context.scene.BIMGeoreferenceProperties.map_coordinates = ",".join([str(o) for o in coordinates])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_coordinates(cls, io):
|
def get_coordinates(cls, io):
|
||||||
if io == "input":
|
if io == "local":
|
||||||
return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.coordinate_input.split(",")]
|
return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.local_coordinates.split(",")]
|
||||||
elif io == "output":
|
elif io == "map":
|
||||||
return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.coordinate_output.split(",")]
|
return [float(co) for co in bpy.context.scene.BIMGeoreferenceProperties.map_coordinates.split(",")]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_cursor_location(cls):
|
def get_cursor_location(cls):
|
||||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
|
||||||
scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
return [o / scale for o in bpy.context.scene.cursor.location]
|
return [o / scale for o in bpy.context.scene.cursor.location]
|
||||||
|
|
||||||
@classmethod
|
@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())
|
scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
bpy.context.scene.cursor.location = [co * scale for co in coordinates]
|
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_orthogonal_height),
|
||||||
float(props.blender_x_axis_abscissa),
|
float(props.blender_x_axis_abscissa),
|
||||||
float(props.blender_x_axis_ordinate),
|
float(props.blender_x_axis_ordinate),
|
||||||
1.0,
|
|
||||||
)
|
)
|
||||||
return ifcopenshell.util.geolocation.auto_xyz2enh(tool.Ifc.get(), *coordinates)
|
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_orthogonal_height),
|
||||||
float(props.blender_x_axis_abscissa),
|
float(props.blender_x_axis_abscissa),
|
||||||
float(props.blender_x_axis_ordinate),
|
float(props.blender_x_axis_ordinate),
|
||||||
1.0,
|
|
||||||
)
|
)
|
||||||
return coordinates
|
return coordinates
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user