Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HGraph.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2000 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: 721105c5937bb5853371c2578fb25a3f4898aa89 $
13 //
14 
18 #ifndef _HGraph_H
19 #define _HGraph_H
20 
21 #ifdef H_PACK_8
22 #pragma pack(push)
23 #pragma pack(8)
24 #endif
25 
26 #include "HUtility.h"
27 #include "HTools.h"
28 #include "varray.h"
29 
30 #define _PI 3.14159265358979323
31 
32 class HGraphAxis;
33 class HGraphLabelNode;
34 class HGraphDataSetNode;
35 class HGraphPieSlice;
36 
37 #ifdef WINDOWS_SYSTEM
38 template class MVO_API VArray< HGraphLabelNode *>;
39 template class MVO_API VArray< HGraphDataSetNode *>;
40 template class MVO_API VArray< HGraphPieSlice *>;
41 #endif
42 
45 {
46  X_Axis=1,
47  Y_Axis,
48  Z_Axis
49 };
50 
53 {
54  PointFormatCartesian=1,
55  PointFormatPolarDegrees,
56  PointFormatPolarRadians
57 };
58 
61 {
62  AxisScaleLinear=1,
63  AxisScaleLogarithmic
64 };
65 
68 {
69  GridTypeNone=1,
70  GridTypeRectangular,
71  GridTypePolar
72 };
73 
76 {
77  PlotTypeScatter=1,
78  PlotTypeLine,
79  PlotTypeBar,
80 };
81 
84 {
85  LegendEntryTypeLine=1,
86  LegendEntryTypeBox
87 };
88 
90 class MVO_API HGraphAxis
91 {
92 public:
93  HGraphAxis():visible(true), axis_scale(AxisScaleLinear), axis_scale_factor(1.0), tick_frequency(1.0),
94  tick_size(0.1), precision(-1), show_labels(true), grid_frequency(1.0), grid_min(-4.0), grid_max(4.0),
95  segment(INVALID_KEY) {min=-4.0; max=4.0;}
96 
97  bool visible; //is the axis visible?
98  double min; //minimal point of axis
99  double max; //maximal point of axis
100  HGraphAxisScale axis_scale; //is the axis linear or logarithmic?
101  double axis_scale_factor; //multiplier, or logarithmic base of the axis (based on axis_scale)
102  double tick_frequency; //how frequently ticks occur on the axis (respects the axis_scale setting)
103  double tick_size; //the size of the actual ticks
104  int precision; //the number of places after the decimal point to display
105  bool show_labels; //whether or not to label each tick
106  double grid_frequency; //how frequently grid lines occur on this axis
107  double grid_min; //minimal point on the axis of the grid
108  double grid_max; //maximal point on the axis of the grid
109  HC_KEY segment; //the location of the axis
110 
111 };
112 
114 class MVO_API HGraphLabelNode
115 {
116 public:
117  HC_KEY segment; //the segment housing the label
118  HC_KEY text_key; //the key of the label itself
119 };
120 
122 class MVO_API HGraphDataSetNode
123 {
124 public:
125  HC_KEY segment; //location in the segment tree of the data
126  int data_size; //how many points are in the data set
127  HGraphPointFormat format; //format of point data
128  bool line_vis; //are the points connected by a polyline?
129  bool bar_vis; //visible in bar charts
130  double bar_width; //the width of the bars to be drawn
131  bool polygon_vis; //the visibility of a colored region
132 };
133 
135 class MVO_API HGraphPieSlice
136 {
137 public:
138  double amount; //how much of the pie is in this slice.
139  HC_KEY segment; //the segment housing the slice
140  HC_KEY text_key; //the key of any label (if any);
141 };
142 
144 class MVO_API HGraphLegend
145 {
146 public:
147 HGraphLegend():segment(INVALID_KEY), title(INVALID_KEY) {entries.ReplaceAt(0,0);}
148 
149 HC_KEY segment;
150 HC_KEY title;
151 VArray< HGraphLabelNode *> entries;
152 };
153 
155 class MVO_API HBaseGraph
156 {
157 public:
158 
164  HBaseGraph(HC_KEY plot_seg);
165 
169  virtual ~HBaseGraph();
170 
171 
177  void GetPlotTitle(char * title);
178 
184  void GetPlotUnicodeTitle(unsigned short * title);
185 
186 
192  virtual void SetPlotTitle(const char * title)=0;
193 
199  virtual void SetPlotUnicodeTitle(unsigned short * title)=0;
200 
206  virtual void GetPlotTitleColor(char * color);
207 
213  virtual void SetPlotTitleColor(const char * color);
214 
215 
221  void GetPlotTitleTextFont(char * font);
222 
228  void SetPlotTitleTextFont(const char * font);
229 
230 
236  HPoint GetPlotTitleLocation();
237 
243  void SetPlotTitleLocation(HPoint loc);
244 
245 
251  HPoint GetPlotOrigin();
252 
258  void SetPlotOrigin(HPoint origin);
259 
260 
266  bool GetFrameVisibility();
267 
273  void SetFrameVisibility(bool visible);
274 
275 
281  void GetFramePattern(char * pattern);
282 
288  void SetFramePattern(const char * pattern);
289 
290 
296  void GetFrameColor(char * color);
297 
303  void SetFrameColor(const char * color);
304 
305 
311  float GetFrameWeight();
312 
318  void SetFrameWeight(float weight);
319 
320 
332  int AddLabel(const char * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, float xvector=1.0,
333  float yvector=0.0, float zvector=0.0);
334 
346  int AddUnicodeLabel(const unsigned short * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian,
347  float xvector=1.0, float yvector=0.0, float zvector=0.0);
348 
354  void RemoveLabel(int label_id);
355 
356 
363  void GetLabelContents(int label_id, char * str);
364 
371  void GetLabelUnicodeContents(int label_id, unsigned short * str);
372 
373 
380  void SetLabelContents(int label_id, const char * str);
381 
388  void SetLabelUnicodeContents(int label_id, const unsigned short * str);
389 
390 
397  void SetLabelTextFont(int label_id, const char * font);
398 
405  void GetLabelTextFont(int label_id, char * font);
406 
413  void SetLabelTextColor(int label_id, const char * color);
414 
421  void GetLabelTextColor(int label_id, char * color);
422 
429  void SetLabelTextAlignment(int label_id, const char * alignment);
430 
437  void GetLabelTextAlignment(int label_id, char * alignment);
438 
446  void SetLabelLocation(int label_id, HPoint loc, HGraphPointFormat format=PointFormatCartesian);
447 
454  HPoint GetLabelLocation(int label_id);
455 
464  void SetLabelTextPath(int label_id, float xvector, float yvector, float zvector);
465 
466 
475  void GetLabelTextPath(int label_id, float *xvector, float *yvector, float *zvector);
476 
477 
484  void AddLegend(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
485 
489  void RemoveLegend();
490 
491 
497  void SetLegendTitle(const char * title);
498 
504  void GetLegendTitle(char * title);
505 
509  void RemoveLegendTitle();
510 
516  void SetLegendUnicodeTitle(const unsigned short * title);
517 
523  void GetLegendUnicodeTitle(unsigned short * title);
524 
525 
531  void SetLegendTitleTextFont(const char * font);
532 
538  void GetLegendTitleTextFont(char * font);
539 
540 
546  void SetLegendTextFont(const char * font);
547 
553  void GetLegendTextFont(char * font);
554 
563  int AddLegendEntry(const char * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
564 
573  int AddLegendUnicodeEntry(const unsigned short * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
574 
580  void RemoveLegendEntry(int entry_id);
581 
590  void GetLegendEntry(int entry_id, char * str, char * color, HGraphLegendEntryType * entry_type=0);
591 
600  void GetLegendUnicodeEntry(int entry_id, unsigned short * str, char * color, HGraphLegendEntryType * entry_type=0);
601 
602 
609  void SetLegendLocation(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
610 
616  HPoint GetLegendLocation();
617 
627  void ConvertPoints(unsigned int in_count, const HPoint *in_points, HGraphPointFormat in_system,
628  HPoint *out_points, HGraphPointFormat out_system);
629 
635  void PreserveData(bool preserve=true);
636 
644  void SetAutomaticUpdates(bool automatic=true);
645 
651  bool GetAutomaticUpdates();
652 
656  virtual void Update();
657 
658 protected:
659  HC_KEY m_plot_segment;
660  HPoint m_origin;
661  bool m_show_frame, m_preserve_data, m_automatic_updates, m_force_update;
662  HGraphLegend m_legend;
663 
664 
665  VArray< HGraphLabelNode *> m_labels;
666 
670  virtual void DrawFrame()=0;
671 
675  virtual void DrawLegend();
676 };
677 
679 class MVO_API HPlot2D : public HBaseGraph
680 {
681 public:
682 
689  HPlot2D(HC_KEY plot_seg, HGraphPlotType plot_type=PlotTypeScatter);
690 
694  virtual ~HPlot2D();
695 
701  void SetPlotTitle(const char * title);
702 
708  void SetPlotUnicodeTitle(unsigned short * title);
709 
710 
716  HGraphPlotType GetPlotType();
717 
723  void SetPlotOrigin(HPoint origin);
724 
725 
731  HGraphGridType GetGridType();
732 
738  void SetGridType(HGraphGridType gtype);
739 
740 
746  bool GetGridVisibility();
747 
753  void SetGridVisibility(bool value);
754 
760  void GetGridPattern(char * pattern);
761 
767  void SetGridPattern(const char * pattern);
768 
769 
775  void GetGridColor(char * color);
776 
782  void SetGridColor(const char * color);
783 
791  HGraphAxisScale GetAxisScale(HGraphAxisSelection axis, double * factor=0);
792 
800  void SetAxisScale(HGraphAxisSelection axis, HGraphAxisScale scale, double factor=0.0);
801 
809  void GetAxisRange(HGraphAxisSelection axis, double* min, double* max);
810 
818  void SetAxisRange(HGraphAxisSelection axis, double min, double max);
819 
820 
825  bool GetAxisVisibility(HGraphAxisSelection axis);
826 
833  void SetAxisVisibility(HGraphAxisSelection axis, bool vis);
834 
835 
842  void GetAxisColor(HGraphAxisSelection axis, char * color);
843 
850  void SetAxisColor(HGraphAxisSelection axis, const char * color);
851 
852 
859  float GetAxisWeight(HGraphAxisSelection axis);
860 
867  void SetAxisWeight(HGraphAxisSelection axis, float weight);
868 
869 
876  double GetAxisTickFrequency(HGraphAxisSelection axis);
877 
884  void SetAxisTickFrequency(HGraphAxisSelection axis, double freq);
885 
886 
893  int GetAxisPrecision(HGraphAxisSelection axis);
894 
901  void SetAxisPrecision(HGraphAxisSelection axis, int precision);
902 
909  double GetAxisTickSize(HGraphAxisSelection axis);
910 
917  void SetAxisTickSize(HGraphAxisSelection axis, double size);
918 
919 
926  double GetAxisGridFrequency(HGraphAxisSelection axis);
927 
934  void SetAxisGridFrequency(HGraphAxisSelection axis, double freq);
935 
943  void GetAxisGridRange(HGraphAxisSelection axis, double* min, double* max);
944 
952  void SetAxisGridRange(HGraphAxisSelection axis, double min, double max);
953 
958  bool GetAxisLabelVisibility(HGraphAxisSelection axis);
959 
966  void SetAxisLabelVisibility(HGraphAxisSelection axis, bool vis);
967 
968 
975  void GetAxisLabelTextFont(HGraphAxisSelection axis, char * font);
976 
983  void SetAxisLabelTextFont(HGraphAxisSelection axis, const char * font);
984 
985 
992  void GetAxisLabelTextColor(HGraphAxisSelection axis, char * color);
993 
1000  void SetAxisLabelTextColor(HGraphAxisSelection axis, const char * color);
1001 
1002 
1011  void SetAxisLabelTextPath(HGraphAxisSelection axis, float xvector,
1012  float yvector, float zvector);
1013 
1014 
1023  void GetAxisLabelTextPath(HGraphAxisSelection axis, float *xvector,
1024  float *yvector, float *zvector);
1025 
1026 
1038  int AddDataSet(int points_count, const HPoint *points, HGraphPointFormat format=PointFormatCartesian,
1039  const HPoint *colors=0);
1040 
1041 
1047  void RemoveDataSet(int data_set);
1048 
1049 
1056  int GetDataSetSize(int data_set);
1057 
1058 
1065  HGraphPointFormat GetDataSetFormat(int data_set);
1066 
1067 
1074  void GetDataSet(int data_set, HPoint *points);
1075 
1087  void ReplaceDataSet(int data_set, int points_count, const HPoint *points,
1088  HGraphPointFormat format=PointFormatCartesian, const HPoint *colors=0);
1089 
1090 
1097  void SetPointColor(int data_set, const char * color);
1098 
1105  void GetPointColor(int data_set, char * color);
1106 
1107 
1114  void SetPointSymbol(int data_set, const char * symbol);
1115 
1122  void GetPointSymbol(int data_set, char * symbol);
1123 
1124 
1131  void SetPointSize(int data_set, double size);
1132 
1139  float GetPointSize(int data_set);
1140 
1141 
1146  bool GetPointVisibility(int data_set);
1147 
1154  void SetPointVisibility(int data_set, bool vis);
1155 
1160  bool GetLineVisibility(int data_set);
1161 
1168  void SetLineVisibility(int data_set, bool vis);
1169 
1170 
1177  void SetLinePattern(int data_set, const char * pattern);
1178 
1185  void GetLinePattern(int data_set, char * pattern);
1186 
1193  void SetLineColor(int data_set, const char * color);
1194 
1201  void GetLineColor(int data_set, char * color);
1202 
1209  float GetLineWeight(int data_set);
1210 
1217  void SetLineWeight(int data_set, float weight);
1218 
1223  bool GetBarVisibility(int data_set);
1224 
1231  void SetBarVisibility(int data_set, bool vis);
1232 
1233 
1240  void SetBarColorMap(int data_set, const char * map);
1241 
1248  void GetBarColorMap(int data_set, char * map);
1249 
1250 
1259  void SetBarColorMapByValue(int data_set, int count, const HPoint * values, const char * color_space=0);
1260 
1269  void GetBarColorMapByValue(int data_set, int * count, HPoint * values, char * color_space);
1270 
1277  double GetBarWidth(int data_set);
1278 
1285  void SetBarWidth(int data_set, double width);
1286 
1291  bool GetBarEdgeVisibility(int data_set);
1292 
1299  void SetBarEdgeVisibility(int data_set, bool vis);
1300 
1301 
1306  bool GetPolygonVisibility(int data_set);
1307 
1308 
1316  void SetPolygonVisibility(int data_set, bool vis);
1317 
1325  void GetPolygonColor(int data_set, char * color);
1326 
1333  void SetPolygonColor(int data_set, const char * color);
1334 
1338  virtual void Update();
1339 
1343  double GetAspectRatio();
1344 
1351  void SetAspectRatio(double ratio);
1352 
1356  void UnSetAspectRatio();
1357 
1358 protected:
1359  HGraphPlotType m_plot_type;
1360  HGraphGridType m_grid_type;
1361  HGraphAxis m_x_axis, m_y_axis;
1362  double m_aspect_ratio;
1363 
1364  VArray< HGraphDataSetNode *> m_points;
1365 
1369  virtual void DrawAxes();
1370 
1374  virtual void DrawGrid();
1375 
1379  virtual void DrawFrame();
1380 
1386  virtual void DrawData(int data_set);
1387 
1388 };
1389 
1391 class MVO_API HPieChart: public HBaseGraph
1392 {
1393 public:
1394 
1400  HPieChart(HC_KEY plot_seg);
1401 
1405  virtual ~HPieChart();
1406 
1412  void SetPlotTitle(const char * title);
1413 
1419  void SetPlotUnicodeTitle(unsigned short * title);
1420 
1421 
1428  int AddPieSlice(double size);
1429 
1430 
1436  void RemovePieSlice(int slice_id);
1437 
1443  void SetPieColorMap(const char * map);
1444 
1450  void GetPieColorMap(char * map);
1451 
1459  void SetPieColorMapByValue(int count, const HPoint * values, const char * color_space=0);
1460 
1468  void GetPieColorMapByValue(int * count, HPoint * values, char * color_space);
1469 
1476  void AddPieSliceLabel(int slice_id, const char * str);
1477 
1484  void AddPieSliceUnicodeLabel(int slice_id, const unsigned short * str);
1485 
1491  void RemovePieSliceLabel(int slice_id);
1492 
1499  void GetPieSliceLabelContents(int slice_id, char * str);
1500 
1507  void GetPieSliceUnicodeLabelContents(int slice_id, unsigned short * str);
1508 
1515  void SetPieSliceLabelTextFont(int slice_id, const char * font);
1516 
1523  void GetPieSliceLabelTextFont(int slice_id, char * font);
1524 
1525 
1531  bool GetPieEdgeVisibility();
1532 
1538  void SetPieEdgeVisibility(bool vis);
1539 
1540 
1546  void GetPieEdgeColor(char * color);
1547 
1553  void SetPieEdgeColor(const char * color);
1554 
1560  double GetPieRadius();
1561 
1567  void SetPieRadius(double radius);
1568 
1574  void SetPlotOrigin(HPoint origin);
1575 
1579  virtual void Update();
1580 
1581 protected:
1582  VArray< HGraphPieSlice *> m_pie;
1583  double m_pie_total;
1584  double m_scale;
1585 
1589  virtual void DrawFrame();
1590 
1594  virtual void DrawPie();
1595 };
1596 
1597 
1598 
1599 #ifdef H_PACK_8
1600 #pragma pack(pop)
1601 #endif
1602 
1603 #endif
1604 
1605 
1606 
1607 
1608 
1609 
1610 
1611 
1612 
1613 
1614 
1615 
1616 
1617 
1618 
1619 
1620 
1621 
1622 
1623 
1624 
1625 
1626 
1627 
1628 
1629 
1630 
1631 
1632 
1633 
1634 
1635 
1636 
1637 
1638 
1639 
Provides plotting capabilities for most 2d graphs including bar charts, line graphs, scatter plots, or any combination of these.
Definition: HGraph.h:679
Definition: HGraph.h:122
Definition: HGraph.h:114
HGraphGridType
Definition: HGraph.h:67
HGraphLegendEntryType
Definition: HGraph.h:83
HGraphPointFormat
Definition: HGraph.h:52
#define HC_KEY
Definition: HGraph.h:155
HGraphAxisScale
Definition: HGraph.h:60
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
Definition: HGraph.h:135
Definition: HGraph.h:90
Definition: HGraph.h:144
HGraphAxisSelection
Definition: HGraph.h:44
Provides simple pie chart creation tools.
Definition: HGraph.h:1391
HGraphPlotType
Definition: HGraph.h:75