forked from RoboCup-SSL/grSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glwidget.h
121 lines (110 loc) · 3.49 KB
/
glwidget.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
/*
grSim - RoboCup Small Size Soccer Robots Simulator
Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QGLWidget>
#include <QGraphicsView>
#include <QTime>
#include <QMenu>
#include "sslworld.h"
#include "configwidget.h"
class GLWidgetGraphicsView;
class GLWidget : public QGLWidget {
Q_OBJECT
public:
GLWidget(QWidget *parent,ConfigWidget* _cfg);
~GLWidget();
dReal getFPS();
ConfigWidget* cfg;
SSLWorld* ssl;
RobotsFomation* forms[6];
QMenu* robpopup,*ballpopup,*mainpopup;
QMenu *blueRobotsMenu,*yellowRobotsMenu;
QAction* moveRobotAct;
QAction* selectRobotAct;
QAction* resetRobotAct;
QAction* moveBallAct;
QAction* lockToBallAct;
QAction* onOffRobotAct;
QAction* lockToRobotAct;
QAction* moveBallHereAct;
QAction* moveRobotHereAct;
QAction* changeCamModeAct;
QMenu *cameraMenu;
int Current_robot,Current_team,cammode;
int lockedIndex;
bool ctrl,alt,kickingball;
double kickpower;
bool fullScreen;
void update3DCursor(int mouse_x,int mouse_y);
void putBall(dReal x,dReal y);
void reform(int team,const QString& act);
void step();
public slots:
void moveRobot();
void resetRobot();
void selectRobot();
void moveCurrentRobot();
void resetCurrentRobot();
void moveBall();
void changeCameraMode();
void yellowRobotsMenuTriggered(QAction* act);
void blueRobotsMenuTriggered(QAction* act);
void switchRobotOnOff();
void moveRobotHere();
void moveBallHere();
void lockCameraToRobot();
void lockCameraToBall();
signals:
void clicked();
void selectedRobot();
void closeSignal(bool);
void toggleFullScreen(bool);
void robotTurnedOnOff(int,bool);
protected:
void paintGL ();
void initializeGL ();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent* event);
void closeEvent(QCloseEvent *event);
private:
int state;
int moving_robot_id,clicked_robot;
int frames;
bool first_time;
QTime time,rendertimer;
dReal m_fps;
QPoint lastPos;
friend class GLWidgetGraphicsView;
};
class GLWidgetGraphicsView : public QGraphicsView
{
private:
GLWidget *glwidget;
public:
GLWidgetGraphicsView(QGraphicsScene *scene,GLWidget* _glwidget);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event);
};
#endif // WIDGET_H