mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 14:26:30 +00:00
Implement fully undo/redo with checks
While these actions are short in the backend--taking about 0.01 seconds to run--the Blender UI lags a lot leading to 2-3 second pauses because of the "refresh_brick_viewer" function being slow. This should be investigated.
This commit is contained in:
@@ -33,6 +33,8 @@ classes = (
|
|||||||
operator.RewindBrickClass,
|
operator.RewindBrickClass,
|
||||||
operator.ViewBrickClass,
|
operator.ViewBrickClass,
|
||||||
operator.ViewBrickItem,
|
operator.ViewBrickItem,
|
||||||
|
operator.UndoBrick,
|
||||||
|
operator.RedoBrick,
|
||||||
operator.SerializeBrick,
|
operator.SerializeBrick,
|
||||||
prop.Brick,
|
prop.Brick,
|
||||||
prop.BIMBrickProperties,
|
prop.BIMBrickProperties,
|
||||||
|
|||||||
@@ -190,6 +190,20 @@ class RemoveBrick(bpy.types.Operator, Operator):
|
|||||||
brick_uri=props.bricks[props.active_brick_index].uri,
|
brick_uri=props.bricks[props.active_brick_index].uri,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class UndoBrick(bpy.types.Operator, Operator):
|
||||||
|
bl_idname = "bim.undo_brick"
|
||||||
|
bl_label = "Undo Brick"
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
core.undo_brick(tool.Brick)
|
||||||
|
|
||||||
|
class RedoBrick(bpy.types.Operator, Operator):
|
||||||
|
bl_idname = "bim.redo_brick"
|
||||||
|
bl_label = "Redo Brick"
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
core.redo_brick(tool.Brick)
|
||||||
|
|
||||||
class SerializeBrick(bpy.types.Operator, Operator):
|
class SerializeBrick(bpy.types.Operator, Operator):
|
||||||
bl_idname = "bim.serialize_brick"
|
bl_idname = "bim.serialize_brick"
|
||||||
bl_label = "Serialize Brick"
|
bl_label = "Serialize Brick"
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ class BIM_PT_brickschema(Panel):
|
|||||||
row.operator("bim.add_brick_feed", text="", icon="PLUGIN")
|
row.operator("bim.add_brick_feed", text="", icon="PLUGIN")
|
||||||
row.operator("bim.remove_brick", text="", icon="X")
|
row.operator("bim.remove_brick", text="", icon="X")
|
||||||
|
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.operator("bim.undo_brick", icon="LOOP_BACK")
|
||||||
|
row.operator("bim.redo_brick", icon="LOOP_FORWARDS")
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.serialize_brick")
|
row.operator("bim.serialize_brick")
|
||||||
|
|
||||||
|
|||||||
@@ -110,5 +110,13 @@ def remove_brick(ifc, brick, library=None, brick_uri=None):
|
|||||||
brick.remove_brick(brick_uri)
|
brick.remove_brick(brick_uri)
|
||||||
brick.run_refresh_brick_viewer()
|
brick.run_refresh_brick_viewer()
|
||||||
|
|
||||||
|
def undo_brick(brick):
|
||||||
|
brick.undo_brick()
|
||||||
|
brick.run_refresh_brick_viewer()
|
||||||
|
|
||||||
|
def redo_brick(brick):
|
||||||
|
brick.redo_brick()
|
||||||
|
brick.run_refresh_brick_viewer()
|
||||||
|
|
||||||
def serialize_brick(brick, file_name="BlenderBIMSerializeTest.ttl"):
|
def serialize_brick(brick, file_name="BlenderBIMSerializeTest.ttl"):
|
||||||
brick.serialize_brick(file_name)
|
brick.serialize_brick(file_name)
|
||||||
@@ -282,9 +282,10 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def remove_brick(cls, brick_uri):
|
def remove_brick(cls, brick_uri):
|
||||||
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
if(BrickStore.graph.triples((URIRef(brick_uri), None, None))):
|
||||||
for triple in BrickStore.graph.triples((URIRef(brick_uri), None, None)):
|
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
||||||
cs.remove(triple)
|
for triple in BrickStore.graph.triples((URIRef(brick_uri), None, None)):
|
||||||
|
cs.remove(triple)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_assign_brick_reference(cls, element=None, library=None, brick_uri=None):
|
def run_assign_brick_reference(cls, element=None, library=None, brick_uri=None):
|
||||||
@@ -312,11 +313,17 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def undo_brick(cls):
|
def undo_brick(cls):
|
||||||
BrickStore.graph.undo()
|
if(len(BrickStore.graph.versions()) > 1):
|
||||||
|
BrickStore.graph.undo()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def redo_brick(cls):
|
def redo_brick(cls):
|
||||||
BrickStore.graph.redo()
|
with BrickStore.graph.conn() as conn:
|
||||||
|
redo_record = conn.execute(
|
||||||
|
"SELECT * from redos " "ORDER BY timestamp ASC LIMIT 1"
|
||||||
|
).fetchone()
|
||||||
|
if redo_record is not None:
|
||||||
|
BrickStore.graph.redo()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def serialize_brick(cls, file_name):
|
def serialize_brick(cls, file_name):
|
||||||
|
|||||||
Reference in New Issue
Block a user