mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Clean up UX to either edit a work schedule attributes or task tree but not both simultaneously
This commit is contained in:
@@ -9,11 +9,11 @@ classes = (
|
||||
operator.RemoveWorkPlan,
|
||||
operator.EnableEditingWorkPlan,
|
||||
operator.DisableEditingWorkPlan,
|
||||
operator.DisableWorkScheduleEditingUI,
|
||||
operator.AddWorkSchedule,
|
||||
operator.EditWorkSchedule,
|
||||
operator.RemoveWorkSchedule,
|
||||
operator.EnableEditingWorkSchedule,
|
||||
operator.EnableEditingTasks,
|
||||
operator.DisableEditingWorkSchedule,
|
||||
operator.LoadTasks,
|
||||
operator.DisableTaskEditingUI,
|
||||
|
||||
@@ -123,15 +123,6 @@ class DisableEditingWorkPlan(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DisableWorkScheduleEditingUI(bpy.types.Operator):
|
||||
bl_idname = "bim.disable_work_schedule_editing_ui"
|
||||
bl_label = "Disable WorkSchedule Editing UI"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMWorkScheduleProperties.is_editing = False
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddWorkSchedule(bpy.types.Operator):
|
||||
bl_idname = "bim.add_work_schedule"
|
||||
bl_label = "Add Work Schedule"
|
||||
@@ -192,7 +183,11 @@ class EnableEditingWorkSchedule(bpy.types.Operator):
|
||||
self.props.active_work_schedule_id = self.work_schedule
|
||||
while len(self.props.work_schedule_attributes) > 0:
|
||||
self.props.work_schedule_attributes.remove(0)
|
||||
self.enable_editing_work_schedule()
|
||||
self.props.is_editing = "WORK_SCHEDULE"
|
||||
return {"FINISHED"}
|
||||
|
||||
def enable_editing_work_schedule(self):
|
||||
data = Data.work_schedules[self.work_schedule]
|
||||
|
||||
for attribute in IfcStore.get_schema().declaration_by_name("IfcWorkSchedule").all_attributes():
|
||||
@@ -213,12 +208,22 @@ class EnableEditingWorkSchedule(bpy.types.Operator):
|
||||
if data[attribute.name()]:
|
||||
new.enum_value = data[attribute.name()]
|
||||
|
||||
|
||||
class EnableEditingTasks(bpy.types.Operator):
|
||||
bl_idname = "bim.enable_editing_tasks"
|
||||
bl_label = "Enable Editing Tasks"
|
||||
work_schedule: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.props = context.scene.BIMWorkScheduleProperties
|
||||
self.props.active_work_schedule_id = self.work_schedule
|
||||
while len(self.props.tasks) > 0:
|
||||
self.props.tasks.remove(0)
|
||||
|
||||
self.contracted_tasks = json.loads(self.props.contracted_tasks)
|
||||
for related_object_id in Data.work_schedules[self.work_schedule]["RelatedObjects"]:
|
||||
self.create_new_task_li(related_object_id, 0)
|
||||
self.props.is_editing = "TASKS"
|
||||
return {"FINISHED"}
|
||||
|
||||
def create_new_task_li(self, related_object_id, level_index):
|
||||
@@ -400,7 +405,7 @@ class AddTask(bpy.types.Operator):
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run("sequence.add_task", self.file, **{"parent_task": self.file.by_id(self.task)})
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_work_schedule(work_schedule=props.active_work_schedule_id)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -414,7 +419,7 @@ class AddSummaryTask(bpy.types.Operator):
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run("sequence.add_task", self.file, **{"work_schedule": self.file.by_id(self.work_schedule)})
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_work_schedule(work_schedule=props.active_work_schedule_id)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -430,7 +435,7 @@ class ExpandTask(bpy.types.Operator):
|
||||
contracted_tasks.remove(self.task)
|
||||
props.contracted_tasks = json.dumps(contracted_tasks)
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_work_schedule(work_schedule=props.active_work_schedule_id)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -446,7 +451,7 @@ class ContractTask(bpy.types.Operator):
|
||||
contracted_tasks.append(self.task)
|
||||
props.contracted_tasks = json.dumps(contracted_tasks)
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_work_schedule(work_schedule=props.active_work_schedule_id)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -464,7 +469,7 @@ class RemoveTask(bpy.types.Operator):
|
||||
task=IfcStore.get_file().by_id(self.task),
|
||||
)
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_work_schedule(work_schedule=props.active_work_schedule_id)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -539,5 +544,5 @@ class EditTask(bpy.types.Operator):
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
bpy.ops.bim.disable_editing_task()
|
||||
bpy.ops.bim.enable_editing_work_schedule(work_schedule=props.active_work_schedule_id)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -72,7 +72,7 @@ class BIMWorkPlanProperties(PropertyGroup):
|
||||
|
||||
class BIMWorkScheduleProperties(PropertyGroup):
|
||||
work_schedule_attributes: CollectionProperty(name="Work Schedule Attributes", type=Attribute)
|
||||
is_editing: BoolProperty(name="Is Editing", default=False)
|
||||
is_editing: StringProperty(name="Is Editing")
|
||||
active_work_schedule_index: IntProperty(name="Active Work Schedules Index")
|
||||
active_work_schedule_id: IntProperty(name="Active Work Schedules Id")
|
||||
tasks: CollectionProperty(name="Tasks", type=Task)
|
||||
|
||||
@@ -85,30 +85,35 @@ class BIM_PT_work_schedules(Panel):
|
||||
if not Data.is_loaded:
|
||||
Data.load(IfcStore.get_file())
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="{} Work Schedules Found".format(len(Data.work_schedules)), icon="TEXT")
|
||||
row = self.layout.row()
|
||||
row.operator("bim.add_work_schedule", icon="ADD")
|
||||
|
||||
for work_schedule_id, work_schedule in Data.work_schedules.items():
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=work_schedule["Name"] or "Unnamed", icon="LINENUMBERS_ON")
|
||||
self.draw_work_schedule_ui(work_schedule_id, work_schedule)
|
||||
|
||||
if self.props.active_work_schedule_id and self.props.active_work_schedule_id == work_schedule_id:
|
||||
def draw_work_schedule_ui(self, work_schedule_id, work_schedule):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=work_schedule["Name"] or "Unnamed", icon="TEXT")
|
||||
|
||||
if self.props.active_work_schedule_id and self.props.active_work_schedule_id == work_schedule_id:
|
||||
if self.props.is_editing == "WORK_SCHEDULE":
|
||||
row.operator("bim.edit_work_schedule", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_work_schedule", text="", icon="X")
|
||||
elif self.props.active_work_schedule_id:
|
||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id
|
||||
else:
|
||||
row.operator(
|
||||
"bim.enable_editing_work_schedule", text="", icon="GREASEPENCIL"
|
||||
).work_schedule = work_schedule_id
|
||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id
|
||||
row.operator("bim.disable_editing_work_schedule", text="", icon="CANCEL")
|
||||
elif self.props.active_work_schedule_id:
|
||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id
|
||||
else:
|
||||
row.operator("bim.enable_editing_tasks", text="", icon="ACTION").work_schedule = work_schedule_id
|
||||
op = row.operator("bim.enable_editing_work_schedule", text="", icon="GREASEPENCIL")
|
||||
op.work_schedule = work_schedule_id
|
||||
row.operator("bim.remove_work_schedule", text="", icon="X").work_schedule = work_schedule_id
|
||||
|
||||
if self.props.active_work_schedule_id == work_schedule_id:
|
||||
self.draw_editable_work_schedule_ui(work_schedule_id, work_schedule)
|
||||
if self.props.active_work_schedule_id == work_schedule_id:
|
||||
if self.props.is_editing == "WORK_SCHEDULE":
|
||||
self.draw_editable_work_schedule_ui()
|
||||
elif self.props.is_editing == "TASKS":
|
||||
self.draw_editable_task_ui(work_schedule_id)
|
||||
|
||||
def draw_editable_work_schedule_ui(self, work_schedule_id, work_schedule):
|
||||
def draw_editable_work_schedule_ui(self):
|
||||
for attribute in self.props.work_schedule_attributes:
|
||||
row = self.layout.row(align=True)
|
||||
if attribute.data_type == "string":
|
||||
@@ -118,6 +123,7 @@ class BIM_PT_work_schedules(Panel):
|
||||
if attribute.is_optional:
|
||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||
|
||||
def draw_editable_task_ui(self, work_schedule_id):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="X Summary Tasks")
|
||||
row.operator("bim.add_summary_task", text="", icon="ADD").work_schedule = work_schedule_id
|
||||
@@ -130,21 +136,18 @@ class BIM_PT_work_schedules(Panel):
|
||||
"active_task_index",
|
||||
)
|
||||
if self.props.active_task_id:
|
||||
self.draw_editable_task_ui()
|
||||
|
||||
def draw_editable_task_ui(self):
|
||||
for attribute in self.props.task_attributes:
|
||||
row = self.layout.row(align=True)
|
||||
if attribute.data_type == "string":
|
||||
row.prop(attribute, "string_value", text=attribute.name)
|
||||
elif attribute.data_type == "boolean":
|
||||
row.prop(attribute, "bool_value", text=attribute.name)
|
||||
elif attribute.data_type == "integer":
|
||||
row.prop(attribute, "int_value", text=attribute.name)
|
||||
elif attribute.data_type == "enum":
|
||||
row.prop(attribute, "enum_value", text=attribute.name)
|
||||
if attribute.is_optional:
|
||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||
for attribute in self.props.task_attributes:
|
||||
row = self.layout.row(align=True)
|
||||
if attribute.data_type == "string":
|
||||
row.prop(attribute, "string_value", text=attribute.name)
|
||||
elif attribute.data_type == "boolean":
|
||||
row.prop(attribute, "bool_value", text=attribute.name)
|
||||
elif attribute.data_type == "integer":
|
||||
row.prop(attribute, "int_value", text=attribute.name)
|
||||
elif attribute.data_type == "enum":
|
||||
row.prop(attribute, "enum_value", text=attribute.name)
|
||||
if attribute.is_optional:
|
||||
row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="")
|
||||
|
||||
|
||||
class BIM_UL_tasks(UIList):
|
||||
|
||||
Reference in New Issue
Block a user