mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Support stacked curves for Summary Plots
This commit is contained in:
parent
82a96a1866
commit
908dcd6828
@ -375,6 +375,17 @@ double RimSummaryCurve::yValueAtTimeT( time_t time ) const
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurve::setOverrideCurveDataY( const std::vector<time_t>& dateTimes, const std::vector<double>& yValues )
|
||||
{
|
||||
if ( m_qwtPlotCurve )
|
||||
{
|
||||
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, true );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
RiaDefines::PlotAxis axisY() const;
|
||||
const std::vector<time_t>& timeStepsY() const;
|
||||
double yValueAtTimeT( time_t time ) const;
|
||||
void setOverrideCurveDataY( const std::vector<time_t>& xValues, const std::vector<double>& yValues );
|
||||
|
||||
// X Axis functions
|
||||
void setSummaryCaseX( RimSummaryCase* sumCase );
|
||||
|
@ -1142,7 +1142,7 @@ void RimSummaryPlot::addCurveAndUpdate( RimSummaryCurve* curve )
|
||||
if ( curve )
|
||||
{
|
||||
m_summaryCurveCollection->addCurve( curve );
|
||||
|
||||
connectCurveSignals( curve );
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
curve->setParentQwtPlotAndReplot( m_plotWidget );
|
||||
@ -1159,7 +1159,7 @@ void RimSummaryPlot::addCurveNoUpdate( RimSummaryCurve* curve )
|
||||
if ( curve )
|
||||
{
|
||||
m_summaryCurveCollection->addCurve( curve );
|
||||
|
||||
connectCurveSignals( curve );
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
curve->setParentQwtPlotNoReplot( m_plotWidget );
|
||||
@ -1189,6 +1189,7 @@ void RimSummaryPlot::deleteCurves( const std::vector<RimSummaryCurve*>& curves )
|
||||
if ( c == curve )
|
||||
{
|
||||
m_summaryCurveCollection->deleteCurve( curve );
|
||||
disconnectCurveSignals( curve );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1358,6 +1359,12 @@ void RimSummaryPlot::updateStackedCurveDataForAxis( RiaDefines::PlotAxis plotAxi
|
||||
// Reset all curves
|
||||
for ( RimSummaryCurve* curve : visibleSummaryCurvesForAxis( plotAxis ) )
|
||||
{
|
||||
// Apply a area filled style if it isn't already set
|
||||
if ( curve->fillStyle() == Qt::NoBrush )
|
||||
{
|
||||
curve->setFillStyle( Qt::SolidPattern );
|
||||
}
|
||||
|
||||
curve->loadDataAndUpdate( false );
|
||||
}
|
||||
|
||||
@ -1387,16 +1394,15 @@ void RimSummaryPlot::updateStackedCurveDataForAxis( RiaDefines::PlotAxis plotAxi
|
||||
}
|
||||
}
|
||||
|
||||
// Apply a area filled style if it isn't already set
|
||||
if ( curve->fillStyle() == Qt::NoBrush )
|
||||
{
|
||||
curve->setFillStyle( Qt::SolidPattern );
|
||||
}
|
||||
// curve->setOverrideCurveDataY( allTimeSteps, allStackedValues );
|
||||
curve->setOverrideCurveDataY( allTimeSteps, allStackedValues );
|
||||
curve->setZOrder( zPos );
|
||||
zPos -= 1.0;
|
||||
}
|
||||
}
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
m_plotWidget->scheduleReplot();
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -1554,6 +1560,10 @@ std::set<RimPlotAxisPropertiesInterface*> RimSummaryPlot::allPlotAxes() const
|
||||
void RimSummaryPlot::cleanupBeforeClose()
|
||||
{
|
||||
detachAllPlotItems();
|
||||
for ( auto curve : summaryCurves() )
|
||||
{
|
||||
disconnectCurveSignals( curve );
|
||||
}
|
||||
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
@ -1563,6 +1573,53 @@ void RimSummaryPlot::cleanupBeforeClose()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::connectCurveSignals( RimSummaryCurve* curve )
|
||||
{
|
||||
curve->dataChanged.connect( this, &RimSummaryPlot::curveDataChanged );
|
||||
curve->visibilityChanged.connect( this, &RimSummaryPlot::curveVisibilityChanged );
|
||||
curve->appearanceChanged.connect( this, &RimSummaryPlot::curveAppearanceChanged );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::disconnectCurveSignals( RimSummaryCurve* curve )
|
||||
{
|
||||
curve->dataChanged.disconnect( this );
|
||||
curve->visibilityChanged.disconnect( this );
|
||||
curve->appearanceChanged.disconnect( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::curveDataChanged( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
updateStackedCurveData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::curveVisibilityChanged( const caf::SignalEmitter* emitter, bool visible )
|
||||
{
|
||||
updateStackedCurveData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::curveAppearanceChanged( const caf::SignalEmitter* emitter )
|
||||
{
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
m_plotWidget->scheduleReplot();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1754,6 +1811,13 @@ void RimSummaryPlot::initAfterRead()
|
||||
setAutoScaleYEnabled( false );
|
||||
}
|
||||
|
||||
for ( auto curve : summaryCurves() )
|
||||
{
|
||||
connectCurveSignals( curve );
|
||||
}
|
||||
|
||||
updateStackedCurveData();
|
||||
|
||||
RimProject* proj = nullptr;
|
||||
this->firstAncestorOrThisOfType( proj );
|
||||
if ( proj )
|
||||
|
@ -226,6 +226,13 @@ private:
|
||||
|
||||
void cleanupBeforeClose();
|
||||
|
||||
void connectCurveSignals( RimSummaryCurve* curve );
|
||||
void disconnectCurveSignals( RimSummaryCurve* curve );
|
||||
|
||||
void curveDataChanged( const caf::SignalEmitter* emitter );
|
||||
void curveVisibilityChanged( const caf::SignalEmitter* emitter, bool visible );
|
||||
void curveAppearanceChanged( const caf::SignalEmitter* emitter );
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_normalizeCurveYValues;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user