Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Graph.h

00001 /* Graph.h
00002  *
00003  * Copyright (C) 2003 -- Sebastian Nowozin, Marco Kunze
00004  *
00005  * Generic function charting widget. Can show multiple functions.
00006  */
00007 
00008 #ifndef GRAPH_H
00009 #define GRAPH_H
00010 
00011 #include <vector>
00012 
00013 #include <qwidget.h>
00014 #include <qpainter.h>
00015 #include <qsize.h>
00016 #include <qcolor.h>
00017 
00018 using namespace std;
00019 
00020 enum GraphDisplayType { GUndefined, BarchartPositive, Barchart,
00021         Waveform, Function };
00022 
00030 class
00031 Graph : public QWidget
00032 {
00033         Q_OBJECT
00034 
00035 public:
00036 
00042         Graph (QWidget *parent = 0, const char *name = 0);
00043 
00046         ~Graph (void);
00047 
00052         void setTitle (const char *title);
00053 
00066         void setDescriptions (const vector<const char *>& desc);
00067 
00072         void setDisplayType (GraphDisplayType type);
00073 
00076         void clear (void);
00077 
00083         void setValues (const vector<vector <double> >& plots);
00084 
00089         void addValue (const vector<double>& plotitem);
00090 
00101         void setDisplaySize (unsigned int display_size);
00102 
00109         unsigned int getDisplaySize (void) const;
00110 
00115         void setColor (const QColor& col);
00116 
00121         void setColor (const vector<QColor>& colors);
00122 
00128         void setMax (const double maximum)
00129         {
00130                 max = maximum;
00131         }
00132 
00144         void setMargins (unsigned int margin_bars = 2,
00145                 unsigned int margin_left = 4, unsigned int margin_right = 4,
00146                 unsigned int margin_up = 4, unsigned int margin_down = 4);
00147 
00148 public slots:
00149         /* no slots needed? */
00150 
00151 protected:
00156         void paintEvent (QPaintEvent *ev);
00157 
00158 private:
00161         GraphDisplayType                type;
00162 
00165         double                          max;
00166 
00169         vector<vector <double> >        plots;
00170 
00174         vector<QColor>          colors;
00175 
00179         vector<const char *>    desc;
00180 
00183         const char *    title;
00184 
00188         unsigned int    display_size;
00189 
00193         QPainter *      painter;
00194 
00203         void plotFunction (const vector<double>& plot, const QColor& col,
00204                 const vector<const char *>& desc);
00205 
00212         const QColor& selectColor (const unsigned int idx) const;
00213 
00215         unsigned int margin_left;
00217         unsigned int margin_right;
00219         unsigned int margin_down;
00221         unsigned int margin_up;
00223         unsigned int margin_bars;
00224 };
00225 
00226 #endif
00227 
00228 

Generated on Mon Feb 24 19:37:43 2003 by doxygen1.3-rc3