2015-08-25 05:40:55 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-09-07 07:29:46 -05:00
|
|
|
#include "RimViewLinker.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
|
2015-09-01 10:14:22 -05:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2015-09-23 05:23:21 -05:00
|
|
|
#include "RigCaseData.h"
|
|
|
|
|
2015-09-01 10:14:22 -05:00
|
|
|
#include "RimCase.h"
|
2015-09-23 05:23:21 -05:00
|
|
|
|
2015-08-25 05:40:55 -05:00
|
|
|
#include "RimEclipseCellColors.h"
|
2015-09-08 03:17:35 -05:00
|
|
|
#include "RimEclipseInputCase.h"
|
|
|
|
#include "RimEclipseResultCase.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
#include "RimEclipseResultDefinition.h"
|
|
|
|
#include "RimEclipseView.h"
|
2015-09-08 03:17:35 -05:00
|
|
|
#include "RimGeoMechCase.h"
|
2015-09-01 10:14:22 -05:00
|
|
|
#include "RimGeoMechCellColors.h"
|
|
|
|
#include "RimGeoMechResultDefinition.h"
|
|
|
|
#include "RimGeoMechView.h"
|
2015-10-13 03:24:11 -05:00
|
|
|
#include "RimViewController.h"
|
2015-09-01 10:14:22 -05:00
|
|
|
#include "RimProject.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
#include "RimView.h"
|
2015-09-08 03:17:35 -05:00
|
|
|
#include "RimViewLinkerCollection.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
|
|
|
|
#include "RiuViewer.h"
|
|
|
|
|
|
|
|
#include "cvfCamera.h"
|
2015-09-23 05:23:21 -05:00
|
|
|
#include "cvfScene.h"
|
2015-09-04 04:42:45 -05:00
|
|
|
#include "cafFrameAnimationControl.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
#include "cvfMatrix4.h"
|
2015-09-01 10:14:22 -05:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimViewLinker, "ViewLinker");
|
2015-08-25 05:40:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
RimViewLinker::RimViewLinker(void)
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-15 02:47:59 -05:00
|
|
|
CAF_PDM_InitObject("Linked Views", "", "", "");
|
2015-09-07 07:54:54 -05:00
|
|
|
|
2015-09-02 06:44:56 -05:00
|
|
|
CAF_PDM_InitField(&m_name, "Name", QString("View Group Name"), "View Group Name", "", "", "");
|
|
|
|
m_name.uiCapability()->setUiHidden(true);
|
2015-09-01 10:14:22 -05:00
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_masterView, "MainView", "Main View", "", "", "");
|
2016-10-10 08:38:31 -05:00
|
|
|
m_masterView.uiCapability()->setUiTreeChildrenHidden(true);
|
2015-09-24 04:29:01 -05:00
|
|
|
m_masterView.uiCapability()->setUiHidden(true);
|
2015-08-25 05:40:55 -05:00
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_viewControllers, "ManagedViews", "Managed Views", "", "", "");
|
|
|
|
m_viewControllers.uiCapability()->setUiHidden(true);
|
2016-10-10 08:38:31 -05:00
|
|
|
m_viewControllers.uiCapability()->setUiTreeChildrenHidden(true);
|
2015-08-25 05:40:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
RimViewLinker::~RimViewLinker(void)
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-16 07:40:50 -05:00
|
|
|
removeOverrides();
|
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
m_viewControllers.deleteAllChildObjects();
|
2015-08-25 05:40:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
void RimViewLinker::updateTimeStep(RimView* sourceView, int timeStep)
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-23 04:01:46 -05:00
|
|
|
CVF_ASSERT(sourceView);
|
|
|
|
|
2015-09-07 07:54:54 -05:00
|
|
|
if (!isActive()) return;
|
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
if (masterView() != sourceView)
|
2015-09-01 10:14:22 -05:00
|
|
|
{
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewController* sourceViewLink = sourceView->viewController();
|
2015-09-23 04:01:46 -05:00
|
|
|
CVF_ASSERT(sourceViewLink);
|
|
|
|
|
2015-09-25 04:26:37 -05:00
|
|
|
if (!sourceViewLink->isTimeStepLinked())
|
2015-09-23 04:01:46 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-09-01 10:14:22 -05:00
|
|
|
}
|
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
if (m_masterView && m_masterView->viewer() && sourceView != m_masterView)
|
2015-09-01 10:14:22 -05:00
|
|
|
{
|
2015-09-24 04:29:01 -05:00
|
|
|
m_masterView->viewer()->setCurrentFrame(timeStep);
|
|
|
|
m_masterView->viewer()->animationControl()->setCurrentFrameOnly(timeStep);
|
2015-09-01 10:14:22 -05:00
|
|
|
}
|
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
RimViewController* viewLink = m_viewControllers[i];
|
2015-09-15 02:47:59 -05:00
|
|
|
|
2015-09-25 04:26:37 -05:00
|
|
|
if (!viewLink->isTimeStepLinked()) continue;
|
|
|
|
|
|
|
|
if ( viewLink->managedView()
|
|
|
|
&& viewLink->managedView() != sourceView
|
|
|
|
&& viewLink->managedView()->viewer())
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-25 04:26:37 -05:00
|
|
|
viewLink->managedView()->viewer()->setCurrentFrame(timeStep);
|
|
|
|
viewLink->managedView()->viewer()->animationControl()->setCurrentFrameOnly(timeStep);
|
2015-08-25 05:40:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
void RimViewLinker::updateCellResult()
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-24 04:29:01 -05:00
|
|
|
RimView* rimView = m_masterView;
|
2015-09-01 10:14:22 -05:00
|
|
|
RimEclipseView* masterEclipseView = dynamic_cast<RimEclipseView*>(rimView);
|
2015-08-27 07:57:04 -05:00
|
|
|
if (masterEclipseView && masterEclipseView->cellResult())
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-08-27 07:57:04 -05:00
|
|
|
RimEclipseResultDefinition* eclipseCellResultDefinition = masterEclipseView->cellResult();
|
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
RimViewController* viewLink = m_viewControllers[i];
|
2015-09-15 02:47:59 -05:00
|
|
|
|
|
|
|
if (viewLink->managedView())
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-23 06:48:25 -05:00
|
|
|
RimView* rimView = viewLink->managedView();
|
|
|
|
RimEclipseView* eclipeView = dynamic_cast<RimEclipseView*>(rimView);
|
|
|
|
if (eclipeView)
|
2015-08-27 07:57:04 -05:00
|
|
|
{
|
2015-09-25 02:39:42 -05:00
|
|
|
if (viewLink->isResultColorControlled())
|
2015-08-27 07:57:04 -05:00
|
|
|
{
|
|
|
|
eclipeView->cellResult()->setPorosityModel(eclipseCellResultDefinition->porosityModel());
|
|
|
|
eclipeView->cellResult()->setResultType(eclipseCellResultDefinition->resultType());
|
|
|
|
eclipeView->cellResult()->setResultVariable(eclipseCellResultDefinition->resultVariable());
|
2015-09-23 05:49:09 -05:00
|
|
|
eclipeView->scheduleCreateDisplayModelAndRedraw();
|
2015-08-27 07:57:04 -05:00
|
|
|
}
|
2015-09-23 06:48:25 -05:00
|
|
|
|
|
|
|
eclipeView->cellResult()->updateIconState();
|
2015-08-27 07:57:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-01 10:14:22 -05:00
|
|
|
RimGeoMechView* masterGeoView = dynamic_cast<RimGeoMechView*>(rimView);
|
2015-08-27 07:57:04 -05:00
|
|
|
if (masterGeoView && masterGeoView->cellResult())
|
|
|
|
{
|
|
|
|
RimGeoMechResultDefinition* geoMechResultDefinition = masterGeoView->cellResult();
|
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-08-27 07:57:04 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
RimViewController* viewLink = m_viewControllers[i];
|
2015-09-15 02:47:59 -05:00
|
|
|
|
|
|
|
if (viewLink->managedView())
|
2015-08-27 07:57:04 -05:00
|
|
|
{
|
2015-09-23 06:48:25 -05:00
|
|
|
RimView* rimView = viewLink->managedView();
|
|
|
|
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(rimView);
|
|
|
|
if (geoView)
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-25 02:39:42 -05:00
|
|
|
if (viewLink->isResultColorControlled())
|
2015-08-27 07:57:04 -05:00
|
|
|
{
|
|
|
|
geoView->cellResult()->setResultAddress(geoMechResultDefinition->resultAddress());
|
|
|
|
geoView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
}
|
2015-09-23 06:48:25 -05:00
|
|
|
|
|
|
|
geoView->cellResult()->updateIconState();
|
2015-08-25 05:40:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
|
2015-10-19 05:10:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::updateRangeFilters(RimCellRangeFilter* changedRangeFilter)
|
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-10-19 05:10:18 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
RimViewController* viewLink = m_viewControllers[i];
|
2015-10-19 05:10:18 -05:00
|
|
|
viewLink->updateRangeFilterOverrides(changedRangeFilter);
|
|
|
|
}
|
|
|
|
}
|
2015-08-27 08:45:22 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-24 07:29:13 -05:00
|
|
|
void RimViewLinker::updateOverrides()
|
2015-08-27 08:45:22 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-08-28 01:01:40 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
RimViewController* viewLink = m_viewControllers[i];
|
2015-09-25 04:26:37 -05:00
|
|
|
if (viewLink->isActive())
|
2015-09-15 02:47:59 -05:00
|
|
|
{
|
2015-09-24 10:40:45 -05:00
|
|
|
viewLink->updateOverrides();
|
2015-09-15 02:47:59 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
viewLink->removeOverrides();
|
|
|
|
}
|
2015-08-28 01:01:40 -05:00
|
|
|
}
|
|
|
|
}
|
2015-08-28 14:05:56 -05:00
|
|
|
|
2015-09-24 07:29:13 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::removeOverrides()
|
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-09-24 07:29:13 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
if (m_viewControllers[i]->managedView())
|
2015-09-24 07:29:13 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
m_viewControllers[i]->removeOverrides();
|
2015-09-24 07:29:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-28 14:05:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
void RimViewLinker::allViewsForCameraSync(RimView* source, std::vector<RimView*>& views)
|
2015-08-28 14:05:56 -05:00
|
|
|
{
|
2015-09-07 07:54:54 -05:00
|
|
|
if (!isActive()) return;
|
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
if (source != m_masterView())
|
2015-09-03 06:06:00 -05:00
|
|
|
{
|
2015-09-24 04:29:01 -05:00
|
|
|
views.push_back(m_masterView());
|
2015-09-03 06:06:00 -05:00
|
|
|
}
|
2015-09-01 10:14:22 -05:00
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-08-28 14:05:56 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
if (m_viewControllers[i]->managedView() && source != m_viewControllers[i]->managedView())
|
2015-08-31 05:31:38 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
if (m_viewControllers[i]->isCameraLinked())
|
2015-09-24 10:40:45 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
views.push_back(m_viewControllers[i]->managedView());
|
2015-09-24 10:40:45 -05:00
|
|
|
}
|
2015-08-31 05:31:38 -05:00
|
|
|
}
|
2015-08-28 14:05:56 -05:00
|
|
|
}
|
|
|
|
}
|
2015-08-30 06:30:46 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-24 07:29:13 -05:00
|
|
|
void RimViewLinker::updateDependentViews()
|
2015-08-30 06:30:46 -05:00
|
|
|
{
|
2015-09-24 07:29:13 -05:00
|
|
|
updateOverrides();
|
2015-08-30 06:30:46 -05:00
|
|
|
updateCellResult();
|
2015-09-24 04:29:01 -05:00
|
|
|
updateScaleZ(m_masterView, m_masterView->scaleZ());
|
|
|
|
updateCamera(m_masterView);
|
2015-10-20 04:13:31 -05:00
|
|
|
updateTimeStep(m_masterView, m_masterView->currentTimeStep());
|
2015-08-30 06:30:46 -05:00
|
|
|
}
|
2015-09-01 10:14:22 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
QString RimViewLinker::displayNameForView(RimView* view)
|
2015-09-01 10:14:22 -05:00
|
|
|
{
|
2015-09-02 10:18:02 -05:00
|
|
|
QString displayName = "None";
|
2015-09-01 10:14:22 -05:00
|
|
|
|
2015-09-02 10:18:02 -05:00
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
RimCase* rimCase = NULL;
|
2016-09-21 06:59:41 -05:00
|
|
|
view->firstAncestorOrThisOfType(rimCase);
|
2015-09-02 10:18:02 -05:00
|
|
|
|
2015-09-11 07:16:13 -05:00
|
|
|
displayName = rimCase->caseUserDescription() + ": " + view->name;
|
2015-09-02 10:18:02 -05:00
|
|
|
}
|
2015-09-01 10:14:22 -05:00
|
|
|
|
|
|
|
return displayName;
|
|
|
|
}
|
|
|
|
|
2015-09-02 01:13:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-24 04:29:01 -05:00
|
|
|
void RimViewLinker::setMasterView(RimView* view)
|
2015-09-02 01:13:17 -05:00
|
|
|
{
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewController* previousViewController = view->viewController();
|
2015-09-24 07:29:13 -05:00
|
|
|
|
|
|
|
// Remove the view as dependent view
|
2015-09-25 04:01:41 -05:00
|
|
|
if (previousViewController)
|
2015-09-24 07:29:13 -05:00
|
|
|
{
|
2015-09-25 04:01:41 -05:00
|
|
|
delete previousViewController;
|
2015-10-20 04:13:31 -05:00
|
|
|
this->m_viewControllers.removeChildObject(NULL);
|
2015-09-24 07:29:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
this->removeOverrides();
|
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
m_masterView = view;
|
2015-09-02 06:44:56 -05:00
|
|
|
|
2015-09-24 07:29:13 -05:00
|
|
|
updateUiNameAndIcon();
|
2015-09-02 01:13:17 -05:00
|
|
|
}
|
2015-09-02 06:44:56 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-24 04:29:01 -05:00
|
|
|
RimView* RimViewLinker::masterView()
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
2015-09-24 04:29:01 -05:00
|
|
|
return m_masterView;
|
2015-09-02 06:44:56 -05:00
|
|
|
}
|
|
|
|
|
2015-09-02 07:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
void RimViewLinker::allViews(std::vector<RimView*>& views)
|
2015-09-02 07:22:36 -05:00
|
|
|
{
|
2015-09-24 04:29:01 -05:00
|
|
|
views.push_back(m_masterView());
|
2015-09-02 07:22:36 -05:00
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-09-02 07:22:36 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
if (m_viewControllers[i]->managedView())
|
2015-09-02 07:22:36 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
views.push_back(m_viewControllers[i]->managedView());
|
2015-09-02 07:22:36 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-02 10:18:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-07 07:29:46 -05:00
|
|
|
void RimViewLinker::initAfterRead()
|
2015-09-02 10:18:02 -05:00
|
|
|
{
|
2015-09-24 07:29:13 -05:00
|
|
|
updateUiNameAndIcon();
|
2015-09-02 10:18:02 -05:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:06:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-23 04:01:46 -05:00
|
|
|
void RimViewLinker::updateScaleZ(RimView* sourceView, double scaleZ)
|
2015-09-03 06:06:00 -05:00
|
|
|
{
|
2015-09-23 04:01:46 -05:00
|
|
|
if (!isActive()) return;
|
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
if (masterView() != sourceView)
|
2015-09-23 04:01:46 -05:00
|
|
|
{
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewController* sourceViewLink = sourceView->viewController();
|
2015-09-23 04:01:46 -05:00
|
|
|
CVF_ASSERT(sourceViewLink);
|
|
|
|
|
2015-09-25 04:26:37 -05:00
|
|
|
if (!sourceViewLink->isCameraLinked())
|
2015-09-23 04:01:46 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 06:06:00 -05:00
|
|
|
std::vector<RimView*> views;
|
2015-09-23 04:01:46 -05:00
|
|
|
allViewsForCameraSync(sourceView, views);
|
2015-09-03 06:06:00 -05:00
|
|
|
|
|
|
|
// Make sure scale factors are identical
|
|
|
|
for (size_t i = 0; i < views.size(); i++)
|
|
|
|
{
|
|
|
|
views[i]->setScaleZAndUpdate(scaleZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-07 07:54:54 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimViewLinker::isActive()
|
|
|
|
{
|
2015-09-08 03:17:35 -05:00
|
|
|
RimViewLinkerCollection* viewLinkerCollection = NULL;
|
2016-09-21 06:59:41 -05:00
|
|
|
this->firstAncestorOrThisOfType(viewLinkerCollection);
|
2015-09-08 03:17:35 -05:00
|
|
|
|
2015-10-21 05:45:35 -05:00
|
|
|
if (!viewLinkerCollection)
|
|
|
|
{
|
|
|
|
// This will happen when the all linked views are about to be deleted
|
|
|
|
// The viewLinker is taken out of the viewLinkerCollection, and no parent can be found
|
|
|
|
// See RicDeleteAllLinkedViewsFeature
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-15 02:47:59 -05:00
|
|
|
return viewLinkerCollection->isActive();
|
2015-09-08 03:17:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Hande icon update locally as PdmUiItem::updateUiIconFromState works only for static icons
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-15 02:47:59 -05:00
|
|
|
void RimViewLinker::applyIconEnabledState(caf::PdmObject* obj, const QIcon& icon, bool disable)
|
2015-09-08 03:17:35 -05:00
|
|
|
{
|
|
|
|
QPixmap icPixmap;
|
2015-09-15 02:47:59 -05:00
|
|
|
icPixmap = icon.pixmap(16, 16, QIcon::Normal);
|
2015-09-08 03:17:35 -05:00
|
|
|
|
2015-09-15 02:47:59 -05:00
|
|
|
if (disable)
|
2015-09-08 03:17:35 -05:00
|
|
|
{
|
|
|
|
QIcon temp(icPixmap);
|
|
|
|
icPixmap = temp.pixmap(16, 16, QIcon::Disabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QIcon newIcon(icPixmap);
|
2015-09-15 02:47:59 -05:00
|
|
|
obj->setUiIcon(newIcon);
|
2015-09-08 03:17:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-15 02:47:59 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-24 07:29:13 -05:00
|
|
|
void RimViewLinker::updateUiNameAndIcon()
|
2015-09-15 02:47:59 -05:00
|
|
|
{
|
2015-09-24 04:29:01 -05:00
|
|
|
RimViewLinker::findNameAndIconFromView(&m_name.v(), &m_originalIcon, m_masterView);
|
2015-09-24 07:29:13 -05:00
|
|
|
RimViewLinker::applyIconEnabledState(this, m_originalIcon, false);
|
2015-09-08 03:17:35 -05:00
|
|
|
}
|
|
|
|
|
2015-09-13 01:54:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::scheduleGeometryRegenForDepViews(RivCellSetEnum geometryType)
|
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-09-13 01:54:32 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
m_viewControllers[i]->scheduleGeometryRegenForDepViews(geometryType);
|
2015-09-13 01:54:32 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::scheduleCreateDisplayModelAndRedrawForDependentViews()
|
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t i = 0; i < m_viewControllers.size(); i++)
|
2015-09-13 01:54:32 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
m_viewControllers[i]->scheduleCreateDisplayModelAndRedrawForDependentView();
|
2015-09-13 01:54:32 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-13 14:26:09 -05:00
|
|
|
|
2015-09-15 02:47:59 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView* view)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(name && icon);
|
|
|
|
|
|
|
|
*name = displayNameForView(view);
|
|
|
|
|
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
RimCase* rimCase = NULL;
|
2016-09-21 06:59:41 -05:00
|
|
|
view->firstAncestorOrThisOfType(rimCase);
|
2015-09-15 02:47:59 -05:00
|
|
|
|
|
|
|
if (dynamic_cast<RimGeoMechCase*>(rimCase))
|
|
|
|
{
|
|
|
|
*icon = QIcon(":/GeoMechCase48x48.png");
|
|
|
|
}
|
|
|
|
else if (dynamic_cast<RimEclipseResultCase*>(rimCase))
|
|
|
|
{
|
|
|
|
*icon = QIcon(":/Case48x48.png");
|
|
|
|
}
|
|
|
|
else if (dynamic_cast<RimEclipseInputCase*>(rimCase))
|
|
|
|
{
|
|
|
|
*icon = QIcon(":/EclipseInput48x48.png");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*icon = QIcon();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-23 05:23:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::updateCamera(RimView* sourceView)
|
|
|
|
{
|
|
|
|
if (!sourceView->viewer()) return;
|
|
|
|
|
|
|
|
if (!isActive()) return;
|
|
|
|
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewController* viewLink = sourceView->viewController();
|
2015-09-23 05:23:21 -05:00
|
|
|
if (viewLink)
|
|
|
|
{
|
2015-09-25 04:26:37 -05:00
|
|
|
if (!viewLink->isCameraLinked())
|
2015-09-23 05:23:21 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<RimView*> viewsToUpdate;
|
|
|
|
allViewsForCameraSync(sourceView, viewsToUpdate);
|
|
|
|
|
|
|
|
cvf::Vec3d sourceCamUp;
|
|
|
|
cvf::Vec3d sourceCamEye;
|
|
|
|
cvf::Vec3d sourceCamViewRefPoint;
|
|
|
|
sourceView->viewer()->mainCamera()->toLookAt(&sourceCamEye, &sourceCamViewRefPoint, &sourceCamUp);
|
|
|
|
|
|
|
|
cvf::Vec3d sourceCamGlobalEye = sourceCamEye;
|
|
|
|
cvf::Vec3d sourceCamGlobalViewRefPoint = sourceCamViewRefPoint;
|
|
|
|
|
|
|
|
// Source bounding box in global coordinates including scaleZ
|
|
|
|
cvf::BoundingBox sourceSceneBB = sourceView->viewer()->currentScene()->boundingBox();
|
|
|
|
|
|
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(sourceView);
|
|
|
|
if (eclipseView
|
|
|
|
&& eclipseView->eclipseCase()
|
|
|
|
&& eclipseView->eclipseCase()->reservoirData()
|
|
|
|
&& eclipseView->eclipseCase()->reservoirData()->mainGrid())
|
|
|
|
{
|
|
|
|
cvf::Vec3d offset = eclipseView->eclipseCase()->reservoirData()->mainGrid()->displayModelOffset();
|
|
|
|
offset.z() *= eclipseView->scaleZ();
|
|
|
|
|
|
|
|
sourceCamGlobalEye += offset;
|
|
|
|
sourceCamGlobalViewRefPoint += offset;
|
|
|
|
|
|
|
|
cvf::Mat4d trans;
|
|
|
|
trans.setTranslation(offset);
|
|
|
|
sourceSceneBB.transform(trans);
|
|
|
|
}
|
|
|
|
|
2016-11-24 05:19:05 -06:00
|
|
|
for (RimView* destinationView : viewsToUpdate)
|
2015-09-23 05:23:21 -05:00
|
|
|
{
|
2016-11-24 05:19:05 -06:00
|
|
|
if (!destinationView) continue;
|
|
|
|
|
|
|
|
destinationView->isPerspectiveView = sourceView->isPerspectiveView;
|
|
|
|
|
|
|
|
RiuViewer* destinationViewer = destinationView->viewer();
|
|
|
|
if (destinationViewer)
|
2015-09-23 05:23:21 -05:00
|
|
|
{
|
2016-11-24 05:19:05 -06:00
|
|
|
destinationViewer->enableParallelProjection(!sourceView->isPerspectiveView);
|
2015-09-23 05:23:21 -05:00
|
|
|
|
|
|
|
// Destination bounding box in global coordinates including scaleZ
|
|
|
|
cvf::BoundingBox destSceneBB = destinationViewer->currentScene()->boundingBox();
|
|
|
|
|
2016-11-24 05:19:05 -06:00
|
|
|
RimEclipseView* destEclipseView = dynamic_cast<RimEclipseView*>(destinationView);
|
2015-09-23 05:23:21 -05:00
|
|
|
if (destEclipseView
|
|
|
|
&& destEclipseView->eclipseCase()
|
|
|
|
&& destEclipseView->eclipseCase()->reservoirData()
|
|
|
|
&& destEclipseView->eclipseCase()->reservoirData()->mainGrid())
|
|
|
|
{
|
|
|
|
cvf::Vec3d destOffset = destEclipseView->eclipseCase()->reservoirData()->mainGrid()->displayModelOffset();
|
|
|
|
destOffset.z() *= destEclipseView->scaleZ();
|
|
|
|
|
|
|
|
cvf::Vec3d destinationCamEye = sourceCamGlobalEye - destOffset;
|
|
|
|
cvf::Vec3d destinationCamViewRefPoint = sourceCamGlobalViewRefPoint - destOffset;
|
|
|
|
|
|
|
|
cvf::Mat4d trans;
|
|
|
|
trans.setTranslation(destOffset);
|
|
|
|
destSceneBB.transform(trans);
|
|
|
|
|
|
|
|
if (isBoundingBoxesOverlappingOrClose(sourceSceneBB, destSceneBB))
|
|
|
|
{
|
|
|
|
destinationViewer->mainCamera()->setFromLookAt(destinationCamEye, destinationCamViewRefPoint, sourceCamUp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Fallback using values from source camera
|
|
|
|
destinationViewer->mainCamera()->setFromLookAt(sourceCamEye, sourceCamViewRefPoint, sourceCamUp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isBoundingBoxesOverlappingOrClose(sourceSceneBB, destSceneBB))
|
|
|
|
{
|
|
|
|
destinationViewer->mainCamera()->setFromLookAt(sourceCamGlobalEye, sourceCamGlobalViewRefPoint, sourceCamUp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Fallback using values from source camera
|
|
|
|
destinationViewer->mainCamera()->setFromLookAt(sourceCamEye, sourceCamViewRefPoint, sourceCamUp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-24 07:01:47 -06:00
|
|
|
destinationViewer->updateParallelProjectionSettings(sourceView->viewer());
|
|
|
|
|
2015-09-23 05:23:21 -05:00
|
|
|
destinationViewer->update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimViewLinker::isBoundingBoxesOverlappingOrClose(const cvf::BoundingBox& sourceBB, const cvf::BoundingBox& destBB)
|
|
|
|
{
|
|
|
|
if (!sourceBB.isValid() || !destBB.isValid()) return false;
|
|
|
|
|
|
|
|
if (sourceBB.intersects(destBB)) return true;
|
|
|
|
|
|
|
|
double largestExtent = sourceBB.extent().length();
|
|
|
|
if (destBB.extent().length() > largestExtent)
|
|
|
|
{
|
|
|
|
largestExtent = destBB.extent().length();
|
|
|
|
}
|
|
|
|
|
|
|
|
double centerDist = (sourceBB.center() - destBB.center()).length();
|
|
|
|
if (centerDist < largestExtent * 5)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-24 07:29:13 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::addDependentView(RimView* view)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(view && view != m_masterView);
|
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
RimViewController* viewContr = new RimViewController;
|
|
|
|
this->m_viewControllers.push_back(viewContr);
|
2015-09-24 07:29:13 -05:00
|
|
|
|
2015-10-20 04:13:31 -05:00
|
|
|
viewContr->setManagedView(view);
|
2015-09-24 07:29:13 -05:00
|
|
|
|
2015-09-24 10:40:45 -05:00
|
|
|
|
2015-09-24 07:29:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::addViewControllers(caf::PdmUiTreeOrdering& uiTreeOrdering)
|
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
for (size_t j = 0; j < m_viewControllers.size(); j++)
|
2015-09-24 07:29:13 -05:00
|
|
|
{
|
2015-10-20 04:13:31 -05:00
|
|
|
uiTreeOrdering.add(m_viewControllers()[j]);
|
2015-09-24 07:29:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-21 05:45:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::applyRangeFilterCollectionByUserChoice()
|
|
|
|
{
|
|
|
|
for (size_t j = 0; j < m_viewControllers.size(); j++)
|
|
|
|
{
|
|
|
|
m_viewControllers[j]->applyRangeFilterCollectionByUserChoice();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinker::removeViewController(RimViewController* viewController)
|
|
|
|
{
|
|
|
|
m_viewControllers.removeChildObject(viewController);
|
|
|
|
}
|
|
|
|
|