And here’s the source, DrawTree Demo (DeskTop) 0.9.zip:
What is “Dimiant” ?
It appears in two For Each
blocks.
Hi Emile, can you locate the class/method containing that ? I just tried a search which did not find “Dimiant” anywhere…
Sorry… my bad.
Dimiant = Variant !!!
(VAR
repaced with DIM
)
Too similar to Diamant (French for Diamond) so my brain never read Variant, but Diamant.
@Robert_Weaver - regarding the time to draw, I’ve been working with trees with millions of nodes. Several points to note:
-
it is essential to check for looping within the tree and stop that. If the code is recursive it results in a stack overflow; if it is iterative it gets stuck in an infinite loop.
-
use iteration (faster), and avoid recursion (slower); you can see where I did that in the example;
-
when traversing a big tree consider imposing a limit on the depth drawn (the number of levels), and let the user explore a sub-branch.
Drawing to the canvas as a bitmap works pretty well provided everything uses right-angles. But I wanted to draw circular trees, with text following the links on any angle. Drawing with 2D objects works, but with big trees there comes a point where it is slower than a bitmap.
OK finished the demo app, nailed the last issue causing exceptions:.
For my situation, I couldn’t truncate the tree, because I needed to traverse every node in order to do the calculation. What I did was mark each node as it was encountered. If I encountered a node that had that mark, then I knew that it had already been traversed, and I could ignore that branch. The same technique was used to detect circular references.
I also gave each node a precedence number such that each node’s precedence number would always be greater than all of its ancestors’ precedence numbers. That allowed the ability to process the tree by precedence order rather than node connections, making it easy to use iteration if necessary.
Somewhere I have some ancient code that I wrote to generate tree diagrams (not in Xojo unfortunately). I’ll have to dig it out and remind myself how I did it.
(Edited spellling)
@Robert_Weaver - OK understand that problem, and there’s something else to ponder.
In my case the tree data is drawn from a shared (multiple concurrent user) database, so the tree is traversed and manipulated using local parameters stored in the icons drawn, not the underlying nodes themselves - otherwise there is a risk users would see invalid results…
My real-world app is somewhat different as the icons can have independently variable width/height (draggable by the corners) and supports alignment and spacing rather like the way Powerpoint does it.
@Art_Gorski
I booted on High Sierra and was able to fire Xojo 2021r1.1. So I loaded your 1.0 demo: very nice.
Thank you for sharing.