mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8461 from OPM/8460-plot-curve-fixes
Guard access to QtCharts objects that might be null Fix visibility of items in legend based on state in parent plot
This commit is contained in:
@@ -982,11 +982,13 @@ void RimPlotCurve::setParentPlotNoReplot( RiuPlotWidget* plotWidget )
|
||||
if ( !plotWidget ) return;
|
||||
|
||||
m_parentPlot = plotWidget;
|
||||
if ( !m_plotCurve )
|
||||
if ( m_plotCurve )
|
||||
{
|
||||
m_plotCurve = m_parentPlot->createPlotCurve( this, "", RiaColorTools::toQColor( m_curveAppearance->color() ) );
|
||||
m_plotCurve->attachToPlot( plotWidget );
|
||||
return;
|
||||
}
|
||||
|
||||
m_plotCurve = m_parentPlot->createPlotCurve( this, "", RiaColorTools::toQColor( m_curveAppearance->color() ) );
|
||||
m_plotCurve->attachToPlot( plotWidget );
|
||||
}
|
||||
|
||||
|
||||
@@ -500,10 +500,12 @@ QString RimSummaryCurve::createCurveAutoName()
|
||||
std::vector<const RimSummaryNameHelper*> nameHelpers;
|
||||
{
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted( plot );
|
||||
auto nameHelper = plot->plotTitleHelper();
|
||||
|
||||
if ( nameHelper ) nameHelpers.push_back( nameHelper );
|
||||
firstAncestorOrThisOfType( plot );
|
||||
if ( plot )
|
||||
{
|
||||
auto nameHelper = plot->plotTitleHelper();
|
||||
if ( nameHelper ) nameHelpers.push_back( nameHelper );
|
||||
}
|
||||
}
|
||||
{
|
||||
RimSummaryMultiPlot* summaryMultiPlot = nullptr;
|
||||
|
||||
@@ -151,7 +151,7 @@ void RimSummaryCurveCollection::reattachPlotCurves()
|
||||
{
|
||||
for ( RimSummaryCurve* curve : m_curves )
|
||||
{
|
||||
curve->reattach();
|
||||
if ( curve->isCurveVisible() ) curve->reattach();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -761,6 +761,11 @@ void RimSummaryPlot::updateLegend()
|
||||
if ( plotWidget() )
|
||||
{
|
||||
plotWidget()->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
|
||||
|
||||
for ( auto c : summaryCurves() )
|
||||
{
|
||||
c->updateLegendEntryVisibilityNoPlotUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
reattachAllCurves();
|
||||
@@ -1525,6 +1530,8 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
}
|
||||
}
|
||||
|
||||
if ( changedField == &m_showPlotLegends ) updateLegend();
|
||||
|
||||
#ifdef USE_QTCHARTS
|
||||
if ( changedField == &m_useQtChartsPlot )
|
||||
{
|
||||
@@ -2172,7 +2179,7 @@ void RimSummaryPlot::updateCurveNames()
|
||||
{
|
||||
for ( auto c : summaryCurves() )
|
||||
{
|
||||
c->updateCurveNameNoLegendUpdate();
|
||||
if ( c->isCurveVisible() ) c->updateCurveNameNoLegendUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user