Salome HOME
Copyright update 2022
[modules/gui.git] / src / Plot2d / Plot2d_ViewFrame.cxx
old mode 100755 (executable)
new mode 100644 (file)
index f92e2b2..6046482
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  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
 #include <qwt_scale_engine.h>
 #include <qwt_plot_zoomer.h>
 #include <qwt_curve_fitter.h>
+#include <qwt_plot_renderer.h>
+#include <qwt_legend.h>
+#include <qwt_scale_widget.h>
 
 #include <stdlib.h>
 #include <limits>
-#include <qprinter.h>
-
-#include <qwt_legend.h>
-#include <qwt_scale_widget.h>
 
 #define DEFAULT_LINE_WIDTH     0     // (default) line width
 #define DEFAULT_MARKER_SIZE    9     // default marker size
@@ -181,10 +180,11 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
      : QWidget (parent, 0),
        myOperation( NoOpId ),
        myCurveType( 1 ),
-       myShowLegend( true ), myLegendPos( 1 ), myLegendFont("Helvetic",12),
-       myLegendColor(Qt::black),
+       myShowLegend( true ), myLegendPos( 1 ), myLegendSymbolType( 0 ), myLegendFont("Helvetic",12),
+       myLegendColor(Qt::black), mySelectedLegendFontColor( Qt::darkBlue ),
        myMarkerSize( DEFAULT_MARKER_SIZE ),
        myBackground( Qt::white ),
+       mySelectionColor( Qt::gray ),
        myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ),
        myTitleEnabled( true ), myXTitleEnabled( true ),
        myYTitleEnabled( true ), myY2TitleEnabled (true),
@@ -206,18 +206,6 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
 
   aLayout->addWidget( myPlot );
 
-  //  createActions();
-  connect( myPlot, SIGNAL( legendClicked( QwtPlotItem* ) ),
-           this, SIGNAL( legendClicked( QwtPlotItem* ) ) );
-
-  // IPAL 21465
-  /*  connect( myPlot->axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ),
-           myPlot, SLOT( onScaleDivChanged() ) );
-  connect( myPlot->axisWidget( QwtPlot::yLeft ), SIGNAL( scaleDivChanged() ),
-           myPlot, SLOT( onScaleDivChanged() ) );
-  if (mySecondY)
-    connect( myPlot->axisWidget( QwtPlot::yRight ), SIGNAL( scaleDivChanged() ),
-    myPlot, SLOT( onScaleDivChanged() ) );*/
 #ifndef NO_SUIT
   Init();
 #endif
@@ -236,7 +224,6 @@ void Plot2d_ViewFrame::Init()
   /* Initial Setup - get from the preferences */
   readPreferences();
 
-  myPlot->setMargin( 5 );
   setCurveType( myCurveType, false );
   setXGrid( myXGridMajorEnabled, myXGridMaxMajor, myXGridMinorEnabled, myXGridMaxMinor, false );
   setYGrid( myYGridMajorEnabled, myYGridMaxMajor, myYGridMinorEnabled, myYGridMaxMinor,
@@ -251,9 +238,12 @@ void Plot2d_ViewFrame::Init()
   setHorScaleMode( myXMode, false );
   setVerScaleMode( myYMode, false );
   setBackgroundColor( myBackground );
+  setSelectionColor( mySelectionColor );
   setLegendPos( myLegendPos );
+  setLegendSymbolType( myLegendSymbolType );
   setLegendFont( myLegendFont );
   setLegendFontColor( myLegendColor );
+  setSelectedLegendFontColor( mySelectedLegendFontColor );
   showLegend( myShowLegend, false );
   myPlot->replot();
 
@@ -272,6 +262,21 @@ void Plot2d_ViewFrame::Init()
   }
   myPlot->canvas()->installEventFilter( this );
 }
+void Plot2d_ViewFrame::SetPreference()
+{
+  readPreferences();
+  setBackgroundColor( myBackground );
+  setSelectionColor( mySelectionColor );
+  setCurveType( myCurveType, true );
+  setMarkerSize( myMarkerSize, true );
+  showLegend( myShowLegend, true );
+  setLegendPos( myLegendPos );
+  setLegendSymbolType( myLegendSymbolType );
+  setLegendFont( myLegendFont );
+  setLegendFontColor( myLegendColor );
+  setSelectedLegendFontColor( mySelectedLegendFontColor );
+  myPlot->replot();
+}
 /*!
   Gets window's central widget
 */
@@ -465,10 +470,13 @@ void Plot2d_ViewFrame::readPreferences()
 
   myShowLegend = resMgr->booleanValue( "Plot2d", "ShowLegend", myShowLegend );
   myLegendPos = resMgr->integerValue( "Plot2d", "LegendPos", myLegendPos );
+  myLegendSymbolType = resMgr->integerValue( "Plot2d", "LegendSymbolType", myLegendSymbolType );
   myLegendFont = resMgr->fontValue( "Plot2d", "LegendFont", myLegendFont );
   myLegendColor = resMgr->colorValue( "Plot2d", "LegendFontColor", myLegendColor );
+  mySelectedLegendFontColor = resMgr->colorValue( "Plot2d", "SelectedLegendFontColor", mySelectedLegendFontColor );
   myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize );
   myBackground = resMgr->colorValue( "Plot2d", "Background", myBackground );
+  mySelectionColor = resMgr->colorValue( "Plot2d", "SelectionColor", mySelectionColor );
 
   myTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowTitle", myTitleEnabled );
   myXTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
@@ -519,13 +527,19 @@ void Plot2d_ViewFrame::writePreferences()
   resMgr->setValue( "Plot2d", "CurveType", myCurveType );
   resMgr->setValue( "Plot2d", "ShowLegend", myShowLegend );
   resMgr->setValue( "Plot2d", "LegendPos", myLegendPos );
+  resMgr->setValue( "Plot2d", "LegendSymbolType", myLegendSymbolType );
   resMgr->setValue( "Plot2d", "LegendFont", myLegendFont );
   resMgr->setValue( "Plot2d", "LegendFontColor", myLegendColor );
+  resMgr->setValue( "Plot2d", "SelectedLegendFontColor", mySelectedLegendFontColor );
   resMgr->setValue( "Plot2d", "MarkerSize", myMarkerSize );
   resMgr->setValue( "Plot2d", "Background", myBackground );
+  resMgr->setValue( "Plot2d", "SelectionColor", mySelectionColor );
   resMgr->setValue( "Plot2d", "ShowTitle", myTitleEnabled );
   resMgr->setValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
   resMgr->setValue( "Plot2d", "ShowVerLeftTitle", myYTitleEnabled );
