2015-09-02 10:18:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-02 10:18:02 -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-02 10:18:02 -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-02 10:18:02 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicShowAllLinkedViewsFeature.h"
|
|
|
|
|
2018-01-16 02:37:08 -06:00
|
|
|
#include "RimGridView.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimViewController.h"
|
2015-09-07 07:29:46 -05:00
|
|
|
#include "RimViewLinker.h"
|
2019-03-27 04:26:08 -05:00
|
|
|
#include "RimViewLinkerCollection.h"
|
2015-09-02 10:18:02 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicShowAllLinkedViewsFeature, "RicShowAllLinkedViewsFeature" );
|
2015-09-02 10:18:02 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-02 10:18:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-06-26 07:28:46 -05:00
|
|
|
bool RicShowAllLinkedViewsFeature::isCommandEnabled() const
|
2015-09-02 10:18:02 -05:00
|
|
|
{
|
2019-03-27 04:26:08 -05:00
|
|
|
return caf::SelectionManager::instance()->selectedItemAncestorOfType<RimViewLinkerCollection>() != nullptr;
|
2015-09-02 10:18:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-02 10:18:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicShowAllLinkedViewsFeature::onActionTriggered( bool isChecked )
|
2015-09-02 10:18:02 -05:00
|
|
|
{
|
2015-09-07 07:29:46 -05:00
|
|
|
std::vector<RimViewLinker*> linkedViews;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &linkedViews );
|
2015-09-02 10:18:02 -05:00
|
|
|
|
2015-09-24 04:29:01 -05:00
|
|
|
std::vector<RimViewController*> managedViews;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &managedViews );
|
2022-11-04 09:48:25 -05:00
|
|
|
for ( auto& managedView : managedViews )
|
2015-09-02 10:18:02 -05:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
RimViewLinker* rimLinked = managedView->firstAncestorOrThisOfTypeAsserted<RimViewLinker>();
|
2015-09-02 10:18:02 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
linkedViews.push_back( rimLinked );
|
2015-09-02 10:18:02 -05:00
|
|
|
}
|
|
|
|
|
2022-11-04 09:48:25 -05:00
|
|
|
for ( auto& linkedView : linkedViews )
|
2015-09-02 10:18:02 -05:00
|
|
|
{
|
2022-11-04 09:48:25 -05:00
|
|
|
auto views = linkedView->allViews();
|
|
|
|
for ( auto& view : views )
|
2015-09-02 10:18:02 -05:00
|
|
|
{
|
2022-11-04 09:48:25 -05:00
|
|
|
view->forceShowWindowOn();
|
2015-09-02 10:18:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-02 10:18:02 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicShowAllLinkedViewsFeature::setupActionLook( QAction* actionToSetup )
|
2015-09-02 10:18:02 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Open All Linked Views" );
|
2015-09-02 10:18:02 -05:00
|
|
|
}
|