Salome HOME
Merge from branch mpa/qwt6_porting
authorvsr <vsr@opencascade.com>
Tue, 18 Feb 2014 10:01:16 +0000 (14:01 +0400)
committervsr <vsr@opencascade.com>
Tue, 18 Feb 2014 10:01:16 +0000 (14:01 +0400)
30 files changed:
doc/salome/gui/images/plot2d_view_settings.png
doc/salome/gui/images/pref_salome_plot2dviewer.png
doc/salome/gui/input/plot2d_viewer.doc
doc/salome/gui/input/setting_preferences.doc
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml
src/LightApp/resources/LightApp_msg_en.ts
src/LightApp/resources/LightApp_msg_fr.ts
src/Plot2d/Plot2d.cxx
src/Plot2d/Plot2d.h
src/Plot2d/Plot2d_AnalyticalCurve.cxx
src/Plot2d/Plot2d_Curve.cxx
src/Plot2d/Plot2d_Histogram.cxx
src/Plot2d/Plot2d_Histogram.h
src/Plot2d/Plot2d_Object.cxx
src/Plot2d/Plot2d_Object.h
src/Plot2d/Plot2d_PlotItems.cxx
src/Plot2d/Plot2d_PlotItems.h
src/Plot2d/Plot2d_SetupViewDlg.cxx
src/Plot2d/Plot2d_SetupViewDlg.h
src/Plot2d/Plot2d_ViewFrame.cxx
src/Plot2d/Plot2d_ViewFrame.h
src/Plot2d/Plot2d_ViewManager.cxx
src/Plot2d/Plot2d_ViewModel.cxx
src/Plot2d/Plot2d_ViewModel.h
src/Plot2d/Plot2d_ViewWindow.cxx
src/Plot2d/resources/Plot2d_msg_en.ts
src/Plot2d/resources/Plot2d_msg_fr.ts
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h

index 2b7ddffc78a3576d36460bd6833f0b2f08ebe41d..e87556beb23f2158c243e0c1230ac32740d9ce12 100644 (file)
Binary files a/doc/salome/gui/images/plot2d_view_settings.png and b/doc/salome/gui/images/plot2d_view_settings.png differ
index 339dbf95012b70579fe3293b43f7af6bfdf58641..b75a840691dcff86ac3435dfaf40f263136cc374 100644 (file)
Binary files a/doc/salome/gui/images/pref_salome_plot2dviewer.png and b/doc/salome/gui/images/pref_salome_plot2dviewer.png differ
index 11640c348850618340e378c5564fdc5792f588a0..b5072eb8530102e9e70a6e27446329d5a4e9a64b 100644 (file)
@@ -138,16 +138,28 @@ The options are as follows:
 - <b>Curve type</b> you can select from \em Points, \em Lines or
   \em Spline.
 
-- <b>Show legend</b> here you can define the position of the
+- <b>Marker size</b> - size of the points (markers) forming curve lines.
+
+- <b>Background color</b> of the XY plot.
+
+- <b>Selection color</b> - this submenu allows to select the color of selected object in the viewer.
+
+- <b>Legend</b> allows specifying the properties of the legend.
+  
+  - <b>Show legend</b> - this options specifies if it's necessary to show legend by default.
+
+  - <b>Legend Position</b> here you can define the position of the
   description table on the XY plot (to the \em Left, to the \em Right,
   on \em Top or on \em Bottom).
+  
+  - <b>Symbol type</b> you can select the type of legend item symbol from "Marker on line" or "Marker above line"
 
-- <b>Legend font</b> here you can set type, face and color for the
+  - <b>Legend font</b> here you can set type, face and color for the
   font of Legend item.
+  
+  - <b>Legend font color</b> - this allows to select the color of the font of the legend item.
 
-- <b>Marker size</b> - size of the points (markers) forming curve lines.
-
-- <b>Background color</b> of the XY plot.
+  - <b>Highlighted legend font color</b> - this submenu allows to select the color of the font of the selected legend item.
 
 - <b>Deviation marker</b> allows specifying the properties of the
   marker, which is used for drawing deviations data.
index 9b0899efd768989ab90d18cb4aaeddf2e655e0e1..99d47827166ed2231240c643ff69d183f509c552 100644 (file)
@@ -186,39 +186,43 @@ titles displayed in the viewer:
 
 \image html pref_salome_plot2dviewer.png
 
-- <b>Show legend</b> - this options specifies if it's necessary to
-show legend by default.
-- <b>Legend Position</b> - this submenu allows to set the default position
-of the legend, it can be located to the left, to the right, on top or
-on bottom of the graph.
-- <b>Legend font</b> - this allows to set type and face for the font of Legend item.
-- <b>Curve Type</b> - this allows to set the representation of graphs in
-your presentations. You can see only <b>Points</b>, points connected with
-<b>Lines</b> or points connected with smooth <b>Splines</b>.
-- <b>Marker Size</b> - this submenu allows you to set the size of
-markers in your graphs.
-- <b>Horizontal</b> and <b>Vertical axis scale</b> - this submenus allow you to set
-the scale for vertical and horizontal axes. It can be either <b>Linear</b> or
-<b>Logarithmic</b>. Note that the <b>Logarithmic</b> scale can be used only
-if the minimum value of corresponding component (abscissa or ordinate)
-of all points displayed in the viewer is greater than zero.
-If this condition is not met, the scale is switched to <b>Linear</b>
-automatically, even if it is set to <b>Logarithmic</b>.
 - <b>Background color</b> - this submenu allows to select the background
 color. Click on the colored line to access to the
 \ref select_color_and_font_page "Select Color" dialog box.
-- <b>Legend font color</b> - this allows to select the color of the
-font of the legend item. 
-- <b>Highlighted legend font color</b> - this submenu allows to select
-the color of the font of the selected legend item. 
 - <b>Selection color</b> - this submenu allows to select the color of
 selected object in the viewer. 
-- <b>Deviation marker color</b> - this submenu allows to select the
-color of the deviation marker. 
-- <b>Deviation marker line width</b> allows to define line width of
-the deviation marker. 
-- <b>Deviation marker tick size</b> allows to define size of the upper
-and lower horizontal lines of the deviation marker. 
+- <b>Viewer</b> - allows specifying the properties of the Plot 2D Viewer.
+  - <b>Curve Type</b> - this allows to set the representation of graphs in
+  your presentations. You can see only <b>Points</b>, points connected with
+  <b>Lines</b> or points connected with smooth <b>Splines</b>.
+  - <b>Marker Size</b> - this submenu allows you to set the size of
+  markers in your graphs.
+  - <b>Horizontal</b> and <b>Vertical axis scale</b> - this submenus allow you to set
+  the scale for vertical and horizontal axes. It can be either <b>Linear</b> or
+  <b>Logarithmic</b>. Note that the <b>Logarithmic</b> scale can be used only
+  if the minimum value of corresponding component (abscissa or ordinate)
+  of all points displayed in the viewer is greater than zero.
+  If this condition is not met, the scale is switched to <b>Linear</b>
+  automatically, even if it is set to <b>Logarithmic</b>.
+  - <b>Deviation marker color</b> - this submenu allows to select the
+  color of the deviation marker. 
+  - <b>Deviation marker line width</b> allows to define line width of
+  the deviation marker. 
+  - <b>Deviation marker tick size</b> allows to define size of the upper
+  and lower horizontal lines of the deviation marker. 
+- <b>Legend</b> - allows specifying the properties of the legend.
+  - <b>Show legend</b> - this options specifies if it's necessary to
+  show legend by default.
+  - <b>Legend Position</b> - this submenu allows to set the default position
+  of the legend, it can be located to the left, to the right, on top or
+  on bottom of the graph.
+  - <b>Symbol type</b> you can select the type of legend item symbol from "Marker on line" 
+  or "Marker above line"
+  - <b>Legend font</b> - this allows to set type and face for the font of Legend item.
+  - <b>Legend font color</b> - this allows to select the color of the
+  font of the legend item. 
+  - <b>Highlighted legend font color</b> - this submenu allows to select
+  the color of the font of the selected legend item. 
 
 <br><h2>Directories Preferences</h2>
 
index 1461178bc5a1dd770dce329664f633379986cfa5..21f213ad9e9a7e3994e9a25695ed94cd1f03d60a 100644 (file)
@@ -2423,22 +2423,18 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
   //pref->setItemProperty( "columns", 2, plot2dGroup );
 
-  // ... -> show legend
-  pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
-                       LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
-  // ... -> legend position
-  int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
-                                            LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
-  aValuesList.clear();
-  anIndicesList.clear();
-  aValuesList   << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
-  anIndicesList << 0               << 1                << 2              << 3                ;
-  pref->setItemProperty( "strings", aValuesList,   legendPosition );
-  pref->setItemProperty( "indexes", anIndicesList, legendPosition );
-  // ... -> legend font
-  pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
-  // ... -> curve type
-  int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
+  // ... -> background
+  pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
+                       LightApp_Preferences::Color, "Plot2d", "Background" );
+  // ... -> selection color
+  pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
+                       LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
+
+  // ... "Viewer" group <<start>>
+  int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
+
+  // .... -> curve type
+  int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
                                        LightApp_Preferences::Selector, "Plot2d", "CurveType" );
   aValuesList.clear();
   anIndicesList.clear();
@@ -2446,13 +2442,13 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   anIndicesList << 0                 << 1                << 2                ;
   pref->setItemProperty( "strings", aValuesList,   curveType );
   pref->setItemProperty( "indexes", anIndicesList, curveType );
-  // ... -> marker size
-  int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
+  // .... -> marker size
+  int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
                                         LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
   pref->setItemProperty( "min", 0, markerSize );
   pref->setItemProperty( "max", 100, markerSize );
-  // ... -> horizontal scaling mode
-  int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
+  // .... -> horizontal scaling mode
+  int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
                                       LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
   aValuesList.clear();
   anIndicesList.clear();
@@ -2460,34 +2456,59 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   anIndicesList << 0                 << 1                     ;
   pref->setItemProperty( "strings", aValuesList,   horScale );
   pref->setItemProperty( "indexes", anIndicesList, horScale );
-  // ... -> vertical scaling mode
-  int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
+  // .... -> vertical scaling mode
+  int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
                                       LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
   pref->setItemProperty( "strings", aValuesList,   verScale );
   pref->setItemProperty( "indexes", anIndicesList, verScale );
-  // ... -> background
-  pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
-                       LightApp_Preferences::Color, "Plot2d", "Background" );
-  // ... -> font color
-  pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
-  // ... -> selection font color
-  pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
-  // ... -> selection color
-  pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
-                       LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
-  // ... -> errors/deviation colot
-  pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
+
+  // .... -> errors/deviation colot
+  pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
                        LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
-  // ... -> deviation markers line size
-  int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
+  // .... -> deviation markers line size
+  int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
                                         LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
   pref->setItemProperty( "min", 1, deviationMarkerLw );
   pref->setItemProperty( "max", 5, deviationMarkerLw );
-  // ... -> deviation markers tick mark size
-  int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
+  // .... -> deviation markers tick mark size
+  int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
                                         LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
   pref->setItemProperty( "min", 1, deviationMarkerTs );
   pref->setItemProperty( "max", 5, deviationMarkerTs );
