mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 07:30:20 -05:00
Fix filter and improve Analysis Plot
* Use button and label without field backing * Use childFieldChangedByUi instead of signal * Select ensemble instead of all realizations in an ensemble
This commit is contained in:
1 parent
47fd2e375c
commit
5a9cb13916
7 files changed
+111
-84
No files matched your search
@@ -53,6 +53,7 @@
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiActionPushButtonEditor.h"
|
||||
#include "cafPdmUiButton.h"
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiGroup.h"
|
||||
@@ -98,16 +99,6 @@ RimAnalysisPlot::RimAnalysisPlot()
|
||||
{
|
||||
CAF_PDM_InitObject( "Analysis Plot", ":/AnalysisPlot16x16.png" );
|
||||
|
||||
// Variable selection
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectedVarsUiField, "selectedVarsUiField", "Selected Vectors" );
|
||||
m_selectedVarsUiField.xmlCapability()->disableIO();
|
||||
m_selectedVarsUiField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
m_selectedVarsUiField.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitField( &m_selectVariablesButtonField, "BrowseButton", false, "..." );
|
||||
caf::PdmUiActionPushButtonEditor::configureEditorForField( &m_selectVariablesButtonField );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_analysisPlotDataSelection, "AnalysisPlotData", "" );
|
||||
m_analysisPlotDataSelection.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
|
||||
@@ -261,12 +252,11 @@ std::set<RifEclipseSummaryAddress> RimAnalysisPlot::unfilteredAddresses() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RigEnsembleParameter> RimAnalysisPlot::ensembleParameters() const
|
||||
{
|
||||
std::set<RigEnsembleParameter> ensembleParms;
|
||||
|
||||
RiaSummaryCurveDefinitionAnalyser* analyserOfSelectedCurveDefs = updateAndGetCurveAnalyzer();
|
||||
|
||||
std::set<RimSummaryEnsemble*> ensembles;
|
||||
|
||||
// If present, add the ensemble for single summary cases
|
||||
for ( RimSummaryCase* sumCase : analyserOfSelectedCurveDefs->m_singleSummaryCases )
|
||||
{
|
||||
if ( sumCase->ensemble() )
|
||||
@@ -275,7 +265,14 @@ std::set<RigEnsembleParameter> RimAnalysisPlot::ensembleParameters() const
|
||||
}
|
||||
}
|
||||
|
||||
for ( RimSummaryEnsemble* ensemble : ensembles )
|
||||
// Add ensembles from the analyzer
|
||||
for ( auto ensemble : analyserOfSelectedCurveDefs->m_ensembles )
|
||||
{
|
||||
ensembles.insert( ensemble );
|
||||
}
|
||||
|
||||
std::set<RigEnsembleParameter> ensembleParms;
|
||||
for ( auto ensemble : ensembles )
|
||||
{
|
||||
std::vector<RigEnsembleParameter> parameters = ensemble->variationSortedEnsembleParameters();
|
||||
ensembleParms.insert( parameters.begin(), parameters.end() );
|
||||
@@ -442,6 +439,34 @@ std::vector<time_t> RimAnalysisPlot::selectedTimeSteps() const
|
||||
return selectedTimeTTimeSteps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnalysisPlot::showSelectVariablesDialog()
|
||||
{
|
||||
RiuSummaryVectorSelectionDialog dlg( nullptr );
|
||||
|
||||
dlg.enableMultiSelect( true );
|
||||
dlg.enableIndividualEnsembleCaseSelection( true );
|
||||
dlg.setCurveSelection( curveDefinitions() );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
std::vector<RiaSummaryCurveDefinition> summaryVectorDefinitions = dlg.curveSelection();
|
||||
|
||||
m_analysisPlotDataSelection.deleteChildren();
|
||||
for ( const RiaSummaryCurveDefinition& vectorDef : summaryVectorDefinitions )
|
||||
{
|
||||
auto dataEntry = new RimAnalysisPlotDataEntry();
|
||||
dataEntry->setFromCurveDefinition( vectorDef );
|
||||
m_analysisPlotDataSelection.push_back( dataEntry );
|
||||
}
|
||||
connectAllCaseSignals();
|
||||
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -449,33 +474,7 @@ void RimAnalysisPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
{
|
||||
RimPlot::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
|
||||
if ( changedField == &m_selectVariablesButtonField )
|
||||
{
|
||||
// Do select variables
|
||||
RiuSummaryVectorSelectionDialog dlg( nullptr );
|
||||
|
||||
dlg.enableMultiSelect( true );
|
||||
dlg.enableIndividualEnsembleCaseSelection( true );
|
||||
dlg.hideEnsembles();
|
||||
dlg.setCurveSelection( curveDefinitions() );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
std::vector<RiaSummaryCurveDefinition> summaryVectorDefinitions = dlg.curveSelection();
|
||||
|
||||
m_analysisPlotDataSelection.deleteChildren();
|
||||
for ( const RiaSummaryCurveDefinition& vectorDef : summaryVectorDefinitions )
|
||||
{
|
||||
auto dataEntry = new RimAnalysisPlotDataEntry();
|
||||
dataEntry->setFromCurveDefinition( vectorDef );
|
||||
m_analysisPlotDataSelection.push_back( dataEntry );
|
||||
}
|
||||
connectAllCaseSignals();
|
||||
}
|
||||
|
||||
m_selectVariablesButtonField = false;
|
||||
}
|
||||
else if ( changedField == &m_timeStepFilter )
|
||||
if ( changedField == &m_timeStepFilter )
|
||||
{
|
||||
m_selectedTimeSteps.v().clear();
|
||||
|
||||
@@ -490,33 +489,40 @@ void RimAnalysisPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnalysisPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
caf::PdmUiGroup* selVectorsGrp = uiOrdering.addNewGroup( "Selected Vectors" );
|
||||
selVectorsGrp->add( &m_selectedVarsUiField );
|
||||
selVectorsGrp->appendToRow( &m_selectVariablesButtonField );
|
||||
selVectorsGrp->add( &m_referenceCase, { .newRow = true, .totalColumnSpan = 3, .leftLabelColumnSpan = 2 } );
|
||||
|
||||
QString vectorNames;
|
||||
if ( updateAndGetCurveAnalyzer() )
|
||||
auto createLabelText = [this]() -> QString
|
||||
{
|
||||
for ( const std::string& vectorName : updateAndGetCurveAnalyzer()->m_vectorNames )
|
||||
QString vectorNames;
|
||||
if ( updateAndGetCurveAnalyzer() )
|
||||
{
|
||||
vectorNames += QString::fromStdString( vectorName ) + ", ";
|
||||
for ( const std::string& vectorName : updateAndGetCurveAnalyzer()->m_vectorNames )
|
||||
{
|
||||
vectorNames += QString::fromStdString( vectorName ) + ", ";
|
||||
}
|
||||
|
||||
if ( !vectorNames.isEmpty() )
|
||||
{
|
||||
vectorNames.chop( 2 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !vectorNames.isEmpty() )
|
||||
{
|
||||
vectorNames.chop( 2 );
|
||||
return vectorNames;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Select Data Sources -->";
|
||||
}
|
||||
};
|
||||
|
||||
if ( !vectorNames.isEmpty() )
|
||||
{
|
||||
m_selectedVarsUiField = vectorNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedVarsUiField = "Select Data Sources -->";
|
||||
}
|
||||
caf::PdmUiGroup* selVectorsGrp = uiOrdering.addNewGroup( "Selected Vectors" );
|
||||
selVectorsGrp->addNewLabel( createLabelText(), { .newRow = false, .totalColumnSpan = 4 } );
|
||||
auto showVectorSelection = selVectorsGrp->addNewButton( "...",
|
||||
[this]() { RimAnalysisPlot::showSelectVariablesDialog(); },
|
||||
{ .newRow = false, .totalColumnSpan = 1 } );
|
||||
showVectorSelection->setAlignment( Qt::AlignRight );
|
||||
|
||||
selVectorsGrp->add( &m_referenceCase );
|
||||
|
||||
caf::PdmUiGroup* timeStepGrp = uiOrdering.addNewGroup( "Time Steps" );
|
||||
timeStepGrp->add( &m_timeStepFilter );
|
||||
@@ -1034,7 +1040,7 @@ std::vector<size_t> RimAnalysisPlot::findTimestepIndices( std::vector<time_t> se
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RiaSummaryCurveDefinition> RimAnalysisPlot::filteredCurveDefs() const
|
||||
{
|
||||
std::vector<RiaSummaryCurveDefinition> dataDefinitions = curveDefinitions();
|
||||
std::vector<RiaSummaryCurveDefinition> dataDefinitions = curveDefinitionsExpanded();
|
||||
|
||||
// Split out the filter targets
|
||||
|
||||
@@ -1649,6 +1655,34 @@ std::vector<RiaSummaryCurveDefinition> RimAnalysisPlot::curveDefinitions() const
|
||||
return curveDefs;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RiaSummaryCurveDefinition> RimAnalysisPlot::curveDefinitionsExpanded() const
|
||||
{
|
||||
std::vector<RiaSummaryCurveDefinition> curveDefs;
|
||||
for ( const auto& dataEntry : m_analysisPlotDataSelection )
|
||||
{
|
||||
auto curveDef = dataEntry->curveDefinition();
|
||||
if ( curveDef.summaryCaseY() )
|
||||
{
|
||||
curveDefs.push_back( curveDef );
|
||||
}
|
||||
else if ( curveDef.ensemble() )
|
||||
{
|
||||
// Expand ensemble curves to individual summary cases
|
||||
RimSummaryEnsemble* ensemble = curveDef.ensemble();
|
||||
for ( RimSummaryCase* sumCase : ensemble->allSummaryCases() )
|
||||
{
|
||||
RiaSummaryCurveDefinition expandedCurveDef( sumCase, curveDef.summaryAddressY(), ensemble );
|
||||
curveDefs.push_back( expandedCurveDef );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return curveDefs;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user