Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / Plot2d / Plot2d_Curve.cxx
1 using namespace std;
2 //  File      : Plot2d_Curve.cxx
3 //  Created   : UI team, 05.09.00
4 //  Descrip   : Curve class
5
6 //  Modified  : Mon Dec 03 15:37:21 2001
7 //  Author    : Vadim SANDLER
8 //  Project   : SALOME
9 //  Module    : Plot2d
10 //  Copyright : Open CASCADE 2001
11 //  $Header$
12
13 #include "Plot2d_Curve.h"
14 #include "utilities.h"
15
16 /*!
17   Constructor
18 */
19 Plot2d_Curve::Plot2d_Curve()
20      : myHorTitle( "" ), myVerTitle( "" ), 
21        myHorUnits( "" ), myVerUnits( "" ), 
22        myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 )
23 {
24 }
25 /*!
26   Destructor
27 */
28 Plot2d_Curve::~Plot2d_Curve()
29 {
30 //  MESSAGE("Plot2d_Curve::~Plot2d_Curve");
31 }
32 /*!
33   Copy constructor. Makes deep copy of data.
34 */
35 Plot2d_Curve::Plot2d_Curve( const Plot2d_Curve& curve )
36 {
37   myAutoAssign = curve.isAutoAssign();
38   myHorTitle   = curve.getHorTitle();
39   myVerTitle   = curve.getVerTitle();
40   myHorUnits   = curve.getHorUnits();
41   myVerUnits   = curve.getVerUnits();
42   myColor      = curve.getColor();
43   myMarker     = curve.getMarker();
44   myLine       = curve.getLine();
45   myLineWidth  = curve.getLineWidth();
46   myHorData.duplicate( curve.horData(), curve.nbPoints() );
47   myVerData.duplicate( curve.verData(), curve.nbPoints() );
48 }
49 /*!
50   operator=. Makes deep copy of data.
51 */
52 Plot2d_Curve& Plot2d_Curve::operator=( const Plot2d_Curve& curve )
53 {
54   myAutoAssign = curve.isAutoAssign();
55   myHorTitle   = curve.getHorTitle();
56   myVerTitle   = curve.getVerTitle();
57   myHorUnits   = curve.getHorUnits();
58   myVerUnits   = curve.getVerUnits();
59   myColor      = curve.getColor();
60   myMarker     = curve.getMarker();
61   myLine       = curve.getLine();
62   myLineWidth  = curve.getLineWidth();
63   myHorData.duplicate( curve.horData(), curve.nbPoints() );
64   myVerData.duplicate( curve.verData(), curve.nbPoints() );
65   return *this;
66 }
67 /*!
68   Sets curve's horizontal title
69 */
70 void Plot2d_Curve::setHorTitle( const QString& title )
71 {
72   myHorTitle = title;
73 }
74 /*!
75   Gets curve's horizontal title
76 */
77 QString Plot2d_Curve::getHorTitle() const
78 {
79   return myHorTitle;
80 }
81 /*!
82   Sets curve's vertical title
83 */
84 void Plot2d_Curve::setVerTitle( const QString& title )
85 {
86   myVerTitle = title;
87 }
88 /*!
89   Gets curve's vertical title
90 */
91 QString Plot2d_Curve::getVerTitle() const
92 {
93   return myVerTitle;
94 }
95 /*!
96   Sets curve's horizontal units
97 */
98 void Plot2d_Curve::setHorUnits( const QString& units )
99 {
100   myHorUnits = units;
101 }
102 /*!
103   Gets curve's horizontal units
104 */
105 QString Plot2d_Curve::getHorUnits() const
106 {
107   return myHorUnits;
108 }
109 /*!
110   Sets curve's vertical units
111 */
112 void Plot2d_Curve::setVerUnits( const QString& units )
113 {
114   myVerUnits = units;
115 }
116 /*!
117   Gets curve's vertical units
118 */
119 QString Plot2d_Curve::getVerUnits() const
120 {
121   return myVerUnits;
122 }
123 /*!
124   Sets curve's data. Makes shallow copy of data.
125 */
126 void Plot2d_Curve::setData( const double* hData, const double* vData, long size )
127 {
128   myHorData.assign( hData, size );
129   myVerData.assign( vData, size );
130 }
131 /*!
132   Gets curve's data : abscissas of points
133 */
134 double* Plot2d_Curve::horData() const
135 {
136   return myHorData.data();
137 }
138 /*!
139   Gets curve's data : ordinates of points
140 */
141 double* Plot2d_Curve::verData() const
142 {
143   return myVerData.data();
144 }
145 /*!
146   Gets curve's data : number of points
147 */
148 long Plot2d_Curve::nbPoints() const
149 {
150   return myHorData.size();
151 }
152 /*!
153   Returns true if curve has no data
154 */
155 bool Plot2d_Curve::isEmpty() const
156 {
157   return ( myHorData.isEmpty() || myVerData.isEmpty() );
158 }
159 /*!
160   Sets curve's AutoAssign flag - in this case attributes will be set automatically
161 */
162 void Plot2d_Curve::setAutoAssign( bool on )
163 {
164   myAutoAssign = on;
165 }
166 /*!
167   Gets curve's AutoAssign flag state
168 */
169 bool Plot2d_Curve::isAutoAssign() const
170 {
171   return myAutoAssign;
172 }
173 /*!
174   Sets curve's color ( and resets AutoAssign flag )
175 */
176 void Plot2d_Curve::setColor( const QColor color )
177 {
178   myColor = color;
179   myAutoAssign = false;
180 }
181 /*!
182   Gets curve's color
183 */
184 QColor Plot2d_Curve::getColor() const
185 {
186   return myColor;
187 }
188 /*!
189   Sets curve's marker ( and resets AutoAssign flag )
190 */
191 void Plot2d_Curve::setMarker( MarkerType marker )
192 {
193   myMarker = marker;
194   myAutoAssign = false;
195 }
196 /*!
197   Gets curve's marker
198 */
199 Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
200 {
201   return myMarker;
202 }
203 /*!
204   Sets curve's line type and width ( and resets AutoAssign flag )
205   NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals. 
206          A line width of 1 will also produce a 1 pixel wide line, but uses a slower more accurate algorithm for diagonals. 
207          For horizontal and vertical lines a line width of 0 is the same as a line width of 1.
208 */
209 void Plot2d_Curve::setLine( LineType line, const int lineWidth )
210 {
211   myLine = line;
212   myLineWidth = lineWidth;
213   if ( myLineWidth < 0 ) myLineWidth = 0;
214   myAutoAssign = false;
215 }
216 /*!
217   Gets curve's line type
218 */
219 Plot2d_Curve::LineType Plot2d_Curve::getLine() const
220 {
221   return myLine;
222 }
223 /*!
224   Gets curve's line width
225 */
226 int Plot2d_Curve::getLineWidth() const
227 {
228   return myLineWidth;
229 }