Graphite  Version 3
An experimental 3D geometry processing program
GEO::Application Class Reference

Base class for all applications. More...

#include <geogram_gfx/gui/application.h>

Inheritance diagram for GEO::Application:
GEO::SimpleApplication GEO::SimpleMeshApplication

Public Member Functions

 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...
 
virtual void set_style (const std::string &value)
 Sets the style of the application. 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...
 
virtual void mouse_button_callback (int button, int action, int mods=0, int source=EVENT_SOURCE_MOUSE)
 Callback called whenenver a mouse button changed. More...
 
virtual void scroll_callback (double xoffset, double yoffset)
 Callback called whenenver the mouse wheel is moved. More...
 
virtual void cursor_pos_callback (double x, double y, int source=EVENT_SOURCE_MOUSE)
 Callback called whenever the mouse cursor is moved. More...
 
virtual void drop_callback (int nb, const char **f)
 Callback called whenever files are dropped in the window. More...
 
virtual void char_callback (unsigned int c)
 Callback called whenever a key is pushed (high level version) More...
 
virtual void key_callback (int key, int scancode, int action, int mods)
 Callback called whenever a key is pushed (low level version) 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 draw_gui ()
 This function is called when the GUI should be redisplayed. More...
 
virtual void draw_graphics ()
 This function is called when the 3d content should be redisplayed. More...
 
virtual void pre_draw ()
 This function is called before starting drawing operations. More...
 
virtual void post_draw ()
 This function is called after all 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 resize (index_t w, index_t h, index_t fb_w, index_t fb_h)
 Called whenever window size changes. More...
 
virtual void one_frame ()
 Draws one frame. More...
 
virtual void main_loop ()
 Enters the main application loop. More...
 
virtual void GL_initialize ()
 Initializes OpenGL and GLUP objects.
 
virtual void GL_terminate ()
 Deallocates OpenGL and GLUP objects.
 
virtual void ImGui_initialize ()
 Initializes the ImGui library.
 
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.
 
virtual void geogram_initialize (int argc, char **argv)
 
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 Applicationinstance ()
 Gets the instance. More...
 
static std::string get_styles ()
 Gets the possible styles. More...
 

Protected Attributes

bool ImGui_firsttime_init_
 
bool menubar_visible_
 
bool phone_screen_
 
bool soft_keyboard_visible_
 

Detailed Description

Base class for all applications.

This class handles the cross-platform creation of a window, OpenGL context, and ImGui. Client code may use SimpleApplication instead.

Definition at line 66 of file application.h.

Constructor & Destructor Documentation

◆ Application()

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

Application constructor.

Parameters
[in]namethe name of the application

Member Function Documentation

◆ char_callback()

virtual void GEO::Application::char_callback ( unsigned int  c)
virtual

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 in GEO::SimpleApplication.

◆ cursor_pos_callback()

virtual void GEO::Application::cursor_pos_callback ( double  x,
double  y,
int  source = EVENT_SOURCE_MOUSE 
)
virtual

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 in GEO::SimpleApplication.

◆ draw()

virtual void GEO::Application::draw ( )
virtual

Redraws the main window.

This function is called by commands that animate objects during computation, by the progress bar and by console output.

◆ draw_graphics()

virtual void GEO::Application::draw_graphics ( )
virtual

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 in GEO::SimpleApplication.

◆ draw_gui()

virtual void GEO::Application::draw_gui ( )
virtual

This function is called when the GUI should be redisplayed.

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

Reimplemented in GEO::SimpleApplication.

◆ drop_callback()

virtual void GEO::Application::drop_callback ( int  nb,
const char **  f 
)
virtual

Callback called whenever files are dropped in the window.

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

Reimplemented in GEO::SimpleApplication.

◆ filenames()

const std::vector<std::string>& GEO::Application::filenames ( ) const
inline

Gets all the filenames specified on the command line.

Returns
a const reference to a vector of strings with the filenames.

Definition at line 548 of file application.h.

◆ get_accept_drops()

bool GEO::Application::get_accept_drops ( ) const
inline

Tests whether drag and drop events are taken into account.

Return values
trueif drag and drop events are taken into account
falseotherwise

Definition at line 308 of file application.h.

