1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : Plot2d_Curve.cxx
6 // Author : Vadim SANDLER
10 #include "Plot2d_Curve.h"
11 #include "utilities.h"
17 Plot2d_Curve::Plot2d_Curve()
18 : myHorTitle( "" ), myVerTitle( "" ),
19 myHorUnits( "" ), myVerUnits( "" ),
20 myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 )
26 Plot2d_Curve::~Plot2d_Curve()
28 // MESSAGE("Plot2d_Curve::~Plot2d_Curve");
31 Copy constructor. Makes deep copy of data.
33 Plot2d_Curve::Plot2d_Curve( const Plot2d_Curve& curve )
35 myAutoAssign = curve.isAutoAssign();
36 myHorTitle = curve.getHorTitle();
37 myVerTitle = curve.getVerTitle();
38 myHorUnits = curve.getHorUnits();
39 myVerUnits = curve.getVerUnits();
40 myColor = curve.getColor();
41 myMarker = curve.getMarker();
42 myLine = curve.getLine();
43 myLineWidth = curve.getLineWidth();
44 myHorData.duplicate( curve.horData(), curve.nbPoints() );
45 myVerData.duplicate( curve.verData(), curve.nbPoints() );
48 operator=. Makes deep copy of data.
50 Plot2d_Curve& Plot2d_Curve::operator=( const Plot2d_Curve& curve )
52 myAutoAssign = curve.isAutoAssign();
53 myHorTitle = curve.getHorTitle();
54 myVerTitle = curve.getVerTitle();
55 myHorUnits = curve.getHorUnits();
56 myVerUnits = curve.getVerUnits();
57 myColor = curve.getColor();
58 myMarker = curve.getMarker();
59 myLine = curve.getLine();
60 myLineWidth = curve.getLineWidth();
61 myHorData.duplicate( curve.horData(), curve.nbPoints() );
62 myVerData.duplicate( curve.verData(), curve.nbPoints() );
66 Sets curve's horizontal title
68 void Plot2d_Curve::setHorTitle( const QString& title )
73 Gets curve's horizontal title
75 QString Plot2d_Curve::getHorTitle() const
80 Sets curve's vertical title
82 void Plot2d_Curve::setVerTitle( const QString& title )
87 Gets curve's vertical title
89 QString Plot2d_Curve::getVerTitle() const
94 Sets curve's horizontal units
96 void Plot2d_Curve::setHorUnits( const QString& units )
101 Gets curve's horizontal units
103 QString Plot2d_Curve::getHorUnits() const
108 Sets curve's vertical units
110 void Plot2d_Curve::setVerUnits( const QString& units )
115 Gets curve's vertical units
117 QString Plot2d_Curve::getVerUnits() const
122 Sets curve's data. Makes shallow copy of data.
124 void Plot2d_Curve::setData( const double* hData, const double* vData, long size )
126 myHorData.assign( hData, size );
127 myVerData.assign( vData, size );
130 Gets curve's data : abscissas of points
132 double* Plot2d_Curve::horData() const
134 return myHorData.data();
137 Gets curve's data : ordinates of points
139 double* Plot2d_Curve::verData() const
141 return myVerData.data();
144 Gets curve's data : number of points
146 long Plot2d_Curve::nbPoints() const
148 return myHorData.size();
151 Returns true if curve has no data
153 bool Plot2d_Curve::isEmpty() const
155 return ( myHorData.isEmpty() || myVerData.isEmpty() );
158 Sets curve's AutoAssign flag - in this case attributes will be set automatically
160 void Plot2d_Curve::setAutoAssign( bool on )
165 Gets curve's AutoAssign flag state
167 bool Plot2d_Curve::isAutoAssign() const
172 Sets curve's color ( and resets AutoAssign flag )
174 void Plot2d_Curve::setColor( const QColor color )
177 myAutoAssign = false;
182 QColor Plot2d_Curve::getColor() const
187 Sets curve's marker ( and resets AutoAssign flag )
189 void Plot2d_Curve::setMarker( MarkerType marker )
192 myAutoAssign = false;
197 Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const
202 Sets curve's line type and width ( and resets AutoAssign flag )
203 NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals.
204 A line width of 1 will also produce a 1 pixel wide line, but uses a slower more accurate algorithm for diagonals.
205 For horizontal and vertical lines a line width of 0 is the same as a line width of 1.
207 void Plot2d_Curve::setLine( LineType line, const int lineWidth )
210 myLineWidth = lineWidth;
211 if ( myLineWidth < 0 ) myLineWidth = 0;
212 myAutoAssign = false;
215 Gets curve's line type
217 Plot2d_Curve::LineType Plot2d_Curve::getLine() const
222 Gets curve's line width
224 int Plot2d_Curve::getLineWidth() const