mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 03:33:48 +00:00
Fix contracting/expanding cost schedule tree and add tests to avoid proof changes
This commit is contained in:
@@ -20,64 +20,65 @@ import bpy
|
|||||||
from . import ui, prop, operator
|
from . import ui, prop, operator
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
operator.AddCostColumn,
|
||||||
|
operator.AddCostItem,
|
||||||
|
operator.AddCostItemQuantity,
|
||||||
operator.AddCostSchedule,
|
operator.AddCostSchedule,
|
||||||
operator.RemoveCostSchedule,
|
operator.AddCostValue,
|
||||||
operator.EditCostSchedule,
|
operator.AddCurrency,
|
||||||
|
operator.AddSummaryCostItem,
|
||||||
|
operator.AssignCostItemQuantity,
|
||||||
|
operator.AssignCostItemType,
|
||||||
|
operator.AssignCostValue,
|
||||||
|
operator.CalculateCostItemResourceValue,
|
||||||
|
operator.ChangeParentCostItem,
|
||||||
|
operator.ClearCostItemAssignments,
|
||||||
|
operator.ContractCostItem,
|
||||||
|
operator.ContractCostItemRate,
|
||||||
|
operator.ContractCostItems,
|
||||||
|
operator.CopyCostItem,
|
||||||
|
operator.CopyCostItemValues,
|
||||||
|
operator.DisableEditingCostItem,
|
||||||
|
operator.DisableEditingCostItemQuantity,
|
||||||
|
operator.DisableEditingCostItemValue,
|
||||||
|
operator.DisableEditingCostSchedule,
|
||||||
operator.EditCostItem,
|
operator.EditCostItem,
|
||||||
operator.EditCostItemQuantity,
|
operator.EditCostItemQuantity,
|
||||||
operator.EditCostItemValue,
|
operator.EditCostItemValue,
|
||||||
operator.EditCostItemValueFormula,
|
operator.EditCostItemValueFormula,
|
||||||
operator.EnableEditingCostSchedule,
|
operator.EditCostSchedule,
|
||||||
operator.EnableEditingCostItems,
|
|
||||||
operator.EnableEditingCostItem,
|
operator.EnableEditingCostItem,
|
||||||
operator.ExportCostSchedules,
|
|
||||||
operator.ExpandCostItems,
|
|
||||||
operator.EnableEditingCostItemQuantities,
|
operator.EnableEditingCostItemQuantities,
|
||||||
operator.EnableEditingCostItemQuantity,
|
operator.EnableEditingCostItemQuantity,
|
||||||
operator.EnableEditingCostItemValues,
|
operator.EnableEditingCostItems,
|
||||||
operator.EnableEditingCostItemValue,
|
operator.EnableEditingCostItemValue,
|
||||||
operator.EnableEditingCostItemValueFormula,
|
operator.EnableEditingCostItemValueFormula,
|
||||||
operator.DisableEditingCostItem,
|
operator.EnableEditingCostItemValues,
|
||||||
operator.DisableEditingCostSchedule,
|
operator.EnableEditingCostSchedule,
|
||||||
operator.DisableEditingCostItemQuantity,
|
|
||||||
operator.DisableEditingCostItemValue,
|
|
||||||
operator.AddCostColumn,
|
|
||||||
operator.RemoveCostColumn,
|
|
||||||
operator.AddCostItem,
|
|
||||||
operator.AddSummaryCostItem,
|
|
||||||
operator.ExpandCostItem,
|
operator.ExpandCostItem,
|
||||||
operator.ContractCostItem,
|
operator.ExpandCostItemRate,
|
||||||
|
operator.ExpandCostItems,
|
||||||
|
operator.ExportCostSchedules,
|
||||||
|
operator.HighlightProductCostItem,
|
||||||
|
operator.ImportCostScheduleCsv,
|
||||||
|
operator.LoadCostItemElementQuantities,
|
||||||
|
operator.LoadCostItemQuantities,
|
||||||
|
operator.LoadCostItemResourceQuantities,
|
||||||
|
operator.LoadCostItemTaskQuantities,
|
||||||
|
operator.LoadCostItemTypes,
|
||||||
|
operator.LoadProductCostItems,
|
||||||
|
operator.LoadScheduleOfRates,
|
||||||
|
operator.RemoveCostColumn,
|
||||||
operator.RemoveCostItem,
|
operator.RemoveCostItem,
|
||||||
operator.AssignCostItemType,
|
|
||||||
operator.UnassignCostItemType,
|
|
||||||
operator.AssignCostItemQuantity,
|
|
||||||
operator.UnassignCostItemQuantity,
|
|
||||||
operator.AddCostItemQuantity,
|
|
||||||
operator.RemoveCostItemQuantity,
|
operator.RemoveCostItemQuantity,
|
||||||
operator.AddCostValue,
|
|
||||||
operator.RemoveCostItemValue,
|
operator.RemoveCostItemValue,
|
||||||
operator.CopyCostItemValues,
|
operator.RemoveCostSchedule,
|
||||||
|
operator.ReorderCostItem,
|
||||||
operator.SelectCostItemProducts,
|
operator.SelectCostItemProducts,
|
||||||
operator.SelectCostScheduleProducts,
|
operator.SelectCostScheduleProducts,
|
||||||
operator.ImportCostScheduleCsv,
|
|
||||||
operator.LoadCostItemQuantities,
|
|
||||||
operator.LoadCostItemTypes,
|
|
||||||
operator.AssignCostValue,
|
|
||||||
operator.LoadScheduleOfRates,
|
|
||||||
operator.ExpandCostItemRate,
|
|
||||||
operator.ContractCostItemRate,
|
|
||||||
operator.CalculateCostItemResourceValue,
|
|
||||||
operator.ClearCostItemAssignments,
|
|
||||||
operator.HighlightProductCostItem,
|
|
||||||
operator.LoadProductCostItems,
|
|
||||||
operator.ReorderCostItem,
|
|
||||||
operator.SelectUnassignedProducts,
|
operator.SelectUnassignedProducts,
|
||||||
operator.LoadCostItemElementQuantities,
|
operator.UnassignCostItemQuantity,
|
||||||
operator.LoadCostItemTaskQuantities,
|
operator.UnassignCostItemType,
|
||||||
operator.LoadCostItemResourceQuantities,
|
|
||||||
operator.ChangeParentCostItem,
|
|
||||||
operator.CopyCostItem,
|
|
||||||
operator.AddCurrency,
|
|
||||||
prop.CostItem,
|
prop.CostItem,
|
||||||
prop.CostItemQuantity,
|
prop.CostItemQuantity,
|
||||||
prop.CostItemType,
|
prop.CostItemType,
|
||||||
|
|||||||
@@ -156,6 +156,17 @@ class ContractCostItem(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
core.contract_cost_item(tool.Cost, cost_item=tool.Ifc.get().by_id(self.cost_item))
|
core.contract_cost_item(tool.Cost, cost_item=tool.Ifc.get().by_id(self.cost_item))
|
||||||
|
|
||||||
|
|
||||||
|
class ContractCostItems(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
|
bl_idname = "bim.contract_cost_items"
|
||||||
|
bl_label = "Contract Cost Item"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
bl_description = "Collapse cost item tree"
|
||||||
|
cost_item: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
core.contract_cost_items(tool.Cost)
|
||||||
|
|
||||||
|
|
||||||
class RemoveCostItem(bpy.types.Operator, tool.Ifc.Operator):
|
class RemoveCostItem(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.remove_cost_item"
|
bl_idname = "bim.remove_cost_item"
|
||||||
bl_label = "Remove Cost Item"
|
bl_label = "Remove Cost Item"
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ class BIM_PT_cost_schedules(Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.alignment = "RIGHT"
|
row.alignment = "RIGHT"
|
||||||
row.operator("bim.add_summary_cost_item", text="Add Summary Cost", icon="ADD")
|
row.operator("bim.add_summary_cost_item", text="Add Summary Cost", icon="ADD")
|
||||||
row.operator("bim.expand_all_tasks", text="Expand All")
|
row.operator("bim.expand_cost_items", text="Expand All")
|
||||||
row.operator("bim.contract_all_tasks", text="Contract All")
|
row.operator("bim.contract_cost_items", text="Contract All")
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.alignment = "RIGHT"
|
row.alignment = "RIGHT"
|
||||||
if self.props.cost_items and self.props.active_cost_item_index < len(self.props.cost_items):
|
if self.props.cost_items and self.props.active_cost_item_index < len(self.props.cost_items):
|
||||||
|
|||||||
@@ -96,11 +96,11 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
props.contracted_cost_items = json.dumps(cls.contracted_cost_items)
|
props.contracted_cost_items = json.dumps(cls.contracted_cost_items)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def contract_cost_item(cls, cost_item_id):
|
def contract_cost_item(cls, cost_item):
|
||||||
props = bpy.context.scene.BIMCostProperties
|
props = bpy.context.scene.BIMCostProperties
|
||||||
if not hasattr(cls, "contracted_cost_items"):
|
if not hasattr(cls, "contracted_cost_items"):
|
||||||
cls.contracted_cost_items = json.loads(props.contracted_cost_items)
|
cls.contracted_cost_items = json.loads(props.contracted_cost_items)
|
||||||
cls.contracted_cost_items.append(cost_item_id)
|
cls.contracted_cost_items.append(cost_item.id())
|
||||||
props.contracted_cost_items = json.dumps(cls.contracted_cost_items)
|
props.contracted_cost_items = json.dumps(cls.contracted_cost_items)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Feature: Cost
|
|||||||
|
|
||||||
Scenario: Add cost schedule
|
Scenario: Add cost schedule
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
|
And I set "scene.BIMCostProperties.cost_schedule_predefined_types" to "COSTPLAN"
|
||||||
When I press "bim.add_cost_schedule"
|
When I press "bim.add_cost_schedule"
|
||||||
Then nothing happens
|
Then nothing happens
|
||||||
|
|
||||||
@@ -111,6 +112,53 @@ Scenario: Add cost item
|
|||||||
When I press "bim.add_cost_item(cost_item={cost_item})"
|
When I press "bim.add_cost_item(cost_item={cost_item})"
|
||||||
Then nothing happens
|
Then nothing happens
|
||||||
|
|
||||||
|
Scenario: Contract Cost Item
|
||||||
|
Given an empty IFC project
|
||||||
|
And I set "scene.BIMCostProperties.cost_schedule_predefined_types" to "COSTPLAN"
|
||||||
|
And I press "bim.add_cost_schedule"
|
||||||
|
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||||
|
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||||
|
And I press "bim.add_summary_cost_item()"
|
||||||
|
And I press "bim.add_cost_item(cost_item={cost_item})"
|
||||||
|
When I press "bim.contract_cost_item(cost_item={cost_item})"
|
||||||
|
Then nothing happens
|
||||||
|
|
||||||
|
Scenario: Contract All Cost Items
|
||||||
|
Given an empty IFC project
|
||||||
|
And I set "scene.BIMCostProperties.cost_schedule_predefined_types" to "COSTPLAN"
|
||||||
|
And I press "bim.add_cost_schedule"
|
||||||
|
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||||
|
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||||
|
And I press "bim.add_summary_cost_item()"
|
||||||
|
And I press "bim.add_cost_item(cost_item={cost_item})"
|
||||||
|
When I press "bim.contract_cost_items"
|
||||||
|
Then nothing happens
|
||||||
|
|
||||||
|
Scenario: Expand Cost Item
|
||||||
|
Given an empty IFC project
|
||||||
|
And I set "scene.BIMCostProperties.cost_schedule_predefined_types" to "COSTPLAN"
|
||||||
|
And I press "bim.add_cost_schedule"
|
||||||
|
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||||
|
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||||
|
And I press "bim.add_summary_cost_item()"
|
||||||
|
And I press "bim.add_cost_item(cost_item={cost_item})"
|
||||||
|
And I press "bim.contract_cost_item(cost_item={cost_item})"
|
||||||
|
When I press "bim.expand_cost_item(cost_item={cost_item})"
|
||||||
|
Then nothing happens
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Expand All Cost Items
|
||||||
|
Given an empty IFC project
|
||||||
|
And I set "scene.BIMCostProperties.cost_schedule_predefined_types" to "COSTPLAN"
|
||||||
|
And I press "bim.add_cost_schedule"
|
||||||
|
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||||
|
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||||
|
And I press "bim.add_summary_cost_item()"
|
||||||
|
And I press "bim.add_cost_item(cost_item={cost_item})"
|
||||||
|
When I press "bim.expand_cost_items"
|
||||||
|
Then nothing happens
|
||||||
|
|
||||||
|
|
||||||
Scenario: Enable editing cost item quantities
|
Scenario: Enable editing cost item quantities
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
And I press "bim.add_cost_schedule"
|
And I press "bim.add_cost_schedule"
|
||||||
|
|||||||
Reference in New Issue
Block a user