Results 1 to 3 of 3

Thread: Replot dinamic curve.

  1. #1
    Join Date
    Jul 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Replot dinamic curve.

    Hi,

    I have extended the class QwtPlot like the example "Oscilloscope". I must write a similar code but more simple. I have a thread "out of my control" that emit a signal each 100 msec. I have write in my custom class this slot:

    Qt Code:
    1. void Plot::addSampledPoint(double time, double sample)
    2. {
    3. samples.append(QPointF(time, sample));
    4. d_curve->setSamples(samples);
    5.  
    6. const QwtScaleMap xMap = canvasMap( d_curve->xAxis() );
    7. const QwtScaleMap yMap = canvasMap( d_curve->yAxis() );
    8. QwtSeriesData<QPointF> *data=d_curve->data();
    9.  
    10. QRectF br = qwtBoundingRect( *data, 0, data->size()-1 );
    11. const QRect clipRect = QwtScaleMap::transform( xMap, yMap, br ).toRect();
    12. d_directPainter->setClipRegion( clipRect );
    13. d_directPainter->drawSeries(d_curve, 0, data->size()-1);
    14. }
    To copy to clipboard, switch view to plain text mode 

    When the samples are a QVector compatible with setSamples. I have no error but when I start the sampling I don't see anything.

    P.s. If I initialize the samples when I write d_curve->attach(this) I van see the point.

    Any suggest? Sorry for my simple English. (Obviously thank you at all).

  2. #2
    Join Date
    Jul 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Replot dinamic curve.

    Hi, I have try with a code more simple code:

    Qt Code:
    1. CurveData *data = static_cast<CurveData *>( d_curve->data() );
    2. QPointF *point=new QPointF(1000, 100);
    3. data->append(*point);
    4.  
    5. QPointF *point2=new QPointF(2000, 10);
    6. data->append(*point2);
    7.  
    8. d_directPainter->drawSeries(d_curve, data->size() - 1, data->size()-1);
    9. replot();
    To copy to clipboard, switch view to plain text mode 

    The graph is ever empty. There are some parameters of canvas() or QwtPlot that I have omitted?

    P.s. What happens when we run "drawSeries" and "replot()" ??

    Thank you all!

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Replot dinamic curve.

    2 problems in your code:

    • Memory leaks: no need for using new here
    • You need to draw the last 2 points, when you want to add a line

    Uwe

Similar Threads

  1. how to get zoomer to replot
    By kja in forum Newbie
    Replies: 3
    Last Post: 17th November 2010, 07:15
  2. Replies: 4
    Last Post: 29th April 2010, 06:11
  3. how to accelerate the replot?
    By rambo83 in forum Qwt
    Replies: 6
    Last Post: 17th March 2010, 11:11
  4. Replies: 1
    Last Post: 22nd January 2010, 14:34
  5. QResource dinamic append resource on run app
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2006, 19:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.