Salome HOME
INT PAL 0052942: Error of geompy.MakeCurveParametric() is printed to a terminal inste...
[modules/gui.git] / src / Plot2d / Plot2d_PlotItems.cxx
index a2222caa553ce03cfc55d44cd2c3ead0d106032c..2bd9903640136c2dcae48741eacd035400733531 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -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<QwtLegend*>( thePlotItem->plot()->legend() );
-  QWidget* widget = legend->legendWidget( itemInfo );
-  QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( 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<Plot2d_Plot2d*>( 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<QwtLegend*>( thePlotItem->plot()->legend() ) ) {
+    if( QWidget* widget = legend->legendWidget( itemInfo ) ) {
+      QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( 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<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+         anItem->setSymbolType( plot->getLegendSymbolType() );
+       anItem->setPen( legendPen() );
+       
+       anItem->setSelected( isSelected() );
+       anItem->updateHighlit();
+       anItem->repaint();
+      }
+    }
   }
 }