00001 #include "gapedrawingwidget.h"
00002 #include "qwt_plot_pixframe.h"
00003 #include <stdio.h>
00004
00005 GapeDrawingWidget::GapeDrawingWidget (QWidget* parent)
00006 : QwtPlot(parent) {
00007
00008
00009
00010
00011 setPlotBorder(GAPE_DRAWING_WIDGET_BORDER_OFFSET);
00012 key = insertCurve(NULL);
00013 connect(this, SIGNAL(plotMouseMoved(const QMouseEvent &)), this, SLOT(receiveMouseMoveEvent(const QMouseEvent &)));
00014 setAutoReplot(false);
00015
00016 setMinimumSize(GAPE_DRAWING_WIDGET_MIN_WIDTH, GAPE_DRAWING_WIDGET_MIN_HEIGHT);
00017
00018
00019 enableGridY(true);
00020 enableGridX(false);
00021
00022
00023
00024
00025 }
00026
00027
00028 void GapeDrawingWidget::setRawData(double* xData, double* yData, int bufferSize) {
00029
00030 setCurveRawData(key, xData, yData, bufferSize);
00031
00032 }
00033
00034 void GapeDrawingWidget::receiveMouseMoveEvent(const QMouseEvent &e ) {
00035
00036
00037
00038 double x, y;
00039
00040
00041
00042
00043 if (e.x() < 0) {
00044 x = 0.0;
00045 } else if (e.x() > d_frmPlot->width() - 2 * GAPE_DRAWING_WIDGET_BORDER_OFFSET) {
00046 x = 1.0;
00047 } else {
00048 x = (double) e.x() / (double) (d_frmPlot->width() - 2 * GAPE_DRAWING_WIDGET_BORDER_OFFSET);
00049 }
00050
00051
00052
00053 if (e.y() < 0) {
00054 y = 1.0;
00055 } else if (e.y() > d_frmPlot->height() - 2 * GAPE_DRAWING_WIDGET_BORDER_OFFSET) {
00056 y = 0.0;
00057 } else {
00058 y = 1.0 - ((double) e.y() / (double) (d_frmPlot->height() - 2 * GAPE_DRAWING_WIDGET_BORDER_OFFSET));
00059 }
00060
00061
00062
00063 emit emitPoint(x,y);
00064 }