Salome HOME
Copyright update 2022
[modules/gui.git] / src / Plot2d / Plot2d_ViewFrame.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 3e65e51..6046482
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  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
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include "Plot2d_Curve.h"
 #include "Plot2d_PlotItems.h"
 #include "Plot2d_FitDataDlg.h"
+#ifndef NO_SUIT
 #include "Plot2d_ViewWindow.h"
+#endif
 #include "Plot2d_SetupViewDlg.h"
+#ifndef NO_ANALYTICAL_CURVES
 #include "Plot2d_AnalyticalCurveDlg.h"
 #include "Plot2d_AnalyticalCurve.h"
+#endif
 #include "Plot2d_ToolTip.h"
 
+#ifndef NO_SUIT
 #include "SUIT_Tools.h"
 #include "SUIT_Session.h"
 #include "SUIT_MessageBox.h"
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Application.h"
+#else
+#include <QMessageBox>
+#endif
 
 #include <QApplication>
 #include <QToolBar>
 #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
@@ -80,7 +87,7 @@
 
 #define FITALL_EVENT           ( QEvent::User + 9999 )
 
-const char* imageZoomCursor[] = { 
+const char* imageZoomCursor[] = {
 "32 32 3 1",
 ". c None",
 "a c #000000",
@@ -118,7 +125,7 @@ const char* imageZoomCursor[] = {
 "................................",
 "................................"};
 
-const char* imageCrossCursor[] = { 
+const char* imageCrossCursor[] = {
   "32 32 3 1",
   ". c None",
   "a c #000000",
@@ -165,22 +172,23 @@ const char* imageCrossCursor[] = {
     #undef min
   #endif
 #endif
-  
+
 /*!
   Constructor
 */
 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),
+       myOperation( NoOpId ),
+       myCurveType( 1 ),
+       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),
-       myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), myY2GridMajorEnabled( true ), 
+       myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), myY2GridMajorEnabled( true ),
        myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ),
        myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ),
        myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ),
@@ -191,30 +199,31 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
   myRNormAlgo = new Plot2d_NormalizeAlgorithm(this);
   myLNormAlgo = new Plot2d_NormalizeAlgorithm(this);
   /* Plot 2d View */
-  QVBoxLayout* aLayout = new QVBoxLayout( this ); 
+  QVBoxLayout* aLayout = new QVBoxLayout( this );
   aLayout->setMargin(0);
   myPlot = new Plot2d_Plot2d( this );
   new Plot2d_ToolTip( this );
 
   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
+}
+/*!
+  Destructor
+*/
+Plot2d_ViewFrame::~Plot2d_ViewFrame()
+{
+}
+/*!
+  Performs the initial setup.
+*/
+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,
@@ -229,14 +238,18 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
   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();
 
-  if ( parent ) {
-    resize( (int)(0.8 * parent->width()), (int)(0.8 * parent->height()) );
+  QWidget* aParent = parentWidget();
+  if ( aParent ) {
+    resize( (int)(0.8 * aParent->width()), (int)(0.8 * aParent->height()) );
   }
   QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
   QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
@@ -249,11 +262,20 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
   }
   myPlot->canvas()->installEventFilter( this );
 }
-/*!
-  Destructor
-*/
-Plot2d_ViewFrame::~Plot2d_ViewFrame()
+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
@@ -277,7 +299,7 @@ void Plot2d_ViewFrame::DisplayAll()
 /*!
    Removes all curves from the view
 */
-void Plot2d_ViewFrame::EraseAll() 
+void Plot2d_ViewFrame::EraseAll()
 {
   objectList anObjects;
   getObjects( anObjects );
@@ -299,30 +321,6 @@ void Plot2d_ViewFrame::EraseAll()
       myIntermittentSegmentList.clear();
   }
 
-  // 2)- Erase all curves points markers
-
-  int nbMark = myMarkerList.size();
-  if (nbMark > 0)
-  {
-      for (int imar=0; imar < nbMark; imar++)
-      {
-          QwtPlotMarker *marker = myMarkerList[imar];
-
-          marker->detach();  // erase in QwtPlot window
-          delete marker;
-      }
-      myMarkerList.clear();
-  }
-
-  // The graphic view's picker
-  Plot2d_QwtPlotPicker *picker = myPlot->getPicker();
-
-  // Clear points markers list and associations (marker,tooltip)
-  if ( picker ) {
-    picker->pMarkers.clear();         // QList<QwtPlotMarker*>
-    picker->pMarkersToolTip.clear();  // QMap<QwtPlotMarker*, QwtText>
-  }
-
   // 3)- Erase all QwtPlotCurve associated with the Plot2d_Curve
 
   int nbCur1 = myQwtPlotCurveList.size();
@@ -464,6 +462,7 @@ QString Plot2d_ViewFrame::getTitle() const
 */
 void Plot2d_ViewFrame::readPreferences()
 {
+#ifndef NO_SUIT
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
 
   myCurveType = resMgr->integerValue( "Plot2d", "CurveType", myCurveType );
@@ -471,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 );
@@ -507,11 +509,11 @@ void Plot2d_ViewFrame::readPreferences()
   setNormRMaxMode( resMgr->booleanValue( "Plot2d", "VerNormRMaxMode", myNormRMax ) );
   QColor c = resMgr->colorValue( "Plot2d", "DeviationMarkerColor", QColor(255,0,0));
   myPlot->setProperty(PLOT2D_DEVIATION_COLOR, c);
-  myPlot->setProperty(PLOT2D_DEVIATION_LW, 
+  myPlot->setProperty(PLOT2D_DEVIATION_LW,
                       resMgr->integerValue( "Plot2d", "DeviationMarkerLineWidth", 1));
-  myPlot->setProperty(PLOT2D_DEVIATION_TS, 
+  myPlot->setProperty(PLOT2D_DEVIATION_TS,
                       resMgr->integerValue( "Plot2d", "DeviationMarkerTickSize", 2));
-
+#endif
 }
 
 /*!
@@ -519,18 +521,25 @@ void Plot2d_ViewFrame::readPreferences()
 */
 void Plot2d_ViewFrame::writePreferences()
 {
+#ifndef NO_SUIT
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
 
   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 );
 
@@ -560,63 +569,64 @@ void Plot2d_ViewFrame::writePreferences()
   resMgr->setValue( "Plot2d", "VerNormLMaxMode", myNormLMax );
   resMgr->setValue( "Plot2d", "VerNormRMinMode", myNormRMin );
   resMgr->setValue( "Plot2d", "VerNormRMaxMode", myNormRMax );
+#endif
 }
 
 /*!
   Prints mouse cursor coordinates into string
 */
-QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) 
+QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
 {
   int i;
   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 );
     if ( xmark-2 == pnt.x() ) {
-      xCoord = majXmark; 
+      xCoord = majXmark;
       xFound = true;
       break;
     }
   }
   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 );
       if ( xmark-2 == pnt.x() ) {
-        xCoord = minXmark; 
+        xCoord = minXmark;
         xFound = true;
         break;
       }
     }
-  }  
-  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 );
     if ( ymark-2 == pnt.y() ) {
-      yCoord = majYmark; 
+      yCoord = majYmark;
       yFound = true;
       break;
     }
   }
   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 );
       if ( ymark-2 == pnt.y() ) {
-        yCoord = minYmark; 
+        yCoord = minYmark;
         yFound = true;
         break;
       }
     }
