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
7c3edae2
Commit
7c3edae2
authored
Nov 15, 2010
by
hengli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with transform from screen to world coordinates.
parent
1fb0417c
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
104 deletions
+164
-104
Pixhawk3DWidget.cc
src/ui/map3D/Pixhawk3DWidget.cc
+107
-61
Pixhawk3DWidget.h
src/ui/map3D/Pixhawk3DWidget.h
+8
-8
Q3DWidget.cc
src/ui/map3D/Q3DWidget.cc
+15
-28
Q3DWidget.h
src/ui/map3D/Q3DWidget.h
+3
-7
Q3DWidgetFactory.cc
src/ui/map3D/Q3DWidgetFactory.cc
+31
-0
No files found.
src/ui/map3D/Pixhawk3DWidget.cc
View file @
7c3edae2
This diff is collapsed.
Click to expand it.
src/ui/map3D/Pixhawk3DWidget.h
View file @
7c3edae2
...
...
@@ -33,6 +33,7 @@
#define PIXHAWK3DWIDGET_H
#include <osgText/Text>
#include <osgEarth/MapNode>
#include "Q3DWidget.h"
...
...
@@ -66,11 +67,11 @@ public:
public
slots
:
void
setActiveUAS
(
UASInterface
*
uas
);
void
markTarget
(
void
);
private
slots
:
void
showGrid
(
int
state
);
void
showTrail
(
int
state
);
void
showWaypoints
(
int
state
);
void
recenterCamera
(
void
);
void
toggleLockCamera
(
int
state
);
...
...
@@ -80,6 +81,7 @@ protected:
private:
osg
::
ref_ptr
<
osg
::
Geode
>
createGrid
(
void
);
osg
::
ref_ptr
<
osg
::
Geode
>
createTrail
(
void
);
osg
::
ref_ptr
<
osgEarth
::
MapNode
>
createMap
(
void
);
osg
::
ref_ptr
<
osg
::
Group
>
createTarget
(
void
);
osg
::
ref_ptr
<
osg
::
Group
>
createWaypoints
(
void
);
...
...
@@ -91,6 +93,8 @@ private:
void
updateTarget
(
float
robotX
,
float
robotY
,
float
robotZ
);
void
updateWaypoints
(
void
);
void
markTarget
(
void
);
double
lastRedrawTime
;
bool
displayGrid
;
...
...
@@ -98,13 +102,6 @@ private:
bool
displayTarget
;
bool
displayWaypoints
;
typedef
struct
{
float
x
;
float
y
;
float
z
;
}
Pose3D
;
bool
lockCamera
;
osg
::
ref_ptr
<
osg
::
Vec3Array
>
trailVertices
;
...
...
@@ -118,8 +115,11 @@ private:
osg
::
ref_ptr
<
osg
::
Geode
>
trailNode
;
osg
::
ref_ptr
<
osg
::
Geometry
>
trailGeometry
;
osg
::
ref_ptr
<
osg
::
DrawArrays
>
trailDrawArrays
;
osg
::
ref_ptr
<
osgEarth
::
MapNode
>
mapNode
;
osg
::
ref_ptr
<
osg
::
Group
>
targetNode
;
osg
::
ref_ptr
<
osg
::
Group
>
waypointsNode
;
QPushButton
*
targetButton
;
};
#endif // PIXHAWK3DWIDGET_H
src/ui/map3D/Q3DWidget.cc
View file @
7c3edae2
...
...
@@ -262,24 +262,29 @@ Q3DWidget::addTimerFunc(uint32_t msecs, void(*func)(void *),
QTimer
::
singleShot
(
msecs
,
this
,
SLOT
(
userTimer
()));
}
std
::
pair
<
float
,
float
>
Q3DWidget
::
getGlobalCursorPosition
(
int32_t
mouseX
,
int32_t
mouseY
)
std
::
pair
<
double
,
double
>
Q3DWidget
::
getGlobalCursorPosition
(
int32_t
mouseX
,
int32_t
mouseY
,
double
z
)
{
osgUtil
::
LineSegmentIntersector
::
Intersections
intersections
;
// normalize cursor position to value between -1 and 1
float
x
=
-
1.0
f
+
static_cast
<
float
>
(
2
*
mouseX
)
/
static_cast
<
float
>
(
width
());
float
y
=
-
1.0
f
+
static_cast
<
float
>
(
2
*
(
height
()
-
mouseY
))
/
static_cast
<
float
>
(
height
());
double
x
=
-
1.0
f
+
static_cast
<
double
>
(
2
*
mouseX
)
/
static_cast
<
double
>
(
width
());
double
y
=
-
1.0
f
+
static_cast
<
double
>
(
2
*
(
height
()
-
mouseY
))
/
static_cast
<
double
>
(
height
());
osg
::
Matrix
pm
=
getCamera
()
->
getProjectionMatrix
();
osg
::
Matrix
vm
=
getCamera
()
->
getViewMatrix
();
osg
::
Matrixd
m
=
getCamera
()
->
getViewMatrix
()
*
getCamera
()
->
getProjectionMatrix
();
osg
::
Matrixd
invM
=
osg
::
Matrixd
::
inverse
(
m
);
osg
::
Vec3d
nearPoint
=
osg
::
Vec3d
(
x
,
y
,
-
1.0
)
*
invM
;
osg
::
Vec3d
farPoint
=
osg
::
Vec3d
(
x
,
y
,
1.0
)
*
invM
;
osg
::
ref_ptr
<
osg
::
LineSegment
>
line
=
projectNormalizedXYIntoObjectCoordinates
(
pm
,
vm
,
x
,
y
);
new
osg
::
LineSegment
(
nearPoint
,
farPoint
);
osg
::
Plane
p
(
line
->
start
()
-
line
->
end
(),
0.0
);
osg
::
Plane
p
(
osg
::
Vec3d
(
0.0
,
0.0
,
1.0
),
osg
::
Vec3d
(
0.0
,
0.0
,
z
)
);
osg
::
Vec3d
projectedPoint
;
getPlaneLineIntersection
(
p
.
asVec4
(),
*
line
,
projectedPoint
);
...
...
@@ -618,24 +623,6 @@ Q3DWidget::convertKey(int key) const
}
}
osg
::
ref_ptr
<
osg
::
LineSegment
>
Q3DWidget
::
projectNormalizedXYIntoObjectCoordinates
(
const
osg
::
Matrix
&
projectionMatrix
,
const
osg
::
Matrix
&
viewMatrix
,
float
x
,
float
y
)
const
{
osg
::
Matrix
matrix
=
viewMatrix
*
projectionMatrix
;
osg
::
Matrix
inverseVP
;
inverseVP
.
invert
(
matrix
);
osg
::
Vec3
nearPoint
=
osg
::
Vec3
(
x
,
y
,
-
1.0
f
)
*
inverseVP
;
osg
::
Vec3
farPoint
=
osg
::
Vec3
(
x
,
y
,
1.0
f
)
*
inverseVP
;
return
osg
::
ref_ptr
<
osg
::
LineSegment
>
(
new
osg
::
LineSegment
(
nearPoint
,
farPoint
));
}
bool
Q3DWidget
::
getPlaneLineIntersection
(
const
osg
::
Vec4d
&
plane
,
const
osg
::
LineSegment
&
line
,
...
...
src/ui/map3D/Q3DWidget.h
View file @
7c3edae2
...
...
@@ -73,8 +73,9 @@ public:
void
addTimerFunc
(
uint
msecs
,
void
(
*
func
)(
void
*
),
void
*
clientData
);
std
::
pair
<
float
,
float
>
getGlobalCursorPosition
(
int32_t
mouseX
,
int32_t
mouseY
);
std
::
pair
<
double
,
double
>
getGlobalCursorPosition
(
int32_t
mouseX
,
int32_t
mouseY
,
double
z
);
protected
slots
:
void
redraw
(
void
);
...
...
@@ -104,11 +105,6 @@ protected:
float
r2d
(
float
angle
);
float
d2r
(
float
angle
);
osgGA
::
GUIEventAdapter
::
KeySymbol
convertKey
(
int
key
)
const
;
osg
::
ref_ptr
<
osg
::
LineSegment
>
projectNormalizedXYIntoObjectCoordinates
(
const
osg
::
Matrix
&
projectionMatrix
,
const
osg
::
Matrix
&
viewMatrix
,
float
x
,
float
y
)
const
;
bool
getPlaneLineIntersection
(
const
osg
::
Vec4d
&
plane
,
const
osg
::
LineSegment
&
line
,
osg
::
Vec3d
&
isect
);
...
...
src/ui/map3D/Q3DWidgetFactory.cc
View file @
7c3edae2
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of the class Q3DWidgetFactory.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#include "Q3DWidgetFactory.h"
#include "Pixhawk3DWidget.h"
...
...
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