Easy3D 2.5.3
MultiViewer Class Reference

A viewer that supports multiple views (arranged in a grid layout). More...

#include <easy3d/viewer/multi_viewer.h>

Inheritance diagram for MultiViewer:
Viewer

Public Member Functions

 MultiViewer (int rows, int cols, const std::string &title="untitled")
 Constructor. More...
 
void assign (int row, int col, const Model *m)
 Assigns the model m to the view at position (row, col). More...
 
void assign (int row, int col, const Drawable *d)
 Assigns the drawable d to the view at position (row, col). More...
 
void set_division_visible (bool b)
 Sets the visibility of the splitting lines of the views (visible by default).
 
bool division_visible () const
 Returns if the splitting lines of the views are visible.
 
vec3 point_under_pixel (int x, int y, bool &found) const override
 Query the XYZ coordinates of the surface point under the cursor. More...
 
- Public Member Functions inherited from Viewer
 Viewer (const std::string &title="Easy3D Viewer", int samples=4, int gl_major=3, int gl_minor=2, bool full_screen=false, bool resizable=true, int depth_bits=24, int stencil_bits=8, int width=800, int height=600)
 Constructor. More...
 
virtual ~Viewer ()
 The destructor.
 
int run (bool see_all=true)
 Run the viewer. More...
 
virtual void exit ()
 Terminate the viewer.
 
void set_title (const std::string &title)
 Set the window title of the viewer. More...
 
const std::string & title () const
 Query the window title of the viewer. More...
 
void resize (int w, int h)
 Set/Change the viewer size. More...
 
int width () const
 Returns the width of the viewer/window.
 
int height () const
 Returns the height of the viewer/window.
 
void viewer_size (int &w, int &h) const
 Queries the size of the viewer/window.
 
int framebuffer_width () const
 Returns the width of the framebuffer, which is identical to: width() * dpi_scaling().
 
int framebuffer_height () const
 Returns the height of the framebuffer, which is identical to: height() * dpi_scaling().
 
void framebuffer_size (int &w, int &h) const
 Queries the size of the framebuffer.
 
void set_position (int xpos, int ypos)
 Sets the position of the content area of the viewer. More...
 
int samples () const
 Query the actual samples of the viewer. More...
 
float dpi_scaling () const
 Query the scaling factor for high DPI devices (e.g., MackBook pro). More...
 
void set_background_color (const easy3d::vec4 &c)
 Set the background color of the viewer. More...
 
const easy3d::vec4background_color () const
 Query the background color of the viewer. More...
 
Cameracamera ()
 Returns the camera used by the viewer. See Camera.
 
const Cameracamera () const
 Returns the camera used by the viewer. See Camera.
 
virtual bool open ()
 Open a model (PointCloud/SurfaceMesh/Graph) from a file into the viewer. On success, the viewer will be in charge of the memory management of the model. More...
 
virtual bool save () const
 Save the active model (if exists) to a file. More...
 
bool add_drawable (Drawable *drawable)
 Add a drawable to the viewer to be visualized. After a drawable being added to the viewer, the viewer will be in charge of its memory management. More...
 
bool delete_drawable (Drawable *drawable)
 
const std::vector< Drawable * > & drawables () const
 Query the drawables managed by this viewer. More...
 
void clear_scene ()
 Delete all visual contents of the viewer (all models and drawables).
 
void update () const
 Update the display (i.e., repaint). More...
 
void fit_screen (const easy3d::Model *model=nullptr)
 Moves the camera so that the entire scene or the active model is centered on the screen at a proper scale. More...
 
bool snapshot () const
 Take a snapshot of the screen and save it to a file. More...
 
bool snapshot (const std::string &file_name, float scaling=1.0f, int samples=0, int back_ground=1, bool expand=true) const
 Take a snapshot of the screen and save it to an image file. Supported image format: png, jpg, bmp, and tga. More...
 
const std::string & usage () const
 The usage information of the viewer. For the time being, it is the manual of this default viewer.
 
void set_usage (const std::string &usg)
 
void bind (const Function &func, Model *model, Key key, Modifier modifier=MODIF_NONE)
 Bind a function that will be triggered by the shortcut 'modifier + key'. More...
 
void set_animation (bool b)
 Enable/Disable animation. More...
 
bool is_animating () const
 Is animation currently being performed.
 
bool delete_model (Model *model)
 Delete a model. The memory of the model will be released and its existing drawables also be deleted. More...
 
const std::vector< Model * > & models () const
 Query the models managed by this viewer. More...
 
Modelcurrent_model () const
 Query the active model. More...
 

Additional Inherited Members

