Merge pull request #8882 from OPM/append_curves

Summary Multiplot: Source Stepping append curves with performance fixes
This commit is contained in:
jonjenssen
2022-05-04 13:11:04 +02:00
committed by GitHub
parent bb6ca0848d
commit 296ddbde42
20 changed files with 349 additions and 73 deletions

View File

@@ -131,6 +131,16 @@ RimSummaryMultiPlot::RimSummaryMultiPlot()
m_appendPrevPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_appendPrevPlot.uiCapability()->setUiIconFromResourceString( ":/AppendPrev.png" );
CAF_PDM_InitField( &m_appendNextCurve, "AppendNextCurve", false, "", "", "Step Next and Add Curve to Plot" );
m_appendNextCurve.xmlCapability()->disableIO();
m_appendNextCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_appendNextCurve.uiCapability()->setUiIconFromResourceString( ":/AppendNextCurve.png" );
CAF_PDM_InitField( &m_appendPrevCurve, "AppendPrevCurve", false, "", "", "Step Previous and Add Curve to Plot" );
m_appendPrevCurve.xmlCapability()->disableIO();
m_appendPrevCurve.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_appendPrevCurve.uiCapability()->setUiIconFromResourceString( ":/AppendPrevCurve.png" );
CAF_PDM_InitField( &m_linkSubPlotAxes, "LinkSubPlotAxes", true, "Link Sub Plot Axes" );
CAF_PDM_InitField( &m_autoAdjustAppearance, "AutoAdjustAppearance", false, "Auto Adjust Appearance" );
@@ -408,6 +418,18 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
int stepDirection = -1;
appendSubPlotByStepping( stepDirection );
}
else if ( changedField == &m_appendNextCurve )
{
m_appendNextCurve = false;
int stepDirection = 1;
appendCurveByStepping( stepDirection );
}
else if ( changedField == &m_appendPrevCurve )
{
m_appendPrevCurve = false;
int stepDirection = -1;
appendCurveByStepping( stepDirection );
}
else if ( changedField == &m_autoAdjustAppearance )
{
checkAndApplyAutoAppearance();
@@ -526,6 +548,9 @@ std::vector<caf::PdmFieldHandle*> RimSummaryMultiPlot::fieldsToShowInToolbar()
toolBarFields.push_back( &m_appendPrevPlot );
toolBarFields.push_back( &m_appendNextPlot );
toolBarFields.push_back( &m_appendPrevCurve );
toolBarFields.push_back( &m_appendNextCurve );
auto multiFields = RimMultiPlot::fieldsToShowInToolbar();
toolBarFields.insert( std::end( toolBarFields ), std::begin( multiFields ), std::end( multiFields ) );
@@ -1069,6 +1094,44 @@ void RimSummaryMultiPlot::appendSubPlotByStepping( int direction )
RiuPlotMainWindowTools::refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryMultiPlot::appendCurveByStepping( int direction )
{
for ( auto plot : summaryPlots() )
{
std::vector<caf::PdmObjectHandle*> addresses;
for ( auto curve : plot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) )
{
auto address = curve->summaryAddressY();
auto sumCase = curve->summaryCaseY();
address = m_sourceStepping->stepAddress( address, direction );
addresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, sumCase->caseId() ) );
}
for ( auto curveSet : plot->curveSets() )
{
auto address = curveSet->summaryAddress();
auto sumEns = curveSet->summaryCaseCollection();
address = m_sourceStepping->stepAddress( address, direction );
addresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, -1, sumEns->ensembleId() ) );
}
plot->handleDroppedObjects( addresses );
for ( auto adr : addresses )
{
delete adr;
}
}
m_sourceStepping->updateStepIndex( direction );
RiuPlotMainWindowTools::refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -79,6 +79,7 @@ public:
void removePlotNoUpdate( RimPlot* plot ) override;
void updateAfterPlotRemove() override;
void updatePlotWindowTitle() override;
std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar() override;
@@ -118,13 +119,13 @@ private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void populateNameHelper( RimSummaryPlotNameHelper* nameHelper );
void updatePlotWindowTitle() override;
void computeAggregatedAxisRange();
void updateSourceStepper();
void duplicate();
void appendSubPlotByStepping( int direction );
void appendCurveByStepping( int direction );
void analyzePlotsAndAdjustAppearanceSettings();
@@ -142,6 +143,9 @@ private:
caf::PdmField<bool> m_appendNextPlot;
caf::PdmField<bool> m_appendPrevPlot;
caf::PdmField<bool> m_appendNextCurve;
caf::PdmField<bool> m_appendPrevCurve;
caf::PdmField<caf::AppEnum<AxisRangeAggregation>> m_axisRangeAggregation;
caf::PdmChildField<RimSummaryPlotSourceStepping*> m_sourceStepping;