+  // .... "Viewer" group <<end>>
+
+  // ... "Legend" group <<start>>
+  int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
+
+  // .... -> show legend
+  pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
+                       LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
+  // .... -> legend position
+  int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
+                                            LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
+  aValuesList.clear();
+  anIndicesList.clear();
+  aValuesList   << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
+  anIndicesList << 0               << 1                << 2              << 3                ;
+  pref->setItemProperty( "strings", aValuesList,   legendPosition );
+  pref->setItemProperty( "indexes", anIndicesList, legendPosition );
+  // .... -> Symbol type
+  int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
+                                            LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
+  aValuesList.clear();
+  anIndicesList.clear();
+  aValuesList   << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
+  anIndicesList << 0                            << 1                        ;
+  pref->setItemProperty( "strings", aValuesList,   legendSymbolType );
+  pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
+  // .... -> legend font
+  pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
+  // ... -> font color
+  pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
+  // ... -> selection font color
+  pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
+  // ... "Legend" group <<end>>
+
   // .. "Plot2d viewer" group <<end>>
 
   // .. "Directories" preferences tab <<start>>
@@ -2953,14 +2974,22 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
   }
 
 #ifndef DISABLE_PLOT2DVIEWER
-  if ( sec == "Plot2d" ) {
-    if( param == "SelectionColor" ) {
-      QColor c = resMgr->colorValue( sec, param );
-      Plot2d_Object::setSelectionColor(c);
-    }
-    else if (param == "SelectedLegendFontColor") {
-      QColor c = resMgr->colorValue( sec, param );      
-      Plot2d_Object::setHighlightedLegendTextColor(c);
+  QList<SUIT_ViewManager*> lst;
+  viewManagers( Plot2d_Viewer::Type(), lst );
+  QListIterator<SUIT_ViewManager*> itPlot2d( lst );
+  while ( itPlot2d.hasNext() ) {
+    SUIT_ViewManager* viewMgr = itPlot2d.next();
+    SUIT_ViewModel* vm = viewMgr->getViewModel();
+    if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
+      continue;
+
+    Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
+
+    viewMgr->setViewModel( vm  );
+    Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
+    if( wnd ) {
+      Plot2d_ViewFrame* frame = wnd->getViewFrame();
+      frame->SetPreference();
     }
   }
 #endif
index 4f93798f49669583b9052a14782e140ef31d9102..5c0b0d5747620248f7c0b3bae3475fd4d48fecce 100644 (file)
     <parameter name="CurveType"    value="1" />
     <parameter name="HorScaleMode" value="0" />
     <parameter name="LegendPos"    value="1" />
+    <parameter name="LegendSymbolType" value="0" />
     <parameter name="LegendFont"   value="Helvetic,12" />
     <parameter name="LegendFontColor"  value="0, 0, 0" />
     <parameter name="SelectedLegendFontColor"  value="255, 255, 255" />
index 1295bba41c2edac75d135bac195bc370b5e64cef..06ebdb47336cd02fa8c34a48b37c19b1d558f663 100644 (file)
@@ -670,6 +670,26 @@ The changes will be applied on the next application session.</translation>
         <source>PREF_GROUP_PLOT2DVIEWER</source>
         <translation>Plot 2D Viewer</translation>
     </message>
+    <message>
+        <source>PREF_GROUP_VIEWER</source>
+        <translation>Viewer</translation>
+    </message>
+    <message>
+        <source>PREF_GROUP_LEGEND</source>
+        <translation>Legend</translation>
+    </message>
+    <message>
+        <source>PREF_LEGEND_SYMBOL_TYPE</source>
+        <translation>Symbol type:</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ABOVE_LINE</source>
+        <translation>Marker above line</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ON_LINE</source>
+        <translation>Marker on line</translation>
+    </message>
     <message>
         <source>PREF_DEVIATION_COLOR</source>
         <translation>Deviation marker color</translation>
index e9f864f59d45b4a61e96e4f87b50453a1ee8e299..7bb01a172ced20cafbda1722fa1d4e19fec0421b 100755 (executable)
@@ -670,6 +670,26 @@ Les modifications seront appliquées à la prochaine session.</translation>
         <source>PREF_GROUP_PLOT2DVIEWER</source>
         <translation>Scène Plot2d</translation>
     </message>
+    <message>
+        <source>PREF_GROUP_VIEWER</source>
+        <translation>Scène</translation>
+    </message>
+    <message>
+        <source>PREF_GROUP_LEGEND</source>
+        <translation>Légende</translation>
+    </message>
+    <message>
+        <source>PREF_LEGEND_SYMBOL_TYPE</source>
+        <translation>Type de symbole:</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ABOVE_LINE</source>
+        <translation>Marqueur dessus de la ligne</translation>
+    </message>
+    <message>
+        <source>PREF_MARKER_ON_LINE</source>
+        <translation>Marqueur sur la ligne</translation>
+    </message>
     <message>
         <source>PREF_DEVIATION_COLOR</source>
         <translation>Couleur des marqueurs de déviation</translation>
index 3fcae1e884dc5e011aa4f52501cee5972b887b06..71d6047264b9da507dc6600e6c0876c0551b0686 100755 (executable)
@@ -529,7 +529,7 @@ bool Plot2d::existMarker( const int rtti, const QwtPlot* thePlot, const QwtSymbo
       if ( anItem && anItem->rtti() == rtti ) {
        QwtPlotCurve* crv = dynamic_cast<QwtPlotCurve*>( anItem );
        if ( crv ) {
-         QwtSymbol::Style aStyle = crv->symbol().style();
+         QwtSymbol::Style aStyle = crv->symbol()->style();
          QColor           aColor = crv->pen().color();
          Qt::PenStyle     aLine  = crv->pen().style();
          ok = closeColors( aColor, color ) && aStyle == typeMarker && aLine == typeLine;
index 9150a254c465480124902faedeff8e6152c9964a..4f0e3d3fa8062be2f83a388178fb8f1515a32842 100755 (executable)
@@ -37,7 +37,9 @@
 #endif
 
 #include <qwt_symbol.h>
-#include <Qt>
+#include <QString>
+#include <QColor>
+#include <QPixmap>
 
 class QPainter;
 class QwtPlot;
index 8e00b9b0ea3840921b421c99304117c900161291..75b14cededbb62199f82321b1e984990d51bca02 100755 (executable)
@@ -165,18 +165,18 @@ void Plot2d_AnalyticalCurve::updatePlotItem()
   aCurve->setSelected(isSelected());
 
   aCurve->setPen( QPen(aColor , lineW, ps ) );
-  aCurve->setSymbol( QwtSymbol( ms, QBrush( aColor ), 
-                               QPen( aColor ), 
-                               QSize( markerS , markerS ) ) );
+  aCurve->setSymbol( new QwtSymbol( ms, QBrush( aColor ),
+                                    QPen( aColor ),
+                                    QSize( markerS , markerS ) ) );
 
   aCurve->setLegendPen(QPen(getColor(), getLineWidth(), ps ));
-  aCurve->setLegendSymbol( QwtSymbol( ms, QBrush( getColor() ), 
-                                     QPen( getColor() ), 
-                                     QSize( getMarkerSize() , getMarkerSize() )));
+  aCurve->setLegendSymbol( new QwtSymbol( ms, QBrush( getColor() ),
+                                          QPen( getColor() ),
+                                          QSize( getMarkerSize() , getMarkerSize() )));
 
   double *x, *y;
   long nb = getData( &x, &y );
-  aCurve->setData( x, y, nb );
+  aCurve->setSamples( x, y, nb );
   aCurve->setTitle(getName());
 }
 
@@ -213,10 +213,10 @@ void Plot2d_AnalyticalCurve::calculate() {
 */
 bool Plot2d_AnalyticalCurve::checkCurve( const QwtPlot* thePlot) {
   if( !myExpression.isEmpty() && thePlot ) {
-       const QwtScaleDiv* div = thePlot->axisScaleDiv(QwtPlot::xBottom);
-       setRangeBegin(div->lowerBound());
-       setRangeEnd(div->upperBound());
-       calculate();
+    const QwtScaleDiv div = thePlot->axisScaleDiv(QwtPlot::xBottom);
+    setRangeBegin(div.lowerBound());
+    setRangeEnd(div.upperBound());
+    calculate();
   }
   return myState == Plot2d_AnalyticalCurve::StateOk;
 }
index 615d5dfd8ebc4077c2119dc59424bdd3b71b6731..4bc84ef7ee1e3cfe49c07b143b2b0bb1766ecd71 100755 (executable)
@@ -135,19 +135,19 @@ void Plot2d_Curve::updatePlotItem( QwtPlotItem* theItem )
   aCurve->setSelected(isSelected());
 
   aCurve->setPen( QPen(aColor , lineW, ps ) );
-  aCurve->setSymbol( QwtSymbol( ms, QBrush( aColor ), 
-                               QPen( aColor ), 
-                               QSize( markerS , markerS ) ) );
+  aCurve->setSymbol( new QwtSymbol( ms, QBrush( aColor ), 
+                                    QPen( aColor ),
+                                    QSize( markerS , markerS ) ) );
 
   aCurve->setLegendPen(QPen(getColor(), getLineWidth(), ps ));
-  aCurve->setLegendSymbol( QwtSymbol( ms, QBrush( getColor() ), 
-                                     QPen( getColor() ), 
-                                     QSize( getMarkerSize() , getMarkerSize() )));
+  aCurve->setLegendSymbol( new QwtSymbol( ms, QBrush( getColor() ),
+                                          QPen( getColor() ),
+                                          QSize( getMarkerSize() , getMarkerSize() )));
   
   double *x, *y, *min, *max;
   long nb = getData( &x, &y );
   if(nb > 0 && x && y) {
-    aCurve->setData( x, y, nb );
+    aCurve->setSamples( x, y, nb );
     delete [] x;
     delete [] y;
     QList<int> idx;
@@ -160,7 +160,7 @@ void Plot2d_Curve::updatePlotItem( QwtPlotItem* theItem )
       aCurve->clearDeviationData();
     }
   } else {
-    aCurve->setData( NULL, NULL, 0 );
+    aCurve->setSamples( NULL, NULL, 0 );
   }
 }
 
index 8e291f2d774f59831ad3549d85c8e12b86b0632e..d41bf002ca24fc07821e5cf1f50378d739ce3a29 100644 (file)
@@ -135,22 +135,20 @@ void Plot2d_Histogram::setData( const QList<double>& theXVals,
 /*!
   Gets data
 */
-QwtIntervalData Plot2d_Histogram::getData() const
+QwtIntervalSeriesData Plot2d_Histogram::getData() const
 {
   pointList aPoints = getPointList();
   int aSize = aPoints.size();
 
-  QwtArray<QwtDoubleInterval> anIntervals( aSize );
-  QwtArray<double> aValues( aSize );
+  QwtArray<QwtIntervalSample> anIntervals( aSize );
   double aX;
   double aWidth = myWidth <= 0 ? myDefWidth : myWidth; // VSR: width is either manually assigned or auto-calculated
   for ( int i = 0; i < aSize; i++ ) {
     aX = aPoints[i].x;
-    anIntervals[i] = QwtDoubleInterval( aX - aWidth/2, aX + aWidth/2 );
-    aValues[i] = aPoints[i].y;
+    anIntervals[i] = QwtIntervalSample( aPoints[i].y, aX - aWidth/2, aX + aWidth/2 );
   }
 
-  return QwtIntervalData( anIntervals, aValues );
+  return QwtIntervalSeriesData( anIntervals );
 }
 
 /*!
index 04fe363a6922fee3958fa8eed4ef66d334c08044..dcb6b3a3df6098baa96e00954ddfb52c9f55bdec 100644 (file)
@@ -28,7 +28,7 @@
 #include "Plot2d.h"
 #include "Plot2d_Object.h"
 
-#include <qwt_interval_data.h>
+#include <qwt_series_data.h>
 
 class PLOT2D_EXPORT Plot2d_Histogram : public Plot2d_Object
 {
@@ -39,30 +39,30 @@ public:
   virtual ~Plot2d_Histogram();
   Plot2d_Histogram& operator= ( const Plot2d_Histogram& );
 
-  virtual int          rtti();
-  virtual QwtPlotItem* createPlotItem();
-  virtual void         autoFill( const QwtPlot* );
-  virtual void         updatePlotItem( QwtPlotItem* );
+  virtual int           rtti();
+  virtual QwtPlotItem*  createPlotItem();
+  virtual void          autoFill( const QwtPlot* );
+  virtual void          updatePlotItem( QwtPlotItem* );
 
-  void                 setData( const QList<double>&, const QList<double>& );
-  QwtIntervalData      getData() const;
+  void                  setData( const QList<double>&, const QList<double>& );
+  QwtIntervalSeriesData getData() const;
 
-  void                 setColor( const QColor& );
-  QColor               getColor() const;
+  void                  setColor( const QColor& );
+  QColor                getColor() const;
 
-  void                 setWidth( const double );
-  double               getWidth( const bool ) const;
+  void                  setWidth( const double );
+  double                getWidth( const bool ) const;
 
-  static double        getMinInterval( const QList<double>& );
+  static double         getMinInterval( const QList<double>& );
 
 protected:
-  QColor               getNextColor( const QwtPlot* );
-  bool                 existColor( const QwtPlot*, const QColor& );
+  QColor                getNextColor( const QwtPlot* );
+  bool                  existColor( const QwtPlot*, const QColor& );
 
 private:
-  QColor               myColor;
-  double               myWidth;
-  double               myDefWidth;
+  QColor                myColor;
+  double                myWidth;
+  double                myDefWidth;
 };
 
 #endif // PLOT2D_HISTOGRAM_H
index 457db98ee077138415c455a500e1953ab642f889..a87640bd65234867204995174715a58723d649ee 100755 (executable)
 
 #include "Plot2d_Object.h"
 
-#ifndef NO_SUIT
-#include <SUIT_Session.h>
-#include <SUIT_ResourceMgr.h>
-#endif
-
 // Static members
 QColor Plot2d_Object::mySelectionColor;
 QColor Plot2d_Object::myHighlightedLegendTextColor;
 
-/*
- * Read colors from the resource manager.
-*/
-void Plot2d_Object::initColors() {
-#ifndef NO_SUIT
-  SUIT_Session* session = SUIT_Session::session();
-  if(!session)
-    return;
-
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  if(resMgr) {
-    mySelectionColor = resMgr->colorValue( "Plot2d", "SelectionColor", QColor(80,80,80) );
-    myHighlightedLegendTextColor = resMgr->colorValue( "Plot2d", "SelectedLegendFontColor", QColor(255,255,255) );
-  }
-#else
-  mySelectionColor = QColor(80,80,80);
-  myHighlightedLegendTextColor = QColor(255,255,255);
-#endif
-}
 
 /*!
   Constructor
@@ -127,7 +103,7 @@ void Plot2d_Object::updatePlotItem( QwtPlotItem* theItem )
     return;
 
   if ( theItem->yAxis() != getYAxis() || theItem->xAxis() != getXAxis() ) {
-    theItem->setAxis( getXAxis(), getYAxis() );
+    theItem->setAxes( getXAxis(), getYAxis() );
 
     QwtPlot* aPlot = theItem->plot();
     if ( aPlot ) {
index 2c219fab7e8d9a60740e1c6f72b75cac7871de70..5682a09adf71abc97c717c7fde6d65330282de39 100755 (executable)
@@ -105,8 +105,6 @@ public:
   void                 setSelected(const bool);
   bool                 isSelected() const;
   
-  static void initColors();
-  
   static void   setSelectionColor(const QColor& c);
   static QColor selectionColor();
 
index be54a678e1e8fd026ae9b94eb9a9762c2c2fc868..c212bf6e514e6824165cea1dc4a01a544f9dbf20 100644 (file)
 
 #include "Plot2d_PlotItems.h"
 #include "Plot2d_Object.h"
+#include "Plot2d_ViewFrame.h"
 
 #include <QPainter>
 #include <QPalette>
 #include <QLayout>
 #include <QLine>
 #include <QVariant>
+#include <QStyleOption>
+#include <QPaintEvent>
 #include <qwt_plot.h>
 #include <qwt_painter.h>
 #include <qwt_scale_map.h>
 #include <qwt_legend.h>
-#include <qwt_legend_item.h>
+#include <qwt_legend_label.h>
 #include <qwt_plot_dict.h>
 
+const int SPACING = 10;
+const int SYMBOL_SIZE = 13;
+
 const char* yAxisLeft[] = {
   "12 12 2 1",
   "  c None",
@@ -72,44 +78,69 @@ const char* yAxisRight[] = {
   "            "};
 
 /*!
-  Constructor of Plot2d_QwtLegendItem
+  Constructor of Plot2d_QwtLegendLabel
 */
-Plot2d_QwtLegendItem::Plot2d_QwtLegendItem( QWidget* parent ) :
-  QwtLegendItem( parent ),
+Plot2d_QwtLegendLabel::Plot2d_QwtLegendLabel( QWidget* parent ) :
+  QwtLegendLabel( parent ),
   myYAxisIdentifierMode( IM_None ),
-  myIsSelected(false)
+  myIsSelected(false),
+  mySymbol( new QwtSymbol() ),
+  mySymbolType(0),
+  myPen( QPen() )
 {
   myYAxisLeftIcon = yAxisLeft;
   myYAxisRightIcon = yAxisRight;
   int anIconWidth = qMax( myYAxisLeftIcon.width(), myYAxisRightIcon.width() );
+  setSpacing( SPACING );
 
   mySpacingCollapsed = spacing();
-  mySpacingExpanded = anIconWidth - mySpacingCollapsed;
+  mySpacingExpanded = anIconWidth + mySpacingCollapsed;
 }
 
 /*!
-  Destructor of Plot2d_QwtLegendItem
+  Destructor of Plot2d_QwtLegendLabel
 */
-Plot2d_QwtLegendItem::~Plot2d_QwtLegendItem()
+Plot2d_QwtLegendLabel::~Plot2d_QwtLegendLabel()
 {
 }
 
 /*!
   Set Y axis identifier displaying mode
 */
-void Plot2d_QwtLegendItem::setYAxisIdentifierMode( const int theMode )
+void Plot2d_QwtLegendLabel::setYAxisIdentifierMode( const int theMode )
 {
   myYAxisIdentifierMode = theMode;
   setSpacing( theMode == IM_None ? mySpacingCollapsed : mySpacingExpanded );
 }
 
 /*!
-  Redefined method of drawing identifier of legend item
+  Paint the identifier to a given rect.
+  \param painter Painter
+  \param rect Rect where to paint
 */
-void Plot2d_QwtLegendItem::drawIdentifier( QPainter* painter, const QRect& rect ) const
+void Plot2d_QwtLegendLabel::drawIdentifier( QPainter* painter, const QRect& rect )
 {
-  QwtLegendItem::drawIdentifier( painter, rect );
+  if ( rect.isEmpty() )
+    return;
 
+  if( myPen.style() != Qt::NoPen ) {
+    painter->save();
+    painter->setPen(myPen);
+    QwtPainter::drawLine( painter, rect.left() - 2, rect.center().y() + mySymbolType * 4,
+                                   rect.right() + 2, rect.center().y() + mySymbolType * 4 );
+    painter->restore();
+  }
+  if ( mySymbol->style() != QwtSymbol::NoSymbol )
+  {
+    QRect symbolRect;
+    symbolRect.setSize( QSize( SYMBOL_SIZE, SYMBOL_SIZE ) );
+    symbolRect.moveCenter( QPoint( rect.center().x(), rect.center().y() - mySymbolType * 4 ) );
+    painter->save();
+    painter->setBrush( mySymbol->brush() );
+    painter->setPen( mySymbol->pen() );
+    mySymbol->drawSymbol( painter, symbolRect );
+    painter->restore();
+  }
   if( myYAxisIdentifierMode != IM_None ) {
     QPixmap aPixmap( myYAxisIdentifierMode == IM_Left ? yAxisLeft : yAxisRight );
     painter->save();
@@ -121,19 +152,22 @@ void Plot2d_QwtLegendItem::drawIdentifier( QPainter* painter, const QRect& rect
 /*!
   Update highliting on the item.
 */
-void Plot2d_QwtLegendItem::updateHighlit() {
+void Plot2d_QwtLegendLabel::updateHighlit() {
   QwtText txt = text();
-  if(isSelected()) {
+  if( isSelected() ) {
     QColor highlightColor = Plot2d_Object::selectionColor();
-    if(highlightColor != txt.backgroundBrush().color()) {
-      txt.setBackgroundBrush(highlightColor);
+    if( highlightColor != txt.backgroundBrush().color() ) {
+      txt.setBackgroundBrush( highlightColor  );
       setText(txt);
     }
-  } else if( QWidget* parent = qobject_cast<QWidget*>(this->parent()->parent()) ) {
-    QPalette aPal = parent->palette();
-    if(aPal.color(QPalette::Background) != txt.backgroundBrush().color()) {
-      txt.setBackgroundBrush(aPal.color(QPalette::Background));
-      setText(txt);
+  }
+  else if( this->parent() ) {
+    if(QWidget* parent = qobject_cast<QWidget*>( this->parent()->parent() ) ) {
+      QPalette aPal = parent->palette();
+      if( aPal.color( QPalette::Background) != txt.backgroundBrush().color() ) {
+        txt.setBackgroundBrush( aPal.color( QPalette::Background ) );
+        setText( txt );
+      }
     }
   }
 }
@@ -141,14 +175,14 @@ void Plot2d_QwtLegendItem::updateHighlit() {
 /*!
   Sets selected property.
 */
-void Plot2d_QwtLegendItem::setSelected(const bool on) {
+void Plot2d_QwtLegendLabel::setSelected(const bool on) {
   myIsSelected = on;
 }
 
 /*!
   Gets selected property.
 */
-bool Plot2d_QwtLegendItem::isSelected() const {
+bool Plot2d_QwtLegendLabel::isSelected() const {
   return myIsSelected;
 }
 
@@ -156,17 +190,79 @@ bool Plot2d_QwtLegendItem::isSelected() const {
 /*
   Draw text of the item.
 */
-void  Plot2d_QwtLegendItem::drawText(QPainter * painter, const QRect &rect) {
+void  Plot2d_QwtLegendLabel::drawText( QPainter * painter, const QRectF &rect ) {
   painter->setPen( isSelected() ? Plot2d_Object::highlightedLegendTextColor() :
-                  getColorFromPalette( QPalette::Text) );
+                   getColorFromPalette( QPalette::Text) );
 
-  QwtLegendItem::drawText( painter, rect );
+  QwtTextLabel::drawText( painter, rect );
+}
+
+/*!
+  Sets symbol.
+*/
+void Plot2d_QwtLegendLabel::setSymbol( const QwtSymbol* theSymbol )
+{
+  mySymbol = new QwtSymbol( theSymbol->style(), theSymbol->brush(),
+                            theSymbol->pen(), theSymbol->size() );
+}
+
+/*!
+  Sets symbol type 0(marker on line) or 1(marker above line).
+*/
+void Plot2d_QwtLegendLabel::setSymbolType( const int theType )
+{
+  mySymbolType = theType;
+}
+
+/*!
+  Sets pen.
+*/
+void Plot2d_QwtLegendLabel::setPen (const QPen& thePen )
+{
+  myPen = thePen;
+}
+
+/*!
+  Redefined method paintEvent of QwtLegendLabel
+*/
+void Plot2d_QwtLegendLabel::paintEvent( QPaintEvent *e )
+{
+  const QRect cr = contentsRect();
+
+  int ButtonFrame = 6;
+  QPainter painter( this );
+  painter.setClipRegion( e->region() );
+
+  if ( isDown() )
+  {
+    qDrawWinButton( &painter, 0, 0, width(), height(),
+                    palette(), true );
+  }
+
+  painter.save();
+  painter.setClipRect( cr );
+
+  drawContents( &painter );
+
+  QRect iconRect = cr;
+  if ( !icon().isNull() )
+  {
+    if ( itemMode() != QwtLegendData::ReadOnly )
+      iconRect.setX( iconRect.x() + ButtonFrame );
+      iconRect.setSize( QSize( icon().size().width() + spacing() ,
+                                  icon().size().height() + spacing() ) );
+      iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) );
+  }
+
+  drawIdentifier( &painter, iconRect );
+
+  painter.restore();
 }
 
 /*
   Get color from the legend pallete by 'role' flag.
 */
-QColor Plot2d_QwtLegendItem::getColorFromPalette(QPalette::ColorRole role) {
+QColor Plot2d_QwtLegendLabel::getColorFromPalette(QPalette::ColorRole role) {
   QWidget* pw = parentWidget();
   QColor  col = palette().color( role );
   while( pw ) {
@@ -242,72 +338,63 @@ void Plot2d_QwtPlotCurve::setYAxisIdentifierEnabled( const bool on )
 /*!
   Redefined method, which updates legend of the curve
 */
-void Plot2d_QwtPlotCurve::updateLegend( QwtLegend* legend ) const
+void Plot2d_QwtPlotCurve::updateLegend( const QwtPlotItem* thePlotItem,
+                                        const QList<QwtLegendData>& theLegendData )
 {
-  if ( !legend )
+  if ( !thePlotItem || !thePlotItem->plot() )
     return;
 
-  QWidget* widget = legend->find( this );
-
-  if ( testItemAttribute(QwtPlotItem::Legend) ) {
-
-    if ( widget == NULL ) {
-      widget = legendItem();
-      if ( widget ) {
-       if ( widget->inherits("QwtLegendItem") ) {
-         QwtLegendItem *label = (QwtLegendItem *)widget;
-         label->setItemMode(legend->itemMode());
-
-         if ( plot() ) {
-           QObject::connect(label, SIGNAL(clicked()),
-                            plot(), SLOT(legendItemClicked()));
-           QObject::connect(label, SIGNAL(checked(bool)),
-                            plot(), SLOT(legendItemChecked(bool)));
-         }
-       }
-       legend->contentsWidget()->layout()->addWidget(widget);
-       legend->insert(this, widget);
-      }
-    }
-
-    QwtPlotCurve::updateLegend( legend );
-
+  if ( !testItemAttribute( QwtPlotItem::Legend ) )
+    return;
 
-    if( Plot2d_QwtLegendItem* anItem = dynamic_cast<Plot2d_QwtLegendItem*>( widget ) ) {
-      int aMode = Plot2d_QwtLegendItem::IM_None;
-      if( myYAxisIdentifierEnabled )
-       aMode = myYAxis == QwtPlot::yRight ?
-         Plot2d_QwtLegendItem::IM_Right :
-         Plot2d_QwtLegendItem::IM_Left;
-      anItem->setYAxisIdentifierMode( aMode );
-      if(isSelected()) {
-       anItem->setCurvePen(legendPen());
-       anItem->setSymbol(legendSymbol());
-      }
-      anItem->setSelected(isSelected());
-      anItem->updateHighlit();
-    }
+  QwtPlotCurve::updateLegend( thePlotItem, theLegendData );
+
+  const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) );
+  QwtLegend* legend = dynamic_cast<QwtLegend*>( thePlotItem->plot()->legend() );
+  QWidget* widget = legend->legendWidget( itemInfo );
+  QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
+  if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)label ) {
+    int aMode = Plot2d_QwtLegendLabel::IM_None;
+    if( myYAxisIdentifierEnabled )
+      aMode = myYAxis == QwtPlot::yRight ?
+              Plot2d_QwtLegendLabel::IM_Right :
+              Plot2d_QwtLegendLabel::IM_Left;
+    anItem->setYAxisIdentifierMode( aMode );
+
+    anItem->setSymbol( legendSymbol() );
+    if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+      anItem->setSymbolType( plot->getLegendSymbolType() );
+    anItem->setPen( legendPen() );
+
+    anItem->setSelected( isSelected() );
+    anItem->updateHighlit();
+    anItem->repaint();
   }
 }
 
 /*!
-  Redefined method, which creates and returns legend item of the curve
+  Redefined method, which updates and calls QwtPlot::autoRefresh() for the parent plot
 */
-QWidget* Plot2d_QwtPlotCurve::legendItem() const
+void Plot2d_QwtPlotCurve::itemChanged()
 {
-  return new Plot2d_QwtLegendItem;
+  if ( plot() )
+    updateLegend( this, legendData() );
+
+  QwtPlotItem::itemChanged();
 }
 
 /*!
   Redefined method, which draw a set of points of a curve.
 */
-void Plot2d_QwtPlotCurve::draw(QPainter *painter,
-                               const QwtScaleMap &xMap, const QwtScaleMap &yMap,
-                               int from, int to) const
+void Plot2d_QwtPlotCurve::drawSeries( QPainter *painter,
+                                      const QwtScaleMap &xMap,
+                                      const QwtScaleMap &yMap,
+                                      const QRectF &canvasRect,
+                                      int from, int to) const
 {
   if (to < 0)
     to = dataSize() - 1;
-  QwtPlotCurve::draw(painter, xMap, yMap, from, to);
+  QwtPlotCurve::drawSeries(painter, xMap, yMap, canvasRect, from, to);
 
   //draw deviation data
   if(hasDeviationData()) {
@@ -321,8 +408,9 @@ void Plot2d_QwtPlotCurve::draw(QPainter *painter,
     painter->setPen(p);
     for (int i = from; i <= to; i++) {
       if(!myDeviationData->values(i,min,max)) continue;
-      xi = x(i);
-      yi = y(i);
+      const QPointF sample = data()->sample( i );
+      xi = sample.x();
+      yi = sample.y();
       xp = xMap.transform(xi);
       ytop = yMap.transform(yi + max);
       ybtm = yMap.transform(yi - min);
@@ -406,7 +494,9 @@ void Plot2d_QwtPlotCurve::clearDeviationData()
   Constructor.
 */
 Plot2d_SelectableItem::Plot2d_SelectableItem():
-  myIsSelected(false)
+  myIsSelected(false),
+  myLegendSymbol( new QwtSymbol() ),
+  myLegendPen( QPen() )
 {
 }
 
@@ -448,15 +538,19 @@ QPen Plot2d_SelectableItem::legendPen() const {
 /*!
   Sets legend symbol property.
 */
-void Plot2d_SelectableItem::setLegendSymbol(const QwtSymbol& s) {
-  myLegendSymbol = s;
+void Plot2d_SelectableItem::setLegendSymbol( const QwtSymbol* s ) {
+  myLegendSymbol->setStyle( s->style() );
+  myLegendSymbol->setBrush( s->brush() );
+  myLegendSymbol->setPen( s->pen() );
+  myLegendSymbol->setSize( s->size() );
 }
 
 /*!
   Sets legend symbol property.
 */
-QwtSymbol Plot2d_SelectableItem::legendSymbol() const {
-  return myLegendSymbol;
+QwtSymbol* Plot2d_SelectableItem::legendSymbol() const {
+  return new QwtSymbol( myLegendSymbol->style(), myLegendSymbol->brush(),
+                        myLegendSymbol->pen(), myLegendSymbol->size() );
 }
 
 /*!
@@ -521,16 +615,16 @@ double Plot2d_HistogramQwtItem::baseline() const
 /*!
   Sets data to object
 */
-void Plot2d_HistogramQwtItem::setData( const QwtIntervalData& theData )
+void Plot2d_HistogramQwtItem::setData( const QwtIntervalSeriesData& theData )
 {
-  myData = theData;
+  myData.setSamples( theData.samples() );
   itemChanged();
 }
 
 /*!
   Returns data from object
 */
-const QwtIntervalData& Plot2d_HistogramQwtItem::data() const
+const QwtIntervalSeriesData& Plot2d_HistogramQwtItem::data() const
 {
   return myData;
 }
@@ -618,7 +712,7 @@ bool Plot2d_HistogramQwtItem::testHistogramAttribute( HistogramAttribute theAttr
 void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
                                    const QwtScaleMap& theXMap,
                                    const QwtScaleMap& theYMap,
-                                   const QRect& ) const
+                                   const QRectF& ) const
 {
   thePainter->setPen( QPen( myColor ) );
 
@@ -627,19 +721,19 @@ void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
 
   for ( int i = 0; i < (int)myData.size(); i++ ) {
     if ( myAttributes & Plot2d_HistogramQwtItem::Xfy ) {
-      const int x2 = theXMap.transform( myData.value( i ) );
+      const int x2 = theXMap.transform( myData.sample(i).value );
       if ( x2 == x0 )
         continue;
-      int y1 = theYMap.transform( myData.interval( i ).minValue() );
-      int y2 = theYMap.transform( myData.interval( i ).maxValue() );
+      int y1 = theYMap.transform( myData.sample( i ).interval.minValue() );
+      int y2 = theYMap.transform( myData.sample( i ).interval.maxValue() );
       if ( y1 > y2 )
         qSwap( y1, y2 );
 
       if ( i < (int)myData.size() - 2 ) {
-        const int yy1 = theYMap.transform( myData.interval(i+1).minValue() );
-        const int yy2 = theYMap.transform( myData.interval(i+1).maxValue() );
+        const int yy1 = theYMap.transform( myData.sample(i+1).interval.minValue() );
+        const int yy2 = theYMap.transform( myData.sample(i+1).interval.maxValue() );
         if ( y2 == qwtMin( yy1, yy2 ) ) {
-          const int xx2 = theXMap.transform( myData.interval(i+1).minValue() );
+          const int xx2 = theXMap.transform( myData.sample(i+1).interval.minValue() );
           if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
                               ( xx2 > x0 && x2 > x0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -650,19 +744,19 @@ void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
       drawBar( thePainter, Qt::Horizontal, QRect( x0, y1, x2 - x0, y2 - y1 ) );
     }
     else {
-      const int y2 = theYMap.transform( myData.value( i ) );
+      const int y2 = theYMap.transform( myData.sample( i ).value );
       if ( y2 == y0 )
         continue;
-      int x1 = theXMap.transform( myData.interval( i ).minValue() );
-      int x2 = theXMap.transform( myData.interval( i ).maxValue() );
+      int x1 = theXMap.transform( myData.sample( i ).interval.minValue() );
+      int x2 = theXMap.transform( myData.sample( i ).interval.maxValue() );
       if ( x1 > x2 )
         qSwap( x1, x2 );
 
       if ( i < (int)myData.size() - 2 ) {
-        const int xx1 = theXMap.transform( myData.interval(i+1).minValue() );
-        const int xx2 = theXMap.transform( myData.interval(i+1).maxValue() );
+        const int xx1 = theXMap.transform( myData.sample(i+1).interval.minValue() );
+        const int xx2 = theXMap.transform( myData.sample(i+1).interval.maxValue() );
         if ( x2 == qwtMin( xx1, xx2 ) ) {
-          const int yy2 = theYMap.transform( myData.value(i+1) );
+          const int yy2 = theYMap.transform( myData.sample(i+1).value );
           if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
                               ( yy2 > y0 && y2 > y0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -756,28 +850,35 @@ QList<QRect> Plot2d_HistogramItem::getBars() const
 /*!
   Set to legend item symbol with color of item
 */
-void Plot2d_HistogramItem::updateLegend( QwtLegend* theLegend ) const
+void Plot2d_HistogramItem::updateLegend( QwtPlotItem* thePlotItem,
+                                         QList<QwtLegendData>& theLegendData )
 {
-  if ( !theLegend )
+  if ( !thePlotItem || !thePlotItem->plot() )
     return;
 
-  Plot2d_HistogramQwtItem::updateLegend( theLegend );
+  Plot2d_HistogramQwtItem::updateLegend( thePlotItem, theLegendData );
 
-  QWidget* theWidget = theLegend->find( this );
-  if ( !theWidget || !theWidget->inherits( "QwtLegendItem" ) )
+  const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) );
+  QwtLegend *legend = dynamic_cast<QwtLegend *>( thePlotItem->plot()->legend() );
+  QWidget* widget = legend->legendWidget( itemInfo );
+
+  if ( !widget || !widget->inherits( "QwtLegendItem" ) )
     return;
 
-  Plot2d_QwtLegendItem* anItem = ( Plot2d_QwtLegendItem* )theWidget;
-  QFontMetrics aFMetrics( anItem->font() );
-  int aSize = aFMetrics.height();
-  QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
-                     QPen( legendPen().color() ), QSize( aSize, aSize ) );
-  anItem->setSymbol( aSymbol );
-  anItem->setIdentifierMode( theLegend->identifierMode()
-                            | QwtLegendItem::ShowSymbol );
-  anItem->setSelected(isSelected());
-  anItem->updateHighlit();
-  anItem->update();
+  QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
+  if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)( label ) ) {
+    QFontMetrics aFMetrics( anItem->font() );
+    int aSize = aFMetrics.height();
+    QwtSymbol* aSymbol = new QwtSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
+                                        QPen( legendPen().color() ), QSize( aSize, aSize ) );
+    anItem->setSymbol( aSymbol );
+    if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+      anItem->setSymbolType( plot->getLegendSymbolType() );
+    anItem->setSelected( isSelected() );
+    anItem->updateHighlit();
+    anItem->update();
+    anItem->repaint();
+  }
 }
 
 /*!
@@ -786,7 +887,7 @@ void Plot2d_HistogramItem::updateLegend( QwtLegend* theLegend ) const
 void Plot2d_HistogramItem::draw( QPainter* thePainter,
                                 const QwtScaleMap& theXMap,
                                 const QwtScaleMap& theYMap,
-                                const QRect& ) const
+                                const QRectF& ) const
 {
   // nds: clear list of bar items
   Plot2d_HistogramItem* anItem = (Plot2d_HistogramItem*)this;
@@ -796,23 +897,23 @@ void Plot2d_HistogramItem::draw( QPainter* thePainter,
   const int x0 = theXMap.transform( baseline() );
   const int y0 = theYMap.transform( baseline() );
 
-  const QwtIntervalData& iData = data();
+  const QwtIntervalSeriesData& iData = data();
 
   for ( int i = 0; i < (int)iData.size(); i++ ) {
     if ( testHistogramAttribute( Plot2d_HistogramItem::Xfy ) ) {
-      const int x2 = theXMap.transform( iData.value( i ) );
+      const int x2 = theXMap.transform( iData.sample(i).value );
       if ( x2 == x0 )
         continue;
-      int y1 = theYMap.transform( iData.interval( i ).minValue() );
-      int y2 = theYMap.transform( iData.interval( i ).maxValue() );
+      int y1 = theYMap.transform( iData.sample(i).interval.minValue() );
+      int y2 = theYMap.transform( iData.sample(i).interval.maxValue() );
       if ( y1 > y2 )
         qSwap( y1, y2 );
 
       if ( i < (int)iData.size() - 2 ) {
-        const int yy1 = theYMap.transform( iData.interval(i+1).minValue() );
-        const int yy2 = theYMap.transform( iData.interval(i+1).maxValue() );
+        const int yy1 = theYMap.transform( iData.sample(i+1).interval.minValue() );
+        const int yy2 = theYMap.transform( iData.sample(i+1).interval.maxValue() );
         if ( y2 == qwtMin( yy1, yy2 ) ) {
-          const int xx2 = theXMap.transform( iData.interval(i+1).minValue() );
+          const int xx2 = theXMap.transform( iData.sample(i+1).interval.minValue() );
           if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
                               ( xx2 > x0 && x2 > x0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -826,19 +927,19 @@ void Plot2d_HistogramItem::draw( QPainter* thePainter,
       anItem->myBarItems.append( aRect );
     }
     else {
-      const int y2 = theYMap.transform( iData.value( i ) );
+      const int y2 = theYMap.transform( iData.sample(i).value );
       if ( y2 == y0 )
         continue;
-      int x1 = theXMap.transform( iData.interval( i ).minValue() );
-      int x2 = theXMap.transform( iData.interval( i ).maxValue() );
+      int x1 = theXMap.transform( iData.sample(i).interval.minValue() );
+      int x2 = theXMap.transform( iData.sample(i).interval.maxValue() );
       if ( x1 > x2 )
         qSwap( x1, x2 );
 
       if ( i < (int)iData.size() - 2 ) {
-        const int xx1 = theXMap.transform( iData.interval(i+1).minValue() );
-        const int xx2 = theXMap.transform( iData.interval(i+1).maxValue() );
+        const int xx1 = theXMap.transform( iData.sample(i+1).interval.minValue() );
+        const int xx2 = theXMap.transform( iData.sample(i+1).interval.maxValue() );
         if ( x2 == qwtMin( xx1, xx2 ) ) {
-          const int yy2 = theYMap.transform( iData.value(i+1) );
+          const int yy2 = theYMap.transform( iData.sample(i+1).value );
           if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
                               ( yy2 > y0 && y2 > y0 ) ) ) {
             // One pixel distance between neighboured bars
@@ -870,15 +971,6 @@ bool Plot2d_HistogramItem::isCrossItems() const
   return myCrossed;
 }
 
-/*!
-  Redefined method, which creates and returns legend item of the curve
-*/
-QWidget* Plot2d_HistogramItem::legendItem() const
-{
-  return new Plot2d_QwtLegendItem;
-}
-
-
 /*!
   Draws bar of histogram and on it bars of histograms with lower height.
 */
@@ -931,3 +1023,29 @@ int Plot2d_HistogramItem::getCrossedTop( const QRect& theRect ) const
   }
   return aRes;
 }
+
+Plot2d_QwtLegend::Plot2d_QwtLegend( QWidget *parent ):
+QwtLegend( parent )
+{
+  setAutoFillBackground(true);
+}
+
+Plot2d_QwtLegend::~Plot2d_QwtLegend()
+{
+}
+
+/*!
+  Redefined method, which create a widget to be inserted into the legend.
+*/
+QWidget *Plot2d_QwtLegend::createWidget( const QwtLegendData &data ) const
+{
+  Q_UNUSED( data );
+
+  Plot2d_QwtLegendLabel *label = new Plot2d_QwtLegendLabel();
+  label->setItemMode( defaultItemMode() );
+
+  connect( label, SIGNAL( clicked() ), SLOT( itemClicked() ) );
+  connect( label, SIGNAL( checked( bool ) ), SLOT( itemChecked( bool ) ) );
+
+  return label;
+}
index 357303a946ba0c1026b20433b273c5ba91082b51..6feff2c1acc8d953d29294db7044f7442dba0ba4 100644 (file)
 
 #include "Plot2d.h"
 
-#include <qwt_legend_item.h>
+#include <qwt_legend_label.h>
+#include <qwt_legend.h>
 #include <qwt_plot_item.h>
 #include <qwt_plot_curve.h>
-#include <qwt_interval_data.h>
 #include <qwt_plot.h>
+#include <qwt_series_data.h>
+#include <qwt_compat.h>
 
-class PLOT2D_EXPORT Plot2d_QwtLegendItem : public QwtLegendItem
+class PLOT2D_EXPORT Plot2d_QwtLegendLabel : public QwtLegendLabel
 {
 public:
   enum YAxisIdentifierMode { IM_None = 0, IM_Left, IM_Right };
 
 public:
-  Plot2d_QwtLegendItem( QWidget* = 0 );
-  virtual ~Plot2d_QwtLegendItem();
+  Plot2d_QwtLegendLabel( QWidget* = 0 );
+  virtual ~Plot2d_QwtLegendLabel();
 
 public:
   void             setYAxisIdentifierMode( const int );
   void             updateHighlit();
-  void             setSelected(const bool on);
+  void             setSelected( const bool on );
   bool             isSelected() const;
-  QColor           getColorFromPalette(QPalette::ColorRole role);  
+  QColor           getColorFromPalette( QPalette::ColorRole role );
+  void             drawIdentifier( QPainter*, const QRect& );
+  void             setSymbol( const QwtSymbol* );
+  void             setSymbolType( const int );
+  void             setPen( const QPen& );
 
 protected:
-  virtual void     drawIdentifier( QPainter*, const QRect& ) const;
-  virtual void     drawText(QPainter *, const QRect &);
+  virtual void     drawText( QPainter*, const QRectF& );
+  virtual void     paintEvent( QPaintEvent* );
 
 private:
 
@@ -62,26 +68,29 @@ private:
   int              mySpacingCollapsed;
   int              mySpacingExpanded;
   bool             myIsSelected;
+  QwtSymbol*       mySymbol;
+  int              mySymbolType;
+  QPen             myPen;
 };
 
 class PLOT2D_EXPORT Plot2d_SelectableItem {
 public:
-    Plot2d_SelectableItem();
-    ~Plot2d_SelectableItem();
-  
-    void             setSelected( const bool );
-    bool             isSelected() const;
-    
-    void             setLegendPen( const QPen & );
-    QPen             legendPen() const;
-       
-    void             setLegendSymbol( const QwtSymbol& );
-    QwtSymbol        legendSymbol() const;
-    
+  Plot2d_SelectableItem();
+  ~Plot2d_SelectableItem();
+
+  void             setSelected( const bool );
+  bool             isSelected() const;
+
+  void             setLegendPen( const QPen& );
+  QPen             legendPen() const;
+
+  void             setLegendSymbol( const QwtSymbol* );
+  QwtSymbol*       legendSymbol() const;
+
 private:
   bool             myIsSelected;
   QPen             myLegendPen;
-  QwtSymbol        myLegendSymbol;
+  QwtSymbol*       myLegendSymbol;
 };
 
 class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve, public Plot2d_SelectableItem
@@ -92,27 +101,28 @@ public:
 
 public:
   virtual void     setYAxisIdentifierEnabled( const bool );
-  virtual void     draw(QPainter *p, 
-                        const QwtScaleMap &xMap, 
-                        const QwtScaleMap &yMap,
-                        int from, int to) const;
+  virtual void     drawSeries( QPainter* p,
+                               const QwtScaleMap& xMap,
+                               const QwtScaleMap& yMap,
+                               const QRectF& canvasRect,
+                               int from, int to) const;
 
-  void             setDeviationData(const double* min, const double* max, const QList<int> &idx);
+  void             setDeviationData( const double* min, const double* max, const QList<int>& idx );
   bool             hasDeviationData() const;
   void             clearDeviationData();
 
-
 protected:
-  virtual void     updateLegend( QwtLegend* ) const;
-  virtual QWidget* legendItem() const;
+  virtual void     updateLegend( const QwtPlotItem*,
+                                 const QList<QwtLegendData>& );
+  virtual void     itemChanged();
 
   QColor           deviationMarkerColor() const;
   int              deviationMarkerLineWidth() const;
   int              deviationMarkerTickSize() const;
 
 private:
-  QwtPlot::Axis        myYAxis;
-  bool                 myYAxisIdentifierEnabled;
+  QwtPlot::Axis    myYAxis;
+  bool             myYAxisIdentifierEnabled;
   
   class Plot2d_DeviationData;
   Plot2d_DeviationData* myDeviationData;
@@ -131,8 +141,8 @@ public:
   explicit Plot2d_HistogramQwtItem( const QwtText& );
   virtual ~Plot2d_HistogramQwtItem();
 
-  void                   setData( const QwtIntervalData& );
-  const QwtIntervalData& data() const;
+  void                   setData( const QwtIntervalSeriesData& );
+  const QwtIntervalSeriesData& data() const;
 
   void                   setColor( const QColor& );
   QColor                 color() const;
@@ -140,7 +150,7 @@ public:
   virtual QwtDoubleRect  boundingRect() const;
   virtual int            rtti() const;
   virtual void           draw( QPainter*, const QwtScaleMap&, 
-                              const QwtScaleMap&, const QRect& ) const;
+                               const QwtScaleMap&, const QRectF& ) const;
 
   void                   setBaseline( double );
   double                 baseline() const;
@@ -156,7 +166,7 @@ private:
 
 private:
   int                    myAttributes;
-  QwtIntervalData        myData;
+  QwtIntervalSeriesData  myData;
   QColor                 myColor;
   double                 myReference;
 };
@@ -168,25 +178,34 @@ public:
   explicit Plot2d_HistogramItem( const QwtText& );
   virtual ~Plot2d_HistogramItem();
 
-  QList<QRect>           getBars() const;
+  QList<QRect>     getBars() const;
 
-  virtual void           updateLegend( QwtLegend* ) const;
-  virtual void           draw( QPainter*, const QwtScaleMap&, 
-                              const QwtScaleMap&, const QRect& ) const;
+  virtual void     updateLegend( QwtPlotItem*,
+                                 QList<QwtLegendData>& );
+  virtual void     draw( QPainter*, const QwtScaleMap&,
+                         const QwtScaleMap&, const QRectF& ) const;
+
+  void             setCrossItems( bool theCross );
+  bool             isCrossItems() const;
 
-  void                   setCrossItems( bool theCross );
-  bool                   isCrossItems() const;
+protected:
+  void             drawRectAndLowers( QPainter*, Qt::Orientation,
+                                      const QRect& ) const;
+  int              getCrossedTop( const QRect& ) const;
 
 protected:
-  void                   drawRectAndLowers( QPainter*, Qt::Orientation,
-                                           const QRect& ) const;
-  int                    getCrossedTop( const QRect& ) const;
+  QList<QRect>     myBarItems;
+  bool             myCrossed;
+};
 
-  virtual QWidget*       legendItem() const;
+class PLOT2D_EXPORT Plot2d_QwtLegend : public QwtLegend
+{
+public:
+  explicit Plot2d_QwtLegend( QWidget *parent = NULL );
+  virtual ~Plot2d_QwtLegend();
 
 protected:
-  QList<QRect>           myBarItems;
-  bool                   myCrossed;
+  virtual QWidget* createWidget( const QwtLegendData& ) const;
 };
 
 #endif // PLOT2D_PLOTITEMS_H
index 814a289326276b9f76126432eb540ab175a73988..712371428f1e905bf559fe11ad1b74e6a9f5779b 100755 (executable)
@@ -89,19 +89,6 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) );
   myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) );
 
-  // legend
-  myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
-  myLegendCombo = new QComboBox( this );
-  myLegendFont = new QtxFontEdit( this );
-  myLegendColor = new QtxColorButton( this );
-  QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
-  myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
-  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
-
   // marker size
   QLabel* aMarkerLab  = new QLabel( tr( "PLOT2D_MARKER_SIZE_LBL" ), this );
   myMarkerSpin = new QSpinBox( this );
@@ -115,6 +102,68 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   QLabel* aBGLab  = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this );
   myBackgroundBtn = new QtxColorButton( this );
 
+  // selection color
+  QLabel* aSelectionLab  = new QLabel( tr( "PLOT2D_SELECTION_COLOR_LBL" ), this );
+  mySelectionBtn = new QtxColorButton( this );
+
+  QHBoxLayout* ViewerColorLayout = new QHBoxLayout;
+  ViewerColorLayout->addWidget( aBGLab );
+  ViewerColorLayout->addWidget( myBackgroundBtn );
+  ViewerColorLayout->addStretch();
+  ViewerColorLayout->addWidget( aSelectionLab );
+  ViewerColorLayout->addWidget( mySelectionBtn );
+  ViewerColorLayout->addStretch();
+
+  // legend
+  QGroupBox* aLegendGrp = new QGroupBox( tr( "PLOT2D_LEGEND_GROUP" ), this );
+  QGridLayout* aLegendLayout = new QGridLayout( aLegendGrp );
+  aLegendLayout->setMargin( MARGIN_SIZE ); aLegendLayout->setSpacing( SPACING_SIZE );
+  aLegendGrp->setLayout( aLegendLayout );
+
+  myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
+
+  QLabel* aLegendPosition = new QLabel( tr( "PLOT2D_LEGEND_POSITION" ), this );
+  myLegendCombo = new QComboBox( this );
+  myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
+  myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
+
+  QLabel* aLegendSymbolType = new QLabel( tr( "PLOT2D_LEGEND_SYMBOL_TYPE" ), this );
+  myLegendSymbolType = new QComboBox( this );
+  myLegendSymbolType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLegendSymbolType->setMinimumWidth( MIN_COMBO_WIDTH );
+  myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ON_LINE" ) );
+  myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ABOVE_LINE" ) );
+
+  QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
+  myLegendFont = new QtxFontEdit( this );
+
+  QLabel* aLegendFontColor = new QLabel( tr( "PLOT2D_LEGEND_FONT_COLOR" ), this );
+  myLegendFontColor = new QtxColorButton( this );
+
+  QLabel* aSelectLegendFontColor = new QLabel( tr( "PLOT2D_SELECTED_LEGEND_FONT_COLOR" ), this );
+  mySelectedLegendFontColor = new QtxColorButton( this );
+
+  QHBoxLayout* FontLayout = new QHBoxLayout;
+  FontLayout->addWidget( aLegendFontColor );
+  FontLayout->addWidget( myLegendFontColor );
+  FontLayout->addStretch();
+  FontLayout->addWidget( aSelectLegendFontColor );
+  FontLayout->addWidget( mySelectedLegendFontColor );
+  FontLayout->addStretch();
+
+  aLegendLayout->addWidget( myLegendCheck,      0, 0 );
+  aLegendLayout->addWidget( aLegendPosition,    1, 0 );
+  aLegendLayout->addWidget( myLegendCombo,      1, 1 );
+  aLegendLayout->addWidget( aLegendSymbolType,  2, 0 );
+  aLegendLayout->addWidget( myLegendSymbolType, 2, 1 );
+  aLegendLayout->addWidget( aLegendFontLab,     3, 0 );
+  aLegendLayout->addWidget( myLegendFont,       3, 1 );
+  aLegendLayout->addLayout( FontLayout,         4, 0, 1, 2 );
+
   //Deviation marker parameters
   QGroupBox* aDeviationGrp = new QGroupBox( tr( "PLOT2D_DEVIATION_MARKER_TLT" ), this );
   QHBoxLayout* aDeviationLayout = new QHBoxLayout(aDeviationGrp);
@@ -375,30 +424,21 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent,
   btnLayout->addWidget( myHelpBtn );
 
   // layout widgets
-  topLayout->addWidget( myTitleCheck,  0,    0    );
-  topLayout->addWidget( myTitleEdit,   0, 1, 1, 3 );
-  topLayout->addWidget( myLegendCheck, 1,    0    );
-  topLayout->addWidget( myLegendCombo, 1,    1    );
-  topLayout->addWidget( aCurveLab,  1,    2    );
-  topLayout->addWidget( myCurveCombo,  1,     3    );
-  topLayout->addWidget( aLegendFontLab,2,    0    );
-  topLayout->addWidget( myLegendFont,     2,    1    );
-  topLayout->addWidget( myLegendColor,  2,    2    );
-
-  topLayout->addWidget( aMarkerLab,    3,    0    );
-  topLayout->addWidget( myMarkerSpin,  3,    1    );
-  QHBoxLayout* bgLayout = new QHBoxLayout;
-  bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch();
-  topLayout->addWidget( aBGLab,        3,    2    );
-  topLayout->addLayout( bgLayout,      3,    3    );
-  topLayout->addWidget( aDeviationGrp,   4, 0, 1, 4 );
-  topLayout->addWidget( aNormalizeGrp,      5, 0, 1, 4 );
-  topLayout->addWidget( aScaleGrp,     6, 0, 1, 4 );
-  topLayout->addWidget( aTabWidget,    7, 0, 1, 4 );
-  topLayout->addWidget( myDefCheck,    8, 0, 1, 4 );
-  topLayout->setRowStretch( 9, 5 );
-
-  topLayout->addLayout( btnLayout,     10, 0, 1, 4 );
+  topLayout->addWidget( myTitleCheck,      0, 0       );
+  topLayout->addWidget( myTitleEdit,       0, 1, 1, 3 );
+  topLayout->addWidget( aCurveLab,         1, 0       );
+  topLayout->addWidget( myCurveCombo,      1, 1       );
+  topLayout->addWidget( aMarkerLab,        2, 0       );
+  topLayout->addWidget( myMarkerSpin,      2, 1       );
+  topLayout->addLayout( ViewerColorLayout, 3, 0, 1, 4 );
+  topLayout->addWidget( aLegendGrp,        4, 0, 1, 4 );
+  topLayout->addWidget( aDeviationGrp,     5, 0, 1, 4 );
+  topLayout->addWidget( aNormalizeGrp,     6, 0, 1, 4 );
+  topLayout->addWidget( aScaleGrp,         7, 0, 1, 4 );
+  topLayout->addWidget( aTabWidget,        8, 0, 1, 4 );
+  topLayout->addWidget( myDefCheck,        9, 0, 1, 4 );
+  topLayout->setRowStretch( 10, 5 );
+  topLayout->addLayout( btnLayout,         11, 0, 1, 4 );
 
   if ( !showDefCheck )
     myDefCheck->hide();
@@ -698,12 +738,15 @@ bool Plot2d_SetupViewDlg::getRMinNormMode()
   \param col legend font color
   \sa isLegendEnabled(), getLegendPos(), getLegendFont()
 */
-void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, const QFont& fnt, const QColor& col )
+void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, int symbolType,
+                                     const QFont& fnt, const QColor& fontColor, const QColor& selFontColor )
 {
   myLegendCheck->setChecked( enable );
   myLegendCombo->setCurrentIndex( pos );
+  myLegendSymbolType->setCurrentIndex( symbolType );
   myLegendFont->setCurrentFont( fnt );
-  myLegendColor->setColor( col );
+  myLegendFontColor->setColor( fontColor );
+  mySelectedLegendFontColor->setColor( selFontColor );
   onLegendChecked();
 }
 
@@ -727,6 +770,16 @@ int Plot2d_SetupViewDlg::getLegendPos()
   return myLegendCombo->currentIndex();
 }
 
+/*!
+  \brief Get legend symbol type.
+  \return legend symbol type: 0 (marker on line), 1 (marker above line)
+  \sa setLegend()
+*/
+int Plot2d_SetupViewDlg::getLegendSymbolType()
+{
+  return myLegendSymbolType->currentIndex();
+}
+
 /*!
   \brief Get legend font.
   \return legend font
@@ -744,7 +797,17 @@ QFont Plot2d_SetupViewDlg::getLegendFont()
 */
 QColor Plot2d_SetupViewDlg::getLegendColor()
 {
-  return myLegendColor->color();
+  return myLegendFontColor->color();
+}
+
+/*!
+  \brief Get selected legend font color.
+  \return selected legend font color
+  \sa setLegend()
+*/
+QColor Plot2d_SetupViewDlg::getSelectedLegendColor()
+{
+  return mySelectedLegendFontColor->color();
 }
 
 /*!
@@ -840,6 +903,26 @@ QColor Plot2d_SetupViewDlg::getBackgroundColor()
   return myBackgroundBtn->color();
 }
 
+/*!
+  \brief Set selection color.
+  \param color selection color
+  \sa getSelectionColor()
+*/
+void Plot2d_SetupViewDlg::setSelectionColor( const QColor& color )
+{
+  mySelectionBtn->setColor( color );
+}
+
+/*!
+  \brief Get selection color.
+  \return selection color
+  \sa setSelectionColor()
+*/
+QColor Plot2d_SetupViewDlg::getSelectionColor()
+{
+  return mySelectionBtn->color();
+}
+
 /*!
   \brief Set major grid parameters.
   \param enableX if \c true, horizontal major grid is enabled
index 1e9f3e4e79e22e3251e5e1132e7cb494b52a5ed5..855ce61f3101698fbd47964e03ab551e9dacfefd 100755 (executable)
@@ -73,11 +73,13 @@ public:
   bool            getRMinNormMode();
   void            setRMinNormMode(const bool);
 
-  void            setLegend( bool, int, const QFont&, const QColor& );
+  void            setLegend( bool, int, int, const QFont&, const QColor&, const QColor& );
   bool            isLegendEnabled();
   int             getLegendPos();
+  int             getLegendSymbolType();
   QFont           getLegendFont();
   QColor          getLegendColor();
+  QColor          getSelectedLegendColor();
   
   void            setMarkerSize( const int );
   int             getMarkerSize();
@@ -85,6 +87,9 @@ public:
   void            setBackgroundColor( const QColor& );
   QColor          getBackgroundColor();
 
+  void            setSelectionColor( const QColor& );
+  QColor          getSelectionColor();
+
   void            setMajorGrid( bool, const int, bool, const int, bool, const int );
   void            getMajorGrid( bool&, int&, bool&, int&, bool&, int& );
   void            setMinorGrid( bool, const int, bool, const int, bool, const int );
@@ -133,7 +138,9 @@ private:
   QLineEdit*      myTitleYEdit;
   QLineEdit*      myTitleY2Edit;
   QtxColorButton* myBackgroundBtn;
-  QtxColorButton* myLegendColor;
+  QtxColorButton* mySelectionBtn;
+  QtxColorButton* myLegendFontColor;
+  QtxColorButton* mySelectedLegendFontColor;
   QtxFontEdit*    myLegendFont;
   QCheckBox*      myXGridCheck;
   QSpinBox*       myXGridSpin;
@@ -150,6 +157,7 @@ private:
   QComboBox*      myCurveCombo;
   QCheckBox*      myLegendCheck;
   QComboBox*      myLegendCombo;
+  QComboBox*      myLegendSymbolType;
   QSpinBox*       myMarkerSpin;
   QComboBox*      myXModeCombo;
   QComboBox*      myYModeCombo;
index 76caaec02e245bdb03c0fe2a9979cfdb847f38b4..083f80bcee579b2931bd53ba1a97b23ce3b95d2a 100755 (executable)
@@ -74,6 +74,7 @@
 #include <qwt_scale_engine.h>
 #include <qwt_plot_zoomer.h>
 #include <qwt_curve_fitter.h>
+#include <qwt_plot_renderer.h>
 
 #include <stdlib.h>
 #include <limits>
@@ -181,10 +182,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 +208,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 +226,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 +240,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 +264,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 +472,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 +529,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 +583,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 +595,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 +606,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 +618,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 +642,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 +654,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 +747,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;
@@ -875,9 +891,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);
@@ -1002,7 +1019,7 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title,
   {
       if (!displayLegend)
         {
-          myPlot->insertLegend( (QwtLegend*)NULL);
+          myPlot->insertLegend( (QwtAbstractLegend*)NULL);
         }
       displayCurve( plot2dCurve);
 
@@ -1024,15 +1041,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 +1089,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;
+  aSymbol->setStyle( markerKind );
+  aPCurve->setSymbol( aSymbol );
 
   // The segment must not have legend's entry
   aPCurve->setItemAttribute( QwtPlotItem::Legend, false);
@@ -1254,13 +1272,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 +1422,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 +1437,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();
@@ -1708,9 +1716,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 +1769,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 +1779,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 +1791,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;
@@ -1857,9 +1877,9 @@ void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool upd
 {
 #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();
@@ -1869,6 +1889,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);
@@ -2020,19 +2041,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();
 }
@@ -2043,7 +2076,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:
@@ -2070,13 +2103,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);
   }
@@ -2090,21 +2141,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 );
@@ -2112,6 +2155,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
 */
@@ -2126,11 +2194,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 )
@@ -2165,6 +2233,7 @@ void Plot2d_ViewFrame::setBackgroundColor( const QColor& color )
   }
   Repaint();
 }
+
 /*!
   Gets background color
 */
@@ -2172,6 +2241,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
 */
@@ -2188,8 +2275,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 );
 
@@ -2225,8 +2312,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) {
@@ -2234,8 +2321,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 );
     }
@@ -2353,6 +2440,12 @@ void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update )
 
   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 )
@@ -2389,9 +2482,21 @@ void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update )
   }
 
   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();
