Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HGraph.h
Go to the documentation of this file.
1 // Copyright (c) 1998-2014 by 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 HC_KEY segment;
163 HC_KEY title;
164 VArray< HGraphLabelNode *> entries;
165 };
166 
168 class MVO_API HBaseGraph
169 {
170 public:
171 
177  HBaseGraph(HC_KEY plot_seg);
178 
182  virtual ~HBaseGraph();
183 
184 
190  void GetPlotTitle(char * title);
191 
197  void GetPlotUnicodeTitle(unsigned short * title);
198 
199 
205  virtual void SetPlotTitle(const char * title)=0;
206 
212  virtual void SetPlotUnicodeTitle(unsigned short * title)=0;
213 
219  virtual void GetPlotTitleColor(char * color);
220 
226  virtual void SetPlotTitleColor(const char * color);
227 
228 
234  void GetPlotTitleTextFont(char * font);
235 
241  void SetPlotTitleTextFont(const char * font);
242 
243 
249  HPoint GetPlotTitleLocation();
250 
256  void SetPlotTitleLocation(HPoint loc);
257 
258 
264  HPoint GetPlotOrigin();
265 
271  void SetPlotOrigin(HPoint origin);
272 
273 
279  bool GetFrameVisibility();
280 
286  void SetFrameVisibility(bool visible);
287 
288 
294  void GetFramePattern(char * pattern);
295 
301  void SetFramePattern(const char * pattern);
302 
303 
309  void GetFrameColor(char * color);
310 
316  void SetFrameColor(const char * color);
317 
318 
324  float GetFrameWeight();
325 
331  void SetFrameWeight(float weight);
332 
333 
345  int AddLabel(const char * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, float xvector=1.0,
346  float yvector=0.0, float zvector=0.0);
347 
359  int AddUnicodeLabel(const unsigned short * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian,
360  float xvector=1.0, float yvector=0.0, float zvector=0.0);
361 
367  void RemoveLabel(int label_id);
368 
369 
376  void GetLabelContents(int label_id, char * str);
377 
384  void GetLabelUnicodeContents(int label_id, unsigned short * str);
385 
386 
393  void SetLabelContents(int label_id, const char * str);
394 
401  void SetLabelUnicodeContents(int label_id, const unsigned short * str);
402 
403 
410  void SetLabelTextFont(int label_id, const char * font);
411 
418  void GetLabelTextFont(int label_id, char * font);
419 
426  void SetLabelTextColor(int label_id, const char * color);
427 
434  void GetLabelTextColor(int label_id, char * color);
435 
442  void SetLabelTextAlignment(int label_id, const char * alignment);
443 
450  void GetLabelTextAlignment(int label_id, char * alignment);
451 
459  void SetLabelLocation(int label_id, HPoint loc, HGraphPointFormat format=PointFormatCartesian);
460 
467  HPoint GetLabelLocation(int label_id);
468 
477  void SetLabelTextPath(int label_id, float xvector, float yvector, float zvector);
478 
479 
488  void GetLabelTextPath(int label_id, float *xvector, float *yvector, float *zvector);
489 
490 
497  void AddLegend(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
498 
502  void RemoveLegend();
503 
504 
510  void SetLegendTitle(const char * title);
511 
517  void GetLegendTitle(char * title);
518 
522  void RemoveLegendTitle();
523 
529  void SetLegendUnicodeTitle(const unsigned short * title);
530 
536  void GetLegendUnicodeTitle(unsigned short * title);
537 
538 
544  void SetLegendTitleTextFont(const char * font);
545 
551  void GetLegendTitleTextFont(char * font);
552 
553 
559  void SetLegendTextFont(const char * font);
560 
566  void GetLegendTextFont(char * font);
567 
576  int AddLegendEntry(const char * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
577 
586  int AddLegendUnicodeEntry(const unsigned short * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
587 
593  void RemoveLegendEntry(int entry_id);
594 
603  void GetLegendEntry(int entry_id, char * str, char * color, HGraphLegendEntryType * entry_type=0);
604 
613  void GetLegendUnicodeEntry(int entry_id, unsigned short * str, char * color, HGraphLegendEntryType * entry_type=0);
614 
615 
622  void SetLegendLocation(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
623 
629  HPoint GetLegendLocation();
630 
640  void ConvertPoints(unsigned int in_count, const HPoint *in_points, HGraphPointFormat in_system,
641  HPoint *out_points, HGraphPointFormat out_system);
642 
648  void PreserveData(bool preserve=true);
649 
657  void SetAutomaticUpdates(bool automatic=true);
658 
664  bool GetAutomaticUpdates();
665 
669  virtual void Update();
670 
671 protected:
672  HC_KEY m_plot_segment;
673  HPoint m_origin;
674  bool m_show_frame, m_preserve_data, m_automatic_updates, m_force_update;
675  HGraphLegend m_legend;
676 
677 
678  VArray< HGraphLabelNode *> m_labels;
679 
683  virtual void DrawFrame()=0;
684 
688  virtual void DrawLegend();
689 };
690 
692 class MVO_API HPlot2D : public HBaseGraph
693 {
694 public:
695 
702  HPlot2D(HC_KEY plot_seg, HGraphPlotType plot_type=PlotTypeScatter);
703 
707  virtual ~HPlot2D();
708 
714  void SetPlotTitle(const char * title);
715 
721  void SetPlotUnicodeTitle(unsigned short * title);
722 
723 
729  HGraphPlotType GetPlotType();
730 
736  void SetPlotOrigin(HPoint origin);
737 
738 
744  HGraphGridType GetGridType();
745 
751  void SetGridType(HGraphGridType gtype);
752 
753 
759  bool GetGridVisibility();
760 
766  void SetGridVisibility(bool value);
767 
773  void GetGridPattern(char * pattern);
774 
780  void SetGridPattern(const char * pattern);
781 
782 
788  void GetGridColor(char * color);
789 
795  void SetGridColor(const char * color);
796 
804  HGraphAxisScale GetAxisScale(HGraphAxisSelection axis, double * factor=0);
805 
813  void SetAxisScale(HGraphAxisSelection axis, HGraphAxisScale scale, double factor=0.0);
814 
822  void GetAxisRange(HGraphAxisSelection axis, double* min, double* max);
823 
831  void SetAxisRange(HGraphAxisSelection axis, double min, double max);
832 
833 
838  bool GetAxisVisibility(HGraphAxisSelection axis);
839 
846  void SetAxisVisibility(HGraphAxisSelection axis, bool vis);
847 
848 
855  void GetAxisColor(HGraphAxisSelection axis, char * color);
856 
863  void SetAxisColor(HGraphAxisSelection axis, const char * color);
864 
865 
872  float GetAxisWeight(HGraphAxisSelection axis);
873 
880  void SetAxisWeight(HGraphAxisSelection axis, float weight);
881 
882 
889  double GetAxisTickFrequency(HGraphAxisSelection axis);
890 
897  void SetAxisTickFrequency(HGraphAxisSelection axis, double freq);
898 
899 
906  int GetAxisPrecision(HGraphAxisSelection axis);
907 
914  void SetAxisPrecision(HGraphAxisSelection axis, int precision);
915 
922  double GetAxisTickSize(HGraphAxisSelection axis);
923 
930  void SetAxisTickSize(HGraphAxisSelection axis, double size);
931 
932 
939  double GetAxisGridFrequency(HGraphAxisSelection axis);
940 
947  void SetAxisGridFrequency(HGraphAxisSelection axis, double freq);
948 
956  void GetAxisGridRange(HGraphAxisSelection axis, double* min, double* max);
957 
965  void SetAxisGridRange(HGraphAxisSelection axis, double min, double max);
966 
971  bool GetAxisLabelVisibility(HGraphAxisSelection axis);
972 
979  void SetAxisLabelVisibility(HGraphAxisSelection axis, bool vis);
980 
981 
988  void GetAxisLabelTextFont(HGraphAxisSelection axis, char * font);
989 
996  void SetAxisLabelTextFont(HGraphAxisSelection axis, const char * font);
997 
998 
1005  void GetAxisLabelTextColor(HGraphAxisSelection axis, char * color);
1006 
1013  void SetAxisLabelTextColor(HGraphAxisSelection axis, const char * color);
1014 
1015 
1024  void SetAxisLabelTextPath(HGraphAxisSelection axis, float xvector,
1025  float yvector, float zvector);
1026 
1027 
1036  void GetAxisLabelTextPath(HGraphAxisSelection axis, float *xvector,
1037  float *yvector, float *zvector);
1038 
1039 
1051  int AddDataSet(int points_count, const HPoint *points, HGraphPointFormat format=PointFormatCartesian,
1052  const HPoint *colors=0);
1053 
1054 
1060  void RemoveDataSet(int data_set);
1061 
1062 
1069  int GetDataSetSize(int data_set);
1070 
1071 
1078  HGraphPointFormat GetDataSetFormat(int data_set);
1079 
1080 
1087  void GetDataSet(int data_set, HPoint *points);
1088 
1100  void ReplaceDataSet(int data_set, int points_count, const HPoint *points,
1101  HGraphPointFormat format=PointFormatCartesian, const HPoint *colors=0);
1102 
1103 
1110  void SetPointColor(int data_set, const char * color);
1111 
1118  void GetPointColor(int data_set, char * color);
1119 
1120 
1127  void SetPointSymbol(int data_set, const char * symbol);
1128 
1135  void GetPointSymbol(int data_set, char * symbol);
1136 
1137 
1144  void SetPointSize(int data_set, double size);
1145 
1152  float GetPointSize(int data_set);
1153 
1154 
1159  bool GetPointVisibility(int data_set);
1160 
1167  void SetPointVisibility(int data_set, bool vis);
1168 
1173  bool GetLineVisibility(int data_set);
1174 
1181  void SetLineVisibility(int data_set, bool vis);
1182 
1183 
1190  void SetLinePattern(int data_set, const char * pattern);
1191 
1198  void GetLinePattern(int data_set, char * pattern);
1199 
1206  void SetLineColor(int data_set, const char * color);
1207 
1214  void GetLineColor(int data_set, char * color);
1215 
1222  float GetLineWeight(int data_set);
1223 
1230  void SetLineWeight(int data_set, float weight);
1231 
1236  bool GetBarVisibility(int data_set);
1237 
1244  void SetBarVisibility(int data_set, bool vis);
1245 
1246 
1253  void SetBarColorMap(int data_set, const char * map);
1254 
1261  void GetBarColorMap(int data_set, char * map);
1262 
1263 
1272  void SetBarColorMapByValue(int data_set, int count, const HPoint * values, const char * color_space=0);
1273 
1282  void GetBarColorMapByValue(int data_set, int * count, HPoint * values, char * color_space);
1283 
1290  double GetBarWidth(int data_set);
1291 
1298  void SetBarWidth(int data_set, double width);
1299 
1304  bool GetBarEdgeVisibility(int data_set);
1305 
1312  void SetBarEdgeVisibility(int data_set, bool vis);
1313 
1314 
1319  bool GetPolygonVisibility(int data_set);
1320 
1321 
1329  void SetPolygonVisibility(int data_set, bool vis);
1330 
1338  void GetPolygonColor(int data_set, char * color);
1339 
1346  void SetPolygonColor(int data_set, const char * color);
1347 
1351  virtual void Update();
1352 
1356  double GetAspectRatio();
1357 
1364  void SetAspectRatio(double ratio);
1365 
1369  void UnSetAspectRatio();
1370 
1371 protected:
1372  HGraphPlotType m_plot_type;
1373  HGraphGridType m_grid_type;
1374  HGraphAxis m_x_axis, m_y_axis;
1375  double m_aspect_ratio;
1376 
1377  VArray< HGraphDataSetNode *> m_points;
1378 
1382  virtual void DrawAxes();
1383 
1387  virtual void DrawGrid();
1388 
1392  virtual void DrawFrame();
1393 
1399  virtual void DrawData(int data_set);
1400 
1401 };
1402 
1404 class MVO_API HPieChart: public HBaseGraph
1405 {
1406 public:
1407 
1413  HPieChart(HC_KEY plot_seg);
1414 
1418  virtual ~HPieChart();
1419 
1425  void SetPlotTitle(const char * title);
1426 
1432  void SetPlotUnicodeTitle(unsigned short * title);
1433 
1434 
1441  int AddPieSlice(double size);
1442 
1443 
1449  void RemovePieSlice(int slice_id);
1450 
1456  void SetPieColorMap(const char * map);
1457 
1463  void GetPieColorMap(char * map);
1464 
1472  void SetPieColorMapByValue(int count, const HPoint * values, const char * color_space=0);
1473 
1481  void GetPieColorMapByValue(int * count, HPoint * values, char * color_space);
1482 
1489  void AddPieSliceLabel(int slice_id, const char * str);
1490 
1497  void AddPieSliceUnicodeLabel(int slice_id, const unsigned short * str);
1498 
1504  void RemovePieSliceLabel(int slice_id);
1505 
1512  void GetPieSliceLabelContents(int slice_id, char * str);
1513 
1520  void GetPieSliceUnicodeLabelContents(int slice_id, unsigned short * str);
1521 
1528  void SetPieSliceLabelTextFont(int slice_id, const char * font);
1529 
1536  void GetPieSliceLabelTextFont(int slice_id, char * font);
1537 
1538 
1544  bool GetPieEdgeVisibility();
1545 
1551  void SetPieEdgeVisibility(bool vis);
1552 
1553 
1559  void GetPieEdgeColor(char * color);
1560 
1566  void SetPieEdgeColor(const char * color);
1567 
1573  double GetPieRadius();
1574 
1580  void SetPieRadius(double radius);
1581 
1587  void SetPlotOrigin(HPoint origin);
1588 
1592  virtual void Update();
1593 
1594 protected:
1595  VArray< HGraphPieSlice *> m_pie;
1596  double m_pie_total;
1597  double m_scale;
1598 
1602  virtual void DrawFrame();
1603 
1607  virtual void DrawPie();
1608 };
1609 
1610 
1611 
1612 #ifdef H_PACK_8
1613 #pragma pack(pop)
1614 #endif
1615 
1616 #endif
1617 
1618 
1619 
1620 
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 
Provides plotting capabilities for most 2d graphs including bar charts, line graphs, scatter plots, or any combination of these.
Definition: HGraph.h:692
Definition: HGraph.h:135
Definition: HGraph.h:127
HGraphGridType
Definition: HGraph.h:62
HGraphLegendEntryType
Definition: HGraph.h:78
HGraphPointFormat
Definition: HGraph.h:47
#define HC_KEY
Definition: HGraph.h:168
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:1404
HGraphPlotType
Definition: HGraph.h:70