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
6302dedf
Commit
6302dedf
authored
Nov 25, 2010
by
Lionel Heng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restored imagery feature. Not yet running.
parent
8464b4ce
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
224 additions
and
88 deletions
+224
-88
MainWindow.h
src/ui/MainWindow.h
+0
-4
Imagery.cc
src/ui/map3D/Imagery.cc
+46
-46
Imagery.h
src/ui/map3D/Imagery.h
+114
-0
Texture.cc
src/ui/map3D/Texture.cc
+53
-23
Texture.h
src/ui/map3D/Texture.h
+10
-7
TextureCache.cc
src/ui/map3D/TextureCache.cc
+1
-8
No files found.
src/ui/MainWindow.h
View file @
6302dedf
...
...
@@ -63,10 +63,6 @@ This file is part of the QGROUNDCONTROL project
#include "HSIDisplay.h"
#include "QGCDataPlot2D.h"
#include "QGCRemoteControlView.h"
#ifdef QGC_OSG_ENABLED
//#include "Q3DWidget.h"
#include "QMap3D.h"
#endif
#include "LogCompressor.h"
...
...
src/ui/map3D/Imagery.cc
View file @
6302dedf
This diff is collapsed.
Click to expand it.
src/ui/map3D/Imagery.h
0 → 100644
View file @
6302dedf
/*=====================================================================
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 Imagery.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#ifndef IMAGERY_H
#define IMAGERY_H
#include <QScopedPointer>
#include <QString>
#include "TextureCache.h"
class
Imagery
{
public:
enum
ImageryType
{
GOOGLE_MAP
=
0
,
GOOGLE_SATELLITE
=
1
,
SWISSTOPO_SATELLITE
=
2
,
SWISSTOPO_SATELLITE_3D
=
3
};
Imagery
();
void
setImageryType
(
ImageryType
type
);
void
setOffset
(
double
xOffset
,
double
yOffset
);
void
prefetch2D
(
double
windowWidth
,
double
windowHeight
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
);
void
draw2D
(
double
windowWidth
,
double
windowHeight
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
);
void
prefetch3D
(
double
radius
,
double
tileResolution
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
,
bool
useHeightModel
);
void
draw3D
(
double
radius
,
double
tileResolution
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
,
bool
useHeightModel
);
bool
update
(
void
);
private:
void
imageBounds
(
int
tileX
,
int
tileY
,
double
tileResolution
,
double
&
x1
,
double
&
y1
,
double
&
x2
,
double
&
y2
,
double
&
x3
,
double
&
y3
,
double
&
x4
,
double
&
y4
)
const
;
void
tileBounds
(
double
tileResolution
,
double
minUtmX
,
double
minUtmY
,
double
maxUtmX
,
double
maxUtmY
,
const
QString
&
utmZone
,
int
&
minTileX
,
int
&
minTileY
,
int
&
maxTileX
,
int
&
maxTileY
,
int
&
zoomLevel
)
const
;
double
tileXToLongitude
(
int
tileX
,
int
numTiles
)
const
;
double
tileYToLatitude
(
int
tileY
,
int
numTiles
)
const
;
int
longitudeToTileX
(
double
longitude
,
int
numTiles
)
const
;
int
latitudeToTileY
(
double
latitude
,
int
numTiles
)
const
;
void
UTMtoTile
(
double
northing
,
double
easting
,
const
QString
&
utmZone
,
double
tileResolution
,
int
&
tileX
,
int
&
tileY
,
int
&
zoomLevel
)
const
;
QChar
UTMLetterDesignator
(
double
latitude
)
const
;
void
LLtoUTM
(
double
latitude
,
double
longitude
,
double
&
utmNorthing
,
double
&
utmEasting
,
QString
&
utmZone
)
const
;
void
UTMtoLL
(
double
utmNorthing
,
double
utmEasting
,
const
QString
&
utmZone
,
double
&
latitude
,
double
&
longitude
)
const
;
QString
getTileLocation
(
int
tileX
,
int
tileY
,
int
zoomLevel
,
double
tileResolution
)
const
;
QScopedPointer
<
TextureCache
>
textureCache
;
ImageryType
currentImageryType
;
double
xOffset
;
double
yOffset
;
};
#endif // IMAGERY_H
src/ui/map3D/Texture.cc
View file @
6302dedf
...
...
@@ -29,12 +29,22 @@ This file is part of the QGROUNDCONTROL project
*
*/
#include <osg/LineWidth>
#include "Texture.h"
Texture
::
Texture
()
:
_is3D
(
false
)
{
texture2D
->
setFilter
(
osg
::
Texture
::
MIN_FILTER
,
osg
::
Texture
::
NEAREST
);
texture2D
->
setFilter
(
osg
::
Texture
::
MAG_FILTER
,
osg
::
Texture
::
NEAREST
);
GLuint
id
;
glGenTextures
(
1
,
&
id
);
t
->
setID
(
id
);
glBindTexture
(
GL_TEXTURE_2D
,
id
);
glPixelStorei
(
GL_UNPACK_ALIGNMENT
,
1
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
}
const
QString
&
...
...
@@ -44,9 +54,9 @@ Texture::getSourceURL(void) const
}
void
Texture
::
setI
D
(
GLuint
id
)
Texture
::
setI
d
(
unsigned
int
_
id
)
{
this
->
id
=
id
;
id
=
_
id
;
}
void
...
...
@@ -87,6 +97,10 @@ Texture::sync(const WebImagePtr& image)
maxV
=
static_cast
<
double
>
(
imageHeight
)
/
static_cast
<
double
>
(
textureHeight
);
osg
::
ref_ptr
<
osg
::
Image
>
image
;
image
->
setImage
(
textureWidth
,
textureHeight
,
8
,
3
,
GL_RGBA
,
GL_UNSIGNED_BYTES
,
NULL
,
osg
::
Image
::
USE_NEW_DELETE
);
texture2D
->
glBindTexture
(
GL_TEXTURE_2D
,
id
);
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
3
,
textureWidth
,
textureHeight
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
NULL
);
...
...
@@ -100,46 +114,56 @@ Texture::sync(const WebImagePtr& image)
}
}
void
osg
::
ref_ptr
<
osg
::
Geometry
>
Texture
::
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
bool
smoothInterpolation
)
const
{
draw
(
x1
,
y1
,
x2
,
y1
,
x2
,
y2
,
x1
,
y2
,
smoothInterpolation
);
return
draw
(
x1
,
y1
,
x2
,
y1
,
x2
,
y2
,
x1
,
y2
,
smoothInterpolation
);
}
void
osg
::
ref_ptr
<
osg
::
Geometry
>
Texture
::
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
float
x3
,
float
y3
,
float
x4
,
float
y4
,
bool
smoothInterpolation
)
const
{
osg
::
ref_ptr
<
osg
::
Geometry
>
geometry
(
new
osg
::
Geometry
);
osg
::
ref_ptr
<
osg
::
StateSet
>
stateset
(
new
osg
::
StateSet
);
if
(
state
==
REQUESTED
)
{
glBegin
(
GL_LINE_LOOP
);
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
);
glVertex2f
(
x1
,
y1
);
glVertex2f
(
x2
,
y2
);
glVertex2f
(
x3
,
y3
);
glVertex2f
(
x4
,
y4
);
glEnd
();
return
;
osg
::
ref_ptr
<
osg
::
Vec2Array
>
vertices
(
new
osg
::
Vec2Array
);
vertices
->
push_back
(
osg
::
Vec2
(
x1
,
y1
));
vertices
->
push_back
(
osg
::
Vec2
(
x2
,
y2
));
vertices
->
push_back
(
osg
::
Vec2
(
x3
,
y3
));
vertices
->
push_back
(
osg
::
Vec2
(
x4
,
y4
));
geometry
->
addPrimitiveSet
(
new
osg
::
DrawArrays
(
osg
::
PrimitiveSet
::
LINES
,
0
,
vertices
->
size
()));
geometry
->
setVertexArray
(
vertices
);
osg
::
ref_ptr
<
osg
::
Vec4Array
>
color
(
new
osg
::
Vec4Array
);
color
->
push_back
(
osg
::
Vec4
(
0.0
f
,
0.0
f
,
1.0
f
,
1.0
f
));
geometry
->
setColorArray
(
color
);
geometry
->
setColorBinding
(
osg
::
Geometry
::
BIND_OVERALL
);
return
geometry
;
}
glEnable
(
GL_TEXTURE_2D
);
glBindTexture
(
GL_TEXTURE_2D
,
id
);
stateset
->
setTextureAttributeAndModes
(
id
,
texture2D
);
float
dx
,
dy
;
if
(
smoothInterpolation
)
{
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_
LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_
LINEAR
);
texture2D
->
setFilter
(
osg
::
Texture
::
MIN_FILTER
,
osg
::
Texture
::
LINEAR
);
texture2D
->
setFilter
(
osg
::
Texture
::
MAG_FILTER
,
osg
::
Texture
::
LINEAR
);
dx
=
1.0
f
/
(
2.0
f
*
textureWidth
);
dy
=
1.0
f
/
(
2.0
f
*
textureHeight
);
}
else
{
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_
NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_
NEAREST
);
texture2D
->
setFilter
(
osg
::
Texture
::
MIN_FILTER
,
osg
::
Texture
::
NEAREST
);
texture2D
->
setFilter
(
osg
::
Texture
::
MAG_FILTER
,
osg
::
Texture
::
NEAREST
);
dx
=
0.0
f
;
dy
=
0.0
f
;
}
...
...
@@ -147,6 +171,14 @@ Texture::draw(float x1, float y1, float x2, float y2,
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
);
if
(
!
_is3D
)
{
osg
::
ref_ptr
<
osg
::
Vec2Array
>
tc
=
new
osg
::
Vec2Array
;
geometry
->
setTexCoordArray
(
id
,
tc
);
tc
->
push_back
(
osg
::
Vec2
(
dx
,
maxV
-
dy
));
tc
->
push_back
(
osg
::
Vec2
(
maxU
-
dx
,
maxV
-
dy
));
tc
->
push_back
(
osg
::
Vec2
(
maxU
-
dx
,
dy
));
tc
->
push_back
(
osg
::
Vec2
(
dx
,
dy
));
glBegin
(
GL_QUADS
);
glTexCoord2f
(
dx
,
maxV
-
dy
);
glVertex3f
(
x1
,
y1
,
0.0
f
);
...
...
@@ -210,8 +242,6 @@ Texture::draw(float x1, float y1, float x2, float y2,
}
}
}
glDisable
(
GL_TEXTURE_2D
);
}
bool
...
...
src/ui/map3D/Texture.h
View file @
6302dedf
...
...
@@ -38,6 +38,8 @@ This file is part of the QGROUNDCONTROL project
#include <GL/gl.h>
#endif
#include <inttypes.h>
#include <osg/ref_ptr>
#include <osg/Geometry>
#include <QSharedPointer>
#include "WebImage.h"
...
...
@@ -49,15 +51,15 @@ public:
const
QString
&
getSourceURL
(
void
)
const
;
void
setI
D
(
GLuint
id
);
void
setI
d
(
unsigned
int
_
id
);
void
sync
(
const
WebImagePtr
&
image
);
void
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
bool
smoothInterpolation
)
const
;
void
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
float
x3
,
float
y3
,
float
x4
,
float
y4
,
bool
smoothInterpolation
)
const
;
osg
::
ref_ptr
<
osg
::
Geometry
>
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
bool
smoothInterpolation
)
const
;
osg
::
ref_ptr
<
osg
::
Geometry
>
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
float
x3
,
float
y3
,
float
x4
,
float
y4
,
bool
smoothInterpolation
)
const
;
bool
is3D
(
void
)
const
;
...
...
@@ -71,7 +73,8 @@ private:
State
state
;
QString
sourceURL
;
GLuint
id
;
unsigned
int
id
;
osg
::
ref_ptr
<
osg
::
Texture2D
>
texture2D
;
int32_t
textureWidth
;
int32_t
textureHeight
;
...
...
src/ui/map3D/TextureCache.cc
View file @
6302dedf
...
...
@@ -38,14 +38,7 @@ TextureCache::TextureCache(uint32_t _cacheSize)
for
(
uint32_t
i
=
0
;
i
<
cacheSize
;
++
i
)
{
TexturePtr
t
(
new
Texture
);
GLuint
id
;
glGenTextures
(
1
,
&
id
);
t
->
setID
(
id
);
glBindTexture
(
GL_TEXTURE_2D
,
id
);
glPixelStorei
(
GL_UNPACK_ALIGNMENT
,
1
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
t
->
setId
(
i
);
textures
.
push_back
(
t
);
}
...
...
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