2015-09-02 06:44:56 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-02 06:44: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-02 06:44: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-02 06:44:56 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicLinkVisibleViewsFeatureUi.h"
|
|
|
|
|
2015-09-07 05:14:50 -05:00
|
|
|
#include "RiaApplication.h"
|
2018-09-12 04:51:52 -05:00
|
|
|
#include "RiaOptionItemFactory.h"
|
2015-09-02 06:44:56 -05:00
|
|
|
|
2022-11-24 03:46:54 -06:00
|
|
|
#include "Rim3dView.h"
|
2015-09-07 05:14:50 -05:00
|
|
|
#include "RimCase.h"
|
2015-09-07 07:29:46 -05:00
|
|
|
#include "RimViewLinker.h"
|
2015-09-02 06:44:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi" );
|
2015-09-02 06:44:56 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-02 06:44:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-11-24 03:46:54 -06:00
|
|
|
RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi()
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
2022-04-22 02:58:51 -05:00
|
|
|
CAF_PDM_InitObject( "Link Visible Views Feature UI", ":/LinkView.svg" );
|
2015-09-02 06:44:56 -05:00
|
|
|
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_masterView, "MasterView", "Primary View" );
|
2015-09-02 06:44:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-02 06:44:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-11-24 03:46:54 -06:00
|
|
|
void RicLinkVisibleViewsFeatureUi::setViews( const std::vector<Rim3dView*>& allViews )
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
|
|
|
m_allViews = allViews;
|
|
|
|
|
2022-11-24 03:46:54 -06:00
|
|
|
auto activeView = RiaApplication::instance()->activeReservoirView();
|
2015-09-07 05:14:50 -05:00
|
|
|
|
2022-11-24 03:46:54 -06:00
|
|
|
for ( size_t i = 0; i < m_allViews.size(); i++ )
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
2022-11-24 03:46:54 -06:00
|
|
|
if ( activeView == m_allViews[i] )
|
2015-09-07 05:14:50 -05:00
|
|
|
{
|
|
|
|
m_masterView = allViews[i];
|
|
|
|
}
|
2015-09-02 06:44:56 -05:00
|
|
|
}
|
|
|
|
|
2015-09-07 05:14:50 -05:00
|
|
|
// Fallback to use first view if no active view is present
|
2022-11-24 03:46:54 -06:00
|
|
|
if ( !m_masterView && !m_allViews.empty() )
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
2022-11-24 03:46:54 -06:00
|
|
|
m_masterView = m_allViews[0];
|
2015-09-02 06:44:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-02 06:44:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-11-24 03:46:54 -06:00
|
|
|
Rim3dView* RicLinkVisibleViewsFeatureUi::masterView()
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
|
|
|
return m_masterView;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-02 06:44:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
QList<caf::PdmOptionItemInfo> RicLinkVisibleViewsFeatureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
2017-01-05 00:57:37 -06:00
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
2015-09-02 06:44:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fieldNeedingOptions == &m_masterView )
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
2022-11-24 03:46:54 -06:00
|
|
|
for ( auto v : m_allViews )
|
2015-09-02 06:44:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName( v, &options );
|
2015-09-02 06:44:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-05 00:57:37 -06:00
|
|
|
return options;
|
2015-09-02 06:44:56 -05:00
|
|
|
}
|