-  }  
+  }
 
   QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).trimmed();
   if ( strX == "-0" )
@@ -630,30 +640,30 @@ 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 );
       if ( ymark-2 == pnt.y() ) {
-        yCoord2 = majYmark; 
+        yCoord2 = majYmark;
         yFound2 = true;
         break;
       }
     }
     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 );
         if ( ymark-2 == pnt.y() ) {
-          yCoord2 = minYmark; 
+          yCoord2 = minYmark;
           yFound2 = true;
           break;
         }
       }
     }
-    QString strY2 = QString::number( yFound2 ? yCoord2 : 
+    QString strY2 = QString::number( yFound2 ? yCoord2 :
                       myPlot->invTransform( QwtPlot::yRight, pnt.y() ) ).trimmed();
     if ( strY2 == "-0" )
     strY2 = "0";
@@ -691,7 +701,7 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
   // Total number of curves
 
    // 1)- Construction of a list by component and by system
+
    // |      component 1      |      component 2      | ..... |      component M      |
    // | syst1 syst2 ... systN | syst1 syst2 ... systN | ..... | syst1 syst2 ... systN |
 
@@ -716,7 +726,7 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
   QwtScaleWidget *wid = myPlot->axisWidget( QwtPlot::xBottom);
   wid->setTitle("  "); // to make the names readable under X axis.
   QFont xFont = myPlot->axisFont(QwtPlot::xBottom);
-  xFont.setPointSize(8); 
+  xFont.setPointSize(8);
   myPlot->setAxisFont(QwtPlot::xBottom, xFont);
   return ret;
 }
@@ -735,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;
@@ -757,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;
@@ -853,7 +863,7 @@ QVector< QVector<QwtPlotCurve *> > Plot2d_ViewFrame::displayPlot2dCurveList( con
       QwtSymbol::Style symbolStyle1 = plot2dCurve1->getMarkerStyle();
       // We attribute to the current group's curve, the color, the line's kind
       // and the marker's kind of the first group's curve
-      
+
       for (icur=icur1+1; icur<icur1+groupSize; icur++)
         {
           Plot2d_Curve *plot2dCurve = curveList.at(icur);
@@ -879,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);
@@ -966,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)
 {
@@ -1006,7 +1017,7 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title,
   {
       if (!displayLegend)
         {
-          myPlot->insertLegend( (QwtLegend*)NULL);
+          myPlot->insertLegend( (QwtAbstractLegend*)NULL);
         }
       displayCurve( plot2dCurve);
 
@@ -1028,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);
@@ -1075,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);
@@ -1142,7 +1154,7 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update )
   updateObject( curve, update );
 }
 
-void Plot2d_ViewFrame::processFiltering(bool update) 
+void Plot2d_ViewFrame::processFiltering(bool update)
 {
   CurveDict aCurves = getCurves();
   AlgoPlot2dInputData aLData, aRData;
@@ -1158,7 +1170,7 @@ void Plot2d_ViewFrame::processFiltering(bool update)
 // Normalization by left Y axis
   if (!myNormLMin && !myNormLMax)
     myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeNone);
-  if(myNormLMin && myNormLMax)  
+  if(myNormLMin && myNormLMax)
     myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMinMax);
   else if(myNormLMin)
     myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMin);
@@ -1171,7 +1183,7 @@ void Plot2d_ViewFrame::processFiltering(bool update)
 // Normalization by right Y axis
   if (!myNormRMin && !myNormRMax)
     myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeNone);
-  if(myNormRMin && myNormRMax)  
+  if(myNormRMin && myNormRMax)
     myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMinMax);
   else if(myNormRMin)
     myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMin);
@@ -1228,11 +1240,11 @@ QwtPlotItem* Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update
   QwtPlotItem* anItem = 0;
   if ( !object )
     return anItem;
-  
+
   if ( object->getYAxis() == QwtPlot::yRight )
     mySecondY = true;
 
-  // san -- Protection against QwtCurve bug in Qwt 0.4.x: 
+  // san -- Protection against QwtCurve bug in Qwt 0.4.x:
   // it crashes if switched to X/Y logarithmic mode, when one or more points have
   // non-positive X/Y coordinate
   if ( myXMode && object->getMinX() <= 0. )
@@ -1242,7 +1254,7 @@ QwtPlotItem* Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update
 
   if ( object->isAutoAssign() )
     object->autoFill( myPlot );
-  
+
   if ( hasPlotObject( object ) ) {
     processFiltering(update);
     updateObject( object, update );
@@ -1258,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 );
@@ -1272,11 +1279,12 @@ QwtPlotItem* Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update
       }
     }
   }
-  updateTitles();
+  updateTitles( false );
   myPlot->updateYAxisIdentifiers();
-  if ( update )
+  if ( update ) {
     myPlot->replot();
-  if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+    if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase(false);
+  }
   return anItem;
 }
 
@@ -1307,7 +1315,9 @@ void Plot2d_ViewFrame::eraseObject( Plot2d_Object* object, bool update )
     QwtPlotItem* anObject = getPlotObject( object );
     eraseBasicObject(anObject,update);
   }
-  if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+  if (update) {
+    if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+  }
 }
 
 void Plot2d_ViewFrame::eraseBasicObject( QwtPlotItem *object, bool update )
@@ -1317,7 +1327,7 @@ void Plot2d_ViewFrame::eraseBasicObject( QwtPlotItem *object, bool update )
   object->hide();
   object->detach();
   myObjects.remove(object);
-  updateTitles();
+  updateTitles(update);
   myPlot->updateYAxisIdentifiers();
   if ( update )
     myPlot->replot();
@@ -1360,9 +1370,10 @@ void Plot2d_ViewFrame::updateObject( Plot2d_Object* object, bool update )
       return;
     updatePlotItem(object, anItem );
     anItem->setVisible( true );
-    if ( update )
+    if ( update ) {
       myPlot->replot();
-    if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+      if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase(false);
+    }
   }
 }
 