@@ -2878,7 +2983,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 );
@@ -2893,7 +2998,6 @@ public:
 */
 Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
   : QwtPlot( parent ),
-    myIsPolished( false ),
     myPicker( 0 )
 {
   // Create alternative scales
@@ -2902,7 +3006,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 ) );
@@ -2917,7 +3020,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 );
 
@@ -2947,7 +3050,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() );
 }
@@ -2984,7 +3087,7 @@ void Plot2d_Plot2d::replot()
 /*!
   Get legend
 */
-QwtLegend* Plot2d_Plot2d::getLegend()
+QwtAbstractLegend* Plot2d_Plot2d::getLegend()
 {
 #if QWT_VERSION < 0x040200
   return d_legend;
@@ -3016,12 +3119,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 );
 }
 
 /*!
@@ -3035,11 +3140,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();
 
@@ -3066,11 +3171,6 @@ QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
   return aPlotMarker;
 }
 
-bool Plot2d_Plot2d::polished() const
-{
-  return myIsPolished;
-}
-
 QwtPlotGrid* Plot2d_Plot2d::grid() const
 {
   return myGrid;
@@ -3081,44 +3181,6 @@ 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.
 */
@@ -3143,19 +3205,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
@@ -3360,6 +3413,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
@@ -3381,8 +3448,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;
@@ -3519,22 +3590,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 );
 }
 
 /*!
@@ -3951,7 +4024,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) {
@@ -3969,7 +4042,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;
 }
 
 /*!
@@ -4120,21 +4193,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++;
@@ -4218,9 +4283,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();
 
@@ -4294,9 +4363,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();
 
@@ -4327,7 +4398,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();
@@ -4371,13 +4442,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
@@ -4400,20 +4469,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());
index f1732b97662d7678e1c8649bb0ad07a01a92efcb..fb23604f28808c9bca6f009b814a111b175452b0 100755 (executable)
@@ -39,6 +39,8 @@
 #include <qwt_scale_draw.h>
 #include <qwt_plot_marker.h>
 #include <qwt_plot_picker.h>
+#include <qwt_plot_canvas.h>
+#include <qwt_legend.h>
 
 #include <iostream>
 #include <ostream>
@@ -74,6 +76,7 @@ public:
   virtual ~Plot2d_ViewFrame();
 
   void Init();
+  void SetPreference();
 
   enum ObjectType { MainTitle, XTitle, YTitle, Y2Title, XAxis, YAxis, Y2Axis };
 
@@ -186,14 +189,20 @@ public:
   void           showLegend( bool, bool = true );
   void           setLegendPos( int );
   int            getLegendPos() const;
+  void           setLegendSymbolType( int );
+  int            getLegendSymbolType() const;
   void           setLegendFont( const QFont& );
   QFont          getLegendFont() const;
   void           setLegendFontColor( const QColor& );
   QColor         getLegendFontColor() const;
+  void           setSelectedLegendFontColor( const QColor& );
+  QColor         getSelectedLegendFontColor() const;
   void           setMarkerSize( const int, bool = true  );
   int            getMarkerSize() const;
   virtual void   setBackgroundColor( const QColor& );
   QColor         backgroundColor() const;
+  virtual void   setSelectionColor( const QColor& );
+  QColor         selectionColor() const;
   void           setXGrid( bool, const int, bool, const int, bool = true );
   void           setYGrid( bool, const int, bool, const int,
                           bool, const int, bool, const int, bool = true );
@@ -232,8 +241,7 @@ public:
   void           setEnableAxis( QwtPlot::Axis, bool );
 
   virtual bool   print( const QString&, const QString& ) const;
-  void           printPlot( QPainter*, const QRect&,
-                           const QwtPlotPrintFilter& = QwtPlotPrintFilter() ) const;
+  void           printPlot( QPainter*, const QRectF& ) const;
 
   QString        getVisualParameters();
   void           setVisualParameters( const QString& );
@@ -294,7 +302,7 @@ signals:
   void           vpNormRModeChanged();
   void           vpCurveChanged();
   void           contextMenuRequested( QContextMenuEvent* );
-  void           legendClicked( QwtPlotItem* );
+  void           clicked (const QVariant&, int );
 
 protected:
   Plot2d_Plot2d*      myPlot;
@@ -304,10 +312,13 @@ protected:
   int                 myCurveType;
   bool                myShowLegend;
   int                 myLegendPos;
+  int                 myLegendSymbolType;
   QFont               myLegendFont;
   QColor              myLegendColor;
+  QColor              mySelectedLegendFontColor;
   int                 myMarkerSize;
   QColor              myBackground;
+  QColor              mySelectionColor;
   QString             myTitle, myXTitle, myYTitle, myY2Title;
   bool                myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled;
   bool                myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled;
@@ -343,26 +354,27 @@ public:
   Plot2d_Plot2d( QWidget* );
   virtual ~Plot2d_Plot2d();
 
-  void           setLogScale( int, bool );
+  void               setLogScale( int, bool );
 
-  void           replot();
-  QwtLegend*     getLegend();
-  QSize          sizeHint() const;
-  QSize          minimumSizeHint() const;
-  void           defaultPicker();
-  void           setPickerMousePattern( int, int = Qt::NoButton );
-  void           setPicker( Plot2d_QwtPlotPicker *picker);
+  void               replot();
+  QwtAbstractLegend* getLegend();
+  QSize              sizeHint() const;
+  QSize              minimumSizeHint() const;
+  void               defaultPicker();
+  void               setPickerMousePattern( int, int = Qt::NoButton );
+  void               setPicker( Plot2d_QwtPlotPicker *picker);
   Plot2d_QwtPlotPicker* getPicker() { return myPicker; }
   Plot2d_AxisScaleDraw* getScaleDraw() { return myScaleDraw; }
   QList<QwtPlotMarker*> getSeparationLineList() { return mySeparationLineList; }
   void clearSeparationLineList();
-  QwtPlotMarker *createMarkerAndTooltip( QwtSymbol symbol,
-                               double    X,
-                               double    Y,
-                               QString & tooltip,
-                               Plot2d_QwtPlotPicker *picker);
+  void setLegendSymbolType( const int );
+  int  getLegendSymbolType();
+  QwtPlotMarker *createMarkerAndTooltip( QwtSymbol* symbol,
+                                         double    X,
+                                         double    Y,
+                                         QString & tooltip,
+                                         Plot2d_QwtPlotPicker *picker);
 
-  bool           polished() const;
   QwtPlotGrid*   grid() const;
   QwtPlotZoomer* zoomer() const;
 
@@ -380,17 +392,9 @@ public:
 
   void createSeparationLine( double Xpos);
 
-
-public slots:
-  virtual void   polish();
-
-protected slots:
-  void           onScaleDivChanged();
-
 protected:
   QwtPlotGrid*   myGrid;
   QList<QColor>  myColors;
-  bool           myIsPolished;
   QwtPlotZoomer* myPlotZoomer;
   Plot2d_AxisScaleDraw* myScaleDraw;
   // The point picker associated with the graphic view
@@ -398,13 +402,13 @@ protected:
 private:
   // List of verticals segments between two curves
   QList<QwtPlotMarker*> mySeparationLineList;
+  int myLegendSymbolType;
 };
 
 class Plot2d_ScaleDraw: public QwtScaleDraw
 {
 public:
   Plot2d_ScaleDraw( char f = 'g', int prec = 6 );
-  Plot2d_ScaleDraw( const QwtScaleDraw& scaleDraw, char f = 'g', int prec = 6 );
 
   virtual QwtText label( double value ) const;
 
@@ -486,7 +490,6 @@ public:
 
   Plot2d_QwtPlotPicker( int            xAxis,
                         int            yAxis,
-                        int            selectionFlags,
                         RubberBand     rubberBand,
                         DisplayMode    trackerMode,
                         QwtPlotCanvas *canvas);
@@ -502,7 +505,7 @@ public:
 
 protected:
 
-  virtual QwtText trackerText( const QwtDoublePoint & pos ) const;
+  virtual QwtText trackerText( const QPoint & pos ) const;
 
 };
 
index 29b7cbf72fba86793a38ea49ad5a81bd12103b62..94e86e02cf19d503523b5a7d8092a647f4dbfd76 100755 (executable)
@@ -66,8 +66,8 @@ bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView )
 
     Plot2d_ViewFrame* aViewFrame = view->getViewFrame();
     Plot2d_Viewer* aViewer = getPlot2dModel();
-    connect( aViewFrame, SIGNAL( legendClicked( QwtPlotItem* ) ), 
-             aViewer, SLOT( onLegendClicked( QwtPlotItem* ) ) );
+    connect( aViewFrame, SIGNAL( clicked(const QVariant&, int) ),
+             aViewer, SLOT( onClicked(const QVariant&, int) ) );
   }
   return res;
 }
index 18fc7a9148be16c8ba4bc10275051191340b8215..0f76b101868168f0bbea4eb3d9325124c2fe8882 100755 (executable)
@@ -40,7 +40,8 @@ Plot2d_Viewer::Plot2d_Viewer(bool theAutoDel)
 {
   myPrs = 0;
   myAutoDel = theAutoDel;
-  Plot2d_Object::initColors();
+  Plot2d_Object::setSelectionColor( QColor(80,80,80) );
+  Plot2d_Object::setHighlightedLegendTextColor( QColor(255,255,255) );
 }
 
 /*!
@@ -219,7 +220,7 @@ void Plot2d_Viewer::onCloneView( Plot2d_ViewFrame* clonedVF, Plot2d_ViewFrame* n
 /*
   SLOT: called when clicked item in the legend from Plot2d_ViewManager
  */
