Ensure default analysis filter works and changes are propagated properly

This commit is contained in:
Gaute Lindkvist 2020-08-27 14:46:29 +02:00 committed by Magne Sjaastad
parent c5255b4008
commit 3269537f25
7 changed files with 39 additions and 24 deletions

View File

@ -168,7 +168,7 @@ RimAnalysisPlot::RimAnalysisPlot()
m_plotDataFilterCollection = new RimPlotDataFilterCollection; m_plotDataFilterCollection = new RimPlotDataFilterCollection;
connectAxisSignals( m_valueAxisProperties() ); connectAxisSignals( m_valueAxisProperties() );
m_plotDataFilterCollection->filtersChanged.connect( this, &RimAnalysisPlot::onFiltersChanged );
setDeletable( true ); setDeletable( true );
} }
@ -416,7 +416,7 @@ void RimAnalysisPlot::maxMinValueFromAddress( const RifEclipseSummaryAddress&
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimAnalysisPlot::onFiltersChanged() void RimAnalysisPlot::onFiltersChanged( const caf::SignalEmitter* emitter )
{ {
this->loadDataAndUpdate(); this->loadDataAndUpdate();
} }
@ -1082,7 +1082,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
std::map<RimSummaryCase*, double> casesToKeepWithValue; std::map<RimSummaryCase*, double> casesToKeepWithValue;
std::map<RifEclipseSummaryAddress, double> sumItemsToKeepWithValue; std::map<RifEclipseSummaryAddress, double> sumItemsToKeepWithValue;
if ( filter->filterTarget() == RimPlotDataFilterItem::ENSEMBLE_CASE ) if ( filter->filterTarget() == RimPlotDataFilterItem::ENSEMBLE_CASE && !filter->ensembleParameterName().isEmpty() )
{ {
sumItemsToKeep = ( *filteredSummaryItems ); // Not filtering items sumItemsToKeep = ( *filteredSummaryItems ); // Not filtering items

View File

@ -92,8 +92,6 @@ public:
double* min, double* min,
double* max ); double* max );
void onFiltersChanged();
std::vector<time_t> selectedTimeSteps(); std::vector<time_t> selectedTimeSteps();
private: private:
@ -114,6 +112,8 @@ private:
std::set<RimSummaryCase*> timestepDefiningSourceCases(); std::set<RimSummaryCase*> timestepDefiningSourceCases();
std::set<RimSummaryCase*> allSourceCases(); std::set<RimSummaryCase*> allSourceCases();
void onFiltersChanged( const caf::SignalEmitter* emitter );
// RimViewWindow overrides // RimViewWindow overrides
QWidget* viewWidget() override; QWidget* viewWidget() override;

View File

@ -51,11 +51,15 @@ RimAnalysisPlot* RimAnalysisPlotCollection::createAnalysisPlot()
plot->setAsPlotMdiWindow(); plot->setAsPlotMdiWindow();
applyFirstEnsembleFieldAddressesToPlot( plot, "FOPT" ); applyFirstEnsembleFieldAddressesToPlot( plot, "FOPT" );
auto filter = plot->plotDataFilterCollection()->addFilter();
// plot->enableAutoPlotTitle( true ); // plot->enableAutoPlotTitle( true );
m_analysisPlots.push_back( plot ); m_analysisPlots.push_back( plot );
plot->loadDataAndUpdate();
auto filter = plot->plotDataFilterCollection()->addFilter();
filter->updateMaxMinAndDefaultValues( true );
plot->loadDataAndUpdate(); plot->loadDataAndUpdate();
plot->updateConnectedEditors(); plot->updateConnectedEditors();
@ -73,13 +77,15 @@ RimAnalysisPlot* RimAnalysisPlotCollection::createAnalysisPlot( RimSummaryCaseCo
plot->setAsPlotMdiWindow(); plot->setAsPlotMdiWindow();
applyEnsembleFieldAndTimeStepToPlot( plot, ensemble, quantityName.toStdString(), timeStep ); applyEnsembleFieldAndTimeStepToPlot( plot, ensemble, quantityName.toStdString(), timeStep );
auto filter = plot->plotDataFilterCollection()->addFilter();
// plot->enableAutoPlotTitle( true ); // plot->enableAutoPlotTitle( true );
m_analysisPlots.push_back( plot ); m_analysisPlots.push_back( plot );
plot->loadDataAndUpdate(); plot->loadDataAndUpdate();
auto filter = plot->plotDataFilterCollection()->addFilter();
filter->updateMaxMinAndDefaultValues( true ); filter->updateMaxMinAndDefaultValues( true );
plot->loadDataAndUpdate(); plot->loadDataAndUpdate();
plot->updateConnectedEditors(); plot->updateConnectedEditors();

View File

@ -25,6 +25,7 @@ CAF_PDM_SOURCE_INIT( RimPlotDataFilterCollection, "PlotDataFilterCollection" );
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimPlotDataFilterCollection::RimPlotDataFilterCollection() RimPlotDataFilterCollection::RimPlotDataFilterCollection()
: filtersChanged( this )
{ {
CAF_PDM_InitObject( "Plot Data Filters", ":/AnalysisPlotFilter16x16.png", "", "" ); CAF_PDM_InitObject( "Plot Data Filters", ":/AnalysisPlotFilter16x16.png", "", "" );
@ -41,6 +42,12 @@ RimPlotDataFilterItem* RimPlotDataFilterCollection::addFilter()
{ {
auto newFilter = new RimPlotDataFilterItem(); auto newFilter = new RimPlotDataFilterItem();
m_filters.push_back( newFilter ); m_filters.push_back( newFilter );
newFilter->updateMaxMinAndDefaultValues( false );
newFilter->filterChanged.connect( this, &RimPlotDataFilterCollection::onFilterChanged );
filtersChanged.send();
return newFilter; return newFilter;
} }
@ -49,8 +56,12 @@ RimPlotDataFilterItem* RimPlotDataFilterCollection::addFilter()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlotDataFilterCollection::removeFilter( RimPlotDataFilterItem* filter ) void RimPlotDataFilterCollection::removeFilter( RimPlotDataFilterItem* filter )
{ {
filter->filterChanged.disconnect( this );
m_filters.removeChildObject( filter ); m_filters.removeChildObject( filter );
delete filter; delete filter;
filtersChanged.send();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -76,3 +87,8 @@ caf::PdmFieldHandle* RimPlotDataFilterCollection::objectToggleField()
{ {
return &m_isActive; return &m_isActive;
} }
void RimPlotDataFilterCollection::onFilterChanged( const caf::SignalEmitter* emitter )
{
filtersChanged.send();
}

View File

@ -30,6 +30,9 @@ class RimPlotDataFilterCollection : public caf::PdmObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public:
caf::Signal<> filtersChanged;
public: public:
RimPlotDataFilterCollection(); RimPlotDataFilterCollection();
@ -41,6 +44,8 @@ public:
private: private:
caf::PdmFieldHandle* objectToggleField() override; caf::PdmFieldHandle* objectToggleField() override;
void onFilterChanged( const caf::SignalEmitter* emitter );
private: private:
caf::PdmField<bool> m_isActive; caf::PdmField<bool> m_isActive;
caf::PdmChildArrayField<RimPlotDataFilterItem*> m_filters; caf::PdmChildArrayField<RimPlotDataFilterItem*> m_filters;

View File

@ -79,6 +79,7 @@ CAF_PDM_SOURCE_INIT( RimPlotDataFilterItem, "PlotDataFilterItem" );
RimPlotDataFilterItem::RimPlotDataFilterItem() RimPlotDataFilterItem::RimPlotDataFilterItem()
: m_lowerLimit( -std::numeric_limits<double>::infinity() ) : m_lowerLimit( -std::numeric_limits<double>::infinity() )
, m_upperLimit( std::numeric_limits<double>::infinity() ) , m_upperLimit( std::numeric_limits<double>::infinity() )
, filterChanged( this )
{ {
CAF_PDM_InitObject( "Plot Data Filter", ":/AnalysisPlotFilter16x16.png", "", "" ); CAF_PDM_InitObject( "Plot Data Filter", ":/AnalysisPlotFilter16x16.png", "", "" );
@ -223,48 +224,32 @@ void RimPlotDataFilterItem::fieldChangedByUi( const caf::PdmFieldHandle* changed
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) const QVariant& newValue )
{ {
RimAnalysisPlot* parentPlot;
this->firstAncestorOrThisOfTypeAsserted( parentPlot );
if ( changedField == &m_filterTarget ) if ( changedField == &m_filterTarget )
{ {
this->updateMaxMinAndDefaultValues( true ); this->updateMaxMinAndDefaultValues( true );
parentPlot->onFiltersChanged();
} }
else if ( changedField == &m_filterQuantityUiField ) else if ( changedField == &m_filterQuantityUiField )
{ {
m_filterAddress->setAddress( m_filterQuantityUiField ); m_filterAddress->setAddress( m_filterQuantityUiField );
this->updateMaxMinAndDefaultValues( true ); this->updateMaxMinAndDefaultValues( true );
parentPlot->onFiltersChanged();
} }
else if ( changedField == &m_filterEnsembleParameter ) else if ( changedField == &m_filterEnsembleParameter )
{ {
this->updateMaxMinAndDefaultValues( true ); this->updateMaxMinAndDefaultValues( true );
parentPlot->onFiltersChanged();
} }
else if ( changedField == &m_useAbsoluteValue ) else if ( changedField == &m_useAbsoluteValue )
{ {
this->updateMaxMinAndDefaultValues( false ); this->updateMaxMinAndDefaultValues( false );
parentPlot->onFiltersChanged();
} }
else if ( changedField == &m_filterOperation ) else if ( changedField == &m_filterOperation )
{ {
this->updateMaxMinAndDefaultValues( false ); this->updateMaxMinAndDefaultValues( false );
parentPlot->onFiltersChanged();
} }
else if ( changedField == &m_consideredTimestepsType || changedField == &m_explicitlySelectedTimeSteps ) else if ( changedField == &m_consideredTimestepsType || changedField == &m_explicitlySelectedTimeSteps )
{ {
this->updateMaxMinAndDefaultValues( false ); this->updateMaxMinAndDefaultValues( false );
parentPlot->onFiltersChanged();
}
else if ( changedField == &m_isActive )
{
parentPlot->onFiltersChanged();
}
else if ( changedField == &m_min || changedField == &m_max )
{
parentPlot->onFiltersChanged();
} }
filterChanged.send();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -55,6 +55,9 @@ class RimPlotDataFilterItem : public caf::PdmObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public:
caf::Signal<> filterChanged;
public: public:
RimPlotDataFilterItem(); RimPlotDataFilterItem();
~RimPlotDataFilterItem() override; ~RimPlotDataFilterItem() override;