A simple GLFW viewer with trackball user interface. More...
#include <pmp/visualization/trackball_viewer.h>
Inherits Window.
Inherited by MeshViewer.
Public Member Functions | |
TrackballViewer (const char *title, int width, int height, bool showgui=true) | |
constructor | |
~TrackballViewer () override | |
destructor | |
void | set_scene (const vec3 ¢er, float radius) |
define the center and radius of the scene/ used for trackball rotation | |
void | view_all () |
adjust camera such that the whole scene (defined by set_scene()) is visible | |
Public Member Functions inherited from Window | |
Window (const char *title, int width, int height, bool showgui=true) | |
constructor | |
virtual | ~Window () |
destructor | |
int | run () |
main window loop | |
Protected Member Functions | |
void | display () override |
this function is called when the scene has to be rendered. | |
void | keyboard (int key, int code, int action, int mods) override |
this function handles keyboard events | |
void | mouse (int button, int action, int mods) override |
this function handles mouse button events | |
void | motion (double xpos, double ypos) override |
this function handles mouse motion (passive/active position) | |
void | scroll (double xoffset, double yoffset) override |
this function handles mouse scroll events | |
void | clear_draw_modes () |
reset the list of draw modes | |
unsigned int | add_draw_mode (const std::string &drawMode) |
add a draw mode | |
void | set_draw_mode (const std::string &drawMode) |
activate a draw mode | |
virtual void | init () |
initialize all OpenGL states | |
virtual void | draw (const std::string &drawMode)=0 |
this function is responsible for rendering the scene | |
void | rotation (int x, int y) |
turn a mouse event into a rotation around the scene center. calls rotate(). | |
void | translation (int x, int y) |
turn a mouse event into a translation in the view plane. calls translate(). | |
void | zoom (int x, int y) |
turn a mouse event into a zoom, i.e., translation in z-direction. calls translate(). | |
bool | pick (vec3 &result) |
get 3D position under the mouse cursor | |
bool | pick (int x, int y, vec3 &result) |
get 3D position of 2D position (x,y) | |
void | fly_to (int x, int y) |
fly toward the position Distributed under the mouse cursor and set rotation center to it | |
void | translate (const vec3 &trans) |
translate the scene and update modelview matrix | |
void | rotate (const vec3 &axis, float angle) |
rotate the scene (around its center) and update modelview matrix | |
bool | map_to_sphere (const ivec2 &point, vec3 &result) |
virtual trackball: map 2D screen point to unit sphere. used by rotate(). | |
Protected Member Functions inherited from Window | |
virtual void | display ()=0 |
this function is called when the scene has to be rendered. | |
virtual void | keyboard (int, int, int, int) |
this function handles keyboard events | |
virtual void | character (unsigned int) |
this function handles unicode character events | |
virtual void | mouse (int, int, int) |
this function handles mouse button events | |
virtual void | motion (double, double) |
this function handles mouse motion (passive/active position) | |
virtual void | scroll (double, double) |
this function handles mouse scroll events | |
virtual void | resize (int, int) |
this function is called if the window is resized | |
virtual void | drop (int, const char **) |
this function is called if a file is dropped onto the window | |
virtual void | process_imgui () |
this function renders the ImGUI elements and handles their events | |
virtual void | do_processing () |
this function is called just before rendering | |
void | init_imgui () |
setup ImGUI user interface | |
void | scale_imgui (float scale) |
scale ImGUI elements and font | |
bool | show_imgui () const |
is ImGUI visible or hidden? | |
void | show_imgui (bool b) |
show or hide ImGUI | |
void | clear_help_items () |
clear help items | |
void | add_help_item (std::string key, std::string description, int position=-1) |
add key binding (or general action description) | |
void | show_help () |
show ImGUI help dialog | |
void | screenshot () |
take a screenshot, save it to title-n.png using the window title and an incremented number n . | |
int | width () const |
width of window | |
int | height () const |
height of window | |
float | high_dpi_scaling () const |
highDPI scaling | |
float | imgui_scaling () const |
imgui scaling | |
void | cursor_pos (double &x, double &y) const |
get position of mouse cursor | |
bool | left_mouse_pressed () const |
is left mouse button pressed down? | |
bool | right_mouse_pressed () const |
is right mouse button pressed down? | |
bool | middle_mouse_pressed () const |
is middle mouse button pressed down? | |
bool | ctrl_pressed () const |
is CTRL modifier key pressed down? | |
bool | alt_pressed () const |
is ALT modifier key pressed down? | |
bool | shift_pressed () const |
is SHIFT modifier key pressed down? | |
Protected Attributes | |
unsigned int | draw_mode_ |
draw modes | |
vec3 | center_ |
scene position and dimension | |
float | near_ |
projection parameters | |
mat4 | projection_matrix_ |
OpenGL matrices. | |
ivec2 | last_point_2d_ |
trackball helpers | |
A simple GLFW viewer with trackball user interface.