1 #include "Plot2d_Curve.h"
7 Plot2d_Curve::Plot2d_Curve()
8 : myHorTitle( "" ), myVerTitle( "" ),
9 myHorUnits( "" ), myVerUnits( "" ),
10 myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 ),
11 myYAxis( QwtPlot::yLeft )
18 Plot2d_Curve::~Plot2d_Curve()
23 Copy constructor. Makes deep copy of data.
25 Plot2d_Curve::Plot2d_Curve( const Plot2d_Curve& curve )
27 myAutoAssign = curve.isAutoAssign();
28 myHorTitle = curve.getHorTitle();
29 myVerTitle = curve.getVerTitle();
30 myHorUnits = curve.getHorUnits();
31 myVerUnits = curve.getVerUnits();
32 myColor = curve.getColor();
33 myMarker = curve.getMarker();
34 myLine = curve.getLine();
35 myLineWidth = curve.getLineWidth();
36 myPoints = curve.getPointList();
40 operator=. Makes deep copy of data.
42 Plot2d_Curve& Plot2d_Curve::operator=( const Plot2d_Curve& curve )
44 myAutoAssign = curve.isAutoAssign();
45 myHorTitle = curve.getHorTitle();
46 myVerTitle = curve.getVerTitle();
47 myHorUnits = curve.getHorUnits();
48 myVerUnits = curve.getVerUnits();
49 myColor = curve.getColor();
50 myMarker = curve.getMarker();
51 myLine = curve.getLine();
52 myLineWidth = curve.getLineWidth();
53 myPoints = curve.getPointList();
58 Sets curve's horizontal title
60 void Plot2d_Curve::setHorTitle( const QString& title )
66 Gets curve's horizontal title
68 QString Plot2d_Curve::getHorTitle() const
74 Sets curve's vertical title
76 void Plot2d_Curve::setVerTitle( const QString& title )
82 Gets curve's vertical title
84 QString Plot2d_Curve::getVerTitle() const
90 Sets curve's horizontal units
92 void Plot2d_Curve::setHorUnits( const QString& units )
98 Gets curve's horizontal units
100 QString Plot2d_Curve::getHorUnits() const
106 Sets curve's vertical units
108 void Plot2d_Curve::setVerUnits( const QString& units )
114 Gets curve's vertical units
116 QString Plot2d_Curve::getVerUnits() const
122 Adds one point for curve.
124 void Plot2d_Curve::addPoint(double theX, double theY)
129 myPoints.append(aPoint);
133 Insert one point for curve on some position.
135 void Plot2d_Curve::insertPoint(int thePos, double theX, double theY)
141 QValueList<Plot2d_Point>::iterator aIt;
143 for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
144 if (thePos == aCurrent) {
145 myPoints.insert(aIt, aPoint);
150 myPoints.append(aPoint);
154 Delete one point for curve on some position.
156 void Plot2d_Curve::deletePoint(int thePos)
158 QValueList<Plot2d_Point>::iterator aIt;
160 for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
161 if (thePos == aCurrent) {
162 myPoints.remove(aIt);
170 Remove all points for curve.
172 void Plot2d_Curve::clearAllPoints()
178 Gets curve's data : abscissas of points
180 pointList Plot2d_Curve::getPointList() const
188 void Plot2d_Curve::setData( const double* hData, const double* vData, long size )
191 for(long i = 0; i < size; i++) addPoint(hData[i], vData[i]);
195 Gets curve's data : abscissas of points
197 double* Plot2d_Curve::horData() const
199 int aNPoints = nbPoints();
200 double* aX = new double[aNPoints];
201 for (int i = 0; i < aNPoints; i++) {
202 aX[i] = myPoints[i].x;
208 Gets curve's data : ordinates of points
210 double* Plot2d_Curve::verData() const
212 int aNPoints = nbPoints();
213 double* aY = new double[aNPoints];
214 for (int i = 0; i < aNPoints; i++) {
215 aY[i] = myPoints[i].y;
221 Gets curve's data : number of points
223 int Plot2d_Curve::nbPoints() const
225 return myPoints.count();
229 Returns true if curve has no data
231 bool Plot2d_Curve::isEmpty() const
233 return myPoints.isEmpty();
237 Sets curve's AutoAssign flag - in this case attributes will be set automatically
239 void Plot2d_Curve::setAutoAssign( bool on )
245 Gets curve's AutoAssign flag state
247 bool Plot2d_Curve::isAutoAssign() const
253 Sets curve's color ( and resets AutoAssign flag )
255 void Plot2d_Curve::setColor( const QColor& color )
258 myAutoAssign = false;
264 QColor Plot2d_Curve::getColor() const
270 Sets curve's marker ( and resets AutoAssign flag )
272 void Plot2d_Curve::setMarker( MarkerType marker )
275 myAutoAssign = false;
281 Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
287 Sets curve's line type and width ( and resets AutoAssign flag )
288 NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals.
289 A line width of 1 will also produce a 1 pixel wide line, but uses a slower more accurate
290 algorithm for diagonals.
291 For horizontal and vertical lines a line width of 0 is the same as a line width of 1.
293 void Plot2d_Curve::setLine( LineType line, const int lineWidth )
296 myLineWidth = lineWidth;
297 if ( myLineWidth < 0 ) myLineWidth = 0;
298 myAutoAssign = false;
302 Gets curve's line type
304 Plot2d_Curve::LineType Plot2d_Curve::getLine() const
310 Gets curve's line width
312 int Plot2d_Curve::getLineWidth() const
320 void Plot2d_Curve::setYAxis(QwtPlot::Axis theYAxis)
322 if(theYAxis == QwtPlot::yLeft || theYAxis == QwtPlot::yRight)
329 QwtPlot::Axis Plot2d_Curve::getYAxis() const