dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
joystickcontrol.h
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 
27 #ifndef JOYSTICKCONTROL_H
28 #define JOYSTICKCONTROL_H
29 
30 #include <QWidget>
31 #include <QGraphicsView>
32 #include <QtSvg/QSvgRenderer>
33 #include <QtSvg/QGraphicsSvgItem>
34 #include "manualcontrolcommand.h"
35 
36 namespace Ui {
37 class JoystickControl;
38 }
39 
40 class JoystickControl : public QGraphicsView
41 {
42  Q_OBJECT
43 
44 public:
45  explicit JoystickControl(QWidget *parent = nullptr);
47  void paint();
48 
49 protected:
50  void mouseMoveEvent(QMouseEvent *event);
51  void mousePressEvent(QMouseEvent *event);
52  void paintEvent(QPaintEvent *event);
53  void resizeEvent(QResizeEvent *event);
54 
55 public slots:
56  void changePosition(double x, double y);
57 
58 signals:
59  void positionClicked(double x, double y);
60 
61 private:
62  QSvgRenderer *m_renderer;
63  QGraphicsSvgItem *m_background;
64  QGraphicsSvgItem *m_joystickArea;
65  QGraphicsSvgItem *m_joystickEnd;
66 };
67 
68 #endif // JOYSTICKCONTROL_H
69 
void mouseMoveEvent(QMouseEvent *event)
Redirect mouse move events to control position.
void positionClicked(double x, double y)
JoystickControl(QWidget *parent=nullptr)
Constructor for JoystickControl widget. Sets up the image of a joystick.
void paintEvent(QPaintEvent *event)
void mousePressEvent(QMouseEvent *event)
Redirect mouse move clicks to control position.
void resizeEvent(QResizeEvent *event)
x
Definition: OPPlots.m:100
void changePosition(double x, double y)
Update the displayed position based on an MCC update.
y
Definition: OPPlots.m:101