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
eff1df53
Commit
eff1df53
authored
Oct 12, 2010
by
Lionel Heng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor changes to 3D imagery code
parent
6ab24659
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
112 deletions
+81
-112
Imagery.cc
src/ui/map3D/Imagery.cc
+16
-50
Imagery.h
src/ui/map3D/Imagery.h
+11
-6
Texture.cc
src/ui/map3D/Texture.cc
+50
-46
Texture.h
src/ui/map3D/Texture.h
+4
-10
No files found.
src/ui/map3D/Imagery.cc
View file @
eff1df53
...
...
@@ -2,6 +2,8 @@
#include <cmath>
#include <sstream>
#include <QNetworkReply>
#include <QPixmap>
//for street-maps to:
//http://mt1.google.com/mt?&x=%d&y=%d&z=%d
...
...
@@ -13,9 +15,12 @@
const
double
WGS84_A
=
6378137.0
;
const
double
WGS84_ECCSQ
=
0.00669437999013
;
Imagery
::
Imagery
()
Imagery
::
Imagery
(
QObject
*
parent
)
:
QObject
(
parent
)
,
networkManager
(
new
QNetworkAccessManager
)
{
// connect(networkManager.data(), SIGNAL(finished(QNetworkReply*)),
// this, SLOT(downloadFinished(QNetworkReply*)));
}
void
...
...
@@ -62,6 +67,8 @@ Imagery::prefetch2D(double windowWidth, double windowHeight,
imageResolution
=
512.0
;
}
}
// networkManager->get(QNetworkRequest(QUrl("")));
}
void
...
...
@@ -98,61 +105,20 @@ Imagery::update(void)
}
void
Imagery
::
drawTexture3D
(
const
TexturePtr
&
t
,
float
x1
,
float
y1
,
float
x2
,
float
y2
,
bool
smooth
)
Imagery
::
downloadFinished
(
QNetworkReply
*
reply
)
{
if
(
t
.
isNull
()
==
0
)
{
if
(
reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
return
;
}
if
(
t
->
getState
()
==
Texture
::
REQUESTED
)
QVariant
attribute
=
reply
->
attribute
(
QNetworkRequest
::
RedirectionTargetAttribute
);
if
(
attribute
.
isValid
()
)
{
glBegin
(
GL_LINE_LOOP
);
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
);
glVertex2f
(
x1
,
y1
);
glVertex2f
(
x2
,
y1
);
glVertex2f
(
x2
,
y2
);
glVertex2f
(
x1
,
y2
);
glEnd
();
return
;
}
glEnable
(
GL_TEXTURE_2D
);
glBindTexture
(
GL_TEXTURE_2D
,
t
->
getTextureId
());
float
dx
,
dy
;
if
(
smooth
)
{
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
dx
=
1.0
f
/
(
2.0
f
*
t
->
getTextureWidth
());
dy
=
1.0
f
/
(
2.0
f
*
t
->
getTextureHeight
());
}
else
{
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
dx
=
0.0
f
;
dy
=
0.0
f
;
}
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
);
glBegin
(
GL_QUADS
);
glTexCoord2f
(
dx
,
t
->
getMaxV
()
-
dy
);
glVertex2f
(
x1
,
y1
);
glTexCoord2f
(
t
->
getMaxU
()
-
dx
,
t
->
getMaxV
()
-
dy
);
glVertex2f
(
x2
,
y1
);
glTexCoord2f
(
t
->
getMaxU
()
-
dx
,
dy
);
glVertex2f
(
x2
,
y2
);
glTexCoord2f
(
dx
,
dy
);
glVertex2f
(
x1
,
y2
);
glEnd
();
glDisable
(
GL_TEXTURE_2D
);
QByteArray
jpegData
=
reply
->
readAll
();
QPixmap
pixmap
;
pixmap
.
loadFromData
(
jpegData
);
}
void
...
...
src/ui/map3D/Imagery.h
View file @
eff1df53
...
...
@@ -3,13 +3,17 @@
#include <inttypes.h>
#include <string>
#include <QNetworkAccessManager>
#include <QObject>
#include "Texture.h"
class
Imagery
class
Imagery
:
public
QObject
{
// Q_OBJECT
public:
Imagery
(
);
explicit
Imagery
(
QObject
*
parent
);
enum
ImageryType
{
...
...
@@ -41,11 +45,10 @@ public:
bool
update
(
void
);
private:
void
drawTexture3D
(
const
TexturePtr
&
t
,
float
x1
,
float
y1
,
float
x2
,
float
y2
,
bool
smooth
);
private
slots
:
void
downloadFinished
(
QNetworkReply
*
reply
);
private:
void
UTMtoTile
(
double
northing
,
double
easting
,
const
std
::
string
&
utmZone
,
double
imageResolution
,
int32_t
&
tileX
,
int32_t
&
tileY
,
int32_t
&
zoomLevel
);
...
...
@@ -61,6 +64,8 @@ private:
double
&
latitude
,
double
&
longitude
);
ImageryType
currentImageryType
;
QScopedPointer
<
QNetworkAccessManager
>
networkManager
;
};
#endif // IMAGERY_H
src/ui/map3D/Texture.cc
View file @
eff1df53
...
...
@@ -5,50 +5,54 @@ Texture::Texture()
}
Texture
::
State
Texture
::
getState
(
void
)
const
{
return
state
;
}
GLuint
Texture
::
getTextureId
(
void
)
const
{
return
textureId
;
}
int32_t
Texture
::
getTextureWidth
(
void
)
const
{
return
textureWidth
;
}
int32_t
Texture
::
getTextureHeight
(
void
)
const
{
return
textureHeight
;
}
int32_t
Texture
::
getImageWidth
(
void
)
const
{
return
imageWidth
;
}
int32_t
Texture
::
getImageHeight
(
void
)
const
{
return
imageHeight
;
}
float
Texture
::
getMaxU
(
void
)
const
{
return
maxU
;
}
float
Texture
::
getMaxV
(
void
)
const
{
return
maxV
;
void
Texture
::
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
bool
smoothInterpolation
)
const
{
if
(
state
==
REQUESTED
)
{
glBegin
(
GL_LINE_LOOP
);
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
);
glVertex2f
(
x1
,
y1
);
glVertex2f
(
x2
,
y1
);
glVertex2f
(
x2
,
y2
);
glVertex2f
(
x1
,
y2
);
glEnd
();
return
;
}
glEnable
(
GL_TEXTURE_2D
);
glBindTexture
(
GL_TEXTURE_2D
,
textureId
);
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
);
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
);
dx
=
0.0
f
;
dy
=
0.0
f
;
}
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
);
glBegin
(
GL_QUADS
);
glTexCoord2f
(
dx
,
maxV
-
dy
);
glVertex2f
(
x1
,
y1
);
glTexCoord2f
(
maxU
-
dx
,
maxV
-
dy
);
glVertex2f
(
x2
,
y1
);
glTexCoord2f
(
maxU
-
dx
,
dy
);
glVertex2f
(
x2
,
y2
);
glTexCoord2f
(
dx
,
dy
);
glVertex2f
(
x1
,
y2
);
glEnd
();
glDisable
(
GL_TEXTURE_2D
);
}
src/ui/map3D/Texture.h
View file @
eff1df53
...
...
@@ -9,6 +9,10 @@ class Texture
public:
Texture
();
void
draw
(
float
x1
,
float
y1
,
float
x2
,
float
y2
,
bool
smoothInterpolation
)
const
;
private:
enum
State
{
UNINITIALIZED
=
0
,
...
...
@@ -16,16 +20,6 @@ public:
READY
=
2
};
State
getState
(
void
)
const
;
GLuint
getTextureId
(
void
)
const
;
int32_t
getTextureWidth
(
void
)
const
;
int32_t
getTextureHeight
(
void
)
const
;
int32_t
getImageWidth
(
void
)
const
;
int32_t
getImageHeight
(
void
)
const
;
float
getMaxU
(
void
)
const
;
float
getMaxV
(
void
)
const
;
private:
State
state
;
GLuint
textureId
;
...
...
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