-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathviewport.hpp
More file actions
78 lines (57 loc) · 1.86 KB
/
viewport.hpp
File metadata and controls
78 lines (57 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef PSTACK_GUI_VIEWPORT_HPP
#define PSTACK_GUI_VIEWPORT_HPP
// OpenGL utilities must be included first
#include "pstack/graphics/buffer.hpp"
#include "pstack/graphics/shader.hpp"
#include "pstack/calc/mesh.hpp"
#include "pstack/gui/transformation.hpp"
#include <wx/event.h>
#include <wx/glcanvas.h>
#include <memory>
namespace pstack::gui {
class main_window;
class viewport : public wxGLCanvas {
public:
viewport(main_window* parent, const wxGLAttributes& canvasAttrs);
private:
bool initialize();
int _scroll_direction = 1;
public:
void set_mesh(const calc::mesh& mesh, const geo::point3<float>& centroid);
void remove_mesh();
private:
void set_mesh_vao(const calc::mesh& mesh);
void set_bounding_box_vao(geo::point3<float> min, geo::point3<float> max);
public:
void render();
void scroll_direction(bool invert_scroll) {
_scroll_direction = invert_scroll ? -1 : 1;
}
void show_bounding_box(bool show) {
_show_bounding_box = show;
render();
}
private:
void render(wxDC& dc);
void on_paint(wxPaintEvent&);
void on_size(wxSizeEvent& event);
void on_left_down(wxMouseEvent& evt);
void on_motion(wxMouseEvent& evt);
void on_left_up(wxMouseEvent& evt);
void on_capture_lost(wxMouseCaptureLostEvent& evt);
void on_scroll(wxMouseEvent& evt);
wxPoint _cached_position;
void on_move_by(wxPoint position);
void on_finish_move();
std::unique_ptr<wxGLContext> _opengl_context = nullptr;
bool _opengl_initialized = false;
graphics::shader _mesh_shader{};
graphics::vertex_array_object _mesh_vao{};
graphics::shader _bounding_box_shader{};
graphics::vertex_array_object _bounding_box_vao{};
bool _show_bounding_box = false;
transformation _transform{};
wxSize _viewport_size{};
};
} // namespace pstack::gui
#endif // PSTACK_GUI_VIEWPORT_HPP