ResInsight/ApplicationCode/Commands/RicEclipsePropertyFilterFeatureImpl.cpp
Jacob Støren 9df1e48543 (#396) Disconnected EclipseResultDefiniton from EclipseView
So that it can be used in WellLogCurves
2015-09-01 17:18:53 +02:00

107 lines
4.7 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicEclipsePropertyFilterFeatureImpl.h"
#include "RimEclipsePropertyFilter.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseView.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseCellColors.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "RiuMainWindow.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimEclipsePropertyFilter*> RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilters()
{
std::vector<RimEclipsePropertyFilter*> propertyFilters;
caf::SelectionManager::instance()->objectsByType(&propertyFilters);
return propertyFilters;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimEclipsePropertyFilterCollection*> RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilterCollections()
{
std::vector<RimEclipsePropertyFilterCollection*> propertyFilterCollections;
caf::SelectionManager::instance()->objectsByType(&propertyFilterCollections);
return propertyFilterCollections;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterFeatureImpl::addPropertyFilter(RimEclipsePropertyFilterCollection* propertyFilterCollection)
{
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
propertyFilterCollection->propertyFilters.push_back(propertyFilter);
setDefaults(propertyFilter);
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
propertyFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(propertyFilter);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter(RimEclipsePropertyFilterCollection* propertyFilterCollection, size_t index)
{
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
propertyFilterCollection->propertyFilters.insertAt(static_cast<int>(index), propertyFilter);
setDefaults(propertyFilter);
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
propertyFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(propertyFilter);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEclipsePropertyFilterFeatureImpl::setDefaults(RimEclipsePropertyFilter* propertyFilter)
{
CVF_ASSERT(propertyFilter);
RimEclipsePropertyFilterCollection* propertyFilterCollection = propertyFilter->parentContainer();
CVF_ASSERT(propertyFilterCollection);
RimEclipseView* reservoirView = propertyFilterCollection->reservoirView();
CVF_ASSERT(reservoirView);
propertyFilter->resultDefinition->setEclipseCase(reservoirView->eclipseCase());
propertyFilter->resultDefinition->setResultVariable(reservoirView->cellResult->resultVariable());
propertyFilter->resultDefinition->setPorosityModel(reservoirView->cellResult->porosityModel());
propertyFilter->resultDefinition->setResultType(reservoirView->cellResult->resultType());
propertyFilter->resultDefinition->loadResult();
propertyFilter->setToDefaultValues();
propertyFilter->updateFilterName();
}