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();
57 QString Plot2d_Curve::getTableTitle() const
63 Sets curve's horizontal title
65 void Plot2d_Curve::setHorTitle( const QString& title )
71 Gets curve's horizontal title
73 QString Plot2d_Curve::getHorTitle() const
79 Sets curve's vertical title
81 void Plot2d_Curve::setVerTitle( const QString& title )
87 Gets curve's vertical title
89 QString Plot2d_Curve::getVerTitle() const
95 Sets curve's horizontal units
97 void Plot2d_Curve::setHorUnits( const QString& units )
103 Gets curve's horizontal units
105 QString Plot2d_Curve::getHorUnits() const
111 Sets curve's vertical units
113 void Plot2d_Curve::setVerUnits( const QString& units )
119 Gets curve's vertical units
121 QString Plot2d_Curve::getVerUnits() const
127 Adds one point for curve.
129 void Plot2d_Curve::addPoint(double theX, double theY)
134 myPoints.append(aPoint);
138 Insert one point for curve on some position.
140 void Plot2d_Curve::insertPoint(int thePos, double theX, double theY)
146 QValueList<Plot2d_Point>::iterator aIt;
148 for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
149 if (thePos == aCurrent) {
150 myPoints.insert(aIt, aPoint);
155 myPoints.append(aPoint);
159 Delete one point for curve on some position.
161 void Plot2d_Curve::deletePoint(int thePos)
163 QValueList<Plot2d_Point>::iterator aIt;
165 for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
166 if (thePos == aCurrent) {
167 myPoints.remove(aIt);
175 Remove all points for curve.
177 void Plot2d_Curve::clearAllPoints()
183 Gets curve's data : abscissas of points
185 pointList Plot2d_Curve::getPointList() const
193 void Plot2d_Curve::setData( const double* hData, const double* vData, long size )
196 for(long i = 0; i < size; i++) addPoint(hData[i], vData[i]);
200 Gets curve's data : abscissas of points
202 double* Plot2d_Curve::horData() const
204 int aNPoints = nbPoints();
205 double* aX = new double[aNPoints];
206 for (int i = 0; i < aNPoints; i++) {
207 aX[i] = myPoints[i].x;
213 Gets curve's data : ordinates of points
215 double* Plot2d_Curve::verData() const
217 int aNPoints = nbPoints();
218 double* aY = new double[aNPoints];
219 for (int i = 0; i < aNPoints; i++) {
220 aY[i] = myPoints[i].y;
226 Gets curve's data : number of points
228 int Plot2d_Curve::nbPoints() const
230 return myPoints.count();
234 Returns true if curve has no data
236 bool Plot2d_Curve::isEmpty() const
238 return myPoints.isEmpty();
242 Sets curve's AutoAssign flag - in this case attributes will be set automatically
244 void Plot2d_Curve::setAutoAssign( bool on )
250 Gets curve's AutoAssign flag state
252 bool Plot2d_Curve::isAutoAssign() const
258 Sets curve's color ( and resets AutoAssign flag )
260 void Plot2d_Curve::setColor( const QColor& color )
263 myAutoAssign = false;
269 QColor Plot2d_Curve::getColor() const
275 Sets curve's marker ( and resets AutoAssign flag )
277 void Plot2d_Curve::setMarker( MarkerType marker )
280 myAutoAssign = false;
286 Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
292 Sets curve's line type and width ( and resets AutoAssign flag )
293 NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals.
294 A line width of 1 will also produce a 1 pixel wide line, but uses a slower more accurate
295 algorithm for diagonals.
296 For horizontal and vertical lines a line width of 0 is the same as a line width of 1.
298 void Plot2d_Curve::setLine( LineType line, const int lineWidth )
301 myLineWidth = lineWidth;
302 if ( myLineWidth < 0 ) myLineWidth = 0;
303 myAutoAssign = false;
307 Gets curve's line type
309 Plot2d_Curve::LineType Plot2d_Curve::getLine() const
315 Gets curve's line width
317 int Plot2d_Curve::getLineWidth() const
325 void Plot2d_Curve::setYAxis(QwtPlot::Axis theYAxis)
327 if(theYAxis == QwtPlot::yLeft || theYAxis == QwtPlot::yRight)
334 QwtPlot::Axis Plot2d_Curve::getYAxis() const