-void Plot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+void Plot2d_Viewer::onClicked(const QVariant& itemInfo, int index)
 {
 }
 
index 78c7a62c8c8d949b1adbbb1f0952994be142b2eb..bafdf9ee73cac1d7dc134c7dbff3d15739a739bf 100755 (executable)
@@ -62,7 +62,7 @@ protected slots:
   void         onDumpView();
   void         onShowToolbar();
   virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* );
-  virtual void onLegendClicked( QwtPlotItem* );
+  virtual void onClicked( const QVariant&, int );
 
 private:
   Plot2d_Prs* myPrs;
index 6df2c8a2280fdde19d62bb5721dca907b53c2f28..8fe81acb02f554a65b22ccf28990b9e323de6da0 100755 (executable)
@@ -866,7 +866,7 @@ void Plot2d_ViewWindow::onPrintView()
   }
 
   QMap< QwtPlotCurve*, QPen > aCurvToPen;
-  QMap< QwtPlotCurve*, QwtSymbol > aCurvToSymbol;
+  QMap< QwtPlotCurve*, QwtSymbol* > aCurvToSymbol;
 
   if ( needColorCorrection )
   {
@@ -891,12 +891,12 @@ void Plot2d_ViewWindow::onPrintView()
       aCurve->setPen( aPen );
 
       // symbol
-      QwtSymbol aSymbol = aCurve->symbol();
+      QwtSymbol* aSymbol = const_cast<QwtSymbol*>( aCurve->symbol() );
       aCurvToSymbol[ aCurve ] = aSymbol;
-      aPen = aSymbol.pen();
+      aPen = aSymbol->pen();
       aPen.setColor( QColor( 0, 0, 0 ) );
       aPen.setWidthF( 1.5 );
-      aSymbol.setPen( aPen );
+      aSymbol->setPen( aPen );
 
       aCurve->setSymbol( aSymbol );
     }