+  resMgr->setValue( "Plot2d", "DeviationMarkerColor", myPlot->property(PLOT2D_DEVIATION_COLOR).value<QColor>() );
+  resMgr->setValue( "Plot2d", "DeviationMarkerLineWidth", myPlot->property(PLOT2D_DEVIATION_LW).toInt() );
+  resMgr->setValue( "Plot2d", "DeviationMarkerTickSize", myPlot->property(PLOT2D_DEVIATION_TS).toInt() );
   if ( mySecondY )
     resMgr->setValue( "Plot2d", "ShowVerRightTitle", myY2TitleEnabled );
 
@@ -567,8 +581,8 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
   QwtValueList aTicks;
   bool xFound = false, yFound = false;
   double xCoord, yCoord;
-  const QwtScaleDiv* aXscale = myPlot->axisScaleDiv( QwtPlot::xBottom );
-  aTicks = aXscale->ticks( QwtScaleDiv::MajorTick );
+  const QwtScaleDiv& aXscale = myPlot->axisScaleDiv( QwtPlot::xBottom );
+  aTicks = aXscale.ticks( QwtScaleDiv::MajorTick );
   for ( i = 0; i < aTicks.count(); i++ ) {
     double majXmark = aTicks[i];
     int xmark = myPlot->transform( QwtPlot::xBottom, majXmark );
@@ -579,7 +593,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
     }
   }
   if ( !xFound ) {
-    aTicks = aXscale->ticks( QwtScaleDiv::MinorTick );
+    aTicks = aXscale.ticks( QwtScaleDiv::MinorTick );
     for ( i = 0; i < aTicks.count(); i++ ) {
       double minXmark = aTicks[i];
       int xmark = myPlot->transform( QwtPlot::xBottom, minXmark );
@@ -590,8 +604,8 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
       }
     }
   }
