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