@@ -1385,7 +1396,7 @@ int Plot2d_ViewFrame::getObjects( objectList& objects ) const
 bool Plot2d_ViewFrame::isVisible( Plot2d_Object* object ) const
 {
   return object && hasPlotObject( object ) && getPlotObject( object )->isVisible();
-} 
+}
 
 /*!
   update legend
@@ -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,19 +1435,14 @@ 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;
-  }
-
-  myPlot->setAxisAutoScale( QwtPlot::yLeft );
-  myPlot->setAxisAutoScale( QwtPlot::xBottom );
-  myPlot->replot();
+  // no need to set auto scaling, it will be disabled by setAxisScale() method call
+  // myPlot->setAxisAutoScale( QwtPlot::yLeft );
+  // myPlot->setAxisAutoScale( QwtPlot::xBottom );
+  // myPlot->replot();
 
   double xmin, xmax, y1min, y1max, y2min, y2max;
   getFitRangeByCurves(xmin, xmax, y1min, y1max, y2min, y2max);
+  getFitRangeByMarkers(xmin, xmax, y1min, y1max, y2min, y2max);
 
   myPlot->setAxisScale( QwtPlot::xBottom, xmin, xmax );
   myPlot->setAxisScale( QwtPlot::yLeft, y1min, y1max );
@@ -1445,7 +1453,7 @@ void Plot2d_ViewFrame::fitAll()
     myPlot->setAxisScale( QwtPlot::yRight, y2min, y2max );
   }
   myPlot->replot();
-  if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+  if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase(false);
 }
 
 /*!
@@ -1462,15 +1470,15 @@ void Plot2d_ViewFrame::fitArea( const QRect& area )
     rect.setHeight( MIN_RECT_SIZE );
     rect.setTop( rect.top() - MIN_RECT_SIZE/2 );
   }
-  myPlot->setAxisScale( QwtPlot::yLeft, 
-            myPlot->invTransform( QwtPlot::yLeft, rect.top() ), 
+  myPlot->setAxisScale( QwtPlot::yLeft,
+            myPlot->invTransform( QwtPlot::yLeft, rect.top() ),
             myPlot->invTransform( QwtPlot::yLeft, rect.bottom() ) );
   if (mySecondY)
-    myPlot->setAxisScale( QwtPlot::yRight, 
-            myPlot->invTransform( QwtPlot::yRight, rect.top() ), 
+    myPlot->setAxisScale( QwtPlot::yRight,
+            myPlot->invTransform( QwtPlot::yRight, rect.top() ),
             myPlot->invTransform( QwtPlot::yRight, rect.bottom() ) );
-  myPlot->setAxisScale( QwtPlot::xBottom, 
-            myPlot->invTransform( QwtPlot::xBottom, rect.left() ), 
+  myPlot->setAxisScale( QwtPlot::xBottom,
+            myPlot->invTransform( QwtPlot::xBottom, rect.left() ),
             myPlot->invTransform( QwtPlot::xBottom, rect.right() ) );
   myPlot->replot();
   if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
@@ -1489,8 +1497,8 @@ void Plot2d_ViewFrame::fitData(const int mode,
     if (mySecondY)
       myPlot->setAxisScale( QwtPlot::yRight, y2Min, y2Max );
   }
-  if ( mode == 0 || mode == 1 ) 
-    myPlot->setAxisScale( QwtPlot::xBottom, xMin, xMax ); 
+  if ( mode == 0 || mode == 1 )
+    myPlot->setAxisScale( QwtPlot::xBottom, xMin, xMax );
   myPlot->replot();
   if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
 }
@@ -1586,15 +1594,56 @@ void Plot2d_ViewFrame::getFitRangeByCurves(double& xMin,  double& xMax,
   }
 }
 
+/*!
+  Gets current fit ranges by Markers
+  All parameters are inout.
+*/
+void Plot2d_ViewFrame::getFitRangeByMarkers(double& xMin,  double& xMax,
+                                            double& yMin,  double& yMax,
+                                            double& y2Min, double& y2Max)
+{
+  Plot2d_QwtPlotPicker *picker=myPlot->getPicker();
+  if(!picker)
+    return;
+  if(picker->pMarkers.empty())
+    return;
+  foreach(QwtPlotMarker *mrker,picker->pMarkers)
+    {
+      bool isV2 = mrker->yAxis() == QwtPlot::yRight;
+      xMin = qMin( xMin, mrker->xValue() );
+      xMax = qMax( xMax, mrker->xValue() );
+      if ( isV2 ) {
+        y2Min = qMin( y2Min, mrker->yValue() );
+        y2Max = qMax( y2Max, mrker->yValue() );
+      }
+      else {
+        yMin = qMin( yMin, mrker->yValue() );
+        yMax = qMax( yMax, mrker->yValue() );
+      }
+      if ( xMin == xMax ) {
+        xMin = xMin == 0. ? -1. : xMin - xMin/10.;
+        xMax = xMax == 0. ?  1. : xMax + xMax/10.;
+      }
+      if ( yMin == yMax ) {
+        yMin = yMin == 0. ? -1. : yMin - yMin/10.;
+        yMax = yMax == 0. ?  1  : yMax + yMax/10.;
+      }
+      if ( y2Min == y2Max ) {
+        y2Min = y2Min == 0. ? -1. : y2Min - y2Min/10.;
+        y2Max = y2Max == 0. ?  1  : y2Max + y2Max/10.;
+      }
+    }
+}
+
 /*!
   Tests if it is necessary to start operation on mouse action
 */
 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 ) {
@@ -1657,7 +1706,7 @@ void Plot2d_ViewFrame::onSettings()
       cols[ "blue-min" ] = color.blue();
   }
 #endif
-  
+
   Plot2d_SetupViewDlg* dlg = new Plot2d_SetupViewDlg( this, true, mySecondY );
   dlg->setMainTitle( myTitleEnabled, myTitle );
   dlg->setXTitle( myXTitleEnabled, myXTitle );
@@ -1665,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);
@@ -1703,7 +1754,7 @@ void Plot2d_ViewFrame::onSettings()
       setTitle( dlg->isY2TitleEnabled(), dlg->getY2Title(), Y2Title, false );
 
     // main title
-    if( dlg->isMainTitleEnabled() && myTitle != dlg->getMainTitle() ) 
+    if( dlg->isMainTitleEnabled() && myTitle != dlg->getMainTitle() )
       myIsDefTitle = false;
     setTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), MainTitle, true );
     // curve type
@@ -1716,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() );
@@ -1723,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() ) {
@@ -1732,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;
@@ -1763,47 +1824,42 @@ void Plot2d_ViewFrame::onSettings()
       setNormRMaxMode( dlg->getRMaxNormMode() );
     }
 