◆ get_font_size()

index_t GEO::Application::get_font_size ( ) const
inline

Gets the font size.

Returns
the font size.

Definition at line 143 of file application.h.

◆ get_frame_buffer_height()

index_t GEO::Application::get_frame_buffer_height ( ) const
inline

Gets the height of the window.

Returns
the height of the frame buffer in pixels.

Definition at line 288 of file application.h.

◆ get_frame_buffer_width()

index_t GEO::Application::get_frame_buffer_width ( ) const
inline

Gets the width of the window.

Returns
the width of the frame buffer in pixels.

Definition at line 280 of file application.h.

◆ get_full_screen()

bool GEO::Application::get_full_screen ( ) const

Tests whether this application is in full-screen mode.

Return values
trueif full-screen mode is used.
falseif windowed mode is used.

◆ get_gui_state()

std::string GEO::Application::get_gui_state ( ) const

Gets the gui state.

Returns
a string that encodes the windows geometries and docking configuration

◆ get_height()

index_t GEO::Application::get_height ( ) const
inline

Gets the height of the window.

Returns
the height of the window in pixels.

Definition at line 272 of file application.h.

◆ get_style()

const std::string& GEO::Application::get_style ( ) const
inline

Gets the style.

Returns
a string with the current style;

Definition at line 115 of file application.h.

◆ get_styles()

static std::string GEO::Application::get_styles ( )
static

Gets the possible styles.

Returns
A semi-colon separated list of the possible styles.

◆ get_width()

index_t GEO::Application::get_width ( ) const
inline

Gets the width of the window.

Returns
the width of the window in pixels.

Definition at line 264 of file application.h.

◆ hidpi_scaling()

double GEO::Application::hidpi_scaling ( ) const
inline

MacOS non-sense.

Returns
a scaling factor between real pixels and logical pixels or something, well I do not understand. Sometimes you need to multiply by it, sometimes to divide, and sometimes you need to use pixel_ratio() instead.

Definition at line 401 of file application.h.

◆ impl_data()

ApplicationData* GEO::Application::impl_data ( )
inline

Gets a pointer to the implementation-specific data.

For internal use only.

Returns
a pointer to the implementation-specific data.

Definition at line 383 of file application.h.

◆ impl_window()

void* GEO::Application::impl_window ( )

Gets a pointer to the implementation-specific window.

For internal use only.

Returns
a pointer to the implementation-specific window.

◆ instance()

static Application* GEO::Application::instance ( )
inlinestatic

Gets the instance.

Returns
a pointer to the instance.

Definition at line 84 of file application.h.

◆ key_callback()

virtual void GEO::Application::key_callback ( int  key,
int  scancode,
int  action,
int  mods 
)
virtual

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 in GEO::SimpleApplication.

◆ key_to_string()

const char* GEO::Application::key_to_string ( int  key)

Converts a key to a symbolic string with the name of the key.

Parameters
[in]keythe key.
Returns
a string with the symbolic name of the key.

◆ list_video_modes()

void GEO::Application::list_video_modes ( )

Lists the video modes that can be used for set_full_screen_mode()

The video modes are listed in the terminal.

◆ lock_updates()

void GEO::Application::lock_updates ( )
inline

Lock updates.

If this function is called, updates are ignored. It is useful when a RenderingContext operation is occuring, to prevent the Console for triggering a drawing operation.

Definition at line 164 of file application.h.

◆ main_loop()

virtual void GEO::Application::main_loop ( )
virtual

Enters the main application loop.

create_window() needs to be called before. This initializes OpenGL and ImGui before the first frame is displayed.

◆ mouse_button_callback()

virtual void GEO::Application::mouse_button_callback ( int  button,
int  action,
int  mods = 0,
int  source = EVENT_SOURCE_MOUSE 
)
virtual

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 in GEO::SimpleApplication.

◆ name()

const std::string& GEO::Application::name ( ) const
inline

Gets the name of this application.

Returns
the name.

Definition at line 93 of file application.h.

◆ needs_to_redraw()

virtual bool GEO::Application::needs_to_redraw ( ) const
virtual

Tests whether the window needs to be redrawn.

Return values
trueif the window needs to be redrawn.
falseif the window is up to date.

