mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
Port RimSurfaceCollection, RimPolygonCollection and the polygon-in-view side onto the new caf::PdmNestedCollection framework, replacing the per-class folder plumbing (m_subCollections field, topmost-folder flag, add/remove/find sub-collection, factory, "new folder" command) with the shared base. - RimSurfaceCollection and RimPolygonCollection now derive from caf::PdmNestedCollection. Each constructor uses the generic folder icon and exposes a static createTopmost() that marks the top instance and applies the branded domain icon; RimOilField calls the factory. - RimPolygonInViewCollection uses the new RimNestedMirrorCollectionInView helper, and a new RimPolygonContainer carries the source-side polygon link. - RicNewSurfaceCollectionFeature is removed; the generic RicNewNestedCollectionFeature drives the "Add Folder" action against both collections. - Update callers (RimAnnotationCollection, RimEnsembleSurface, polygon command features) and the scripting wrapper (RimcSurfaceCollection), plus the Python add-folder binding and polygon test.
155 lines
5.7 KiB
C++
155 lines
5.7 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2024 Equinor ASA
|
|
//
|
|
// 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.
|
|
//
|
|
// 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.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RimPolygonInViewCollection.h"
|
|
|
|
#include "ContourMap/RimEclipseContourMapView.h"
|
|
#include "Rim3dView.h"
|
|
#include "RimPolygon.h"
|
|
#include "RimPolygonCollection.h"
|
|
#include "RimPolygonInView.h"
|
|
#include "RimTools.h"
|
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
|
|
|
CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimPolygonInViewCollection::RimPolygonInViewCollection()
|
|
{
|
|
CAF_PDM_InitObject( "Polygons", ":/Folder.png" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_itemsInView, "Polygons", "Polygons" );
|
|
CAF_PDM_InitFieldNoDefault( &m_collectionsInView, "Collections", "Collections" );
|
|
CAF_PDM_InitFieldNoDefault( &m_sourceCollection, "SourceCollection", "Source Collection" );
|
|
m_sourceCollection.uiCapability()->setUiHidden( true );
|
|
|
|
nameField()->uiCapability()->setUiHidden( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPolygonInViewCollection::updateFromPolygonCollection()
|
|
{
|
|
if ( !sourceCollection() )
|
|
{
|
|
setSourceCollection( RimTools::polygonCollection() );
|
|
}
|
|
updateFromSource();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimPolygonInView*> RimPolygonInViewCollection::visiblePolygonsInView() const
|
|
{
|
|
if ( !m_isChecked ) return {};
|
|
|
|
std::vector<RimPolygonInView*> polys = m_itemsInView.childrenByType();
|
|
|
|
for ( auto coll : m_collectionsInView )
|
|
{
|
|
if ( !coll->isChecked() ) continue;
|
|
|
|
auto other = coll->visiblePolygonsInView();
|
|
polys.insert( polys.end(), other.begin(), other.end() );
|
|
}
|
|
|
|
return polys;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimPolygonInView*> RimPolygonInViewCollection::allPolygonsInView() const
|
|
{
|
|
std::vector<RimPolygonInView*> polys = m_itemsInView.childrenByType();
|
|
|
|
for ( auto coll : m_collectionsInView )
|
|
{
|
|
auto other = coll->visiblePolygonsInView();
|
|
polys.insert( polys.end(), other.begin(), other.end() );
|
|
}
|
|
|
|
return polys;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
|
{
|
|
RimCheckableNamedObject::fieldChangedByUi( changedField, oldValue, newValue );
|
|
|
|
if ( changedField == &m_isChecked )
|
|
{
|
|
for ( auto poly : visiblePolygonsInView() )
|
|
{
|
|
poly->updateConnectedEditors();
|
|
}
|
|
|
|
if ( auto view = firstAncestorOfType<Rim3dView>() )
|
|
{
|
|
view->scheduleCreateDisplayModelAndRedraw();
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPolygonInViewCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
|
{
|
|
if ( firstAncestorOfType<RimEclipseContourMapView>() )
|
|
{
|
|
menuBuilder << "RicCreateContourMapPolygonFeature";
|
|
}
|
|
RimPolygonCollection::appendPolygonMenuItems( menuBuilder );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimPolygonContainer*> RimPolygonInViewCollection::sourceSubCollections() const
|
|
{
|
|
if ( auto* src = sourceCollection() ) return src->subCollections();
|
|
return {};
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimPolygon*> RimPolygonInViewCollection::sourceItems() const
|
|
{
|
|
if ( auto* src = sourceCollection() ) return src->items();
|
|
return {};
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimPolygonInView* RimPolygonInViewCollection::createItemInView( RimPolygon* source )
|
|
{
|
|
auto* viewItem = new RimPolygonInView();
|
|
viewItem->setPolygon( source );
|
|
return viewItem;
|
|
}
|