Salome HOME
Merge from V6_main 01/04/2013
[modules/gui.git] / src / Plot2d / Plot2d.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File   : Plot2d.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 //
26 #ifndef PLOT2D_H
27 #define PLOT2D_H
28
29 #ifdef WIN32
30 #  if defined PLOT2D_EXPORTS || defined Plot2d_EXPORTS
31 #    define PLOT2D_EXPORT __declspec(dllexport)
32 #  else
33 #    define PLOT2D_EXPORT __declspec(dllimport)
34 #  endif
35 #else
36 #  define PLOT2D_EXPORT
37 #endif
38
39 #include <qwt_symbol.h>
40 #include <Qt>
41
42 class QPainter;
43 class QwtPlot;
44
45 // Properties on the deviation marker.
46 #define PLOT2D_DEVIATION_COLOR "DEVIATION_COLOR"
47 #define PLOT2D_DEVIATION_LW "DEVIATION_LW"
48 #define PLOT2D_DEVIATION_TS "DEVIATION_TS"
49
50 struct PLOT2D_EXPORT Plot2d_Point
51 {
52   double x;
53   double y;
54   double* deviationPtr;
55   QString text;
56   Plot2d_Point();
57   Plot2d_Point( double theX, double theY, const QString& theText = QString() );
58   ~Plot2d_Point();
59   bool deviation(double& min, double& max) const;
60   bool hasDeviation() const;
61   void setDeviation(double min, double max);
62   void clearDeviation();
63   bool minDeviation(double& min) const;
64   bool maxDeviation(double& max) const;
65 };
66
67 typedef QList<Plot2d_Point> pointList;
68
69
70 namespace Plot2d
71 {
72   typedef enum { None, 
73                  Circle,  
74                  Rectangle,
75                  Diamond,
76                  DTriangle,
77                  UTriangle,
78                  LTriangle,
79                  RTriangle,
80                  Cross,
81                  XCross
82   } MarkerType;
83
84   typedef enum {
85     NoPen,
86     Solid, 
87     Dash, 
88     Dot, 
89     DashDot, 
90     DashDotDot
91   } LineType;
92
93   QwtSymbol::Style         plot2qwtMarker( MarkerType );
94   MarkerType qwt2plotMarker( QwtSymbol::Style );
95
96   Qt::PenStyle             plot2qwtLine( LineType );
97   LineType                 qwt2plotLine( Qt::PenStyle );
98
99   void                     drawLine( QPainter*, const QPoint&, const QPoint&, 
100                                      Qt::PenStyle = Qt::SolidLine, 
101                                      const QColor& = Qt::black, int = 0 );
102   void                     drawLine( QPainter*, const QPoint&, const QPoint&, 
103                                      LineType = Solid, 
104                                      const QColor& = Qt::black, int = 0 );
105   void                     drawLine( QPainter*, int, int, int, int,
106                                      Qt::PenStyle = Qt::SolidLine, 
107                                      const QColor& = Qt::black, int = 0 );
108   void                     drawLine( QPainter*, int, int, int, int,
109                                      LineType = Solid, 
110                                      const QColor& = Qt::black, int = 0 );
111
112   void                     drawMarker( QPainter*, const QPoint&, const QRect&,
113                                        QwtSymbol::Style = QwtSymbol::Ellipse,
114                                        const QColor& = Qt::black );
115   void                     drawMarker( QPainter*, const QPoint&, const QRect&,
116                                        MarkerType = Circle,
117                                        const QColor& = Qt::black );
118   void                     drawMarker( QPainter*, int, int, int, int,
119                                        QwtSymbol::Style = QwtSymbol::Ellipse,
120                                        const QColor& = Qt::black );
121   void                     drawMarker( QPainter*, int, int, int, int,
122                                        MarkerType = Circle,
123                                        const QColor& = Qt::black );
124   
125   QPixmap                  markerIcon( const QSize&, const QColor&, 
126                                       Plot2d::MarkerType );
127
128   QPixmap                  lineIcon( const QSize&,  const QColor&, 
129                                      Plot2d::LineType );
130
131   void                     getNextMarker( const int rtti, const QwtPlot*, QwtSymbol::Style&,
132                                           QColor&, Qt::PenStyle& );
133   
134   bool                     existMarker( const int rtti , const QwtPlot*, const QwtSymbol::Style,
135                                         const QColor&, const Qt::PenStyle );
136
137
138   bool                     closeColors( const QColor&, 
139                                         const QColor&, 
140                                         int distance = -1 );
141
142 }
143
144 #if defined WIN32
145 #  pragma warning ( disable: 4251 )
146 #endif
147
148 #endif // PLOT2D_H