wxFreeChart
compdateaxis.h
1 // Name: compdateaxis.h
3 // Purpose: comp date axis declarations
4 // Author: Moskvichev Andrey V.
5 // Created: 2008/11/07
6 // Copyright: (c) 2008-2010 Moskvichev Andrey V.
7 // Licence: wxWidgets licence
9 
10 #ifndef COMPDATEAXIS_H_
11 #define COMPDATEAXIS_H_
12 
13 #include <wx/axis/axis.h>
14 #include <wx/areadraw.h>
15 
16 #include <wx/dynarray.h>
17 
18 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDateSpan, wxDateSpanArray, WXDLLIMPEXP_FREECHART);
19 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxTimeSpan, wxTimeSpanArray, WXDLLIMPEXP_FREECHART);
20 
26 class WXDLLIMPEXP_FREECHART CompDateAxis : public Axis
27 {
28  DECLARE_CLASS(CompDateAxis)
29 public:
30  CompDateAxis(AXIS_LOCATION location);
31  virtual ~CompDateAxis();
32 
33  virtual void Draw(wxDC &dc, wxRect rc);
34 
35  virtual void DrawGridLines(wxDC &dc, wxRect rc);
36 
37  virtual wxCoord GetExtent(wxDC &dc);
38 
39  virtual bool UpdateBounds() wxOVERRIDE;
40 
41  virtual void GetDataBounds(double &minValue, double &maxValue) const;
42 
43  virtual wxCoord ToGraphics(wxDC &dc, int minCoord, int gRange, double value);
44 
45  virtual double ToData(wxDC &dc, int minCoord, int gRange, wxCoord g);
46 
50  void AddInterval(const wxDateSpan &interval);
51 
52  void AddInterval(const wxTimeSpan &interval);
53 
59  void SetSpanDraw(AreaDraw *spanDraw)
60  {
61  wxREPLACE(m_spanDraw, spanDraw);
62  }
63 
64 protected:
65  virtual bool AcceptDataset(Dataset *dataset);
66 
67 private:
68  void DrawSpan(wxDC &dc, wxRect rcAxis, int spanNum, wxString spanLabel, double start, double end);
69 
70  wxString GetSpanLabel(wxDateTime date, wxDateSpan span);
71 
72  wxCoord GetSpanExtent(wxDC &dc);
73 
74  bool GetWindowDateBounds(wxDateTime &date0, wxDateTime &date1);
75 
76  double DateToDataCoord(wxDateTime &date);
77 
78  bool GetFirstDate(wxDateTime &date);
79  bool GetLastDate(wxDateTime &date);
80 
81  bool GetFirstLastDate(wxDateTime &firstDate, wxDateTime &lastDate);
82 
83  bool GetMinSpan(wxDateSpan &span);
84 
85  size_t m_dateCount;
86 
87  bool m_fillDateGaps;
88 
89  wxFont m_labelFont;
90  wxColour m_labelColour;
91 
92  wxCoord m_minLabelGap; // minimal distance between labels in date/time span
93  wxCoord m_labelMargin; // distance between label and span area bounds
94  AreaDraw *m_spanDraw;
95 
96  wxDateSpanArray m_dateSpans;
97 };
98 
99 #endif /* COMPDATEAXIS_H_ */
virtual wxCoord ToGraphics(wxDC &dc, int minCoord, int gRange, double value)
Transforms coordinate from data space to graphics space.
virtual wxCoord GetExtent(wxDC &dc)=0
Used to determine minimal size needed to draw axis contents, minimal width for vertical axes...
virtual void Draw(wxDC &dc, wxRect rc)=0
Performs axis drawing.
Composite date axis.
Definition: compdateaxis.h:26
void SetSpanDraw(AreaDraw *spanDraw)
Sets area draw to draw spans background.
Definition: compdateaxis.h:59
virtual void GetDataBounds(double &minValue, double &maxValue) const =0
Returns data bounds.
Base class for all axes.
Definition: axis.h:39
virtual bool UpdateBounds()=0
Performs axis bounds update after dataset/s change.
Base class for all datasets (XYDatasets, XYZDatasets, CategoryDatasets, OHLCDatasets, etc).
Definition: dataset.h:39
Base class for drawing area background.
Definition: areadraw.h:22
virtual bool AcceptDataset(Dataset *dataset)=0
Checks whether dataset can be accepted by this axis.
virtual void DrawGridLines(wxDC &dc, wxRect rcData)=0
Draws grid lines for axis.
virtual double ToData(wxDC &dc, int minCoord, int gRange, wxCoord g)
Transforms coordinate from graphics space to data space.