From 699965230d742ce7d6f2a3fec6ee507c9633c219 Mon Sep 17 00:00:00 2001 From: "Stevan.Gavrilovic" Date: Wed, 9 Aug 2023 10:54:00 -0700 Subject: [PATCH 1/3] Implemented REDi recovery module and updated PBE for Qt6 --- LossModel/HazusGeneralSettingsContainer.cpp | 14 +- LossModel/LossModelSelection.cpp | 2 +- LossModel/PelicunCollapseLimit.cpp | 2 +- LossModel/PelicunCollapseMode.cpp | 10 +- LossModel/PelicunComponentContainer.cpp | 14 +- LossModel/PelicunComponentGroup.cpp | 2 +- LossModel/PelicunDamageContainer.cpp | 16 +- LossModel/PelicunDemandContainer.cpp | 18 +- LossModel/PelicunLossRepairContainer.cpp | 16 +- LossModel/PelicunOutputsContainer.cpp | 2 +- LossModel/PelicunPopulationGroup.cpp | 2 +- LossModel/PelicunResidualParams.cpp | 2 +- LossModel/PelicunShared.cpp | 10 +- LossModel/PelicunShared.h | 3 +- LossModel/PelicunTruncationLimit.cpp | 2 +- LossModel/PerformanceMethodSelection.cpp | 239 ++++++++++++++++++ LossModel/PerformanceMethodSelection.h | 90 +++++++ PBE.pro | 42 ++- .../PerformanceMethodSelection.cpp | 66 +++++ .../PerformanceMethodSelection.h | 61 +++++ PerformanceMethod/REDiWidget.cpp | 149 +++++++++++ PerformanceMethod/REDiWidget.h | 71 ++++++ ResultsPelicun.cpp | 89 ++++++- ResultsPelicun.h | 5 +- WorkflowAppPBE.cpp | 34 ++- WorkflowAppPBE.h | 2 + main.cpp | 2 +- 27 files changed, 876 insertions(+), 89 deletions(-) create mode 100644 LossModel/PerformanceMethodSelection.cpp create mode 100644 LossModel/PerformanceMethodSelection.h create mode 100644 PerformanceMethod/PerformanceMethodSelection.cpp create mode 100644 PerformanceMethod/PerformanceMethodSelection.h create mode 100644 PerformanceMethod/REDiWidget.cpp create mode 100644 PerformanceMethod/REDiWidget.h diff --git a/LossModel/HazusGeneralSettingsContainer.cpp b/LossModel/HazusGeneralSettingsContainer.cpp index 2f14dff..d4e1f6f 100644 --- a/LossModel/HazusGeneralSettingsContainer.cpp +++ b/LossModel/HazusGeneralSettingsContainer.cpp @@ -97,7 +97,7 @@ HazusGeneralSettingsContainer::HazusGeneralSettingsContainer(QWidget *parent) EDP_dataLayout->addWidget(EDPFilePath); EDP_dataLayout->addWidget(chooseEDP_data); EDP_dataLayout->setSpacing(1); - EDP_dataLayout->setMargin(0); + EDP_dataLayout->setContentsMargins(0,0,0,0); responseFormLayout->addRow(tr(" EDP data: "), EDP_dataLayout); // EDP distribution @@ -443,7 +443,7 @@ HazusGeneralSettingsContainer::HazusGeneralSettingsContainer(QWidget *parent) populationLayout->addWidget(populationFilePath); populationLayout->addWidget(choosePopulation); populationLayout->setSpacing(1); - populationLayout->setMargin(0); + populationLayout->setContentsMargins(0,0,0,0); lossFormLayout->addRow(tr(" Custom distribution: "), populationLayout); @@ -464,7 +464,7 @@ HazusGeneralSettingsContainer::HazusGeneralSettingsContainer(QWidget *parent) fragilityLayout->addWidget(fragilityFolderPath); fragilityLayout->addWidget(chooseFragility); fragilityLayout->setSpacing(1); - fragilityLayout->setMargin(0); + fragilityLayout->setContentsMargins(0,0,0,0); lossFormLayout->addRow(tr("Custom DL data: "), fragilityLayout); @@ -486,24 +486,24 @@ HazusGeneralSettingsContainer::HazusGeneralSettingsContainer(QWidget *parent) mainV1Layout->addWidget(responseGroupBox); mainV1Layout->addStretch(1); mainV1Layout->setSpacing(10); - mainV1Layout->setMargin(0); + mainV1Layout->setContentsMargins(0,0,0,0); mainV2Layout->addWidget(damageGroupBox); mainV2Layout->addStretch(1); mainV2Layout->setSpacing(10); - mainV2Layout->setMargin(0); + mainV2Layout->setContentsMargins(0,0,0,0); mainV3Layout->addWidget(lossGroupBox); mainV3Layout->addStretch(1); mainV3Layout->setSpacing(10); - mainV3Layout->setMargin(0); + mainV3Layout->setContentsMargins(0,0,0,0); mainHLayout->addLayout(mainV1Layout, 1); mainHLayout->addLayout(mainV2Layout, 1); mainHLayout->addLayout(mainV3Layout, 1); mainHLayout->addStretch(); mainHLayout->setSpacing(10); - mainHLayout->setMargin(0); + mainHLayout->setContentsMargins(0,0,0,0); mainLayout->addLayout(titleLayout); mainLayout->addLayout(mainHLayout, 0); diff --git a/LossModel/LossModelSelection.cpp b/LossModel/LossModelSelection.cpp index e4036a3..8dc85a5 100644 --- a/LossModel/LossModelSelection.cpp +++ b/LossModel/LossModelSelection.cpp @@ -98,7 +98,7 @@ LossModelSelection::LossModelSelection( // add the stacked widget to the main layout layout->addWidget(sa); - layout->setMargin(0); + layout->setContentsMargins(0,0,0,0); this->setLayout(layout); theCurrentMethod=thePelicunWidget; diff --git a/LossModel/PelicunCollapseLimit.cpp b/LossModel/PelicunCollapseLimit.cpp index 84fc134..98469f8 100644 --- a/LossModel/PelicunCollapseLimit.cpp +++ b/LossModel/PelicunCollapseLimit.cpp @@ -84,7 +84,7 @@ CollapseLimit::CollapseLimit(QWidget *parent, QMap *CL_data_in mainLayout->addWidget(clDemandLimit); mainLayout->addStretch(); mainLayout->setSpacing(10); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0,0,0,0);; this->setLayout(mainLayout); } diff --git a/LossModel/PelicunCollapseMode.cpp b/LossModel/PelicunCollapseMode.cpp index 2abf6fe..b538684 100644 --- a/LossModel/PelicunCollapseMode.cpp +++ b/LossModel/PelicunCollapseMode.cpp @@ -64,7 +64,7 @@ CollapseMode::CollapseMode(QWidget *parent) nameLayout->addWidget(collapseModeLabel); nameLayout->addWidget(collapseModeName); nameLayout->setSpacing(1); - nameLayout->setMargin(0); + nameLayout->setContentsMargins(0,0,0,0);; // Vertical layout for collapse mode probability QVBoxLayout * probabilityLayout = new QVBoxLayout(); @@ -78,7 +78,7 @@ CollapseMode::CollapseMode(QWidget *parent) probabilityLayout->addWidget(probabilityLabel); probabilityLayout->addWidget(collapseModeProbability); probabilityLayout->setSpacing(1); - probabilityLayout->setMargin(0); + probabilityLayout->setContentsMargins(0,0,0,0);; // Vertical layout to deal with the area affected by the collapse mode QVBoxLayout * affectedAreaLayout = new QVBoxLayout(); @@ -95,7 +95,7 @@ CollapseMode::CollapseMode(QWidget *parent) affectedAreaLayout->addWidget(collapseModeAffectedAreaLabel); affectedAreaLayout->addWidget(collapseModeAffectedArea); affectedAreaLayout->setSpacing(1); - affectedAreaLayout->setMargin(0); + affectedAreaLayout->setContentsMargins(0,0,0,0); // Vertical layout to deal with collapse mode injuries QVBoxLayout * injuriesLayout = new QVBoxLayout(); @@ -110,7 +110,7 @@ CollapseMode::CollapseMode(QWidget *parent) injuriesLayout->addWidget(collapseModeInjuriesLabel); injuriesLayout->addWidget(collapseModeInjuries); injuriesLayout->setSpacing(1); - injuriesLayout->setMargin(0); + injuriesLayout->setContentsMargins(0,0,0,0); button = new QRadioButton(); @@ -125,7 +125,7 @@ CollapseMode::CollapseMode(QWidget *parent) mainLayout->addLayout(injuriesLayout); mainLayout->addStretch(); mainLayout->setSpacing(10); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0,0,0,0); this->setLayout(mainLayout); } diff --git a/LossModel/PelicunComponentContainer.cpp b/LossModel/PelicunComponentContainer.cpp index 4af90f2..723a547 100644 --- a/LossModel/PelicunComponentContainer.cpp +++ b/LossModel/PelicunComponentContainer.cpp @@ -513,7 +513,7 @@ PelicunComponentContainer::PelicunComponentContainer(QWidget *parent) loPGroup_header->addStretch(); loPGroup_header->setSpacing(10); - loPGroup_header->setMargin(0); + loPGroup_header->setContentsMargins(0,0,0,0);; loPDetails->addLayout(loPGroup_header); @@ -537,7 +537,7 @@ PelicunComponentContainer::PelicunComponentContainer(QWidget *parent) QWidget *PGWidget = new QWidget; loPGList = new QVBoxLayout(); loPGList->addStretch(); - loPGList->setMargin(0); + loPGList->setContentsMargins(0,0,0,0);; PGWidget->setLayout(loPGList); POPQuantityList->setWidget(PGWidget); @@ -842,7 +842,7 @@ PelicunComponentContainer::PelicunComponentContainer(QWidget *parent) loCGroup_header->addStretch(); loCGroup_header->setSpacing(10); - loCGroup_header->setMargin(0); + loCGroup_header->setContentsMargins(0,0,0,0);; loCDetails->addLayout(loCGroup_header); @@ -854,7 +854,7 @@ PelicunComponentContainer::PelicunComponentContainer(QWidget *parent) loCQuantityRemove->addSpacing(2); loCQuantityRemove->setSpacing(5); - loCQuantityRemove->setMargin(0); + loCQuantityRemove->setContentsMargins(0,0,0,0);; smRemoveCG = new QSignalMapper(this); connect(smRemoveCG, SIGNAL(mapped(QWidget*)), this, @@ -871,7 +871,7 @@ PelicunComponentContainer::PelicunComponentContainer(QWidget *parent) loCGList = new QVBoxLayout(); loCGList->setAlignment(Qt::AlignTop); loCGList->setSpacing(5); - loCGList->setMargin(0); + loCGList->setContentsMargins(0,0,0,0);; CGWidget->setLayout(loCGList); saQuantityList->setWidget(CGWidget); @@ -1462,7 +1462,7 @@ PelicunComponentContainer::exportComponentVulnerabilityDB(void) { // copy the db file(s) to the desired location //QFileInfo fi = leAdditionalComponentDB->text(); - QFileInfo fi = cmpVulnerabilityDB; + QFileInfo fi = QFileInfo(cmpVulnerabilityDB); //QFileInfo fi = this->updateComponentVulnerabilityDB(); // get the filenames @@ -1733,7 +1733,7 @@ PelicunComponentContainer::loadComponentAssignment(QString filePath) { CG_data -> insert("comment", line_list[6]); } } else { - this->statusMessage("Error while parsing line " + QString(counter) + " in the config file"); + this->statusMessage("Error while parsing line " + QString::number(counter) + " in the config file"); } } diff --git a/LossModel/PelicunComponentGroup.cpp b/LossModel/PelicunComponentGroup.cpp index 69c12b6..a76ff20 100644 --- a/LossModel/PelicunComponentGroup.cpp +++ b/LossModel/PelicunComponentGroup.cpp @@ -175,7 +175,7 @@ ComponentGroup::ComponentGroup(QWidget *parent, QMap *CG_data_ //mainLayout->addWidget(button); mainLayout->addStretch(); mainLayout->setSpacing(10); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0,0,0,0); this->setLayout(mainLayout); } diff --git a/LossModel/PelicunDamageContainer.cpp b/LossModel/PelicunDamageContainer.cpp index e387b4e..ce80405 100644 --- a/LossModel/PelicunDamageContainer.cpp +++ b/LossModel/PelicunDamageContainer.cpp @@ -74,7 +74,7 @@ PelicunDamageContainer::PelicunDamageContainer(QWidget *parent) // Excessive RID QHBoxLayout *residualDriftLayout = new QHBoxLayout(); - residualDriftLayout->setMargin(0); + residualDriftLayout->setContentsMargins(0,0,0,0);; excessiveRID = new QCheckBox(); excessiveRID->setText(""); @@ -94,12 +94,12 @@ PelicunDamageContainer::PelicunDamageContainer(QWidget *parent) irreparableSettings = new QWidget(); QVBoxLayout * loIrrepV = new QVBoxLayout(irreparableSettings); - loIrrepV->setMargin(0); + loIrrepV->setContentsMargins(0,0,0,0);; // - - - - QHBoxLayout *loExcRIDHeader = new QHBoxLayout(); - loExcRIDHeader->setMargin(0); + loExcRIDHeader->setContentsMargins(0,0,0,0);; QLabel *lblPlaceHolder = new QLabel(); lblPlaceHolder->setText(""); @@ -128,7 +128,7 @@ PelicunDamageContainer::PelicunDamageContainer(QWidget *parent) // - - - - QHBoxLayout *loExcRIDValues = new QHBoxLayout(); - loExcRIDValues->setMargin(0); + loExcRIDValues->setContentsMargins(0,0,0,0);; QLabel *lblRIDCapacity = new QLabel(); lblRIDCapacity->setText("Drift Capacity: "); @@ -177,7 +177,7 @@ PelicunDamageContainer::PelicunDamageContainer(QWidget *parent) // Collapse QHBoxLayout *collapseLayout = new QHBoxLayout(); - collapseLayout->setMargin(0); + collapseLayout->setContentsMargins(0,0,0,0);; collapseCheck = new QCheckBox(); collapseCheck->setText(""); @@ -197,12 +197,12 @@ PelicunDamageContainer::PelicunDamageContainer(QWidget *parent) collapseSettings = new QWidget(); QVBoxLayout * loColSetV = new QVBoxLayout(collapseSettings); - loColSetV->setMargin(0); + loColSetV->setContentsMargins(0,0,0,0);; // - - - - QHBoxLayout *loCollapseHeader = new QHBoxLayout(); - loCollapseHeader->setMargin(0); + loCollapseHeader->setContentsMargins(0,0,0,0);; QLabel *lblCollapseDemand = new QLabel(); lblCollapseDemand->setText("Demand"); @@ -237,7 +237,7 @@ PelicunDamageContainer::PelicunDamageContainer(QWidget *parent) // - - - - QHBoxLayout *loCollapseValues = new QHBoxLayout(); - loCollapseValues->setMargin(0); + loCollapseValues->setContentsMargins(0,0,0,0);; colDemand = new QLineEdit(); colDemand->setToolTip( diff --git a/LossModel/PelicunDemandContainer.cpp b/LossModel/PelicunDemandContainer.cpp index b035d8c..79652bc 100644 --- a/LossModel/PelicunDemandContainer.cpp +++ b/LossModel/PelicunDemandContainer.cpp @@ -214,7 +214,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loTLimit_header->addStretch(); loTLimit_header->setSpacing(10); - loTLimit_header->setMargin(0); + loTLimit_header->setContentsMargins(0,0,0,0);; loTRV->addLayout(loTLimit_header); @@ -226,7 +226,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loTruncLimRemove->addSpacing(2); loTruncLimRemove->setSpacing(5); - loTruncLimRemove->setMargin(0); + loTruncLimRemove->setContentsMargins(0,0,0,0);; smRemoveTL = new QSignalMapper(this); connect(smRemoveTL, SIGNAL(mapped(QWidget*)), this, @@ -245,7 +245,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loTLList = new QVBoxLayout(); loTLList->setAlignment(Qt::AlignTop); loTLList->setSpacing(5); - loTLList->setMargin(0); + loTLList->setContentsMargins(0,0,0,0);; TLWidget->setLayout(loTLList); saTruncLimits->setWidget(TLWidget); @@ -355,7 +355,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loCLimit_header->addStretch(); loCLimit_header->setSpacing(10); - loCLimit_header->setMargin(0); + loCLimit_header->setContentsMargins(0,0,0,0);; loCollV->addLayout(loCLimit_header); @@ -367,7 +367,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loCollLimRemove->addSpacing(2); loCollLimRemove->setSpacing(5); - loCollLimRemove->setMargin(0); + loCollLimRemove->setContentsMargins(0,0,0,0);; smRemoveCL = new QSignalMapper(this); connect(smRemoveCL, SIGNAL(mapped(QWidget*)), this, @@ -383,7 +383,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) QWidget *CLWidget = new QWidget; loCLList = new QVBoxLayout(); loCLList->setAlignment(Qt::AlignTop); - loCLList->setMargin(0); + loCLList->setContentsMargins(0,0,0,0);; loCLList->setSpacing(5); CLWidget->setLayout(loCLList); saCollapseLims->setWidget(CLWidget); @@ -507,7 +507,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loRParam_header->addStretch(); loRParam_header->setSpacing(10); - loRParam_header->setMargin(0); + loRParam_header->setContentsMargins(0,0,0,0);; loRDV->addLayout(loRParam_header); @@ -519,7 +519,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loResidualPRemove->addSpacing(2); loResidualPRemove->setSpacing(5); - loResidualPRemove->setMargin(0); + loResidualPRemove->setContentsMargins(0,0,0,0);; smRemoveRP = new QSignalMapper(this); connect(smRemoveRP, SIGNAL(mapped(QWidget*)), this, @@ -538,7 +538,7 @@ PelicunDemandContainer::PelicunDemandContainer(QWidget *parent) loRPList = new QVBoxLayout(); loRPList->setAlignment(Qt::AlignTop); loRPList->setSpacing(5); - loRPList->setMargin(0); + loRPList->setContentsMargins(0,0,0,0);; YDWidget->setLayout(loRPList); saYieldDrift->setWidget(YDWidget); diff --git a/LossModel/PelicunLossRepairContainer.cpp b/LossModel/PelicunLossRepairContainer.cpp index fbc62d3..f8479c5 100644 --- a/LossModel/PelicunLossRepairContainer.cpp +++ b/LossModel/PelicunLossRepairContainer.cpp @@ -293,7 +293,7 @@ PelicunLossRepairContainer::PelicunLossRepairContainer(QWidget *parent) // Replacement QHBoxLayout *replacementLayout = new QHBoxLayout(); - replacementLayout->setMargin(0); + replacementLayout->setContentsMargins(0,0,0,0);; replacementCheck = new QCheckBox(); replacementCheck->setText(""); @@ -314,11 +314,11 @@ PelicunLossRepairContainer::PelicunLossRepairContainer(QWidget *parent) replacementSettings = new QWidget(); QVBoxLayout * loRepSetV = new QVBoxLayout(replacementSettings); - loRepSetV->setMargin(0); + loRepSetV->setContentsMargins(0,0,0,0);; // - - - - QHBoxLayout * loReplacementHeader = new QHBoxLayout(); - loReplacementHeader->setMargin(0); + loReplacementHeader->setContentsMargins(0,0,0,0);; QLabel *lblPlaceholder = new QLabel(); lblPlaceholder->setText(""); @@ -363,7 +363,7 @@ PelicunLossRepairContainer::PelicunLossRepairContainer(QWidget *parent) repCostSettings = new QWidget(); QHBoxLayout * loReplacementCostValues = new QHBoxLayout(repCostSettings); - loReplacementCostValues->setMargin(0); + loReplacementCostValues->setContentsMargins(0,0,0,0);; QLabel *lblCost = new QLabel(); lblCost->setText("Cost: "); @@ -427,7 +427,7 @@ PelicunLossRepairContainer::PelicunLossRepairContainer(QWidget *parent) repTimeSettings = new QWidget(); QHBoxLayout * loReplacementTimeValues = new QHBoxLayout(repTimeSettings); - loReplacementTimeValues->setMargin(0); + loReplacementTimeValues->setContentsMargins(0,0,0,0);; QLabel *lblTime = new QLabel(); lblTime->setText("Time: "); @@ -491,7 +491,7 @@ PelicunLossRepairContainer::PelicunLossRepairContainer(QWidget *parent) repCarbonSettings = new QWidget(); QHBoxLayout * loReplacementCarbonValues = new QHBoxLayout(repCarbonSettings); - loReplacementCarbonValues->setMargin(0); + loReplacementCarbonValues->setContentsMargins(0,0,0,0);; QLabel *lblCarbon = new QLabel(); lblCarbon->setText("Carbon: "); @@ -554,7 +554,7 @@ PelicunLossRepairContainer::PelicunLossRepairContainer(QWidget *parent) repEnergySettings = new QWidget(); QHBoxLayout * loReplacementEnergyValues = new QHBoxLayout(repEnergySettings); - loReplacementEnergyValues->setMargin(0); + loReplacementEnergyValues->setContentsMargins(0,0,0,0);; QLabel *lblEnergy = new QLabel(); lblEnergy->setText("Energy: "); @@ -1241,7 +1241,7 @@ PelicunLossRepairContainer::exportConsequenceDB(void) { qDebug() << QString("Exporting consequence database..."); // copy the db file(s) to the desired location - QFileInfo fi = leAdditionalComponentDB->text(); + QFileInfo fi = QFileInfo(leAdditionalComponentDB->text()); // get the filenames QString csvFileName = fi.fileName(); diff --git a/LossModel/PelicunOutputsContainer.cpp b/LossModel/PelicunOutputsContainer.cpp index ca2742b..d352e18 100644 --- a/LossModel/PelicunOutputsContainer.cpp +++ b/LossModel/PelicunOutputsContainer.cpp @@ -71,7 +71,7 @@ PelicunOutputsContainer::PelicunOutputsContainer(QWidget *parent) // Output Format QHBoxLayout *outputFormatLayout = new QHBoxLayout(); - outputFormatLayout->setMargin(0); + outputFormatLayout->setContentsMargins(0,0,0,0);; QLabel *lblOutputFormat = new QLabel(); lblOutputFormat->setText("Format:"); diff --git a/LossModel/PelicunPopulationGroup.cpp b/LossModel/PelicunPopulationGroup.cpp index 43465a7..5ac4278 100644 --- a/LossModel/PelicunPopulationGroup.cpp +++ b/LossModel/PelicunPopulationGroup.cpp @@ -124,7 +124,7 @@ PopulationGroup::PopulationGroup(QWidget *parent, QMap *PG_dat mainLayout->addWidget(pgComment, 1); mainLayout->addStretch(); mainLayout->setSpacing(10); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0,0,0,0); this->setLayout(mainLayout); } diff --git a/LossModel/PelicunResidualParams.cpp b/LossModel/PelicunResidualParams.cpp index 8a63870..d73816e 100644 --- a/LossModel/PelicunResidualParams.cpp +++ b/LossModel/PelicunResidualParams.cpp @@ -88,7 +88,7 @@ ResidualParam::ResidualParam(QWidget *parent, QMap *RP_data_in mainLayout->addWidget(rpYieldDrift); mainLayout->addStretch(); mainLayout->setSpacing(10); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0,0,0,0);; this->setLayout(mainLayout); } diff --git a/LossModel/PelicunShared.cpp b/LossModel/PelicunShared.cpp index 4c8b53e..96b48e2 100644 --- a/LossModel/PelicunShared.cpp +++ b/LossModel/PelicunShared.cpp @@ -48,7 +48,7 @@ parseCSVLine(QString &line, QStringList &line_list, int c_0 = 0; for (int c=0; cstatusMessage("Error while parsing CSV file at the following line: " + line); } @@ -89,4 +89,4 @@ parseCSVLine(QString &line, QStringList &line_list, } } } -} \ No newline at end of file +} diff --git a/LossModel/PelicunShared.h b/LossModel/PelicunShared.h index a06ed7a..b202168 100644 --- a/LossModel/PelicunShared.h +++ b/LossModel/PelicunShared.h @@ -42,9 +42,8 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include class QString; -class QStringList; void parseCSVLine(QString &line, QStringList &line_list, SimCenterAppWidget *parent=nullptr); -#endif // PELICUN_SHARED_H \ No newline at end of file +#endif // PELICUN_SHARED_H diff --git a/LossModel/PelicunTruncationLimit.cpp b/LossModel/PelicunTruncationLimit.cpp index e306a93..bbace72 100644 --- a/LossModel/PelicunTruncationLimit.cpp +++ b/LossModel/PelicunTruncationLimit.cpp @@ -95,7 +95,7 @@ TruncationLimit::TruncationLimit(QWidget *parent, QMap *TL_dat mainLayout->addWidget(tlUpperLimit); mainLayout->addStretch(); mainLayout->setSpacing(10); - mainLayout->setMargin(0); + mainLayout->setContentsMargins(0,0,0,0);; this->setLayout(mainLayout); } diff --git a/LossModel/PerformanceMethodSelection.cpp b/LossModel/PerformanceMethodSelection.cpp new file mode 100644 index 0000000..9300fd8 --- /dev/null +++ b/LossModel/PerformanceMethodSelection.cpp @@ -0,0 +1,239 @@ +/* ***************************************************************************** +Copyright (c) 2016-2017, The Regents of the University of California (Regents). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*************************************************************************** */ + +// Written: fmckenna, adamzs + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "PerformanceMethodSelection.h" +#include + +PerformanceMethodSelection::PerformanceMethodSelection( + + QWidget *parent) + : SimCenterAppWidget(parent) +{ + QVBoxLayout *layout = new QVBoxLayout(); + + QHBoxLayout *theSelectionLayout = new QHBoxLayout(); + + // set up the selection part + + SectionTitle *label=new SectionTitle(); + label->setMinimumWidth(250); + label->setText(QString("Damage and Loss Assessment")); + + dlSelection = new QComboBox(); + dlSelection->setObjectName("DLMethodCombox"); + + dlSelection->addItem(tr("Pelicun")); + dlSelection->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + dlSelection->setItemData(1, "Use the Pelicun integrated performance assessment framework.", Qt::ToolTipRole); + + theSelectionLayout->addWidget(label); + QSpacerItem *spacer = new QSpacerItem(50,10); + theSelectionLayout->addItem(spacer); + theSelectionLayout->addWidget(dlSelection); + theSelectionLayout->addStretch(); + layout->addLayout(theSelectionLayout); + + // create stacked widget + + QScrollArea *sa = new QScrollArea; + sa->setWidgetResizable(true); + sa->setLineWidth(0); + sa->setFrameShape(QFrame::NoFrame); + + theStackedWidget = new QStackedWidget(); + + sa->setWidget(theStackedWidget); + + // create individual DL widgets and add them to the stacked widget + + // Adding Pelicun DL widget + thePelicunWidget = new PelicunLossModel(); + theStackedWidget->addWidget(thePelicunWidget); + + // add the stacked widget to the main layout + + layout->addWidget(sa); + layout->setContentsMargins(0,0,0,0); + this->setLayout(layout); + theCurrentMethod=thePelicunWidget; + + // connect signal and slots + + connect(dlSelection, SIGNAL(currentIndexChanged(QString)), this, + SLOT(dlSelectionChanged(QString))); + + // set pelicun as the default + //dlSelection->setCurrentText("HAZUS MH"); + //this->dlSelectionChanged(QString("HAZUS MH")); + //layout->setMargin(0); +} + +PerformanceMethodSelection::~PerformanceMethodSelection() +{ + +} + +void PerformanceMethodSelection::clear(void) +{ + +} + +bool +PerformanceMethodSelection::outputToJSON(QJsonObject &jsonObject) +{ + bool result = true; + + result = theCurrentMethod->outputToJSON(jsonObject); + + return result; +} + +bool +PerformanceMethodSelection::inputFromJSON(QJsonObject &jsonObject) +{ + bool result = false; + + if (theCurrentMethod != 0) { + result = theCurrentMethod->inputFromJSON(jsonObject); + } + + return result; +} + +bool +PerformanceMethodSelection::outputAppDataToJSON(QJsonObject &jsonObject, QJsonObject &lossModelObject) { + + // + // per API, need to add name of application to be called in AppLication + // and all data to be used in ApplicationDate + // + + bool result = true; + + if (theCurrentMethod != 0) { + result = theCurrentMethod->outputAppDataToJSON(jsonObject); + } + + return result; +} + +bool +PerformanceMethodSelection::inputAppDataFromJSON(QJsonObject &jsonObject) { + + bool result = true; + + if (jsonObject.contains("Application")) { + QJsonValue theDLAppName = jsonObject["Application"].toString(); + + if (theDLAppName == QString("Pelicun3")) { + dlSelection->setCurrentText("Pelicun"); + + } else { + // show a warning that the application is not recognized + // TODO + + // default + + // this might seem silly, but it sets the template for future expansion + dlSelection->setCurrentText("Pelicun"); + } + + // invoke inputAppDataFromJSON on new DL method + if (theCurrentMethod != 0 && !jsonObject.isEmpty()) { + result = theCurrentMethod->inputAppDataFromJSON(jsonObject); + } + + } + + return result; +} + +void PerformanceMethodSelection::dlSelectionChanged(const QString &arg1) +{ + + // + // switch stacked widgets depending on text + // note type output in json and name in pull down are not the same and hence the || + // + + if (arg1 == QString("Pelicun")) { + + theStackedWidget->setCurrentIndex(0); + theCurrentMethod = thePelicunWidget; + + } else { + errorMessage("ERROR: Loss Input - no valid Method provided .. keeping old"); + qDebug() << "ERROR: Loss Input - no valid Method provided .. keeping old" << arg1; + } + + return; +} + +bool +PerformanceMethodSelection::copyFiles(QString &destDir) { + + bool result = true; + + if (theCurrentMethod != 0) { + GoogleAnalytics::ReportAppUsage("DL-Pelicun"); + return theCurrentMethod->copyFiles(destDir); + } + + return result; +} + + +QString +PerformanceMethodSelection::getFragilityFolder(){ + return theCurrentMethod->getFragilityFolder(); +} + +QString +PerformanceMethodSelection::getPopulationFile(){ + return theCurrentMethod->getPopulationFile(); +} diff --git a/LossModel/PerformanceMethodSelection.h b/LossModel/PerformanceMethodSelection.h new file mode 100644 index 0000000..b2ad8ec --- /dev/null +++ b/LossModel/PerformanceMethodSelection.h @@ -0,0 +1,90 @@ +#ifndef PERFORMANCE_METHOD_SELECTION_H +#define PERFORMANCE_METHOD_SELECTION_H + +/* ***************************************************************************** +Copyright (c) 2016-2017, The Regents of the University of California (Regents). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*************************************************************************** */ + +// Written: fmckenna, adamzs + +#include +#include "LossMethod.h" +#include "PelicunLossModel.h" +#include + +class QComboBox; +class QStackedWidget; +class QVBoxLayout; + +class RandomVariablesContainer; + +class PerformanceMethodSelection : public SimCenterAppWidget +{ + Q_OBJECT +public: + + explicit PerformanceMethodSelection(QWidget *parent = 0); + + ~PerformanceMethodSelection(); + + QString getFragilityFolder(); + QString getPopulationFile(); + + bool inputFromJSON(QJsonObject &rvObject); + bool outputToJSON(QJsonObject &rvObject); + bool outputAppDataToJSON(QJsonObject &rvObject, QJsonObject &lossModelObject); + bool inputAppDataFromJSON(QJsonObject &rvObject); + bool copyFiles(QString &destDir); + +public slots: + void clear(void); + void dlSelectionChanged(const QString &arg1); + +signals: + void dlWidgetChanged(void); + +private: + QStackedWidget *theStackedWidget; + QComboBox *dlSelection; + + RandomVariablesContainer *theRandVariableIW; + + LossMethod *theCurrentMethod; + PelicunLossModel *thePelicunWidget; + + bool selectionChangeOK; +}; + +#endif // PERFORMANCE_METHOD_SELECTION_H diff --git a/PBE.pro b/PBE.pro index b3b97dc..fcf1f8c 100644 --- a/PBE.pro +++ b/PBE.pro @@ -5,8 +5,8 @@ #------------------------------------------------- QT += core gui charts concurrent network widgets -QT += sql qml webenginewidgets uitools -QT += webengine webchannel 3dcore 3drender 3dextras +QT += sql qml webenginewidgets core5compat +QT += webchannel 3dcore 3drender 3dextras #MOC_DIR = $$DESTDIR/.moc #UI_DIR = $$DESTDIR/.ui @@ -23,7 +23,7 @@ TEMPLATE = app VERSION=3.0 DEFINES += APP_VERSION=\\\"$$VERSION\\\" -include($$PWD/ConanHelper.pri) +#include($$PWD/ConanHelper.pri) win32{ LIBS = $$replace(LIBS, .dll.lib, .dll) @@ -34,22 +34,14 @@ win32{ DEFINES += CURL_STATICLIB } -win32 { -RC_ICONS = icons/NHERI-PBE-Icon.ico -LIBS += $$PWD/../quazip/build/quazip/Release/quazip1-gt5.lib -} else { - - mac { - ICON = icons/NHERI-PBE-Icon.icns - DEFINES += _GRAPHICS_Qt3D - QMAKE_INFO_PLIST=$$PWD/Info.plist - LIBS += $$PWD/../quazip/build/quazip/libquazip1-qt5.1.4.dylib - } else { - LIBS += -lc - } -} -INCLUDEPATH += $$PWD/../quazip/quazip +LIBS += -L/opt/homebrew/Cellar/curl/8.0.1/lib/ -lcurl.4 +INCLUDEPATH += /opt/homebrew/Cellar/curl/8.1.2_1/include +INCLUDEPATH += /opt/homebrew/Cellar/quazip/1.4/include/quazip + +macx: LIBS += -L/opt/homebrew/Cellar/quazip/1.4/lib/ -lquazip1-qt6.1.4 +INCLUDEPATH += $$/opt/homebrew/Cellar/quazip/1.4/include + include(../SimCenterCommon/Common/Common.pri) include(../SimCenterCommon/Workflow/Workflow.pri) @@ -58,7 +50,8 @@ include(../SimCenterCommon/InputSheetBM/InputSheetBM.pri) include(../EE-UQ/EarthquakeEvents.pri) include(../QS3hark/QS3hark.pri) -INCLUDEPATH += "./Component" +INCLUDEPATH += "./Component" \ + PerformanceMethod SOURCES += main.cpp \ WorkflowAppPBE.cpp \ @@ -83,7 +76,9 @@ SOURCES += main.cpp \ LossModel/HazusGeneralSettingsContainer.cpp \ LossModel/HazusLossModel.cpp \ LossModel/LossMethod.cpp \ - LossModel/PelicunShared.cpp + LossModel/PelicunShared.cpp \ + PerformanceMethod/PerformanceMethodSelection.cpp \ + PerformanceMethod/REDiWidget.cpp \ @@ -110,10 +105,11 @@ HEADERS += \ LossModel/HazusLossModel.h \ LossModel/HazusGeneralSettingsContainer.h \ LossModel/LossMethod.h \ - LossModel/PelicunShared.h + LossModel/PelicunShared.h \ + PerformanceMethod/PerformanceMethodSelection.h \ + PerformanceMethod/REDiWidget.h \ RESOURCES += \ images.qrc -OTHER_FILES += conanfile.py - +#OTHER_FILES += conanfile.py diff --git a/PerformanceMethod/PerformanceMethodSelection.cpp b/PerformanceMethod/PerformanceMethodSelection.cpp new file mode 100644 index 0000000..d2594a5 --- /dev/null +++ b/PerformanceMethod/PerformanceMethodSelection.cpp @@ -0,0 +1,66 @@ +/* ***************************************************************************** +Copyright (c) 2016-2017, The Regents of the University of California (Regents). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*************************************************************************** */ + +// Written: Stevan Gavrilovic + + + +#include "NoneWidget.h" +#include "REDiWidget.h" +#include "PerformanceMethodSelection.h" + +PerformanceMethodSelection::PerformanceMethodSelection(QWidget *parent) + : SimCenterAppSelection(QString("PRF Application"), QString("Performance"), parent) +{ + // The none widget + theNoneWidget = new NoneWidget(); + + // The REDi widget + theREDiWidget = new REDiWidget(); + + this->addComponent(QString("None"), QString("None"), theNoneWidget); + this->addComponent(QString("REDi"), QString("REDi"), theREDiWidget); + + +} + +PerformanceMethodSelection::~PerformanceMethodSelection() +{ + +} + + + diff --git a/PerformanceMethod/PerformanceMethodSelection.h b/PerformanceMethod/PerformanceMethodSelection.h new file mode 100644 index 0000000..61ba147 --- /dev/null +++ b/PerformanceMethod/PerformanceMethodSelection.h @@ -0,0 +1,61 @@ +#ifndef PERFORMANCE_METHOD_SELECTION_H +#define PERFORMANCE_METHOD_SELECTION_H + +/* ***************************************************************************** +Copyright (c) 2016-2017, The Regents of the University of California (Regents). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*************************************************************************** */ + +// Written: Stevan Gavrilovic + +#include + +class REDiWidget; +class NoneWidget; + +class PerformanceMethodSelection : public SimCenterAppSelection +{ + Q_OBJECT +public: + + explicit PerformanceMethodSelection(QWidget *parent = 0); + ~PerformanceMethodSelection(); + + +private: + REDiWidget* theREDiWidget = nullptr; + NoneWidget* theNoneWidget = nullptr; +}; + +#endif // PERFORMANCE_METHOD_SELECTION_H diff --git a/PerformanceMethod/REDiWidget.cpp b/PerformanceMethod/REDiWidget.cpp new file mode 100644 index 0000000..598e9cf --- /dev/null +++ b/PerformanceMethod/REDiWidget.cpp @@ -0,0 +1,149 @@ +/* ***************************************************************************** +Copyright (c) 2016-2017, The Regents of the University of California (Regents). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*************************************************************************** */ + +// Written: Stevan Gavrilovic + +#include "REDiWidget.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include > + + +REDiWidget::REDiWidget(QWidget *parent) + : SimCenterAppWidget(parent) +{ + riskParamsLE = new QLineEdit(this); + riskParamsLE->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* layout = new QVBoxLayout(this); + + auto infoTxt = tr("Resilience-based Engineering Design Initiative (REDiā„¢) Seismic Building Recovery Methodology by ARUP"); + setWindowTitle(infoTxt); + + auto redi_label = new QLabel(infoTxt); + layout->addWidget(redi_label,0,Qt::AlignCenter); + + auto rpTextLabel = new QLabel("Path to risk parameters file:"); + + auto browseButton = new QPushButton("Browse"); + browseButton->setFixedWidth(100); + connect(browseButton, &QPushButton::pressed, this, &REDiWidget::handleBrowseButtonPressed); + + QHBoxLayout* inputLayout = new QHBoxLayout(this); + inputLayout->addWidget(rpTextLabel); + inputLayout->addWidget(riskParamsLE); + inputLayout->addWidget(browseButton); + + layout->addLayout(inputLayout); + layout->addStretch(1); + +} + + +REDiWidget::~REDiWidget() +{ + +} + + +bool REDiWidget::outputToJSON(QJsonObject &jsonObj){ + + jsonObj["Application"] = "REDi"; + + return true; +} + + +bool REDiWidget::inputFromJSON(QJsonObject &jsonObject){ + + Q_UNUSED(jsonObject); + return true; +} + + + +bool REDiWidget::outputAppDataToJSON(QJsonObject &jsonObj){ + + auto riskParamPath = riskParamsLE->text().trimmed(); + jsonObj["riskParametersPath"] = riskParamPath; + + return true; +} + + +bool REDiWidget::inputAppDataFromJSON(QJsonObject &jsonObject){ + + if (jsonObject.contains("ApplicationData")) + { + if (jsonObject["ApplicationData"].toObject().contains("riskParametersPath")) + { + QJsonValue riskParamsPathValue = jsonObject["ApplicationData"].toObject()["riskParametersPath"]; + + if (riskParamsPathValue.isNull()) + return false; + + riskParamsLE->setText(riskParamsPathValue.toString()); + return true; + } + } + + return false; +} + + +void REDiWidget::clear(void) +{ + riskParamsLE->clear(); +} + + +void REDiWidget::handleBrowseButtonPressed() +{ + +} + + + + + diff --git a/PerformanceMethod/REDiWidget.h b/PerformanceMethod/REDiWidget.h new file mode 100644 index 0000000..b4fdd36 --- /dev/null +++ b/PerformanceMethod/REDiWidget.h @@ -0,0 +1,71 @@ +#ifndef REDiWidget_H +#define REDiWidget_H +/* ***************************************************************************** +Copyright (c) 2016-2017, The Regents of the University of California (Regents). +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. + +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS +PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*************************************************************************** */ + +// Written: Stevan Gavrilovic + +#include + +class QLineEdit; + +class REDiWidget : public SimCenterAppWidget +{ + Q_OBJECT + +public: + REDiWidget(QWidget *parent = 0); + ~REDiWidget(); + + bool outputToJSON(QJsonObject &rvObject); + bool inputFromJSON(QJsonObject &rvObject); + bool outputAppDataToJSON(QJsonObject &jsonObj); + bool inputAppDataFromJSON(QJsonObject &jsonObject); + + void clear(void); + +private slots: + + void handleBrowseButtonPressed(); + +private: + + QLineEdit *riskParamsLE = nullptr; + +}; + + +#endif // REDiWidget_H diff --git a/ResultsPelicun.cpp b/ResultsPelicun.cpp index 8625013..d465033 100644 --- a/ResultsPelicun.cpp +++ b/ResultsPelicun.cpp @@ -72,7 +72,6 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include #include #include -using namespace QtCharts; #include #include #include @@ -495,7 +494,7 @@ int ResultsPelicun::processResults(QString &inputFileName, // QWidget *summaryWidget = new QWidget(); - QVBoxLayout *summaryLayout = new QVBoxLayout(); + summaryLayout = new QVBoxLayout(); summaryWidget->setLayout(summaryLayout); // @@ -836,6 +835,88 @@ int ResultsPelicun::processResults(QString &inputFileName, return 0; } + + +int ResultsPelicun::processREDiResults(QString &inputFileName, + QString &resultsDirName) { + + if(summaryLayout == nullptr) + return 0; + + QDir rDir(resultsDirName); + QFile inputFile(inputFileName); + + inputFile.open(QFile::ReadOnly | QFile::Text); + + QString val; + val=inputFile.readAll(); + QJsonDocument doc = QJsonDocument::fromJson(val.toUtf8()); + QJsonObject inputData = doc.object(); + inputFile.close(); + + auto redi_res_path = resultsDirName + QDir::separator() + "REDi_output" + QDir::separator() + "redi_summary_stats.json"; + + QFile resultsSummaryFile(redi_res_path); + + if(!resultsSummaryFile.exists()) + return 0; + + resultsSummaryFile.open(QFile::ReadOnly | QFile::Text); + + QString val2; + val2=resultsSummaryFile.readAll(); + QJsonDocument res_doc = QJsonDocument::fromJson(val2.toUtf8()); + QJsonObject resData = res_doc.object(); + resultsSummaryFile.close(); + + + if(resData.isEmpty()) + this->errorMessage("Error, the REDi results file "+redi_res_path+" is empty or failed to load as json"); + + + summaryLayout->addWidget(new QLabel("REDi Recovery"), 0, Qt::AlignCenter); + + // add a separator line after the row + QFrame *sepLine = new QFrame; + sepLine->setFrameShape(QFrame::HLine); + sepLine->setFrameShadow(QFrame::Raised); + summaryLayout->addWidget(sepLine); + + + QJsonObject::const_iterator it; + for (it = resData.constBegin(); it != resData.constEnd(); ++it) { + QString key = it.key(); + QJsonValue value = it.value().toObject(); + + auto DV_DisplayName = key; + + double DV_min = value["min"].toDouble(); + double DV_10 = value["0.10%"].toDouble(); + double DV_50 = value["50%"].toDouble(); + double DV_90 = value["90%"].toDouble(); + double DV_max = value["max"].toDouble(); + + double DV_mean = value["mean"].toDouble(); + double DV_stdDev = value["std"].toDouble(); + double DV_logStdDev = value["log_std"].toDouble(); + + QWidget *theWidget = this->createSummaryItem2(DV_DisplayName, + DV_mean, DV_stdDev, DV_logStdDev, DV_min, DV_10, DV_50, DV_90, DV_max); + summaryLayout->addWidget(theWidget); + + // add a separator line after the row + QFrame *sepLine = new QFrame; + sepLine->setFrameShape(QFrame::HLine); + sepLine->setFrameShadow(QFrame::Sunken); + summaryLayout->addWidget(sepLine); + + + } + + return 0; +} + + void ResultsPelicun::getColData(QVector &data, int numRow, int col) { bool ok; @@ -1094,7 +1175,7 @@ ResultsPelicun::onSpreadsheetCellClicked(int row, int col) QLineSeries *series= new QLineSeries; // cumulative distributionn - qSort(dataValues); + std::sort(dataValues.begin(),dataValues.end()); for (int i=0; iappend(dataValues[i], 1.0*i/totalSampleCount); @@ -1132,7 +1213,7 @@ static QWidget *addLabeledLineEdit(QString theLabelName, QLineEdit **theLineEdit theLayout->addWidget(theLabel); theLayout->addWidget(theEdit); theLayout->setSpacing(0); - theLayout->setMargin(0); + theLayout->setContentsMargins(0,0,0,0); QWidget *theWidget = new QWidget(); theWidget->setLayout(theLayout); diff --git a/ResultsPelicun.h b/ResultsPelicun.h index c8083b3..3233044 100644 --- a/ResultsPelicun.h +++ b/ResultsPelicun.h @@ -41,9 +41,9 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include #include -using namespace QtCharts; class QTextEdit; +class QVBoxLayout; class QTabWidget; class MyTableWidget; @@ -58,6 +58,7 @@ class ResultsPelicun : public SimCenterWidget bool inputFromJSON(QJsonObject &jsonObject); int processResults(QString &inputFile, QString &resultsDir); + int processREDiResults(QString &inputFileName, QString &resultsDirName); signals: @@ -91,6 +92,8 @@ public slots: QVectortheMeans; QVectortheStdDevs; int dataType; // min/max or mean/stdDev + QVBoxLayout *summaryLayout = nullptr; + }; #endif // RESULTS_PELICUN_H diff --git a/WorkflowAppPBE.cpp b/WorkflowAppPBE.cpp index ac45858..374987c 100644 --- a/WorkflowAppPBE.cpp +++ b/WorkflowAppPBE.cpp @@ -75,6 +75,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include #include #include +#include #include #include #include @@ -120,6 +121,7 @@ WorkflowAppPBE::WorkflowAppPBE(RemoteService *theService, QWidget *parent) theAnalysisSelection = new FEA_Selection(); theUQ_Selection = new UQ_EngineSelection(ForwardOnly); theDLModelSelection = new LossModelSelection(); + thePrfMethodSelection = new PerformanceMethodSelection(); theResults = new ResultsPelicun(); localApp = new LocalApplication("sWHALE.py"); @@ -187,7 +189,7 @@ WorkflowAppPBE::WorkflowAppPBE(RemoteService *theService, QWidget *parent) QHBoxLayout *horizontalLayout = new QHBoxLayout(); this->setLayout(horizontalLayout); this->setContentsMargins(0,5,0,5); - horizontalLayout->setMargin(0); + horizontalLayout->setContentsMargins(0,0,0,0); theComponentSelection = new SimCenterComponentSelection(); horizontalLayout->addWidget(theComponentSelection); @@ -199,6 +201,7 @@ WorkflowAppPBE::WorkflowAppPBE(RemoteService *theService, QWidget *parent) theComponentSelection->addComponent(QString("FEM"), theAnalysisSelection); theComponentSelection->addComponent(QString("RV"), theRVs); theComponentSelection->addComponent(QString("DL"), theDLModelSelection); + theComponentSelection->addComponent(QString("PRF"), thePrfMethodSelection); theComponentSelection->addComponent(QString("RES"), theResults); theComponentSelection->displayComponent("DL"); @@ -310,7 +313,7 @@ WorkflowAppPBE::outputToJSON(QJsonObject &jsonObjectTop) { qDebug() << "WorkflowAppPBE::outputToJSON - EVENT_Selection failed appData"; return result; } - + result = theRunWidget->outputToJSON(jsonObjectTop); if (result == false) { qDebug() << "WorkflowAppPBE::outputToJSON - Run failed"; @@ -325,6 +328,27 @@ WorkflowAppPBE::outputToJSON(QJsonObject &jsonObjectTop) { jsonObjectTop["DL"] = jsonLossModel; + QJsonObject appPrf; + if (thePrfMethodSelection->outputToJSON(appPrf) == false) { + qDebug() << "WorkflowAppPBE::outputToJSON - PRF_Selection failed"; + return false; + } + + + QJsonObject dataPrf; + result = thePrfMethodSelection->outputAppDataToJSON(dataPrf); + if (result == false) { + qDebug() << "WorkflowAppPBE::outputToJSON - Prf Method Selection failed appData"; + return result; + } + + QJsonObject prfFinal = appPrf["Performance"].toObject(); + jsonObjectTop["Performance"] = prfFinal; + + prfFinal["ApplicationData"] = dataPrf["Performance"]; + apps["Performance"] = prfFinal; + + QJsonObject appsDL; if (theDLModelSelection->outputAppDataToJSON(appsDL, jsonLossModel) == false) { qDebug() << "WorkflowAppPBE::outputToJSON - DL_Selection failed appData"; @@ -364,6 +388,8 @@ WorkflowAppPBE::processResults(QString &dirPath) { statusMessage("Backend Done. Processing Results ..."); theResults->processResults(loadedFile, dirPath); + theResults->processREDiResults(loadedFile, dirPath); + theRunWidget->hide(); theComponentSelection->displayComponent("RES"); this->runComplete(); @@ -423,6 +449,10 @@ WorkflowAppPBE::inputFromJSON(QJsonObject &jsonObject) if (theAnalysisSelection->inputAppDataFromJSON(theApplicationObject) == false) this->errorMessage("EE_UQ: failed to read FEM application"); + if (thePrfMethodSelection->inputAppDataFromJSON(theApplicationObject) == false) + this->errorMessage("PBE: failed to read PRF Method data"); + + } else return false; diff --git a/WorkflowAppPBE.h b/WorkflowAppPBE.h index 88ba5f7..a11352d 100644 --- a/WorkflowAppPBE.h +++ b/WorkflowAppPBE.h @@ -44,6 +44,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include class LossModelSelection; +class PerformanceMethodSelection; class RandomVariablesContainer; class InputWidgetUQ; @@ -119,6 +120,7 @@ public slots: EarthquakeEventSelection *theEventSelection; FEA_Selection *theAnalysisSelection; LossModelSelection *theDLModelSelection; + PerformanceMethodSelection * thePrfMethodSelection; ResultsPelicun *theResults; QString loadedFile; diff --git a/main.cpp b/main.cpp index 761f654..cc8fc38 100644 --- a/main.cpp +++ b/main.cpp @@ -39,7 +39,7 @@ void customMessageOutput(QtMsgType type, const QMessageLogContext &context, cons QFile outFile(logFilePath); outFile.open(QIODevice::WriteOnly | QIODevice::Append); QTextStream ts(&outFile); - ts << txt << endl; + ts << txt << Qt::endl; outFile.close(); } else { fprintf(stderr, "%s %s: %s (%s:%u, %s)\n", formattedTimeMsg.constData(), logLevelMsg.constData(), localMsg.constData(), context.file, context.line, context.function); From 844de9855caa42aa2d28f9478ab6a38c91809630 Mon Sep 17 00:00:00 2001 From: yisangriB Date: Tue, 26 Sep 2023 10:53:07 -0700 Subject: [PATCH 2/3] sy - tmp - to make it work on my win machine --- PBE.pro | 30 ++++++++++++++++++++++-------- ResultsPelicun.h | 2 +- conanfile.py | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/PBE.pro b/PBE.pro index fcf1f8c..d181f6d 100644 --- a/PBE.pro +++ b/PBE.pro @@ -5,7 +5,7 @@ #------------------------------------------------- QT += core gui charts concurrent network widgets -QT += sql qml webenginewidgets core5compat +QT += sql qml webenginewidgets QT += webchannel 3dcore 3drender 3dextras #MOC_DIR = $$DESTDIR/.moc @@ -23,7 +23,7 @@ TEMPLATE = app VERSION=3.0 DEFINES += APP_VERSION=\\\"$$VERSION\\\" -#include($$PWD/ConanHelper.pri) +include($$PWD/ConanHelper.pri) win32{ LIBS = $$replace(LIBS, .dll.lib, .dll) @@ -34,14 +34,28 @@ win32{ DEFINES += CURL_STATICLIB } +LIBS += $$PWD/../quazip/build/quazip/Debug/quazip1-qt5d.lib +win32 { + RC_ICONS = icons/NHERI-PBE-Icon.ico +} else { -LIBS += -L/opt/homebrew/Cellar/curl/8.0.1/lib/ -lcurl.4 -INCLUDEPATH += /opt/homebrew/Cellar/curl/8.1.2_1/include -INCLUDEPATH += /opt/homebrew/Cellar/quazip/1.4/include/quazip + mac { + ICON = icons/NHERI-PBE-Icon.icns + DEFINES += _GRAPHICS_Qt3D + QMAKE_INFO_PLIST=$$PWD/Info.plist + LIBS += $$PWD/../quazip/build/quazip/libquazip1-qt5.1.4.dylib + } else { + LIBS += -lc + } -macx: LIBS += -L/opt/homebrew/Cellar/quazip/1.4/lib/ -lquazip1-qt6.1.4 -INCLUDEPATH += $$/opt/homebrew/Cellar/quazip/1.4/include + LIBS += -L/opt/homebrew/Cellar/curl/8.0.1/lib/ -lcurl.4 + INCLUDEPATH += /opt/homebrew/Cellar/curl/8.1.2_1/include + INCLUDEPATH += /opt/homebrew/Cellar/quazip/1.4/include/quazip + macx: LIBS += -L/opt/homebrew/Cellar/quazip/1.4/lib/ -lquazip1-qt6.1.4 + INCLUDEPATH += $$/opt/homebrew/Cellar/quazip/1.4/include + +} include(../SimCenterCommon/Common/Common.pri) include(../SimCenterCommon/Workflow/Workflow.pri) @@ -112,4 +126,4 @@ HEADERS += \ RESOURCES += \ images.qrc -#OTHER_FILES += conanfile.py +OTHER_FILES += conanfile.py diff --git a/ResultsPelicun.h b/ResultsPelicun.h index 3233044..83d5668 100644 --- a/ResultsPelicun.h +++ b/ResultsPelicun.h @@ -46,7 +46,7 @@ class QTextEdit; class QVBoxLayout; class QTabWidget; class MyTableWidget; - +using namespace QtCharts; class ResultsPelicun : public SimCenterWidget { Q_OBJECT diff --git a/conanfile.py b/conanfile.py index e68622d..5b4cc24 100644 --- a/conanfile.py +++ b/conanfile.py @@ -11,7 +11,7 @@ class PBE(ConanFile): generators = "qmake" requires = ["jansson/2.13.1", "libcurl/7.72.0", - "zlib/1.2.13", + "zlib/1.2.11", #'quazip/1.4', #"hdf5/1.12.0" ] From 216ecc65c421d456d931d194b177c484503e1949 Mon Sep 17 00:00:00 2001 From: yisangriB Date: Mon, 30 Sep 2024 21:37:28 -0700 Subject: [PATCH 3/3] sy - temporary to connect with pre-trained surrogate --- WorkflowAppPBE.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/WorkflowAppPBE.cpp b/WorkflowAppPBE.cpp index c1f55e8..e35a5c7 100644 --- a/WorkflowAppPBE.cpp +++ b/WorkflowAppPBE.cpp @@ -182,6 +182,10 @@ WorkflowAppPBE::WorkflowAppPBE(RemoteService *theService, QWidget *parent) connect(remoteApp,SIGNAL(successfullJobStart()), theRunWidget, SLOT(hide())); + // SY connect queryEVT and the reply + connect(theUQ_Selection, SIGNAL(queryEVT()), theEventSelection, SLOT(replyEventType())); + connect(theEventSelection, SIGNAL(typeEVT(QString)), theUQ_Selection, SLOT(setEventType(QString))); + // // create layout, create component selction & add to layout & then add components to cmponentselection // @@ -262,9 +266,15 @@ WorkflowAppPBE::outputToJSON(QJsonObject &jsonObjectTop) { if (result == false) return result; + + // sy - temporary solution.. // built in EDP QJsonObject appsEDP; - appsEDP["Application"] = "StandardEarthquakeEDP"; + if (theSIM_Selection->getCurrentSIM()=="SurrogateGPBuildingModel") { + appsEDP["Application"] = "SurrogateEDP"; + } else { + appsEDP["Application"] = "StandardEarthquakeEDP"; + } QJsonObject dataObj; appsEDP["ApplicationData"] = dataObj; apps["EDP"] = appsEDP;