Use polygon as data source for intersection

- Use polygon as data source for intersection
- Add padlock icon
- Show padlock icon on read only polygons
- Add Fwk function appendMenuItems() to make it possible to define context menu content in a PdmObject
- Context menu "Create Polygon Intersection"
- Updates to make visualization consistent with object and object collection enabled state
This commit is contained in:
Magne Sjaastad
2024-02-25 09:21:48 +01:00
committed by GitHub
parent 09151ec6af
commit 28d281e1d6
45 changed files with 632 additions and 125 deletions

View File

@@ -145,6 +145,12 @@ void RimCellFilterCollection::fieldChangedByUi( const caf::PdmFieldHandle* chang
uiCapability()->updateConnectedEditors();
onFilterUpdated( nullptr );
for ( const auto& filter : m_cellFilters )
{
// Update the filters to make sure the 3D polygon targets are removed if the filter collection is disabled
filter->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
@@ -255,13 +261,22 @@ bool RimCellFilterCollection::hasActiveIncludeRangeFilters() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase )
RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon )
{
RimPolygonFilter* pFilter = new RimPolygonFilter();
pFilter->setCase( srcCase );
pFilter->setPolygon( polygon );
addFilter( pFilter );
pFilter->configurePolygonEditor();
pFilter->enablePicking( true );
if ( polygon )
{
pFilter->enableFilter( true );
}
else
{
pFilter->enablePicking( true );
}
onFilterUpdated( pFilter );
return pFilter;
}
@@ -490,12 +505,14 @@ void RimCellFilterCollection::updateCellVisibilityByIndex( cvf::UByteArray* incl
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimCellFilterCollection::cellFilterPolygons() const
std::vector<RimPolygonInView*> RimCellFilterCollection::enabledCellFilterPolygons() const
{
std::vector<RimPolygonInView*> polyInView;
for ( const auto& filter : m_cellFilters )
{
if ( !filter->isActive() ) continue;
if ( auto polygonFilter = dynamic_cast<RimPolygonFilter*>( filter.p() ) )
{
polyInView.push_back( polygonFilter->polygonInView() );

View File

@@ -33,6 +33,7 @@ class RimUserDefinedFilter;
class RimUserDefinedIndexFilter;
class RimCase;
class RimPolygonInView;
class RimPolygon;
namespace cvf
{
@@ -53,7 +54,7 @@ public:
caf::Signal<> filtersChanged;
RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase );
RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon );
RimCellRangeFilter* addNewCellRangeFilter( RimCase* srcCase, int gridIndex, int sliceDirection = -1, int defaultSlice = -1 );
RimCellIndexFilter* addNewCellIndexFilter( RimCase* srcCase );
RimUserDefinedFilter* addNewUserDefinedFilter( RimCase* srcCase );
@@ -70,7 +71,7 @@ public:
void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const;
void updateCellVisibilityByIndex( cvf::UByteArray* cellsIncluded, cvf::UByteArray* cellsExcluded, size_t gridIndex ) const;
std::vector<RimPolygonInView*> cellFilterPolygons() const;
std::vector<RimPolygonInView*> enabledCellFilterPolygons() const;
std::vector<RimCellFilter*> filters() const;
bool hasActiveFilters() const;

View File

@@ -389,7 +389,7 @@ void RimEclipsePropertyFilter::defineObjectEditorAttribute( QString uiConfigName
if ( treeItemAttribute )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( ":/chain.png" );
treeItemAttribute->tags.push_back( std::move( tag ) );

View File

@@ -26,6 +26,7 @@
#include "RigMainGrid.h"
#include "RigReservoirGridTools.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimGeoMechCase.h"
#include "RimPolylineTarget.h"
@@ -153,6 +154,18 @@ void RimPolygonFilter::enableKFilter( bool bEnable )
m_enableKFilter = bEnable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::setPolygon( RimPolygon* polygon )
{
if ( polygon )
{
m_polygonDataSource = PolygonDataSource::GLOBAL_POLYGON;
m_cellFilterPolygon = polygon;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -238,18 +251,16 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
uiOrdering.add( &m_name );
auto dataSourceGroup = uiOrdering.addNewGroup( "Polygon Data Source" );
dataSourceGroup->add( &m_polygonDataSource );
if ( !isPolygonDefinedLocally() )
{
dataSourceGroup->add( &m_cellFilterPolygon );
dataSourceGroup->add( &m_editPolygonButton, { .newRow = false } );
}
auto group = uiOrdering.addNewGroup( "General" );
group->add( &m_filterMode );
group->add( &m_geometricalShape );
group->add( &m_enableFiltering );
group->add( &m_polygonDataSource );
if ( !isPolygonDefinedLocally() )
{
group->add( &m_cellFilterPolygon );
group->add( &m_editPolygonButton, { .newRow = false } );
}
auto group1 = uiOrdering.addNewGroup( "Polygon Selection" );
group1->add( &m_polyFilterMode );
@@ -319,7 +330,7 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField
{
if ( changedField == &m_editPolygonButton )
{
RimPolygonTools::selectPolygonInView( m_cellFilterPolygon(), this );
RimPolygonTools::selectAndActivatePolygonInView( m_cellFilterPolygon(), this );
m_editPolygonButton = false;
@@ -768,9 +779,9 @@ void RimPolygonFilter::updateCells()
// get polyline as vector
std::vector<cvf::Vec3d> points;
for ( auto target : m_polygonEditor->activeTargets() )
if ( m_polygonEditor && m_polygonEditor->polygon() )
{
points.push_back( target->targetPointXYZ() );
points = m_polygonEditor->polygon()->pointsInDomainCoords();
}
// We need at least three points to make a closed polygon, or just 2 for a polyline
@@ -870,6 +881,11 @@ bool RimPolygonFilter::pickingEnabled() const
//--------------------------------------------------------------------------------------------------
caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const
{
auto filterColl = firstAncestorOfType<RimCellFilterCollection>();
if ( filterColl && !filterColl->isActive() ) return nullptr;
if ( !isActive() ) return nullptr;
return m_pickTargetsEventHandler.get();
}

View File

@@ -74,6 +74,7 @@ public:
void enableFilter( bool bEnable );
void enableKFilter( bool bEnable );
void setPolygon( RimPolygon* polygon );
bool isFilterEnabled() const override;