2015-09-15 09:28:17 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-15 09:28:17 -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-15 09:28:17 -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-15 09:28:17 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicUnLinkViewFeature.h"
|
|
|
|
|
2015-10-21 06:27:10 -05:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2018-01-09 03:11:28 -06:00
|
|
|
#include "Rim3dView.h"
|
2019-10-24 02:55:55 -05:00
|
|
|
#include "RimGridView.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimProject.h"
|
2015-10-21 06:27:10 -05:00
|
|
|
#include "RimViewController.h"
|
2015-09-15 09:28:17 -05:00
|
|
|
#include "RimViewLinker.h"
|
|
|
|
|
2015-10-21 06:27:10 -05:00
|
|
|
#include "cafCmdFeatureManager.h"
|
2015-09-15 09:28:17 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
2019-10-28 11:13:18 -05:00
|
|
|
#include "RimViewLinkerCollection.h"
|
2019-11-04 04:34:34 -06:00
|
|
|
#include <QAction>
|
2015-10-21 06:27:10 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicUnLinkViewFeature, "RicUnLinkViewFeature" );
|
2015-09-15 09:28:17 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-15 09:28:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicUnLinkViewFeature::isCommandEnabled()
|
|
|
|
{
|
2019-10-24 02:55:55 -05:00
|
|
|
Rim3dView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
|
|
|
|
;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !activeView ) return false;
|
|
|
|
|
2019-10-28 11:13:18 -05:00
|
|
|
if ( activeView->assosiatedViewLinker() )
|
2015-09-15 09:28:17 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-15 09:28:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicUnLinkViewFeature::onActionTriggered( bool isChecked )
|
2015-09-15 09:28:17 -05:00
|
|
|
{
|
2019-10-24 02:55:55 -05:00
|
|
|
Rim3dView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
|
|
|
|
;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !activeView ) return;
|
|
|
|
|
2015-09-25 04:01:41 -05:00
|
|
|
RimViewController* viewController = activeView->viewController();
|
2019-10-28 11:13:18 -05:00
|
|
|
RimViewLinker* viewLinker = activeView->assosiatedViewLinker();
|
2015-09-15 09:28:17 -05:00
|
|
|
|
2019-10-28 11:13:18 -05:00
|
|
|
if ( viewController )
|
|
|
|
{
|
2021-01-11 11:47:09 -06:00
|
|
|
viewController->applyCellFilterCollectionByUserChoice();
|
2019-10-28 11:13:18 -05:00
|
|
|
delete viewController;
|
2020-02-12 04:43:15 -06:00
|
|
|
viewLinker->removeViewController( nullptr ); // Remove the slots in the vector that was set to nullptr by the
|
|
|
|
// destructor
|
2019-10-28 11:13:18 -05:00
|
|
|
}
|
|
|
|
else if ( viewLinker )
|
2015-09-15 09:28:17 -05:00
|
|
|
{
|
2021-01-11 11:47:09 -06:00
|
|
|
viewLinker->applyCellFilterCollectionByUserChoice();
|
2015-09-15 09:28:17 -05:00
|
|
|
|
2019-10-28 11:13:18 -05:00
|
|
|
RimGridView* firstControlledView = viewLinker->firstControlledView();
|
|
|
|
|
|
|
|
if ( firstControlledView )
|
|
|
|
{
|
2019-11-04 04:34:34 -06:00
|
|
|
viewLinker->setMasterView( firstControlledView );
|
2019-10-28 11:13:18 -05:00
|
|
|
|
|
|
|
viewLinker->updateDependentViews();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Remove the view linker object from the view linker collection
|
|
|
|
// viewLinkerCollection->viewLinker is a PdmChildField containing one RimViewLinker child object
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject::current()->viewLinkerCollection->viewLinker.removeChildObject( viewLinker );
|
2019-10-28 11:13:18 -05:00
|
|
|
|
|
|
|
delete viewLinker;
|
|
|
|
}
|
2019-11-25 05:38:00 -06:00
|
|
|
activeView->updateAutoName();
|
2015-09-15 09:28:17 -05:00
|
|
|
}
|
2019-10-28 11:13:18 -05:00
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject::current()->viewLinkerCollection.uiCapability()->updateConnectedEditors();
|
|
|
|
RimProject::current()->uiCapability()->updateConnectedEditors();
|
2015-09-15 09:28:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-15 09:28:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicUnLinkViewFeature::setupActionLook( QAction* actionToSetup )
|
2015-09-15 09:28:17 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Unlink View" );
|
2020-10-01 10:25:19 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/UnLinkView.svg" ) );
|
2015-09-15 09:28:17 -05:00
|
|
|
}
|