◆ one_frame()

virtual void GEO::Application::one_frame ( )
virtual

Draws one frame.

This triggers a GUI and/or a scene update as needed.

◆ pixel_ratio()

double GEO::Application::pixel_ratio ( ) const
inline

More MacOS non-sense.

Returns
something like hidpi_scaling(), that is a scaling factor between real pixels and logical pixels or something, well I do not understand. Sometimes you need to multiply by it, sometimes to divide, and sometimes you need to use hidpi_scaling() instead.

Definition at line 413 of file application.h.

◆ post_draw()

virtual void GEO::Application::post_draw ( )
virtual

This function is called after all drawing operations.

It can be used to execute queued commands.

Reimplemented in GEO::SimpleApplication.

◆ pre_draw()

virtual void GEO::Application::pre_draw ( )
virtual

This function is called before starting drawing operations.

Some implementations use it to initialize / restore graphic objects.

◆ resize()

virtual void GEO::Application::resize ( index_t  w,
index_t  h,
index_t  fb_w,
index_t  fb_h 
)
virtual

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 in GEO::SimpleApplication.

◆ restart_gui()

void GEO::Application::restart_gui ( )
inline

Restarts the gui.

A flag is set and the gui is restarted at the next frame.

Definition at line 374 of file application.h.

◆ scaling()

double GEO::Application::scaling ( ) const

Gets the global scaling to be applied to all GUI elements.

Returns
1.0 if the default font is used, more/less if a larger/ smaller font is used.

◆ scroll_callback()

virtual void GEO::Application::scroll_callback ( double  xoffset,
double  yoffset 
)
virtual

Callback called whenenver the mouse wheel is moved.

Parameters
[in]xoffset,yoffsetwheel displacement

Reimplemented in GEO::SimpleApplication.

◆ set_accept_drops()

void GEO::Application::set_accept_drops ( bool  value)
inline

Sets whether drag and drop events should be taken into account.

Parameters
[in]valuetrue if drag and drop events should be taken into account, false otherwise

Definition at line 298 of file application.h.

◆ set_font_size()

void GEO::Application::set_font_size ( index_t  value)

Sets the font size.

Parameters
[in]valuethe font size.

◆ set_full_screen()

void GEO::Application::set_full_screen ( bool  x)

Sets full-screen mode.

Parameters
[in]xtrue if full-screen mode should be used, false if windowed-mode should be used.

◆ set_full_screen_mode()

void GEO::Application::set_full_screen_mode ( index_t  w = 0,
index_t  h = 0,
index_t  hz = 0,
index_t  monitor = 0 
)

Sets full-screen mode.

All arguments to zero sets default mode.

Parameters
[in]w,hwidth and height in pixels
[in]hzrefresh rate in Hz
[in]monitorthe id of the monitor

◆ set_gui_state()

void GEO::Application::set_gui_state ( std::string  x)

Sets the gui state.

Parameters
[in]xa string that encodes the windows geometries and docking configuration obtained through get_gui_state()

◆ set_style()

virtual void GEO::Application::set_style ( const std::string &  value)
virtual

Sets the style of the application.

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

Reimplemented in GEO::SimpleApplication.

◆ set_window_icon()

void GEO::Application::set_window_icon ( Image image)

Sets the icon of the window.

Parameters
[in]imagea pointer to the image to be used as the icon.

◆ set_windowed_mode()

void GEO::Application::set_windowed_mode ( index_t  w = 0,
index_t  h = 0 
)

Sets windowed mode.

Parameters
[in]w,hwidth and height in pixels. If zero, use current dimensions.

◆ start()

virtual void GEO::Application::start ( int  argc = 0,
char **  argv = nullptr 
)
virtual

Starts the main event loop of the application.

Parameters
[in]argc,argvoptional command line parameters. If specified then they are used to initialize geogram, else geogram is supposed to be already initialized by caller.

Member Data Documentation

◆ ImGui_firsttime_init_

bool GEO::Application::ImGui_firsttime_init_
protected

true if ImGui was once initialized

Definition at line 594 of file application.h.

◆ phone_screen_

bool GEO::Application::phone_screen_
protected

true if running on a phone

Definition at line 596 of file application.h.


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