Results 1 to 4 of 4

Thread: Plot only part of QwtCurve in real time plot

  1. #1
    Join Date
    Mar 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Plot only part of QwtCurve in real time plot

    I have a QVector in which I'm constantly appending data so I can plot on a QwtPlot. But with a high frequency I guess the vector becames too large and the program crashes.

    My question is, how can I create a QwtCurve which is only beggining in some point of time, bacause the time that has already passed is not necessary in the vector as it was already plotted.

    here's my code:

    Qt Code:
    1. QVector<double> xv;
    2. QVector<double> cv1;
    3. QVector<double> cv2;
    To copy to clipboard, switch view to plain text mode 

    as global variables,

    Qt Code:
    1. void gui::process_new_info(QByteArray array)
    2. {
    3. int v = 0;
    4.  
    5. double f = ui->frequency->value();
    6.  
    7. xv.append(sizeof_array/f);
    8.  
    9. char *buf = array.data();
    10.  
    11. if (ui->ecgPlux->isChecked() == true || ui->channel_1->currentIndex() != 0)
    12. {
    13. cv1.append(buf[1]);
    14.  
    15. QwtPlotCurve *curve1 = new QwtPlotCurve;
    16. curve1->attach(plot_all[0]);
    17. curve1->setData(xv,cv1);
    18. curve1->setPen(QPen(Qt::blue,1));
    19. plot_all[0]->replot();
    20.  
    21. QwtPlotCurve *curve2 = new QwtPlotCurve;
    22. curve2->attach(plot[0]);
    23. curve2->setData(xv,cv1);
    24. curve2->setPen(QPen(Qt::blue,1));
    25. plot[0]->replot();
    26. }
    27.  
    28. if (ui->xyzPlux->isChecked() == true || ui->channel_2->currentIndex() != 0)
    29. {
    30. cv2.append(buf[2]);
    31.  
    32. QwtPlotCurve *curve3 = new QwtPlotCurve;
    33. curve3->attach(plot_all[1]);
    34. curve3->setData(xv,cv2);
    35. curve3->setPen(QPen(Qt::blue,1));
    36. plot_all[0]->replot();
    37.  
    38. QwtPlotCurve *curve4 = new QwtPlotCurve;
    39. curve4->attach(plot[1]);
    40. curve4->setData(xv,cv1);
    41. curve4->setPen(QPen(Qt::blue,1));
    42. plot[1]->replot();
    43. }
    44.  
    45. //printf ("%d ->", buf[0]);
    46. fprintf (data, "%d,", buf[0]);
    47.  
    48. for (int i = 1; i < 9; i++)
    49. {
    50. v = buf[i];
    51. //printf ("%d,", v);
    52. fprintf (data, "%d,", v);
    53. }
    54.  
    55. //printf ("\n");
    56. fprintf (data, "\n");
    57.  
    58. sizeof_array++;
    59. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plot only part of QwtCurve in real time plot

    I got it to work. I'll publish it later in case someone else needs it.

  3. #3
    Join Date
    Jan 2013
    Posts
    21
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Plot only part of QwtCurve in real time plot

    Hi, SamuelNLP
    I met the same question with you. How did you solve it? Would you like to publish your code? Thank you very much.

  4. #4
    Join Date
    Apr 2013
    Posts
    9
    Qt products
    Qt4 Qt5

    Default Re: Plot only part of QwtCurve in real time plot

    Sir,

    I'm new to QT and QWT. Can u please give me a sample code of realtime plotting. My requirement is "Read the data [eg: Roll and Pitch] from a .bin file and plot based on time. I have tried.. but it is not plotting based on time

    Thanks
    Sree

Similar Threads

  1. How to plot real time x/y graph in Qtopia
    By desperado_43 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 18th May 2012, 08:00
  2. real time graph plot
    By robotics in forum Qt Programming
    Replies: 5
    Last Post: 24th May 2011, 05:04
  3. Replies: 1
    Last Post: 27th April 2011, 10:35
  4. QFileSystemWatcher with a Qwt Real-time plot
    By gen_mass in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2010, 21:28
  5. Best way in Qt to plot curve per real-time reading?
    By Sheng in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2009, 22:33

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.