Easy3D 2.6.1
Loading...
Searching...
No Matches
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.
 
 ~MultiViewer () override
 Destructor.
 
void assign (int row, int col, const Model *m)
 Assigns the model m to the view at position (row, col).
 
void assign (int row, int col, const Drawable *d)
 Assigns the drawable d to the view at position (row, col).
 
void set_division_visible (bool b)
 Sets the visibility of the splitting lines of the views.
 
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.
 
int rows () const
 Return the number of rows (of the grid-like layout) of the viewer.
 
int columns () const
 Return the number of columns (of the grid-like layout) of the viewer.
 
void set_layout (int rows, int cols)
 Set/Change the layout of the viewer.
 
bool snapshot () const override
 Take a snapshot of the screen and save it to a file.
 
- 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.
 
virtual ~Viewer ()
 The destructor.
 
int run (bool see_all=true)
 Run the viewer.
 
virtual void exit ()
 Terminate the viewer.
 
void set_title (const std::string &title)
 Set the window title of the viewer.
 
const std::string & title () const
 Query the window title of the viewer.
 
void resize (int w, int h)
 Set/Change the viewer size.
 
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.
 
int samples () const
 Query the actual samples of the viewer.
 
float dpi_scaling () const
 Query the scaling factor for high DPI devices (e.g., MackBook pro).
 
void set_background_color (const vec4 &color)
 Set the background color of the viewer.
 
const vec4background_color () const
 Query the background color of the viewer.
 
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.
 
virtual bool save () const
 Save the active model (if exists) to a file.
 
Drawableadd_drawable (std::shared_ptr< Drawable > drawable)
 Add a drawable to the viewer to be visualized. On success, the viewer will be in charge of the memory management of the drawable.
 
Drawableadd_drawable (Drawable *drawable)
 Add a drawable to the viewer to be visualized. On success, the viewer will be in charge of the memory management of the drawable.
 
bool delete_drawable (Drawable *drawable)
 
const std::vector< std::shared_ptr< Drawable > > & drawables () const
 Query the drawables managed by this viewer.
 
void clear_scene ()
 Delete all visual contents of the viewer (all models and drawables).
 
void update () const
 Update the display (i.e., repaint).
 
void fit_screen (const Model *model=nullptr)
 Moves the camera so that the entire scene or the active model is centered on the screen at a proper scale.
 
bool snapshot (const std::string &file_name, float scaling=1.0f, int samples=4, 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.
 
void set_usage (const std::string &manual="default", const std::string &screen_hint="")
 The usage information of the viewer.
 
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'.
 
void set_animation (bool b)
 Enable/Disable animation.
 
bool is_animating () const
 Is animation currently being performed.
 
Modeladd_model (Model *model, bool create_default_drawables=true)
 Add an existing model to the viewer to be visualized. On success, the viewer will be in charge of the memory management of the model.
 
virtual bool delete_model (Model *model)
 Delete a model. The memory of the model will be released and its existing drawables also be deleted.
 
const std::vector< std::shared_ptr< Model > > & models () const
 Query the models managed by this viewer.
 
Modelcurrent_model () const
 Query the active model.
 

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)>
 
std::function< bool(Viewer *viewer)> animation_func_
 Function called at an equal interval for animation.
 
virtual Modeladd_model (const std::string &file_name, bool create_default_drawables=true)
 Add a model from a file to the viewer to be visualized. On success, the viewer will be in charge of the memory management of the model. The loaded model can be accessed by the 'current_model()' method.
 
Modeladd_model (std::shared_ptr< Model > model, bool create_default_drawables=true)
 Add an existing model to the viewer to be visualized. On success, the viewer will be in charge of the memory management of the model.
 

Detailed Description

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

Examples
Tutorial_205_MultiView/main.cpp.

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).
colsThe number of columns (of the grid-like layout).
titleThe title of the viewer window.

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
You need to first add the drawable to the viewer by calling add_drawable(). The add_drawable() function does not assign the drawable to any view for rendering. However, add_drawable() allows the viewer to take ownership of the drawable.
Parameters
rowThe row index of the view.
colThe column index of the view.
dThe drawable to assign.

◆ 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
You need to first add the model to the viewer by calling add_model(). The add_model() function does not assign the model to any view for rendering. However, add_model() allows the viewer to take ownership of the model.
Parameters
rowThe row index of the view.
colThe column index of the view.
mThe model to assign.

◆ columns()

int columns ( ) const
inline

Return the number of columns (of the grid-like layout) of the viewer.

Returns
The number of columns.

◆ division_visible()

bool division_visible ( ) const

Returns if the splitting lines of the views are visible.

Returns
true if the splitting lines are visible, false otherwise.

◆ 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 is 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.

◆ rows()

int rows ( ) const
inline

Return the number of rows (of the grid-like layout) of the viewer.

Returns
The number of rows.

◆ set_division_visible()

void set_division_visible ( bool b)

Sets the visibility of the splitting lines of the views.

Parameters
bWhether the splitting lines are visible.

◆ set_layout()

void set_layout ( int rows,
int cols )

Set/Change the layout of the viewer.

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

◆ snapshot()

bool snapshot ( ) const
overridevirtual

Take a snapshot of the screen and save it to a file.

This method takes a snapshot of the screen and saves the snapshot into an image file. Internally, it will pop up a file dialog for specifying the file name.

Returns
true on success and false otherwise.

Reimplemented from Viewer.


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