From a47d1ac32aec364416994d3eda47ca8bd012eae4 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 12 Aug 2020 21:50:57 +1000 Subject: [PATCH] Add prototype drawing style UI --- .../blenderbim/bim/__init__.py | 5 +++ .../blenderbim/bim/operator.py | 38 +++++++++++++++++++ src/ifcblenderexport/blenderbim/bim/prop.py | 10 +++++ src/ifcblenderexport/blenderbim/bim/ui.py | 28 +++++++++++++- 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 2aef58685a..9498a110be 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -180,6 +180,10 @@ if bpy is not None: operator.CalculateObjectVolumes, operator.AddOpening, operator.SetOverrideColour, + operator.AddDrawingStyle, + operator.RemoveDrawingStyle, + operator.SaveDrawingStyle, + operator.ActivateDrawingStyle, prop.StrProperty, prop.Variable, prop.Role, @@ -196,6 +200,7 @@ if bpy is not None: prop.ClashSource, prop.ClashSet, prop.Constraint, + prop.DrawingStyle, prop.BcfTopic, prop.BcfTopicLabel, prop.BcfTopicFile, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 93dc554e4b..2e7ac1d43c 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -3456,3 +3456,41 @@ class SetOverrideColour(bpy.types.Operator): area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D') area.spaces[0].shading.color_type = 'OBJECT' return {'FINISHED'} + + +class AddDrawingStyle(bpy.types.Operator): + bl_idname = 'bim.add_drawing_style' + bl_label = 'Add Drawing Style' + + def execute(self, context): + new = bpy.context.scene.DocProperties.drawing_styles.add() + new.name = 'New Drawing Style' + return {'FINISHED'} + + +class RemoveDrawingStyle(bpy.types.Operator): + bl_idname = 'bim.remove_drawing_style' + bl_label = 'Remove Drawing Style' + index: bpy.props.IntProperty() + + def execute(self, context): + bpy.context.scene.DocProperties.drawing_styles.remove(self.index) + return {'FINISHED'} + + +class SaveDrawingStyle(bpy.types.Operator): + bl_idname = 'bim.save_drawing_style' + bl_label = 'Save Drawing Style' + + def execute(self, context): + # TODO + return {'FINISHED'} + + +class ActivateDrawingStyle(bpy.types.Operator): + bl_idname = 'bim.activate_drawing_style' + bl_label = 'Activate Drawing Style' + + def execute(self, context): + # TODO + return {'FINISHED'} diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 8368a1e414..7dcf280473 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -400,6 +400,14 @@ class Subcontext(PropertyGroup): target_view: StringProperty(name='Target View') +class DrawingStyle(PropertyGroup): + name: StringProperty(name='Name') + raster_style: StringProperty(name='Raster Style') + vector_style: StringProperty(name='Vector Style') + include_query: StringProperty(name='Include Query') + exclude_query: StringProperty(name='Exclude Query') + + class DocProperties(PropertyGroup): should_recut: BoolProperty(name="Should Recut", default=True) should_recut_selected: BoolProperty(name="Should Recut Selected Only", default=False) @@ -410,6 +418,7 @@ class DocProperties(PropertyGroup): sheet_name: StringProperty(name="Sheet Name", update=refreshSheets) available_sheets: EnumProperty(items=getSheets, name="Available Sheets") ifc_files: CollectionProperty(name='IFCs', type=StrProperty) + drawing_styles: CollectionProperty(name='Drawing Styles', type=DrawingStyle) class BIMCameraProperties(PropertyGroup): @@ -423,6 +432,7 @@ class BIMCameraProperties(PropertyGroup): ('CUSTOM', 'Custom', '') ], name='Cut Objects') cut_objects_custom: StringProperty(name='Custom Cut') + active_drawing_style_index: IntProperty(name='Active Drawing Style Index') class BIMTextProperties(PropertyGroup): diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index d2985695c9..8e41f6bfde 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -823,7 +823,7 @@ class BIM_PT_section_plane(Panel): row.operator('bim.remove_section_plane') class BIM_PT_camera(Panel): - bl_label = "Diagrams and Documentation" + bl_label = "Drawing Generation" bl_idname = "BIM_PT_camera" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' @@ -870,8 +870,32 @@ class BIM_PT_camera(Panel): row = layout.row() row.prop(props, 'diagram_scale') + layout.label(text="Drawing Styles:") + row = layout.row(align=True) - row.operator('bim.cut_section') + row.operator('bim.add_drawing_style') + + if dprops.drawing_styles: + layout.template_list('BIM_UL_generic', '', dprops, 'drawing_styles', props, 'active_drawing_style_index') + + if props.active_drawing_style_index < len(dprops.drawing_styles): + drawing_style = dprops.drawing_styles[props.active_drawing_style_index] + + row = layout.row(align=True) + row.prop(drawing_style, 'name') + row.operator('bim.remove_drawing_style', icon='X', text='').index = props.active_drawing_style_index + + row = layout.row(align=True) + row.prop(drawing_style, 'raster_style') + row = layout.row(align=True) + row.prop(drawing_style, 'vector_style') + row = layout.row(align=True) + row.prop(drawing_style, 'include_query') + row = layout.row(align=True) + row.prop(drawing_style, 'exclude_query') + + row = layout.row(align=True) + row.operator('bim.cut_section', text='Create Drawing') op = row.operator('bim.open_view', icon='URL', text='') op.view = context.active_object.name.split('/')[1]