mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
If the mapping is not applicable, we just use the numbers as is. If the ecl case is inside the geom case, we use the mapping. Removed initAfterRead on ViewController
975 lines
34 KiB
C++
975 lines
34 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2015- Statoil ASA
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
//
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RimViewController.h"
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RigCaseData.h"
|
|
#include "RigCaseToCaseCellMapper.h"
|
|
#include "RigFemPartCollection.h"
|
|
#include "RigGeoMechCaseData.h"
|
|
|
|
#include "RimCase.h"
|
|
#include "RimCellRangeFilterCollection.h"
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseCellColors.h"
|
|
#include "RimEclipsePropertyFilterCollection.h"
|
|
#include "RimEclipseView.h"
|
|
#include "RimGeoMechCase.h"
|
|
#include "RimGeoMechCellColors.h"
|
|
#include "RimGeoMechPropertyFilterCollection.h"
|
|
#include "RimGeoMechView.h"
|
|
#include "RimProject.h"
|
|
#include "RimView.h"
|
|
#include "RimViewLinker.h"
|
|
#include "RimViewLinkerCollection.h"
|
|
|
|
#include "RiuViewer.h"
|
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
#include "RigCaseToCaseRangeFilterMapper.h"
|
|
|
|
#include <QMessageBox>
|
|
|
|
CAF_PDM_SOURCE_INIT(RimViewController, "ViewController");
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimViewController::RimViewController(void)
|
|
{
|
|
CAF_PDM_InitObject("View Link", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", "");
|
|
m_isActive.uiCapability()->setUiHidden(true);
|
|
|
|
QString defaultName = "View Config: Empty view";
|
|
CAF_PDM_InitField(&m_name, "Name", defaultName, "Managed View Name", "", "", "");
|
|
m_name.uiCapability()->setUiHidden(true);
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_managedView, "ManagedView", "Linked View", "", "", "");
|
|
m_managedView.uiCapability()->setUiChildrenHidden(true);
|
|
|
|
CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera", "", "", "");
|
|
CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step", "", "", "");
|
|
CAF_PDM_InitField(&m_syncCellResult, "SyncCellResult", false, "Cell Result", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_syncVisibleCells, "SyncVisibleCells", false, "Visible Cells", "", "", "");
|
|
/// We do not support this. Consider to remove sometime
|
|
m_syncVisibleCells.uiCapability()->setUiHidden(true);
|
|
m_syncVisibleCells.xmlCapability()->setIOWritable(false);
|
|
m_syncVisibleCells.xmlCapability()->setIOReadable(false);
|
|
|
|
CAF_PDM_InitField(&m_syncRangeFilters, "SyncRangeFilters", false, "Range Filters", "", "", "");
|
|
CAF_PDM_InitField(&m_syncPropertyFilters, "SyncPropertyFilters", false,"Property Filters", "", "", "");
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimViewController::~RimViewController(void)
|
|
{
|
|
this->removeOverrides();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QList<caf::PdmOptionItemInfo> RimViewController::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
{
|
|
QList<caf::PdmOptionItemInfo> optionList;
|
|
|
|
if (fieldNeedingOptions == &m_managedView)
|
|
{
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
std::vector<RimView*> views;
|
|
proj->allNotLinkedViews(views);
|
|
|
|
// Add currently linked view to list
|
|
if (this->managedView())
|
|
{
|
|
views.push_back(this->managedView());
|
|
}
|
|
|
|
RimViewLinker* linkedViews = NULL;
|
|
this->firstAnchestorOrThisOfType(linkedViews);
|
|
|
|
for (size_t i = 0; i< views.size(); i++)
|
|
{
|
|
if (views[i] != linkedViews->masterView())
|
|
{
|
|
RimCase* rimCase = NULL;
|
|
views[i]->firstAnchestorOrThisOfType(rimCase);
|
|
QIcon icon;
|
|
if (rimCase)
|
|
{
|
|
icon = rimCase->uiCapability()->uiIcon();
|
|
}
|
|
|
|
optionList.push_back(caf::PdmOptionItemInfo(RimViewLinker::displayNameForView(views[i]),
|
|
QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(views[i])),
|
|
false,
|
|
icon));
|
|
}
|
|
}
|
|
|
|
if (optionList.size() > 0)
|
|
{
|
|
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
|
}
|
|
}
|
|
|
|
return optionList;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
|
{
|
|
updateDisplayNameAndIcon();
|
|
uiTreeOrdering.setForgetRemainingFields(true);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
{
|
|
if (changedField == &m_isActive)
|
|
{
|
|
if (!m_isActive)
|
|
{
|
|
applyRangeFilterCollectionByUserChoice();
|
|
}
|
|
|
|
updateOverrides();
|
|
updateResultColorsControl();
|
|
updateCameraLink();
|
|
updateDisplayNameAndIcon();
|
|
updateTimeStepLink();
|
|
}
|
|
else if (changedField == &m_syncCamera)
|
|
{
|
|
updateCameraLink();
|
|
}
|
|
else if (changedField == &m_syncTimeStep )
|
|
{
|
|
updateTimeStepLink();
|
|
}
|
|
else if (changedField == &m_syncCellResult)
|
|
{
|
|
updateResultColorsControl();
|
|
if (managedEclipseView())
|
|
{
|
|
managedEclipseView()->cellResult()->updateIconState();
|
|
}
|
|
else if (managedGeoView())
|
|
{
|
|
managedGeoView()->cellResult()->updateIconState();
|
|
}
|
|
}
|
|
else if (changedField == &m_syncRangeFilters)
|
|
{
|
|
if (!m_syncRangeFilters)
|
|
{
|
|
applyRangeFilterCollectionByUserChoice();
|
|
}
|
|
updateOverrides();
|
|
}
|
|
else if (changedField == &m_syncPropertyFilters)
|
|
{
|
|
updateOverrides();
|
|
}
|
|
else if (changedField == &m_managedView)
|
|
{
|
|
PdmObjectHandle* prevValue = oldValue.value<caf::PdmPointer<PdmObjectHandle> >().rawPtr();
|
|
RimView* previousManagedView = dynamic_cast<RimView*>(prevValue);
|
|
RimViewController::removeOverrides(previousManagedView);
|
|
|
|
setManagedView(m_managedView());
|
|
|
|
m_name.uiCapability()->updateConnectedEditors();
|
|
}
|
|
else if (&m_syncVisibleCells == changedField)
|
|
{
|
|
updateOptionSensitivity();
|
|
updateOverrides();
|
|
}
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimEclipseView* RimViewController::managedEclipseView()
|
|
{
|
|
RimView* rimView = m_managedView;
|
|
|
|
return dynamic_cast<RimEclipseView*>(rimView);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimGeoMechView* RimViewController::managedGeoView()
|
|
{
|
|
RimView* rimView = m_managedView;
|
|
|
|
return dynamic_cast<RimGeoMechView*>(rimView);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::updateOverrides()
|
|
{
|
|
RimViewLinker* viewLinker = ownerViewLinker();
|
|
|
|
RimView* masterView = viewLinker->masterView();
|
|
|
|
CVF_ASSERT(masterView);
|
|
|
|
if (m_managedView)
|
|
{
|
|
RimEclipseView* manEclView = managedEclipseView();
|
|
RimGeoMechView* manGeoView = managedGeoView();
|
|
|
|
if (isVisibleCellsOveridden())
|
|
{
|
|
if (manEclView) manEclView->setOverridePropertyFilterCollection(NULL);
|
|
if (manGeoView) manGeoView->setOverridePropertyFilterCollection(NULL);
|
|
m_managedView->scheduleGeometryRegen(OVERRIDDEN_CELL_VISIBILITY);
|
|
m_managedView->scheduleCreateDisplayModelAndRedraw();
|
|
}
|
|
else
|
|
{
|
|
RimEclipseView* masterEclipseView = dynamic_cast<RimEclipseView*>(masterView);
|
|
if (masterEclipseView)
|
|
{
|
|
|
|
if (manEclView)
|
|
{
|
|
if (isPropertyFilterOveridden())
|
|
{
|
|
manEclView->setOverridePropertyFilterCollection(masterEclipseView->propertyFilterCollection());
|
|
}
|
|
else
|
|
{
|
|
manEclView->setOverridePropertyFilterCollection(NULL);
|
|
}
|
|
}
|
|
}
|
|
|
|
RimGeoMechView* masterGeoView = dynamic_cast<RimGeoMechView*>(masterView);
|
|
if (masterGeoView)
|
|
{
|
|
if (manGeoView)
|
|
{
|
|
if (isPropertyFilterOveridden())
|
|
{
|
|
manGeoView->setOverridePropertyFilterCollection(masterGeoView->propertyFilterCollection());
|
|
}
|
|
else
|
|
{
|
|
manGeoView->setOverridePropertyFilterCollection(NULL);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
this->updateRangeFilterOverrides(NULL);
|
|
|
|
if (manGeoView)
|
|
{
|
|
manGeoView->updateIconStateForFilterCollections();
|
|
}
|
|
|
|
if (manEclView)
|
|
{
|
|
manEclView->updateIconStateForFilterCollections();
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::removeOverrides()
|
|
{
|
|
removeOverrides(m_managedView);
|
|
}
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::removeOverrides(RimView* view)
|
|
{
|
|
if (view)
|
|
{
|
|
RimEclipseView* manEclView = dynamic_cast<RimEclipseView*>(view);
|
|
RimGeoMechView* manGeoView = dynamic_cast<RimGeoMechView*>(view);
|
|
|
|
if (manEclView) manEclView->setOverridePropertyFilterCollection(NULL);
|
|
if (manGeoView) manGeoView->setOverridePropertyFilterCollection(NULL);
|
|
|
|
view->setOverrideRangeFilterCollection(NULL);
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::updateOptionSensitivity()
|
|
{
|
|
RimViewLinker* linkedViews = NULL;
|
|
firstAnchestorOrThisOfType(linkedViews);
|
|
CVF_ASSERT(linkedViews);
|
|
|
|
RimView* mainView = linkedViews->masterView();
|
|
CVF_ASSERT(mainView);
|
|
|
|
RimEclipseView* eclipseMasterView = dynamic_cast<RimEclipseView*>(mainView);
|
|
RimGeoMechView* geoMasterView = dynamic_cast<RimGeoMechView*>(mainView);
|
|
|
|
bool isMasterAndDependentViewDifferentType = false;
|
|
if (eclipseMasterView && !managedEclipseView())
|
|
{
|
|
isMasterAndDependentViewDifferentType = true;
|
|
}
|
|
if (geoMasterView && !managedGeoView())
|
|
{
|
|
isMasterAndDependentViewDifferentType = true;
|
|
}
|
|
|
|
if (isMasterAndDependentViewDifferentType)
|
|
{
|
|
this->m_syncCellResult.uiCapability()->setUiReadOnly(true);
|
|
this->m_syncCellResult = false;
|
|
}
|
|
else
|
|
{
|
|
this->m_syncCellResult.uiCapability()->setUiReadOnly(false);
|
|
}
|
|
|
|
if (isPropertyFilterControlPossible())
|
|
{
|
|
this->m_syncPropertyFilters.uiCapability()->setUiReadOnly(false);
|
|
}
|
|
else
|
|
{
|
|
this->m_syncPropertyFilters.uiCapability()->setUiReadOnly(true);
|
|
this->m_syncPropertyFilters = false;
|
|
}
|
|
|
|
|
|
if (isRangeFilterControlPossible())
|
|
{
|
|
this->m_syncRangeFilters.uiCapability()->setUiReadOnly(false);
|
|
}
|
|
else
|
|
{
|
|
this->m_syncRangeFilters.uiCapability()->setUiReadOnly(true);
|
|
this->m_syncRangeFilters = false;
|
|
}
|
|
|
|
m_syncVisibleCells.uiCapability()->setUiReadOnly(!this->isMasterAndDepViewDifferentType());
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimView* RimViewController::managedView()
|
|
{
|
|
return m_managedView;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::setManagedView(RimView* view)
|
|
{
|
|
m_managedView = view;
|
|
|
|
updateOptionSensitivity();
|
|
updateOverrides();
|
|
updateResultColorsControl();
|
|
updateCameraLink();
|
|
updateDisplayNameAndIcon();
|
|
updateTimeStepLink();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
{
|
|
updateOptionSensitivity();
|
|
uiOrdering.add(&m_managedView);
|
|
|
|
caf::PdmUiGroup* scriptGroup = uiOrdering.addNewGroup("Link Options");
|
|
|
|
scriptGroup->add(&m_syncCamera);
|
|
scriptGroup->add(&m_syncTimeStep);
|
|
scriptGroup->add(&m_syncCellResult);
|
|
|
|
caf::PdmUiGroup* visibleCells = uiOrdering.addNewGroup("Link Cell Filters");
|
|
visibleCells->add(&m_syncVisibleCells);
|
|
visibleCells->add(&m_syncRangeFilters);
|
|
visibleCells->add(&m_syncPropertyFilters);
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::updateDisplayNameAndIcon()
|
|
{
|
|
RimViewLinker::findNameAndIconFromView(&m_name.v(), &m_originalIcon, managedView());
|
|
RimViewLinker::applyIconEnabledState(this, m_originalIcon, !m_isActive());
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::updateCameraLink()
|
|
{
|
|
if (!this->isCameraLinked()) return;
|
|
if (m_managedView)
|
|
{
|
|
RimViewLinker* viewLinker = this->ownerViewLinker();
|
|
|
|
viewLinker->updateScaleZ(viewLinker->masterView(), viewLinker->masterView()->scaleZ());
|
|
viewLinker->updateCamera(viewLinker->masterView());
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::updateTimeStepLink()
|
|
{
|
|
if (!this->isTimeStepLinked()) return;
|
|
|
|
if (m_managedView)
|
|
{
|
|
RimViewLinker* viewLinker = this->ownerViewLinker();
|
|
|
|
viewLinker->updateTimeStep(viewLinker->masterView(), viewLinker->masterView()->currentTimeStep());
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::updateResultColorsControl()
|
|
{
|
|
if (!this->isResultColorControlled()) return;
|
|
|
|
RimViewLinker* viewLinker = ownerViewLinker();
|
|
viewLinker->updateCellResult();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimViewLinker* RimViewController::ownerViewLinker()
|
|
{
|
|
RimViewLinker* viewLinker = NULL;
|
|
this->firstAnchestorOrThisOfType(viewLinker);
|
|
|
|
return viewLinker;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const RigCaseToCaseCellMapper* RimViewController::cellMapper()
|
|
{
|
|
RimEclipseView* masterEclipseView = dynamic_cast<RimEclipseView*>(masterView());
|
|
RimEclipseView* dependEclipseView = managedEclipseView();
|
|
RimGeoMechView* masterGeomechView = dynamic_cast<RimGeoMechView*>(masterView());
|
|
RimGeoMechView* dependGeomechView = managedGeoView();
|
|
|
|
RigMainGrid* masterEclGrid = NULL;
|
|
RigMainGrid* dependEclGrid = NULL;
|
|
RigFemPart* masterFemPart = NULL;
|
|
RigFemPart* dependFemPart = NULL;
|
|
|
|
if (masterEclipseView && masterEclipseView->eclipseCase()->reservoirData())
|
|
{
|
|
masterEclGrid = masterEclipseView->eclipseCase()->reservoirData()->mainGrid();
|
|
}
|
|
|
|
if (dependEclipseView && dependEclipseView->eclipseCase()->reservoirData())
|
|
{
|
|
dependEclGrid = dependEclipseView->eclipseCase()->reservoirData()->mainGrid();
|
|
}
|
|
|
|
if (masterGeomechView && masterGeomechView->geoMechCase()->geoMechData()
|
|
&& masterGeomechView->geoMechCase()->geoMechData()->femParts()->partCount())
|
|
{
|
|
masterFemPart = masterGeomechView->geoMechCase()->geoMechData()->femParts()->part(0);
|
|
}
|
|
|
|
if (dependGeomechView && dependGeomechView->geoMechCase()->geoMechData()
|
|
&& dependGeomechView->geoMechCase()->geoMechData()->femParts()->partCount())
|
|
{
|
|
dependFemPart = dependGeomechView->geoMechCase()->geoMechData()->femParts()->part(0);
|
|
}
|
|
|
|
// If we have the correct mapping already, return it.
|
|
if (m_caseToCaseCellMapper.notNull())
|
|
{
|
|
if ( masterEclGrid == m_caseToCaseCellMapper->masterGrid()
|
|
&& dependEclGrid == m_caseToCaseCellMapper->dependentGrid()
|
|
&& masterFemPart == m_caseToCaseCellMapper->masterFemPart()
|
|
&& dependFemPart == m_caseToCaseCellMapper->dependentFemPart())
|
|
{
|
|
return m_caseToCaseCellMapper.p();
|
|
}
|
|
else
|
|
{
|
|
m_caseToCaseCellMapper = NULL;
|
|
}
|
|
}
|
|
|
|
// Create the mapping if needed
|
|
|
|
if (m_caseToCaseCellMapper.isNull())
|
|
{
|
|
if (masterEclGrid && dependFemPart)
|
|
{
|
|
m_caseToCaseCellMapper = new RigCaseToCaseCellMapper(masterEclGrid, dependFemPart);
|
|
}
|
|
else if (masterEclGrid && dependEclGrid)
|
|
{
|
|
m_caseToCaseCellMapper = new RigCaseToCaseCellMapper(masterEclGrid, dependEclGrid);
|
|
}
|
|
else if (masterFemPart && dependFemPart)
|
|
{
|
|
m_caseToCaseCellMapper = new RigCaseToCaseCellMapper(masterFemPart, dependFemPart);
|
|
}
|
|
else if (masterFemPart && dependEclGrid)
|
|
{
|
|
m_caseToCaseCellMapper = new RigCaseToCaseCellMapper(masterFemPart, dependEclGrid);
|
|
}
|
|
}
|
|
|
|
return m_caseToCaseCellMapper.p();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimView* RimViewController::masterView()
|
|
{
|
|
return ownerViewLinker()->masterView();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isMasterAndDepViewDifferentType()
|
|
{
|
|
RimEclipseView* eclipseMasterView = dynamic_cast<RimEclipseView*>(masterView());
|
|
RimGeoMechView* geoMasterView = dynamic_cast<RimGeoMechView*>(masterView());
|
|
|
|
bool isMasterAndDependentViewDifferentType = false;
|
|
if (eclipseMasterView && !managedEclipseView())
|
|
{
|
|
isMasterAndDependentViewDifferentType = true;
|
|
}
|
|
if (geoMasterView && !managedGeoView())
|
|
{
|
|
isMasterAndDependentViewDifferentType = true;
|
|
}
|
|
|
|
return isMasterAndDependentViewDifferentType;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::scheduleCreateDisplayModelAndRedrawForDependentView()
|
|
{
|
|
if (!this->isActive()) return;
|
|
|
|
if (this->isVisibleCellsOveridden()
|
|
|| this->isRangeFiltersControlled()
|
|
|| this->isPropertyFilterOveridden()
|
|
|| this->isResultColorControlled()
|
|
)
|
|
{
|
|
if (this->managedView())
|
|
{
|
|
this->managedView()->scheduleCreateDisplayModelAndRedraw();
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::scheduleGeometryRegenForDepViews(RivCellSetEnum geometryType)
|
|
{
|
|
if (!this->isActive()) return;
|
|
|
|
if ( this->isVisibleCellsOveridden()
|
|
|| this->isRangeFiltersControlled()
|
|
|| this->isPropertyFilterOveridden()
|
|
|| this->isResultColorControlled()
|
|
)
|
|
{
|
|
if (this->managedView())
|
|
{
|
|
if (this->isVisibleCellsOveridden())
|
|
{
|
|
this->managedView()->scheduleGeometryRegen(OVERRIDDEN_CELL_VISIBILITY);
|
|
}
|
|
|
|
this->managedView()->scheduleGeometryRegen(geometryType);
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isActive()
|
|
{
|
|
return ownerViewLinker()->isActive() && this->m_isActive();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isCameraLinked()
|
|
{
|
|
if (ownerViewLinker()->isActive() && this->m_isActive())
|
|
{
|
|
return m_syncCamera;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isTimeStepLinked()
|
|
{
|
|
if (ownerViewLinker()->isActive() && this->m_isActive())
|
|
{
|
|
return m_syncTimeStep;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isResultColorControlled()
|
|
{
|
|
if (ownerViewLinker()->isActive() && this->m_isActive())
|
|
{
|
|
return m_syncCellResult;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isVisibleCellsOveridden()
|
|
{
|
|
if (isMasterAndDepViewDifferentType())
|
|
{
|
|
if (ownerViewLinker()->isActive() && this->m_isActive())
|
|
{
|
|
return m_syncVisibleCells();
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isRangeFilterControlPossible()
|
|
{
|
|
return true;
|
|
#if 0
|
|
if (!isMasterAndDepViewDifferentType()) return true;
|
|
|
|
// Make sure the cases are in the same domain
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(masterView());
|
|
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(masterView());
|
|
if (!geomView) geomView = managedGeoView();
|
|
if (!eclipseView) eclipseView = managedEclipseView();
|
|
|
|
if (eclipseView && geomView)
|
|
{
|
|
if (eclipseView->eclipseCase()->reservoirData() && geomView->geoMechCase()->geoMechData())
|
|
{
|
|
RigMainGrid* eclGrid = eclipseView->eclipseCase()->reservoirData()->mainGrid();
|
|
RigFemPart* femPart = geomView->geoMechCase()->geoMechData()->femParts()->part(0);
|
|
|
|
if (eclGrid && femPart)
|
|
{
|
|
cvf::BoundingBox fembb = femPart->boundingBox();
|
|
cvf::BoundingBox eclbb = eclGrid->boundingBox();
|
|
return fembb.contains(eclbb.min()) && fembb.contains(eclbb.max());
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isRangeFilterMappingApliccable()
|
|
{
|
|
if (!isMasterAndDepViewDifferentType()) return false;
|
|
|
|
// Make sure the cases are in the same domain
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(masterView());
|
|
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(masterView());
|
|
if (!geomView) geomView = managedGeoView();
|
|
if (!eclipseView) eclipseView = managedEclipseView();
|
|
|
|
if (eclipseView && geomView)
|
|
{
|
|
if (eclipseView->eclipseCase()->reservoirData() && geomView->geoMechCase()->geoMechData())
|
|
{
|
|
RigMainGrid* eclGrid = eclipseView->eclipseCase()->reservoirData()->mainGrid();
|
|
RigFemPart* femPart = geomView->geoMechCase()->geoMechData()->femParts()->part(0);
|
|
|
|
if (eclGrid && femPart)
|
|
{
|
|
cvf::BoundingBox fembb = femPart->boundingBox();
|
|
cvf::BoundingBox eclbb = eclGrid->boundingBox();
|
|
return fembb.contains(eclbb.min()) && fembb.contains(eclbb.max());
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isRangeFiltersControlled()
|
|
{
|
|
if (!isRangeFilterControlPossible()) return false;
|
|
|
|
if (ownerViewLinker()->isActive() && this->m_isActive())
|
|
{
|
|
return m_syncRangeFilters;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isPropertyFilterControlPossible()
|
|
{
|
|
// The cases need to be the same
|
|
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(masterView());
|
|
|
|
if (geomView)
|
|
{
|
|
RimGeoMechView* depGeomView = managedGeoView();
|
|
if (depGeomView && geomView->geoMechCase() == depGeomView->geoMechCase())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(masterView());
|
|
|
|
if (eclipseView)
|
|
{
|
|
RimEclipseView* depEclipseView = managedEclipseView();
|
|
if (depEclipseView && eclipseView->eclipseCase() == depEclipseView->eclipseCase())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::isPropertyFilterOveridden()
|
|
{
|
|
if (!isPropertyFilterControlPossible()) return false;
|
|
|
|
if (ownerViewLinker()->isActive() && this->m_isActive())
|
|
{
|
|
return m_syncPropertyFilters;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRangeFilter)
|
|
{
|
|
if (!isRangeFiltersControlled())
|
|
{
|
|
managedView()->setOverrideRangeFilterCollection(NULL);
|
|
|
|
return;
|
|
}
|
|
|
|
// Todo: Optimize by only mapping the changed range filter, if needed.
|
|
|
|
{
|
|
// Copy the rangeFilterCollection
|
|
|
|
RimCellRangeFilterCollection* sourceFilterCollection = masterView()->rangeFilterCollection();
|
|
QString xmlRangeFilterCollCopy = sourceFilterCollection->writeObjectToXmlString();
|
|
PdmObjectHandle* objectCopy = PdmXmlObjectHandle::readUnknownObjectFromXmlString(xmlRangeFilterCollCopy, caf::PdmDefaultObjectFactory::instance());
|
|
RimCellRangeFilterCollection* overrideRangeFilterColl = dynamic_cast<RimCellRangeFilterCollection*>(objectCopy);
|
|
|
|
// Convert the range filter to fit in the managed view if needed
|
|
if (isRangeFilterMappingApliccable())
|
|
{
|
|
RimEclipseView* eclipseMasterView = dynamic_cast<RimEclipseView*>(masterView());
|
|
RimGeoMechView* geoMasterView = dynamic_cast<RimGeoMechView*>(masterView());
|
|
RimEclipseView* depEclView = managedEclipseView();
|
|
RimGeoMechView* depGeomView = managedGeoView();
|
|
|
|
if (eclipseMasterView && depGeomView)
|
|
{
|
|
if (eclipseMasterView->eclipseCase()->reservoirData())
|
|
{
|
|
RigMainGrid* srcEclGrid = eclipseMasterView->eclipseCase()->reservoirData()->mainGrid();
|
|
RigFemPart* dstFemPart = depGeomView->geoMechCase()->geoMechData()->femParts()->part(0);
|
|
for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx)
|
|
{
|
|
RimCellRangeFilter* srcRFilter = sourceFilterCollection->rangeFilters[rfIdx];
|
|
RimCellRangeFilter* dstRFilter = overrideRangeFilterColl->rangeFilters[rfIdx];
|
|
RigCaseToCaseRangeFilterMapper::convertRangeFilterEclToFem(srcRFilter, srcEclGrid,
|
|
dstRFilter, dstFemPart);
|
|
}
|
|
}
|
|
}
|
|
else if (geoMasterView && depEclView)
|
|
{
|
|
if (depEclView->eclipseCase()->reservoirData())
|
|
{
|
|
RigFemPart* srcFemPart = geoMasterView->geoMechCase()->geoMechData()->femParts()->part(0);
|
|
RigMainGrid* dstEclGrid = depEclView->eclipseCase()->reservoirData()->mainGrid();
|
|
for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx)
|
|
{
|
|
RimCellRangeFilter* srcRFilter = sourceFilterCollection->rangeFilters[rfIdx];
|
|
RimCellRangeFilter* dstRFilter = overrideRangeFilterColl->rangeFilters[rfIdx];
|
|
RigCaseToCaseRangeFilterMapper::convertRangeFilterFemToEcl(srcRFilter, srcFemPart,
|
|
dstRFilter, dstEclGrid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
managedView()->setOverrideRangeFilterCollection(overrideRangeFilterColl);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimViewController::applyRangeFilterCollectionByUserChoice()
|
|
{
|
|
if (!m_managedView->overrideRangeFilterCollection())
|
|
{
|
|
return;
|
|
}
|
|
|
|
bool restoreOriginal = askUserToRestoreOriginalRangeFilterCollection(m_managedView->name);
|
|
if (restoreOriginal)
|
|
{
|
|
m_managedView->setOverrideRangeFilterCollection(NULL);
|
|
}
|
|
else
|
|
{
|
|
m_managedView->replaceRangeFilterCollectionWithOverride();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimViewController::askUserToRestoreOriginalRangeFilterCollection(const QString& viewName)
|
|
{
|
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
|
|
|
QMessageBox msgBox(activeView->viewer()->layoutWidget());
|
|
msgBox.setIcon(QMessageBox::Question);
|
|
|
|
QString questionText;
|
|
questionText = QString("The linked view named \"%1\" is about to be unlinked. The range filters can either restore the original or keep the current range filters based on the master view.").arg(viewName);
|
|
|
|
msgBox.setText(questionText);
|
|
msgBox.setInformativeText("Do you want to restore the original range filters?");
|
|
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
|
|
int ret = msgBox.exec();
|
|
if (ret == QMessageBox::Yes)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|