mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
editing sequence relationships now requires less clicks
This commit is contained in:
@@ -886,7 +886,7 @@ class EnableEditingTaskSequence(bpy.types.Operator):
|
|||||||
task: bpy.props.IntProperty()
|
task: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
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"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,18 @@ def update_active_task_index(self, context):
|
|||||||
bpy.ops.bim.load_task_inputs()
|
bpy.ops.bim.load_task_inputs()
|
||||||
bpy.ops.bim.load_task_resources()
|
bpy.ops.bim.load_task_resources()
|
||||||
bpy.ops.bim.load_task_outputs()
|
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()
|
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):
|
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_work_schedule_id: IntProperty(name="Active Work Schedules Id")
|
||||||
active_task_index: IntProperty(name="Active Task Index", update=update_active_task_index)
|
active_task_index: IntProperty(name="Active Task Index", update=update_active_task_index)
|
||||||
active_task_id: IntProperty(name="Active Task Id")
|
active_task_id: IntProperty(name="Active Task Id")
|
||||||
|
highlighted_task_id: IntProperty(name="Highlited Task Id")
|
||||||
task_attributes: CollectionProperty(name="Task Attributes", type=Attribute)
|
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_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)
|
should_show_task_bar_selection: BoolProperty(name="Add to task bar", default=False)
|
||||||
|
|||||||
@@ -219,6 +219,8 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
elif self.props.editing_task_type == "ATTRIBUTES":
|
elif self.props.editing_task_type == "ATTRIBUTES":
|
||||||
row.operator("bim.edit_task", text="", icon="CHECKMARK")
|
row.operator("bim.edit_task", text="", icon="CHECKMARK")
|
||||||
row.operator("bim.disable_editing_task", text="Cancel", icon="CANCEL")
|
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:
|
else:
|
||||||
row.prop(self.props, "show_task_operators", text="Edit", icon="GREASEPENCIL")
|
row.prop(self.props, "show_task_operators", text="Edit", icon="GREASEPENCIL")
|
||||||
if self.props.show_task_operators:
|
if self.props.show_task_operators:
|
||||||
@@ -226,7 +228,7 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
row2.alignment = "RIGHT"
|
row2.alignment = "RIGHT"
|
||||||
|
|
||||||
row2.prop(self.props, "enable_reorder", text="", icon="SORTALPHA")
|
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_time", text="", icon="TIME").task = ifc_definition_id
|
||||||
row2.operator(
|
row2.operator(
|
||||||
"bim.enable_editing_task_calendar", text="", icon="VIEW_ORTHO"
|
"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()
|
self.draw_editable_task_attributes_ui()
|
||||||
elif self.props.active_task_id and self.props.editing_task_type == "CALENDAR":
|
elif self.props.active_task_id and self.props.editing_task_type == "CALENDAR":
|
||||||
self.draw_editable_task_calendar_ui()
|
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()
|
self.draw_editable_task_sequence_ui()
|
||||||
elif self.props.active_task_time_id and self.props.editing_task_type == "TASKTIME":
|
elif self.props.active_task_time_id and self.props.editing_task_type == "TASKTIME":
|
||||||
self.draw_editable_task_time_attributes_ui()
|
self.draw_editable_task_time_attributes_ui()
|
||||||
|
|
||||||
def draw_editable_task_sequence_ui(self):
|
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 = self.layout.row()
|
||||||
row.label(text="{} Predecessors".format(len(task["IsSuccessorFrom"])), icon="BACK")
|
row.label(text="{} Predecessors".format(len(task["IsSuccessorFrom"])), icon="BACK")
|
||||||
for sequence_id in task["IsSuccessorFrom"]:
|
for sequence_id in task["IsSuccessorFrom"]:
|
||||||
@@ -800,19 +802,18 @@ class BIM_UL_tasks(UIList):
|
|||||||
)
|
)
|
||||||
if self.props.enable_reorder:
|
if self.props.enable_reorder:
|
||||||
self.draw_order_operator(row, item.ifc_definition_id)
|
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.highlighted_task_id != item.ifc_definition_id:
|
||||||
if self.props.editing_task_type == "SEQUENCE" and self.props.active_task_id != item.ifc_definition_id:
|
if item.is_predecessor:
|
||||||
if item.is_predecessor:
|
op = row.operator("bim.unassign_predecessor", text="", icon="BACK", emboss=False)
|
||||||
op = row.operator("bim.unassign_predecessor", text="", icon="BACK", emboss=False)
|
else:
|
||||||
else:
|
op = row.operator("bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False)
|
||||||
op = row.operator("bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False)
|
op.task = item.ifc_definition_id
|
||||||
op.task = item.ifc_definition_id
|
|
||||||
|
|
||||||
if item.is_successor:
|
if item.is_successor:
|
||||||
op = row.operator("bim.unassign_successor", text="", icon="FORWARD", emboss=False)
|
op = row.operator("bim.unassign_successor", text="", icon="FORWARD", emboss=False)
|
||||||
else:
|
else:
|
||||||
op = row.operator("bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False)
|
op = row.operator("bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False)
|
||||||
op.task = item.ifc_definition_id
|
op.task = item.ifc_definition_id
|
||||||
|
|
||||||
def draw_order_operator(self, row, ifc_definition_id):
|
def draw_order_operator(self, row, ifc_definition_id):
|
||||||
task = SequenceData.data["tasks"][ifc_definition_id]
|
task = SequenceData.data["tasks"][ifc_definition_id]
|
||||||
|
|||||||
@@ -196,25 +196,25 @@ def edit_task_time(ifc, sequence, task_time=None):
|
|||||||
|
|
||||||
|
|
||||||
def assign_predecessor(ifc, sequence, task=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)
|
ifc.run("sequence.assign_sequence", relating_process=task, related_process=predecessor_task)
|
||||||
sequence.load_task_properties()
|
sequence.load_task_properties()
|
||||||
|
|
||||||
|
|
||||||
def unassign_predecessor(ifc, sequence, task=None):
|
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)
|
ifc.run("sequence.unassign_sequence", relating_process=task, related_process=predecessor_task)
|
||||||
sequence.load_task_properties()
|
sequence.load_task_properties()
|
||||||
|
|
||||||
|
|
||||||
def assign_successor(ifc, sequence, task=None):
|
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)
|
ifc.run("sequence.assign_sequence", relating_process=successor_task, related_process=task)
|
||||||
sequence.load_task_properties()
|
sequence.load_task_properties()
|
||||||
|
|
||||||
|
|
||||||
def unassign_successor(ifc, sequence, task=None):
|
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)
|
ifc.run("sequence.unassign_sequence", relating_process=successor_task, related_process=task)
|
||||||
sequence.load_task_properties()
|
sequence.load_task_properties()
|
||||||
|
|
||||||
@@ -379,13 +379,8 @@ def remove_task_calendar(ifc, sequence, task=None, work_calendar=None):
|
|||||||
sequence.load_task_properties()
|
sequence.load_task_properties()
|
||||||
|
|
||||||
|
|
||||||
def enable_editing_task_sequence(sequence, task=None):
|
def enable_editing_task_sequence(sequence):
|
||||||
sequence.enable_editing_task_sequence(task)
|
sequence.enable_editing_task_sequence()
|
||||||
sequence.load_task_properties()
|
|
||||||
|
|
||||||
|
|
||||||
def disable_editing_task_sequence(sequence, task=None):
|
|
||||||
sequence.enable_editing_task_sequence(task)
|
|
||||||
sequence.load_task_properties()
|
sequence.load_task_properties()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -681,7 +681,7 @@ class Sequence:
|
|||||||
def enable_editing_sequence_lag_time(cls, rel_sequence): pass
|
def enable_editing_sequence_lag_time(cls, rel_sequence): pass
|
||||||
def enable_editing_task_attributes(cls, task): pass
|
def enable_editing_task_attributes(cls, task): pass
|
||||||
def enable_editing_task_calendar(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_task_time(cls, task): pass
|
||||||
def enable_editing_work_calendar_times(cls, work_calendar): pass
|
def enable_editing_work_calendar_times(cls, work_calendar): pass
|
||||||
def enable_editing_work_calendar(cls, work_calendar): pass
|
def enable_editing_work_calendar(cls, work_calendar): pass
|
||||||
|
|||||||
@@ -194,14 +194,12 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
props.is_task_update_enabled = False
|
props.is_task_update_enabled = False
|
||||||
|
|
||||||
for item in task_props.tasks:
|
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)
|
task = tool.Ifc.get().by_id(item.ifc_definition_id)
|
||||||
item.name = task.Name or "Unnamed"
|
item.name = task.Name or "Unnamed"
|
||||||
item.identification = task.Identification or "XXX"
|
item.identification = task.Identification or "XXX"
|
||||||
if props.active_task_id:
|
if props.highlighted_task_id:
|
||||||
item.is_predecessor = props.active_task_id in [rel.RelatedProcess.id() for rel in task.IsPredecessorTo]
|
item.is_predecessor = props.highlighted_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]
|
item.is_successor = props.highlighted_task_id in [rel.RelatingProcess.id() for rel in task.IsSuccessorFrom]
|
||||||
calendar = ifcopenshell.util.sequence.derive_calendar(task)
|
calendar = ifcopenshell.util.sequence.derive_calendar(task)
|
||||||
if task.HasAssignments:
|
if task.HasAssignments:
|
||||||
for rel in task.HasAssignments:
|
for rel in task.HasAssignments:
|
||||||
@@ -375,6 +373,7 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
def disable_editing_task(cls):
|
def disable_editing_task(cls):
|
||||||
bpy.context.scene.BIMWorkScheduleProperties.active_task_id = 0
|
bpy.context.scene.BIMWorkScheduleProperties.active_task_id = 0
|
||||||
bpy.context.scene.BIMWorkScheduleProperties.active_task_time_id = 0
|
bpy.context.scene.BIMWorkScheduleProperties.active_task_time_id = 0
|
||||||
|
bpy.context.scene.BIMWorkScheduleProperties.editing_task_type = ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_task_time_attributes(cls):
|
def get_task_time_attributes(cls):
|
||||||
@@ -645,9 +644,8 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
props.editing_task_type = "CALENDAR"
|
props.editing_task_type = "CALENDAR"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def enable_editing_task_sequence(cls, task):
|
def enable_editing_task_sequence(cls):
|
||||||
props = bpy.context.scene.BIMWorkScheduleProperties
|
props = bpy.context.scene.BIMWorkScheduleProperties
|
||||||
props.active_task_id = task.id()
|
|
||||||
props.editing_task_type = "SEQUENCE"
|
props.editing_task_type = "SEQUENCE"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user