Page Index Toggle Pages: 1 ... 3 4 [5]  Send TopicPrint
Very Hot Topic (More than 25 Replies) Link routing - supperposition + arrow orientation (Read 32464 times)
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link routing - supperposition + arrow orientat
Reply #60 - Jun 24th, 2009 at 5:50am
Print Post  
Hi Marie,

A) It should be enough to set it to false in response to the MouseUp event, both for created and cancelled links.

B) The code you've emailed us shows a LinkCreated handler but not LinkCreating. Could you send LinkCreating too?

Stoyan
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Link routing - supperposition + arrow orientat
Reply #61 - Jun 25th, 2009 at 2:47pm
Print Post  
Hi Stoyan,

A) Perfect Grin

B) In addition to the code I sent you about the "ApproxBezier" crash I still get (see http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_brep;action=display;num=124576041...), here is the LinkCreating code:
Code
Select All
void Diagram_LinkCreating(object sender, LinkValidationEventArgs e)
{
    if (e.Link == null || e.Link.Origin == null || !(e.Link.Origin is TableNode))
    {
        e.Cancel = true;
        return;
    }

    // Draw bezier curve
    // Uses e.MousePosition as the endPt instead of calculating if from the link.
    this.Diagram.RouteLink(e.Link, e.MousePosition);

    // Equivalent to AllowUnconnectedLinks=TRUE, but with nice bezier links painting ;)
    if (e.Destination == null)
    {
        e.Cancel = true;
        return;
    }

    // Checks if the link is allowed
    bool linkValid = ValidateLink(e.Link, e.Destination, e.AnchorIndex, e.TableRow, false, false);
    e.Cancel = !linkValid;

    e.Link.ShadowColor = Color.Transparent;
} 



