tcElevationOptimization: fix typo s/write/read/
[tecorrec.git] / geo / tcGlobe.h
blob4da8d49117242b5bdb413424b29afbf74a6b538a
1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * Tecorrec is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * Tecorrec is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with Tecorrec. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _tcGlobe_h_
21 #define _tcGlobe_h_
23 /**
24 * @file tcGlobe.h
25 * @brief Manages data for a globe.
28 #include "tcSrtmModel.h"
30 #include <QList>
32 class tcGeo;
33 class tcGeoImageData;
34 class tcObserver;
36 /** Manages data for a globe.
37 * Holds terrain elevation and imagery data.
39 class tcGlobe
41 public:
44 * Enumerations
47 /// Elevation modes.
48 enum ElevationMode
50 NoElevation,
51 RawElevation,
52 CorrectedElevation
55 /// Colour codings.
56 enum ColourCoding {
57 NoColourCoding = 0,
58 ElevationSampleAlignment
62 * Constructors + destructor
65 /// Primary constructor.
66 tcGlobe(double meanRadius);
68 /// Destructor.
69 virtual ~tcGlobe();
72 * Data sets
75 /// Add some imagery data.
76 void addImagery(tcGeoImageData* data);
78 /// Get the imagery data.
79 const QList<tcGeoImageData*>& imagery() const;
81 /// Get the elevation model.
82 tcSrtmModel* dem() const;
85 * Rendering
88 /// Render from the POV of an observer.
89 void render(tcObserver* const observer = 0, bool adaptive = true, const tcGeo* extent = 0);
91 /// Set the elevation mode to render in.
92 void setElevationMode(int dem, ElevationMode mode);
94 /// Set the level of interpolation.
95 void setElevationInterpolation(float interpolation);
97 /// Set the elevation data set name.
98 void setElevationDataSet(int dem, const QString& name);
100 /// Set colour coding method.
101 void setColourCoding(ColourCoding colourCoding);
103 /// Adjust the mapping between bands and colour channels.
104 void setColourMapping(int outputChannel, int inputBand, int inputGroup);
107 * Accessors
110 /// Get the mean radius.
111 double meanRadius() const;
113 /// Get the altitude above sea level at a sample in a render state.
114 double altitudeAt(const tcSrtmModel::RenderState& state, int x, int y, tcGeo* outCoord, bool* isAccurate = 0) const;
116 /// Get the altitude above sea level at a coordinate.
117 double altitudeAt(const tcGeo& coord, bool* isAccurate = 0) const;
119 /// Get the radius at a coordinate.
120 double radiusAt(const tcGeo& coord) const;
122 /// Get the texture coordinate of the effective texture at a geographical coordinate.
123 maths::Vector<2,double> textureCoordOfGeo(const tcGeo& coord) const;
125 /// Get the current normal at a coordinate.
126 maths::Vector<3,float> normalAt(int norm, const tcGeo& coord) const;
128 private:
131 * Rendering
134 /// Draw a line of latitude.
135 void drawLineOfLatitude(double latitude) const;
137 /// Render a cell.
138 void renderCell(tcObserver* const observer, const tcGeo& swCorner, const tcGeo& neCorner, int samples, bool normals = false,
139 bool northEdge = false, bool eastEdge = false, bool southEdge = false, bool westEdge = false) const;
141 private:
144 * Variables
147 /// Mean radius in metres.
148 double m_meanRadius;
150 /// Elevation model.
151 tcSrtmModel* m_elevation;
153 /// Image data.
154 QList<tcGeoImageData*> m_imagery;
157 * Rendering options
160 /// Current elevation mode.
161 ElevationMode m_elevationMode[2];
163 /// Current level of elevation interpolation.
164 float m_elevationInterpolation;
166 /// Colour coding method.
167 ColourCoding m_colourCoding;
169 /// Mapping of bands to colour channels.
170 int m_colourMapping[6][2];
173 #endif