mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
#11618 Add menu to create filter from existing polygons
This commit is contained in:
parent
bf471b6c73
commit
f561973319
@ -42,6 +42,13 @@ CAF_CMD_SOURCE_INIT( RicNewPolygonFilterFeature, "RicNewPolygonFilterFeature" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimPolygon* polygonDataSource = nullptr;
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<void*>() )
|
||||
{
|
||||
polygonDataSource = static_cast<RimPolygon*>( userData.value<void*>() );
|
||||
}
|
||||
|
||||
auto cellFilterCollection = caf::SelectionManager::instance()->selectedItemOfType<RimCellFilterCollection>();
|
||||
|
||||
if ( !cellFilterCollection )
|
||||
@ -55,19 +62,24 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( !cellFilterCollection ) return;
|
||||
|
||||
auto polygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
|
||||
if ( !polygon )
|
||||
if ( !polygonDataSource )
|
||||
{
|
||||
if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>() )
|
||||
auto selectedPolygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
|
||||
if ( !selectedPolygon )
|
||||
{
|
||||
polygon = polygonInView->polygon();
|
||||
if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>() )
|
||||
{
|
||||
selectedPolygon = polygonInView->polygon();
|
||||
}
|
||||
}
|
||||
|
||||
polygonDataSource = selectedPolygon;
|
||||
}
|
||||
|
||||
auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();
|
||||
if ( sourceCase )
|
||||
{
|
||||
if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) )
|
||||
if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygonDataSource ) )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
|
||||
}
|
||||
@ -80,5 +92,5 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
|
||||
void RicNewPolygonFilterFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/CellFilter_Polygon.png" ) );
|
||||
actionToSetup->setText( "New Polygon Filter" );
|
||||
actionToSetup->setText( "New User Defined Polygon Filter" );
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "RimCellFilter.h"
|
||||
#include "RimCellIndexFilter.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimPolygonFilter.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimUserDefinedFilter.h"
|
||||
@ -30,6 +31,10 @@
|
||||
#include "RimViewController.h"
|
||||
#include "RimViewLinker.h"
|
||||
|
||||
#include "Polygons/RimPolygon.h"
|
||||
#include "Polygons/RimPolygonCollection.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmFieldReorderCapability.h"
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
@ -126,6 +131,41 @@ void RimCellFilterCollection::setCase( RimCase* theCase )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellFilterCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
||||
{
|
||||
menuBuilder << "RicPasteCellFiltersFeature";
|
||||
menuBuilder << "Separator";
|
||||
|
||||
menuBuilder.subMenuStart( "New Polygon Filter", QIcon( ":/CellFilter_Polygon.png" ) );
|
||||
{
|
||||
auto project = RimProject::current();
|
||||
auto polygonCollection = project->activeOilField()->polygonCollection();
|
||||
for ( auto p : polygonCollection->allPolygons() )
|
||||
{
|
||||
if ( !p ) continue;
|
||||
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicNewPolygonFilterFeature", p->name(), QVariant::fromValue( static_cast<void*>( p ) ) );
|
||||
}
|
||||
}
|
||||
menuBuilder.subMenuEnd();
|
||||
|
||||
menuBuilder << "RicNewPolygonFilterFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder.subMenuStart( "Slice Filters" );
|
||||
menuBuilder << "RicNewRangeFilterSliceIFeature";
|
||||
menuBuilder << "RicNewRangeFilterSliceJFeature";
|
||||
menuBuilder << "RicNewRangeFilterSliceKFeature";
|
||||
menuBuilder.subMenuEnd();
|
||||
menuBuilder << "RicNewCellRangeFilterFeature";
|
||||
menuBuilder << "RicNewCellIndexFilterFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicNewUserDefinedFilterFeature";
|
||||
menuBuilder << "RicNewUserDefinedIndexFilterFeature";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -93,6 +93,8 @@ public:
|
||||
|
||||
void setCase( RimCase* theCase );
|
||||
|
||||
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
|
||||
|
||||
protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
@ -250,8 +250,9 @@ void RimPolygon::onColorTagClicked( const SignalEmitter* emitter, size_t index )
|
||||
void RimPolygon::appendPolygonMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder )
|
||||
{
|
||||
menuBuilder << "RicNewPolygonIntersectionFeature";
|
||||
menuBuilder << "RicNewPolygonFilterFeature";
|
||||
menuBuilder.addCmdFeature( "RicNewPolygonFilterFeature", "New Polygon Filter" );
|
||||
menuBuilder << "Separator";
|
||||
|
||||
menuBuilder << "RicDuplicatePolygonFeature";
|
||||
menuBuilder << "RicSimplifyPolygonFeature";
|
||||
menuBuilder << "Separator";
|
||||
|
@ -37,8 +37,6 @@
|
||||
#include "RimCalcScript.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimCellFilterCollection.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimColorLegend.h"
|
||||
#include "RimColorLegendCollection.h"
|
||||
#include "RimColorLegendItem.h"
|
||||
@ -51,14 +49,12 @@
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimEclipseCaseEnsemble.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseContourMapView.h"
|
||||
#include "RimEclipseContourMapViewCollection.h"
|
||||
#include "RimEclipseFaultColors.h"
|
||||
#include "RimEclipseInputProperty.h"
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimEclipsePropertyFilterCollection.h"
|
||||
#include "RimEclipseResultAddress.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseStatisticsCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseViewCollection.h"
|
||||
@ -70,7 +66,6 @@
|
||||
#include "RimEnsembleFractureStatisticsCollection.h"
|
||||
#include "RimExtrudedCurveIntersection.h"
|
||||
#include "RimFaultInView.h"
|
||||
#include "RimFaultInViewCollection.h"
|
||||
#include "RimFaultReactivationModel.h"
|
||||
#include "RimFishbones.h"
|
||||
#include "RimFishbonesCollection.h"
|
||||
@ -79,11 +74,9 @@
|
||||
#include "RimFlowPlotCollection.h"
|
||||
#include "RimFormationNames.h"
|
||||
#include "RimFormationNamesCollection.h"
|
||||
#include "RimFractureTemplate.h"
|
||||
#include "RimFractureTemplateCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechContourMapView.h"
|
||||
#include "RimGeoMechContourMapViewCollection.h"
|
||||
#include "RimGeoMechModels.h"
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
@ -100,7 +93,6 @@
|
||||
#include "RimIntersectionResultsDefinitionCollection.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimMultiPlot.h"
|
||||
#include "RimMultiPlotCollection.h"
|
||||
#include "RimObservedSummaryData.h"
|
||||
#include "RimOsduWellPath.h"
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
@ -128,7 +120,6 @@
|
||||
#include "RimStimPlanFractureTemplate.h"
|
||||
#include "RimStimPlanModel.h"
|
||||
#include "RimStimPlanModelCollection.h"
|
||||
#include "RimStimPlanModelPlot.h"
|
||||
#include "RimStimPlanModelTemplate.h"
|
||||
#include "RimStimPlanModelTemplateCollection.h"
|
||||
#include "RimStreamlineInViewCollection.h"
|
||||
@ -1034,22 +1025,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicCopySurfaceFeature";
|
||||
menuBuilder << "RicReloadSurfaceFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimCellFilterCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicPasteCellFiltersFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicNewPolygonFilterFeature";
|
||||
menuBuilder << "RicNewCellRangeFilterFeature";
|
||||
menuBuilder.subMenuStart( "Slice Filters" );
|
||||
menuBuilder << "RicNewRangeFilterSliceIFeature";
|
||||
menuBuilder << "RicNewRangeFilterSliceJFeature";
|
||||
menuBuilder << "RicNewRangeFilterSliceKFeature";
|
||||
menuBuilder.subMenuEnd();
|
||||
menuBuilder << "RicNewCellIndexFilterFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicNewUserDefinedFilterFeature";
|
||||
menuBuilder << "RicNewUserDefinedIndexFilterFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimSeismicSectionCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewInlineSeismicSectionFeature";
|
||||
|
Loading…
Reference in New Issue
Block a user