@@ -221,6 +221,8 @@ OpenStudioApp::OpenStudioApp(int& argc, char** argv)
221
221
waitDialog->show ();
222
222
emit resetWaitDialog ();
223
223
224
+ measureManager ().setResourcesPath (resourcesPath ());
225
+
224
226
// Non blocking
225
227
startMeasureManagerProcess ();
226
228
@@ -266,14 +268,11 @@ void OpenStudioApp::onMeasureManagerAndLibraryReady() {
266
268
msgBox.setText (tr (" Failed to start the Measure Manager. Would you like to keep waiting?" ));
267
269
msgBox.setStandardButtons (QMessageBox::Retry | QMessageBox::Close);
268
270
if (msgBox.exec () == QMessageBox::Close) {
269
- // this is a fatal error, application will close
270
- showFailedMeasureManagerDialog ();
271
- QCoreApplication::exit ();
272
- return ;
273
- } else {
274
- measureManager ().waitForStarted (10000 );
275
- ++currentTry;
271
+ // user can cancel out of this quit, turns into retry
272
+ quit ();
276
273
}
274
+ measureManager ().waitForStarted (10000 );
275
+ ++currentTry;
277
276
}
278
277
LOG (Info, " Recovered from Measure Manager problem, managed to start it on try " << currentTry
279
278
<< " at: " << toString (measureManager ().url ().toString ()));
@@ -1174,8 +1173,9 @@ void OpenStudioApp::readSettings() {
1174
1173
setLastPath (settings.value (" lastPath" , QDir::homePath ()).toString ());
1175
1174
setDviewPath (openstudio::toPath (settings.value (" dviewPath" , " " ).toString ()));
1176
1175
m_currLang = settings.value (" language" , " en" ).toString ();
1177
- m_useClassicCLI = settings.value (" useClassicCLI" , false ).toBool ();
1178
- LOG_FREE (Debug, " OpenStudioApp" , " \n\n\n m_currLang=[" << m_currLang.toStdString () << " ], m_useClassicCLI=" << m_useClassicCLI << " \n\n\n " );
1176
+ LOG_FREE (Debug, " OpenStudioApp" ,
1177
+ " \n\n\n m_currLang=[" << m_currLang.toStdString () << " ]"
1178
+ << " \n\n\n " );
1179
1179
if (m_currLang.isEmpty ()) {
1180
1180
m_currLang = " en" ;
1181
1181
}
@@ -1246,6 +1246,7 @@ void OpenStudioApp::connectOSDocumentSignals() {
1246
1246
connect (m_osDocument.get (), &OSDocument::changeLanguageClicked, this , &OpenStudioApp::changeLanguage);
1247
1247
connect (m_osDocument.get (), &OSDocument::loadLibraryClicked, this , &OpenStudioApp::loadLibrary);
1248
1248
connect (m_osDocument.get (), &OSDocument::loadExampleModelClicked, this , &OpenStudioApp::loadExampleModel);
1249
+ connect (m_osDocument.get (), &OSDocument::loadShoeboxModelClicked, this , &OpenStudioApp::loadShoeboxModel);
1249
1250
connect (m_osDocument.get (), &OSDocument::newClicked, this , &OpenStudioApp::newModel);
1250
1251
connect (m_osDocument.get (), &OSDocument::helpClicked, this , &OpenStudioApp::showHelp);
1251
1252
connect (m_osDocument.get (), &OSDocument::checkForUpdateClicked, this , &OpenStudioApp::checkForUpdate);
@@ -1267,6 +1268,7 @@ void OpenStudioApp::disconnectOSDocumentSignals() {
1267
1268
disconnect (m_osDocument.get (), &OSDocument::configureExternalToolsClicked, this , &OpenStudioApp::configureExternalTools);
1268
1269
disconnect (m_osDocument.get (), &OSDocument::loadLibraryClicked, this , &OpenStudioApp::loadLibrary);
1269
1270
disconnect (m_osDocument.get (), &OSDocument::loadExampleModelClicked, this , &OpenStudioApp::loadExampleModel);
1271
+ disconnect (m_osDocument.get (), &OSDocument::loadShoeboxModelClicked, this , &OpenStudioApp::loadShoeboxModel);
1270
1272
disconnect (m_osDocument.get (), &OSDocument::newClicked, this , &OpenStudioApp::newModel);
1271
1273
disconnect (m_osDocument.get (), &OSDocument::helpClicked, this , &OpenStudioApp::showHelp);
1272
1274
disconnect (m_osDocument.get (), &OSDocument::checkForUpdateClicked, this , &OpenStudioApp::checkForUpdate);
@@ -1286,19 +1288,18 @@ void OpenStudioApp::measureManagerProcessFinished() {
1286
1288
QByteArray stdErr = m_measureManagerProcess->readAllStandardError ();
1287
1289
QByteArray stdOut = m_measureManagerProcess->readAllStandardOutput ();
1288
1290
1289
- QString text = tr (" Measure Manager has crashed, attempting to restart . Do you want to reset Measure Manager settings ?" );
1291
+ QString text = tr (" Measure Manager has crashed. Do you want to retry ?" );
1290
1292
QString detailedText;
1291
1293
detailedText += stdErr;
1292
1294
detailedText += stdOut;
1293
1295
1294
- QMessageBox messageBox (QMessageBox::Warning , tr (" Measure Manager Crashed" ), text, QMessageBox::RestoreDefaults | QMessageBox::Close, mainWidget (),
1296
+ QMessageBox messageBox (QMessageBox::Critical , tr (" Measure Manager Crashed" ), text, QMessageBox::Retry | QMessageBox::Close, mainWidget (),
1295
1297
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
1296
1298
messageBox.setDetailedText (detailedText);
1297
1299
1298
- if (messageBox.exec () == QMessageBox::RestoreDefaults) {
1299
- QSettings settings (QCoreApplication::organizationName (), QCoreApplication::applicationName ());
1300
- settings.setValue (" useClassicCLI" , true );
1301
- m_useClassicCLI = true ;
1300
+ if (messageBox.exec () == QMessageBox::Close) {
1301
+ // user can cancel out of quit, turns into retry
1302
+ quit ();
1302
1303
}
1303
1304
1304
1305
startMeasureManagerProcess ();
@@ -1351,9 +1352,7 @@ void OpenStudioApp::startMeasureManagerProcess() {
1351
1352
const QString program = toQString (openstudioCLIPath ());
1352
1353
QStringList arguments;
1353
1354
1354
- if (m_useClassicCLI) {
1355
- arguments << " classic" ;
1356
- }
1355
+ // MeasureManager does not work in classic CLI https://github.com/NREL/OpenStudio/issues/5212
1357
1356
arguments << " measure" ;
1358
1357
arguments << " -s" ;
1359
1358
arguments << portString;
@@ -1561,6 +1560,42 @@ void OpenStudioApp::loadExampleModel() {
1561
1560
OpenStudioApp::setQuitOnLastWindowClosed (wasQuitOnLastWindowClosed);
1562
1561
}
1563
1562
1563
+ void OpenStudioApp::loadShoeboxModel () {
1564
+
1565
+ bool wasQuitOnLastWindowClosed = OpenStudioApp::quitOnLastWindowClosed ();
1566
+ OpenStudioApp::setQuitOnLastWindowClosed (false );
1567
+
1568
+ if (m_osDocument) {
1569
+ if (!closeDocument ()) {
1570
+ OpenStudioApp::setQuitOnLastWindowClosed (wasQuitOnLastWindowClosed);
1571
+ return ;
1572
+ }
1573
+ processEvents ();
1574
+ }
1575
+
1576
+ osversion::VersionTranslator versionTranslator;
1577
+ versionTranslator.setAllowNewerVersions (false );
1578
+
1579
+ auto filePath = resourcesPath () / toPath (" ShoeboxModel/ShoeboxExample.osm" );
1580
+ boost::optional<openstudio::model::Model> model = versionTranslator.loadModel (filePath);
1581
+ if (!model && isOpenStudioApplicationRunningFromBuildDirectory ()) {
1582
+ filePath = getOpenStudioCoalitionMeasuresSourceDirectory () / toPath (" models/ShoeboxExample.osm" );
1583
+ model = versionTranslator.loadModel (filePath);
1584
+ }
1585
+
1586
+ if (model) {
1587
+ m_osDocument = std::make_shared<OSDocument>(componentLibrary (), resourcesPath (), model, toQString (filePath), false , startTabIndex ());
1588
+ m_osDocument->setSavePath (" " );
1589
+ connectOSDocumentSignals ();
1590
+
1591
+ QTimer::singleShot (0 , m_osDocument.get (), &OSDocument::markAsModified);
1592
+ }
1593
+
1594
+ waitDialog ()->hide ();
1595
+
1596
+ OpenStudioApp::setQuitOnLastWindowClosed (wasQuitOnLastWindowClosed);
1597
+ }
1598
+
1564
1599
void OpenStudioApp::changeDefaultLibraries () {
1565
1600
auto defaultPaths = defaultLibraryPaths ();
1566
1601
auto paths = libraryPaths ();
@@ -1590,18 +1625,6 @@ void OpenStudioApp::removeLibraryFromsSettings(const openstudio::path& path) {
1590
1625
writeLibraryPaths (paths);
1591
1626
}
1592
1627
1593
- void OpenStudioApp::showFailedMeasureManagerDialog () {
1594
-
1595
- QString text = tr (" The OpenStudio Application must close. Do you want to reset Measure Manager settings?\n\n " );
1596
- QMessageBox::StandardButton reply = QMessageBox::critical (mainWidget (), QString (" Failed to connect to Measure Manager" ), text,
1597
- QMessageBox::RestoreDefaults | QMessageBox::Close, QMessageBox::RestoreDefaults);
1598
- if (reply == QMessageBox::RestoreDefaults) {
1599
- QSettings settings (QCoreApplication::organizationName (), QCoreApplication::applicationName ());
1600
- settings.setValue (" useClassicCLI" , true );
1601
- settings.sync ();
1602
- }
1603
- }
1604
-
1605
1628
void OpenStudioApp::showFailedLibraryDialog (const std::vector<std::string>& failedPaths) {
1606
1629
if (!failedPaths.empty ()) {
1607
1630
QString text = tr (" Failed to load the following libraries...\n\n " );
0 commit comments