index 3f7bea97e4f6644865e51b28e1796664b583d159..ff29205857c08b5da5218e5549ad72612a423414 100644 (file)
         <source>PLOT2D_BACKGROUND_COLOR_LBL</source>
         <translation>Background color:</translation>
     </message>
+    <message>
+        <source>PLOT2D_SELECTION_COLOR_LBL</source>
+        <translation>Selection color:</translation>
+    </message>
     <message>
         <source>PLOT2D_DEVIATION_MARKER_TLT</source>
         <translation>Deviation marker</translation>
@@ -565,6 +569,34 @@ Logarithmic scale for ordinate axis is not allowed.</translation>
         <source>PLOT2D_ENABLE_MAIN_TITLE</source>
         <translation>Main title</translation>
     </message>
+    <message>
+        <source>PLOT2D_LEGEND_GROUP</source>
+        <translation>Legend</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_POSITION</source>
+        <translation>Legend position:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_SYMBOL_TYPE</source>
+        <translation>Symbol type:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ABOVE_LINE</source>
+        <translation>Marker above line</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ON_LINE</source>
+        <translation>Marker on line</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_FONT_COLOR</source>
+        <translation>Legend font color:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
+        <translation>Highlighted legend font color:</translation>
+    </message> 
     <message>
         <source>TOT_PLOT2D_CURVES_LINES</source>
         <translation>Draw lines</translation>
