diff --git a/src/blenderbim/blenderbim/bim/module/brick/operator.py b/src/blenderbim/blenderbim/bim/module/brick/operator.py index 6c01e98266..f95685e032 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/operator.py +++ b/src/blenderbim/blenderbim/bim/module/brick/operator.py @@ -57,9 +57,10 @@ class ViewBrickClass(bpy.types.Operator, Operator): bl_label = "View Brick Class" bl_options = {"REGISTER", "UNDO"} brick_class: bpy.props.StringProperty(name="Brick Class") + split_screen: bpy.props.BoolProperty(name="Split Screen", default=False, options={"HIDDEN"}) def _execute(self, context): - core.view_brick_class(tool.Brick, brick_class=self.brick_class) + core.view_brick_class(tool.Brick, brick_class=self.brick_class, split_screen=self.split_screen) class ViewBrickItem(bpy.types.Operator, Operator): @@ -67,18 +68,20 @@ class ViewBrickItem(bpy.types.Operator, Operator): bl_label = "View Brick Item" bl_options = {"REGISTER", "UNDO"} item: bpy.props.StringProperty(name="Brick Item") + split_screen: bpy.props.BoolProperty(name="Split Screen", default=False, options={"HIDDEN"}) def _execute(self, context): - core.view_brick_item(tool.Brick, item=self.item) + core.view_brick_item(tool.Brick, item=self.item, split_screen=self.split_screen) class RewindBrickClass(bpy.types.Operator, Operator): bl_idname = "bim.rewind_brick_class" bl_label = "Rewind Brick Class" bl_options = {"REGISTER", "UNDO"} + split_screen: bpy.props.BoolProperty(name="Split Screen", default=False, options={"HIDDEN"}) def _execute(self, context): - core.rewind_brick_class(tool.Brick) + core.rewind_brick_class(tool.Brick, split_screen=self.split_screen) class CloseBrickProject(bpy.types.Operator, Operator): @@ -205,9 +208,10 @@ class RefreshBrickViewer(bpy.types.Operator, Operator): bl_idname = "bim.refresh_brick_viewer" bl_label = "Refresh Brick Viewer" bl_options = {"REGISTER", "UNDO"} + split_screen: bpy.props.BoolProperty(name="Split Screen", default=False, options={"HIDDEN"}) def _execute(self, context): - core.refresh_brick_viewer(tool.Brick) + core.refresh_brick_viewer(tool.Brick, split_screen=self.split_screen) class RemoveBrick(bpy.types.Operator, Operator): @@ -268,10 +272,14 @@ class SetBrickListRoot(bpy.types.Operator, Operator): bl_idname = "bim.set_brick_list_root" bl_label = "Set Brick View Type" bl_options = {"REGISTER", "UNDO"} + split_screen: bpy.props.BoolProperty(name="Split Screen", default=False, options={"HIDDEN"}) def _execute(self, context): - root = context.scene.BIMBrickProperties.brick_list_root - core.set_brick_list_root(tool.Brick, brick_root=root) + if self.split_screen: + root = context.scene.BIMBrickProperties.split_screen_brick_list_root + else: + root = context.scene.BIMBrickProperties.brick_list_root + core.set_brick_list_root(tool.Brick, brick_root=root, split_screen=self.split_screen) class RemoveBrickRelation(bpy.types.Operator, Operator): diff --git a/src/blenderbim/blenderbim/bim/module/brick/prop.py b/src/blenderbim/blenderbim/bim/module/brick/prop.py index 9246e5f560..2396b65a59 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/prop.py +++ b/src/blenderbim/blenderbim/bim/module/brick/prop.py @@ -97,4 +97,9 @@ class BIMBrickProperties(PropertyGroup): new_brick_relation_object: StringProperty(name="New Brick Relation Object") add_relation_failed: BoolProperty(name="Add Relation Failed", default=False) # create relations split screen - split_screen_toggled: BoolProperty(name="Split Screen Toggled", default=False) \ No newline at end of file + split_screen_toggled: BoolProperty(name="Split Screen Toggled", default=False) + split_screen_bricks: CollectionProperty(name="Split Screen Bricks", type=Brick) + split_screen_active_brick_index: IntProperty(name="Split Screen Active Brick Index", update=update_active_brick_index) + split_screen_active_brick_class: StringProperty(name="Split Screen Active Brick Class") + split_screen_brick_breadcrumbs: CollectionProperty(name="Split Screen Brick Breadcrumbs", type=StrProperty) + split_screen_brick_list_root: EnumProperty(name="Split Screen Brick List Root", items=get_brick_roots) \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/brick/ui.py b/src/blenderbim/blenderbim/bim/module/brick/ui.py index 6997b0f7ab..445f87e076 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/ui.py +++ b/src/blenderbim/blenderbim/bim/module/brick/ui.py @@ -86,27 +86,48 @@ class BIM_PT_brickschema(Panel): row.prop(data=self.props, property="new_brick_label", text="") prop_with_search(row, self.props, "brick_entity_class", text="") row.operator("bim.add_brick", text="", icon="ADD") - - row = self.layout.row(align=True) - col = row.column() - col.alignment = "LEFT" - if len(self.props.brick_breadcrumbs): - row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV") - col = row.column() - col.alignment = "RIGHT" - row.operator("bim.remove_brick", text="", icon="X") # row.operator("bim.refresh_brick_viewer", text="", icon="FILE_REFRESH") row = self.layout.row(align=True) - row.label(text=self.props.active_brick_class) + col = row.column() + col.alignment = "RIGHT" + row.prop(data=self.props, property="split_screen_toggled", text="", icon="WINDOW") + + grid = self.layout.grid_flow(even_columns=True) + grid1 = grid.column(align=True) + row = grid1.row(align=True) + if len(self.props.brick_breadcrumbs): + op = row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV") + op.split_screen = False row.prop(data=self.props, property="set_list_root_toggled", text="", icon="OUTLINER") + row.label(text=self.props.active_brick_class) if self.props.set_list_root_toggled: - row = self.layout.row(align=True) + row = grid1.row(align=True) row.operator("bim.set_brick_list_root", text="Set View") row.prop(data=self.props, property="brick_list_root", text="") - self.layout.template_list("BIM_UL_bricks", "", self.props, "bricks", self.props, "active_brick_index") + row = grid1.row() + BIM_UL_bricks.split_screen = False + row.template_list("BIM_UL_bricks", "", self.props, "bricks", self.props, "active_brick_index") + + if self.props.split_screen_toggled: + grid2 = grid.column(align=True) + row = grid2.row(align=True) + if len(self.props.split_screen_brick_breadcrumbs): + op = row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV") + op.split_screen = True + row.label(text=self.props.split_screen_active_brick_class) + + if self.props.set_list_root_toggled: + row = grid2.row(align=True) + op = row.operator("bim.set_brick_list_root", text="Set View") + op.split_screen = True + row.prop(data=self.props, property="split_screen_brick_list_root", text="") + + row = grid2.row() + BIM_UL_bricks.split_screen = True + row.template_list("BIM_UL_bricks", "", self.props, "split_screen_bricks", self.props, "split_screen_active_brick_index") if BrickschemaData.data["active_relations"]: row = self.layout.row(align=True) @@ -114,15 +135,11 @@ class BIM_PT_brickschema(Panel): col.alignment = "RIGHT" row.prop(data=self.props, property="brick_create_relations_toggled", text="", icon="PLUGIN") row.prop(data=self.props, property="brick_edit_relations_toggled", text="", icon="TOOL_SETTINGS") - + row.operator("bim.remove_brick", text="", icon="X") + if self.props.brick_create_relations_toggled: row = self.layout.row(align=True) - col = row.column() - col.alignment = "LEFT" row.label(text="Create Relation:") - col = row.column() - col.alignment = "RIGHT" - row.prop(data=self.props, property="split_screen_toggled", text="", icon="WINDOW") if not self.props.new_brick_relation_type == "http://www.w3.org/2000/01/rdf-schema#label": row = self.layout.row(align=True) @@ -203,12 +220,15 @@ class BIM_PT_ifc_brickschema_references(Panel): class BIM_UL_bricks(UIList): + split_screen = False + def draw_item(self, context, layout, data, item, icon, active_data, active_propname): if item: row = layout.row(align=True) + label = item.label if item.label else item.name if item.total_items: op = row.operator("bim.view_brick_class", text="", icon="DISCLOSURE_TRI_RIGHT", emboss=False) op.brick_class = item.name - row.label(text=item.label if item.label else item.name) - if item.total_items: - row.label(text=str(item.total_items)) + op.split_screen = self.split_screen + label = label + " (" + str(item.total_items) + ")" + row.label(text=label) diff --git a/src/blenderbim/blenderbim/core/brick.py b/src/blenderbim/blenderbim/core/brick.py index 3866fa593d..dace67569d 100644 --- a/src/blenderbim/blenderbim/core/brick.py +++ b/src/blenderbim/blenderbim/core/brick.py @@ -20,34 +20,37 @@ def load_brick_project(brick, filepath=None, brick_root=None): brick.load_brick_file(filepath) brick.import_brick_classes(brick_root) + brick.import_brick_classes(brick_root, split_screen=True) brick.set_active_brick_class(brick_root) + brick.set_active_brick_class(brick_root, split_screen=True) -def view_brick_class(brick, brick_class=None): - brick.add_brick_breadcrumb() - brick.clear_brick_browser() - brick.import_brick_classes(brick_class) - brick.import_brick_items(brick_class) - brick.set_active_brick_class(brick_class) +def view_brick_class(brick, brick_class=None, split_screen=False): + brick.add_brick_breadcrumb(split_screen=split_screen) + brick.clear_brick_browser(split_screen=split_screen) + brick.import_brick_classes(brick_class, split_screen=split_screen) + brick.import_brick_items(brick_class, split_screen=split_screen) + brick.set_active_brick_class(brick_class, split_screen=split_screen) -def view_brick_item(brick, item=None): +def view_brick_item(brick, item=None, split_screen=False): brick_class = brick.get_item_class(item) - view_brick_class(brick, brick_class=brick_class) - brick.select_browser_item(item) + view_brick_class(brick, brick_class=brick_class, split_screen=split_screen) + brick.select_browser_item(item, split_screen=split_screen) -def rewind_brick_class(brick): - previous_class = brick.pop_brick_breadcrumb() - brick.clear_brick_browser() - brick.import_brick_classes(previous_class) - brick.import_brick_items(previous_class) - brick.set_active_brick_class(previous_class) +def rewind_brick_class(brick, split_screen=False): + previous_class = brick.pop_brick_breadcrumb(split_screen=split_screen) + brick.clear_brick_browser(split_screen=split_screen) + brick.import_brick_classes(previous_class, split_screen=split_screen) + brick.import_brick_items(previous_class, split_screen=split_screen) + brick.set_active_brick_class(previous_class, split_screen=split_screen) def close_brick_project(brick): brick.clear_project() brick.clear_brick_browser() + brick.clear_brick_browser(split_screen=True) def convert_brick_project(ifc, brick): @@ -76,11 +79,13 @@ def add_brick(ifc, brick, element=None, namespace=None, brick_class=None, librar else: brick_uri = brick.add_brick(namespace, brick_class, label) brick.run_refresh_brick_viewer() + brick.run_refresh_brick_viewer(split_screen=True) def add_brick_relation(brick, brick_uri=None, predicate=None, object=None): brick.add_relation(brick_uri, predicate, object) brick.run_refresh_brick_viewer() + brick.run_refresh_brick_viewer(split_screen=True) def convert_ifc_to_brick(brick, namespace=None, library=None): @@ -95,12 +100,17 @@ def convert_ifc_to_brick(brick, namespace=None, library=None): def new_brick_file(brick, brick_root=None): brick.new_brick_file() brick.import_brick_classes(brick_root) + brick.import_brick_classes(brick_root, split_screen=True) brick.set_active_brick_class(brick_root) + brick.set_active_brick_class(brick_root, split_screen=True) -def refresh_brick_viewer(brick): - brick.run_view_brick_class(brick_class=brick.get_active_brick_class()) - brick.pop_brick_breadcrumb() +def refresh_brick_viewer(brick, split_screen=False): + if split_screen: + brick.run_view_brick_class(brick_class=brick.get_active_brick_class(split_screen=split_screen), split_screen=split_screen) + else: + brick.run_view_brick_class(brick_class=brick.get_active_brick_class(), split_screen=split_screen) + brick.pop_brick_breadcrumb(split_screen=split_screen) def remove_brick(ifc, brick, library=None, brick_uri=None): @@ -110,6 +120,7 @@ def remove_brick(ifc, brick, library=None, brick_uri=None): ifc.run("library.remove_reference", reference=reference) brick.remove_brick(brick_uri) brick.run_refresh_brick_viewer() + brick.run_refresh_brick_viewer(split_screen=True) def serialize_brick(brick): @@ -120,11 +131,11 @@ def add_namespace(brick, alias=None, uri=None): brick.add_namespace(alias, uri) -def set_brick_list_root(brick, brick_root=None): - brick.clear_brick_browser() - brick.import_brick_classes(brick_root) - brick.set_active_brick_class(brick_root) - brick.clear_breadcrumbs() +def set_brick_list_root(brick, brick_root=None, split_screen=False): + brick.clear_brick_browser(split_screen=split_screen) + brick.import_brick_classes(brick_root, split_screen=split_screen) + brick.set_active_brick_class(brick_root, split_screen=split_screen) + brick.clear_breadcrumbs(split_screen=split_screen) def remove_brick_relation(brick, brick_uri=None, predicate=None, object=None): diff --git a/src/blenderbim/blenderbim/tool/brick.py b/src/blenderbim/blenderbim/tool/brick.py index 0f3eb90c9f..8f308d1590 100644 --- a/src/blenderbim/blenderbim/tool/brick.py +++ b/src/blenderbim/blenderbim/tool/brick.py @@ -53,9 +53,14 @@ class Brick(blenderbim.core.tool.Brick): return str(brick) @classmethod - def add_brick_breadcrumb(cls): - new = bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.add() - new.name = bpy.context.scene.BIMBrickProperties.active_brick_class + def add_brick_breadcrumb(cls, split_screen=False): + props = bpy.context.scene.BIMBrickProperties + if split_screen: + new = props.split_screen_brick_breadcrumbs.add() + new.name = props.split_screen_active_brick_class + else: + new = props.brick_breadcrumbs.add() + new.name = props.active_brick_class @classmethod def add_brick_from_element(cls, element, namespace, brick_class): @@ -126,14 +131,18 @@ class Brick(blenderbim.core.tool.Brick): cs.remove(triple) @classmethod - def clear_brick_browser(cls): - bpy.context.scene.BIMBrickProperties.bricks.clear() + def clear_brick_browser(cls, split_screen=False): + props = bpy.context.scene.BIMBrickProperties + if split_screen: + props.split_screen_bricks.clear() + else: + props.bricks.clear() @classmethod def clear_project(cls): BrickStore.purge() bpy.context.scene.BIMBrickProperties.active_brick_class == "" - bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear() + bpy.context.scene.BIMBrickProperties.split_screen_active_brick_class == "" @classmethod def export_brick_attributes(cls, brick_uri): @@ -143,7 +152,9 @@ class Brick(blenderbim.core.tool.Brick): return {"Identification": brick_uri, "Name": brick_uri.split("#")[-1]} @classmethod - def get_active_brick_class(cls): + def get_active_brick_class(cls, split_screen=False): + if split_screen: + return bpy.context.scene.BIMBrickProperties.split_screen_active_brick_class return bpy.context.scene.BIMBrickProperties.active_brick_class @classmethod @@ -224,7 +235,7 @@ class Brick(blenderbim.core.tool.Brick): return uri.split("#")[0] + "#" @classmethod - def import_brick_classes(cls, brick_class): + def import_brick_classes(cls, brick_class, split_screen=False): query = BrickStore.graph.query( """ PREFIX brick: @@ -243,8 +254,12 @@ class Brick(blenderbim.core.tool.Brick): "{brick_class}", brick_class ) ) + if split_screen: + bricks = bpy.context.scene.BIMBrickProperties.split_screen_bricks + else: + bricks = bpy.context.scene.BIMBrickProperties.bricks for row in query: - new = bpy.context.scene.BIMBrickProperties.bricks.add() + new = bricks.add() label = row.get("label") if label: new.label = label.toPython() @@ -253,7 +268,7 @@ class Brick(blenderbim.core.tool.Brick): new.total_items = row.get("total_items").toPython() @classmethod - def import_brick_items(cls, brick_class): + def import_brick_items(cls, brick_class, split_screen=False): query = BrickStore.graph.query( """ PREFIX brick: @@ -270,8 +285,12 @@ class Brick(blenderbim.core.tool.Brick): "{brick_class}", brick_class ) ) + if split_screen: + bricks = bpy.context.scene.BIMBrickProperties.split_screen_bricks + else: + bricks = bpy.context.scene.BIMBrickProperties.bricks for row in query: - new = bpy.context.scene.BIMBrickProperties.bricks.add() + new = bricks.add() label = row.get("label") if label: new.label = label.toPython() @@ -307,11 +326,16 @@ class Brick(blenderbim.core.tool.Brick): BrickStore.load_relationships() @classmethod - def pop_brick_breadcrumb(cls): - crumb = bpy.context.scene.BIMBrickProperties.brick_breadcrumbs[-1] + def pop_brick_breadcrumb(cls, split_screen=False): + props = bpy.context.scene.BIMBrickProperties + if split_screen: + breadcrumbs = props.split_screen_brick_breadcrumbs + else: + breadcrumbs = props.brick_breadcrumbs + crumb = breadcrumbs[-1] name = crumb.name - last_index = len(bpy.context.scene.BIMBrickProperties.brick_breadcrumbs) - 1 - bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.remove(last_index) + last_index = len(breadcrumbs) - 1 + breadcrumbs.remove(last_index) return name @classmethod @@ -328,22 +352,29 @@ class Brick(blenderbim.core.tool.Brick): ) @classmethod - def run_refresh_brick_viewer(cls): - return blenderbim.core.brick.refresh_brick_viewer(tool.Brick) + def run_refresh_brick_viewer(cls, split_screen=False): + return blenderbim.core.brick.refresh_brick_viewer(tool.Brick, split_screen) @classmethod - def run_view_brick_class(cls, brick_class=None): - return blenderbim.core.brick.view_brick_class(tool.Brick, brick_class=brick_class) + def run_view_brick_class(cls, brick_class=None, split_screen=False): + return blenderbim.core.brick.view_brick_class(tool.Brick, brick_class=brick_class, split_screen=split_screen) @classmethod - def select_browser_item(cls, item): + def select_browser_item(cls, item, split_screen=False): name = item.split("#")[-1] props = bpy.context.scene.BIMBrickProperties - props.active_brick_index = props.bricks.find(name) + if split_screen: + props.split_screen_active_brick_index = props.split_screen_bricks.find(name) + else: + props.active_brick_index = props.bricks.find(name) @classmethod - def set_active_brick_class(cls, brick_class): - bpy.context.scene.BIMBrickProperties.active_brick_class = brick_class + def set_active_brick_class(cls, brick_class, split_screen=False): + props = bpy.context.scene.BIMBrickProperties + if split_screen: + props.split_screen_active_brick_class = brick_class + else: + props.active_brick_class = brick_class @classmethod def serialize_brick(cls): @@ -355,8 +386,11 @@ class Brick(blenderbim.core.tool.Brick): BrickStore.load_namespaces() @classmethod - def clear_breadcrumbs(cls): - bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear() + def clear_breadcrumbs(cls, split_screen=False): + if split_screen: + bpy.context.scene.BIMBrickProperties.split_screen_brick_breadcrumbs.clear() + else: + bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear() class BrickStore: schema = None # this is now a os path