1 #include "Plot2d_Curve.h"
6 Plot2d_Curve::Plot2d_Curve()
7 : myHorTitle( "" ), myVerTitle( "" ),
8 myHorUnits( "" ), myVerUnits( "" ),
9 myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 ),
10 myYAxis( QwtPlot::yLeft )
17 Plot2d_Curve::~Plot2d_Curve()
22 Copy constructor. Makes deep copy of data.
24 Plot2d_Curve::Plot2d_Curve( const Plot2d_Curve& curve )
26 myAutoAssign = curve.isAutoAssign();
27 myHorTitle = curve.getHorTitle();
28 myVerTitle = curve.getVerTitle();
29 myHorUnits = curve.getHorUnits();
30 myVerUnits = curve.getVerUnits();
31 myColor = curve.getColor();
32 myMarker = curve.getMarker();
33 myLine = curve.getLine();
34 myLineWidth = curve.getLineWidth();
35 myPoints = curve.getPointList();
39 operator=. Makes deep copy of data.
41 Plot2d_Curve& Plot2d_Curve::operator=( const Plot2d_Curve& curve )
43 myAutoAssign = curve.isAutoAssign();
44 myHorTitle = curve.getHorTitle();
45 myVerTitle = curve.getVerTitle();
46 myHorUnits = curve.getHorUnits();
47 myVerUnits = curve.getVerUnits();
48 myColor = curve.getColor();
49 myMarker = curve.getMarker();
50 myLine = curve.getLine();
51 myLineWidth = curve.getLineWidth();
52 myPoints = curve.getPointList();
57 Sets curve's horizontal title
59 void Plot2d_Curve::setHorTitle( const QString& title )
65 Gets curve's horizontal title
67 QString Plot2d_Curve::getHorTitle() const
73 Sets curve's vertical title
75 void Plot2d_Curve::setVerTitle( const QString& title )
81 Gets curve's vertical title
83 QString Plot2d_Curve::getVerTitle() const
89 Sets curve's horizontal units
91 void Plot2d_Curve::setHorUnits( const QString& units )
97 Gets curve's horizontal units
99 QString Plot2d_Curve::getHorUnits() const
105 Sets curve's vertical units
107 void Plot2d_Curve::setVerUnits( const QString& units )
113 Gets curve's vertical units
115 QString Plot2d_Curve::getVerUnits() const
121 Adds one point for curve.
123 void Plot2d_Curve::addPoint(double theX, double theY)
128 myPoints.append(aPoint);
132 Insert one point for curve on some position.
134 void Plot2d_Curve::insertPoint(int thePos, double theX, double theY)
140 QValueList<Plot2d_Point>::iterator aIt;
142 for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
143 if (thePos == aCurrent) {
144 myPoints.insert(aIt, aPoint);
149 myPoints.append(aPoint);
153 Delete one point for curve on some position.
155 void Plot2d_Curve::deletePoint(int thePos)
157 QValueList<Plot2d_Point>::iterator aIt;
159 for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
160 if (thePos == aCurrent) {
161 myPoints.remove(aIt);
169 Remove all points for curve.
171 void Plot2d_Curve::clearAllPoints()
177 Gets curve's data : abscissas of points
179 pointList Plot2d_Curve::getPointList() const
187 void Plot2d_Curve::setData( const double* hData, const double* vData, long size )
190 for(long i = 0; i < size; i++) addPoint(hData[i], vData[i]);
194 Gets curve's data : abscissas of points
196 double* Plot2d_Curve::horData() const
198 int aNPoints = nbPoints();
199 double* aX = new double[aNPoints];
200 for (int i = 0; i < aNPoints; i++) {
201 aX[i] = myPoints[i].x;
207 Gets curve's data : ordinates of points
209 double* Plot2d_Curve::verData() const
211 int aNPoints = nbPoints();
212 double* aY = new double[aNPoints];
213 for (int i = 0; i < aNPoints; i++) {
214 aY[i] = myPoints[i].y;
220 Gets curve's data : number of points
222 int Plot2d_Curve::nbPoints() const
224 return myPoints.count();
228 Returns true if curve has no data
230 bool Plot2d_Curve::isEmpty() const
232 return myPoints.isEmpty();
236 Sets curve's AutoAssign flag - in this case attributes will be set automatically
238 void Plot2d_Curve::setAutoAssign( bool on )
244 Gets curve's AutoAssign flag state
246 bool Plot2d_Curve::isAutoAssign() const
252 Sets curve's color ( and resets AutoAssign flag )
254 void Plot2d_Curve::setColor( const QColor color )
257 myAutoAssign = false;
263 QColor Plot2d_Curve::getColor() const
269 Sets curve's marker ( and resets AutoAssign flag )
271 void Plot2d_Curve::setMarker( MarkerType marker )
274 myAutoAssign = false;
280 Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
286 Sets curve's line type and width ( and resets AutoAssign flag )
287 NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals.
288 A line width of 1 will also produce a 1 pixel wide line, but uses a slower more accurate
289 algorithm for diagonals.
290 For horizontal and vertical lines a line width of 0 is the same as a line width of 1.
292 void Plot2d_Curve::setLine( LineType line, const int lineWidth )
295 myLineWidth = lineWidth;
296 if ( myLineWidth < 0 ) myLineWidth = 0;
297 myAutoAssign = false;
301 Gets curve's line type
303 Plot2d_Curve::LineType Plot2d_Curve::getLine() const
309 Gets curve's line width
311 int Plot2d_Curve::getLineWidth() const
319 void Plot2d_Curve::setYAxis(QwtPlot::Axis theYAxis)
321 if(theYAxis == QwtPlot::yLeft || theYAxis == QwtPlot::yRight)
328 QwtPlot::Axis Plot2d_Curve::getYAxis() const