Geogram  Version 1.9.1
A programming library of geometric algorithms
GEO::SimpleMeshApplication Class Reference

An Application that manipulates a single Mesh. More...

#include <geogram_gfx/gui/simple_mesh_application.h>

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

Public Member Functions

 SimpleMeshApplication (const std::string &name)
 Application constructor.
 
void install_key_file_navigation ()
 Installs key navigation callbacks. More...
 
- Public Member Functions inherited from GEO::SimpleApplication
 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...
 
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 ()
 

Protected Member Functions

void geogram_initialize (int argc, char **argv) override
 
std::string supported_read_file_extensions () override
 Gets the list of supported file extensions for reading. More...
 
std::string supported_write_file_extensions () override
 Gets the list of supported file extensions for writing. More...
 
void draw_object_properties () override
 Draws the contents of the object properties window. More...
 
void draw_scene () override
 Draws the scene. More...
 
void GL_initialize () override
 Initializes OpenGL and GLUP objects. More...
 
void GL_terminate () override
 Deallocates OpenGL and GLUP objects. More...
 
bool load (const std::string &filename) override
 Loads a file. More...
 
bool save (const std::string &filename) override
 Saves the current content to a file. More...
 
virtual void draw_points ()
 Called at the beginning of draw_scene(). More...
 
virtual void draw_edges ()
 
virtual void draw_surface ()
 
virtual void draw_volume ()
 
void get_bbox (const Mesh &M_in, double *xyzmin, double *xyzmax, bool animate)
 Gets the bounding box of a mesh animation. More...
 
void jump_to_file (int relative_index)
 
Meshmesh ()
 Gets the mesh. More...
 
MeshGfxmesh_gfx ()
 Gets the mesh graphics. More...
 
void show_vertices ()
 Makes the vertices visible.
 
void hide_vertices ()
 Makes the vertices invisible.
 
void show_surface ()
 Makes the surface facets visible.
 
void hide_surface ()
 Makes the surface facets invisible.
 
void show_volume ()
 Makes the volume cells visible.
 
void hide_volume ()
 Makes the volume cells invisible.
 
virtual void show_attributes ()
 Makes the attributes visible.
 
virtual void hide_attributes ()
 Makes the attributes invisible.
 
void autorange ()
 Adjusts the current minimum and maximum attribute value to the currently bound attribute if any.
 
std::string attribute_names ()
 Gets the list of attribute names. More...
 
void set_attribute (const std::string &attribute)
 Sets the currently displayed attribute. More...
 
- Protected Member Functions inherited from GEO::SimpleApplication
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_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_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...
 
ImTextureID convert_to_ImTextureID (GLuint gl_texture_id_in)
 Converts an OpenGL texture ID into an ImGUI texture ID. More...
 
void browse (const std::string &path, bool subdirs=false)
 Recursively browses a directory and generates menu items. More...
 
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 SimpleMeshApplicationinstance ()
 Gets the instance. More...
 
static void increment_anim_time_callback ()
 increments the animation time in the current instance. More...
 
static void decrement_anim_time_callback ()
 derements the animation time in the current instance. More...
 
static void increment_cells_shrink_callback ()
 increments the cells shrinkage. More...
 
static void decrement_cells_shrink_callback ()
 decrements the cells shrinkage. More...
 
static void next_file ()
 Loads the next file. More...
 
static void prev_file ()
 Loads the previous file. More...
 
static void first_file ()
 Loads the first file in the current directory.
 
static void last_file ()
 Loads the last file in the current directory.
 
- Static Protected Member Functions inherited from GEO::SimpleApplication
static void replay_latest_command ()
 

Protected Attributes

Mesh mesh_
 
MeshGfx mesh_gfx_
 
float anim_speed_
 
float anim_time_
 
bool show_vertices_
 
bool show_vertices_selection_
 
float vertices_size_
 
vec4f vertices_color_
 
float vertices_transparency_
 
bool show_surface_
 
bool show_surface_sides_
 
bool show_mesh_
 
float mesh_width_
 
vec4f mesh_color_
 
bool show_surface_borders_
 
vec4f surface_color_
 
vec4f surface_color_2_
 
bool show_volume_
 
float cells_shrink_
 
vec4f volume_color_
 
bool show_colored_cells_
 
bool show_hexes_
 
bool show_connectors_
 
bool show_attributes_
 
index_t current_colormap_index_
 
std::string attribute_
 
MeshElementsFlags attribute_subelements_
 
std::string attribute_name_
 
float attribute_min_
 
float attribute_max_
 
- Protected Attributes inherited from GEO::SimpleApplication
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_
 

Additional Inherited Members

- Static Public Member Functions inherited from GEO::SimpleApplication
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 inherited from GEO::SimpleApplication
enum  MouseOp { MOUSE_NOOP , MOUSE_ROTATE , MOUSE_TRANSLATE , MOUSE_ZOOM }
 
enum  MouseTarget { MOUSE_NOTARGET , MOUSE_OBJECT , MOUSE_LIGHT , MOUSE_CLIP }
 

