-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Node Graph Editors with ImGui #306
Comments
EDITED 2019GENERALLY SPEAKING YOU CAN HEAD TO THE WIKI FOR LISTINGS Listing relevant links posted the thread. Dig in the thread for details! https://github.com/thedmd/imgui-node-editor (Original 2015 answer) You can start with actual ImGui Windows but as you dig into connections and more features they will likely get in your way? It may be more awkward to restrict them within a given spot, etc. One benefit is that they will handle overlapping for you. Creating your own mini-window not too hard:
If you can avoid overlapping it'll be simpler. If you can't the next easiest thing would probably be to handle ordering/sorting them yourself. |
Thanks for the reply. That seems reasonable. I think I will just go for non-overlapping as this is mostly for a prototype so that should be fine. |
Here's a proof of concept demo. It's quite incomplete but shows that it is possible. I'm declaring some ImVec2 operators to make the code simpler. If you have your own math types with conversions via IM_VEC2_CLASS_EXTRA you are probably better off using them. Sort of work but I'm not very happy with it because it wasn't that trivial to pull off (3 hours including bugfix) and I had to dodge a few non-obvious trap. I'll probably keep massaging that code. I'll move the hermite curve rendering to new drawing API. Do you know of a good non-stupid reference for API that handle various types of curves? (bezier, hermite, catmull rom. etc.). They are easy to implement but I wonder if there's a way of ordering parameters that's more standard or obvious. An API to handle multiple points should be available so that thick splines can have their end connecting nicely. Code |
👍 thanks! :) |
Yeah I have been thinking about what curves to actually use for the lines. I thought about just using b-spline or something similar but I have no idea what "real" editors are using. |
Hi, |
@ocornut nice!! 👍 @NocturnDragon what algorithm does the rect layouts use? I notice it somehow seems to avoid overlapping itself? |
I'm not sure those node/graph should or will be a concept of core ImGui by the way. It's more of an example code. My intuition is the real value will be to keep massaging and improving the lower-level stuff so that it becomes more easier and natural to create this sort of thing from scratch. |
I asked the creator of Fog framework who has a lot of experience with vector libraries (Cairo, AGG, etc.) and he told me, that in Fog (and also it's successor Blend 2D) he supports only quad and cubic Bezier curves, because it's enough (and it's much easier to translate these into any other curve needed e.g. by the rendering engine). He also told me, that e.g. Cairo supports only cubic curves. So, in the name of simplicity, feel free to take a look at the API of Bezier curves in Fog. |
Fully agree that this shouldn't be part of core ImGui but an interesting use-case to support with the API itself as you say. |
Small comment. I tested your prototype and when dragging the color values it seems to always reset back to default. I haven't investigated yet but just wanted to let you know. |
Yeah they are just dummy values, didn't want to clutter the example with too much things.
If you aren't in a hurry I'll keep working on that in the future, add the linkage, move curves rendering to the main api and generally simplify / clean up / clarify where I can. |
Not in a major hurry no so great stuff here :) I also think it's good in general to have a example that "bends" the regular use-case a bit. |
Add yeah I agree that general curve rendering would fit good in the API, and getting linkage in the example would be great of course. |
Awesome work! 👍
+1 for rectangular and 45 degree angle links. I find them way more readable than curves/spaghetti stuff. :) |
Any plans to switch to nanovg renderer? ) |
ImGui already does anti-aliased text and lines so I'm not sure why that would be needed? |
Probably not because NanoVG is rather runtime heavy for the performance we are aiming for. But as emoon say is there is a specific reason/feature you would want it? Also please open a new topic for that. Thanks! |
Just to say that I'm also developing my own version based on the code posted by Omar. |
Just thought i'd say I love the background.
How'd you do that (add a background that is).
|
@Flix01 Awesome! 👍 |
Adam: they are just lines. You can just draw shapes or images and that's a background done.. |
@Hevedy Partially using:
CTRL+mouse wheel should increase the font size and the node sizes, but their position stays the same. |
I've just implemented a basic node copy/paste functionality. However there are some problems with the popup menus: if I right-click on a node and then right-click on another without closing the first menu, a (wrong) menu appears in the position of the old one. It should close the old one and open the correct menu on the new node instead... I don't know how to fix it. You can check the live test linked above, that keeps updating too (even if it does not support serialization). [Edit] I discovered that the problem is composed by two sub-issues:
|
@Hevedy I've added proper zoom. It's still WIP ATM, but if you have Firefox you can test it using CTRL+mouse wheel in the test demo above. |
Thank you. |
My goal with There are no additional caching mechanisms or complex logic involved, other then that all the nodes are sorted and kept in a Z-order to handle overlapping. Nodes and links that fall outside the visible canvas area are not drawn. Node drawing is achieved through a one-shot process using BuildNodeGeometry(...) followed by repeated calls to DrawNode(...). For prototyping purposes, you can easily strip it down to the raw state machine by using ImGuiNodes::Update() and related functions such as UpdateCanvasGeometry() and UpdateNodesFromCanvas(). Special thanks to @gboisse for providing valuable insights. |
@thedmd I'd like to be able to draw thousands :D in my test case all links are always visible as there's one top node connected to all the 499 others. |
@ahmidou: for your usecase with thousands of nodes/links I would like to encourage you to try your own attack here :) |
Hey @ChemistAion that's what I'll probably do in the long run, but for now I'm fine with your solution. Thanks for the reference implementation!! |
Hey @ocornut I'm trying to incorporate a part of your solution into my own and I was wondering how would it be possible to draw connections between the new nodes that are added to the canvas? Any help is appreciated. Thanks. IE. Creating connection between the nodes generated I've given an example below. |
It looks like you would be better off using one of the several existing solutions (linked at the top of this thread and https://github.com/ocornut/imgui/wiki/Useful-Extensions) instead of starting from my old quick proof-of-concept. |
This link is dead now. @ChemistAion Could you repost it possibly? I'm curious to see how you achieve the performance boost! |
@reformstudios: Details on how to test it: #306 (comment) Finally, mentioned here and there its "speed" comes from the fact that this is a v. simple state-machine: #306 (comment) Additionally, please find the list of other ideas/approaches: #306 (comment) |
Thanks for that! I have to confess, I have no idea how to add your node editor to my simple imgui app. |
@reformstudios: yep, that will work... |
Thank you so much for such quick replies! |
Another Node Editor but with a different approach. To be as customizable as possible while requiring very few lines of code to create custom nodes. |
Thank you Gabriele, and thanks for adding this the wiki section with an image. |
@ocornut I would like to work on adding Zoom support for ImNodeHandler. I've had a look at imgui-node-editor implementation. But it's quite hefty and doesn't work with combos and similar. Could you point me in the right direction to develop such feature? |
@ChemistAion if I understand correctly you do not render the ImGui widgets but only custom graphics, right? My goal is to allow the user to create the node's body as you create an ordinary ImGui window. (I haven't had the chance to have a look at nem0's project yet) |
@Fattorino: yes, my example is shown with exclusively custom graphics - the goal was to build nodes-editor state machine/engine not the frontend. Regarding your actual question, I wanted only to direct your attention to the foundations of the zoom calculations/idea: |
Thanks for the help, especially @nem0 whose solution was extremely fitting and allowed me to implement an almost identical solution ImNodeFlow Zoom. |
Yes, I think that is the smartest decision. When I find the time I'll see how it looks. And thanks |
Note that 1.90 introduced a This makes it easy to e.g. load one font at 100%, one font at 400% size, and swap between them when you cross over the 200% lines. All other font metrics will appears identical so there's much less juggling with sizes. |
New styling system, and therefore new looks for ImNodeFlow, any feedback? |
Closing this as "not sure why it was still open" Feel free to post if you have generic feedback/discussion on the topic. |
It seems that onurae/core-nodes isn't on the list, so leaving it here. :) |
Hi,
So I'm thinking of using ImGui for doing a basic node graph that can be used to edit materials. There are lots of programs that does this but for example:
http://keenleveldesign.com/pimp/protools/shaderfusion/ShaderFusionReleasePromo/shaderfusion01.jpg
I wonder how one would go about doing something similar with ImGui. Having separate windows for each box is likely (?) the best approach as it would allow the user to move them around and what not.
I guess adding some custom stuff for doing the connections + lines as well shouldn't be too hard but I just wanted your thoughts about it.
Cheers!
The text was updated successfully, but these errors were encountered: