mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 10:28:37 +00:00
Simplify UI for context management
This commit is contained in:
@@ -59,12 +59,9 @@ classes = (
|
|||||||
operator.FetchLibraryInformation,
|
operator.FetchLibraryInformation,
|
||||||
operator.FetchExternalMaterial,
|
operator.FetchExternalMaterial,
|
||||||
operator.FetchObjectPassport,
|
operator.FetchObjectPassport,
|
||||||
operator.AddContext,
|
|
||||||
operator.RemoveContext,
|
|
||||||
operator.AddSubcontext,
|
operator.AddSubcontext,
|
||||||
operator.RemoveSubcontext,
|
operator.RemoveSubcontext,
|
||||||
prop.Subcontext,
|
prop.Subcontext,
|
||||||
prop.Context,
|
|
||||||
prop.BIMProperties,
|
prop.BIMProperties,
|
||||||
prop.BIMLibrary,
|
prop.BIMLibrary,
|
||||||
prop.MapConversion,
|
prop.MapConversion,
|
||||||
|
|||||||
@@ -715,33 +715,14 @@ class FetchObjectPassport(bpy.types.Operator):
|
|||||||
bpy.context.active_object.data = bpy.data.meshes[identification]
|
bpy.context.active_object.data = bpy.data.meshes[identification]
|
||||||
|
|
||||||
|
|
||||||
class AddContext(bpy.types.Operator):
|
|
||||||
bl_idname = 'bim.add_context'
|
|
||||||
bl_label = 'Add Context'
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
context = bpy.context.scene.BIMProperties.contexts.add()
|
|
||||||
context.name = bpy.context.scene.BIMProperties.available_contexts
|
|
||||||
return {'FINISHED'}
|
|
||||||
|
|
||||||
|
|
||||||
class RemoveContext(bpy.types.Operator):
|
|
||||||
bl_idname = 'bim.remove_context'
|
|
||||||
bl_label = 'Remove Context'
|
|
||||||
index: bpy.props.IntProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
bpy.context.scene.BIMProperties.contexts.remove(self.index)
|
|
||||||
return {'FINISHED'}
|
|
||||||
|
|
||||||
|
|
||||||
class AddSubcontext(bpy.types.Operator):
|
class AddSubcontext(bpy.types.Operator):
|
||||||
bl_idname = 'bim.add_subcontext'
|
bl_idname = 'bim.add_subcontext'
|
||||||
bl_label = 'Add Subcontext'
|
bl_label = 'Add Subcontext'
|
||||||
context_index: bpy.props.IntProperty()
|
context: bpy.props.StringProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
subcontext = bpy.context.scene.BIMProperties.contexts[self.context_index].subcontexts.add()
|
props = bpy.context.scene.BIMProperties
|
||||||
|
subcontext = getattr(bpy.context.scene.BIMProperties, '{}_subcontexts'.format(self.context)).add()
|
||||||
subcontext.name = bpy.context.scene.BIMProperties.available_subcontexts
|
subcontext.name = bpy.context.scene.BIMProperties.available_subcontexts
|
||||||
subcontext.target_view = bpy.context.scene.BIMProperties.available_target_views
|
subcontext.target_view = bpy.context.scene.BIMProperties.available_target_views
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
@@ -753,8 +734,7 @@ class RemoveSubcontext(bpy.types.Operator):
|
|||||||
indexes: bpy.props.StringProperty()
|
indexes: bpy.props.StringProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
context_index, subcontext_index = self.indexes.split('-')
|
context, subcontext_index = self.indexes.split('-')
|
||||||
context_index = int(context_index)
|
|
||||||
subcontext_index = int(subcontext_index)
|
subcontext_index = int(subcontext_index)
|
||||||
bpy.context.scene.BIMProperties.contexts[context_index].subcontexts.remove(subcontext_index)
|
getattr(bpy.context.scene.BIMProperties, '{}_subcontexts'.format(context)).remove(subcontext_index)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -137,14 +137,6 @@ def getApplicableDocuments(self, context):
|
|||||||
return documents_enum
|
return documents_enum
|
||||||
|
|
||||||
|
|
||||||
def getContexts(self, context):
|
|
||||||
global contexts_enum
|
|
||||||
contexts_enum.clear()
|
|
||||||
for context in export_ifc.IfcExportSettings().contexts:
|
|
||||||
contexts_enum.append((context, context, ''))
|
|
||||||
return contexts_enum
|
|
||||||
|
|
||||||
|
|
||||||
def getSubcontexts(self, context):
|
def getSubcontexts(self, context):
|
||||||
global subcontexts_enum
|
global subcontexts_enum
|
||||||
subcontexts_enum.clear()
|
subcontexts_enum.clear()
|
||||||
@@ -168,12 +160,6 @@ class Subcontext(PropertyGroup):
|
|||||||
target_view: StringProperty(name='Target View')
|
target_view: StringProperty(name='Target View')
|
||||||
|
|
||||||
|
|
||||||
class Context(PropertyGroup):
|
|
||||||
name: StringProperty(name='Name')
|
|
||||||
foobar: StringProperty(name='foobar')
|
|
||||||
subcontexts: CollectionProperty(name='Subcontexts', type=Subcontext)
|
|
||||||
|
|
||||||
|
|
||||||
class BIMProperties(PropertyGroup):
|
class BIMProperties(PropertyGroup):
|
||||||
schema_dir: StringProperty(default=os.path.join(cwd ,'schema') + os.path.sep, name="Schema Directory")
|
schema_dir: StringProperty(default=os.path.join(cwd ,'schema') + os.path.sep, name="Schema Directory")
|
||||||
data_dir: StringProperty(default=os.path.join(cwd, 'data') + os.path.sep, name="Data Directory")
|
data_dir: StringProperty(default=os.path.join(cwd, 'data') + os.path.sep, name="Data Directory")
|
||||||
@@ -200,8 +186,10 @@ class BIMProperties(PropertyGroup):
|
|||||||
aggregate_name: StringProperty(name="Aggregate Name")
|
aggregate_name: StringProperty(name="Aggregate Name")
|
||||||
classification: EnumProperty(items=getClassifications, name="Classification", update=refreshReferences)
|
classification: EnumProperty(items=getClassifications, name="Classification", update=refreshReferences)
|
||||||
reference: EnumProperty(items=getReferences, name="Reference")
|
reference: EnumProperty(items=getReferences, name="Reference")
|
||||||
contexts: CollectionProperty(name="Contexts", type=Context)
|
has_model_context: BoolProperty(name="Has Model Context", default=True)
|
||||||
available_contexts: EnumProperty(items=getContexts, name="Available Contexts")
|
has_plan_context: BoolProperty(name="Has Plan Context", default=False)
|
||||||
|
model_subcontexts: CollectionProperty(name='Model Subcontexts', type=Subcontext)
|
||||||
|
plan_subcontexts: CollectionProperty(name='Plan Subcontexts', type=Subcontext)
|
||||||
available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts")
|
available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts")
|
||||||
available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views")
|
available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views")
|
||||||
|
|
||||||
|
|||||||
@@ -195,27 +195,21 @@ class BIM_PT_context(Panel):
|
|||||||
scene = context.scene
|
scene = context.scene
|
||||||
props = scene.BIMProperties
|
props = scene.BIMProperties
|
||||||
|
|
||||||
row = layout.row(align=True)
|
for context in ['model', 'plan']:
|
||||||
row.prop(props, 'available_contexts', text='')
|
|
||||||
row.operator('bim.add_context', icon='ADD', text='')
|
|
||||||
|
|
||||||
for index, context in enumerate(props.contexts):
|
|
||||||
layout.label(text="Geometric Representation Context:")
|
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(context, 'name', text='')
|
row.prop(props, 'has_{}_context'.format(context))
|
||||||
row.operator('bim.remove_context', icon='X', text='').index = index
|
layout.label(text="Geometric Representation Subcontexts:")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, 'available_subcontexts', text='')
|
row.prop(props, 'available_subcontexts', text='')
|
||||||
row.prop(props, 'available_target_views', text='')
|
row.prop(props, 'available_target_views', text='')
|
||||||
row.operator('bim.add_subcontext', icon='ADD', text='').context_index = index
|
row.operator('bim.add_subcontext', icon='ADD', text='').context = context
|
||||||
|
|
||||||
for subcontext_index, subcontext in enumerate(context.subcontexts):
|
for subcontext_index, subcontext in enumerate(getattr(props, '{}_subcontexts'.format(context))):
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(subcontext, 'name', text='')
|
row.prop(subcontext, 'name', text='')
|
||||||
row.prop(subcontext, 'target_view', text='')
|
row.prop(subcontext, 'target_view', text='')
|
||||||
row.operator('bim.remove_subcontext', icon='X', text='').indexes = '{}-{}'.format(index, subcontext_index)
|
row.operator('bim.remove_subcontext', icon='X', text='').indexes = '{}-{}'.format(context, subcontext_index)
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_bim(Panel):
|
class BIM_PT_bim(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user