caStripPlot::caStripPlot(QWidget *parent): QwtPlot(parent) { timerID = false; thisXaxisType = TimeScale; HISTORY = 60; thisUnits = Second; thisPeriod = 60; NumberOfCurves = MAXCURVES; onInit = true; timeInterval = 1.0; setAutoReplot(false); setAutoFillBackground(true); Start = true; // define a grid plotGrid = new QwtPlotGrid(); plotGrid->attach(this); plotLayout()->setAlignCanvasToScales(true); // define our axis if(thisXaxisType == TimeScale) { setAxisScale(QwtPlot::xBottom, 0, HISTORY); } else { setAxisScale(QwtPlot::xBottom, -HISTORY, 0); } setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom); setAxisScale(QwtPlot::yLeft, 0, 1000); if(thisXaxisType == TimeScale) { // due to time scale we need some distance scaleWidget = axisWidget(QwtPlot::xBottom); const int fmh = QFontMetrics(scaleWidget->font()).height(); scaleWidget->setMinBorderDist(fmh * 2, fmh * 2); // define time axis QTime timeNow= QTime::currentTime(); setAxisScaleDraw ( QwtPlot::xBottom, new TimeScaleDraw ( timeNow ) ); } // define our curves for(int i=0; i< MAXCURVES; i++) { curve[i] = new QwtPlotCurve(); errorcurve[i] = new QwtPlotIntervalCurve(); fillcurve[i] = new QwtPlotIntervalCurve(); if(i>0) { curve[i]->setZ(curve[i]->z() - i); fillcurve[i]->setZ(fillcurve[i]->z() - i); errorcurve[i]->setZ(errorcurve[i]->z() - i); } curve[i]->attach(this); errorcurve[i]->attach(this); fillcurve[i]->attach(this); showCurve(i, false); thisYaxisLimitsMax[i] = 100; thisYaxisLimitsMin[i] = 0; } // default colors and styles setTitlePlot(""); setTitleX(""); setTitleY(""); setBackground(Qt::black); setForeground(QColor(133, 190, 232)); setScaleColor(Qt::black); setGrid(true); setGridColor(Qt::gray); for(int i=0; i< MAXCURVES; i++) setStyle(Lines, i); setColor(Qt::white, 0); setColor(Qt::red, 1); setColor(Qt::yellow, 2); setColor(Qt::cyan, 3); setColor(Qt::magenta, 4); setColor(Qt::green, 5); setColor(Qt::blue, 6); setXaxisEnabled(true); setYaxisEnabled(true); setLegendEnabled(true); setAxisFont(QwtPlot::xBottom, QFont("Arial", 10)); setAxisFont(QwtPlot::yLeft, QFont("Arial", 10)); installEventFilter(this); // display timer Timer = new QTimer(this); Timer->setInterval(1000); connect(Timer, SIGNAL(timeout()), this, SLOT(TimeOut())); // data collection thread timerThread = new stripplotthread(); timerThread->start(); timerThread->threadSetTimer(100); timerThread->setPriority(QThread::HighPriority); connect(this, SIGNAL(timerThreadStop()), timerThread, SLOT(runStop())); connect(timerThread, SIGNAL(update()), this, SLOT(TimeOutThread()), Qt::DirectConnection); }
caWaterfallPlot::caWaterfallPlot(QWidget *parent): QWidget(parent) { QHBoxLayout *hboxLayout = new QHBoxLayout(this); thisCountNumber = 0; datamutex = new QMutex; // define a new plot plot = new QwtPlot(this); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); plot->setSizePolicy(sizePolicy); // add it to layout hboxLayout->addWidget(plot); // define spectrogram d_spectrogram = new QwtPlotSpectrogram(); d_spectrogram->setRenderThreadCount(0); // use system specific thread count d_spectrogram->setColorMap(new ColorMap_Wavelength()); // define data m_data = new SpectrogramData(); // set 200 rows ( NumberofColumns columns for demo setRows(nbRows); setCols(nbCols); ActualNumberOfColumns = NumberOfColumns = nbCols; reducedArray = (double*) malloc(ActualNumberOfColumns * sizeof(double)); memset(reducedArray, 0, ActualNumberOfColumns *sizeof(double)); // initialize data m_data->initData(NumberOfColumns, getRows()); thisIntensityMin = 0; thisIntensityMax = 1000; setIntensityScalingMax(Channel); setIntensityScalingMin(Channel); // set data to spectrogram countRows = 0; d_spectrogram->setData(m_data); d_spectrogram->attach(plot); // define a grid plotGrid = new QwtPlotGrid(); plotGrid->attach(plot); // no titles yet setTitlePlot(""); setTitleX(""); setTitleY(""); // enable axis setXaxisEnabled(true); setYaxisEnabled(true); setCustomMap(""); setDiscreteCustomMap(false); setColormap(spectrum_wavelength); updatePlot(); firstMonitorPlot = firstDemoPlot = firstTimerPlot = true; // set a timer for nice demo thisUnits = Millisecond; thisPeriod = 200; Timer = new QTimer(this); Timer->setInterval((int) thisPeriod); Timer->start(); position = 0.0; drift = 1.0; disableDemo = false; connect(Timer, SIGNAL(timeout()), this, SLOT(TimeOut())); }