//---------------------------------------------------------------------------
void JrkPlotDialog::onUpdateGraph()
{
    JrkPlotData *curve;
    double v;
    int i, j, sample;

    // move data down one step
    if(dataCount >= SAMPLES) {
        v = INTERVAL/1000.0;

        for(i=0; i<(signed) jrkdata.size(); i++) {
            curve = (JrkPlotData *)jrkdata.at(i);

            for(j=1; j<SAMPLES; j++) {
                curve->data[j-1] = curve->data[j];

                if(i == 0)
                    timeData[j-1] += v;
            }
        }

        timeData[SAMPLES - 1] += v;
        ui->jrkPlot->setAxisScale(QwtPlot::xBottom, timeData[0], timeData[SAMPLES - 1]);
    }

    // qDebug("fb= %d sfb = %d", data_ptr->feedback, data_ptr->scaledFeedback);
    sample = dataCount < SAMPLES ? dataCount:(SAMPLES - 1);

    setCurveData(curve_input,               sample, data_ptr->input);
    setCurveData(curve_target,              sample, data_ptr->target);
    setCurveData(curve_feedback,            sample, data_ptr->feedback);
    setCurveData(curve_scaled_feedback,     sample, data_ptr->scaledFeedback);
    setCurveData(curve_error,               sample, pid_data_ptr->error);
    setCurveData(curve_integral,            sample, pid_data_ptr->integral);
    setCurveData(curve_derivative,          sample, pid_data_ptr->derivative);
    setCurveData(curve_duty_cycle_target,   sample, data_ptr->dutyCycleTarget);
    setCurveData(curve_duty_cycle,          sample, data_ptr->dutyCycle);
    setCurveData(curve_current,             sample, data_ptr->current);


    for(j=0; j<(signed) jrkdata.size(); j++) {
        curve = (JrkPlotData *)jrkdata.at(j);
        curve->curve->setRawSamples(timeData, curve->data, dataCount);
    }

    if(dataCount < SAMPLES)
        dataCount++;

    ui->jrkPlot->replot();
}
Пример #2
0
  MyPlot( QWidget *parent=0, char *name=0 ) : QwtPlot( parent, name )
  {
    // Show a title
    setTitle( "This is an Example" );

    // Show a legend at the bottom
    setAutoLegend( true );
    setLegendPos( Qwt::Bottom );

    // Show the axes
    setAxisTitle( xBottom, "x" );
    setAxisTitle( yLeft, "y" );

    // Insert two curves and get IDs for them
    long cSin = insertCurve( "y = sin(x)" );
    long cSign = insertCurve( "y = sign(sin(x))" );

    // Calculate the data, 500 points each
    const int points = 500;
    double x[ points ];
    double sn[ points ];
    double sg[ points ];

    for( int i=0; i<points; i++ )
    {
      x[i] = (3.0*3.14/double(points))*double(i);
    
      sn[i] = 2.0*sin( x[i] );
      sg[i] = (sn[i]>0)?1:((sn[i]<0)?-1:0);
    }

    // Copy the data to the plot
    setCurveData( cSin, x, sn, points );
    setCurveData( cSign, x, sg, points );

    // Set the style of the curves
    setCurvePen( cSin, QPen( blue ) );
    setCurvePen( cSign, QPen( green, 3 ) );

    // Show the plots
    replot();
  }
void PlotViewInterpolation::update() {
  ML::MatNxN C;
  int const& n = _p->_model->getDataDimension();
  for (int t = 0; t < TOTAL_INTERP; ++t) {
    for (int d = 0; d < n; ++d) {
      int c_id = n * t + d;
      INTERP_TYPE type = static_cast<INTERP_TYPE>(t);
      _p->_model->get1dCurve(type, d, 10.0f, &C);
      clearCurve(c_id);
      setCurveData(c_id, C, t);
    }
  }

  for (int d = 0, n = _p->_model->getDataDimension(); d < n; ++d) {
    int c_id = n * TOTAL_INTERP + d;
    _p->_model->get1dRegression(d, 10.0f, &C);
    clearCurve(c_id);
    setCurveData(c_id, C, TOTAL_INTERP);
  }
}
Пример #4
0
void PlotWindow::signalSmoothingChanged()
{
	// Filter the data
	filterCurveData();

	// Update the plots
	setCurveData();
	_plot->replot();

	// Update other windows viewing this data
	emit updateDataView();
}
Пример #5
0
void PlotWindow::drawGraphs()
{
	filterCurveData();
	setCurveData();
	if (_x_axis_measurement->currentIndex() == 0) // time
	{
		_plot->setAxisScale(QwtPlot::xBottom, 0, _data_log->totalTime());
	}
	else // distance
	{
		_plot->setAxisScale(QwtPlot::xBottom, 0, _data_log->totalDist());
	}
	_plot->setAxisScale(QwtPlot::yLeft,-15,230,0);
	_plot_zoomer->setZoomBase(true);
}