- Public Types inherited from Viewer
enum  Key {
  KEY_UNKNOWN = -1 , KEY_0 = 48 , KEY_1 = 49 , KEY_2 = 50 ,
  KEY_3 = 51 , KEY_4 = 52 , KEY_5 = 53 , KEY_6 = 54 ,
  KEY_7 = 55 , KEY_8 = 56 , KEY_9 = 57 , KEY_A = 65 ,
  KEY_B = 66 , KEY_C = 67 , KEY_D = 68 , KEY_E = 69 ,
  KEY_F = 70 , KEY_G = 71 , KEY_H = 72 , KEY_I = 73 ,
  KEY_J = 74 , KEY_K = 75 , KEY_L = 76 , KEY_M = 77 ,
  KEY_N = 78 , KEY_O = 79 , KEY_P = 80 , KEY_Q = 81 ,
  KEY_R = 82 , KEY_S = 83 , KEY_T = 84 , KEY_U = 85 ,
  KEY_V = 86 , KEY_W = 87 , KEY_X = 88 , KEY_Y = 89 ,
  KEY_Z = 90 , KEY_RIGHT = 262 , KEY_LEFT = 263 , KEY_DOWN = 264 ,
  KEY_UP = 265 , KEY_F1 = 290 , KEY_F2 = 291 , KEY_F3 = 292 ,
  KEY_F4 = 293 , KEY_F5 = 294 , KEY_F6 = 295 , KEY_F7 = 296 ,
  KEY_F8 = 297 , KEY_F9 = 298 , KEY_SPACE = 32 , KEY_COMMA = 44 ,
  KEY_MINUS = 45 , KEY_PERIOD = 46 , KEY_SLASH = 47 , KEY_SEMICOLON = 59 ,
  KEY_EQUAL = 61 , KEY_LEFT_BRACKET = 91 , KEY_BACKSLASH = 92 , KEY_RIGHT_BRACKET = 93
}
 The keys. Currently only a limited number of commonly used keys are supported.
 
enum  Modifier { MODIF_NONE = 0x0000 , MODIF_SHIFT = 0x0001 , MODIF_CTRL = 0x0002 , MODIF_ALT = 0x0004 }
 The key modifiers. Currently only Shift, Ctrl, and Alt are supported.
 
enum  Button { BUTTON_LEFT = 0 , BUTTON_RIGHT = 1 , BUTTON_MIDDLE = 2 }
 Mouse buttons.
 
using Function = std::function< bool(Viewer *viewer, Model *model)>
 
- Public Attributes inherited from Viewer
std::function< bool(Viewer *viewer)> animation_func_
 Function called at an equal interval for animation.
 

Detailed Description

A viewer that supports multiple views (arranged in a grid layout).

Examples
Tutorial_205_MultiView.

Constructor & Destructor Documentation

◆ MultiViewer()

MultiViewer ( int  rows,
int  cols,
const std::string &  title = "untitled" 
)

Constructor.

Parameters
rowsThe number of rows (of the grid-like layout).
colThe number of columns (of the grid-like layout).

Member Function Documentation

◆ assign() [1/2]

void assign ( int  row,
int  col,
const Drawable d 
)

Assigns the drawable d to the view at position (row, col).

This function assigns the drawable d to the view at position (row, col). After that, the drawable will be visualized in this view (regardless of other views visualizing the same drawable).

Note
By default, a drawable added to the viewer through add_drawable() is not assigned to any view for visualization. However, add_drawable() allows the viewer to take ownership of the drawable, so its memory management is handled by the viewer.

◆ assign() [2/2]

void assign ( int  row,
int  col,
const Model m 
)

Assigns the model m to the view at position (row, col).

This function assigns the model m to the view at position (row, col). After that, the model will be visualized in this view (regardless of other views visualizing the same model).

Note
By default, a model added to the viewer through add_model() is not assigned to any view for visualization. However, add_model() allows the viewer to take ownership of the model, so memory management and drawable creation for the model are handled by the viewer.
Examples
Tutorial_205_MultiView.

◆ point_under_pixel()

vec3 point_under_pixel ( int  x,
int  y,
bool &  found 
) const
overridevirtual

Query the XYZ coordinates of the surface point under the cursor.

Parameters
xThe cursor x-coordinate, relative to the left edge of the content area.
yThe cursor y-coordinate, relative to the top edge of the content area.
foundindicates whether the point was found or not.
Returns
The coordinates of the 3D point located at pixel (x, y) on screen. The returned point is valid only if found was returned true.
Attention
The screen point (x, y) is expressed in the screen coordinate system with an origin in the upper left corner. So it doesn't necessarily correspond to a pixel on High DPI devices, e.g., a Mac with a Retina display. If your inherited viewer uses a customized content area, you must also reimplement this function such that the x and y are relative to left and top edges of the content area, respectively.

Reimplemented from Viewer.


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