Skip to content

Commit

Permalink
Improve UI ordering for contained polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 21, 2024
1 parent 242df5f commit 780c548
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field,
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
// When interactive edit of polyline coordinates in enabled in RimPolygonInView::m_enablePicking, the editors to RimPolygonFilter must
// be updated to trigger calls to RimPolylinePickerInterface

updateConnectedEditors();
}

Expand Down Expand Up @@ -269,7 +272,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
if ( isPolygonDefinedLocally() )
{
caf::PdmUiGroup* polyDefinitionGroup = uiOrdering.addNewGroup( "Polygon Definition" );
m_polygonEditor()->uiOrdering( uiConfigName, *polyDefinitionGroup );
m_polygonEditor()->uiOrderingForLocalPolygon( uiConfigName, *polyDefinitionGroup );
}
}

Expand Down Expand Up @@ -303,12 +306,15 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField

if ( changedField == &m_polygonDataSource )
{
if ( !isPolygonDefinedLocally() && m_cellFilterPolygon() == nullptr )
if ( !isPolygonDefinedLocally() )
{
auto polygonCollection = RimTools::polygonCollection();
if ( polygonCollection && !polygonCollection->allPolygons().empty() )
if ( m_cellFilterPolygon() == nullptr || m_cellFilterPolygon() == m_internalPolygon )
{
m_cellFilterPolygon = polygonCollection->allPolygons().front();
auto polygonCollection = RimTools::polygonCollection();
if ( polygonCollection && !polygonCollection->allPolygons().empty() )
{
m_cellFilterPolygon = polygonCollection->allPolygons().front();
}
}
}
configurePolygonEditor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ RimPolygonAppearance::RimPolygonAppearance()
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );

CAF_PDM_InitField( &m_isClosed, "IsClosed", false, "Closed Polygon" );
CAF_PDM_InitField( &m_isClosed, "IsClosed", true, "Closed Polygon" );
CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" );
CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" );

Expand Down
10 changes: 10 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_enablePicking );
uiOrdering.add( &m_targets );
uiOrdering.add( &m_handleScalingFactor );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;

void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );

protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
Expand Down

0 comments on commit 780c548

Please sign in to comment.