mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 08:32:48 +00:00
Improve UX of task tree by shifting buttons and changing column widths
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
||||||
#
|
#
|
||||||
@@ -152,6 +151,37 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
elif self.props.editing_type == "TASKS":
|
elif self.props.editing_type == "TASKS":
|
||||||
self.draw_editable_task_ui(work_schedule_id)
|
self.draw_editable_task_ui(work_schedule_id)
|
||||||
|
|
||||||
|
def draw_task_operators(self):
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
row.alignment = "RIGHT"
|
||||||
|
ifc_definition_id = None
|
||||||
|
if self.tprops.tasks and self.props.active_task_index < len(self.tprops.tasks):
|
||||||
|
task = self.tprops.tasks[self.props.active_task_index]
|
||||||
|
ifc_definition_id = task.ifc_definition_id
|
||||||
|
if ifc_definition_id:
|
||||||
|
if self.props.active_task_id == ifc_definition_id:
|
||||||
|
if self.props.editing_task_type == "TASKTIME":
|
||||||
|
row.operator("bim.edit_task_time", text="", icon="CHECKMARK")
|
||||||
|
elif self.props.editing_task_type == "ATTRIBUTES":
|
||||||
|
row.operator("bim.edit_task", text="", icon="CHECKMARK")
|
||||||
|
row.operator("bim.disable_editing_task", text="", icon="CANCEL")
|
||||||
|
elif self.props.active_task_id:
|
||||||
|
row.operator("bim.add_task", text="", icon="ADD").task = ifc_definition_id
|
||||||
|
row.operator("bim.remove_task", text="", icon="X").task = ifc_definition_id
|
||||||
|
else:
|
||||||
|
row.operator("bim.enable_editing_task_sequence", text="", icon="TRACKING").task = ifc_definition_id
|
||||||
|
row.operator(
|
||||||
|
"bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text=""
|
||||||
|
).task = ifc_definition_id
|
||||||
|
row.operator("bim.enable_editing_task_time", text="", icon="TIME").task = ifc_definition_id
|
||||||
|
row.operator("bim.enable_editing_task_calendar", text="", icon="VIEW_ORTHO").task = ifc_definition_id
|
||||||
|
row.operator(
|
||||||
|
"bim.enable_assigning_process_to_resources", text="", icon="COMMUNITY"
|
||||||
|
).task = ifc_definition_id
|
||||||
|
row.operator("bim.enable_editing_task", text="", icon="GREASEPENCIL").task = ifc_definition_id
|
||||||
|
row.operator("bim.add_task", text="", icon="ADD").task = ifc_definition_id
|
||||||
|
row.operator("bim.remove_task", text="", icon="X").task = ifc_definition_id
|
||||||
|
|
||||||
def draw_column_ui(self):
|
def draw_column_ui(self):
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(self.props, "column_types", text="")
|
row.prop(self.props, "column_types", text="")
|
||||||
@@ -205,6 +235,7 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
draw_attributes(self.props.work_schedule_attributes, self.layout)
|
draw_attributes(self.props.work_schedule_attributes, self.layout)
|
||||||
|
|
||||||
def draw_editable_task_ui(self, work_schedule_id):
|
def draw_editable_task_ui(self, work_schedule_id):
|
||||||
|
self.draw_task_operators()
|
||||||
self.layout.template_list(
|
self.layout.template_list(
|
||||||
"BIM_UL_tasks",
|
"BIM_UL_tasks",
|
||||||
"",
|
"",
|
||||||
@@ -313,6 +344,7 @@ class BIM_PT_work_schedules(Panel):
|
|||||||
op.task = self.props.active_task_id
|
op.task = self.props.active_task_id
|
||||||
op.resource = related_obect_id
|
op.resource = related_obect_id
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_task_columns(UIList):
|
class BIM_UL_task_columns(UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
props = context.scene.BIMWorkScheduleProperties
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
@@ -327,59 +359,21 @@ class BIM_UL_task_columns(UIList):
|
|||||||
class BIM_UL_tasks(UIList):
|
class BIM_UL_tasks(UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if item:
|
||||||
props = context.scene.BIMWorkScheduleProperties
|
self.props = context.scene.BIMWorkScheduleProperties
|
||||||
task = IfcStore.get_file().by_id(item.ifc_definition_id)
|
task = IfcStore.get_file().by_id(item.ifc_definition_id)
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
for i in range(0, item.level_index):
|
|
||||||
row.label(text="", icon="BLANK1")
|
|
||||||
if item.has_children:
|
|
||||||
if item.is_expanded:
|
|
||||||
row.operator(
|
|
||||||
"bim.contract_task", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
|
||||||
).task = item.ifc_definition_id
|
|
||||||
else:
|
|
||||||
row.operator(
|
|
||||||
"bim.expand_task", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
|
||||||
).task = item.ifc_definition_id
|
|
||||||
else:
|
|
||||||
row.label(text="", icon="DOT")
|
|
||||||
row.prop(item, "identification", emboss=False, text="")
|
|
||||||
row.prop(item, "name", emboss=False, text="")
|
|
||||||
|
|
||||||
for column in props.columns:
|
self.draw_hierarchy(row, item)
|
||||||
if column.name == "IfcTaskTime.ScheduleStart":
|
|
||||||
if item.derived_start:
|
split1 = row.split(factor=0.1)
|
||||||
row.label(text=item.derived_start + "*")
|
split1.prop(item, "identification", emboss=False, text="")
|
||||||
else:
|
split2 = split1.split(factor=0.9 - min(0.5, 0.15 * len(self.props.columns)))
|
||||||
row.prop(item, "start", emboss=False, text="")
|
split2.prop(item, "name", emboss=False, text="")
|
||||||
elif column.name == "IfcTaskTime.ScheduleFinish":
|
|
||||||
if item.derived_finish:
|
self.draw_custom_columns(split2, item, task)
|
||||||
row.label(text=item.derived_finish + "*")
|
|
||||||
else:
|
|
||||||
row.prop(item, "finish", emboss=False, text="")
|
|
||||||
elif column.name == "IfcTaskTime.ScheduleDuration":
|
|
||||||
if item.derived_duration:
|
|
||||||
row.label(text=item.derived_duration + "*")
|
|
||||||
else:
|
|
||||||
row.prop(item, "duration", emboss=False, text="")
|
|
||||||
elif column.name == "Controls.Calendar":
|
|
||||||
if item.derived_calendar:
|
|
||||||
row.label(text=item.derived_calendar + "*")
|
|
||||||
else:
|
|
||||||
row.label(text=item.calendar or "-")
|
|
||||||
else:
|
|
||||||
ifc_class, name = column.name.split(".")
|
|
||||||
if ifc_class == "IfcTask":
|
|
||||||
value = getattr(task, name)
|
|
||||||
elif ifc_class == "IfcTaskTime":
|
|
||||||
value = getattr(task.TaskTime, name) if task.TaskTime else None
|
|
||||||
if value is None:
|
|
||||||
value = "-"
|
|
||||||
row.label(text=str(value))
|
|
||||||
|
|
||||||
if context.active_object:
|
if context.active_object:
|
||||||
oprops = context.active_object.BIMObjectProperties
|
oprops = context.active_object.BIMObjectProperties
|
||||||
row = layout.row(align=True)
|
|
||||||
|
|
||||||
if oprops.ifc_definition_id in Data.tasks[item.ifc_definition_id]["OperatesOn"]:
|
if oprops.ifc_definition_id in Data.tasks[item.ifc_definition_id]["OperatesOn"]:
|
||||||
op = row.operator("bim.unassign_process", text="", icon="MARKER_HLT", emboss=False)
|
op = row.operator("bim.unassign_process", text="", icon="MARKER_HLT", emboss=False)
|
||||||
@@ -395,7 +389,7 @@ class BIM_UL_tasks(UIList):
|
|||||||
op = row.operator("bim.assign_product", text="", icon="KEYFRAME", emboss=False)
|
op = row.operator("bim.assign_product", text="", icon="KEYFRAME", emboss=False)
|
||||||
op.task = item.ifc_definition_id
|
op.task = item.ifc_definition_id
|
||||||
|
|
||||||
if props.active_task_id and props.editing_task_type == "ATTRIBUTES":
|
if self.props.active_task_id and self.props.editing_task_type == "ATTRIBUTES":
|
||||||
row.prop(
|
row.prop(
|
||||||
item,
|
item,
|
||||||
"is_selected",
|
"is_selected",
|
||||||
@@ -404,47 +398,66 @@ class BIM_UL_tasks(UIList):
|
|||||||
emboss=False,
|
emboss=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
if props.active_task_id == item.ifc_definition_id:
|
if self.props.active_task_id:
|
||||||
if props.editing_task_type == "TASKTIME":
|
if self.props.editing_task_type == "SEQUENCE" and self.props.active_task_id != item.ifc_definition_id:
|
||||||
row.operator("bim.edit_task_time", 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 props.editing_task_type == "SEQUENCE":
|
|
||||||
if item.is_predecessor:
|
if item.is_predecessor:
|
||||||
row.operator(
|
op = row.operator("bim.unassign_predecessor", text="", icon="BACK", emboss=False)
|
||||||
"bim.unassign_predecessor", text="", icon="BACK", emboss=False
|
|
||||||
).task = item.ifc_definition_id
|
|
||||||
else:
|
else:
|
||||||
row.operator(
|
op = row.operator("bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False)
|
||||||
"bim.assign_predecessor", text="", icon="TRACKING_BACKWARDS", emboss=False
|
op.task = item.ifc_definition_id
|
||||||
).task = item.ifc_definition_id
|
|
||||||
|
|
||||||
if item.is_successor:
|
if item.is_successor:
|
||||||
row.operator(
|
op = row.operator("bim.unassign_successor", text="", icon="FORWARD", emboss=False)
|
||||||
"bim.unassign_successor", text="", icon="FORWARD", emboss=False
|
|
||||||
).task = item.ifc_definition_id
|
|
||||||
else:
|
else:
|
||||||
row.operator(
|
op = row.operator("bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False)
|
||||||
"bim.assign_successor", text="", icon="TRACKING_FORWARDS", emboss=False
|
op.task = item.ifc_definition_id
|
||||||
).task = item.ifc_definition_id
|
|
||||||
|
|
||||||
row.operator("bim.add_task", text="", icon="ADD").task = item.ifc_definition_id
|
def draw_hierarchy(self, row, item):
|
||||||
row.operator("bim.remove_task", text="", icon="X").task = item.ifc_definition_id
|
for i in range(0, item.level_index):
|
||||||
|
row.label(text="", icon="BLANK1")
|
||||||
|
if item.has_children:
|
||||||
|
if item.is_expanded:
|
||||||
|
row.operator(
|
||||||
|
"bim.contract_task", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
||||||
|
).task = item.ifc_definition_id
|
||||||
else:
|
else:
|
||||||
row.operator("bim.enable_editing_task_sequence", text="", icon="TRACKING").task = item.ifc_definition_id
|
|
||||||
row.operator(
|
row.operator(
|
||||||
"bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text=""
|
"bim.expand_task", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
||||||
).task = item.ifc_definition_id
|
).task = item.ifc_definition_id
|
||||||
row.operator("bim.enable_editing_task_time", text="", icon="TIME").task = item.ifc_definition_id
|
else:
|
||||||
row.operator(
|
row.label(text="", icon="DOT")
|
||||||
"bim.enable_editing_task_calendar", text="", icon="VIEW_ORTHO"
|
|
||||||
).task = item.ifc_definition_id
|
def draw_custom_columns(self, row, item, task):
|
||||||
row.operator("bim.enable_assigning_process_to_resources", text="", icon="COMMUNITY").task = item.ifc_definition_id
|
for column in self.props.columns:
|
||||||
row.operator("bim.enable_editing_task", text="", icon="GREASEPENCIL").task = item.ifc_definition_id
|
if column.name == "IfcTaskTime.ScheduleStart":
|
||||||
row.operator("bim.add_task", text="", icon="ADD").task = item.ifc_definition_id
|
if item.derived_start:
|
||||||
row.operator("bim.remove_task", text="", icon="X").task = item.ifc_definition_id
|
row.label(text=item.derived_start + "*")
|
||||||
|
else:
|
||||||
|
row.prop(item, "start", emboss=False, text="")
|
||||||
|
elif column.name == "IfcTaskTime.ScheduleFinish":
|
||||||
|
if item.derived_finish:
|
||||||
|
row.label(text=item.derived_finish + "*")
|
||||||
|
else:
|
||||||
|
row.prop(item, "finish", emboss=False, text="")
|
||||||
|
elif column.name == "IfcTaskTime.ScheduleDuration":
|
||||||
|
if item.derived_duration:
|
||||||
|
row.label(text=item.derived_duration + "*")
|
||||||
|
else:
|
||||||
|
row.prop(item, "duration", emboss=False, text="")
|
||||||
|
elif column.name == "Controls.Calendar":
|
||||||
|
if item.derived_calendar:
|
||||||
|
row.label(text=item.derived_calendar + "*")
|
||||||
|
else:
|
||||||
|
row.label(text=item.calendar or "-")
|
||||||
|
else:
|
||||||
|
ifc_class, name = column.name.split(".")
|
||||||
|
if ifc_class == "IfcTask":
|
||||||
|
value = getattr(task, name)
|
||||||
|
elif ifc_class == "IfcTaskTime":
|
||||||
|
value = getattr(task.TaskTime, name) if task.TaskTime else None
|
||||||
|
if value is None:
|
||||||
|
value = "-"
|
||||||
|
row.label(text=str(value))
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_work_calendars(Panel):
|
class BIM_PT_work_calendars(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user