PDA

View Full Version : Rotating a point on a curve about another point



hypnotic401
13th June 2011, 15:58
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?

hypnotic401
14th June 2011, 16:29
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!

d_stranz
18th June 2011, 16:32
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.

hypnotic401
21st June 2011, 19:37
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