My (B) problem happens in RouteLink when I do UpdateFromPoints. In my test sample (lightly modified Entities sample), I don't get the crash, but the links don't get updated as a bezier (i.e. the links are straight instead of bezier curves when creating them). Once the're created, everything is fine (In my sample only since my real application crashes if the LinkCreating code is activate).
In my real application, even though the LinkCreating code and other related codes are almost the same (but not the anchor point's code), the links don't get updated while creating them (i.e. I get cascading links somehow but no bezier) and I also get a crash every time I am creating a link and go over an anchor point:
Code
Select All
System.NullReferenceException was unhandled
  Message="La référence d'objet n'est pas définie à une instance d'un objet."
  Source="MindFusion.Diagramming"
  StackTrace:
       à MindFusion.Diagramming.DiagramLink.x0d5905a18dc24aa7(Boolean x1c5ff8c3c1ac16ad)
       à MindFusion.Diagramming.DiagramLink.UpdateFromPoints(Boolean updateGroups)
       à MindFusion.Diagramming.DiagramLink.UpdateFromPoints()
       à [...].RouteLink(DiagramLink link, PointF endPt, Boolean verbose) dans [...]
       à [...].Diagram_LinkCreating(Object sender, LinkValidationEventArgs e) dans [...]
       à MindFusion.Diagramming.Diagram.OnLinkCreating(LinkValidationEventArgs e)
 



So my problems are
(1) The crash in UpdateFromPoints
(2) The fact that I can't have bezier-looking links while creating them.
(3) The crash as described in my other post (in MindFusion.Utilities.ApproxBezier(PointF[] points, Int32 startIdx, Int32 quality))

Thanks!
Marie

Edit: I forgot to set Diagram.AllowUnconnectedLinks to true... When it is, I get the UpdateFromPoints crash every time LinkCreating gets called (i.e. almost at the moment I start creating a link), not just when over an anchor point (I don't event get there anymore).
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link routing - supperposition + arrow orientat
Reply #62 - Jun 29th, 2009 at 1:42pm
Print Post  
Hi Marie,

Could you send me the latest version of your RouteLink() method. The one I have takes a single DiagramLink argument, and the one from the LinkCreating code above seems to receive an additional PointF argument.

Stoyan
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Link routing - supperposition + arrow orientat
Reply #63 - Jun 29th, 2009 at 1:53pm
Print Post  
Hi Stoyan,

I just sent you the code.

Thanks agains Cheesy Cheesy!
Marie
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link routing - supperposition + arrow orientat
Reply #64 - Jun 29th, 2009 at 2:01pm
Print Post  
I'll need the GetDestinationAnchorPt code too 8)

Thanks
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Link routing - supperposition + arrow orientat
Reply #65 - Jun 29th, 2009 at 2:04pm
Print Post  
Sent.

Thanks,
Marie
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link routing - supperposition + arrow orientat
Reply #66 - Jun 29th, 2009 at 2:31pm
Print Post  
Hi Marie,

If you change the number of the link's control points as you do in the code below, you must also update SegmentCount.

Code
Select All
if (link.ControlPoints.Count != 4)
{
	link.ControlPoints.Clear();
	link.ControlPoints.Add(startPt);
	link.ControlPoints.Add(controlPt2);
	link.ControlPoints.Add(controlPt3);
	link.ControlPoints.Add(endPt);
}
 



You should call the UpdateFormPoints method that takes an updateSegmentCount argument (new in version 5.3), or if you are still using v5.2.1, assign the points using this method:

Code
Select All
private void SetLinkPoints(DiagramLink link, params PointF[] points)
{
	link.AutoRoute = false;
	link.SegmentCount = link.Style != LinkStyle.Bezier ? (short)(points.Length - 1) : (short)((points.Count - 1) / 3);
	link.Style = LinkStyle.Cascading;
	link.ControlPoints.Clear();
	link.ControlPoints.AddRange(points);
	link.UpdateFromPoints();
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Link routing - supperposition + arrow orientat
Reply #67 - Jun 29th, 2009 at 2:45pm
Print Post  
Hi Stoyan,

I don't understand why I should update SegmentCount. My links should always be Bezier and my default SegmentCount in diagram is 1. I don't change it anywhere. I tried adding it but it doesn't work. However, if it's quick, I don't mind doing it.

I replaced my control points setting code by the following (your code but without the link style assignment) in my RouteLink method:
Code
Select All
private static void SetLinkPoints(DiagramLink link, params PointF[] points)
{
    link.AutoRoute = false;
    link.SegmentCount = link.Style != LinkStyle.Bezier ? (short)(points.Length - 1) : (short)((points.Length - 1) / 3);
    //link.Style = LinkStyle.Cascading;     // I want Bezier curves!!! not cascading!
    link.ControlPoints.Clear();
    link.ControlPoints.AddRange(points);
    link.UpdateFromPoints();
} 



I still get the UpdateFromPoints crash:
Code
Select All
System.NullReferenceException was unhandled
  Message="La référence d'objet n'est pas définie à une instance d'un objet."
  Source="MindFusion.Diagramming"
  StackTrace:
       à MindFusion.Diagramming.DiagramLink.x0d5905a18dc24aa7(Boolean x1c5ff8c3c1ac16ad)
       à MindFusion.Diagramming.DiagramLink.UpdateFromPoints(Boolean updateGroups)
       à MindFusion.Diagramming.DiagramLink.UpdateFromPoints()
       à [...].SetLinkPoints(DiagramLink link, PointF[] points) 



So my problems have not changed:
(1) The crash in UpdateFromPoints
(2) The fact that I can't have bezier-looking links while creating them.
(3) The crash as described in my other post (in MindFusion.Utilities.ApproxBezier(PointF[] points, Int32 startIdx, Int32 quality))

Did you successfully get bezier-looking links while creating them?

I'll try with the new version just in case (I want to use it anyway). Even though I asked previously to receive the version emails, it seems that this time it didn't work... Could you send me the version for my company please?

Thank you.
Marie
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link routing - supperposition + arrow orientat
Reply #68 - Jun 29th, 2009 at 3:02pm
Print Post  
I get neither a crash nor a bezier looking link. With your code you will get a crash if you start with a SegmentCount > 1, so I assumed that's what happening.

Regarding the link being a straight line - this happens because the validation LinkCreating event is called before the control processes the mouse movement, and the processing for a link being created places all of its control points on a straight line. So LinkCreating is not a good place to change the point positions anyway.

We have forwarded the upgrade link to you, have you received it now? Also check in the 'junk ' email folder of your email app.

Stoyan
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Link routing - supperposition + arrow orientat
Reply #69 - Jun 29th, 2009 at 3:28pm
Print Post  
Hi Stoyan,

I received the upgrade link successfully and installed the new version Cheesy.

My code now looks like:
Code
Select All
private static void SetLinkPoints(DiagramLink link, params PointF[] points)
{
    link.AutoRoute = false;
    link.SegmentCount = link.Style != LinkStyle.Bezier ? (short)(points.Length - 1) : (short)((points.Length - 1) / 3);
    //link.Style = LinkStyle.Cascading;     // I want Bezier curves!!! not cascading!
    link.ControlPoints.Clear();
    link.ControlPoints.AddRange(points);
    link.UpdateFromPoints(true, true);
} 


(I now have access to UpdateFromPoints parameters).

I still get the same crash, but with different stack trace. Here it is (in case it helps you):
Code
Select All
System.NullReferenceException was unhandled
  Message="La référence d'objet n'est pas définie à une instance d'un objet."
  Source="MindFusion.Diagramming"
  StackTrace:
 à MindFusion.Diagramming.DiagramLink.xb05f5d996d82647f(Anchoring x7ba664bd6885b404, Boolean x49743b78538984b7)
 à MindFusion.Diagramming.DiagramLink.xb05f5d996d82647f(Anchoring x7ba664bd6885b404)
 à MindFusion.Diagramming.DiagramLink.set_SegmentCount(Int16 value)
 à [...].SetLinkPoints(DiagramLink link, PointF[] points) 



Since LinkCreating doesn't work, do you have an idea of how to do it (have bezier-looking links during creation)?

Thanks,
Marie
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link routing - supperposition + arrow orientat
Reply #70 - Jun 29th, 2009 at 3:38pm
Print Post  
Are there any nodes attached to the link using AttachTo? You don't need the link.SegmentCount assignment above if you call link.UpdateFromPoints(true, true) in the end, so removing it now might stop the exceptions.

Since this won't work from LinkCreating anyway, you might override DiagramLink.UpdateCreate to set the points. Another option is to create a class that implements ILinkRouter and move your code to its RouteLink method. Then you could set an instance of your class as Diagram.LinkRouter to be used during creation with the RouteWhileCreating flag, and switch back to QuickRouter if you need to use the built-in routing at some point.

Stoyan
  
Back to top
 
IP Logged
 
marie
Full Member
***
Offline



Posts: 147
Joined: Nov 11th, 2008
Re: Link routing - supperposition + arrow orientat
Reply #71 - Jun 30th, 2009 at 6:12pm
Print Post  
Hi Stoyan,

Thanks for your suggestions. They'll be tried later Wink.

Thanks,
Marie
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 ... 3 4 [5] 
Send TopicPrint