-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgui_window.h
131 lines (104 loc) · 3.72 KB
/
gui_window.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* @author Hauke Strasdat, Steven Lovegrove
*
* Copyright (C) 2010 Hauke Strasdat, Steven Lovegrove
* Imperial College London
*
* gui_window.h is part of RobotVision.
*
* RobotVision is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* RobotVision is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RV_GUI_WINDOW_H
#define RV_GUI_WINDOW_H
#include <vector>
#include <list>
#include <set>
#include <cvd/glwindow.h>
#include "rectangle.h"
#include "quadtree.h"
namespace RobotVision
{
// Forward declarations
class GuiWindow;
class Viewport
{
friend class GuiWindow;
public:
Viewport() {}
Viewport(const CVD::ImageRef& size )
: pixel_size(TooN::makeVector(size.x,size.y)) { }
Viewport(const TooN::Vector<2>& size )
: pixel_size(size) { }
virtual CVD::GLWindow::EventHandler* get_handler() = 0;
inline Rectangle& BoundingBox() { return bounding_box; }
inline TooN::Vector<2>& PixelSize() { return pixel_size; }
inline float Left() { return bounding_box.x1; }
inline float Top() { return bounding_box.y1; }
inline float Width() { return bounding_box.Width(); }
inline float Height() { return bounding_box.Height(); }
protected:
GuiWindow* win;
TooN::Vector<2> pixel_size;
Rectangle bounding_box;
};
class GuiWindow : public CVD::GLWindow, public CVD::GLWindow::EventHandler
{
friend class Viewport;
friend class ViewEventHandler;
public:
const static int EVENT_VIEW_ACTIVATED = 2134;
const static int EVENT_VIEW_DEACTIVATED = 2135;
GuiWindow(const CVD::ImageRef & ir,
const CVD::GLWindow* sharedContext = NULL);
~GuiWindow();
void nextFrame(CVD::GLWindow::EventHandler& handler);
void handle_events_default();
bool closed();
void on_key_down(CVD::GLWindow& /*win*/, int /*key*/);
void on_key_up(CVD::GLWindow& /*win*/, int /*key*/);
void on_mouse_move(CVD::GLWindow& /*win*/,
CVD::ImageRef /*where*/,
int /*state*/);
void on_mouse_down(CVD::GLWindow& /*win*/,
CVD::ImageRef /*where*/,
int /*state*/,
int /*button*/);
void on_mouse_up(CVD::GLWindow& /*win*/,
CVD::ImageRef /*where*/,
int /*state*/, int /*button*/);
void on_resize(CVD::GLWindow& /*win*/,
CVD::ImageRef /*size*/);
void on_event(CVD::GLWindow& /*win*/,
int /*event*/);
void set_active_view(Viewport* view);
Viewport* get_active_view();
// Connect view to this window within region box
void connectView(Viewport & view, const Rectangle & box);
std::set<int> active_point_set;
void * quad;
protected:
// Return view that contains window point wp
Viewport* get_view( const CVD::ImageRef& wp, CVD::ImageRef* vp );
// Return coordinates relative to view
CVD::ImageRef view_coords( const Viewport* view,
const CVD::ImageRef wp ) const;
// int num_id;
std::list<Viewport*> viewpt_list;
CVD::ImageRef active_pos;
Viewport * active_view;
int mode;
};
}
#endif // RV_GUI_WINDOW_H