Mobile API Reference  MicroStrategy 2019
Plot.h
Go to the documentation of this file.
1 //====================================================================
2 // Filename: Plot.h
3 // Date: 2008-05-21
4 // Authors: Bing Huang
5 
6 // Copyright (C) 1997-2008 MicroStrategy Incorporated
7 // All rights reserved
8 //====================================================================
9 
10 #ifndef MsiChart_Plot_h
11 #define MsiChart_Plot_h
12 
13 #include "../Dataset.h"
14 #include "Legend.h"
15 
16 #include "GraphObjectManager.h"
17 #include "TrendLineObject.h"
18 #include "DataLabelManager.h"
19 
20 namespace MsiChart
21 {
22  //enumerations and structs
23  typedef enum
24  {
25  TLI_Y1 = 0,
26  TLI_Y2 = 1,
29 
31  {
33  , mOrder(3), mPeriod(2), mShowEquation(false), mShowCoefficients(false)
35  {}
36 
42  void GetOptions(Int32 iPropertyId, VARIANT* opValue) const;
43 
52  };
53 
54  typedef enum
55  {
56  VA_Y1 = 0,
57  VA_Y2 = 1,
58  VA_BOTH = 2,
62 
63  //pre-declaration
64  class TextObject;
65  class TrendLineObject;
66 
67  /*
68  virtual base class for all plot classes
69  */
70  class Plot : public GraphObjectManager
71  {
72  public:
74 
75  //ctor & dtor
76  Plot(const TripleId& irTripleId, GraphObjectManager* ipManager, const Rect2D& irDataArea);
77  virtual ~Plot();
78 
79  //Pure virtual functions from GraphObjectManager
80  virtual void Draw();
81  virtual void GenerateView();
82  virtual void GenerateImageMap(ImageMap &iorImageMap);
83 
84  //Virtual functions from GraphObjectManager
85  virtual GraphObject::Ptr OnPointDetection(const Point2D& irCursor) const;
86  virtual void OnRectangleSelection(const Rect2D& irRect, std::vector<GraphObject::Ptr>& iorSelectedObjects) const;
87 
88  virtual bool GetToolTipData(Int32 iSeriesID, Int32 iGroupID, double& orValue, double& orPercentValue, Int32 iOffset = 0);
89 
90  virtual bool GetGroupSpace(std::vector<Int32>& orVect, Int32 iGroupIndex); //< voice over
91  virtual Int32 GetMaxElementRadius(); //< graph matrix
92  virtual void RefreshValueAxis(const std::map<Int32, std::pair<double, double> >& irScaleSet, const Rect2D& irRect);
93  virtual bool GetMaxElementOffsetClippedByBoundary(bool iIsOnXAxis, double& orLowOffset, double& orHighOffset);
94  virtual bool GetGMPiePositon(Point2D& orCood, double iXInput, double iYInput, Int32 iXSubIndex = 0, Int32 iYSubIndex = 0, Int32 iXSectionCount = 1, Int32 iYSectionCount = 1,Int32 iRadius = 2);
95 
97  virtual void DrawTrendLinesAndEquations();
102  void GetDataArea(Rect2D& orDataArea) const;
103 
108  void SetDataArea(const Rect2D& irDataArea);
109 
114  Dataset::Ptr GetDataset() const;
115 
120  Legend::Ptr GetLegend() const;
121 
126  void SetDataset(Dataset::Ptr iDataSetPtr);
127 
132  void SetLegend(Legend::Ptr iLegendPtr);
133 
138  void AddSeries(Int32 iSeriesId);
139 
140 
147  Int32 GetSeriesIndexByID(Int32 iSeriesId) const;
148 
159  void MoveLabel(TextObject* ipTextObject, const Point2D& irTopRight, const Point2D& irBottomLeft, bool iIsReverse, bool iIsVertical, EnumDSSGraphDataTextPosition iLabelLocation) const;
160  /*void MoveLabel(TextObject* ipTextObject, const Point2D& irTopRight, const Point2D& irBottomLeft, bool iIsReverse, bool iIsVertical, EnumDSSGraphDataTextPosition iLabelLocation, bool iSmart) const;
161  bool IsLabelClipped(TextObject* ipTextObject, bool iIsVertical, EnumDSSGraphDataTextPosition iOriginalPosition, EnumDSSGraphDataTextPosition& iorBestPosition) const;*/
162 
171  void AddLegendMarkerToCollection(Int32 iSeriesId, GraphCollectionObject* ipRiserCollection, bool iIsLineCollection = false, bool iIsShownMarker = true, unsigned char iMarkerShape = DssGraphMarkerShapeRectangle, bool iIsShownLine = true, bool iIsLineVertical = false) const;
172 
188  void CreateTrendLine(const std::vector<double>& irX, const std::vector<double>& irY, const TripleId& irTripleId,
189  GraphObjectManager* ipManager, GraphCollectionObject* ipParentObject, Axis* ipXAxis, Axis* ipYAxis,
190  GraphTrendLineOptions* ipTrendLineOptions, const Rect2D& irDataArea, bool iIsVertical, const Point2D& irDepthOffset, bool iIsY2 = false);
191 
197  void AdjustTrendLineEquation(Rect2D& irRect, EnumTrendLineIndex iIndex);
198 
204  void DrawTrendLinesAndEquations(Rect2D& irClipRect, bool iIsY2 = false);
205 
210 
215 
216  bool HasTrendLines() const;
217 
219 
221 
222  //kai;2016/Jul/26;DE35637;fix GM referenceline issue, change to metric to decide whether to draw
223  bool GetVAMetricIndexDrawn(Int32 iValueMetricIndex);
224  void SetVAMetricIndexDrawn(Int32 iValueMetricIndex);
225  /*
226  bool GetVAIndexDrawn(Int32 iValueAxis);
227  void SetVAIndexDrawn(Int32 iValueAxis, bool iDrawn);
228  */
229  protected:
235  void LoadTrendLineProperties(Int32 iSeriesId, GraphTrendLineOptions& iorTrendLineOption) const;
236 
243  void LoadValueAxisInfo(Int32 iSeriesIndex, bool iIsDualAxes, EnumValueAxis& orValueAxis) const;
244 
247 
248  std::vector<Int32> mGroupID;
249  std::vector<Int32> mSeriesId;
251 
252  //use to put trend line object.
253  std::vector<TrendLineObject::Ptr> mTrendLines[2];
254 
255  //use to put the objects that should be draw after trend line.
256  //for example, custom line and series text labels.
257  std::vector<GraphObject::Ptr> mPostTrendLineObjects;
258 
259  // GM Text objects manager including data label and reference line label.
261 
262  // RefLineSupport
263  bool mVAIndexDrawn[5];
264  std::set<Int32> mVAIndexDrawnSet;
265 
266  private:
272  void hUpdateTrendLineFormatLine(TrendLineObject::Ptr iTrendLinePtr);
273  };
274 
276  {
277  return mDatasetPtr;
278  }
279 
281  {
282  return mLegendPtr;
283  }
284 
285  inline void Plot::SetLegend(Legend::Ptr iLegendPtr)
286  {
287  mLegendPtr = iLegendPtr;
288  }
289 
290  inline void Plot::SetDataset(Dataset::Ptr iDataSetPtr)
291  {
292  mDatasetPtr = iDataSetPtr;
293  }
294 
295  inline void Plot::AddSeries(Int32 iSeriesId)
296  {
297  mSeriesId.push_back(iSeriesId);
298  }
299 
300  inline bool Plot::HasTrendLines() const
301  {
302  return !mTrendLines[0].empty() || !mTrendLines[1].empty();
303  }
304 
306  {
307  if (mLabelManager.IsNull()) {
309  }
310  return mLabelManager;
311  }
312  /*
313  inline bool Plot::GetVAIndexDrawn(Int32 iValueAxisIndex)
314  {
315  return mVAIndexDrawn[iValueAxisIndex];
316  }
317 
318  inline void Plot::SetVAIndexDrawn(Int32 iValueAxisIndex, bool iDrawn)
319  {
320  mVAIndexDrawn[iValueAxisIndex] = iDrawn;
321  }
322  */
323 
324  inline bool Plot::GetVAMetricIndexDrawn(Int32 iValueMetricIndex)
325  {
326  return mVAIndexDrawnSet.find(iValueMetricIndex) != mVAIndexDrawnSet.end();
327  }
328 
329  inline void Plot::SetVAMetricIndexDrawn(Int32 iValueMetricIndex)
330  {
331  mVAIndexDrawnSet.insert(iValueMetricIndex);
332  }
333 
334 }
335 
336 #endif
bool IsNull() const
Definition: SmartBase.h:83
ChartContext::Ptr mChartContextPtr
The drawing context instance. Only one object in a chart.
Definition: GraphObjectManager.h:273
Definition: DataLabelManager.h:142
bool mShowCoefficients
Definition: Plot.h:48
Definition: Plot.h:25
void LoadValueAxisInfo(Int32 iSeriesIndex, bool iIsDualAxes, EnumValueAxis &orValueAxis) const
void GetOptions(Int32 iPropertyId, VARIANT *opValue) const
void SetDataset(Dataset::Ptr iDataSetPtr)
Definition: Plot.h:290
EnumDSSGraphRegressionType mRegressionType
Definition: Plot.h:44
Legend::Ptr GetLegend() const
Definition: Plot.h:280
bool HasTrendLines() const
Definition: Plot.h:300
Dataset::Ptr mDatasetPtr
Definition: Plot.h:245
void SetVAMetricIndexDrawn(Int32 iValueMetricIndex)
Definition: Plot.h:329
Definition: Plot.h:57
void CreateTrendLine(const std::vector< double > &irX, const std::vector< double > &irY, const TripleId &irTripleId, GraphObjectManager *ipManager, GraphCollectionObject *ipParentObject, Axis *ipXAxis, Axis *ipYAxis, GraphTrendLineOptions *ipTrendLineOptions, const Rect2D &irDataArea, bool iIsVertical, const Point2D &irDepthOffset, bool iIsY2=false)
virtual bool GetMaxElementOffsetClippedByBoundary(bool iIsOnXAxis, double &orLowOffset, double &orHighOffset)
Definition: GraphCollectionObject.h:19
EnumValueAxis
Definition: Plot.h:54
virtual void GenerateImageMap(ImageMap &iorImageMap)
bool GetVAMetricIndexDrawn(Int32 iValueMetricIndex)
Definition: Plot.h:324
std::vector< GraphObject::Ptr > mPostTrendLineObjects
Definition: Plot.h:257
virtual bool GetGroupSpace(std::vector< Int32 > &orVect, Int32 iGroupIndex)
Plot(const TripleId &irTripleId, GraphObjectManager *ipManager, const Rect2D &irDataArea)
Definition: Dataset.h:198
void MoveLabel(TextObject *ipTextObject, const Point2D &irTopRight, const Point2D &irBottomLeft, bool iIsReverse, bool iIsVertical, EnumDSSGraphDataTextPosition iLabelLocation) const
bool mUserSeriesGraphColor
Definition: Plot.h:49
EnumDSSGraphDataTextPosition
Definition: DSSIPhoneEnums.h:1836
Definition: DSSIPhoneEnums.h:1982
DataLabelManager::Ptr mLabelManager
Definition: Plot.h:260
bool mUseSeasonal
Definition: Plot.h:50
#define Int32
Definition: BasicTypes.h:20
Definition: Axis.h:123
virtual Int32 GetMaxElementRadius()
void GetDataArea(Rect2D &orDataArea) const
Definition: TextObject.h:181
virtual void RefreshValueAxis(const std::map< Int32, std::pair< double, double > > &irScaleSet, const Rect2D &irRect)
Legend::Ptr mLegendPtr
Definition: Plot.h:246
MSynch::SmartPtr< Plot > Ptr
Definition: Plot.h:73
void AddLegendMarkerToCollection(Int32 iSeriesId, GraphCollectionObject *ipRiserCollection, bool iIsLineCollection=false, bool iIsShownMarker=true, unsigned char iMarkerShape=DssGraphMarkerShapeRectangle, bool iIsShownLine=true, bool iIsLineVertical=false) const
void AddTrendLineAnadRefLine(GraphObject::Ptr iLine)
Definition: Plot.h:26
bool mShowEquation
Definition: Plot.h:47
Definition: SmartPtr.h:38
Rect2D mDataArea
Definition: Plot.h:250
virtual void GenerateView()
Int32 mPeriod
Definition: Plot.h:46
Definition: Plot.h:60
void LoadTrendLineProperties(Int32 iSeriesId, GraphTrendLineOptions &iorTrendLineOption) const
virtual void OnRectangleSelection(const Rect2D &irRect, std::vector< GraphObject::Ptr > &iorSelectedObjects) const
std::vector< Int32 > mSeriesId
Definition: Plot.h:249
bool mIsExpomentialBaseNearOne
Definition: Plot.h:51
void DrawPostTrendLineObjects()
Definition: ABLPlot.h:21
std::vector< AreaRec * > ImageMap
Definition: ImageMap.h:99
Definition: Plot.h:56
std::vector< TrendLineObject::Ptr > mTrendLines[2]
Definition: Plot.h:253
Dataset::Ptr GetDataset() const
Definition: Plot.h:275
void AdjustTrendLineEquation(Rect2D &irRect, EnumTrendLineIndex iIndex)
EnumTrendLineIndex
Definition: Plot.h:23
Definition: Msi_variant.h:147
EnumDSSGraphRegressionType
Definition: DSSIPhoneEnums.h:1902
bool mVAIndexDrawn[5]
Definition: Plot.h:263
GraphObjectManager * mpManager
The manager object which created the current object.
Definition: GraphObjectManager.h:276
Definition: Plot.h:59
std::vector< Int32 > mGroupID
Definition: Plot.h:248
void SetDataArea(const Rect2D &irDataArea)
std::set< Int32 > mVAIndexDrawnSet
Definition: Plot.h:264
virtual void Draw()
void GeneratePostTrendLineViews()
GraphTrendLineOptions()
Definition: Plot.h:32
Definition: Plot.h:27
Definition: DSSIPhoneEnums.h:1904
Int32 mOrder
Definition: Plot.h:45
virtual bool GetToolTipData(Int32 iSeriesID, Int32 iGroupID, double &orValue, double &orPercentValue, Int32 iOffset=0)
Definition: Plot.h:70
virtual bool GetGMPiePositon(Point2D &orCood, double iXInput, double iYInput, Int32 iXSubIndex=0, Int32 iYSubIndex=0, Int32 iXSectionCount=1, Int32 iYSectionCount=1, Int32 iRadius=2)
Definition: GraphObjectManager.h:37
Use four Int32 values to represent a 2D rectangle.
Definition: Rect2D.h:25
virtual ~Plot()
Definition: Plot.h:58
void SetLegend(Legend::Ptr iLegendPtr)
Definition: Plot.h:285
Definition: Plot.h:30
virtual void DrawTrendLinesAndEquations()
Draw trendlines and equations.
DataLabelManager::Ptr GetDataLabelManager()
Definition: Plot.h:305
Definition: Common.h:397
Int32 GetSeriesIndexByID(Int32 iSeriesId) const
virtual GraphObject::Ptr OnPointDetection(const Point2D &irCursor) const
void AddSeries(Int32 iSeriesId)
Definition: Plot.h:295