wxArt2D
axis.h
Go to the documentation of this file.
1 /*! \file wx/curves/axis.h
2  \brief classes for plotting curve and pie data, and editing them.
3 
4  Data stored in a derived a2dCanvasObject, can be plotted as a curve of pie chart.
5  One can add markers on the curves, and several curves can be plot as a group in one plot.
6 
7  \author Klaas Holwerda
8 
9  Copyright: 2000-2004 (c) Klaas Holwerda
10 
11  Licence: wxWidgets Licence
12 
13  RCS-ID: $Id: axis.h,v 1.13 2008/09/05 19:01:12 titato Exp $
14 */
15 
16 #ifndef __WXAXIS_H__
17 #define __WXAXIS_H__
18 
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22 
23 #include "wx/curves/meta.h"
24 
25 class A2DCURVESDLLEXP a2dCurveAxis;
26 
27 //! base class for axis tic formatter
28 /*!
29  \ingroup canvasobject meta curve
30 */
31 class A2DCURVESDLLEXP a2dTicFormatter : public a2dCanvasObject
32 {
33 
34 public:
35  //! default constructor
37 
38  //! destructor
39  virtual ~a2dTicFormatter();
40 
41  a2dTicFormatter( const a2dTicFormatter& other, CloneOptions options, a2dRefMap* refs );
42 
43  //! Set the parent axis that owns this formatter. Used by a2dCurveAxis::SetFormatter()
44  void SetAxis( a2dCurveAxis* axis ) { m_axis = axis; }
45 
46  //! Set how tic text is formated/displayed.
47  virtual void SetTicFormat( const wxString& format ) { m_format = format; }
48 
49  //! Default implementation. Returns printf(m_format, dTicValue)
50  virtual wxString GetTicText( double dTicValue ) const;
51 
52  //! Default tic format
53  const wxString& GetTicFormat() const { return m_format;}
54 
55  DECLARE_DYNAMIC_CLASS( a2dTicFormatter )
56 
57 protected:
58  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
59 
60  //! parent of formatter
61  a2dCurveAxis* m_axis;
62 
63  // format string for tic text
64  wxString m_format;
65 };
66 
67 #if defined(WXART2D_USINGDLL)
68 template class A2DCURVESDLLEXP a2dSmrtPtr<a2dTicFormatter>;
69 #endif
70 
71 class A2DCURVESDLLEXP a2dTimeTicFormatter : public a2dTicFormatter
72 {
73 
74 public:
75  //!default constructor
77 
78  //!destructor
79  virtual ~a2dTimeTicFormatter();
80 
81  //! Set how tic text is formated/displayed.
82  void SetTicFormat( const wxString& format );
83 
84  virtual wxString GetTicText( double dTicValue );
85 
86  virtual bool CanRender() { return FALSE; }
87 
88  virtual void DoRender( a2dIterC& WXUNUSED( ic ), OVERLAP WXUNUSED( clipparent ) ) {}
89 
90  DECLARE_DYNAMIC_CLASS( a2dTimeTicFormatter )
91 
92 };
93 
94 #if defined(WXART2D_USINGDLL)
95 template class A2DCURVESDLLEXP a2dSmrtPtr<a2dTimeTicFormatter>;
96 #endif
97 
98 //! base class for axis in a2dCanvasXYDisplayGroup
99 /*!
100  \ingroup canvasobject meta curve
101 */
102 class A2DCURVESDLLEXP a2dCurveAxis: public a2dCurveObject
103 {
104 public:
105 
106  a2dCurveAxis( double length = 0, bool yaxis = false );
107 
108  virtual ~a2dCurveAxis();
109 
110  a2dCurveAxis( const a2dCurveAxis& other, CloneOptions options, a2dRefMap* refs );
111 
112  //! define which part is displayed on this axis
113  void SetBoundaries( double min, double max );
114 
115  /*!
116  defines how the boundary values are displayed as tic labels this axis.
117  i.e this allows a linear translation of aquired data to real messurement
118  units (0-100 <==> 0-2500 rpm)
119 
120  */
121  void SetTicBoundaries( double min, double max );
122 
123  double GetTicMin( void ) const { return m_ticmin;}
124 
125  double GetTicMax( void ) const { return m_ticmax;}
126 
127  //! get real minimum
128  /*!
129  this returns the lowest boundary value ( min(m_min,m_max) )
130  */
131  double GetAxisMin() const { return wxMin( m_min, m_max ); }
132 
133  //! get real maximum
134  /*!
135  this returns the highest boundry value ( max(m_min,m_max) )
136  */
137  double GetAxisMax() const { return wxMax( m_min, m_max ); }
138 
139  //! get minimum
140  /*!
141  this returns the boundary value set as min.
142  if m_yaxis is set, this is the figure displayed at lowest Y, else X.
143  */
144  double GetBoundaryMin() const { return m_min; }
145 
146  //! get maximum
147  /*!
148  this returns the boundary value set as max.
149  if m_yaxis is set, this is the figure displayed at highest Y, else X
150  */
151  double GetBoundaryMax() const { return m_max; }
152 
153  //! set length in world coordinates ( not axis coordinates )
154  /*!
155  the pyhsical extend of this axis on screen
156  */
157  void SetLength( double length );
158 
159  //! get length in world coordinates.
160  double GetLength() const { return m_length; }
161 
162  //! return true is this axis is Yaxis
163  bool IsYAxis() const { return m_yaxis; }
164 
165  //! set position of axis ( zero is default )
166  /*!
167  This value is in the data coordinates system of the a2dCanvasXYDisplayGroup, which uses the axis.
168  */
169  void SetPosition( double position ) { m_position = position; SetPending( true ); }
170 
171  //! get position of axis ( zero is default )
172  double GetPosition() const { return m_position; }
173 
174  //! show tics
175  void SetShowTics( bool showtics ) { m_showtics = showtics; SetPending( true ); }
176 
177  //! distance of tic lines in X/Y (curve coords)
178  void SetTic ( double d ) { m_tic = d; SetPending( true ); }
179 
180  //! get distance of tic lines in X/Y (curve coords)
181  double GetTic() const { return ( m_tic == 0 ) ? ( m_max - m_min ) / 10 : m_tic; }
182 
183  double GetTicStart() const;
184 
185  //! height of tic lines
186  void SetTicHeight ( double height ) { m_ticheight = height; SetPending( true ); }
187 
188  double GetTicHeight() const { return ( m_ticheight == 0 ) ? m_length / 100 : m_ticheight; }
189 
190  //! height of tics text set to font
191  void SetTicTextHeight ( double height ) { m_font.SetSize( height ); SetPending( true ); }
192 
193  //! return size of font
194  double GetTicTextHeight() const { return m_font.GetSize(); }
195 
196  //! tics display on side of drawing
197  void SetSideTic( bool sidetic ) { m_sidetic = sidetic; SetPending( true ); }
198 
199  //! Set how tic text is formated/displayed.
200  void SetTicFormat( const wxString& format ) { m_pTicFormatter->SetTicFormat( format ); SetPending( true ); }
201 
202  //! Set how common tic text is formated/displayed for all (Y-axes).
203  void SetCommonTicFormat( const wxString& format ) { m_commonTicFormat = format; SetPending( true ); }
204 
205  //! Set a stroke for tics
206  void SetTicStroke( const a2dStroke& stroke );
207 
208  //! Set a stroke for tics text
209  void SetTicTextStroke( const a2dStroke& stroke );
210 
211  //! Font for tics.
212  void SetFontTic( const a2dFont& font ) { m_font = font;}
213 
214  //! Set a stroke for axis
215  void SetAxisStroke( const a2dStroke& stroke );
216 
217  //!Set units for this axis
218  void SetUnits( const wxString& units ) { m_units = units; SetPending( true ); }
219 
220  void SetUnitsStroke( const a2dStroke& stroke );
221 
222  void SetUnitsStroke( const wxColour& color, double width = 0, a2dStrokeStyle style = a2dSTROKE_SOLID );
223 
224  const wxString& GetUnits() const { return m_units; }
225 
226  void SetInvertTic( bool inverttic );
227 
228  void SetAutoSizedTic( bool autosized ) { if ( m_autosizedtic != autosized ) { m_autosizedtic = autosized; SetPending( true ); } }
229 
230  virtual void AddLevel( const wxString& levelName, double val, a2dCanvasObject* object );
231 
232  a2dCanvasObject* GetLevel( const wxString& levelName );
233 
234  bool GetLevelValue( const wxString& levelName, double& val );
235 
236  void MirrorLevels();
237 
238  double ConvertWorld2Axis( double RelativeWorldValue );
239 
240  double ConvertAxis2World( double AxisValue );
241 
242  //! Replace current tic formatter
243  void SetFormatter( a2dTicFormatter* pFormatter );
244 
245  //! Get current tic formatter
246  a2dTicFormatter* GetFormatter() { return m_pTicFormatter; }
247 
248  DECLARE_DYNAMIC_CLASS( a2dCurveAxis )
249 
250 protected:
251  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
252 
253  bool HasLevelMarkers() const;
254 
255  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
256  void DoUpdateViewDependentObjects( a2dIterC& ic );
257 
258 #if wxART2D_USE_CVGIO
259  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
260 
261  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
262 #endif //wxART2D_USE_CVGIO
263 
264 protected:
265  //!this is a not implemented copy constructor that avoids automatic creation of one
266  a2dCurveAxis( const a2dCurveAxis& other );
267 
268  //! length in parent world coordinates
269  double m_length;
270 
271  //! minimum on axis (internal boundaries)
272  double m_min;
273  //! maximum on axis (internal boundaries)
274  double m_max;
275 
276  //! tic scale minimum on axis
277  double m_ticmin;
278  //! tic scale maximum on axis
279  double m_ticmax;
280 
281  //! position of axis
282  double m_position;
283 
284  //! is this an Y axis
285  bool m_yaxis;
286 
287  //! if true tics are displayed
289 
290  // distance of tics
291  double m_tic;
292 
293  // tic height
294  double m_ticheight;
295 
296  // use side tic
297  bool m_sidetic;
298 
299  // use another side for tics
300  bool m_inverttic;
301 
302  // use to set auto size for tics
303  bool m_autosizedtic;
304 
305  //! tic font
307 
308  // units for this axis
309  wxString m_units;
310 
311  a2dStroke m_stroketic;
312  a2dStroke m_stroketictext;
313  a2dStroke m_strokeaxis;
314 
315  a2dStroke m_strokeunits;
316 
317  // current formatter
318  a2dSmrtPtr<a2dTicFormatter> m_pTicFormatter;
319 
320  // common format string for all Y-axes
321  wxString m_commonTicFormat;
322 
323  mutable a2dBoundingBox m_untransbboxtictext;
324  /*
325  static const a2dPropertyIdRefObject PROPID_stroketic;
326  static const a2dPropertyIdRefObject PROPID_stroketictext;
327  static const a2dPropertyIdRefObject PROPID_strokeaxis;
328  */
329 };
330 
331 
332 #if defined(WXART2D_USINGDLL)
333 template class A2DCURVESDLLEXP a2dSmrtPtr<a2dCurveAxis>;
334 #endif
335 
336 //! base class for axis in a2dCanvasXYDisplayGroup
337 /*!
338  \ingroup canvasobject meta curve
339 */
340 class A2DCURVESDLLEXP a2dCurveAxisLin: public a2dCurveAxis
341 {
342 public:
343 
344  a2dCurveAxisLin( double length = 0, bool yaxis = false );
345 
346  virtual ~a2dCurveAxisLin();
347 
348  a2dCurveAxisLin( const a2dCurveAxisLin& other, CloneOptions options, a2dRefMap* refs );
349 
350  DECLARE_DYNAMIC_CLASS( a2dCurveAxisLin )
351 
352 protected:
353  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
354 
355  void DoRender( a2dIterC& ic, OVERLAP clipparent );
356 
357 #if wxART2D_USE_CVGIO
358  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
359 
360  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
361 #endif //wxART2D_USE_CVGIO
362 
363 private:
364  //!this is a not implemented copy constructor that avoids automatic creation of one
365  a2dCurveAxisLin( const a2dCurveAxisLin& other );
366 
367 };
368 
369 
370 #if 0
371 //! base class for axis area in a2dCanvasXYDisplayGroup
372 /*!
373  \ingroup canvasobject meta curve
374 */
375 class A2DCURVESDLLEXP a2dCurveAxisArea: public a2dCurveObject
376 {
377 public:
378 
379  a2dCurveAxisArea();
380 
381  virtual ~a2dCurveAxisArea();
382 
383  a2dCurveAxisArea( const a2dCurveAxisArea& other, CloneOptions options, a2dRefMap* refs );
384 
385  a2dCurveAxis* GetAxis( const wxString axisname );
386  a2dCurveAxis* GetAxis( int nIndex );
387 
388  //! set length in world coordinates ( not axis coordinates )
389  /*!
390  the pyhsical extend of this axis on screen
391  */
392  void SetLength( double length );
393 
394  //! get length in world coordinates.
395  double GetLength() { return m_length; }
396 
397  DECLARE_CLASS( a2dCurveAxisArea )
398 
399 protected:
400 
401  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
402 
403  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
404 
405  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
406 
407  void DoRender( a2dIterC& ic, OVERLAP clipparent );
408 
409 protected:
410 
411  //! length in parent world coordinates
412  double m_length;
413 
414 };
415 #endif // ifdef 0
416 
417 #endif
418 
double GetPosition() const
get position of axis ( zero is default )
Definition: axis.h:172
double m_max
maximum on axis (internal boundaries)
Definition: axis.h:274
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
classes for plotting curve and pie data, and editing them.
void SetUnits(const wxString &units)
Set units for this axis.
Definition: axis.h:218
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: canobj.cpp:1426
void SetCommonTicFormat(const wxString &format)
Set how common tic text is formated/displayed for all (Y-axes).
Definition: axis.h:203
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
Ref Counted base object.
Definition: gen.h:1045
double m_ticmin
tic scale minimum on axis
Definition: axis.h:277
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
double GetTic() const
get distance of tic lines in X/Y (curve coords)
Definition: axis.h:181
double m_length
length in parent world coordinates
Definition: axis.h:269
double m_ticmax
tic scale maximum on axis
Definition: axis.h:279
void SetTicTextHeight(double height)
height of tics text set to font
Definition: axis.h:191
base class for axis in a2dCanvasXYDisplayGroup
Definition: axis.h:102
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
void SetSideTic(bool sidetic)
tics display on side of drawing
Definition: axis.h:197
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
double GetBoundaryMin() const
get minimum
Definition: axis.h:144
void SetTic(double d)
distance of tic lines in X/Y (curve coords)
Definition: axis.h:178
double m_position
position of axis
Definition: axis.h:282
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: canobj.cpp:4695
a2dCurveObject for objects needing to know its parent a2dCurvesArea.
Definition: curve.h:42
virtual void SetTicFormat(const wxString &format)
Set how tic text is formated/displayed.
Definition: axis.h:47
bool IsYAxis() const
return true is this axis is Yaxis
Definition: axis.h:163
base class for axis in a2dCanvasXYDisplayGroup
Definition: axis.h:340
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
void SetAxis(a2dCurveAxis *axis)
Set the parent axis that owns this formatter. Used by a2dCurveAxis::SetFormatter() ...
Definition: axis.h:44
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
bool m_yaxis
is this an Y axis
Definition: axis.h:285
bool m_showtics
if true tics are displayed
Definition: axis.h:288
void SetTicHeight(double height)
height of tic lines
Definition: axis.h:186
double GetLength() const
get length in world coordinates.
Definition: axis.h:160
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
void SetShowTics(bool showtics)
show tics
Definition: axis.h:175
double GetBoundaryMax() const
get maximum
Definition: axis.h:151
void SetFontTic(const a2dFont &font)
Font for tics.
Definition: axis.h:212
void SetPosition(double position)
set position of axis ( zero is default )
Definition: axis.h:169
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
double GetAxisMax() const
get real maximum
Definition: axis.h:137
double m_min
minimum on axis (internal boundaries)
Definition: axis.h:272
a2dFont m_font
tic font
Definition: axis.h:306
a2dTicFormatter * GetFormatter()
Get current tic formatter.
Definition: axis.h:246
void SetTicFormat(const wxString &format)
Set how tic text is formated/displayed.
Definition: axis.h:200
a2dStrokeStyle
stroke styles for a2dStroke
Definition: stylebase.h:298
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: axis.h:88
list of a2dObject&#39;s
Definition: gen.h:3157
base class for axis tic formatter
Definition: axis.h:31
CloneOptions
options for cloning
Definition: gen.h:1200
const wxString & GetTicFormat() const
Default tic format.
Definition: axis.h:53
double GetAxisMin() const
get real minimum
Definition: axis.h:131
double GetTicTextHeight() const
return size of font
Definition: axis.h:194
axis.h Source File -- Sun Oct 12 2014 17:04:12 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation