Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HGraph.h

Go to the documentation of this file.
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: 6218f942fea36aa8b4e2849fd8a1f29ee29cbb17 $
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()
00094         : axis_scale_factor(1.0)
00095         , tick_frequency(1.0)
00096         , tick_size(0.1)
00097         , grid_frequency(1.0)
00098         , grid_min(-4.0)
00099         , grid_max(4.0)
00100         , segment(INVALID_KEY)
00101         , precision(-1)
00102         , axis_scale(AxisScaleLinear)
00103         , show_labels(true)
00104         , visible(true)
00105     {
00106         min = -4.0;
00107         max = 4.0;
00108     }
00109 
00110     double min;                 //minimal point of axis
00111     double max;                 //maximal point of axis
00112     
00113     double axis_scale_factor;   //multiplier, or logarithmic base of the axis (based on axis_scale)
00114     double tick_frequency;      //how frequently ticks occur on the axis (respects the axis_scale setting)
00115     double tick_size;           //the size of the actual ticks
00116 
00117     double grid_frequency;      //how frequently grid lines occur on this axis
00118     double grid_min;            //minimal point on the axis of the grid
00119     double grid_max;            //maximal point on the axis of the grid
00120 
00121     HC_KEY segment;             //the location of the axis
00122 
00123     int precision;              //the number of places after the decimal point to display
00124 
00125     HGraphAxisScale axis_scale; //is the axis linear or logarithmic?
00126     
00127     bool show_labels;           //whether or not to label each tick
00128     bool visible;               //is the axis visible?
00129 };
00130 
00132 class MVO_API HGraphLabelNode
00133 {
00134 public:
00135     HC_KEY segment;             //the segment housing the label
00136     HC_KEY text_key;            //the key of the label itself
00137 };
00138 
00140 class MVO_API HGraphDataSetNode
00141 {
00142 public:
00143     double bar_width;           //the width of the bars to be drawn
00144     HC_KEY segment;             //location in the segment tree of the data
00145     int data_size;              //how many points are in the data set
00146     HGraphPointFormat format;   //format of point data
00147     bool line_vis;              //are the points connected by a polyline?
00148     bool bar_vis;               //visible in bar charts
00149     bool polygon_vis;           //the visibility of a colored region
00150 };
00151 
00153 class MVO_API HGraphPieSlice
00154 {
00155 public:
00156     double amount;              //how much of the pie is in this slice.
00157     HC_KEY segment;             //the segment housing the slice
00158     HC_KEY text_key;            //the key of any label (if any);
00159 };
00160 
00162 class MVO_API HGraphLegend
00163 {
00164 public:
00165 HGraphLegend():segment(INVALID_KEY), title(INVALID_KEY) {entries.ReplaceAt(0,0);}
00166 
00167 HC_KEY segment;
00168 HC_KEY title;
00169 VArray< HGraphLabelNode *> entries;
00170 };
00171 
00173 class MVO_API HBaseGraph
00174 {
00175 public:
00176 
00182     HBaseGraph(HC_KEY plot_seg);
00183 
00187     virtual ~HBaseGraph();
00188 
00189 
00195     void GetPlotTitle(char * title);
00196 
00202     void GetPlotUnicodeTitle(unsigned short * title);
00203 
00204 
00210     virtual void SetPlotTitle(const char * title)=0;
00211 
00217     virtual void SetPlotUnicodeTitle(unsigned short * title)=0;
00218 
00224     virtual void GetPlotTitleColor(char * color);
00225 
00231     virtual void SetPlotTitleColor(const char * color);
00232 
00233 
00239     void GetPlotTitleTextFont(char * font);
00240 
00246     void SetPlotTitleTextFont(const char * font);
00247 
00248 
00254     HPoint GetPlotTitleLocation();
00255 
00261     void SetPlotTitleLocation(HPoint loc);
00262 
00263 
00269     HPoint GetPlotOrigin();
00270 
00276     void SetPlotOrigin(HPoint origin);
00277 
00278 
00284     bool GetFrameVisibility();
00285 
00291     void SetFrameVisibility(bool visible);
00292 
00293 
00299     void GetFramePattern(char * pattern);
00300 
00306     void SetFramePattern(const char * pattern);
00307 
00308     
00314     void GetFrameColor(char * color);
00315 
00321     void SetFrameColor(const char * color);
00322 
00323     
00329     float GetFrameWeight();
00330 
00336     void SetFrameWeight(float weight);
00337 
00338     
00350     int AddLabel(const char * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, float xvector=1.0,
00351         float yvector=0.0, float zvector=0.0);
00352     
00364     int AddUnicodeLabel(const unsigned short * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, 
00365         float xvector=1.0, float yvector=0.0, float zvector=0.0);
00366     
00372     void RemoveLabel(int label_id);
00373 
00374 
00381     void GetLabelContents(int label_id, char * str);
00382 
00389     void GetLabelUnicodeContents(int label_id, unsigned short * str);
00390 
00391 
00398     void SetLabelContents(int label_id, const char * str);
00399 
00406     void SetLabelUnicodeContents(int label_id, const unsigned short * str);
00407 
00408 
00415     void SetLabelTextFont(int label_id, const char * font);
00416 
00423     void GetLabelTextFont(int label_id, char * font);
00424 
00431     void SetLabelTextColor(int label_id, const char * color);
00432 
00439     void GetLabelTextColor(int label_id, char * color);
00440     
00447     void SetLabelTextAlignment(int label_id, const char * alignment);
00448 
00455     void GetLabelTextAlignment(int label_id, char * alignment);
00456 
00464     void SetLabelLocation(int label_id, HPoint loc, HGraphPointFormat format=PointFormatCartesian);
00465 
00472     HPoint GetLabelLocation(int label_id);
00473 
00482     void SetLabelTextPath(int label_id, float xvector, float yvector, float zvector);
00483 
00484 
00493     void GetLabelTextPath(int label_id, float *xvector, float *yvector, float *zvector);
00494 
00495 
00502     void AddLegend(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
00503 
00507     void RemoveLegend();
00508 
00509 
00515     void SetLegendTitle(const char * title);
00516 
00522     void GetLegendTitle(char * title);
00523 
00527     void RemoveLegendTitle();
00528 
00534     void SetLegendUnicodeTitle(const unsigned short * title);
00535 
00541     void GetLegendUnicodeTitle(unsigned short * title);
00542     
00543     
00549     void SetLegendTitleTextFont(const char * font);
00550 
00556     void GetLegendTitleTextFont(char * font);
00557 
00558 
00564     void SetLegendTextFont(const char * font);
00565 
00571     void GetLegendTextFont(char * font);
00572 
00581     int AddLegendEntry(const char * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
00582 
00591     int AddLegendUnicodeEntry(const unsigned short * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
00592     
00598     void RemoveLegendEntry(int entry_id);
00599 
00608     void GetLegendEntry(int entry_id, char * str, char * color, HGraphLegendEntryType * entry_type=0);
00609 
00618     void GetLegendUnicodeEntry(int entry_id, unsigned short * str, char * color, HGraphLegendEntryType * entry_type=0);
00619 
00620     
00627     void SetLegendLocation(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
00628 
00634     HPoint GetLegendLocation();
00635 
00645     void ConvertPoints(unsigned int in_count, const HPoint *in_points, HGraphPointFormat in_system, 
00646         HPoint *out_points, HGraphPointFormat out_system);
00647 
00653     void PreserveData(bool preserve=true);
00654 
00662     void SetAutomaticUpdates(bool automatic=true);
00663 
00669     bool GetAutomaticUpdates();
00670 
00674     virtual void Update();
00675  
00676 protected:
00677     HC_KEY m_plot_segment;
00678     HPoint m_origin;
00679     bool m_show_frame, m_preserve_data, m_automatic_updates, m_force_update;    
00680     HGraphLegend m_legend;
00681 
00682     
00683     VArray< HGraphLabelNode *> m_labels;
00684 
00688     virtual void DrawFrame()=0;
00689 
00693     virtual void DrawLegend();
00694 };
00695 
00697 class MVO_API HPlot2D : public HBaseGraph
00698 {
00699 public:
00700 
00707     HPlot2D(HC_KEY plot_seg, HGraphPlotType plot_type=PlotTypeScatter);
00708 
00712     virtual ~HPlot2D();
00713 
00719     void SetPlotTitle(const char * title);
00720 
00726     void SetPlotUnicodeTitle(unsigned short * title);
00727 
00728 
00734     HGraphPlotType GetPlotType();
00735 
00741     void SetPlotOrigin(HPoint origin);
00742 
00743     
00749     HGraphGridType GetGridType();
00750     
00756     void SetGridType(HGraphGridType gtype);
00757 
00758 
00764     bool GetGridVisibility();
00765 
00771     void SetGridVisibility(bool value);
00772 
00778     void GetGridPattern(char * pattern);
00779 
00785     void SetGridPattern(const char * pattern);
00786 
00787 
00793     void GetGridColor(char * color);
00794 
00800     void SetGridColor(const char * color);
00801 
00809     HGraphAxisScale GetAxisScale(HGraphAxisSelection axis, double * factor=0);
00810 
00818     void SetAxisScale(HGraphAxisSelection axis, HGraphAxisScale scale, double factor=0.0);
00819 
00827     void GetAxisRange(HGraphAxisSelection axis, double* min, double* max);
00828 
00836     void SetAxisRange(HGraphAxisSelection axis, double min, double max);
00837 
00838 
00843     bool GetAxisVisibility(HGraphAxisSelection axis);
00844 
00851     void SetAxisVisibility(HGraphAxisSelection axis, bool vis);
00852 
00853 
00860     void GetAxisColor(HGraphAxisSelection axis, char * color);
00861 
00868     void SetAxisColor(HGraphAxisSelection axis, const char * color);
00869 
00870 
00877     float GetAxisWeight(HGraphAxisSelection axis);
00878 
00885     void SetAxisWeight(HGraphAxisSelection axis, float weight);
00886 
00887 
00894     double GetAxisTickFrequency(HGraphAxisSelection axis);
00895 
00902     void SetAxisTickFrequency(HGraphAxisSelection axis, double freq);
00903 
00904     
00911     int GetAxisPrecision(HGraphAxisSelection axis);
00912     
00919     void SetAxisPrecision(HGraphAxisSelection axis, int precision);
00920 
00927     double GetAxisTickSize(HGraphAxisSelection axis);
00928 
00935     void SetAxisTickSize(HGraphAxisSelection axis, double size);
00936 
00937     
00944     double GetAxisGridFrequency(HGraphAxisSelection axis);
00945 
00952     void SetAxisGridFrequency(HGraphAxisSelection axis, double freq);
00953 
00961     void GetAxisGridRange(HGraphAxisSelection axis, double* min, double* max);
00962 
00970     void SetAxisGridRange(HGraphAxisSelection axis, double min, double max);
00971 
00976     bool GetAxisLabelVisibility(HGraphAxisSelection axis);
00977 
00984     void SetAxisLabelVisibility(HGraphAxisSelection axis, bool vis);
00985 
00986 
00993     void GetAxisLabelTextFont(HGraphAxisSelection axis, char * font);
00994 
01001     void SetAxisLabelTextFont(HGraphAxisSelection axis, const char * font);
01002 
01003 
01010     void GetAxisLabelTextColor(HGraphAxisSelection axis, char * color);
01011 
01018     void SetAxisLabelTextColor(HGraphAxisSelection axis, const char * color);
01019 
01020 
01029     void SetAxisLabelTextPath(HGraphAxisSelection axis, float xvector,  
01030         float yvector, float zvector);
01031 
01032 
01041     void GetAxisLabelTextPath(HGraphAxisSelection axis, float *xvector, 
01042         float *yvector, float *zvector);
01043 
01044 
01056     int AddDataSet(int points_count, const HPoint *points, HGraphPointFormat format=PointFormatCartesian, 
01057                     const HPoint *colors=0);
01058 
01059 
01065     void RemoveDataSet(int data_set);
01066 
01067 
01074     int GetDataSetSize(int data_set);
01075 
01076 
01083     HGraphPointFormat GetDataSetFormat(int data_set);
01084 
01085     
01092     void GetDataSet(int data_set, HPoint *points);
01093     
01105     void ReplaceDataSet(int data_set, int points_count, const HPoint *points, 
01106                         HGraphPointFormat format=PointFormatCartesian, const HPoint *colors=0);
01107 
01108     
01115     void SetPointColor(int data_set, const char * color);
01116 
01123     void GetPointColor(int data_set, char * color);
01124 
01125 
01132     void SetPointSymbol(int data_set, const char * symbol);
01133 
01140     void GetPointSymbol(int data_set, char * symbol);
01141 
01142 
01149     void SetPointSize(int data_set, double size);
01150 
01157     float GetPointSize(int data_set);
01158 
01159 
01164     bool GetPointVisibility(int data_set);
01165 
01172     void SetPointVisibility(int data_set, bool vis);
01173 
01178     bool GetLineVisibility(int data_set);
01179 
01186     void SetLineVisibility(int data_set, bool vis);
01187 
01188 
01195     void SetLinePattern(int data_set, const char * pattern);
01196 
01203     void GetLinePattern(int data_set, char * pattern);
01204 
01211     void SetLineColor(int data_set, const char * color);
01212 
01219     void GetLineColor(int data_set, char * color);
01220 
01227     float GetLineWeight(int data_set);
01228 
01235     void SetLineWeight(int data_set, float weight);
01236 
01241     bool GetBarVisibility(int data_set);
01242 
01249     void SetBarVisibility(int data_set, bool vis);
01250 
01251     
01258     void SetBarColorMap(int data_set, const char * map);
01259 
01266     void GetBarColorMap(int data_set, char * map);
01267 
01268 
01277     void SetBarColorMapByValue(int data_set, int count, const HPoint * values, const char * color_space=0);
01278     
01287     void GetBarColorMapByValue(int data_set, int * count, HPoint * values,  char * color_space);
01288     
01295     double GetBarWidth(int data_set);
01296 
01303     void SetBarWidth(int data_set, double width);
01304     
01309     bool GetBarEdgeVisibility(int data_set);
01310 
01317     void SetBarEdgeVisibility(int data_set, bool vis);
01318 
01319     
01324     bool GetPolygonVisibility(int data_set);
01325 
01326     
01334     void SetPolygonVisibility(int data_set, bool vis);
01335 
01343     void GetPolygonColor(int data_set, char * color);
01344 
01351     void SetPolygonColor(int data_set, const char * color);
01352 
01356     virtual void Update();
01357 
01361     double GetAspectRatio();
01362 
01369     void SetAspectRatio(double ratio);
01370 
01374     void UnSetAspectRatio();
01375 
01376 protected:
01377     HGraphPlotType m_plot_type;
01378     HGraphGridType m_grid_type;
01379     HGraphAxis m_x_axis, m_y_axis;
01380     double m_aspect_ratio;
01381 
01382     VArray< HGraphDataSetNode *> m_points;
01383 
01387     virtual void DrawAxes();
01388 
01392     virtual void DrawGrid();
01393 
01397     virtual void DrawFrame();
01398 
01404     virtual void DrawData(int data_set);
01405 
01406 };
01407 
01409 class MVO_API HPieChart: public HBaseGraph
01410 {
01411 public:
01412 
01418     HPieChart(HC_KEY plot_seg);
01419 
01423     virtual ~HPieChart();
01424 
01430     void SetPlotTitle(const char * title);
01431 
01437     void SetPlotUnicodeTitle(unsigned short * title);
01438 
01439     
01446     int AddPieSlice(double size);
01447 
01448 
01454     void RemovePieSlice(int slice_id);
01455 
01461     void SetPieColorMap(const char * map);
01462 
01468     void GetPieColorMap(char * map);
01469 
01477     void SetPieColorMapByValue(int count, const HPoint * values, const char * color_space=0);
01478 
01486     void GetPieColorMapByValue(int * count, HPoint * values,  char * color_space);
01487 
01494     void AddPieSliceLabel(int slice_id, const char * str);
01495 
01502     void AddPieSliceUnicodeLabel(int slice_id, const unsigned short * str);
01503 
01509     void RemovePieSliceLabel(int slice_id);
01510 
01517     void GetPieSliceLabelContents(int slice_id, char * str);
01518 
01525     void GetPieSliceUnicodeLabelContents(int slice_id, unsigned short * str);
01526 
01533     void SetPieSliceLabelTextFont(int slice_id, const char * font);
01534 
01541     void GetPieSliceLabelTextFont(int slice_id, char * font);
01542     
01543     
01549     bool GetPieEdgeVisibility();
01550 
01556     void SetPieEdgeVisibility(bool vis);
01557     
01558     
01564     void GetPieEdgeColor(char * color);
01565 
01571     void SetPieEdgeColor(const char * color);
01572 
01578     double GetPieRadius();
01579 
01585     void SetPieRadius(double radius);
01586 
01592     void SetPlotOrigin(HPoint origin);
01593 
01597     virtual void Update();
01598 
01599 protected:
01600     VArray< HGraphPieSlice *> m_pie;
01601     double m_pie_total;
01602     double m_scale;
01603 
01607     virtual void DrawFrame();
01608 
01612     virtual void DrawPie();
01613 };
01614 
01615 
01616 
01617 #ifdef H_PACK_8
01618 #pragma pack(pop)
01619 #endif
01620 
01621 #endif
01622 
01623 
01624 
01625 
01626 
01627 
01628 
01629 
01630 
01631 
01632 
01633 
01634 
01635 
01636 
01637 
01638 
01639 
01640 
01641 
01642 
01643 
01644 
01645 
01646 
01647 
01648 
01649 
01650 
01651 
01652 
01653 
01654 
01655 
01656 
01657