HGraph.h
Go to the documentation of this file.
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
13 #ifndef _HGraph_H
14 #define _HGraph_H
15 
16 #ifdef H_PACK_8
17 #pragma pack(push)
18 #pragma pack(8)
19 #endif
20 
21 #include "HUtility.h"
22 #include "HTools.h"
23 #include "varray.h"
24 
25 #define _PI 3.14159265358979323
26 
27 class HGraphAxis;
28 class HGraphLabelNode;
29 class HGraphDataSetNode;
30 class HGraphPieSlice;
31 
32 #ifdef WINDOWS_SYSTEM
33 template class MVO_API VArray< HGraphLabelNode *>;
34 template class MVO_API VArray< HGraphDataSetNode *>;
35 template class MVO_API VArray< HGraphPieSlice *>;
36 #endif
37 
40 {
41  X_Axis=1,
42  Y_Axis,
43  Z_Axis
44 };
45 
48 {
49  PointFormatCartesian=1,
50  PointFormatPolarDegrees,
51  PointFormatPolarRadians
52 };
53 
56 {
57  AxisScaleLinear=1,
58  AxisScaleLogarithmic
59 };
60 
63 {
64  GridTypeNone=1,
65  GridTypeRectangular,
66  GridTypePolar
67 };
68 
71 {
72  PlotTypeScatter=1,
73  PlotTypeLine,
74  PlotTypeBar,
75 };
76 
79 {
80  LegendEntryTypeLine=1,
81  LegendEntryTypeBox
82 };
83 
85 class MVO_API HGraphAxis
86 {
87 public:
88  HGraphAxis()
89  : axis_scale_factor(1.0)
90  , tick_frequency(1.0)
91  , tick_size(0.1)
92  , grid_frequency(1.0)
93  , grid_min(-4.0)
94  , grid_max(4.0)
95  , segment(INVALID_KEY)
96  , precision(-1)
97  , axis_scale(AxisScaleLinear)
98  , show_labels(true)
99  , visible(true)
100  {
101  min = -4.0;
102  max = 4.0;
103  }
104 
105  double min; //minimal point of axis
106  double max; //maximal point of axis
107 
108  double axis_scale_factor; //multiplier, or logarithmic base of the axis (based on axis_scale)
109  double tick_frequency; //how frequently ticks occur on the axis (respects the axis_scale setting)
110  double tick_size; //the size of the actual ticks
111 
112  double grid_frequency; //how frequently grid lines occur on this axis
113  double grid_min; //minimal point on the axis of the grid
114  double grid_max; //maximal point on the axis of the grid
115 
116  HC_KEY segment; //the location of the axis
117 
118  int precision; //the number of places after the decimal point to display
119 
120  HGraphAxisScale axis_scale; //is the axis linear or logarithmic?
121 
122  bool show_labels; //whether or not to label each tick
123  bool visible; //is the axis visible?
124 };
125 
127 class MVO_API HGraphLabelNode
128 {
129 public:
130  HC_KEY segment; //the segment housing the label
131  HC_KEY text_key; //the key of the label itself
132 };
133 
135 class MVO_API HGraphDataSetNode
136 {
137 public:
138  double bar_width; //the width of the bars to be drawn
139  HC_KEY segment; //location in the segment tree of the data
140  int data_size; //how many points are in the data set
141  HGraphPointFormat format; //format of point data
142  bool line_vis; //are the points connected by a polyline?
143  bool bar_vis; //visible in bar charts
144  bool polygon_vis; //the visibility of a colored region
145 };
146 
148 class MVO_API HGraphPieSlice
149 {
150 public:
151  double amount; //how much of the pie is in this slice.
152  HC_KEY segment; //the segment housing the slice
153  HC_KEY text_key; //the key of any label (if any);
154 };
155 
157 class MVO_API HGraphLegend
158 {
159 public:
160 HGraphLegend():segment(INVALID_KEY), title(INVALID_KEY) {entries.ReplaceAt(0,0);}
161 
162 # if _MSC_VER >= 1900
163 HGraphLegend(HGraphLegend &&) = delete;
164 # endif
165 
166 HC_KEY segment;
167 HC_KEY title;
168 VArray< HGraphLabelNode *> entries;
169 };
170 
172 class MVO_API HBaseGraph
173 {
174 public:
175 
181  HBaseGraph(HC_KEY plot_seg);
182 
186  virtual ~HBaseGraph();
187 
188 
194  void GetPlotTitle(char * title);
195 
201  void GetPlotUnicodeTitle(unsigned short * title);
202 
203 
209  virtual void SetPlotTitle(const char * title)=0;
210 
216  virtual void SetPlotUnicodeTitle(unsigned short * title)=0;
217 
223  virtual void GetPlotTitleColor(char * color);
224 
230  virtual void SetPlotTitleColor(const char * color);
231 
232 
238  void GetPlotTitleTextFont(char * font);
239 
245  void SetPlotTitleTextFont(const char * font);
246 
247 
253  HPoint GetPlotTitleLocation();
254 
260  void SetPlotTitleLocation(HPoint loc);
261 
262 
268  HPoint GetPlotOrigin();
269 
275  void SetPlotOrigin(HPoint origin);
276 
277 
283  bool GetFrameVisibility();
284 
290  void SetFrameVisibility(bool visible);
291 
292 
298  void GetFramePattern(char * pattern);
299 
305  void SetFramePattern(const char * pattern);
306 
307 
313  void GetFrameColor(char * color);
314 
320  void SetFrameColor(const char * color);
321 
322 
328  float GetFrameWeight();
329 
335  void SetFrameWeight(float weight);
336 
337 
349  int AddLabel(const char * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, float xvector=1.0,
350  float yvector=0.0, float zvector=0.0);
351 
363  int AddUnicodeLabel(const unsigned short * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian,
364  float xvector=1.0, float yvector=0.0, float zvector=0.0);
365 
371  void RemoveLabel(int label_id);
372 
373 
380  void GetLabelContents(int label_id, char * str);
381 
388  void GetLabelUnicodeContents(int label_id, unsigned short * str);
389 
390 
397  void SetLabelContents(int label_id, const char * str);
398 
405  void SetLabelUnicodeContents(int label_id, const unsigned short * str);
406 
407 
414  void SetLabelTextFont(int label_id, const char * font);
415 
422  void GetLabelTextFont(int label_id, char * font);
423 
430  void SetLabelTextColor(int label_id, const char * color);
431 
438  void GetLabelTextColor(int label_id, char * color);
439 
446  void SetLabelTextAlignment(int label_id, const char * alignment);
447 
454  void GetLabelTextAlignment(int label_id, char * alignment);
455 
463  void SetLabelLocation(int label_id, HPoint loc, HGraphPointFormat format=PointFormatCartesian);
464 
471  HPoint GetLabelLocation(int label_id);
472 
481  void SetLabelTextPath(int label_id, float xvector, float yvector, float zvector);
482 
483 
492  void GetLabelTextPath(int label_id, float *xvector, float *yvector, float *zvector);
493 
494 
501  void AddLegend(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
502 
506  void RemoveLegend();
507 
508 
514  void SetLegendTitle(const char * title);
515 
521  void GetLegendTitle(char * title);
522 
526  void RemoveLegendTitle();
527 
533  void SetLegendUnicodeTitle(const unsigned short * title);
534 
540  void GetLegendUnicodeTitle(unsigned short * title);
541 
542 
548  void SetLegendTitleTextFont(const char * font);
549 
555  void GetLegendTitleTextFont(char * font);
556 
557 
563  void SetLegendTextFont(const char * font);
564 
570  void GetLegendTextFont(char * font);
571 
580  int AddLegendEntry(const char * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
581 
590  int AddLegendUnicodeEntry(const unsigned short * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
591 
597  void RemoveLegendEntry(int entry_id);
598 
607  void GetLegendEntry(int entry_id, char * str, char * color, HGraphLegendEntryType * entry_type=0);
608 
617  void GetLegendUnicodeEntry(int entry_id, unsigned short * str, char * color, HGraphLegendEntryType * entry_type=0);
618 
619 
626  void SetLegendLocation(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
627 
633  HPoint GetLegendLocation();
634 
644  void ConvertPoints(unsigned int in_count, const HPoint in_points[], HGraphPointFormat in_system,
645  HPoint out_points[], HGraphPointFormat out_system);
646 
652  void PreserveData(bool preserve=true);
653 
661  void SetAutomaticUpdates(bool automatic=true);
662 
668  bool GetAutomaticUpdates();
669 
673  virtual void Update();
674 
675 protected:
676  HC_KEY m_plot_segment;
677  HPoint m_origin;
678  bool m_show_frame, m_preserve_data, m_automatic_updates, m_force_update;
679  HGraphLegend m_legend;
680 
681 
682  VArray< HGraphLabelNode *> m_labels;
683 
687  virtual void DrawFrame()=0;
688 
692  virtual void DrawLegend();
693 };
694 
696 class MVO_API HPlot2D : public HBaseGraph
697 {
698 public:
699 
706  HPlot2D(HC_KEY plot_seg, HGraphPlotType plot_type=PlotTypeScatter);
707 
711  virtual ~HPlot2D();
712 
718  void SetPlotTitle(const char * title);
719 
725  void SetPlotUnicodeTitle(unsigned short * title);
726 
727 
733  HGraphPlotType GetPlotType();
734 
740  void SetPlotOrigin(HPoint origin);
741 
742 
748  HGraphGridType GetGridType();
749 
755  void SetGridType(HGraphGridType gtype);
756 
757 
763  bool GetGridVisibility();
764 
770  void SetGridVisibility(bool value);
771 
777  void GetGridPattern(char * pattern);
778 
784  void SetGridPattern(const char * pattern);
785 
786 
792  void GetGridColor(char * color);
793 
799  void SetGridColor(const char * color);
800 
808  HGraphAxisScale GetAxisScale(HGraphAxisSelection axis, double * factor=0);
809 
817  void SetAxisScale(HGraphAxisSelection axis, HGraphAxisScale scale, double factor=0.0);
818 
826  void GetAxisRange(HGraphAxisSelection axis, double* min, double* max);
827 
835  void SetAxisRange(HGraphAxisSelection axis, double min, double max);
836 
837 
842  bool GetAxisVisibility(HGraphAxisSelection axis);
843 
850  void SetAxisVisibility(HGraphAxisSelection axis, bool vis);
851 
852 
859  void GetAxisColor(HGraphAxisSelection axis, char * color);
860 
867  void SetAxisColor(HGraphAxisSelection axis, const char * color);
868 
869 
876  float GetAxisWeight(HGraphAxisSelection axis);
877 
884  void SetAxisWeight(HGraphAxisSelection axis, float weight);
885 
886 
893  double GetAxisTickFrequency(HGraphAxisSelection axis);
894 
901  void SetAxisTickFrequency(HGraphAxisSelection axis, double freq);
902 
903 
910  int GetAxisPrecision(HGraphAxisSelection axis);
911 
918  void SetAxisPrecision(HGraphAxisSelection axis, int precision);
919 
926  double GetAxisTickSize(HGraphAxisSelection axis);
927 
934  void SetAxisTickSize(HGraphAxisSelection axis, double size);
935 
936 
943  double GetAxisGridFrequency(HGraphAxisSelection axis);
944 
951  void SetAxisGridFrequency(HGraphAxisSelection axis, double freq);
952 
960  void GetAxisGridRange(HGraphAxisSelection axis, double* min, double* max);
961 
969  void SetAxisGridRange(HGraphAxisSelection axis, double min, double max);
970 
975  bool GetAxisLabelVisibility(HGraphAxisSelection axis);
976 
983  void SetAxisLabelVisibility(HGraphAxisSelection axis, bool vis);
984 
985 
992  void GetAxisLabelTextFont(HGraphAxisSelection axis, char * font);
993 
1000  void SetAxisLabelTextFont(HGraphAxisSelection axis, const char * font);
1001 
1002 
1009  void GetAxisLabelTextColor(HGraphAxisSelection axis, char * color);
1010 
1017  void SetAxisLabelTextColor(HGraphAxisSelection axis, const char * color);
1018 
1019 
1028  void SetAxisLabelTextPath(HGraphAxisSelection axis, float xvector,
1029  float yvector, float zvector);
1030 
1031 
1040  void GetAxisLabelTextPath(HGraphAxisSelection axis, float *xvector,
1041  float *yvector, float *zvector);
1042 
1043 
1055  int AddDataSet(int points_count, const HPoint points[], HGraphPointFormat format=PointFormatCartesian,
1056  const HPoint colors[]=0);
1057 
1058 
1064  void RemoveDataSet(int data_set);
1065 
1066 
1073  int GetDataSetSize(int data_set);
1074 
1075 
1082  HGraphPointFormat GetDataSetFormat(int data_set);
1083 
1084 
1091  void GetDataSet(int data_set, HPoint points[]);
1092 
1104  void ReplaceDataSet(int data_set, int points_count, const HPoint points[],
1105  HGraphPointFormat format=PointFormatCartesian, const HPoint colors[]=0);
1106 
1107 
1114  void SetPointColor(int data_set, const char * color);
1115 
1122  void GetPointColor(int data_set, char * color);
1123 
1124 
1131  void SetPointSymbol(int data_set, const char * symbol);
1132 
1139  void GetPointSymbol(int data_set, char * symbol);
1140 
1141 
1148  void SetPointSize(int data_set, double size);
1149 
1156  float GetPointSize(int data_set);
1157 
1158 
1163  bool GetPointVisibility(int data_set);
1164 
1171  void SetPointVisibility(int data_set, bool vis);
1172 
1177  bool GetLineVisibility(int data_set);
1178 
1185  void SetLineVisibility(int data_set, bool vis);
1186 
1187 
1194  void SetLinePattern(int data_set, const char * pattern);
1195 
1202  void GetLinePattern(int data_set, char * pattern);
1203 
1210  void SetLineColor(int data_set, const char * color);
1211 
1218  void GetLineColor(int data_set, char * color);
1219 
1226  float GetLineWeight(int data_set);
1227 
1234  void SetLineWeight(int data_set, float weight);
1235 
1240  bool GetBarVisibility(int data_set);
1241 
1248  void SetBarVisibility(int data_set, bool vis);
1249 
1250 
1257  void SetBarColorMap(int data_set, const char * map);
1258 
1265  void GetBarColorMap(int data_set, char * map);
1266 
1267 
1276  void SetBarColorMapByValue(int data_set, int count, const HPoint values[], const char * color_space=0);
1277 
1286  void GetBarColorMapByValue(int data_set, int * count, HPoint values[], char * color_space);
1287 
1294  double GetBarWidth(int data_set);
1295 
1302  void SetBarWidth(int data_set, double width);
1303 
1308  bool GetBarEdgeVisibility(int data_set);
1309 
1316  void SetBarEdgeVisibility(int data_set, bool vis);
1317 
1318 
1323  bool GetPolygonVisibility(int data_set);
1324 
1325 
1333  void SetPolygonVisibility(int data_set, bool vis);
1334 
1342  void GetPolygonColor(int data_set, char * color);
1343 
1350  void SetPolygonColor(int data_set, const char * color);
1351 
1355  virtual void Update();
1356 
1360  double GetAspectRatio();
1361 
1368  void SetAspectRatio(double ratio);
1369 
1373  void UnSetAspectRatio();
1374 
1375 protected:
1376  HGraphPlotType m_plot_type;
1377  HGraphGridType m_grid_type;
1378  HGraphAxis m_x_axis, m_y_axis;
1379  double m_aspect_ratio;
1380 
1381  VArray< HGraphDataSetNode *> m_points;
1382 
1386  virtual void DrawAxes();
1387 
1391  virtual void DrawGrid();
1392 
1396  virtual void DrawFrame();
1397 
1403  virtual void DrawData(int data_set);
1404 
1405 };
1406 
1408 class MVO_API HPieChart: public HBaseGraph
1409 {
1410 public:
1411 
1417  HPieChart(HC_KEY plot_seg);
1418 
1422  virtual ~HPieChart();
1423 
1429  void SetPlotTitle(const char * title);
1430 
1436  void SetPlotUnicodeTitle(unsigned short * title);
1437 
1438 
1445  int AddPieSlice(double size);
1446 
1447 
1453  void RemovePieSlice(int slice_id);
1454 
1460  void SetPieColorMap(const char * map);
1461 
1467  void GetPieColorMap(char * map);
1468 
1476  void SetPieColorMapByValue(int count, const HPoint values[], const char * color_space=0);
1477 
1485  void GetPieColorMapByValue(int * count, HPoint values[], char * color_space);
1486 
1493  void AddPieSliceLabel(int slice_id, const char * str);
1494 
1501  void AddPieSliceUnicodeLabel(int slice_id, const unsigned short * str);
1502 
1508  void RemovePieSliceLabel(int slice_id);
1509 
1516  void GetPieSliceLabelContents(int slice_id, char * str);
1517 
1524  void GetPieSliceUnicodeLabelContents(int slice_id, unsigned short * str);
1525 
1532  void SetPieSliceLabelTextFont(int slice_id, const char * font);
1533 
1540  void GetPieSliceLabelTextFont(int slice_id, char * font);
1541 
1542 
1548  bool GetPieEdgeVisibility();
1549 
1555  void SetPieEdgeVisibility(bool vis);
1556 
1557 
1563  void GetPieEdgeColor(char * color);
1564 
1570  void SetPieEdgeColor(const char * color);
1571 
1577  double GetPieRadius();
1578 
1584  void SetPieRadius(double radius);
1585 
1591  void SetPlotOrigin(HPoint origin);
1592 
1596  virtual void Update();
1597 
1598 protected:
1599  VArray< HGraphPieSlice *> m_pie;
1600  double m_pie_total;
1601  double m_scale;
1602 
1606  virtual void DrawFrame();
1607 
1611  virtual void DrawPie();
1612 };
1613 
1614 
1615 
1616 #ifdef H_PACK_8
1617 #pragma pack(pop)
1618 #endif
1619 
1620 #endif
1621 
1622 
1623 
1624 
1625 
1626 
1627 
1628 
1629 
1630 
1631 
1632 
1633 
1634 
1635 
1636 
1637 
1638 
1639 
1640 
1641 
1642 
1643 
1644 
1645 
1646 
1647 
1648 
1649 
1650 
1651 
1652 
1653 
1654 
1655 
1656 
Provides plotting capabilities for most 2d graphs including bar charts, line graphs, scatter plots, or any combination of these.
Definition: HGraph.h:696
Definition: HGraph.h:135
Definition: HGraph.h:127
HGraphGridType
Definition: HGraph.h:62
HGraphLegendEntryType
Definition: HGraph.h:78
HGraphPointFormat
Definition: HGraph.h:47
Definition: HGraph.h:172
HGraphAxisScale
Definition: HGraph.h:55
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:121
Definition: HGraph.h:148
Definition: HGraph.h:85
Definition: HGraph.h:157
HGraphAxisSelection
Definition: HGraph.h:39
Provides simple pie chart creation tools.
Definition: HGraph.h:1408
HGraphPlotType
Definition: HGraph.h:70