wxFreeChart
dataset.h
1 // Name: dataset.h
3 // Purpose: dataset base class 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 DATASET_H_
11 #define DATASET_H_
12 
13 #include <wx/wxfreechartdefs.h>
14 
15 #include <time.h>
16 
17 #include <wx/refobject.h>
18 
19 #include <wx/chartrenderer.h>
20 #include <wx/marker.h>
21 
22 #include <wx/dynarray.h>
23 
24 class Dataset;
25 class DateTimeDataset;
26 
27 #define FOREACH_SERIE(index, dataset) \
28  for (size_t index = 0; index < dataset->GetSerieCount(); index++)
29 
30 #define FOREACH_DATAITEM(index, serie, dataset) \
31  for (size_t index = 0; index < dataset->GetCount(serie); index++)
32 
33 wxDECLARE_EVENT(EVT_DATASET_CHANGED, wxCommandEvent);
34 
39 class WXDLLIMPEXP_FREECHART Dataset : public wxEvtHandler, public RefObject
40 {
41  DECLARE_CLASS(Dataset)
42 public:
43  Dataset();
44  virtual ~Dataset();
45 
50  void SetRenderer(Renderer *renderer);
51 
52  Renderer *GetBaseRenderer();
53 
59  void BeginUpdate();
60 
66  void EndUpdate();
67 
72  virtual size_t GetSerieCount() = 0;
73 
79  virtual size_t GetCount(size_t serie) = 0;
80 
86  virtual wxString GetSerieName(size_t serie) = 0;
87 
93  virtual double GetMinValue(bool vertical) = 0;
94 
100  virtual double GetMaxValue(bool vertical) = 0;
101 
102  virtual DateTimeDataset *AsDateTimeDataset();
103 
108  void AddMarker(Marker *marker);
109 
114  size_t GetMarkersCount();
115 
121  Marker *GetMarker(size_t index);
122 
123  //
124  // DrawObjectObserver
125  //
126  // Received from renderer, or marker
127  virtual void NeedRedraw(DrawObject *obj);
128 
133  void DatasetChanged();
134 
135 protected:
140  virtual bool AcceptRenderer(Renderer *r) = 0;
141 
142  Renderer *m_renderer;
143 private:
144  bool m_updating;
145  bool m_changed;
146 
147  MarkerArray m_markers;
148 };
149 
153 class WXDLLIMPEXP_FREECHART DateTimeDataset
154 {
155 public:
156  DateTimeDataset();
157  virtual ~DateTimeDataset();
158 
164  virtual time_t GetDate(size_t index) = 0;
165 
170  virtual size_t GetCount() = 0;
171 };
172 
173 WX_DECLARE_USER_EXPORTED_OBJARRAY(Dataset *, DatasetArrayBase, WXDLLIMPEXP_FREECHART);
174 
175 class WXDLLIMPEXP_FREECHART DatasetArray : public DatasetArrayBase
176 {
177 public:
178  DatasetArray();
179  virtual ~DatasetArray();
180 
181  void Add(Dataset *dataset);
182 
183  void Remove(Dataset *dataset);
184 
185  void RemoveAt(size_t index, size_t count = 1);
186 };
187 
188 #endif /*DATASET_H_*/
Base class for all renderers.
Definition: chartrenderer.h:21
Object with reference counter.
Definition: refobject.h:8
Markers base class.
Definition: marker.h:24
Base class for objects drawn on chart or perform drawing of another objects (like renderers...
Definition: drawobject.h:22
Base class for all datasets (XYDatasets, XYZDatasets, CategoryDatasets, OHLCDatasets, etc).
Definition: dataset.h:39
Base class for datasets, with date/time.
Definition: dataset.h:153