-    myPlot->setProperty(PLOT2D_DEVIATION_COLOR, 
+    myPlot->setProperty(PLOT2D_DEVIATION_COLOR,
                         dlg->getDeviationMarkerCl());
-    myPlot->setProperty(PLOT2D_DEVIATION_LW, 
+    myPlot->setProperty(PLOT2D_DEVIATION_LW,
                         dlg->getDeviationMarkerLw());
-    myPlot->setProperty(PLOT2D_DEVIATION_TS, 
+    myPlot->setProperty(PLOT2D_DEVIATION_TS,
                          dlg->getDeviationMarkerTs());
 
 
     // update view
     myPlot->replot();
     // update preferences
-    if ( dlg->isSetAsDefault() ) 
+    if ( dlg->isSetAsDefault() )
       writePreferences();
   }
   delete dlg;
 }
 
+#ifndef NO_ANALYTICAL_CURVES
 /*!
   "Analytical Curves" toolbar action slot
 */
 void Plot2d_ViewFrame::onAnalyticalCurve()
 {
-#ifndef DISABLE_PYCONSOLE
   Plot2d_AnalyticalCurveDlg dlg( this, this );
   dlg.exec();
   updateAnalyticalCurves();
-#endif
 }
 
 void Plot2d_ViewFrame::addAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
 {
-#ifndef DISABLE_PYCONSOLE
-       myAnalyticalCurves.append(theCurve);
-#endif
+  myAnalyticalCurves.append(theCurve);
 }
 
 void Plot2d_ViewFrame::removeAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
 {
-#ifndef DISABLE_PYCONSOLE
-       theCurve->setAction(Plot2d_AnalyticalCurve::ActRemoveFromView);
-#endif
+  theCurve->setAction(Plot2d_AnalyticalCurve::ActRemoveFromView);
 }
 
 /*
@@ -1811,47 +1867,44 @@ void Plot2d_ViewFrame::removeAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
 */
 void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool updateView)
 {
-#ifndef DISABLE_PYCONSOLE
   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();
-  
+
   switch( c->getAction() ) {
   case Plot2d_AnalyticalCurve::ActAddInView:
     if( c->isActive() ) {
       c->updatePlotItem();
       item->attach( myPlot );
+      item->itemChanged();
       item->show();
     }
     c->setAction(Plot2d_AnalyticalCurve::ActNothing);
     break;
-    
+
   case Plot2d_AnalyticalCurve::ActUpdateInView:
     if(c->isActive()) {
       c->updatePlotItem();
       item->show();
-    } else {      
+    } else {
       item->hide();
       item->detach();
     }
-    
+
     c->setAction(Plot2d_AnalyticalCurve::ActNothing);
-    break;    
+    break;
   case Plot2d_AnalyticalCurve::ActRemoveFromView:
     item->hide();
     item->detach();
-    myAnalyticalCurves.removeAll(c);
-    delete c;
     break;
   }
 
   if(updateView)
     myPlot->replot();
-#endif
 }
 
 /*
@@ -1859,13 +1912,22 @@ void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool upd
 */
 void Plot2d_ViewFrame::updateAnalyticalCurves()
 {
-#ifndef DISABLE_PYCONSOLE
   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();
-#endif
 }
 
 /*!
@@ -1873,22 +1935,21 @@ void Plot2d_ViewFrame::updateAnalyticalCurves()
 */
 AnalyticalCurveList Plot2d_ViewFrame::getAnalyticalCurves() const
 {
-  return myAnalyticalCurves;
+  return myAnalyticalCurves  ;
 }
 
 /*!
   Get analytical curve by plot item.
 */
 Plot2d_AnalyticalCurve* Plot2d_ViewFrame::getAnalyticalCurve(QwtPlotItem * theItem) {
-#ifndef DISABLE_PYCONSOLE
   AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
   for( ; it != myAnalyticalCurves.end(); it++) {
-    if((*it)->plotItem() == theItem);
-               return (*it);
+    if((*it)->plotItem() == theItem)
+      return (*it);
   }
   return 0;
-#endif
 }
+#endif
 
 /*!
   "Fit Data" command slot
@@ -1898,14 +1959,16 @@ void Plot2d_ViewFrame::onFitData()
   Plot2d_FitDataDlg* dlg = new Plot2d_FitDataDlg( this, mySecondY );
   double xMin,xMax,yMin,yMax,y2Min,y2Max;
   getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
-  
+
   dlg->setRange( xMin, xMax, yMin, yMax, y2Min, y2Max );
   if ( dlg->exec() == QDialog::Accepted ) {
     int mode = dlg->getRange( xMin, xMax, yMin, yMax, y2Min, y2Max );
     fitData(mode,xMin,xMax,yMin,yMax,y2Min,y2Max);
   }
   delete dlg;
+#ifndef NO_ANALYTICAL_CURVES
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -1913,7 +1976,7 @@ void Plot2d_ViewFrame::onFitData()
 */
 void Plot2d_ViewFrame::onChangeBackground()
 {
-  QColor selColor = QColorDialog::getColor ( backgroundColor(), this ); 
+  QColor selColor = QColorDialog::getColor ( backgroundColor(), this );
   if ( selColor.isValid() ) {
     setBackgroundColor( selColor );
   }
@@ -1932,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();
@@ -1950,7 +2020,7 @@ int Plot2d_ViewFrame::getCurveType() const
   \param curveKey - curve id
   \param title - new title
 */
-void Plot2d_ViewFrame::setCurveTitle( Plot2d_Curve* curve, const QString& title ) 
+void Plot2d_ViewFrame::setCurveTitle( Plot2d_Curve* curve, const QString& title )
 {
   setObjectTitle( curve, title );
 }
@@ -1960,11 +2030,11 @@ void Plot2d_ViewFrame::setCurveTitle( Plot2d_Curve* curve, const QString& title
   \param object - object id
   \param title - new title
 */
-void Plot2d_ViewFrame::setObjectTitle( Plot2d_Object* object, const QString& title ) 
-{ 
+void Plot2d_ViewFrame::setObjectTitle( Plot2d_Object* object, const QString& title )
+{
   if ( object && hasPlotObject( object ) )
     getPlotObject( object )->setTitle( title );
-}   
+}
 
 /*!
   Shows/hides legend
@@ -1973,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 );
-      legend->setFrameStyle( QFrame::Box | QFrame::Sunken );      
+    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 );
+    }
+    else {
+      legend = dynamic_cast<QwtLegend*>(absLegend);
+    }
+    if(legend) {
+      myPlot->insertLegend( legend );
+      setLegendPos( myLegendPos );
+      setLegendFont( myLegendFont );
+      setLegendFontColor( myLegendColor );
     }
-    legend->setItemMode( QwtLegend::ClickableItem );
-    myPlot->insertLegend( legend );
-    setLegendPos( myLegendPos );
-    setLegendFont( myLegendFont );
-    setLegendFontColor( myLegendColor );  
   }
   else
     myPlot->insertLegend( 0 );
+
+  if( show && update )
+    updateLegend();
+
   if ( update )
     myPlot->replot();
 }
@@ -1996,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:
@@ -2023,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);
   }
@@ -2043,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 );
@@ -2065,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
 */
@@ -2079,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 )
@@ -2118,6 +2235,7 @@ void Plot2d_ViewFrame::setBackgroundColor( const QColor& color )
   }
   Repaint();
 }
+
 /*!
   Gets background color
 */
@@ -2125,11 +2243,29 @@ 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
 */
-void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax, 
-         bool xMinorEnabled, const int xMinorMax, 
+void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax,
+         bool xMinorEnabled, const int xMinorMax,
          bool update )
 {
   myXGridMajorEnabled = xMajorEnabled;
@@ -2141,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 );
 
@@ -2152,10 +2288,10 @@ void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax,
 /*!
   Sets ver.axis grid parameters
 */
-void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax, 
+void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax,
                                  bool yMinorEnabled, const int yMinorMax,
-                                 bool y2MajorEnabled, const int y2MajorMax, 
-                                 bool y2MinorEnabled, const int y2MinorMax, 
+                                 bool y2MajorEnabled, const int y2MajorMax,
+                                 bool y2MinorEnabled, const int y2MinorMax,
                                  bool update )
 {
   myYGridMajorEnabled = yMajorEnabled;
@@ -2178,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) {
@@ -2187,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 );
     }
@@ -2292,16 +2428,26 @@ void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update )
   if ( myXMode == mode )
     return;
 
-  // san -- Protection against QwtCurve bug in Qwt 0.4.x: 
+  // san -- Protection against QwtCurve bug in Qwt 0.4.x:
   // it crashes if switched to X/Y logarithmic mode, when one or more points have
   // non-positive X/Y coordinate
   if ( mode && !isXLogEnabled() ){
-    SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+#ifndef NO_SUIT
+    SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+#else
+    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 )
@@ -2325,18 +2471,34 @@ void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update )
   if ( myYMode == mode )
     return;
 
