mabuseif commited on
Commit
9f07b4c
·
verified ·
1 Parent(s): d00cdea

Update app/intro.py

Browse files
Files changed (1) hide show
  1. app/intro.py +13 -5
app/intro.py CHANGED
@@ -16,6 +16,7 @@ import io
16
  import logging
17
  from datetime import datetime
18
  from typing import Dict, Any, Optional
 
19
 
20
  # Configure logging
21
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -143,7 +144,7 @@ def display_project_management_section():
143
  st.warning("Please enter a project name in the Building Information section before exporting.")
144
 
145
  def start_new_project():
146
- """Initialize a new project by resetting the project_data in session state."""
147
  # Keep a backup of the current project data in case user wants to recover
148
  if 'project_data_backup' not in st.session_state:
149
  st.session_state.project_data_backup = {}
@@ -153,6 +154,13 @@ def start_new_project():
153
  backup_timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
154
  st.session_state.project_data_backup[backup_timestamp] = st.session_state.project_data.copy()
155
 
 
 
 
 
 
 
 
156
  # Reset project data to match main.py structure
157
  st.session_state.project_data = {
158
  "project_name": "",
@@ -209,15 +217,15 @@ def start_new_project():
209
  "ground_reflectivity": 0.2
210
  },
211
  "materials": {
212
- "library": {},
213
  "project": {}
214
  },
215
  "fenestrations": {
216
- "library": {},
217
  "project": {}
218
  },
219
  "constructions": {
220
- "library": {},
221
  "project": {}
222
  },
223
  "components": {
@@ -327,7 +335,7 @@ def start_new_project():
327
  }
328
  }
329
 
330
- logger.info("New project initialized")
331
 
332
  def load_project(uploaded_file) -> bool:
333
  """
 
16
  import logging
17
  from datetime import datetime
18
  from typing import Dict, Any, Optional
19
+ from app.m_c_data import SAMPLE_MATERIALS, SAMPLE_FENESTRATIONS, SAMPLE_CONSTRUCTIONS
20
 
21
  # Configure logging
22
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
144
  st.warning("Please enter a project name in the Building Information section before exporting.")
145
 
146
  def start_new_project():
147
+ """Initialize a new project by resetting project-specific data while preserving library data."""
148
  # Keep a backup of the current project data in case user wants to recover
149
  if 'project_data_backup' not in st.session_state:
150
  st.session_state.project_data_backup = {}
 
154
  backup_timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
155
  st.session_state.project_data_backup[backup_timestamp] = st.session_state.project_data.copy()
156
 
157
+ # Preserve library data from current session state or initialize with defaults
158
+ library_data = {
159
+ "materials": st.session_state.project_data.get("materials", {}).get("library", dict(SAMPLE_MATERIALS)),
160
+ "fenestrations": st.session_state.project_data.get("fenestrations", {}).get("library", dict(SAMPLE_FENESTRATIONS)),
161
+ "constructions": st.session_state.project_data.get("constructions", {}).get("library", dict(SAMPLE_CONSTRUCTIONS))
162
+ }
163
+
164
  # Reset project data to match main.py structure
165
  st.session_state.project_data = {
166
  "project_name": "",
 
217
  "ground_reflectivity": 0.2
218
  },
219
  "materials": {
220
+ "library": library_data["materials"],
221
  "project": {}
222
  },
223
  "fenestrations": {
224
+ "library": library_data["fenestrations"],
225
  "project": {}
226
  },
227
  "constructions": {
228
+ "library": library_data["constructions"],
229
  "project": {}
230
  },
231
  "components": {
 
335
  }
336
  }
337
 
338
+ logger.info("New project initialized with preserved library data")
339
 
340
  def load_project(uploaded_file) -> bool:
341
  """