Select Git revision
plotter.cc 10.47 KiB
// **************************************************************************
// File: plotter.cc
//
// Author: Phil Gillaspy
//
// Last Modified: 04/18/2012
//
// Description:
// This is the class which plots the GQ GMC's CPM data.
//
// This code is virtually copied verbatim from the book "C++ GUI
// Programming with Qt4".
//
//
// *************************************************************************
#include <QtGui>
#include <cmath>
#include "plotter.hh"
extern int numPoints;
extern void getCPM(int i);
const int kSampleInterval = 10000; // CPM every 10 seconds
Plotter::Plotter(QWidget *parent)
: QWidget(parent)
{
setBackgroundRole(QPalette::Dark);
setAutoFillBackground(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setFocusPolicy(Qt::StrongFocus);
rubberBandIsShown = false;
zoomInButton = new QToolButton(this);
zoomInButton->setIcon(QIcon(":/images/zoomin.png"));
zoomInButton->adjustSize();
connect(zoomInButton, SIGNAL(clicked()), this, SLOT(zoomIn()));
zoomOutButton = new QToolButton(this);
zoomOutButton->setIcon(QIcon(":/images/zoomout.png"));
zoomOutButton->adjustSize();
connect(zoomOutButton, SIGNAL(clicked()), this, SLOT(zoomOut()));
setPlotSettings(PlotSettings());
sampleCnt = 0;
myTimerID = 0;
bScroll = false;
}
void Plotter::startSample()
{
myTimerID = startTimer(1000);
}
void Plotter::timerEvent(QTimerEvent * event)
{
if (event->timerId() == myTimerID)
{
getCPM(sampleCnt);
++sampleCnt;
if (sampleCnt >= numPoints)
{
bScroll = true;
sampleCnt = numPoints/2;
}
else
bScroll = false;