• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
ScanlineTextureMapperContext.h
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2007 Andrew Manson <g.real.ate@gmail.com>
9 // Copyright 2011 Bernhard Beschow <bbeschow@cs.tu-berlin.de
10 //
11 
12 #ifndef MARBLE_SCANLINETEXTUREMAPPERCONTEXT_H
13 #define MARBLE_SCANLINETEXTUREMAPPERCONTEXT_H
14 
15 #include <QSize>
16 #include <QImage>
17 
18 #include "GeoSceneTiled.h"
19 #include "MarbleMath.h"
20 #include "MathHelper.h"
21 
22 namespace Marble
23 {
24 
25 class StackedTile;
26 class StackedTileLoader;
27 class ViewportParams;
28 
29 
30 class ScanlineTextureMapperContext
31 {
32 public:
33  ScanlineTextureMapperContext( StackedTileLoader * const tileLoader, int tileLevel );
34 
35  void pixelValueF( const qreal lon, const qreal lat,
36  QRgb* const scanLine );
37  void pixelValue( const qreal lon, const qreal lat,
38  QRgb* const scanLine );
39 
40  void pixelValueApproxF( const qreal lon, const qreal lat,
41  QRgb *scanLine, const int n );
42  void pixelValueApprox( const qreal lon, const qreal lat,
43  QRgb *scanLine, const int n );
44 
45  static int interpolationStep( const ViewportParams *viewport, MapQuality mapQuality );
46 
47  static QImage::Format optimalCanvasImageFormat( const ViewportParams *viewport );
48 
49  int globalWidth() const;
50  int globalHeight() const;
51 
52 private:
53  // method for fast integer calculation
54  void nextTile( int& posx, int& posy );
55 
56  // method for precise interpolation
57  void nextTile( qreal& posx, qreal& posy );
58 
59  // Converts Radian to global texture coordinates
60  // ( with origin in center, measured in pixel)
61  qreal rad2PixelX( const qreal lon ) const;
62  qreal rad2PixelY( const qreal lat ) const;
63 
64  // Checks whether the pixelValueApprox method will make use of more than
65  // one tile
66  bool isOutOfTileRange( const int itLon, const int itLat,
67  const int itStepLon, const int itStepLat,
68  const int n ) const;
69 
70  bool isOutOfTileRangeF( const qreal itLon, const qreal itLat,
71  const qreal itStepLon, const qreal itStepLat,
72  const int n ) const;
73 
74 private:
75  StackedTileLoader *const m_tileLoader;
76  GeoSceneTiled::Projection const m_textureProjection;
78  QSize const m_tileSize;
79 
80  int const m_tileLevel;
81  int const m_globalWidth;
82  int const m_globalHeight;
83  qreal const m_normGlobalWidth;
84  qreal const m_normGlobalHeight;
85 
86  const StackedTile *m_tile;
87 
88  int m_deltaLevel;
89 
90  // Coordinate transformations:
91 
92  // Position of the tile in global Texture Coordinates
93  // ( with origin in upper left corner, measured in pixel)
94  int m_tilePosX;
95  int m_tilePosY;
96  int m_vTileStartX;
97  int m_vTileStartY;
98 
99  // Converts global texture coordinates
100  // ( with origin in center, measured in pixel)
101  // to tile coordinates ( measured in pixel )
102  qreal m_toTileCoordinatesLon;
103  qreal m_toTileCoordinatesLat;
104 
105  // Previous coordinates
106  qreal m_prevLat;
107  qreal m_prevLon;
108 };
109 
110 inline int ScanlineTextureMapperContext::globalWidth() const
111 {
112  return m_globalWidth;
113 }
114 
115 inline int ScanlineTextureMapperContext::globalHeight() const
116 {
117  return m_globalHeight;
118 }
119 
120 inline qreal ScanlineTextureMapperContext::rad2PixelX( const qreal lon ) const
121 {
122  return lon * m_normGlobalWidth;
123 }
124 
125 inline qreal ScanlineTextureMapperContext::rad2PixelY( const qreal lat ) const
126 {
127  switch ( m_textureProjection ) {
128  case GeoSceneTiled::Equirectangular:
129  return -lat * m_normGlobalHeight;
130  case GeoSceneTiled::Mercator:
131  if ( fabs( lat ) < 1.4835 ) {
132  // We develop the inverse Gudermannian into a MacLaurin Series:
133  // In spite of the many elements needed to get decent
134  // accuracy this is still faster by far than calculating the
135  // trigonometric expression:
136  // return - asinh( tan( lat ) ) * 0.5 * m_normGlobalHeight;
137 
138  // We are using the Horner Scheme as a polynom representation
139 
140  return - gdInv( lat ) * 0.5 * m_normGlobalHeight;
141  }
142  if ( lat >= +1.4835 )
143  // asinh( tan (1.4835)) => 3.1309587
144  return - 3.1309587 * 0.5 * m_normGlobalHeight;
145  if ( lat <= -1.4835 )
146  // asinh( tan( -1.4835 )) => −3.1309587
147  return 3.1309587 * 0.5 * m_normGlobalHeight;
148  }
149 
150  // Dummy value to avoid a warning.
151  return 0.0;
152 }
153 
154 }
155 
156 #endif
Marble::ScanlineTextureMapperContext::pixelValueApprox
void pixelValueApprox(const qreal lon, const qreal lat, QRgb *scanLine, const int n)
Definition: ScanlineTextureMapperContext.cpp:276
Marble::ScanlineTextureMapperContext::pixelValue
void pixelValue(const qreal lon, const qreal lat, QRgb *const scanLine)
Definition: ScanlineTextureMapperContext.cpp:83
Marble::GeoSceneTiled::Equirectangular
Definition: GeoSceneTiled.h:47
Marble::gdInv
qreal gdInv(qreal x)
This method is a fast Mac Laurin power series approximation of the.
Definition: MarbleMath.h:96
MarbleMath.h
Marble::GeoSceneTiled::Projection
Projection
Definition: GeoSceneTiled.h:47
Marble::ScanlineTextureMapperContext::globalWidth
int globalWidth() const
Definition: ScanlineTextureMapperContext.h:110
Marble::MapQuality
MapQuality
This enum is used to choose the map quality shown in the view.
Definition: MarbleGlobal.h:82
Marble::ScanlineTextureMapperContext::globalHeight
int globalHeight() const
Definition: ScanlineTextureMapperContext.h:115
Marble::StackedTileLoader
Tile loading from a quad tree.
Definition: StackedTileLoader.h:59
Marble::StackedTile
A single tile that consists of a stack of Tile layers.
Definition: StackedTile.h:56
Marble::ScanlineTextureMapperContext::ScanlineTextureMapperContext
ScanlineTextureMapperContext(StackedTileLoader *const tileLoader, int tileLevel)
Definition: ScanlineTextureMapperContext.cpp:25
MathHelper.h
Marble::ScanlineTextureMapperContext::optimalCanvasImageFormat
static QImage::Format optimalCanvasImageFormat(const ViewportParams *viewport)
Definition: ScanlineTextureMapperContext.cpp:429
Marble::ScanlineTextureMapperContext::pixelValueApproxF
void pixelValueApproxF(const qreal lon, const qreal lat, QRgb *scanLine, const int n)
Definition: ScanlineTextureMapperContext.cpp:130
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
QSize
Marble::GeoSceneTiled::Mercator
Definition: GeoSceneTiled.h:47
Marble::ScanlineTextureMapperContext::pixelValueF
void pixelValueF(const qreal lon, const qreal lat, QRgb *const scanLine)
Definition: ScanlineTextureMapperContext.cpp:47
GeoSceneTiled.h
Marble::ScanlineTextureMapperContext::interpolationStep
static int interpolationStep(const ViewportParams *viewport, MapQuality mapQuality)
Definition: ScanlineTextureMapperContext.cpp:401
Marble::ScanlineTextureMapperContext
Definition: ScanlineTextureMapperContext.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal