Results 1 to 6 of 6

Thread: Curve legend doesn't show a symbol entirely

  1. #1
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Curve legend doesn't show a symbol entirely

    Hello all,

    I faced with a problem that using QwtPlotCurve::LegendShowSymbol doesn't show a symbol (a circle in my case) in a legend entirely:
    legend1.png

    Here is an example code:
    Qt Code:
    1. class TestPlot: public QwtPlot
    2. {
    3.  
    4. public:
    5.  
    6. TestPlot(QWidget * parent = NULL);
    7.  
    8. private:
    9.  
    10. QwtPlotCurve _curve;
    11.  
    12. };
    13.  
    14. TestPlot::TestPlot(QWidget * parent) : QwtPlot(parent)
    15. {
    16.  
    17. QwtSymbol *sym = new QwtSymbol(QwtSymbol::Ellipse);
    18. sym->setSize(5);
    19. sym->setPen(QColor(Qt::blue));
    20.  
    21. _curve.setSymbol(sym);
    22. _curve.setStyle(QwtPlotCurve::NoCurve);
    23. _curve.setTitle(tr ("Curve"));
    24. _curve.setLegendAttribute(QwtPlotCurve::LegendShowSymbol);
    25. _curve.attach(this);
    26.  
    27. QVector <double> x;
    28.  
    29. for (unsigned i = 0; i < 10; ++i)
    30. {
    31. x.push_back(i);
    32. }
    33.  
    34. _curve.setSamples(x, x);
    35.  
    36. QwtLegend *legend = new QwtLegend(this);
    37. insertLegend(legend, QwtPlot::BottomLegend);
    38. }
    To copy to clipboard, switch view to plain text mode 

    If I change a symbol size from 5 to 10 everything looks nice:
    legend2.png

    Does anybody know why this can happen?
    Thanks for any help!

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

    Default Re: Curve legend doesn't show a symbol entirely

    I can't confirm this on my box.

    What version of Qwt/Qt on which platform do you have. Does it still happen with Qwt from SVN trunk ?

    Uwe

  3. #3
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Curve legend doesn't show a symbol entirely

    Yes, it happens with the last Qwt version from SVN trunk.

    I use Qt 4.7.0 and platform is Windows 7 Professional.

  4. #4
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Curve legend doesn't show a symbol entirely

    I've figured it out!

    The problem is in using even/odd QwtSymbol sizes.
    E.g. it is better to set an even size using a circle (QwtSymbol::Ellipse), and odd size using QwtSymbol::Star1.

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

    Default Re: Curve legend doesn't show a symbol entirely

    Ah o.k. but then the odd size of the ellipse should be also bad on the plot itself ?

    Unfortunately I had to rewrite much of the symbol code for Qwt 6 because of the floating point based render engine ( + symbols can be cached in a pixmap, what is sometimes faster ). So I might have introduced bugs in this version.

    Uwe

  6. #6
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Curve legend doesn't show a symbol entirely

    The ellipse with an odd side looks ok by itself. But if I put a circle with an odd size in a circe with an even size there is a problem that the inner circle looks asymmetrical:

    legend3.png

    Qt Code:
    1. QwtSymbol *sym1 = new QwtSymbol(QwtSymbol::Ellipse);
    2. sym1->setSize(14);
    3. sym1->setPen(QColor(Qt::blue));
    4.  
    5. _curve1.setSymbol(sym1);
    6. _curve1.setStyle(QwtPlotCurve::NoCurve);
    7. _curve1.attach(this);
    8.  
    9. QwtSymbol *sym2 = new QwtSymbol(QwtSymbol::Ellipse, Qt::black, QColor(Qt::black), QSize(7, 7));
    10.  
    11. _curve2.setSymbol(sym2);
    12. _curve2.setStyle(QwtPlotCurve::NoCurve);
    13. _curve2.attach(this);
    14.  
    15. QVector <double> x;
    16.  
    17. for (unsigned i = 0; i < 10; ++i)
    18. {
    19. x.push_back(i);
    20. }
    21.  
    22. _curve1.setSamples(x, x);
    23. _curve2.setSamples(x, x);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QGraphicsTextItem doesn't show up
    By chapu in forum Qt Programming
    Replies: 6
    Last Post: 12th July 2010, 01:48
  2. Replies: 1
    Last Post: 22nd June 2010, 20:56
  3. Replies: 3
    Last Post: 26th March 2010, 22:25
  4. Drawing curve legend
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 04:42
  5. Replies: 3
    Last Post: 22nd January 2010, 17:46

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.