-  // san -- Protection against QwtCurve bug in Qwt 0.4.x: 
+  // san -- Protection against QwtCurve bug in Qwt 0.4.x:
   // it crashes if switched to X/Y logarithmic mode, when one or more points have
   // non-positive X/Y coordinate
   if ( mode && !isYLogEnabled() ){
-    SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+#ifndef NO_SUIT
+    SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+#else
+    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();
@@ -2504,29 +2666,31 @@ bool Plot2d_ViewFrame::isLegendShow() const
 */
 void Plot2d_ViewFrame::plotMousePressed( const QMouseEvent& me )
 {
+#ifndef NO_SUIT
   Plot2d_ViewWindow* aParent = dynamic_cast<Plot2d_ViewWindow*>(parent());
   if (aParent)
      aParent->putInfo(getInfo(me.pos()));
+#endif
   if ( myOperation == NoOpId )
     myOperation = testOperation( me );
   if ( myOperation != NoOpId ) {
     myPnt = me.pos();
     if ( myOperation == GlPanId ) {
       myPlot->setAxisScale( QwtPlot::yLeft,
-          myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) - myYDistance/2, 
+          myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) - myYDistance/2,
           myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) + myYDistance/2 );
-      myPlot->setAxisScale( QwtPlot::xBottom, 
-          myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) - myXDistance/2, 
+      myPlot->setAxisScale( QwtPlot::xBottom,
+          myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) - myXDistance/2,
           myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) + myXDistance/2 );
       if (mySecondY)
         myPlot->setAxisScale( QwtPlot::yRight,
-          myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) - myYDistance2/2, 
+          myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) - myYDistance2/2,
           myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) + myYDistance2/2 );
       myPlot->replot();
     }
   }
   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() );
@@ -2534,7 +2698,7 @@ void Plot2d_ViewFrame::plotMousePressed( const QMouseEvent& me )
       parent()->eventFilter(this, aEvent);
     }
   }
-  setFocus(); 
+  setFocus();
 }
 /*!
   Slot, called when user moves mouse
@@ -2547,7 +2711,7 @@ bool Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me )
   bool aRes = false;
   if ( myOperation != NoOpId) {
     if ( myOperation == ZoomId ) {
-      this->incrementalZoom( dx, dy ); 
+      this->incrementalZoom( dx, dy );
       myPnt = me.pos();
       aRes = true;
     }
@@ -2558,9 +2722,11 @@ bool Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me )
     }
   }
   else {
+#ifndef NO_SUIT
      Plot2d_ViewWindow* aParent = dynamic_cast<Plot2d_ViewWindow*>(parent());
      if (aParent)
        aParent->putInfo(getInfo(me.pos()));
+#endif
   }
   return aRes;
 }
@@ -2574,43 +2740,47 @@ void Plot2d_ViewFrame::plotMouseReleased( const QMouseEvent& me )
     QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
                               me.pos(), me.globalPos() );
     emit contextMenuRequested( &aEvent );
-  } 
+  }
   else {
+#ifndef NO_ANALYTICAL_CURVES
     updateAnalyticalCurves();
+#endif
   }
   myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) );
   myPlot->defaultPicker();
 
+#ifndef NO_SUIT
   Plot2d_ViewWindow* aParent = dynamic_cast<Plot2d_ViewWindow*>(parent());
    if (aParent)
      aParent->putInfo(tr("INF_READY"));
+#endif
   myOperation = NoOpId;
 }
 /*!
   Slot, called when user wheeling mouse
 */
 void Plot2d_ViewFrame::wheelEvent(QWheelEvent* event)
