Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Snap to grid point for Nodes (Read 4555 times)
milosa
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: Mar 16th, 2017
Snap to grid point for Nodes
Apr 10th, 2017 at 12:40pm
Print Post  
Hi,

I would like to know which point of the node (top left corner?) of the node is used when snap to grid is calculated?

Is there a way to configure which point of the node will be used in this calculation?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Snap to grid point for Nodes
Reply #1 - Apr 10th, 2017 at 12:49pm
Print Post  
Hi,

All corners are aligned when you draw a new node, the top-left one when you move, or whatever one is being dragged when you resize. The top-left when moving cannot be customized at this time, but maybe you could offset the node from NodeModified event handler.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
benjamin huser
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Oct 23rd, 2014
Re: Snap to grid point for Nodes
Reply #2 - Apr 11th, 2017 at 9:22am
Print Post  
Hi
we now tried to apply a RenderTransform in the the XAML that wrapps the DiagramNode:
        <Grid.RenderTransform>
            <TranslateTransform X="{Binding InsertionPointHorizontalOffset}" Y="{Binding InsertionPointVerticalOffset}" />
        </Grid.RenderTransform>

This works fine except that the Handles and AnchorPoints are not applying the TranslateTransform as it seems.
We have custom implementation of the Node that derives from DiagramNodeAdapter, so I tried as well overriding DrawHandles/DrawAnchorPoints and add:
         graphics.PushTransform(new TranslateTransform(nodeViewModel.InsertionPointHorizontalOffset, nodeViewModel.InsertionPointVerticalOffset));
         base.DrawHandles(graphics, hstyle);

Now the Hadles (Rotate, Resize, Move) are properly displayed where they should be, but when you hover over the handles it is not working (Mouse Cursor is not changed, you cannot invoke the action), this is still on the "old position" that is not applying the transform.
I added an image that shows the problem, I hover over the "move" handle but it shows the "resize handle" because the resize would be there if no translation would have been applied...

More or less the same behavior happend with the Anchor Points, so they are still at the original position.

Do you know how we can make this work?
  

handleissue.png ( 3 KB | 104 Downloads )
handleissue.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Snap to grid point for Nodes
Reply #3 - Apr 12th, 2017 at 8:57am
Print Post  
You want to align the middle point of moved node to the grid instead of top-left corner? The handles and anchor points are in a separate FrameworkElement - node.Adorner. Relying on render transforms will break many other things like routing, automatic layouts etc when node.Bounds does not correspond to apparent position.
  
Back to top
 
IP Logged
 
benjamin huser
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Oct 23rd, 2014
Re: Snap to grid point for Nodes
Reply #4 - Apr 12th, 2017 at 10:33am
Print Post  
Hi Slavcho

yes we have a requirement that we are able to align it on any point (top left, center, basically whatever the user decides) and we were looking into how to solve this.
But if you say that is not possible right now and it does not make sense to use the "workaround" of RenderTransforms we will challenge or at least postpone it.

Thanks for your help
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Snap to grid point for Nodes
Reply #5 - Apr 12th, 2017 at 11:14am
Print Post  
Hi Benjamin,

In short term, if you use custom node classes we could change a private Rect UpdateRectMove(rect) method to a protected virtual one so you could override it, or we could raise an event from the method if you use built-in node types. We can as well add a property defining alignment position but it won't make it for upcoming release.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
benjamin huser
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Oct 23rd, 2014
Re: Snap to grid point for Nodes
Reply #6 - Apr 12th, 2017 at 1:39pm
Print Post  
Hi Slavcho

I quickly discussed it and we are not so in a hurry with this feature that we need it right now, so we would prefer a solution where we can define the alignement position, even if it will not make it for the next release.
In order to plan it a bit better, do you roughly know when it could be in a release that we could make use of?

Thanks a lot for your support!
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Snap to grid point for Nodes
Reply #7 - Apr 13th, 2017 at 8:25am
Print Post  
Hi Benjamin,

We are now preparing beta version, with official release planned for the end of this month. Next one will come in 3-4 months; we'll upload pre-release build once we have the property available.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
benjamin huser
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Oct 23rd, 2014
Re: Snap to grid point for Nodes
Reply #8 - Apr 13th, 2017 at 8:57am
Print Post  
Hi Slavcho

that sounds good, many thanks.

Regards
Benjamin
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Snap to grid point for Nodes
Reply #9 - Jun 29th, 2017 at 2:12pm
Print Post  
Hi Benjamin,

This build adds a GridAlignPoint position property to nodes that lets you change move alignment point -
https://mindfusion.eu/_beta/wpfdiag35.zip

E.g. this sets it to the center of node -
Code
Select All
e.Node.GridAlignPoint = new RelativePosition
{
	X = 50, XUnit = UnitType.Percentage,
	Y = 50, YUnit = UnitType.Percentage
}; 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint