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 "cafSelectionManagerTools.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
CAF_CMD_SOURCE_INIT(RicNewDerivedEnsembleFeature, "RicNewDerivedEnsembleFeature");
|
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->setEnsemble2(ensembles[1]);
|
||||||
newEnsemble->updateDerivedEnsembleCases();
|
newEnsemble->updateDerivedEnsembleCases();
|
||||||
|
|
||||||
|
if (newEnsemble->allSummaryCases().empty())
|
||||||
|
{
|
||||||
|
if(!showWarningDialogWithQuestion())
|
||||||
|
{
|
||||||
|
mainColl->removeCaseCollection(newEnsemble);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ class RicNewDerivedEnsembleFeature : public caf::CmdFeature
|
|||||||
{
|
{
|
||||||
CAF_CMD_HEADER_INIT;
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void showWarningDialog();
|
||||||
|
static bool showWarningDialogWithQuestion();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual bool isCommandEnabled();
|
virtual bool isCommandEnabled();
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "RiaTimeHistoryCurveMerger.h"
|
#include "RiaTimeHistoryCurveMerger.h"
|
||||||
|
|
||||||
|
#include "SummaryPlotCommands/RicNewDerivedEnsembleFeature.h"
|
||||||
|
|
||||||
#include "RimDerivedEnsembleCaseCollection.h"
|
#include "RimDerivedEnsembleCaseCollection.h"
|
||||||
#include "RimDerivedEnsembleCase.h"
|
#include "RimDerivedEnsembleCase.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
@@ -66,7 +68,7 @@ RimDerivedEnsembleCaseCollection::RimDerivedEnsembleCaseCollection()
|
|||||||
m_swapEnsemblesButton.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
m_swapEnsemblesButton.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||||
m_swapEnsemblesButton.xmlCapability()->disableIO();
|
m_swapEnsemblesButton.xmlCapability()->disableIO();
|
||||||
|
|
||||||
CAF_PDM_InitField(&m_caseCount, "CaseCount", 0, "Number of Cases", "", "", "");
|
CAF_PDM_InitField(&m_caseCount, "CaseCount", QString(""), "Matching Cases", "", "", "");
|
||||||
m_caseCount.uiCapability()->setUiReadOnly(true);
|
m_caseCount.uiCapability()->setUiReadOnly(true);
|
||||||
|
|
||||||
// Do not show child cases
|
// Do not show child cases
|
||||||
@@ -207,7 +209,10 @@ QList<caf::PdmOptionItemInfo> RimDerivedEnsembleCaseCollection::calculateValueOp
|
|||||||
}
|
}
|
||||||
else if (fieldNeedingOptions == &m_caseCount)
|
else if (fieldNeedingOptions == &m_caseCount)
|
||||||
{
|
{
|
||||||
m_caseCount = (int)m_cases.size();
|
size_t caseCount1 = m_ensemble1 ? m_ensemble1->allSummaryCases().size() : 0;
|
||||||
|
size_t caseCount2 = m_ensemble2 ? m_ensemble2->allSummaryCases().size() : 0;
|
||||||
|
|
||||||
|
m_caseCount = QString("%1 / %2").arg((int)m_cases.size()).arg(std::max(caseCount1, caseCount2));
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
@@ -236,16 +241,19 @@ void RimDerivedEnsembleCaseCollection::fieldChangedByUi(const caf::PdmFieldHandl
|
|||||||
bool doUpdate = false;
|
bool doUpdate = false;
|
||||||
bool doUpdateCases = false;
|
bool doUpdateCases = false;
|
||||||
bool doClearAllData = false;
|
bool doClearAllData = false;
|
||||||
|
bool doShowDialog = false;
|
||||||
|
|
||||||
if (changedField == &m_ensemble1 || changedField == &m_ensemble2)
|
if (changedField == &m_ensemble1 || changedField == &m_ensemble2)
|
||||||
{
|
{
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
doUpdateCases = true;
|
doUpdateCases = true;
|
||||||
|
doShowDialog = true;
|
||||||
}
|
}
|
||||||
else if (changedField == &m_operator)
|
else if (changedField == &m_operator)
|
||||||
{
|
{
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
doUpdateCases = true;
|
doUpdateCases = true;
|
||||||
|
doShowDialog = false;
|
||||||
}
|
}
|
||||||
else if (changedField == &m_swapEnsemblesButton)
|
else if (changedField == &m_swapEnsemblesButton)
|
||||||
{
|
{
|
||||||
@@ -256,17 +264,22 @@ void RimDerivedEnsembleCaseCollection::fieldChangedByUi(const caf::PdmFieldHandl
|
|||||||
|
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
doUpdateCases = true;
|
doUpdateCases = true;
|
||||||
|
doShowDialog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doUpdate)
|
if (doUpdate)
|
||||||
{
|
{
|
||||||
updateAutoName();
|
updateAutoName();
|
||||||
//if (doClearAllData) clearAllData();
|
|
||||||
|
|
||||||
if (doUpdateCases)
|
if (doUpdateCases)
|
||||||
{
|
{
|
||||||
updateDerivedEnsembleCases();
|
updateDerivedEnsembleCases();
|
||||||
updateConnectedEditors();
|
updateConnectedEditors();
|
||||||
|
|
||||||
|
if (doShowDialog && m_ensemble1 != nullptr && m_ensemble2 != nullptr && allSummaryCases().empty())
|
||||||
|
{
|
||||||
|
RicNewDerivedEnsembleFeature::showWarningDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateReferringCurveSets();
|
updateReferringCurveSets();
|
||||||
|
|||||||
@@ -81,5 +81,5 @@ private:
|
|||||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble2;
|
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble2;
|
||||||
caf::PdmField<caf::AppEnum<DerivedEnsembleOperator>> m_operator;
|
caf::PdmField<caf::AppEnum<DerivedEnsembleOperator>> m_operator;
|
||||||
caf::PdmField<bool> m_swapEnsemblesButton;
|
caf::PdmField<bool> m_swapEnsemblesButton;
|
||||||
caf::PdmField<int> m_caseCount;
|
caf::PdmField<QString> m_caseCount;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user