From 954722f40b9fc906facc00b9250893267d8b4e91 Mon Sep 17 00:00:00 2001 From: "Sigma Dimensions (Yass)" <79010126+myoualid@users.noreply.github.com> Date: Mon, 21 Aug 2023 13:24:36 +0100 Subject: [PATCH] editing sequence relationships now requires less clicks --- .../bim/module/sequence/operator.py | 2 +- .../blenderbim/bim/module/sequence/prop.py | 12 +++++++ .../blenderbim/bim/module/sequence/ui.py | 31 ++++++++++--------- src/blenderbim/blenderbim/core/sequence.py | 17 ++++------ src/blenderbim/blenderbim/core/tool.py | 2 +- src/blenderbim/blenderbim/tool/sequence.py | 12 +++---- 6 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index fa9889c947..d2fdb77f28 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -886,7 +886,7 @@ class EnableEditingTaskSequence(bpy.types.Operator): task: bpy.props.IntProperty() def execute(self, context): - core.enable_editing_task_sequence(tool.Sequence, task=tool.Ifc.get().by_id(self.task)) + core.enable_editing_task_sequence(tool.Sequence) return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/sequence/prop.py b/src/blenderbim/blenderbim/bim/module/sequence/prop.py index d23cc50a2c..ec6c2cc330 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/prop.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/prop.py @@ -91,7 +91,18 @@ def update_active_task_index(self, context): bpy.ops.bim.load_task_inputs() bpy.ops.bim.load_task_resources() bpy.ops.bim.load_task_outputs() + task = tool.Sequence.get_highlighted_task() + self.highlighted_task_id = task.id() if task else 0 blenderbim.bim.module.pset.data.refresh() + if self.editing_task_type == "SEQUENCE": + tool.Sequence.load_task_properties() + + +def update_highlighted_task_id(self): + task = tool.Sequence.get_highlighted_task() + self.highlighted_task_id = task.id() if task else 0 + print("current Task ID: " + str(self.highlighted_task_id)) + tool.Sequence.load_task_properties() def update_active_task_outputs(self, context): @@ -387,6 +398,7 @@ class BIMWorkScheduleProperties(PropertyGroup): active_work_schedule_id: IntProperty(name="Active Work Schedules Id") active_task_index: IntProperty(name="Active Task Index", update=update_active_task_index) active_task_id: IntProperty(name="Active Task Id") + highlighted_task_id: IntProperty(name="Highlited Task Id") task_attributes: CollectionProperty(name="Task Attributes", type=Attribute) should_show_visualisation_ui: BoolProperty(name="Should Show Visualisation UI", default=True, update=switch_options) should_show_task_bar_selection: BoolProperty(name="Add to task bar", default=False) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/ui.py b/src/blenderbim/blenderbim/bim/module/sequence/ui.py index e41e143e9b..4be950d9fe 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/ui.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/ui.py @@ -219,6 +219,8 @@ class BIM_PT_work_schedules(Panel): elif self.props.editing_task_type == "ATTRIBUTES": row.operator("bim.edit_task", text="", icon="CHECKMARK") row.operator("bim.disable_editing_task", text="Cancel", icon="CANCEL") + elif self.props.editing_task_type == "SEQUENCE": + row.operator("bim.disable_editing_task", text="Cancel", icon="CANCEL") else: row.prop(self.props, "show_task_operators", text="Edit", icon="GREASEPENCIL") if self.props.show_task_operators: @@ -226,7 +228,7 @@ class BIM_PT_work_schedules(Panel): row2.alignment = "RIGHT" row2.prop(self.props, "enable_reorder", text="", icon="SORTALPHA") - row2.operator("bim.enable_editing_task_sequence", text="", icon="TRACKING").task = ifc_definition_id + row2.operator("bim.enable_editing_task_sequence", text="", icon="TRACKING") row2.operator("bim.enable_editing_task_time", text="", icon="TIME").task = ifc_definition_id row2.operator( "bim.enable_editing_task_calendar", text="", icon="VIEW_ORTHO" @@ -293,13 +295,13 @@ class BIM_PT_work_schedules(Panel): self.draw_editable_task_attributes_ui() elif self.props.active_task_id and self.props.editing_task_type == "CALENDAR": self.draw_editable_task_calendar_ui() - elif self.props.active_task_id and self.props.editing_task_type == "SEQUENCE": + elif self.props.highlighted_task_id and self.props.editing_task_type == "SEQUENCE": self.draw_editable_task_sequence_ui() elif self.props.active_task_time_id and self.props.editing_task_type == "TASKTIME": self.draw_editable_task_time_attributes_ui() def draw_editable_task_sequence_ui(self): - task = SequenceData.data["tasks"][self.props.active_task_id] + task = SequenceData.data["tasks"][self.props.highlighted_task_id] row = self.layout.row() row.label(text="{} Predecessors".format(len(task["IsSuccessorFrom"])), icon="BACK") for sequence_id in task["IsSuccessorFrom"]: @@ -800,19 +802,18 @@ class BIM_UL_tasks(UIList): ) if self.props.enable_reorder: self.draw_order_operator(row, item.ifc_definition_id) - if self.props.active_task_id: - if self.props.editing_task_type == "SEQUENCE" and self.props.active_task_id != item.ifc_definition_id: - if item.is_predecessor: - op = row.operator("bim.unassign_predecessor", text="", icon="BACK", emboss=False) - else: - op = row.operator("bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False) - op.task = item.ifc_definition_id + if self.props.editing_task_type == "SEQUENCE" and self.props.highlighted_task_id != item.ifc_definition_id: + if item.is_predecessor: + op = row.operator("bim.unassign_predecessor", text="", icon="BACK", emboss=False) + else: + op = row.operator("bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False) + op.task = item.ifc_definition_id - if item.is_successor: - op = row.operator("bim.unassign_successor", text="", icon="FORWARD", emboss=False) - else: - op = row.operator("bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False) - op.task = item.ifc_definition_id + if item.is_successor: + op = row.operator("bim.unassign_successor", text="", icon="FORWARD", emboss=False) + else: + op = row.operator("bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False) + op.task = item.ifc_definition_id def draw_order_operator(self, row, ifc_definition_id): task = SequenceData.data["tasks"][ifc_definition_id] diff --git a/src/blenderbim/blenderbim/core/sequence.py b/src/blenderbim/blenderbim/core/sequence.py index 72d9afb293..a7ef055de6 100644 --- a/src/blenderbim/blenderbim/core/sequence.py +++ b/src/blenderbim/blenderbim/core/sequence.py @@ -196,25 +196,25 @@ def edit_task_time(ifc, sequence, task_time=None): def assign_predecessor(ifc, sequence, task=None): - predecessor_task = sequence.get_active_task() + predecessor_task = sequence.get_highlighted_task() ifc.run("sequence.assign_sequence", relating_process=task, related_process=predecessor_task) sequence.load_task_properties() def unassign_predecessor(ifc, sequence, task=None): - predecessor_task = sequence.get_active_task() + predecessor_task = sequence.get_highlighted_task() ifc.run("sequence.unassign_sequence", relating_process=task, related_process=predecessor_task) sequence.load_task_properties() def assign_successor(ifc, sequence, task=None): - successor_task = sequence.get_active_task() + successor_task = sequence.get_highlighted_task() ifc.run("sequence.assign_sequence", relating_process=successor_task, related_process=task) sequence.load_task_properties() def unassign_successor(ifc, sequence, task=None): - successor_task = sequence.get_active_task() + successor_task = sequence.get_highlighted_task() ifc.run("sequence.unassign_sequence", relating_process=successor_task, related_process=task) sequence.load_task_properties() @@ -379,13 +379,8 @@ def remove_task_calendar(ifc, sequence, task=None, work_calendar=None): sequence.load_task_properties() -def enable_editing_task_sequence(sequence, task=None): - sequence.enable_editing_task_sequence(task) - sequence.load_task_properties() - - -def disable_editing_task_sequence(sequence, task=None): - sequence.enable_editing_task_sequence(task) +def enable_editing_task_sequence(sequence): + sequence.enable_editing_task_sequence() sequence.load_task_properties() diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index 37ed517eaf..91b3bcf2eb 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -681,7 +681,7 @@ class Sequence: def enable_editing_sequence_lag_time(cls, rel_sequence): pass def enable_editing_task_attributes(cls, task): pass def enable_editing_task_calendar(cls, task): pass - def enable_editing_task_sequence(cls, task): pass + def enable_editing_task_sequence(cls): pass def enable_editing_task_time(cls, task): pass def enable_editing_work_calendar_times(cls, work_calendar): pass def enable_editing_work_calendar(cls, work_calendar): pass diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index db4b2879f7..81434c08be 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -194,14 +194,12 @@ class Sequence(blenderbim.core.tool.Sequence): props.is_task_update_enabled = False for item in task_props.tasks: - # if task and item.ifc_definition_id != task.id(): - # continue task = tool.Ifc.get().by_id(item.ifc_definition_id) item.name = task.Name or "Unnamed" item.identification = task.Identification or "XXX" - if props.active_task_id: - item.is_predecessor = props.active_task_id in [rel.RelatedProcess.id() for rel in task.IsPredecessorTo] - item.is_successor = props.active_task_id in [rel.RelatingProcess.id() for rel in task.IsSuccessorFrom] + if props.highlighted_task_id: + item.is_predecessor = props.highlighted_task_id in [rel.RelatedProcess.id() for rel in task.IsPredecessorTo] + item.is_successor = props.highlighted_task_id in [rel.RelatingProcess.id() for rel in task.IsSuccessorFrom] calendar = ifcopenshell.util.sequence.derive_calendar(task) if task.HasAssignments: for rel in task.HasAssignments: @@ -375,6 +373,7 @@ class Sequence(blenderbim.core.tool.Sequence): def disable_editing_task(cls): bpy.context.scene.BIMWorkScheduleProperties.active_task_id = 0 bpy.context.scene.BIMWorkScheduleProperties.active_task_time_id = 0 + bpy.context.scene.BIMWorkScheduleProperties.editing_task_type = "" @classmethod def get_task_time_attributes(cls): @@ -645,9 +644,8 @@ class Sequence(blenderbim.core.tool.Sequence): props.editing_task_type = "CALENDAR" @classmethod - def enable_editing_task_sequence(cls, task): + def enable_editing_task_sequence(cls): props = bpy.context.scene.BIMWorkScheduleProperties - props.active_task_id = task.id() props.editing_task_type = "SEQUENCE" @classmethod