Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DataPlot.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 __DataPlot_hh__
26 #define __DataPlot_hh__
27 
28 #include <bias_config.h>
29 #include <Base/Image/Image.hh>
30 #include <Base/Image/ColourRGB.hh>
31 #include <vector>
32 
33 namespace BIAS {
34 
35  /**
36  * \class DataPlot
37  * \brief Class to plot data as lines, crosses etc, as gnuplot does, duplicates functionality in
38  * class GraphPlotter
39  * \author evers
40  * \date April 2009
41  */
42  class BIASUtils_EXPORT DataPlot
43  {
44 
45  public:
46 
47  enum DrawingStyle {
50  Cross
51  };
52 
53  // put an complete initialized image here.
54  DataPlot(Image<unsigned char> &PlotArea);
55  ~DataPlot();
56 
57  void SetXRange(float min,float max);
58  void SetYRange(float min,float max);
59  void SetDrawingStyle(enum DrawingStyle);
60  void SetAutoRange(bool x, bool y);
61  void SetThickness(unsigned int t){Thickness_ = t;};
62  // draw a complete data set at once
63  void Plot(const std::vector<float> &data);
64  void CutLinePlot();
65 
66  void Plot(const std::vector<float> &x,const std::vector<float> &y);
67 
68  /** \brief draw single value, no AutoRange possible
69  \return 0 for success, -1 for x out of range, -2 for y out of range */
70  int Plot(float x, float y);
71 
72  void Clear();
73  void DrawXAxis();
74  void DrawYAxis();
76  {BGColour_ = color;};
78  {PenColour_ = color;}
79 
80 
81  protected:
82  // convert window coordinates (MinX_<=wx<=MaxX_, MinY_<=wy<=MaxY_) to view-port coordinates
83  // 0<=vx<PlotArea_->GetWidht(), 0<=vy<=PlotArea_->GetHeight()
84  int WindowToViewport_(float wx,float wy, unsigned int &vx,unsigned int &vy);
85 
86  void DrawLine_(unsigned int x,unsigned int y,unsigned int x2, unsigned int y2);
87 
88  float MaxX_,MinX_,MaxY_,MinY_;
89  bool AutoRangeX_,AutoRangeY_;
90  unsigned int BorderX_,BorderY_;
92  unsigned char **DrawIda_; // cache these
93  unsigned char ChannelCount_; // cache these
94  unsigned int PlotAreaHeight_,PlotAreaWidth_;
95 
98 
100  int LastVX_,LastVY_;
101  }; //class
102 
103 } //namespace
104 
105 
106 
107 #endif
108 
void SetPenColour(ColourRGB< unsigned char > color)
Definition: DataPlot.hh:77
unsigned int PlotAreaWidth_
Definition: DataPlot.hh:94
unsigned char ** DrawIda_
Definition: DataPlot.hh:92
Image< unsigned char > * PlotArea_
Definition: DataPlot.hh:91
unsigned int BorderY_
Definition: DataPlot.hh:90
DrawingStyle DrawStyle_
Definition: DataPlot.hh:96
ColourRGB< unsigned char > PenColour_
Definition: DataPlot.hh:99
unsigned char ChannelCount_
Definition: DataPlot.hh:93
void SetThickness(unsigned int t)
Definition: DataPlot.hh:61
void SetBGColour(ColourRGB< unsigned char > color)
Definition: DataPlot.hh:75
bool AutoRangeY_
Definition: DataPlot.hh:89
Class to plot data as lines, crosses etc, as gnuplot does, duplicates functionality in class GraphPlo...
Definition: DataPlot.hh:42