clean up Resource UI using column layout

This commit is contained in:
Sigma Dimensions (Yass)
2023-08-23 21:15:59 +01:00
parent 5d85390715
commit 4e31a87c20
@@ -80,7 +80,7 @@ class BIM_PT_resources(Panel):
row = self.layout.row(align=True) row = self.layout.row(align=True)
row.alignment = "RIGHT" row.alignment = "RIGHT"
row.prop(self.props, "should_show_resource_tools", icon="RECOVER_LAST") row.prop(self.props, "should_show_resource_tools", text="Resource Tools",icon="RECOVER_LAST")
if self.props.should_show_resource_tools: if self.props.should_show_resource_tools:
total_resources = len(self.tprops.resources) total_resources = len(self.tprops.resources)
if not total_resources or self.props.active_resource_index >= total_resources: if not total_resources or self.props.active_resource_index >= total_resources:
@@ -109,43 +109,44 @@ class BIM_PT_resources(Panel):
and metric["reference"] == "Usage.ScheduleWork" and metric["reference"] == "Usage.ScheduleWork"
): ):
is_work_locked = True is_work_locked = True
row = self.layout.row() grid = self.layout.grid_flow(columns=3, even_columns=False, even_rows=False, align=False)
row.label(text="Resource Work")
schedule_work = "Schedule Work: {}".format(resource.get("ScheduleWork")) col1 = grid.column(align=True)
row = self.layout.row() col2 = grid.column(align=False)
row.alignment = "LEFT" col3 = grid.column(align=True)
row.label(text="Schedule Usage:") col1.ui_units_x = 1
row.prop(self.tprops.resources[self.props.active_resource_index], "schedule_usage", text="") col2.ui_units_x = 1
row2 = self.layout.row() col3.ui_units_x = 2
row2.alignment = "LEFT"
row2.label(text=schedule_work, icon="ARMATURE_DATA") row1_col1 = col1.row()
if not is_usage_locked: row1_col1.label(text="Schedule Work")
op = row.operator("bim.add_usage_constraint", text="", icon="UNLOCKED") row1col2 = col2.row()
op.resource = ifc_definition_id row1col2.label(text=resource.get("ScheduleWork", "-"), icon="TIME")
op.attribute = "Usage.ScheduleUsage"
else: row1col3 = col3.row()
op = row.operator("bim.remove_usage_constraint", text="", icon="LOCKED") row1col3.operator("bim.calculate_resource_work", text="", icon="TEMP").resource = ifc_definition_id
op.resource = ifc_definition_id op = row1col3.operator(
op.attribute = "Usage.ScheduleUsage" "bim.add_usage_constraint" if not is_work_locked else "bim.remove_usage_constraint",
if not is_work_locked: text="",
op = row2.operator("bim.add_usage_constraint", text="", icon="UNLOCKED") icon="LOCKED" if is_work_locked else "UNLOCKED",
op.resource = ifc_definition_id )
op.attribute = "Usage.ScheduleWork" op.resource = ifc_definition_id
else: op.attribute = "Usage.ScheduleWork"
op = row2.operator("bim.remove_usage_constraint", text="", icon="LOCKED") row2_col1 = col1.row()
op.resource = ifc_definition_id row2_col1.label(text="Schedule Usage")
op.attribute = "Usage.ScheduleWork" row2col2 = col2.row()
row2col2.prop(self.tprops.resources[self.props.active_resource_index], "schedule_usage", text="")
row2col3 = col3.row()
op = row2col3.operator(
"bim.add_usage_constraint" if not is_usage_locked else "bim.remove_usage_constraint",
text="",
icon="LOCKED" if is_usage_locked else "UNLOCKED",
)
op.resource = ifc_definition_id
op.attribute = "Usage.ScheduleUsage"
productivity = resource["Productivity"] productivity = resource["Productivity"]
parent_productivity = resource["InheritedProductivity"] parent_productivity = resource["InheritedProductivity"]
row = self.layout.row()
row.operator(
"bim.calculate_resource_work", text="Calculate Work", icon="TEMP"
).resource = ifc_definition_id
row = self.layout.row()
row.label(text="Productivity")
row = self.layout.row() row = self.layout.row()
if productivity: if productivity:
produtivitiy_rate_message = "Current Productivity Rate: {} {} / {}".format( produtivitiy_rate_message = "Current Productivity Rate: {} {} / {}".format(
@@ -162,24 +163,30 @@ class BIM_PT_resources(Panel):
parent_productivity["TimeConsumed"], parent_productivity["TimeConsumed"],
) )
row.alignment = "LEFT" row.alignment = "LEFT"
row.label(text=produtivitiy_rate_message, icon="ARMATURE_DATA") row.label(text="Productivity: {}".format(produtivitiy_rate_message), icon="ARMATURE_DATA")
else: else:
row = self.layout.row(align=True) row = self.layout.row(align=True)
row.alignment = "LEFT" row.alignment = "LEFT"
produtivitiy_rate_message = "No productivity data found" produtivitiy_rate_message = "No productivity data found"
row.label(text=produtivitiy_rate_message, icon="ARMATURE_DATA") row.label(text="Productivity: {}".format(produtivitiy_rate_message), icon="ARMATURE_DATA")
productivity_props = context.scene.BIMResourceProductivity productivity_props = context.scene.BIMResourceProductivity
row = self.layout.row(align=True) grid = self.layout.grid_flow(columns=2, even_columns=False, even_rows=False, align=False)
row.alignment = "RIGHT" col1 = grid.column(align=False)
row.prop(productivity_props, "quantity_produced", text="Quantity Produced") col2 = grid.column(align=False)
row.prop(productivity_props, "quantity_produced_name", text="Quantity Name") col1.ui_units_x = 1
row = self.layout.row() col2.ui_units_x = 3
row.alignment = "RIGHT" row1_col1 = col1.row()
self.draw_duration_property(productivity_props.quantity_consumed, row) row1_col1.label(text="Quantity")
row = self.layout.row() row1_col2 = col2.row()
row.alignment = "RIGHT" row1_col2.prop(productivity_props, "quantity_produced", text="")
row.operator("bim.edit_productivity_data", text="Apply", icon="CHECKMARK") row1_col2.prop(productivity_props, "quantity_produced_name", text="")
row2_col1 = col1.row()
row2_col1.label(text="Time")
row2_col2 = col2.row()
self.draw_duration_property(productivity_props.quantity_consumed, row2_col2)
row3_col2 = col2.row()
row3_col2.alignment = "RIGHT"
row3_col2.operator("bim.edit_productivity_data", text="", icon="CHECKMARK")
def draw_resource_operators(self): def draw_resource_operators(self):
row = self.layout.row(align=True) row = self.layout.row(align=True)
@@ -311,7 +318,6 @@ class BIM_PT_resources(Panel):
def draw_duration_property(self, duration_props, layout): def draw_duration_property(self, duration_props, layout):
for duration_prop in duration_props: for duration_prop in duration_props:
if duration_prop.name == "BaseQuantityConsumed": if duration_prop.name == "BaseQuantityConsumed":
layout.label(text=duration_prop.name)
layout.prop(duration_prop, "years", text="Y") layout.prop(duration_prop, "years", text="Y")
layout.prop(duration_prop, "months", text="M") layout.prop(duration_prop, "months", text="M")
layout.prop(duration_prop, "days", text="D") layout.prop(duration_prop, "days", text="D")