Skip to content
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

Implot demo: add link in the readme (+ minor warning fix) #43

Merged
merged 4 commits into from
Jan 3, 2025

Conversation

pthom
Copy link
Contributor

@pthom pthom commented Jan 3, 2025

Hi,

Following
#25

Here is a PR which adds a link to the demo in the Readme. If you have a better wording proposition please apply it. This is just a suggestion.


About ImGui Bundle integration:

By the way, I added ImPlot3D to ImGui bundle (see latest commits. It is now available in the C++ and Python side of Dear ImGui Bundle.

The integration went smoothly. I had to make a fork for implot3d, since one part of the API was impossible to port to python without manual adjustments (see this commit which adapts the API for PlotSurface for Python bindings)

As an example, here is a working python app with Implot3D:

from imgui_bundle import imgui, immapp, implot3d
import numpy as np


def demo3d_lineplots():
    xs1 = np.linspace(0, 1, 1001)
    ys1 = 0.5 + 0.5 * np.cos(50 * (xs1 + imgui.get_time() / 10))
    zs1 = 0.5 + 0.5 * np.sin(50 * (xs1 + imgui.get_time() / 10))

    xs2 = np.linspace(0, 1, 20)
    ys2 = xs2 * xs2
    zs2 = xs2 * ys2

    if implot3d.begin_plot("Line Plots"):
        implot3d.setup_axes("x", "y", "z")
        implot3d.plot_line("f(x)", xs1, ys1, zs1)
        implot3d.set_next_marker_style(implot3d.Marker_.circle.value)
        implot3d.plot_line("g(x)", xs2, ys2, zs2, implot3d.LineFlags_.segments.value)
        implot3d.end_plot()


immapp.run(demo3d_lineplots, with_implot3d=True)

pthom added 2 commits January 3, 2025 10:21
ImGui::Text(some_char_ptr) is dangerous because some_char_ptr could be a format string.
This raises a justifiable warning in some compilers.
@pthom
Copy link
Contributor Author

pthom commented Jan 3, 2025

I have one question related to ImGui Bundle: I have to release a corrective patch to ImGui Bundle this week-end (because of issues not related to ImPlot3D).

At the moment, I'm using your commit 653b302
Do you think this version is OK for a first integration or would you advise me to use the dev branch?
It is not that important: this will be the first release of ImGui Bundle with ImPlot3D, but I will not communicate loudly about it yet, since there will be other / better ones after :-)

@brenocq brenocq self-requested a review January 3, 2025 19:06
@brenocq brenocq added type:docs Improvements or additions to documentation prio:medium Medium priority status:review The task is under review labels Jan 3, 2025
@brenocq brenocq changed the base branch from main to dev January 3, 2025 19:18
Copy link
Owner

@brenocq brenocq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome to me

README.md Outdated Show resolved Hide resolved
@brenocq
Copy link
Owner

brenocq commented Jan 3, 2025

I moved my replies to #45, let's continue the conversation in that dicussion since this PR will be merged!

By the way, I added ImPlot3D to ImGui bundle (see latest commits. It is now available in the C++ and Python side of Dear ImGui Bundle.

Wow this is amazing! I had no idea ImPlot3D could be ported to python when I started it kkkkkkk great to see it! I tried testing it locally following these commands:

python -m venv .env
source .env/bin/activate.fish
pip install imgui-bundle
pip install opencv-python
pip install pyGLM
python imgui_bundle.py

However, I got the following error:

Traceback (most recent call last):
  File "/home/breno/Downloads/bundle-test/imgui_bundle.py", line 1, in <module>
    from imgui_bundle import imgui, immapp, implot3d
  File "/home/breno/Downloads/bundle-test/imgui_bundle.py", line 1, in <module>
    from imgui_bundle import imgui, immapp, implot3d
ImportError: cannot import name 'imgui' from partially initialized module 'imgui_bundle' (most likely due to a circular import) (/home/breno/Downloads/bundle-test/imgui_bundle.py)

Here is the pip freeze for reference

annotated-types==0.7.0
glfw==2.8.0
imgui-bundle==1.6.1
munch==4.0.0
numpy==2.2.1
opencv-python==4.10.0.84
pillow==11.1.0
pydantic==2.10.4
pydantic_core==2.27.2
PyGLM==2.7.3
PyOpenGL==3.1.7
typing_extensions==4.12.2

Let me know if I did something wrong! I would love to test the python bindings :)

The integration went smoothly. I had to make a fork for implot3d, since one part of the API was impossible to port to python without manual adjustments (see this commit which adapts the API for PlotSurface for Python bindings)

I don't mind having two signatures for the SurfacePlot. Ideally, we would have only one method to avoid confusing some users, but having two signatures sounds worth it if it is the only way to get SurfacePlot Python binding.

At the moment, I'm using your commit 653b302
Do you think this version is OK for a first integration or would you advise me to use the dev branch?

It is fine to use this commit for your release! I advise using the main branch for releases since the dev branch may be a bit unstable.

It is not that important: this will be the first release of ImGui Bundle with ImPlot3D, but I will not communicate loudly about it yet, since there will be other / better ones after :-)

Sounds very exciting, I'm looking forward to using it!

@brenocq brenocq merged commit 10f0beb into brenocq:dev Jan 3, 2025
@brenocq brenocq added status:done Task completed successfully and removed status:review The task is under review labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio:medium Medium priority status:done Task completed successfully type:docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants