Spaces:
Sleeping
Sleeping
Update app/components.py
Browse files- app/components.py +57 -23
app/components.py
CHANGED
|
@@ -212,30 +212,42 @@ def display_component_tab(comp_type: str):
|
|
| 212 |
|
| 213 |
# Construction or fenestration selection
|
| 214 |
if comp_type in ["walls", "roofs", "floors"]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
construction = st.selectbox(
|
| 216 |
"Construction",
|
| 217 |
-
|
| 218 |
-
index=
|
| 219 |
help="Select the construction assembly for this component."
|
| 220 |
)
|
| 221 |
else: # Windows, doors, skylights
|
| 222 |
# For fenestrations, we need to select a parent component
|
| 223 |
parent_components = get_parent_components(comp_type)
|
| 224 |
|
| 225 |
-
|
|
|
|
| 226 |
st.error(f"No parent components available. Please create walls/roofs first.")
|
|
|
|
| 227 |
|
| 228 |
parent_component = st.selectbox(
|
| 229 |
"Parent Component",
|
| 230 |
-
|
| 231 |
-
index=
|
| 232 |
help="Select the wall or roof component this fenestration belongs to."
|
| 233 |
)
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
fenestration = st.selectbox(
|
| 236 |
"Fenestration",
|
| 237 |
-
|
| 238 |
-
index=
|
| 239 |
help="Select the fenestration type for this component."
|
| 240 |
)
|
| 241 |
|
|
@@ -268,18 +280,29 @@ def display_component_tab(comp_type: str):
|
|
| 268 |
|
| 269 |
if comp_type in ["walls", "roofs", "floors"]:
|
| 270 |
component_data["construction"] = construction
|
| 271 |
-
# Get U-value from construction
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
| 273 |
else:
|
| 274 |
component_data["fenestration"] = fenestration
|
| 275 |
component_data["parent_component"] = parent_component
|
| 276 |
-
# Get U-value and other properties from fenestration
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
else:
|
| 281 |
-
component_data["
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
# Handle edit mode
|
| 285 |
if is_edit:
|
|
@@ -513,10 +536,16 @@ def get_available_constructions() -> Dict[str, Any]:
|
|
| 513 |
"""
|
| 514 |
available_constructions = {}
|
| 515 |
|
| 516 |
-
# Add constructions
|
| 517 |
if "constructions" in st.session_state.project_data:
|
| 518 |
-
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
|
| 521 |
return available_constructions
|
| 522 |
|
|
@@ -529,11 +558,16 @@ def get_available_fenestrations() -> Dict[str, Any]:
|
|
| 529 |
"""
|
| 530 |
available_fenestrations = {}
|
| 531 |
|
| 532 |
-
# Add fenestrations
|
| 533 |
-
if "
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
available_fenestrations[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
|
| 538 |
return available_fenestrations
|
| 539 |
|
|
|
|
| 212 |
|
| 213 |
# Construction or fenestration selection
|
| 214 |
if comp_type in ["walls", "roofs", "floors"]:
|
| 215 |
+
construction_options = list(available_items.keys())
|
| 216 |
+
if not construction_options:
|
| 217 |
+
st.error("No constructions available. Please create constructions first.")
|
| 218 |
+
construction_options = [""]
|
| 219 |
+
|
| 220 |
construction = st.selectbox(
|
| 221 |
"Construction",
|
| 222 |
+
construction_options,
|
| 223 |
+
index=construction_options.index(editor_state.get("construction", "")) if editor_state.get("construction", "") in construction_options else 0,
|
| 224 |
help="Select the construction assembly for this component."
|
| 225 |
)
|
| 226 |
else: # Windows, doors, skylights
|
| 227 |
# For fenestrations, we need to select a parent component
|
| 228 |
parent_components = get_parent_components(comp_type)
|
| 229 |
|
| 230 |
+
parent_options = list(parent_components.keys())
|
| 231 |
+
if not parent_options:
|
| 232 |
st.error(f"No parent components available. Please create walls/roofs first.")
|
| 233 |
+
parent_options = [""]
|
| 234 |
|
| 235 |
parent_component = st.selectbox(
|
| 236 |
"Parent Component",
|
| 237 |
+
parent_options,
|
| 238 |
+
index=parent_options.index(editor_state.get("parent_component", "")) if editor_state.get("parent_component", "") in parent_options else 0,
|
| 239 |
help="Select the wall or roof component this fenestration belongs to."
|
| 240 |
)
|
| 241 |
|
| 242 |
+
fenestration_options = list(available_items.keys())
|
| 243 |
+
if not fenestration_options:
|
| 244 |
+
st.error("No fenestrations available. Please create fenestrations first.")
|
| 245 |
+
fenestration_options = [""]
|
| 246 |
+
|
| 247 |
fenestration = st.selectbox(
|
| 248 |
"Fenestration",
|
| 249 |
+
fenestration_options,
|
| 250 |
+
index=fenestration_options.index(editor_state.get("fenestration", "")) if editor_state.get("fenestration", "") in fenestration_options else 0,
|
| 251 |
help="Select the fenestration type for this component."
|
| 252 |
)
|
| 253 |
|
|
|
|
| 280 |
|
| 281 |
if comp_type in ["walls", "roofs", "floors"]:
|
| 282 |
component_data["construction"] = construction
|
| 283 |
+
# Get U-value from construction if available
|
| 284 |
+
if construction in available_items:
|
| 285 |
+
component_data["u_value"] = available_items[construction].get("u_value", 0.0)
|
| 286 |
+
else:
|
| 287 |
+
component_data["u_value"] = 0.0
|
| 288 |
else:
|
| 289 |
component_data["fenestration"] = fenestration
|
| 290 |
component_data["parent_component"] = parent_component
|
| 291 |
+
# Get U-value and other properties from fenestration if available
|
| 292 |
+
if fenestration in available_items:
|
| 293 |
+
component_data["u_value"] = available_items[fenestration].get("u_value", 0.0)
|
| 294 |
+
if comp_type == "doors":
|
| 295 |
+
component_data["solar_absorptivity"] = available_items[fenestration].get("solar_absorptivity", 0.7)
|
| 296 |
+
else:
|
| 297 |
+
component_data["shgc"] = available_items[fenestration].get("shgc", 0.7)
|
| 298 |
+
component_data["visible_transmittance"] = available_items[fenestration].get("visible_transmittance", 0.7)
|
| 299 |
else:
|
| 300 |
+
component_data["u_value"] = 0.0
|
| 301 |
+
if comp_type == "doors":
|
| 302 |
+
component_data["solar_absorptivity"] = 0.7
|
| 303 |
+
else:
|
| 304 |
+
component_data["shgc"] = 0.7
|
| 305 |
+
component_data["visible_transmittance"] = 0.7
|
| 306 |
|
| 307 |
# Handle edit mode
|
| 308 |
if is_edit:
|
|
|
|
| 536 |
"""
|
| 537 |
available_constructions = {}
|
| 538 |
|
| 539 |
+
# Add library constructions
|
| 540 |
if "constructions" in st.session_state.project_data:
|
| 541 |
+
if "library" in st.session_state.project_data["constructions"]:
|
| 542 |
+
for name, construction in st.session_state.project_data["constructions"]["library"].items():
|
| 543 |
+
available_constructions[name] = construction
|
| 544 |
+
|
| 545 |
+
# Add project constructions
|
| 546 |
+
if "project" in st.session_state.project_data["constructions"]:
|
| 547 |
+
for name, construction in st.session_state.project_data["constructions"]["project"].items():
|
| 548 |
+
available_constructions[name] = construction
|
| 549 |
|
| 550 |
return available_constructions
|
| 551 |
|
|
|
|
| 558 |
"""
|
| 559 |
available_fenestrations = {}
|
| 560 |
|
| 561 |
+
# Add library fenestrations
|
| 562 |
+
if "fenestrations" in st.session_state.project_data:
|
| 563 |
+
if "library" in st.session_state.project_data["fenestrations"]:
|
| 564 |
+
for name, fenestration in st.session_state.project_data["fenestrations"]["library"].items():
|
| 565 |
+
available_fenestrations[name] = fenestration
|
| 566 |
+
|
| 567 |
+
# Add project fenestrations
|
| 568 |
+
if "project" in st.session_state.project_data["fenestrations"]:
|
| 569 |
+
for name, fenestration in st.session_state.project_data["fenestrations"]["project"].items():
|
| 570 |
+
available_fenestrations[name] = fenestration
|
| 571 |
|
| 572 |
return available_fenestrations
|
| 573 |
|