Transformed static functions from ViewLinker to dynamic functions in RimView

This commit is contained in:
Magne Sjaastad 2015-09-25 11:01:41 +02:00
parent 034a78ae0c
commit 4424c110be
23 changed files with 126 additions and 131 deletions

View File

@ -1977,7 +1977,7 @@ void RiaApplication::slotUpdateScheduledDisplayModels()
for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i)
{
if (m_resViewsToUpdate[i]->controllingViewLink())
if (m_resViewsToUpdate[i]->viewController())
dependent3DViewsToUpdate.insert(m_resViewsToUpdate[i]);
else
independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]);

View File

@ -42,7 +42,7 @@ bool RicLinkViewFeature::isCommandEnabled()
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return false;
RimViewController* viewController = activeView->controllingViewLink();
RimViewController* viewController = activeView->viewController();
if(viewController)
{
@ -50,8 +50,7 @@ bool RicLinkViewFeature::isCommandEnabled()
}
else
{
RimViewLinker* vLinker = RimViewLinker::viewLinkerIfMainView(activeView);
if (!vLinker)
if (!activeView->isMasterView())
{
return true;
}

View File

@ -43,7 +43,7 @@ bool RicSetMasterViewFeature::isCommandEnabled()
if (!activeView) return false;
RimProject* proj = RiaApplication::instance()->project();
RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView);
RimViewLinker* viewLinker = activeView->assosiatedViewLinker();
if (viewLinker && viewLinker->masterView() == activeView)
{
return false;

View File

@ -42,7 +42,7 @@ bool RicShowLinkOptionsFeature::isCommandEnabled()
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return false;
RimViewController* viewController = activeView->controllingViewLink();
RimViewController* viewController = activeView->viewController();
if (viewController)
{
@ -60,7 +60,7 @@ void RicShowLinkOptionsFeature::onActionTriggered(bool isChecked)
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
RimViewController* viewController = activeView->controllingViewLink();
RimViewController* viewController = activeView->viewController();
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(viewController);
}

View File

@ -40,7 +40,7 @@ bool RicUnLinkViewFeature::isCommandEnabled()
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return false;
RimViewController* viewController = activeView->controllingViewLink();
RimViewController* viewController = activeView->viewController();
if (viewController)
{
@ -59,7 +59,7 @@ void RicUnLinkViewFeature::onActionTriggered(bool isChecked)
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
RimViewController* viewController = activeView->controllingViewLink();
RimViewController* viewController = activeView->viewController();
caf::SelectionManager::instance()->setSelectedItem(viewController);
caf::CmdFeature* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicDeleteItemFeature");

View File

@ -140,7 +140,7 @@ void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum
std::vector<RivGeoMechPartMgrCache::Key> RivGeoMechVizLogic::keysToVisiblePartMgrs(int timeStepIndex)
{
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs;
if (m_geomechView->controllingViewLink() && m_geomechView->controllingViewLink()->isVisibleCellsOveridden())
if (m_geomechView->viewController() && m_geomechView->viewController()->isVisibleCellsOveridden())
{
visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(OVERRIDDEN_CELL_VISIBILITY, -1));
}
@ -216,7 +216,7 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache:
{
RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(elmVisibility.p(),
caseData->femParts()->part(femPartIdx),
m_geomechView->controllingViewLink());
m_geomechView->viewController());
}
else if (pMgrKey.geometryType() == ALL_CELLS)

View File

@ -597,7 +597,7 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib
void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid)
{
RimViewController* masterViewLink = m_reservoirView->controllingViewLink();
RimViewController* masterViewLink = m_reservoirView->viewController();
CVF_ASSERT(masterViewLink);

View File

@ -320,8 +320,8 @@ void RimCellRangeFilterCollection::updateIconState()
{
bool activeIcon = true;
RimViewController* viewLink = RimViewLinker::viewLinkForView(baseView());
if (viewLink && viewLink->isRangeFilterOveridden())
RimViewController* viewController = baseView()->viewController();
if (viewController && viewController->isRangeFilterOveridden())
{
activeIcon = false;
}

View File

@ -229,8 +229,8 @@ RimLegendConfig* RimEclipseCellColors::legendConfig()
//--------------------------------------------------------------------------------------------------
void RimEclipseCellColors::updateIconState()
{
RimViewController* viewLink = RimViewLinker::viewLinkForView(m_reservoirView);
if (viewLink && viewLink->isResultColorControlled())
RimViewController* viewController = m_reservoirView->viewController();
if (viewController && viewController->isResultColorControlled())
{
updateUiIconFromState(false);
}

View File

@ -156,8 +156,8 @@ void RimEclipsePropertyFilterCollection::updateIconState()
RimEclipseView* view = NULL;
this->firstAnchestorOrThisOfType(view);
RimViewController* viewLink = RimViewLinker::viewLinkForView(view);
if (viewLink && viewLink->isPropertyFilterOveridden())
RimViewController* viewController = view->viewController();
if (viewController && viewController->isPropertyFilterOveridden())
{
activeIcon = false;
}

View File

@ -30,7 +30,6 @@
#include "RimEclipseView.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimView.h"
#include "RimProject.h"
#include "RimViewLinker.h"
#include "RimWellLogPlotCurve.h"
@ -156,10 +155,7 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
{
if (view)
{
RimProject* proj = NULL;
view->firstAnchestorOrThisOfType(proj);
RimViewLinker* viewLinker = proj->findViewLinkerFromView(view);
RimViewLinker* viewLinker = view->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateCellResult();

View File

@ -331,12 +331,12 @@ void RimEclipseView::createDisplayModel()
// For property filtered geometry : just set all the models as empty scenes
// updateCurrentTimeStep requests the actual parts
if (this->controllingViewLink() && this->controllingViewLink()->isVisibleCellsOveridden()
if (this->viewController() && this->viewController()->isVisibleCellsOveridden()
|| !this->propertyFilterCollection()->hasActiveFilters())
{
std::vector<RivCellSetEnum> geometryTypesToAdd;
if (this->controllingViewLink() && this->controllingViewLink()->isVisibleCellsOveridden())
if (this->viewController() && this->viewController()->isVisibleCellsOveridden())
{
geometryTypesToAdd.push_back(OVERRIDDEN_CELL_VISIBILITY);
@ -581,7 +581,7 @@ void RimEclipseView::updateCurrentTimeStep()
geometriesToRecolor.push_back(RANGE_FILTERED);
geometriesToRecolor.push_back(RANGE_FILTERED_WELL_CELLS);
}
else if (this->controllingViewLink() && this->controllingViewLink()->isVisibleCellsOveridden())
else if (this->viewController() && this->viewController()->isVisibleCellsOveridden())
{
geometriesToRecolor.push_back(OVERRIDDEN_CELL_VISIBILITY);
}
@ -846,10 +846,13 @@ void RimEclipseView::scheduleGeometryRegen(RivCellSetEnum geometryType)
{
m_reservoirGridPartManager->scheduleGeometryRegen(geometryType);
RimViewLinker* viewLinker = RimViewLinker::viewLinkerIfMainView(this);
if (viewLinker)
if (this->isMasterView())
{
viewLinker->scheduleGeometryRegenForDepViews(geometryType);
RimViewLinker* viewLinker = this->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->scheduleGeometryRegenForDepViews(geometryType);
}
}
m_currentReservoirCellVisibility = NULL;
@ -1290,7 +1293,7 @@ void RimEclipseView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
//--------------------------------------------------------------------------------------------------
void RimEclipseView::forceFaultVisibilityOn()
{
if (this->controllingViewLink() && this->controllingViewLink()->isVisibleCellsOveridden())
if (this->viewController() && this->viewController()->isVisibleCellsOveridden())
{
m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(OVERRIDDEN_CELL_VISIBILITY, true);
return;
@ -1316,7 +1319,7 @@ void RimEclipseView::forceFaultVisibilityOn()
std::vector<RivCellSetEnum> RimEclipseView::visibleFaultGeometryTypes() const
{
std::vector<RivCellSetEnum> faultParts;
if (this->controllingViewLink() && this->controllingViewLink()->isVisibleCellsOveridden())
if (this->viewController() && this->viewController()->isVisibleCellsOveridden())
{
faultParts.push_back(OVERRIDDEN_CELL_VISIBILITY);
if (this->faultCollection()->showFaultsOutsideFilters())

View File

@ -53,8 +53,8 @@ void RimGeoMechCellColors::updateIconState()
RimView* rimView = NULL;
this->firstAnchestorOrThisOfType(rimView);
RimViewController* viewLink = RimViewLinker::viewLinkForView(rimView);
if (viewLink && viewLink->isResultColorControlled())
RimViewController* viewController = rimView->viewController();
if (viewController && viewController->isResultColorControlled())
{
updateUiIconFromState(false);
}

View File

@ -158,8 +158,8 @@ void RimGeoMechPropertyFilterCollection::updateIconState()
RimGeoMechView* view = NULL;
this->firstAnchestorOrThisOfType(view);
RimViewController* viewLink = RimViewLinker::viewLinkForView(view);
if (viewLink && viewLink->isPropertyFilterOveridden())
RimViewController* viewController = view->viewController();
if (viewController && viewController->isPropertyFilterOveridden())
{
activeIcon = false;
}

View File

@ -30,12 +30,9 @@
#include "RimGeoMechCellColors.h"
#include "RimGeoMechPropertyFilter.h"
#include "RimGeoMechView.h"
#include "RimProject.h"
#include "RimViewLinker.h"
#include "RimWellLogPlotCurve.h"
#include "RiuMainWindow.h"
#include "cafPdmUiListEditor.h"
namespace caf {
@ -192,10 +189,7 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
{
if (view)
{
RimProject* proj = NULL;
view->firstAnchestorOrThisOfType(proj);
RimViewLinker* viewLinker = proj->findViewLinkerFromView(view);
RimViewLinker* viewLinker = view->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateCellResult();

View File

@ -512,10 +512,13 @@ void RimGeoMechView::scheduleGeometryRegen(RivCellSetEnum geometryType)
{
m_vizLogic->scheduleGeometryRegen(geometryType);
RimViewLinker* viewLinker = RimViewLinker::viewLinkerIfMainView(this);
if (viewLinker)
if (this->isMasterView())
{
viewLinker->scheduleGeometryRegenForDepViews(geometryType);
RimViewLinker* viewLinker = this->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->scheduleGeometryRegenForDepViews(geometryType);
}
}
m_currentReservoirCellVisibility = NULL;
}

View File

@ -980,14 +980,6 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS
uiTreeOrdering.setForgetRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimProject::findViewLinkerFromView(RimView* view)
{
return RimViewLinker::viewLinkerForMainOrControlledView(view);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -93,7 +93,6 @@ public:
void actionsBasedOnSelection(QMenu& contextMenu);
RimViewLinker* findViewLinkerFromView(RimView* view);
void recreateMainPlotCollection();
protected:

View File

@ -191,10 +191,13 @@ void RimView::updateViewerWidget()
void RimView::scheduleCreateDisplayModelAndRedraw()
{
RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this);
RimViewLinker* viewLinker = RimViewLinker::viewLinkerIfMainView(this);
if (viewLinker)
if (this->isMasterView())
{
viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews();
RimViewLinker* viewLinker = this->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews();
}
}
}
@ -450,7 +453,7 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
m_viewer->update();
RimViewLinker* viewLinker = RimViewLinker::viewLinkerForMainOrControlledView(this);
RimViewLinker* viewLinker = this->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateScaleZ(this, scaleZ);
@ -481,7 +484,7 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
{
m_viewer->update();
RimViewLinker* viewLinker = RimViewLinker::viewLinkerForMainOrControlledView(this);
RimViewLinker* viewLinker = this->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateTimeStep(this, m_currentTimeStep);
@ -586,9 +589,56 @@ void RimView::setScaleZAndUpdate(double scaleZ)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewController* RimView::controllingViewLink() const
RimViewController* RimView::viewController() const
{
return RimViewLinker::viewLinkForView(this);
RimViewController* viewController = NULL;
std::vector<caf::PdmObjectHandle*> reffingObjs;
this->objectsWithReferringPtrFields(reffingObjs);
for (size_t i = 0; i < reffingObjs.size(); ++i)
{
viewController = dynamic_cast<RimViewController*>(reffingObjs[i]);
if (viewController) break;
}
return viewController;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimView::viewLinkerIfMasterView() const
{
RimViewLinker* viewLinker = NULL;
std::vector<caf::PdmObjectHandle*> reffingObjs;
this->objectsWithReferringPtrFields(reffingObjs);
for (size_t i = 0; i < reffingObjs.size(); ++i)
{
viewLinker = dynamic_cast<RimViewLinker*>(reffingObjs[i]);
if (viewLinker) break;
}
return viewLinker;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimView::assosiatedViewLinker() const
{
RimViewLinker* viewLinker = this->viewLinkerIfMasterView();
if (!viewLinker)
{
RimViewController* viewController = this->viewController();
if (viewController)
{
viewLinker = viewController->ownerViewLinker();
}
}
return viewLinker;
}
//--------------------------------------------------------------------------------------------------
@ -605,3 +655,16 @@ cvf::ref<cvf::UByteArray> RimView::currentTotalCellVisibility()
return m_currentReservoirCellVisibility;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimView::isMasterView() const
{
RimViewLinker* viewLinker = this->assosiatedViewLinker();
if (viewLinker && this == viewLinker->masterView())
{
return true;
}
return false;
}

View File

@ -125,7 +125,10 @@ public:
void scheduleCreateDisplayModelAndRedraw();
void createDisplayModelAndRedraw();
RimViewController* controllingViewLink() const;
RimViewController* viewController() const;
bool isMasterView() const;
RimViewLinker* assosiatedViewLinker() const;
cvf::ref<cvf::UByteArray> currentTotalCellVisibility();
public:
@ -175,6 +178,9 @@ protected:
cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility;
private:
RimViewLinker* viewLinkerIfMasterView() const;
private:
bool m_previousGridModeMeshLinesWasFaults;
caf::PdmField<bool> m_disableLighting;

View File

@ -90,7 +90,7 @@ void RimViewLinker::updateTimeStep(RimView* sourceView, int timeStep)
if (masterView() != sourceView)
{
RimViewController* sourceViewLink = sourceView->controllingViewLink();
RimViewController* sourceViewLink = sourceView->viewController();
CVF_ASSERT(sourceViewLink);
if (!sourceViewLink->isActive() || !sourceViewLink->isTimeStepLinked())
@ -285,13 +285,13 @@ QString RimViewLinker::displayNameForView(RimView* view)
//--------------------------------------------------------------------------------------------------
void RimViewLinker::setMasterView(RimView* view)
{
RimViewController* previousViewLink = RimViewLinker::viewLinkForView(view);
RimViewController* previousViewController = view->viewController();
// Remove the view as dependent view
if (previousViewLink)
if (previousViewController)
{
this->viewLinks.removeChildObject(previousViewLink);
delete previousViewLink;
this->viewLinks.removeChildObject(previousViewController);
delete previousViewController;
}
this->removeOverrides();
@ -342,7 +342,7 @@ void RimViewLinker::updateScaleZ(RimView* sourceView, double scaleZ)
if (masterView() != sourceView)
{
RimViewController* sourceViewLink = viewLinkForView(sourceView);
RimViewController* sourceViewLink = sourceView->viewController();
CVF_ASSERT(sourceViewLink);
if (!sourceViewLink->isActive() || !sourceViewLink->isCameraLinked())
@ -456,61 +456,6 @@ void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewController* RimViewLinker::viewLinkForView(const RimView* view)
{
RimViewController* viewLink = NULL;
std::vector<caf::PdmObjectHandle*> reffingObjs;
view->objectsWithReferringPtrFields(reffingObjs);
for (size_t i = 0; i < reffingObjs.size(); ++i)
{
viewLink = dynamic_cast<RimViewController*>(reffingObjs[i]);
if (viewLink) break;
}
return viewLink;
}
//--------------------------------------------------------------------------------------------------
/// Return view linker if view is the main view (controlling) view
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimViewLinker::viewLinkerIfMainView(RimView* view)
{
RimViewLinker* viewLinker = NULL;
std::vector<caf::PdmObjectHandle*> reffingObjs;
view->objectsWithReferringPtrFields(reffingObjs);
for (size_t i = 0; i < reffingObjs.size(); ++i)
{
viewLinker = dynamic_cast<RimViewLinker*>(reffingObjs[i]);
if (viewLinker) break;
}
return viewLinker;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimViewLinker::viewLinkerForMainOrControlledView(RimView* view)
{
RimViewLinker* viewLinker = RimViewLinker::viewLinkerIfMainView(view);
if (!viewLinker)
{
RimViewController* viewLink = RimViewLinker::viewLinkForView(view);
if (viewLink)
{
viewLinker = viewLink->ownerViewLinker();
}
}
return viewLinker;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -520,7 +465,7 @@ void RimViewLinker::updateCamera(RimView* sourceView)
if (!isActive()) return;
RimViewController* viewLink = sourceView->controllingViewLink();
RimViewController* viewLink = sourceView->viewController();
if (viewLink)
{
if ((!viewLink->isActive() || !viewLink->isCameraLinked()))

View File

@ -78,11 +78,6 @@ public:
public:
static QString displayNameForView(RimView* view);
// Move to RimView and make nonstatic
static RimViewController* viewLinkForView(const RimView* view);
static RimViewLinker* viewLinkerIfMainView(RimView* view);
static RimViewLinker* viewLinkerForMainOrControlledView(RimView* view);
protected:
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; }
virtual void initAfterRead();

View File

@ -260,7 +260,7 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex)
if (m_reservoirView)
{
RimViewLinker* viewLinker = RimViewLinker::viewLinkerForMainOrControlledView(m_reservoirView);
RimViewLinker* viewLinker = m_reservoirView->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateTimeStep(m_reservoirView, frameIndex);
@ -487,7 +487,7 @@ void RiuViewer::navigationPolicyUpdate()
if (m_reservoirView)
{
RimViewLinker* viewLinker = RimViewLinker::viewLinkerForMainOrControlledView(m_reservoirView);
RimViewLinker* viewLinker = m_reservoirView->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateCamera(m_reservoirView);