40#ifndef H_GEOGRAM_GFX_GUI_SIMPLE_APPLICATION_H
41#define H_GEOGRAM_GFX_GUI_SIMPLE_APPLICATION_H
51#include <geogram_gfx/imgui_ext/imgui_ext.h>
52#include <geogram_gfx/imgui_ext/icon_font.h>
97 virtual bool save(
const std::string& filename);
106 virtual bool load(
const std::string& filename);
120 text_editor_visible_ =
true;
127 text_editor_visible_ =
false;
134 console_visible_ =
true;
141 console_visible_ =
false;
161 double xmin,
double ymin,
double zmin,
162 double xmax,
double ymax,
double zmax
172 double& xmin,
double& ymin,
double& zmin,
173 double& xmax,
double& ymax,
double& zmax
184 void set_clipping(
bool x) {
188 void set_lighting(
bool x) {
192 void set_background_color(
const vec4f& color) {
193 background_color_ = color;
196 virtual bool exec_command(
const char* command);
198 static SimpleApplication* instance() {
199 return dynamic_cast<SimpleApplication*
>(
242 const std::string& key, std::function<
void()> cb,
243 const char* help =
nullptr
253 const std::string& key,
bool* p_val,
254 const char* help =
nullptr
265 void key_callback(
int key,
int scancode,
int action,
int mods)
override;
271 int button,
int action,
int mods,
int source
394 virtual bool can_load(
const std::string& filename);
442 void browse(
const std::string& path,
bool subdirs=
false);
455 strcpy(filename_, filename.c_str());
487 void set_default_layout();
491 virtual const char* default_layout()
const;
492 virtual const char* default_layout_android_vertical()
const;
493 virtual const char* default_layout_android_horizontal()
const;
496 static void replay_latest_command();
503 GLUPclipMode clip_mode_;
507 vec4f background_color_;
509 bool viewer_properties_visible_;
510 bool object_properties_visible_;
511 bool console_visible_;
512 bool text_editor_visible_;
513 bool use_text_editor_;
517 vec3 object_translation_;
521 vec3 clip_translation_;
529 MOUSE_NOOP, MOUSE_ROTATE, MOUSE_TRANSLATE, MOUSE_ZOOM
533 MOUSE_NOTARGET, MOUSE_OBJECT, MOUSE_LIGHT, MOUSE_CLIP
541 mat4 modelview_transpose_;
542 mat4 project_transpose_;
545 std::string current_file_;
546 char filename_[geo_imgui_string_length];
547 GLuint geogram_logo_texture_;
549 Console_var console_;
550 StatusBar_var status_bar_;
551 TextEditor text_editor_;
553 std::map< std::string, std::function<void()> > key_funcs_;
554 std::map< std::string, std::string > key_funcs_help_;
566 lua_State* lua_state_;
567 bool lua_error_occured_;
Base class for all applications.
static Application * instance()
Gets the instance.
Enables to interactively define a rotation.
Axis-aligned bounding box.
SimpleApplication is an Application with pre-created and customizable menus, commands,...
virtual void draw_fileops_menu()
Draws other file operation menu.
virtual void draw_console()
Draws the console.
void cursor_pos_callback(double x, double y, int source) override
Callback called whenever the mouse cursor is moved.
virtual void draw_scene_begin()
Setups OpenGL for scene drawing.
virtual void draw_application_menus()
Draws the application menus.
virtual void draw_load_menu()
Draws the load menu and browser.
void drop_callback(int nb, const char **f) override
Callback called whenever files are dropped in the window.
virtual bool save(const std::string &filename)
Saves the current content to a file.
virtual bool can_load(const std::string &filename)
Tests whether a file can be loaded.
TextEditor & text_editor()
Gets the text editor.
virtual void draw_viewer_properties()
Draws the contents of viewer properties window.
virtual void draw_about()
Draws the about box in the file menu.
virtual void draw_application_icons()
Draws the application icons on the menubar.
void char_callback(unsigned int c) override
Callback called whenever a key is pushed (high level version)
virtual void draw_help()
Draws help info (accelarators)
void set_style(const std::string &style) override
Sets the style of the application.
virtual void draw_scene_end()
Cleanups OpenGL after scene drawing.
void mouse_button_callback(int button, int action, int mods, int source) override
Callback called whenenver a mouse button changed.
void hide_text_editor()
Hides the text editor.
vec3 project(const vec3 &p)
Projects a point from model space to window coordinates.
vec3 unproject(const vec3 &p)
Unprojects a 3d point from window coordinates to model space.
void resize(index_t w, index_t h, index_t fb_w, index_t fb_h) override
Called whenever window size changes.
void init_colormap(const std::string &name, const char **xpm_data)
Initializes a new colormap from name and xpm data.
virtual void draw_menu_bar()
Draws the menu bar.
vec2 unproject_2d(const vec2 &p)
Unprojects a 2d point from window coordinates to model space.
virtual void draw_windows_menu()
Draws the windows menu.
virtual void draw_viewer_properties_window()
Draws the viewer properties window frame and contents.
void show_console()
Shows the console.
void show_text_editor()
Shows the text editor.
void GL_initialize() override
Initializes OpenGL and GLUP objects.
void key_callback(int key, int scancode, int action, int mods) override
Callback called whenever a key is pushed (low level version)
ImTextureID convert_to_ImTextureID(GLuint gl_texture_id_in)
Converts an OpenGL texture ID into an ImGUI texture ID.
SimpleApplication(const std::string &name)
SimpleApplication constructor.
void scroll_callback(double xoffset, double yoffset) override
Callback called whenenver the mouse wheel is moved.
void browse(const std::string &path, bool subdirs=false)
Recursively browses a directory and generates menu items.
void draw_gui() override
This function is called when the GUI should be redisplayed.
virtual void draw_command_window()
Draws the active command window if any.
void get_region_of_interest(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const
Gets the region of interest.
virtual void draw_object_properties()
Draws the contents of the object properties window.
void draw_graphics() override
This function is called when the 3d content should be redisplayed.
void set_default_filename(const std::string &filename)
Sets the default filename used to save the current file.
virtual std::string supported_read_file_extensions()
Gets the list of supported file extensions for reading.
void post_draw() override
This function is called after all drawing operations.
void home()
Restores default viewing parameters.
void ImGui_initialize() override
Initializes the ImGui library.
~SimpleApplication() override
SimpleApplication destructor.
virtual bool load(const std::string &filename)
Loads a file.
void GL_terminate() override
Deallocates OpenGL and GLUP objects.
void hide_console()
Hides the console.
virtual void draw_scene()
Draws the scene.
virtual std::string supported_write_file_extensions()
Gets the list of supported file extensions for writing.
void add_key_func(const std::string &key, std::function< void()> cb, const char *help=nullptr)
Declares a function to be triggered when a key is pressed.
void init_colormaps()
Initializes all the default colormaps.
void geogram_initialize(int argc, char **argv) override
void add_key_toggle(const std::string &key, bool *p_val, const char *help=nullptr)
Declares a boolean to be toggled when a key is pressed.
virtual void draw_save_menu()
Draws the save menu.
void set_region_of_interest(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Sets the region of interest.
virtual void draw_object_properties_window()
Draw the object properties window frame and contents.
A minimalistic text editor.
Vector with aligned memory allocation.
A simple system to interface C++ functions with a ImGui interface. Used mainly by geobox.
Common include file, providing basic definitions. Should be included before anything else by all head...
Low-level base class for full screen effects.
Base class for all applications.
Controls a 3d rotation from user mouse input.
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
Implementation of the status bar.