mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#372) Drag Drop Move implemented.
User question on closing/moving a statistics source case
This commit is contained in:
@@ -19,21 +19,26 @@
|
||||
|
||||
#include "RicCloseCaseFeature.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimGeoMechModels.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimEclipseStatisticsCase.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechModels.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmFieldHandle.h"
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCloseCaseFeature, "RicCloseCaseFeature");
|
||||
|
||||
@@ -54,7 +59,13 @@ void RicCloseCaseFeature::onActionTriggered(bool isChecked)
|
||||
RimGeoMechCase* geoMechCase = selectedGeoMechCase();
|
||||
if (eclipseCase)
|
||||
{
|
||||
deleteEclipseCase(eclipseCase);
|
||||
std::vector<RimEclipseCase*> casesToBeDeleted;
|
||||
casesToBeDeleted.push_back(eclipseCase);
|
||||
|
||||
if (userConfirmedGridCaseGroupChange(casesToBeDeleted))
|
||||
{
|
||||
deleteEclipseCase(eclipseCase);
|
||||
}
|
||||
}
|
||||
else if (geoMechCase)
|
||||
{
|
||||
@@ -169,3 +180,82 @@ void RicCloseCaseFeature::deleteGeoMechCase(RimGeoMechCase* geoMechCase)
|
||||
|
||||
delete geoMechCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCloseCaseFeature::hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gridCaseGroup)
|
||||
{
|
||||
CVF_ASSERT(gridCaseGroup);
|
||||
|
||||
for (size_t i = 0; i < gridCaseGroup->statisticsCaseCollection()->reservoirs().size(); i++)
|
||||
{
|
||||
RimEclipseStatisticsCase* rimStaticsCase = dynamic_cast<RimEclipseStatisticsCase*>(gridCaseGroup->statisticsCaseCollection()->reservoirs[i]);
|
||||
if (rimStaticsCase)
|
||||
{
|
||||
if (rimStaticsCase->hasComputedStatistics())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCloseCaseFeature::userConfirmedGridCaseGroupChange(const std::vector<RimEclipseCase*>& casesToBeDeleted)
|
||||
{
|
||||
std::vector<RimIdenticalGridCaseGroup*> gridCaseGroups;
|
||||
|
||||
for (size_t i = 0; i < casesToBeDeleted.size(); i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
||||
casesToBeDeleted[i]->firstAnchestorOrThisOfType(gridCaseGroup);
|
||||
|
||||
if (hasAnyStatisticsResults(gridCaseGroup))
|
||||
{
|
||||
gridCaseGroups.push_back(gridCaseGroup);
|
||||
}
|
||||
}
|
||||
|
||||
if (gridCaseGroups.size() > 0)
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
|
||||
QMessageBox msgBox(mainWnd);
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
|
||||
QString questionText;
|
||||
if (gridCaseGroups.size() == 1)
|
||||
{
|
||||
questionText = QString("This operation will invalidate statistics results in grid case group\n\"%1\".\n").arg(gridCaseGroups[0]->name());
|
||||
questionText += "Computed results in this group will be deleted if you continue.";
|
||||
}
|
||||
else
|
||||
{
|
||||
questionText = "This operation will invalidate statistics results in grid case groups\n";
|
||||
for (size_t i = 0; i < gridCaseGroups.size(); i++)
|
||||
{
|
||||
questionText += QString("\"%1\"\n").arg(gridCaseGroups[i]->name());
|
||||
}
|
||||
|
||||
questionText += "Computed results in these groups will be deleted if you continue.";
|
||||
}
|
||||
|
||||
msgBox.setText(questionText);
|
||||
msgBox.setInformativeText("Do you want to continue?");
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
int ret = msgBox.exec();
|
||||
if (ret == QMessageBox::No)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user