Results 1 to 3 of 3

Thread: How to rotate markers in qwt

  1. #1
    Join Date
    Aug 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to rotate markers in qwt

    I want to rotate my marker in my plot but i cant. Here is my code to adding images to plot:

    Qt Code:
    1. QPixmap pixmap("image");
    2.  
    3. QwtSymbol *symbol = new QwtSymbol;
    4. symbol->setPixmap(pixmap);
    5.  
    6. marker = new QwtPlotMarker;
    7. marker->setSymbol( symbol);
    8. marker->attach(this);
    To copy to clipboard, switch view to plain text mode 

    I tried to rotate with QTransform but i couldnt achive. Is there any trick to solve this problem?

    Thanks.

  2. #2
    Join Date
    Dec 2013
    Location
    Toronto, Canada
    Posts
    62
    Thanked 16 Times in 15 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to rotate markers in qwt

    I have not tried anything close to this...
    You could...

    Qt Code:
    1. QwtPlotMarker * marker;
    2. ....
    3. ....
    4.  
    5. QMatrix m...
    6. m.rotate(angleOfRotation);
    7.  
    8. const QwtSymbol* oldSymbol = marker->symbol();
    9.  
    10. QwtSymbol* newSymbol = new QwtSymbol(m.map(oldSymbol->path()), oldSymbol->brush(), oldSymbol->pen());
    11.  
    12. marker->setSymbol(newSymbol);
    13. ...
    To copy to clipboard, switch view to plain text mode 


    Added after 32 minutes:


    Or
    ...
    Qt Code:
    1. CustSymbol : public QwtSymbol
    2. {
    3. public:
    4. ...
    5. double rotation()const
    6. {
    7. return _rotation;
    8. }
    9.  
    10. void seRotation(double angle)
    11. {
    12. _rotation = angle;
    13. }
    14.  
    15. protected:
    16. virtual void drawSymbols( QPainter *, const QPointF *, int numPoints ) const;
    17. double _rotation;
    18. };
    To copy to clipboard, switch view to plain text mode 

    and reimplement drawSymbols( )
    Qt Code:
    1. void CustSymbol::drawSymbols( QPainter *, const QPointF *, int numPoints )
    2. {
    3. ...
    4. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Cah; 5th April 2014 at 02:50.

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

    Default Re: How to rotate markers in qwt

    Your question is more or less unrelated to QwtSymbol/QwtMarker - what you want to know is how to rotate an image.

    When the source of your image is made from vectors ( SVG graphics or something you create in code yourself f.e a QwtGraphic ) rotating can be done without any loss in quality - simply by creating the rotated image from this source with a rotating transformation. If the source is based on some raster graphic format all you can do without losing quality is to mirror the image ( QImage::mirrored() ). For all other angles you have to use QImage::transformed().

    Uwe

Similar Threads

  1. Random markers from nowhere.
    By Spitfire in forum Qwt
    Replies: 10
    Last Post: 3rd November 2011, 14:43
  2. Replies: 1
    Last Post: 10th May 2011, 06:29
  3. how to set markers below a slider in qt
    By qt_user in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2010, 07:02
  4. Markers are not removed from QwtPlot
    By MuzZviman in forum Qwt
    Replies: 1
    Last Post: 3rd June 2010, 07:25
  5. qscintilla and markers
    By sawerset in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2009, 21:39

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.