Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Rotation questions (Read 2319 times)
-= E W O U D =-
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Location: Netherlands
Joined: Aug 26th, 2014
Rotation questions
Aug 28th, 2014 at 12:53pm
Print Post  
Hi,

1. Is it possible to have a ShapeNode rotate around another point than it's center?
2. Is it possible to have a group of nodes rotate around a common center?

Thank you,
Ewoud
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Rotation questions
Reply #1 - Aug 28th, 2014 at 3:17pm
Print Post  
Hi,

Quote:
1. Is it possible to have a ShapeNode rotate around another point than it's center?


That's not supported out of the box. You could probably implement it by overriding DiagramNode.Draw method to apply a different transform before calling DrawLocal. Current Draw code looks like this:

Code
Select All
public override void Draw(IGraphics graphics, RenderOptions options)
{
    GraphicsState state = graphics.Save();

    RectangleF b = GetBounds();
    graphics.TranslateTransform(b.X, b.Y);

    if (GetRotationAngle() != 0)
    {
        Point center = GetLocalCenter();
        graphics.TranslateTransform(center.X, center.Y);
        graphics.RotateTransform(GetRotationAngle());
        graphics.TranslateTransform(-center.X, -center.Y);
    }

    DrawLocal(graphics, options);

    graphics.Restore(state);

    DrawManipulators(graphics, false, false);

    if (ShouldRenderAnchors(options))
        DrawAnchors(graphics);
} 



You'd also have to override additional methods such as DrawHandles and GetRotatedBounds.

Quote:
2. Is it possible to have a group of nodes rotate around a common center?


You could set the group's FollowMasterRotation property to make the children rotate around the parent node's center.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
-= E W O U D =-
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Location: Netherlands
Joined: Aug 26th, 2014
Re: Rotation questions
Reply #2 - Aug 29th, 2014 at 11:06am
Print Post  
Thank you for the answer.

I could probably add a temporary node at the desired rotation center (when none of the exiting nodes are), create a temporary group (with the (temporary) node as the 'master'), set FollowMasterRotation on the group, rotate and remove all temporary constructs.

This would allow me to rotate any node or group of nodes around an arbitrary point. Correct?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Rotation questions
Reply #3 - Aug 29th, 2014 at 2:50pm
Print Post  
Yes, that will work. Creating and removing temporary nodes will mess up the undo history though if you keep undo enabled. You might have to filter out undo records from ActionRecording events in such case.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint