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
185 Gets curve's data : abscissas of points
187 double* Plot2d_Curve::horData() const
189 int aNPoints = nbPoints();
190 double* aX = new double[aNPoints];
191 for (int i = 0; i < aNPoints; i++) {
192 aX[i] = myPoints[i].x;
198 Gets curve's data : ordinates of points
200 double* Plot2d_Curve::verData() const
202 int aNPoints = nbPoints();
203 double* aY = new double[aNPoints];
204 for (int i = 0; i < aNPoints; i++) {
205 aY[i] = myPoints[i].y;
211 Gets curve's data : number of points
213 int Plot2d_Curve::nbPoints() const
215 return myPoints.count();
219 Returns true if curve has no data
221 bool Plot2d_Curve::isEmpty() const
223 return myPoints.isEmpty();
227 Sets curve's AutoAssign flag - in this case attributes will be set automatically
229 void Plot2d_Curve::setAutoAssign( bool on )
235 Gets curve's AutoAssign flag state
237 bool Plot2d_Curve::isAutoAssign() const
243 Sets curve's color ( and resets AutoAssign flag )
245 void Plot2d_Curve::setColor( const QColor color )
248 myAutoAssign = false;
254 QColor Plot2d_Curve::getColor() const
260 Sets curve's marker ( and resets AutoAssign flag )
262 void Plot2d_Curve::setMarker( MarkerType marker )
265 myAutoAssign = false;
271 Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
277 Sets curve's line type and width ( and resets AutoAssign flag )
278 NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals.
279 A line width of 1 will also produce a 1 pixel wide line, but uses a slower more accurate
280 algorithm for diagonals.
281 For horizontal and vertical lines a line width of 0 is the same as a line width of 1.
283 void Plot2d_Curve::setLine( LineType line, const int lineWidth )
286 myLineWidth = lineWidth;
287 if ( myLineWidth < 0 ) myLineWidth = 0;
288 myAutoAssign = false;
292 Gets curve's line type
294 Plot2d_Curve::LineType Plot2d_Curve::getLine() const
300 Gets curve's line width
302 int Plot2d_Curve::getLineWidth() const
310 void Plot2d_Curve::setYAxis(QwtPlot::Axis theYAxis)
312 if(theYAxis == QwtPlot::yLeft || theYAxis == QwtPlot::yRight)
319 QwtPlot::Axis Plot2d_Curve::getYAxis() const