Skip to content

Commit

Permalink
Merge pull request #733 from openstudiocoalition/671_MarkPythonErrorC…
Browse files Browse the repository at this point in the history
…lassicCLI

Fix #671 - Mark Python Measures as in Error if use classic CLI to run the simulation
  • Loading branch information
jmarrec authored Sep 3, 2024
2 parents 82183e6 + 8d50667 commit f43dd7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/shared_gui_components/LocalLibraryController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,11 @@ QWidget* LibraryItemDelegate::view(QSharedPointer<OSListItem> dataSource) {
// Name

widget->label->setText(libraryItem->displayName());
if (libraryItem->hasError()) {
const bool useClassicCLI = OSAppBase::instance()->currentDocument()->mainWindow()->useClassicCLI();
if (useClassicCLI && (measureLanguage == MeasureLanguage::Python)) {
widget->setToolTip("Python Measures are not supported in the Classic CLI.\nYou can change CLI version using 'Preferences->Use Classic CLI'.");
widget->errorLabel->setVisible(true);
} else if (libraryItem->hasError()) {
widget->setToolTip(libraryItem->error());
widget->errorLabel->setVisible(true);
} else {
Expand Down
24 changes: 17 additions & 7 deletions src/shared_gui_components/WorkflowController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "BaseApp.hpp"
#include "../openstudio_lib/OSAppBase.hpp"
#include "../openstudio_lib/OSDocument.hpp"
#include "../openstudio_lib/MainWindow.hpp"
#include "LocalLibraryController.hpp"
#include "WorkflowTools.hpp"
#include "../model_editor/Utilities.hpp"
Expand Down Expand Up @@ -556,7 +557,9 @@ QWidget* MeasureStepItemDelegate::view(QSharedPointer<OSListItem> dataSource) {
if (QSharedPointer<MeasureStepItem> measureStepItem = dataSource.objectCast<MeasureStepItem>()) {
auto* workflowStepView = new WorkflowStepView();

const QString measureLangStr = toQString(measureStepItem->measureLanguage().valueName());
const MeasureLanguage measureLanguage = measureStepItem->measureLanguage();

const QString measureLangStr = toQString(measureLanguage.valueName());
if (measureStepItem->measureType() == MeasureType::ModelMeasure) {
workflowStepView->workflowStepButton->measureTypeBadge->setPixmap(
QPixmap(QString(":/images/openstudio_measure_icon_%1.png").arg(measureLangStr))
Expand Down Expand Up @@ -591,13 +594,20 @@ QWidget* MeasureStepItemDelegate::view(QSharedPointer<OSListItem> dataSource) {

connect(measureStepItem.data(), &MeasureStepItem::selectedChanged, workflowStepView->workflowStepButton, &WorkflowStepButton::setHasEmphasis);

try {
// Warning Icon
workflowStepView->workflowStepButton->cautionLabel->setVisible(measureStepItem->hasIncompleteArguments());
connect(measureStepItem.data(), &MeasureStepItem::argumentsChanged, workflowStepView->workflowStepButton->cautionLabel, &QLabel::setVisible);
} catch (const std::exception& e) {
workflowStepView->workflowStepButton->errorLabel->setToolTip(e.what());
const bool useClassicCLI = OSAppBase::instance()->currentDocument()->mainWindow()->useClassicCLI();
if (useClassicCLI && (measureLanguage == MeasureLanguage::Python)) {
workflowStepView->workflowStepButton->errorLabel->setToolTip(
"Python Measures are not supported in the Classic CLI.\nYou can change CLI version using 'Preferences->Use Classic CLI'.");
workflowStepView->workflowStepButton->errorLabel->setVisible(true);
} else {
try {
// Warning Icon
workflowStepView->workflowStepButton->cautionLabel->setVisible(measureStepItem->hasIncompleteArguments());
connect(measureStepItem.data(), &MeasureStepItem::argumentsChanged, workflowStepView->workflowStepButton->cautionLabel, &QLabel::setVisible);
} catch (const std::exception& e) {
workflowStepView->workflowStepButton->errorLabel->setToolTip(e.what());
workflowStepView->workflowStepButton->errorLabel->setVisible(true);
}
}

// Up and down buttons
Expand Down

0 comments on commit f43dd7a

Please sign in to comment.