00001 // 00002 // Copyright (c) 2000 by Tech Soft 3D, LLC. 00003 // The information contained herein is confidential and proprietary to 00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 // civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 // and criminal remedies in the event of unauthorized use or misappropriation 00007 // of its trade secrets. Use of this information by anyone other than 00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 // written non-disclosure agreement, expressly prescribing the scope and 00010 // manner of such use. 00011 // 00012 // $Id$ 00013 // 00014 00018 #ifndef _HGraph_H 00019 #define _HGraph_H 00020 00021 #ifdef H_PACK_8 00022 #pragma pack(push) 00023 #pragma pack(8) 00024 #endif 00025 00026 #include "HUtility.h" 00027 #include "HTools.h" 00028 #include "varray.h" 00029 00030 #define _PI 3.14159265358979323 00031 00032 class HGraphAxis; 00033 class HGraphLabelNode; 00034 class HGraphDataSetNode; 00035 class HGraphPieSlice; 00036 00037 #ifdef WINDOWS_SYSTEM 00038 template class MVO_API VArray< HGraphLabelNode *>; 00039 template class MVO_API VArray< HGraphDataSetNode *>; 00040 template class MVO_API VArray< HGraphPieSlice *>; 00041 #endif 00042 00044 enum HGraphAxisSelection 00045 { 00046 X_Axis=1, 00047 Y_Axis, 00048 Z_Axis 00049 }; 00050 00052 enum HGraphPointFormat 00053 { 00054 PointFormatCartesian=1, 00055 PointFormatPolarDegrees, 00056 PointFormatPolarRadians 00057 }; 00058 00060 enum HGraphAxisScale 00061 { 00062 AxisScaleLinear=1, 00063 AxisScaleLogarithmic 00064 }; 00065 00067 enum HGraphGridType 00068 { 00069 GridTypeNone=1, 00070 GridTypeRectangular, 00071 GridTypePolar 00072 }; 00073 00075 enum HGraphPlotType 00076 { 00077 PlotTypeScatter=1, 00078 PlotTypeLine, 00079 PlotTypeBar, 00080 }; 00081 00083 enum HGraphLegendEntryType 00084 { 00085 LegendEntryTypeLine=1, 00086 LegendEntryTypeBox 00087 }; 00088 00090 class MVO_API HGraphAxis 00091 { 00092 public: 00093 HGraphAxis():visible(true), axis_scale(AxisScaleLinear), axis_scale_factor(1.0), tick_frequency(1.0), 00094 tick_size(0.1), precision(-1), show_labels(true), grid_frequency(1.0), grid_min(-4.0), grid_max(4.0), 00095 segment(INVALID_KEY) {min=-4.0; max=4.0;} 00096 00097 bool visible; //is the axis visible? 00098 double min; //minimal point of axis 00099 double max; //maximal point of axis 00100 HGraphAxisScale axis_scale; //is the axis linear or logarithmic? 00101 double axis_scale_factor; //multiplier, or logarithmic base of the axis (based on axis_scale) 00102 double tick_frequency; //how frequently ticks occur on the axis (respects the axis_scale setting) 00103 double tick_size; //the size of the actual ticks 00104 int precision; //the number of places after the decimal point to display 00105 bool show_labels; //whether or not to label each tick 00106 double grid_frequency; //how frequently grid lines occur on this axis 00107 double grid_min; //minimal point on the axis of the grid 00108 double grid_max; //maximal point on the axis of the grid 00109 HC_KEY segment; //the location of the axis 00110 00111 }; 00112 00114 class MVO_API HGraphLabelNode 00115 { 00116 public: 00117 HC_KEY segment; //the segment housing the label 00118 HC_KEY text_key; //the key of the label itself 00119 }; 00120 00122 class MVO_API HGraphDataSetNode 00123 { 00124 public: 00125 HC_KEY segment; //location in the segment tree of the data 00126 int data_size; //how many points are in the data set 00127 HGraphPointFormat format; //format of point data 00128 bool line_vis; //are the points connected by a polyline? 00129 bool bar_vis; //visible in bar charts 00130 double bar_width; //the width of the bars to be drawn 00131 bool polygon_vis; //the visibility of a colored region 00132 }; 00133 00135 class MVO_API HGraphPieSlice 00136 { 00137 public: 00138 double amount; //how much of the pie is in this slice. 00139 HC_KEY segment; //the segment housing the slice 00140 HC_KEY text_key; //the key of any label (if any); 00141 }; 00142 00144 class MVO_API HGraphLegend 00145 { 00146 public: 00147 HGraphLegend():segment(INVALID_KEY), title(INVALID_KEY) {entries.ReplaceAt(0,0);} 00148 00149 HC_KEY segment; 00150 HC_KEY title; 00151 VArray< HGraphLabelNode *> entries; 00152 }; 00153 00155 class MVO_API HBaseGraph 00156 { 00157 public: 00158 00164 HBaseGraph(HC_KEY plot_seg); 00165 00169 virtual ~HBaseGraph(); 00170 00171 00177 void GetPlotTitle(char * title); 00178 00184 void GetPlotUnicodeTitle(unsigned short * title); 00185 00186 00192 virtual void SetPlotTitle(const char * title)=0; 00193 00199 virtual void SetPlotUnicodeTitle(unsigned short * title)=0; 00200 00206 virtual void GetPlotTitleColor(char * color); 00207 00213 virtual void SetPlotTitleColor(const char * color); 00214 00215 00221 void GetPlotTitleTextFont(char * font); 00222 00228 void SetPlotTitleTextFont(const char * font); 00229 00230 00236 HPoint GetPlotTitleLocation(); 00237 00243 void SetPlotTitleLocation(HPoint loc); 00244 00245 00251 HPoint GetPlotOrigin(); 00252 00258 void SetPlotOrigin(HPoint origin); 00259 00260 00266 bool GetFrameVisibility(); 00267 00273 void SetFrameVisibility(bool visible); 00274 00275 00281 void GetFramePattern(char * pattern); 00282 00288 void SetFramePattern(const char * pattern); 00289 00290 00296 void GetFrameColor(char * color); 00297 00303 void SetFrameColor(const char * color); 00304 00305 00311 float GetFrameWeight(); 00312 00318 void SetFrameWeight(float weight); 00319 00320 00332 int AddLabel(const char * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, float xvector=1.0, 00333 float yvector=0.0, float zvector=0.0); 00334 00346 int AddUnicodeLabel(const unsigned short * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, 00347 float xvector=1.0, float yvector=0.0, float zvector=0.0); 00348 00354 void RemoveLabel(int label_id); 00355 00356 00363 void GetLabelContents(int label_id, char * str); 00364 00371 void GetLabelUnicodeContents(int label_id, unsigned short * str); 00372 00373 00380 void SetLabelContents(int label_id, const char * str); 00381 00388 void SetLabelUnicodeContents(int label_id, const unsigned short * str); 00389 00390 00397 void SetLabelTextFont(int label_id, const char * font); 00398 00405 void GetLabelTextFont(int label_id, char * font); 00406 00413 void SetLabelTextColor(int label_id, const char * color); 00414 00421 void GetLabelTextColor(int label_id, char * color); 00422 00429 void SetLabelTextAlignment(int label_id, const char * alignment); 00430 00437 void GetLabelTextAlignment(int label_id, char * alignment); 00438 00446 void SetLabelLocation(int label_id, HPoint loc, HGraphPointFormat format=PointFormatCartesian); 00447 00454 HPoint GetLabelLocation(int label_id); 00455 00464 void SetLabelTextPath(int label_id, float xvector, float yvector, float zvector); 00465 00466 00475 void GetLabelTextPath(int label_id, float *xvector, float *yvector, float *zvector); 00476 00477 00484 void AddLegend(HPoint loc, HGraphPointFormat format=PointFormatCartesian); 00485 00489 void RemoveLegend(); 00490 00491 00497 void SetLegendTitle(const char * title); 00498 00504 void GetLegendTitle(char * title); 00505 00509 void RemoveLegendTitle(); 00510 00516 void SetLegendUnicodeTitle(const unsigned short * title); 00517 00523 void GetLegendUnicodeTitle(unsigned short * title); 00524 00525 00531 void SetLegendTitleTextFont(const char * font); 00532 00538 void GetLegendTitleTextFont(char * font); 00539 00540 00546 void SetLegendTextFont(const char * font); 00547 00553 void GetLegendTextFont(char * font); 00554 00563 int AddLegendEntry(const char * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine); 00564 00573 int AddLegendUnicodeEntry(const unsigned short * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine); 00574 00580 void RemoveLegendEntry(int entry_id); 00581 00590 void GetLegendEntry(int entry_id, char * str, char * color, HGraphLegendEntryType * entry_type=0); 00591 00600 void GetLegendUnicodeEntry(int entry_id, unsigned short * str, char * color, HGraphLegendEntryType * entry_type=0); 00601 00602 00609 void SetLegendLocation(HPoint loc, HGraphPointFormat format=PointFormatCartesian); 00610 00616 HPoint GetLegendLocation(); 00617 00627 void ConvertPoints(unsigned int in_count, const HPoint *in_points, HGraphPointFormat in_system, 00628 HPoint *out_points, HGraphPointFormat out_system); 00629 00635 void PreserveData(bool preserve=true); 00636 00644 void SetAutomaticUpdates(bool automatic=true); 00645 00651 bool GetAutomaticUpdates(); 00652 00656 virtual void Update(); 00657 00658 protected: 00659 HC_KEY m_plot_segment; 00660 HPoint m_origin; 00661 bool m_show_frame, m_preserve_data, m_automatic_updates, m_force_update; 00662 HGraphLegend m_legend; 00663 00664 00665 VArray< HGraphLabelNode *> m_labels; 00666 00670 virtual void DrawFrame()=0; 00671 00675 virtual void DrawLegend(); 00676 }; 00677 00679 class MVO_API HPlot2D : public HBaseGraph 00680 { 00681 public: 00682 00689 HPlot2D(HC_KEY plot_seg, HGraphPlotType plot_type=PlotTypeScatter); 00690 00694 virtual ~HPlot2D(); 00695 00701 void SetPlotTitle(const char * title); 00702 00708 void SetPlotUnicodeTitle(unsigned short * title); 00709 00710 00716 HGraphPlotType GetPlotType(); 00717 00723 void SetPlotOrigin(HPoint origin); 00724 00725 00731 HGraphGridType GetGridType(); 00732 00738 void SetGridType(HGraphGridType gtype); 00739 00740 00746 bool GetGridVisibility(); 00747 00753 void SetGridVisibility(bool value); 00754 00760 void GetGridPattern(char * pattern); 00761 00767 void SetGridPattern(const char * pattern); 00768 00769 00775 void GetGridColor(char * color); 00776 00782 void SetGridColor(const char * color); 00783 00791 HGraphAxisScale GetAxisScale(HGraphAxisSelection axis, double * factor=0); 00792 00800 void SetAxisScale(HGraphAxisSelection axis, HGraphAxisScale scale, double factor=0.0); 00801 00809 void GetAxisRange(HGraphAxisSelection axis, double* min, double* max); 00810 00818 void SetAxisRange(HGraphAxisSelection axis, double min, double max); 00819 00820 00825 bool GetAxisVisibility(HGraphAxisSelection axis); 00826 00833 void SetAxisVisibility(HGraphAxisSelection axis, bool vis); 00834 00835 00842 void GetAxisColor(HGraphAxisSelection axis, char * color); 00843 00850 void SetAxisColor(HGraphAxisSelection axis, const char * color); 00851 00852 00859 float GetAxisWeight(HGraphAxisSelection axis); 00860 00867 void SetAxisWeight(HGraphAxisSelection axis, float weight); 00868 00869 00876 double GetAxisTickFrequency(HGraphAxisSelection axis); 00877 00884 void SetAxisTickFrequency(HGraphAxisSelection axis, double freq); 00885 00886 00893 int GetAxisPrecision(HGraphAxisSelection axis); 00894 00901 void SetAxisPrecision(HGraphAxisSelection axis, int precision); 00902 00909 double GetAxisTickSize(HGraphAxisSelection axis); 00910 00917 void SetAxisTickSize(HGraphAxisSelection axis, double size); 00918 00919 00926 double GetAxisGridFrequency(HGraphAxisSelection axis); 00927 00934 void SetAxisGridFrequency(HGraphAxisSelection axis, double freq); 00935 00943 void GetAxisGridRange(HGraphAxisSelection axis, double* min, double* max); 00944 00952 void SetAxisGridRange(HGraphAxisSelection axis, double min, double max); 00953 00958 bool GetAxisLabelVisibility(HGraphAxisSelection axis); 00959 00966 void SetAxisLabelVisibility(HGraphAxisSelection axis, bool vis); 00967 00968 00975 void GetAxisLabelTextFont(HGraphAxisSelection axis, char * font); 00976 00983 void SetAxisLabelTextFont(HGraphAxisSelection axis, const char * font); 00984 00985 00992 void GetAxisLabelTextColor(HGraphAxisSelection axis, char * color); 00993 01000 void SetAxisLabelTextColor(HGraphAxisSelection axis, const char * color); 01001 01002 01011 void SetAxisLabelTextPath(HGraphAxisSelection axis, float xvector, 01012 float yvector, float zvector); 01013 01014 01023 void GetAxisLabelTextPath(HGraphAxisSelection axis, float *xvector, 01024 float *yvector, float *zvector); 01025 01026 01038 int AddDataSet(int points_count, const HPoint *points, HGraphPointFormat format=PointFormatCartesian, 01039 const HPoint *colors=0); 01040 01041 01047 void RemoveDataSet(int data_set); 01048 01049 01056 int GetDataSetSize(int data_set); 01057 01058 01065 HGraphPointFormat GetDataSetFormat(int data_set); 01066 01067 01074 void GetDataSet(int data_set, HPoint *points); 01075 01087 void ReplaceDataSet(int data_set, int points_count, const HPoint *points, 01088 HGraphPointFormat format=PointFormatCartesian, const HPoint *colors=0); 01089 01090 01097 void SetPointColor(int data_set, const char * color); 01098 01105 void GetPointColor(int data_set, char * color); 01106 01107 01114 void SetPointSymbol(int data_set, const char * symbol); 01115 01122 void GetPointSymbol(int data_set, char * symbol); 01123 01124 01131 void SetPointSize(int data_set, double size); 01132 01139 float GetPointSize(int data_set); 01140 01141 01146 bool GetPointVisibility(int data_set); 01147 01154 void SetPointVisibility(int data_set, bool vis); 01155 01160 bool GetLineVisibility(int data_set); 01161 01168 void SetLineVisibility(int data_set, bool vis); 01169 01170 01177 void SetLinePattern(int data_set, const char * pattern); 01178 01185 void GetLinePattern(int data_set, char * pattern); 01186 01193 void SetLineColor(int data_set, const char * color); 01194 01201 void GetLineColor(int data_set, char * color); 01202 01209 float GetLineWeight(int data_set); 01210 01217 void SetLineWeight(int data_set, float weight); 01218 01223 bool GetBarVisibility(int data_set); 01224 01231 void SetBarVisibility(int data_set, bool vis); 01232 01233 01240 void SetBarColorMap(int data_set, const char * map); 01241 01248 void GetBarColorMap(int data_set, char * map); 01249 01250 01259 void SetBarColorMapByValue(int data_set, int count, const HPoint * values, const char * color_space=0); 01260 01269 void GetBarColorMapByValue(int data_set, int * count, HPoint * values, char * color_space); 01270 01277 double GetBarWidth(int data_set); 01278 01285 void SetBarWidth(int data_set, double width); 01286 01291 bool GetBarEdgeVisibility(int data_set); 01292 01299 void SetBarEdgeVisibility(int data_set, bool vis); 01300 01301 01306 bool GetPolygonVisibility(int data_set); 01307 01308 01316 void SetPolygonVisibility(int data_set, bool vis); 01317 01325 void GetPolygonColor(int data_set, char * color); 01326 01333 void SetPolygonColor(int data_set, const char * color); 01334 01338 virtual void Update(); 01339 01343 double GetAspectRatio(); 01344 01351 void SetAspectRatio(double ratio); 01352 01356 void UnSetAspectRatio(); 01357 01358 protected: 01359 HGraphPlotType m_plot_type; 01360 HGraphGridType m_grid_type; 01361 HGraphAxis m_x_axis, m_y_axis; 01362 double m_aspect_ratio; 01363 01364 VArray< HGraphDataSetNode *> m_points; 01365 01369 virtual void DrawAxes(); 01370 01374 virtual void DrawGrid(); 01375 01379 virtual void DrawFrame(); 01380 01386 virtual void DrawData(int data_set); 01387 01388 }; 01389 01391 class MVO_API HPieChart: public HBaseGraph 01392 { 01393 public: 01394 01400 HPieChart(HC_KEY plot_seg); 01401 01405 virtual ~HPieChart(); 01406 01412 void SetPlotTitle(const char * title); 01413 01419 void SetPlotUnicodeTitle(unsigned short * title); 01420 01421 01428 int AddPieSlice(double size); 01429 01430 01436 void RemovePieSlice(int slice_id); 01437 01443 void SetPieColorMap(const char * map); 01444 01450 void GetPieColorMap(char * map); 01451 01459 void SetPieColorMapByValue(int count, const HPoint * values, const char * color_space=0); 01460 01468 void GetPieColorMapByValue(int * count, HPoint * values, char * color_space); 01469 01476 void AddPieSliceLabel(int slice_id, const char * str); 01477 01484 void AddPieSliceUnicodeLabel(int slice_id, const unsigned short * str); 01485 01491 void RemovePieSliceLabel(int slice_id); 01492 01499 void GetPieSliceLabelContents(int slice_id, char * str); 01500 01507 void GetPieSliceUnicodeLabelContents(int slice_id, unsigned short * str); 01508 01515 void SetPieSliceLabelTextFont(int slice_id, const char * font); 01516 01523 void GetPieSliceLabelTextFont(int slice_id, char * font); 01524 01525 01531 bool GetPieEdgeVisibility(); 01532 01538 void SetPieEdgeVisibility(bool vis); 01539 01540 01546 void GetPieEdgeColor(char * color); 01547 01553 void SetPieEdgeColor(const char * color); 01554 01560 double GetPieRadius(); 01561 01567 void SetPieRadius(double radius); 01568 01574 void SetPlotOrigin(HPoint origin); 01575 01579 virtual void Update(); 01580 01581 protected: 01582 VArray< HGraphPieSlice *> m_pie; 01583 double m_pie_total; 01584 double m_scale; 01585 01589 virtual void DrawFrame(); 01590 01594 virtual void DrawPie(); 01595 }; 01596 01597 01598 01599 #ifdef H_PACK_8 01600 #pragma pack(pop) 01601 #endif 01602 01603 #endif 01604 01605 01606 01607 01608 01609 01610 01611 01612 01613 01614 01615 01616 01617 01618 01619 01620 01621 01622 01623 01624 01625 01626 01627 01628 01629 01630 01631 01632 01633 01634 01635 01636 01637 01638 01639