mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 07:49:59 +00:00
Support editing IfcSurfaceStyleLighting in UI
This commit is contained in:
@@ -43,6 +43,7 @@ classes = (
|
|||||||
operator.UpdateCurrentStyle,
|
operator.UpdateCurrentStyle,
|
||||||
operator.UpdateStyleColours,
|
operator.UpdateStyleColours,
|
||||||
operator.UpdateStyleTextures,
|
operator.UpdateStyleTextures,
|
||||||
|
prop.ColourRgb,
|
||||||
prop.Style,
|
prop.Style,
|
||||||
prop.Texture,
|
prop.Texture,
|
||||||
prop.BIMStylesProperties,
|
prop.BIMStylesProperties,
|
||||||
|
|||||||
@@ -506,9 +506,23 @@ class EnableEditingSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
surface_style = tool.Style.get_style_elements(style).get(self.ifc_class, None)
|
surface_style = tool.Style.get_style_elements(style).get(self.ifc_class, None)
|
||||||
attributes = tool.Style.get_style_ui_props_attributes(self.ifc_class)
|
attributes = tool.Style.get_style_ui_props_attributes(self.ifc_class)
|
||||||
|
|
||||||
|
# lighting style require special handling since Attribute doesn't support colors
|
||||||
|
callback = None
|
||||||
|
if self.ifc_class == "IfcSurfaceStyleLighting":
|
||||||
|
|
||||||
|
def callback(attribute_name, _, data):
|
||||||
|
color = attributes.add()
|
||||||
|
color.name = attribute_name
|
||||||
|
color_value = data[attribute_name]
|
||||||
|
if color_value is None:
|
||||||
|
return
|
||||||
|
color.color_name = color_value.Name or ""
|
||||||
|
color.color_value = (color_value.Red, color_value.Green, color_value.Blue)
|
||||||
|
|
||||||
if attributes is not None:
|
if attributes is not None:
|
||||||
attributes.clear()
|
attributes.clear()
|
||||||
blenderbim.bim.helper.import_attributes2(surface_style or self.ifc_class, attributes)
|
blenderbim.bim.helper.import_attributes2(surface_style or self.ifc_class, attributes, callback)
|
||||||
|
|
||||||
|
|
||||||
class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
@@ -576,13 +590,12 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
||||||
else:
|
else:
|
||||||
attributes = tool.Style.get_style_ui_props_attributes(self.surface_style.is_a())
|
attributes = tool.Style.get_style_ui_props_attributes(self.surface_style.is_a())
|
||||||
if attributes is not None:
|
ifcopenshell.api.run(
|
||||||
ifcopenshell.api.run(
|
"style.edit_surface_style",
|
||||||
"style.edit_surface_style",
|
tool.Ifc.get(),
|
||||||
tool.Ifc.get(),
|
style=self.surface_style,
|
||||||
style=self.surface_style,
|
attributes=blenderbim.bim.helper.export_attributes(attributes),
|
||||||
attributes=blenderbim.bim.helper.export_attributes(attributes),
|
)
|
||||||
)
|
|
||||||
|
|
||||||
def add_new_style(self):
|
def add_new_style(self):
|
||||||
material = tool.Ifc.get_object(self.style)
|
material = tool.Ifc.get_object(self.style)
|
||||||
@@ -627,14 +640,13 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style)
|
||||||
else:
|
else:
|
||||||
attributes = tool.Style.get_style_ui_props_attributes(self.props.is_editing_class)
|
attributes = tool.Style.get_style_ui_props_attributes(self.props.is_editing_class)
|
||||||
if attributes is not None:
|
surface_style = ifcopenshell.api.run(
|
||||||
surface_style = ifcopenshell.api.run(
|
"style.add_surface_style",
|
||||||
"style.add_surface_style",
|
tool.Ifc.get(),
|
||||||
tool.Ifc.get(),
|
style=self.style,
|
||||||
style=self.style,
|
ifc_class=self.props.is_editing_class,
|
||||||
ifc_class=self.props.is_editing_class,
|
attributes=blenderbim.bim.helper.export_attributes(attributes),
|
||||||
attributes=blenderbim.bim.helper.export_attributes(attributes),
|
)
|
||||||
)
|
|
||||||
|
|
||||||
def get_shading_attributes(self):
|
def get_shading_attributes(self):
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -112,6 +112,29 @@ class Texture(PropertyGroup):
|
|||||||
path: StringProperty(name="Texture Path", update=update_shader_graph)
|
path: StringProperty(name="Texture Path", update=update_shader_graph)
|
||||||
|
|
||||||
|
|
||||||
|
class ColourRgb(PropertyGroup):
|
||||||
|
name: StringProperty()
|
||||||
|
color_value: FloatVectorProperty(size=3, subtype="COLOR", default=(1, 1, 1))
|
||||||
|
# not exposed in the UI, here just to preserve the data
|
||||||
|
color_name: StringProperty("Color Name")
|
||||||
|
|
||||||
|
# to fit blender.bim.helper.export_attributes
|
||||||
|
def get_value(self):
|
||||||
|
return {
|
||||||
|
"Name": self.color_name or None,
|
||||||
|
"Red": self.color_value[0],
|
||||||
|
"Green": self.color_value[1],
|
||||||
|
"Blue": self.color_value[2],
|
||||||
|
}
|
||||||
|
|
||||||
|
# to fit blender.bim.helper.draw_attribute
|
||||||
|
is_uri = False
|
||||||
|
is_optional = False
|
||||||
|
|
||||||
|
def get_value_name(self):
|
||||||
|
return "color_value"
|
||||||
|
|
||||||
|
|
||||||
class BIMStylesProperties(PropertyGroup):
|
class BIMStylesProperties(PropertyGroup):
|
||||||
is_adding: BoolProperty(name="Is Adding")
|
is_adding: BoolProperty(name="Is Adding")
|
||||||
is_editing: BoolProperty(name="Is Editing")
|
is_editing: BoolProperty(name="Is Editing")
|
||||||
@@ -120,6 +143,7 @@ class BIMStylesProperties(PropertyGroup):
|
|||||||
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
||||||
external_style_attributes: CollectionProperty(name="External Style Attributes", type=Attribute)
|
external_style_attributes: CollectionProperty(name="External Style Attributes", type=Attribute)
|
||||||
refraction_style_attributes: CollectionProperty(name="Refraction Style Attributes", type=Attribute)
|
refraction_style_attributes: CollectionProperty(name="Refraction Style Attributes", type=Attribute)
|
||||||
|
lighting_style_colours: CollectionProperty(name="Lighting Style Colours", type=ColourRgb)
|
||||||
style_type: EnumProperty(items=get_style_types, default=2, name="Style Type")
|
style_type: EnumProperty(items=get_style_types, default=2, name="Style Type")
|
||||||
style_name: StringProperty(name="Style Name")
|
style_name: StringProperty(name="Style Name")
|
||||||
surface_style_class: EnumProperty(
|
surface_style_class: EnumProperty(
|
||||||
|
|||||||
@@ -136,9 +136,8 @@ class BIM_PT_styles(Panel):
|
|||||||
self.draw_surface_style_with_textures()
|
self.draw_surface_style_with_textures()
|
||||||
elif self.props.is_editing_class == "IfcSurfaceStyleRefraction":
|
elif self.props.is_editing_class == "IfcSurfaceStyleRefraction":
|
||||||
self.draw_refraction_surface_style()
|
self.draw_refraction_surface_style()
|
||||||
else:
|
else: # IfcSurfaceStyleLighting
|
||||||
# TODO: UI Lighting
|
self.draw_lighting_surface_style()
|
||||||
self.layout.label(text=f"{self.props.is_editing_class} UI is not yet supported.")
|
|
||||||
|
|
||||||
def draw_surface_style_shading(self):
|
def draw_surface_style_shading(self):
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
@@ -246,6 +245,12 @@ class BIM_PT_styles(Panel):
|
|||||||
row.operator("bim.edit_surface_style", text="Save Refraction Style", icon="CHECKMARK")
|
row.operator("bim.edit_surface_style", text="Save Refraction Style", icon="CHECKMARK")
|
||||||
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
|
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
|
||||||
|
|
||||||
|
def draw_lighting_surface_style(self):
|
||||||
|
blenderbim.bim.helper.draw_attributes(self.props.lighting_style_colours, self.layout)
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.operator("bim.edit_surface_style", text="Save Lighting Style", icon="CHECKMARK")
|
||||||
|
row.operator("bim.disable_editing_style", text="", icon="CANCEL")
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_style(MaterialButtonsPanel, Panel):
|
class BIM_PT_style(MaterialButtonsPanel, Panel):
|
||||||
bl_label = "Style"
|
bl_label = "Style"
|
||||||
|
|||||||
@@ -460,6 +460,8 @@ class Style(blenderbim.core.tool.Style):
|
|||||||
return props.external_style_attributes
|
return props.external_style_attributes
|
||||||
elif style_type == "IfcSurfaceStyleRefraction":
|
elif style_type == "IfcSurfaceStyleRefraction":
|
||||||
return props.refraction_style_attributes
|
return props.refraction_style_attributes
|
||||||
|
elif style_type == "IfcSurfaceStyleLighting":
|
||||||
|
return props.lighting_style_colours
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_presentation_styles(cls, style_type):
|
def import_presentation_styles(cls, style_type):
|
||||||
|
|||||||
Reference in New Issue
Block a user