Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

gapedrawingwidget.cpp

00001 #include "gapedrawingwidget.h"
00002 #include "qwt_plot_pixframe.h"
00003 #include <stdio.h>
00004 
00005 GapeDrawingWidget::GapeDrawingWidget (QWidget* parent)//, double* xData, double* yData, int bufSize)
00006 : QwtPlot(parent) {
00007 
00008     //preferredSize.setHeight(GAPE_DRAWING_WIDGET_MIN_HEIGHT);
00009     //preferredSize.setWidth(GAPE_DRAWING_WIDGET_MIN_WIDTH);
00010 
00011     setPlotBorder(GAPE_DRAWING_WIDGET_BORDER_OFFSET);
00012     key = insertCurve(NULL);//Samples in Time Domain");
00013     connect(this, SIGNAL(plotMouseMoved(const QMouseEvent &)), this, SLOT(receiveMouseMoveEvent(const QMouseEvent &)));
00014     setAutoReplot(false);
00015     //setAutoReplot(true);
00016     setMinimumSize(GAPE_DRAWING_WIDGET_MIN_WIDTH, GAPE_DRAWING_WIDGET_MIN_HEIGHT);
00017     //setBackgroundColor(GAPE_DRAWING_WIDGET_BG_COLOR);
00018     //setCurveColor(GAPE_DRAWING_WIDGET_CURVE_COLOR);
00019     enableGridY(true);
00020     enableGridX(false);
00021     //long mY = insertLineMarker("", QwtPlot::yLeft );
00022   //setMarkerYPos( mY, 0.0 );
00023   //setAxisScale(QwtPlot::xBottom, 0.0,1.0);
00024     //setAxisScale(QwtPlot::yLeft, -1.0,1.0);
00025 }
00026 
00027 
00028 void GapeDrawingWidget::setRawData(double* xData, double* yData, int bufferSize) {
00029     //GapeConsts::reportError("GDW srd\n");
00030     setCurveRawData(key, xData, yData, bufferSize);
00031     //setCurveData(key, xData, yData, bufferSize);
00032 }
00033 
00034 void GapeDrawingWidget::receiveMouseMoveEvent(const QMouseEvent &e ) {
00035     //GapeConsts::reportError("GapeDrawingWidget rec mouse move!\n");
00036     //char msg[256];
00037 
00038     double x, y;
00039 
00040     //the pixels reported by mouse events are generally off by a bit, and either wt or qwt has a
00041     //bug/feature where negative coordinates are reported in when our plot area is given a border.
00042     //the x scales to a 0.0 - 1.0 range
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     //same bug thing here, and we also must flip our y coordinate, since qt uses top left = 0,0
00052     //we also scale to a 0.0 to 1.0 range
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     //sprintf(msg,"pos = %g %g mouse = %d %d and max = %d %d\n",x,y,e.x(),e.y(),d_frmPlot->width(),d_frmPlot->height());
00062     //GapeConsts::reportError(msg);
00063     emit emitPoint(x,y);
00064 }

Generated at Thu Jun 21 13:28:49 2001 for GAPE by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001