mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +00:00
Minor code shuffling to reflect the fact that projected CRS has a higher priority than map conversion
This commit is contained in:
@@ -17,27 +17,6 @@ class EnableEditingGeoreferencing(bpy.types.Operator):
|
|||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
|
|
||||||
while len(props.map_conversion) > 0:
|
|
||||||
props.map_conversion.remove(0)
|
|
||||||
|
|
||||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcMapConversion").all_attributes():
|
|
||||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
|
||||||
if data_type == "entity":
|
|
||||||
continue
|
|
||||||
new = props.map_conversion.add()
|
|
||||||
new.name = attribute.name()
|
|
||||||
new.is_null = Data.map_conversion[attribute.name()] is None
|
|
||||||
new.is_optional = attribute.optional()
|
|
||||||
new.data_type = data_type
|
|
||||||
if data_type == "string":
|
|
||||||
new.string_value = "" if new.is_null else Data.map_conversion[attribute.name()]
|
|
||||||
elif data_type == "float":
|
|
||||||
new.float_value = 0.0 if new.is_null else Data.map_conversion[attribute.name()]
|
|
||||||
elif data_type == "integer":
|
|
||||||
new.int_value = 0 if new.is_null else Data.map_conversion[attribute.name()]
|
|
||||||
elif data_type == "boolean":
|
|
||||||
new.bool_value = False if new.is_null else Data.map_conversion[attribute.name()]
|
|
||||||
|
|
||||||
while len(props.projected_crs) > 0:
|
while len(props.projected_crs) > 0:
|
||||||
props.projected_crs.remove(0)
|
props.projected_crs.remove(0)
|
||||||
|
|
||||||
@@ -69,6 +48,27 @@ class EnableEditingGeoreferencing(bpy.types.Operator):
|
|||||||
elif props.map_unit_type == "IfcConversionBasedUnit":
|
elif props.map_unit_type == "IfcConversionBasedUnit":
|
||||||
props.map_unit_imperial = Data.projected_crs["MapUnit"]["Name"]
|
props.map_unit_imperial = Data.projected_crs["MapUnit"]["Name"]
|
||||||
|
|
||||||
|
while len(props.map_conversion) > 0:
|
||||||
|
props.map_conversion.remove(0)
|
||||||
|
|
||||||
|
for attribute in IfcStore.get_schema().declaration_by_name("IfcMapConversion").all_attributes():
|
||||||
|
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||||
|
if data_type == "entity":
|
||||||
|
continue
|
||||||
|
new = props.map_conversion.add()
|
||||||
|
new.name = attribute.name()
|
||||||
|
new.is_null = Data.map_conversion[attribute.name()] is None
|
||||||
|
new.is_optional = attribute.optional()
|
||||||
|
new.data_type = data_type
|
||||||
|
if data_type == "string":
|
||||||
|
new.string_value = "" if new.is_null else Data.map_conversion[attribute.name()]
|
||||||
|
elif data_type == "float":
|
||||||
|
new.float_value = 0.0 if new.is_null else Data.map_conversion[attribute.name()]
|
||||||
|
elif data_type == "integer":
|
||||||
|
new.int_value = 0 if new.is_null else Data.map_conversion[attribute.name()]
|
||||||
|
elif data_type == "boolean":
|
||||||
|
new.bool_value = False if new.is_null else Data.map_conversion[attribute.name()]
|
||||||
|
|
||||||
props.is_editing = True
|
props.is_editing = True
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@@ -91,23 +91,6 @@ class EditGeoreferencing(bpy.types.Operator):
|
|||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
|
|
||||||
map_conversion = {}
|
|
||||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcMapConversion").all_attributes():
|
|
||||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
|
||||||
if data_type == "entity":
|
|
||||||
continue
|
|
||||||
blender_attribute = props.map_conversion.get(attribute.name())
|
|
||||||
if blender_attribute.is_null:
|
|
||||||
map_conversion[attribute.name()] = None
|
|
||||||
elif blender_attribute.data_type == "string":
|
|
||||||
map_conversion[attribute.name()] = blender_attribute.string_value
|
|
||||||
elif blender_attribute.data_type == "float":
|
|
||||||
map_conversion[attribute.name()] = blender_attribute.float_value
|
|
||||||
elif blender_attribute.data_type == "integer":
|
|
||||||
map_conversion[attribute.name()] = blender_attribute.int_value
|
|
||||||
elif blender_attribute.data_type == "boolean":
|
|
||||||
map_conversion[attribute.name()] = blender_attribute.bool_value
|
|
||||||
|
|
||||||
projected_crs = {}
|
projected_crs = {}
|
||||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcProjectedCRS").all_attributes():
|
for attribute in IfcStore.get_schema().declaration_by_name("IfcProjectedCRS").all_attributes():
|
||||||
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||||
@@ -129,6 +112,23 @@ class EditGeoreferencing(bpy.types.Operator):
|
|||||||
if not props.is_map_unit_null:
|
if not props.is_map_unit_null:
|
||||||
map_unit = props.map_unit_si if props.map_unit_type == "IfcSIUnit" else props.map_unit_imperial
|
map_unit = props.map_unit_si if props.map_unit_type == "IfcSIUnit" else props.map_unit_imperial
|
||||||
|
|
||||||
|
map_conversion = {}
|
||||||
|
for attribute in IfcStore.get_schema().declaration_by_name("IfcMapConversion").all_attributes():
|
||||||
|
data_type = ifcopenshell.util.attribute.get_primitive_type(attribute)
|
||||||
|
if data_type == "entity":
|
||||||
|
continue
|
||||||
|
blender_attribute = props.map_conversion.get(attribute.name())
|
||||||
|
if blender_attribute.is_null:
|
||||||
|
map_conversion[attribute.name()] = None
|
||||||
|
elif blender_attribute.data_type == "string":
|
||||||
|
map_conversion[attribute.name()] = blender_attribute.string_value
|
||||||
|
elif blender_attribute.data_type == "float":
|
||||||
|
map_conversion[attribute.name()] = blender_attribute.float_value
|
||||||
|
elif blender_attribute.data_type == "integer":
|
||||||
|
map_conversion[attribute.name()] = blender_attribute.int_value
|
||||||
|
elif blender_attribute.data_type == "boolean":
|
||||||
|
map_conversion[attribute.name()] = blender_attribute.bool_value
|
||||||
|
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"georeference.edit_georeferencing",
|
"georeference.edit_georeferencing",
|
||||||
self.file,
|
self.file,
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ class BIM_PT_gis(Panel):
|
|||||||
return IfcStore.get_file()
|
return IfcStore.get_file()
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
self.layout.use_property_split = True
|
||||||
|
self.layout.use_property_decorate = False
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
if not Data.is_loaded:
|
if not Data.is_loaded:
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
@@ -26,30 +28,10 @@ class BIM_PT_gis(Panel):
|
|||||||
def draw_editable_ui(self, context):
|
def draw_editable_ui(self, context):
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="Map Conversion", icon="GRID")
|
row.label(text="Projected CRS", icon="WORLD")
|
||||||
row.operator("bim.edit_georeferencing", icon="CHECKMARK", text="")
|
row.operator("bim.edit_georeferencing", icon="CHECKMARK", text="")
|
||||||
row.operator("bim.disable_editing_georeferencing", icon="X", text="")
|
row.operator("bim.disable_editing_georeferencing", icon="X", text="")
|
||||||
|
|
||||||
for attribute in props.map_conversion:
|
|
||||||
if attribute.name == "XAxisAbscissa" and hasattr(context.scene, "sun_pos_properties"):
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.operator("bim.get_north_offset", text="Set IFC North")
|
|
||||||
row.operator("bim.set_north_offset", text="Set Blender North")
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
if attribute.data_type == "string":
|
|
||||||
row.prop(attribute, "string_value", text=attribute.name)
|
|
||||||
elif attribute.data_type == "integer":
|
|
||||||
row.prop(attribute, "int_value", text=attribute.name)
|
|
||||||
elif attribute.data_type == "float":
|
|
||||||
row.prop(attribute, "float_value", text=attribute.name)
|
|
||||||
elif attribute.data_type == "boolean":
|
|
||||||
row.prop(attribute, "bool_value", text=attribute.name)
|
|
||||||
if attribute.is_optional:
|
|
||||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text="Projected CRS", icon="WORLD")
|
|
||||||
|
|
||||||
for attribute in props.projected_crs:
|
for attribute in props.projected_crs:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if attribute.data_type == "string":
|
if attribute.data_type == "string":
|
||||||
@@ -70,10 +52,31 @@ class BIM_PT_gis(Panel):
|
|||||||
row.prop(props, "map_unit_imperial", text="")
|
row.prop(props, "map_unit_imperial", text="")
|
||||||
row.prop(props, "is_map_unit_null", icon="RADIOBUT_OFF" if props.is_map_unit_null else "RADIOBUT_ON", text="")
|
row.prop(props, "is_map_unit_null", icon="RADIOBUT_OFF" if props.is_map_unit_null else "RADIOBUT_ON", text="")
|
||||||
|
|
||||||
|
row = self.layout.row()
|
||||||
|
row.label(text="Map Conversion", icon="GRID")
|
||||||
|
|
||||||
|
for attribute in props.map_conversion:
|
||||||
|
if attribute.name == "Scale" and hasattr(context.scene, "sun_pos_properties"):
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.operator("bim.get_north_offset", text="Set IFC North")
|
||||||
|
row.operator("bim.set_north_offset", text="Set Blender North")
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
if attribute.data_type == "string":
|
||||||
|
row.prop(attribute, "string_value", text=attribute.name)
|
||||||
|
elif attribute.data_type == "integer":
|
||||||
|
row.prop(attribute, "int_value", text=attribute.name)
|
||||||
|
elif attribute.data_type == "float":
|
||||||
|
row.prop(attribute, "float_value", text=attribute.name)
|
||||||
|
elif attribute.data_type == "boolean":
|
||||||
|
row.prop(attribute, "bool_value", text=attribute.name)
|
||||||
|
if attribute.is_optional:
|
||||||
|
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||||
|
|
||||||
|
|
||||||
def draw_ui(self, context):
|
def draw_ui(self, context):
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
|
|
||||||
if not Data.map_conversion and IfcStore.get_file().schema != "IFC2X3":
|
if not Data.projected_crs and IfcStore.get_file().schema != "IFC2X3":
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="Not Georeferenced")
|
row.label(text="Not Georeferenced")
|
||||||
row.operator("bim.add_georeferencing", icon="ADD", text="")
|
row.operator("bim.add_georeferencing", icon="ADD", text="")
|
||||||
@@ -104,11 +107,30 @@ class BIM_PT_gis(Panel):
|
|||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.label(text="Not Georeferenced")
|
row.label(text="Not Georeferenced")
|
||||||
|
|
||||||
|
if Data.projected_crs:
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.label(text="Projected CRS", icon="WORLD")
|
||||||
|
row.operator("bim.enable_editing_georeferencing", icon="GREASEPENCIL", text="")
|
||||||
|
row.operator("bim.remove_georeferencing", icon="X", text="")
|
||||||
|
|
||||||
|
for key, value in Data.projected_crs.items():
|
||||||
|
if key == "id" or key == "type" or not value:
|
||||||
|
continue
|
||||||
|
if key == "MapUnit":
|
||||||
|
unit_value = value.get("Prefix", "") or ""
|
||||||
|
unit_value += value["Name"]
|
||||||
|
value = unit_value
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.label(text=key)
|
||||||
|
row.label(text=str(value))
|
||||||
|
|
||||||
|
if not Data.projected_crs["Name"]:
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.label(text="Undefined CRS")
|
||||||
|
|
||||||
if Data.map_conversion:
|
if Data.map_conversion:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="Map Conversion", icon="GRID")
|
row.label(text="Map Conversion", icon="GRID")
|
||||||
row.operator("bim.enable_editing_georeferencing", icon="GREASEPENCIL", text="")
|
|
||||||
row.operator("bim.remove_georeferencing", icon="X", text="")
|
|
||||||
|
|
||||||
for key, value in Data.map_conversion.items():
|
for key, value in Data.map_conversion.items():
|
||||||
if key == "id" or key == "type" or key == "SourceCRS" or key == "TargetCRS" or not value:
|
if key == "id" or key == "type" or key == "SourceCRS" or key == "TargetCRS" or not value:
|
||||||
@@ -116,21 +138,20 @@ class BIM_PT_gis(Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=key)
|
row.label(text=key)
|
||||||
row.label(text=str(value))
|
row.label(text=str(value))
|
||||||
|
if key == "XAxisOrdinate":
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.label(text="Derived Angle")
|
||||||
|
row.label(
|
||||||
|
text=str(
|
||||||
|
round(
|
||||||
|
ifcopenshell.util.geolocation.xaxis2angle(
|
||||||
|
Data.map_conversion["XAxisAbscissa"], Data.map_conversion["XAxisOrdinate"]
|
||||||
|
),
|
||||||
|
3,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if Data.projected_crs:
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text="Projected CRS", icon="WORLD")
|
|
||||||
|
|
||||||
for key, value in Data.projected_crs.items():
|
|
||||||
if key == "id" or key == "type" or not value:
|
|
||||||
continue
|
|
||||||
if key == "MapUnit":
|
|
||||||
unit_value = value.get("Prefix", "") or ""
|
|
||||||
unit_value += value["Name"]
|
|
||||||
value = unit_value
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text=key)
|
|
||||||
row.label(text=str(value))
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_gis_utilities(Panel):
|
class BIM_PT_gis_utilities(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user