Skip to content

Commit

Permalink
Enable value filter in statistics contourmap (#12078)
Browse files Browse the repository at this point in the history
* Enable value filtering in stat contourmap and fix map redraw logic
* Make switching case in contourmap  work
  • Loading branch information
jonjenssen authored Jan 21, 2025
1 parent 7acbc86 commit 2bcdc62
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ bool RimContourMapProjection::gridMappingNeedsUpdating() const
if ( cellGridIdxVisibility.isNull() ) return true;

cvf::ref<cvf::UByteArray> currentVisibility = getCellVisibility();
if ( currentVisibility->size() != cellGridIdxVisibility->size() ) return true;

CVF_ASSERT( currentVisibility->size() == cellGridIdxVisibility->size() );
for ( size_t i = 0; i < currentVisibility->size(); ++i )
{
if ( ( *currentVisibility )[i] != ( *cellGridIdxVisibility )[i] ) return true;
Expand Down Expand Up @@ -540,9 +540,7 @@ void RimContourMapProjection::fieldChangedByUi( const caf::PdmFieldHandle* chang
}

baseView()->updateConnectedEditors();

RimProject* proj = RimProject::current();
proj->scheduleCreateDisplayModelAndRedrawAllViews();
baseView()->scheduleCreateDisplayModelAndRedraw();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ class RimContourMapProjection : public RimCheckableNamedObject

void appendValueFilterGroup( caf::PdmUiOrdering& uiOrdering );

virtual bool gridMappingNeedsUpdating() const;

private:
bool resultsNeedsUpdating( int timeStep ) const;
bool gridMappingNeedsUpdating() const;
bool geometryNeedsUpdating() const;
void clearResults();
void clearMinMaxValueRange();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ double RimStatisticsContourMapProjection::sampleSpacing() const
void RimStatisticsContourMapProjection::clearGridMappingAndRedraw()
{
clearGridMapping();
updateConnectedEditors();
generateResultsIfNecessary( view()->currentTimeStep() );
updateLegend();
updateConnectedEditors();

RimEclipseView* parentView = firstAncestorOrThisOfTypeAsserted<RimEclipseView>();
parentView->scheduleCreateDisplayModelAndRedraw();
Expand Down Expand Up @@ -292,6 +292,8 @@ void RimStatisticsContourMapProjection::defineUiOrdering( QString uiConfigName,
{
uiOrdering.add( &m_statisticsType );

appendValueFilterGroup( uiOrdering );

caf::PdmUiGroup* mainGroup = uiOrdering.addNewGroup( "Projection Settings" );
mainGroup->add( &m_showContourLines );
mainGroup->add( &m_showContourLabels );
Expand Down Expand Up @@ -326,8 +328,7 @@ void RimStatisticsContourMapProjection::fieldChangedByUi( const caf::PdmFieldHan
const QVariant& oldValue,
const QVariant& newValue )
{
if ( ( changedField == &m_statisticsType ) || ( changedField == &m_showContourLines ) || ( changedField == &m_showContourLabels ) ||
( changedField == &m_smoothContourLines ) )
if ( changedField == &m_statisticsType )
{
clearGridMappingAndRedraw();
}
Expand All @@ -336,3 +337,24 @@ void RimStatisticsContourMapProjection::fieldChangedByUi( const caf::PdmFieldHan
RimContourMapProjection::fieldChangedByUi( changedField, oldValue, newValue );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimStatisticsContourMapProjection::gridMappingNeedsUpdating() const
{
if ( !m_contourMapProjection ) return true;

auto cellGridIdxVisibility = m_contourMapProjection->getCellVisibility();
if ( cellGridIdxVisibility.isNull() ) return true;

cvf::ref<cvf::UByteArray> currentVisibility = getCellVisibility();
if ( currentVisibility->size() != cellGridIdxVisibility->size() ) return true;

for ( size_t i = 0; i < currentVisibility->size(); ++i )
{
if ( ( *currentVisibility )[i] != ( *cellGridIdxVisibility )[i] ) return true;
}

return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class RimStatisticsContourMapProjection : public RimContourMapProjection

void updateAfterResultGeneration( int timeStep ) override;

bool gridMappingNeedsUpdating() const override;

protected:
// Framework overrides
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,54 +163,6 @@ void RimStatisticsContourMapView::defineUiTreeOrdering( caf::PdmUiTreeOrdering&
uiTreeOrdering.skipRemainingChildren();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsContourMapView::onUpdateLegends()
{
if ( auto viewer = nativeOrOverrideViewer() )
{
if ( !isUsingOverrideViewer() )
{
viewer->removeAllColorLegends();
}
else if ( cellResult() && cellResult()->legendConfig() )
{
viewer->removeColorLegend( cellResult()->legendConfig()->titledOverlayFrame() );
}

if ( m_contourMapProjection && m_contourMapProjection->isChecked() )
{
RimRegularLegendConfig* projectionLegend = m_contourMapProjection->legendConfig();
if ( projectionLegend )
{
m_contourMapProjection->updateLegend();
if ( projectionLegend->showLegend() )
{
viewer->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame(), isUsingOverrideViewer() );
}
}
}

// Hide the scale widget if any 3D views are present, as the display of the scale widget is only working for
// default rotation. The update is triggered in RimViewLinker::updateScaleWidgetVisibility()

bool any3DViewsLinked = false;

if ( auto viewLinker = assosiatedViewLinker() )
{
auto views = viewLinker->allViews();
for ( auto v : views )
{
if ( dynamic_cast<RimStatisticsContourMapView*>( v ) ) continue;
any3DViewsLinked = true;
}
}

viewer->showScaleLegend( any3DViewsLinked ? false : m_showScaleLegend() );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class RimStatisticsContourMapView : public RimEclipseContourMapView
QString timeStepName( int frameIdx ) const override;
QStringList timeStepStrings() const override;

void onUpdateLegends() override;

private:
caf::PdmPtrField<RimStatisticsContourMap*> m_statisticsContourMap;
};

0 comments on commit 2bcdc62

Please sign in to comment.