KSquare Utilities
Chart.h
Go to the documentation of this file.
1 /* Chart.h -- Used to build Charts from data-series.
2  * Copyright (C) 1994-2011 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _CHART_
6 #define _CHART_
7 
8 #include <vector>
9 
10 #include "KKBaseTypes.h"
11 #include "KKStr.h"
12 #include "Raster.h"
13 #include "Point.h"
14 
15 namespace KKB
16 {
17  /**
18  *@brief Used to Create chart's from defined series of data.
19  *@details This class is meant to allow you to define multiple series, their x and y ranges and the
20  * data for each series.
21  *@todo This class Chart has not been used as of yet so requires testing.
22  */
23 
24  class Chart
25  {
26  public:
27  class Series;
28  class XLabel;
29  class PlotPoint;
30 
31  typedef Series* SeriesPtr;
34 
35 
36  Chart (KKStr _title);
37 
38  ~Chart ();
39 
40  kkint32 NumOfSeries () {return (kkint32)series.size ();}
41 
42  void AddAValue (kkuint32 _seriesIDX,
43  float _xVal,
44  float _yVal
45  );
46 
47  RasterPtr CreateRaster ();
48 
49  void DefineASeries (KKStr _name);
50 
51  void DefineASeries (KKStr _name,
52  PixelValue _color
53  );
54 
55 
56  void DefineAXLabel (float _xVal,
57  KKStr _name
58  );
59 
60  void Save (KKStr _fileName);
61 
62  void SaveAsImage (KKStr _fileName);
63 
64  private:
65  kkint32 LookUpXLableIDX (double xVal);
66 
67  PlotPointPtr LookUpPoint (kkint32 seriesIDX,
68  double yVal
69  );
70 
71  Point RasterCoordinates (const PlotPoint& plotPoint);
72 
73 
74 
75  KKStr title;
76  SeriesList series;
77  std::vector<XLabel> xLabels;
78 
79  float minXValue;
80  float maxXValue;
81 
82  float minYValue;
83  float maxYValue;
84 
85  kkint32 maxPointsPlotedInASeries;
86 
87 
88  kkint32 numOfDefaultColorsUsed;
89 
90  // Used when creating Raster of Chart.
91  kkint32 chartWidth;
92  kkint32 chartHeight;
93  kkint32 xOffset;
94  kkint32 yOffset;
95  double yRange;
96  double xRange;
97  double yScale;
98  double xScale;
99  double xMin;
100  double xMax;
101  double yMin;
102  double yMax;
103  double yIncrement;
104  }; /* Chart */
105 
106 } /* KKB */
107 
108 #endif
Series * SeriesPtr
Definition: Chart.h:29
PlotPoint * PlotPointPtr
Definition: Chart.h:33
vector< SeriesPtr > SeriesList
Definition: Chart.h:32
__int32 kkint32
Definition: KKBaseTypes.h:88
void DefineASeries(KKStr _name, PixelValue _color)
Definition: Chart.cpp:253
void DefineAXLabel(float _xVal, KKStr _name)
Definition: Chart.cpp:263
void Save(KKStr _fileName)
Definition: Chart.cpp:487
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void AddAValue(kkuint32 _seriesIDX, float _xVal, float _yVal)
Definition: Chart.cpp:184
void DefineASeries(KKStr _name)
Definition: Chart.cpp:245
Used by Raster class and MorphOp derived classes to denote a single pixel location in Raster image...
Definition: Point.h:20
KKTHread * KKTHreadPtr
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
Chart(KKStr _title)
Definition: Chart.cpp:142
kkint32 NumOfSeries()
Definition: Chart.h:40
RasterPtr CreateRaster()
Definition: Chart.cpp:287
Used to Create chart&#39;s from defined series of data.
Definition: Chart.h:24
Used by the Raster Class to represent the contents of one pixel.
Definition: PixelValue.h:22
void SaveAsImage(KKStr _fileName)
Definition: Chart.cpp:445