Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GraphPlotter.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef __GRAPHPLOTTER_hh__
26 #define __GRAPHPLOTTER_hh__
27 
28 // includes
29 #include <bias_config.h>
30 #include <Base/Image/Image.hh>
31 
32 #ifndef BIAS_HAVE_OPENCV
33 # error BIAS_HAVE_OPENCV not defined. Please recompile BIAS with USE_OPENCV enabled if you want to use GraphPlotter.
34 #endif
35 namespace BIAS {
36 
44  };
45 
46  /** @class GraphPlotter
47  @brief Use this class to plot data as gnuplot does
48  @ingroup g_utils
49  @author ischiller 10/2008 */
50  class BIASUtils_EXPORT GraphPlotter
51  {
52  public:
53  /// constructor
54  GraphPlotter();
55 
56  /// destructor
57  ~GraphPlotter();
58 
59  void SetXRange(double minX, double maxX);
60  void SetYRange(double minY, double maxY);
61 
62  void SetXTics(unsigned xtics);
63  void SetYTics(unsigned ytics);
64 
65  void SetXLabel(std::string label);
66  void SetYLabel(std::string label);
67 
68  void SetImageSize(unsigned width, unsigned height);
69 
70  void SetDrawGrid(bool drawGrid);
71  void SetAxesToYLeftAndXBottom(bool fixAxes);
72 
73  void SetLineThickness(unsigned thickness);
74  void SetTextThickness(unsigned thickness);
75 
76  void SetLabel(std::string label, BIAS::ColourRGB<unsigned char> color){
77  std::pair<std::string,BIAS::ColourRGB<unsigned char> > lb;
78  lb = std::make_pair(label,color);
79  labels_.push_back(lb);
80  }
81 
82  void Reset();
83 
84  /**
85  @brief draws xvalues against yvalues
86  */
87  void Draw(std::vector<double>& xValues,
88  std::vector<double>& yValues,
91 
92  /**
93  @brief draws xvalues against yvalues with standard deviations
94  as errorbars
95  */
96  void Draw(std::vector<double>& xValues,
97  std::vector<double>& yValues,
98  std::vector<double>& yStdDeviation,
102  std::vector<std::string> *labels = NULL);
103 
104 
105  void DrawLabels();
106 
107 
108  BIAS::Image<unsigned char>* GetImage();
109  BIAS::Image<unsigned char> GetCopyOfImage();
110 
111  protected:
112  void Prepare_();
113  std::vector< std::pair<std::string,BIAS::ColourRGB<unsigned char> > > labels_;
114 
116  double xCoeff_, yCoeff_;
117  double xMin_, xMax_, yMin_,yMax_;
118  int xTics_ , yTics_;
119  unsigned width_ , height_;
120  std::string xLabel_,yLabel_;
121  int xOffset_,yOffset_;
128  unsigned dLineThickness_;
129  unsigned dTextThickness_;
130  }; // class GraphPlotter
131 
132 } // namespace
133 
134 #endif // __GRAPHPLOTTER_hh__
std::vector< std::pair< std::string, BIAS::ColourRGB< unsigned char > > > labels_
std::string yLabel_
GraphPlotter_DrawStyle
Definition: GraphPlotter.hh:37
void SetLabel(std::string label, BIAS::ColourRGB< unsigned char > color)
Definition: GraphPlotter.hh:76
unsigned dTextThickness_
BIAS::Image< unsigned char > image_
unsigned dLineThickness_
Use this class to plot data as gnuplot does.
Definition: GraphPlotter.hh:50