From 926970b256189589bd5d68afaef86993655e5915 Mon Sep 17 00:00:00 2001 From: rileywong311 Date: Thu, 10 Aug 2023 13:32:45 -0700 Subject: [PATCH] Polish Brick UI and add "last saved" label --- .../blenderbim/bim/module/brick/ui.py | 32 +++++++++++-------- src/blenderbim/blenderbim/tool/brick.py | 11 +++++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/brick/ui.py b/src/blenderbim/blenderbim/bim/module/brick/ui.py index 20a46e8d45..a32ec17bf9 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/ui.py +++ b/src/blenderbim/blenderbim/bim/module/brick/ui.py @@ -42,9 +42,17 @@ class BIM_PT_brickschema(Panel): row.operator("bim.load_brick_project", text="Load Project") return + row = self.layout.row(align=True) if BrickStore.path: - row = self.layout.row(align=True) row.label(text=BrickStore.path, icon="FILEBROWSER") + else: + row.label(text="No file", icon="FILEBROWSER") + + row = self.layout.row(align=True) + if BrickStore.last_saved: + row.label(text=BrickStore.last_saved, icon="TIME") + else: + row.label(text="Not saved", icon="TIME") row = self.layout.row(align=True) op = row.operator("bim.serialize_brick", icon="EXPORT", text="Save") @@ -55,7 +63,7 @@ class BIM_PT_brickschema(Panel): row = self.layout.row(align=True) row.prop(data=self.props, property="brick_settings_toggled", text="", icon="PREFERENCES") - + if self.props.brick_settings_toggled: box = self.layout.box() row = box.row(align=True) @@ -86,43 +94,43 @@ 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.operator("bim.refresh_brick_viewer", text="", icon="FILE_REFRESH") row = self.layout.row(align=True) col = row.column() col.alignment = "RIGHT" row.prop(data=self.props, property="set_list_root_toggled", text="", icon="OUTLINER") row.prop(data=self.props, property="split_screen_toggled", text="", icon="WINDOW") + row.operator("bim.refresh_brick_viewer", text="", icon="FILE_REFRESH") grid = self.layout.grid_flow(even_columns=True) - grid1 = grid.column(align=True) - row = grid1.row(align=True) + grid_left = grid.column(align=True) + row = grid_left.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.label(text=self.props.active_brick_class) if self.props.set_list_root_toggled: - row = grid1.row(align=True) + row = grid_left.row(align=True) row.prop(data=self.props, property="brick_list_root", text="") - row = grid1.row() + row = grid_left.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) + grid_right = grid.column(align=True) + row = grid_right.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) + row = grid_right.row(align=True) row.prop(data=self.props, property="split_screen_brick_list_root", text="") - row = grid2.row() + row = grid_right.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") @@ -161,12 +169,10 @@ class BIM_PT_brickschema(Panel): prop_with_search(row, self.props, "new_brick_relation_type", text="") row.prop(data=self.props, property="new_brick_relation_object", text="") row.operator("bim.add_brick_relation", text="", icon="ADD") - if self.props.brick_create_relations_toggled and self.props.add_relation_failed: row = self.layout.row(align=True) row.label(text="Failed to find this entity!", icon="ERROR") - for relation in BrickschemaData.data["active_relations"]: row = self.layout.row(align=True) diff --git a/src/blenderbim/blenderbim/tool/brick.py b/src/blenderbim/blenderbim/tool/brick.py index 8758cc49d1..0afac1de09 100644 --- a/src/blenderbim/blenderbim/tool/brick.py +++ b/src/blenderbim/blenderbim/tool/brick.py @@ -23,6 +23,7 @@ import ifcopenshell.util.brick import blenderbim.core.tool import blenderbim.tool as tool from contextlib import contextmanager +import datetime try: import brickschema @@ -308,6 +309,7 @@ class Brick(blenderbim.core.tool.Brick): with BrickStore.graph.new_changeset("PROJECT") as cs: cs.load_file(filepath) BrickStore.path = filepath + cls.set_last_saved() BrickStore.load_namespaces() BrickStore.load_entity_classes() BrickStore.load_relationships() @@ -378,6 +380,7 @@ class Brick(blenderbim.core.tool.Brick): @classmethod def serialize_brick(cls): BrickStore.get_project().serialize(destination=BrickStore.path, format="turtle") + cls.set_last_saved() @classmethod def add_namespace(cls, alias, uri): @@ -391,11 +394,18 @@ class Brick(blenderbim.core.tool.Brick): else: bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear() + @classmethod + def set_last_saved(cls): + save = os.path.getmtime(BrickStore.path) + save = datetime.datetime.fromtimestamp(save) + BrickStore.last_saved = f"{save.year}-{save.month}-{save.day} {save.hour}:{save.minute}" + class BrickStore: schema = None # this is now a os path path = None # file path if the project was loaded in graph = None # this is the VersionedGraphCollection with 2 arbitrarily named graphs: "schema" and "project" # "SCHEMA" holds the Brick.ttl metadata; "PROJECT" holds all the authored entities + last_saved = None history = [] future = [] current_changesets = 0 @@ -415,6 +425,7 @@ class BrickStore: BrickStore.schema = None BrickStore.graph = None BrickStore.path = None + BrickStore.last_saved = None BrickStore.namespaces = [] BrickStore.entity_classes = {} BrickStore.relationships = []