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>
92 virtual bool save(
const std::string& filename);
101 virtual bool load(
const std::string& filename);
115 text_editor_visible_ =
true;
122 text_editor_visible_ =
false;
129 console_visible_ =
true;
136 console_visible_ =
false;
156 double xmin,
double ymin,
double zmin,
157 double xmax,
double ymax,
double zmax
167 double& xmin,
double& ymin,
double& zmin,
168 double& xmax,
double& ymax,
double& zmax
179 void set_clipping(
bool x) {
183 void set_lighting(
bool x) {
187 void set_background_color(
const vec4f& color) {
188 background_color_ = color;
191 virtual bool exec_command(
const char* command);
193 static SimpleApplication* instance() {
194 return dynamic_cast<SimpleApplication*
>(
237 const std::string& key, std::function<
void()> cb,
238 const char* help =
nullptr
248 const std::string& key,
bool* p_val,
249 const char* help =
nullptr
260 void key_callback(
int key,
int scancode,
int action,
int mods)
override;
266 int button,
int action,
int mods,
int source
389 virtual bool can_load(
const std::string& filename);
437 void browse(
const std::string& path,
bool subdirs=
false);
450 strcpy(filename_, filename.c_str());
482 void set_default_layout();
486 virtual const char* default_layout()
const;
487 virtual const char* default_layout_android_vertical()
const;
488 virtual const char* default_layout_android_horizontal()
const;
491 static void replay_latest_command();
498 GLUPclipMode clip_mode_;
502 vec4f background_color_;
504 bool viewer_properties_visible_;
505 bool object_properties_visible_;
506 bool console_visible_;
507 bool text_editor_visible_;
508 bool use_text_editor_;
512 vec3 object_translation_;
516 vec3 clip_translation_;
524 MOUSE_NOOP, MOUSE_ROTATE, MOUSE_TRANSLATE, MOUSE_ZOOM
528 MOUSE_NOTARGET, MOUSE_OBJECT, MOUSE_LIGHT, MOUSE_CLIP
536 mat4 modelview_transpose_;
537 mat4 project_transpose_;
540 std::string current_file_;
541 char filename_[geo_imgui_string_length];
542 GLuint geogram_logo_texture_;
544 Console_var console_;
545 StatusBar_var status_bar_;
546 TextEditor text_editor_;
548 std::map< std::string, std::function<void()> > key_funcs_;
549 std::map< std::string, std::string > key_funcs_help_;
561 lua_State* lua_state_;
562 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.
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.
virtual void draw_viewer_properties()
Draws the contents of viewer properties window.
virtual void draw_about()
Draws the about box in the file menu.
TextEditor & text_editor()
Gets the text editor.
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.
Matrix< 4, Numeric::float64 > mat4
Represents a 4x4 matrix.
vecng< 4, Numeric::float32 > vec4f
Represents points and vectors in 4d with single-precision coordinates.
geo_index_t index_t
The type for storing and manipulating indices.
vecng< 2, Numeric::float64 > vec2
Represents points and vectors in 2d.
Implementation of the status bar.