Results 1 to 1 of 1

Thread: qwt-6.0.2 subclassing QwtPlotCurve and reimpl. drawSymbols for rotated markers

  1. #1
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qwt-6.0.2 subclassing QwtPlotCurve and reimpl. drawSymbols for rotated markers

    Hello you all,
    I'm using qwt 6.0.2 and I'm trying to draw rotated markers by a custom angle, tipically 30° counterclockwise.

    Surfing the group, I found this thread in which is described how to plot custom markers/symbols: unfortunately doesn't work for me, because the signature of the method QwtPlotCurve::drawSymbols doesn't match with my version.
    How do I solve this?


    Added after 57 minutes:


    Actually I solved quick and dirty modifying directly QwtPlotMarker sources.

    Addedo to .h:

    Qt Code:
    1. void setLabelRotationAngle(double angle = 0.0);
    2. ...
    3. private:
    4. double _rotationAngle;
    To copy to clipboard, switch view to plain text mode 

    Added to .cpp:

    Qt Code:
    1. QwtPlotItem( QwtText( "Marker" ) ),
    2. _rotationAngle(0.0)
    3. {
    4. d_data = new PrivateData;
    5. setZ( 30.0 );
    6. }
    7. .....
    8. void QwtPlotMarker::setLabelRotationAngle(double angle)
    9. {
    10. _rotationAngle = angle;
    11. }
    To copy to clipboard, switch view to plain text mode 
    and into drawlabel method:

    Qt Code:
    1. void QwtPlotMarker::drawLabel( QPainter *painter,
    2. const QRectF &canvasRect, const QPointF &pos ) const
    3. {
    4. .....
    5. if (_rotationAngle != 0.0){
    6. painter->setRenderHint(QPainter::Antialiasing);
    7. painter->rotate(_rotationAngle);
    8. }
    9. const QRectF textRect( 0, 0, textSize.width(), textSize.height() );
    10. d_data->label.draw( painter, textRect );
    11. }
    To copy to clipboard, switch view to plain text mode 

    the client side:
    Qt Code:
    1. marker->setLabel(QString::fromLatin1(QDateTime::fromTime_t(ge->timestamp).toString("hh:mm").toAscii()));
    2. marker->setLabelOrientation(Qt::Horizontal);
    3. marker->setLinePen(QPen(Qt::darkGray, 0, Qt::DotLine));
    4. marker->setLineStyle(QwtPlotMarker::NoLine);
    5. marker->setXValue(ge->timestamp);
    6. marker->setYValue(d);
    7. marker->setLabelAlignment(Qt::AlignCenter | Qt::AlignLeft);
    8. // the tip:
    9. marker->setLabelRotationAngle(-30.0);
    10.  
    11. curve->add_marker(marker);
    12. marker->attach(this);
    To copy to clipboard, switch view to plain text mode 
    the results:
    Attached Images Attached Images
    Last edited by corrado1972; 13th May 2013 at 15:24.

Similar Threads

  1. Replies: 8
    Last Post: 9th February 2014, 12:37
  2. Resizing a rotated QGraphicsRectItem
    By Seishin in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2012, 15:31
  3. Replies: 8
    Last Post: 18th October 2012, 07:23
  4. Replies: 1
    Last Post: 11th May 2012, 08:02
  5. rotated labels
    By jayw710 in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2006, 17:47

Tags for this Thread

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.