FLAMEGPU / FLAMEGPU2-visualiser

Cross platform real-time OpenGL visualiser for FLAMEGPU2 models.
1 stars 2 forks source link

Simple user interface for interacting with models #92

Open mondus opened 2 years ago

mondus commented 2 years ago

Suggest a couple of utility functions which would add control to a movable UI window rendered with OpenGL.

addUISliderControl(name_of_env_var, min_range, max_range): This should create a slider element in the UI so that the environment property (float or int) can be varied interactively. E.g. Boids rule weights.

addUIToggleControl(callback): This should create a toggle button element in the UI so that the environment property (int or bool) can be varied interactively. E.g. Exit open/closed.

There are some nice simple libraries for this e.g. https://github.com/wjakob/nanogui Although this wouldn't be overly difficult to implement from scratch.

mondus commented 2 years ago

@MILeach Has used https://github.com/ocornut/imgui which seems like a good candidate library.

Robadob commented 2 years ago

Sliders don't work, would require users to additionally specify min/max/step, alot of extra hassle.

Probably easier to just allow users to type in a new value.

Need to complete #17 first, shouldn't be too difficult after that.

Robadob commented 2 years ago

cc @mondus

Main question is whether users should be able to create multiple distinct UI panels, or only one.

In both cases, probably want to move customisation into a distinct class to save cluttering ModelVis further.

All customisation should largely consist of a direct mapping to IMGUI features, with some extra fudge to pull in the correct data. Maybe I'm blind, but I can't find a clear documentation list of the UI elements supports (widgets), short of just reading the header imgui.h.

/**
 * This provides an interface for managing the render options for a specific CUDASimulation
 */
class ModelVis {
     ...
     /**
      * Add a customisable user interface panel to the visualisation
      *
      * Each panel can be moved around the screen/minimised with custom elements representing environment properties added
      * @param panel_title The string that will be visible in the title of the panel
      */
     PanelVis newUIPanel(const std::string &panel_title);
};
/**
 * This provides an interface for constructing visualisation UI panels.
 * Elements added will appear vertically in the same order that they are added
 */
class PanelVis {
     /**
      * Add a slider which displays the named environment property and allows it's value to be updated
      *
      * @param property_name Name of the affected environment property
      * @param min Minimum value of the slider
      * @param max Maximum value of the slider
      * @param steps Number of steps available on the slider
      * @throw exception::InvalidProperty When a slider has already been defined (in any UI for this property)
      */
     template<typename T>
     void newEnvironmentPropertySlider(const std::string &property_name, T min, T max, unsigned int steps);
     /**
      * Add a label which displays the named environment property's value 
      *
      * @param property_name Name of the affected environment property
      */
     void newEnvironmentPropertyLabel(const std::string &property_name);
     /**
      * Add a label containing a fixed string
      *
      * @param label_text Text of the label
      */
     void newStaticLabel(const std::string &label_text);
     ...  // Whatever other UI elements we decide to support
};
mondus commented 2 years ago

Interface looks good. I would suggest for now a single UI Panel only with the ability to toggle its view on or off using a keyboard binding. Label should support multi line to allow a model like description to be displayed.