#3109 Ensemble calculation. Display warning dialog when no cases from the two ensembles match

This commit is contained in:
Bjørn Erik Jensen
2018-06-28 08:34:14 +02:00
parent 33d8655c3a
commit dde88a010e
4 changed files with 54 additions and 4 deletions

View File

@@ -29,12 +29,37 @@
#include "cafSelectionManagerTools.h"
#include <QAction>
#include <QMessageBox>
#include <memory>
CAF_CMD_SOURCE_INIT(RicNewDerivedEnsembleFeature, "RicNewDerivedEnsembleFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewDerivedEnsembleFeature::showWarningDialog()
{
QMessageBox::warning(nullptr, "Ensemble Matching", "None of the cases in the ensembles match");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewDerivedEnsembleFeature::showWarningDialogWithQuestion()
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle("Ensemble Matching");
msgBox.setText("None of the cases in the ensembles match");
msgBox.setInformativeText("Do you want to keep the derived ensemble?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
int ret = msgBox.exec();
return ret == QMessageBox::Yes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -67,6 +92,14 @@ void RicNewDerivedEnsembleFeature::onActionTriggered(bool isChecked)
{
newEnsemble->setEnsemble2(ensembles[1]);
newEnsemble->updateDerivedEnsembleCases();
if (newEnsemble->allSummaryCases().empty())
{
if(!showWarningDialogWithQuestion())
{
mainColl->removeCaseCollection(newEnsemble);
}
}
}
}

View File

@@ -31,6 +31,10 @@ class RicNewDerivedEnsembleFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void showWarningDialog();
static bool showWarningDialogWithQuestion();
protected:
// Overrides
virtual bool isCommandEnabled();