2015-06-19 07:09:45 -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 "RimGeoMechPropertyFilterCollection.h"
|
2015-08-27 15:54:37 -05:00
|
|
|
|
|
|
|
#include "RimGeoMechCellColors.h"
|
2015-06-19 07:09:45 -05:00
|
|
|
#include "RimGeoMechPropertyFilter.h"
|
|
|
|
#include "RimGeoMechView.h"
|
2015-09-23 07:35:35 -05:00
|
|
|
#include "RimViewLink.h"
|
2015-09-07 07:29:46 -05:00
|
|
|
#include "RimViewLinker.h"
|
2015-06-19 07:09:45 -05:00
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimGeoMechPropertyFilterCollection, "GeoMechPropertyFilters");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechPropertyFilterCollection::RimGeoMechPropertyFilterCollection()
|
|
|
|
{
|
2015-08-24 10:26:22 -05:00
|
|
|
CAF_PDM_InitObject("Property Filters", ":/CellFilter_Values.png", "", "");
|
2015-06-19 07:09:45 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&propertyFilters, "PropertyFilters", "Property Filters", "", "", "");
|
2015-08-11 08:23:57 -05:00
|
|
|
propertyFilters.uiCapability()->setUiHidden(true);
|
|
|
|
|
2015-09-23 07:35:35 -05:00
|
|
|
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
|
|
|
isActive.uiCapability()->setUiHidden(true);
|
2015-06-19 07:09:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechView* RimGeoMechPropertyFilterCollection::reservoirView()
|
|
|
|
{
|
2015-08-27 15:54:37 -05:00
|
|
|
RimGeoMechView* geoMechView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(geoMechView);
|
|
|
|
|
|
|
|
return geoMechView;
|
2015-06-19 07:09:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGeoMechPropertyFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2015-09-23 07:35:35 -05:00
|
|
|
updateIconState();
|
2015-06-19 07:09:45 -05:00
|
|
|
|
2015-08-27 15:54:37 -05:00
|
|
|
updateDisplayModelNotifyManagedViews();
|
2015-06-19 07:09:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGeoMechPropertyFilterCollection::loadAndInitializePropertyFilters()
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < propertyFilters.size(); i++)
|
|
|
|
{
|
|
|
|
RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i];
|
2015-09-01 10:11:23 -05:00
|
|
|
propertyFilter->resultDefinition->setGeoMechCase(reservoirView()->geoMechCase());
|
2015-06-19 07:09:45 -05:00
|
|
|
propertyFilter->resultDefinition->loadResult();
|
|
|
|
propertyFilter->computeResultValueRange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGeoMechPropertyFilterCollection::initAfterRead()
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < propertyFilters.size(); i++)
|
|
|
|
{
|
|
|
|
RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i];
|
|
|
|
|
|
|
|
propertyFilter->setParentContainer(this);
|
2015-09-01 10:11:23 -05:00
|
|
|
propertyFilter->resultDefinition->setGeoMechCase(reservoirView()->geoMechCase());
|
2015-06-19 07:09:45 -05:00
|
|
|
propertyFilter->updateIconState();
|
|
|
|
}
|
|
|
|
|
2015-09-23 07:35:35 -05:00
|
|
|
updateIconState();
|
2015-06-19 07:09:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGeoMechPropertyFilterCollection::hasActiveFilters() const
|
|
|
|
{
|
2015-09-23 07:35:35 -05:00
|
|
|
if (!isActive) return false;
|
2015-06-19 07:09:45 -05:00
|
|
|
|
|
|
|
for (size_t i = 0; i < propertyFilters.size(); i++)
|
|
|
|
{
|
|
|
|
RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i];
|
|
|
|
if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Returns whether any of the active property filters are based on a dynamic result
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGeoMechPropertyFilterCollection::hasActiveDynamicFilters() const
|
|
|
|
{
|
|
|
|
return hasActiveFilters();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimGeoMechPropertyFilterCollection::objectToggleField()
|
|
|
|
{
|
2015-09-23 07:35:35 -05:00
|
|
|
return &isActive;
|
2015-06-19 07:09:45 -05:00
|
|
|
}
|
2015-08-27 15:54:37 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGeoMechPropertyFilterCollection::updateDisplayModelNotifyManagedViews()
|
|
|
|
{
|
|
|
|
RimGeoMechView* view = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(view);
|
|
|
|
CVF_ASSERT(view);
|
|
|
|
|
|
|
|
view->scheduleGeometryRegen(PROPERTY_FILTERED);
|
|
|
|
view->scheduleCreateDisplayModelAndRedraw();
|
2015-09-23 07:35:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGeoMechPropertyFilterCollection::updateIconState()
|
|
|
|
{
|
|
|
|
bool activeIcon = true;
|
2015-08-27 15:54:37 -05:00
|
|
|
|
2015-09-23 07:35:35 -05:00
|
|
|
RimGeoMechView* view = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(view);
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewController* viewController = view->viewController();
|
2015-09-25 07:44:47 -05:00
|
|
|
if (viewController && ( viewController->isPropertyFilterOveridden()
|
|
|
|
|| viewController->isVisibleCellsOveridden()))
|
2015-09-23 07:35:35 -05:00
|
|
|
{
|
|
|
|
activeIcon = false;
|
|
|
|
}
|
2015-09-01 10:14:22 -05:00
|
|
|
|
2015-09-23 07:35:35 -05:00
|
|
|
if (!isActive)
|
2015-09-01 10:14:22 -05:00
|
|
|
{
|
2015-09-23 07:35:35 -05:00
|
|
|
activeIcon = false;
|
2015-09-01 10:14:22 -05:00
|
|
|
}
|
2015-09-23 07:35:35 -05:00
|
|
|
|
|
|
|
updateUiIconFromState(activeIcon);
|
|
|
|
|
|
|
|
uiCapability()->updateConnectedEditors();
|
2015-08-27 15:54:37 -05:00
|
|
|
}
|