mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-07 14:43:10 -06:00
Memory Management : Fixes related to plot objects and curves
This commit is contained in:
parent
47a44a79df
commit
4693dc44ef
@ -131,7 +131,6 @@ RimPlotCurve::~RimPlotCurve()
|
|||||||
{
|
{
|
||||||
if ( m_plotCurve )
|
if ( m_plotCurve )
|
||||||
{
|
{
|
||||||
detach();
|
|
||||||
delete m_plotCurve;
|
delete m_plotCurve;
|
||||||
m_plotCurve = nullptr;
|
m_plotCurve = nullptr;
|
||||||
}
|
}
|
||||||
@ -1017,12 +1016,15 @@ void RimPlotCurve::detach( bool deletePlotCurve )
|
|||||||
{
|
{
|
||||||
if ( m_plotCurve )
|
if ( m_plotCurve )
|
||||||
{
|
{
|
||||||
m_plotCurve->detach();
|
|
||||||
if ( deletePlotCurve )
|
if ( deletePlotCurve )
|
||||||
{
|
{
|
||||||
delete m_plotCurve;
|
delete m_plotCurve;
|
||||||
m_plotCurve = nullptr;
|
m_plotCurve = nullptr;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_plotCurve->detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
replotParentPlot();
|
replotParentPlot();
|
||||||
@ -1033,7 +1035,7 @@ void RimPlotCurve::detach( bool deletePlotCurve )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimPlotCurve::reattach()
|
void RimPlotCurve::reattach()
|
||||||
{
|
{
|
||||||
if ( m_parentPlot ) attach( m_parentPlot );
|
if ( m_parentPlot && canCurveBeAttached() ) attach( m_parentPlot );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -1044,6 +1046,15 @@ bool RimPlotCurve::isSameCurve( const RiuPlotCurve* plotCurve ) const
|
|||||||
return m_plotCurve == plotCurve;
|
return m_plotCurve == plotCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimPlotCurve::deletePlotCurve()
|
||||||
|
{
|
||||||
|
delete m_plotCurve;
|
||||||
|
m_plotCurve = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -126,6 +126,7 @@ public:
|
|||||||
void detach( bool deletePlotCurve = false );
|
void detach( bool deletePlotCurve = false );
|
||||||
void reattach();
|
void reattach();
|
||||||
bool isSameCurve( const RiuPlotCurve* plotCurve ) const;
|
bool isSameCurve( const RiuPlotCurve* plotCurve ) const;
|
||||||
|
void deletePlotCurve();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString createCurveAutoName() = 0;
|
virtual QString createCurveAutoName() = 0;
|
||||||
|
@ -179,7 +179,7 @@ RimSummaryPlot::~RimSummaryPlot()
|
|||||||
{
|
{
|
||||||
removeMdiWindowFromMdiArea();
|
removeMdiWindowFromMdiArea();
|
||||||
|
|
||||||
cleanupBeforeClose();
|
deletePlotCurvesAndPlotWidget();
|
||||||
|
|
||||||
delete m_summaryCurveCollection;
|
delete m_summaryCurveCollection;
|
||||||
delete m_ensembleCurveSetCollection;
|
delete m_ensembleCurveSetCollection;
|
||||||
@ -1378,7 +1378,7 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|||||||
|
|
||||||
// Destroy viewer
|
// Destroy viewer
|
||||||
removeMdiWindowFromMdiArea();
|
removeMdiWindowFromMdiArea();
|
||||||
cleanupBeforeClose();
|
deletePlotCurvesAndPlotWidget();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1401,14 +1401,9 @@ void RimSummaryPlot::childFieldChangedByUi( const caf::PdmFieldHandle* changedCh
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryPlot::updateStackedCurveData()
|
void RimSummaryPlot::updateStackedCurveData()
|
||||||
{
|
{
|
||||||
for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties )
|
auto anyStackedCurvesPresent = updateStackedCurveDataForRelevantAxes();
|
||||||
{
|
|
||||||
if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ||
|
|
||||||
axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT )
|
|
||||||
updateStackedCurveDataForAxis( axisProperties->plotAxisType() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( plotWidget() )
|
if ( plotWidget() && anyStackedCurvesPresent )
|
||||||
{
|
{
|
||||||
reattachAllCurves();
|
reattachAllCurves();
|
||||||
plotWidget()->scheduleReplot();
|
plotWidget()->scheduleReplot();
|
||||||
@ -1418,13 +1413,30 @@ void RimSummaryPlot::updateStackedCurveData()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryPlot::updateStackedCurveDataForAxis( RiuPlotAxis plotAxis )
|
bool RimSummaryPlot::updateStackedCurveDataForRelevantAxes()
|
||||||
{
|
{
|
||||||
std::map<RiaDefines::PhaseType, size_t> curvePhaseCount;
|
bool anyStackedCurvesPresent = false;
|
||||||
|
for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties )
|
||||||
|
{
|
||||||
|
if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT ||
|
||||||
|
axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT )
|
||||||
|
{
|
||||||
|
anyStackedCurvesPresent |= updateStackedCurveDataForAxis( axisProperties->plotAxisType() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return anyStackedCurvesPresent;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimSummaryPlot::updateStackedCurveDataForAxis( RiuPlotAxis plotAxis )
|
||||||
|
{
|
||||||
auto stackedCurves = visibleStackedSummaryCurvesForAxis( plotAxis );
|
auto stackedCurves = visibleStackedSummaryCurvesForAxis( plotAxis );
|
||||||
|
if ( stackedCurves.empty() ) return false;
|
||||||
|
|
||||||
// Reset all curves
|
std::map<RiaDefines::PhaseType, size_t> curvePhaseCount;
|
||||||
for ( RimSummaryCurve* curve : stackedCurves )
|
for ( RimSummaryCurve* curve : stackedCurves )
|
||||||
{
|
{
|
||||||
// Apply a area filled style if it isn't already set
|
// Apply a area filled style if it isn't already set
|
||||||
@ -1473,6 +1485,8 @@ void RimSummaryPlot::updateStackedCurveDataForAxis( RiuPlotAxis plotAxis )
|
|||||||
zPos -= 1.0;
|
zPos -= 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -1595,7 +1609,7 @@ void RimSummaryPlot::updateZoomFromParentPlot()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryPlot::cleanupBeforeClose()
|
void RimSummaryPlot::deletePlotCurvesAndPlotWidget()
|
||||||
{
|
{
|
||||||
if ( isDeletable() )
|
if ( isDeletable() )
|
||||||
{
|
{
|
||||||
@ -1606,6 +1620,8 @@ void RimSummaryPlot::cleanupBeforeClose()
|
|||||||
plotWidget()->setParent( nullptr );
|
plotWidget()->setParent( nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteAllPlotCurves();
|
||||||
|
|
||||||
if ( m_summaryPlot )
|
if ( m_summaryPlot )
|
||||||
{
|
{
|
||||||
m_summaryPlot.reset();
|
m_summaryPlot.reset();
|
||||||
@ -1905,7 +1921,11 @@ void RimSummaryPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( newCurves > 0 ) applyDefaultCurveAppearances();
|
if ( newCurves > 0 )
|
||||||
|
{
|
||||||
|
applyDefaultCurveAppearances();
|
||||||
|
loadDataAndUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
updateConnectedEditors();
|
updateConnectedEditors();
|
||||||
}
|
}
|
||||||
@ -1919,7 +1939,6 @@ void RimSummaryPlot::addNewCurveY( const RifEclipseSummaryAddress& address, RimS
|
|||||||
newCurve->setSummaryCaseY( summaryCase );
|
newCurve->setSummaryCaseY( summaryCase );
|
||||||
newCurve->setSummaryAddressYAndApplyInterpolation( address );
|
newCurve->setSummaryAddressYAndApplyInterpolation( address );
|
||||||
addCurveNoUpdate( newCurve );
|
addCurveNoUpdate( newCurve );
|
||||||
newCurve->loadDataAndUpdate( true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -1996,7 +2015,7 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent
|
|||||||
|
|
||||||
if ( useQtCharts )
|
if ( useQtCharts )
|
||||||
{
|
{
|
||||||
m_summaryPlot = std::make_unique<RiuSummaryQtChartsPlot>( this, mainWindowParent );
|
m_summaryPlot = std::make_unique<RiuSummaryQtChartsPlot>( this );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2044,7 +2063,7 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryPlot::deleteViewWidget()
|
void RimSummaryPlot::deleteViewWidget()
|
||||||
{
|
{
|
||||||
cleanupBeforeClose();
|
deletePlotCurvesAndPlotWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -2190,6 +2209,17 @@ void RimSummaryPlot::detachAllPlotItems()
|
|||||||
m_plotInfoLabel->detach();
|
m_plotInfoLabel->detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryPlot::deleteAllPlotCurves()
|
||||||
|
{
|
||||||
|
for ( auto* c : summaryCurves() )
|
||||||
|
{
|
||||||
|
c->deletePlotCurve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -206,6 +206,7 @@ private:
|
|||||||
void doUpdateLayout() override;
|
void doUpdateLayout() override;
|
||||||
|
|
||||||
void detachAllPlotItems();
|
void detachAllPlotItems();
|
||||||
|
void deleteAllPlotCurves();
|
||||||
|
|
||||||
void handleKeyPressEvent( QKeyEvent* keyEvent ) override;
|
void handleKeyPressEvent( QKeyEvent* keyEvent ) override;
|
||||||
|
|
||||||
@ -223,9 +224,6 @@ protected:
|
|||||||
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
||||||
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
|
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
|
||||||
|
|
||||||
void updateStackedCurveData();
|
|
||||||
void updateStackedCurveDataForAxis( RiuPlotAxis plotAxis );
|
|
||||||
|
|
||||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
void onLoadDataAndUpdate() override;
|
void onLoadDataAndUpdate() override;
|
||||||
@ -249,7 +247,7 @@ private:
|
|||||||
|
|
||||||
void updateTimeAxis( RimSummaryTimeAxisProperties* timeAxisProperties );
|
void updateTimeAxis( RimSummaryTimeAxisProperties* timeAxisProperties );
|
||||||
|
|
||||||
void cleanupBeforeClose();
|
void deletePlotCurvesAndPlotWidget();
|
||||||
|
|
||||||
void connectCurveSignals( RimSummaryCurve* curve );
|
void connectCurveSignals( RimSummaryCurve* curve );
|
||||||
void disconnectCurveSignals( RimSummaryCurve* curve );
|
void disconnectCurveSignals( RimSummaryCurve* curve );
|
||||||
@ -272,6 +270,10 @@ private:
|
|||||||
|
|
||||||
void addNewCurveY( const RifEclipseSummaryAddress& address, RimSummaryCase* summaryCase );
|
void addNewCurveY( const RifEclipseSummaryAddress& address, RimSummaryCase* summaryCase );
|
||||||
|
|
||||||
|
void updateStackedCurveData();
|
||||||
|
bool updateStackedCurveDataForAxis( RiuPlotAxis plotAxis );
|
||||||
|
bool updateStackedCurveDataForRelevantAxes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef USE_QTCHARTS
|
#ifdef USE_QTCHARTS
|
||||||
caf::PdmField<bool> m_useQtChartsPlot;
|
caf::PdmField<bool> m_useQtChartsPlot;
|
||||||
|
@ -54,7 +54,26 @@ RiuQtChartsPlotCurve::RiuQtChartsPlotCurve( RimPlotCurve* ownerRimCurve, const Q
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuQtChartsPlotCurve::~RiuQtChartsPlotCurve()
|
RiuQtChartsPlotCurve::~RiuQtChartsPlotCurve()
|
||||||
{
|
{
|
||||||
detach();
|
if ( m_plotWidget && m_plotWidget->qtChart() )
|
||||||
|
{
|
||||||
|
auto* line = lineSeries();
|
||||||
|
if ( line )
|
||||||
|
{
|
||||||
|
m_plotWidget->qtChart()->removeSeries( line );
|
||||||
|
|
||||||
|
// removeSeries() releases chart ownership of the data, delete data to avoid memory leak
|
||||||
|
delete line;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* scatter = scatterSeries();
|
||||||
|
if ( scatter )
|
||||||
|
{
|
||||||
|
m_plotWidget->qtChart()->removeSeries( scatter );
|
||||||
|
|
||||||
|
// removeSeries() releases chart ownership of the data, delete data to avoid memory leak
|
||||||
|
delete scatter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Delete if it is still owned by by plot curve
|
// Delete if it is still owned by by plot curve
|
||||||
delete m_lineSeries;
|
delete m_lineSeries;
|
||||||
@ -164,8 +183,6 @@ void RiuQtChartsPlotCurve::detach()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( m_plotWidget ) setVisibleInLegend( false );
|
if ( m_plotWidget ) setVisibleInLegend( false );
|
||||||
|
|
||||||
m_plotWidget = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -188,13 +205,15 @@ void RiuQtChartsPlotCurve::setSamplesInPlot( const std::vector<double>& xValues,
|
|||||||
QtCharts::QLineSeries* line = lineSeries();
|
QtCharts::QLineSeries* line = lineSeries();
|
||||||
QtCharts::QScatterSeries* scatter = scatterSeries();
|
QtCharts::QScatterSeries* scatter = scatterSeries();
|
||||||
|
|
||||||
line->clear();
|
QVector<QPointF> values( static_cast<int>( xValues.size() ) );
|
||||||
scatter->clear();
|
|
||||||
for ( int i = 0; i < static_cast<int>( xValues.size() ); i++ )
|
for ( int i = 0; i < static_cast<int>( xValues.size() ); i++ )
|
||||||
{
|
{
|
||||||
line->append( xValues[i], yValues[i] );
|
values[i] = QPointF( xValues[i], yValues[i] );
|
||||||
scatter->append( xValues[i], yValues[i] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
line->replace( values );
|
||||||
|
scatter->replace( values );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -90,7 +90,7 @@ private:
|
|||||||
QtCharts::QLineSeries* m_lineSeries;
|
QtCharts::QLineSeries* m_lineSeries;
|
||||||
QtCharts::QScatterSeries* m_scatterSeries;
|
QtCharts::QScatterSeries* m_scatterSeries;
|
||||||
std::shared_ptr<RiuPlotCurveSymbol> m_symbol;
|
std::shared_ptr<RiuPlotCurveSymbol> m_symbol;
|
||||||
RiuQtChartsPlotWidget* m_plotWidget;
|
QPointer<RiuQtChartsPlotWidget> m_plotWidget;
|
||||||
RiuPlotAxis m_axisX;
|
RiuPlotAxis m_axisX;
|
||||||
RiuPlotAxis m_axisY;
|
RiuPlotAxis m_axisY;
|
||||||
};
|
};
|
||||||
|
@ -717,8 +717,8 @@ RiuQtChartsPlotWidget::AxisScaleType RiuQtChartsPlotWidget::axisScaleType( RiuPl
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQtChartsPlotWidget::setAxisScaleType( RiuPlotAxis axis, RiuQtChartsPlotWidget::AxisScaleType axisScaleType )
|
void RiuQtChartsPlotWidget::setAxisScaleType( RiuPlotAxis axis, RiuQtChartsPlotWidget::AxisScaleType axisScaleType )
|
||||||
{
|
{
|
||||||
QAbstractAxis* removeaxis = plotAxis( axis );
|
QAbstractAxis* axisToBeDeleted = plotAxis( axis );
|
||||||
QAbstractAxis* insertaxis = nullptr;
|
QAbstractAxis* insertaxis = nullptr;
|
||||||
|
|
||||||
if ( axisScaleType == AxisScaleType::LOGARITHMIC )
|
if ( axisScaleType == AxisScaleType::LOGARITHMIC )
|
||||||
{
|
{
|
||||||
@ -734,15 +734,19 @@ void RiuQtChartsPlotWidget::setAxisScaleType( RiuPlotAxis axis, RiuQtChartsPlotW
|
|||||||
}
|
}
|
||||||
|
|
||||||
QChart* chart = qtChart();
|
QChart* chart = qtChart();
|
||||||
if ( chart->axes().contains( removeaxis ) ) chart->removeAxis( removeaxis );
|
if ( chart->axes().contains( axisToBeDeleted ) ) chart->removeAxis( axisToBeDeleted );
|
||||||
chart->addAxis( insertaxis, mapPlotAxisToQtAlignment( axis.axis() ) );
|
chart->addAxis( insertaxis, mapPlotAxisToQtAlignment( axis.axis() ) );
|
||||||
|
|
||||||
m_axes[axis] = insertaxis;
|
m_axes[axis] = insertaxis;
|
||||||
for ( auto serie : chart->series() )
|
for ( auto serie : chart->series() )
|
||||||
{
|
{
|
||||||
if ( serie->attachedAxes().contains( removeaxis ) ) serie->detachAxis( removeaxis );
|
if ( serie->attachedAxes().contains( axisToBeDeleted ) ) serie->detachAxis( axisToBeDeleted );
|
||||||
serie->attachAxis( insertaxis );
|
serie->attachAxis( insertaxis );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We have the ownership of the axis object, delete to avoid memory leak
|
||||||
|
delete axisToBeDeleted;
|
||||||
|
axisToBeDeleted = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -789,8 +793,6 @@ void RiuQtChartsPlotWidget::attach( RiuPlotCurve* plotCurve,
|
|||||||
qtChart()->addSeries( series );
|
qtChart()->addSeries( series );
|
||||||
setXAxis( xAxis, series );
|
setXAxis( xAxis, series );
|
||||||
setXAxis( yAxis, series );
|
setXAxis( yAxis, series );
|
||||||
rescaleAxis( xAxis );
|
|
||||||
rescaleAxis( yAxis );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,12 +63,10 @@ RiuQwtPlotCurve::RiuQwtPlotCurve( RimPlotCurve* ownerRimCurve, const QString& ti
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuQwtPlotCurve::~RiuQwtPlotCurve()
|
RiuQwtPlotCurve::~RiuQwtPlotCurve()
|
||||||
{
|
{
|
||||||
if ( m_qwtCurveErrorBars )
|
detach();
|
||||||
{
|
|
||||||
m_qwtCurveErrorBars->detach();
|
delete m_qwtCurveErrorBars;
|
||||||
delete m_qwtCurveErrorBars;
|
m_qwtCurveErrorBars = nullptr;
|
||||||
m_qwtCurveErrorBars = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -37,8 +37,7 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuSummaryPlot::RiuSummaryPlot( RimSummaryPlot* plot, QWidget* parent )
|
RiuSummaryPlot::RiuSummaryPlot( RimSummaryPlot* plot )
|
||||||
: QWidget( parent )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +53,8 @@ RiuSummaryPlot::~RiuSummaryPlot()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuSummaryPlot::showContextMenu( QPoint pos )
|
void RiuSummaryPlot::showContextMenu( QPoint pos )
|
||||||
{
|
{
|
||||||
|
if ( !plotWidget() ) return;
|
||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ void RiuSummaryPlot::showContextMenu( QPoint pos )
|
|||||||
|
|
||||||
if ( plotCurve && closestCurvePoint >= 0 )
|
if ( plotCurve && closestCurvePoint >= 0 )
|
||||||
{
|
{
|
||||||
RimSummaryCurve* summaryCurve = dynamic_cast<RimSummaryCurve*>( plotCurve->ownerRimCurve() );
|
auto* summaryCurve = dynamic_cast<RimSummaryCurve*>( plotCurve->ownerRimCurve() );
|
||||||
if ( summaryCurve && closestCurvePoint < (int)summaryCurve->timeStepsY().size() )
|
if ( summaryCurve && closestCurvePoint < (int)summaryCurve->timeStepsY().size() )
|
||||||
{
|
{
|
||||||
std::time_t timeStep = summaryCurve->timeStepsY()[closestCurvePoint];
|
std::time_t timeStep = summaryCurve->timeStepsY()[closestCurvePoint];
|
||||||
@ -105,7 +106,7 @@ void RiuSummaryPlot::showContextMenu( QPoint pos )
|
|||||||
|
|
||||||
if ( !curveClicked )
|
if ( !curveClicked )
|
||||||
{
|
{
|
||||||
RimSummaryPlot* summaryPlot = static_cast<RimSummaryPlot*>( plotWidget()->plotDefinition() );
|
auto* summaryPlot = static_cast<RimSummaryPlot*>( plotWidget()->plotDefinition() );
|
||||||
std::vector<RimEnsembleCurveSet*> allCurveSetsInPlot;
|
std::vector<RimEnsembleCurveSet*> allCurveSetsInPlot;
|
||||||
summaryPlot->descendantsOfType( allCurveSetsInPlot );
|
summaryPlot->descendantsOfType( allCurveSetsInPlot );
|
||||||
for ( auto curveSet : allCurveSetsInPlot )
|
for ( auto curveSet : allCurveSetsInPlot )
|
||||||
@ -185,9 +186,9 @@ void RiuSummaryPlot::showContextMenu( QPoint pos )
|
|||||||
|
|
||||||
menuBuilder.appendToMenu( &menu );
|
menuBuilder.appendToMenu( &menu );
|
||||||
|
|
||||||
if ( menu.actions().size() > 0 )
|
if ( !menu.actions().empty() )
|
||||||
{
|
{
|
||||||
menu.exec( mapToGlobal( pos ) );
|
menu.exec( plotWidget()->mapToGlobal( pos ) );
|
||||||
|
|
||||||
// Parts of progress dialog GUI can be present after menu has closed related to
|
// Parts of progress dialog GUI can be present after menu has closed related to
|
||||||
// RicImportGridModelFromSummaryCurveFeature. Make sure the plot is updated, and call processEvents() to make
|
// RicImportGridModelFromSummaryCurveFeature. Make sure the plot is updated, and call processEvents() to make
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "RiaQDateTimeTools.h"
|
#include "RiaQDateTimeTools.h"
|
||||||
#include "RiuInterfaceToViewWindow.h"
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QObject>
|
||||||
|
#include <QPoint>
|
||||||
|
|
||||||
class RimSummaryPlot;
|
class RimSummaryPlot;
|
||||||
class RimPlotAxisPropertiesInterface;
|
class RimPlotAxisPropertiesInterface;
|
||||||
@ -32,12 +32,12 @@ class RiuPlotWidget;
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class RiuSummaryPlot : public QWidget
|
class RiuSummaryPlot : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RiuSummaryPlot( RimSummaryPlot* plot, QWidget* parent );
|
RiuSummaryPlot( RimSummaryPlot* plot );
|
||||||
~RiuSummaryPlot() override;
|
~RiuSummaryPlot();
|
||||||
|
|
||||||
virtual void useDateBasedTimeAxis(
|
virtual void useDateBasedTimeAxis(
|
||||||
const QString& dateFormat,
|
const QString& dateFormat,
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ )
|
RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot )
|
||||||
: RiuSummaryPlot( plot, parent )
|
: RiuSummaryPlot( plot )
|
||||||
{
|
{
|
||||||
m_plotWidget = new RiuQtChartsPlotWidget( plot );
|
m_plotWidget = new RiuQtChartsPlotWidget( plot );
|
||||||
m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu );
|
m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
@ -49,6 +49,8 @@ RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* p
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuSummaryQtChartsPlot::~RiuSummaryQtChartsPlot()
|
RiuSummaryQtChartsPlot::~RiuSummaryQtChartsPlot()
|
||||||
{
|
{
|
||||||
|
delete m_plotWidget;
|
||||||
|
m_plotWidget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -38,7 +38,7 @@ class RiuSummaryQtChartsPlot : public RiuSummaryPlot
|
|||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent = nullptr );
|
RiuSummaryQtChartsPlot( RimSummaryPlot* plot );
|
||||||
~RiuSummaryQtChartsPlot() override;
|
~RiuSummaryQtChartsPlot() override;
|
||||||
|
|
||||||
void useDateBasedTimeAxis( const QString& dateFormat,
|
void useDateBasedTimeAxis( const QString& dateFormat,
|
||||||
|
@ -94,7 +94,7 @@ static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider;
|
|||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ )
|
RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ )
|
||||||
: RiuSummaryPlot( plot, parent )
|
: RiuSummaryPlot( plot )
|
||||||
{
|
{
|
||||||
m_plotWidget = new RiuQwtPlotWidget( plot, parent );
|
m_plotWidget = new RiuQwtPlotWidget( plot, parent );
|
||||||
m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu );
|
m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
@ -138,6 +138,8 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*=
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuSummaryQwtPlot::~RiuSummaryQwtPlot()
|
RiuSummaryQwtPlot::~RiuSummaryQwtPlot()
|
||||||
{
|
{
|
||||||
|
delete m_plotWidget;
|
||||||
|
m_plotWidget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -45,7 +45,7 @@ class RiuSummaryQwtPlot : public RiuSummaryPlot
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent = nullptr );
|
RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent = nullptr );
|
||||||
~RiuSummaryQwtPlot() override;
|
~RiuSummaryQwtPlot();
|
||||||
|
|
||||||
void useDateBasedTimeAxis( const QString& dateFormat,
|
void useDateBasedTimeAxis( const QString& dateFormat,
|
||||||
const QString& timeFormat,
|
const QString& timeFormat,
|
||||||
|
Loading…
Reference in New Issue
Block a user