Polygon UI updates (#11975)

* Polygon UI updates
This commit is contained in:
jonjenssen 2024-12-06 14:26:30 +01:00 committed by GitHub
parent 53a31c88c9
commit 711cb267fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 109 additions and 35 deletions

View File

@ -34,6 +34,7 @@
#include "Polygons/RimPolygon.h" #include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h" #include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonInView.h"
#include "cafCmdFeatureMenuBuilder.h" #include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmFieldReorderCapability.h" #include "cafPdmFieldReorderCapability.h"
@ -619,7 +620,13 @@ std::vector<RimPolygonInView*> RimCellFilterCollection::enabledCellFilterPolygon
if ( auto polygonFilter = dynamic_cast<RimPolygonFilter*>( filter.p() ) ) if ( auto polygonFilter = dynamic_cast<RimPolygonFilter*>( filter.p() ) )
{ {
polyInView.push_back( polygonFilter->polygonInView() ); if ( !polygonFilter->isSelected() ) continue;
auto piv = polygonFilter->polygonInView();
if ( piv && piv->showLines() )
{
polyInView.push_back( piv );
}
} }
} }

View File

@ -43,6 +43,7 @@
#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h" #include "WellPathCommands/RicPolylineTargetsPickEventHandler.h"
#include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiPushButtonEditor.h"
#include "cafSelectionManager.h"
#include <limits> #include <limits>
@ -92,6 +93,7 @@ RimPolygonFilter::RimPolygonFilter()
: RimCellFilter( RimCellFilter::INDEX ) : RimCellFilter( RimCellFilter::INDEX )
, m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) ) , m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) )
, m_intervalTool( true ) , m_intervalTool( true )
, m_isSelected( false )
{ {
CAF_PDM_InitObject( "Polyline Filter", ":/CellFilter_Polygon.png" ); CAF_PDM_InitObject( "Polyline Filter", ":/CellFilter_Polygon.png" );
@ -174,6 +176,14 @@ bool RimPolygonFilter::isFilterEnabled() const
return m_isActive() && m_enableFiltering; return m_isActive() && m_enableFiltering;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::isSelected() const
{
return m_isSelected;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1003,6 +1013,21 @@ void RimPolygonFilter::onObjectChanged( const caf::SignalEmitter* emitter )
updateIconState(); updateIconState();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
{
bool selectedState = m_isSelected;
auto selectedFilter = dynamic_cast<RimPolygonFilter*>( caf::SelectionManager::instance()->selectedItem() );
m_isSelected = ( selectedFilter == this );
if ( selectedState != m_isSelected )
{
filterChanged.send();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Find which K layer we hit, in any of the grids, for any of the selected points /// Find which K layer we hit, in any of the grids, for any of the selected points
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
#include "cafPdmChildField.h" #include "cafPdmChildField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "cafPdmPtrField.h" #include "cafPdmPtrField.h"
#include "cafSelectionChangedReceiver.h"
class RimPolygon; class RimPolygon;
class RimPolylineTarget; class RimPolylineTarget;
@ -40,7 +41,7 @@ class RicPolylineTargetsPickEventHandler;
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface, public caf::SelectionChangedReceiver
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@ -77,8 +78,10 @@ public:
void setPolygon( RimPolygon* polygon ); void setPolygon( RimPolygon* polygon );
bool isFilterEnabled() const override; bool isFilterEnabled() const override;
bool isSelected() const;
void enablePicking( bool enable ); void enablePicking( bool enable );
bool pickingEnabled() const override;
void updateCellIndexFilter( cvf::UByteArray* includeVisibility, cvf::UByteArray* excludeVisibility, int gridIndex ) override; void updateCellIndexFilter( cvf::UByteArray* includeVisibility, cvf::UByteArray* excludeVisibility, int gridIndex ) override;
void onGridChanged() override; void onGridChanged() override;
@ -96,6 +99,8 @@ protected:
QString fullName() const override; QString fullName() const override;
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
private: private:
void updateCells(); void updateCells();
void updateCellsForEclipse( const std::vector<cvf::Vec3d>& points, RimEclipseCase* eCase ); void updateCellsForEclipse( const std::vector<cvf::Vec3d>& points, RimEclipseCase* eCase );
@ -124,7 +129,6 @@ private:
void updateEditorsAndVisualization() override; void updateEditorsAndVisualization() override;
void updateVisualization() override; void updateVisualization() override;
std::vector<RimPolylineTarget*> activeTargets() const override; std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override; caf::PickEventHandler* pickEventHandler() const override;
caf::AppEnum<GeometricalShape> geometricalShape() const; caf::AppEnum<GeometricalShape> geometricalShape() const;
@ -144,6 +148,8 @@ private:
RimCellFilterIntervalTool m_intervalTool; RimCellFilterIntervalTool m_intervalTool;
bool m_isSelected;
// Local polygon and polygon editor // Local polygon and polygon editor
caf::PdmPtrField<RimPolygon*> m_cellFilterPolygon; caf::PdmPtrField<RimPolygon*> m_cellFilterPolygon;
caf::PdmChildField<RimPolygon*> m_internalPolygon; caf::PdmChildField<RimPolygon*> m_internalPolygon;

View File

@ -159,6 +159,14 @@ void RimPolygon::setColor( const cvf::Color3f& color )
m_appearance->setLineColor( color ); m_appearance->setLineColor( color );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygon::showLines() const
{
return m_appearance->showLines();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -186,7 +194,6 @@ void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons
if ( changedField == &m_pointsInDomainCoords ) if ( changedField == &m_pointsInDomainCoords )
{ {
coordinatesChanged.send(); coordinatesChanged.send();
objectChanged.send();
} }
if ( changedField == &m_editPolygonButton ) if ( changedField == &m_editPolygonButton )
@ -195,9 +202,9 @@ void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons
RimPolygonTools::activate3dEditOfPolygonInView( this, activeView ); RimPolygonTools::activate3dEditOfPolygonInView( this, activeView );
m_editPolygonButton = false; m_editPolygonButton = false;
return; return;
} }
objectChanged.send();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -58,6 +58,8 @@ public:
cvf::Color3f color() const; cvf::Color3f color() const;
void setColor( const cvf::Color3f& color ); void setColor( const cvf::Color3f& color );
bool showLines() const;
cvf::ref<RigPolyLinesData> polyLinesData() const override; cvf::ref<RigPolyLinesData> polyLinesData() const override;
void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );

View File

@ -124,6 +124,14 @@ bool RimPolygonAppearance::isClosed() const
return m_isClosed(); return m_isClosed();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonAppearance::showLines() const
{
return m_showLines();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -40,6 +40,8 @@ public:
cvf::Color3f lineColor() const; cvf::Color3f lineColor() const;
void setLineColor( const cvf::Color3f& color ); void setLineColor( const cvf::Color3f& color );
bool showLines() const;
public: public:
RimPolygonAppearance(); RimPolygonAppearance();

View File

@ -39,7 +39,10 @@ RimPolygonFile::RimPolygonFile()
{ {
CAF_PDM_InitObject( "PolygonFile", ":/Folder.png" ); CAF_PDM_InitObject( "PolygonFile", ":/Folder.png" );
CAF_PDM_InitFieldNoDefault( &m_fileName, "StimPlanFileName", "File Name" ); CAF_PDM_InitFieldNoDefault( &m_fileName, "FileName", "File Name" );
m_fileName.registerKeywordAlias( "StimPlanFileName" );
m_fileName.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" ); CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
setDeletable( true ); setDeletable( true );
@ -62,11 +65,17 @@ void RimPolygonFile::loadData()
{ {
auto polygonsFromFile = importDataFromFile( m_fileName().path() ); auto polygonsFromFile = importDataFromFile( m_fileName().path() );
if ( polygonsFromFile.size() == 1 )
{
polygonsFromFile[0]->setName( name() );
}
if ( m_polygons.size() == polygonsFromFile.size() ) if ( m_polygons.size() == polygonsFromFile.size() )
{ {
for ( size_t i = 0; i < m_polygons.size(); i++ ) for ( size_t i = 0; i < m_polygons.size(); i++ )
{ {
auto projectPoly = m_polygons()[i]; auto projectPoly = m_polygons()[i];
projectPoly->setDeletable( false );
auto filePoly = polygonsFromFile[i]; auto filePoly = polygonsFromFile[i];
projectPoly->setPointsInDomainCoords( filePoly->pointsInDomainCoords() ); projectPoly->setPointsInDomainCoords( filePoly->pointsInDomainCoords() );
projectPoly->coordinatesChanged.send(); // updates editors projectPoly->coordinatesChanged.send(); // updates editors
@ -157,14 +166,18 @@ std::vector<RimPolygon*> RimPolygonFile::importDataFromFile( const QString& file
std::vector<RimPolygon*> polygons; std::vector<RimPolygon*> polygons;
QFileInfo fi( fileName );
const QString basename = fi.baseName();
for ( const auto& [polygonId, filePolygon] : filePolygons ) for ( const auto& [polygonId, filePolygon] : filePolygons )
{ {
auto polygon = new RimPolygon(); auto polygon = new RimPolygon();
polygon->disableStorageOfPolygonPoints(); polygon->disableStorageOfPolygonPoints();
polygon->setReadOnly( true ); polygon->setReadOnly( true );
polygon->setDeletable( false );
int id = ( polygonId != -1 ) ? polygonId : static_cast<int>( polygons.size() + 1 ); int id = ( polygonId != -1 ) ? polygonId : static_cast<int>( polygons.size() + 1 );
polygon->setName( QString( "Polygon %1" ).arg( id ) ); polygon->setName( QString( "%1 (%2)" ).arg( basename ).arg( id ) );
polygon->setPointsInDomainCoords( filePolygon ); polygon->setPointsInDomainCoords( filePolygon );
polygons.push_back( polygon ); polygons.push_back( polygon );
} }
@ -183,7 +196,7 @@ std::vector<RimPolygon*> RimPolygonFile::importDataFromFile( const QString& file
void RimPolygonFile::updateName() void RimPolygonFile::updateName()
{ {
QFileInfo fileInfo( m_fileName().path() ); QFileInfo fileInfo( m_fileName().path() );
setName( fileInfo.fileName() ); setName( fileInfo.baseName() );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -165,6 +165,18 @@ void RimPolygonInView::updateVisualization()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonInView::showLines() const
{
if ( auto poly = polygon() )
{
return poly->showLines() && isChecked();
}
return false;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -389,6 +401,11 @@ void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPolygonInView::onObjectChanged( const caf::SignalEmitter* emitter ) void RimPolygonInView::onObjectChanged( const caf::SignalEmitter* emitter )
{ {
// make sure name is in sync
if ( dynamic_cast<const RimPolygon*>( emitter ) )
{
setName( m_polygon->name() );
}
updateVisualization(); updateVisualization();
} }

View File

@ -67,6 +67,8 @@ public:
cvf::ref<RigPolyLinesData> polyLinesData() const override; cvf::ref<RigPolyLinesData> polyLinesData() const override;
bool showLines() const;
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override; void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;

View File

@ -32,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimPolygonInViewCollection::RimPolygonInViewCollection() RimPolygonInViewCollection::RimPolygonInViewCollection()
{ {
CAF_PDM_InitObject( "Polygons", ":/PolylinesFromFile16x16.png" ); CAF_PDM_InitObject( "Polygons", ":/Folder.png" );
CAF_PDM_InitFieldNoDefault( &m_polygonsInView, "Polygons", "Polygons" ); CAF_PDM_InitFieldNoDefault( &m_polygonsInView, "Polygons", "Polygons" );
CAF_PDM_InitFieldNoDefault( &m_collectionsInView, "Collections", "Collections" ); CAF_PDM_InitFieldNoDefault( &m_collectionsInView, "Collections", "Collections" );
@ -172,6 +172,7 @@ void RimPolygonInViewCollection::syncCollectionsWithView()
for ( auto polygonFile : polygonCollection->polygonFiles() ) for ( auto polygonFile : polygonCollection->polygonFiles() )
{ {
if ( polygonFile->polygons().empty() ) continue; if ( polygonFile->polygons().empty() ) continue;
if ( polygonFile->polygons().size() == 1 ) continue;
auto viewPolygonFile = getCollectionInViewForPolygonFile( polygonFile ); auto viewPolygonFile = getCollectionInViewForPolygonFile( polygonFile );
if ( viewPolygonFile == nullptr ) if ( viewPolygonFile == nullptr )
@ -217,6 +218,13 @@ void RimPolygonInViewCollection::syncPolygonsWithView()
{ {
auto polygonCollection = RimTools::polygonCollection(); auto polygonCollection = RimTools::polygonCollection();
polygons = polygonCollection->userDefinedPolygons(); polygons = polygonCollection->userDefinedPolygons();
for ( auto polyfile : polygonCollection->polygonFiles() )
{
if ( polyfile->polygons().size() == 1 )
{
polygons.push_back( polyfile->polygons()[0] );
}
}
} }
std::vector<RimPolygonInView*> newPolygonsInView; std::vector<RimPolygonInView*> newPolygonsInView;

View File

@ -101,6 +101,7 @@ RimGridView::RimGridView()
CAF_PDM_InitFieldNoDefault( &m_polygonInViewCollection, "PolygonInViewCollection", "Polygon Collection Field" ); CAF_PDM_InitFieldNoDefault( &m_polygonInViewCollection, "PolygonInViewCollection", "Polygon Collection Field" );
m_polygonInViewCollection = new RimPolygonInViewCollection(); m_polygonInViewCollection = new RimPolygonInViewCollection();
m_polygonInViewCollection->uiCapability()->setUiIcon( caf::IconProvider( ":/PolylinesFromFile16x16.png" ) );
CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" ); CAF_PDM_InitFieldNoDefault( &m_cellFilterCollection, "RangeFilters", "Cell Filter Collection Field" );
m_cellFilterCollection = new RimCellFilterCollection(); m_cellFilterCollection = new RimCellFilterCollection();

View File

@ -558,27 +558,6 @@ std::pair<int, int> RiuMultiPlotPage::rowAndColumnCount( int plotWidgetCount ) c
return std::make_pair( rowCount, columnCount ); return std::make_pair( rowCount, columnCount );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
{
if ( !m_plotDefinition ) return;
for ( RiuPlotWidget* plotWidget : m_plotWidgets )
{
if ( !plotWidget ) continue;
RimPlot* plot = plotWidget->plotDefinition();
if ( !plot ) continue;
bool isSelected = false;
for ( int changedLevel : changedSelectionLevels )
{
isSelected = isSelected || caf::SelectionManager::instance()->isSelected( plot, changedLevel );
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -23,7 +23,6 @@
#include "RiaDefines.h" #include "RiaDefines.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
#include "cafSelectionChangedReceiver.h"
#include "qwt_axis_id.h" #include "qwt_axis_id.h"
@ -55,7 +54,7 @@ class QwtPlot;
// RiuMultiPlotPage // RiuMultiPlotPage
// //
//================================================================================================== //==================================================================================================
class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, public RiuInterfaceToViewWindow class RiuMultiPlotPage : public QWidget, public RiuInterfaceToViewWindow
{ {
Q_OBJECT Q_OBJECT
@ -117,8 +116,6 @@ protected:
void alignAxes(); void alignAxes();
void alignAxis( QwtAxisId axis, int row, std::function<bool( int, int, int )> positionMatcher ); void alignAxis( QwtAxisId axis, int row, std::function<bool( int, int, int )> positionMatcher );
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
virtual bool showYAxis( int row, int column ) const; virtual bool showYAxis( int row, int column ) const;
virtual void reinsertPlotWidgets(); virtual void reinsertPlotWidgets();