Support importing P6 sequence types and new view sequences UI

This commit is contained in:
Dion Moult
2021-04-30 21:34:18 +10:00
parent 932a21309f
commit be87b17909
6 changed files with 102 additions and 24 deletions
@@ -38,6 +38,7 @@ classes = (
operator.RemoveTask,
operator.EnableEditingTask,
operator.DisableEditingTask,
operator.DisableEditingTaskTime,
operator.EditTask,
operator.AssignPredecessor,
operator.AssignSuccessor,
@@ -45,6 +46,7 @@ classes = (
operator.UnassignSuccessor,
operator.EnableEditingTaskTime,
operator.EnableEditingTaskCalendar,
operator.EnableEditingTaskSequence,
operator.EditTaskTime,
operator.EditTaskCalendar,
operator.RemoveTaskCalendar,
@@ -291,8 +291,12 @@ class LoadTaskProperties(bpy.types.Operator):
item.name = task["Name"] or "Unnamed"
item.identification = task["Identification"] or "XXX"
if self.props.active_task_id:
item.is_predecessor = self.props.active_task_id in task["IsPredecessorTo"]
item.is_successor = self.props.active_task_id in task["IsSuccessorFrom"]
item.is_predecessor = self.props.active_task_id in [
Data.sequences[r]["RelatedProcess"] for r in task["IsPredecessorTo"]
]
item.is_successor = self.props.active_task_id in [
Data.sequences[r]["RelatingProcess"] for r in task["IsSuccessorFrom"]
]
if task["TaskTime"]:
task_time = Data.task_times[task["TaskTime"]]
item.start = self.canonicalise_time(task_time["ScheduleStart"])
@@ -440,7 +444,6 @@ class EnableEditingTaskTime(bpy.types.Operator):
props.active_task_time_id = task_time_id
props.active_task_id = self.task
props.editing_task_type = "TASKTIME"
bpy.ops.bim.load_task_properties()
return {"FINISHED"}
def add_task_time(self):
@@ -530,7 +533,6 @@ class EnableEditingTask(bpy.types.Operator):
new.enum_value = data[attribute.name()]
props.active_task_id = self.task
props.editing_task_type = "ATTRIBUTES"
bpy.ops.bim.load_task_properties()
return {"FINISHED"}
@@ -1159,3 +1161,26 @@ class RemoveTaskCalendar(bpy.types.Operator):
)
Data.load(IfcStore.get_file())
return {"FINISHED"}
class EnableEditingTaskSequence(bpy.types.Operator):
bl_idname = "bim.enable_editing_task_sequence"
bl_label = "Enable Editing Task Sequence"
task: bpy.props.IntProperty()
def execute(self, context):
props = context.scene.BIMWorkScheduleProperties
props.active_task_id = self.task
props.editing_task_type = "SEQUENCE"
bpy.ops.bim.load_task_properties()
return {"FINISHED"}
class DisableEditingTaskTime(bpy.types.Operator):
bl_idname = "bim.disable_editing_task_time"
bl_label = "Disable Editing Task Time"
def execute(self, context):
context.scene.BIMWorkScheduleProperties.active_task_time_id = 0
bpy.ops.bim.disable_editing_task()
return {"FINISHED"}
@@ -156,7 +156,7 @@ class BIMWorkScheduleProperties(PropertyGroup):
active_task_index: IntProperty(name="Active Task Index")
active_task_id: IntProperty(name="Active Task Id")
task_attributes: CollectionProperty(name="Task Attributes", type=Attribute)
should_show_times: BoolProperty(name="Should Show Times", default=True)
should_show_times: BoolProperty(name="Should Show Times", default=False)
active_task_time_id: IntProperty(name="Active Task Id")
task_time_attributes: CollectionProperty(name="Task Time Attributes", type=Attribute)
contracted_tasks: StringProperty(name="Contracted Task Items", default="[]")
@@ -149,9 +149,30 @@ 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":
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 = Data.tasks[self.props.active_task_id]
row = self.layout.row()
row.label(text="{} Predecessors".format(len(task["IsSuccessorFrom"])), icon="BACK")
for sequence_id in task["IsSuccessorFrom"]:
self.draw_editable_sequence_ui(Data.sequences[sequence_id], "RelatingProcess")
row = self.layout.row()
row.label(text="{} Successors".format(len(task["IsPredecessorTo"])), icon="FORWARD")
for sequence_id in task["IsPredecessorTo"]:
self.draw_editable_sequence_ui(Data.sequences[sequence_id], "RelatedProcess")
def draw_editable_sequence_ui(self, sequence, process_type):
task = Data.tasks[sequence[process_type]]
row = self.layout.row(align=True)
row.label(text=task["Identification"] or "XXX")
row.label(text=task["Name"] or "Unnamed")
row.label(text=sequence["SequenceType"] or "N/A")
def draw_editable_task_calendar_ui(self):
task = Data.tasks[self.props.active_task_id]
if task["HasAssignmentsWorkCalendar"]:
@@ -240,31 +261,35 @@ class BIM_UL_tasks(UIList):
row.operator("bim.edit_task_time", text="", icon="CHECKMARK")
elif props.editing_task_type == "CALENDAR":
row.operator("bim.disable_editing_task", text="", icon="CHECKMARK")
elif props.editing_task_type == "SEQUENCE":
row.operator("bim.disable_editing_task", text="", icon="CHECKMARK")
elif props.editing_task_type == "ATTRIBUTES":
row.operator("bim.edit_task", text="", icon="CHECKMARK")
row.operator("bim.disable_editing_task", text="", icon="CANCEL")
elif props.active_task_id:
if item.is_predecessor:
row.operator(
"bim.unassign_predecessor", text="", icon="BACK", emboss=False
).task = item.ifc_definition_id
else:
row.operator(
"bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False
).task = item.ifc_definition_id
if props.editing_task_type == "SEQUENCE":
if item.is_predecessor:
row.operator(
"bim.unassign_predecessor", text="", icon="BACK", emboss=False
).task = item.ifc_definition_id
else:
row.operator(
"bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False
).task = item.ifc_definition_id
if item.is_successor:
row.operator(
"bim.unassign_successor", text="", icon="FORWARD", emboss=False
).task = item.ifc_definition_id
else:
row.operator(
"bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False
).task = item.ifc_definition_id
if item.is_successor:
row.operator(
"bim.unassign_successor", text="", icon="FORWARD", emboss=False
).task = item.ifc_definition_id
else:
row.operator(
"bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False
).task = item.ifc_definition_id
row.operator("bim.add_task", text="", icon="ADD").task = item.ifc_definition_id
row.operator("bim.remove_task", text="", icon="X").task = item.ifc_definition_id
else:
row.operator("bim.enable_editing_task_sequence", text="", icon="TRACKING").task = item.ifc_definition_id
row.operator("bim.enable_editing_task_time", text="", icon="TIME").task = item.ifc_definition_id
row.operator("bim.enable_editing_task_calendar", text="", icon="VIEW_ORTHO").task = item.ifc_definition_id
row.operator("bim.enable_editing_task", text="", icon="GREASEPENCIL").task = item.ifc_definition_id