-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SciView.addNode, Node.addChild, Node.(set)Parent ambiguity #497
Comments
I think I like the idea of listening to scene graph changes and calling publishNode automatically. |
Since this deals with API, I'd like to resolve it for |
@skalarproduktraum wants to do this task but he needs time to mull about it |
Ok, this is related: #504 |
sciview (not scenery) user's perspective:
|
my take would be a bit anti-Kotlin chatty: exemplified on Spheres:
shortcuts:
Notice the policy: explicit creation and explicit adding -- often I prefer to first prepare the object before I introduce it into the scene but that's breaking API... let me come back with a better proposal in a while |
I found myself doing this in a script yesterday: sciview/src/main/resources/sc/iview/scripts/find_and_count_cells_cardona.py Lines 89 to 93 in 7fcf71f
|
Just brainstorming: One major point for me though: convenience functions that do everything in one call are useful when you're in SciJava scripting land, where types (let along generics) becomes frustrating (e.g. in dynamic languages). Convenience create-and-add functions
More custom usageTBH, I think the example I linked above is pretty reasonable. If you want to do something custom in the scene graph, then do it with scenery and use sciview to publish the node. In theory if there was a real need to add child nodes and publish them in sciview simultaneously, then we could add some extension functions to [That said, this needs to be clearly presented and documented, because this hasn't been a usage pattern that we have been promoting yet.] [edit again:] This leads me to suggest that we should clean up API on the sciview side, and add more examples/documentation of both cases. |
my problem was that I, until you sent the post a while ago, failed to have a nodes hanged under some another node of mine (which was in the root of the scene) and have them visible in the inspector... I tried several combinations of setting parent, adding child,... and was getting either duplicitly visibly items or none.... I was missing the I agree that the example is good and I like it actually (I can get solo basic obj, incrementally set it up, and only then decide to make it available in the scene)... just failed to get the whole construction using the current API |
@xulman it is 100% sciview's fault not yours. |
no one's to blame (except myself) |
Let's just blame the software 👼 |
'publishNode()' is 3 days old. There was no way to do this properly before^^ |
I like the pattern, I understand the API must stay (not break), and I'm okay with that (if I may say). Just thinking of adding one/two convenience functions to make it crystal clear for newcomers:
the latter is a helper to easier find the "publishing code", the block would then look more node-ish: node = new Sphere()
node.spatial()....foo...
node.material().... blah...\
node.publishUnderParent( someParent ); (@kephale me back from the lunch... sorry for the delays) |
You know an API change is good when you already assume it has been around forever :D |
The new methods that @xulman suggests sound great to me and would be pretty straightforward as extension functions |
can I do PR? |
That would be wonderful! |
Maybe let @skalarproduktraum know you're diving into it. |
so user would either be using the mighty |
equivalent to the the code lives here... would need to do something about the now-testing |
I am open to deprecating |
I only really use I share @xulman's frustration with the block function argument. It is really hard to use that properly from Java, and probably even worse from SciJava scripting languages. |
it's not so bad at all once the programmer recalls/understands everything... just to explain: |
@xulman and I had a chat during lunch and he mentioned his struggels with adding childs to parent nodes in sciView.
In SciView/Java there is a setParent method generated which looks like it is on the same level as addChild. And worst of it all, both are, used alone, wrong. In SciView one has to use SciView.addNode (which directly adds the node under scene, so no other parent) or addChild + SciView.publishNode to add a node in away that it shows up in the inspector and is known to imageJs services.
In scenery and kotlin this is a bit more clear. There is the addChild method and the parent property. This hints that a child should be added by using the function.
possible solutions on the scenery side
possible solutions on the sciView side
The text was updated successfully, but these errors were encountered: