diff --git a/Source/CeditQt/main_window.py b/Source/CeditQt/main_window.py index b8d71f7b2..269ee2d31 100644 --- a/Source/CeditQt/main_window.py +++ b/Source/CeditQt/main_window.py @@ -768,13 +768,13 @@ def refresh_reference_lists(self, *_args): target_ids = self.current_target_ids() self.compartments_tab.set_material_ids(material_ids) - self.wall_vents_tab.set_compartment_ids(compartment_ids) + self.wall_vents_tab.set_compartments(self.compartments_tab.compartments) self.wall_vents_tab.set_target_ids(target_ids) self.ceiling_floor_vents_tab.set_compartments(self.compartments_tab.compartments) self.ceiling_floor_vents_tab.set_target_ids(target_ids) self.mechanical_vents_tab.set_compartments(self.compartments_tab.compartments) self.mechanical_vents_tab.set_target_ids(target_ids) - self.fires_tab.set_compartment_ids(compartment_ids) + self.fires_tab.set_compartments(self.compartments_tab.compartments) self.fires_tab.set_target_ids(target_ids) self.targets_tab.set_compartment_ids(compartment_ids) self.targets_tab.set_material_ids(material_ids) diff --git a/Source/CeditQt/tabs/fires_tab.py b/Source/CeditQt/tabs/fires_tab.py index 49bb7aff5..c3c540bae 100644 --- a/Source/CeditQt/tabs/fires_tab.py +++ b/Source/CeditQt/tabs/fires_tab.py @@ -29,7 +29,7 @@ from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure -from cfast_case import CfastCase, FireDefinition, FireProperty, FireRampPoint +from cfast_case import CfastCase, Compartment, FireDefinition, FireProperty, FireRampPoint from table_widgets import HoverEditTableWidget from units import ( AREA, @@ -300,6 +300,7 @@ def __init__(self, parent=None): self.fires: list[FireDefinition] = [] self.fire_properties: list[FireProperty] = [] self.compartment_ids: list[str] = [] + self.compartment_sizes: dict[str, tuple[float, float]] = {} self.target_ids: list[str] = [] self.summary_table = HoverEditTableWidget(0, 11) @@ -625,6 +626,10 @@ def update_compartment_choices(self): self.compartment_combo.setEditText("") self.compartment_combo.blockSignals(False) + def set_compartments(self, compartments: list[Compartment]): + self.compartment_sizes = {comp.id: (comp.width, comp.depth) for comp in compartments if comp.id} + self.set_compartment_ids([comp.id for comp in compartments]) + def set_compartment_ids(self, compartment_ids: list[str]): self.compartment_ids = [comp_id for comp_id in compartment_ids if comp_id] self.update_compartment_choices() @@ -1095,6 +1100,7 @@ def update_plot(self): def add_new_fire(self): self.save_current_editor() + width, depth = self.compartment_sizes.get(self.default_compartment(), (0.0, 0.0)) number = len(self.fires) + 1 fire_id = f"Fire_{number}" prop_id = f"{fire_id}_Fire" @@ -1116,8 +1122,8 @@ def add_new_fire(self): fire_property_id=prop_id, ignition_criterion="TIME", setpoint=0.0, - x_position=2.5, - y_position=2.5, + x_position=width / 2.0, + y_position=depth / 2.0, ) self.fire_properties.append(prop) self.fires.append(fire) @@ -1126,6 +1132,7 @@ def add_new_fire(self): def add_t_squared_fire(self): self.save_current_editor() + width, depth = self.compartment_sizes.get(self.default_compartment(), (0.0, 0.0)) number = len(self.fires) + 1 fire_id = f"T2_Fire_{number}" prop_id = f"{fire_id}_Fire" @@ -1151,8 +1158,8 @@ def add_t_squared_fire(self): fire_property_id=prop_id, ignition_criterion="TIME", setpoint=0.0, - x_position=2.5, - y_position=2.5, + x_position=width / 2.0, + y_position=depth / 2.0, ) self.fire_properties.append(prop) self.fires.append(fire) diff --git a/Source/CeditQt/tabs/output_tab.py b/Source/CeditQt/tabs/output_tab.py index 7c980b1c4..aee9c95af 100644 --- a/Source/CeditQt/tabs/output_tab.py +++ b/Source/CeditQt/tabs/output_tab.py @@ -552,7 +552,11 @@ def first_empty_row(self, table: QTableWidget) -> int: def add_visualization(self): row = self.first_empty_row(self.visual_table) self.updating = True - values = ["", "2-D", "All", "X-Axis", format_value(LENGTH, 0.0)] + compartment = self.compartments[0] if self.compartments else None + values = [ + "", "2-D", compartment.id if compartment else "All", "X-Axis", + format_value(LENGTH, compartment.width / 2.0 if compartment else 0.0), + ] for col, value in enumerate(values): self.set_cell_text(self.visual_table, row, col, value, editable=(col != 0)) self.updating = False diff --git a/Source/CeditQt/tabs/wall_vents_tab.py b/Source/CeditQt/tabs/wall_vents_tab.py index 56fe40d04..22d388063 100644 --- a/Source/CeditQt/tabs/wall_vents_tab.py +++ b/Source/CeditQt/tabs/wall_vents_tab.py @@ -18,7 +18,7 @@ QWidget, ) -from cfast_case import CfastCase, WallVent +from cfast_case import CfastCase, Compartment, WallVent from table_widgets import HoverEditTableWidget from units import LENGTH, TIME, format_number, format_value, parse_number, parse_value, unit_label @@ -59,6 +59,7 @@ def __init__(self, parent=None): self.records: list[dict] = [] self.loading = False self.compartment_ids: list[str] = [] + self.compartment_sizes: dict[str, tuple[float, float]] = {} self.target_ids: list[str] = [] self.summary_table = HoverEditTableWidget(0, 9) @@ -298,15 +299,17 @@ def connect_editor_signals(self): self.schedule_table.cellChanged.connect(self.update_current_record) def make_default_record(self, index: int) -> dict: + wall_width, wall_height = self.compartment_sizes.get(self.default_first_compartment(), (1.0, 2.0)) + width, height = min(1.0, wall_width), min(2.0, wall_height) return { "id": f"WallVent_{index}", "first_compartment": self.default_first_compartment(), "second_compartment": "Outside", - "bottom": format_value(LENGTH, 0.0), - "height": format_value(LENGTH, 2.0), - "width": format_value(LENGTH, 1.0), + "bottom": format_value(LENGTH, (wall_height - height) / 2.0), + "height": format_value(LENGTH, height), + "width": format_value(LENGTH, width), "face": "Front", - "offset": format_value(LENGTH, 2.0), + "offset": format_value(LENGTH, (wall_width - width) / 2.0), "criterion": "Time", "setpoint": "0", "target": "", @@ -484,6 +487,10 @@ def set_combo_text(self, combo: QComboBox, text: str): else: combo.setEditText(text) + def set_compartments(self, compartments: list[Compartment]): + self.compartment_sizes = {comp.id: (comp.width, comp.height) for comp in compartments if comp.id} + self.set_compartment_ids([comp.id for comp in compartments]) + def set_compartment_ids(self, compartment_ids: list[str]): self.compartment_ids = [comp_id for comp_id in compartment_ids if comp_id] choices = ["Outside"] + self.compartment_ids