-  const QwtScaleDiv* aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft );
-  aTicks = aYscale->ticks( QwtScaleDiv::MajorTick );
+  const QwtScaleDiv& aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft );
+  aTicks = aYscale.ticks( QwtScaleDiv::MajorTick );
   for ( i = 0; i < aTicks.count(); i++ ) {
     double majYmark = aTicks[i];
     int ymark = myPlot->transform( QwtPlot::yLeft, majYmark );
@@ -602,7 +616,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
     }
   }
   if ( !yFound ) {
-    aTicks = aYscale->ticks( QwtScaleDiv::MinorTick );
+    aTicks = aYscale.ticks( QwtScaleDiv::MinorTick );
     for ( i = 0; i < aTicks.count(); i++ ) {
       double minYmark = aTicks[i];
       int ymark = myPlot->transform( QwtPlot::yLeft, minYmark );
@@ -626,8 +640,8 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
     bool yFound2 = false;
     double yCoord2;
 
-    const QwtScaleDiv* aYscale2 = myPlot->axisScaleDiv( QwtPlot::yRight );
-    aTicks = aYscale2->ticks( QwtScaleDiv::MajorTick );
+    const QwtScaleDiv& aYscale2 = myPlot->axisScaleDiv( QwtPlot::yRight );
+    aTicks = aYscale2.ticks( QwtScaleDiv::MajorTick );
     for ( i = 0; i < aTicks.count(); i++ ) {
       double majYmark = aTicks[i];
       int ymark = myPlot->transform( QwtPlot::yRight, majYmark );
@@ -638,7 +652,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
       }
     }
     if ( !yFound2 ) {
-      aTicks = aYscale2->ticks( QwtScaleDiv::MinorTick );
+      aTicks = aYscale2.ticks( QwtScaleDiv::MinorTick );
       for ( i = 0; i < aTicks.count(); i++ ) {
         double minYmark = aTicks[i];
         int ymark = myPlot->transform( QwtPlot::yRight, minYmark );
@@ -731,8 +745,8 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
                                                                              bool  displayLegend, const QList< bool >& sides)
 {
   // Consider the new legend's entries
-  // (PB: to update the legend we must remove it and put a new QwtLegend in the QwtPlot)
-  myPlot->insertLegend( (QwtLegend*)NULL); // we remove here, we shall put at the end
+  // (PB: to update the legend we must remove it and put a new QwtAbstractLegend in the QwtPlot)
+  myPlot->insertLegend( (QwtAbstractLegend*)NULL); // we remove here, we shall put at the end
 
   int nbAllCurves = curveList.size();
   int nbGroups    = nbAllCurves / groupSize;
@@ -753,12 +767,12 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
       icur2 = icur1 + groupSize -1;
 
       // For all curves in one group
-      double XgroupMin, XgroupMax;
-      double YgroupMin, YgroupMax;
+      double XgroupMin = 0., XgroupMax = 0.;
+      double YgroupMin = 0., YgroupMax = 0.;
 
       // For one curve
-      double XcurveMin, XcurveMax;
-      double YcurveMin, YcurveMax;
+      double XcurveMin = 0., XcurveMax = 0.;
+      double YcurveMin = 0., YcurveMax = 0.;
       double *Xval;
       double *Yval;
       int nbPoints;
@@ -875,9 +889,10 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
           QwtPlotCurve* plotCurve = dynamic_cast<QwtPlotCurve *>(getPlotObject(plot2dCurve));
           vectCurve[ig].push_back(plotCurve);
           // Modify the points' markers
-          QwtSymbol symbol(plotCurve->symbol()) ;
-          symbol.setStyle(symbolStyle1);
-          symbol.setPen(QPen(color1,lineWidth1));
+          QwtSymbol* symbol = new QwtSymbol(plotCurve->symbol()->style(), plotCurve->symbol()->brush(),
+                                            plotCurve->symbol()->pen(), plotCurve->symbol()->size()) ;
+          symbol->setStyle(symbolStyle1);
+          symbol->setPen(QPen(color1,lineWidth1));
           //symbol.setBrush( QBrush( color1));
           //QSize size = 0.5*(symbol.size());
           //symbol.setSize(size);
@@ -962,7 +977,7 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title,
                                                    int lineWidth,
                                                    QColor & lineColor,
                                                    QwtSymbol::Style markerKind,
-                                                   Plot2d_QwtPlotPicker* picker,
+                                                   Plot2d_QwtPlotPicker* /*picker*/,
                                                    bool toDraw,
                                                    bool displayLegend)
 {
@@ -1002,7 +1017,7 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title,
   {
       if (!displayLegend)
         {
-          myPlot->insertLegend( (QwtLegend*)NULL);
+          myPlot->insertLegend( (QwtAbstractLegend*)NULL);
         }
       displayCurve( plot2dCurve);
 
@@ -1024,15 +1039,16 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title,
       }
 
       // Modify points' markers
-      QwtSymbol symbol (plotCurve->symbol()) ;
-      symbol.setStyle( markerKind);
+      QwtSymbol* symbol = new QwtSymbol( plotCurve->symbol()->style(), plotCurve->symbol()->brush(),
+                                            plotCurve->symbol()->pen(), plotCurve->symbol()->size() ) ;
+      symbol->setStyle( markerKind );
       //
       if (markerKind != QwtSymbol::NoSymbol)
       {
-          symbol.setPen( QPen( theColor, lineWidth));
-          symbol.setBrush( QBrush( theColor));
-          QSize size = 2.0*(symbol.size()); //0.5
-          symbol.setSize(size);
+        symbol->setPen( QPen( theColor, lineWidth));
+        symbol->setBrush( QBrush( theColor));
+        QSize size = 2.0*(symbol->size()); //0.5
+        symbol->setSize(size);
       }
 
       plotCurve->setSymbol( symbol);
@@ -1071,14 +1087,14 @@ QwtPlotCurve *Plot2d_ViewFrame::createSegment( double *X, double *Y, int nbPoint
                                                QColor & lineColor,
                                                QwtSymbol::Style markerKind, bool side)
 {
-  QwtPlotCurve* aPCurve = new QwtPlotCurve();
+  QwtPlotCurve* aPCurve = new QwtPlotCurve( QString::null );
 
-  aPCurve->setData( X, Y, nbPoint);
+  aPCurve->setSamples( X, Y, nbPoint);
 
   aPCurve->setPen( QPen( lineColor, lineWidth, lineKind));
-  QwtSymbol aSymbol;
-  aSymbol.setStyle( markerKind);
-  aPCurve->setSymbol( aSymbol);
+  QwtSymbol* aSymbol = new QwtSymbol();
+  aSymbol->setStyle( markerKind );
+  aPCurve->setSymbol( aSymbol );
 
   // The segment must not have legend's entry
   aPCurve->setItemAttribute( QwtPlotItem::Legend, false);
@@ -1254,13 +1270,8 @@ QwtPlotItem* Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update
       Plot2d_Curve* aCurve = dynamic_cast<Plot2d_Curve*>( object );
       if ( aCurve )
       {
-       //myMarkerSize = 1;
-        //aCurve->setMarkerSize( myMarkerSize );
-
-       if (aCurve->getMarkerSize() == 0)
-       {
-            aCurve->setMarkerSize( myMarkerSize );
-       }
+        if ( aCurve->getMarkerSize() == 0 )
+          aCurve->setMarkerSize( myMarkerSize );
 
         processFiltering(update);
         updatePlotItem( aCurve, anItem );
@@ -1409,10 +1420,12 @@ void Plot2d_ViewFrame::updateLegend( const Plot2d_Prs* prs )
   update legend
 */
 void Plot2d_ViewFrame::updateLegend() {
-  if ( myPlot->getLegend() ) {
-    ObjectDict::iterator it = myObjects.begin();
-    for( ; it != myObjects.end(); ++it )
-      it.key()->updateLegend(myPlot->getLegend());
+  const QwtPlotItemList& items = myPlot->itemList();
+  QwtPlotItemIterator it;
+  for ( it = items.begin(); it != items.end(); it++ ) {
+    QwtPlotItem* item = *it;
+    if ( item )
+      item->updateLegend( item, item->legendData() );
   }
 }
 
@@ -1422,14 +1435,7 @@ void Plot2d_ViewFrame::updateLegend() {
 */
 void Plot2d_ViewFrame::fitAll()
 {
-  // Postpone fitAll operation until QwtPlot geometry
-  // has been fully defined
-  if ( !myPlot->polished() ){
-    QApplication::postEvent( this, new QEvent( (QEvent::Type)FITALL_EVENT ) );
-    return;
-  }
-
-  // no need to set auto scaling, it wiil be disabled by setAxisScale() method call
+  // no need to set auto scaling, it will be disabled by setAxisScale() method call
   // myPlot->setAxisAutoScale( QwtPlot::yLeft );
   // myPlot->setAxisAutoScale( QwtPlot::xBottom );
   // myPlot->replot();
@@ -1634,10 +1640,10 @@ void Plot2d_ViewFrame::getFitRangeByMarkers(double& xMin,  double& xMax,
 */
 int Plot2d_ViewFrame::testOperation( const QMouseEvent& me )
 {
-  int btn = me.button() | me.modifiers();
-  const int zoomBtn = Qt::ControlModifier | Qt::LeftButton;
-  const int panBtn  = Qt::ControlModifier | Qt::MidButton;
-  const int fitBtn  = Qt::ControlModifier | Qt::RightButton;
+  int btn = (int)me.button() | (int)me.modifiers();
+  const int zoomBtn = (int)Qt::ControlModifier | (int)Qt::LeftButton;
+  const int panBtn  = (int)Qt::ControlModifier | (int)Qt::MidButton;
+  const int fitBtn  = (int)Qt::ControlModifier | (int)Qt::RightButton;
 
   int op = NoOpId;
   if ( btn == zoomBtn ) {
@@ -1708,9 +1714,11 @@ void Plot2d_ViewFrame::onSettings()
   if (mySecondY)
     dlg->setY2Title( myY2TitleEnabled, myY2Title );
   dlg->setCurveType( myCurveType );
-  dlg->setLegend( myShowLegend, myLegendPos, myLegendFont, myLegendColor );
+  dlg->setLegend( myShowLegend, myLegendPos, myLegendSymbolType, myLegendFont,
+                  myLegendColor, mySelectedLegendFontColor );
   dlg->setMarkerSize( myMarkerSize );
   dlg->setBackgroundColor( myBackground );
+  dlg->setSelectionColor( mySelectionColor );
   dlg->setScaleMode(myXMode, myYMode);
   dlg->setLMinNormMode(myNormLMin);
   dlg->setLMaxNormMode(myNormLMax);
@@ -1759,6 +1767,9 @@ void Plot2d_ViewFrame::onSettings()
     }
     if ( myLegendPos != dlg->getLegendPos() ) {
       setLegendPos( dlg->getLegendPos() );
+    }
+    if ( myLegendSymbolType != dlg->getLegendSymbolType() ) {
+      setLegendSymbolType( dlg->getLegendSymbolType() );
     }
        if ( myLegendFont != dlg->getLegendFont() ) {
       setLegendFont( dlg->getLegendFont() );
@@ -1766,6 +1777,9 @@ void Plot2d_ViewFrame::onSettings()
        if ( myLegendColor != dlg->getLegendColor() ) {
       setLegendFontColor( dlg->getLegendColor() );
     }
+    if ( mySelectedLegendFontColor != dlg->getSelectedLegendColor() ) {
+      setSelectedLegendFontColor( dlg->getSelectedLegendColor() );
+    }
 
     // marker size
     if ( myMarkerSize != dlg->getMarkerSize() ) {
@@ -1775,6 +1789,10 @@ void Plot2d_ViewFrame::onSettings()
     if ( myBackground != dlg->getBackgroundColor() ) {
       setBackgroundColor( dlg->getBackgroundColor() );
     }
+    // selection color
+    if ( mySelectionColor != dlg->getSelectionColor() ) {
+      setSelectionColor( dlg->getSelectionColor() );
+    }
     // grid
     bool aXGridMajorEnabled, aXGridMinorEnabled, aYGridMajorEnabled, aYGridMinorEnabled,
          aY2GridMajorEnabled, aY2GridMinorEnabled;
@@ -1850,9 +1868,9 @@ void Plot2d_ViewFrame::removeAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
 void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool updateView)
 {
   if(!c) return;
-  QwtScaleDiv* div = myPlot->axisScaleDiv(QwtPlot::xBottom);
-  c->setRangeBegin(div->lowerBound());
-  c->setRangeEnd(div->upperBound());
+  QwtScaleDiv div = myPlot->axisScaleDiv(QwtPlot::xBottom);
+  c->setRangeBegin(div.lowerBound());
+  c->setRangeEnd(div.upperBound());
   c->calculate();
   c->setMarkerSize(myMarkerSize);
   QwtPlotItem* item = c->plotItem();
@@ -1862,6 +1880,7 @@ void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool upd
     if( c->isActive() ) {
       c->updatePlotItem();
       item->attach( myPlot );
+      item->itemChanged();
       item->show();
     }
     c->setAction(Plot2d_AnalyticalCurve::ActNothing);
@@ -1881,8 +1900,6 @@ void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool upd
   case Plot2d_AnalyticalCurve::ActRemoveFromView:
     item->hide();
     item->detach();
-    myAnalyticalCurves.removeAll(c);
-    delete c;
     break;
   }
 
@@ -1896,8 +1913,19 @@ void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool upd
 void Plot2d_ViewFrame::updateAnalyticalCurves()
 {
   AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
+  AnalyticalCurveList toDelete;
   for( ; it != myAnalyticalCurves.end(); it++) {
-    updateAnalyticalCurve(*it);
+    Plot2d_AnalyticalCurve* c = (*it);
+    updateAnalyticalCurve(c);
+    if(c && c->getAction() == Plot2d_AnalyticalCurve::ActRemoveFromView)
+      toDelete.push_back(c);
+  }
+  it = toDelete.begin();
+  for( ; it != toDelete.end(); it++) {
+    Plot2d_AnalyticalCurve* c = (*it);
+    myAnalyticalCurves.removeAll(c);
+    delete c;
+    c = NULL;
   }
   myPlot->replot();
 }
@@ -1907,7 +1935,7 @@ void Plot2d_ViewFrame::updateAnalyticalCurves()
 */
 AnalyticalCurveList Plot2d_ViewFrame::getAnalyticalCurves() const
 {
-  return myAnalyticalCurves;
+  return myAnalyticalCurves  ;
 }
 
 /*!
@@ -1916,8 +1944,8 @@ AnalyticalCurveList Plot2d_ViewFrame::getAnalyticalCurves() const
 Plot2d_AnalyticalCurve* Plot2d_ViewFrame::getAnalyticalCurve(QwtPlotItem * theItem) {
   AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
   for( ; it != myAnalyticalCurves.end(); it++) {
-    if((*it)->plotItem() == theItem);
-               return (*it);
+    if((*it)->plotItem() == theItem)
+      return (*it);
   }
   return 0;
 }
@@ -1967,6 +1995,13 @@ void Plot2d_ViewFrame::setCurveType( int curveType, bool update )
     if ( crv )
       setCurveType( crv, myCurveType );
   }
+  for(int i=0 ; i < myAnalyticalCurves.count(); i++) {
+    QwtPlotCurve* aPCurve = dynamic_cast<QwtPlotCurve*>( myAnalyticalCurves[i]->plotItem() );
+    Plot2d_AnalyticalCurve* aCurve = dynamic_cast<Plot2d_AnalyticalCurve*>( myAnalyticalCurves[i] );
+    if ( aPCurve && aCurve ) {
+      setCurveType( aPCurve, myCurveType );
+    }
+  }
   if ( update )
     myPlot->replot();
   emit vpCurveChanged();
@@ -2008,19 +2043,31 @@ void Plot2d_ViewFrame::showLegend( bool show, bool update )
 {
   myShowLegend = show;
   if ( myShowLegend ) {
-    QwtLegend* legend = myPlot->legend();
-    if ( !legend ) {
-      legend = new QwtLegend( myPlot );
+    QwtAbstractLegend* absLegend = myPlot->legend();
+    QwtLegend* legend = 0;
+    if ( !absLegend ) {
+      legend = new Plot2d_QwtLegend( myPlot );
+      legend->setDefaultItemMode(QwtLegendData::Clickable);
+      connect( legend, SIGNAL( clicked (const QVariant&, int) ),
+               this, SIGNAL( clicked (const QVariant&, int) ) );
       legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
     }
-    legend->setItemMode( QwtLegend::ClickableItem );
-    myPlot->insertLegend( legend );
-    setLegendPos( myLegendPos );
-    setLegendFont( myLegendFont );
-    setLegendFontColor( myLegendColor );
+    else {
+      legend = dynamic_cast<QwtLegend*>(absLegend);
+    }
+    if(legend) {
+      myPlot->insertLegend( legend );
+      setLegendPos( myLegendPos );
+      setLegendFont( myLegendFont );
+      setLegendFontColor( myLegendColor );
+    }
   }
   else
     myPlot->insertLegend( 0 );
+
+  if( show && update )
+    updateLegend();
+
   if ( update )
     myPlot->replot();
 }
@@ -2031,7 +2078,7 @@ void Plot2d_ViewFrame::showLegend( bool show, bool update )
 void Plot2d_ViewFrame::setLegendPos( int pos )
 {
   myLegendPos = pos;
-  QwtLegend* legend = myPlot->legend();
+  QwtAbstractLegend* legend = myPlot->legend();
   if ( legend ) {
     switch( pos ) {
     case 0:
@@ -2058,13 +2105,31 @@ int Plot2d_ViewFrame::getLegendPos() const
   return myLegendPos;
 }
 
+/*!
+  Sets legend symbol type : 0 - marker on line, 1 - marker above line
+*/
+void Plot2d_ViewFrame::setLegendSymbolType( int type )
+{
+  myLegendSymbolType = type;
+  myPlot->setLegendSymbolType( type );
+  updateLegend();
+}
+
+/*!
+  Gets legend symbol type : 0 - marker on line, 1 - marker above line
+*/
+int Plot2d_ViewFrame::getLegendSymbolType() const
+{
+  return myLegendSymbolType;
+}
+
 /*!
   Sets legend font
 */
 void Plot2d_ViewFrame::setLegendFont( const QFont& fnt )
 {
   myLegendFont = fnt;
-  QwtLegend* legend = myPlot->legend();
+  QwtAbstractLegend* legend = myPlot->legend();
   if ( legend ) {
     legend->setFont(fnt);
   }
@@ -2078,21 +2143,13 @@ QFont Plot2d_ViewFrame::getLegendFont() const
   return myLegendFont;
 }
 
-/*!
-  Gets legend font color
-*/
-QColor Plot2d_ViewFrame::getLegendFontColor() const
-{
-  return myLegendColor;
-}
-
 /*!
   Sets legend font color
 */
 void Plot2d_ViewFrame::setLegendFontColor( const QColor& col )
 {
   myLegendColor = col;
-  QwtLegend* legend = myPlot->legend();
+  QwtAbstractLegend* legend = myPlot->legend();
   if ( legend ) {
     QPalette pal = legend->palette();
     pal.setColor( QPalette::Text, col );
@@ -2100,6 +2157,31 @@ void Plot2d_ViewFrame::setLegendFontColor( const QColor& col )
   }
 }
 
+/*!
+  Gets legend font color
+*/
+QColor Plot2d_ViewFrame::getLegendFontColor() const
+{
+  return myLegendColor;
+}
+
+/*!
+  Sets selected legend font color
+*/
+void Plot2d_ViewFrame::setSelectedLegendFontColor( const QColor& col )
+{
+  mySelectedLegendFontColor = col;
+  Plot2d_Object::setHighlightedLegendTextColor( col );
+}
+
+/*!
+  Gets selected legend font color
+*/
+QColor Plot2d_ViewFrame::getSelectedLegendFontColor() const
+{
+  return mySelectedLegendFontColor;
+}
+
 /*!
   Sets new marker size
 */
@@ -2114,11 +2196,11 @@ void Plot2d_ViewFrame::setMarkerSize( const int size, bool update )
       QwtPlotCurve* crv = it.key();
       if ( crv )
       {
-        QwtSymbol aSymbol = crv->symbol();
-        aSymbol.setSize( myMarkerSize, myMarkerSize );
+        QwtSymbol* aSymbol = new QwtSymbol( crv->symbol()->style(), crv->symbol()->brush(),
+                                                   crv->symbol()->pen(), QSize( myMarkerSize, myMarkerSize ) );
         crv->setSymbol( aSymbol );
-       if(it.value())
-         it.value()->setMarkerSize( myMarkerSize );
+        if( it.value() )
+             it.value()->setMarkerSize( myMarkerSize );
       }
     }
     if ( update )
@@ -2153,6 +2235,7 @@ void Plot2d_ViewFrame::setBackgroundColor( const QColor& color )
   }
   Repaint();
 }
+
 /*!
   Gets background color
 */
@@ -2160,6 +2243,24 @@ QColor Plot2d_ViewFrame::backgroundColor() const
 {
   return myBackground;
 }
+
+/*!
+  Sets selection color
+*/
+void Plot2d_ViewFrame::setSelectionColor( const QColor& color )
+{
+  mySelectionColor = color;
+  Plot2d_Object::setSelectionColor( color );
+}
+
+/*!
+  Gets selection color
+*/
+QColor Plot2d_ViewFrame::selectionColor() const
+{
+  return mySelectionColor;
+}
+
 /*!
   Sets hor.axis grid parameters
 */
@@ -2176,8 +2277,8 @@ void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax,
   myPlot->setAxisMaxMinor( QwtPlot::xBottom, myXGridMaxMinor );
 
   QwtPlotGrid* grid = myPlot->grid();
-  if ( myPlot->axisScaleDiv( QwtPlot::xBottom ) )
-    grid->setXDiv( *myPlot->axisScaleDiv( QwtPlot::xBottom ) );
+  if ( !myPlot->axisScaleDiv( QwtPlot::xBottom ).isEmpty() )
+    grid->setXDiv( myPlot->axisScaleDiv( QwtPlot::xBottom ) );
   grid->enableX( myXGridMajorEnabled );
   grid->enableXMin( myXGridMinorEnabled );
 
@@ -2213,8 +2314,8 @@ void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax,
   }
 
   QwtPlotGrid* grid = myPlot->grid();
-  if ( myPlot->axisScaleDiv( QwtPlot::yLeft ) )
-    grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yLeft ) );
+  if ( !myPlot->axisScaleDiv( QwtPlot::yLeft ).isEmpty() )
+    grid->setYDiv( myPlot->axisScaleDiv( QwtPlot::yLeft ) );
 
   if (mySecondY) {
     if (myYGridMajorEnabled) {
@@ -2222,8 +2323,8 @@ void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax,
       grid->enableYMin( myYGridMinorEnabled );
     }
     else if (myY2GridMajorEnabled) {
-      if ( myPlot->axisScaleDiv( QwtPlot::yRight ) )
-        grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yRight ) );
+      if ( !myPlot->axisScaleDiv( QwtPlot::yRight ).isEmpty() )
+        grid->setYDiv( myPlot->axisScaleDiv( QwtPlot::yRight ) );
       grid->enableY( myY2GridMajorEnabled );
       grid->enableYMin( myY2GridMinorEnabled );
     }
@@ -2332,15 +2433,21 @@ void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update )
   // non-positive X/Y coordinate
   if ( mode && !isXLogEnabled() ){
 #ifndef NO_SUIT
-    SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+    SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
 #else
-    QMessageBox::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+    QMessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
 #endif
     return;
   }
 
   myXMode = mode;
 
+  // set bounds of logarithmic scale
+  if( myXMode != 0 ) {
+    myPlot->setAxisScale( QwtPlot::xBottom, 1.0, 1e5 );
+    myPlot->updateAxes();
+  }
+
   myPlot->setLogScale(QwtPlot::xBottom, myXMode != 0);
 
   if ( update )
@@ -2369,17 +2476,29 @@ void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update )
   // non-positive X/Y coordinate
   if ( mode && !isYLogEnabled() ){
 #ifndef NO_SUIT
-    SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+    SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
 #else
-    QMessageBox::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+    QMessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
 #endif
     return;
   }
 
   myYMode = mode;
+
+  // set bounds of logarithmic scale
+  if( myYMode != 0 ){
+    myPlot->setAxisScale( QwtPlot::yLeft, 1.0, 1e5 );
+    myPlot->updateAxes();
+  }
+
   myPlot->setLogScale(QwtPlot::yLeft, myYMode != 0);
-  if (mySecondY)
+  if (mySecondY) {
+    if( myYMode != 0 ){
+      myPlot->setAxisScale( QwtPlot::yRight, 1.0, 1e5 );
+      myPlot->updateAxes();
+    }
     myPlot->setLogScale( QwtPlot::yRight, myYMode != 0 );
+  }
 
   if ( update )
     fitAll();
@@ -2571,7 +2690,7 @@ void Plot2d_ViewFrame::plotMousePressed( const QMouseEvent& me )
     }
   }
   else {
-    int btn = me.button() | me.modifiers();
+    int btn = (int)me.button() | (int)me.modifiers();
     if (btn == Qt::RightButton) {
       QMouseEvent* aEvent = new QMouseEvent(QEvent::MouseButtonPress,
                                             me.pos(), me.button(), me.buttons(), me.modifiers() );
@@ -2731,7 +2850,7 @@ bool Plot2d_ViewFrame::hasPlotObject( Plot2d_Object* object ) const
 /*!
   Sets curve type
 */
-void Plot2d_ViewFrame::setCurveType( QwtPlotCurve* curve, int curveType )
+void Plot2d_ViewFrame::setCurveType( QwtPlotCurve* curve, int /*curveType*/ )
 {
   if ( !curve )
     return;
@@ -2866,7 +2985,7 @@ void Plot2d_ViewFrame::setEnableAxis( QwtPlot::Axis theAxis, bool isEnable )
 class Plot2d_QwtPlotZoomer : public QwtPlotZoomer
 {
 public:
-  Plot2d_QwtPlotZoomer( int xAxis, int yAxis, QwtPlotCanvas* canvas )
+  Plot2d_QwtPlotZoomer( int xAxis, int yAxis, QWidget* canvas )
   : QwtPlotZoomer( xAxis, yAxis, canvas )
   {
     qApp->installEventFilter( this );
@@ -2881,7 +3000,6 @@ public:
 */
 Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   : QwtPlot( parent ),
-    myIsPolished( false ),
     myPicker( 0 )
 {
   // Create alternative scales
@@ -2890,7 +3008,6 @@ Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   setAxisScaleDraw( QwtPlot::yRight,  new Plot2d_ScaleDraw() );
 
   myPlotZoomer = new Plot2d_QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() );
-  myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner );
   myPlotZoomer->setTrackerMode( QwtPicker::AlwaysOff );
   myPlotZoomer->setRubberBand( QwtPicker::RectRubberBand );
   myPlotZoomer->setRubberBandPen( QColor( Qt::green ) );
@@ -2905,7 +3022,7 @@ Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   myScaleDraw = NULL;
 // grid
   myGrid = new QwtPlotGrid();
-  QPen aMajPen = myGrid->majPen();
+  QPen aMajPen = myGrid->majorPen();
   aMajPen.setStyle( Qt::DashLine );
   myGrid->setPen( aMajPen );
 
@@ -2935,7 +3052,7 @@ Plot2d_Plot2d::~Plot2d_Plot2d()
 void Plot2d_Plot2d::setLogScale( int axisId, bool log10 )
 {
   if ( log10 )
-    setAxisScaleEngine( axisId, new QwtLog10ScaleEngine() );
+    setAxisScaleEngine( axisId, new QwtLogScaleEngine() );
   else
     setAxisScaleEngine( axisId, new QwtLinearScaleEngine() );
 }
@@ -2972,7 +3089,7 @@ void Plot2d_Plot2d::replot()
 /*!
   Get legend
 */
-QwtLegend* Plot2d_Plot2d::getLegend()
+QwtAbstractLegend* Plot2d_Plot2d::getLegend()
 {
 #if QWT_VERSION < 0x040200
   return d_legend;
@@ -3004,12 +3121,14 @@ void Plot2d_Plot2d::defaultPicker()
   myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1,
                                  Qt::RightButton, Qt::ControlModifier ); // zooming button
   for ( int i = QwtEventPattern::MouseSelect2; i < QwtEventPattern::MouseSelect6; i++ )
-    myPlotZoomer->setMousePattern( i, Qt::NoButton, Qt::NoButton );
+    myPlotZoomer->setMousePattern( (QwtEventPattern::MousePatternCode)i, Qt::NoButton,
+                                      Qt::NoModifier );
 }
 
 void Plot2d_Plot2d::setPickerMousePattern( int button, int state )
 {
-  myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1, button, state );
+  myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1, (Qt::MouseButton)button,
+                                        (Qt::KeyboardModifiers)state );
 }
 
 /*!
@@ -3023,11 +3142,11 @@ void Plot2d_Plot2d::setPicker( Plot2d_QwtPlotPicker *picker)
 /*!
  * Create marker and tooltip associed with a point
  */
-QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
-                                            double    X,
-                                            double    Y,
-                                            QString & tooltip,
-                                            Plot2d_QwtPlotPicker *picker)
+QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol* symbol,
+                                                      double    X,
+                                                      double    Y,
+                                                      QString & tooltip,
+                                                      Plot2d_QwtPlotPicker *picker)
 {
   QwtPlotMarker* aPlotMarker = new QwtPlotMarker();
 
@@ -3054,59 +3173,16 @@ QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
   return aPlotMarker;
 }
 