Detailed Description

An Application that manipulates a single Mesh.

Definition at line 52 of file simple_mesh_application.h.

Member Function Documentation

◆ attribute_names()

std::string GEO::SimpleMeshApplication::attribute_names ( )
protected

Gets the list of attribute names.

Returns
the ';'-separated list of attribute names.

◆ decrement_anim_time_callback()

static void GEO::SimpleMeshApplication::decrement_anim_time_callback ( )
staticprotected

derements the animation time in the current instance.

Callback bound to the 'r' key

◆ decrement_cells_shrink_callback()

static void GEO::SimpleMeshApplication::decrement_cells_shrink_callback ( )
staticprotected

decrements the cells shrinkage.

Callback bound to the 'x' key

◆ draw_object_properties()

void GEO::SimpleMeshApplication::draw_object_properties ( )
overrideprotectedvirtual

Draws the contents of the object properties window.

Reimplemented from GEO::SimpleApplication.

◆ draw_points()

virtual void GEO::SimpleMeshApplication::draw_points ( )
protectedvirtual

Called at the beginning of draw_scene().

Configures mesh_graphics_ in function of drawing attributes.

◆ draw_scene()

void GEO::SimpleMeshApplication::draw_scene ( )
overrideprotectedvirtual

Draws the scene.

Reimplemented from GEO::SimpleApplication.

◆ geogram_initialize()

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

Reimplemented from GEO::SimpleApplication.

◆ get_bbox()

void GEO::SimpleMeshApplication::get_bbox ( const Mesh M_in,
double *  xyzmin,
double *  xyzmax,
bool  animate 
)
protected

Gets the bounding box of a mesh animation.

In animated mode, the mesh animation is stored as a mesh with 6d coordinates, that correspond to the geometric location at the vertices at time 0 and at time 1.

Parameters
[in]M_inthe mesh
[out]xyzmina pointer to the three minimum coordinates
[out]xyzmaxa pointer to the three maximum coordinates
[in]animatetrue if displaying a mesh animation

◆ GL_initialize()

void GEO::SimpleMeshApplication::GL_initialize ( )
overrideprotectedvirtual

Initializes OpenGL and GLUP objects.

Reimplemented from GEO::SimpleApplication.

◆ GL_terminate()

void GEO::SimpleMeshApplication::GL_terminate ( )
overrideprotectedvirtual

Deallocates OpenGL and GLUP objects.

Reimplemented from GEO::SimpleApplication.

◆ increment_anim_time_callback()

static void GEO::SimpleMeshApplication::increment_anim_time_callback ( )
staticprotected

increments the animation time in the current instance.

Callback bound to the 't' key

◆ increment_cells_shrink_callback()

static void GEO::SimpleMeshApplication::increment_cells_shrink_callback ( )
staticprotected

increments the cells shrinkage.

Callback bound to the 'w' key

◆ install_key_file_navigation()

void GEO::SimpleMeshApplication::install_key_file_navigation ( )

Installs key navigation callbacks.

up,down,home,end keys navigate files in current directory.

◆ instance()

static SimpleMeshApplication* GEO::SimpleMeshApplication::instance ( )
inlinestaticprotected

Gets the instance.

Returns
a pointer to the current SimpleMeshApplication.

Definition at line 117 of file simple_mesh_application.h.

◆ load()

bool GEO::SimpleMeshApplication::load ( const std::string &  filename)
overrideprotectedvirtual

Loads a file.

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

Return values
trueif the file could be sucessfully loaded
falseotherwise

Reimplemented from GEO::SimpleApplication.

◆ mesh()

Mesh* GEO::SimpleMeshApplication::mesh ( )
inlineprotected

Gets the mesh.

Returns
a pointer to the Mesh.

Definition at line 209 of file simple_mesh_application.h.

◆ mesh_gfx()

MeshGfx* GEO::SimpleMeshApplication::mesh_gfx ( )
inlineprotected

Gets the mesh graphics.

Returns
a pointer to the MeshGfx.

Definition at line 217 of file simple_mesh_application.h.

◆ next_file()

static void GEO::SimpleMeshApplication::next_file ( )
staticprotected

Loads the next file.

Call back bound to the 'arrow down' key

◆ prev_file()

static void GEO::SimpleMeshApplication::prev_file ( )
staticprotected

Loads the previous file.

Call back bound to the 'arrow up' key

◆ save()

bool GEO::SimpleMeshApplication::save ( const std::string &  filename)
overrideprotectedvirtual

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

◆ set_attribute()

void GEO::SimpleMeshApplication::set_attribute ( const std::string &  attribute)
protected

Sets the currently displayed attribute.

Parameters
[in]attributethe name of the attribute to be displayed, prefixed by element type.

◆ supported_read_file_extensions()

std::string GEO::SimpleMeshApplication::supported_read_file_extensions ( )
overrideprotectedvirtual

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

◆ supported_write_file_extensions()

std::string GEO::SimpleMeshApplication::supported_write_file_extensions ( )
overrideprotectedvirtual

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


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