00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(AFX_CHARTAXIS_H__063D695C_43CF_4A46_8AA0_C7E00268E0D3__INCLUDED_)
00023 #define AFX_CHARTAXIS_H__063D695C_43CF_4A46_8AA0_C7E00268E0D3__INCLUDED_
00024
00025 #if _MSC_VER > 1000
00026 #pragma once
00027 #endif // _MSC_VER > 1000
00028
00029 #include "ChartObject.h"
00030 #include "ChartScrollBar.h"
00031 #include "ChartString.h"
00032 #include <afx.h>
00033
00034 #include <list>
00035
00036 class CChartGrid;
00037 class CChartSerie;
00038 class CChartAxisLabel;
00039
00040 class CChartAxis : public CChartObject
00041 {
00042 friend CChartCtrl;
00043 friend CChartGrid;
00044 friend CChartSerie;
00045 friend CChartScrollBar;
00046
00047 public:
00048
00049 enum AxisType
00050 {
00051 atStandard = 0,
00052 atLogarithmic,
00053 atDateTime
00054 };
00055 void SetAxisType(AxisType Type);
00056 AxisType GetAxisType() const { return m_AxisType; }
00057
00058 enum TimeInterval
00059 {
00060 tiSecond,
00061 tiMinute,
00062 tiHour,
00063 tiDay,
00064 tiMonth,
00065 tiYear
00066 };
00067 void SetDateTimeIncrement(bool bAuto, TimeInterval Interval, int Multiplier);
00068 void SetTickIncrement(bool bAuto, double Increment);
00069 double GetTickIncrement() const { return m_TickIncrement; }
00070
00071 void SetDateTimeFormat(bool bAutomatic, const TChartString& strFormat);
00072
00073 int GetPosition();
00074
00075 void SetInverted(bool bNewValue);
00076 bool IsInverted() const { return m_bIsInverted; }
00077 void SetLogarithmic(bool bNewValue)
00078 {
00079 if (bNewValue)
00080 m_AxisType = atLogarithmic;
00081 else
00082 m_AxisType = atStandard;
00083 RefreshAutoAxis();
00084 }
00085 bool IsLogarithmic() const { return (m_AxisType == atLogarithmic); }
00086 void SetAutomatic(bool bNewValue);
00087 bool IsAutomatic() const { return m_bIsAutomatic; }
00088
00089 void SetMinMax(double Minimum, double Maximum);
00090 void GetMinMax(double& Minimum, double& Maximum) const
00091 {
00092 Minimum = m_MinValue;
00093 Maximum = m_MaxValue;
00094 }
00095
00096 long ValueToScreen(double Value) const;
00097 double ScreenToValue(long ScreenVal) const;
00098
00099 void SetTextColor(COLORREF NewColor);
00100 COLORREF GetTextColor() const { return m_TextColor; }
00101
00102 void SetFont(int nPointSize, const TChartString& strFaceName);
00103
00104 CChartAxisLabel* GetLabel() const { return m_pAxisLabel; }
00105 CChartGrid* GetGrid() const { return m_pAxisGrid; }
00106
00107 CChartAxis(CChartCtrl* pParent,bool bHoriz);
00108 virtual ~CChartAxis();
00109
00110 void SetMarginSize(bool bAuto, int iNewSize);
00111
00112 void SetPanZoomEnabled(bool bEnabled) { m_bZoomEnabled = bEnabled; }
00113 void SetZoomLimit(double dLimit) { m_dZoomLimit = dLimit; }
00114
00115 void EnableScrollBar(bool bEnabled);
00116 bool ScrollBarEnabled() const
00117 {
00118 if (m_pScrollBar)
00119 return (m_pScrollBar->GetEnabled());
00120 else
00121 return false;
00122 }
00123 void SetAutoHideScrollBar(bool bAutoHide);
00124 bool GetAutoHideScrollBar() const;
00125
00126 private:
00127 void CalculateTickIncrement();
00128 void CalculateFirstTick();
00129 double GetNextTickValue(double Previous);
00130 CString GetTickLabel(double Tick);
00131 CSize GetLargestTick(CDC* pDC);
00132 void Recalculate();
00133 COleDateTime AddMonthToDate(const COleDateTime& Date, int iMonthsToAdd);
00134 void DrawLabel(CDC* pDC);
00135 void RefreshDTTickFormat();
00136
00137 void PanAxis(long PanStart, long PanEnd);
00138 void SetZoomMinMax(double Minimum, double Maximum);
00139 void UndoZoom();
00140
00141 void SetDecimals(int NewValue) { m_DecCount = NewValue; }
00142 bool IsHorizontal() const { return m_bIsHorizontal; }
00143
00144 int GetAxisLenght() const;
00145 void SetSecondary(bool bNewVal) { m_bIsSecondary = bNewVal; }
00146 bool GetSecondary() const { return m_bIsSecondary; }
00147
00148 bool RefreshAutoAxis();
00149 void GetSeriesMinMax(double& Minimum, double& Maximum);
00150
00151 void SetAxisSize(CRect ControlRect,CRect MarginRect);
00152 int ClipMargin(CRect ControlRect,CRect& MarginRect,CDC* pDC);
00153
00154 void Draw(CDC* pDC);
00155
00156
00157 void RegisterSeries(CChartSerie* pSeries);
00158 void UnregisterSeries(CChartSerie* pSeries);
00159
00160 void CreateScrollBar();
00161 void UpdateScrollBarPos();
00162 void RefreshScrollBar();
00163
00164 AxisType m_AxisType;
00165
00166 bool m_bIsHorizontal;
00167 bool m_bIsInverted;
00168 bool m_bIsAutomatic;
00169
00170 bool m_bIsSecondary;
00171
00172 double m_MaxValue;
00173 double m_MinValue;
00174 double m_UnzoomMin;
00175 double m_UnzoomMax;
00176
00177 bool m_bAutoTicks;
00178 double m_TickIncrement;
00179 double m_FirstTickVal;
00180
00181 unsigned int m_DecCount;
00182 int m_StartPos;
00183 int m_EndPos;
00184
00185 int m_nFontSize;
00186 TChartString m_strFontName;
00187
00188 CChartGrid* m_pAxisGrid;
00189 CChartAxisLabel* m_pAxisLabel;
00190
00191 typedef std::list<CChartSerie*> SeriesList;
00192 SeriesList m_pRelatedSeries;
00193
00194
00195
00196 bool m_bAutoMargin;
00197 int m_iMarginSize;
00198
00199 COLORREF m_TextColor;
00200
00201
00202 TChartString m_strDTTickFormat;
00203 bool m_bAutoTickFormat;
00204 TimeInterval m_BaseInterval;
00205 int m_iDTTickIntervalMult;
00206
00207 bool m_bZoomEnabled;
00208 double m_dZoomLimit;
00209
00210 CChartScrollBar* m_pScrollBar;
00211 };
00212
00213 #endif // !defined(AFX_CHARTAXIS_H__063D695C_43CF_4A46_8AA0_C7E00268E0D3__INCLUDED_)