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
a50b0425
Commit
a50b0425
authored
Nov 24, 2010
by
James Goppert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hooked up map/vehicle buttons for osgearth.
parent
6ad0a690
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
QMap3D.cc
src/ui/map3D/QMap3D.cc
+19
-5
QMap3D.h
src/ui/map3D/QMap3D.h
+3
-0
QOSGWidget.h
src/ui/map3D/QOSGWidget.h
+1
-2
No files found.
src/ui/map3D/QMap3D.cc
View file @
a50b0425
...
...
@@ -31,20 +31,34 @@ This file is part of the QGROUNDCONTROL project
#include "QMap3D.h"
#include <osgEarthUtil/EarthManipulator>
#include <
stdexcept
>
#include <
QFileDialog
>
QMap3D
::
QMap3D
(
QWidget
*
parent
,
const
char
*
name
,
WindowFlags
f
)
:
QWidget
(
parent
,
f
)
{
setupUi
(
this
);
osg
::
ref_ptr
<
osg
::
Node
>
map
=
osgDB
::
readNodeFile
(
"data/yahoo_heightfield.earth"
);
if
(
!
map
)
throw
std
::
runtime_error
(
"unable to load file"
);
graphicsView
->
updateCamera
();
graphicsView
->
setCameraManipulator
(
new
osgEarthUtil
::
EarthManipulator
);
graphicsView
->
setSceneData
(
map
);
graphicsView
->
setSceneData
(
new
osg
::
Group
);
graphicsView
->
updateCamera
();
show
();
}
QMap3D
::~
QMap3D
()
{
}
void
QMap3D
::
on_pushButton_map_clicked
()
{
QString
mapName
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Select an OsgEarth map file"
),
QDesktopServices
::
storageLocation
(
QDesktopServices
::
DesktopLocation
),
tr
(
"OsgEarth file (*.earth);;"
));
graphicsView
->
getSceneData
()
->
asGroup
()
->
addChild
(
osgDB
::
readNodeFile
(
mapName
.
toStdString
()));
graphicsView
->
updateCamera
();
}
void
QMap3D
::
on_pushButton_vehicle_clicked
()
{
QString
vehicleName
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Select a 3D model for your vehicle"
),
QDesktopServices
::
storageLocation
(
QDesktopServices
::
DesktopLocation
),
tr
(
"OsgEarth file (*.osg, *.ac, *.3ds);;"
));
graphicsView
->
getSceneData
()
->
asGroup
()
->
addChild
(
osgDB
::
readNodeFile
(
vehicleName
.
toStdString
()));
graphicsView
->
updateCamera
();
}
src/ui/map3D/QMap3D.h
View file @
a50b0425
...
...
@@ -45,6 +45,9 @@ class QMap3D : public QWidget, private Ui::QMap3D
public:
QMap3D
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
,
WindowFlags
f
=
0
);
~
QMap3D
();
public
slots
:
void
on_pushButton_map_clicked
();
void
on_pushButton_vehicle_clicked
();
};
#endif // QMAP3D_H
...
...
src/ui/map3D/QOSGWidget.h
View file @
a50b0425
...
...
@@ -133,8 +133,7 @@ class ViewerQOSG : public osgViewer::Viewer, public QOSGWidget
void
updateCamera
()
{
getCamera
()
->
setViewport
(
new
osg
::
Viewport
(
0
,
0
,
width
(),
height
()));
// we want an aspect ratio of 1.0, not: static_cast<double>(width())/static_cast<double>(height())
getCamera
()
->
setProjectionMatrixAsPerspective
(
30
.
0
f
,
1
.
0
f
,
1
.
0
f
,
10000
.
0
f
);
getCamera
()
->
setProjectionMatrixAsPerspective
(
30
.
0
f
,
1
.
0
f
,
static_cast
<
double
>
(
width
())
/
static_cast
<
double
>
(
height
()),
10000
.
0
f
);
getCamera
()
->
setGraphicsContext
(
getGraphicsWindow
());
}
...
...
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