index e4796f09a9274da8f31e8a0506c902d53772d4b1..3503778e65b65fbc0b4a6b0b43fc39056facdd02 100755 (executable)
         <source>PLOT2D_BACKGROUND_COLOR_LBL</source>
         <translation>Couleur d&apos;arrière-plan:</translation>
     </message>
+    <message>
+        <source>PLOT2D_SELECTION_COLOR_LBL</source>
+        <translation>Couleur de sélection:</translation>
+    </message>
     <message>
         <source>PLOT2D_DEVIATION_MARKER_TLT</source>
         <translation>Marqueur de déviation</translation>
@@ -565,6 +569,34 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
         <source>PLOT2D_ENABLE_MAIN_TITLE</source>
         <translation>Titre principal</translation>
     </message>
+    <message>
+        <source>PLOT2D_LEGEND_GROUP</source>
+        <translation>Légende</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_POSITION</source>
+        <translation>Position de la Légende:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_SYMBOL_TYPE</source>
+        <translation>Type de symbole:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ABOVE_LINE</source>
+        <translation>Marqueur dessus de la ligne</translation>
+    </message>
+    <message>
+        <source>PLOT2D_MARKER_ON_LINE</source>
+        <translation>Marqueur sur la ligne</translation>
+    </message>
+    <message>
+        <source>PLOT2D_LEGEND_FONT_COLOR</source>
+        <translation>Couleur de police de la légende:</translation>
+    </message>
+    <message>
+        <source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
+        <translation>Couleur de surlignement de la légende:</translation>
+    </message> 
     <message>
         <source>TOT_PLOT2D_CURVES_LINES</source>
         <translation>Dessiner des lignes</translation>
index a250c04ba990e1e94a786b91d014f7cf24e45031..0f4ed1d7dc3a2867be254d1959b4d2b0b0557659 100644 (file)
@@ -400,11 +400,13 @@ SUIT_ViewWindow* SPlot2d_Viewer::createView( SUIT_Desktop* theDesktop )
   SLOT: called when action "Legend Clicked" is activated.
   override "onLegendClicked" method from Plot2d_ViewModel.
 */
-void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+void SPlot2d_Viewer::onClicked( const QVariant& itemInfo, int index )
 {
   Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
   if(aViewFrame == NULL) return;
 
+  QwtPlotItem* plotItem = aViewFrame->getPlot()->infoToItem( itemInfo );
+
   bool isAnalytical = false;
   AnalyticalCurveList curves = aViewFrame->getAnalyticalCurves();
    foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
index eef72df462cc787c5da689b0409b62825c3b53ef..562932b9a5f57c9ca0ab916c34a8c3173e660cea 100644 (file)
@@ -84,7 +84,7 @@ public:
   Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
 
 protected slots:
-  virtual void onLegendClicked( QwtPlotItem* plotItem );
+  virtual void onClicked( const QVariant&, int );
 
 signals:
   void legendSelected( const QString& );