2012-05-18 09:45:23 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2014-09-23 15:04:57 +02:00
|
|
|
// Copyright (C) 2011- Statoil ASA
|
|
|
|
|
// Copyright (C) 2013- Ceetron Solutions AS
|
|
|
|
|
// Copyright (C) 2011-2012 Ceetron AS
|
2012-05-18 09:45:23 +02:00
|
|
|
//
|
|
|
|
|
// 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 "RimCellRangeFilterCollection.h"
|
2014-07-24 10:11:43 +02:00
|
|
|
|
2017-02-24 14:01:42 +01:00
|
|
|
#include "RimCellRangeFilter.h"
|
2018-01-09 10:11:28 +01:00
|
|
|
#include "Rim3dView.h"
|
2015-10-13 10:24:11 +02:00
|
|
|
#include "RimViewController.h"
|
2015-09-07 14:29:46 +02:00
|
|
|
#include "RimViewLinker.h"
|
2015-08-12 11:30:27 +02:00
|
|
|
|
|
|
|
|
#include "cafPdmUiEditorHandle.h"
|
|
|
|
|
|
2017-06-28 13:46:19 +02:00
|
|
|
#include "cvfStructGridGeometryGenerator.h"
|
|
|
|
|
|
2012-05-18 09:45:23 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimCellRangeFilterCollection, "CellRangeFilterCollection");
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimCellRangeFilterCollection::RimCellRangeFilterCollection()
|
|
|
|
|
{
|
2015-08-10 08:00:16 +02:00
|
|
|
CAF_PDM_InitObject("Range Filters", ":/CellFilter_Range.png", "", "");
|
2012-05-18 09:45:23 +02:00
|
|
|
|
2013-04-25 10:48:44 +02:00
|
|
|
CAF_PDM_InitFieldNoDefault(&rangeFilters, "RangeFilters", "Range Filters", "", "", "");
|
2015-08-10 08:00:16 +02:00
|
|
|
rangeFilters.uiCapability()->setUiHidden(true);
|
|
|
|
|
|
2013-09-06 15:05:41 +02:00
|
|
|
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
2015-08-05 13:27:36 +02:00
|
|
|
isActive.uiCapability()->setUiHidden(true);
|
2012-05-18 09:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimCellRangeFilterCollection::~RimCellRangeFilterCollection()
|
|
|
|
|
{
|
2015-07-31 18:58:23 +02:00
|
|
|
rangeFilters.deleteAllChildObjects();
|
2012-05-18 09:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
/// RimCellRangeFilter is using Eclipse 1-based indexing, adjust filter values before
|
|
|
|
|
// populating cvf::CellRangeFilter (which is 0-based)
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-05-21 11:46:04 +02:00
|
|
|
void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex) const
|
2012-05-18 09:45:23 +02:00
|
|
|
{
|
|
|
|
|
CVF_ASSERT(cellRangeFilter);
|
|
|
|
|
|
2015-07-31 18:58:23 +02:00
|
|
|
for (size_t i = 0; i < rangeFilters.size(); i++)
|
2012-05-18 09:45:23 +02:00
|
|
|
{
|
2015-07-31 18:58:23 +02:00
|
|
|
RimCellRangeFilter* rangeFilter = rangeFilters[i];
|
2012-05-18 09:45:23 +02:00
|
|
|
|
2015-05-21 11:46:04 +02:00
|
|
|
if (rangeFilter && rangeFilter->isActive() && static_cast<size_t>(rangeFilter->gridIndex()) == gridIndex)
|
2012-05-18 09:45:23 +02:00
|
|
|
{
|
|
|
|
|
if (rangeFilter->filterMode == RimCellFilter::INCLUDE)
|
|
|
|
|
{
|
2018-05-31 11:41:48 +02:00
|
|
|
if (rangeFilter->useIndividualCellIndices())
|
|
|
|
|
{
|
|
|
|
|
for (const auto& cellIndex : rangeFilter->individualCellIndices())
|
|
|
|
|
{
|
|
|
|
|
cellRangeFilter->addCellInclude(
|
|
|
|
|
cellIndex.x() - 1 , cellIndex.y() - 1, cellIndex.z() - 1, rangeFilter->propagateToSubGrids());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cellRangeFilter->addCellIncludeRange(
|
|
|
|
|
rangeFilter->startIndexI - 1,
|
|
|
|
|
rangeFilter->startIndexJ - 1,
|
|
|
|
|
rangeFilter->startIndexK - 1,
|
|
|
|
|
rangeFilter->startIndexI - 1 + rangeFilter->cellCountI,
|
|
|
|
|
rangeFilter->startIndexJ - 1 + rangeFilter->cellCountJ,
|
|
|
|
|
rangeFilter->startIndexK - 1 + rangeFilter->cellCountK,
|
|
|
|
|
rangeFilter->propagateToSubGrids());
|
|
|
|
|
}
|
2012-05-18 09:45:23 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-05-31 11:41:48 +02:00
|
|
|
if (rangeFilter->useIndividualCellIndices())
|
|
|
|
|
{
|
|
|
|
|
for (const auto& cellIndex : rangeFilter->individualCellIndices())
|
|
|
|
|
{
|
|
|
|
|
cellRangeFilter->addCellExclude(
|
|
|
|
|
cellIndex.x() - 1, cellIndex.y() - 1, cellIndex.z() - 1, rangeFilter->propagateToSubGrids());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cellRangeFilter->addCellExcludeRange(
|
|
|
|
|
rangeFilter->startIndexI - 1,
|
|
|
|
|
rangeFilter->startIndexJ - 1,
|
|
|
|
|
rangeFilter->startIndexK - 1,
|
|
|
|
|
rangeFilter->startIndexI - 1 + rangeFilter->cellCountI,
|
|
|
|
|
rangeFilter->startIndexJ - 1 + rangeFilter->cellCountJ,
|
|
|
|
|
rangeFilter->startIndexK - 1 + rangeFilter->cellCountK,
|
|
|
|
|
rangeFilter->propagateToSubGrids());
|
|
|
|
|
}
|
2012-05-18 09:45:23 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
|
{
|
2015-09-23 14:35:35 +02:00
|
|
|
updateIconState();
|
2015-11-02 09:30:04 +01:00
|
|
|
uiCapability()->updateConnectedEditors();
|
2015-08-27 22:54:37 +02:00
|
|
|
|
2018-02-18 18:56:43 +01:00
|
|
|
updateDisplayModeNotifyManagedViews(nullptr);
|
2012-05-18 09:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-10-19 12:10:18 +02:00
|
|
|
void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRangeFilter* changedRangeFilter)
|
2012-05-18 09:45:23 +02:00
|
|
|
{
|
2018-02-18 18:56:43 +01:00
|
|
|
Rim3dView* view = nullptr;
|
2016-09-21 13:59:41 +02:00
|
|
|
firstAncestorOrThisOfType(view);
|
2017-02-24 16:00:56 +01:00
|
|
|
if (!view) return;
|
2012-05-18 09:45:23 +02:00
|
|
|
|
2015-10-19 12:10:18 +02:00
|
|
|
if (view->isMasterView())
|
|
|
|
|
{
|
|
|
|
|
RimViewLinker* viewLinker = view->assosiatedViewLinker();
|
|
|
|
|
if (viewLinker)
|
|
|
|
|
{
|
|
|
|
|
// Update data for range filter
|
|
|
|
|
// Update of display model is handled by view->scheduleGeometryRegen, also for managed views
|
|
|
|
|
viewLinker->updateRangeFilters(changedRangeFilter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-07 15:07:11 +01:00
|
|
|
view->scheduleGeometryRegen(VISIBLE_WELL_CELLS);
|
2015-09-01 17:14:22 +02:00
|
|
|
view->scheduleGeometryRegen(RANGE_FILTERED);
|
|
|
|
|
view->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
|
2015-08-26 18:51:55 +02:00
|
|
|
|
2015-09-01 17:14:22 +02:00
|
|
|
view->scheduleCreateDisplayModelAndRedraw();
|
2012-05-18 09:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimCellRangeFilterCollection::hasActiveFilters() const
|
|
|
|
|
{
|
2013-09-06 15:05:41 +02:00
|
|
|
if (!isActive()) return false;
|
2013-04-25 10:48:44 +02:00
|
|
|
|
2015-07-31 18:58:23 +02:00
|
|
|
for (size_t i = 0; i < rangeFilters.size(); i++)
|
2012-05-18 09:45:23 +02:00
|
|
|
{
|
2015-07-31 18:58:23 +02:00
|
|
|
if (rangeFilters[i]->isActive()) return true;
|
2012-05-18 09:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-02-12 14:00:39 +01:00
|
|
|
|
2013-04-25 10:48:44 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
caf::PdmFieldHandle* RimCellRangeFilterCollection::objectToggleField()
|
|
|
|
|
{
|
2013-09-06 15:05:41 +02:00
|
|
|
return &isActive;
|
2013-04-25 10:48:44 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 08:49:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const
|
|
|
|
|
{
|
2013-09-06 15:05:41 +02:00
|
|
|
if (!isActive) return false;
|
2013-08-08 08:49:29 +02:00
|
|
|
|
2015-07-31 18:58:23 +02:00
|
|
|
for (size_t i = 0; i < rangeFilters.size(); i++)
|
2013-08-08 08:49:29 +02:00
|
|
|
{
|
2015-07-31 18:58:23 +02:00
|
|
|
if (rangeFilters[i]->isActive() && rangeFilters[i]->filterMode() == RimCellFilter::INCLUDE) return true;
|
2013-08-08 08:49:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-27 13:44:27 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-09 10:11:28 +01:00
|
|
|
Rim3dView* RimCellRangeFilterCollection::baseView() const
|
2015-08-27 13:44:27 +02:00
|
|
|
{
|
2018-02-18 18:56:43 +01:00
|
|
|
Rim3dView* rimView = nullptr;
|
2016-09-21 13:59:41 +02:00
|
|
|
firstAncestorOrThisOfType(rimView);
|
2015-08-27 13:44:27 +02:00
|
|
|
|
|
|
|
|
return rimView;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 14:35:35 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimCellRangeFilterCollection::updateIconState()
|
|
|
|
|
{
|
|
|
|
|
bool activeIcon = true;
|
|
|
|
|
|
2015-09-25 11:01:41 +02:00
|
|
|
RimViewController* viewController = baseView()->viewController();
|
2015-10-19 12:10:18 +02:00
|
|
|
if (viewController && ( viewController->isRangeFiltersControlled()
|
2015-09-25 14:44:47 +02:00
|
|
|
|| viewController->isVisibleCellsOveridden()) )
|
2015-09-23 14:35:35 +02:00
|
|
|
{
|
|
|
|
|
activeIcon = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isActive)
|
|
|
|
|
{
|
|
|
|
|
activeIcon = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateUiIconFromState(activeIcon);
|
|
|
|
|
|
2015-10-28 12:23:24 +01:00
|
|
|
for (size_t i = 0; i < rangeFilters.size(); i++)
|
|
|
|
|
{
|
2015-11-02 09:30:04 +01:00
|
|
|
RimCellRangeFilter* rangeFilter = rangeFilters[i];
|
|
|
|
|
rangeFilter->updateActiveState();
|
|
|
|
|
rangeFilter->updateIconState();
|
2015-11-02 07:18:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimCellRangeFilterCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName)
|
|
|
|
|
{
|
|
|
|
|
PdmObject::defineUiTreeOrdering(uiTreeOrdering, uiConfigName);
|
|
|
|
|
|
|
|
|
|
RimViewController* viewController = baseView()->viewController();
|
|
|
|
|
if (viewController && viewController->isRangeFiltersControlled())
|
|
|
|
|
{
|
|
|
|
|
isActive.uiCapability()->setUiReadOnly(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isActive.uiCapability()->setUiReadOnly(false);
|
2015-10-28 12:23:24 +01:00
|
|
|
}
|
2015-11-02 09:30:04 +01:00
|
|
|
|
|
|
|
|
updateIconState();
|
2015-09-23 14:35:35 +02:00
|
|
|
}
|
|
|
|
|
|