mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
bring back filter operators into new Filter subpanel and change filter by storey to filter by container
This commit is contained in:
@@ -20,7 +20,7 @@ import bpy
|
|||||||
from . import ui, prop, operator
|
from . import ui, prop, operator
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.ActivateIfcBuildingStoreyFilter,
|
operator.ActivateContainerFilter,
|
||||||
operator.ActivateIfcClassFilter,
|
operator.ActivateIfcClassFilter,
|
||||||
operator.AddFilter,
|
operator.AddFilter,
|
||||||
operator.AddFilterGroup,
|
operator.AddFilterGroup,
|
||||||
@@ -58,6 +58,7 @@ classes = (
|
|||||||
prop.SearchQueryGroup,
|
prop.SearchQueryGroup,
|
||||||
prop.IfcSelectorProperties,
|
prop.IfcSelectorProperties,
|
||||||
ui.BIM_PT_search,
|
ui.BIM_PT_search,
|
||||||
|
ui.BIM_PT_filter,
|
||||||
ui.BIM_PT_colour_by_property,
|
ui.BIM_PT_colour_by_property,
|
||||||
ui.BIM_PT_select_similar,
|
ui.BIM_PT_select_similar,
|
||||||
ui.BIM_UL_colourscheme,
|
ui.BIM_UL_colourscheme,
|
||||||
|
|||||||
@@ -466,8 +466,8 @@ class ToggleFilterSelection(Operator):
|
|||||||
if props.filter_type == "CLASSES":
|
if props.filter_type == "CLASSES":
|
||||||
for ifc_class in props.filter_classes:
|
for ifc_class in props.filter_classes:
|
||||||
ifc_class.is_selected = self.selecting_actionbool
|
ifc_class.is_selected = self.selecting_actionbool
|
||||||
elif props.filter_type == "BUILDINGSTOREYS":
|
elif props.filter_type == "CONTAINER":
|
||||||
for building_storey in props.filter_building_storeys:
|
for building_storey in props.filter_container:
|
||||||
building_storey.is_selected = self.selecting_actionbool
|
building_storey.is_selected = self.selecting_actionbool
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@@ -525,11 +525,11 @@ class ActivateIfcClassFilter(Operator):
|
|||||||
row.operator("bim.toggle_filter_selection", text="Deselect All").action = "DESELECT"
|
row.operator("bim.toggle_filter_selection", text="Deselect All").action = "DESELECT"
|
||||||
|
|
||||||
|
|
||||||
class ActivateIfcBuildingStoreyFilter(Operator):
|
class ActivateContainerFilter(Operator):
|
||||||
"""Filter the current selection by Building Storey"""
|
"""Filter the current selection by Building Storey"""
|
||||||
|
|
||||||
bl_idname = "bim.activate_ifc_building_storey_filter"
|
bl_idname = "bim.activate_ifc_container_filter"
|
||||||
bl_label = "Filter by Building Storey"
|
bl_label = "Filter by Container"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
@@ -540,27 +540,29 @@ class ActivateIfcBuildingStoreyFilter(Operator):
|
|||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
props = bpy.context.scene.BIMSearchProperties
|
props = bpy.context.scene.BIMSearchProperties
|
||||||
props.filter_building_storeys.clear()
|
props.filter_container.clear()
|
||||||
|
|
||||||
ifc_building_storeys = {}
|
containers = {}
|
||||||
|
containers.setdefault("None", 0)
|
||||||
for obj in context.selected_objects:
|
for obj in context.selected_objects:
|
||||||
storey = tool.Misc.get_object_storey(obj)
|
container = tool.Spatial.get_container(tool.Ifc.get_entity(obj))
|
||||||
if not storey:
|
if not container:
|
||||||
|
containers["None"] += 1
|
||||||
continue
|
continue
|
||||||
ifc_building_storeys.setdefault(storey.Name, 0)
|
containers.setdefault(container.Name, 0)
|
||||||
ifc_building_storeys[storey.Name] += 1
|
containers[container.Name] += 1
|
||||||
|
|
||||||
for name, total in dict(sorted(ifc_building_storeys.items())).items():
|
for name, total in dict(sorted(containers.items())).items():
|
||||||
new = props.filter_building_storeys.add()
|
new = props.filter_container.add()
|
||||||
new.name = name
|
new.name = name
|
||||||
new.total = total
|
new.total = total
|
||||||
|
|
||||||
props.filter_type = "BUILDINGSTOREYS"
|
props.filter_type = "CONTAINER"
|
||||||
|
|
||||||
return context.window_manager.invoke_props_dialog(self, width=250)
|
return context.window_manager.invoke_props_dialog(self, width=250)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
bpy.context.scene.BIMSearchProperties.filter_building_storeys.clear()
|
bpy.context.scene.BIMSearchProperties.filter_container.clear()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
@@ -568,12 +570,12 @@ class ActivateIfcBuildingStoreyFilter(Operator):
|
|||||||
"BIM_UL_ifc_building_storey_filter",
|
"BIM_UL_ifc_building_storey_filter",
|
||||||
"",
|
"",
|
||||||
context.scene.BIMSearchProperties,
|
context.scene.BIMSearchProperties,
|
||||||
"filter_building_storeys",
|
"filter_container",
|
||||||
context.scene.BIMSearchProperties,
|
context.scene.BIMSearchProperties,
|
||||||
"filter_building_storeys_index",
|
"filter_container_index",
|
||||||
rows=20
|
rows=20
|
||||||
if len(bpy.context.scene.BIMSearchProperties.filter_building_storeys) > 20
|
if len(bpy.context.scene.BIMSearchProperties.filter_container) > 20
|
||||||
else len(bpy.context.scene.BIMSearchProperties.filter_building_storeys),
|
else len(bpy.context.scene.BIMSearchProperties.filter_container),
|
||||||
)
|
)
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.toggle_filter_selection", text="Select All").action = "SELECT"
|
row.operator("bim.toggle_filter_selection", text="Select All").action = "SELECT"
|
||||||
|
|||||||
@@ -70,15 +70,15 @@ def update_is_class_selected(self, context):
|
|||||||
new.obj = obj
|
new.obj = obj
|
||||||
|
|
||||||
|
|
||||||
def update_is_level_selected(self, context):
|
def update_is_container_selected(self, context):
|
||||||
if self.is_selected:
|
if self.is_selected:
|
||||||
for obj in self.unselected_objects:
|
for obj in self.unselected_objects:
|
||||||
obj.obj.select_set(True)
|
obj.obj.select_set(True)
|
||||||
self.unselected_objects.clear()
|
self.unselected_objects.clear()
|
||||||
else:
|
else:
|
||||||
for obj in context.selected_objects:
|
for obj in context.selected_objects:
|
||||||
level = tool.Misc.get_object_storey(obj)
|
container = tool.Spatial.get_container(tool.Ifc.get_entity(obj))
|
||||||
if level and level.Name == self.name:
|
if (container and container.Name == self.name) or (not container and self.name== "None"):
|
||||||
obj.select_set(False)
|
obj.select_set(False)
|
||||||
new = self.unselected_objects.add()
|
new = self.unselected_objects.add()
|
||||||
new.obj = obj
|
new.obj = obj
|
||||||
@@ -93,7 +93,7 @@ class BIMFilterClasses(PropertyGroup):
|
|||||||
|
|
||||||
class BIMFilterBuildingStoreys(PropertyGroup):
|
class BIMFilterBuildingStoreys(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
is_selected: BoolProperty(name="Is Level Selected", default=True, update=update_is_level_selected)
|
is_selected: BoolProperty(name="Is Level Selected", default=True, update=update_is_container_selected)
|
||||||
total: IntProperty(name="Total")
|
total: IntProperty(name="Total")
|
||||||
unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects")
|
unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects")
|
||||||
|
|
||||||
@@ -140,8 +140,8 @@ class BIMSearchProperties(PropertyGroup):
|
|||||||
filter_type: StringProperty(name="Filter Type")
|
filter_type: StringProperty(name="Filter Type")
|
||||||
filter_classes: CollectionProperty(type=BIMFilterClasses, name="Filter Classes")
|
filter_classes: CollectionProperty(type=BIMFilterClasses, name="Filter Classes")
|
||||||
filter_classes_index: IntProperty(name="Filter Classes Index")
|
filter_classes_index: IntProperty(name="Filter Classes Index")
|
||||||
filter_building_storeys: CollectionProperty(type=BIMFilterBuildingStoreys, name="Filter Level")
|
filter_container: CollectionProperty(type=BIMFilterBuildingStoreys, name="Filter Level")
|
||||||
filter_building_storeys_index: IntProperty(name="Filter Level Index")
|
filter_container_index: IntProperty(name="Filter Level Index")
|
||||||
|
|
||||||
|
|
||||||
def get_classes(self, ifc_product):
|
def get_classes(self, ifc_product):
|
||||||
|
|||||||
@@ -42,11 +42,21 @@ class BIM_PT_search(Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.search", text="Search", icon="VIEWZOOM")
|
row.operator("bim.search", text="Search", icon="VIEWZOOM")
|
||||||
|
|
||||||
return # Temporary for now whilst searching is being upgraded.
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_filter(Panel):
|
||||||
|
bl_label = "Filter Selection"
|
||||||
|
bl_idname = "BIM_PT_filter"
|
||||||
|
bl_space_type = "PROPERTIES"
|
||||||
|
bl_region_type = "WINDOW"
|
||||||
|
bl_context = "scene"
|
||||||
|
bl_parent_id = "BIM_PT_tab_grouping_and_filtering"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.activate_ifc_class_filter", icon="FILTER")
|
row.operator("bim.activate_ifc_class_filter", icon="FILTER")
|
||||||
row.operator("bim.activate_ifc_building_storey_filter", icon="FILTER")
|
row.operator("bim.activate_ifc_container_filter", icon="FILTER")
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_colour_by_property(Panel):
|
class BIM_PT_colour_by_property(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user