Polygon updates (#11298)

* Make menus similar for polygon and polygonInView
* Crash fix: Iterator might be invalidated by erase, reorder operations.
* Update pick editor after reload
* Do not enable edit if polygon is read only
* Make sure filter and intersection geometry is updated after a reload
* Make sure other pick editors are updated when polygon in view is changed
This commit is contained in:
jonjenssen
2024-03-18 14:31:06 +01:00
committed by GitHub
parent 853d68df8b
commit 2001c94a39
10 changed files with 53 additions and 14 deletions

View File

@@ -84,14 +84,7 @@ void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrde
//--------------------------------------------------------------------------------------------------
void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicDuplicatePolygonFeature";
menuBuilder << "RicNewPolygonIntersectionFeature";
menuBuilder << "RicNewPolygonFilterFeature";
menuBuilder << "Separator";
menuBuilder << "RicExportPolygonCsvFeature";
menuBuilder << "RicExportPolygonPolFeature";
menuBuilder << "Separator";
menuBuilder << "RicSimplifyPolygonFeature";
RimPolygon::appendPolygonMenuItems( menuBuilder );
}
//--------------------------------------------------------------------------------------------------
@@ -251,6 +244,21 @@ void RimPolygon::onColorTagClicked( const SignalEmitter* emitter, size_t index )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::appendPolygonMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder )
{
menuBuilder << "RicNewPolygonIntersectionFeature";
menuBuilder << "RicNewPolygonFilterFeature";
menuBuilder << "Separator";
menuBuilder << "RicDuplicatePolygonFeature";
menuBuilder << "RicSimplifyPolygonFeature";
menuBuilder << "Separator";
menuBuilder << "RicExportPolygonCsvFeature";
menuBuilder << "RicExportPolygonPolFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -61,10 +61,12 @@ public:
cvf::ref<RigPolyLinesData> polyLinesData() const override;
void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void onColorTagClicked( const SignalEmitter* emitter, size_t index );
static void appendPolygonMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder );
private:
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;

View File

@@ -147,6 +147,15 @@ std::vector<RimPolygon*> RimPolygonCollection::allPolygons() const
return allPolygons;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::appendPolygonMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder )
{
menuBuilder << "RicCreatePolygonFeature";
menuBuilder << "RicImportPolygonFileFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -169,8 +178,7 @@ void RimPolygonCollection::childFieldChangedByUi( const caf::PdmFieldHandle* cha
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicCreatePolygonFeature";
menuBuilder << "RicImportPolygonFileFeature";
RimPolygonCollection::appendPolygonMenuItems( menuBuilder );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -47,6 +47,8 @@ public:
std::vector<RimPolygonFile*> polygonFiles() const;
std::vector<RimPolygon*> allPolygons() const;
static void appendPolygonMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder );
private:
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;

View File

@@ -69,6 +69,8 @@ void RimPolygonFile::loadData()
auto projectPoly = m_polygons()[i];
auto filePoly = polygonsFromFile[i];
projectPoly->setPointsInDomainCoords( filePoly->pointsInDomainCoords() );
projectPoly->coordinatesChanged.send(); // updates editors
projectPoly->objectChanged.send(); // updates filters
delete filePoly;
}
}

View File

@@ -233,6 +233,13 @@ void RimPolygonInView::updatePolygonFromTargets()
points.push_back( target->targetPointXYZ() );
}
m_polygon->setPointsInDomainCoords( points );
// update other pick editors, make sure we don't update ourselves
m_polygon->coordinatesChanged.block( this );
m_polygon->coordinatesChanged.send();
m_polygon->coordinatesChanged.unblock( this );
m_polygon->objectChanged.send();
}
}
@@ -374,7 +381,7 @@ void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::Pdm
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
if ( m_polygon() ) m_polygon->appendMenuItems( menuBuilder );
RimPolygon::appendPolygonMenuItems( menuBuilder );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -123,6 +123,14 @@ void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
RimPolygonCollection::appendPolygonMenuItems( menuBuilder );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -222,8 +230,8 @@ void RimPolygonInViewCollection::syncPolygonsWithView()
if ( it != existingPolygonsInView.end() )
{
newPolygonsInView.push_back( *it );
existingPolygonsInView.erase( it );
( *it )->updateTargetsFromPolygon();
existingPolygonsInView.erase( it );
}
else
{

View File

@@ -45,6 +45,7 @@ public:
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void setPolygonFile( RimPolygonFile* polygonFile );
RimPolygonFile* polygonFile() const;