00001
00002
00003
00004
00005
00006
00007
00009
00010 #ifndef AXISPLOT_H_
00011 #define AXISPLOT_H_
00012
00013 #include <wx/plot.h>
00014 #include <wx/axis/axis.h>
00015
00016 #include <wx/areadraw.h>
00017 #include <wx/legend.h>
00018 #include <wx/marker.h>
00019
00020 #include <wx/dynarray.h>
00021
00025 class WXDLLIMPEXP_FREECHART DataAxisLink
00026 {
00027 public:
00028 DataAxisLink(Dataset *dataset, Axis *axis)
00029 {
00030 m_dataset = dataset;
00031 m_axis = axis;
00032 }
00033
00034 DataAxisLink(const DataAxisLink &o)
00035 {
00036 m_dataset = o.m_dataset;
00037 m_axis = o.m_axis;
00038 }
00039
00040 ~DataAxisLink()
00041 {
00042 }
00043
00044 Dataset *m_dataset;
00045 Axis *m_axis;
00046 };
00047
00048 WX_DECLARE_USER_EXPORTED_OBJARRAY(DataAxisLink, DataAxisLinkArray, WXDLLIMPEXP_FREECHART);
00049
00053 class WXDLLIMPEXP_FREECHART AxisPlot : public Plot,
00054 public DrawObserver, public DatasetObserver, public AxisObserver
00055 {
00056 public:
00057 AxisPlot();
00058 virtual ~AxisPlot();
00059
00064 void AddAxis(Axis *axis);
00065
00070 void AddDataset(Dataset *dataset);
00071
00079 void AddObjects(Dataset *dataset, Axis *verticalAxis, Axis *horizontalAxis);
00080
00085 size_t GetDatasetCount();
00086
00092 Dataset *GetDataset(size_t index);
00093
00099 void LinkDataHorizontalAxis(size_t nData, size_t nAxis);
00100
00106 void LinkDataVerticalAxis(size_t nData, size_t nAxis);
00107
00115 Axis *GetDatasetAxis(Dataset *dataset, size_t index, bool vertical);
00116
00126 Axis *GetDatasetAxis(Dataset *dataset, bool vertical);
00127
00135 Axis *GetDatasetVerticalAxis(Dataset *dataset)
00136 {
00137 return GetDatasetAxis(dataset, true);
00138 }
00139
00147 Axis *GetDatasetHorizontalAxis(Dataset *dataset)
00148 {
00149 return GetDatasetAxis(dataset, false);
00150 }
00151
00158 Dataset *GetAxisDataset(Axis *axis, size_t index)
00159 {
00160 return axis->GetDataset(index);
00161 }
00162
00168 void SetDrawGrid(bool drawGridVertical, bool drawGridHorizontal);
00169
00174 void SetDataBackground(AreaDraw *dataBackground);
00175
00180 void SetLegend(Legend *legend);
00181
00193 bool ToDataCoords(size_t nData, wxDC &dc, wxRect rc, wxCoord gx, wxCoord gy, double *x, double *y);
00194
00195
00196
00197
00198 virtual void NeedRedraw(DrawObject *obj);
00199
00200
00201
00202
00203 virtual void DatasetChanged(Dataset *dataset);
00204
00205
00206
00207
00208 virtual void AxisChanged(Axis *axis);
00209
00210 virtual void BoundsChanged(Axis *axis);
00211
00212 protected:
00213
00214
00215
00216
00222 virtual bool AcceptAxis(Axis *axis) = 0;
00223
00229 virtual bool AcceptDataset(Dataset *dataset) = 0;
00230
00236 virtual void DrawDatasets(wxDC &dc, wxRect rc) = 0;
00237
00238 wxCoord GetAxesExtent(wxDC &dc, AxisArray *axes);
00239
00240 private:
00241
00242
00243
00244 virtual void DrawData(wxDC &dc, wxRect rc);
00245
00246 virtual bool HasData();
00247
00248
00249 void UpdateAxis(Dataset *dataset = NULL);
00250
00251
00252
00253
00254
00262 void CalcDataArea(wxDC &dc, wxRect rc, wxRect &rcData, wxRect &rcLegend);
00263
00270 void DrawAxes(wxDC &dc, wxRect &rc, wxRect rcData);
00271
00279 void DrawAxesArray(wxDC &dc, wxRect rc, AxisArray *axes, bool vertical);
00280
00281
00287 void DrawGridLines(wxDC &dc, wxRect rcData);
00288
00294 void DrawMarkers(wxDC &dc, wxRect rcData);
00295
00301 void DrawDataArea(wxDC &dc, wxRect rcData);
00302
00308 void DrawLegend(wxDC &dc, wxRect rcLegend);
00309
00310 bool m_drawGridVertical;
00311 bool m_drawGridHorizontal;
00312
00313 AxisArray m_leftAxes;
00314 AxisArray m_rightAxes;
00315 AxisArray m_topAxes;
00316 AxisArray m_bottomAxes;
00317
00318 AxisArray m_horizontalAxes;
00319 AxisArray m_verticalAxes;
00320
00321 DataAxisLinkArray m_links;
00322
00323 DatasetArray m_datasets;
00324 AreaDraw *m_dataBackground;
00325
00326 wxCoord m_legendPlotGap;
00327
00328 Legend *m_legend;
00329
00330
00331 };
00332
00333 #endif