-bool Plot2d_Plot2d::polished() const
-{
-  return myIsPolished;
-}
-
 QwtPlotGrid* Plot2d_Plot2d::grid() const
 {
   return myGrid;
-};
+}
 
 QwtPlotZoomer* Plot2d_Plot2d::zoomer() const
 {
   return myPlotZoomer;
 }
 
-/*!
-  Slot: checks the current labels format and change it if needed
-*/
-void Plot2d_Plot2d::onScaleDivChanged()
-{
-  QwtScaleWidget* aSW = 0;
-  if ( ( aSW = dynamic_cast<QwtScaleWidget*>(sender()) ) ) {
-    int axisId = -1;
-    switch ( aSW->alignment() ) {
-    case QwtScaleDraw::BottomScale:
-      axisId = QwtPlot::xBottom;
-      break;
-    case QwtScaleDraw::LeftScale:
-      axisId = QwtPlot::yLeft;
-      break;
-    case QwtScaleDraw::RightScale:
-      axisId = QwtPlot::yRight;
-      break;
-    default:
-      break;
-    }
-
-    if ( axisId >= 0 ) {
-      QwtScaleMap map = canvasMap(axisId);
-      double aDist = fabs(map.s2()-map.s1()) / (axisMaxMajor(axisId)*axisMaxMinor(axisId));
-
-      QString aDistStr;
-      aDistStr.sprintf("%e",aDist);
-      int aPrecision = aDistStr.right(aDistStr.length()-aDistStr.indexOf('e')-2).toInt();
-
-      QwtScaleDraw* aQwtSD = axisScaleDraw(axisId);
-      Plot2d_ScaleDraw* aPlot2dSD = dynamic_cast<Plot2d_ScaleDraw*>(aQwtSD);
-      if ( ( !aPlot2dSD && aPrecision > 6 ) || ( aPlot2dSD && aPlot2dSD->precision() != aPrecision ) )
-        setAxisScaleDraw( axisId, new Plot2d_ScaleDraw(*aQwtSD, 'f', aPrecision) );
-    }
-  }
-}
-
 /*!
   Updates identifiers of Y axis type in the legend.
 */
