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

New desktop GUI using ImGui #583

Merged
merged 130 commits into from
Jun 25, 2021
Merged

New desktop GUI using ImGui #583

merged 130 commits into from
Jun 25, 2021

Conversation

GPMueller
Copy link
Member

@GPMueller GPMueller commented Jan 6, 2021

  • basic visualisation with mouse and keyboard interaction
  • renderer customisation with arbitrary amount and combination of renderers
  • ability to run any of the calculation methods
  • plots of energy and recent history of max. force (i.e. convergence)
  • information overlays
  • configuration setters
  • ability to set parameters for all methods
  • ability to change Hamiltonian parameters
  • ability to change the geometry
  • interaction modes: regular, dragging, vacancies, pinning
  • saving settings for ui, visualisation, spin configuration and plotting in a config file
  • some basic documentation to match the Qt GUI docs

Closes #20.
Closes #68.
Closes #112.
Closes #119.
Closes #178.
Closes #213.
Closes #247.
Closes #401.
Closes #407.
Closes #448.
Closes #452.
Closes #473.
Closes #474.
Closes #546.

Related to issue #511.

Note: the API for setting the Hamiltonian at runtime has been implemented on the branch fixed-imgui.

GPMueller and others added 30 commits June 21, 2020 15:36
- modified main.cpp accordingly and applied some formatting
- modified VFRendering for GLAD to work
- basic functionality is working: opening a glfw window with some imgui content and drawing VFRendering arrows
The code should run, but it produces visually incorrect results - the GUI is not coloured correctly and the arrows are not drawn correctly.
The imgui now uses a separate webgl canvas placed on top of the VFRendering canvas.
Also made some minor modifications to the gui contents.
- added contents to the overlay, split into system and calculation info
- added a parameter-window that adapts to the selected method
- added a keybindings window
- added an about window
- added more content to the menu bar
- starting and stopping calculations, selectable via the menu bar and the info-widget
- handling mouse and keyboard via imgui instead of glfw
- initialize vfr geometry etc from info out of spirit and update spins every time we draw
- added initial plots
- added required pthread compile and link commands to be able to run simulation threads in the web UI (note: this currently only works in chromium-based browsers)
- can now only build either the current ui-web or ui-imgui for web
- added spirit.worker.js to gitignore
- added favicon.ico
- added a little exception-catching to print better errors on the web UI if they occur
Can control the background colour and the light direction, using the new gizmo3d.
- wrong #define used in VFRendering::View
- missing include in main_web.cpp
- missing simulation stop and thread join before closing window
- more bools in main_window instead of static
- reordered widgets.hpp
- some widgets windows can now be closed
- overlays can now be also toggled with "i" key
- improved scrolling behaviour on Apple
- now handling ctrl/cmd difference on Apple
- renamed `main_window` -> `MainWindow`.
- moved static variables from main_window.cpp into MainWindow class
- moved show_menu_bar to MainWindow, since it is the main window menu bar
- better toggles for windows, which can now also be closed by 'x'-button
- more information added to "about"-window
- renamed `loop` to `draw`
- added drawing during resizing (unfortunately this is not yet smooth)
- added `vfr_needs_redraw` and `vfr_needs_data` in order to save some CPU load
- moved usage of VFRendering into RenderingLayer class
- added MainWindow functions for manipulating the chain
- added indicator of chain length
- added res/Logo_Ghost.png as compiled resource in CMake
- added `textures::load_from_file`, which uses the compiled resource files and loads a given file into an OpenGL texture
- added logo to the "about"-window
- also fixed missing rendering_layer.cpp in source list
The tooltip on the method selection is helpful to explain what the acronyms mean.
- removed `glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 )`, which would require webgl2
- also improved styles to reduce opacity of windows, which can have strange effects in the browser
- also some formatting changes
- fixed application icon (at least for windows)
- added stb_image_resize.h to thirdparty/stb
- restructured textures.hpp/cpp and renamed to images.hpp/cpp
- added Logo_Ghost_Final_Notext.png, which is now resized using stb_image_resize to generate glfw app icons in various sizes
- improved "about window" formatting and logo size
- replaced a lot of ImGui::Text with ImGui::TextUnformatted
- removed AppIcon32.png and AppIcon128.png
@GPMueller
Copy link
Member Author

GPMueller commented Feb 1, 2021

The imgui web app has apparently been broken by commit 9becfa5. The bug is triggered by any calls to setOption<VFRendering::View::Option::IS_VISIBLE_IMPLEMENTATION> from within the RendererWidgets. It seems to be because the OpenGL context for ImGui, set in MainWindow::draw (emscripten_webgl_make_context_current( context_imgui )), is still the current context when these shader-changing functions are called within the widgets.

A solution might be to create a std::deque<std::function<void()>> onto which the vfr-calls are placed. This queue could be worked off by MainWIndow between emscripten_webgl_make_context_current( context_vfr ) and rendering_layer.draw( display_w, display_h ).

Now using ImGui's implementation of backends.
The main problem was that VFR options and renderers were being updated from within ImGui calls, while the active context was the one for the ImGui. This has been circumvented by adding all options updates to a deque that is worked off right before drawing. Also, the `emscripten_webgl_make_context_current( context_vfr )` call has been moved to right in front of the VFR draw.
Furthermore, some shaders were not working reliably with WebGL: `const int` cannot be converted to `float` and the `f` postfix is not supported by OpenGL ES 2.
Added some basicexception handling to `emscripten_loop`.
Also
- some fixes for the ImGui update.
- some minor naming fixes.
- minor update of main_web.cpp
@GPMueller
Copy link
Member Author

Note: bf2bb6a, updating ImGui to v1.81, adds the tables feature. This could be used to display and allow to edit the exchange and DM interaction pairs.

Since the desktop web app now (since 4981481) seems to work correctly, it would be a good time to add the mobile and desktop web apps to the list of CI artifacts.

This applies mainly to the interaction modes. Not sure if an something was changed with an ImGui update, but the current solution using `io.MouseDrawCursor` did not seem to work correctly anymore.
@GPMueller
Copy link
Member Author

I have added some basic documentation of the IM GUI usage and build process.
From my side, this PR can be merged now. I would recommend doing fixes and improvements on feature-branches rather than further increasing the size of this PR.

@GPMueller GPMueller requested a review from MSallermann May 30, 2021 17:39
@GPMueller GPMueller marked this pull request as ready for review May 30, 2021 17:46
Updated the build docs accordingly.
Also made some minor fixes to Qt GUI docs.
Now automatically copies the current image when an increase of the chain length is requested.
Also fixed a bug in ui-imgui that caused a crash when reducing the chain length
@MSallermann MSallermann merged commit ad9c9d4 into develop Jun 25, 2021
@GPMueller GPMueller deleted the feature-imgui branch February 9, 2023 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment