Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
7490ed51
Commit
7490ed51
authored
Sep 16, 2011
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More state checking on user interaction, catching corner cases
parent
8fb8b1fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
10 deletions
+40
-10
HSIDisplay.cc
src/ui/HSIDisplay.cc
+37
-10
HSIDisplay.h
src/ui/HSIDisplay.h
+3
-0
No files found.
src/ui/HSIDisplay.cc
View file @
7490ed51
...
@@ -85,7 +85,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
...
@@ -85,7 +85,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
bodyYawSet
(
0.0
f
),
bodyYawSet
(
0.0
f
),
uiXSetCoordinate
(
0.0
f
),
uiXSetCoordinate
(
0.0
f
),
uiYSetCoordinate
(
0.0
f
),
uiYSetCoordinate
(
0.0
f
),
uiZSetCoordinate
(
0.0
f
),
uiZSetCoordinate
(
-
0.65
f
),
uiYawSet
(
0.0
f
),
uiYawSet
(
0.0
f
),
metricWidth
(
4.0
),
metricWidth
(
4.0
),
positionLock
(
false
),
positionLock
(
false
),
...
@@ -101,7 +101,9 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
...
@@ -101,7 +101,9 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
bottomMargin
(
10.0
f
),
bottomMargin
(
10.0
f
),
topMargin
(
12.0
f
),
topMargin
(
12.0
f
),
userSetPointSet
(
false
),
userSetPointSet
(
false
),
dragStarted
(
false
)
dragStarted
(
false
),
leftDragStarted
(
false
),
mouseHasMoved
(
false
)
{
{
refreshTimer
->
setInterval
(
updateInterval
);
refreshTimer
->
setInterval
(
updateInterval
);
...
@@ -550,12 +552,30 @@ void HSIDisplay::mouseDoubleClickEvent(QMouseEvent * event)
...
@@ -550,12 +552,30 @@ void HSIDisplay::mouseDoubleClickEvent(QMouseEvent * event)
void
HSIDisplay
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
void
HSIDisplay
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
{
if
(
event
->
type
()
==
QMouseEvent
::
MouseButtonRelease
&&
event
->
button
()
==
Qt
::
RightButton
)
if
(
mouseHasMoved
)
{
{
qDebug
()
<<
"YAW CHANGED"
<<
uiYawSet
;
if
(
event
->
type
()
==
QMouseEvent
::
MouseButtonRelease
&&
event
->
button
()
==
Qt
::
RightButton
)
setBodySetpointCoordinateYaw
(
uiYawSet
);
{
dragStarted
=
false
;
if
(
dragStarted
)
{
qDebug
()
<<
"YAW CHANGED"
<<
uiYawSet
;
setBodySetpointCoordinateYaw
(
uiYawSet
);
setStatusMessage
(
QString
(
"SENT NEW YAW: %1"
).
arg
(
uiYawSet
));
dragStarted
=
false
;
}
}
if
(
event
->
type
()
==
QMouseEvent
::
MouseButtonRelease
&&
event
->
button
()
==
Qt
::
LeftButton
)
{
if
(
leftDragStarted
)
{
qDebug
()
<<
"Z CHANGED"
<<
uiZSetCoordinate
;
setStatusMessage
(
QString
(
"SENT NEW Z: %1"
).
arg
(
uiZSetCoordinate
));
setBodySetpointCoordinateZ
(
uiZSetCoordinate
);
leftDragStarted
=
false
;
}
}
}
}
mouseHasMoved
=
false
;
}
}
void
HSIDisplay
::
mousePressEvent
(
QMouseEvent
*
event
)
void
HSIDisplay
::
mousePressEvent
(
QMouseEvent
*
event
)
...
@@ -571,9 +591,11 @@ void HSIDisplay::mousePressEvent(QMouseEvent * event)
...
@@ -571,9 +591,11 @@ void HSIDisplay::mousePressEvent(QMouseEvent * event)
}
}
else
if
(
event
->
button
()
==
Qt
::
LeftButton
)
else
if
(
event
->
button
()
==
Qt
::
LeftButton
)
{
{
startY
=
event
->
y
();
leftDragStarted
=
true
;
}
}
}
}
mouseHasMoved
=
false
;
}
}
void
HSIDisplay
::
mouseMoveEvent
(
QMouseEvent
*
event
)
void
HSIDisplay
::
mouseMoveEvent
(
QMouseEvent
*
event
)
...
@@ -581,6 +603,14 @@ void HSIDisplay::mouseMoveEvent(QMouseEvent * event)
...
@@ -581,6 +603,14 @@ void HSIDisplay::mouseMoveEvent(QMouseEvent * event)
if
(
event
->
type
()
==
QMouseEvent
::
MouseMove
)
if
(
event
->
type
()
==
QMouseEvent
::
MouseMove
)
{
{
if
(
dragStarted
)
uiYawSet
-=
0.06
f
*
(
startX
-
event
->
x
())
/
this
->
frameSize
().
width
();
if
(
dragStarted
)
uiYawSet
-=
0.06
f
*
(
startX
-
event
->
x
())
/
this
->
frameSize
().
width
();
if
(
leftDragStarted
)
{
uiZSetCoordinate
-=
0.06
f
*
(
startY
-
event
->
y
())
/
this
->
frameSize
().
height
();
setStatusMessage
(
QString
(
"NEW Z: %1"
).
arg
(
uiZSetCoordinate
));
}
if
(
leftDragStarted
||
dragStarted
)
mouseHasMoved
=
true
;
}
}
}
}
...
@@ -673,7 +703,6 @@ void HSIDisplay::setBodySetpointCoordinateXY(double x, double y)
...
@@ -673,7 +703,6 @@ void HSIDisplay::setBodySetpointCoordinateXY(double x, double y)
if
(
uas
&&
mavInitialized
)
if
(
uas
&&
mavInitialized
)
{
{
uiZSetCoordinate
=
-
0.65
;
sendBodySetPointCoordinates
();
sendBodySetPointCoordinates
();
qDebug
()
<<
"Setting new setpoint at x: "
<<
x
<<
"metric y:"
<<
y
;
qDebug
()
<<
"Setting new setpoint at x: "
<<
x
<<
"metric y:"
<<
y
;
}
}
...
@@ -693,14 +722,12 @@ void HSIDisplay::setBodySetpointCoordinateYaw(double yaw)
...
@@ -693,14 +722,12 @@ void HSIDisplay::setBodySetpointCoordinateYaw(double yaw)
{
{
uiXSetCoordinate
=
bodyXSetCoordinate
;
uiXSetCoordinate
=
bodyXSetCoordinate
;
uiYSetCoordinate
=
bodyYSetCoordinate
;
uiYSetCoordinate
=
bodyYSetCoordinate
;
uiZSetCoordinate
=
-
0.65
f
;
}
}
else
if
(
!
userXYSetPointSet
&&
mavInitialized
)
else
if
(
!
userXYSetPointSet
&&
mavInitialized
)
{
{
QPointF
coord
=
metricBodyToWorld
(
QPointF
(
0.0
,
0.0
));
QPointF
coord
=
metricBodyToWorld
(
QPointF
(
0.0
,
0.0
));
uiXSetCoordinate
=
coord
.
x
();
uiXSetCoordinate
=
coord
.
x
();
uiYSetCoordinate
=
coord
.
y
();
uiYSetCoordinate
=
coord
.
y
();
uiZSetCoordinate
=
-
0.65
f
;
}
}
userSetPointSet
=
true
;
userSetPointSet
=
true
;
// Set coordinates and send them out to MAV
// Set coordinates and send them out to MAV
...
...
src/ui/HSIDisplay.h
View file @
7490ed51
...
@@ -160,7 +160,10 @@ protected:
...
@@ -160,7 +160,10 @@ protected:
QMap
<
int
,
float
>
objectBearings
;
QMap
<
int
,
float
>
objectBearings
;
QMap
<
int
,
float
>
objectDistances
;
QMap
<
int
,
float
>
objectDistances
;
bool
dragStarted
;
bool
dragStarted
;
bool
leftDragStarted
;
bool
mouseHasMoved
;
float
startX
;
float
startX
;
float
startY
;
QTimer
statusClearTimer
;
QTimer
statusClearTimer
;
QString
statusMessage
;
QString
statusMessage
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment