mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1288 Show view selection dialog also from 3D view
This commit is contained in:
parent
ecfd61ce68
commit
db56dd4bc9
@ -20,13 +20,15 @@
|
||||
|
||||
#include "RicShowContributingWellsFeatureImpl.h"
|
||||
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseWell.h"
|
||||
#include "RimViewManipulator.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
@ -59,10 +61,19 @@ void RicShowContributingWellsFeature::onActionTriggered(bool isChecked)
|
||||
RimEclipseView* eclipseView = nullptr;
|
||||
well->firstAncestorOrThisOfTypeAsserted(eclipseView);
|
||||
|
||||
RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(eclipseView, well->name(), eclipseView->currentTimeStep());
|
||||
RimEclipseResultCase* eclipseResultCase = nullptr;
|
||||
well->firstAncestorOrThisOfTypeAsserted(eclipseResultCase);
|
||||
|
||||
RiuMainWindow::instance()->setExpanded(eclipseView, true);
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(eclipseView);
|
||||
RimEclipseView* modifiedView = RicShowContributingWellsFeatureImpl::showViewSelection(eclipseResultCase, well->name(), eclipseView->currentTimeStep());
|
||||
if (modifiedView)
|
||||
{
|
||||
modifiedView->createDisplayModelAndRedraw();
|
||||
|
||||
std::vector<RimView*> viewsToUpdate;
|
||||
viewsToUpdate.push_back(modifiedView);
|
||||
|
||||
RimViewManipulator::applySourceViewCameraOnDestinationViews(eclipseView, viewsToUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -18,6 +18,10 @@
|
||||
|
||||
#include "RicShowContributingWellsFeatureImpl.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicSelectViewUI.h"
|
||||
|
||||
#include "RigFlowDiagResultAddress.h"
|
||||
#include "RigSingleWellResultsData.h"
|
||||
|
||||
@ -28,14 +32,111 @@
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseWell.h"
|
||||
#include "RimEclipseWellCollection.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RimFaultCollection.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimViewManipulator.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafAssert.h"
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RicShowContributingWellsFeatureImpl::showViewSelection(RimEclipseResultCase* wellAllocationResultCase, QString wellName, int timeStep)
|
||||
{
|
||||
const QString lastUsedViewKey("lastUsedViewKey");
|
||||
|
||||
RimEclipseView* defaultSelectedView = nullptr;
|
||||
{
|
||||
QString lastUsedViewRef = RiaApplication::instance()->cacheDataObject(lastUsedViewKey).toString();
|
||||
RimEclipseView* lastUsedView = dynamic_cast<RimEclipseView*>(caf::PdmReferenceHelper::objectFromReference(RiaApplication::instance()->project(), lastUsedViewRef));
|
||||
if (lastUsedView)
|
||||
{
|
||||
RimEclipseResultCase* lastUsedViewResultCase = nullptr;
|
||||
lastUsedView->firstAncestorOrThisOfTypeAsserted(lastUsedViewResultCase);
|
||||
|
||||
if (lastUsedViewResultCase == wellAllocationResultCase)
|
||||
{
|
||||
defaultSelectedView = lastUsedView;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defaultSelectedView)
|
||||
{
|
||||
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
if (activeView)
|
||||
{
|
||||
RimEclipseResultCase* activeViewResultCase = nullptr;
|
||||
activeView->firstAncestorOrThisOfTypeAsserted(activeViewResultCase);
|
||||
|
||||
if (activeViewResultCase == wellAllocationResultCase)
|
||||
{
|
||||
defaultSelectedView = activeView;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wellAllocationResultCase->views().size() > 0)
|
||||
{
|
||||
defaultSelectedView = dynamic_cast<RimEclipseView*>(wellAllocationResultCase->views()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RicSelectViewUI featureUi;
|
||||
if (defaultSelectedView)
|
||||
{
|
||||
featureUi.setView(defaultSelectedView);
|
||||
}
|
||||
else
|
||||
{
|
||||
featureUi.setCase(wellAllocationResultCase);
|
||||
}
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Show Contributing Wells in View", "");
|
||||
propertyDialog.resize(QSize(400, 200));
|
||||
|
||||
if (propertyDialog.exec() != QDialog::Accepted) return nullptr;
|
||||
|
||||
RimEclipseView* viewToManipulate = nullptr;
|
||||
if (featureUi.createNewView())
|
||||
{
|
||||
RimEclipseView* createdView = wellAllocationResultCase->createAndAddReservoirView();
|
||||
createdView->name = featureUi.newViewName();
|
||||
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
createdView->loadDataAndUpdate();
|
||||
wellAllocationResultCase->updateConnectedEditors();
|
||||
|
||||
viewToManipulate = createdView;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewToManipulate = featureUi.selectedView();
|
||||
}
|
||||
|
||||
CAF_ASSERT(viewToManipulate);
|
||||
|
||||
|
||||
RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(viewToManipulate, wellName, timeStep);
|
||||
|
||||
auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicShowMainWindowFeature");
|
||||
feature->actionTriggered(false);
|
||||
|
||||
RiuMainWindow::instance()->setExpanded(viewToManipulate, true);
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(viewToManipulate);
|
||||
|
||||
QString refFromProjectToView = caf::PdmReferenceHelper::referenceFromRootToObject(RiaApplication::instance()->project(), viewToManipulate);
|
||||
RiaApplication::instance()->setCacheDataObject(lastUsedViewKey, refFromProjectToView);
|
||||
|
||||
return viewToManipulate;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -22,10 +22,11 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RimEclipseWell;
|
||||
class RimEclipseView;
|
||||
class RimFlowDiagSolution;
|
||||
class RigSingleWellResultsData;
|
||||
class RimEclipseResultCase;
|
||||
class RimEclipseView;
|
||||
class RimEclipseWell;
|
||||
class RimFlowDiagSolution;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -33,9 +34,11 @@ class RigSingleWellResultsData;
|
||||
class RicShowContributingWellsFeatureImpl
|
||||
{
|
||||
public:
|
||||
static void modifyViewToShowContributingWells(RimEclipseView* viewToModify, const QString& wellName, int timeStep);
|
||||
static RimEclipseView* showViewSelection(RimEclipseResultCase* wellAllocationResultCase, QString wellName, int timeStep);
|
||||
|
||||
private:
|
||||
static void modifyViewToShowContributingWells(RimEclipseView* viewToModify, const QString& wellName, int timeStep);
|
||||
|
||||
static std::vector<QString> findContributingTracerNames(
|
||||
const RimFlowDiagSolution* flowDiagSolution,
|
||||
const RigSingleWellResultsData* wellResults,
|
||||
|
@ -20,20 +20,12 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicSelectViewUI.h"
|
||||
#include "RicShowContributingWellsFeatureImpl.h"
|
||||
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicShowContributingWellsFromPlotFeature, "RicShowContributingWellsFromPlotFeature");
|
||||
@ -51,100 +43,16 @@ bool RicShowContributingWellsFromPlotFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowContributingWellsFromPlotFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
const QString lastUsedViewKey("lastUsedViewKey");
|
||||
|
||||
RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot();
|
||||
if (!wellAllocationPlot) return;
|
||||
|
||||
RimEclipseResultCase* wellAllocationResultCase = nullptr;
|
||||
wellAllocationPlot->flowDiagSolution()->firstAncestorOrThisOfTypeAsserted(wellAllocationResultCase);
|
||||
|
||||
RimEclipseView* defaultSelectedView = nullptr;
|
||||
|
||||
{
|
||||
QString lastUsedViewRef = RiaApplication::instance()->cacheDataObject(lastUsedViewKey).toString();
|
||||
RimEclipseView* lastUsedView = dynamic_cast<RimEclipseView*>(caf::PdmReferenceHelper::objectFromReference(RiaApplication::instance()->project(), lastUsedViewRef));
|
||||
if (lastUsedView)
|
||||
{
|
||||
RimEclipseResultCase* lastUsedViewResultCase = nullptr;
|
||||
lastUsedView->firstAncestorOrThisOfTypeAsserted(lastUsedViewResultCase);
|
||||
|
||||
if (lastUsedViewResultCase == wellAllocationResultCase)
|
||||
{
|
||||
defaultSelectedView = lastUsedView;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defaultSelectedView)
|
||||
{
|
||||
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
if (activeView)
|
||||
{
|
||||
RimEclipseResultCase* activeViewResultCase = nullptr;
|
||||
activeView->firstAncestorOrThisOfTypeAsserted(activeViewResultCase);
|
||||
|
||||
if (activeViewResultCase == wellAllocationResultCase)
|
||||
{
|
||||
defaultSelectedView = activeView;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wellAllocationResultCase->views().size() > 0)
|
||||
{
|
||||
defaultSelectedView = dynamic_cast<RimEclipseView*>(wellAllocationResultCase->views()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RicSelectViewUI featureUi;
|
||||
if (defaultSelectedView)
|
||||
{
|
||||
featureUi.setView(defaultSelectedView);
|
||||
}
|
||||
else
|
||||
{
|
||||
featureUi.setCase(wellAllocationResultCase);
|
||||
}
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Show Contributing Wells in View", "");
|
||||
propertyDialog.resize(QSize(400, 200));
|
||||
|
||||
if (propertyDialog.exec() != QDialog::Accepted) return;
|
||||
|
||||
RimEclipseView* viewToManipulate = nullptr;
|
||||
if (featureUi.createNewView())
|
||||
{
|
||||
RimEclipseView* createdView = wellAllocationResultCase->createAndAddReservoirView();
|
||||
createdView->name = featureUi.newViewName();
|
||||
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
createdView->loadDataAndUpdate();
|
||||
wellAllocationResultCase->updateConnectedEditors();
|
||||
|
||||
viewToManipulate = createdView;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewToManipulate = featureUi.selectedView();
|
||||
}
|
||||
|
||||
CAF_ASSERT(viewToManipulate);
|
||||
|
||||
int timeStep = wellAllocationPlot->timeStep();
|
||||
QString wellName = wellAllocationPlot->wellName();
|
||||
|
||||
RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(viewToManipulate, wellName, timeStep);
|
||||
RimEclipseResultCase* wellAllocationResultCase = nullptr;
|
||||
wellAllocationPlot->flowDiagSolution()->firstAncestorOrThisOfTypeAsserted(wellAllocationResultCase);
|
||||
|
||||
auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicShowMainWindowFeature");
|
||||
feature->actionTriggered(false);
|
||||
|
||||
RiuMainWindow::instance()->setExpanded(viewToManipulate, true);
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(viewToManipulate);
|
||||
|
||||
QString refFromProjectToView = caf::PdmReferenceHelper::referenceFromRootToObject(RiaApplication::instance()->project(), viewToManipulate);
|
||||
RiaApplication::instance()->setCacheDataObject(lastUsedViewKey, refFromProjectToView);
|
||||
RicShowContributingWellsFeatureImpl::showViewSelection(wellAllocationResultCase, wellName, timeStep);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user