Results 1 to 4 of 4

Thread: QwtSymbol problem

  1. #1
    Join Date
    Aug 2017
    Posts
    9
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default QwtSymbol problem

    Hi,

    How to set limit symbol number in the curve?

    I created symbol in my curve like below.
    Qt Code:
    1. curve->setSymbol( new QwtSymbol( QwtSymbol::Style(1) ,
    2. QBrush( curveColor ), QPen( curveColor ),
    3. QSize( 3.0, 3.0 ) ) );
    To copy to clipboard, switch view to plain text mode 

    When I show the curve, it appears thousand of symbols in my curve. Like below picture.
    Capture.jpg

    But, I only want to show 20 symbol in my curve. How to implement it?

    Thanks a lot!

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

    Default Re: QwtSymbol problem

    You have 2 options:


    1. overload QwtPlotCurve::drawSymbols ( preferable )
    2. disable symbols for the curve and use 20 QwtPlotMarkers


    Uwe

  3. The following user says thank you to Uwe for this useful post:

    lin3398032 (5th April 2018)

  4. #3
    Join Date
    Aug 2017
    Posts
    9
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtSymbol problem

    Hi Uwe,

    Thanks a lot.

    I try to implement drawSymbols like below
    Qt Code:
    1. void mycurveplot::drawSymbols(QPainter *painter, const QwtSymbol &symbol,
    2. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    3. int from, int to) const
    4. {
    5.  
    6. painter->setBrush(symbol.brush());
    7. painter->setPen(symbol.pen());
    8. const QwtMetricsMap &metricsMap = QwtPainter::metricsMap(); [COLOR="#FF0000"]//doesn't work in Qwt 6.0.1[/COLOR]
    9. QRect rect;
    10. rect.setSize(metricsMap .screenToLayout(symbol.size()));
    11.  
    12. if( to <= from || m_symboNumber <= 1 )
    13. return ;
    14.  
    15. int step ;
    16. if( m_symboNumber < to - from )
    17. step = ( to - from ) / ( m_symboNumber - 1 ) ;
    18. else
    19. step = 1 ;
    20. for (int i = from; i <= to; i += step )
    21. {
    22.  
    23. const double xi = xMap.transform(x(i)); [COLOR="#FF0000"]//doesn't work in Qwt 6.0.1[/COLOR]
    24. const double yi = yMap.transform(y(i)); //doesn't work in Qwt 6.0.1
    25. rect.moveCenter(QPoint(xi, yi));
    26. symbol.drawSymbol(painter, rect);
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    I find similar implement, but it seems it only work in Qwt 5.
    But where 'x()' come from in xMap.transform(x(i))?

    Also, since QwtMetricsMap is deprecated in Qwt6, is any class can replace it?
    Thanks!

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

    Default Re: QwtSymbol problem

    Quote Originally Posted by lin3398032 View Post
    But where 'x()' come from in xMap.transform?
    Qt Code:
    1. const QwtSeriesData< QPointF>* data = curve->data();
    2. for ( int i = 0; i < data->size(); i++ )
    3. {
    4. const QPointF point = data->sample( i );
    5. ....
    6. }
    To copy to clipboard, switch view to plain text mode 
    Also, since QwtMetricsMap is deprecated in Qwt6, is any class can replace it?
    This class was to work around limitations of an integer based graphic backend, but since Qt4 QPainter can deal with doubles

    Uwe

  6. The following user says thank you to Uwe for this useful post:

    lin3398032 (10th April 2018)

Similar Threads

  1. How to rotate QwtSymbol
    By Suchitra in forum Qwt
    Replies: 1
    Last Post: 2nd August 2014, 12:10
  2. Tooltip to QwtSymbol ???
    By jesse_mark in forum Qwt
    Replies: 15
    Last Post: 17th October 2012, 10:49
  3. Replies: 4
    Last Post: 29th March 2011, 21:33
  4. Alignment of QwtSymbol
    By FelixB in forum Qwt
    Replies: 2
    Last Post: 11th January 2011, 09:40
  5. QwtSymbol highlighting?
    By shud in forum Qwt
    Replies: 1
    Last Post: 2nd October 2009, 22:42

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.