]> SALOME platform Git repositories - modules/gui.git/blob - src/Plot2d/Plot2d_Curve.h
Salome HOME
bd3be97bdd2fd6c5f0150e32827be3a235f3039c
[modules/gui.git] / src / Plot2d / Plot2d_Curve.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef PLOT2D_CURVE_H
20 #define PLOT2D_CURVE_H
21
22 #include "Plot2d.h"
23 #include <qvaluelist.h>
24 #include <qptrlist.h>
25 #include <qwt_plot.h>
26
27 class QColor;
28
29 typedef struct
30 {
31   double x;
32   double y;
33   QString text;
34 } Plot2d_Point;
35
36 typedef QValueList<Plot2d_Point> pointList;
37
38 class PLOT2D_EXPORT Plot2d_Curve
39 {
40 public:
41   enum MarkerType { None,      Circle,    Rectangle, Diamond,
42         DTriangle, UTriangle, LTriangle, RTriangle,
43         Cross, XCross };
44   enum LineType { NoPen, Solid, Dash, Dot, DashDot, DashDotDot };
45
46   Plot2d_Curve();
47   virtual ~Plot2d_Curve();
48   Plot2d_Curve( const Plot2d_Curve& curve );
49   Plot2d_Curve& operator= ( const Plot2d_Curve& curve );
50
51   virtual QString getTableTitle() const;
52   
53   void        setHorTitle( const QString& title );
54   QString     getHorTitle() const;
55   void        setVerTitle( const QString& title );
56   QString     getVerTitle() const;
57   void        setHorUnits( const QString& units );
58   QString     getHorUnits() const;
59   void        setVerUnits( const QString& units );
60   QString     getVerUnits() const;
61   void        addPoint(double theX, double theY, const QString& = QString::null );
62   void        insertPoint(int thePos, double theX, double theY, const QString& = QString::null );
63   void        deletePoint(int thePos);
64   void        clearAllPoints();
65   pointList   getPointList() const;
66
67   void        setData( const double* hData, const double* vData, long size, const QStringList& = QStringList() );
68   double*     horData() const;
69   double*     verData() const;
70
71   void        setText( const int, const QString& );
72   QString     text( const int ) const;
73
74   int         nbPoints() const;
75   bool        isEmpty() const;
76
77   void        setAutoAssign( bool on );
78   bool        isAutoAssign() const;
79   void        setColor( const QColor& color );
80   QColor      getColor() const;
81   void        setMarker( MarkerType marker );
82   MarkerType  getMarker() const;
83   void        setLine( LineType line, const int lineWidth = 0 );
84   LineType    getLine() const;
85   int         getLineWidth() const;
86   void        setYAxis(QwtPlot::Axis theYAxis);
87   QwtPlot::Axis getYAxis() const;
88
89   // Protection against QwtCurve::drawLines() bug in Qwt 0.4.x: 
90   // it crashes if switched to X/Y logarithmic mode, when one or more points have
91   // non-positive X/Y coordinate
92   double      getMinX() const;
93   double      getMinY() const;
94
95 protected:
96   bool        myAutoAssign;
97   QString     myHorTitle;
98   QString     myVerTitle;
99   QString     myHorUnits;
100   QString     myVerUnits;
101   QColor      myColor;
102   MarkerType  myMarker;
103   LineType    myLine;
104   int         myLineWidth;
105   QwtPlot::Axis myYAxis;
106
107   pointList   myPoints;
108 };
109
110 typedef QPtrList<Plot2d_Curve> curveList;
111
112 #endif