Exemplo n.º 1
0
/*!
  \brief Draw a set of points of a curve.
  When observing an measurement while it is running, new points have to be
  added to an existing curve. drawCurve can be used to display them avoiding
  a complete redraw of the canvas.

  \param key curve key
  \param from index of the first point to be painted
  \param to index of the last point to be painted. If to < 0 the
         curve will be painted to its last point.
  \sa QwtCurve::draw
*/
void QwtPlot::drawCurve(long key, int from, int to)
{
    QwtPlotCurve *curve = d_curves->find(key);
    if ( !curve )
        return;

    QPainter p(canvas());

    p.setClipping(TRUE);
    p.setClipRect(canvas()->contentsRect());

    curve->draw(&p,
        canvasMap(curve->xAxis()), canvasMap(curve->yAxis()),
        from, to);

    if ( canvas()->cacheMode() && canvas()->cache())
    {
        QPainter cachePainter(canvas()->cache());
        cachePainter.translate(-canvas()->contentsRect().x(),
            -canvas()->contentsRect().y());

        curve->draw(&cachePainter,
            canvasMap(curve->xAxis()), canvasMap(curve->yAxis()),
            from, to);
    }
}
Exemplo n.º 2
0
//! Redraw grid, curves, and markers. The draw code
//  does not clear clipRegion prior to painting.
//  \param p painter used for drawing
void QwtPlot::drawCanvas(QPainter *p)
{
    QwtDiMap map[axisCnt];
    for ( int axis = 0; axis < axisCnt; axis++ )
        map[axis] = canvasMap(axis);

    QRect rect = d_canvas->contentsRect();

    //
    // draw grid
    //
    if ( d_grid.enabled() &&
         axisEnabled( d_grid.xAxis() ) &&
         axisEnabled( d_grid.yAxis() ) )
    {
        d_grid.draw(p, rect, map[d_grid.xAxis()], map[d_grid.yAxis()]);
    }

    //
    //  draw curves
    //

    QIntDictIterator<QwtPlotCurve> itc(*d_curves);
    for (QwtPlotCurve *curve = itc.toFirst(); curve != 0; curve = ++itc )
    {
      if ( curve->enabled() &&
           axisEnabled( curve->xAxis() ) &&
           axisEnabled( curve->yAxis() ) )
      {
            curve->draw(p, map[curve->xAxis()], map[curve->yAxis()]);
      }
    }

    //
    // draw markers
    //

    QIntDictIterator<QwtPlotMarker> itm(*d_markers);
    for (QwtPlotMarker *marker = itm.toFirst(); marker != 0; marker = ++itm )
    {
        if ( marker->enabled() && axisEnabled( marker->xAxis() ) &&
               axisEnabled( marker->yAxis() ) )
        {
            marker->draw(p,
                map[marker->xAxis()].transform(marker->xValue()),
                map[marker->yAxis()].transform(marker->yValue()),
                rect);
        }
    }
}
Exemplo n.º 3
0
void QwtPlot::drawCanvasItems(QPainter *painter, const QRect &rect, 
        const QwtArray<QwtDiMap> &map, const QwtPlotPrintFilter &pfilter) const
{
    //
    // draw grid
    //
    if ( pfilter.options() & QwtPlotPrintFilter::PrintGrid )
    {
        if ( d_grid->enabled() )
        {
            d_grid->draw(painter, rect, 
                map[d_grid->xAxis()], map[d_grid->yAxis()]);
        }
    }

    //
    //  draw curves
    //
    QwtPlotCurveIterator itc = curveIterator();
    for (QwtPlotCurve *curve = itc.toFirst(); curve != 0; curve = ++itc )
    {
        if ( curve->enabled() )
        {
            curve->draw(painter, 
                map[curve->xAxis()], map[curve->yAxis()]);
        }
    }

    //
    // draw markers
    //
    QwtPlotMarkerIterator itm = markerIterator();
    for (QwtPlotMarker *marker = itm.toFirst(); marker != 0; marker = ++itm )
    {
        if ( marker->enabled() )
        {
            marker->draw(painter,
                map[marker->xAxis()].transform(marker->xValue()),
                map[marker->yAxis()].transform(marker->yValue()),
                rect);
        }
    }
}
Exemplo n.º 4
0
void MainWin::drawContents( QPainter *painter )
{
    int deltay, i;

    QRect r = contentsRect();

    deltay = r.height() / CurvCnt - 1;

    r.setHeight( deltay );


    xMap.setPaintInterval( r.left(), r.right() );
    yMap.setPaintInterval( r.top(), r.bottom() );

    painter->setRenderHint( QPainter::Antialiasing,
	curve.testRenderHint( QwtPlotItem::RenderAntialiased ) );
    curve.draw( painter, xMap, yMap, r );

}