Skip to content

start imgui implementation #571

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

Merged
merged 192 commits into from
Sep 29, 2024
Merged

start imgui implementation #571

merged 192 commits into from
Sep 29, 2024

Conversation

kushalkolar
Copy link
Member

@kushalkolar kushalkolar commented Jul 30, 2024

The actual imgui implementation discussed with @clewis7

image

Started implemetning ImguiFigure, kinda alright so far.

tasks:

  • BaseGUI
  • complete ImguiFigure
    • manages imgui rendering
    • manages standard right click menu
    • manages EdgeWindows
  • subplot toolbar
  • standard right click menu
  • allow adding custom GUIs to edges of canvas, these are managed by ImguiFigure
  • allow graphics to "request" starting their own right click menu on the next render cycle
    • right click menu for hlut/colorbar tool
  • ImageWidget, along with play button etc. Maybe we can use time.perf_counter() and actually display a specific FPS?
  • tests :D
  • image widget imgui example with EdgeWindow
  • a basic imgui example with EdgeWindow
  • move image widget examples from notebook to main docs
  • make sure non-imgui use is not affected!
  • remove ipywidget and qt toolbars, cleanup anything else that needs cleaning up, remove output contexts!

closes #494 , closes #260 , closes #360

This was referenced Jul 30, 2024
@kushalkolar
Copy link
Member Author

Should be possible to dynamically add and remove GUIs to edges if the BaseGUI subclass implements a cleanup method.

@kushalkolar kushalkolar force-pushed the imgui-implementation branch from 4a08c2e to 247c191 Compare July 31, 2024 06:32
@kushalkolar
Copy link
Member Author

depends on #574

@kushalkolar
Copy link
Member Author

cmap picker, last thing I'm making before the sliders for ImageWidget 😄

cmap-picker-2024-07-31_02.37.21.mp4

@clewis7 @apasarkar

@kushalkolar
Copy link
Member Author

Might make more sense to subclass Subplot and add the toolbar to it directly

@kushalkolar
Copy link
Member Author

ok now after subsampling the cockatoo video memory consumption when I build locally remains < 1.5GB. Before it was ~2.7 GB.

Comment on lines +18 to +21
# Ignore and do not use the next 2 lines
# for the purposes of docs gallery generation we subsample and only use 15 frames
movie_sub = movie[:15, ::12, ::12].copy()
del movie
Copy link
Member Author

Choose a reason for hiding this comment

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

@clewis7 until we either figure out a way to hide this from the docs example code (maybe do it under the hood in ImageWidget by checking for RTD_BUILD=1 env variable) or fix the annoying sphinx gallery memory leak

Copy link
Member

Choose a reason for hiding this comment

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

I think we do it under the hood by checking for env variable

Comment on lines +23 to +25
shared = pygfx.renderers.wgpu.get_shared()
self._texture_limit_2d = shared.device.limits["max-texture-dimension2d"]

Copy link
Member Author

Choose a reason for hiding this comment

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

@clewis7 so now instead of tiling textures based on the default 8192 WGPU limit, it will read the limits currently set on the adapter and use those 😄 . This way we can set it to whatever we want in the tests, such as 1024 or 2048, and it will dynamically read the value that has been set for creating the texture array!

Copy link
Member

Choose a reason for hiding this comment

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

cool!

Comment on lines +27 to +30
if "RTD_BUILD" in os.environ.keys():
if os.environ["RTD_BUILD"] == "1":
self._playing["t"] = True
self._loop = True
Copy link
Member Author

Choose a reason for hiding this comment

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

@clewis7 this is how the video auto-plays upon ImageWidget create for docs gallery generation

Comment on lines +7 to +8
def pytest_sessionstart(session):
pygfx.renderers.wgpu.set_wgpu_limits(**{"max-texture-dimension2d": MAX_TEXTURE_SIZE})
Copy link
Member Author

Choose a reason for hiding this comment

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

@clewis7 This is how we set the limit before the test session starts. The limit must be set before any renderer object is created, so it that's why it's in pytest_sessionstart()

Copy link
Member Author

Choose a reason for hiding this comment

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

@clewis7 so the difs here make sure that the TextureArray can be created correctly for the various scenarios given a limit of 1024, could you go through it and just check that the logic is correct? I've put notes.

Comment on lines +172 to +173
row_indices_values=np.array([0, MAX_TEXTURE_SIZE]),
col_indices_values=np.array([0, MAX_TEXTURE_SIZE, 2 * MAX_TEXTURE_SIZE]),
Copy link
Member Author

Choose a reason for hiding this comment

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

So if we have an data array of shape (1200, 2200), and the limit is 1024 then we need a TextureArray of shape (2, 3), that's the buffer_shape here.

for the rows, we need 2 because 1200 with a limit of 1024 means we will have array with 1024 rows and another with 176

Same logic for the columns and the other tests below for test_tall and test_square

Copy link
Member Author

Choose a reason for hiding this comment

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

imagewidget tools show up in test screenshots too :D

@kushalkolar
Copy link
Member Author

ALL TESTS FINALLY PASSING AND RTD BUILD IS BUILDING 🥳 🥳 🥳 🥳

I didn't expent the hardest thing about this would be dealing with rtd limits and sphinx gallery memory leak 🤦

@clewis7 few final comments up here just to get you up to speed, and if you could do a final check on that TextureArray test stuff I pointed out at the bottom. Other than that good to go!!

@kushalkolar
Copy link
Member Author

I updated the user guide with imgui images, need to figure out why the vids are not looping, I used imageio to make them 🤔

@clewis7
Copy link
Member

clewis7 commented Sep 29, 2024

LGTM!

@kushalkolar kushalkolar merged commit ab5b787 into main Sep 29, 2024
10 checks passed
@kushalkolar kushalkolar deleted the imgui-implementation branch September 29, 2024 17:18
@EricThomson
Copy link
Contributor

This looks amazing Kushal!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qt UI small toolbar buttons on Mac traitlet's deprecation Usage with glfw - imgui
5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy