Results 1 to 4 of 4

Thread: Rotating a point on a curve about another point

  1. #1
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Rotating a point on a curve about another point

    Hello,

    I am trying to rotate a vector curve about a certain point. I have an anchor point that will only move about the y and x axes. The arrow point (the top of the vector) moves along with the anchor point (via the change in x and change in y of the anchor point). The arrow point need only to rotate around the anchor point. I need to vector length to stay the same while the arrow point rotates.

    I have installed the canvas picker and subclassed it myself. I am able to rotate the arrow point, but, the user is allowed to resize the actual length of the vector curve. I do not want to be able to resize that vector length.

    How would I go about rotating that arrow about the anchor point?

  2. #2
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rotating a point on a curve about another point

    Sorry to double post, I figured out how to rotate the curve. I am now confused as to how to rotate the symbols on the curve. If anyone could provide insight that would be excellent!

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,491
    Thanks
    252
    Thanked 717 Times in 707 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Rotating a point on a curve about another point

    Do you mean to actually rotate the symbols themselves (like a square becomes a diamond when rotated 90 degrees), or just rotate the locations of the symbols to correspond to the new curve location?

    To rotate the symbol locations, you apply the same transformation as you do for the points in the curve. I don't think there is any way to rotate the symbol icons themselves, except by deriving a new class from QwtSymbol and applying the transform to the QPainter in the paint() method before calling QwtSymbol:: paint(). (Maybe it is in the paint event, don't have Qwt sources in front of me so I don't know exactly where drawing takes place).

    If you do that, you may have to translate the center of the symbol to the origin first before rotating, then translate back to its correct location. Be sure to remove the transform from the painter before leaving your paint method, otherwise everything that follows will be wonky.

    Edit: It is possible that QwtPlot caches symbols like it does tick labels and other things. So you may also have to force it to clear the cache before your rotated symbols will be drawn correctly. Don't know this for sure either.

  4. The following user says thank you to d_stranz for this useful post:

    hypnotic401 (21st June 2011)

  5. #4
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rotating a point on a curve about another point

    I figured it out. It was in the way I was rotating the painter. The correct way of doing it you had listed as your first option. I transformed the painter to the rectangles center (of the qwtsymbol) then rotate the painter and translated it back to the original center. Thank you for you input though! I ended up using my friend google XD
    SEGMENTATION FAULT: At who the hell knows where.

Similar Threads

  1. Replies: 2
    Last Post: 16th May 2011, 08:06
  2. Replies: 2
    Last Post: 5th May 2011, 06:53
  3. Replies: 2
    Last Post: 28th April 2011, 08:42
  4. Replies: 1
    Last Post: 9th December 2009, 17:14
  5. get the point of a fitted curve
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 2nd January 2009, 04:03

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.