-{ 
+{
   QwtPlotLayout* pl = myPlot->plotLayout();
 
   // compute zooming factor
   double aDelta = event->delta();
-  double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.; 
+  double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.;
 
-  bool scaleXBottom = pl->scaleRect(QwtPlot::xBottom).contains( event->pos() ) || 
+  bool scaleXBottom = pl->scaleRect(QwtPlot::xBottom).contains( event->pos() ) ||
                       pl->canvasRect().contains( event->pos() );
-  bool scaleYLeft   = pl->scaleRect(QwtPlot::yLeft).contains( event->pos() ) || 
+  bool scaleYLeft   = pl->scaleRect(QwtPlot::yLeft).contains( event->pos() ) ||
                       pl->canvasRect().contains( event->pos() );
-  bool scaleYRight  = mySecondY && ( pl->scaleRect(QwtPlot::yRight).contains( event->pos() ) || 
+  bool scaleYRight  = mySecondY && ( pl->scaleRect(QwtPlot::yRight).contains( event->pos() ) ||
                                     pl->canvasRect().contains( event->pos() ) );
 
   // scale x bottom axis
-  if ( scaleXBottom ) { 
+  if ( scaleXBottom ) {
     QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
     if ( xMap.s2() - xMap.s1() > 1.0e-12 || aScale > 1 )
       myPlot->setAxisScale( QwtPlot::xBottom, xMap.s1(), xMap.s1() + aScale*(xMap.s2() - xMap.s1()) );
   }
-  
+
   // scale y left axis
   if ( scaleYLeft ) {
     QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
@@ -2624,15 +2794,17 @@ void Plot2d_ViewFrame::wheelEvent(QWheelEvent* event)
     if ( yMap.s2() - yMap.s1() > 10e-12 || aScale > 1 )
       myPlot->setAxisScale( QwtPlot::yRight, yMap.s1(), yMap.s1() + aScale*(yMap.s2() - yMap.s1()) );
   }
-  
+
   // redraw
   myPlot->replot();
   // update zoomer
   if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
   // store current mouse position
   myPnt = event->pos();
+#ifndef NO_ANALYTICAL_CURVES
   // update analytical curves
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -2678,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;
@@ -2701,7 +2873,10 @@ void Plot2d_ViewFrame::setCurveType( QwtPlotCurve* curve, int curveType )
   View operations : Pan view
 */
 void Plot2d_ViewFrame::onViewPan()
-{ 
+{
+  // reset the previous operation
+  myPlot->defaultPicker();
+
   QCursor panCursor (Qt::SizeAllCursor);
   myPlot->canvas()->setCursor( panCursor );
   myOperation = PanId;
@@ -2709,24 +2884,32 @@ void Plot2d_ViewFrame::onViewPan()
 /*!
   View operations : Zoom view
 */
-void Plot2d_ViewFrame::onViewZoom() 
+void Plot2d_ViewFrame::onViewZoom()
 {
+  // reset the previous operation
+  myPlot->defaultPicker();
+
   QPixmap zoomPixmap (imageZoomCursor);
   QCursor zoomCursor (zoomPixmap);
   myPlot->canvas()->setCursor( zoomCursor );
   myOperation = ZoomId;
 }
 /*!
-  View operations : Fot All
+  View operations : Fit All
 */
-void Plot2d_ViewFrame::onViewFitAll() 
-{ 
+void Plot2d_ViewFrame::onViewFitAll()
+{
   fitAll();
+
+  // reset the previous operation
+  myPlot->defaultPicker();
+  myPlot->canvas()->setCursor( QCursor(Qt::CrossCursor) );
+  myOperation = NoOpId;
 }
 /*!
   View operations : Fit Area
 */
-void Plot2d_ViewFrame::onViewFitArea() 
+void Plot2d_ViewFrame::onViewFitArea()
 {
   myPlot->canvas()->setCursor( QCursor( Qt::PointingHandCursor ) );
   myOperation = FitAreaId;
@@ -2735,8 +2918,11 @@ void Plot2d_ViewFrame::onViewFitArea()
 /*!
   View operations : Global panning
 */
-void Plot2d_ViewFrame::onViewGlobalPan() 
+void Plot2d_ViewFrame::onViewGlobalPan()
 {
+  // reset the previous operation
+  myPlot->defaultPicker();
+
   QPixmap globalPanPixmap (imageCrossCursor);
   QCursor glPanCursor (globalPanPixmap);
   myPlot->canvas()->setCursor( glPanCursor );
@@ -2755,7 +2941,8 @@ void Plot2d_ViewFrame::onViewGlobalPan()
     QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
     myYDistance2 = yMap2.s2() - yMap2.s1();
   }
-  fitAll();
+  // don't make fit all
+  // fitAll();
   myOperation = GlPanId;
 }
 
@@ -2798,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 );
@@ -2813,7 +3000,7 @@ public:
 */
 Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   : QwtPlot( parent ),
-    myIsPolished( false )
+    myPicker( 0 )
 {
   // Create alternative scales
   setAxisScaleDraw( QwtPlot::yLeft,   new Plot2d_ScaleDraw() );
@@ -2821,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 ) );
@@ -2832,11 +3018,11 @@ Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   setAxisAutoScale( QwtPlot::yLeft );
   setAxisAutoScale( QwtPlot::yRight );
   setAxisAutoScale( QwtPlot::xBottom );
-  
+
   myScaleDraw = NULL;
 // grid
   myGrid = new QwtPlotGrid();
-  QPen aMajPen = myGrid->majPen();
+  QPen aMajPen = myGrid->majorPen();
   aMajPen.setStyle( Qt::DashLine );
   myGrid->setPen( aMajPen );
 
@@ -2866,13 +3052,13 @@ 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() );
 }
 
 /*!
-  Recalculates and redraws Plot 2d view 
+  Recalculates and redraws Plot 2d view
 */
 void Plot2d_Plot2d::replot()
 {
@@ -2897,17 +3083,17 @@ void Plot2d_Plot2d::replot()
   enableAxis( QwtPlot::yRight,  enableYRight );
 
   updateLayout();  // to fix bug(?) of Qwt - view is not updated when title is changed
-  QwtPlot::replot(); 
+  QwtPlot::replot();
 }
 
 /*!
   Get legend
 */
-QwtLegend* Plot2d_Plot2d::getLegend()
+QwtAbstractLegend* Plot2d_Plot2d::getLegend()
 {
 #if QWT_VERSION < 0x040200
   return d_legend;
-#else  
+#else
   return legend(); /* mpv: porting to the Qwt 4.2.0 */
 #endif
 }
@@ -2935,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 );
 }
 
 /*!
@@ -2954,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();
 
@@ -2968,7 +3156,7 @@ QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
   aPlotMarker->setYValue(Y);
   //
   aPlotMarker->attach(this);
-                       
+
   // Associate a tooltip with the point's marker
   // PB: how to obtain a tooltip with a rectangular frame ?
   //QwtText tooltip ("X=" + QString::number(X) + " Y=" + QString::number(Y) );
@@ -2979,65 +3167,22 @@ QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
   text.setBackgroundBrush( QBrush(tooltipColor)); //, Qt::SolidPattern));
   //
   if ( picker ) {
-    picker->pMarkers.append( aPlotMarker); 
+    picker->pMarkers.append( aPlotMarker);
     picker->pMarkersToolTip[ aPlotMarker] = text;
   }
   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.
 */
@@ -3062,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
@@ -3137,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
 
@@ -3279,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
@@ -3300,9 +3450,13 @@ 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;
-  myTitle = vf->myTitle; 
+  mySelectionColor = vf->mySelectionColor;
+  myTitle = vf->myTitle;
   myXTitle = vf->myXTitle;
   myYTitle = vf->myYTitle;
   myY2Title = vf->myY2Title;
@@ -3331,7 +3485,7 @@ void Plot2d_ViewFrame::copyPreferences( Plot2d_ViewFrame* vf )
   Updates titles according to curves
 */
 #define BRACKETIZE(x) QString( "[ " ) + x + QString( " ]" )
-void Plot2d_ViewFrame::updateTitles(
+void Plot2d_ViewFrame::updateTitles( const bool update )
 {
   ObjectDict::iterator it = myObjects.begin();
   QStringList aXTitles;
@@ -3351,7 +3505,7 @@ void Plot2d_ViewFrame::updateTitles()
     QString yTitle = anObject->getVerTitle().trimmed();
     QString xUnits = anObject->getHorUnits().trimmed();
     QString yUnits = anObject->getVerUnits().trimmed();
-    
+
     if ( anObject->getYAxis() == QwtPlot::yLeft ) {
       if ( !aYTitles.contains( yTitle ) )
         aYTitles.append( yTitle );
@@ -3397,12 +3551,17 @@ void Plot2d_ViewFrame::updateTitles()
   if ( !y2Title.isEmpty() && !y2Units.isEmpty() )
     y2Title += " ";
 
-  setTitle( myXTitleEnabled, xTitle + xUnits, XTitle, true );
-  setTitle( myYTitleEnabled, yTitle + yUnits, YTitle, true );
+  setTitle( myXTitleEnabled, xTitle + xUnits, XTitle, false );
+  setTitle( myYTitleEnabled, yTitle + yUnits, YTitle, false );
   if ( mySecondY )
-    setTitle( myY2TitleEnabled, y2Title + y2Units, Y2Title, true );
-  if( myIsDefTitle ) 
-    setTitle( true, aTables.join("; "), MainTitle, true );
+    setTitle( myY2TitleEnabled, y2Title + y2Units, Y2Title, false );
+  if( myIsDefTitle )
+    setTitle( true, aTables.join("; "), MainTitle, false );
+
+  // do update if necessary
+  if ( update ) {
+    myPlot->replot();
+  }
 }
 
 /*!
@@ -3420,9 +3579,11 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const
   if( myPlot )
   {
     QPaintDevice* pd = 0;
-    if( format=="PS" || format=="EPS" )
+    if( format=="PS" || format=="EPS" || format == "PDF" )
     {
       QPrinter* pr = new QPrinter( QPrinter::HighResolution );
+      if(format == "PDF")
+         pr->setOutputFormat(QPrinter::PdfFormat);
       pr->setPageSize( QPrinter::A4 );
       pr->setOutputFileName( file );
       pr->setPrintProgram( "" );
@@ -3431,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 );
 }
 
 /*!
@@ -3464,22 +3627,22 @@ QString Plot2d_ViewFrame::getVisualParameters()
   getFitRanges( xmin, xmax, ymin, ymax, y2min, y2max );
   QString retStr;
   //Store font in the visual parameters string as:
-  //  
+  //
   // ...*FontFamily|FontSize|B|I|U|r:g:b*...
-  
+
   retStr.sprintf( "%d*%d*%d*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%s|%i|%i|%i|%i|%i:%i:%i",
                  myXMode, myYMode, mySecondY, xmin, xmax, ymin, ymax, y2min, y2max,
                  qPrintable(myLegendFont.family()), myLegendFont.pointSize(),myLegendFont.bold(),
                  myLegendFont.italic(), myLegendFont.underline(),myLegendColor.red(),
                  myLegendColor.green(), myLegendColor.blue());
-  
+
  //store all Analytical curves
   //store each curve in the following format
   // ...*Name|isActive|Expresion|NbInervals|isAutoAssign[|MarkerType|LineType|LineWidth|r:g:b]
   // parameters in the [ ] is optional in case if isAutoAssign == true
   AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
   Plot2d_AnalyticalCurve* c = 0;
-  bool isAuto; 
+  bool isAuto;
   for( ; it != myAnalyticalCurves.end(); it++) {
     c = (*it);
     if(!c) continue;
@@ -3506,7 +3669,7 @@ QString Plot2d_ViewFrame::getVisualParameters()
     }
   }
   retStr += QString( "*%1" ).arg( Qtx::colorToString( backgroundColor() ) );
-  return retStr; 
+  return retStr;
   */
 }
 
@@ -3536,12 +3699,12 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters )
       setTitle( myY2TitleEnabled, myY2Title, Y2Title, false );
     setHorScaleMode( myXMode, /*update=*/false );
     setVerScaleMode( myYMode, /*update=*/false );
-    
+
     if (mySecondY) {
       QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
       myYDistance2 = yMap2.s2() - yMap2.s1();
     }
-    
+
     fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );
     fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );
   }
