Results 1 to 5 of 5

Thread: qwt several curves at a plot

  1. #1
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qwt several curves at a plot

    I have a problem using the member function attach several times. I have attached many curves, than I make replot. As a result, only last attached curve is visible. Compiler does not find any errors. Here is my member function which draws several characteristics stored in ps_x and ps_y sequentially in the single column. The number of characteristics equals number_of_characteristics. I use qwt 6. version.

    Qt Code:
    1. void DataPlot::plot_Draw(double ps_x[], double ps_y[], double x_min, double x_max, double y_min, double y_max, int number_of_characteristics)
    2. {
    3. double psx[1500];
    4. double psy[1500];
    5.  
    6. setAxisScale(QwtPlot::xBottom, x_min, x_max);
    7. setAxisScale(QwtPlot::yLeft, y_min, y_max);
    8.  
    9. QwtPlotCurve *d_curves[number_of_characteristics];
    10.  
    11. for (int j=0;j<number_of_characteristics;j++){
    12.  
    13. d_curves[j] = new QwtPlotCurve("Gain spectra");
    14. d_curves[j]->setRenderHint(QwtPlotItem::RenderAntialiased);
    15. d_curves[j]->setPen(QPen(QColor(150,150,200),2));
    16. d_curves[j]->setStyle(QwtPlotCurve::Lines);
    17.  
    18. for (int j1=0;j1<1500;j1++){
    19. psx[j1]=ps_x[j1+j*1500];
    20. psy[j1]=ps_y[j1+j*1500];
    21. };
    22. // Insert new curves
    23. d_curves[j]->setRawSamples(psx,psy,1500);
    24. d_curves[j]->attach(this);
    25. };
    26. replot();
    27. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Dec 2010
    Location
    US, Washington State
    Posts
    54
    Thanks
    3
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwt several curves at a plot

    Probably this, from docs on QwtPlotCurve::attach
    Attach the item to a plot.

    This method will attach a QwtPlotItem to the QwtPlot argument. It will first detach the QwtPlotItem from any plot from a previous call to attach (if necessary). If a NULL argument is passed, it will detach from any QwtPlot it was attached to.

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

    Default Re: qwt several curves at a plot

    Use setSamples instead of setRawSamples.

    Uwe

  4. #4
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qwt several curves at a plot

    Thank you Uwe! setSemples works perfect in my case.

    What is difference between these functions? Where can I find tutorial for qwt 6.0. ?

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,258
    Thanked 862 Times in 811 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwt several curves at a plot

    Quote Originally Posted by freude3 View Post
    Yes, but how does in this case can the demo "sinusplot" works?
    The bad code assigns memory from the stack without copying it. What has this to do with the sinusplot example - that uses a synthetic data class without storing arrays at all.

    Uwe

Similar Threads

  1. qwt display curves
    By sergio486 in forum Qt Programming
    Replies: 0
    Last Post: 11th December 2010, 22:27
  2. Information about curves
    By den in forum Qwt
    Replies: 1
    Last Post: 27th April 2010, 20:02
  3. Replies: 1
    Last Post: 7th December 2009, 15:59
  4. Multiple curves on top of each other
    By jmsbc in forum Qwt
    Replies: 2
    Last Post: 15th July 2009, 20:46
  5. Replies: 7
    Last Post: 22nd September 2008, 23:05

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.