mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Polish Brick UI and add "last saved" label
This commit is contained in:
@@ -42,9 +42,17 @@ class BIM_PT_brickschema(Panel):
|
|||||||
row.operator("bim.load_brick_project", text="Load Project")
|
row.operator("bim.load_brick_project", text="Load Project")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
row = self.layout.row(align=True)
|
||||||
if BrickStore.path:
|
if BrickStore.path:
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text=BrickStore.path, icon="FILEBROWSER")
|
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)
|
row = self.layout.row(align=True)
|
||||||
op = row.operator("bim.serialize_brick", icon="EXPORT", text="Save")
|
op = row.operator("bim.serialize_brick", icon="EXPORT", text="Save")
|
||||||
@@ -86,43 +94,43 @@ class BIM_PT_brickschema(Panel):
|
|||||||
row.prop(data=self.props, property="new_brick_label", text="")
|
row.prop(data=self.props, property="new_brick_label", text="")
|
||||||
prop_with_search(row, self.props, "brick_entity_class", text="")
|
prop_with_search(row, self.props, "brick_entity_class", text="")
|
||||||
row.operator("bim.add_brick", text="", icon="ADD")
|
row.operator("bim.add_brick", text="", icon="ADD")
|
||||||
# row.operator("bim.refresh_brick_viewer", text="", icon="FILE_REFRESH")
|
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.alignment = "RIGHT"
|
col.alignment = "RIGHT"
|
||||||
row.prop(data=self.props, property="set_list_root_toggled", text="", icon="OUTLINER")
|
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.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)
|
grid = self.layout.grid_flow(even_columns=True)
|
||||||
grid1 = grid.column(align=True)
|
grid_left = grid.column(align=True)
|
||||||
row = grid1.row(align=True)
|
row = grid_left.row(align=True)
|
||||||
if len(self.props.brick_breadcrumbs):
|
if len(self.props.brick_breadcrumbs):
|
||||||
op = row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV")
|
op = row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV")
|
||||||
op.split_screen = False
|
op.split_screen = False
|
||||||
row.label(text=self.props.active_brick_class)
|
row.label(text=self.props.active_brick_class)
|
||||||
|
|
||||||
if self.props.set_list_root_toggled:
|
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.prop(data=self.props, property="brick_list_root", text="")
|
||||||
|
|
||||||
row = grid1.row()
|
row = grid_left.row()
|
||||||
BIM_UL_bricks.split_screen = False
|
BIM_UL_bricks.split_screen = False
|
||||||
row.template_list("BIM_UL_bricks", "", self.props, "bricks", self.props, "active_brick_index")
|
row.template_list("BIM_UL_bricks", "", self.props, "bricks", self.props, "active_brick_index")
|
||||||
|
|
||||||
if self.props.split_screen_toggled:
|
if self.props.split_screen_toggled:
|
||||||
grid2 = grid.column(align=True)
|
grid_right = grid.column(align=True)
|
||||||
row = grid2.row(align=True)
|
row = grid_right.row(align=True)
|
||||||
if len(self.props.split_screen_brick_breadcrumbs):
|
if len(self.props.split_screen_brick_breadcrumbs):
|
||||||
op = row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV")
|
op = row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV")
|
||||||
op.split_screen = True
|
op.split_screen = True
|
||||||
row.label(text=self.props.split_screen_active_brick_class)
|
row.label(text=self.props.split_screen_active_brick_class)
|
||||||
|
|
||||||
if self.props.set_list_root_toggled:
|
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.prop(data=self.props, property="split_screen_brick_list_root", text="")
|
||||||
|
|
||||||
row = grid2.row()
|
row = grid_right.row()
|
||||||
BIM_UL_bricks.split_screen = True
|
BIM_UL_bricks.split_screen = True
|
||||||
row.template_list("BIM_UL_bricks", "", self.props, "split_screen_bricks", self.props, "split_screen_active_brick_index")
|
row.template_list("BIM_UL_bricks", "", self.props, "split_screen_bricks", self.props, "split_screen_active_brick_index")
|
||||||
|
|
||||||
@@ -162,12 +170,10 @@ class BIM_PT_brickschema(Panel):
|
|||||||
row.prop(data=self.props, property="new_brick_relation_object", text="")
|
row.prop(data=self.props, property="new_brick_relation_object", text="")
|
||||||
row.operator("bim.add_brick_relation", text="", icon="ADD")
|
row.operator("bim.add_brick_relation", text="", icon="ADD")
|
||||||
|
|
||||||
|
|
||||||
if self.props.brick_create_relations_toggled and self.props.add_relation_failed:
|
if self.props.brick_create_relations_toggled and self.props.add_relation_failed:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="Failed to find this entity!", icon="ERROR")
|
row.label(text="Failed to find this entity!", icon="ERROR")
|
||||||
|
|
||||||
|
|
||||||
for relation in BrickschemaData.data["active_relations"]:
|
for relation in BrickschemaData.data["active_relations"]:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=relation["predicate_name"])
|
row.label(text=relation["predicate_name"])
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import ifcopenshell.util.brick
|
|||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
import datetime
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import brickschema
|
import brickschema
|
||||||
@@ -308,6 +309,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
||||||
cs.load_file(filepath)
|
cs.load_file(filepath)
|
||||||
BrickStore.path = filepath
|
BrickStore.path = filepath
|
||||||
|
cls.set_last_saved()
|
||||||
BrickStore.load_namespaces()
|
BrickStore.load_namespaces()
|
||||||
BrickStore.load_entity_classes()
|
BrickStore.load_entity_classes()
|
||||||
BrickStore.load_relationships()
|
BrickStore.load_relationships()
|
||||||
@@ -378,6 +380,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def serialize_brick(cls):
|
def serialize_brick(cls):
|
||||||
BrickStore.get_project().serialize(destination=BrickStore.path, format="turtle")
|
BrickStore.get_project().serialize(destination=BrickStore.path, format="turtle")
|
||||||
|
cls.set_last_saved()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_namespace(cls, alias, uri):
|
def add_namespace(cls, alias, uri):
|
||||||
@@ -391,11 +394,18 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
else:
|
else:
|
||||||
bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear()
|
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:
|
class BrickStore:
|
||||||
schema = None # this is now a os path
|
schema = None # this is now a os path
|
||||||
path = None # file path if the project was loaded in
|
path = None # file path if the project was loaded in
|
||||||
graph = None # this is the VersionedGraphCollection with 2 arbitrarily named graphs: "schema" and "project"
|
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
|
# "SCHEMA" holds the Brick.ttl metadata; "PROJECT" holds all the authored entities
|
||||||
|
last_saved = None
|
||||||
history = []
|
history = []
|
||||||
future = []
|
future = []
|
||||||
current_changesets = 0
|
current_changesets = 0
|
||||||
@@ -415,6 +425,7 @@ class BrickStore:
|
|||||||
BrickStore.schema = None
|
BrickStore.schema = None
|
||||||
BrickStore.graph = None
|
BrickStore.graph = None
|
||||||
BrickStore.path = None
|
BrickStore.path = None
|
||||||
|
BrickStore.last_saved = None
|
||||||
BrickStore.namespaces = []
|
BrickStore.namespaces = []
|
||||||
BrickStore.entity_classes = {}
|
BrickStore.entity_classes = {}
|
||||||
BrickStore.relationships = []
|
BrickStore.relationships = []
|
||||||
|
|||||||
Reference in New Issue
Block a user