@@ -3564,9 +3727,10 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters )
                                                 colorList[2].toInt());
              setLegendFontColor( myLegendColor );
       }
-    }    
+    }
   }
 
+#ifndef NO_ANALYTICAL_CURVES
   //Restore all Analytical curves
   int startCurveIndex = 10;
   if( paramsLst.size() >= startCurveIndex+1 ) {
@@ -3604,6 +3768,7 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters )
     }
     myPlot->replot();
   }
+#endif
 }
 
 /*!
@@ -3658,11 +3823,12 @@ QString Plot2d_ViewFrame::getXmlVisualParameters() {
   aWriter.writeEndElement();
   aWriter.writeEndElement();
 
+#ifndef NO_ANALYTICAL_CURVES
   //AnalyticalCurve
-  aWriter.writeStartElement("AnalyticalCurves");  
+  aWriter.writeStartElement("AnalyticalCurves");
   AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
   Plot2d_AnalyticalCurve* c = 0;
-  bool isAuto; 
+  bool isAuto;
   int id = 1;
   for( ; it != myAnalyticalCurves.end(); it++) {
     c = (*it);
@@ -3672,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()));
@@ -3686,10 +3852,11 @@ QString Plot2d_ViewFrame::getXmlVisualParameters() {
     id++;
   }
   aWriter.writeEndElement(); //AnalyticalCurve
+#endif
 
   //Background
-  aWriter.writeStartElement(QString("Background").arg(id));
-  aWriter.writeStartElement(QString("BackgroundColor").arg(id));
+  aWriter.writeStartElement(QString("Background"));
+  aWriter.writeStartElement(QString("BackgroundColor"));
   aWriter.writeAttribute("R", QString("").sprintf("%d",backgroundColor().red()));
   aWriter.writeAttribute("G", QString("").sprintf("%d",backgroundColor().green()));
   aWriter.writeAttribute("B", QString("").sprintf("%d",backgroundColor().blue()));
@@ -3705,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()) {
@@ -3743,6 +3910,7 @@ bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
                  setLegendFontColor( myLegendColor );
             setLegendFont(myLegendFont);
         } else if(aReader.name().toString().indexOf("AnalyticalCurve_") >= 0) {
+#ifndef NO_ANALYTICAL_CURVES
             Plot2d_AnalyticalCurve* c = new Plot2d_AnalyticalCurve();
                  c->setName(aAttr.value("Name").toString());
                  c->setActive((bool)aAttr.value("IsActive").toString().toInt());
@@ -3752,7 +3920,7 @@ bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
                  if( !c->isAutoAssign() ) {
                    c->setMarker((Plot2d::MarkerType)aAttr.value("Marker").toString().toInt());
                    c->setLine((Plot2d::LineType)aAttr.value("Line").toString().toInt());
-                   c->setLineWidth(aAttr.value("LineWidth").toString().toInt());               
+                   c->setLineWidth(aAttr.value("LineWidth").toString().toInt());
                    c->setColor(QColor(aAttr.value("R").toString().toInt(),
                                                   aAttr.value("G").toString().toInt(),
                                                   aAttr.value("B").toString().toInt()));
@@ -3761,6 +3929,7 @@ bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
                  }
                  addAnalyticalCurve(c);
                  updateAnalyticalCurve(c);
+#endif
         } else if(aReader.name().toString() == "BackgroundColor") {
           setBackgroundColor(QColor(aAttr.value("R").toString().toInt(),
                                                      aAttr.value("G").toString().toInt(),
@@ -3775,11 +3944,11 @@ bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
   if (mySecondY)
     setTitle( myY2TitleEnabled, myY2Title, Y2Title, false );
   setHorScaleMode( myXMode, /*update=*/false );
-  setVerScaleMode( myYMode, /*update=*/false );    
+  setVerScaleMode( myYMode, /*update=*/false );
   if (mySecondY) {
     QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
     myYDistance2 = yMap2.s2() - yMap2.s1();
-  }    
+  }
   setNormLMinMode(leftMin);
   setNormLMaxMode(leftMax);
   setNormRMinMode(rightMin);
@@ -3787,7 +3956,7 @@ bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
 
   showLegend( myShowLegend, false );
 
-  fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );  
+  fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );
   return true;
 }
 
@@ -3797,17 +3966,17 @@ bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
 void Plot2d_ViewFrame::incrementalPan( const int incrX, const int incrY ) {
   QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
   QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
-  
-  myPlot->setAxisScale( QwtPlot::yLeft, 
-                        myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s1() )-incrY ), 
+
+  myPlot->setAxisScale( QwtPlot::yLeft,
+                        myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s1() )-incrY ),
                         myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s2() )-incrY ) );
-  myPlot->setAxisScale( QwtPlot::xBottom, 
+  myPlot->setAxisScale( QwtPlot::xBottom,
                         myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s1() )-incrX ),
-                        myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s2() )-incrX ) ); 
+                        myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s2() )-incrX ) );
   if (mySecondY) {
     QwtScaleMap y2Map = myPlot->canvasMap( QwtPlot::yRight );
     myPlot->setAxisScale( QwtPlot::yRight,
-                          myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.s1() )-incrY ), 
+                          myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.s1() )-incrY ),
                           myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.s2() )-incrY ) );
   }
   myPlot->replot();
