Salome HOME
updated copyright message
[modules/gui.git] / src / Plot2d / Plot2d_PlotItems.h
index 357303a946ba0c1026b20433b273c5ba91082b51..04917db5dfd94ae68e781987ab90643628921c80 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 #include "Plot2d.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,39 @@ 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;
 
-  void                   setCrossItems( bool theCross );
-  bool                   isCrossItems() const;
+  virtual void     updateLegend( const QwtPlotItem *,
+                                  const QList<QwtLegendData> & );
+  virtual void     draw( QPainter*, const QwtScaleMap&,
+                         const QwtScaleMap&, const QRectF& ) const;
+
+  virtual void     itemChanged();
+
+  virtual QwtGraphic legendIcon( int index, const QSizeF & ) 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