00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SIMPLEPLOT_H
00026 #define SIMPLEPLOT_H
00027
00028 #include <QWidget>
00029 #include <QDateTime>
00030
00031 class QwtScaleMap;
00032 class QwtPlotCurve;
00033
00041 class SimplePlot : public QWidget
00042 {
00043 Q_OBJECT
00044 public:
00052 SimplePlot(int lineSize, QPointF lineAxis,
00053 const QDateTime &startStamp,
00054 QWidget *parent = 0);
00056 ~SimplePlot();
00057
00062 void initCurves(int curveCount);
00068 void setData(const double *x, const QVector<QVector<double> > &vYData);
00073 void setLineAxisBounds(QPointF p);
00079 void setSampleBounds(QPoint p);
00084 QPoint getSampleBounds() const;
00085
00087 bool isValid() const { return d_valid; }
00088
00090 QSize minimumSizeHint() const { return QSize(400, 200); }
00091
00092 protected:
00099 void mousePressEvent(QMouseEvent *event);
00106 void mouseMoveEvent(QMouseEvent *event);
00113 void enterEvent(QEvent *event);
00120 void leaveEvent(QEvent *event);
00121
00128 virtual void paintEvent(QPaintEvent *event);
00129
00130 signals:
00138 void valueClicked(int line, int sample);
00139
00140 private:
00141 void createCurves();
00142 void shiftDown(QRect &rect, int offset) const { rect.translate(0, offset); }
00143 void drawContents(QPainter *painter);
00144 void drawMarker(QPainter *painter);
00145 void drawShadow(QPainter *painter);
00146
00147 int samplesprCurve;
00148 int curveCount;
00149 int d_deltay;
00150 double d_deltax;
00151
00152 bool d_valid;
00153 bool markerVisible;
00154
00155 QwtScaleMap *xMap;
00156 QwtScaleMap *yMap;
00157
00158 QRect markerRect;
00159 QRect shadowRect;
00160
00161 QPoint d_samplebounds;
00162 QPointF d_lineaxisbounds;
00163
00164 QVector<QwtPlotCurve *> curves;
00165
00166 QDateTime curvesStartTime;
00167 };
00168 inline void SimplePlot::setSampleBounds(QPoint p)
00169 { d_samplebounds = p; }
00170 inline QPoint SimplePlot::getSampleBounds() const
00171 { return d_samplebounds; }
00172 inline void SimplePlot::setLineAxisBounds(QPointF p)
00173 { d_lineaxisbounds = p; }
00174
00175 #endif // SIMPLEPLOT_H