mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Missing legend (#9095)
* Make sure ensemble curveset legends are shown in multiplot legend. * Remove information already shown in title from curve legend. * Fix missing legend when creating curve plot from ensemble curves * Show actual curve color in legend
This commit is contained in:
parent
aeab09eceb
commit
d4ff0a0175
@ -49,6 +49,8 @@ void RicNewSummaryPlotFromCurveFeature::onActionTriggered( bool isChecked )
|
|||||||
auto curveCopy =
|
auto curveCopy =
|
||||||
dynamic_cast<RimSummaryCurve*>( curve->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
dynamic_cast<RimSummaryCurve*>( curve->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||||
|
|
||||||
|
curveCopy->setShowInLegend( true );
|
||||||
|
|
||||||
RimSummaryPlot* plot = RicSummaryPlotBuilder::createPlot( { curveCopy } );
|
RimSummaryPlot* plot = RicSummaryPlotBuilder::createPlot( { curveCopy } );
|
||||||
|
|
||||||
std::vector<RimSummaryPlot*> plots = { plot };
|
std::vector<RimSummaryPlot*> plots = { plot };
|
||||||
|
@ -304,11 +304,6 @@ void RimEnsembleCurveSet::setParentPlotNoReplot( RiuPlotWidget* plot )
|
|||||||
{
|
{
|
||||||
curve->setParentPlotNoReplot( plot );
|
curve->setParentPlotNoReplot( plot );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_plotCurveForLegendText )
|
|
||||||
{
|
|
||||||
m_plotCurveForLegendText = plot->createPlotCurve( nullptr, "", Qt::black );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -338,15 +333,6 @@ void RimEnsembleCurveSet::reattachPlotCurves()
|
|||||||
{
|
{
|
||||||
curve->reattach();
|
curve->reattach();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_plotCurveForLegendText )
|
|
||||||
{
|
|
||||||
m_plotCurveForLegendText->detach();
|
|
||||||
|
|
||||||
RimSummaryPlot* plot = nullptr;
|
|
||||||
firstAncestorOrThisOfType( plot );
|
|
||||||
if ( plot && plot->plotWidget() ) m_plotCurveForLegendText->attachToPlot( plot->plotWidget() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -625,15 +611,6 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
|||||||
|
|
||||||
if ( changedField == &m_showCurves )
|
if ( changedField == &m_showCurves )
|
||||||
{
|
{
|
||||||
if ( !m_showCurves() && m_plotCurveForLegendText )
|
|
||||||
{
|
|
||||||
// Need to detach the legend since the plot type might change from Qwt to QtCharts.
|
|
||||||
// The plot curve for legend text needs to be recreated when curves are shown next time.
|
|
||||||
m_plotCurveForLegendText->detach();
|
|
||||||
delete m_plotCurveForLegendText;
|
|
||||||
m_plotCurveForLegendText = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadDataAndUpdate( true );
|
loadDataAndUpdate( true );
|
||||||
|
|
||||||
updateConnectedEditors();
|
updateConnectedEditors();
|
||||||
@ -1589,6 +1566,11 @@ void RimEnsembleCurveSet::updateCurveColors()
|
|||||||
curvesToColor[i]->updateCurveAppearance();
|
curvesToColor[i]->updateCurveAppearance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_plotCurveForLegendText )
|
||||||
|
{
|
||||||
|
m_plotCurveForLegendText->setColor( RiaColorTools::toQColor( m_color ) );
|
||||||
|
}
|
||||||
|
|
||||||
RimSummaryPlot* plot;
|
RimSummaryPlot* plot;
|
||||||
firstAncestorOrThisOfType( plot );
|
firstAncestorOrThisOfType( plot );
|
||||||
if ( plot && plot->plotWidget() )
|
if ( plot && plot->plotWidget() )
|
||||||
@ -1730,9 +1712,6 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
|
|||||||
newSummaryCurves[i]->updatePlotAxis();
|
newSummaryCurves[i]->updatePlotAxis();
|
||||||
newSummaryCurves[i]->setShowInLegend( false );
|
newSummaryCurves[i]->setShowInLegend( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( plot->plotWidget() && m_plotCurveForLegendText )
|
|
||||||
m_plotCurveForLegendText->attachToPlot( plot->plotWidget() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( plot->plotWidget() )
|
if ( plot->plotWidget() )
|
||||||
@ -1741,6 +1720,14 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
|
|||||||
plot->scheduleReplotIfVisible();
|
plot->scheduleReplotIfVisible();
|
||||||
plot->updateAxes();
|
plot->updateAxes();
|
||||||
plot->updatePlotInfoLabel();
|
plot->updatePlotInfoLabel();
|
||||||
|
|
||||||
|
if ( !m_plotCurveForLegendText )
|
||||||
|
{
|
||||||
|
m_plotCurveForLegendText =
|
||||||
|
plot->plotWidget()->createPlotCurve( nullptr, "", RiaColorTools::toQColor( m_color ) );
|
||||||
|
}
|
||||||
|
m_plotCurveForLegendText->attachToPlot( plot->plotWidget() );
|
||||||
|
updateEnsembleLegendItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateCurveColors();
|
updateCurveColors();
|
||||||
@ -2044,8 +2031,8 @@ QString RimEnsembleCurveSet::createAutoName() const
|
|||||||
RimSummaryPlot* plot = nullptr;
|
RimSummaryPlot* plot = nullptr;
|
||||||
firstAncestorOrThisOfTypeAsserted( plot );
|
firstAncestorOrThisOfTypeAsserted( plot );
|
||||||
|
|
||||||
QString curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(),
|
QString curveSetName =
|
||||||
plot->activePlotTitleHelperAllCurves() );
|
m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), plot->plotTitleHelper() );
|
||||||
if ( curveSetName.isEmpty() )
|
if ( curveSetName.isEmpty() )
|
||||||
{
|
{
|
||||||
curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), nullptr );
|
curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), nullptr );
|
||||||
|
@ -94,6 +94,7 @@ public:
|
|||||||
const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) = 0;
|
const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) = 0;
|
||||||
|
|
||||||
virtual void setBrush( const QBrush& brush ) = 0;
|
virtual void setBrush( const QBrush& brush ) = 0;
|
||||||
|
virtual void setColor( const QColor& color ) = 0;
|
||||||
|
|
||||||
void setBlackAndWhiteLegendIcon( bool blackAndWhite );
|
void setBlackAndWhiteLegendIcon( bool blackAndWhite );
|
||||||
virtual void setVisibleInLegend( bool isVisibleInLegend ) = 0;
|
virtual void setVisibleInLegend( bool isVisibleInLegend ) = 0;
|
||||||
|
@ -164,6 +164,20 @@ void RiuQtChartsPlotCurve::setBrush( const QBrush& brush )
|
|||||||
areaSeries()->setBrush( brush );
|
areaSeries()->setBrush( brush );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuQtChartsPlotCurve::setColor( const QColor& color )
|
||||||
|
{
|
||||||
|
QPen curvePen = lineSeries()->pen();
|
||||||
|
curvePen.setColor( color );
|
||||||
|
lineSeries()->setPen( curvePen );
|
||||||
|
|
||||||
|
curvePen = areaSeries()->pen();
|
||||||
|
curvePen.setColor( color );
|
||||||
|
areaSeries()->setPen( curvePen );
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) override;
|
const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) override;
|
||||||
|
|
||||||
void setBrush( const QBrush& brush ) override;
|
void setBrush( const QBrush& brush ) override;
|
||||||
|
void setColor( const QColor& color ) override;
|
||||||
|
|
||||||
void setLegendIconSize( const QSize& iconSize ) override;
|
void setLegendIconSize( const QSize& iconSize ) override;
|
||||||
QSize legendIconSize() const override;
|
QSize legendIconSize() const override;
|
||||||
|
@ -263,6 +263,16 @@ void RiuQwtPlotCurve::setBrush( const QBrush& brush )
|
|||||||
QwtPlotCurve::setBrush( brush );
|
QwtPlotCurve::setBrush( brush );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuQwtPlotCurve::setColor( const QColor& color )
|
||||||
|
{
|
||||||
|
QPen curvePen = pen();
|
||||||
|
curvePen.setColor( color );
|
||||||
|
setPen( curvePen );
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) override;
|
const QBrush& fillBrush = QBrush( Qt::NoBrush ) ) override;
|
||||||
|
|
||||||
void setBrush( const QBrush& brush ) override;
|
void setBrush( const QBrush& brush ) override;
|
||||||
|
void setColor( const QColor& color ) override;
|
||||||
|
|
||||||
void setLegendIconSize( const QSize& iconSize ) override;
|
void setLegendIconSize( const QSize& iconSize ) override;
|
||||||
QSize legendIconSize() const override;
|
QSize legendIconSize() const override;
|
||||||
|
Loading…
Reference in New Issue
Block a user