mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3109 Ensemble calculation. Display warning dialog when no cases from the two ensembles match
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user