@@ -3131,19 +3207,10 @@ void Plot2d_Plot2d::updateYAxisIdentifiers()
     if ( Plot2d_QwtPlotCurve* aPCurve = dynamic_cast<Plot2d_QwtPlotCurve*>( item ) )
       aPCurve->setYAxisIdentifierEnabled( enableYLeft && enableYRight );
     if ( item && item->isVisible() && legend() )
-      item->updateLegend( legend() );
+      item->updateLegend( item, item->legendData() );
   }
 }
 
-/*!
-  Sets the flag saying that QwtPlot geometry has been fully defined.
-*/
-void Plot2d_Plot2d::polish()
-{
-  QwtPlot::polish();
-  myIsPolished = true;
-}
-
 // Methods to manage axis graduations
 
 /* Create definition and graduations of axes
@@ -3206,7 +3273,7 @@ void Plot2d_Plot2d::displayXTicksAndLabels(
   QList<double> allTicks;
 
   double devXmin, devXmax;  // X interval of a system
-  double gapXmin, gapXmax;  // X interval between two systems
+  double gapXmin = 0., gapXmax = 0.;  // X interval between two systems
   double devLabPos;         // Label's position of a system
   double segmentPos;  // Position of the vertical segment between current system and the next
 
@@ -3348,6 +3415,20 @@ void Plot2d_Plot2d::clearSeparationLineList()
   mySeparationLineList.clear();
 }
 
+/* Set type of legend symbol
+ */
+void Plot2d_Plot2d::setLegendSymbolType( const int type )
+{
+  myLegendSymbolType = type;
+}
+
+/* Get type of legend symbol
+ */
+int Plot2d_Plot2d::getLegendSymbolType()
+{
+  return myLegendSymbolType;
+}
+
 /*!
   Creates presentation of object
   Default implementation is empty
@@ -3369,8 +3450,12 @@ void Plot2d_ViewFrame::copyPreferences( Plot2d_ViewFrame* vf )
   myCurveType = vf->myCurveType;
   myShowLegend = vf->myShowLegend;
   myLegendPos = vf->myLegendPos;
+  myLegendSymbolType = vf->myLegendSymbolType;
+  myLegendFont = vf->myLegendFont;
+  mySelectedLegendFontColor = vf->mySelectedLegendFontColor;
   myMarkerSize = vf->myMarkerSize;
   myBackground = vf->myBackground;
+  mySelectionColor = vf->mySelectionColor;
   myTitle = vf->myTitle;
   myXTitle = vf->myXTitle;
   myYTitle = vf->myYTitle;
@@ -3507,22 +3592,24 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const
 
     if( pd )
     {
-      myPlot->print( *pd );
+      QwtPlotRenderer* pr = new QwtPlotRenderer();
+      pr->renderTo( myPlot, *pd );
       res = true;
       delete pd;
     }
   }
   return res;
 #endif
+
 }
 
 /**
  * Print Plot2d window
  */
