-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
add wrapper for imgui PlotLines widget #50
Conversation
This patch only wraps the PlotLines widget from imgui, but the histogram and other plotting widgets could be wrapped also. This also adds an example in examples/plot showing both g.PlotLines() and g.PlotLinesV(). Future work: the imgui plotting widget is a little limited, it would be nice for GIU to support a more robust plotting system. This could perhaps be done from scratch based on a Canvas widget, possibly by writing a back-end for gonum/plot.
@charlesdaniels Thanks! Checking this project, https://github.com/epezent/implot, it might be an option to integrate with. |
As an aside relating to future work, an improved plot would probably best be done by either binding epezent/implot or by waiting for it to be merged into imgui. |
Haha I guess we had the same thought at the same time! Do you have any thoughts on the right way to do that? Would you suggest creating a separate repo that binds implot into GIU, or should it be integrated directly into GIU? |
@charlesdaniels Ha! I'm currently using https://github.com/gonum/plot to display complex chart, but the down side is the chart is static. To create a extendable plot system is necessary in future. |
@charlesdaniels Few days ago, I'm think about to re-implement implot in golang... |
It looks like its just ~2.2kLOC, so it could probably be transliterated. Just skimming it very briefly I don't see any C++-isms that might be hard to translate such as classes or polymorphism. I think this would be a feasible project. |
Hi! Just popping in to say hello. Please let me know if there are any changes that I can make to ImPlot so that your integration is easier. Also, note that @sonoro1234 made a C binding here: |
I've been mucking about with Cgo lately... I will give this a try. The imgui bindings that GIU is based on bind directly against imgui, with only a few thin C functions that convert some object types to I assume cimgui is similar, but the main thing I'm unclear on is how imgui itself internally handles state. I don't see anything obvious in imgui-go that looks like it's storing a pointer to somewhere that the state lives, so I assume it's a "global" within imgui itself? @epezent you are obviously a lot more familiar with the C++ version of imgui, so maybe you could comment on this? As far as changes, the most I think we would need would be a few What I'm concerned about is whether or not the imgui stuff in implot will be able to "find" the imgui stuff in imgui-go. I think if we can get bindings working, that would be a lot less work than transliterating (and then keeping up with upstream updates). It's not like GIU doesn't already implicitly depend on Cgo via imgui-go. What I think makes the most sense if @AllenDang is not opposed, and what I will try to do when I get a chance, will be for me (or someone else) to create a repo that's just the imgui-go bindings for implot, then have GIU be a down-stream consumer of that library. (disclaimer for @epezent -- I am not really affiliated with GIU, I'm just a drive by committer for now... but a drive by committer with an interest in live GUI plots in Golang) Thanks for stopping by! |
Hmm, this is above my pay grade (never touched go or Cgo), but might it be possible to just merge |
@epezent Thanks for your great job. And @charlesdaniels I think it will be better to embed implot.h and implot.cpp inside giu. The benefit is easier to change the cpp code to suit giu's need. |
BTW, @charlesdaniels I think the PlotLinesV could use two float32 params to define size. This will be easier to use and omit to import imgui package. Can you make a new PR to that? |
Ok, I started messing with binding implot, and I've hit a bit of a wall... https://github.com/charlesdaniels/implot-go Namely, implot is having trouble including |
@charlesdaniels Add it directly into giu/imgui |
This patch only wraps the PlotLines widget from imgui, but the histogram
and other plotting widgets could be wrapped also.
This also adds an example in examples/plot showing both g.PlotLines()
and g.PlotLinesV().
Future work: the imgui plotting widget is a little limited, it would be
nice for GIU to support a more robust plotting system. This could
perhaps be done from scratch based on a Canvas widget, possibly by
writing a back-end for gonum/plot.