Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HGraph.h
Go to the documentation of this file.
00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc.
00002 //
00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
00004 // and considered a trade secret as defined under civil and criminal statutes.
00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
00006 // unauthorized use or misappropriation of its trade secrets.  Use of this information
00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
00009 
00013 #ifndef _HGraph_H
00014 #define _HGraph_H
00015 
00016 #ifdef H_PACK_8
00017 #pragma pack(push)
00018 #pragma pack(8)
00019 #endif
00020 
00021 #include "HUtility.h"
00022 #include "HTools.h"
00023 #include "varray.h"
00024 
00025 #define _PI 3.14159265358979323
00026 
00027 class HGraphAxis;
00028 class HGraphLabelNode;
00029 class HGraphDataSetNode;
00030 class HGraphPieSlice;
00031 
00032 #ifdef WINDOWS_SYSTEM
00033 template class MVO_API VArray< HGraphLabelNode *>;
00034 template class MVO_API VArray< HGraphDataSetNode *>;
00035 template class MVO_API VArray< HGraphPieSlice *>;
00036 #endif
00037 
00039 enum HGraphAxisSelection
00040 {
00041     X_Axis=1,
00042     Y_Axis,
00043     Z_Axis
00044 };
00045 
00047 enum HGraphPointFormat
00048 {
00049     PointFormatCartesian=1,
00050     PointFormatPolarDegrees,
00051     PointFormatPolarRadians
00052 };
00053 
00055 enum HGraphAxisScale
00056 {
00057     AxisScaleLinear=1,
00058     AxisScaleLogarithmic
00059 };
00060 
00062 enum HGraphGridType
00063 {
00064     GridTypeNone=1,
00065     GridTypeRectangular,
00066     GridTypePolar
00067 };
00068 
00070 enum HGraphPlotType
00071 {
00072     PlotTypeScatter=1,
00073     PlotTypeLine,
00074     PlotTypeBar,
00075 };
00076 
00078 enum HGraphLegendEntryType
00079 {
00080     LegendEntryTypeLine=1,
00081     LegendEntryTypeBox
00082 };
00083 
00085 class MVO_API HGraphAxis
00086 {
00087 public:
00088     HGraphAxis()
00089         : axis_scale_factor(1.0)
00090         , tick_frequency(1.0)
00091         , tick_size(0.1)
00092         , grid_frequency(1.0)
00093         , grid_min(-4.0)
00094         , grid_max(4.0)
00095         , segment(INVALID_KEY)
00096         , precision(-1)
00097         , axis_scale(AxisScaleLinear)
00098         , show_labels(true)
00099         , visible(true)
00100     {
00101         min = -4.0;
00102         max = 4.0;
00103     }
00104 
00105     double min;                 //minimal point of axis
00106     double max;                 //maximal point of axis
00107     
00108     double axis_scale_factor;   //multiplier, or logarithmic base of the axis (based on axis_scale)
00109     double tick_frequency;      //how frequently ticks occur on the axis (respects the axis_scale setting)
00110     double tick_size;           //the size of the actual ticks
00111 
00112     double grid_frequency;      //how frequently grid lines occur on this axis
00113     double grid_min;            //minimal point on the axis of the grid
00114     double grid_max;            //maximal point on the axis of the grid
00115 
00116     HC_KEY segment;             //the location of the axis
00117 
00118     int precision;              //the number of places after the decimal point to display
00119 
00120     HGraphAxisScale axis_scale; //is the axis linear or logarithmic?
00121     
00122     bool show_labels;           //whether or not to label each tick
00123     bool visible;               //is the axis visible?
00124 };
00125 
00127 class MVO_API HGraphLabelNode
00128 {
00129 public:
00130     HC_KEY segment;             //the segment housing the label
00131     HC_KEY text_key;            //the key of the label itself
00132 };
00133 
00135 class MVO_API HGraphDataSetNode
00136 {
00137 public:
00138     double bar_width;           //the width of the bars to be drawn
00139     HC_KEY segment;             //location in the segment tree of the data
00140     int data_size;              //how many points are in the data set
00141     HGraphPointFormat format;   //format of point data
00142     bool line_vis;              //are the points connected by a polyline?
00143     bool bar_vis;               //visible in bar charts
00144     bool polygon_vis;           //the visibility of a colored region
00145 };
00146 
00148 class MVO_API HGraphPieSlice
00149 {
00150 public:
00151     double amount;              //how much of the pie is in this slice.
00152     HC_KEY segment;             //the segment housing the slice
00153     HC_KEY text_key;            //the key of any label (if any);
00154 };
00155 
00157 class MVO_API HGraphLegend
00158 {
00159 public:
00160 HGraphLegend():segment(INVALID_KEY), title(INVALID_KEY) {entries.ReplaceAt(0,0);}
00161 
00162 HC_KEY segment;
00163 HC_KEY title;
00164 VArray< HGraphLabelNode *> entries;
00165 };
00166 
00168 class MVO_API HBaseGraph
00169 {
00170 public:
00171 
00177     HBaseGraph(HC_KEY plot_seg);
00178 
00182     virtual ~HBaseGraph();
00183 
00184 
00190     void GetPlotTitle(char * title);
00191 
00197     void GetPlotUnicodeTitle(unsigned short * title);
00198 
00199 
00205     virtual void SetPlotTitle(const char * title)=0;
00206 
00212     virtual void SetPlotUnicodeTitle(unsigned short * title)=0;
00213 
00219     virtual void GetPlotTitleColor(char * color);
00220 
00226     virtual void SetPlotTitleColor(const char * color);
00227 
00228 
00234     void GetPlotTitleTextFont(char * font);
00235 
00241     void SetPlotTitleTextFont(const char * font);
00242 
00243 
00249     HPoint GetPlotTitleLocation();
00250 
00256     void SetPlotTitleLocation(HPoint loc);
00257 
00258 
00264     HPoint GetPlotOrigin();
00265 
00271     void SetPlotOrigin(HPoint origin);
00272 
00273 
00279     bool GetFrameVisibility();
00280 
00286     void SetFrameVisibility(bool visible);
00287 
00288 
00294     void GetFramePattern(char * pattern);
00295 
00301     void SetFramePattern(const char * pattern);
00302 
00303     
00309     void GetFrameColor(char * color);
00310 
00316     void SetFrameColor(const char * color);
00317 
00318     
00324     float GetFrameWeight();
00325 
00331     void SetFrameWeight(float weight);
00332 
00333     
00345     int AddLabel(const char * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, float xvector=1.0,
00346         float yvector=0.0, float zvector=0.0);
00347     
00359     int AddUnicodeLabel(const unsigned short * str, HPoint loc, HGraphPointFormat format=PointFormatCartesian, 
00360         float xvector=1.0, float yvector=0.0, float zvector=0.0);
00361     
00367     void RemoveLabel(int label_id);
00368 
00369 
00376     void GetLabelContents(int label_id, char * str);
00377 
00384     void GetLabelUnicodeContents(int label_id, unsigned short * str);
00385 
00386 
00393     void SetLabelContents(int label_id, const char * str);
00394 
00401     void SetLabelUnicodeContents(int label_id, const unsigned short * str);
00402 
00403 
00410     void SetLabelTextFont(int label_id, const char * font);
00411 
00418     void GetLabelTextFont(int label_id, char * font);
00419 
00426     void SetLabelTextColor(int label_id, const char * color);
00427 
00434     void GetLabelTextColor(int label_id, char * color);
00435     
00442     void SetLabelTextAlignment(int label_id, const char * alignment);
00443 
00450     void GetLabelTextAlignment(int label_id, char * alignment);
00451 
00459     void SetLabelLocation(int label_id, HPoint loc, HGraphPointFormat format=PointFormatCartesian);
00460 
00467     HPoint GetLabelLocation(int label_id);
00468 
00477     void SetLabelTextPath(int label_id, float xvector, float yvector, float zvector);
00478 
00479 
00488     void GetLabelTextPath(int label_id, float *xvector, float *yvector, float *zvector);
00489 
00490 
00497     void AddLegend(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
00498 
00502     void RemoveLegend();
00503 
00504 
00510     void SetLegendTitle(const char * title);
00511 
00517     void GetLegendTitle(char * title);
00518 
00522     void RemoveLegendTitle();
00523 
00529     void SetLegendUnicodeTitle(const unsigned short * title);
00530 
00536     void GetLegendUnicodeTitle(unsigned short * title);
00537     
00538     
00544     void SetLegendTitleTextFont(const char * font);
00545 
00551     void GetLegendTitleTextFont(char * font);
00552 
00553 
00559     void SetLegendTextFont(const char * font);
00560 
00566     void GetLegendTextFont(char * font);
00567 
00576     int AddLegendEntry(const char * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
00577 
00586     int AddLegendUnicodeEntry(const unsigned short * str, const char * color, HGraphLegendEntryType ltype=LegendEntryTypeLine);
00587     
00593     void RemoveLegendEntry(int entry_id);
00594 
00603     void GetLegendEntry(int entry_id, char * str, char * color, HGraphLegendEntryType * entry_type=0);
00604 
00613     void GetLegendUnicodeEntry(int entry_id, unsigned short * str, char * color, HGraphLegendEntryType * entry_type=0);
00614 
00615     
00622     void SetLegendLocation(HPoint loc, HGraphPointFormat format=PointFormatCartesian);
00623 
00629     HPoint GetLegendLocation();
00630 
00640     void ConvertPoints(unsigned int in_count, const HPoint *in_points, HGraphPointFormat in_system, 
00641         HPoint *out_points, HGraphPointFormat out_system);
00642 
00648     void PreserveData(bool preserve=true);
00649 
00657     void SetAutomaticUpdates(bool automatic=true);
00658 
00664     bool GetAutomaticUpdates();
00665 
00669     virtual void Update();
00670  
00671 protected:
00672     HC_KEY m_plot_segment;
00673     HPoint m_origin;
00674     bool m_show_frame, m_preserve_data, m_automatic_updates, m_force_update;    
00675     HGraphLegend m_legend;
00676 
00677     
00678     VArray< HGraphLabelNode *> m_labels;
00679 
00683     virtual void DrawFrame()=0;
00684 
00688     virtual void DrawLegend();
00689 };
00690 
00692 class MVO_API HPlot2D : public HBaseGraph
00693 {
00694 public:
00695 
00702     HPlot2D(HC_KEY plot_seg, HGraphPlotType plot_type=PlotTypeScatter);
00703 
00707     virtual ~HPlot2D();
00708 
00714     void SetPlotTitle(const char * title);
00715 
00721     void SetPlotUnicodeTitle(unsigned short * title);
00722 
00723 
00729     HGraphPlotType GetPlotType();
00730 
00736     void SetPlotOrigin(HPoint origin);
00737 
00738     
00744     HGraphGridType GetGridType();
00745     
00751     void SetGridType(HGraphGridType gtype);
00752 
00753 
00759     bool GetGridVisibility();
00760 
00766     void SetGridVisibility(bool value);
00767 
00773     void GetGridPattern(char * pattern);
00774 
00780     void SetGridPattern(const char * pattern);
00781 
00782 
00788     void GetGridColor(char * color);
00789 
00795     void SetGridColor(const char * color);
00796 
00804     HGraphAxisScale GetAxisScale(HGraphAxisSelection axis, double * factor=0);
00805 
00813     void SetAxisScale(HGraphAxisSelection axis, HGraphAxisScale scale, double factor=0.0);
00814 
00822     void GetAxisRange(HGraphAxisSelection axis, double* min, double* max);
00823 
00831     void SetAxisRange(HGraphAxisSelection axis, double min, double max);
00832 
00833 
00838     bool GetAxisVisibility(HGraphAxisSelection axis);
00839 
00846     void SetAxisVisibility(HGraphAxisSelection axis, bool vis);
00847 
00848 
00855     void GetAxisColor(HGraphAxisSelection axis, char * color);
00856 
00863     void SetAxisColor(HGraphAxisSelection axis, const char * color);
00864 
00865 
00872     float GetAxisWeight(HGraphAxisSelection axis);
00873 
00880     void SetAxisWeight(HGraphAxisSelection axis, float weight);
00881 
00882 
00889     double GetAxisTickFrequency(HGraphAxisSelection axis);
00890 
00897     void SetAxisTickFrequency(HGraphAxisSelection axis, double freq);
00898 
00899     
00906     int GetAxisPrecision(HGraphAxisSelection axis);
00907     
00914     void SetAxisPrecision(HGraphAxisSelection axis, int precision);
00915 
00922     double GetAxisTickSize(HGraphAxisSelection axis);
00923 
00930     void SetAxisTickSize(HGraphAxisSelection axis, double size);
00931 
00932     
00939     double GetAxisGridFrequency(HGraphAxisSelection axis);
00940 
00947     void SetAxisGridFrequency(HGraphAxisSelection axis, double freq);
00948 
00956     void GetAxisGridRange(HGraphAxisSelection axis, double* min, double* max);
00957 
00965     void SetAxisGridRange(HGraphAxisSelection axis, double min, double max);
00966 
00971     bool GetAxisLabelVisibility(HGraphAxisSelection axis);
00972 
00979     void SetAxisLabelVisibility(HGraphAxisSelection axis, bool vis);
00980 
00981 
00988     void GetAxisLabelTextFont(HGraphAxisSelection axis, char * font);
00989 
00996     void SetAxisLabelTextFont(HGraphAxisSelection axis, const char * font);
00997 
00998 
01005     void GetAxisLabelTextColor(HGraphAxisSelection axis, char * color);
01006 
01013     void SetAxisLabelTextColor(HGraphAxisSelection axis, const char * color);
01014 
01015 
01024     void SetAxisLabelTextPath(HGraphAxisSelection axis, float xvector,  
01025         float yvector, float zvector);
01026 
01027 
01036     void GetAxisLabelTextPath(HGraphAxisSelection axis, float *xvector, 
01037         float *yvector, float *zvector);
01038 
01039 
01051     int AddDataSet(int points_count, const HPoint *points, HGraphPointFormat format=PointFormatCartesian, 
01052                     const HPoint *colors=0);
01053 
01054 
01060     void RemoveDataSet(int data_set);
01061 
01062 
01069     int GetDataSetSize(int data_set);
01070 
01071 
01078     HGraphPointFormat GetDataSetFormat(int data_set);
01079 
01080     
01087     void GetDataSet(int data_set, HPoint *points);
01088     
01100     void ReplaceDataSet(int data_set, int points_count, const HPoint *points, 
01101                         HGraphPointFormat format=PointFormatCartesian, const HPoint *colors=0);
01102 
01103     
01110     void SetPointColor(int data_set, const char * color);
01111 
01118     void GetPointColor(int data_set, char * color);
01119 
01120 
01127     void SetPointSymbol(int data_set, const char * symbol);
01128 
01135     void GetPointSymbol(int data_set, char * symbol);
01136 
01137 
01144     void SetPointSize(int data_set, double size);
01145 
01152     float GetPointSize(int data_set);
01153 
01154 
01159     bool GetPointVisibility(int data_set);
01160 
01167     void SetPointVisibility(int data_set, bool vis);
01168 
01173     bool GetLineVisibility(int data_set);
01174 
01181     void SetLineVisibility(int data_set, bool vis);
01182 
01183 
01190     void SetLinePattern(int data_set, const char * pattern);
01191 
01198     void GetLinePattern(int data_set, char * pattern);
01199 
01206     void SetLineColor(int data_set, const char * color);
01207 
01214     void GetLineColor(int data_set, char * color);
01215 
01222     float GetLineWeight(int data_set);
01223 
01230     void SetLineWeight(int data_set, float weight);
01231 
01236     bool GetBarVisibility(int data_set);
01237 
01244     void SetBarVisibility(int data_set, bool vis);
01245 
01246     
01253     void SetBarColorMap(int data_set, const char * map);
01254 
01261     void GetBarColorMap(int data_set, char * map);
01262 
01263 
01272     void SetBarColorMapByValue(int data_set, int count, const HPoint * values, const char * color_space=0);
01273     
01282     void GetBarColorMapByValue(int data_set, int * count, HPoint * values,  char * color_space);
01283     
01290     double GetBarWidth(int data_set);
01291 
01298     void SetBarWidth(int data_set, double width);
01299     
01304     bool GetBarEdgeVisibility(int data_set);
01305 
01312     void SetBarEdgeVisibility(int data_set, bool vis);
01313 
01314     
01319     bool GetPolygonVisibility(int data_set);
01320 
01321     
01329     void SetPolygonVisibility(int data_set, bool vis);
01330 
01338     void GetPolygonColor(int data_set, char * color);
01339 
01346     void SetPolygonColor(int data_set, const char * color);
01347 
01351     virtual void Update();
01352 
01356     double GetAspectRatio();
01357 
01364     void SetAspectRatio(double ratio);
01365 
01369     void UnSetAspectRatio();
01370 
01371 protected:
01372     HGraphPlotType m_plot_type;
01373     HGraphGridType m_grid_type;
01374     HGraphAxis m_x_axis, m_y_axis;
01375     double m_aspect_ratio;
01376 
01377     VArray< HGraphDataSetNode *> m_points;
01378 
01382     virtual void DrawAxes();
01383 
01387     virtual void DrawGrid();
01388 
01392     virtual void DrawFrame();
01393 
01399     virtual void DrawData(int data_set);
01400 
01401 };
01402 
01404 class MVO_API HPieChart: public HBaseGraph
01405 {
01406 public:
01407 
01413     HPieChart(HC_KEY plot_seg);
01414 
01418     virtual ~HPieChart();
01419 
01425     void SetPlotTitle(const char * title);
01426 
01432     void SetPlotUnicodeTitle(unsigned short * title);
01433 
01434     
01441     int AddPieSlice(double size);
01442 
01443 
01449     void RemovePieSlice(int slice_id);
01450 
01456     void SetPieColorMap(const char * map);
01457 
01463     void GetPieColorMap(char * map);
01464 
01472     void SetPieColorMapByValue(int count, const HPoint * values, const char * color_space=0);
01473 
01481     void GetPieColorMapByValue(int * count, HPoint * values,  char * color_space);
01482 
01489     void AddPieSliceLabel(int slice_id, const char * str);
01490 
01497     void AddPieSliceUnicodeLabel(int slice_id, const unsigned short * str);
01498 
01504     void RemovePieSliceLabel(int slice_id);
01505 
01512     void GetPieSliceLabelContents(int slice_id, char * str);
01513 
01520     void GetPieSliceUnicodeLabelContents(int slice_id, unsigned short * str);
01521 
01528     void SetPieSliceLabelTextFont(int slice_id, const char * font);
01529 
01536     void GetPieSliceLabelTextFont(int slice_id, char * font);
01537     
01538     
01544     bool GetPieEdgeVisibility();
01545 
01551     void SetPieEdgeVisibility(bool vis);
01552     
01553     
01559     void GetPieEdgeColor(char * color);
01560 
01566     void SetPieEdgeColor(const char * color);
01567 
01573     double GetPieRadius();
01574 
01580     void SetPieRadius(double radius);
01581 
01587     void SetPlotOrigin(HPoint origin);
01588 
01592     virtual void Update();
01593 
01594 protected:
01595     VArray< HGraphPieSlice *> m_pie;
01596     double m_pie_total;
01597     double m_scale;
01598 
01602     virtual void DrawFrame();
01603 
01607     virtual void DrawPie();
01608 };
01609 
01610 
01611 
01612 #ifdef H_PACK_8
01613 #pragma pack(pop)
01614 #endif
01615 
01616 #endif
01617 
01618 
01619 
01620 
01621 
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