Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Exception: Layout measurement ... should not return NaN values as its DesiredSize (Read 8312 times)
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Exception: Layout measurement ... should not return NaN values as its DesiredSize
Aug 22nd, 2014 at 1:24pm
Print Post  
Hi,

I'm having an issue with the OrthogonalRouter throwing exceptions after a few Arrange calls to route the links. The exception is:

Code
Select All
System.InvalidOperationException
"Layout measurement override of element 'MindFusion.Diagramming.Wpf.DiagramLink' should not return NaN values as its DesiredSize." 



with the following call stack:

Code
Select All
   at System.Windows.UIElement.Measure(Size availableSize)
   at A.A.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MindFusion.Diagramming.Wpf.Diagram.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Window.MeasureOverrideHelper(Size constraint)
   at System.Windows.Window.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at Test.App.Main() in ...Test\obj\x86\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart() 



Any ideas?

Best Regards,
-Mihai
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #1 - Aug 22nd, 2014 at 4:28pm
Print Post  
Could you attach diagram's xml file saved before calling OrthogonalRouter?
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #2 - Aug 22nd, 2014 at 7:01pm
Print Post  
Not easily (NDA / confidential), unless I strip it down a lot. Is there no other way to attack this?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #3 - Aug 25th, 2014 at 7:36am
Print Post  
We'll need the node positions and connections for debugging this. Stripping down the confidential data should be a matter of setting a few properties, e.g.
Code
Select All
foreach (var item in diagram.Items)
{
	item.Text = "";
	item.ToolTip = "";
	item.Tag = null;
}
diagram.SaveToXml("debug.xml"); 



unless the diagram drawing itself shows some secret plan...
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #4 - Aug 25th, 2014 at 7:52am
Print Post  
It's the diagram itself that's confidential.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #5 - Aug 25th, 2014 at 9:43am
Print Post  
Measured size might be NaN if any link control point has a NaN coordinate. Try looping over all links immediately after Arrange call and check the ControlPoints values, can you find any link point with a NaN value for X or Y?
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #6 - Aug 25th, 2014 at 11:46am
Print Post  
Hi Stoyan,

Yes, I am able to find a couple of links with NaN(s) like the following:

Code
Select All
link.ControlPoints.Count	6	int
link.ControlPoints[0]	{624,244094488189;498,263779527559}	System.Windows.Point
link.ControlPoints[1]	{626,744094488189;498,263779527559}	System.Windows.Point
link.ControlPoints[2]	{626,744094488189;902,763779527559}	System.Windows.Point
link.ControlPoints[3]	{NaN;NaN}	System.Windows.Point
link.ControlPoints[4]	{NaN;462}	System.Windows.Point
link.ControlPoints[5]	{634,244094488189;462}	System.Windows.Point 



What next?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #7 - Aug 25th, 2014 at 3:43pm
Print Post  
We've doubled-checked the OrthogonalRouter code and can't see anything that would create NaN values, unless some of the input nodes have NaN coordinates. Can you find any nodes that have NaNs in their Bounds?
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #8 - Aug 25th, 2014 at 6:58pm
Print Post  
Thanks for checking. There seem to be no nodes with NaN(s) in their Bounds.

But by the way, I can't get the OrthogonalRouter to produce the output I'm after, so maybe if that is addressed, the exception will go away. So let me detail:
  • I have a very tall node, with several small nodes at its right side, arranged in a couple of columns
  • Most of the small nodes are connected to the tall node

I would like the links to have the shortest possible length, say horizontally to the tall node's right edge. Instead, the links go around the tall node, although they could easily go straight without crossing each-other, or any other nodes for that matter.

Here are the parameters for the router:
Code
Select All
var router = new OrthogonalRouter()
{
    Anchoring = Anchoring.Keep,
    EndOrientation = MindFusion.Diagramming.Wpf.Orientation.Horizontal,
    StartOrientation = MindFusion.Diagramming.Wpf.Orientation.Horizontal,
    NodeDistance = 0
}; 


What could I be doing wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #9 - Aug 26th, 2014 at 6:43am
Print Post  
OrthogonalRouter distributes link along the full perimeter of nodes in order to leave more space between them. If you prefer simple straight lines between the nodes when possible, try using the ArrangeLinks method from SequenceDiagram sample project.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Exception: Layout measurement ... should not return NaN values as its DesiredSize
Reply #10 - Aug 26th, 2014 at 8:16am
Print Post  
Quote:
OrthogonalRouter distributes link along the full perimeter of nodes in order to leave more space between them.

It seems to do the opposite in my case... I have a feeling I'm doing something wrong, like not adding something to the list of items passed to the Arrange method.

Quote:
If you prefer simple straight lines between the nodes when possible, try using the ArrangeLinks method from SequenceDiagram sample project.

Thanks for the tip, I'll check it out.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint