Geogram  Version 1.9.1
A programming library of geometric algorithms
GEO::SimpleApplication Class Reference
Inheritance diagram for GEO::SimpleApplication:
GEO::Application GEO::SimpleMeshApplication

Classes

struct  ColormapInfo
 

Public Member Functions

 SimpleApplication (const std::string &name)
 SimpleApplication constructor. More...
 
 ~SimpleApplication () override
 SimpleApplication destructor.
 
void draw_gui () override
 This function is called when the GUI should be redisplayed. More...
 
void draw_graphics () override
 This function is called when the 3d content should be redisplayed. More...
 
virtual bool save (const std::string &filename)
 Saves the current content to a file. More...
 
virtual bool load (const std::string &filename)
 Loads a file. More...
 
TextEditortext_editor ()
 Gets the text editor. More...
 
void show_text_editor ()
 Shows the text editor.
 
void hide_text_editor ()
 Hides the text editor.
 
void show_console ()
 Shows the console.
 
void hide_console ()
 Hides the console.
 
void home ()
 Restores default viewing parameters.
 
void set_style (const std::string &style) override
 Sets the style of the application. More...
 
void set_region_of_interest (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
 Sets the region of interest. More...
 
void get_region_of_interest (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const
 Gets the region of interest. More...
 
void zoom_in ()
 
void zoom_out ()
 
void set_clipping (bool x)
 
void set_lighting (bool x)
 
void set_background_color (const vec4f &color)
 
virtual bool exec_command (const char *command)
 
vec3 project (const vec3 &p)
 Projects a point from model space to window coordinates. More...
 
vec3 unproject (const vec3 &p)
 Unprojects a 3d point from window coordinates to model space. More...
 
vec2 unproject_2d (const vec2 &p)
 Unprojects a 2d point from window coordinates to model space. More...
 
void drop_callback (int nb, const char **f) override
 Callback called whenever files are dropped in the window. More...
 
- Public Member Functions inherited from GEO::Application
 Application (const std::string &name)
 Application constructor. More...
 
virtual ~Application ()
 Application destructor.
 
const std::string & name () const
 Gets the name of this application. More...
 
virtual void start (int argc=0, char **argv=nullptr)
 Starts the main event loop of the application. More...
 
virtual void stop ()
 Stops the application.
 
const std::string & get_style () const
 Gets the style. More...
 
void set_font_size (index_t value)
 Sets the font size. More...
 
index_t get_font_size () const
 Gets the font size. More...
 
virtual void update ()
 Indicates that the main window should be redrawn.
 
void draw_dock_space ()
 Draws a dockspace that fills the current window.
 
void lock_updates ()
 Lock updates. More...
 
void unlock_updates ()
 Unlock updates.
 
virtual void draw ()
 Redraws the main window. More...
 
double scaling () const
 Gets the global scaling to be applied to all GUI elements. More...
 
void set_full_screen_mode (index_t w=0, index_t h=0, index_t hz=0, index_t monitor=0)
 Sets full-screen mode. More...
 
void set_windowed_mode (index_t w=0, index_t h=0)
 Sets windowed mode. More...
 
void list_video_modes ()
 Lists the video modes that can be used for set_full_screen_mode() More...
 
void iconify ()
 Iconifies this application.
 
void restore ()
 Restores this application.
 
void set_gui_state (std::string x)
 Sets the gui state. More...
 
std::string get_gui_state () const
 Gets the gui state. More...
 
void set_full_screen (bool x)
 Sets full-screen mode. More...
 
bool get_full_screen () const
 Tests whether this application is in full-screen mode. More...
 
index_t get_width () const
 Gets the width of the window. More...
 
index_t get_height () const
 Gets the height of the window. More...
 
index_t get_frame_buffer_width () const
 Gets the width of the window. More...
 
index_t get_frame_buffer_height () const
 Gets the height of the window. More...
 
void set_accept_drops (bool value)
 Sets whether drag and drop events should be taken into account. More...
 
bool get_accept_drops () const
 Tests whether drag and drop events are taken into account. More...
 
void set_window_icon (Image *image)
 Sets the icon of the window. More...
 
void restart_gui ()
 Restarts the gui. More...
 
ApplicationData * impl_data ()
 Gets a pointer to the implementation-specific data. More...
 
void * impl_window ()
 Gets a pointer to the implementation-specific window. More...
 
double hidpi_scaling () const
 MacOS non-sense. More...
 
double pixel_ratio () const
 More MacOS non-sense. More...
 
void reset_soft_keyboard_flag ()
 Used internally.
 
const char * key_to_string (int key)
 Converts a key to a symbolic string with the name of the key. More...
 
virtual void pre_draw ()
 This function is called before starting drawing operations. More...
 
virtual bool needs_to_redraw () const
 Tests whether the window needs to be redrawn. More...
 
virtual void create_window ()
 Creates the window using GLFW.
 
virtual void delete_window ()
 Deletes the window created by GLFW.
 
virtual void one_frame ()
 Draws one frame. More...
 
virtual void main_loop ()
 Enters the main application loop. More...
 
virtual void ImGui_load_fonts ()
 Loads the fonts in ImGui.
 
virtual void ImGui_terminate ()
 Deallocates objects used by the ImGui library.
 
virtual void ImGui_new_frame ()
 Notifies ImGui that a new frame has just started.
 
void callbacks_initialize ()
 Initializes the callbacks if not already initialized.
 
const std::vector< std::string > & filenames () const
 Gets all the filenames specified on the command line. More...
 
bool animate () const
 
bool * animate_ptr ()
 
void start_animation ()
 
void stop_animation ()
 

Static Public Member Functions

static SimpleApplicationinstance ()
 
- Static Public Member Functions inherited from GEO::Application
static Applicationinstance ()
 Gets the instance. More...
 
static std::string get_styles ()
 Gets the possible styles. More...
 

Protected Types

enum  MouseOp { MOUSE_NOOP , MOUSE_ROTATE , MOUSE_TRANSLATE , MOUSE_ZOOM }
 
enum  MouseTarget { MOUSE_NOTARGET , MOUSE_OBJECT , MOUSE_LIGHT , MOUSE_CLIP }
 

Protected Member Functions

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. More...
 
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. More...
 
void char_callback (unsigned int c) override
 Callback called whenever a key is pushed (high level version) More...
 
void key_callback (int key, int scancode, int action, int mods) override
 Callback called whenever a key is pushed (low level version) More...
 
void mouse_button_callback (int button, int action, int mods, int source) override
 Callback called whenenver a mouse button changed. More...
 
void cursor_pos_callback (double x, double y, int source) override
 Callback called whenever the mouse cursor is moved. More...
 
void scroll_callback (double xoffset, double yoffset) override
 Callback called whenenver the mouse wheel is moved. More...
 
virtual void draw_scene_begin ()
 Setups OpenGL for scene drawing.
 
virtual void draw_scene ()
 Draws the scene.
 
virtual void draw_scene_end ()
 Cleanups OpenGL after scene drawing.
 
virtual void draw_viewer_properties_window ()
 Draws the viewer properties window frame and contents.
 
virtual void draw_viewer_properties ()
 Draws the contents of viewer properties window.
 
virtual void draw_object_properties_window ()
 Draw the object properties window frame and contents.
 
virtual void draw_object_properties ()
 Draws the contents of the object properties window.
 
virtual void draw_command_window ()
 Draws the active command window if any.
 
virtual void draw_console ()
 Draws the console.
 
virtual void draw_menu_bar ()
 Draws the menu bar.
 
virtual void draw_load_menu ()
 Draws the load menu and browser.
 
virtual void draw_save_menu ()
 Draws the save menu.
 
virtual void draw_fileops_menu ()
 Draws other file operation menu. More...
 
virtual void draw_about ()
 Draws the about box in the file menu.
 
virtual void draw_help ()
 Draws help info (accelarators)
 
virtual void draw_windows_menu ()
 Draws the windows menu.
 
virtual void draw_application_menus ()
 Draws the application menus. More...
 
virtual void draw_application_icons ()
 Draws the application icons on the menubar. More...
 
void post_draw () override
 This function is called after all drawing operations. More...
 
virtual bool can_load (const std::string &filename)
 Tests whether a file can be loaded. More...
 
virtual std::string supported_read_file_extensions ()
 Gets the list of supported file extensions for reading. More...
 
virtual std::string supported_write_file_extensions ()
 Gets the list of supported file extensions for writing. More...
 
ImTextureID convert_to_ImTextureID (GLuint gl_texture_id_in)
 Converts an OpenGL texture ID into an ImGUI texture ID. More...
 
void GL_initialize () override
 Initializes OpenGL and GLUP objects. More...
 
void GL_terminate () override
 Deallocates OpenGL and GLUP objects. More...
 
void browse (const std::string &path, bool subdirs=false)
 Recursively browses a directory and generates menu items. More...
 
void geogram_initialize (int argc, char **argv) override
 
void set_default_filename (const std::string &filename)
 Sets the default filename used to save the current file. More...
 
void init_colormap (const std::string &name, const char **xpm_data)
 Initializes a new colormap from name and xpm data. More...
 
void init_colormaps ()
 Initializes all the default colormaps. More...
 
void ImGui_initialize () override
 Initializes the ImGui library. More...
 
void set_2d ()
 
void set_3d ()
 
void set_default_layout ()
 
void resize (index_t w, index_t h, index_t fb_w, index_t fb_h) override
 Called whenever window size changes. More...
 
virtual const char * default_layout () const
 
virtual const char * default_layout_android_vertical () const
 
virtual const char * default_layout_android_horizontal () const
 

Static Protected Member Functions

static void replay_latest_command ()
 

Protected Attributes

bool locked_
 
bool lighting_
 
bool edit_light_
 
bool clipping_
 
GLUPclipMode clip_mode_
 
bool edit_clip_
 
bool fixed_clip_
 
GLenum effect_
 
vec4f background_color_
 
bool viewer_properties_visible_
 
bool object_properties_visible_
 
bool console_visible_
 
bool text_editor_visible_
 
bool use_text_editor_
 
Box roi_
 
double roi_radius_
 
vec3 object_translation_
 
ArcBall object_rotation_
 
ArcBall light_rotation_
 
ArcBall clip_rotation_
 
vec3 clip_translation_
 
bool three_D_
 
double zoom_
 
double zoom_down_
 
bool props_pinned_
 
enum GEO::SimpleApplication::MouseOp mouse_op_
 
enum GEO::SimpleApplication::MouseTarget mouse_target_
 
vec2 mouse_down_xy_
 
vec2 mouse_xy_
 
GLint viewport_ [4]
 
mat4 modelview_transpose_
 
mat4 project_transpose_
 
std::string path_
 
std::string current_file_
 
char filename_ [geo_imgui_string_length]
 
GLuint geogram_logo_texture_
 
Console_var console_
 
StatusBar_var status_bar_
 
TextEditor text_editor_
 
std::map< std::string, std::function< void()> > key_funcs_
 
std::map< std::string, std::string > key_funcs_help_
 
vector< ColormapInfocolormaps_
 
FullScreenEffectImpl_var full_screen_effect_
 
lua_State * lua_state_
 
bool lua_error_occured_
 
- Protected Attributes inherited from GEO::Application
bool ImGui_firsttime_init_
 
bool menubar_visible_
 
bool phone_screen_
 
bool soft_keyboard_visible_
 

Detailed Description

Definition at line 61 of file simple_application.h.

Constructor & Destructor Documentation

◆ SimpleApplication()

GEO::SimpleApplication::SimpleApplication ( const std::string &  name)

SimpleApplication constructor.

Parameters
[in]namethe name of the application.

Member Function Documentation

◆ add_key_func()

void GEO::SimpleApplication::add_key_func ( const std::string &  key,
std::function< void()>  cb,
const char *  help = nullptr 
)
protected

Declares a function to be triggered when a key is pressed.

Parameters
[in]keythe key ("a" for a, "F1" for F1)
[in]cbthe function to be called
[in]helpan optional help string

◆ add_key_toggle()

void GEO::SimpleApplication::add_key_toggle ( const std::string &  key,
bool *  p_val,
const char *  help = nullptr 
)
protected

Declares a boolean to be toggled when a key is pressed.

Parameters
[in]keythe key ("a" for a, "F1" for F1)
[in]p_vala pointer to the boolean
[in]helpan optional help string

◆ browse()

void GEO::SimpleApplication::browse ( const std::string &  path,
bool  subdirs = false 
)
protected

Recursively browses a directory and generates menu items.

Parameters
[in]paththe path to be browsed
[in]subdirsif true, browse subdirectories as well

◆ can_load()

virtual bool GEO::SimpleApplication::can_load ( const std::string &  filename)
protectedvirtual

Tests whether a file can be loaded.

This function can be used to filter the files displayed in the "Load..." menu. Baseclass implementation always return true. Derived classes may overload it and return false for files with unknown extensions.

◆ char_callback()

void GEO::SimpleApplication::char_callback ( unsigned int  c)
overrideprotectedvirtual

Callback called whenever a key is pushed (high level version)

Parameters
[in]cthe ASCII code of the character that corresponds to the pushed key.

Reimplemented from GEO::Application.

◆ convert_to_ImTextureID()

ImTextureID GEO::SimpleApplication::convert_to_ImTextureID ( GLuint  gl_texture_id_in)
protected

Converts an OpenGL texture ID into an ImGUI texture ID.

Parameters
[in]gl_texture_id_inthe OpenGL texture ID
Returns
the corresponding ImGUI texture ID

◆ cursor_pos_callback()

void GEO::SimpleApplication::cursor_pos_callback ( double  x,
double  y,
int  source 
)
overrideprotectedvirtual

Callback called whenever the mouse cursor is moved.

Parameters
[in]x,ythe new position of the mouse cursor.
[in]sourcethe event source (one of EVENT_SOURCE_MOUSE, EVENT_SOURCE_FINGER, EVENT_SOURCE_STYLUS)

Reimplemented from GEO::Application.

◆ draw_application_icons()

virtual void GEO::SimpleApplication::draw_application_icons ( )
protectedvirtual

Draws the application icons on the menubar.

Meant to be overloaded by derived classes.

◆ draw_application_menus()

virtual void GEO::SimpleApplication::draw_application_menus ( )
protectedvirtual

Draws the application menus.

Meant to be overloaded by derived classes.

◆ draw_fileops_menu()

virtual void GEO::SimpleApplication::draw_fileops_menu ( )
protectedvirtual

Draws other file operation menu.

Default implementation does nothing. It can be overloaded to add other menu items in the file menu.

◆ draw_graphics()

void GEO::SimpleApplication::draw_graphics ( )
overridevirtual

This function is called when the 3d content should be redisplayed.

This function is meant to be overloaded by subclasses. default implementation does nothing.

Reimplemented from GEO::Application.

◆ draw_gui()

void GEO::SimpleApplication::draw_gui ( )
overridevirtual

This function is called when the GUI should be redisplayed.

This function is meant to be overloaded by subclasses. default implementation does nothing.

Reimplemented from GEO::Application.

◆ drop_callback()

void GEO::SimpleApplication::drop_callback ( int  nb,
const char **  f 
)
overridevirtual

Callback called whenever files are dropped in the window.

Parameters
[in]nbnumber of files.
[in]fthe array of file names.

Reimplemented from GEO::Application.

◆ geogram_initialize()

void GEO::SimpleApplication::geogram_initialize ( int  argc,
char **  argv 
)
overrideprotectedvirtual

Reimplemented from GEO::Application.

Reimplemented in GEO::SimpleMeshApplication.

◆ get_region_of_interest()

void GEO::SimpleApplication::get_region_of_interest ( double &  xmin,
double &  ymin,
double &  zmin,
double &  xmax,
double &  ymax,
double &  zmax 
) const

Gets the region of interest.

See also
set_region_of_interest()
Parameters
[out]xmin,ymin,zmin,xmax,ymax,zmaxthe bounds of the region of interest.

◆ GL_initialize()

void GEO::SimpleApplication::GL_initialize ( )
overrideprotectedvirtual

Initializes OpenGL and GLUP objects.

Reimplemented from GEO::Application.

Reimplemented in GEO::SimpleMeshApplication.

◆ GL_terminate()

void GEO::SimpleApplication::GL_terminate ( )
overrideprotectedvirtual

Deallocates OpenGL and GLUP objects.

Reimplemented from GEO::Application.

Reimplemented in GEO::SimpleMeshApplication.

◆ ImGui_initialize()

void GEO::SimpleApplication::ImGui_initialize ( )
overrideprotectedvirtual

Initializes the ImGui library.

Reimplemented from GEO::Application.

◆ init_colormap()

void GEO::SimpleApplication::init_colormap ( const std::string &  name,
const char **  xpm_data 
)
protected

Initializes a new colormap from name and xpm data.

This function can be called only once the OpenGL context is ready, for instance in the init_graphics() function.

Parameters
[in]namethe name of the colormap
[in]xpm_datathe image data of the colormap.

◆ init_colormaps()

void GEO::SimpleApplication::init_colormaps ( )
protected

Initializes all the default colormaps.

This function can be called only once the OpenGL context is ready, for instance in the init_graphics() function.

◆ key_callback()

void GEO::SimpleApplication::key_callback ( int  key,
int  scancode,
int  action,
int  mods 
)
overrideprotectedvirtual

Callback called whenever a key is pushed (low level version)

Parameters
[in]keykey code (window system specific)
[in]scancodescan code (window system specific)
[in]actionpush or release (window system specific)
[in]modscurrent key modifieds (window system specific)

Reimplemented from GEO::Application.

◆ load()

virtual bool GEO::SimpleApplication::load ( const std::string &  filename)
virtual

Loads a file.

Baseclass implementation does nothing. Derived classes may overload this function.

Return values
trueif the file could be sucessfully loaded
falseotherwise

Reimplemented in GEO::SimpleMeshApplication.

◆ mouse_button_callback()

void GEO::SimpleApplication::mouse_button_callback ( int  button,
int  action,
int  mods,
int  source 
)
overrideprotectedvirtual

Callback called whenenver a mouse button changed.

Parameters
[in]buttonthe button
[in]actionthe action (one of EVENT_ACTION_UP, EVENT_ACTION_DOWN, EVENT_ACTION_DRAG)
[in]modsthe current key modifiers (not implemented yet)
[in]sourcethe event source (one of EVENT_SOURCE_MOUSE, EVENT_SOURCE_FINGER, EVENT_SOURCE_STYLUS)

Reimplemented from GEO::Application.

◆ post_draw()

void GEO::SimpleApplication::post_draw ( )
overrideprotectedvirtual

This function is called after all drawing operations.

It can be used to execute queued commands.

Reimplemented from GEO::Application.

◆ project()

vec3 GEO::SimpleApplication::project ( const vec3 p)

Projects a point from model space to window coordinates.

Parameters
[in]pthe point in model space coordinates.
Returns
the point in window coordinates, that is [0,width-1] x [0,height-1]

◆ resize()

void GEO::SimpleApplication::resize ( index_t  w,
index_t  h,
index_t  fb_w,
index_t  fb_h 
)
overrideprotectedvirtual

Called whenever window size changes.

Parameters
[in]w,hthe new window width and height in pixels.
[in]fb_w,fb_hthe new framebuffer width and height in pixels.

Called whenenver the size of the window does not match the current size.

Reimplemented from GEO::Application.

◆ save()

virtual bool GEO::SimpleApplication::save ( const std::string &  filename)
virtual

Saves the current content to a file.

Baseclass implementation does nothing. Derived classes may overload this function.

Return values
trueif the file could be sucessfully saved.
falseotherwise

Reimplemented in GEO::SimpleMeshApplication.

◆ scroll_callback()

void GEO::SimpleApplication::scroll_callback ( double  xoffset,
double  yoffset 
)
overrideprotectedvirtual

Callback called whenenver the mouse wheel is moved.

Parameters
[in]xoffset,yoffsetwheel displacement

Reimplemented from GEO::Application.

◆ set_default_filename()

void GEO::SimpleApplication::set_default_filename ( const std::string &  filename)
inlineprotected

Sets the default filename used to save the current file.

Parameters
[in]filenamethe default filename.

Definition at line 449 of file simple_application.h.

◆ set_region_of_interest()

void GEO::SimpleApplication::set_region_of_interest ( double  xmin,
double  ymin,
double  zmin,
double  xmax,
double  ymax,
double  zmax 
)

Sets the region of interest.

This defines the default target of the camera

Parameters
[in]xmin,ymin,zmin,xmax,ymax,zmaxthe bounds of the region of interest.

◆ set_style()

void GEO::SimpleApplication::set_style ( const std::string &  style)
overridevirtual

Sets the style of the application.

Parameters
[in]valueone of Dark, Light, DarkGray, LightGray
See also
get_styles()

Reimplemented from GEO::Application.

◆ supported_read_file_extensions()

virtual std::string GEO::SimpleApplication::supported_read_file_extensions ( )
protectedvirtual

Gets the list of supported file extensions for reading.

This function may be olverloaded by derived class. Base class implementation returns "". If this function returns "", then no "Load..." option is displayed in the "File" menu.

Returns
The semi-colon separated list of supported file extensions, or "*" if all file extensions are supported.

Reimplemented in GEO::SimpleMeshApplication.

◆ supported_write_file_extensions()

virtual std::string GEO::SimpleApplication::supported_write_file_extensions ( )
protectedvirtual

Gets the list of supported file extensions for writing.

This function may be olverloaded by derived class. Base class implementation returns "". If this function returns "", then no "Save..." option is displayed in the "File" menu. If it returns a colon-separated list of extensions, then the "Save..." option displays a list of possible file names for each supported extension.

Returns
The semi-colon separated list of supported file extensions, or "*" if all file extensions are supported.

Reimplemented in GEO::SimpleMeshApplication.

◆ text_editor()

TextEditor& GEO::SimpleApplication::text_editor ( )
inline

Gets the text editor.

Returns
a reference to the text editor.

Definition at line 107 of file simple_application.h.

◆ unproject()

vec3 GEO::SimpleApplication::unproject ( const vec3 p)

Unprojects a 3d point from window coordinates to model space.

Parameters
[in]pthe 3d point in window coordinates, that is [0,width-1] x [0,height-1]
Returns
the point in model space coordinates.

◆ unproject_2d()

vec2 GEO::SimpleApplication::unproject_2d ( const vec2 p)

Unprojects a 2d point from window coordinates to model space.

Parameters
[in]pthe 2d point in screen space coordinates.
Returns
the 2d point in model space coordinates.

Member Data Documentation

◆ zoom_down_

double GEO::SimpleApplication::zoom_down_
protected

Zoom when mouse down.

Definition at line 519 of file simple_application.h.


The documentation for this class was generated from the following file: