Results 1 to 4 of 4

Thread: Drawing lines on qwtpolarplot

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    1

    Default Drawing lines on qwtpolarplot

    Hi,

    I am having some difficulties drawing multiple lines on my polar plot. I can create multiple qwtpolarmarkers on the plot but when I create a line of type qwtpolarcurve and attach it to the polar plot, only the last curve will be displayed.

    pseudo code to illustrate:
    Qt Code:
    1. QwtPolarMarker * polarmarker = new QwtPolarMarker();
    2. polarmarker->setPosition(......);
    3. polarmarker->attach(polarPlot);
    4. polarPlot->replot(); //1st marker is displayed
    5.  
    6. QwtPolarMarker * polarmarker2 = new QwtPolarMarker();
    7. polarmarker2->setPosition(......);
    8. polarmarker2->attach(polarPlot);
    9. polarPlot->replot(); //2nd marker is displayed
    10.  
    11. QwtPolarCurve * curve = new QwtPolarCurve();
    12. curve->setData(......);
    13. curve->attach(polarPlot);
    14. polarPlot->replot(); // 1st line is displayed
    15.  
    16. QwtPolarCurve * curve2 = new QwtPolarCurve();
    17. curve2->setData(......);
    18. curve2->attach(polarPlot);
    19. polarPlot->replot(); // 2nd line is displayed, 1st line disappears
    To copy to clipboard, switch view to plain text mode 

    I stepped through the codes and I can see that the 1st curve is plotted before disappearing on the last replot call. Any ideas on what I might be missing?

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drawing lines on qwtpolarplot

    Pseudo code is o.k. and of course it is possible to have more than one curve: see the examples.

    Uwe

  3. #3
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    1

    Default Re: Drawing lines on qwtpolarplot

    Hi Uwe,

    I realized that by calling replot on the polar plot anywhere in my program will cause any drawn qwtpolarcurve to disappear as well.

    Could it be the way I do setdata?

    Heres the code i used to pass into setdata:

    Qt Code:
    1. class PolarData: public QwtSeriesData<QwtPointPolar>
    2. {
    3. public:
    4. PolarData (const double* x, const double* y, size_t size) :
    5. d_x (x),
    6. d_y (y),
    7. d_size (size) {}
    8.  
    9. virtual QRectF boundingRect() const {
    10. if (d_boundingRect.width() < 0) {
    11. d_boundingRect = qwtBoundingRect (*this);
    12. }
    13. return d_boundingRect;
    14. }
    15.  
    16. virtual size_t size() const {
    17. return d_size;
    18. }
    19. virtual QwtPointPolar sample (size_t i) const {
    20. return QwtPointPolar (d_x[int (i)], d_y[int (i)]);
    21. }
    22.  
    23. private:
    24. const double* d_x;
    25. const double* d_y;
    26. size_t d_size;
    27. };
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,241
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drawing lines on qwtpolarplot

    Depends on what happens to the memory d_x, d_y are pointing to.

    Uwe

Similar Threads

  1. Replies: 3
    Last Post: 7th March 2013, 06:14
  2. drawing lines using qpainter from file
    By neutrino in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2013, 09:03
  3. QwtPolarPlot questions
    By Galabis in forum Qwt
    Replies: 4
    Last Post: 28th June 2012, 06:16
  4. Animating a QwtPolarPlot
    By bwnicewo in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2012, 17:54
  5. Drawing row/column lines in QTreeWidget
    By warvimo in forum Newbie
    Replies: 0
    Last Post: 25th May 2012, 17: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.