Split true north in API and Blender UI to be editable independent of georeferencing

They are two separate concepts, after all.
This commit is contained in:
Dion Moult
2024-06-23 23:19:27 +10:00
parent 013b138e5c
commit e295d596fe
11 changed files with 273 additions and 110 deletions
@@ -25,10 +25,13 @@ classes = (
operator.ConvertGlobalToLocal,
operator.ConvertLocalToGlobal,
operator.DisableEditingGeoreferencing,
operator.DisableEditingTrueNorth,
operator.DisableEditingWCS,
operator.EditGeoreferencing,
operator.EditTrueNorth,
operator.EditWCS,
operator.EnableEditingGeoreferencing,
operator.EnableEditingTrueNorth,
operator.EnableEditingWCS,
operator.GetCursorLocation,
operator.ImportPlot,
@@ -39,6 +42,8 @@ classes = (
operator.SetIfcTrueNorth,
prop.BIMGeoreferenceProperties,
ui.BIM_PT_gis,
ui.BIM_PT_gis_wcs,
ui.BIM_PT_gis_true_north,
ui.BIM_PT_gis_calculator,
)
@@ -219,3 +219,33 @@ class DisableEditingWCS(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context):
core.disable_editing_wcs(tool.Georeference)
class EnableEditingTrueNorth(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.enable_editing_true_north"
bl_label = "Enable Editing True North"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Enable editing True North"
def _execute(self, context):
core.enable_editing_true_north(tool.Georeference)
class EditTrueNorth(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.edit_true_north"
bl_label = "Edit True North"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Edit the True North"
def _execute(self, context):
core.edit_true_north(tool.Ifc, tool.Georeference)
class DisableEditingTrueNorth(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.disable_editing_true_north"
bl_label = "Disable Editing True North"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Close editing panel"
def _execute(self, context):
core.disable_editing_true_north(tool.Georeference)
@@ -44,6 +44,7 @@ class BIMGeoreferenceProperties(PropertyGroup):
)
is_editing: BoolProperty(name="Is Editing")
is_editing_wcs: BoolProperty(name="Is Editing WCS")
is_editing_true_north: BoolProperty(name="Is Editing True North")
coordinate_operation: CollectionProperty(name="Coordinate Operation", type=Attribute)
projected_crs: CollectionProperty(name="Projected CRS", type=Attribute)
local_coordinates: StringProperty(
@@ -44,11 +44,6 @@ class BIM_PT_gis(Panel):
else:
self.draw_ui(context)
if props.is_editing_wcs:
self.draw_editable_wcs_ui(context)
else:
self.draw_wcs_ui()
def draw_editable_ui(self, context):
props = context.scene.BIMGeoreferenceProperties
row = self.layout.row(align=True)
@@ -68,19 +63,6 @@ class BIM_PT_gis(Panel):
row.operator("bim.set_blender_grid_north", text="Set Blender North")
draw_attribute(attribute, self.layout.row())
row = self.layout.row()
row.label(text="True North", icon="LIGHT_SUN")
row = self.layout.row()
row.prop(props, "has_true_north")
row = self.layout.row()
row.prop(props, "true_north_abscissa")
row = self.layout.row()
row.prop(props, "true_north_ordinate")
if hasattr(context.scene, "sun_pos_properties"):
row = self.layout.row(align=True)
row.operator("bim.set_ifc_true_north", text="Set IFC North")
row.operator("bim.set_blender_true_north", text="Set Blender North")
def draw_ui(self, context):
props = context.scene.BIMGeoreferenceProperties
@@ -153,24 +135,83 @@ class BIM_PT_gis(Panel):
row.label(text="Derived Angle")
row.label(text=GeoreferenceData.data["map_derived_angle"])
class BIM_PT_gis_true_north(Panel):
bl_idname = "BIM_PT_gis_true_north"
bl_label = "True North"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
bl_parent_id = "BIM_PT_gis"
def draw(self, context):
if not GeoreferenceData.is_loaded:
GeoreferenceData.load()
self.props = context.scene.BIMGeoreferenceProperties
if self.props.is_editing_true_north:
self.draw_editable_ui(context)
else:
self.draw_ui()
def draw_editable_ui(self, context):
row = self.layout.row()
row.prop(self.props, "has_true_north")
row = self.layout.row()
row.prop(self.props, "true_north_abscissa")
row = self.layout.row()
row.prop(self.props, "true_north_ordinate")
if hasattr(context.scene, "sun_pos_properties"):
row = self.layout.row(align=True)
row.operator("bim.set_ifc_true_north", text="Set IFC North")
row.operator("bim.set_blender_true_north", text="Set Blender North")
row = self.layout.row(align=True)
row.operator("bim.edit_true_north", icon="CHECKMARK")
row.operator("bim.disable_editing_true_north", icon="CANCEL", text="")
def draw_ui(self):
if GeoreferenceData.data["true_north"]:
row = self.layout.row()
row.label(text="True North", icon="LIGHT_SUN")
row = self.layout.row(align=True)
row.label(text="Vector")
row.label(text=str(GeoreferenceData.data["true_north"][0:2])[1:-1])
row.operator("bim.enable_editing_true_north", icon="GREASEPENCIL", text="")
row = self.layout.row(align=True)
row.label(text="Derived Angle")
row.label(text=GeoreferenceData.data["true_derived_angle"])
else:
row = self.layout.row(align=True)
row.label(text="No True North Found", icon="LIGHT_SUN")
row.operator("bim.enable_editing_true_north", icon="GREASEPENCIL", text="")
def draw_wcs_ui(self):
row = self.layout.row(align=True)
row.label(text="World Coordinate System", icon="EMPTY_ARROWS")
row.operator("bim.enable_editing_wcs", icon="GREASEPENCIL", text="")
class BIM_PT_gis_wcs(Panel):
bl_idname = "BIM_PT_gis_wcs"
bl_label = "World Coordinate System"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
bl_parent_id = "BIM_PT_gis"
def draw(self, context):
if not GeoreferenceData.is_loaded:
GeoreferenceData.load()
props = context.scene.BIMGeoreferenceProperties
if props.is_editing_wcs:
self.draw_editable_ui(context)
else:
self.draw_ui()
def draw_ui(self):
if GeoreferenceData.data["world_coordinate_system"]["has_transformation"]:
row = self.layout.row()
row = self.layout.row(align=True)
row.label(text="Unrecommended Transformation Found", icon="ERROR")
row.operator("bim.enable_editing_wcs", icon="GREASEPENCIL", text="")
row = self.layout.row(align=True)
row.label(text="X")
row.label(text=str(GeoreferenceData.data["world_coordinate_system"]["x"]))
@@ -186,8 +227,9 @@ class BIM_PT_gis(Panel):
else:
row = self.layout.row()
row.label(text="No WCS Transformation", icon="CHECKMARK")
row.operator("bim.enable_editing_wcs", icon="GREASEPENCIL", text="")
def draw_editable_wcs_ui(self, context):
def draw_editable_ui(self, context):
props = context.scene.BIMGeoreferenceProperties
row = self.layout.row(align=True)
+14 -1
View File
@@ -24,7 +24,6 @@ def add_georeferencing(georeference):
def enable_editing_georeferencing(georeference):
georeference.import_projected_crs()
georeference.import_coordinate_operation()
georeference.import_true_north()
georeference.enable_editing()
@@ -100,3 +99,17 @@ def edit_wcs(ifc, georeference):
wcs = georeference.export_wcs()
georeference.set_wcs(wcs)
georeference.disable_editing_wcs()
def enable_editing_true_north(georeference):
georeference.import_true_north()
georeference.enable_editing_true_north()
def disable_editing_true_north(georeference):
georeference.disable_editing_true_north()
def edit_true_north(ifc, georeference):
ifc.run("georeference.edit_true_north", true_north=georeference.get_true_north_attributes())
georeference.disable_editing_true_north()
@@ -179,6 +179,15 @@ class Georeference(blenderbim.core.tool.Georeference):
def disable_editing_wcs(cls):
bpy.context.scene.BIMGeoreferenceProperties.is_editing_wcs = False
@classmethod
def enable_editing_true_north(cls):
bpy.context.scene.BIMGeoreferenceProperties.is_editing_true_north = True
@classmethod
def disable_editing_true_north(cls):
bpy.context.scene.BIMGeoreferenceProperties.is_editing_true_north = False
@classmethod
def set_coordinates(cls, io, coordinates):
if io == "local":