2015-08-10 11:13:27 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2015-08-14 09:45:57 +02:00
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2015-08-14 09:45:57 +02:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
2015-08-10 11:13:27 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2015-08-14 09:45:57 +02:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
2015-08-10 11:13:27 +02:00
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-08-10 11:13:27 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2015-08-17 15:00:45 +02:00
|
|
|
#include "RicRangeFilterFeatureImpl.h"
|
2017-11-29 09:03:22 +01:00
|
|
|
|
2015-08-10 11:13:27 +02:00
|
|
|
#include "RicRangeFilterNewExec.h"
|
|
|
|
|
|
2017-11-29 09:03:22 +01:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
|
2015-08-10 11:13:27 +02:00
|
|
|
#include "RimCellRangeFilter.h"
|
|
|
|
|
#include "RimCellRangeFilterCollection.h"
|
2018-01-16 09:37:08 +01:00
|
|
|
#include "RimGridView.h"
|
2017-11-29 09:03:22 +01:00
|
|
|
#include "RimViewController.h"
|
2015-08-10 11:13:27 +02:00
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-08-10 11:13:27 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-17 15:00:45 +02:00
|
|
|
bool RicRangeFilterFeatureImpl::isRangeFilterCommandAvailable()
|
2015-08-10 11:13:27 +02:00
|
|
|
{
|
2015-10-23 14:28:21 +02:00
|
|
|
RimCellRangeFilterCollection* rangeFilterCollection = findRangeFilterCollection();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !rangeFilterCollection ) return false;
|
2015-10-23 14:28:21 +02:00
|
|
|
|
2018-01-15 14:52:22 +01:00
|
|
|
RimGridView* view;
|
2019-09-06 10:40:57 +02:00
|
|
|
rangeFilterCollection->firstAncestorOrThisOfType( view );
|
|
|
|
|
if ( view )
|
2015-10-23 14:28:21 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
RimViewController* vc = view->viewController();
|
|
|
|
|
if ( !vc ) return true;
|
|
|
|
|
return ( !vc->isRangeFiltersControlled() );
|
2015-10-23 14:28:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2015-08-10 11:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-08-10 11:13:27 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-17 15:00:45 +02:00
|
|
|
RicRangeFilterNewExec* RicRangeFilterFeatureImpl::createRangeFilterExecCommand()
|
2015-08-10 11:13:27 +02:00
|
|
|
{
|
|
|
|
|
RimCellRangeFilterCollection* rangeFilterCollection = findRangeFilterCollection();
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec( rangeFilterCollection );
|
2015-08-10 11:13:27 +02:00
|
|
|
|
|
|
|
|
return filterExec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2015-08-10 11:13:27 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-17 15:00:45 +02:00
|
|
|
RimCellRangeFilterCollection* RicRangeFilterFeatureImpl::findRangeFilterCollection()
|
2015-08-10 11:13:27 +02:00
|
|
|
{
|
2017-11-29 09:03:22 +01:00
|
|
|
RimCellRangeFilterCollection* rangeFilterCollection = nullptr;
|
2019-11-19 11:08:59 +01:00
|
|
|
|
2019-11-08 11:23:06 +01:00
|
|
|
rangeFilterCollection = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimCellRangeFilterCollection>();
|
2019-09-06 10:40:57 +02:00
|
|
|
|
2019-11-08 11:23:06 +01:00
|
|
|
if ( !rangeFilterCollection )
|
2015-08-10 11:13:27 +02:00
|
|
|
{
|
2019-11-08 11:23:06 +01:00
|
|
|
RimGridView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
|
|
|
|
|
if ( view )
|
|
|
|
|
{
|
|
|
|
|
rangeFilterCollection = view->rangeFilterCollection();
|
|
|
|
|
}
|
2015-08-10 11:13:27 +02:00
|
|
|
}
|
2015-08-14 13:21:04 +02:00
|
|
|
|
2015-08-10 11:13:27 +02:00
|
|
|
return rangeFilterCollection;
|
|
|
|
|
}
|