00001
00002
00003
00004
00005
00006 #ifndef MARX2DGRAPH_H
00007 #define MARX2DGRAPH_H
00008
00009 #include <QWidget>
00010 #include <QPen>
00011 #include <QBrush>
00012 #include <QPainter>
00013 #include <QPalette>
00014 #include <QColor>
00015 #include <QRectF>
00016 #include <QLineF>
00017 #include <QSize>
00018 #include <QGridLayout>
00019 #include <QString>
00020 #include <QMouseEvent>
00021
00022 #include <sstream>
00023 #include <iostream>
00024 #include <iomanip>
00025 #include <string>
00026
00027 #include "realvec.h"
00028 namespace MarsyasQt
00029 {
00041 class Marx2DGraph : public QWidget
00042 {
00043 Q_OBJECT
00044
00045 public:
00046
00047 Marx2DGraph( QWidget *parent=0 );
00048 Marx2DGraph( int size=0, QWidget *parent=0 );
00049
00050 bool setBuffer( Marsyas::realvec& );
00051
00052 void test();
00053
00054 void setPlotType( int );
00055 void setAxisDisplayType( int );
00056 void setGraphDataColor( QColor );
00057 void setGraphLabelsAndAxisColor( QColor );
00058 void setBGColor( QColor );
00059 void setGraphDataPointSize( float );
00060 void setGraphDataPointType( int );
00061 void setGraphDataLineSize( float );
00062 void setShowAxisScale( bool );
00063 void setAntialias( bool );
00064 void setXAxisLabel( std::string );
00065 void setYAxisLabel( std::string );
00066 void setXAxisLabelOn( bool );
00067 void setYAxisLabelOn( bool );
00068 void setYMaxMin(float ymax, float ymin);
00069 void displayXaxis( bool );
00070
00071 void addLabel( std::string );
00072
00073
00074 enum { POINTS, PRECISION, LINEAR_INTERPOLATION, POLYNOMIAL_INTERPOLATION };
00075 enum { CIRCLES, SQUARES, XS };
00076 enum { CONNECTED, BROKEN };
00077
00078
00079 protected:
00080 void mousePressEvent(QMouseEvent *);
00081 void mouseMoveEvent(QMouseEvent *);
00082 void mouseReleaseEvent(QMouseEvent *);
00083 void paintEvent(QPaintEvent *);
00084 void resizeEvent(QResizeEvent *);
00085
00086
00087
00088 private:
00089 QPainter painter;
00090
00091 void plotpoints(QPainter *);
00092 void plotprecision(QPainter *);
00093 void plotlinearinterpolation(QPainter *);
00094 void plotpolyinterpolation(QPainter *);
00095
00096 void draw_x_ticks(QPainter *);
00097 void draw_y_ticks(QPainter *);
00098
00099 bool ticks;
00100 bool display;
00101 bool showXaxis;
00102 bool show_axis_scale;
00103
00104 bool antialias;
00105
00106 float mousex;
00107 float mousey;
00108 float dsample;
00109 float dvalue;
00110 std::string dsamplestring;
00111 std::string dvaluestring;
00112
00113
00114 Marsyas::realvec* buffer;
00115 long buffersize;
00116 float ymaxval, yminval;
00117
00118
00119 int plot_type;
00120 int axis_display_type;
00121
00122 std::string xlabelmessage;
00123 std::string ylabelmessage;
00124 bool xlabel;
00125 bool ylabel;
00126
00127 float width, height, xpos, ypos;
00128 float gheight, gwidth;
00129 float xaxisoffset;
00130 float yaxisoffset;
00131 float yaxisscale;
00132
00133 float point_size;
00134 int point_type;
00135
00136 QColor data_color;
00137 QColor label_color;
00138 QColor bg_color;
00139
00140 QPen pen;
00141 float pen_width;
00142 float data_pen_width;
00143
00144 std::string label;
00145
00146 };
00147 }
00148
00149 #endif