From 31a58a213c79458927328f1c2745154340a54eb8 Mon Sep 17 00:00:00 2001 From: rnv Date: Mon, 21 Jul 2014 12:43:39 +0400 Subject: [PATCH] Fix for the "22651: [CEA 1224] suppressed code in Plot 2D" issue. --- src/Plot2d/Plot2d_PlotItems.cxx | 42 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Plot2d/Plot2d_PlotItems.cxx b/src/Plot2d/Plot2d_PlotItems.cxx index a2222caa5..73fd3b40c 100644 --- a/src/Plot2d/Plot2d_PlotItems.cxx +++ b/src/Plot2d/Plot2d_PlotItems.cxx @@ -349,26 +349,28 @@ void Plot2d_QwtPlotCurve::updateLegend( const QwtPlotItem* thePlotItem, QwtPlotCurve::updateLegend( thePlotItem, theLegendData ); - const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) ); - QwtLegend* legend = dynamic_cast( thePlotItem->plot()->legend() ); - QWidget* widget = legend->legendWidget( itemInfo ); - QwtLegendLabel* label = dynamic_cast( widget ); - if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)label ) { - int aMode = Plot2d_QwtLegendLabel::IM_None; - if( myYAxisIdentifierEnabled ) - aMode = myYAxis == QwtPlot::yRight ? - Plot2d_QwtLegendLabel::IM_Right : - Plot2d_QwtLegendLabel::IM_Left; - anItem->setYAxisIdentifierMode( aMode ); - - anItem->setSymbol( legendSymbol() ); - if( Plot2d_Plot2d* plot = dynamic_cast( thePlotItem->plot() ) ) - anItem->setSymbolType( plot->getLegendSymbolType() ); - anItem->setPen( legendPen() ); - - anItem->setSelected( isSelected() ); - anItem->updateHighlit(); - anItem->repaint(); + const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) ); + if( QwtLegend* legend = dynamic_cast( thePlotItem->plot()->legend() ) ) { + if( QWidget* widget = legend->legendWidget( itemInfo ) ) { + QwtLegendLabel* label = dynamic_cast( widget ); + if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)label ) { + int aMode = Plot2d_QwtLegendLabel::IM_None; + if( myYAxisIdentifierEnabled ) + aMode = myYAxis == QwtPlot::yRight ? + Plot2d_QwtLegendLabel::IM_Right : + Plot2d_QwtLegendLabel::IM_Left; + anItem->setYAxisIdentifierMode( aMode ); + + anItem->setSymbol( legendSymbol() ); + if( Plot2d_Plot2d* plot = dynamic_cast( thePlotItem->plot() ) ) + anItem->setSymbolType( plot->getLegendSymbolType() ); + anItem->setPen( legendPen() ); + + anItem->setSelected( isSelected() ); + anItem->updateHighlit(); + anItem->repaint(); + } + } } } -- 2.39.2