2015-09-16 08:13:56 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-16 08:13:56 -05: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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-16 08:13:56 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-09-16 08:13:56 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicSetMasterViewFeature.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2016-08-11 02:10:56 -05:00
|
|
|
|
2019-01-11 06:56:35 -06:00
|
|
|
#include "RimEclipseContourMapView.h"
|
2018-01-16 02:37:08 -06:00
|
|
|
#include "RimGridView.h"
|
2018-11-22 01:46:01 -06:00
|
|
|
#include "RimProject.h"
|
2015-10-13 03:24:11 -05:00
|
|
|
#include "RimViewController.h"
|
2015-09-16 08:13:56 -05:00
|
|
|
#include "RimViewLinker.h"
|
|
|
|
#include "RimViewLinkerCollection.h"
|
|
|
|
|
2018-02-27 08:21:14 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2015-09-16 08:13:56 -05:00
|
|
|
|
2019-10-28 11:26:33 -05:00
|
|
|
#include "RimGeoMechContourMapView.h"
|
2015-09-16 08:13:56 -05:00
|
|
|
#include <QAction>
|
|
|
|
#include <QTreeView>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicSetMasterViewFeature, "RicSetMasterViewFeature" );
|
2015-09-16 08:13:56 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-16 08:13:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicSetMasterViewFeature::isCommandEnabled()
|
|
|
|
{
|
2019-10-24 02:55:55 -05:00
|
|
|
RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !activeView ) return false;
|
2019-10-28 11:26:33 -05:00
|
|
|
if ( dynamic_cast<RimEclipseContourMapView*>( activeView ) != nullptr ) return false;
|
|
|
|
if ( dynamic_cast<RimGeoMechContourMapView*>( activeView ) != nullptr ) return false;
|
2015-09-16 08:13:56 -05:00
|
|
|
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewLinker* viewLinker = activeView->assosiatedViewLinker();
|
2015-09-16 08:13:56 -05:00
|
|
|
|
2019-10-28 11:26:33 -05:00
|
|
|
if ( !viewLinker ) return false;
|
|
|
|
if ( viewLinker->masterView() == activeView ) return false;
|
2018-11-22 01:46:01 -06:00
|
|
|
|
2015-09-16 08:13:56 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-16 08:13:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicSetMasterViewFeature::onActionTriggered( bool isChecked )
|
2015-09-16 08:13:56 -05:00
|
|
|
{
|
2019-10-24 02:55:55 -05:00
|
|
|
RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !activeView ) return;
|
2015-09-16 08:13:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
2015-09-16 08:13:56 -05:00
|
|
|
RimViewLinker* viewLinker = proj->viewLinkerCollection()->viewLinker();
|
|
|
|
|
2015-10-21 05:45:35 -05:00
|
|
|
viewLinker->applyRangeFilterCollectionByUserChoice();
|
|
|
|
|
2018-01-15 07:52:22 -06:00
|
|
|
RimGridView* previousMasterView = viewLinker->masterView();
|
2015-09-16 08:13:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
viewLinker->setMasterView( activeView );
|
2015-10-20 04:13:31 -05:00
|
|
|
viewLinker->updateDependentViews();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
viewLinker->addDependentView( previousMasterView );
|
2015-09-16 08:13:56 -05:00
|
|
|
|
|
|
|
proj->viewLinkerCollection.uiCapability()->updateConnectedEditors();
|
|
|
|
proj->updateConnectedEditors();
|
|
|
|
|
|
|
|
// Set managed view collection to selected and expanded in project tree
|
2019-09-06 03:40:57 -05:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( viewLinker );
|
|
|
|
Riu3DMainWindowTools::setExpanded( viewLinker );
|
2015-09-16 08:13:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-16 08:13:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicSetMasterViewFeature::setupActionLook( QAction* actionToSetup )
|
2015-09-16 08:13:56 -05:00
|
|
|
{
|
2019-10-28 09:39:01 -05:00
|
|
|
actionToSetup->setText( "Set As Primary Linked View" );
|
2019-10-28 06:38:20 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/MasterView16x16.png" ) );
|
2015-09-16 08:13:56 -05:00
|
|
|
}
|