Mobile API Reference  MicroStrategy 2019
Axis.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : Axis.h
3 // AUTHOR : Liang Liu
4 // CREATION : 2008-05-15
5 // Copyright (C) MicroStrategy Incorporated 2008
6 // All Rights Reserved
7 //==============================================================================================
8 #ifndef MsiChart_Axis_h
9 #define MsiChart_Axis_h
10 
11 #include "GraphObjectManager.h"
12 #include "TextObject.h"
13 
14 namespace MsiChart
15 {
16  //---------Axis Related enumerations-----------------------------------
19  {
26  };
27 
30  {
31  AD_X,
32  AD_Y,
34  };
35 
38  {
47  };
48 
51  {
58  };
59 
60  //---------Axis Related structures----------------------------------
63  {
64  GraphAxisGeneral(unsigned char mAxisLabelsLocation, unsigned char iAxisDirection);
66  unsigned char mAxisLabelsLocation;
79  unsigned char mAxisDirection;
82 
83  bool mIsValid;
84  };
85 
88  {
89  GraphAxisGrid(bool iShowGridLines, unsigned char iGridStyle);
93  unsigned char mGridStyle;
97  double mGridInterval;
98  };
99 
101  struct AxisObject
102  {
108  };
109 
111  extern const AxisObject gAxisObjects[];
112  const Int32 gLabelMargin = 4;
113  const Int32 gMaxLabelLength = 42;
114 
123  class Axis: public GraphObjectManager
124  {
125  public:
133  Axis(const TripleId& irTripleId, GraphObjectManager* ipManager, unsigned char iAxisLabelsLocation,
134  unsigned char iAxisDirection);
135  virtual ~Axis();
136 
142  void SetDeviceDataArea(const Rect2D& irDeviceDataArea);
143 
147  void GetDeviceDataArea(Rect2D& orDeviceDataArea);
148 
149 
150  //---------Override functions-------------------------------------
151  virtual void GetOptions(Int32 iSeriesId, Int32 iPropertyId, CComVariant* opValue) const;
152  virtual GraphObject::Ptr OnPointDetection(const Point2D& irCursor) const;
153 
157  bool IsReverseOrder();
162  void SetDepthAndDirection(Int32 iDepth, Int32 iDepthDirection);
163 
168  void GenerateAxisLine(std::vector<GraphObject::Ptr>& iorGraphObjectList);
175  void GenerateGridLines(const Rect2D& irDataArea, Int32 iAreaId, std::vector<GraphObject::Ptr>& iorGraphObjectList);
176  void GenerateGridLines(); //This is used by ipad Graph matrix to generate ticks.
177 
184  void GenerateInterlacedGrids(const Rect2D& irDataArea, Int32 iAreaId, std::vector<GraphObject::Ptr>& iorGraphObjectList);
185  virtual void GetInterlacedPositions(std::vector<double>& orPositions);
186 
192  virtual double GetLogicalCoord(Int32 iAbsoluteCoord) = 0;
193 
199  virtual float GetAbsoluteCoord(double iLogicalCoord) = 0;
200 
206  virtual void GetMinMaxLogicalCoord(double& orMin, double& orMax) const = 0;
207 
212  virtual double GetSlopeFactor(double iLogicalCoord) const = 0;
213 
218  virtual bool IsLogarithmic() const;
219 
220 
221  virtual double GetPositionAtTick(double iTickValue) = 0;
222 
226  bool IsMajorGridShown() const;
230  bool IsInterlacedShown() const;
234  bool IsLabelsShown() const;
238  bool IsTitleShown() const;
239 
243  void ReserveTitleArea(Rect2D& iorTitleArea);
244 
250  void SetAxisInfoFor3D(Int32 iAxisLength, Int32 iAxisMargin);
255  Int32 GetAxisLengthFor3D() const;
256 
262  double ValueToPositionFor3D(double iLogicalCoord) const;
263 
271  virtual void GenerateLabelsFor3D(const std::vector<Point2D>& irGridPoints, const DVector2D& irUnitOffsetDirection,
272  GraphCollectionObject* ipLabelCollectioin, std::vector<GraphObject::Ptr>& iorGraphObjectList) = 0;
273 
281  void GenerateTitleFor3D(Int32 iObjectId, Point2D& irRefPoint, const DVector2D& irUnitOffsetDirection, std::vector<GraphObject::Ptr>& iorGraphObjectList);
282 
289  virtual void GetGridLinePositionsFor3D(std::vector<double>& orGridLinePositions, EnumGraphObjectType iGraphObjectType) const = 0;
290 
291 
292 
293 
294  virtual void TrimAxisPadding(Rect2D& iorRect, bool iUseFixedMargin = true);
295 
301  Int32 GetAxisTitleLocationId(Int32 iAxisTitleId) const;
302 
307  Int32 GetInterlacedGridId() const;
308 
320  void InitObjectSet(const TripleId& irTripleId, EnumGraphObjectType iGraphObjectType);
321 
333  GraphCollectionObject* GetObjectSet(EnumGraphObjectType iGraphObjectType) const;
334 
340  virtual void OnZooming(Int32 iOldStart, Int32 iOldEnd, Int32 iNewStart, Int32 iNewEnd) = 0;
341 
346  void DrawTitleAndLabels();
347 
351  void SetIsAxisForRangeLegend(bool iIsForRangeLegend);
352 
356  double GetIntervalSpace();
357 
364  virtual Int32 LayoutAxis(bool iIsRotated, Int32& orMaxLabelSpace) = 0;
365 
366  //return the axis label rotation information.
368 
372 
375  bool IsUniformAxis() const;
376  void SetAsUniformAxis(bool iUniformAxis);
377  protected:
381  virtual void CreateAxisLine();
385  Int32 GetIndex() const;
386 
393  void ReserveTitle(Rect2D& iorTitleArea, bool iIsReversed);
399  void UpdateTitleLocation(const Rect2D& irTitleArea);
400 
409  void ReserveDepthAxisLine(Rect2D& iorDeviceDataArea, bool iIsReversed = false, bool iBothDirections = false) const;
410 
417  void GetLabelOffset(Int32 iLabelLocation, Point2D& orOffset) const;
418 
422  bool HasLabelsOnBothSides() const;
429  bool HasDepthAxisLine(Int32 iLabelLocation) const;
434  bool IsVerticalAxis() const;
435 
447  void GetOneGridLine(Int32 iLocation, Int32 iGridStyle, Int32 iTickLength,
448  const Point2D& irLeftOrBottom, const Point2D& irRightOrTop, std::vector<Point2D>& orPolyLine);
455  void GenerateOneLineObject(const TripleId& irTripleId, const std::vector<Point2D>& irPolyLine, GraphCollectionObject* ipGridLineSet);
456 
461  bool IsRightDirection() const;
466  bool IsLeftDirection() const;
471  bool IsUpDirection() const;
476  bool IsDownDirection() const;
482  bool HasOuterTicks(Int32 iGridStyle) const;
489  bool HasTwoGridLineParts(Int32 iGridStyle) const;
490 
496  void TrimMarginsForDepthAxis(Int32& iorLowMargin, Int32& iorHighMargin) const;
501  void GetDepthMargin(Int32& orLowMargin, Int32& orHighMargin) const;
509  void MoveLabel(TextObject* ipLabel, const Point2D& irGridPoint, const DVector2D& irUnitOffsetDirection, Int32 iLabelMargin = gLabelMargin) const;
514  void MoveTitleForManual(TextObject* ipAxisTitle) const;
519  void MoveGraphObjectList(std::vector<GraphObject::Ptr>& iorGraphObjectList);
520 
524  void LoadProperties();
525 
526 
527 
528  //---------Data members----------------------------------
534 
535  bool mUseDepth;
540  double mLowTrim;
541  double mHighTrim;
542 
544  std::vector<GraphObject::Ptr> mManagerGraphObjectList;
545 
549 
556 
559  private:
568  void hGenerateGrids(const Rect2D& irDataArea, std::vector<GraphObject::Ptr>& iorGraphObjectList, bool iIsGridLine);
573  virtual void hGenerateGridsByArea(bool iIsGridLine) = 0;
574 
579  void hMapGridOptions(GraphAxisGrid& iorGrid);
586  void hGenerateOneAxisLine(Int32 iLabelLocation);
590  void hGenerateDepthAxisLine();
596  void hGetAxisLine(Int32 iLabelLocation, Point2D& orStart, Point2D& orEnd) const;
597 
609  void hGetOneDepthGridLine(Int32 iLocation, Int32 iGridStyle, Int32 iTickLength,
610  const Point2D& irLeftOrBottom, const Point2D& irRightOrTop, std::vector<Point2D>& orPolyLine);
614  void hUseInnerDataArea();
615  };
616 
617  inline void Axis::SetDeviceDataArea(const Rect2D& irDeviceDataArea)
618  {
619  mDeviceDataArea = irDeviceDataArea;
620  }
621 
622  inline void Axis::GetDeviceDataArea(Rect2D& orDeviceDataArea)
623  {
624  orDeviceDataArea = mDeviceDataArea;
625  }
626 
627  inline bool Axis::IsReverseOrder()
628  {
630  }
631 
632  inline bool Axis::HasLabelsOnBothSides() const
633  {
635  }
636 
637  inline bool Axis::IsVerticalAxis() const
638  {
639  return mAxisInfo.mAxisDirection == AD_Y;
640  }
641 
642  inline bool Axis::IsRightDirection() const
643  {
644  return mDepthDirection < 90 || mDepthDirection > 270;
645  }
646  inline bool Axis::IsLeftDirection() const
647  {
648  return mDepthDirection > 90 && mDepthDirection < 270;
649  }
650  inline bool Axis::IsUpDirection() const
651  {
652  return mDepthDirection < 180;
653  }
654  inline bool Axis::IsDownDirection() const
655  {
656  return mDepthDirection > 180;
657  }
658  inline bool Axis::HasOuterTicks(Int32 iGridStyle) const
659  {
660  return iGridStyle == DssGraphGridOuterTicks ||
661  iGridStyle == DssGraphGridBoth ||
662  iGridStyle == DssGraphGridSpanningTicks;
663  }
664  inline bool Axis::HasTwoGridLineParts(Int32 iGridStyle) const
665  {
666  return HasLabelsOnBothSides() && (iGridStyle == DssGraphGridInnerTicks ||
667  iGridStyle == DssGraphGridOuterTicks || iGridStyle == DssGraphGridSpanningTicks);
668  }
669  inline bool Axis::IsLogarithmic() const
670  {
671  return false;
672  }
673  inline bool Axis::IsMajorGridShown() const
674  {
675  return mMajorGrid.mShowGridLines;
676  }
677  inline bool Axis::IsInterlacedShown() const
678  {
680  }
681  inline bool Axis::IsLabelsShown() const
682  {
683  return mAxisInfo.mShowAxisLabels;
684  }
685  inline bool Axis::IsTitleShown() const
686  {
687  return mAxisInfo.mShowAxisTitle;
688  }
689  inline void Axis::SetAxisInfoFor3D(Int32 iAxisLength, Int32 iAxisMargin)
690  {
691  mAxisLengthFor3D = iAxisLength;
692  mAxisMarginFor3D = iAxisMargin;
693  }
695  {
696  return mAxisLengthFor3D;
697  }
698  inline bool Axis::IsUniformAxis() const
699  {
701  return mIsUniformAxis;
702  }
703  inline void Axis::SetAsUniformAxis(bool iUniformAxis)
704  {
705  mIsUniformAxis = iUniformAxis;
706  }
707 }
708 #endif
void TrimMarginsForDepthAxis(Int32 &iorLowMargin, Int32 &iorHighMargin) const
Definition: Vector2D.h:21
Int32 mCustomLineId
The object ID of custom line.
Definition: Axis.h:107
void SetDepthAndDirection(Int32 iDepth, Int32 iDepthDirection)
Int32 mMinorId
The object ID of Minor gridline.
Definition: Axis.h:105
ChartContext::Ptr mChartContextPtr
The drawing context instance. Only one object in a chart.
Definition: GraphObjectManager.h:273
bool mIsValid
Definition: Axis.h:83
virtual float GetAbsoluteCoord(double iLogicalCoord)=0
void GenerateAxisLine(std::vector< GraphObject::Ptr > &iorGraphObjectList)
double mGridInterval
Indicates the manual grid interval.
Definition: Axis.h:97
void SetIsAxisForRangeLegend(bool iIsForRangeLegend)
Int32 mTickLength
Tick Length.
Definition: Axis.h:533
Int32 GetIndex() const
Vertical, or Y direction in 3D chart.
Definition: Axis.h:32
bool IsRightDirection() const
Definition: Axis.h:642
bool mIsAxisFor3D
Definition: Axis.h:546
void MoveLabel(TextObject *ipLabel, const Point2D &irGridPoint, const DVector2D &irUnitOffsetDirection, Int32 iLabelMargin=gLabelMargin) const
bool mIsUniformAxis
Definition: Axis.h:558
Definition: Axis.h:24
bool mUseInterlacedGrids
Indicate whether current axis has interlaced grids.
Definition: Axis.h:81
Z direction in 3D chart.
Definition: Axis.h:33
void LoadProperties()
GraphAxisGeneral(unsigned char mAxisLabelsLocation, unsigned char iAxisDirection)
This struct is used to get the object ID of labels, major/minor grid lines or axis title from axis in...
Definition: Axis.h:101
Int32 mLabelId
The object ID of axis label.
Definition: Axis.h:103
GraphCollectionObject * GetObjectSet(EnumGraphObjectType iGraphObjectType) const
virtual void GetInterlacedPositions(std::vector< double > &orPositions)
Definition: DSSIPhoneEnums.h:1891
EnumAxisDirection
Enum for axis direction.
Definition: Axis.h:29
void SetAxisInfoFor3D(Int32 iAxisLength, Int32 iAxisMargin)
Definition: Axis.h:689
void ReserveTitleArea(Rect2D &iorTitleArea)
Definition: DSSIPhoneEnums.h:1890
bool HasLabelsOnBothSides() const
Definition: Axis.h:632
Definition: GraphCollectionObject.h:19
unsigned char mGridStyle
Indicates which style of grid lines should be shown. Should be a value in EnumGridStyle.
Definition: Axis.h:93
void GetOneGridLine(Int32 iLocation, Int32 iGridStyle, Int32 iTickLength, const Point2D &irLeftOrBottom, const Point2D &irRightOrTop, std::vector< Point2D > &orPolyLine)
Definition: Axis.h:52
EnumGraphObjectType
Enum for GraphObject type in Axis.
Definition: Axis.h:50
Grid line properties.
Definition: Axis.h:87
#define _ASSERTE(x)
Definition: Asserte.h:40
Int32 mMajorId
The object ID of Major gridline.
Definition: Axis.h:104
bool mUseManualGrid
Indicates whether manual grid interval should be used or not.
Definition: Axis.h:95
bool mUseDepth
Indicate whether to use depth or not.
Definition: Axis.h:535
bool IsVerticalAxis() const
Definition: Axis.h:637
Horizontal, or X direction in 3D chart.
Definition: Axis.h:31
Definition: Axis.h:25
Int32 mAxisLengthFor3D
Definition: Axis.h:547
bool HasOuterTicks(Int32 iGridStyle) const
Definition: Axis.h:658
Definition: Axis.h:21
virtual void GetMinMaxLogicalCoord(double &orMin, double &orMax) const =0
bool IsReverseOrder()
Definition: Axis.h:627
Definition: Axis.h:46
Definition: Axis.h:41
void MoveTitleForManual(TextObject *ipAxisTitle) const
void ReserveDepthAxisLine(Rect2D &iorDeviceDataArea, bool iIsReversed=false, bool iBothDirections=false) const
const Int32 gLabelMargin
Definition: Axis.h:112
bool mShowAxisTitle
Indicate whether the axis title should be shown or not.
Definition: Axis.h:74
void GenerateTitleFor3D(Int32 iObjectId, Point2D &irRefPoint, const DVector2D &irUnitOffsetDirection, std::vector< GraphObject::Ptr > &iorGraphObjectList)
Definition: Axis.h:56
Int32 mTitleId
The object ID of axis title.
Definition: Axis.h:106
bool mIsForRangeLegend
Is this axis is used by a range legend.
Definition: Axis.h:557
virtual Int32 GetUniformAxisExtraPadding()
double mHighTrim
When depth is not used, the grid lines need to be put into manager&#39;s graph object list...
Definition: Axis.h:541
void DrawTitleAndLabels()
double ValueToPositionFor3D(double iLogicalCoord) const
General axis properties.
Definition: Axis.h:62
Definition: Axis.h:45
#define Int32
Definition: BasicTypes.h:20
Definition: Axis.h:123
MBase::String mAxisTitle
Axis title string.
Definition: Axis.h:539
void GetLabelOffset(Int32 iLabelLocation, Point2D &orOffset) const
void GenerateOneLineObject(const TripleId &irTripleId, const std::vector< Point2D > &irPolyLine, GraphCollectionObject *ipGridLineSet)
bool IsMajorGridShown() const
Definition: Axis.h:673
bool IsInterlacedShown() const
Definition: Axis.h:677
GraphCollectionObject * mpMinorGridSet
Definition: Axis.h:551
virtual double GetPositionAtTick(double iTickValue)=0
Definition: TextObject.h:181
void ReserveTitle(Rect2D &iorTitleArea, bool iIsReversed)
unsigned char mAxisLabelsLocation
Indicates on which side the axis labels should be shown. Should be a value in EnumAxisLabelsLocation...
Definition: Axis.h:66
Point2D mDepthOffset
Indicate the depth offset.
Definition: Axis.h:538
virtual bool IsLogarithmic() const
Definition: Axis.h:669
virtual void GetOptions(Int32 iSeriesId, Int32 iPropertyId, CComVariant *opValue) const
virtual void TrimAxisPadding(Rect2D &iorRect, bool iUseFixedMargin=true)
virtual void CreateAxisLine()
EnumAxisLabelsLocation
Enum for axis label location.
Definition: Axis.h:18
Definition: DSSIPhoneEnums.h:1889
Int32 mDepthDirection
Indicate the depth direction.
Definition: Axis.h:537
const AxisObject gAxisObjects[]
Store the object ID of labels, major grid lines, minor grid lines or axis title.
const Int32 gMaxLabelLength
Definition: Axis.h:113
Int32 GetAxisTitleLocationId(Int32 iAxisTitleId) const
virtual GraphObject::Ptr OnPointDetection(const Point2D &irCursor) const
bool IsTimeSeriesChart() const
Definition: ChartContext.h:2355
void UpdateTitleLocation(const Rect2D &irTitleArea)
Definition: Axis.h:39
GraphCollectionObject * mpInterlacedGridSet
Definition: Axis.h:552
unsigned char mAxisDirection
Definition: Axis.h:79
bool IsUniformAxis() const
Definition: Axis.h:698
GraphCollectionObject * mpAxisLabelSet
Definition: Axis.h:554
virtual void GetGridLinePositionsFor3D(std::vector< double > &orGridLinePositions, EnumGraphObjectType iGraphObjectType) const =0
void SetDeviceDataArea(const Rect2D &irDeviceDataArea)
Definition: Axis.h:617
virtual void OnZooming(Int32 iOldStart, Int32 iOldEnd, Int32 iNewStart, Int32 iNewEnd)=0
std::basic_string< WCHAR, std::char_traits< WCHAR >, Allocator< WCHAR > > String
Definition: BaseString.h:26
void GetDeviceDataArea(Rect2D &orDeviceDataArea)
Definition: Axis.h:622
virtual double GetLogicalCoord(Int32 iAbsoluteCoord)=0
bool IsLeftDirection() const
Definition: Axis.h:646
virtual double GetSlopeFactor(double iLogicalCoord) const =0
bool IsUpDirection() const
Definition: Axis.h:650
bool IsTitleShown() const
Definition: Axis.h:685
bool HasTwoGridLineParts(Int32 iGridStyle) const
Definition: Axis.h:664
Definition: ABLPlot.h:21
bool IsDownDirection() const
Definition: Axis.h:654
bool mShowAxisLabels
Indicate whether the axis labels should be shown or not.
Definition: Axis.h:72
bool IsLabelsShown() const
Definition: Axis.h:681
bool mShowAxisLine
Indicate whether the axis line should be shown or not.
Definition: Axis.h:70
Int32 GetLabelRotation()
Definition: Axis.h:20
virtual void GenerateLabelsFor3D(const std::vector< Point2D > &irGridPoints, const DVector2D &irUnitOffsetDirection, GraphCollectionObject *ipLabelCollectioin, std::vector< GraphObject::Ptr > &iorGraphObjectList)=0
Definition: Axis.h:22
Int32 GetAxisLengthFor3D() const
Definition: Axis.h:694
Definition: Axis.h:57
void InitObjectSet(const TripleId &irTripleId, EnumGraphObjectType iGraphObjectType)
virtual Int32 LayoutAxis(bool iIsRotated, Int32 &orMaxLabelSpace)=0
double mLowTrim
Definition: Axis.h:540
Definition: Axis.h:55
Definition: Msi_ccomvariant.h:24
bool HasDepthAxisLine(Int32 iLabelLocation) const
void SetAsUniformAxis(bool iUniformAxis)
Definition: Axis.h:703
Definition: Axis.h:43
GraphAxisGrid mMinorGrid
Properties of minor grid lines.
Definition: Axis.h:531
MSynch::SmartPtr< Axis > Ptr
Definition: Axis.h:126
void GenerateInterlacedGrids(const Rect2D &irDataArea, Int32 iAreaId, std::vector< GraphObject::Ptr > &iorGraphObjectList)
Axis(const TripleId &irTripleId, GraphObjectManager *ipManager, unsigned char iAxisLabelsLocation, unsigned char iAxisDirection)
Rect2D mDeviceDataArea
Indicate the data area of current axis.
Definition: Axis.h:532
std::vector< GraphObject::Ptr > mManagerGraphObjectList
Definition: Axis.h:544
virtual ~Axis()
EnumAxisIndex
Enum for axis index in gAxisObjects.
Definition: Axis.h:37
bool IsGraphMatrix() const
Definition: ChartContext.h:2384
Definition: Axis.h:42
Definition: Axis.h:23
Definition: Axis.h:40
Definition: Axis.h:44
GraphAxisGrid(bool iShowGridLines, unsigned char iGridStyle)
double GetIntervalSpace()
void GetDepthMargin(Int32 &orLowMargin, Int32 &orHighMargin) const
void GenerateGridLines()
GraphCollectionObject * mpAxisLineSet
Definition: Axis.h:555
Definition: GraphObjectManager.h:37
void MoveGraphObjectList(std::vector< GraphObject::Ptr > &iorGraphObjectList)
GraphAxisGeneral mAxisInfo
General axis properties.
Definition: Axis.h:529
Definition: Axis.h:53
Use four Int32 values to represent a 2D rectangle.
Definition: Rect2D.h:25
GraphCollectionObject * mpAxisTitleSet
Definition: Axis.h:553
bool mAxisDrawInReverse
Indicates whether the axis labels should be shown in reverse order (e.g. from bottom to top...
Definition: Axis.h:68
Definition: DSSIPhoneEnums.h:1892
Int32 mAxisMarginFor3D
Definition: Axis.h:548
Definition: Axis.h:54
Definition: Common.h:397
Int32 mDepth
Indicate the depth value.
Definition: Axis.h:536
bool mShowGridLines
Indicates whether grid lines should be shown or not.
Definition: Axis.h:91
GraphCollectionObject * mpMajorGridSet
Definition: Axis.h:550
GraphAxisGrid mMajorGrid
Properties of major grid lines.
Definition: Axis.h:530
Int32 GetInterlacedGridId() const