View File

@@ -2043,20 +2043,60 @@ std::pair<int, std::vector<RimSummaryCurve*>> RimSummaryPlot::handleSummaryAddre
if ( summaryAddr->isEnsemble() )
{
std::map<RifEclipseSummaryAddress, std::set<RimSummaryCaseCollection*>> dataVectorMap;
for ( auto& curve : curveSets() )
{
const auto curveAddress = curve->summaryAddress();
dataVectorMap[curveAddress].insert( curve->summaryCaseCollection() );
}
auto ensemble = RiaSummaryTools::ensembleById( summaryAddr->ensembleId() );
if ( ensemble )
{
addNewEnsembleCurveY( summaryAddr->address(), ensemble );
newCurves++;
RifEclipseSummaryAddress droppedAddress = summaryAddr->address();
bool skipAddress = false;
if ( dataVectorMap.count( droppedAddress ) > 0 )
{
skipAddress = ( dataVectorMap[droppedAddress].count( ensemble ) > 0 );
}
if ( !skipAddress )
{
addNewEnsembleCurveY( droppedAddress, ensemble );
newCurves++;
}
}
}
else
{
std::map<RifEclipseSummaryAddress, std::set<RimSummaryCase*>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
dataVectorMap[curveAddress].insert( curve->summaryCaseY() );
}
auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAddr->caseId() );
if ( summaryCase )
{
curves.push_back( addNewCurveY( summaryAddr->address(), summaryCase ) );
newCurves++;
RifEclipseSummaryAddress droppedAddress = summaryAddr->address();
bool skipAddress = false;
if ( dataVectorMap.count( droppedAddress ) > 0 )
{
skipAddress = ( dataVectorMap[droppedAddress].count( summaryCase ) > 0 );
}
if ( !skipAddress )
{
curves.push_back( addNewCurveY( droppedAddress, summaryCase ) );
newCurves++;
}
}
}
return { newCurves, curves };

View File

@@ -516,6 +516,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
if ( summaryMultiPlot )
{
summaryMultiPlot->updatePlots();
summaryMultiPlot->updatePlotWindowTitle();
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateMultiPlotToolBar();
}
@@ -883,11 +884,11 @@ bool RimSummaryPlotSourceStepping::isYAxisStepping() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlotSourceStepping::modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset )
void RimSummaryPlotSourceStepping::modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset, bool notifyChange )
{
bool useOptionsOnly;
QList<caf::PdmOptionItemInfo> options = calculateValueOptions( valueField, &useOptionsOnly );
RimDataSourceSteppingTools::modifyCurrentIndex( valueField, options, indexOffset );
RimDataSourceSteppingTools::modifyCurrentIndex( valueField, options, indexOffset, notifyChange );
}
//--------------------------------------------------------------------------------------------------
@@ -1285,3 +1286,15 @@ RimSummaryCaseCollection* RimSummaryPlotSourceStepping::stepEnsemble( int direct
return m_ensemble;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlotSourceStepping::updateStepIndex( int direction )
{
caf::PdmValueField* valueField = fieldToModify();
if ( !valueField ) return;
bool notifyChange = false;
modifyCurrentIndex( valueField, direction, notifyChange );
}

View File

@@ -75,6 +75,8 @@ public:
RimSummaryPlotSourceStepping::SourceSteppingDimension stepDimension() const;
void updateStepIndex( int direction );
private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
@@ -102,7 +104,7 @@ private:
bool isXAxisStepping() const;
bool isYAxisStepping() const;
void modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset );
void modifyCurrentIndex( caf::PdmValueField* valueField, int indexOffset, bool notifyChange = true );
std::vector<RimSummaryCase*> summaryCasesForSourceStepping();