-void Plot2d_ViewFrame::printPlot( QPainter* p, const QRect& rect,
-                                  const QwtPlotPrintFilter& filter ) const
+void Plot2d_ViewFrame::printPlot( QPainter* p, const QRectF& rect) const
 {
-  myPlot->print( p, rect, filter );
+  QwtPlotRenderer* pr = new QwtPlotRenderer();
+  pr->render( myPlot, p, rect );
 }
 
 /*!
@@ -3751,7 +3838,7 @@ QString Plot2d_ViewFrame::getXmlVisualParameters() {
     aWriter.writeAttribute("Name",c->getName());
     aWriter.writeAttribute("IsActive", QString("").sprintf("%d",       c->isActive()));
                aWriter.writeAttribute("Expression", c->getExpression());
-    aWriter.writeAttribute("NbIntervals", QString("").sprintf("%d",    c->getNbIntervals()));
+    aWriter.writeAttribute("NbIntervals", QString("").sprintf("%ld",   c->getNbIntervals()));
     aWriter.writeAttribute("isAuto", QString("").sprintf("%d",isAuto));
     if(!isAuto) {
       aWriter.writeAttribute("Marker", QString("").sprintf("%d",(int)c->getMarker()));
@@ -3785,7 +3872,7 @@ QString Plot2d_ViewFrame::getXmlVisualParameters() {
 */
 bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
   QXmlStreamReader aReader(parameters);
