The class to visualize analog joystick swing on a widget.
More...
#include <joystick.hh>
|
void | setX (const float &value) |
| Set the value of the x coordinate. More...
|
|
void | setY (const float &value) |
| Set the value of the y coordinate. More...
|
|
void | addXAnimation () |
| Add an animation for the joystick to return to the x-axis zero position. More...
|
|
void | addYAnimation () |
| Add an animation for the joystick to return to the y-axis zero position. More...
|
|
void | removeXAnimation () |
| Remove an animation for the joystick to return to the x-axis zero position. More...
|
|
void | removeYAnimation () |
| Remove an animation for the joystick to return to the y-axis zero position. More...
|
|
void | setAlignment (Qt::Alignment align) |
| Set the widget alignment. More...
|
|
void | movePos (const QPoint &coordinates) |
| Change the knop coordinates. More...
|
|
|
void | xChange (float value) |
| Signal emitted when the x coordinate value changed. More...
|
|
void | yChange (float value) |
| Signal emitted when the y coordinate value changed. More...
|
|
|
float | checkValue (const float &value, const float &min, const float &max) const |
| Check if the coordinate value is in proper range. More...
|
|
void | resizeEvent (QResizeEvent *event) override |
| Event handler to change size of widget. More...
|
|
virtual void | paintEvent (QPaintEvent *event) override |
| Draw an analog joystick with its' background. More...
|
|
Definition at line 25 of file joystick.hh.
◆ Joystick()
Joystick::Joystick |
( |
QWidget * |
parent = nullptr | ) |
|
|
explicit |
- Parameters
-
[in,out] | parent | Pointer to the parent QWidget object. |
Definition at line 24 of file joystick.cpp.
◆ ~Joystick()
◆ addXAnimation
void Joystick::addXAnimation |
( |
| ) |
|
|
slot |
◆ addYAnimation
void Joystick::addYAnimation |
( |
| ) |
|
|
slot |
◆ checkValue()
float Joystick::checkValue |
( |
const float & |
value, |
|
|
const float & |
min, |
|
|
const float & |
max |
|
) |
| const |
|
private |
- Parameters
-
[in] | value | Value to be check. |
[in] | min | Minimal value. |
[in] | max | Maximal value. |
- Return values
-
min | value is below range. |
max | value is above range. |
value | value is in proper range. |
Definition at line 126 of file joystick.cpp.
◆ movePos
void Joystick::movePos |
( |
const QPoint & |
coordinates | ) |
|
|
slot |
Calculate coordinates which will be used to draw the knob from raw coordinates passed as parameter. Emit signal when coordinates change.
- Parameters
-
[in] | coordinates | Point with the coordinates read from the serial port. |
Definition at line 94 of file joystick.cpp.
◆ paintEvent()
void Joystick::paintEvent |
( |
QPaintEvent * |
event | ) |
|
|
overrideprivatevirtual |
- Parameters
-
[in] | event | Paint event [not used]. |
Definition at line 173 of file joystick.cpp.
◆ removeXAnimation
void Joystick::removeXAnimation |
( |
| ) |
|
|
slot |
◆ removeYAnimation
void Joystick::removeYAnimation |
( |
| ) |
|
|
slot |
◆ resizeEvent()
void Joystick::resizeEvent |
( |
QResizeEvent * |
event | ) |
|
|
overrideprivate |
Change the widget geometry to properly display visualization.
- Parameters
-
[in] | event | Resize event [not used]. |
Definition at line 131 of file joystick.cpp.
◆ setAlignment
void Joystick::setAlignment |
( |
Qt::Alignment |
align | ) |
|
|
slot |
Alignment is used in the resizeEvent to properly calculate the widget dimensions.
- Parameters
-
Definition at line 89 of file joystick.cpp.
◆ setX
void Joystick::setX |
( |
const float & |
value | ) |
|
|
slot |
- Parameters
-
[in] | value | Value of the x coordinate in range from -1.f to 1.f. |
Definition at line 41 of file joystick.cpp.
◆ setY
void Joystick::setY |
( |
const float & |
value | ) |
|
|
slot |
- Parameters
-
[in] | value | Value of the y coordinate in range from -1.f to 1.f. |
Definition at line 52 of file joystick.cpp.
◆ x()
float Joystick::x |
( |
| ) |
const |
|
inline |
- Returns
- Value of the x coordinate.
Definition at line 42 of file joystick.hh.
◆ xChange
void Joystick::xChange |
( |
float |
value | ) |
|
|
signal |
- Parameters
-
[in] | value | Value of the x coordinate. |
◆ y()
float Joystick::y |
( |
| ) |
const |
|
inline |
- Returns
- Value of the y coordinate.
Definition at line 48 of file joystick.hh.
◆ yChange
void Joystick::yChange |
( |
float |
value | ) |
|
|
signal |
- Parameters
-
[in] | value | Value of the y coordinate. |
◆ _alignment
Qt::Alignment Joystick::_alignment |
|
private |
◆ _animation
QParallelAnimationGroup* Joystick::_animation |
|
private |
◆ _bounds
◆ _knopBounds
QRectF Joystick::_knopBounds |
|
private |
◆ _midPoint
const float Joystick::_midPoint = 2048.0 |
|
private |
◆ _x
◆ _xAnimation
QPropertyAnimation* Joystick::_xAnimation |
|
private |
◆ _y
◆ _yAnimation
QPropertyAnimation* Joystick::_yAnimation |
|
private |
The documentation for this class was generated from the following files: