mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Sector export: Hide empty Refinement Regions folder in project tree
Add shouldBeVisibleInTree() to RimRefinementRegionCollection (true only when at least one region exists) and consult it from RimEclipseView::defineUiTreeOrdering. Refresh the parent view's connected editors from addNewRegion, removeRegion, and onChildDeleted so the folder appears and disappears as regions are added or removed via the generic delete-item action. The "New Refinement Region" action remains reachable from the Eclipse view's context menu while the folder is hidden.
This commit is contained in:
@@ -2063,7 +2063,7 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
{
|
||||
uiTreeOrdering.add( m_overlayInfoConfig() );
|
||||
uiTreeOrdering.add( m_gridCollection() );
|
||||
if ( m_refinementRegions() ) uiTreeOrdering.add( m_refinementRegions() );
|
||||
if ( m_refinementRegions() && m_refinementRegions()->shouldBeVisibleInTree() ) uiTreeOrdering.add( m_refinementRegions() );
|
||||
uiTreeOrdering.add( cellResult() );
|
||||
uiTreeOrdering.add( cellEdgeResult() );
|
||||
uiTreeOrdering.add( cellFilterCollection() );
|
||||
|
||||
@@ -51,6 +51,14 @@ bool RimRefinementRegionCollection::isActive() const
|
||||
return m_isActive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimRefinementRegionCollection::shouldBeVisibleInTree() const
|
||||
{
|
||||
return !m_regions.empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -86,6 +94,9 @@ RimRefinementRegion* RimRefinementRegionCollection::addNewRegion( RimEclipseCase
|
||||
region->setDefaultsFromCase( eclipseCase );
|
||||
|
||||
updateConnectedEditors();
|
||||
// Visibility of this collection in the parent view's tree depends on m_regions being non-empty,
|
||||
// so refresh the parent so the folder appears when the first region is added.
|
||||
if ( auto* view = firstAncestorOrThisOfType<Rim3dView>() ) view->updateConnectedEditors();
|
||||
return region;
|
||||
}
|
||||
|
||||
@@ -106,6 +117,17 @@ void RimRefinementRegionCollection::removeRegion( RimRefinementRegion* region )
|
||||
m_regions.removeChild( region );
|
||||
delete region;
|
||||
updateConnectedEditors();
|
||||
if ( auto* view = firstAncestorOrThisOfType<Rim3dView>() ) view->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Refresh the parent view's tree so the collection folder disappears once the last region is
|
||||
/// removed via the generic delete-item action.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRefinementRegionCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
||||
std::vector<caf::PdmObjectHandle*>& referringObjects )
|
||||
{
|
||||
if ( auto* view = firstAncestorOrThisOfType<Rim3dView>() ) view->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -49,6 +49,9 @@ public:
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
// Hide the collection node in the project tree while it has no regions, to keep the tree tidy.
|
||||
bool shouldBeVisibleInTree() const;
|
||||
|
||||
std::vector<RimRefinementRegion*> regions() const;
|
||||
std::vector<RimRefinementRegion*> activeRegions() const;
|
||||
|
||||
@@ -66,6 +69,7 @@ public:
|
||||
|
||||
protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_isActive;
|
||||
|
||||
Reference in New Issue
Block a user