00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _CHARTAXIS_H_
00023 #define _CHARTAXIS_H_
00024
00025 #include "ChartScrollBar.h"
00026 #include "ChartString.h"
00027 #include <afx.h>
00028
00029 #include <list>
00030
00031 class CChartCtrl;
00032 class CChartGrid;
00033 class CChartSerie;
00034 class CChartAxisLabel;
00035
00037
00049 class CChartAxis
00050 {
00051 friend CChartCtrl;
00052 friend CChartGrid;
00053 friend CChartSerie;
00054 friend CChartScrollBar;
00055
00056 public:
00058 CChartAxis();
00060 virtual ~CChartAxis();
00061
00063 int GetPosition();
00064
00066
00072 void SetInverted(bool bInverted);
00074 bool IsInverted() const { return m_bIsInverted; }
00075
00077
00084 void SetAutomatic(bool bAutomatic);
00086
00089 bool IsAutomatic() const { return m_AutoMode != NotAutomatic; }
00090
00092 enum EAxisAutoModes
00093 {
00095 NotAutomatic,
00097 FullAutomatic,
00099 ScreenAutomatic
00100 };
00101
00103 void SetAutomaticMode(EAxisAutoModes AutoMode);
00105 EAxisAutoModes GetAutomaticMode() const { return m_AutoMode; }
00106
00108 void SetVisible(bool bVisible);
00110 bool IsVisible() const { return m_bIsVisible; }
00111
00113
00121 void SetMinMax(double Minimum, double Maximum);
00123 void GetMinMax(double& Minimum, double& Maximum) const
00124 {
00125 Minimum = m_MinValue;
00126 Maximum = m_MaxValue;
00127 }
00128
00130 void SetAxisColor(COLORREF NewColor);
00132 void SetTextColor(COLORREF NewColor);
00134 COLORREF GetTextColor() const { return m_TextColor; }
00136
00142 void SetFont(int nPointSize, const TChartString& strFaceName);
00143
00145 CChartAxisLabel* GetLabel() const { return m_pAxisLabel; }
00147 CChartGrid* GetGrid() const { return m_pAxisGrid; }
00148
00150
00158 void SetMarginSize(bool bAuto, int iNewSize);
00159
00161 void SetPanZoomEnabled(bool bEnabled) { m_bZoomEnabled = bEnabled; }
00163
00166 void SetZoomLimit(double dLimit) { m_dZoomLimit = dLimit; }
00167
00169 void EnableScrollBar(bool bEnabled);
00171 bool ScrollBarEnabled() const
00172 {
00173 if (m_pScrollBar)
00174 return (m_pScrollBar->GetEnabled());
00175 else
00176 return false;
00177 }
00179
00183 void SetAutoHideScrollBar(bool bAutoHide);
00185 bool GetAutoHideScrollBar() const;
00186
00188
00201 virtual void SetDiscrete(bool bDiscrete);
00202
00204
00212 long ValueToScreen(double Value) const;
00214
00225 virtual double ScreenToValue(long ScreenVal) const;
00226
00228 bool IsHorizontal() const { return m_bIsHorizontal; }
00229
00231 BOOL IsPointInside(const CPoint& screenPoint) const;
00232
00233 protected:
00235
00239 virtual double GetFirstTickValue() const = 0;
00241
00250 virtual bool GetNextTickValue(double dCurrentTick, double& dNextTick) const = 0;
00252
00260 virtual long GetTickPos(double Value) const = 0;
00262
00270 virtual long ValueToScreenDiscrete(double Value) const = 0;
00272
00280 virtual long ValueToScreenStandard(double Value) const;
00281
00283
00290 virtual TChartString GetTickLabel(double TickValue) const = 0;
00291
00293 virtual void RefreshTickIncrement() = 0;
00295 virtual void RefreshFirstTick() = 0;
00296
00298
00307 virtual void GetScrollbarSteps(int& iTotalSteps, int& iCurrentStep);
00309
00320 virtual void SetAxisToScrollStep(int iPreviousStep, int iCurrentStep, bool bScrollInverted);
00321
00323
00331 virtual void PanAxis(long PanStart, long PanEnd);
00333 virtual void SetZoomMinMax(double Minimum, double Maximum);
00335 void UndoZoom();
00336
00338 long GetAxisLenght() const;
00340 void GetSeriesMinMax(double& Minimum, double& Maximum);
00342 void GetSeriesScreenMinMax(double& Minimum, double& Maximum);
00343
00344 private:
00346
00349 bool RefreshAutoAxis();
00351
00354 bool RefreshScreenAutoAxis();
00355
00357
00362 CSize GetLargestTick(CDC* pDC);
00363
00365
00369 void SetSecondary(bool bSecondary) { m_bIsSecondary = bSecondary; }
00371 bool IsSecondary() const { return m_bIsSecondary; }
00373 void SetHorizontal(bool bHorizontal);
00374
00376
00380 void Draw(CDC* pDC);
00382
00386 void DrawLabel(CDC* pDC);
00388
00396 void DrawTick(CDC* pDC, double dTickVal);
00398
00404 bool IsLabelOnAxis(double TickVal);
00405
00407
00410 void RegisterSeries(CChartSerie* pSeries);
00412 void UnregisterSeries(CChartSerie* pSeries);
00413
00415 void CreateScrollBar();
00417 void UpdateScrollBarPos();
00419 void RefreshScrollBar();
00420
00422 void SetParent(CChartCtrl* pParent);
00423
00425
00431 void SetAxisSize(const CRect& ControlRect, const CRect& MarginRect);
00433
00441 int ClipMargin(CRect ControlRect,CRect& MarginRect,CDC* pDC);
00443
00447 void Recalculate();
00448
00449 protected:
00451 CChartCtrl* m_pParentCtrl;
00452
00454 bool m_bIsHorizontal;
00456 bool m_bIsInverted;
00458
00460 EAxisAutoModes m_AutoMode;
00461
00463 bool m_bIsVisible;
00464
00466
00470 bool m_bIsSecondary;
00471
00473 double m_MaxValue;
00475 double m_MinValue;
00477 double m_UnzoomMin;
00479 double m_UnzoomMax;
00480
00482 bool m_bAutoTicks;
00484 bool m_bDiscrete;
00485
00487 int m_StartPos;
00489 int m_EndPos;
00491 CRect m_AxisRect;
00492
00493 private:
00495 int m_nFontSize;
00497 TChartString m_strFontName;
00499 COLORREF m_TextColor;
00501 COLORREF m_AxisColor;
00502
00504 CChartGrid* m_pAxisGrid;
00506 CChartAxisLabel* m_pAxisLabel;
00507
00508 typedef std::list<CChartSerie*> SeriesList;
00510 SeriesList m_pRelatedSeries;
00511
00513 bool m_bAutoMargin;
00515 int m_iMarginSize;
00516
00518 bool m_bZoomEnabled;
00520 double m_dZoomLimit;
00521
00523 CChartScrollBar* m_pScrollBar;
00524 };
00525
00526 #endif // _CHARTAXIS_H_