Easy3D 2.5.3
multi_viewer.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_VIEWER_MULTI_VIEWER_H
28#define EASY3D_VIEWER_MULTI_VIEWER_H
29
30#include <easy3d/viewer/viewer.h>
31
32
33namespace easy3d {
34
35 class Model;
36 class Drawable;
37 class ShaderProgram;
38 class VertexArrayObject;
39
44 class MultiViewer : public Viewer {
45 public:
51 MultiViewer(int rows, int cols, const std::string &title = "untitled");
52 ~MultiViewer() override;
53
62 void assign(int row, int col, const Model *m);
63
71 void assign(int row, int col, const Drawable *d);
72
74 void set_division_visible(bool b) { division_visible_ = b; }
75
77 bool division_visible() const { return division_visible_; }
78
92 vec3 point_under_pixel(int x, int y, bool &found) const override;
93
94 protected:
95 void init() override;
96 void post_resize(int w, int h) override;
97 void draw() const override;
98
99 // overloaded, so mouse positions are relative to the current view
100 bool mouse_press_event(int x, int y, int button, int modifiers) override;
101 // overloaded, so mouse positions are relative to the current view
102 bool mouse_release_event(int x, int y, int button, int modifiers) override;
103 // overloaded, so mouse positions are relative to the current view
104 bool mouse_drag_event(int x, int y, int dx, int dy, int button, int modifiers) override;
105
106 void draw_division() const;
107 void update_division();
108
109 private:
110 int num_rows_;
111 int num_cols_;
112 // A sub-view of the multi-view viewer.
113 struct View {
114 std::vector<const Model *> models; // the models to show in this view
115 std::vector<const Drawable *> drawables; // the drawables to show in this view
116 ivec4 viewport;
117 };
118 std::vector<std::vector<View> > views_;
119 VertexArrayObject *division_vao_;
120 ShaderProgram *lines_program_;
121 unsigned int division_vertex_buffer_;
122 bool division_visible_;
123
124 int view_width_; // the width of the views
125 int view_height_; // the height of the views
126 };
127
128}
129
130#endif // EASY3D_VIEWER_MULTI_VIEWER_H
The base class for drawable objects. A drawable represent a set of points, line segments,...
Definition: drawable.h:56
The base class of renderable 3D models.
Definition: model.h:49
A viewer that supports multiple views (arranged in a grid layout).
Definition: multi_viewer.h:44
vec3 point_under_pixel(int x, int y, bool &found) const override
Query the XYZ coordinates of the surface point under the cursor.
Definition: multi_viewer.cpp:255
bool division_visible() const
Returns if the splitting lines of the views are visible.
Definition: multi_viewer.h:77
void assign(int row, int col, const Model *m)
Assigns the model m to the view at position (row, col).
Definition: multi_viewer.cpp:74
MultiViewer(int rows, int cols, const std::string &title="untitled")
Constructor.
Definition: multi_viewer.cpp:45
void set_division_visible(bool b)
Sets the visibility of the splitting lines of the views (visible by default).
Definition: multi_viewer.h:74
The built-in Easy3D viewer.
Definition: viewer.h:61
const std::string & title() const
Query the window title of the viewer.
Definition: viewer.h:119
const std::vector< Model * > & models() const
Query the models managed by this viewer.
Definition: viewer.h:263
const std::vector< Drawable * > & drawables() const
Query the drawables managed by this viewer.
Definition: viewer.h:302
Definition: collider.cpp:182