@@ -3819,10 +3988,10 @@ void Plot2d_ViewFrame::incrementalPan( const int incrX, const int incrY ) {
 void Plot2d_ViewFrame::incrementalZoom( const int incrX, const int incrY ) {
   QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
   QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
-  
-  myPlot->setAxisScale( QwtPlot::yLeft, yMap.s1(), 
+
+  myPlot->setAxisScale( QwtPlot::yLeft, yMap.s1(),
                         myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s2() ) + incrY ) );
-  myPlot->setAxisScale( QwtPlot::xBottom, xMap.s1(), 
+  myPlot->setAxisScale( QwtPlot::xBottom, xMap.s1(),
                         myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s2() ) - incrX ) );
   if (mySecondY) {
     QwtScaleMap y2Map = myPlot->canvasMap( QwtPlot::yRight );
@@ -3833,7 +4002,7 @@ void Plot2d_ViewFrame::incrementalZoom( const int incrX, const int incrY ) {
 }
 
 /*
-  Update plot item 
+  Update plot item
 */
 void Plot2d_ViewFrame::updatePlotItem(Plot2d_Object* theObject, QwtPlotItem* theItem) {
   theObject->updatePlotItem( theItem );
@@ -3857,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) {
@@ -3875,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;
 }
 
 /*!
@@ -3893,7 +4062,7 @@ Plot2d_Curve* Plot2d_ViewFrame::getClosestCurve( QPoint p, double& distance, int
       continue;
     double d;
     int i = aCurve->closestPoint( p, &d );
-    if ( index > -1 && ( distance < 0 || d < distance ) ) {
+    if ( i > -1 && ( distance < 0 || d < distance ) ) {
       pCurve = it.value();
       distance = d;
       index = i;
@@ -3902,6 +4071,7 @@ Plot2d_Curve* Plot2d_ViewFrame::getClosestCurve( QPoint p, double& distance, int
   return pCurve;
 }
 
+#ifndef NO_ANALYTICAL_CURVES
 /*!
  \brief  Deselect all analytical curves.
 */
@@ -3910,6 +4080,7 @@ void Plot2d_ViewFrame::deselectAnalyticalCurves() {
    c->setSelected(false);
   }
 }
+#endif
 
 /*!
  \brief  Deselect all objects, except analytical curves.
@@ -3929,7 +4100,9 @@ void Plot2d_ViewFrame::deselectObjects() {
 void Plot2d_ViewFrame::onPanLeft()
 {
   this->incrementalPan( -INCREMENT_FOR_OP, 0 );
+#ifndef NO_ANALYTICAL_CURVES
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -3938,7 +4111,9 @@ void Plot2d_ViewFrame::onPanLeft()
 void Plot2d_ViewFrame::onPanRight()
 {
   this->incrementalPan( INCREMENT_FOR_OP, 0 );
+#ifndef NO_ANALYTICAL_CURVES
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -3947,7 +4122,9 @@ void Plot2d_ViewFrame::onPanRight()
 void Plot2d_ViewFrame::onPanUp()
 {
   this->incrementalPan( 0, -INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -3956,7 +4133,9 @@ void Plot2d_ViewFrame::onPanUp()
 void Plot2d_ViewFrame::onPanDown()
 {
   this->incrementalPan( 0, INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -3965,7 +4144,9 @@ void Plot2d_ViewFrame::onPanDown()
 void Plot2d_ViewFrame::onZoomIn()
 {
   this->incrementalZoom( INCREMENT_FOR_OP, INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -3974,7 +4155,9 @@ void Plot2d_ViewFrame::onZoomIn()
 void Plot2d_ViewFrame::onZoomOut()
 {
   this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
   updateAnalyticalCurves();
+#endif
 }
 
 /*!
@@ -3994,7 +4177,7 @@ void Plot2d_ViewFrame::customEvent( QEvent* ce )
  *
 */
 Plot2d_Object* Plot2d_ViewFrame::getPlotObject( QwtPlotItem* plotItem ) const {
-  
+
   ObjectDict::const_iterator it = myObjects.begin();
   for( ; it != myObjects.end(); ++it ) {
     if ( it.key() == plotItem ) {
@@ -4012,25 +4195,17 @@ 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++; 
-      aDist *= 10.; 
+      precision++;
+      aDist *= 10.;
     }
     if ( precision > 0 && value > 0 )
       return QLocale::system().toString( value,'f', precision );
@@ -4110,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();
 
@@ -4120,13 +4299,19 @@ void Plot2d_AxisScaleDraw::draw( QPainter* painter, const QPalette & palette) co
 
   for (int i = 0; i < myTicks.size(); i++)
   {
-      drawLabel( painter, myTicks[i]);               
-  }      
-               
+      drawLabel( painter, myTicks[i]);
+  }
+
   //std::cout << "Ok for Plot2d_AxisScaleDraw::draw()" << std::endl;
 }
 
 
+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))
@@ -4186,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();
 
@@ -4198,7 +4385,7 @@ void Plot2d_AxisScaleDraw::applyTicks()
 
   if (myLowerBound != -1 && myUpperBound != -1)
               aScaleDiv->setInterval(myLowerBound, myUpperBound);
-               
+
   //for (int i = 0; i < myTicks.size(); i++){
   //  QPoint p = labelPosition( i );
   //  qDebug() << i<< ") applyTicks -> LABEL" <<p;
@@ -4219,11 +4406,11 @@ 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();
-                 
+
       QFont devicef( DEVICE_FONT, DEVICE_FONT_SIZE, QFont::Bold);
       //
       //painter->setPen( QColor("blue") );
@@ -4243,7 +4430,7 @@ void Plot2d_AxisScaleDraw::drawLabel( QPainter* painter, double value) const
       QwtScaleDraw::drawLabel( painter, value );
   }
 }
-    
+
 
 void Plot2d_AxisScaleDraw::drawTick( QPainter* painter, double value, int len) const
 {
@@ -4253,29 +4440,27 @@ void Plot2d_AxisScaleDraw::drawTick( QPainter* painter, double value, int len) c
   if ( myLabelX.contains(value) )
   {
       QwtScaleDraw::drawTick( painter, value, len);
-  } 
+  }
 }
 
 
 /* Management of tooltips associated with markers for curves points or others points
  */
 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
 {
 }
-  
+
 Plot2d_QwtPlotPicker::Plot2d_QwtPlotPicker( int            xAxis,
                                             int            yAxis,
                                             QwtPlotCanvas *canvas)
@@ -4292,30 +4477,40 @@ 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 )
-  {
+  for (QList<QwtPlotMarker* >::const_iterator pMarkerIt = pMarkers.begin();pMarkerIt != pMarkers.end(); ++pMarkerIt )
+    {
       QwtPlotMarker* pMarker = *pMarkerIt;
       if ( pMarker != NULL )
-      {
-          QwtDoubleRect  bound0        = pMarker->boundingRect();
-          QwtDoublePoint center_bound0 = bound0.center();
-          double left = center_bound0.x()-(BOUND_HV_SIZE/2.);
-          double top  = center_bound0.y()-(BOUND_HV_SIZE/2.);
+        {
+          const QwtSymbol* symb=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();
+          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()));
          
-          QwtDoubleRect  bound( left, top , BOUND_HV_SIZE, BOUND_HV_SIZE);
+          if ( x2 < x1 )
+            qSwap(x1, x2);
+          if ( y2 < y1 )
+            qSwap(y1, y2);
          
-          if( bound.contains(pos) )
-          {
-            //QString toolTip =  "X="  + QString::number( pMarker->xValue() )
-            //                 + " Y=" + QString::number( pMarker->yValue() );
-            return pMarkersToolTip[pMarker];
-          }
-      }        
+          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());
+          bound00.setWidth(bound00.width()+sz.width());
+          bound00.setHeight(bound00.height()+sz.height());
+          if( bound00.contains(toto) )
+            {
+              return pMarkersToolTip[pMarker];
+            }
+        }
   }
-      
-  return QwtText();      
+  return QwtText();
 }