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-28 01:01:40 -05:00
|
|
|
#include "RimGeoMechPropertyFilterCollection.h"
|
|
|
|
#include "RimGeoMechView.h"
|
2015-09-01 10:14:22 -05:00
|
|
|
#include "RimLinkedViews.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"
|
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimManagedViewConfig, "RimManagedViewConfig");
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimManagedViewConfig::RimManagedViewConfig(void)
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("View Config", ":/chain.png", "", "");
|
|
|
|
|
2015-08-28 04:48:16 -05:00
|
|
|
QString defaultName = "View Config : Empty view";
|
|
|
|
CAF_PDM_InitField(&name, "Name", defaultName, "Managed View Name", "", "", "");
|
2015-09-01 10:14:22 -05:00
|
|
|
name.uiCapability()->setUiHidden(true);
|
2015-08-28 04:48:16 -05:00
|
|
|
|
2015-08-25 05:40:55 -05:00
|
|
|
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)
|
|
|
|
{
|
2015-08-30 06:30:46 -05:00
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
2015-08-25 05:40:55 -05:00
|
|
|
std::vector<RimView*> views;
|
2015-08-30 06:30:46 -05:00
|
|
|
proj->allVisibleViews(views);
|
|
|
|
|
|
|
|
RimView* masterView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(masterView);
|
2015-08-25 05:40:55 -05:00
|
|
|
|
|
|
|
for (size_t i = 0; i< views.size(); i++)
|
|
|
|
{
|
2015-08-30 06:30:46 -05:00
|
|
|
if (views[i] != masterView)
|
|
|
|
{
|
|
|
|
optionList.push_back(caf::PdmOptionItemInfo(displayNameForView(views[i]), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(views[i]))));
|
|
|
|
}
|
2015-08-25 05:40:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (optionList.size() > 0)
|
|
|
|
{
|
|
|
|
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return optionList;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
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)
|
|
|
|
{
|
2015-09-01 10:14:22 -05:00
|
|
|
if (changedField == &syncCamera && syncCamera())
|
2015-08-27 06:44:27 -05:00
|
|
|
{
|
2015-09-01 10:14:22 -05:00
|
|
|
if (managedView && managedView->viewer()) managedView->viewer()->update();
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
2015-09-01 10:14:22 -05:00
|
|
|
else if (changedField == &syncTimeStep && syncTimeStep())
|
2015-08-27 07:57:04 -05:00
|
|
|
{
|
2015-09-01 10:14:22 -05:00
|
|
|
if (managedView)
|
2015-08-27 07:57:04 -05:00
|
|
|
{
|
2015-09-01 10:14:22 -05:00
|
|
|
RimLinkedViews* linkedViews = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(linkedViews);
|
|
|
|
linkedViews->updateTimeStep(managedView, managedView->currentTimeStep());
|
2015-08-27 07:57:04 -05:00
|
|
|
}
|
|
|
|
}
|
2015-09-01 10:14:22 -05:00
|
|
|
else if (changedField == &syncCellResult && syncCellResult())
|
|
|
|
{
|
|
|
|
RimLinkedViews* linkedViews = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(linkedViews);
|
|
|
|
linkedViews->updateCellResult();
|
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
else if (changedField == &syncRangeFilters)
|
|
|
|
{
|
2015-08-28 01:01:40 -05:00
|
|
|
configureOverridesUpdateDisplayModel();
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
2015-08-27 08:45:22 -05:00
|
|
|
else if (changedField == &syncPropertyFilters)
|
|
|
|
{
|
2015-08-28 01:01:40 -05:00
|
|
|
configureOverridesUpdateDisplayModel();
|
2015-08-27 08:45:22 -05:00
|
|
|
}
|
2015-08-27 06:44:27 -05:00
|
|
|
else if (changedField == &managedView)
|
|
|
|
{
|
2015-08-28 01:01:40 -05:00
|
|
|
configureOverridesUpdateDisplayModel();
|
2015-08-27 06:44:27 -05:00
|
|
|
|
|
|
|
if (managedView)
|
|
|
|
{
|
2015-08-27 07:57:04 -05:00
|
|
|
if (syncCellResult())
|
|
|
|
{
|
2015-09-01 10:14:22 -05:00
|
|
|
RimLinkedViews* linkedViews = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(linkedViews);
|
|
|
|
linkedViews->updateCellResult();
|
2015-08-27 07:57:04 -05:00
|
|
|
}
|
2015-08-28 04:48:16 -05:00
|
|
|
|
|
|
|
name = displayNameForView(managedView);
|
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-28 01:06:35 -05:00
|
|
|
|
2015-09-01 10:14:22 -05:00
|
|
|
RimLinkedViews* linkedViews = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(linkedViews);
|
|
|
|
linkedViews->configureOverrides();
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
2015-08-28 04:48:16 -05:00
|
|
|
|
|
|
|
updateDisplayName();
|
|
|
|
name.uiCapability()->updateConnectedEditors();
|
2015-08-27 06:44:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-28 01:01:40 -05:00
|
|
|
void RimManagedViewConfig::initAfterRead()
|
|
|
|
{
|
2015-08-28 01:06:35 -05:00
|
|
|
configureOverrides();
|
2015-08-28 04:48:16 -05:00
|
|
|
updateDisplayName();
|
2015-08-28 01:01:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimEclipseView* RimManagedViewConfig::managedEclipseView()
|
|
|
|
{
|
|
|
|
RimView* rimView = managedView;
|
|
|
|
|
|
|
|
return dynamic_cast<RimEclipseView*>(rimView);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechView* RimManagedViewConfig::managedGeoView()
|
|
|
|
{
|
|
|
|
RimView* rimView = managedView;
|
|
|
|
|
|
|
|
return dynamic_cast<RimGeoMechView*>(rimView);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::configureOverridesUpdateDisplayModel()
|
2015-08-28 01:06:35 -05:00
|
|
|
{
|
|
|
|
configureOverrides();
|
|
|
|
|
|
|
|
if (managedView)
|
|
|
|
{
|
|
|
|
managedView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews();
|
|
|
|
}
|
|
|
|
|
|
|
|
RimEclipseView* eclipseView = managedEclipseView();
|
|
|
|
if (eclipseView)
|
|
|
|
{
|
|
|
|
eclipseView->propertyFilterCollection()->updateDisplayModelNotifyManagedViews();
|
|
|
|
}
|
|
|
|
|
|
|
|
RimGeoMechView* geoView = managedGeoView();
|
|
|
|
if (geoView)
|
|
|
|
{
|
|
|
|
geoView->propertyFilterCollection()->updateDisplayModelNotifyManagedViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::configureOverrides()
|
2015-08-27 06:44:27 -05:00
|
|
|
{
|
2015-09-01 10:14:22 -05:00
|
|
|
RimLinkedViews* linkedViews = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(linkedViews);
|
|
|
|
|
|
|
|
RimView* masterView = linkedViews->mainView();
|
2015-08-27 06:44:27 -05:00
|
|
|
|
|
|
|
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-28 01:01:40 -05:00
|
|
|
}
|
2015-08-27 15:54:37 -05:00
|
|
|
}
|
|
|
|
|
2015-08-28 04:48:16 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimManagedViewConfig::displayNameForView(RimView* view)
|
|
|
|
{
|
2015-09-01 10:14:22 -05:00
|
|
|
return RimLinkedViews::displayNameForView(view);
|
|
|
|
/*
|
2015-08-28 04:48:16 -05:00
|
|
|
CVF_ASSERT(view);
|
|
|
|
|
|
|
|
RimCase* rimCase = NULL;
|
|
|
|
firstAnchestorOrThisOfType(rimCase);
|
|
|
|
|
|
|
|
QString displayName = rimCase->caseUserDescription() + " : " + view->name;
|
|
|
|
|
|
|
|
return displayName;
|
2015-09-01 10:14:22 -05:00
|
|
|
*/
|
2015-08-28 04:48:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimManagedViewConfig::updateDisplayName()
|
|
|
|
{
|
|
|
|
if (managedView)
|
|
|
|
{
|
|
|
|
name = displayNameForView(managedView);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name = "View Config : Empty view";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|