2015-09-08 03:17:35 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-08 03:17:35 -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-08 03:17:35 -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-08 03:17:35 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimViewLinkerCollection.h"
|
|
|
|
|
2020-05-18 09:02:27 -05:00
|
|
|
#include "RimProject.h"
|
2015-10-13 03:24:11 -05:00
|
|
|
#include "RimViewController.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimViewLinker.h"
|
2015-09-08 03:17:35 -05:00
|
|
|
|
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RimViewLinkerCollection, "RimViewLinkerCollection" );
|
2015-09-08 03:17:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-08 03:17:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-04-14 07:07:45 -05:00
|
|
|
RimViewLinkerCollection::RimViewLinkerCollection()
|
2015-09-08 03:17:35 -05:00
|
|
|
{
|
2022-04-22 02:58:51 -05:00
|
|
|
CAF_PDM_InitObject( "Linked Views", ":/LinkView.svg" );
|
2015-09-08 03:17:35 -05:00
|
|
|
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitField( &isActive, "Active", true, "Active" );
|
2019-09-06 03:40:57 -05:00
|
|
|
isActive.uiCapability()->setUiHidden( true );
|
2015-09-08 03:17:35 -05:00
|
|
|
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &viewLinker, "ViewLinkers", "View Linkers" );
|
2021-10-13 06:39:46 -05:00
|
|
|
viewLinker.uiCapability()->setUiTreeHidden( true );
|
2015-09-08 03:17:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-08 03:17:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-04-14 07:07:45 -05:00
|
|
|
RimViewLinkerCollection::~RimViewLinkerCollection()
|
2015-09-08 03:17:35 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( viewLinker() ) delete viewLinker();
|
2015-09-08 03:17:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-08 03:17:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
void RimViewLinkerCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
|
2015-09-08 03:17:35 -05:00
|
|
|
{
|
2015-09-16 07:26:25 -05:00
|
|
|
RimViewLinker* childObject = viewLinker();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( childObject )
|
2015-09-08 03:17:35 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
uiTreeOrdering.add( childObject );
|
|
|
|
childObject->addViewControllers( uiTreeOrdering );
|
2015-09-08 03:17:35 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
uiTreeOrdering.skipRemainingChildren( true );
|
2015-09-08 03:17:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-08 03:17:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RimViewLinkerCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
2015-09-08 03:17:35 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( &isActive == changedField )
|
2015-09-13 14:26:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( viewLinker() )
|
2015-09-13 14:26:09 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !isActive )
|
2015-10-21 05:45:35 -05:00
|
|
|
{
|
2021-01-11 11:47:09 -06:00
|
|
|
viewLinker()->applyCellFilterCollectionByUserChoice();
|
2015-10-21 05:45:35 -05:00
|
|
|
}
|
|
|
|
|
2015-09-24 07:29:13 -05:00
|
|
|
viewLinker()->updateDependentViews();
|
2022-10-31 04:41:50 -05:00
|
|
|
viewLinker()->updateWindowTitles();
|
2015-09-13 14:26:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-08 03:17:35 -05:00
|
|
|
this->updateUiIconFromToggleField();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-08 03:17:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewLinkerCollection::initAfterRead()
|
|
|
|
{
|
|
|
|
this->updateUiIconFromToggleField();
|
|
|
|
}
|
2020-05-18 09:02:27 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RimViewLinkerCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
|
2020-05-18 09:02:27 -05:00
|
|
|
{
|
|
|
|
uiCapability()->updateConnectedEditors();
|
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2020-05-18 09:02:27 -05:00
|
|
|
if ( project )
|
|
|
|
{
|
|
|
|
// Update visibility of top level Linked Views item in the project tree
|
|
|
|
// Not visible if no views are linked
|
|
|
|
project->uiCapability()->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
}
|