diff --git a/README.md b/README.md
index 6ffa57a..75e3589 100644
--- a/README.md
+++ b/README.md
@@ -59,17 +59,17 @@ python scripts/verify_installation.py
### 🖥️ **Running the Desktop Application**
```sh
-python src/osbridgelcca/desktop/app.py
+python src_web/osbridgelcca/desktop/app.py
```
### 🌐 **Running the Web Application**
#### **Start the Backend Server**
```sh
-python src/osbridgelcca/backend/manage.py runserver
+python src_web/osbridgelcca/backend/manage.py runserver
```
#### **Start the Frontend**
```sh
-cd src/osbridgelcca/web
+cd src_web/osbridgelcca/web
npm install
npm start
```
diff --git a/install.bat b/install.bat
index 5a1a326..312ff7a 100644
--- a/install.bat
+++ b/install.bat
@@ -1,6 +1,13 @@
@echo off
echo Creating and activating Conda environment...
-call conda activate osbridgelcca || conda create -n osbridgelcca python=3.9 -y && conda activate osbridgelcca
+
+REM Try activating the environment
+call conda activate osbridgelcca 2>nul
+if errorlevel 1 (
+ echo Environment not found. Creating it now...
+ call conda create -n osbridgelcca python=3.9 -y
+ call conda activate osbridgelcca
+)
echo Installing dependencies from pyproject.toml...
pip install .
diff --git a/scripts/verify_installation.py b/scripts/verify_installation.py
index 9e6afe4..8ceaa8c 100644
--- a/scripts/verify_installation.py
+++ b/scripts/verify_installation.py
@@ -1,5 +1,6 @@
import importlib
import sys
+sys.stdout.reconfigure(encoding='utf-8')
# List of required packages
REQUIRED_PACKAGES = [
diff --git a/src/__init__.py b/src/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/osbridgelcca/backend/__init__.py b/src/osbridgelcca/backend/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/osbridgelcca/backend/config.py b/src/osbridgelcca/backend/config.py
index 5aea750..3d78f4d 100644
--- a/src/osbridgelcca/backend/config.py
+++ b/src/osbridgelcca/backend/config.py
@@ -1 +1,22 @@
# Placeholder for app configuration
+
+import os
+from pathlib import Path
+
+# Base directory of the project
+BASE_DIR = Path(__file__).resolve().parent.parent.parent
+
+# Database configuration
+DATABASE_URL = os.getenv('DATABASE_URL', f'sqlite:///{BASE_DIR}/data/lcca.db')
+
+# Create data directory if it doesn't exist
+DATA_DIR = BASE_DIR / 'data'
+DATA_DIR.mkdir(exist_ok=True)
+
+# Database configuration options
+DB_CONFIG = {
+ 'pool_size': 5,
+ 'max_overflow': 10,
+ 'pool_timeout': 30,
+ 'pool_recycle': 1800
+}
diff --git a/src/osbridgelcca/backend/database.py b/src/osbridgelcca/backend/database.py
new file mode 100644
index 0000000..b239887
--- /dev/null
+++ b/src/osbridgelcca/backend/database.py
@@ -0,0 +1,28 @@
+import os
+from sqlalchemy import create_engine
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.pool import QueuePool
+from .models import Base
+from .config import DATABASE_URL, DB_CONFIG
+
+# Create engine with connection pooling
+engine = create_engine(
+ DATABASE_URL,
+ poolclass=QueuePool,
+ **DB_CONFIG
+)
+
+# Create session factory
+SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
+
+def get_db():
+ """Get database session"""
+ db = SessionLocal()
+ try:
+ yield db
+ finally:
+ db.close()
+
+def init_database():
+ """Initialize database tables"""
+ Base.metadata.create_all(bind=engine)
\ No newline at end of file
diff --git a/src/osbridgelcca/backend/main.py b/src/osbridgelcca/backend/main.py
index daa4a22..d768a4c 100644
--- a/src/osbridgelcca/backend/main.py
+++ b/src/osbridgelcca/backend/main.py
@@ -1 +1,3 @@
-# Placeholder for Flask API entry point
+from osbridgelcca.backend.database import init_database
+
+init_database()
diff --git a/src/osbridgelcca/backend/models.py b/src/osbridgelcca/backend/models.py
new file mode 100644
index 0000000..c99a675
--- /dev/null
+++ b/src/osbridgelcca/backend/models.py
@@ -0,0 +1,92 @@
+from sqlalchemy import create_engine, Column, Integer, Float, String, ForeignKey, DateTime, JSON
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import relationship
+from datetime import datetime, UTC
+
+Base = declarative_base()
+
+class MaterialRate(Base):
+ """Regional schedule of rates for materials"""
+ __tablename__ = 'material_rates'
+
+ id = Column(Integer, primary_key=True)
+ material_name = Column(String(100), nullable=False)
+ region = Column(String(50), nullable=False)
+ unit = Column(String(20), nullable=False)
+ rate = Column(Float, nullable=False)
+ currency = Column(String, nullable=False)
+ last_updated = Column(DateTime, default=lambda: datetime.now(UTC))
+
+class ScrapValue(Base):
+ """Scrap values and recyclability percentages"""
+ __tablename__ = 'scrap_values'
+
+ id = Column(Integer, primary_key=True)
+ material_name = Column(String(100), nullable=False)
+ scrap_value = Column(Float, nullable=False)
+ recyclability_percentage = Column(Float, nullable=False)
+ currency = Column(String, nullable=False)
+ last_updated = Column(DateTime, default=lambda: datetime.now(UTC))
+
+class EnvironmentalImpact(Base):
+ """Environmental impact data from EPDs"""
+ __tablename__ = 'environmental_impacts'
+
+ id = Column(Integer, primary_key=True)
+ material_name = Column(String(100), nullable=False)
+ epd_id = Column(String(50), nullable=False)
+ global_warming_potential = Column(Float, nullable=False) # kg CO2 eq
+ water_consumption = Column(Float) # m³
+ energy_consumption = Column(Float) # MJ
+ waste_generation = Column(Float) # kg
+ last_updated = Column(DateTime, default=lambda: datetime.now(UTC))
+
+class SocialCostOfCarbon(Base):
+ """Country-specific social cost of carbon"""
+ __tablename__ = 'social_cost_of_carbon'
+
+ id = Column(Integer, primary_key=True)
+ country = Column(String(50), nullable=False)
+ year = Column(Integer, nullable=False)
+ cost_per_ton = Column(Float, nullable=False) # USD per ton CO2
+ currency = Column(String, nullable=False)
+ last_updated = Column(DateTime, default=lambda: datetime.now(UTC))
+
+class TransportEmissionFactor(Base):
+ """Road transport carbon emission factors"""
+ __tablename__ = 'transport_emission_factors'
+
+ id = Column(Integer, primary_key=True)
+ vehicle_type = Column(String(50), nullable=False)
+ emission_factor = Column(Float, nullable=False) # kg CO2 per km
+ load_factor = Column(Float) # Average load factor
+ last_updated = Column(DateTime, default=lambda: datetime.now(UTC))
+
+class VehicleOperationCost(Base):
+ """Vehicle operation costs"""
+ __tablename__ = 'vehicle_operation_costs'
+
+ id = Column(Integer, primary_key=True)
+ vehicle_type = Column(String(50), nullable=False)
+ fuel_cost_per_km = Column(Float, nullable=False)
+ maintenance_cost_per_km = Column(Float, nullable=False)
+ insurance_cost_per_year = Column(Float, nullable=False)
+ currency = Column(String(3), nullable=False)
+ last_updated = Column(DateTime, default=lambda: datetime.now(UTC))
+
+class UserAnalysis(Base):
+ """User analyses storage"""
+ __tablename__ = 'user_analyses'
+
+ id = Column(Integer, primary_key=True)
+ user_id = Column(String(50), nullable=False)
+ analysis_name = Column(String(100), nullable=False)
+ analysis_data = Column(JSON, nullable=False)
+ created_at = Column(DateTime, default=lambda: datetime.now(UTC))
+ updated_at = Column(DateTime, default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC))
+
+def init_db(db_url):
+ """Initialize the database"""
+ engine = create_engine(db_url)
+ Base.metadata.create_all(engine)
+ return engine
\ No newline at end of file
diff --git a/src/osbridgelcca/core/__init__.py b/src/osbridgelcca/core/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/osbridgelcca/core/bridge_lcc.py b/src/osbridgelcca/core/bridge_lcc.py
index 4cb3716..1b9138c 100644
--- a/src/osbridgelcca/core/bridge_lcc.py
+++ b/src/osbridgelcca/core/bridge_lcc.py
@@ -1,26 +1,84 @@
+import pandas as pd
+from input_data import Input
+from cost_components import CostComponent
+from src.osbridgelcca.core.cost_components import InitialConstructionCost, InitialCarbonEmissionCost, TimeCost, \
+ RoadUserCost
+
+
class BridgeLCC:
"""Main class for handling Life Cycle Cost Analysis of bridges."""
-
- def __init__(self, project_name, inputs):
+
+ def __init__(self, project_name: str, inputs: Input):
self.project_name = project_name
- self.inputs = inputs # Dictionary of user inputs
- self.outputs = {}
+ self.inputs = inputs # Expecting an instance of Input class
+ self.outputs = {} # Initialize output storage
def calculate_lcc(self):
"""Calculate the total life cycle cost based on input parameters."""
try:
- material_cost = sum(self.inputs["bill_of_quantity"].values())
- maintenance_cost = self.inputs["maintenance_cost"]
- operation_cost = self.inputs["vehicle_operating_cost"]
- discount_rate = self.inputs["discount_rate"]
+ material_cost = self.inputs.material_data.quantity * self.inputs.material_data.unit_rate
+ maintenance_cost = self.inputs.maintenance_data.periodic_maintenance_rate
+ operation_cost = self.inputs.traffic_data.annual_traffic_increase * 5000 # Example formula
+ discount_rate = self.inputs.finance_data.discount_rate / 100 # Convert percentage to decimal
# Simple NPV calculation
total_cost = (material_cost + maintenance_cost + operation_cost) / (1 + discount_rate)
self.outputs["total_lcc"] = total_cost
return total_cost
- except KeyError as e:
+ except AttributeError as e:
raise ValueError(f"Missing input parameter: {e}")
def get_outputs(self):
"""Return computed outputs."""
return self.outputs
+
+ def tabulate_cost_components(self):
+ """Create a Pandas DataFrame for cost components."""
+ data = {
+ "Sl. No.": list(range(1, 12)) + ["Total"],
+ "Cost Component": [
+ "Initial costs", "Initial carbon emissions costs", "Time costs",
+ "Road user costs due to re-routing", "Carbon emission cost due to re-routing",
+ "Periodic maintenance costs", "Periodic maintenance carbon emissions costs",
+ "Annual routine inspection costs", "Repair and rehabilitation costs",
+ "Demolition and disposal costs", "Recycling costs", "Total life cycle cost"
+ ],
+ "Cost Amount": [InitialConstructionCost.amount,
+ InitialCarbonEmissionCost.amount,
+ TimeCost.amount,
+ RoadUserCost.amount,
+ 82.62, 19.36, 1.5, 17.68, 13.8, 0, 0.84, -2.67, 212.81],
+ "Life Cycle Stage": [
+ "Initial", "Initial", "Initial", "Initial", "Initial",
+ "Use", "Use", "Use", "Use",
+ "End", "End", "Total"
+ ],
+ "Cost Type": [
+ "Economic", "Environmental", "Social", "Social", "Environmental",
+ "Economic", "Environmental", "Economic", "Economic",
+ "Economic", "Economic", "Total"
+ ]
+ }
+
+ df = pd.DataFrame(data)
+ return df
+
+# Example Usage
+if __name__ == "__main__":
+ from input_data import MaterialData, FinanceData, TrafficData, MaintenanceData, RepairData, DemolitionData, RecycleData, CarbonEmissionData
+
+ material = MaterialData("Steel", "Reinforcement bars", 5000, "kg", 60, "Govt Schedule", 32, 2.5, "EPD Source", 5, 90)
+ finance = FinanceData(5.0, 7.5, 1.2)
+ carbon = CarbonEmissionData("SSP2", "RCP6", 1200)
+ traffic = TrafficData(15, 4000, "Plain", "Urban", 10, {"Car": 50, "Truck": 30, "Bus": 20})
+ maintenance = MaintenanceData(0.55, 1.0, 10, 5, 1)
+ repair = RepairData("Component-wise repair details")
+ demolition = DemolitionData(10)
+ recycle = RecycleData(80, 10000, 5000)
+
+ project_input = Input(material, finance, carbon, traffic, maintenance, repair, demolition, recycle)
+ bridge = BridgeLCC("Bridge A", project_input)
+
+ print("Total LCC:", bridge.calculate_lcc())
+ print("\nCost Components Table:")
+ print(bridge.tabulate_cost_components())
diff --git a/src/osbridgelcca/core/cost_component.py b/src/osbridgelcca/core/cost_component.py
deleted file mode 100644
index c839b93..0000000
--- a/src/osbridgelcca/core/cost_component.py
+++ /dev/null
@@ -1,176 +0,0 @@
-from abc import ABC, abstractmethod
-
-class CostComponent(ABC):
- """Abstract Base Class for different cost components in Life Cycle Cost Analysis."""
-
- def __init__(self, amount, category, is_initial, is_recurring, present_worth_factor):
- """
- Initialize a generic cost component.
-
- :param amount: Cost amount in INR
- :param category: Economic, Environmental, or Social
- :param is_initial: True if an initial cost, False if future cost
- :param is_recurring: True if recurring, False if one-time
- :param present_worth_factor: Discounting factor for future costs (present_worth_factor)
- """
- self.amount = amount
- self.category = category
- self.is_initial = is_initial
- self.is_recurring = is_recurring
- self.present_worth_factor = present_worth_factor
-
- @abstractmethod
- def calculate_cost(self):
- """Abstract method to be implemented by subclasses for cost calculation."""
- pass
-
-
-class InitialConstructionCost(CostComponent):
- """Covers material, labor, and equipment costs for bridge construction."""
-
- def __init__(self, quantity, rate):
- super().__init__(amount=quantity * rate, category="Economic", is_initial=True, is_recurring=False, present_worth_factor=1.00)
- self.quantity = quantity
- self.rate = rate
-
- def calculate_cost(self):
- return self.quantity * self.rate * self.present_worth_factor
-
-
-class InitialCarbonEmissionCost(CostComponent):
- """Calculates initial carbon emissions from material production and transport."""
-
- def __init__(self, material_quantity, carbon_emission_factor, carbon_cost):
- super().__init__(amount=(material_quantity * carbon_emission_factor) * carbon_cost, category="Environmental", is_initial=True, is_recurring=False, present_worth_factor=1.00)
- self.material_quantity = material_quantity
- self.carbon_emission_factor = carbon_emission_factor
- self.carbon_cost = carbon_cost
-
- def calculate_cost(self):
- return (self.material_quantity * self.carbon_emission_factor) * self.carbon_cost * self.present_worth_factor
-
-
-class TimeCost(CostComponent):
- """Calculates economic losses due to construction delays."""
-
- def __init__(self, construction_cost, interest_rate, time, investment_ratio):
- cost = construction_cost * interest_rate * time * investment_ratio
- super().__init__(amount=cost, category="Economic", is_initial=True, is_recurring=False, present_worth_factor=1.00)
- self.construction_cost = construction_cost
- self.interest_rate = interest_rate
- self.time = time
- self.investment_ratio = investment_ratio
-
- def calculate_cost(self):
- return self.construction_cost * self.interest_rate * self.time * self.investment_ratio * self.present_worth_factor
-
-
-class RoadUserCost(CostComponent):
- """Evaluates economic impact on road users due to delays and detours."""
-
- def __init__(self, vehicles_affected, vehicle_operation_cost, construction_time):
- cost = vehicles_affected * vehicle_operation_cost * construction_time
- super().__init__(amount=cost, category="Economic", is_initial=True, is_recurring=False, present_worth_factor=1.00)
- self.vehicles_affected = vehicles_affected
- self.vehicle_operation_cost = vehicle_operation_cost
- self.construction_time = construction_time
-
- def calculate_cost(self):
- return self.vehicles_affected * self.vehicle_operation_cost * self.construction_time * self.present_worth_factor
-
-
-class AdditionalCarbonEmissionCost(CostComponent):
- """Accounts for increased emissions from detoured traffic during bridge work."""
-
- def __init__(self, vehicles_affected, reroute_distance, co2_emission_per_km, carbon_cost):
- cost = vehicles_affected * reroute_distance * co2_emission_per_km * carbon_cost
- super().__init__(amount=cost, category="Environmental", is_initial=True, is_recurring=False, present_worth_factor=1.00)
- self.vehicles_affected = vehicles_affected
- self.reroute_distance = reroute_distance
- self.co2_emission_per_km = co2_emission_per_km
- self.carbon_cost = carbon_cost
-
- def calculate_cost(self):
- return self.vehicles_affected * self.reroute_distance * self.co2_emission_per_km * self.carbon_cost * self.present_worth_factor
-
-
-class PeriodicMaintenanceCost(CostComponent):
- """Includes expenses for routine maintenance activities."""
-
- def __init__(self, maintenance_cost_rate, construction_cost, discount_rate, period, design_life):
- pwf = sum(1 / ((1 + discount_rate) ** (i * period)) for i in range(1, int(design_life / period) + 1))
- cost = maintenance_cost_rate * construction_cost * pwf
- super().__init__(amount=cost, category="Economic", is_initial=False, is_recurring=True, present_worth_factor=pwf)
- self.maintenance_cost_rate = maintenance_cost_rate
- self.construction_cost = construction_cost
- self.discount_rate = discount_rate
- self.period = period
- self.design_life = design_life
-
- def calculate_cost(self):
- return self.maintenance_cost_rate * self.construction_cost * self.present_worth_factor
-
-
-class PeriodicMaintenanceCarbonCost(CostComponent):
- """Calculates emissions from maintenance activities."""
-
- def __init__(self, material_quantity, carbon_emission_factor, carbon_cost, discount_rate, period, design_life):
- pwf = sum(1 / ((1 + discount_rate) ** (i * period)) for i in range(1, int(design_life / period) + 1))
- cost = material_quantity * carbon_emission_factor * carbon_cost * pwf
- super().__init__(amount=cost, category="Environmental", is_initial=False, is_recurring=True, present_worth_factor=pwf)
- self.material_quantity = material_quantity
- self.carbon_emission_factor = carbon_emission_factor
- self.carbon_cost = carbon_cost
-
- def calculate_cost(self):
- return self.material_quantity * self.carbon_emission_factor * self.carbon_cost * self.present_worth_factor
-
-
-class RoutineInspectionCost(CostComponent):
- """Annual cost of inspections for structural integrity."""
-
- def __init__(self, quantity, rate, discount_rate, design_life):
- pwf = sum(1 / ((1 + discount_rate) ** i) for i in range(1, design_life + 1))
- cost = quantity * rate * pwf
- super().__init__(amount=cost, category="Economic", is_initial=False, is_recurring=True, present_worth_factor=pwf)
- self.quantity = quantity
- self.rate = rate
-
- def calculate_cost(self):
- return self.quantity * self.rate * self.present_worth_factor
-
-
-class RepairAndRehabilitationCost(CostComponent):
- """Covers major structural repairs and retrofitting."""
-
- def __init__(self, repair_cost_rate, construction_cost, discount_rate, period, design_life):
- pwf = sum(1 / ((1 + discount_rate) ** (i * period)) for i in range(1, int(design_life / period) + 1))
- cost = repair_cost_rate * construction_cost * pwf
- super().__init__(amount=cost, category="Economic", is_initial=False, is_recurring=True, present_worth_factor=pwf)
-
- def calculate_cost(self):
- return self.amount
-
-
-class DemolitionCost(CostComponent):
- """Costs incurred at the end of bridge life for demolition and disposal."""
-
- def __init__(self, demolition_rate, construction_cost, discount_rate, design_life):
- pwf = 1 / ((1 + discount_rate) ** design_life)
- cost = demolition_rate * construction_cost * pwf
- super().__init__(amount=cost, category="Economic", is_initial=False, is_recurring=False, present_worth_factor=pwf)
-
- def calculate_cost(self):
- return self.amount
-
-
-class RecyclingCost(CostComponent):
- """Accounts for material salvage and repurposing costs."""
-
- def __init__(self, scrap_value, quantity, discount_rate, design_life):
- pwf = 1 / ((1 + discount_rate) ** design_life)
- cost = scrap_value * quantity * pwf
- super().__init__(amount=cost, category="Economic", is_initial=False, is_recurring=False, present_worth_factor=pwf)
-
- def calculate_cost(self):
- return self.amount
diff --git a/src/osbridgelcca/core/cost_components.py b/src/osbridgelcca/core/cost_components.py
new file mode 100644
index 0000000..eb00fc6
--- /dev/null
+++ b/src/osbridgelcca/core/cost_components.py
@@ -0,0 +1,214 @@
+from abc import ABC, abstractmethod
+import pandas as pd
+
+
+
+class CostComponent(ABC):
+ """Abstract Base Class for different cost components in Life Cycle Cost Analysis."""
+
+ def __init__(self):
+ self.amount = 0 # To be calculated in subclasses
+ self.category = None # Defined in subclass
+ self.is_initial = None # Defined in subclass
+ self.is_recurring = None # Defined in subclass
+ self.pwf = None # To be calculated in subclasses
+
+ @abstractmethod
+ def calculate_cost(self):
+ """Abstract method to be implemented by subclasses for cost calculation."""
+ pass
+
+ def __str__(self):
+ return f"{self.__class__.__name__}: Amount = {self.amount:.2f}, Category = {self.category}"
+
+
+def calculate_pwf(discount_rate=None, design_life=None, is_initial=False, is_recurring=True, interval=1,
+ future_year=None):
+ """
+ Calculates the Present Worth Factor (PWF) based on cost type.
+
+ :param discount_rate: Discount rate (decimal form, e.g., 0.05 for 5%).
+ :param design_life: Total design life in years.
+ :param is_initial: True for initial cost (PWF = 1).
+ :param is_recurring: True for recurring costs.
+ :param interval: Interval in years for recurring costs (default is 1).
+ :param future_year: Year when a non-recurring future cost occurs.
+ :return: Present Worth Factor (PWF).
+ """
+ if is_initial:
+ return 1.0 # Initial cost has no discounting
+ elif not is_recurring:
+ if future_year is None:
+ raise ValueError("future_year must be provided for non-recurring future costs")
+ return 1 / ((1 + discount_rate) ** future_year)
+ else:
+ return sum(1 / ((1 + discount_rate) ** (i * interval)) for i in range(1, int(design_life / interval) + 1))
+
+
+class InitialConstructionCost(CostComponent):
+ def __init__(self, material_boq: pd.DataFrame):
+ super().__init__()
+ self.material_boq = material_boq
+ self.category = "Economic"
+ self.is_initial = True
+ self.is_recurring = False
+ self.pwf = calculate_pwf(is_initial=True)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return (self.material_boq.iloc[:, 2] * self.material_boq.iloc[:, 3]).sum()
+
+
+class InitialCarbonEmissionCost(CostComponent):
+ def __init__(self, material_boq: pd.DataFrame, carbon_cost):
+ super().__init__()
+ self.material_boq = material_boq
+ self.carbon_cost = carbon_cost
+ self.category = "Environmental"
+ self.is_initial = True
+ self.is_recurring = False
+ self.pwf = calculate_pwf(is_initial=True)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.carbon_cost * (self.material_boq.iloc[:, 2] * self.material_boq.iloc[:, 4]).sum()
+
+
+class TimeCost(CostComponent):
+ def __init__(self, construction_cost, interest_rate, construction_time, investment_ratio):
+ super().__init__()
+ self.construction_cost = construction_cost
+ self.interest_rate = interest_rate
+ self.construction_time = construction_time
+ self.investment_ratio = investment_ratio
+ self.category = "Economic"
+ self.is_initial = True
+ self.is_recurring = False
+ self.pwf = calculate_pwf(is_initial=True)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.construction_cost * self.interest_rate * self.construction_time * self.investment_ratio
+
+
+class RoadUserCost(CostComponent):
+ def __init__(self, vehicles_affected, vehicle_operation_cost, construction_time):
+ super().__init__()
+ self.vehicles_affected = vehicles_affected
+ self.vehicle_operation_cost = vehicle_operation_cost
+ self.construction_time = construction_time
+ self.delay_cost = 0.00
+ self.category = "Economic"
+ self.is_initial = True
+ self.is_recurring = False
+ self.pwf = 1.0
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.vehicles_affected * (self.vehicle_operation_cost + self.delay_cost) * self.construction_time
+
+
+class ReroutingCarbonEmissionCost(CostComponent):
+ def __init__(self, vehicles_affected, reroute_distance, co2_emission_per_km, carbon_cost):
+ super().__init__()
+ self.vehicles_affected = vehicles_affected
+ self.reroute_distance = reroute_distance
+ self.co2_emission_per_km = co2_emission_per_km
+ self.carbon_cost = carbon_cost
+ self.category = "Environmental"
+ self.is_initial = True
+ self.is_recurring = False
+ self.pwf = 1.0
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.vehicles_affected * self.reroute_distance * self.co2_emission_per_km * self.carbon_cost
+
+
+class PeriodicMaintenanceCost(CostComponent):
+ def __init__(self, maintenance_cost_rate, construction_cost, discount_rate, interval, design_life):
+ super().__init__()
+ self.maintenance_cost_rate = maintenance_cost_rate
+ self.construction_cost = construction_cost
+ self.discount_rate = discount_rate
+ self.interval = interval
+ self.design_life = design_life
+ self.category = "Economic"
+ self.is_initial = False
+ self.is_recurring = True
+ self.pwf = calculate_pwf(discount_rate, design_life=self.design_life, is_recurring=self.is_recurring,
+ interval=interval)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.maintenance_cost_rate * self.construction_cost * self.pwf
+
+
+class PeriodicMaintenanceCarbonEmissionCost(CostComponent):
+ def __init__(self, material_quantity, carbon_emission_factor, carbon_cost, discount_rate, interval, design_life):
+ super().__init__()
+ self.material_quantity = material_quantity
+ self.carbon_emission_factor = carbon_emission_factor
+ self.carbon_cost = carbon_cost
+ self.discount_rate = discount_rate
+ self.interval = interval
+ self.design_life = design_life
+ self.category = "Environmental"
+ self.is_initial = False
+ self.is_recurring = True
+ self.pwf = calculate_pwf(discount_rate, design_life, is_recurring=True, interval=interval)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.material_quantity * self.carbon_emission_factor * self.carbon_cost * self.pwf
+
+
+class RoutineInspectionCost(CostComponent):
+ def __init__(self, quantity, rate, discount_rate, design_life):
+ super().__init__()
+ self.quantity = quantity
+ self.rate = rate
+ self.discount_rate = discount_rate
+ self.design_life = design_life
+ self.category = "Economic"
+ self.is_initial = False
+ self.is_recurring = True
+ self.pwf = calculate_pwf(discount_rate, design_life, is_recurring=True)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.quantity * self.rate * self.pwf
+
+
+class DemolitionCost(CostComponent):
+ def __init__(self, demolition_rate, construction_cost, discount_rate, design_life):
+ super().__init__()
+ self.demolition_rate = demolition_rate
+ self.construction_cost = construction_cost
+ self.discount_rate = discount_rate
+ self.design_life = design_life
+ self.category = "Economic"
+ self.is_initial = False
+ self.is_recurring = False
+ self.pwf = calculate_pwf(discount_rate, design_life, is_recurring=False, future_year=design_life)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.demolition_rate * self.construction_cost * self.pwf
+
+
+class RecyclingCost(CostComponent):
+ def __init__(self, scrap_value, quantity, discount_rate, design_life):
+ super().__init__()
+ self.scrap_value = scrap_value
+ self.quantity = quantity
+ self.discount_rate = discount_rate
+ self.design_life = design_life
+ self.category = "Economic"
+ self.is_initial = False
+ self.is_recurring = False
+ self.pwf = calculate_pwf(discount_rate, design_life, is_recurring=False, future_year=design_life)
+ self.amount = self.calculate_cost()
+
+ def calculate_cost(self):
+ return self.scrap_value * self.quantity * self.pwf
diff --git a/src/osbridgelcca/desktop_app/app.py b/src/osbridgelcca/desktop_app/app.py
index 62e7ee9..2257fd7 100644
--- a/src/osbridgelcca/desktop_app/app.py
+++ b/src/osbridgelcca/desktop_app/app.py
@@ -1,3 +1,899 @@
+import sys
+import csv
+import json
+from PyQt5 import QtWidgets
+from ui.input_form import save_general_info
+from ui.project_details_windows.ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog
+from ui.project_details_windows.ProjectDetails_Foundation_Window import Ui_Foundation_Dialog
+from ui.project_details_windows.ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog
+from ui.project_details_windows.ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog
+from ui.project_details_windows.ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog
+from ui.project_details_windows.ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog
+from ui.project_details_windows.ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog
+from ui.project_details_windows.ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog
+from ui.project_details_windows.ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog
+from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout,
+ QHBoxLayout, QPushButton, QLabel, QTreeWidget,
+ QTreeWidgetItem, QTabBar, QFrame, QSplitter,
+ QToolBar, QAction, QGroupBox, QMenu, QLineEdit,
+ QComboBox, QMessageBox, QGridLayout)
+from PyQt5.QtGui import QIcon, QFont
+from PyQt5.QtCore import Qt, QSize
+
+class BICCAStudio(QMainWindow):
+ def openBridgeTrafficWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_BridgeTraffic_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openFoundationWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_Foundation_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openCarbonEmissionWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_CarbonEmission_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openDemolitionWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_Demolition_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openFinancialWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_FinancialData_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openMaintenanceWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_Maintenance_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openMiscellaneousWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_Miscellaneous_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openSubStructureWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_SubStructure_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def openSuperStructureWindow(self):
+ self.window = QtWidgets.QDialog()
+ self.ui = Ui_SuperStructure_Dialog()
+ self.ui.setupUi(self.window)
+ self.window.show()
+
+ def __init__(self):
+ super().__init__()
+ self.setWindowTitle(" Initial Construction Cost Initial Carbon emission Cost Time Cost Road User Cost Carbon Emission due to Re-Routing Periodic Maintenance Costs Maintenance Emission Costs Routine Inspectection Costs Repair & Rehabilitation Costs Reconstruction Costs Demolition & Disposal Cost Recycling Cost Total Life-Cycle Cost Annual Increaase in Traffic if Re-Routing duration increases more than a year
m3
")) + self.label_63.setText(_translate("CarbonEmission_Dialog", "kg")) + #self.pushButton_13.setText(_translate("CarbonEmission_Dialog", "+ Add Material")) + #self.pushButton_49.setText(_translate("CarbonEmission_Dialog", "+ Add Material")) + self.label_74.setText(_translate("CarbonEmission_Dialog", "(MJ/kg)")) + self.label_75.setText(_translate("CarbonEmission_Dialog", "(MJ/kg)")) + self.label_76.setText(_translate("CarbonEmission_Dialog", "kg C02e/kg")) + self.label_77.setText(_translate("CarbonEmission_Dialog", "kg C02e/kg")) + self.label_78.setText(_translate("CarbonEmission_Dialog", "(MJ/kg)")) + self.label_79.setText(_translate("CarbonEmission_Dialog", "kg C02e/kg")) + self.label_64.setText(_translate("CarbonEmission_Dialog", "m3
")) + self.label_65.setText(_translate("CarbonEmission_Dialog", "kg")) + self.label_80.setText(_translate("CarbonEmission_Dialog", "kg C02e/kg")) + self.label_66.setText(_translate("CarbonEmission_Dialog", "Component:")) + self.label_67.setText(_translate("CarbonEmission_Dialog", "Material Type and Grade")) + self.label_81.setText(_translate("CarbonEmission_Dialog", "(MJ/kg)")) + self.label_68.setText(_translate("CarbonEmission_Dialog", "Carbon Emission Factor")) + self.label_69.setText(_translate("CarbonEmission_Dialog", "Quantity")) + self.comboBox_22.setItemText(0, _translate("CarbonEmission_Dialog", "Concrete")) + self.comboBox_22.setItemText(1, _translate("CarbonEmission_Dialog", "Steel")) + self.label_70.setText(_translate("CarbonEmission_Dialog", "Emboided Carbon Energy")) + self.comboBox_23.setItemText(0, _translate("CarbonEmission_Dialog", "Steel")) + self.comboBox_23.setItemText(1, _translate("CarbonEmission_Dialog", "Concrete")) + self.comboBox_24.setItemText(0, _translate("CarbonEmission_Dialog", "Earthwork")) + self.comboBox_24.setItemText(1, _translate("CarbonEmission_Dialog", "RCC in Foundation")) + self.label_71.setText(_translate("CarbonEmission_Dialog", "Unit")) + self.label_82.setText(_translate("CarbonEmission_Dialog", "(MJ/kg)")) + self.label_83.setText(_translate("CarbonEmission_Dialog", "kg C02e/kg")) + self.label_84.setText(_translate("CarbonEmission_Dialog", "m3
")) + self.label_85.setText(_translate("CarbonEmission_Dialog", "kg")) + self.label_86.setText(_translate("CarbonEmission_Dialog", "kg C02e/kg")) + self.label_87.setText(_translate("CarbonEmission_Dialog", "Component:")) + self.label_88.setText(_translate("CarbonEmission_Dialog", "Material Type and Grade")) + self.label_89.setText(_translate("CarbonEmission_Dialog", "(MJ/kg)")) + self.label_90.setText(_translate("CarbonEmission_Dialog", "Carbon Emission Factor")) + self.label_91.setText(_translate("CarbonEmission_Dialog", "Quantity")) + self.comboBox_25.setItemText(0, _translate("CarbonEmission_Dialog", "Concrete")) + self.comboBox_25.setItemText(1, _translate("CarbonEmission_Dialog", "Steel")) + self.label_92.setText(_translate("CarbonEmission_Dialog", "Emboided Carbon Energy")) + self.comboBox_26.setItemText(0, _translate("CarbonEmission_Dialog", "Steel")) + self.comboBox_26.setItemText(1, _translate("CarbonEmission_Dialog", "Concrete")) + self.comboBox_27.setItemText(0, _translate("CarbonEmission_Dialog", "Earthwork")) + self.comboBox_27.setItemText(1, _translate("CarbonEmission_Dialog", "RCC in Foundation")) + self.label_93.setText(_translate("CarbonEmission_Dialog", "Unit")) + self.pushButton_50.setText(_translate("CarbonEmission_Dialog", "+ Add Material")) + self.label_72.setText(_translate("CarbonEmission_Dialog", "Input Parameters")) + self.pushButton_51.setText(_translate("CarbonEmission_Dialog", "Structure Works Data")) + self.pushButton_52.setText(_translate("CarbonEmission_Dialog", "Foundation")) + self.pushButton_53.setText(_translate("CarbonEmission_Dialog", "Super-Structure")) + self.pushButton_54.setText(_translate("CarbonEmission_Dialog", "Sub-Structure")) + self.pushButton_55.setText(_translate("CarbonEmission_Dialog", "Miscellaneous")) + self.pushButton_56.setText(_translate("CarbonEmission_Dialog", "Financial Data")) + self.pushButton_57.setText(_translate("CarbonEmission_Dialog", "Carbon Emission Data")) + self.pushButton_58.setText(_translate("CarbonEmission_Dialog", "Carbon Emission Cost Data")) + self.pushButton_59.setText(_translate("CarbonEmission_Dialog", "Bridge and Traffic Data")) + self.pushButton_60.setText(_translate("CarbonEmission_Dialog", "Maintenance and Repair")) + self.pushButton_61.setText(_translate("CarbonEmission_Dialog", "Disposal and Recycling")) + self.label_73.setText(_translate("CarbonEmission_Dialog", "Output")) + self.textBrowser_4.setHtml(_translate("CarbonEmission_Dialog", "\n" +"\n" +"Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + self.pushButton_62.setText(_translate("CarbonEmission_Dialog", "Carbon Emission Data ")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate numeric fields + float(self.lineEdit_37.text()) if self.lineEdit_37.text() else 0 + float(self.lineEdit_38.text()) if self.lineEdit_38.text() else 0 + float(self.lineEdit_39.text()) if self.lineEdit_39.text() else 0 + float(self.lineEdit_40.text()) if self.lineEdit_40.text() else 0 + float(self.lineEdit_41.text()) if self.lineEdit_41.text() else 0 + float(self.lineEdit_42.text()) if self.lineEdit_42.text() else 0 + float(self.lineEdit_48.text()) if self.lineEdit_48.text() else 0 + float(self.lineEdit_44.text()) if self.lineEdit_44.text() else 0 + float(self.lineEdit_46.text()) if self.lineEdit_46.text() else 0 + float(self.lineEdit_47.text()) if self.lineEdit_47.text() else 0 + float(self.lineEdit_45.text()) if self.lineEdit_45.text() else 0 + float(self.lineEdit_54.text()) if self.lineEdit_54.text() else 0 + float(self.lineEdit_50.text()) if self.lineEdit_50.text() else 0 + float(self.lineEdit_52.text()) if self.lineEdit_52.text() else 0 + float(self.lineEdit_53.text()) if self.lineEdit_53.text() else 0 + float(self.lineEdit_51.text()) if self.lineEdit_51.text() else 0 + float(self.lineEdit_49.text()) if self.lineEdit_49.text() else 0 + + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + # First component section + "component_1": self.comboBox_19.currentText(), + "material_type_1": self.comboBox_20.currentText(), + "material_grade_1": self.comboBox_21.currentText(), + "quantity_1": self.lineEdit_37.text(), + "unit_1": self.lineEdit_38.text(), + "embodied_carbon_energy_1": self.lineEdit_39.text(), + "carbon_emission_factor_1": self.lineEdit_41.text(), + + # Second component section + "component_2": self.comboBox_24.currentText(), + "material_type_2": self.comboBox_22.currentText(), + "material_grade_2": self.comboBox_23.currentText(), + "quantity_2": self.lineEdit_48.text(), + "unit_2": self.lineEdit_44.text(), + "embodied_carbon_energy_2": self.lineEdit_46.text(), + "carbon_emission_factor_2": self.lineEdit_47.text(), + + # Third component section + "component_3": self.comboBox_27.currentText(), + "material_type_3": self.comboBox_25.currentText(), + "material_grade_3": self.comboBox_26.currentText(), + "quantity_3": self.lineEdit_54.text(), + "unit_3": self.lineEdit_50.text(), + "embodied_carbon_energy_3": self.lineEdit_52.text(), + "carbon_emission_factor_3": self.lineEdit_53.text(), + } + + # Save to JSON file + try: + import json + from datetime import datetime + + # Create filename with timestamp + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"carbon_emission_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Carbon emission data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + CarbonEmission_Dialog.accept() + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + CarbonEmission_Dialog = QtWidgets.QDialog() + ui = Ui_CarbonEmission_Dialog() + ui.setupUi(CarbonEmission_Dialog) + CarbonEmission_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_DemolitionANDRecyclingData_Window.py b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_DemolitionANDRecyclingData_Window.py new file mode 100644 index 0000000..a9167b2 --- /dev/null +++ b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_DemolitionANDRecyclingData_Window.py @@ -0,0 +1,486 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'C:\Users\saans\AppData\Local\Programs\Python\Python310\Lib\site-packages\qt5_applications\Qt\bin\ProjectDetails_Demolition&RecyclingData_Window.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QMessageBox + + + +#from ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog + + + + + + + +class Ui_Demolition_Dialog(object): + def openBridgeTrafficWindow(self): + from ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_BridgeTraffic_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFoundationWindow(self): + from ProjectDetails_Foundation_Window import Ui_Foundation_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Foundation_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openCarbonEmissionWindow(self): + from ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_CarbonEmission_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openDemolitionWindow(self): + self.window = QtWidgets.QDialog() + self.ui = Ui_Demolition_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFinancialWindow(self): + from ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_FinancialData_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMaintenanceWindow(self): + from ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Maintenance_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMiscellaneousWindow(self): + from ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Miscellaneous_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSubStructureWindow(self): + from ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SubStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSuperStructureWindow(self): + from ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SuperStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def setupUi(self, Demolition_Dialog): + Demolition_Dialog.setObjectName("Demolition_Dialog") + Demolition_Dialog.resize(1440, 900) + Demolition_Dialog.setStyleSheet("background-color: #fafafa") + self.pushButton_6 = QtWidgets.QPushButton(Demolition_Dialog) + self.pushButton_6.setGeometry(QtCore.QRect(350, 30, 261, 25)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(True) + font.setWeight(75) + self.pushButton_6.setFont(font) + self.pushButton_6.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton_6.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton_6.setStyleSheet("background-color: rgb(240,230,230)") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/Dismiss.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_6.setIcon(icon) + self.pushButton_6.setAutoRepeat(False) + self.pushButton_6.setObjectName("pushButton_6") + self.label = QtWidgets.QLabel(Demolition_Dialog) + self.label.setGeometry(QtCore.QRect(10, 55, 244, 691)) + font = QtGui.QFont() + font.setPointSize(10) + self.label.setFont(font) + self.label.setStyleSheet("background-color: rgb(240,230,230)") + self.label.setText("") + self.label.setObjectName("label") + self.widget_2 = QtWidgets.QWidget(Demolition_Dialog) + self.widget_2.setGeometry(QtCore.QRect(350, 55, 692, 205)) + self.widget_2.setStyleSheet("background-color: #fff9f9") + self.widget_2.setObjectName("widget_2") + self.label_7 = QtWidgets.QLabel(self.widget_2) + self.label_7.setGeometry(QtCore.QRect(20, 110, 231, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_7.setFont(font) + self.label_7.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_7.setObjectName("label_7") + self.label_8 = QtWidgets.QLabel(self.widget_2) + self.label_8.setGeometry(QtCore.QRect(20, 140, 221, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_8.setFont(font) + self.label_8.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_8.setObjectName("label_8") + self.lineEdit_5 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_5.setGeometry(QtCore.QRect(290, 30, 121, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_5.setFont(font) + self.lineEdit_5.setStyleSheet("background-color: #ffffff") + self.lineEdit_5.setObjectName("lineEdit_5") + self.lineEdit_6 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_6.setGeometry(QtCore.QRect(290, 110, 121, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_6.setFont(font) + self.lineEdit_6.setStyleSheet("background-color: #ffffff") + self.lineEdit_6.setText("") + self.lineEdit_6.setObjectName("lineEdit_6") + self.buttonBox_2 = QtWidgets.QDialogButtonBox(self.widget_2) + self.buttonBox_2.setGeometry(QtCore.QRect(340, 170, 341, 32)) + self.buttonBox_2.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox_2.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox_2.setObjectName("buttonBox_2") + self.lineEdit_13 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_13.setGeometry(QtCore.QRect(290, 140, 121, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_13.setFont(font) + self.lineEdit_13.setStyleSheet("background-color: #ffffff") + self.lineEdit_13.setObjectName("lineEdit_13") + self.label_21 = QtWidgets.QLabel(self.widget_2) + self.label_21.setGeometry(QtCore.QRect(420, 30, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_21.setFont(font) + self.label_21.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_21.setObjectName("label_21") + self.label_23 = QtWidgets.QLabel(self.widget_2) + self.label_23.setGeometry(QtCore.QRect(420, 110, 71, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_23.setFont(font) + self.label_23.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_23.setObjectName("label_23") + self.textBrowser_2 = QtWidgets.QTextBrowser(self.widget_2) + self.textBrowser_2.setGeometry(QtCore.QRect(20, 20, 256, 51)) + self.textBrowser_2.setObjectName("textBrowser_2") + self.label_22 = QtWidgets.QLabel(self.widget_2) + self.label_22.setGeometry(QtCore.QRect(420, 140, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_22.setFont(font) + self.label_22.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_22.setObjectName("label_22") + self.pushButton = QtWidgets.QPushButton(Demolition_Dialog) + self.pushButton.setGeometry(QtCore.QRect(10, 30, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton.setFont(font) + self.pushButton.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton.setStyleSheet("background-color: rgb(240,230,230)") + self.pushButton.setIcon(icon) + self.pushButton.setAutoRepeat(False) + self.pushButton.setObjectName("pushButton") + self.scrollArea = QtWidgets.QScrollArea(Demolition_Dialog) + self.scrollArea.setGeometry(QtCore.QRect(10, 60, 241, 681)) + self.scrollArea.setAutoFillBackground(False) + self.scrollArea.setStyleSheet("background-color: #fff9f9") + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents = QtWidgets.QWidget() + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 239, 679)) + self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") + self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_2.setGeometry(QtCore.QRect(0, 0, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_2.setFont(font) + self.label_2.setStyleSheet("background-color: rgb(240,230,230)") + self.label_2.setAlignment(QtCore.Qt.AlignCenter) + self.label_2.setObjectName("label_2") + self.widget = QtWidgets.QWidget(self.scrollAreaWidgetContents) + self.widget.setGeometry(QtCore.QRect(0, 30, 221, 357)) + self.widget.setStyleSheet("background-color: #fff9f9") + self.widget.setObjectName("widget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.pushButton_15 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_15.setFont(font) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled (1).png"), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.pushButton_15.setIcon(icon1) + self.pushButton_15.setCheckable(True) + self.pushButton_15.setAutoDefault(True) + self.pushButton_15.setObjectName("pushButton_15") + self.verticalLayout.addWidget(self.pushButton_15) + self.widget_5 = QtWidgets.QWidget(self.widget) + self.widget_5.setObjectName("widget_5") + self.formLayout = QtWidgets.QFormLayout(self.widget_5) + self.formLayout.setObjectName("formLayout") + self.pushButton_20 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openFoundationWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_20.setFont(font) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_20.setIcon(icon2) + self.pushButton_20.setObjectName("pushButton_20") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.pushButton_20) + self.pushButton_21 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSuperStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_21.setFont(font) + self.pushButton_21.setIcon(icon2) + self.pushButton_21.setObjectName("pushButton_21") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.pushButton_21) + self.pushButton_22 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSubStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_22.setFont(font) + self.pushButton_22.setIcon(icon2) + self.pushButton_22.setObjectName("pushButton_22") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.pushButton_22) + self.pushButton_23 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openMiscellaneousWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_23.setFont(font) + self.pushButton_23.setIcon(icon2) + self.pushButton_23.setObjectName("pushButton_23") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pushButton_23) + self.verticalLayout.addWidget(self.widget_5) + self.pushButton_19 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openFinancialWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_19.setFont(font) + self.pushButton_19.setObjectName("pushButton_19") + self.verticalLayout.addWidget(self.pushButton_19) + self.pushButton_16 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_16.setFont(font) + self.pushButton_16.setIcon(icon1) + self.pushButton_16.setCheckable(True) + self.pushButton_16.setObjectName("pushButton_16") + self.verticalLayout.addWidget(self.pushButton_16) + self.widget_8 = QtWidgets.QWidget(self.widget) + self.widget_8.setMinimumSize(QtCore.QSize(203, 21)) + self.widget_8.setMaximumSize(QtCore.QSize(281, 21)) + self.widget_8.setObjectName("widget_8") + self.pushButton_14 = QtWidgets.QPushButton(self.widget_8, clicked=lambda: self.openCarbonEmissionWindow()) + self.pushButton_14.setGeometry(QtCore.QRect(20, 0, 183, 21)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_14.setFont(font) + self.pushButton_14.setIcon(icon2) + self.pushButton_14.setObjectName("pushButton_14") + self.verticalLayout.addWidget(self.widget_8) + self.pushButton_17 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openBridgeTrafficWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_17.setFont(font) + self.pushButton_17.setObjectName("pushButton_17") + self.verticalLayout.addWidget(self.pushButton_17) + self.pushButton_18 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openMaintenanceWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_18.setFont(font) + self.pushButton_18.setObjectName("pushButton_18") + self.verticalLayout.addWidget(self.pushButton_18) + self.pushButton_10 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openDemolitionWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_10.setFont(font) + self.pushButton_10.setObjectName("pushButton_10") + self.verticalLayout.addWidget(self.pushButton_10) + self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_3.setGeometry(QtCore.QRect(0, 387, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_3.setFont(font) + self.label_3.setStyleSheet("background-color: rgb(240,230,230)") + self.label_3.setAlignment(QtCore.Qt.AlignCenter) + self.label_3.setObjectName("label_3") + self.textBrowser = QtWidgets.QTextBrowser(self.scrollAreaWidgetContents) + self.textBrowser.setGeometry(QtCore.QRect(0, 418, 221, 221)) + self.textBrowser.setStyleSheet("background-color: #fff9f9") + self.textBrowser.setObjectName("textBrowser") + self.verticalScrollBar = QtWidgets.QScrollBar(self.scrollAreaWidgetContents) + self.verticalScrollBar.setGeometry(QtCore.QRect(220, 0, 16, 641)) + self.verticalScrollBar.setStyleSheet("background-color: #F0F0F0") + self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical) + self.verticalScrollBar.setObjectName("verticalScrollBar") + self.widget.raise_() + self.label_2.raise_() + self.label_3.raise_() + self.textBrowser.raise_() + self.verticalScrollBar.raise_() + self.scrollArea.setWidget(self.scrollAreaWidgetContents) + + self.retranslateUi(Demolition_Dialog) + self.buttonBox_2.accepted.connect(self.handle_save) # type: ignore + self.buttonBox_2.rejected.connect(lambda: self.show_warning(Demolition_Dialog)) # type: ignore + self.pushButton_15.toggled['bool'].connect(self.widget_5.setVisible) # type: ignore + self.pushButton_16.toggled['bool'].connect(self.widget_8.setVisible) # type: ignore + QtCore.QMetaObject.connectSlotsByName(Demolition_Dialog) + + def show_warning(self, dialog): + """ + Show a warning window when the Close button is pressed. + """ + warning_box = QMessageBox() + warning_box.setIcon(QMessageBox.Warning) + warning_box.setWindowTitle("Confirm Close") + warning_box.setText("Are you sure you want to close without saving?") + warning_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + warning_box.setDefaultButton(QMessageBox.No) + + # Check the user's response + response = warning_box.exec_() + if response == QMessageBox.Yes: + dialog.reject() # Close the application + else: + pass # Do nothing, return to the dialog + + def retranslateUi(self, Demolition_Dialog): + _translate = QtCore.QCoreApplication.translate + Demolition_Dialog.setWindowTitle(_translate("Demolition_Dialog", "Demolition and Recycling Data")) + self.pushButton_6.setText(_translate("Demolition_Dialog", "Demolition and Recycling Data ")) + self.label_7.setText(_translate("Demolition_Dialog", "Scrap Value of Structural Steel")) + self.label_8.setText(_translate("Demolition_Dialog", "Structural Steel Scrap")) + self.label_21.setText(_translate("Demolition_Dialog", "(%)")) + self.label_23.setText(_translate("Demolition_Dialog", "(INR/MT)")) + self.textBrowser_2.setHtml(_translate("Demolition_Dialog", "\n" +"\n" +"Demolition Cost rate as percentage to total construction cost
")) + self.label_22.setText(_translate("Demolition_Dialog", "(%)")) + self.pushButton.setText(_translate("Demolition_Dialog", "Project Details Window ")) + self.label_2.setText(_translate("Demolition_Dialog", "Input Parameters")) + self.pushButton_15.setText(_translate("Demolition_Dialog", "Structure Works Data")) + self.pushButton_20.setText(_translate("Demolition_Dialog", "Foundation")) + self.pushButton_21.setText(_translate("Demolition_Dialog", "Super-Structure")) + self.pushButton_22.setText(_translate("Demolition_Dialog", "Sub-Structure")) + self.pushButton_23.setText(_translate("Demolition_Dialog", "Miscellaneous")) + self.pushButton_19.setText(_translate("Demolition_Dialog", "Financial Data")) + self.pushButton_16.setText(_translate("Demolition_Dialog", "Carbon Emission Data")) + self.pushButton_14.setText(_translate("Demolition_Dialog", "Carbon Emission Cost Data")) + self.pushButton_17.setText(_translate("Demolition_Dialog", "Bridge and Traffic Data")) + self.pushButton_18.setText(_translate("Demolition_Dialog", "Maintenance and Repair")) + self.pushButton_10.setText(_translate("Demolition_Dialog", "Disposal and Recycling")) + self.label_3.setText(_translate("Demolition_Dialog", "Output")) + self.textBrowser.setHtml(_translate("Demolition_Dialog", "\n" +"\n" +"Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate numeric fields + float(self.lineEdit_5.text()) if self.lineEdit_5.text() else 0 + float(self.lineEdit_6.text()) if self.lineEdit_6.text() else 0 + float(self.lineEdit_13.text()) if self.lineEdit_13.text() else 0 + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + "demolition_cost_rate": self.lineEdit_5.text(), + "scrap_value_structural_steel": self.lineEdit_6.text(), + "structural_steel_scrap": self.lineEdit_13.text(), + } + + # Save to JSON file + try: + import json + from datetime import datetime + + # Create filename with timestamp + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"demolition_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Demolition data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + Demolition_Dialog.accept() + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Demolition_Dialog = QtWidgets.QDialog() + ui = Ui_Demolition_Dialog() + ui.setupUi(Demolition_Dialog) + Demolition_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_FinancialData_Window.py b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_FinancialData_Window.py new file mode 100644 index 0000000..713a0b8 --- /dev/null +++ b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_FinancialData_Window.py @@ -0,0 +1,520 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'C:\Users\saans\AppData\Local\Programs\Python\Python310\Lib\site-packages\qt5_applications\Qt\bin\ProjectDetails_FinancialData_Window.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QMessageBox + + + +#from ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog + + + + + + +class Ui_FinancialData_Dialog(object): + def openBridgeTrafficWindow(self): + from ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_BridgeTraffic_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFoundationWindow(self): + from ProjectDetails_Foundation_Window import Ui_Foundation_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Foundation_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openCarbonEmissionWindow(self): + from ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_CarbonEmission_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openDemolitionWindow(self): + from ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Demolition_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFinancialWindow(self): + self.window = QtWidgets.QDialog() + self.ui = Ui_FinancialData_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMaintenanceWindow(self): + from ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Maintenance_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMiscellaneousWindow(self): + from ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Miscellaneous_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSubStructureWindow(self): + from ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SubStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSuperStructureWindow(self): + from ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SuperStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def setupUi(self, FinancialData_Dialog): + FinancialData_Dialog.setObjectName("FinancialData_Dialog") + FinancialData_Dialog.resize(1440, 900) + FinancialData_Dialog.setStyleSheet("background-color:#FAFAFA") + self.label = QtWidgets.QLabel(FinancialData_Dialog) + self.label.setGeometry(QtCore.QRect(10, 65, 244, 691)) + font = QtGui.QFont() + font.setPointSize(10) + self.label.setFont(font) + self.label.setStyleSheet("background-color: rgb(240,230,230)") + self.label.setText("") + self.label.setObjectName("label") + self.pushButton = QtWidgets.QPushButton(FinancialData_Dialog) + self.pushButton.setGeometry(QtCore.QRect(10, 40, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton.setFont(font) + self.pushButton.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton.setStyleSheet("background-color: rgb(240,230,230)") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/Dismiss.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton.setIcon(icon) + self.pushButton.setAutoRepeat(False) + self.pushButton.setObjectName("pushButton") + self.widget_2 = QtWidgets.QWidget(FinancialData_Dialog) + self.widget_2.setGeometry(QtCore.QRect(350, 65, 736, 249)) + self.widget_2.setStyleSheet("background-color: #fff9f9") + self.widget_2.setObjectName("widget_2") + self.label_4 = QtWidgets.QLabel(self.widget_2) + self.label_4.setGeometry(QtCore.QRect(20, 20, 141, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_4.setFont(font) + self.label_4.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_4.setObjectName("label_4") + self.label_5 = QtWidgets.QLabel(self.widget_2) + self.label_5.setGeometry(QtCore.QRect(20, 80, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_5.setFont(font) + self.label_5.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_5.setObjectName("label_5") + self.label_6 = QtWidgets.QLabel(self.widget_2) + self.label_6.setGeometry(QtCore.QRect(20, 50, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_6.setFont(font) + self.label_6.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_6.setObjectName("label_6") + self.label_7 = QtWidgets.QLabel(self.widget_2) + self.label_7.setGeometry(QtCore.QRect(20, 110, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_7.setFont(font) + self.label_7.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_7.setObjectName("label_7") + self.label_8 = QtWidgets.QLabel(self.widget_2) + self.label_8.setGeometry(QtCore.QRect(20, 140, 221, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_8.setFont(font) + self.label_8.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_8.setObjectName("label_8") + self.comboBox_2 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_2.setGeometry(QtCore.QRect(270, 80, 101, 22)) + self.comboBox_2.setStyleSheet("background-color: #ffffff") + self.comboBox_2.setObjectName("comboBox_2") + self.comboBox_3 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_3.setGeometry(QtCore.QRect(270, 50, 101, 22)) + self.comboBox_3.setStyleSheet("background-color: #ffffff") + self.comboBox_3.setObjectName("comboBox_3") + self.lineEdit_5 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_5.setGeometry(QtCore.QRect(270, 20, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_5.setFont(font) + self.lineEdit_5.setStyleSheet("background-color: #ffffff") + self.lineEdit_5.setObjectName("lineEdit_5") + self.lineEdit_6 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_6.setGeometry(QtCore.QRect(270, 110, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_6.setFont(font) + self.lineEdit_6.setStyleSheet("background-color: #ffffff") + self.lineEdit_6.setObjectName("lineEdit_6") + self.buttonBox_2 = QtWidgets.QDialogButtonBox(self.widget_2) + self.buttonBox_2.setGeometry(QtCore.QRect(380, 210, 341, 32)) + self.buttonBox_2.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox_2.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox_2.setObjectName("buttonBox_2") + self.lineEdit_13 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_13.setGeometry(QtCore.QRect(270, 140, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_13.setFont(font) + self.lineEdit_13.setStyleSheet("background-color: #ffffff") + self.lineEdit_13.setObjectName("lineEdit_13") + self.label_21 = QtWidgets.QLabel(self.widget_2) + self.label_21.setGeometry(QtCore.QRect(390, 20, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_21.setFont(font) + self.label_21.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_21.setObjectName("label_21") + self.label_22 = QtWidgets.QLabel(self.widget_2) + self.label_22.setGeometry(QtCore.QRect(390, 50, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_22.setFont(font) + self.label_22.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_22.setObjectName("label_22") + self.label_23 = QtWidgets.QLabel(self.widget_2) + self.label_23.setGeometry(QtCore.QRect(390, 110, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_23.setFont(font) + self.label_23.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_23.setObjectName("label_23") + self.label_24 = QtWidgets.QLabel(self.widget_2) + self.label_24.setGeometry(QtCore.QRect(390, 140, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_24.setFont(font) + self.label_24.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_24.setObjectName("label_24") + self.scrollArea = QtWidgets.QScrollArea(FinancialData_Dialog) + self.scrollArea.setGeometry(QtCore.QRect(10, 70, 241, 681)) + self.scrollArea.setAutoFillBackground(False) + self.scrollArea.setStyleSheet("background-color: #fff9f9") + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents = QtWidgets.QWidget() + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 239, 679)) + self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") + self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_2.setGeometry(QtCore.QRect(0, 0, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_2.setFont(font) + self.label_2.setStyleSheet("background-color: rgb(240,230,230)") + self.label_2.setAlignment(QtCore.Qt.AlignCenter) + self.label_2.setObjectName("label_2") + self.widget = QtWidgets.QWidget(self.scrollAreaWidgetContents) + self.widget.setGeometry(QtCore.QRect(0, 30, 221, 357)) + self.widget.setStyleSheet("background-color: #fff9f9") + self.widget.setObjectName("widget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.pushButton_15 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_15.setFont(font) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled (1).png"), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.pushButton_15.setIcon(icon1) + self.pushButton_15.setCheckable(True) + self.pushButton_15.setAutoDefault(True) + self.pushButton_15.setObjectName("pushButton_15") + self.verticalLayout.addWidget(self.pushButton_15) + self.widget_5 = QtWidgets.QWidget(self.widget) + self.widget_5.setObjectName("widget_5") + self.formLayout = QtWidgets.QFormLayout(self.widget_5) + self.formLayout.setObjectName("formLayout") + self.pushButton_20 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openFoundationWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_20.setFont(font) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_20.setIcon(icon2) + self.pushButton_20.setObjectName("pushButton_20") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.pushButton_20) + self.pushButton_21 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSuperStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_21.setFont(font) + self.pushButton_21.setIcon(icon2) + self.pushButton_21.setObjectName("pushButton_21") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.pushButton_21) + self.pushButton_22 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSubStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_22.setFont(font) + self.pushButton_22.setIcon(icon2) + self.pushButton_22.setObjectName("pushButton_22") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.pushButton_22) + self.pushButton_23 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openMiscellaneousWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_23.setFont(font) + self.pushButton_23.setIcon(icon2) + self.pushButton_23.setObjectName("pushButton_23") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pushButton_23) + self.verticalLayout.addWidget(self.widget_5) + self.pushButton_19 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openFinancialWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_19.setFont(font) + self.pushButton_19.setObjectName("pushButton_19") + self.verticalLayout.addWidget(self.pushButton_19) + self.pushButton_16 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_16.setFont(font) + self.pushButton_16.setIcon(icon1) + self.pushButton_16.setCheckable(True) + self.pushButton_16.setObjectName("pushButton_16") + self.verticalLayout.addWidget(self.pushButton_16) + self.widget_8 = QtWidgets.QWidget(self.widget) + self.widget_8.setMinimumSize(QtCore.QSize(203, 21)) + self.widget_8.setMaximumSize(QtCore.QSize(281, 21)) + self.widget_8.setObjectName("widget_8") + self.pushButton_14 = QtWidgets.QPushButton(self.widget_8, clicked=lambda: self.openCarbonEmissionWindow()) + self.pushButton_14.setGeometry(QtCore.QRect(20, 0, 183, 21)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_14.setFont(font) + self.pushButton_14.setIcon(icon2) + self.pushButton_14.setObjectName("pushButton_14") + self.verticalLayout.addWidget(self.widget_8) + self.pushButton_17 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openBridgeTrafficWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_17.setFont(font) + self.pushButton_17.setObjectName("pushButton_17") + self.verticalLayout.addWidget(self.pushButton_17) + self.pushButton_18 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openMaintenanceWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_18.setFont(font) + self.pushButton_18.setObjectName("pushButton_18") + self.verticalLayout.addWidget(self.pushButton_18) + self.pushButton_10 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openDemolitionWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_10.setFont(font) + self.pushButton_10.setObjectName("pushButton_10") + self.verticalLayout.addWidget(self.pushButton_10) + self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_3.setGeometry(QtCore.QRect(0, 387, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_3.setFont(font) + self.label_3.setStyleSheet("background-color: rgb(240,230,230)") + self.label_3.setAlignment(QtCore.Qt.AlignCenter) + self.label_3.setObjectName("label_3") + self.textBrowser = QtWidgets.QTextBrowser(self.scrollAreaWidgetContents) + self.textBrowser.setGeometry(QtCore.QRect(0, 418, 221, 221)) + self.textBrowser.setStyleSheet("background-color: #fff9f9") + self.textBrowser.setObjectName("textBrowser") + self.verticalScrollBar = QtWidgets.QScrollBar(self.scrollAreaWidgetContents) + self.verticalScrollBar.setGeometry(QtCore.QRect(220, 0, 16, 641)) + self.verticalScrollBar.setStyleSheet("background-color: #F0F0F0") + self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical) + self.verticalScrollBar.setObjectName("verticalScrollBar") + self.widget.raise_() + self.label_2.raise_() + self.label_3.raise_() + self.textBrowser.raise_() + self.verticalScrollBar.raise_() + self.scrollArea.setWidget(self.scrollAreaWidgetContents) + self.pushButton_6 = QtWidgets.QPushButton(FinancialData_Dialog) + self.pushButton_6.setGeometry(QtCore.QRect(350, 40, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(True) + font.setWeight(75) + self.pushButton_6.setFont(font) + self.pushButton_6.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton_6.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton_6.setStyleSheet("background-color: rgb(240,230,230)") + self.pushButton_6.setIcon(icon) + self.pushButton_6.setAutoRepeat(False) + self.pushButton_6.setObjectName("pushButton_6") + + self.retranslateUi(FinancialData_Dialog) + self.buttonBox_2.accepted.connect(self.handle_save) # type: ignore + self.buttonBox_2.rejected.connect(lambda: self.show_warning(FinancialData_Dialog)) # type: ignore + self.pushButton_15.toggled['bool'].connect(self.widget_5.setVisible) # type: ignore + self.pushButton_16.toggled['bool'].connect(self.widget_8.setVisible) # type: ignore + QtCore.QMetaObject.connectSlotsByName(FinancialData_Dialog) + + def show_warning(self, dialog): + """ + Show a warning window when the Close button is pressed. + """ + warning_box = QMessageBox() + warning_box.setIcon(QMessageBox.Warning) + warning_box.setWindowTitle("Confirm Close") + warning_box.setText("Are you sure you want to close without saving?") + warning_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + warning_box.setDefaultButton(QMessageBox.No) + + # Check the user's response + response = warning_box.exec_() + if response == QMessageBox.Yes: + dialog.reject() # Close the application + else: + pass # Do nothing, return to the dialog + + def retranslateUi(self, FinancialData_Dialog): + _translate = QtCore.QCoreApplication.translate + FinancialData_Dialog.setWindowTitle(_translate("FinancialData_Dialog", "Dialog")) + self.pushButton.setText(_translate("FinancialData_Dialog", "Project Details Window ")) + self.label_4.setText(_translate("FinancialData_Dialog", "Real Discount Rate")) + self.label_5.setText(_translate("FinancialData_Dialog", "Investment Ratio")) + self.label_6.setText(_translate("FinancialData_Dialog", "Interest Rate")) + self.label_7.setText(_translate("FinancialData_Dialog", "Duration of Study ")) + self.label_8.setText(_translate("FinancialData_Dialog", "Time for construction of Base Project")) + self.label_21.setText(_translate("FinancialData_Dialog", "(%)")) + self.label_22.setText(_translate("FinancialData_Dialog", "(%)")) + self.label_23.setText(_translate("FinancialData_Dialog", "(years)")) + self.label_24.setText(_translate("FinancialData_Dialog", "(years)")) + self.label_2.setText(_translate("FinancialData_Dialog", "Input Parameters")) + self.pushButton_15.setText(_translate("FinancialData_Dialog", "Structure Works Data")) + self.pushButton_20.setText(_translate("FinancialData_Dialog", "Foundation")) + self.pushButton_21.setText(_translate("FinancialData_Dialog", "Super-Structure")) + self.pushButton_22.setText(_translate("FinancialData_Dialog", "Sub-Structure")) + self.pushButton_23.setText(_translate("FinancialData_Dialog", "Miscellaneous")) + self.pushButton_19.setText(_translate("FinancialData_Dialog", "Financial Data")) + self.pushButton_16.setText(_translate("FinancialData_Dialog", "Carbon Emission Data")) + self.pushButton_14.setText(_translate("FinancialData_Dialog", "Carbon Emission Cost Data")) + self.pushButton_17.setText(_translate("FinancialData_Dialog", "Bridge and Traffic Data")) + self.pushButton_18.setText(_translate("FinancialData_Dialog", "Maintenance and Repair")) + self.pushButton_10.setText(_translate("FinancialData_Dialog", "Disposal and Recycling")) + self.label_3.setText(_translate("FinancialData_Dialog", "Output")) + self.textBrowser.setHtml(_translate("FinancialData_Dialog", "\n" +"\n" +"Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + self.pushButton_6.setText(_translate("FinancialData_Dialog", "Financial Data ")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate numeric fields + float(self.lineEdit_5.text()) if self.lineEdit_5.text() else 0 # Real Discount Rate + float(self.comboBox_3.currentText()) if self.comboBox_3.currentText() else 0 # Interest Rate + float(self.comboBox_2.currentText()) if self.comboBox_2.currentText() else 0 # Investment Ratio + float(self.lineEdit_6.text()) if self.lineEdit_6.text() else 0 # Duration of Study + float(self.lineEdit_13.text()) if self.lineEdit_13.text() else 0 # Time for construction + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + "real_discount_rate": self.lineEdit_5.text(), + "interest_rate": self.comboBox_3.currentText(), + "investment_ratio": self.comboBox_2.currentText(), + "duration_of_study": self.lineEdit_6.text(), + "construction_time_base_project": self.lineEdit_13.text(), + } + + # Save to JSON file + try: + import json + from datetime import datetime + + # Create filename with timestamp + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"financial_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Financial data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + FinancialData_Dialog.accept() + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + FinancialData_Dialog = QtWidgets.QDialog() + ui = Ui_FinancialData_Dialog() + ui.setupUi(FinancialData_Dialog) + FinancialData_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_Foundation_Window.py b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_Foundation_Window.py new file mode 100644 index 0000000..69a8792 --- /dev/null +++ b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_Foundation_Window.py @@ -0,0 +1,764 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'C:\Users\saans\AppData\Local\Programs\Python\Python310\Lib\site-packages\qt5_applications\Qt\bin\ProjectDetails_Foundation_Window.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets +#from form_data_storage import save_form_data +from PyQt5.QtWidgets import QMessageBox + +#from ProjectDetails_Foundation_Window import Ui_Foundation_Dialog + + + + + + + + + +class Ui_Foundation_Dialog(object): + def openBridgeTrafficWindow(self): + from ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_BridgeTraffic_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFoundationWindow(self): + self.window = QtWidgets.QDialog() + self.ui = Ui_Foundation_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openCarbonEmissionWindow(self): + from ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_CarbonEmission_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openDemolitionWindow(self): + from ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Demolition_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFinancialWindow(self): + from ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_FinancialData_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMaintenanceWindow(self): + from ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Maintenance_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMiscellaneousWindow(self): + from ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Miscellaneous_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSubStructureWindow(self): + from ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SubStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSuperStructureWindow(self): + from ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SuperStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def setupUi(self, Foundation_Dialog): + Foundation_Dialog.setObjectName("Foundation_Dialog") + Foundation_Dialog.resize(1440, 900) + Foundation_Dialog.setAutoFillBackground(False) + Foundation_Dialog.setStyleSheet("background-color:#FAFAFA") + self.label = QtWidgets.QLabel(Foundation_Dialog) + self.label.setGeometry(QtCore.QRect(10, 50, 244, 691)) + font = QtGui.QFont() + font.setPointSize(10) + self.label.setFont(font) + self.label.setStyleSheet("background-color: rgb(240,230,230)") + self.label.setText("") + self.label.setObjectName("label") + self.pushButton = QtWidgets.QPushButton(Foundation_Dialog) + self.pushButton.setGeometry(QtCore.QRect(10, 25, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton.setFont(font) + self.pushButton.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton.setStyleSheet("background-color: rgb(240,230,230)") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/Dismiss.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton.setIcon(icon) + self.pushButton.setAutoRepeat(False) + self.pushButton.setObjectName("pushButton") + self.scrollArea = QtWidgets.QScrollArea(Foundation_Dialog) + self.scrollArea.setGeometry(QtCore.QRect(10, 55, 241, 681)) + self.scrollArea.setAutoFillBackground(False) + self.scrollArea.setStyleSheet("background-color: #fff9f9") + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents = QtWidgets.QWidget() + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 239, 679)) + self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") + self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_2.setGeometry(QtCore.QRect(0, 0, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_2.setFont(font) + self.label_2.setStyleSheet("background-color: rgb(240,230,230)") + self.label_2.setAlignment(QtCore.Qt.AlignCenter) + self.label_2.setObjectName("label_2") + self.widget = QtWidgets.QWidget(self.scrollAreaWidgetContents) + self.widget.setGeometry(QtCore.QRect(0, 30, 221, 357)) + self.widget.setStyleSheet("background-color: #fff9f9") + self.widget.setObjectName("widget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.pushButton_15 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_15.setFont(font) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled (1).png"), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.pushButton_15.setIcon(icon1) + self.pushButton_15.setCheckable(True) + self.pushButton_15.setAutoDefault(True) + self.pushButton_15.setObjectName("pushButton_15") + self.verticalLayout.addWidget(self.pushButton_15) + self.widget_5 = QtWidgets.QWidget(self.widget) + self.widget_5.setObjectName("widget_5") + self.formLayout = QtWidgets.QFormLayout(self.widget_5) + self.formLayout.setObjectName("formLayout") + self.pushButton_20 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openFoundationWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_20.setFont(font) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_20.setIcon(icon2) + self.pushButton_20.setObjectName("pushButton_20") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.pushButton_20) + self.pushButton_21 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSuperStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_21.setFont(font) + self.pushButton_21.setIcon(icon2) + self.pushButton_21.setObjectName("pushButton_21") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.pushButton_21) + self.pushButton_22 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSubStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_22.setFont(font) + self.pushButton_22.setIcon(icon2) + self.pushButton_22.setObjectName("pushButton_22") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.pushButton_22) + self.pushButton_23 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openMiscellaneousWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_23.setFont(font) + self.pushButton_23.setIcon(icon2) + self.pushButton_23.setObjectName("pushButton_23") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pushButton_23) + self.verticalLayout.addWidget(self.widget_5) + self.pushButton_19 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openFinancialWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_19.setFont(font) + self.pushButton_19.setObjectName("pushButton_19") + self.verticalLayout.addWidget(self.pushButton_19) + self.pushButton_16 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_16.setFont(font) + self.pushButton_16.setIcon(icon1) + self.pushButton_16.setCheckable(True) + self.pushButton_16.setObjectName("pushButton_16") + self.verticalLayout.addWidget(self.pushButton_16) + self.widget_8 = QtWidgets.QWidget(self.widget) + self.widget_8.setMinimumSize(QtCore.QSize(203, 21)) + self.widget_8.setMaximumSize(QtCore.QSize(281, 21)) + self.widget_8.setObjectName("widget_8") + self.pushButton_14 = QtWidgets.QPushButton(self.widget_8, clicked=lambda: self.openCarbonEmissionWindow()) + self.pushButton_14.setGeometry(QtCore.QRect(20, 0, 183, 21)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_14.setFont(font) + self.pushButton_14.setIcon(icon2) + self.pushButton_14.setObjectName("pushButton_14") + self.verticalLayout.addWidget(self.widget_8) + self.pushButton_17 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openBridgeTrafficWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_17.setFont(font) + self.pushButton_17.setObjectName("pushButton_17") + self.verticalLayout.addWidget(self.pushButton_17) + self.pushButton_18 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openMaintenanceWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_18.setFont(font) + self.pushButton_18.setObjectName("pushButton_18") + self.verticalLayout.addWidget(self.pushButton_18) + self.pushButton_10 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openDemolitionWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_10.setFont(font) + self.pushButton_10.setObjectName("pushButton_10") + self.verticalLayout.addWidget(self.pushButton_10) + self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_3.setGeometry(QtCore.QRect(0, 387, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_3.setFont(font) + self.label_3.setStyleSheet("background-color: rgb(240,230,230)") + self.label_3.setAlignment(QtCore.Qt.AlignCenter) + self.label_3.setObjectName("label_3") + self.textBrowser = QtWidgets.QTextBrowser(self.scrollAreaWidgetContents) + self.textBrowser.setGeometry(QtCore.QRect(0, 418, 221, 221)) + self.textBrowser.setStyleSheet("background-color: #fff9f9") + self.textBrowser.setObjectName("textBrowser") + self.verticalScrollBar = QtWidgets.QScrollBar(self.scrollAreaWidgetContents) + self.verticalScrollBar.setGeometry(QtCore.QRect(220, 0, 16, 641)) + self.verticalScrollBar.setStyleSheet("background-color: #F0F0F0") + self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical) + self.verticalScrollBar.setObjectName("verticalScrollBar") + self.widget.raise_() + self.label_2.raise_() + self.label_3.raise_() + self.textBrowser.raise_() + self.verticalScrollBar.raise_() + self.scrollArea.setWidget(self.scrollAreaWidgetContents) + self.widget_2 = QtWidgets.QWidget(Foundation_Dialog) + self.widget_2.setGeometry(QtCore.QRect(350, 50, 778, 624)) + self.widget_2.setStyleSheet("background-color: #fff9f9") + self.widget_2.setObjectName("widget_2") + self.label_4 = QtWidgets.QLabel(self.widget_2) + self.label_4.setGeometry(QtCore.QRect(20, 10, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_4.setFont(font) + self.label_4.setObjectName("label_4") + self.comboBox = QtWidgets.QComboBox(self.widget_2) + self.comboBox.setGeometry(QtCore.QRect(140, 10, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox.setFont(font) + self.comboBox.setStyleSheet("background-color: #ffffff") + self.comboBox.setObjectName("comboBox") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.pushButton_2 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_2.setGeometry(QtCore.QRect(350, 10, 190, 23)) + self.pushButton_2.setStyleSheet("background-color: #ffffff") + self.pushButton_2.setObjectName("pushButton_2") + self.label_5 = QtWidgets.QLabel(self.widget_2) + self.label_5.setGeometry(QtCore.QRect(20, 70, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_5.setFont(font) + self.label_5.setAlignment(QtCore.Qt.AlignCenter) + self.label_5.setObjectName("label_5") + self.label_6 = QtWidgets.QLabel(self.widget_2) + self.label_6.setGeometry(QtCore.QRect(551, 70, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_6.setFont(font) + self.label_6.setAlignment(QtCore.Qt.AlignCenter) + self.label_6.setObjectName("label_6") + self.label_7 = QtWidgets.QLabel(self.widget_2) + self.label_7.setGeometry(QtCore.QRect(191, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_7.setFont(font) + self.label_7.setAlignment(QtCore.Qt.AlignCenter) + self.label_7.setObjectName("label_7") + self.label_8 = QtWidgets.QLabel(self.widget_2) + self.label_8.setGeometry(QtCore.QRect(311, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_8.setFont(font) + self.label_8.setAlignment(QtCore.Qt.AlignCenter) + self.label_8.setObjectName("label_8") + self.label_9 = QtWidgets.QLabel(self.widget_2) + self.label_9.setGeometry(QtCore.QRect(431, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_9.setFont(font) + self.label_9.setAlignment(QtCore.Qt.AlignCenter) + self.label_9.setObjectName("label_9") + self.comboBox_2 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_2.setGeometry(QtCore.QRect(30, 100, 140, 22)) + self.comboBox_2.setStyleSheet("background-color: #ffffff") + self.comboBox_2.setObjectName("comboBox_2") + self.comboBox_3 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_3.setGeometry(QtCore.QRect(30, 130, 140, 22)) + self.comboBox_3.setStyleSheet("background-color: #ffffff") + self.comboBox_3.setObjectName("comboBox_3") + self.lineEdit = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit.setGeometry(QtCore.QRect(210, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit.setFont(font) + self.lineEdit.setStyleSheet("background-color: #ffffff") + self.lineEdit.setObjectName("lineEdit") + self.lineEdit_2 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_2.setGeometry(QtCore.QRect(210, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_2.setFont(font) + self.lineEdit_2.setStyleSheet("background-color: #ffffff") + self.lineEdit_2.setObjectName("lineEdit_2") + self.label_10 = QtWidgets.QLabel(self.widget_2) + self.label_10.setGeometry(QtCore.QRect(340, 100, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_10.setFont(font) + self.label_10.setStyleSheet("background-color: #ffffff") + self.label_10.setAlignment(QtCore.Qt.AlignCenter) + self.label_10.setObjectName("label_10") + self.label_11 = QtWidgets.QLabel(self.widget_2) + self.label_11.setGeometry(QtCore.QRect(340, 130, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_11.setFont(font) + self.label_11.setStyleSheet("background-color: #ffffff") + self.label_11.setAlignment(QtCore.Qt.AlignCenter) + self.label_11.setObjectName("label_11") + self.lineEdit_3 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_3.setGeometry(QtCore.QRect(450, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_3.setFont(font) + self.lineEdit_3.setStyleSheet("background-color: #ffffff") + self.lineEdit_3.setObjectName("lineEdit_3") + self.lineEdit_4 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_4.setGeometry(QtCore.QRect(450, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_4.setFont(font) + self.lineEdit_4.setStyleSheet("background-color: #ffffff") + self.lineEdit_4.setObjectName("lineEdit_4") + self.lineEdit_5 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_5.setGeometry(QtCore.QRect(570, 100, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_5.setFont(font) + self.lineEdit_5.setStyleSheet("background-color: #ffffff") + self.lineEdit_5.setObjectName("lineEdit_5") + self.lineEdit_6 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_6.setGeometry(QtCore.QRect(570, 130, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_6.setFont(font) + self.lineEdit_6.setStyleSheet("background-color: #ffffff") + self.lineEdit_6.setObjectName("lineEdit_6") + self.pushButton_3 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_3.setGeometry(QtCore.QRect(300, 200, 190, 23)) + self.pushButton_3.setStyleSheet("background-color: #ffffff") + self.pushButton_3.setObjectName("pushButton_3") + self.label_12 = QtWidgets.QLabel(self.widget_2) + self.label_12.setGeometry(QtCore.QRect(30, 330, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_12.setFont(font) + self.label_12.setAlignment(QtCore.Qt.AlignCenter) + self.label_12.setObjectName("label_12") + self.comboBox_4 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_4.setGeometry(QtCore.QRect(150, 270, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox_4.setFont(font) + self.comboBox_4.setStyleSheet("background-color: #ffffff") + self.comboBox_4.setObjectName("comboBox_4") + self.comboBox_4.addItem("") + self.comboBox_4.addItem("") + self.label_13 = QtWidgets.QLabel(self.widget_2) + self.label_13.setGeometry(QtCore.QRect(441, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_13.setFont(font) + self.label_13.setAlignment(QtCore.Qt.AlignCenter) + self.label_13.setObjectName("label_13") + self.label_14 = QtWidgets.QLabel(self.widget_2) + self.label_14.setGeometry(QtCore.QRect(350, 390, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_14.setFont(font) + self.label_14.setStyleSheet("background-color: #ffffff") + self.label_14.setAlignment(QtCore.Qt.AlignCenter) + self.label_14.setObjectName("label_14") + self.label_15 = QtWidgets.QLabel(self.widget_2) + self.label_15.setGeometry(QtCore.QRect(561, 330, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_15.setFont(font) + self.label_15.setAlignment(QtCore.Qt.AlignCenter) + self.label_15.setObjectName("label_15") + self.label_16 = QtWidgets.QLabel(self.widget_2) + self.label_16.setGeometry(QtCore.QRect(350, 360, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_16.setFont(font) + self.label_16.setStyleSheet("background-color: #ffffff") + self.label_16.setAlignment(QtCore.Qt.AlignCenter) + self.label_16.setObjectName("label_16") + self.label_17 = QtWidgets.QLabel(self.widget_2) + self.label_17.setGeometry(QtCore.QRect(321, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_17.setFont(font) + self.label_17.setAlignment(QtCore.Qt.AlignCenter) + self.label_17.setObjectName("label_17") + self.lineEdit_7 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_7.setGeometry(QtCore.QRect(220, 390, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_7.setFont(font) + self.lineEdit_7.setStyleSheet("background-color: #ffffff") + self.lineEdit_7.setObjectName("lineEdit_7") + self.lineEdit_8 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_8.setGeometry(QtCore.QRect(580, 360, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_8.setFont(font) + self.lineEdit_8.setStyleSheet("background-color: #ffffff") + self.lineEdit_8.setObjectName("lineEdit_8") + self.label_18 = QtWidgets.QLabel(self.widget_2) + self.label_18.setGeometry(QtCore.QRect(201, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_18.setFont(font) + self.label_18.setAlignment(QtCore.Qt.AlignCenter) + self.label_18.setObjectName("label_18") + self.pushButton_4 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_4.setGeometry(QtCore.QRect(310, 460, 190, 23)) + self.pushButton_4.setStyleSheet("background-color: #ffffff") + self.pushButton_4.setObjectName("pushButton_4") + self.lineEdit_9 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_9.setGeometry(QtCore.QRect(220, 360, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_9.setFont(font) + self.lineEdit_9.setStyleSheet("background-color: #ffffff") + self.lineEdit_9.setObjectName("lineEdit_9") + self.lineEdit_10 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_10.setGeometry(QtCore.QRect(460, 360, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_10.setFont(font) + self.lineEdit_10.setStyleSheet("background-color: #ffffff") + self.lineEdit_10.setObjectName("lineEdit_10") + self.lineEdit_11 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_11.setGeometry(QtCore.QRect(460, 390, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_11.setFont(font) + self.lineEdit_11.setStyleSheet("background-color: #ffffff") + self.lineEdit_11.setObjectName("lineEdit_11") + self.pushButton_5 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_5.setGeometry(QtCore.QRect(360, 270, 190, 23)) + self.pushButton_5.setStyleSheet("background-color: #ffffff") + self.pushButton_5.setObjectName("pushButton_5") + self.label_19 = QtWidgets.QLabel(self.widget_2) + self.label_19.setGeometry(QtCore.QRect(30, 270, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_19.setFont(font) + self.label_19.setObjectName("label_19") + self.lineEdit_12 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_12.setGeometry(QtCore.QRect(580, 390, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_12.setFont(font) + self.lineEdit_12.setStyleSheet("background-color: #ffffff") + self.lineEdit_12.setObjectName("lineEdit_12") + self.comboBox_5 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_5.setGeometry(QtCore.QRect(40, 360, 140, 22)) + self.comboBox_5.setStyleSheet("background-color: #ffffff") + self.comboBox_5.setObjectName("comboBox_5") + self.comboBox_5.addItem("") + self.comboBox_5.addItem("") + self.comboBox_6 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_6.setGeometry(QtCore.QRect(40, 390, 140, 22)) + self.comboBox_6.setStyleSheet("background-color: #ffffff") + self.comboBox_6.setObjectName("comboBox_6") + self.comboBox_6.addItem("") + self.comboBox_6.addItem("") + self.buttonBox = QtWidgets.QDialogButtonBox(self.widget_2) + self.buttonBox.setGeometry(QtCore.QRect(420, 580, 341, 32)) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox.setCenterButtons(False) + self.buttonBox.setObjectName("buttonBox") + self.line = QtWidgets.QFrame(self.widget_2) + self.line.setGeometry(QtCore.QRect(10, 250, 761, 16)) + self.line.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line.setLineWidth(2) + self.line.setMidLineWidth(2) + self.line.setFrameShape(QtWidgets.QFrame.HLine) + self.line.setObjectName("line") + self.line_2 = QtWidgets.QFrame(self.widget_2) + self.line_2.setGeometry(QtCore.QRect(10, 500, 761, 16)) + self.line_2.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_2.setLineWidth(2) + self.line_2.setMidLineWidth(2) + self.line_2.setFrameShape(QtWidgets.QFrame.HLine) + self.line_2.setObjectName("line_2") + self.pushButton_6 = QtWidgets.QPushButton(Foundation_Dialog) + self.pushButton_6.setGeometry(QtCore.QRect(350, 25, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(True) + font.setWeight(75) + self.pushButton_6.setFont(font) + self.pushButton_6.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton_6.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton_6.setStyleSheet("background-color: rgb(240,230,230)") + self.pushButton_6.setIcon(icon) + self.pushButton_6.setAutoRepeat(False) + self.pushButton_6.setObjectName("pushButton_6") + + self.retranslateUi(Foundation_Dialog) + self.buttonBox.accepted.connect(self.handle_save) # type: ignore + #self.buttonBox.accepted.connect(self.save_data) + self.buttonBox.rejected.connect(lambda: self.show_warning(Foundation_Dialog)) # type: ignore + self.pushButton_15.toggled['bool'].connect(self.widget_5.setVisible) # type: ignore + self.pushButton_16.toggled['bool'].connect(self.widget_8.setVisible) # type: ignore + + QtCore.QMetaObject.connectSlotsByName(Foundation_Dialog) + + def show_warning(self, dialog): + """ + Show a warning window when the Close button is pressed. + """ + warning_box = QMessageBox() + warning_box.setIcon(QMessageBox.Warning) + warning_box.setWindowTitle("Confirm Close") + warning_box.setText("Are you sure you want to close without saving?") + warning_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + warning_box.setDefaultButton(QMessageBox.No) + + # Check the user's response + response = warning_box.exec_() + if response == QMessageBox.Yes: + dialog.reject() # Close the application + else: + pass # Do nothing, return to the dialog + + ''' + def save_data(self): + """ + Collect form data and save it to the global dictionary. + """ + data = { + "component": self.comboBox.currentText(), + "sub_component": self.comboBox_2.currentText(), + "quantity": self.lineEdit.text(), + "unit": self.label_10.text(), + "rate": self.lineEdit_3.text(), + "material_type": self.comboBox_4.currentText(), + } + save_form_data("Foundation_Dialog", data)''' + + def retranslateUi(self, Foundation_Dialog): + _translate = QtCore.QCoreApplication.translate + Foundation_Dialog.setWindowTitle(_translate("Foundation_Dialog", "Dialog")) + self.pushButton.setText(_translate("Foundation_Dialog", "Project Details Window ")) + self.label_2.setText(_translate("Foundation_Dialog", "Input Parameters")) + self.pushButton_15.setText(_translate("Foundation_Dialog", "Structure Works Data")) + self.pushButton_20.setText(_translate("Foundation_Dialog", "Foundation")) + self.pushButton_21.setText(_translate("Foundation_Dialog", "Super-Structure")) + self.pushButton_22.setText(_translate("Foundation_Dialog", "Sub-Structure")) + self.pushButton_23.setText(_translate("Foundation_Dialog", "Miscellaneous")) + self.pushButton_19.setText(_translate("Foundation_Dialog", "Financial Data")) + self.pushButton_16.setText(_translate("Foundation_Dialog", "Carbon Emission Data")) + self.pushButton_14.setText(_translate("Foundation_Dialog", "Carbon Emission Cost Data")) + self.pushButton_17.setText(_translate("Foundation_Dialog", "Bridge and Traffic Data")) + self.pushButton_18.setText(_translate("Foundation_Dialog", "Maintenance and Repair")) + self.pushButton_10.setText(_translate("Foundation_Dialog", "Disposal and Recycling")) + self.label_3.setText(_translate("Foundation_Dialog", "Output")) + self.textBrowser.setHtml(_translate("Foundation_Dialog", "\n" +"\n" +"Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + self.label_4.setText(_translate("Foundation_Dialog", "Components:")) + self.comboBox.setItemText(0, _translate("Foundation_Dialog", "Earthwork")) + self.comboBox.setItemText(1, _translate("Foundation_Dialog", "RCC in Foundation")) + self.pushButton_2.setText(_translate("Foundation_Dialog", "+ Add Sub-Component")) + self.label_5.setText(_translate("Foundation_Dialog", "Material Type and Grade")) + self.label_6.setText(_translate("Foundation_Dialog", "Rate Data Source")) + self.label_7.setText(_translate("Foundation_Dialog", "Quantity")) + self.label_8.setText(_translate("Foundation_Dialog", "Unit")) + self.label_9.setText(_translate("Foundation_Dialog", "Rate")) + self.label_10.setText(_translate("Foundation_Dialog", "m3
")) + self.label_11.setText(_translate("Foundation_Dialog", "kg")) + self.pushButton_3.setText(_translate("Foundation_Dialog", "+ Add Material")) + self.label_12.setText(_translate("Foundation_Dialog", "Material Type and Grade")) + self.comboBox_4.setItemText(0, _translate("Foundation_Dialog", "RCC in Foundation")) + self.comboBox_4.setItemText(1, _translate("Foundation_Dialog", "Earthwork")) + self.label_13.setText(_translate("Foundation_Dialog", "Rate")) + self.label_14.setText(_translate("Foundation_Dialog", "kg")) + self.label_15.setText(_translate("Foundation_Dialog", "Rate Data Source")) + self.label_16.setText(_translate("Foundation_Dialog", "m3
")) + self.label_17.setText(_translate("Foundation_Dialog", "Unit")) + self.label_18.setText(_translate("Foundation_Dialog", "Quantity")) + self.pushButton_4.setText(_translate("Foundation_Dialog", "+ Add Material")) + self.pushButton_5.setText(_translate("Foundation_Dialog", "+ Add Sub-Component")) + self.label_19.setText(_translate("Foundation_Dialog", "Components:")) + self.comboBox_5.setItemText(0, _translate("Foundation_Dialog", "Concrete")) + self.comboBox_5.setItemText(1, _translate("Foundation_Dialog", "Steel")) + self.comboBox_6.setItemText(0, _translate("Foundation_Dialog", "Steel")) + self.comboBox_6.setItemText(1, _translate("Foundation_Dialog", "Concrete")) + self.pushButton_6.setText(_translate("Foundation_Dialog", "Foundation ")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate numeric fields + float(self.lineEdit.text()) if self.lineEdit.text() else 0 # Quantity 1 + float(self.lineEdit_2.text()) if self.lineEdit_2.text() else 0 # Quantity 2 + float(self.lineEdit_3.text()) if self.lineEdit_3.text() else 0 # Rate 1 + float(self.lineEdit_4.text()) if self.lineEdit_4.text() else 0 # Rate 2 + float(self.lineEdit_5.text()) if self.lineEdit_5.text() else 0 # Rate Data Source 1 + float(self.lineEdit_6.text()) if self.lineEdit_6.text() else 0 # Rate Data Source 2 + float(self.lineEdit_7.text()) if self.lineEdit_7.text() else 0 # Quantity 3 + float(self.lineEdit_8.text()) if self.lineEdit_8.text() else 0 # Rate Data Source 3 + float(self.lineEdit_9.text()) if self.lineEdit_9.text() else 0 # Quantity 4 + float(self.lineEdit_10.text()) if self.lineEdit_10.text() else 0 # Rate 3 + float(self.lineEdit_11.text()) if self.lineEdit_11.text() else 0 # Rate 4 + float(self.lineEdit_12.text()) if self.lineEdit_12.text() else 0 # Rate Data Source 4 + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + "component_1": self.comboBox.currentText(), + "sub_component_1": self.comboBox_2.currentText(), + "material_type_1": self.comboBox_5.currentText(), + "material_grade_1": self.comboBox_6.currentText(), + "quantity_1": self.lineEdit.text(), + "unit_1": self.label_10.text(), + "rate_1": self.lineEdit_3.text(), + "rate_data_source_1": self.lineEdit_5.text(), + + "component_2": self.comboBox_4.currentText(), + "sub_component_2": self.comboBox_3.currentText(), + "material_type_2": self.comboBox_5.currentText(), + "material_grade_2": self.comboBox_6.currentText(), + "quantity_2": self.lineEdit_2.text(), + "unit_2": self.label_11.text(), + "rate_2": self.lineEdit_4.text(), + "rate_data_source_2": self.lineEdit_6.text(), + + "quantity_3": self.lineEdit_9.text(), + "unit_3": self.label_16.text(), + "rate_3": self.lineEdit_10.text(), + "quantity_4": self.lineEdit_7.text(), + "unit_4": self.label_14.text(), + "rate_4": self.lineEdit_11.text(), + "rate_data_source_3": self.lineEdit_8.text(), + "rate_data_source_4": self.lineEdit_12.text(), + } + + # Save to JSON file + try: + import json + from datetime import datetime + + # Create filename with timestamp + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"foundation_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Foundation data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + Foundation_Dialog.accept() + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Foundation_Dialog = QtWidgets.QDialog() + ui = Ui_Foundation_Dialog() + ui.setupUi(Foundation_Dialog) + Foundation_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_MaintenanceANDRepairData_Window.py b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_MaintenanceANDRepairData_Window.py new file mode 100644 index 0000000..a36d92b --- /dev/null +++ b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_MaintenanceANDRepairData_Window.py @@ -0,0 +1,571 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'C:\Users\saans\AppData\Local\Programs\Python\Python310\Lib\site-packages\qt5_applications\Qt\bin\ProjectDetails_Maintenance&RepairData_Window.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QMessageBox + + + + + +#from ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog + + + + + +class Ui_Maintenance_Dialog(object): + def openBridgeTrafficWindow(self): + from ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_BridgeTraffic_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFoundationWindow(self): + from ProjectDetails_Foundation_Window import Ui_Foundation_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Foundation_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openCarbonEmissionWindow(self): + from ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_CarbonEmission_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openDemolitionWindow(self): + from ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Demolition_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFinancialWindow(self): + from ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_FinancialData_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMaintenanceWindow(self): + self.window = QtWidgets.QDialog() + self.ui = Ui_Maintenance_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMiscellaneousWindow(self): + from ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Miscellaneous_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSubStructureWindow(self): + from ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SubStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSuperStructureWindow(self): + from ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SuperStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def setupUi(self, Maintenance_Dialog): + Maintenance_Dialog.setObjectName("Maintenance_Dialog") + Maintenance_Dialog.resize(1440, 900) + Maintenance_Dialog.setStyleSheet("background-color: #fafafa") + self.pushButton_6 = QtWidgets.QPushButton(Maintenance_Dialog) + self.pushButton_6.setGeometry(QtCore.QRect(350, 35, 261, 25)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(True) + font.setWeight(75) + self.pushButton_6.setFont(font) + self.pushButton_6.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton_6.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton_6.setStyleSheet("background-color: rgb(240,230,230)") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/Dismiss.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_6.setIcon(icon) + self.pushButton_6.setAutoRepeat(False) + self.pushButton_6.setObjectName("pushButton_6") + self.label = QtWidgets.QLabel(Maintenance_Dialog) + self.label.setGeometry(QtCore.QRect(10, 60, 244, 691)) + font = QtGui.QFont() + font.setPointSize(10) + self.label.setFont(font) + self.label.setStyleSheet("background-color: rgb(240,230,230)") + self.label.setText("") + self.label.setObjectName("label") + self.widget_2 = QtWidgets.QWidget(Maintenance_Dialog) + self.widget_2.setGeometry(QtCore.QRect(350, 60, 784, 304)) + self.widget_2.setStyleSheet("background-color: #fff9f9") + self.widget_2.setObjectName("widget_2") + self.label_4 = QtWidgets.QLabel(self.widget_2) + self.label_4.setGeometry(QtCore.QRect(20, 240, 201, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_4.setFont(font) + self.label_4.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_4.setObjectName("label_4") + self.label_5 = QtWidgets.QLabel(self.widget_2) + self.label_5.setGeometry(QtCore.QRect(600, 60, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_5.setFont(font) + self.label_5.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_5.setObjectName("label_5") + self.label_6 = QtWidgets.QLabel(self.widget_2) + self.label_6.setGeometry(QtCore.QRect(600, 30, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_6.setFont(font) + self.label_6.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_6.setObjectName("label_6") + self.label_7 = QtWidgets.QLabel(self.widget_2) + self.label_7.setGeometry(QtCore.QRect(600, 90, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_7.setFont(font) + self.label_7.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_7.setObjectName("label_7") + self.label_8 = QtWidgets.QLabel(self.widget_2) + self.label_8.setGeometry(QtCore.QRect(20, 200, 221, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_8.setFont(font) + self.label_8.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_8.setObjectName("label_8") + self.lineEdit_5 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_5.setGeometry(QtCore.QRect(270, 30, 181, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_5.setFont(font) + self.lineEdit_5.setStyleSheet("background-color: #ffffff") + self.lineEdit_5.setObjectName("lineEdit_5") + self.buttonBox_2 = QtWidgets.QDialogButtonBox(self.widget_2) + self.buttonBox_2.setGeometry(QtCore.QRect(440, 270, 341, 32)) + self.buttonBox_2.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox_2.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox_2.setObjectName("buttonBox_2") + self.label_21 = QtWidgets.QLabel(self.widget_2) + self.label_21.setGeometry(QtCore.QRect(470, 30, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_21.setFont(font) + self.label_21.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_21.setObjectName("label_21") + self.label_22 = QtWidgets.QLabel(self.widget_2) + self.label_22.setGeometry(QtCore.QRect(470, 90, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_22.setFont(font) + self.label_22.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_22.setObjectName("label_22") + self.label_23 = QtWidgets.QLabel(self.widget_2) + self.label_23.setGeometry(QtCore.QRect(470, 200, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_23.setFont(font) + self.label_23.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_23.setObjectName("label_23") + self.label_24 = QtWidgets.QLabel(self.widget_2) + self.label_24.setGeometry(QtCore.QRect(470, 240, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_24.setFont(font) + self.label_24.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_24.setObjectName("label_24") + self.textBrowser_2 = QtWidgets.QTextBrowser(self.widget_2) + self.textBrowser_2.setGeometry(QtCore.QRect(20, 10, 231, 51)) + self.textBrowser_2.setObjectName("textBrowser_2") + self.textBrowser_3 = QtWidgets.QTextBrowser(self.widget_2) + self.textBrowser_3.setGeometry(QtCore.QRect(20, 70, 231, 51)) + self.textBrowser_3.setObjectName("textBrowser_3") + self.textBrowser_4 = QtWidgets.QTextBrowser(self.widget_2) + self.textBrowser_4.setGeometry(QtCore.QRect(20, 130, 231, 51)) + self.textBrowser_4.setObjectName("textBrowser_4") + self.lineEdit_7 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_7.setGeometry(QtCore.QRect(270, 90, 181, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_7.setFont(font) + self.lineEdit_7.setStyleSheet("background-color: #ffffff") + self.lineEdit_7.setObjectName("lineEdit_7") + self.lineEdit_8 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_8.setGeometry(QtCore.QRect(270, 150, 181, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_8.setFont(font) + self.lineEdit_8.setStyleSheet("background-color: #ffffff") + self.lineEdit_8.setObjectName("lineEdit_8") + self.lineEdit_9 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_9.setGeometry(QtCore.QRect(270, 200, 181, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_9.setFont(font) + self.lineEdit_9.setStyleSheet("background-color: #ffffff") + self.lineEdit_9.setObjectName("lineEdit_9") + self.lineEdit_10 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_10.setGeometry(QtCore.QRect(270, 240, 181, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_10.setFont(font) + self.lineEdit_10.setStyleSheet("background-color: #ffffff") + self.lineEdit_10.setObjectName("lineEdit_10") + self.label_25 = QtWidgets.QLabel(self.widget_2) + self.label_25.setGeometry(QtCore.QRect(470, 150, 51, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_25.setFont(font) + self.label_25.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.label_25.setObjectName("label_25") + self.pushButton = QtWidgets.QPushButton(Maintenance_Dialog) + self.pushButton.setGeometry(QtCore.QRect(10, 35, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton.setFont(font) + self.pushButton.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton.setStyleSheet("background-color: rgb(240,230,230)") + self.pushButton.setIcon(icon) + self.pushButton.setAutoRepeat(False) + self.pushButton.setObjectName("pushButton") + self.scrollArea = QtWidgets.QScrollArea(Maintenance_Dialog) + self.scrollArea.setGeometry(QtCore.QRect(10, 65, 241, 681)) + self.scrollArea.setAutoFillBackground(False) + self.scrollArea.setStyleSheet("background-color: #fff9f9") + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents = QtWidgets.QWidget() + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 239, 679)) + self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") + self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_2.setGeometry(QtCore.QRect(0, 0, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_2.setFont(font) + self.label_2.setStyleSheet("background-color: rgb(240,230,230)") + self.label_2.setAlignment(QtCore.Qt.AlignCenter) + self.label_2.setObjectName("label_2") + self.widget = QtWidgets.QWidget(self.scrollAreaWidgetContents) + self.widget.setGeometry(QtCore.QRect(0, 30, 221, 357)) + self.widget.setStyleSheet("background-color: #fff9f9") + self.widget.setObjectName("widget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.pushButton_15 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_15.setFont(font) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled (1).png"), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.pushButton_15.setIcon(icon1) + self.pushButton_15.setCheckable(True) + self.pushButton_15.setAutoDefault(True) + self.pushButton_15.setObjectName("pushButton_15") + self.verticalLayout.addWidget(self.pushButton_15) + self.widget_5 = QtWidgets.QWidget(self.widget) + self.widget_5.setObjectName("widget_5") + self.formLayout = QtWidgets.QFormLayout(self.widget_5) + self.formLayout.setObjectName("formLayout") + self.pushButton_20 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openFoundationWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_20.setFont(font) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_20.setIcon(icon2) + self.pushButton_20.setObjectName("pushButton_20") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.pushButton_20) + self.pushButton_21 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSuperStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_21.setFont(font) + self.pushButton_21.setIcon(icon2) + self.pushButton_21.setObjectName("pushButton_21") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.pushButton_21) + self.pushButton_22 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openSubStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_22.setFont(font) + self.pushButton_22.setIcon(icon2) + self.pushButton_22.setObjectName("pushButton_22") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.pushButton_22) + self.pushButton_23 = QtWidgets.QPushButton(self.widget_5, clicked=lambda: self.openMiscellaneousWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_23.setFont(font) + self.pushButton_23.setIcon(icon2) + self.pushButton_23.setObjectName("pushButton_23") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pushButton_23) + self.verticalLayout.addWidget(self.widget_5) + self.pushButton_19 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openFinancialWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_19.setFont(font) + self.pushButton_19.setObjectName("pushButton_19") + self.verticalLayout.addWidget(self.pushButton_19) + self.pushButton_16 = QtWidgets.QPushButton(self.widget) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_16.setFont(font) + self.pushButton_16.setIcon(icon1) + self.pushButton_16.setCheckable(True) + self.pushButton_16.setObjectName("pushButton_16") + self.verticalLayout.addWidget(self.pushButton_16) + self.widget_8 = QtWidgets.QWidget(self.widget) + self.widget_8.setMinimumSize(QtCore.QSize(203, 21)) + self.widget_8.setMaximumSize(QtCore.QSize(281, 21)) + self.widget_8.setObjectName("widget_8") + self.pushButton_14 = QtWidgets.QPushButton(self.widget_8, clicked=lambda: self.openCarbonEmissionWindow()) + self.pushButton_14.setGeometry(QtCore.QRect(20, 0, 183, 21)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_14.setFont(font) + self.pushButton_14.setIcon(icon2) + self.pushButton_14.setObjectName("pushButton_14") + self.verticalLayout.addWidget(self.widget_8) + self.pushButton_17 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openBridgeTrafficWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_17.setFont(font) + self.pushButton_17.setObjectName("pushButton_17") + self.verticalLayout.addWidget(self.pushButton_17) + self.pushButton_18 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openMaintenanceWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_18.setFont(font) + self.pushButton_18.setObjectName("pushButton_18") + self.verticalLayout.addWidget(self.pushButton_18) + self.pushButton_10 = QtWidgets.QPushButton(self.widget, clicked=lambda: self.openDemolitionWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_10.setFont(font) + self.pushButton_10.setObjectName("pushButton_10") + self.verticalLayout.addWidget(self.pushButton_10) + self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents) + self.label_3.setGeometry(QtCore.QRect(0, 387, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_3.setFont(font) + self.label_3.setStyleSheet("background-color: rgb(240,230,230)") + self.label_3.setAlignment(QtCore.Qt.AlignCenter) + self.label_3.setObjectName("label_3") + self.textBrowser = QtWidgets.QTextBrowser(self.scrollAreaWidgetContents) + self.textBrowser.setGeometry(QtCore.QRect(0, 418, 221, 221)) + self.textBrowser.setStyleSheet("background-color: #fff9f9") + self.textBrowser.setObjectName("textBrowser") + self.verticalScrollBar = QtWidgets.QScrollBar(self.scrollAreaWidgetContents) + self.verticalScrollBar.setGeometry(QtCore.QRect(220, 0, 16, 641)) + self.verticalScrollBar.setStyleSheet("background-color: #F0F0F0") + self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical) + self.verticalScrollBar.setObjectName("verticalScrollBar") + self.widget.raise_() + self.label_2.raise_() + self.label_3.raise_() + self.textBrowser.raise_() + self.verticalScrollBar.raise_() + self.scrollArea.setWidget(self.scrollAreaWidgetContents) + + self.retranslateUi(Maintenance_Dialog) + self.buttonBox_2.accepted.connect(self.handle_save) # type: ignore + self.buttonBox_2.rejected.connect(lambda: self.show_warning(Maintenance_Dialog)) # type: ignore + self.pushButton_15.toggled['bool'].connect(self.widget_5.setVisible) # type: ignore + self.pushButton_16.toggled['bool'].connect(self.widget_8.setVisible) # type: ignore + QtCore.QMetaObject.connectSlotsByName(Maintenance_Dialog) + + def show_warning(self, dialog): + """ + Show a warning window when the Close button is pressed. + """ + warning_box = QMessageBox() + warning_box.setIcon(QMessageBox.Warning) + warning_box.setWindowTitle("Confirm Close") + warning_box.setText("Are you sure you want to close without saving?") + warning_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + warning_box.setDefaultButton(QMessageBox.No) + + # Check the user's response + response = warning_box.exec_() + if response == QMessageBox.Yes: + dialog.reject() # Close the application + else: + pass # Do nothing, return to the dialog + + def retranslateUi(self, Maintenance_Dialog): + _translate = QtCore.QCoreApplication.translate + Maintenance_Dialog.setWindowTitle(_translate("Maintenance_Dialog", "Maintenance and Repair Data")) + self.pushButton_6.setText(_translate("Maintenance_Dialog", "Maintenance and Repair Data ")) + self.label_4.setText(_translate("Maintenance_Dialog", "Frequency of Routine Inspection")) + self.label_5.setText(_translate("Maintenance_Dialog", "Investment Ratio")) + self.label_6.setText(_translate("Maintenance_Dialog", "Interest Rate")) + self.label_7.setText(_translate("Maintenance_Dialog", "Duration of Study ")) + self.label_8.setText(_translate("Maintenance_Dialog", "Frequency of Periodic Maintenance")) + self.label_21.setText(_translate("Maintenance_Dialog", "(%)")) + self.label_22.setText(_translate("Maintenance_Dialog", "(%)")) + self.label_23.setText(_translate("Maintenance_Dialog", "(years)")) + self.label_24.setText(_translate("Maintenance_Dialog", "(years)")) + self.textBrowser_2.setHtml(_translate("Maintenance_Dialog", "\n" +"\n" +"Periodic Maintenance Cost rate as percentage to total construction cost
")) + self.textBrowser_3.setHtml(_translate("Maintenance_Dialog", "\n" +"\n" +"Annual Routine Inspection cost rate as percentage of total construction cost
")) + self.textBrowser_4.setHtml(_translate("Maintenance_Dialog", "\n" +"\n" +"Repair and Rehabilitation cost rate as
percentage of total construction cost
Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate all numeric fields + float(self.lineEdit_5.text()) if self.lineEdit_5.text() else 0 # Periodic Maintenance Cost Rate + float(self.lineEdit_7.text()) if self.lineEdit_7.text() else 0 # Annual Routine Inspection Cost Rate + float(self.lineEdit_8.text()) if self.lineEdit_8.text() else 0 # Repair Rehabilitation Cost Rate + float(self.lineEdit_9.text()) if self.lineEdit_9.text() else 0 # Frequency of Periodic Maintenance + float(self.lineEdit_10.text()) if self.lineEdit_10.text() else 0 # Frequency of Routine Inspection + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + "periodic_maintenance": { + "cost_rate": self.lineEdit_5.text(), + "description": "Periodic Maintenance Cost rate as percentage to total construction cost" + }, + "routine_inspection": { + "cost_rate": self.lineEdit_7.text(), + "frequency": self.lineEdit_10.text(), + "description": "Annual Routine Inspection cost rate as percentage of total construction cost" + }, + "repair_rehabilitation": { + "cost_rate": self.lineEdit_8.text(), + "description": "Repair and Rehabilitation cost rate as percentage of total construction cost" + }, + "periodic_maintenance_frequency": self.lineEdit_9.text(), + "financial_parameters": { + "interest_rate": self.label_6.text().replace("(%)", "").strip(), + "investment_ratio": self.label_5.text().replace("(%)", "").strip(), + "study_duration": self.label_7.text().replace("(years)", "").strip() + } + } + + # Save to JSON file + try: + import json + from datetime import datetime + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"maintenance_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Maintenance data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + Maintenance_Dialog.accept() + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Maintenance_Dialog = QtWidgets.QDialog() + ui = Ui_Maintenance_Dialog() + ui.setupUi(Maintenance_Dialog) + Maintenance_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_Miscellaneous_Window.py b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_Miscellaneous_Window.py new file mode 100644 index 0000000..cfe53e2 --- /dev/null +++ b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_Miscellaneous_Window.py @@ -0,0 +1,743 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'C:\Users\saans\AppData\Local\Programs\Python\Python310\Lib\site-packages\qt5_applications\Qt\bin\ProjectDetails_Miscellaneous_Window.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QMessageBox + + + + + + +#from ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog + + + + +class Ui_Miscellaneous_Dialog(object): + def openBridgeTrafficWindow(self): + from ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_BridgeTraffic_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFoundationWindow(self): + from ProjectDetails_Foundation_Window import Ui_Foundation_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Foundation_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openCarbonEmissionWindow(self): + from ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_CarbonEmission_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openDemolitionWindow(self): + from ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Demolition_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFinancialWindow(self): + from ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_FinancialData_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMaintenanceWindow(self): + from ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Maintenance_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMiscellaneousWindow(self): + self.window = QtWidgets.QDialog() + self.ui = Ui_Miscellaneous_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSubStructureWindow(self): + from ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SubStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSuperStructureWindow(self): + from ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SuperStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def setupUi(self, Miscellaneous_Dialog): + Miscellaneous_Dialog.setObjectName("Miscellaneous_Dialog") + Miscellaneous_Dialog.resize(1440, 900) + Miscellaneous_Dialog.setStyleSheet("background-color:#FAFAFA") + self.pushButton = QtWidgets.QPushButton(Miscellaneous_Dialog) + self.pushButton.setGeometry(QtCore.QRect(10, 10, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton.setFont(font) + self.pushButton.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton.setStyleSheet("background-color: rgb(240,230,230)") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/Dismiss.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton.setIcon(icon) + self.pushButton.setAutoRepeat(False) + self.pushButton.setObjectName("pushButton") + self.widget_2 = QtWidgets.QWidget(Miscellaneous_Dialog) + self.widget_2.setGeometry(QtCore.QRect(350, 35, 778, 624)) + self.widget_2.setStyleSheet("background-color: #fff9f9") + self.widget_2.setObjectName("widget_2") + self.label_38 = QtWidgets.QLabel(self.widget_2) + self.label_38.setGeometry(QtCore.QRect(20, 10, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_38.setFont(font) + self.label_38.setObjectName("label_38") + self.comboBox_13 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_13.setGeometry(QtCore.QRect(140, 10, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox_13.setFont(font) + self.comboBox_13.setStyleSheet("background-color: #ffffff") + self.comboBox_13.setObjectName("comboBox_13") + self.comboBox_13.addItem("") + self.pushButton_10 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_10.setGeometry(QtCore.QRect(350, 10, 190, 23)) + self.pushButton_10.setStyleSheet("background-color: #ffffff") + self.pushButton_10.setObjectName("pushButton_10") + self.label_39 = QtWidgets.QLabel(self.widget_2) + self.label_39.setGeometry(QtCore.QRect(20, 70, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_39.setFont(font) + self.label_39.setAlignment(QtCore.Qt.AlignCenter) + self.label_39.setObjectName("label_39") + self.label_40 = QtWidgets.QLabel(self.widget_2) + self.label_40.setGeometry(QtCore.QRect(551, 70, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_40.setFont(font) + self.label_40.setAlignment(QtCore.Qt.AlignCenter) + self.label_40.setObjectName("label_40") + self.label_41 = QtWidgets.QLabel(self.widget_2) + self.label_41.setGeometry(QtCore.QRect(191, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_41.setFont(font) + self.label_41.setAlignment(QtCore.Qt.AlignCenter) + self.label_41.setObjectName("label_41") + self.label_42 = QtWidgets.QLabel(self.widget_2) + self.label_42.setGeometry(QtCore.QRect(311, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_42.setFont(font) + self.label_42.setAlignment(QtCore.Qt.AlignCenter) + self.label_42.setObjectName("label_42") + self.label_43 = QtWidgets.QLabel(self.widget_2) + self.label_43.setGeometry(QtCore.QRect(431, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_43.setFont(font) + self.label_43.setAlignment(QtCore.Qt.AlignCenter) + self.label_43.setObjectName("label_43") + self.comboBox_14 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_14.setGeometry(QtCore.QRect(30, 100, 140, 22)) + self.comboBox_14.setStyleSheet("background-color: #ffffff") + self.comboBox_14.setObjectName("comboBox_14") + self.comboBox_15 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_15.setGeometry(QtCore.QRect(30, 130, 140, 22)) + self.comboBox_15.setStyleSheet("background-color: #ffffff") + self.comboBox_15.setObjectName("comboBox_15") + self.lineEdit_25 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_25.setGeometry(QtCore.QRect(210, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_25.setFont(font) + self.lineEdit_25.setStyleSheet("background-color: #ffffff") + self.lineEdit_25.setObjectName("lineEdit_25") + self.lineEdit_26 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_26.setGeometry(QtCore.QRect(210, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_26.setFont(font) + self.lineEdit_26.setStyleSheet("background-color: #ffffff") + self.lineEdit_26.setObjectName("lineEdit_26") + self.label_44 = QtWidgets.QLabel(self.widget_2) + self.label_44.setGeometry(QtCore.QRect(340, 100, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_44.setFont(font) + self.label_44.setStyleSheet("background-color: #ffffff") + self.label_44.setAlignment(QtCore.Qt.AlignCenter) + self.label_44.setObjectName("label_44") + self.label_45 = QtWidgets.QLabel(self.widget_2) + self.label_45.setGeometry(QtCore.QRect(340, 130, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_45.setFont(font) + self.label_45.setStyleSheet("background-color: #ffffff") + self.label_45.setAlignment(QtCore.Qt.AlignCenter) + self.label_45.setObjectName("label_45") + self.lineEdit_27 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_27.setGeometry(QtCore.QRect(450, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_27.setFont(font) + self.lineEdit_27.setStyleSheet("background-color: #ffffff") + self.lineEdit_27.setObjectName("lineEdit_27") + self.lineEdit_28 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_28.setGeometry(QtCore.QRect(450, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_28.setFont(font) + self.lineEdit_28.setStyleSheet("background-color: #ffffff") + self.lineEdit_28.setObjectName("lineEdit_28") + self.lineEdit_29 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_29.setGeometry(QtCore.QRect(570, 100, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_29.setFont(font) + self.lineEdit_29.setStyleSheet("background-color: #ffffff") + self.lineEdit_29.setObjectName("lineEdit_29") + self.lineEdit_30 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_30.setGeometry(QtCore.QRect(570, 130, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_30.setFont(font) + self.lineEdit_30.setStyleSheet("background-color: #ffffff") + self.lineEdit_30.setObjectName("lineEdit_30") + self.pushButton_13 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_13.setGeometry(QtCore.QRect(300, 200, 190, 23)) + self.pushButton_13.setStyleSheet("background-color: #ffffff") + self.pushButton_13.setObjectName("pushButton_13") + self.label_46 = QtWidgets.QLabel(self.widget_2) + self.label_46.setGeometry(QtCore.QRect(30, 330, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_46.setFont(font) + self.label_46.setAlignment(QtCore.Qt.AlignCenter) + self.label_46.setObjectName("label_46") + self.comboBox_16 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_16.setGeometry(QtCore.QRect(150, 270, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox_16.setFont(font) + self.comboBox_16.setStyleSheet("background-color: #ffffff") + self.comboBox_16.setObjectName("comboBox_16") + self.comboBox_16.addItem("") + self.label_47 = QtWidgets.QLabel(self.widget_2) + self.label_47.setGeometry(QtCore.QRect(441, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_47.setFont(font) + self.label_47.setAlignment(QtCore.Qt.AlignCenter) + self.label_47.setObjectName("label_47") + self.label_48 = QtWidgets.QLabel(self.widget_2) + self.label_48.setGeometry(QtCore.QRect(350, 390, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_48.setFont(font) + self.label_48.setStyleSheet("background-color: #ffffff") + self.label_48.setAlignment(QtCore.Qt.AlignCenter) + self.label_48.setObjectName("label_48") + self.label_49 = QtWidgets.QLabel(self.widget_2) + self.label_49.setGeometry(QtCore.QRect(561, 330, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_49.setFont(font) + self.label_49.setAlignment(QtCore.Qt.AlignCenter) + self.label_49.setObjectName("label_49") + self.label_50 = QtWidgets.QLabel(self.widget_2) + self.label_50.setGeometry(QtCore.QRect(350, 360, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_50.setFont(font) + self.label_50.setStyleSheet("background-color: #ffffff") + self.label_50.setAlignment(QtCore.Qt.AlignCenter) + self.label_50.setObjectName("label_50") + self.label_51 = QtWidgets.QLabel(self.widget_2) + self.label_51.setGeometry(QtCore.QRect(321, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_51.setFont(font) + self.label_51.setAlignment(QtCore.Qt.AlignCenter) + self.label_51.setObjectName("label_51") + self.lineEdit_31 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_31.setGeometry(QtCore.QRect(220, 390, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_31.setFont(font) + self.lineEdit_31.setStyleSheet("background-color: #ffffff") + self.lineEdit_31.setObjectName("lineEdit_31") + self.lineEdit_32 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_32.setGeometry(QtCore.QRect(580, 360, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_32.setFont(font) + self.lineEdit_32.setStyleSheet("background-color: #ffffff") + self.lineEdit_32.setObjectName("lineEdit_32") + self.label_52 = QtWidgets.QLabel(self.widget_2) + self.label_52.setGeometry(QtCore.QRect(201, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_52.setFont(font) + self.label_52.setAlignment(QtCore.Qt.AlignCenter) + self.label_52.setObjectName("label_52") + self.pushButton_14 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_14.setGeometry(QtCore.QRect(310, 460, 190, 23)) + self.pushButton_14.setStyleSheet("background-color: #ffffff") + self.pushButton_14.setObjectName("pushButton_14") + self.lineEdit_33 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_33.setGeometry(QtCore.QRect(220, 360, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_33.setFont(font) + self.lineEdit_33.setStyleSheet("background-color: #ffffff") + self.lineEdit_33.setObjectName("lineEdit_33") + self.lineEdit_34 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_34.setGeometry(QtCore.QRect(460, 360, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_34.setFont(font) + self.lineEdit_34.setStyleSheet("background-color: #ffffff") + self.lineEdit_34.setObjectName("lineEdit_34") + self.lineEdit_35 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_35.setGeometry(QtCore.QRect(460, 390, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_35.setFont(font) + self.lineEdit_35.setStyleSheet("background-color: #ffffff") + self.lineEdit_35.setObjectName("lineEdit_35") + self.pushButton_15 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_15.setGeometry(QtCore.QRect(360, 270, 190, 23)) + self.pushButton_15.setStyleSheet("background-color: #ffffff") + self.pushButton_15.setObjectName("pushButton_15") + self.label_53 = QtWidgets.QLabel(self.widget_2) + self.label_53.setGeometry(QtCore.QRect(30, 270, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_53.setFont(font) + self.label_53.setObjectName("label_53") + self.lineEdit_36 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_36.setGeometry(QtCore.QRect(580, 390, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_36.setFont(font) + self.lineEdit_36.setStyleSheet("background-color: #ffffff") + self.lineEdit_36.setObjectName("lineEdit_36") + self.comboBox_17 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_17.setGeometry(QtCore.QRect(40, 360, 140, 22)) + self.comboBox_17.setStyleSheet("background-color: #ffffff") + self.comboBox_17.setObjectName("comboBox_17") + self.comboBox_17.addItem("") + self.comboBox_17.addItem("") + self.comboBox_18 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_18.setGeometry(QtCore.QRect(40, 390, 140, 22)) + self.comboBox_18.setStyleSheet("background-color: #ffffff") + self.comboBox_18.setObjectName("comboBox_18") + self.comboBox_18.addItem("") + self.comboBox_18.addItem("") + self.line_5 = QtWidgets.QFrame(self.widget_2) + self.line_5.setGeometry(QtCore.QRect(10, 250, 761, 16)) + self.line_5.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_5.setLineWidth(2) + self.line_5.setMidLineWidth(2) + self.line_5.setFrameShape(QtWidgets.QFrame.HLine) + self.line_5.setObjectName("line_5") + self.line_6 = QtWidgets.QFrame(self.widget_2) + self.line_6.setGeometry(QtCore.QRect(10, 500, 761, 16)) + self.line_6.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line_6.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_6.setLineWidth(2) + self.line_6.setMidLineWidth(2) + self.line_6.setFrameShape(QtWidgets.QFrame.HLine) + self.line_6.setObjectName("line_6") + self.buttonBox = QtWidgets.QDialogButtonBox(self.widget_2) + self.buttonBox.setGeometry(QtCore.QRect(430, 590, 341, 32)) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox.setObjectName("buttonBox") + self.label = QtWidgets.QLabel(Miscellaneous_Dialog) + self.label.setGeometry(QtCore.QRect(10, 35, 244, 691)) + font = QtGui.QFont() + font.setPointSize(10) + self.label.setFont(font) + self.label.setStyleSheet("background-color: rgb(240,230,230)") + self.label.setText("") + self.label.setObjectName("label") + self.pushButton_6 = QtWidgets.QPushButton(Miscellaneous_Dialog) + self.pushButton_6.setGeometry(QtCore.QRect(350, 10, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(True) + font.setWeight(75) + self.pushButton_6.setFont(font) + self.pushButton_6.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton_6.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton_6.setStyleSheet("background-color: rgb(240,230,230)") + self.pushButton_6.setIcon(icon) + self.pushButton_6.setAutoRepeat(False) + self.pushButton_6.setObjectName("pushButton_6") + self.scrollArea = QtWidgets.QScrollArea(Miscellaneous_Dialog) + self.scrollArea.setGeometry(QtCore.QRect(10, 40, 241, 681)) + self.scrollArea.setAutoFillBackground(False) + self.scrollArea.setStyleSheet("background-color: #fff9f9") + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() + self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 239, 679)) + self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") + self.label_54 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) + self.label_54.setGeometry(QtCore.QRect(0, 0, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_54.setFont(font) + self.label_54.setStyleSheet("background-color: rgb(240,230,230)") + self.label_54.setAlignment(QtCore.Qt.AlignCenter) + self.label_54.setObjectName("label_54") + self.widget_4 = QtWidgets.QWidget(self.scrollAreaWidgetContents_3) + self.widget_4.setGeometry(QtCore.QRect(0, 30, 221, 357)) + self.widget_4.setStyleSheet("background-color: #fff9f9") + self.widget_4.setObjectName("widget_4") + self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.widget_4) + self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.pushButton_34 = QtWidgets.QPushButton(self.widget_4) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_34.setFont(font) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled (1).png"), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.pushButton_34.setIcon(icon1) + self.pushButton_34.setCheckable(True) + self.pushButton_34.setAutoDefault(True) + self.pushButton_34.setObjectName("pushButton_34") + self.verticalLayout_3.addWidget(self.pushButton_34) + self.widget_7 = QtWidgets.QWidget(self.widget_4) + self.widget_7.setObjectName("widget_7") + self.formLayout_3 = QtWidgets.QFormLayout(self.widget_7) + self.formLayout_3.setObjectName("formLayout_3") + self.pushButton_35 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openFoundationWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_35.setFont(font) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_35.setIcon(icon2) + self.pushButton_35.setObjectName("pushButton_35") + self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.pushButton_35) + self.pushButton_36 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openSuperStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_36.setFont(font) + self.pushButton_36.setIcon(icon2) + self.pushButton_36.setObjectName("pushButton_36") + self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.pushButton_36) + self.pushButton_37 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openSubStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_37.setFont(font) + self.pushButton_37.setIcon(icon2) + self.pushButton_37.setObjectName("pushButton_37") + self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.pushButton_37) + self.pushButton_38 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openMiscellaneousWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_38.setFont(font) + self.pushButton_38.setIcon(icon2) + self.pushButton_38.setObjectName("pushButton_38") + self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pushButton_38) + self.verticalLayout_3.addWidget(self.widget_7) + self.pushButton_39 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openFinancialWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_39.setFont(font) + self.pushButton_39.setObjectName("pushButton_39") + self.verticalLayout_3.addWidget(self.pushButton_39) + self.pushButton_40 = QtWidgets.QPushButton(self.widget_4) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_40.setFont(font) + self.pushButton_40.setIcon(icon1) + self.pushButton_40.setCheckable(True) + self.pushButton_40.setObjectName("pushButton_40") + self.verticalLayout_3.addWidget(self.pushButton_40) + self.widget_10 = QtWidgets.QWidget(self.widget_4) + self.widget_10.setMinimumSize(QtCore.QSize(203, 21)) + self.widget_10.setMaximumSize(QtCore.QSize(281, 21)) + self.widget_10.setObjectName("widget_10") + self.pushButton_41 = QtWidgets.QPushButton(self.widget_10, clicked=lambda: self.openCarbonEmissionWindow()) + self.pushButton_41.setGeometry(QtCore.QRect(20, 0, 183, 21)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_41.setFont(font) + self.pushButton_41.setIcon(icon2) + self.pushButton_41.setObjectName("pushButton_41") + self.verticalLayout_3.addWidget(self.widget_10) + self.pushButton_42 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openBridgeTrafficWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_42.setFont(font) + self.pushButton_42.setObjectName("pushButton_42") + self.verticalLayout_3.addWidget(self.pushButton_42) + self.pushButton_43 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openMaintenanceWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_43.setFont(font) + self.pushButton_43.setObjectName("pushButton_43") + self.verticalLayout_3.addWidget(self.pushButton_43) + self.pushButton_16 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openDemolitionWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_16.setFont(font) + self.pushButton_16.setObjectName("pushButton_16") + self.verticalLayout_3.addWidget(self.pushButton_16) + self.label_55 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) + self.label_55.setGeometry(QtCore.QRect(0, 387, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_55.setFont(font) + self.label_55.setStyleSheet("background-color: rgb(240,230,230)") + self.label_55.setAlignment(QtCore.Qt.AlignCenter) + self.label_55.setObjectName("label_55") + self.textBrowser_3 = QtWidgets.QTextBrowser(self.scrollAreaWidgetContents_3) + self.textBrowser_3.setGeometry(QtCore.QRect(0, 418, 221, 221)) + self.textBrowser_3.setStyleSheet("background-color: #fff9f9") + self.textBrowser_3.setObjectName("textBrowser_3") + self.verticalScrollBar_3 = QtWidgets.QScrollBar(self.scrollAreaWidgetContents_3) + self.verticalScrollBar_3.setGeometry(QtCore.QRect(220, 0, 16, 641)) + self.verticalScrollBar_3.setStyleSheet("background-color: #F0F0F0") + self.verticalScrollBar_3.setOrientation(QtCore.Qt.Vertical) + self.verticalScrollBar_3.setObjectName("verticalScrollBar_3") + self.scrollArea.setWidget(self.scrollAreaWidgetContents_3) + + self.retranslateUi(Miscellaneous_Dialog) + self.buttonBox.accepted.connect(self.handle_save) # type: ignore + self.buttonBox.rejected.connect(lambda: self.show_warning(Miscellaneous_Dialog)) # type: ignore + QtCore.QMetaObject.connectSlotsByName(Miscellaneous_Dialog) + + def show_warning(self, dialog): + """ + Show a warning window when the Close button is pressed. + """ + warning_box = QMessageBox() + warning_box.setIcon(QMessageBox.Warning) + warning_box.setWindowTitle("Confirm Close") + warning_box.setText("Are you sure you want to close without saving?") + warning_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + warning_box.setDefaultButton(QMessageBox.No) + + # Check the user's response + response = warning_box.exec_() + if response == QMessageBox.Yes: + dialog.reject() # Close the application + else: + pass # Do nothing, return to the dialog + + def retranslateUi(self, Miscellaneous_Dialog): + _translate = QtCore.QCoreApplication.translate + Miscellaneous_Dialog.setWindowTitle(_translate("Miscellaneous_Dialog", "Dialog")) + self.pushButton.setText(_translate("Miscellaneous_Dialog", "Project Details Window ")) + self.label_38.setText(_translate("Miscellaneous_Dialog", "Components:")) + self.comboBox_13.setItemText(0, _translate("Miscellaneous_Dialog", "Expansion Joint")) + self.pushButton_10.setText(_translate("Miscellaneous_Dialog", "+ Add Sub-Component")) + self.label_39.setText(_translate("Miscellaneous_Dialog", "Material Type and Grade")) + self.label_40.setText(_translate("Miscellaneous_Dialog", "Rate Data Source")) + self.label_41.setText(_translate("Miscellaneous_Dialog", "Quantity")) + self.label_42.setText(_translate("Miscellaneous_Dialog", "Unit")) + self.label_43.setText(_translate("Miscellaneous_Dialog", "Rate")) + self.label_44.setText(_translate("Miscellaneous_Dialog", "m3
")) + self.label_45.setText(_translate("Miscellaneous_Dialog", "kg")) + self.pushButton_13.setText(_translate("Miscellaneous_Dialog", "+ Add Material")) + self.label_46.setText(_translate("Miscellaneous_Dialog", "Material Type and Grade")) + self.comboBox_16.setItemText(0, _translate("Miscellaneous_Dialog", "Bearing")) + self.label_47.setText(_translate("Miscellaneous_Dialog", "Rate")) + self.label_48.setText(_translate("Miscellaneous_Dialog", "kg")) + self.label_49.setText(_translate("Miscellaneous_Dialog", "Rate Data Source")) + self.label_50.setText(_translate("Miscellaneous_Dialog", "m3
")) + self.label_51.setText(_translate("Miscellaneous_Dialog", "Unit")) + self.label_52.setText(_translate("Miscellaneous_Dialog", "Quantity")) + self.pushButton_14.setText(_translate("Miscellaneous_Dialog", "+ Add Material")) + self.pushButton_15.setText(_translate("Miscellaneous_Dialog", "+ Add Sub-Component")) + self.label_53.setText(_translate("Miscellaneous_Dialog", "Components:")) + self.comboBox_17.setItemText(0, _translate("Miscellaneous_Dialog", "Concrete")) + self.comboBox_17.setItemText(1, _translate("Miscellaneous_Dialog", "Steel")) + self.comboBox_18.setItemText(0, _translate("Miscellaneous_Dialog", "Steel")) + self.comboBox_18.setItemText(1, _translate("Miscellaneous_Dialog", "Concrete")) + self.pushButton_6.setText(_translate("Miscellaneous_Dialog", "Miscellaneous ")) + self.label_54.setText(_translate("Miscellaneous_Dialog", "Input Parameters")) + self.pushButton_34.setText(_translate("Miscellaneous_Dialog", "Structure Works Data")) + self.pushButton_35.setText(_translate("Miscellaneous_Dialog", "Foundation")) + self.pushButton_36.setText(_translate("Miscellaneous_Dialog", "Super-Structure")) + self.pushButton_37.setText(_translate("Miscellaneous_Dialog", "Sub-Structure")) + self.pushButton_38.setText(_translate("Miscellaneous_Dialog", "Miscellaneous")) + self.pushButton_39.setText(_translate("Miscellaneous_Dialog", "Financial Data")) + self.pushButton_40.setText(_translate("Miscellaneous_Dialog", "Carbon Emission Data")) + self.pushButton_41.setText(_translate("Miscellaneous_Dialog", "Carbon Emission Cost Data")) + self.pushButton_42.setText(_translate("Miscellaneous_Dialog", "Bridge and Traffic Data")) + self.pushButton_43.setText(_translate("Miscellaneous_Dialog", "Maintenance and Repair")) + self.pushButton_16.setText(_translate("Miscellaneous_Dialog", "Disposal and Recycling")) + self.label_55.setText(_translate("Miscellaneous_Dialog", "Output")) + self.textBrowser_3.setHtml(_translate("Miscellaneous_Dialog", "\n" +"\n" +"Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate all numeric fields + fields_to_validate = [ + self.lineEdit_25, self.lineEdit_26, self.lineEdit_27, + self.lineEdit_28, self.lineEdit_29, self.lineEdit_30, + self.lineEdit_31, self.lineEdit_32, self.lineEdit_33, + self.lineEdit_34, self.lineEdit_35, self.lineEdit_36 + ] + + for field in fields_to_validate: + if field.text(): # Only validate if field is not empty + float(field.text()) + + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + "expansion_joint": { + "component": self.comboBox_13.currentText(), + "materials": [ + { + "type_grade": self.comboBox_14.currentText(), + "quantity": self.lineEdit_25.text(), + "unit": self.label_44.text(), + "rate": self.lineEdit_27.text(), + "rate_source": self.lineEdit_29.text() + }, + { + "type_grade": self.comboBox_15.currentText(), + "quantity": self.lineEdit_26.text(), + "unit": self.label_45.text(), + "rate": self.lineEdit_28.text(), + "rate_source": self.lineEdit_30.text() + } + ] + }, + "bearing": { + "component": self.comboBox_16.currentText(), + "materials": [ + { + "type_grade": self.comboBox_17.currentText(), + "quantity": self.lineEdit_33.text(), + "unit": self.label_50.text(), + "rate": self.lineEdit_34.text(), + "rate_source": self.lineEdit_32.text() + }, + { + "type_grade": self.comboBox_18.currentText(), + "quantity": self.lineEdit_31.text(), + "unit": self.label_48.text(), + "rate": self.lineEdit_35.text(), + "rate_source": self.lineEdit_36.text() + } + ] + } + } + + # Save to JSON file + try: + import json + from datetime import datetime + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"miscellaneous_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Miscellaneous data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + Miscellaneous_Dialog.accept() + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Miscellaneous_Dialog = QtWidgets.QDialog() + ui = Ui_Miscellaneous_Dialog() + ui.setupUi(Miscellaneous_Dialog) + Miscellaneous_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_SubStructure_Window.py b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_SubStructure_Window.py new file mode 100644 index 0000000..62f1c04 --- /dev/null +++ b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_SubStructure_Window.py @@ -0,0 +1,723 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'C:\Users\saans\AppData\Local\Programs\Python\Python310\Lib\site-packages\qt5_applications\Qt\bin\ProjectDetails_SubStructure_Window.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QMessageBox +#from Warning_Window import Ui_Warning_Dialog + + + + + + + +#from ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog + + + +class Ui_SubStructure_Dialog(object): + def openBridgeTrafficWindow(self): + from ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_BridgeTraffic_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFoundationWindow(self): + from ProjectDetails_Foundation_Window import Ui_Foundation_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Foundation_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openCarbonEmissionWindow(self): + from ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_CarbonEmission_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openDemolitionWindow(self): + from ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Demolition_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFinancialWindow(self): + from ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_FinancialData_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMaintenanceWindow(self): + from ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Maintenance_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMiscellaneousWindow(self): + from ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Miscellaneous_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSubStructureWindow(self): + self.window = QtWidgets.QDialog() + self.ui = Ui_SubStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSuperStructureWindow(self): + from ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SuperStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def setupUi(self, SubStructure_Dialog): + SubStructure_Dialog.setObjectName("SubStructure_Dialog") + SubStructure_Dialog.resize(1440, 900) + SubStructure_Dialog.setStyleSheet("background-color:#FAFAFA") + self.label = QtWidgets.QLabel(SubStructure_Dialog) + self.label.setGeometry(QtCore.QRect(10, 35, 244, 691)) + font = QtGui.QFont() + font.setPointSize(10) + self.label.setFont(font) + self.label.setStyleSheet("background-color: rgb(240,230,230)") + self.label.setText("") + self.label.setObjectName("label") + self.pushButton = QtWidgets.QPushButton(SubStructure_Dialog) + self.pushButton.setGeometry(QtCore.QRect(10, 10, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton.setFont(font) + self.pushButton.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton.setStyleSheet("background-color: rgb(240,230,230)") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/Dismiss.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton.setIcon(icon) + self.pushButton.setAutoRepeat(False) + self.pushButton.setObjectName("pushButton") + self.widget_2 = QtWidgets.QWidget(SubStructure_Dialog) + self.widget_2.setGeometry(QtCore.QRect(350, 35, 778, 624)) + self.widget_2.setStyleSheet("background-color: #fff9f9") + self.widget_2.setObjectName("widget_2") + self.label_38 = QtWidgets.QLabel(self.widget_2) + self.label_38.setGeometry(QtCore.QRect(20, 10, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_38.setFont(font) + self.label_38.setObjectName("label_38") + self.comboBox_13 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_13.setGeometry(QtCore.QRect(140, 10, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox_13.setFont(font) + self.comboBox_13.setStyleSheet("background-color: #ffffff") + self.comboBox_13.setObjectName("comboBox_13") + self.comboBox_13.addItem("") + self.pushButton_10 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_10.setGeometry(QtCore.QRect(350, 10, 190, 23)) + self.pushButton_10.setStyleSheet("background-color: #ffffff") + self.pushButton_10.setObjectName("pushButton_10") + self.label_39 = QtWidgets.QLabel(self.widget_2) + self.label_39.setGeometry(QtCore.QRect(20, 70, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_39.setFont(font) + self.label_39.setAlignment(QtCore.Qt.AlignCenter) + self.label_39.setObjectName("label_39") + self.label_40 = QtWidgets.QLabel(self.widget_2) + self.label_40.setGeometry(QtCore.QRect(551, 70, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_40.setFont(font) + self.label_40.setAlignment(QtCore.Qt.AlignCenter) + self.label_40.setObjectName("label_40") + self.label_41 = QtWidgets.QLabel(self.widget_2) + self.label_41.setGeometry(QtCore.QRect(191, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_41.setFont(font) + self.label_41.setAlignment(QtCore.Qt.AlignCenter) + self.label_41.setObjectName("label_41") + self.label_42 = QtWidgets.QLabel(self.widget_2) + self.label_42.setGeometry(QtCore.QRect(311, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_42.setFont(font) + self.label_42.setAlignment(QtCore.Qt.AlignCenter) + self.label_42.setObjectName("label_42") + self.label_43 = QtWidgets.QLabel(self.widget_2) + self.label_43.setGeometry(QtCore.QRect(431, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_43.setFont(font) + self.label_43.setAlignment(QtCore.Qt.AlignCenter) + self.label_43.setObjectName("label_43") + self.comboBox_14 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_14.setGeometry(QtCore.QRect(30, 100, 140, 22)) + self.comboBox_14.setStyleSheet("background-color: #ffffff") + self.comboBox_14.setObjectName("comboBox_14") + self.comboBox_15 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_15.setGeometry(QtCore.QRect(30, 130, 140, 22)) + self.comboBox_15.setStyleSheet("background-color: #ffffff") + self.comboBox_15.setObjectName("comboBox_15") + self.lineEdit_25 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_25.setGeometry(QtCore.QRect(210, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_25.setFont(font) + self.lineEdit_25.setStyleSheet("background-color: #ffffff") + self.lineEdit_25.setObjectName("lineEdit_25") + self.lineEdit_26 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_26.setGeometry(QtCore.QRect(210, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_26.setFont(font) + self.lineEdit_26.setStyleSheet("background-color: #ffffff") + self.lineEdit_26.setObjectName("lineEdit_26") + self.label_44 = QtWidgets.QLabel(self.widget_2) + self.label_44.setGeometry(QtCore.QRect(340, 100, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_44.setFont(font) + self.label_44.setStyleSheet("background-color: #ffffff") + self.label_44.setAlignment(QtCore.Qt.AlignCenter) + self.label_44.setObjectName("label_44") + self.label_45 = QtWidgets.QLabel(self.widget_2) + self.label_45.setGeometry(QtCore.QRect(340, 130, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_45.setFont(font) + self.label_45.setStyleSheet("background-color: #ffffff") + self.label_45.setAlignment(QtCore.Qt.AlignCenter) + self.label_45.setObjectName("label_45") + self.lineEdit_27 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_27.setGeometry(QtCore.QRect(450, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_27.setFont(font) + self.lineEdit_27.setStyleSheet("background-color: #ffffff") + self.lineEdit_27.setObjectName("lineEdit_27") + self.lineEdit_28 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_28.setGeometry(QtCore.QRect(450, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_28.setFont(font) + self.lineEdit_28.setStyleSheet("background-color: #ffffff") + self.lineEdit_28.setObjectName("lineEdit_28") + self.lineEdit_29 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_29.setGeometry(QtCore.QRect(570, 100, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_29.setFont(font) + self.lineEdit_29.setStyleSheet("background-color: #ffffff") + self.lineEdit_29.setObjectName("lineEdit_29") + self.lineEdit_30 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_30.setGeometry(QtCore.QRect(570, 130, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_30.setFont(font) + self.lineEdit_30.setStyleSheet("background-color: #ffffff") + self.lineEdit_30.setObjectName("lineEdit_30") + self.pushButton_13 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_13.setGeometry(QtCore.QRect(300, 200, 190, 23)) + self.pushButton_13.setStyleSheet("background-color: #ffffff") + self.pushButton_13.setObjectName("pushButton_13") + self.label_46 = QtWidgets.QLabel(self.widget_2) + self.label_46.setGeometry(QtCore.QRect(30, 330, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_46.setFont(font) + self.label_46.setAlignment(QtCore.Qt.AlignCenter) + self.label_46.setObjectName("label_46") + self.comboBox_16 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_16.setGeometry(QtCore.QRect(150, 270, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox_16.setFont(font) + self.comboBox_16.setStyleSheet("background-color: #ffffff") + self.comboBox_16.setObjectName("comboBox_16") + self.comboBox_16.addItem("") + self.label_47 = QtWidgets.QLabel(self.widget_2) + self.label_47.setGeometry(QtCore.QRect(441, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_47.setFont(font) + self.label_47.setAlignment(QtCore.Qt.AlignCenter) + self.label_47.setObjectName("label_47") + self.label_48 = QtWidgets.QLabel(self.widget_2) + self.label_48.setGeometry(QtCore.QRect(350, 390, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_48.setFont(font) + self.label_48.setStyleSheet("background-color: #ffffff") + self.label_48.setAlignment(QtCore.Qt.AlignCenter) + self.label_48.setObjectName("label_48") + self.label_49 = QtWidgets.QLabel(self.widget_2) + self.label_49.setGeometry(QtCore.QRect(561, 330, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_49.setFont(font) + self.label_49.setAlignment(QtCore.Qt.AlignCenter) + self.label_49.setObjectName("label_49") + self.label_50 = QtWidgets.QLabel(self.widget_2) + self.label_50.setGeometry(QtCore.QRect(350, 360, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_50.setFont(font) + self.label_50.setStyleSheet("background-color: #ffffff") + self.label_50.setAlignment(QtCore.Qt.AlignCenter) + self.label_50.setObjectName("label_50") + self.label_51 = QtWidgets.QLabel(self.widget_2) + self.label_51.setGeometry(QtCore.QRect(321, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_51.setFont(font) + self.label_51.setAlignment(QtCore.Qt.AlignCenter) + self.label_51.setObjectName("label_51") + self.lineEdit_31 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_31.setGeometry(QtCore.QRect(220, 390, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_31.setFont(font) + self.lineEdit_31.setStyleSheet("background-color: #ffffff") + self.lineEdit_31.setObjectName("lineEdit_31") + self.lineEdit_32 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_32.setGeometry(QtCore.QRect(580, 360, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_32.setFont(font) + self.lineEdit_32.setStyleSheet("background-color: #ffffff") + self.lineEdit_32.setObjectName("lineEdit_32") + self.label_52 = QtWidgets.QLabel(self.widget_2) + self.label_52.setGeometry(QtCore.QRect(201, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_52.setFont(font) + self.label_52.setAlignment(QtCore.Qt.AlignCenter) + self.label_52.setObjectName("label_52") + self.pushButton_14 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_14.setGeometry(QtCore.QRect(310, 460, 190, 23)) + self.pushButton_14.setStyleSheet("background-color: #ffffff") + self.pushButton_14.setObjectName("pushButton_14") + self.pushButton_15 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_15.setGeometry(QtCore.QRect(360, 270, 190, 23)) + self.pushButton_15.setStyleSheet("background-color: #ffffff") + self.pushButton_15.setObjectName("pushButton_15") + self.label_53 = QtWidgets.QLabel(self.widget_2) + self.label_53.setGeometry(QtCore.QRect(30, 270, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_53.setFont(font) + self.label_53.setObjectName("label_53") + self.lineEdit_36 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_36.setGeometry(QtCore.QRect(580, 390, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_36.setFont(font) + self.lineEdit_36.setStyleSheet("background-color: #ffffff") + self.lineEdit_36.setObjectName("lineEdit_36") + self.comboBox_17 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_17.setGeometry(QtCore.QRect(40, 360, 140, 22)) + self.comboBox_17.setStyleSheet("background-color: #ffffff") + self.comboBox_17.setObjectName("comboBox_17") + self.comboBox_17.addItem("") + self.comboBox_17.addItem("") + self.comboBox_18 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_18.setGeometry(QtCore.QRect(40, 390, 140, 22)) + self.comboBox_18.setStyleSheet("background-color: #ffffff") + self.comboBox_18.setObjectName("comboBox_18") + self.comboBox_18.addItem("") + self.comboBox_18.addItem("") + self.line_5 = QtWidgets.QFrame(self.widget_2) + self.line_5.setGeometry(QtCore.QRect(10, 250, 761, 16)) + self.line_5.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_5.setLineWidth(2) + self.line_5.setMidLineWidth(2) + self.line_5.setFrameShape(QtWidgets.QFrame.HLine) + self.line_5.setObjectName("line_5") + self.line_6 = QtWidgets.QFrame(self.widget_2) + self.line_6.setGeometry(QtCore.QRect(10, 500, 761, 16)) + self.line_6.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line_6.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_6.setLineWidth(2) + self.line_6.setMidLineWidth(2) + self.line_6.setFrameShape(QtWidgets.QFrame.HLine) + self.line_6.setObjectName("line_6") + self.buttonBox = QtWidgets.QDialogButtonBox(self.widget_2) + self.buttonBox.setGeometry(QtCore.QRect(430, 590, 341, 32)) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox.setObjectName("buttonBox") + self.pushButton_6 = QtWidgets.QPushButton(SubStructure_Dialog) + self.pushButton_6.setGeometry(QtCore.QRect(350, 10, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(True) + font.setWeight(75) + self.pushButton_6.setFont(font) + self.pushButton_6.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton_6.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton_6.setStyleSheet("background-color: rgb(240,230,230)") + self.pushButton_6.setIcon(icon) + self.pushButton_6.setAutoRepeat(False) + self.pushButton_6.setObjectName("pushButton_6") + self.scrollArea = QtWidgets.QScrollArea(SubStructure_Dialog) + self.scrollArea.setGeometry(QtCore.QRect(10, 40, 241, 681)) + self.scrollArea.setAutoFillBackground(False) + self.scrollArea.setStyleSheet("background-color: #fff9f9") + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() + self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 239, 679)) + self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") + self.label_54 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) + self.label_54.setGeometry(QtCore.QRect(0, 0, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_54.setFont(font) + self.label_54.setStyleSheet("background-color: rgb(240,230,230)") + self.label_54.setAlignment(QtCore.Qt.AlignCenter) + self.label_54.setObjectName("label_54") + self.widget_4 = QtWidgets.QWidget(self.scrollAreaWidgetContents_3) + self.widget_4.setGeometry(QtCore.QRect(0, 30, 221, 357)) + self.widget_4.setStyleSheet("background-color: #fff9f9") + self.widget_4.setObjectName("widget_4") + self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.widget_4) + self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.pushButton_34 = QtWidgets.QPushButton(self.widget_4) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_34.setFont(font) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled (1).png"), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.pushButton_34.setIcon(icon1) + self.pushButton_34.setCheckable(True) + self.pushButton_34.setAutoDefault(True) + self.pushButton_34.setObjectName("pushButton_34") + self.verticalLayout_3.addWidget(self.pushButton_34) + self.widget_7 = QtWidgets.QWidget(self.widget_4) + self.widget_7.setObjectName("widget_7") + self.formLayout_3 = QtWidgets.QFormLayout(self.widget_7) + self.formLayout_3.setObjectName("formLayout_3") + self.pushButton_35 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openFoundationWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_35.setFont(font) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_35.setIcon(icon2) + self.pushButton_35.setObjectName("pushButton_35") + self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.pushButton_35) + self.pushButton_36 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openSuperStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_36.setFont(font) + self.pushButton_36.setIcon(icon2) + self.pushButton_36.setObjectName("pushButton_36") + self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.pushButton_36) + self.pushButton_37 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openSubStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_37.setFont(font) + self.pushButton_37.setIcon(icon2) + self.pushButton_37.setObjectName("pushButton_37") + self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.pushButton_37) + self.pushButton_38 = QtWidgets.QPushButton(self.widget_7, clicked=lambda: self.openMiscellaneousWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_38.setFont(font) + self.pushButton_38.setIcon(icon2) + self.pushButton_38.setObjectName("pushButton_38") + self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pushButton_38) + self.verticalLayout_3.addWidget(self.widget_7) + self.pushButton_39 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openFinancialWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_39.setFont(font) + self.pushButton_39.setObjectName("pushButton_39") + self.verticalLayout_3.addWidget(self.pushButton_39) + self.pushButton_40 = QtWidgets.QPushButton(self.widget_4) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_40.setFont(font) + self.pushButton_40.setIcon(icon1) + self.pushButton_40.setCheckable(True) + self.pushButton_40.setObjectName("pushButton_40") + self.verticalLayout_3.addWidget(self.pushButton_40) + self.widget_10 = QtWidgets.QWidget(self.widget_4) + self.widget_10.setMinimumSize(QtCore.QSize(203, 21)) + self.widget_10.setMaximumSize(QtCore.QSize(281, 21)) + self.widget_10.setObjectName("widget_10") + self.pushButton_41 = QtWidgets.QPushButton(self.widget_10, clicked=lambda: self.openCarbonEmissionWindow()) + self.pushButton_41.setGeometry(QtCore.QRect(20, 0, 183, 21)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_41.setFont(font) + self.pushButton_41.setIcon(icon2) + self.pushButton_41.setObjectName("pushButton_41") + self.verticalLayout_3.addWidget(self.widget_10) + self.pushButton_42 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openBridgeTrafficWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_42.setFont(font) + self.pushButton_42.setObjectName("pushButton_42") + self.verticalLayout_3.addWidget(self.pushButton_42) + self.pushButton_43 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openMaintenanceWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_43.setFont(font) + self.pushButton_43.setObjectName("pushButton_43") + self.verticalLayout_3.addWidget(self.pushButton_43) + self.pushButton_16 = QtWidgets.QPushButton(self.widget_4, clicked=lambda: self.openDemolitionWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_16.setFont(font) + self.pushButton_16.setObjectName("pushButton_16") + self.verticalLayout_3.addWidget(self.pushButton_16) + self.label_55 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) + self.label_55.setGeometry(QtCore.QRect(0, 387, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_55.setFont(font) + self.label_55.setStyleSheet("background-color: rgb(240,230,230)") + self.label_55.setAlignment(QtCore.Qt.AlignCenter) + self.label_55.setObjectName("label_55") + self.textBrowser_3 = QtWidgets.QTextBrowser(self.scrollAreaWidgetContents_3) + self.textBrowser_3.setGeometry(QtCore.QRect(0, 418, 221, 221)) + self.textBrowser_3.setStyleSheet("background-color: #fff9f9") + self.textBrowser_3.setObjectName("textBrowser_3") + self.verticalScrollBar_3 = QtWidgets.QScrollBar(self.scrollAreaWidgetContents_3) + self.verticalScrollBar_3.setGeometry(QtCore.QRect(220, 0, 16, 641)) + self.verticalScrollBar_3.setStyleSheet("background-color: #F0F0F0") + self.verticalScrollBar_3.setOrientation(QtCore.Qt.Vertical) + self.verticalScrollBar_3.setObjectName("verticalScrollBar_3") + self.scrollArea.setWidget(self.scrollAreaWidgetContents_3) + + self.retranslateUi(SubStructure_Dialog) + self.buttonBox.accepted.connect(self.handle_save) # type: ignore# type: ignore + self.buttonBox.rejected.connect(lambda: self.show_warning(SubStructure_Dialog)) # type: ignore + #self.buttonBox.rejected.connect(SubStructure_Dialog.reject) + QtCore.QMetaObject.connectSlotsByName(SubStructure_Dialog) + + def show_warning(self, dialog): + """ + Show a warning window when the Close button is pressed. + """ + warning_box = QMessageBox() + warning_box.setIcon(QMessageBox.Warning) + warning_box.setWindowTitle("Confirm Close") + warning_box.setText("Are you sure you want to close without saving?") + warning_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + warning_box.setDefaultButton(QMessageBox.No) + + # Check the user's response + response = warning_box.exec_() + if response == QMessageBox.Yes: + dialog.reject() # Close the application + else: + pass # Do nothing, return to the dialog + + def retranslateUi(self, SubStructure_Dialog): + _translate = QtCore.QCoreApplication.translate + SubStructure_Dialog.setWindowTitle(_translate("SubStructure_Dialog", "Sub-Structure Dialog")) + self.pushButton.setText(_translate("SubStructure_Dialog", "Project Details Window ")) + self.label_38.setText(_translate("SubStructure_Dialog", "Components:")) + self.comboBox_13.setItemText(0, _translate("SubStructure_Dialog", "Piers")) + self.pushButton_10.setText(_translate("SubStructure_Dialog", "+ Add Sub-Component")) + self.label_39.setText(_translate("SubStructure_Dialog", "Material Type and Grade")) + self.label_40.setText(_translate("SubStructure_Dialog", "Rate Data Source")) + self.label_41.setText(_translate("SubStructure_Dialog", "Quantity")) + self.label_42.setText(_translate("SubStructure_Dialog", "Unit")) + self.label_43.setText(_translate("SubStructure_Dialog", "Rate")) + self.label_44.setText(_translate("SubStructure_Dialog", "m3
")) + self.label_45.setText(_translate("SubStructure_Dialog", "kg")) + self.pushButton_13.setText(_translate("SubStructure_Dialog", "+ Add Material")) + self.label_46.setText(_translate("SubStructure_Dialog", "Material Type and Grade")) + self.comboBox_16.setItemText(0, _translate("SubStructure_Dialog", "Abutment")) + self.label_47.setText(_translate("SubStructure_Dialog", "Rate")) + self.label_48.setText(_translate("SubStructure_Dialog", "kg")) + self.label_49.setText(_translate("SubStructure_Dialog", "Rate Data Source")) + self.label_50.setText(_translate("SubStructure_Dialog", "m3
")) + self.label_51.setText(_translate("SubStructure_Dialog", "Unit")) + self.label_52.setText(_translate("SubStructure_Dialog", "Quantity")) + self.pushButton_14.setText(_translate("SubStructure_Dialog", "+ Add Material")) + self.pushButton_15.setText(_translate("SubStructure_Dialog", "+ Add Sub-Component")) + self.label_53.setText(_translate("SubStructure_Dialog", "Components:")) + self.comboBox_17.setItemText(0, _translate("SubStructure_Dialog", "Concrete")) + self.comboBox_17.setItemText(1, _translate("SubStructure_Dialog", "Steel")) + self.comboBox_18.setItemText(0, _translate("SubStructure_Dialog", "Steel")) + self.comboBox_18.setItemText(1, _translate("SubStructure_Dialog", "Concrete")) + self.pushButton_6.setText(_translate("SubStructure_Dialog", "Sub-Structure ")) + self.label_54.setText(_translate("SubStructure_Dialog", "Input Parameters")) + self.pushButton_34.setText(_translate("SubStructure_Dialog", "Structure Works Data")) + self.pushButton_35.setText(_translate("SubStructure_Dialog", "Foundation")) + self.pushButton_36.setText(_translate("SubStructure_Dialog", "Super-Structure")) + self.pushButton_37.setText(_translate("SubStructure_Dialog", "Sub-Structure")) + self.pushButton_38.setText(_translate("SubStructure_Dialog", "Miscellaneous")) + self.pushButton_39.setText(_translate("SubStructure_Dialog", "Financial Data")) + self.pushButton_40.setText(_translate("SubStructure_Dialog", "Carbon Emission Data")) + self.pushButton_41.setText(_translate("SubStructure_Dialog", "Carbon Emission Cost Data")) + self.pushButton_42.setText(_translate("SubStructure_Dialog", "Bridge and Traffic Data")) + self.pushButton_43.setText(_translate("SubStructure_Dialog", "Maintenance and Repair")) + self.pushButton_16.setText(_translate("SubStructure_Dialog", "Disposal and Recycling")) + self.label_55.setText(_translate("SubStructure_Dialog", "Output")) + self.textBrowser_3.setHtml(_translate("SubStructure_Dialog", "\n" +"\n" +"Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate all numeric fields + fields_to_validate = [ + self.lineEdit_25, self.lineEdit_26, self.lineEdit_27, + self.lineEdit_28, self.lineEdit_29, self.lineEdit_30, + self.lineEdit_31, self.lineEdit_32, self.lineEdit_33, + self.lineEdit_34, self.lineEdit_35, self.lineEdit_36 + ] + + for field in fields_to_validate: + if field.text(): # Only validate if field is not empty + float(field.text()) + + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + "piers": { + "component": self.comboBox_13.currentText(), + "materials": [ + { + "type_grade": self.comboBox_14.currentText(), + "quantity": self.lineEdit_25.text(), + "unit": self.label_44.text(), + "rate": self.lineEdit_27.text(), + "rate_source": self.lineEdit_29.text() + }, + { + "type_grade": self.comboBox_15.currentText(), + "quantity": self.lineEdit_26.text(), + "unit": self.label_45.text(), + "rate": self.lineEdit_28.text(), + "rate_source": self.lineEdit_30.text() + } + ] + }, + "abutment": { + "component": self.comboBox_16.currentText(), + "materials": [ + { + "type_grade": self.comboBox_17.currentText(), + "quantity": self.lineEdit_33.text(), + "unit": self.label_50.text(), + "rate": self.lineEdit_34.text(), + "rate_source": self.lineEdit_32.text() + }, + { + "type_grade": self.comboBox_18.currentText(), + "quantity": self.lineEdit_31.text(), + "unit": self.label_48.text(), + "rate": self.lineEdit_35.text(), + "rate_source": self.lineEdit_36.text() + } + ] + } + } + + # Save to JSON file + try: + import json + from datetime import datetime + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"substructure_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Sub-structure data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + SubStructure_Dialog.accept() + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + SubStructure_Dialog = QtWidgets.QDialog() + ui = Ui_SubStructure_Dialog() + ui.setupUi(SubStructure_Dialog) + SubStructure_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_SuperStructure_Window.py b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_SuperStructure_Window.py new file mode 100644 index 0000000..d407f2d --- /dev/null +++ b/src/osbridgelcca/desktop_app/ui/project_details_windows/ProjectDetails_SuperStructure_Window.py @@ -0,0 +1,742 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'C:\Users\saans\AppData\Local\Programs\Python\Python310\Lib\site-packages\qt5_applications\Qt\bin\ProjectDetails_SuperStructure_Window.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtWidgets import QMessageBox + + + + + + + + +#from ProjectDetails_SuperStructure_Window import Ui_SuperStructure_Dialog + + +class Ui_SuperStructure_Dialog(object): + def openBridgeTrafficWindow(self): + from ProjectDetails_BridgeANDTrafficData_Window import Ui_BridgeTraffic_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_BridgeTraffic_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFoundationWindow(self): + from ProjectDetails_Foundation_Window import Ui_Foundation_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Foundation_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openCarbonEmissionWindow(self): + from ProjectDetails_CarbonEmissionData_Window import Ui_CarbonEmission_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_CarbonEmission_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openDemolitionWindow(self): + from ProjectDetails_DemolitionANDRecyclingData_Window import Ui_Demolition_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Demolition_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openFinancialWindow(self): + from ProjectDetails_FinancialData_Window import Ui_FinancialData_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_FinancialData_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMaintenanceWindow(self): + from ProjectDetails_MaintenanceANDRepairData_Window import Ui_Maintenance_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Maintenance_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openMiscellaneousWindow(self): + from ProjectDetails_Miscellaneous_Window import Ui_Miscellaneous_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_Miscellaneous_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSubStructureWindow(self): + from ProjectDetails_SubStructure_Window import Ui_SubStructure_Dialog + self.window = QtWidgets.QDialog() + self.ui = Ui_SubStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def openSuperStructureWindow(self): + self.window = QtWidgets.QDialog() + self.ui = Ui_SuperStructure_Dialog() + self.ui.setupUi(self.window) + self.window.show() + + def setupUi(self, SuperStructure_Dialog): + SuperStructure_Dialog.setObjectName("SuperStructure_Dialog") + SuperStructure_Dialog.resize(1440, 900) + SuperStructure_Dialog.setStyleSheet("background-color:#FAFAFA") + self.label = QtWidgets.QLabel(SuperStructure_Dialog) + self.label.setGeometry(QtCore.QRect(10, 35, 244, 691)) + font = QtGui.QFont() + font.setPointSize(10) + self.label.setFont(font) + self.label.setStyleSheet("background-color: rgb(240,230,230)") + self.label.setText("") + self.label.setObjectName("label") + self.pushButton_6 = QtWidgets.QPushButton(SuperStructure_Dialog) + self.pushButton_6.setGeometry(QtCore.QRect(350, 10, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(True) + font.setWeight(75) + self.pushButton_6.setFont(font) + self.pushButton_6.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton_6.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton_6.setStyleSheet("background-color: rgb(240,230,230)") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/Dismiss.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_6.setIcon(icon) + self.pushButton_6.setAutoRepeat(False) + self.pushButton_6.setObjectName("pushButton_6") + self.widget_2 = QtWidgets.QWidget(SuperStructure_Dialog) + self.widget_2.setGeometry(QtCore.QRect(350, 35, 778, 624)) + self.widget_2.setStyleSheet("background-color: #fff9f9") + self.widget_2.setObjectName("widget_2") + self.label_20 = QtWidgets.QLabel(self.widget_2) + self.label_20.setGeometry(QtCore.QRect(20, 10, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_20.setFont(font) + self.label_20.setObjectName("label_20") + self.comboBox_7 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_7.setGeometry(QtCore.QRect(140, 10, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox_7.setFont(font) + self.comboBox_7.setStyleSheet("background-color: #ffffff") + self.comboBox_7.setObjectName("comboBox_7") + self.comboBox_7.addItem("") + self.pushButton_7 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_7.setGeometry(QtCore.QRect(350, 10, 190, 23)) + self.pushButton_7.setStyleSheet("background-color: #ffffff") + self.pushButton_7.setObjectName("pushButton_7") + self.label_21 = QtWidgets.QLabel(self.widget_2) + self.label_21.setGeometry(QtCore.QRect(20, 70, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_21.setFont(font) + self.label_21.setAlignment(QtCore.Qt.AlignCenter) + self.label_21.setObjectName("label_21") + self.label_22 = QtWidgets.QLabel(self.widget_2) + self.label_22.setGeometry(QtCore.QRect(551, 70, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_22.setFont(font) + self.label_22.setAlignment(QtCore.Qt.AlignCenter) + self.label_22.setObjectName("label_22") + self.label_23 = QtWidgets.QLabel(self.widget_2) + self.label_23.setGeometry(QtCore.QRect(191, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_23.setFont(font) + self.label_23.setAlignment(QtCore.Qt.AlignCenter) + self.label_23.setObjectName("label_23") + self.label_24 = QtWidgets.QLabel(self.widget_2) + self.label_24.setGeometry(QtCore.QRect(311, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_24.setFont(font) + self.label_24.setAlignment(QtCore.Qt.AlignCenter) + self.label_24.setObjectName("label_24") + self.label_25 = QtWidgets.QLabel(self.widget_2) + self.label_25.setGeometry(QtCore.QRect(431, 70, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_25.setFont(font) + self.label_25.setAlignment(QtCore.Qt.AlignCenter) + self.label_25.setObjectName("label_25") + self.comboBox_8 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_8.setGeometry(QtCore.QRect(30, 100, 140, 22)) + self.comboBox_8.setStyleSheet("background-color: #ffffff") + self.comboBox_8.setObjectName("comboBox_8") + self.comboBox_9 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_9.setGeometry(QtCore.QRect(30, 130, 140, 22)) + self.comboBox_9.setStyleSheet("background-color: #ffffff") + self.comboBox_9.setObjectName("comboBox_9") + self.lineEdit_13 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_13.setGeometry(QtCore.QRect(210, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_13.setFont(font) + self.lineEdit_13.setStyleSheet("background-color: #ffffff") + self.lineEdit_13.setObjectName("lineEdit_13") + self.lineEdit_14 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_14.setGeometry(QtCore.QRect(210, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_14.setFont(font) + self.lineEdit_14.setStyleSheet("background-color: #ffffff") + self.lineEdit_14.setObjectName("lineEdit_14") + self.label_26 = QtWidgets.QLabel(self.widget_2) + self.label_26.setGeometry(QtCore.QRect(340, 100, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_26.setFont(font) + self.label_26.setStyleSheet("background-color: #ffffff") + self.label_26.setAlignment(QtCore.Qt.AlignCenter) + self.label_26.setObjectName("label_26") + self.label_27 = QtWidgets.QLabel(self.widget_2) + self.label_27.setGeometry(QtCore.QRect(340, 130, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_27.setFont(font) + self.label_27.setStyleSheet("background-color: #ffffff") + self.label_27.setAlignment(QtCore.Qt.AlignCenter) + self.label_27.setObjectName("label_27") + self.lineEdit_15 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_15.setGeometry(QtCore.QRect(450, 100, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_15.setFont(font) + self.lineEdit_15.setStyleSheet("background-color: #ffffff") + self.lineEdit_15.setObjectName("lineEdit_15") + self.lineEdit_16 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_16.setGeometry(QtCore.QRect(450, 130, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_16.setFont(font) + self.lineEdit_16.setStyleSheet("background-color: #ffffff") + self.lineEdit_16.setObjectName("lineEdit_16") + self.lineEdit_17 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_17.setGeometry(QtCore.QRect(570, 100, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_17.setFont(font) + self.lineEdit_17.setStyleSheet("background-color: #ffffff") + self.lineEdit_17.setObjectName("lineEdit_17") + self.lineEdit_18 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_18.setGeometry(QtCore.QRect(570, 130, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_18.setFont(font) + self.lineEdit_18.setStyleSheet("background-color: #ffffff") + self.lineEdit_18.setObjectName("lineEdit_18") + self.pushButton_8 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_8.setGeometry(QtCore.QRect(300, 200, 190, 23)) + self.pushButton_8.setStyleSheet("background-color: #ffffff") + self.pushButton_8.setObjectName("pushButton_8") + self.label_28 = QtWidgets.QLabel(self.widget_2) + self.label_28.setGeometry(QtCore.QRect(30, 330, 161, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_28.setFont(font) + self.label_28.setAlignment(QtCore.Qt.AlignCenter) + self.label_28.setObjectName("label_28") + self.comboBox_10 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_10.setGeometry(QtCore.QRect(150, 270, 190, 22)) + font = QtGui.QFont() + font.setPointSize(10) + self.comboBox_10.setFont(font) + self.comboBox_10.setStyleSheet("background-color: #ffffff") + self.comboBox_10.setObjectName("comboBox_10") + self.comboBox_10.addItem("") + self.label_29 = QtWidgets.QLabel(self.widget_2) + self.label_29.setGeometry(QtCore.QRect(441, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_29.setFont(font) + self.label_29.setAlignment(QtCore.Qt.AlignCenter) + self.label_29.setObjectName("label_29") + self.label_30 = QtWidgets.QLabel(self.widget_2) + self.label_30.setGeometry(QtCore.QRect(350, 390, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_30.setFont(font) + self.label_30.setStyleSheet("background-color: #ffffff") + self.label_30.setAlignment(QtCore.Qt.AlignCenter) + self.label_30.setObjectName("label_30") + self.label_31 = QtWidgets.QLabel(self.widget_2) + self.label_31.setGeometry(QtCore.QRect(561, 330, 140, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_31.setFont(font) + self.label_31.setAlignment(QtCore.Qt.AlignCenter) + self.label_31.setObjectName("label_31") + self.label_32 = QtWidgets.QLabel(self.widget_2) + self.label_32.setGeometry(QtCore.QRect(350, 360, 51, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_32.setFont(font) + self.label_32.setStyleSheet("background-color: #ffffff") + self.label_32.setAlignment(QtCore.Qt.AlignCenter) + self.label_32.setObjectName("label_32") + self.label_33 = QtWidgets.QLabel(self.widget_2) + self.label_33.setGeometry(QtCore.QRect(321, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_33.setFont(font) + self.label_33.setAlignment(QtCore.Qt.AlignCenter) + self.label_33.setObjectName("label_33") + self.lineEdit_19 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_19.setGeometry(QtCore.QRect(220, 390, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_19.setFont(font) + self.lineEdit_19.setStyleSheet("background-color: #ffffff") + self.lineEdit_19.setObjectName("lineEdit_19") + self.lineEdit_20 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_20.setGeometry(QtCore.QRect(580, 360, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_20.setFont(font) + self.lineEdit_20.setStyleSheet("background-color: #ffffff") + self.lineEdit_20.setObjectName("lineEdit_20") + self.label_34 = QtWidgets.QLabel(self.widget_2) + self.label_34.setGeometry(QtCore.QRect(201, 330, 110, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_34.setFont(font) + self.label_34.setAlignment(QtCore.Qt.AlignCenter) + self.label_34.setObjectName("label_34") + self.pushButton_9 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_9.setGeometry(QtCore.QRect(310, 460, 190, 23)) + self.pushButton_9.setStyleSheet("background-color: #ffffff") + self.pushButton_9.setObjectName("pushButton_9") + self.lineEdit_21 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_21.setGeometry(QtCore.QRect(220, 360, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_21.setFont(font) + self.lineEdit_21.setStyleSheet("background-color: #ffffff") + self.lineEdit_21.setObjectName("lineEdit_21") + self.lineEdit_22 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_22.setGeometry(QtCore.QRect(460, 360, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_22.setFont(font) + self.lineEdit_22.setStyleSheet("background-color: #ffffff") + self.lineEdit_22.setObjectName("lineEdit_22") + self.lineEdit_23 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_23.setGeometry(QtCore.QRect(460, 390, 81, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_23.setFont(font) + self.lineEdit_23.setStyleSheet("background-color: #ffffff") + self.lineEdit_23.setObjectName("lineEdit_23") + self.pushButton_11 = QtWidgets.QPushButton(self.widget_2) + self.pushButton_11.setGeometry(QtCore.QRect(360, 270, 190, 23)) + self.pushButton_11.setStyleSheet("background-color: #ffffff") + self.pushButton_11.setObjectName("pushButton_11") + self.label_35 = QtWidgets.QLabel(self.widget_2) + self.label_35.setGeometry(QtCore.QRect(30, 270, 91, 21)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_35.setFont(font) + self.label_35.setObjectName("label_35") + self.lineEdit_24 = QtWidgets.QLineEdit(self.widget_2) + self.lineEdit_24.setGeometry(QtCore.QRect(580, 390, 101, 20)) + font = QtGui.QFont() + font.setPointSize(10) + self.lineEdit_24.setFont(font) + self.lineEdit_24.setStyleSheet("background-color: #ffffff") + self.lineEdit_24.setObjectName("lineEdit_24") + self.comboBox_11 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_11.setGeometry(QtCore.QRect(40, 360, 140, 22)) + self.comboBox_11.setStyleSheet("background-color: #ffffff") + self.comboBox_11.setObjectName("comboBox_11") + self.comboBox_11.addItem("") + self.comboBox_11.addItem("") + self.comboBox_12 = QtWidgets.QComboBox(self.widget_2) + self.comboBox_12.setGeometry(QtCore.QRect(40, 390, 140, 22)) + self.comboBox_12.setStyleSheet("background-color: #ffffff") + self.comboBox_12.setObjectName("comboBox_12") + self.comboBox_12.addItem("") + self.comboBox_12.addItem("") + self.line_3 = QtWidgets.QFrame(self.widget_2) + self.line_3.setGeometry(QtCore.QRect(10, 250, 761, 16)) + self.line_3.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_3.setLineWidth(2) + self.line_3.setMidLineWidth(2) + self.line_3.setFrameShape(QtWidgets.QFrame.HLine) + self.line_3.setObjectName("line_3") + self.line_4 = QtWidgets.QFrame(self.widget_2) + self.line_4.setGeometry(QtCore.QRect(10, 500, 761, 16)) + self.line_4.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_4.setLineWidth(2) + self.line_4.setMidLineWidth(2) + self.line_4.setFrameShape(QtWidgets.QFrame.HLine) + self.line_4.setObjectName("line_4") + self.buttonBox = QtWidgets.QDialogButtonBox(self.widget_2) + self.buttonBox.setGeometry(QtCore.QRect(430, 580, 341, 32)) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close|QtWidgets.QDialogButtonBox.Save) + self.buttonBox.setObjectName("buttonBox") + self.scrollArea = QtWidgets.QScrollArea(SuperStructure_Dialog) + self.scrollArea.setGeometry(QtCore.QRect(10, 40, 241, 681)) + self.scrollArea.setAutoFillBackground(False) + self.scrollArea.setStyleSheet("background-color: #fff9f9") + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents_2 = QtWidgets.QWidget() + self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 239, 679)) + self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") + self.label_36 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2) + self.label_36.setGeometry(QtCore.QRect(0, 0, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_36.setFont(font) + self.label_36.setStyleSheet("background-color: rgb(240,230,230)") + self.label_36.setAlignment(QtCore.Qt.AlignCenter) + self.label_36.setObjectName("label_36") + self.widget_3 = QtWidgets.QWidget(self.scrollAreaWidgetContents_2) + self.widget_3.setGeometry(QtCore.QRect(0, 30, 221, 357)) + self.widget_3.setStyleSheet("background-color: #fff9f9") + self.widget_3.setObjectName("widget_3") + self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget_3) + self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.pushButton_24 = QtWidgets.QPushButton(self.widget_3) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_24.setFont(font) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled (1).png"), QtGui.QIcon.Normal, QtGui.QIcon.On) + self.pushButton_24.setIcon(icon1) + self.pushButton_24.setCheckable(True) + self.pushButton_24.setAutoDefault(True) + self.pushButton_24.setObjectName("pushButton_24") + self.verticalLayout_2.addWidget(self.pushButton_24) + self.widget_6 = QtWidgets.QWidget(self.widget_3) + self.widget_6.setObjectName("widget_6") + self.formLayout_2 = QtWidgets.QFormLayout(self.widget_6) + self.formLayout_2.setObjectName("formLayout_2") + self.pushButton_25 = QtWidgets.QPushButton(self.widget_6, clicked=lambda: self.openFoundationWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_25.setFont(font) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap("C:\\Users\\saans\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\qt5_applications\\Qt\\bin\\../../../../../../../../../../Downloads/play_arrow_filled.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton_25.setIcon(icon2) + self.pushButton_25.setObjectName("pushButton_25") + self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.pushButton_25) + self.pushButton_26 = QtWidgets.QPushButton(self.widget_6, clicked=lambda: self.openSuperStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_26.setFont(font) + self.pushButton_26.setIcon(icon2) + self.pushButton_26.setObjectName("pushButton_26") + self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.pushButton_26) + self.pushButton_27 = QtWidgets.QPushButton(self.widget_6, clicked=lambda: self.openSubStructureWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_27.setFont(font) + self.pushButton_27.setIcon(icon2) + self.pushButton_27.setObjectName("pushButton_27") + self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.pushButton_27) + self.pushButton_28 = QtWidgets.QPushButton(self.widget_6, clicked=lambda: self.openMiscellaneousWindow()) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_28.setFont(font) + self.pushButton_28.setIcon(icon2) + self.pushButton_28.setObjectName("pushButton_28") + self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.pushButton_28) + self.verticalLayout_2.addWidget(self.widget_6) + self.pushButton_29 = QtWidgets.QPushButton(self.widget_3, clicked=lambda: self.openFinancialWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_29.setFont(font) + self.pushButton_29.setObjectName("pushButton_29") + self.verticalLayout_2.addWidget(self.pushButton_29) + self.pushButton_30 = QtWidgets.QPushButton(self.widget_3) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_30.setFont(font) + self.pushButton_30.setIcon(icon1) + self.pushButton_30.setCheckable(True) + self.pushButton_30.setObjectName("pushButton_30") + self.verticalLayout_2.addWidget(self.pushButton_30) + self.widget_9 = QtWidgets.QWidget(self.widget_3) + self.widget_9.setMinimumSize(QtCore.QSize(203, 21)) + self.widget_9.setMaximumSize(QtCore.QSize(281, 21)) + self.widget_9.setObjectName("widget_9") + self.pushButton_31 = QtWidgets.QPushButton(self.widget_9, clicked=lambda: self.openCarbonEmissionWindow()) + self.pushButton_31.setGeometry(QtCore.QRect(20, 0, 183, 21)) + font = QtGui.QFont() + font.setPointSize(10) + font.setBold(False) + font.setWeight(50) + self.pushButton_31.setFont(font) + self.pushButton_31.setIcon(icon2) + self.pushButton_31.setObjectName("pushButton_31") + self.verticalLayout_2.addWidget(self.widget_9) + self.pushButton_32 = QtWidgets.QPushButton(self.widget_3, clicked=lambda: self.openBridgeTrafficWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_32.setFont(font) + self.pushButton_32.setObjectName("pushButton_32") + self.verticalLayout_2.addWidget(self.pushButton_32) + self.pushButton_33 = QtWidgets.QPushButton(self.widget_3, clicked=lambda: self.openMaintenanceWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_33.setFont(font) + self.pushButton_33.setObjectName("pushButton_33") + self.verticalLayout_2.addWidget(self.pushButton_33) + self.pushButton_12 = QtWidgets.QPushButton(self.widget_3, clicked=lambda: self.openDemolitionWindow()) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton_12.setFont(font) + self.pushButton_12.setObjectName("pushButton_12") + self.verticalLayout_2.addWidget(self.pushButton_12) + self.label_37 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2) + self.label_37.setGeometry(QtCore.QRect(0, 387, 221, 31)) + font = QtGui.QFont() + font.setPointSize(10) + self.label_37.setFont(font) + self.label_37.setStyleSheet("background-color: rgb(240,230,230)") + self.label_37.setAlignment(QtCore.Qt.AlignCenter) + self.label_37.setObjectName("label_37") + self.textBrowser_2 = QtWidgets.QTextBrowser(self.scrollAreaWidgetContents_2) + self.textBrowser_2.setGeometry(QtCore.QRect(0, 418, 221, 221)) + self.textBrowser_2.setStyleSheet("background-color: #fff9f9") + self.textBrowser_2.setObjectName("textBrowser_2") + self.verticalScrollBar_2 = QtWidgets.QScrollBar(self.scrollAreaWidgetContents_2) + self.verticalScrollBar_2.setGeometry(QtCore.QRect(220, 0, 16, 641)) + self.verticalScrollBar_2.setStyleSheet("background-color: #F0F0F0") + self.verticalScrollBar_2.setOrientation(QtCore.Qt.Vertical) + self.verticalScrollBar_2.setObjectName("verticalScrollBar_2") + self.scrollArea.setWidget(self.scrollAreaWidgetContents_2) + self.pushButton = QtWidgets.QPushButton(SuperStructure_Dialog) + self.pushButton.setGeometry(QtCore.QRect(10, 10, 188, 25)) + font = QtGui.QFont() + font.setPointSize(10) + self.pushButton.setFont(font) + self.pushButton.setFocusPolicy(QtCore.Qt.StrongFocus) + self.pushButton.setLayoutDirection(QtCore.Qt.RightToLeft) + self.pushButton.setStyleSheet("background-color: rgb(240,230,230)") + self.pushButton.setIcon(icon) + self.pushButton.setAutoRepeat(False) + self.pushButton.setObjectName("pushButton") + + self.retranslateUi(SuperStructure_Dialog) + self.buttonBox.accepted.connect(self.handle_save) # type: ignore + self.buttonBox.rejected.connect(lambda: self.show_warning(SuperStructure_Dialog)) # type: ignore + QtCore.QMetaObject.connectSlotsByName(SuperStructure_Dialog) + + def show_warning(self, dialog): + """ + Show a warning window when the Close button is pressed. + """ + warning_box = QMessageBox() + warning_box.setIcon(QMessageBox.Warning) + warning_box.setWindowTitle("Confirm Close") + warning_box.setText("Are you sure you want to close without saving?") + warning_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + warning_box.setDefaultButton(QMessageBox.No) + + # Check the user's response + response = warning_box.exec_() + if response == QMessageBox.Yes: + dialog.reject() # Close the application + else: + pass # Do nothing, return to the dialog + + def retranslateUi(self, SuperStructure_Dialog): + _translate = QtCore.QCoreApplication.translate + SuperStructure_Dialog.setWindowTitle(_translate("SuperStructure_Dialog", "Dialog")) + self.pushButton_6.setText(_translate("SuperStructure_Dialog", "Super-Structure ")) + self.label_20.setText(_translate("SuperStructure_Dialog", "Components:")) + self.comboBox_7.setItemText(0, _translate("SuperStructure_Dialog", "Deck")) + self.pushButton_7.setText(_translate("SuperStructure_Dialog", "+ Add Sub-Component")) + self.label_21.setText(_translate("SuperStructure_Dialog", "Material Type and Grade")) + self.label_22.setText(_translate("SuperStructure_Dialog", "Rate Data Source")) + self.label_23.setText(_translate("SuperStructure_Dialog", "Quantity")) + self.label_24.setText(_translate("SuperStructure_Dialog", "Unit")) + self.label_25.setText(_translate("SuperStructure_Dialog", "Rate")) + self.label_26.setText(_translate("SuperStructure_Dialog", "m3
")) + self.label_27.setText(_translate("SuperStructure_Dialog", "kg")) + self.pushButton_8.setText(_translate("SuperStructure_Dialog", "+ Add Material")) + self.label_28.setText(_translate("SuperStructure_Dialog", "Material Type and Grade")) + self.comboBox_10.setItemText(0, _translate("SuperStructure_Dialog", "Cables")) + self.label_29.setText(_translate("SuperStructure_Dialog", "Rate")) + self.label_30.setText(_translate("SuperStructure_Dialog", "kg")) + self.label_31.setText(_translate("SuperStructure_Dialog", "Rate Data Source")) + self.label_32.setText(_translate("SuperStructure_Dialog", "m3
")) + self.label_33.setText(_translate("SuperStructure_Dialog", "Unit")) + self.label_34.setText(_translate("SuperStructure_Dialog", "Quantity")) + self.pushButton_9.setText(_translate("SuperStructure_Dialog", "+ Add Material")) + self.pushButton_11.setText(_translate("SuperStructure_Dialog", "+ Add Sub-Component")) + self.label_35.setText(_translate("SuperStructure_Dialog", "Components:")) + self.comboBox_11.setItemText(0, _translate("SuperStructure_Dialog", "Concrete")) + self.comboBox_11.setItemText(1, _translate("SuperStructure_Dialog", "Steel")) + self.comboBox_12.setItemText(0, _translate("SuperStructure_Dialog", "Steel")) + self.comboBox_12.setItemText(1, _translate("SuperStructure_Dialog", "Concrete")) + self.label_36.setText(_translate("SuperStructure_Dialog", "Input Parameters")) + self.pushButton_24.setText(_translate("SuperStructure_Dialog", "Structure Works Data")) + self.pushButton_25.setText(_translate("SuperStructure_Dialog", "Foundation")) + self.pushButton_26.setText(_translate("SuperStructure_Dialog", "Super-Structure")) + self.pushButton_27.setText(_translate("SuperStructure_Dialog", "Sub-Structure")) + self.pushButton_28.setText(_translate("SuperStructure_Dialog", "Miscellaneous")) + self.pushButton_29.setText(_translate("SuperStructure_Dialog", "Financial Data")) + self.pushButton_30.setText(_translate("SuperStructure_Dialog", "Carbon Emission Data")) + self.pushButton_31.setText(_translate("SuperStructure_Dialog", "Carbon Emission Cost Data")) + self.pushButton_32.setText(_translate("SuperStructure_Dialog", "Bridge and Traffic Data")) + self.pushButton_33.setText(_translate("SuperStructure_Dialog", "Maintenance and Repair")) + self.pushButton_12.setText(_translate("SuperStructure_Dialog", "Disposal and Recycling")) + self.label_37.setText(_translate("SuperStructure_Dialog", "Output")) + self.textBrowser_2.setHtml(_translate("SuperStructure_Dialog", "\n" +"\n" +"Initial Construction Cost
\n" +"Initial Carbon emission Cost
\n" +"Time Cost
\n" +"Road User Cost
\n" +"Carbon Emission due to Re-Routing
\n" +"Periodic Maintenance Costs
\n" +"Maintenance Emission Costs
\n" +"Routine Inspectection Costs
\n" +"Repair & Rehabilitation Costs
\n" +"Reconstruction Costs
\n" +"Demolition & Disposal Cost
\n" +"Recycling Cost
\n" +"Total Life-Cycle Cost
")) + self.pushButton.setText(_translate("SuperStructure_Dialog", "Project Details Window ")) + + def validate_data(self): + """Validate input data before saving""" + try: + # Validate all numeric fields + fields_to_validate = [ + self.lineEdit_13, self.lineEdit_14, self.lineEdit_15, + self.lineEdit_16, self.lineEdit_17, self.lineEdit_18, + self.lineEdit_19, self.lineEdit_20, self.lineEdit_21, + self.lineEdit_22, self.lineEdit_23, self.lineEdit_24 + ] + + for field in fields_to_validate: + if field.text(): # Only validate if field is not empty + float(field.text()) + + return True + + except ValueError: + QMessageBox.warning( + None, + "Validation Error", + "Please enter valid numbers in all numeric fields", + QMessageBox.Ok + ) + return False + + def save_data(self): + """Collect all input data and save it to a JSON file""" + if not self.validate_data(): + return False + + data = { + "deck": { + "component": self.comboBox_7.currentText(), + "materials": [ + { + "type_grade": self.comboBox_8.currentText(), + "quantity": self.lineEdit_13.text(), + "unit": self.label_26.text(), + "rate": self.lineEdit_15.text(), + "rate_source": self.lineEdit_17.text() + }, + { + "type_grade": self.comboBox_9.currentText(), + "quantity": self.lineEdit_14.text(), + "unit": self.label_27.text(), + "rate": self.lineEdit_16.text(), + "rate_source": self.lineEdit_18.text() + } + ] + }, + "cables": { + "component": self.comboBox_10.currentText(), + "materials": [ + { + "type_grade": self.comboBox_11.currentText(), + "quantity": self.lineEdit_21.text(), + "unit": self.label_32.text(), + "rate": self.lineEdit_22.text(), + "rate_source": self.lineEdit_20.text() + }, + { + "type_grade": self.comboBox_12.currentText(), + "quantity": self.lineEdit_19.text(), + "unit": self.label_30.text(), + "rate": self.lineEdit_23.text(), + "rate_source": self.lineEdit_24.text() + } + ] + } + } + + # Save to JSON file + try: + import json + from datetime import datetime + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = f"superstructure_data_{timestamp}.json" + + with open(filename, 'w') as f: + json.dump(data, f, indent=4) + + # Show success message + QMessageBox.information( + None, + "Success", + f"Super-structure data saved successfully to {filename}", + QMessageBox.Ok + ) + + return True + + except Exception as e: + QMessageBox.critical( + None, + "Error", + f"Failed to save data: {str(e)}", + QMessageBox.Ok + ) + return False + + def handle_save(self): + """Handle the save operation and close the dialog if successful""" + if self.save_data(): # Only close if save was successful + SuperStructure_Dialog.accept() + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + SuperStructure_Dialog = QtWidgets.QDialog() + ui = Ui_SuperStructure_Dialog() + ui.setupUi(SuperStructure_Dialog) + SuperStructure_Dialog.show() + sys.exit(app.exec_()) diff --git a/src/osbridgelcca/web_app/src/components/InputForm.jsx b/src/osbridgelcca/web_app/src_web/components/InputForm.jsx similarity index 100% rename from src/osbridgelcca/web_app/src/components/InputForm.jsx rename to src/osbridgelcca/web_app/src_web/components/InputForm.jsx diff --git a/src/osbridgelcca/web_app/src/components/ResultsView.jsx b/src/osbridgelcca/web_app/src_web/components/ResultsView.jsx similarity index 100% rename from src/osbridgelcca/web_app/src/components/ResultsView.jsx rename to src/osbridgelcca/web_app/src_web/components/ResultsView.jsx diff --git a/src/osbridgelcca/web_app/src/services/api.js b/src/osbridgelcca/web_app/src_web/services/api.js similarity index 100% rename from src/osbridgelcca/web_app/src/services/api.js rename to src/osbridgelcca/web_app/src_web/services/api.js diff --git a/tests/unit_tests/conftest.py b/tests/unit_tests/conftest.py index a0993b8..afb922a 100644 --- a/tests/unit_tests/conftest.py +++ b/tests/unit_tests/conftest.py @@ -1,12 +1,5 @@ -import pytest -from backend.main import app as flask_app +import sys +import os -@pytest.fixture -def client(): - """Flask test client""" - return flask_app.test_client() - -@pytest.fixture -def sample_cost_data(): - """Sample cost data for testing""" - return {"quantity": 100, "rate": 500} +# Add the src_web directory to sys.path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../src_web'))) diff --git a/tests/unit_tests/test_cost_components.py b/tests/unit_tests/test_cost_components.py new file mode 100644 index 0000000..9f0fc0b --- /dev/null +++ b/tests/unit_tests/test_cost_components.py @@ -0,0 +1,58 @@ +import pytest +from src.osbridgelcca.core.cost_components import ( + InitialConstructionCost, + InitialCarbonEmissionCost, + TimeCost, + RoadUserCost, + ReroutingCarbonEmissionCost, + PeriodicMaintenanceCost, + PeriodicMaintenanceCarbonCost, + RoutineInspectionCost, + RepairAndRehabilitationCost, + DemolitionCost, + RecyclingCost, +) + +def test_initial_construction_cost(): + cost = InitialConstructionCost(quantity=100, rate=50) + assert cost.calculate_cost() == 5000 + +def test_initial_carbon_emission_cost(): + cost = InitialCarbonEmissionCost(material_quantity=100, carbon_emission_factor=2, carbon_cost=10) + assert cost.calculate_cost() == 2000 + +def test_time_cost(): + cost = TimeCost(construction_cost=10000, interest_rate=0.05, construction_time=2, investment_ratio=0.8) + assert cost.calculate_cost() == 800.0 + +def test_road_user_cost(): + cost = RoadUserCost(vehicles_affected=1000, vehicle_operation_cost=2, construction_time=5) + assert cost.calculate_cost() == 10000 + +def test_additional_carbon_emission_cost(): + cost = ReroutingCarbonEmissionCost(vehicles_affected=1000, reroute_distance=10, co2_emission_per_km=0.5, carbon_cost=20) + assert cost.calculate_cost() == 100000.0 + +def test_periodic_maintenance_cost(): + cost = PeriodicMaintenanceCost(maintenance_cost_rate=0.02, construction_cost=100000, discount_rate=0.03, period=5, design_life=50) + assert cost.calculate_cost() > 0 # Ensure cost is calculated + +def test_periodic_maintenance_carbon_cost(): + cost = PeriodicMaintenanceCarbonCost(material_quantity=500, carbon_emission_factor=1.5, carbon_cost=20, discount_rate=0.03, period=5, design_life=50) + assert cost.calculate_cost() > 0 + +def test_routine_inspection_cost(): + cost = RoutineInspectionCost(quantity=10, rate=1000, discount_rate=0.03, design_life=50) + assert cost.calculate_cost() > 0 + +def test_repair_and_rehabilitation_cost(): + cost = RepairAndRehabilitationCost(repair_cost_rate=0.1, construction_cost=100000, discount_rate=0.03, period=10, design_life=50) + assert cost.calculate_cost() > 0 + +def test_demolition_cost(): + cost = DemolitionCost(demolition_rate=0.05, construction_cost=100000, discount_rate=0.03, design_life=50) + assert cost.calculate_cost() > 0 + +def test_recycling_cost(): + cost = RecyclingCost(scrap_value=1000, quantity=10, discount_rate=0.03, design_life=50) + assert cost.calculate_cost() > 0