QwtPlotCurve * PlotViewWidget::addCurveData(WaveformData *curveData, bool secondary, QColor col)
{
    maWaveformData << curveData;

    QwtPlotCurve *waveCurve = new QwtPlotCurve("dummy");
    waveCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    waveCurve->setPen(QPen(col));
    waveCurve->setSamples( curveData );
    maCurves << waveCurve;
    waveCurve->attach(this);

    if( !mSecondaryAxis || maCurves.length() == 0 ) // no secondary axis or just one plot
    {
        replot();
        setAxisScaleDiv(QwtPlot::yRight, axisScaleDiv(QwtPlot::yLeft));
        replot();
    }
    else
    {
        if(secondary)
        {
            setAxisAutoScale(QwtPlot::yRight);
            waveCurve->setYAxis(QwtPlot::yRight);
        }
        else
        {
            waveCurve->setYAxis(QwtPlot::yLeft);
        }
    }

    repaint();
    return waveCurve;
}
Esempio n. 2
0
void HarmPlot::addCurves() throw (QLE)
{
    Harmonics* harmonics = new Harmonics(this->dir, this->ii);
    for(int i=0; i <= MAX_HARM - 2; i++) {
        this->data[i] = harmonics->getHarm(i+2); // begin from second harmonic
        if( ! this->data[i])
            continue; // have not more harmonic in IR

        QString name = "Harmonic";
        name += i;
        QwtPlotCurve* curve = new QwtPlotCurve(name);
        curve->setPen(QPen(HARM_COLORS[i]));
        curve->setYAxis(QwtPlot::yLeft);
        curve->attach(this);
        curve->setSamples(this->data[i]->freqs, this->data[i]->values, this->data[i]->length);
    }
    delete harmonics;
}
Esempio n. 3
0
IRPlot::IRPlot(const QString& aDir, IRInfo anIi, QWidget *parent) throw (QLE) : QwtPlot(parent)
{
    this->dir = aDir;
    this->ii = anIi;

    this->time = 0;
    this->amps = 0;

    this->setAutoReplot(false);
    this->setCanvasBackground(BG_COLOR);

    unsigned curveLength = this->calculate();

    this->setAxisScale( xBottom, this->time[0], this->time[curveLength-1]);
    this->setAxisAutoScale( xBottom);
    this->setAxisScale( yLeft, -1.5, 1.5);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
#if QWT_VERSION > 0x060000
    grid->setMajorPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinorPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#else
    grid->setMajPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#endif
    grid->attach(this);

    QwtPlotCurve* ampCurve = new QwtPlotCurve("IR_Plot");
    ampCurve->setPen(QPen(AMP_CURVE_COLOR));
    ampCurve->setYAxis(QwtPlot::yLeft);
    ampCurve->attach(this);
    ampCurve->setSamples(this->time, this->amps, curveLength);

    QwtPlotPanner* panner = new QwtPlotPanner(this->canvas());
    panner->setMouseButton(Qt::MidButton);
    panner->setEnabled(true);

    this->setAutoReplot(true);
}
Esempio n. 4
0
void LinePlot::linePlotData(LinePlotData::Ptr data,  const std::string& name, QColor color, double offset )
{
  if (!data) return;


  // set based on data - record overall min and max
  if ( (data->minX() < m_xAxisMin) || (data->maxX() > m_xAxisMax) )
  {
    if  (data->minX() < m_xAxisMin) m_xAxisMin = data->minX();
    if  (data->maxX() > m_xAxisMax) m_xAxisMax = data->maxX();
  }
  if (numberOfCurves() == 0)
  {
    m_lineThickness = 10;
  }


  /// todo - curve collection - shared pointers
  QwtPlotCurve * curve = new QwtPlotCurve(toQString(name));
  if (color == Qt::color0) 
  { // generate new color from color map
    color = curveColor(m_lastColor);
    m_lastColor = color;
  }
  curve->setPen(curvePen(color));
  curve->attach(m_qwtPlot);
  curve->setData(*data);

  // check for number of different units (std::string  based)
  QString curveUnits = toQString(data->units());
  if (m_leftAxisUnits == "NONE SPECIFIED")
  {
    m_leftAxisUnits = curveUnits;
    this->leftAxisTitleFromUnits(toString(m_leftAxisUnits));
    curve->setYAxis(QwtPlot::yLeft);
    m_qwtPlot->enableAxis(QwtPlot::yRight, false);
  }
  else if (m_leftAxisUnits.toUpper() == curveUnits.toUpper())
  {
    curve->setYAxis(QwtPlot::yLeft);
    m_qwtPlot->enableAxis(QwtPlot::yRight, false);
  }
  else if (m_rightAxisUnits == "NONE SPECIFIED")
  {
    m_rightAxisUnits = curveUnits;
    this->rightAxisTitleFromUnits(toString(m_rightAxisUnits));
    curve->setYAxis(QwtPlot::yRight);
    m_qwtPlot->enableAxis(QwtPlot::yRight, true);
  }
  else if (m_rightAxisUnits.toUpper() == curveUnits.toUpper())
  {
    curve->setYAxis(QwtPlot::yRight);
    m_qwtPlot->enableAxis(QwtPlot::yRight, true);
  }
  else // more than 2 units - scale all curves
  {
    scaleCurves(curve);
    m_qwtPlot->enableAxis(QwtPlot::yRight, false);
    this->leftAxisTitle("Scaled");
  }



/// update legend and replot
  showCurve(curve, true);

//  initZoomer();

}