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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimManagedViewConfig.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
|
|
|
#include "RimCase.h"
|
2015-08-27 06:44:27 -05:00
|
|
|
#include "RimCellRangeFilterCollection.h"
|
2015-08-27 08:45:22 -05:00
|
|
|
#include "RimEclipsePropertyFilterCollection.h"
|
|
|
|
#include "RimEclipseView.h"
|
2015-08-27 07:57:04 -05:00
|
|
|
#include "RimManagedViewCollection.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimView.h"
|
|
|
|
|
2015-08-27 06:44:27 -05:00
|
|
|
#include "RiuViewer.h"
|
|
|
|
|
2015-08-25 05:40:55 -05:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2015-08-27 15:54:37 -05:00
|
|
|
#include "RimGeoMechView.h"
|
|
|
|
#include "RimGeoMechPropertyFilterCollection.h"
|
2015-08-25 05:40:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimManagedViewConfig, "RimManagedViewConfig");
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimManagedViewConfig::RimManagedViewConfig(void)
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("View Config", ":/chain.png", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&managedView, "ManagedView", "Managed View", "", "", "");
|
|
|
|
managedView.uiCapability()->setUiChildrenHidden(true);
|
|
|
|
|
2015-08-27 08:45:22 -05:00
|
|
|
CAF_PDM_InitField(&syncCamera, "SyncCamera", true, "Sync Camera", "", "", "");
|
|
|
|
CAF_PDM_InitField(&syncCellResult, "SyncCellResult", true, "Sync Cell Result", "", "", "");
|
|
|
|
CAF_PDM_InitField(&syncTimeStep, "SyncTimeStep", true, "Sync Time Step", "", "", "");
|
|
|
|
CAF_PDM_InitField(&syncRangeFilters, "SyncRangeFilters", true, "Sync Range Filters", "", "", "");
|
|
|
|
CAF_PDM_InitField(&syncPropertyFilters, "SyncPropertyFilters", true,"Sync Property Filters", "", "", "");
|
2015-08-25 05:40:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimManagedViewConfig::~RimManagedViewConfig(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimManagedViewConfig::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> optionList;
|
|
|
|
|
|
|
|
if (fieldNeedingOptions == &managedView)
|
|
|
|
{
|
|
|
|
std::vector<RimView*> views;
|
|
|
|
allVisibleViews(views);
|
|
|
|
|
|
|
|
for (size_t i = 0; i< views.size(); i++)
|
|
|
|
{
|
|
|
|
optionList.push_back(caf::PdmOptionItemInfo(views[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(views[i]))));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optionList.size() > 0)
|
|
|
|
{
|
|
|
|
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return optionList;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::allVisibleViews(std::vector<RimView*>& views)
|
|
|
|
{
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
|
|
|
|
RimView* masterView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(masterView);
|
|
|
|
|
|
|
|
if (proj)
|
|
|
|
{
|
|
|
|
std::vector<RimCase*> cases;
|
|
|
|
proj->allCases(cases);
|
|
|
|
for (size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++)
|
|
|
|
{
|
|
|
|
RimCase* rimCase = cases[caseIdx];
|
|
|
|
|
|
|
|
std::vector<RimView*> caseViews = rimCase->views();
|
|
|
|
for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++)
|
|
|
|
{
|
|
|
|
if (caseViews[viewIdx]->viewer() && caseViews[viewIdx] != masterView)
|
|
|
|
{
|
|
|
|
views.push_back(caseViews[viewIdx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
|
|
|
{
|
|
|
|
uiTreeOrdering.setForgetRemainingFields(true);
|
|
|
|
}
|
|
|
|
|
2015-08-27 06:44:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (changedField == &syncCamera || changedField == &syncTimeStep)
|
|
|
|
{
|
|
|
|
RimView* masterView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(masterView);
|
|
|
|
|
|
|
|
masterView->viewer()->update();
|
|
|
|
}
|
2015-08-27 07:57:04 -05:00
|
|
|
else if (changedField == &syncCellResult)
|
|
|
|
{
|
|
|
|
// When cell result is activated, update cell result in managed views
|
|
|
|
// Original result Will not be restored when cell result is disabled
|
|
|
|
|
|
|
|
if (syncCellResult())
|
|
|
|
{
|
|
|
|
RimView* masterView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(masterView);
|
|
|
|
|
|
|
|
masterView->managedViewCollection()->updateCellResult();
|
|
|
|
}
|
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
else if (changedField == &syncRangeFilters)
|
|
|
|
{
|
|
|
|
configureOverrides();
|
|
|
|
|
|
|
|
if (managedView)
|
|
|
|
{
|
2015-08-27 15:54:37 -05:00
|
|
|
managedView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews();
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
|
|
|
}
|
2015-08-27 08:45:22 -05:00
|
|
|
else if (changedField == &syncPropertyFilters)
|
|
|
|
{
|
|
|
|
configureOverrides();
|
|
|
|
|
|
|
|
RimEclipseView* eclipseView = managedEclipseView();
|
|
|
|
if (eclipseView)
|
|
|
|
{
|
2015-08-27 15:54:37 -05:00
|
|
|
eclipseView->propertyFilterCollection()->updateDisplayModelNotifyManagedViews();
|
|
|
|
}
|
|
|
|
|
|
|
|
RimGeoMechView* geoView = managedGeoView();
|
|
|
|
if (geoView)
|
|
|
|
{
|
|
|
|
geoView->scheduleGeometryRegen(PROPERTY_FILTERED);
|
|
|
|
geoView->scheduleCreateDisplayModelAndRedraw();
|
2015-08-27 08:45:22 -05:00
|
|
|
}
|
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
else if (changedField == &managedView)
|
|
|
|
{
|
|
|
|
configureOverrides();
|
|
|
|
|
|
|
|
if (managedView)
|
|
|
|
{
|
2015-08-27 15:54:37 -05:00
|
|
|
managedView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews();
|
2015-08-27 07:57:04 -05:00
|
|
|
|
|
|
|
if (syncCellResult())
|
|
|
|
{
|
|
|
|
RimView* masterView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(masterView);
|
|
|
|
|
|
|
|
masterView->managedViewCollection()->updateCellResult();
|
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
PdmObjectHandle* prevValue = oldValue.value<caf::PdmPointer<PdmObjectHandle> >().rawPtr();
|
|
|
|
if (prevValue)
|
|
|
|
{
|
|
|
|
RimView* rimView = dynamic_cast<RimView*>(prevValue);
|
|
|
|
rimView->setOverrideRangeFilterCollection(NULL);
|
2015-08-27 15:54:37 -05:00
|
|
|
rimView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews();
|
2015-08-27 08:45:22 -05:00
|
|
|
|
|
|
|
RimEclipseView* rimEclipseView = dynamic_cast<RimEclipseView*>(rimView);
|
|
|
|
if (rimEclipseView)
|
|
|
|
{
|
|
|
|
rimEclipseView->setOverridePropertyFilterCollection(NULL);
|
|
|
|
}
|
2015-08-27 15:54:37 -05:00
|
|
|
|
|
|
|
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(rimView);
|
|
|
|
if (geoView)
|
|
|
|
{
|
|
|
|
geoView->setOverridePropertyFilterCollection(NULL);
|
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::configureOverrides()
|
|
|
|
{
|
|
|
|
RimView* masterView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(masterView);
|
|
|
|
|
|
|
|
if (managedView)
|
|
|
|
{
|
|
|
|
if (syncRangeFilters)
|
|
|
|
{
|
|
|
|
managedView->setOverrideRangeFilterCollection(masterView->rangeFilterCollection());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
managedView->setOverrideRangeFilterCollection(NULL);
|
|
|
|
}
|
2015-08-27 08:45:22 -05:00
|
|
|
|
|
|
|
RimEclipseView* masterEclipseView = dynamic_cast<RimEclipseView*>(masterView);
|
|
|
|
if (masterEclipseView)
|
|
|
|
{
|
|
|
|
RimEclipseView* eclipseView = managedEclipseView();
|
|
|
|
if (eclipseView)
|
|
|
|
{
|
|
|
|
if (syncPropertyFilters)
|
|
|
|
{
|
|
|
|
eclipseView->setOverridePropertyFilterCollection(masterEclipseView->propertyFilterCollection());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eclipseView->setOverridePropertyFilterCollection(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-27 15:54:37 -05:00
|
|
|
|
|
|
|
RimGeoMechView* masterGeoView = dynamic_cast<RimGeoMechView*>(masterView);
|
|
|
|
if (masterGeoView)
|
|
|
|
{
|
|
|
|
RimGeoMechView* geoView = managedGeoView();
|
|
|
|
if (geoView)
|
|
|
|
{
|
|
|
|
if (syncPropertyFilters)
|
|
|
|
{
|
|
|
|
geoView->setOverridePropertyFilterCollection(masterGeoView->propertyFilterCollection());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geoView->setOverridePropertyFilterCollection(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::initAfterRead()
|
|
|
|
{
|
|
|
|
configureOverrides();
|
|
|
|
}
|
|
|
|
|
2015-08-27 08:45:22 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimEclipseView* RimManagedViewConfig::managedEclipseView()
|
|
|
|
{
|
|
|
|
RimView* rimView = managedView;
|
|
|
|
|
|
|
|
return dynamic_cast<RimEclipseView*>(rimView);
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:54:37 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechView* RimManagedViewConfig::managedGeoView()
|
|
|
|
{
|
|
|
|
RimView* rimView = managedView;
|
|
|
|
|
|
|
|
return dynamic_cast<RimGeoMechView*>(rimView);
|
|
|
|
}
|
|
|
|
|