Skip to content

ENH: added GUI features

Nicholas Milef requested to merge NickMilef/iMSTK:GUI_Feature into master

Integrated Dear ImGui, only works with Vulkan. I planned to do VTK too, but the problem is that the integration is tricky due to VTK not using a standard cross-platform windowing system (GLFW, SDL, etc.). Dear ImGui provides bindings for the major system but VTK uses the OS-specific windowing systems. Also, VTK rendering hides the swapping of buffers, and the rendering of the UI needs to be placed before the swapping. I will look further into this.

The bulk of the MR isn't the integration but rather the wrapping of features around ImGui so that it's much more usable. The ImGui API isn't that user-friendly (state-machine like OpenGL), but wrapping it made it much easier to use. I will explain the architecture below:

  • Canvas: attached to the Viewer. You can add Widgets to the canvas.
  • Widget: the main UI element class. Every UI element inherits from this.
  • WidgetList: a list of Widget objects. The reason why this is a separate class from a vector is so that you can search for widgets by name. Unlike a map, the insertion order is preserved, which is important for UI elements that display on top of each other.
  • Window (Widget): can hold other widgets. Looks like a window.
  • Shape (Widget): currently circles and rectangles are supported (subclasses).
  • Text (Widget): text is supported, although only one font type is supported.

I added some features to allow text and shapes to be directly displayed on the canvas without a window. Technically, the ImGui API supports this, but I made it seamless, so the user doesn't have to issue different instructions depending on where they want to add it.

Edited by Nicholas Milef

Merge request reports