-  double xmin, xmax, ymin, ymax, y2min, y2max;
+  double xmin = 0., xmax = 0., ymin = 0., ymax = 0., y2min = 0., y2max = 0.;
   bool leftMin,leftMax,rightMin,rightMax;
   leftMin = leftMax = rightMin = rightMax = false;
   while(!aReader.atEnd()) {
@@ -3939,7 +4026,7 @@ void Plot2d_ViewFrame::updatePlotItem(Plot2d_Object* theObject, QwtPlotItem* the
         xNew[j] = itTmp.value().at(j).first;
         yNew[j] = itTmp.value().at(j).second;
       }
-      cu->setData(xNew, yNew,j);
+      cu->setSamples(xNew, yNew,j);
       delete [] xNew;
       delete [] yNew;
       if(aNormAlgo->getNormalizationMode() != Plot2d_NormalizeAlgorithm::NormalizeNone) {
@@ -3957,7 +4044,7 @@ void Plot2d_ViewFrame::updatePlotItem(Plot2d_Object* theObject, QwtPlotItem* the
  */
 QwtPlotCanvas* Plot2d_ViewFrame::getPlotCanvas() const
 {
-  return myPlot ? myPlot->canvas() : 0;
+  return myPlot ? (QwtPlotCanvas*)myPlot->canvas() : 0;
 }
 
 /*!
@@ -4108,21 +4195,13 @@ Plot2d_ScaleDraw::Plot2d_ScaleDraw( char f, int prec )
   invalidateCache();
 }
 
-Plot2d_ScaleDraw::Plot2d_ScaleDraw( const QwtScaleDraw& scaleDraw, char f, int prec )
-  : QwtScaleDraw(scaleDraw),
-    myFormat(f),
-    myPrecision(prec)
-{
-  invalidateCache();
-}
-
 QwtText Plot2d_ScaleDraw::label( double value ) const
 {
-  QwtScaleMap m = map();
+  QwtScaleMap m = scaleMap();
   QString str1 = QwtScaleDraw::label( m.s1() ).text();
   QString str2 = QwtScaleDraw::label( m.s2() ).text();
   if ( str1 == str2 ) {
-    double aDist = fabs(map().s2()-map().s1())/5;
+    double aDist = fabs(scaleMap().s2()-scaleMap().s1())/5;
     int precision = 0;
     while (aDist < 1 ) {
       precision++;
@@ -4206,9 +4285,13 @@ void Plot2d_AxisScaleDraw::draw( QPainter* painter, const QPalette & palette) co
   major_ticks.clear();
 
   major_ticks.append( myTicks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick,  major_ticks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick,  minor_ticks);
+
+  QwtScaleDiv aScaleDiv = myPlot->axisScaleDiv( QwtPlot::xBottom );
+  aScaleDiv.setTicks( QwtScaleDiv::MajorTick,  major_ticks );
+  aScaleDiv.setTicks( QwtScaleDiv::MediumTick, medium_ticks );
+  aScaleDiv.setTicks( QwtScaleDiv::MinorTick,  minor_ticks );
+  myPlot->setAxisScaleDiv( QwtPlot::xBottom, aScaleDiv );
+
   QwtScaleDraw *scale = myPlot->axisScaleDraw(QwtPlot::xBottom);
   ((Plot2d_AxisScaleDraw*)(scale))->applyTicks();
 
@@ -4223,6 +4306,12 @@ void Plot2d_AxisScaleDraw::draw( QPainter* painter, const QPalette & palette) co
 }
 
 
+double Plot2d_AxisScaleDraw::extent( const QFont &font ) const
+{
+  QFontMetrics fm( font );
+  return QwtScaleDraw::extent( font ) + fm.height() * 2;
+}
+
 QwtText Plot2d_AxisScaleDraw::label( double value) const
 {
   if (myLabelX.contains(value))
@@ -4282,9 +4371,11 @@ void Plot2d_AxisScaleDraw::applyTicks()
   medium_ticks.clear();
   minor_ticks.clear();
 
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick, myTicks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
-  myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick, minor_ticks);
+  QwtScaleDiv aQwtScaleDiv = myPlot->axisScaleDiv( QwtPlot::xBottom );
+  aQwtScaleDiv.setTicks( QwtScaleDiv::MajorTick, myTicks );
+  aQwtScaleDiv.setTicks( QwtScaleDiv::MediumTick, medium_ticks );
+  aQwtScaleDiv.setTicks( QwtScaleDiv::MinorTick, minor_ticks );
+  myPlot->setAxisScaleDiv( QwtPlot::xBottom, aQwtScaleDiv );
 
   QwtScaleDiv* aScaleDiv = (QwtScaleDiv*) &scaleDiv();
 
@@ -4315,7 +4406,7 @@ void Plot2d_AxisScaleDraw::drawLabel( QPainter* painter, double value) const
       //const char *c_label = std_label.c_str();
       //std::cout << "    deviceLabel= |" << c_label << "|" << std::endl;
 
-      QPoint p = labelPosition( value );
+      QPointF p = labelPosition( value );
       p += QPoint(0, DEVICE_BY);
       QFont  prevf = painter->font();
       //QColor prevc = (painter->pen()).color();
@@ -4359,13 +4450,11 @@ const double Plot2d_QwtPlotPicker::BOUND_HV_SIZE = 0.2;
 
 Plot2d_QwtPlotPicker::Plot2d_QwtPlotPicker( int            xAxis,
                                             int            yAxis,
-                                            int            selectionFlags,
                                             RubberBand     rubberBand,
                                             DisplayMode    trackerMode,
                                             QwtPlotCanvas *canvas)
 : QwtPlotPicker( xAxis,
                  yAxis,
-                 selectionFlags,
                  rubberBand,
                  trackerMode,
                  canvas)    // of drawing zone QwtPlot
@@ -4388,20 +4477,30 @@ Plot2d_QwtPlotPicker::~Plot2d_QwtPlotPicker()
 
 /* Return the tooltip associated with a point when the mouse cursor pass near
  */
-QwtText Plot2d_QwtPlotPicker::trackerText( const QwtDoublePoint & pos ) const
+QwtText Plot2d_QwtPlotPicker::trackerText( const QPoint & pos ) const
 {
   for (QList<QwtPlotMarker* >::const_iterator pMarkerIt = pMarkers.begin();pMarkerIt != pMarkers.end(); ++pMarkerIt )
     {
       QwtPlotMarker* pMarker = *pMarkerIt;
       if ( pMarker != NULL )
         {
-          const QwtSymbol &symb=pMarker->symbol();
-          const QSize& sz=symb.size();
+          const QwtSymbolsymb=pMarker->symbol();
+          const QSize& sz=symb->size();
           const QwtScaleMap yMapRef=plot()->canvasMap(QwtPlot::yLeft);
           const QwtScaleMap xMap=plot()->canvasMap(pMarker->xAxis());
           const QwtScaleMap yMap=plot()->canvasMap(pMarker->yAxis());
           QwtDoubleRect  bound0=pMarker->boundingRect();
-          QRect bound00=pMarker->transform(xMap,yMap,bound0);
+          int x1 = qRound(xMap.transform(bound0.left()));
+          int x2 = qRound(xMap.transform(bound0.right()));
+          int y1 = qRound(yMap.transform(bound0.top()));
+          int y2 = qRound(yMap.transform(bound0.bottom()));
+         
+          if ( x2 < x1 )
+            qSwap(x1, x2);
+          if ( y2 < y1 )
+            qSwap(y1, y2);
+         
+          QRect bound00=QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
           QPoint toto(xMap.transform(pos.x()),yMapRef.transform(pos.y()));
           bound00.setX(bound00.x()-sz.width());
           bound00.setY(bound00.y()-sz.height());