wxArt2D
plotbox.h
Go to the documentation of this file.
1 /*! \file wx/curves/plotbox.h
2  \brief Higher level of data plotting, adding title and legends.
3  \author Sirin Nitinawarat
4 
5  Copyright: 2000-2004 (c) Robert Roebling
6 
7  Licence: wxWidgets Licence
8 
9  RCS-ID: $Id: plotbox.h,v 1.24 2008/09/05 19:01:12 titato Exp $
10 */
11 
12 #ifndef __WXPLOTBOX_H__
13 #define __WXPLOTBOX_H__
14 
15 #ifndef WX_PRECOMP
16 #include "wx/wx.h"
17 #endif
18 
19 #include "wx/canvas/canobj.h"
20 #include "wx/canvas/canprim.h"
21 #include "wx/curves/meta.h"
22 
23 //! plot a group of curves on a given area in world coordinates.
24 /*
25  The curves are displayed in the a2dCanvasXYDisplayGroup its
26  internal coordinates, which are used within the axis area.
27 
28  Next to displaying the curves, the title and axis labels can be set.
29 */
30 class A2DCURVESDLLEXP a2dPlot : public a2dCanvasXYDisplayGroup
31 {
32  DECLARE_EVENT_TABLE()
33 
34 public:
35 
36  a2dPlot( double x = 0, double y = 0 );
37 
38  a2dPlot( const a2dPlot& other, CloneOptions options, a2dRefMap* refs );
39 
40  virtual ~a2dPlot();
41 
42  //! set title above plot, empty string removes it
43  void SetTitle( const wxString& title );
44 
45  //! set title above plot using a text object, NULL removes it
46  void SetTitleTextDc( a2dText* title );
47 
48  //! set markerShow under plot using a a2dMarkerShow object, NULL removes it
49  void SetMarkerShow( a2dMarkerShow* showm );
50 
51  //! set X label on axis, empty string removes it
52  void SetXLabel( const wxString& xlabel, const wxColour& color = wxNullColour );
53 
54  //! set X label on axis as text object, NULL removes it
55  void SetXLabelTextDc( a2dText* xLabelTextDc );
56 
57  //! set Y label on axis, empty string removes it
58  void SetYLabel( const wxString& ylabel, const wxColour& color = wxNullColour )
59  {
60  SetY1Label( ylabel, color );
61  }
62  //! set Y label on axis as text object, NULL removes it
63  void SetYLabelTextDc( a2dText* yLabelTextDc )
64  {
65  SetY1LabelTextDc( yLabelTextDc );
66  }
67 
68  //! set Y label on axis, empty string removes it
69  void SetY1Label( const wxString& ylabel, const wxColour& color = wxNullColour );
70 
71  //! set Y label on axis as text object, NULL removes it
72  void SetY1LabelTextDc( a2dText* yLabelTextDc );
73 
74  //! set Y label on axis, empty string removes it
75  void SetY2Label( const wxString& ylabel, const wxColour& color = wxNullColour );
76 
77  //! set Y label on axis as text object, NULL removes it
78  void SetY2LabelTextDc( a2dText* yLabelTextDc );
79 
80  //! if true text objects title xlabel and ylabel will be set in position automatically
81  void SetAutoPlace( bool autoPlace ) { m_autoPlace = autoPlace; }
82 
83  //! if true text ylabel will be set according curves area name
84  void SetAutoYAxesNames( bool autoYNames )
85  {
86  m_autoYNames = autoYNames; SetPending( true );
87  }
88 
89  //! extra distance around plot
90  void SetPadding( double leftPadding, double rightPadding, double topPadding, double bottomPadding );
91 
92  DECLARE_DYNAMIC_CLASS( a2dPlot )
93 
94 protected:
95 
96 #if wxART2D_USE_CVGIO
97  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
98 
99  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
100 #endif //wxART2D_USE_CVGIO
101 
102  void DoRender( a2dIterC& ic, OVERLAP clipparent );
103 
104  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
105 
106  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
107 
108  void SetPosYLabel( a2dText* yLabelTextDc, double x, double y, double tHeight, bool left );
109 
110 private:
111 
112  void OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event );
113 
114 protected:
115 
116  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
117 
118  //! padding.
120  //! padding.
122  //! padding.
123  double m_topPadding;
124  //! padding.
126 
127  bool m_autoPlace;
128 
129  bool m_autoYNames;
130 
131 private:
132  //!this is a not implemented copy constructor that avoids automatic creation of one
133  a2dPlot( const a2dPlot& other );
134 };
135 
136 #if defined(WXART2D_USINGDLL)
137 template class A2DCURVESDLLEXP a2dSmrtPtr<a2dPlot>;
138 #endif
139 
140 //! legend for a group of curves.
141 /*!
142  for all cuvres in a a2dCanvasXYDisplayGroup, display the name in a colums of Text
143 */
144 class A2DCURVESDLLEXP a2dCurveGroupLegend : public a2dCanvasObject
145 {
146 public:
147 
148  a2dCurveGroupLegend( const wxString& format = _T( "name = %s" ) , a2dCanvasXYDisplayGroupAreas* curveGroup = 0,
149  const a2dFont& font = *a2dDEFAULT_CANVASFONT );
150 
151  a2dCurveGroupLegend( const a2dCurveGroupLegend& other, CloneOptions options, a2dRefMap* refs );
152 
153  virtual ~a2dCurveGroupLegend();
154 
155  void SetCurveGroup( a2dCanvasXYDisplayGroupAreas* curveGroup ) { m_curveGroup = curveGroup; }
156 
157  a2dCanvasXYDisplayGroupAreas* GetCurveGroup() const { return m_curveGroup; }
158 
159  void SetFont( const a2dFont& font ) { m_font = font; SetPending( true );}
160 
161  //! Set Space in world coordinates between two lines
162  inline void SetLineSpacing( double linespace )
163  { m_linespace = linespace; SetPending( true ); }
164  //! Get Space in world coordinates between two lines
165  inline double GetLineSpacing() const { return m_linespace; }
166 
167  //! Height in world coordinates of one line
168  inline double GetLineHeight() const { return m_font.GetLineHeight(); }
169 
170  DECLARE_DYNAMIC_CLASS( a2dCurveGroupLegend )
171 
172  DECLARE_EVENT_TABLE()
173 
174 protected:
175 
176  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
177 
178  void OnChar( wxKeyEvent& event );
179 
180  void DoWalker( wxObject* parent, a2dWalkerIOHandler& handler );
181 
182  void DoAddPending( a2dIterC& ic );
183 
184  //void OnEnterObject(a2dCanvasObjectEvent &event);
185 
186  //void OnLeaveObject(a2dCanvasObjectEvent &event);
187 
188  void OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event );
189 
190 #if wxART2D_USE_CVGIO
191  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
192 
193  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
194 #endif //wxART2D_USE_CVGIO
195 
196  void DependencyPending( a2dWalkerIOHandler* WXUNUSED( handler ) );
197 
198  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
199 
200  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
201 
202  void DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) );
203 
204  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
205 
207 
208  wxString m_format;
209 
210  //! legend font
212 
213  //! space between the lines
214  double m_linespace;
215 
216 private:
217  //!this is a not implemented copy constructor that avoids automatic creation of one
219 };
220 
221 
222 
223 #endif
224 
225 
all basic primitives derived from a2dCanvasObject
classes for plotting curve and pie data, and editing them.
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
void SetAutoPlace(bool autoPlace)
if true text objects title xlabel and ylabel will be set in position automatically ...
Definition: plotbox.h:81
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
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
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
double GetLineSpacing() const
Get Space in world coordinates between two lines.
Definition: plotbox.h:165
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
The base class for all drawable objects in a a2dCanvasDocument.
double m_linespace
space between the lines
Definition: plotbox.h:214
For Showing Marker position of Markers on a Curve.
Definition: marker.h:408
plot a group of curves on a given area in world coordinates.
Definition: plotbox.h:30
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dFont m_font
legend font
Definition: plotbox.h:211
simple curve group with just one a2dCurvesArea in use
Definition: curvegroup.h:697
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
double GetLineHeight() const
Height in world coordinates of one line.
Definition: plotbox.h:168
double m_bottomPadding
padding.
Definition: plotbox.h:121
a2dText is an abstract base class.
Definition: cantext.h:93
double m_topPadding
padding.
Definition: plotbox.h:123
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Special object group to plot a2dCurve Objects but also any other a2dCanvasObject. ...
Definition: curvegroup.h:394
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
void SetYLabel(const wxString &ylabel, const wxColour &color=wxNullColour)
set Y label on axis, empty string removes it
Definition: plotbox.h:58
legend for a group of curves.
Definition: plotbox.h:144
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
void SetAutoYAxesNames(bool autoYNames)
if true text ylabel will be set according curves area name
Definition: plotbox.h:84
double m_leftPadding
padding.
Definition: plotbox.h:119
void SetYLabelTextDc(a2dText *yLabelTextDc)
set Y label on axis as text object, NULL removes it
Definition: plotbox.h:63
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
double m_rightPadding
padding.
Definition: plotbox.h:125
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
list of a2dObject&#39;s
Definition: gen.h:3157
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
Definition: a2dlist.h:20
CloneOptions
options for cloning
Definition: gen.h:1200
void SetLineSpacing(double linespace)
Set Space in world coordinates between two lines.
Definition: plotbox.h:162
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
plotbox.h Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation