/* * * This file is part of the Virtual Leaf. * * The Virtual Leaf is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The Virtual Leaf is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the Virtual Leaf. If not, see . * * Copyright 2010 Roeland Merks. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "data_plot.h" using namespace std; static const string _module_id("$Id$"); // // Initialize main window // DataPlot::DataPlot(QWidget *parent, const QString title, const QStringList curvenames ): QwtPlot(parent), d_interval(0), d_timerId(-1) { // Number of curves is number of names given ncurves = curvenames.size(); // allocate data and curves d_t = new double[PLOT_SIZE]; d_x = new double *[ncurves]; d_x[0] = new double[ncurves*PLOT_SIZE]; for (int i=1;isetFrameStyle(QFrame::Box | QFrame::Plain ); canvas()->setLineWidth(1); for ( int i = 0; i < QwtPlot::axisCnt; i++ ) { QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); if ( scaleWidget ) scaleWidget->setMargin(0); QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); if ( scaleDraw ) scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); } } // Generate new values void DataPlot::AddValue(double t,double *x) { // std::cerr << "AddValue receives: " << t << ", " << y << ", " << z << std::endl; // Plot slowly fills up, then shifts to the left if ( data_pos >= PLOT_SIZE ) { for ( int j = 0; j < PLOT_SIZE - 1; j++ ) d_t[j] = d_t[j+1]; for ( int i=0;iresize(400,300); show(); } PlotDialog::~PlotDialog(void) { delete plot; }