2 // File : Plot2d_Curve.cxx
3 // Created : UI team, 05.09.00
4 // Descrip : Curve class
6 // Modified : Mon Dec 03 15:37:21 2001
7 // Author : Vadim SANDLER
10 // Copyright : Open CASCADE 2001
13 #include "Plot2d_Curve.h"
14 #include "utilities.h"
19 Plot2d_Curve::Plot2d_Curve()
20 : myHorTitle( "" ), myVerTitle( "" ),
21 myHorUnits( "" ), myVerUnits( "" ),
22 myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 )
28 Plot2d_Curve::~Plot2d_Curve()
30 // MESSAGE("Plot2d_Curve::~Plot2d_Curve");
33 Copy constructor. Makes deep copy of data.
35 Plot2d_Curve::Plot2d_Curve( const Plot2d_Curve& curve )
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() );
50 operator=. Makes deep copy of data.
52 Plot2d_Curve& Plot2d_Curve::operator=( const Plot2d_Curve& curve )
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() );
68 Sets curve's horizontal title
70 void Plot2d_Curve::setHorTitle( const QString& title )
75 Gets curve's horizontal title
77 QString Plot2d_Curve::getHorTitle() const
82 Sets curve's vertical title
84 void Plot2d_Curve::setVerTitle( const QString& title )
89 Gets curve's vertical title
91 QString Plot2d_Curve::getVerTitle() const
96 Sets curve's horizontal units
98 void Plot2d_Curve::setHorUnits( const QString& units )
103 Gets curve's horizontal units
105 QString Plot2d_Curve::getHorUnits() const
110 Sets curve's vertical units
112 void Plot2d_Curve::setVerUnits( const QString& units )
117 Gets curve's vertical units
119 QString Plot2d_Curve::getVerUnits() const
124 Sets curve's data. Makes shallow copy of data.
126 void Plot2d_Curve::setData( const double* hData, const double* vData, long size )
128 myHorData.assign( hData, size );
129 myVerData.assign( vData, size );
132 Gets curve's data : abscissas of points
134 double* Plot2d_Curve::horData() const
136 return myHorData.data();
139 Gets curve's data : ordinates of points
141 double* Plot2d_Curve::verData() const
143 return myVerData.data();
146 Gets curve's data : number of points
148 long Plot2d_Curve::nbPoints() const
150 return myHorData.size();
153 Returns true if curve has no data
155 bool Plot2d_Curve::isEmpty() const
157 return ( myHorData.isEmpty() || myVerData.isEmpty() );
160 Sets curve's AutoAssign flag - in this case attributes will be set automatically
162 void Plot2d_Curve::setAutoAssign( bool on )
167 Gets curve's AutoAssign flag state
169 bool Plot2d_Curve::isAutoAssign() const
174 Sets curve's color ( and resets AutoAssign flag )
176 void Plot2d_Curve::setColor( const QColor color )
179 myAutoAssign = false;
184 QColor Plot2d_Curve::getColor() const
189 Sets curve's marker ( and resets AutoAssign flag )
191 void Plot2d_Curve::setMarker( MarkerType marker )
194 myAutoAssign = false;
199 Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
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.
209 void Plot2d_Curve::setLine( LineType line, const int lineWidth )
212 myLineWidth = lineWidth;
213 if ( myLineWidth < 0 ) myLineWidth = 0;
214 myAutoAssign = false;
217 Gets curve's line type
219 Plot2d_Curve::LineType Plot2d_Curve::getLine() const
224 Gets curve's line width
226 int Plot2d_Curve::getLineWidth() const