Mobile API Reference  MicroStrategy 2019
PieSliceObject.h
Go to the documentation of this file.
1 //=====================================================================================
2 // Filename: Kernel/SourceCode/ChartEngine/PrivateSource/PieSliceObject.h
3 // Date: 2008-05-22
4 // Authors: Bing Huang
5 
6 // Copyright (C) 1997-2008 MicroStrategy Incorporated
7 // All rights reserved
8 //=====================================================================================
9 
10 #ifndef MsiChart_PieSliceObject_h
11 #define MsiChart_PieSliceObject_h
12 
13 #include "ShapeObject.h"
14 
15 namespace MsiChart
16 {
17  //related structs and enums
18  typedef enum
19  {
27 
28  typedef enum
29  {
33 
34  struct Angle
35  {
36  Angle(Int32 iStartAngle = 0, Int32 iEndAngle = 0)
37  : mStartAngle(iStartAngle), mEndAngle(iEndAngle)
38  {}
39 
42  };
43 
44  struct SliceInfo
45  {
46  float mStartAngle;
47  float mEndAngle;
49  bool mIsRingPie;
51  double mScale;
52 
54  float mRadius;
55  Int32 mMaxRadius;//no proportional
57 
58  SliceInfo(float iStartAngle, float iEndAngle, float iRingPieFactor,
59  bool iIsRingPie, bool iIs2DCircular, double iScale, const Point2D& irCenter,
60  float iRadius, Int32 iMaxRadius, Int32 iDepth, double iPercentContribution = 0)
61  : mStartAngle(iStartAngle),
62  mEndAngle(iEndAngle),
63  mRingPieFactor(iRingPieFactor),
64  mIsRingPie(iIsRingPie),
65  mIs2DCircular(iIs2DCircular),
66  mScale(iScale),
67  mCenter(irCenter),
68  mRadius(iRadius),
69  mMaxRadius(iMaxRadius),
70  mDepth(iDepth)
71  {}
72  };
73 
74  class PieSliceObject : public ShapeObject
75  {
76  public:
78 
79  PieSliceObject(const TripleId& irTripleId, GraphObjectManager* ipManager,
80  Int32 iExplode, float iStartAngle, float iEndAngle, float iRingPieFactor,
81  bool iIsRingPie, bool iIs2DCircular, double iScale, const Point2D& irCenter,
82  float iRadius, Int32 iMaxRadius, Int32 iDepth, bool iOneSeries,
83  GraphCollectionObject* ipParentObject = NULL, bool iIsShown = true);
84 
85  //Constructor method 2 for new pie chart.
86  PieSliceObject(const TripleId& irTripleId, Int32 iAngleIndex, Int32 iSliceId, GraphObjectManager* ipManager,
87  Int32 iExplode, Int32 iStartAngle, Int32 iEndAngle, float iRingPieFactor,
88  bool iIsRingPie, bool iIs2DCircular, double iScale, const Point2D& irCenter,
89  float iRadius, Int32 iMaxRadius, Int32 iDepth, bool iOneSeries,
90  GraphCollectionObject* ipParentObject = NULL, bool iIsShown = true);
91 
92 
93 
94  //virtual functions from GraphObject
95  virtual void Draw() const;
96  virtual void DrawInnerOutLine();
97  virtual void DrawOutLine();
98  virtual bool PointInObject(const Point2D& irPoint);
99  virtual bool ObjectInRectangle(const Rect2D& irRect);
100  virtual void GenerateImageMap(ImageMap& iorImageMap);
101  virtual void GetOptions(Int32 iPropertyId, CComVariant* opValue) const;
102  virtual void GetBoundingRect(Rect2D& orBoundingRect) const;
103 
108  const SliceInfo* GetSliceInfo() const;
109 
115  void SetBoundingRectType(BoundingRectType iBoundingRectType) const;
116 
122  void SetCylinderStart(Int32 iCylinderStart) const;
123 
129  void SetCylinderEnd(Int32 iCylinderEnd) const;
130 
135  void SetDrawOutline(bool iIsOutline);
136 
137  void SetWhitenOuterBorder(bool iIsWhiten);
138 
139  void SetOutLineInfo(bool iIsConsectiveOutline, bool iIsHighLightStartAngelEdge, bool iIsHighLightEndAngleEdge);
140 
141  void SetIsNeedInnerStrokeForConsectiveSlcie(bool iStroke);
142 
143  float GetStartAngelRadian();
144  float GetEndAngelRadian();
145 
150  void ConvertAngle(Angle& iorAngle) const;
151 
162  bool GetIntersectionConvertedAngles(const Angle& irAngle1, const Angle& irAngle2, Angle& orAngle) const;
163 
171  bool GetIntersectionAngle(const Angle& irAngle1, const Angle& irAngle2) const;
172 
181  bool GetIntersectionAngle(const Angle& irAngle1, const Angle& irAngle2, Angle& orAngle) const;
182 
186  void ElementDrawRingPieTop();
187 
192 
196  void ElementFillSide();
197 
202  void GetLeaderLineStartPoint(Point2D& orPoint) const;
203 
212  void GetSectorImageMap(const Point2D& irCenter, const Int32 iRadius, const Int32 iStartAngle, const Int32 iEndAngle, ImageMap& iorImageMap) const;
213 
222  void GetSideRectangleImageMap(const Point2D& irCenter, const Int32 iRadius, const Int32 iDepth, const Int32 iAngle, ImageMap& iorImageMap) const;
223 
233  void GetCylinderImageMap(const Point2D& irCenter, const Int32 iRadius, const Int32 iDepth, const Int32 iStartAngle, const Int32 iEndAngle, ImageMap& iorImageMap) const;
234 
235  void UpdateRadius(Int32 iRadius, Int32 iMaxRadius);
236 
237  Point2D GetPointByRatio(double iRadiusRatio, bool iSmartLabels = false) const;
238 
240 
241  Int32 GetMiddleAngle() const;
242 
243  Int32 GetAngleIndex() const;
244 
245  Int32 GetSliceIndex() const;
246 
247  float GetMiddleAngleRadian() const;
248 
249  protected:
250  //pure virtual functions from ShapeObject
251  virtual void GetClockwisePolygon(std::vector<Point2D>& orPolygon) const;
252  virtual void FillBevel() const;
253  virtual bool IsCircularShape() const;
254 
255  friend class PieSliceElementObject;
256 
257  private:
261  void hDrawGlowEffect() const;
262 
266  void hApplyFillAndLine() const;
267 
271  void hFillSide() const;
272 
276  void hDrawRingPieSlice() const;
277 
278  void hDrawRingPieInnerStroke() const;
279 
283  void hDrawRingPieOneSeriesTop() const;
284 
288  void hDrawRingPieOneSeriesBottom() const;
289 
293  void hDrawRingPieMiddle() const;
294 
298  void hDrawRingPieTop() const;
299 
303  void hDrawRingPieBottom() const;
304 
309  void hDrawRingPieMiddleRectangle(RectangleAngle iRectangleAngle) const;
310 
314  void hDrawRingPieMiddleCylinder() const;
315 
322  void hDrawCylinder(bool iIsRing, Int32 iStartAngle, Int32 iEndAngle) const;
323 
327  void hDrawNormalPieSlice() const;
328 
329  void hDrawNormalPieInnerStroke() const;
330 
334  void hDrawNormalPieOneSeriesTop() const;
335 
339  void hDrawNormalPieOneSeriesBottom() const;
340 
344  void hDrawNormalPieMiddle() const;
345 
349  void hDrawNormalPieTop() const;
350 
354  void hDrawNormalPieBottom() const;
355 
360  void hDrawNormalPieMiddleRectangle(RectangleAngle iRectangleAngle) const;
361 
365  void hDrawNormalPieMiddleCylinder() const;
366 
372  bool hPointInRingPieSlice(const Point2D& irPoint) const;
373 
379  bool hPointInNormalPieSlice(const Point2D& irPoint) const;
380 
386  bool hGetIntersectionConvertedAngleToSliceAngle(const Angle& irAngle) const;
387 
392  void hGetTopBottomBoundingRect(Rect2D& orBoundingRect) const;
393 
398  void hGetCylinderBoundingRect(Rect2D& orBoundingRect) const;
399 
404  void hGetRectangleBoundingRect(Rect2D& orBoundingRect) const;
405 
406  void hWhitenOuterBorder() const;
407 
408  //SliceInfo mSliceInfo;
409  SliceInfo mSliceInfo;
410 
411  //used by "GetBoudingRect()"
412  mutable BoundingRectType mBoundingRectType;
413  mutable Int32 mCylinderStart;
414  mutable Int32 mCylinderEnd;
415  //deal with the case that there is only one series
416  bool mOneSeries;
417  mutable bool mIsOutline;
418 
419  Point2D mOriginalCenter;
420  float mStartAngleRadian;
421  float mEndAngleRadian;
422  float mMiddleAngleRadian;
423 
424  Int32 mMiddleAngle;
425  Int32 mMiddleAngleQuadrant;
426 
427  Int32 mAngleIndex;
428  Int32 mSliceIndex;
429 
430  bool mIsShown;
431  bool mIsWhitenOuterBorder;
432 
433  // Enhacement of Highline, for multiple slice connected, highlight the outer border as a group as web did.
434  bool mIsConsecutiveHighLihgt;
435  bool mIsConsecutiveSlcieNeedInnerStroke;
436  bool mIsHighLightStartAngleEdge;
437  bool mIsHighLightEndAngleEdge;
438  };
439 
440  inline void PieSliceObject::SetCylinderStart(Int32 iCylinderStart) const
441  {
442  mCylinderStart = iCylinderStart;
443  }
444 
445  inline void PieSliceObject::SetCylinderEnd(Int32 iCylinderEnd) const
446  {
447  mCylinderEnd = iCylinderEnd;
448  }
449 
450  inline void PieSliceObject::SetBoundingRectType(BoundingRectType iBoundingRectType) const
451  {
452  mBoundingRectType = iBoundingRectType;
453  }
454 
455  inline void PieSliceObject::SetDrawOutline(bool iIsOutline)
456  {
457  mIsOutline = iIsOutline;
458  }
459 
461  {
462  return &mSliceInfo;
463  }
464 
466  {
467  return mMiddleAngleQuadrant;
468  }
469 
471  {
472  return mMiddleAngle;
473  }
474 
476  {
477  return mMiddleAngleRadian;
478  }
479 
481  {
482  return mAngleIndex;
483  }
484 
486  {
487  return mSliceIndex;
488  }
489 
491  {
492  mIsConsecutiveSlcieNeedInnerStroke = iStroke;
493  }
494 
496  {
497  return mStartAngleRadian;
498  }
499 
501  {
502  return mEndAngleRadian;
503  }
504 
505  inline void PieSliceObject::SetOutLineInfo(bool iIsConsectiveOutline, bool iIsHighLightStartAngelEdge, bool iIsHighLightEndAngleEdge)
506  {
507  mIsConsecutiveHighLihgt = iIsConsectiveOutline;
508  mIsHighLightStartAngleEdge = iIsHighLightStartAngelEdge;
509  mIsHighLightEndAngleEdge = iIsHighLightEndAngleEdge;
510  }
511 
512  inline void PieSliceObject::SetWhitenOuterBorder(bool iIsWhiten)
513  {
514  mIsWhitenOuterBorder = iIsWhiten;
515  }
516 
517 }
518 
519 #endif
RectangleAngle
Definition: PieSliceObject.h:28
float mRingPieFactor
Definition: PieSliceObject.h:48
float GetEndAngelRadian()
Definition: PieSliceObject.h:500
float mStartAngle
Definition: PieSliceObject.h:46
float GetMiddleAngleRadian() const
Definition: PieSliceObject.h:475
Int32 GetSliceIndex() const
Definition: PieSliceObject.h:485
virtual bool PointInObject(const Point2D &irPoint)
Int32 mMaxRadius
Definition: PieSliceObject.h:55
void GetCylinderImageMap(const Point2D &irCenter, const Int32 iRadius, const Int32 iDepth, const Int32 iStartAngle, const Int32 iEndAngle, ImageMap &iorImageMap) const
bool GetIntersectionConvertedAngles(const Angle &irAngle1, const Angle &irAngle2, Angle &orAngle) const
Definition: PieSliceObject.h:20
virtual bool IsCircularShape() const
MSynch::SmartPtr< PieSliceObject > Ptr
Definition: PieSliceObject.h:77
Definition: PieSliceObject.h:44
float mRadius
Definition: PieSliceObject.h:54
float mEndAngle
Definition: PieSliceObject.h:47
Definition: PieSliceObject.h:25
Definition: PieSliceObject.h:23
Definition: PieSliceObject.h:74
const SliceInfo * GetSliceInfo() const
Definition: PieSliceObject.h:460
Definition: PieSliceObject.h:34
Angle(Int32 iStartAngle=0, Int32 iEndAngle=0)
Definition: PieSliceObject.h:36
Point2D mCenter
Definition: PieSliceObject.h:53
Definition: GraphCollectionObject.h:19
Point2D GetPointByRatio(double iRadiusRatio, bool iSmartLabels=false) const
virtual void GetOptions(Int32 iPropertyId, CComVariant *opValue) const
Definition: PieSliceObject.h:22
bool GetIntersectionAngle(const Angle &irAngle1, const Angle &irAngle2) const
bool mIs2DCircular
Definition: PieSliceObject.h:50
void GetSectorImageMap(const Point2D &irCenter, const Int32 iRadius, const Int32 iStartAngle, const Int32 iEndAngle, ImageMap &iorImageMap) const
void SetCylinderStart(Int32 iCylinderStart) const
Definition: PieSliceObject.h:440
Definition: PieSliceObject.h:24
Definition: ShapeObject.h:20
virtual void DrawOutLine()
virtual void GetClockwisePolygon(std::vector< Point2D > &orPolygon) const
void SetWhitenOuterBorder(bool iIsWhiten)
Definition: PieSliceObject.h:512
double mScale
Definition: PieSliceObject.h:51
void SetIsNeedInnerStrokeForConsectiveSlcie(bool iStroke)
Definition: PieSliceObject.h:490
void GetLeaderLineStartPoint(Point2D &orPoint) const
bool mIsRingPie
Definition: PieSliceObject.h:49
virtual void Draw() const
#define Int32
Definition: BasicTypes.h:20
void SetOutLineInfo(bool iIsConsectiveOutline, bool iIsHighLightStartAngelEdge, bool iIsHighLightEndAngleEdge)
Definition: PieSliceObject.h:505
Int32 GetAngleIndex() const
Definition: PieSliceObject.h:480
Int32 mEndAngle
Definition: PieSliceObject.h:41
BoundingRectType
Definition: PieSliceObject.h:18
Definition: PieSliceElementObject.h:17
Definition: PieSliceObject.h:31
Definition: SmartPtr.h:38
Int32 GetMiddleAngle() const
Definition: PieSliceObject.h:470
void GetSideRectangleImageMap(const Point2D &irCenter, const Int32 iRadius, const Int32 iDepth, const Int32 iAngle, ImageMap &iorImageMap) const
void UpdateRadius(Int32 iRadius, Int32 iMaxRadius)
void ConvertAngle(Angle &iorAngle) const
Definition: ABLPlot.h:21
std::vector< AreaRec * > ImageMap
Definition: ImageMap.h:99
Int32 mDepth
Definition: PieSliceObject.h:56
Definition: PieSliceObject.h:21
void SetCylinderEnd(Int32 iCylinderEnd) const
Definition: PieSliceObject.h:445
Int32 GetMiddleAngleQuadrant() const
Definition: PieSliceObject.h:465
Int32 mStartAngle
Definition: PieSliceObject.h:40
virtual void DrawInnerOutLine()
virtual void GetBoundingRect(Rect2D &orBoundingRect) const
Definition: Msi_ccomvariant.h:24
Definition: PieSliceObject.h:30
SliceInfo(float iStartAngle, float iEndAngle, float iRingPieFactor, bool iIsRingPie, bool iIs2DCircular, double iScale, const Point2D &irCenter, float iRadius, Int32 iMaxRadius, Int32 iDepth, double iPercentContribution=0)
Definition: PieSliceObject.h:58
virtual void FillBevel() const
void SetDrawOutline(bool iIsOutline)
Definition: PieSliceObject.h:455
virtual bool ObjectInRectangle(const Rect2D &irRect)
#define NULL
Definition: Null.h:10
Definition: GraphObjectManager.h:37
float GetStartAngelRadian()
Definition: PieSliceObject.h:495
virtual void GenerateImageMap(ImageMap &iorImageMap)
Use four Int32 values to represent a 2D rectangle.
Definition: Rect2D.h:25
void SetBoundingRectType(BoundingRectType iBoundingRectType) const
Definition: PieSliceObject.h:450
Definition: Common.h:397
PieSliceObject(const TripleId &irTripleId, GraphObjectManager *ipManager, Int32 iExplode, float iStartAngle, float iEndAngle, float iRingPieFactor, bool iIsRingPie, bool iIs2DCircular, double iScale, const Point2D &irCenter, float iRadius, Int32 iMaxRadius, Int32 iDepth, bool iOneSeries, GraphCollectionObject *ipParentObject=NULL, bool iIsShown=true)