Mobile API Reference  MicroStrategy 2019
GridMap.h
Go to the documentation of this file.
1 //
2 // GridMap.h
3 // IPhoneChart
4 //
5 // Created by Li, En on 1/4/13.
6 // Copyright (c) 2013 __MyCompanyName__. All rights reserved.
7 //
8 
9 #ifndef IPhoneChart_GridMap_h
10 #define IPhoneChart_GridMap_h
11 
12 
13 #include "Point2D.h"
14 #include "Rect2D.h"
15 #include "PolygonObject.h"
16 #include "PolyLineObject.h"
17 #include "RectangleObject.h"
18 #include "FormatFont.h"
19 
20 namespace MsiChart {
21 
22  struct Circle
23  {
24  Circle() : mCenter(Point2D(0,0)), mRadius(0)
25  {}
26 
27  Circle(Point2D iCenter, Int32 iRadius) : mCenter(iCenter), mRadius(iRadius)
28  {}
29 
32  };
33 
34  typedef std::pair<Int32, Int32> OccupyIndex; //0: Host marker, 1: Data label
35  typedef std::vector<std::vector<Int32> > GridMatrix;
36  typedef std::vector<std::vector<std::vector<OccupyIndex> > > HMDLMatrix;
37  typedef std::vector<std::vector<std::vector<Rect2D> > > RectMatrix;
38  typedef std::vector<std::vector<std::vector<Circle> > > CircleMatrix;
39  struct GridMap
40  {
41  bool mIsValid;
48 
53 
54  GridMap();
55  GridMap(const Rect2D& irRect, const Rect2D& irUnit);
56  ~GridMap();
57  Int32 ToMetric(); //to Get the metric
58  bool UpdataMatrix(const Point2D irCenter, const Int32 irRadius, bool iIsAdd); //Circle
59  bool UpdateMatrix(const Rect2D& irOccupy, bool iIsAdd = true, EnumDSSGraphFontRotation iRotation = DssGraphFontRotateNormal);
60  bool UpdateMatrix(bool iIsDataLabel, const Rect2D& irOccupy); //Rect, label or data marker bound
61  bool UpdateMatrix(const PolygonObject* irOccupy, bool iIsAdd = true); //Polygon
62  bool UpdateMatrix(const PolyLineObject* irOccupy, bool iIsAdd = true); //Polyline
63  bool UpdateMatrix(const Point2D& irSegmentStart, const Point2D& irSegmentEnd, bool iIsAdd = true); //segment
64  bool RestoreMatrix(const Rect2D& irOccupy);
65  bool IsAccomdatable(const Rect2D& irHostMarker, const Rect2D& irOccupy, Point2D& orPosition, EnumDSSGraphFontRotation iRotation = DssGraphFontRotateNormal);
66  bool IsAccomdatable(const Rect2D& irHostMarker, const Rect2D& irOccupy);
67  bool IsAccomdatable(const Rect2D& irOccupy, const EnumDssGraphMatrixDataLabelPosition& irLocation);
68  bool IsAccomdatable(const Rect2D& irOccupy);
69  bool IsAccomdatable(const Rect2D& irOccupy, bool iIsExceptDataLabel);
70  bool IsAccomdatable(const Point2D& irCenter, const Int32 irRadius, const Rect2D& irOccupy);
71  bool IsAccomdatableConsiderAccurateDistanceInThePadding(const Point2D& irHostCenter, const Int32 irHostRadius, const Rect2D &irOccupy);
73  bool IsFitPddingWithBorder(const Rect2D& irOccupy, const Rect2D& irFrame);
74  bool IsTwoObjectFitPadding(const Point2D& irCenter, const Int32& irRadius, const Rect2D& irDLRect, const Int32 &irPadding);
75  bool IsTwoRectFitPadding(const Rect2D &irDLRect, const Rect2D &irRect, const Int32 &irPadding);
76  //record the occupy object index(index in data label vector)
77  bool UpdataMatrixOccupy(bool iIsDataLabel, const Rect2D& irOccupy, Int32 iDataLabelIndex);
78  //record the occupy object(bounding box)
79  bool UpdataMatrixOccupyObject(const Rect2D& irOccupy, const Rect2D& irOccupiedObject);
80  bool UpdataMatrixOccupyCircleObject(const Rect2D& irOccupy, const Point2D& irCenter, const Int32 irRadius);
81 
82  // GM Bubble Partial Rendering Support, Overlap detection
83  bool IsAccomdatableWithOverlapNumber(Int32 iOverlapNumber, const Int32& iMarkerShape, const Point2D& irMarkerCenter, const Int32& irMarkerSize);
84 
85  std::vector<PolyLineObject::Ptr> ToDraw(GraphObjectManager* ipManager);
86 
87  private:
88 
89  bool hIsOccupiedByHostMarker(const Rect2D& irHostMarker, int irX,int irY);
90  bool hIsOccupiedByHostMarker(const Point2D irCenter, const Int32 irRadius, int irX,int irY);
91 
92  Point2D hGetApproximateCenterFromTopLeft(Point2D& irTopLeftPoint, Int32 iXOffset, Int32 iYOffset);
93 
94  Int32 hCountOverlapsInRect(Int32 iStartX, Int32 iStartY, Int32 iXCover, Int32 iYCover, Point2D& orPoint, Int32 iLimit = 1);
95  bool hTreatTiltOccupation(const Rect2D& irOccupy, bool iIsAdd = true, bool iIs45 = true);
96 
97  //@Return false if the point to be mapped falls out of the Grid Map.
98  bool hPointToIndex(const Point2D& irPoint, Int32& orX, Int32& orY, bool iIsUseFloorValue = true);
99 
100  //@Return false if the target Rect can not be enclosed by the Grid Map
101  bool hGetRectPositon(const Rect2D& irPoint, Int32& orX, Int32& orY, Int32& orXCover, Int32& orYCover);
102  //void hGetApproximateCenter(Point2D& orPoint, const Point2D& irVertex, Int32
103  bool hSearchInAreas(Point2D& orPoint, const Point2D& irMarkerCenter, Int32 iOriginX, Int32 iOriginY, Int32 iWidth, Int32 iHeight);
104  bool hSearchAlongAxes(Point2D& orPoint, const Point2D& irMarkerCenter, const Point2D& irOriginIndex,
105  const Point2D& irXYOffset, const Point2D irRectCover, bool& iorAlreadyHasOnePlacement, /*double& iorPreDistance,*/ bool iIsYFirst = true);
106 
107  void hIndexToPoint(Int32 iX, Int32 iY, Point2D& iorPoint2D);
108 
109  //judge whether two segments intersected
110  bool hSegmentsIntersection(const Point2D& irPoint1, const Point2D& irPoint2, const Point2D& irPoint3, const Point2D& irPoint4);
111  int hDirection(const Point2D& irPoint1, const Point2D& irPoint2, const Point2D& irPoint3);
112  bool hOnSegment(const Point2D& irPoint1, const Point2D& irPoint2, const Point2D& irPoint3);
113  };
114 
115 }
116 #endif
bool RestoreMatrix(const Rect2D &irOccupy)
bool IsFitPddingWithBorder(const Rect2D &irOccupy, const Rect2D &irFrame)
bool IsAccomdatable(const Rect2D &irHostMarker, const Rect2D &irOccupy, Point2D &orPosition, EnumDSSGraphFontRotation iRotation=DssGraphFontRotateNormal)
Represents a polygon area.
Definition: PolygonObject.h:17
RectMatrix mRectMatrix
Definition: GridMap.h:51
Int32 mXCount
Definition: GridMap.h:45
bool IsAccomdatableConsiderAccurateDistanceInThePadding(const Point2D &irHostCenter, const Int32 irHostRadius, const Rect2D &irOccupy)
Int32 mYUnit
Definition: GridMap.h:44
CircleMatrix mCircleMatrix
Definition: GridMap.h:52
Point2D mCenter
Definition: GridMap.h:30
std::vector< std::vector< Int32 > > GridMatrix
Definition: GridMap.h:35
Definition: GridMap.h:39
Definition: DSSIPhoneEnums.h:1706
Delegates Poly lines.
Definition: PolyLineObject.h:17
#define Int32
Definition: BasicTypes.h:20
Int32 mMetric
Definition: GridMap.h:42
std::vector< PolyLineObject::Ptr > ToDraw(GraphObjectManager *ipManager)
GridMatrix mMatrix
Definition: GridMap.h:49
EnumDSSGraphFontRotation
Definition: DSSIPhoneEnums.h:1704
bool UpdataMatrix(const Point2D irCenter, const Int32 irRadius, bool iIsAdd)
std::pair< Int32, Int32 > OccupyIndex
Definition: GridMap.h:34
Definition: ABLPlot.h:21
bool UpdataMatrixOccupy(bool iIsDataLabel, const Rect2D &irOccupy, Int32 iDataLabelIndex)
bool UpdateMatrix(const Rect2D &irOccupy, bool iIsAdd=true, EnumDSSGraphFontRotation iRotation=DssGraphFontRotateNormal)
bool mIsValid
Definition: GridMap.h:41
Int32 mYCount
Definition: GridMap.h:46
std::vector< std::vector< std::vector< Rect2D > > > RectMatrix
Definition: GridMap.h:37
Int32 mRadius
Definition: GridMap.h:31
bool IsAccomdatableWithOverlapNumber(Int32 iOverlapNumber, const Int32 &iMarkerShape, const Point2D &irMarkerCenter, const Int32 &irMarkerSize)
EnumDssGraphMatrixDataLabelPosition
Definition: Common.h:131
Definition: GridMap.h:22
std::vector< std::vector< std::vector< Circle > > > CircleMatrix
Definition: GridMap.h:38
std::vector< std::vector< std::vector< OccupyIndex > > > HMDLMatrix
Definition: GridMap.h:36
bool UpdataMatrixOccupyCircleObject(const Rect2D &irOccupy, const Point2D &irCenter, const Int32 irRadius)
Circle()
Definition: GridMap.h:24
HMDLMatrix mHMDLMatrix
Definition: GridMap.h:50
Definition: GraphObjectManager.h:37
bool IsTwoRectFitPadding(const Rect2D &irDLRect, const Rect2D &irRect, const Int32 &irPadding)
Circle(Point2D iCenter, Int32 iRadius)
Definition: GridMap.h:27
Point2D mOrigin
Definition: GridMap.h:47
Use four Int32 values to represent a 2D rectangle.
Definition: Rect2D.h:25
bool IsTwoObjectFitPadding(const Point2D &irCenter, const Int32 &irRadius, const Rect2D &irDLRect, const Int32 &irPadding)
bool UpdataMatrixOccupyObject(const Rect2D &irOccupy, const Rect2D &irOccupiedObject)
Int32 mXUnit
Definition: GridMap.h:43