ResInsight/ApplicationCode/ProjectDataModel/RimManagedViewCollection.cpp

252 lines
9.5 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimManagedViewCollection.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimManagedViewConfig.h"
#include "RimView.h"
#include "RiuViewer.h"
#include "cvfCamera.h"
#include "cvfMatrix4.h"
#include "RimGeoMechView.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechCellColors.h"
CAF_PDM_SOURCE_INIT(RimManagedViewCollection, "RimManagedViewCollection");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimManagedViewCollection::RimManagedViewCollection(void)
{
CAF_PDM_InitObject("Managed Views", ":/chain.png", "", "");
CAF_PDM_InitFieldNoDefault(&managedViews, "ManagedViews", "Managed Views", "", "", "");
managedViews.uiCapability()->setUiHidden(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimManagedViewCollection::~RimManagedViewCollection(void)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimManagedViewCollection::updateTimeStep(int timeStep)
{
for (size_t i = 0; i < managedViews.size(); i++)
{
RimManagedViewConfig* managedViewConfig = managedViews[i];
if (managedViewConfig->managedView())
{
if (managedViewConfig->syncTimeStep() && managedViewConfig->managedView()->viewer())
{
managedViewConfig->managedView()->viewer()->slotSetCurrentFrame(timeStep);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimManagedViewCollection::updateCellResult()
{
RimView* masterView = NULL;
firstAnchestorOrThisOfType(masterView);
RimEclipseView* masterEclipseView = dynamic_cast<RimEclipseView*>(masterView);
if (masterEclipseView && masterEclipseView->cellResult())
{
RimEclipseResultDefinition* eclipseCellResultDefinition = masterEclipseView->cellResult();
for (size_t i = 0; i < managedViews.size(); i++)
{
RimManagedViewConfig* managedViewConfig = managedViews[i];
if (managedViewConfig->managedView())
{
if (managedViewConfig->syncCellResult())
{
RimView* rimView = managedViewConfig->managedView();
RimEclipseView* eclipeView = dynamic_cast<RimEclipseView*>(rimView);
if (eclipeView)
{
eclipeView->cellResult()->setPorosityModel(eclipseCellResultDefinition->porosityModel());
eclipeView->cellResult()->setResultType(eclipseCellResultDefinition->resultType());
eclipeView->cellResult()->setResultVariable(eclipseCellResultDefinition->resultVariable());
}
}
// Notify recursively
managedViewConfig->managedView()->managedViewCollection()->updateCellResult();
}
}
}
RimGeoMechView* masterGeoView = dynamic_cast<RimGeoMechView*>(masterView);
if (masterGeoView && masterGeoView->cellResult())
{
RimGeoMechResultDefinition* geoMechResultDefinition = masterGeoView->cellResult();
for (size_t i = 0; i < managedViews.size(); i++)
{
RimManagedViewConfig* managedViewConfig = managedViews[i];
if (managedViewConfig->managedView())
{
if (managedViewConfig->syncCellResult())
{
RimView* rimView = managedViewConfig->managedView();
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(rimView);
if (geoView)
{
geoView->cellResult()->setResultAddress(geoMechResultDefinition->resultAddress());
geoView->scheduleCreateDisplayModelAndRedraw();
}
}
// Notify recursively
managedViewConfig->managedView()->managedViewCollection()->updateCellResult();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimManagedViewCollection::updateRangeFilters()
{
for (size_t i = 0; i < managedViews.size(); i++)
{
RimManagedViewConfig* managedViewConfig = managedViews[i];
if (managedViewConfig->managedView())
{
if (managedViewConfig->syncRangeFilters())
{
RimView* rimView = managedViewConfig->managedView();
RimEclipseView* eclipeView = dynamic_cast<RimEclipseView*>(rimView);
if (eclipeView)
{
eclipeView->scheduleGeometryRegen(RANGE_FILTERED);
eclipeView->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
eclipeView->scheduleCreateDisplayModelAndRedraw();
}
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(rimView);
if (geoView)
{
geoView->scheduleGeometryRegen(RANGE_FILTERED);
geoView->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
geoView->scheduleCreateDisplayModelAndRedraw();
}
}
// Notify recursively
managedViewConfig->managedView()->managedViewCollection()->updateRangeFilters();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimManagedViewCollection::updatePropertyFilters()
{
for (size_t i = 0; i < managedViews.size(); i++)
{
RimManagedViewConfig* managedViewConfig = managedViews[i];
if (managedViewConfig->managedView())
{
if (managedViewConfig->syncPropertyFilters())
{
RimView* rimView = managedViewConfig->managedView();
RimEclipseView* eclipeView = dynamic_cast<RimEclipseView*>(rimView);
if (eclipeView)
{
eclipeView->scheduleGeometryRegen(RANGE_FILTERED);
eclipeView->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
eclipeView->scheduleCreateDisplayModelAndRedraw();
}
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(rimView);
if (geoView)
{
geoView->scheduleGeometryRegen(PROPERTY_FILTERED);
geoView->scheduleCreateDisplayModelAndRedraw();
}
}
// Notify recursively
managedViewConfig->managedView()->managedViewCollection()->updatePropertyFilters();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimManagedViewCollection::configureOverrides()
{
for (size_t i = 0; i < managedViews.size(); i++)
{
RimManagedViewConfig* managedViewConfig = managedViews[i];
managedViewConfig->configureOverrides();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimManagedViewCollection::allManagedViews(std::vector<RimView*>& views)
{
for (size_t i = 0; i < managedViews.size(); i++)
{
managedViews[i]->allManagedViews(views);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimManagedViewCollection::applyAllOperations()
{
RimView* masterView = NULL;
firstAnchestorOrThisOfType(masterView);
configureOverrides();
updateCellResult();
updateTimeStep(masterView->currentTimeStep());
updateRangeFilters();
updatePropertyFilters();
}