Easy3D 2.6.1
Loading...
Searching...
No Matches
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 <memory>
31#include <easy3d/viewer/viewer.h>
32
33
34namespace easy3d {
35
36 class Model;
37 class LinesDrawable2D;
38
43 class MultiViewer : public Viewer {
44 public:
51 MultiViewer(int rows, int cols, const std::string &title = "untitled");
55 ~MultiViewer() override;
56
68 void assign(int row, int col, const Model *m);
69
81 void assign(int row, int col, const Drawable *d);
82
87 void set_division_visible(bool b);
88
93 bool division_visible() const;
94
108 vec3 point_under_pixel(int x, int y, bool &found) const override;
109
114 int rows() const { return num_rows_; }
115
120 int columns() const { return num_cols_; }
121
127 void set_layout(int rows, int cols);
128
135 bool snapshot() const override;
136
137 protected:
138 void init() override;
139 void post_resize(int w, int h) override;
140 void draw() const override;
141
142 // overloaded, so mouse positions are relative to the current view
143 bool mouse_release_event(int x, int y, int button, int modifiers) override;
144 // overloaded, so mouse positions are relative to the current view
145 bool mouse_drag_event(int x, int y, int dx, int dy, int button, int modifiers) override;
146
147 void update_division();
148
149 protected:
150 int num_rows_;
151 int num_cols_;
152 // A sub-view of the multi-view viewer.
153 struct View {
154 std::vector<const Model *> models; // the models to show in this view
155 std::vector<const Drawable *> drawables; // the drawables to show in this view
156 ivec4 viewport;
157 };
158 std::vector<std::vector<View> > views_;
159
160 int view_width_; // the width of the views
161 int view_height_; // the height of the views
162
163 std::unique_ptr<LinesDrawable2D> drawable_division_;
164 };
165
166}
167
168#endif // EASY3D_VIEWER_MULTI_VIEWER_H
The base class for drawable objects. A drawable represent a set of points, line segments,...
Definition drawable.h:58
The drawable for rendering a set of line segments in the screen space.
Definition drawable_lines_2D.h:43
The base class of renderable 3D models.
Definition model.h:50
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:291
int columns() const
Return the number of columns (of the grid-like layout) of the viewer.
Definition multi_viewer.h:120
bool snapshot() const override
Take a snapshot of the screen and save it to a file.
Definition multi_viewer.cpp:73
bool division_visible() const
Returns if the splitting lines of the views are visible.
Definition multi_viewer.cpp:162
void assign(int row, int col, const Model *m)
Assigns the model m to the view at position (row, col).
Definition multi_viewer.cpp:124
~MultiViewer() override
Destructor.
Definition multi_viewer.cpp:53
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.
Definition multi_viewer.cpp:156
int rows() const
Return the number of rows (of the grid-like layout) of the viewer.
Definition multi_viewer.h:114
void set_layout(int rows, int cols)
Set/Change the layout of the viewer.
Definition multi_viewer.cpp:60
const std::string & title() const
Query the window title of the viewer.
Definition viewer.h:123
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.
Definition viewer.cpp:75
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
Vec< 4, int32_t > ivec4
A 4D point/vector of int32_t type.
Definition types.h:60