Basic elevation optimisation channel
[tecorrec.git] / geo / tcGlobe.h
blob0047d598597d98e5064b18052c1fe60ff1b1e197
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 class tcGeo;
31 class tcGeoImageData;
32 class tcObserver;
34 /** Manages data for a globe.
35 * Holds terrain elevation and imagery data.
37 class tcGlobe
39 public:
42 * Enumerations
45 /// Elevation modes.
46 enum ElevationMode
48 NoElevation,
49 RawElevation,
50 CorrectedElevation
53 /// Colour codings.
54 enum ColourCoding {
55 NoColourCoding = 0,
56 ElevationSampleAlignment
60 * Constructors + destructor
63 /// Primary constructor.
64 tcGlobe(double meanRadius);
66 /// Destructor.
67 virtual ~tcGlobe();
70 * Data sets
73 /// Set the imagery data.
74 void setImagery(tcGeoImageData* data);
76 /// Get the imagery data.
77 tcGeoImageData* imagery() const;
79 /// Get the elevation model.
80 tcSrtmModel* dem() const;
83 * Rendering
86 /// Render from the POV of an observer.
87 void render(tcObserver* const observer = 0, bool adaptive = true, const tcGeo* extent = 0);
89 /// Set the elevation mode to render in.
90 void setElevationMode(ElevationMode mode);
92 /// Set the level of correction to show.
93 void setElevationCorrection(float correction);
95 /// Set the elevation data set name.
96 void setElevationDataSet(const QString& name);
98 /// Set colour coding method.
99 void setColourCoding(ColourCoding colourCoding);
101 /// Adjust the mapping between bands and colour channels.
102 void setColourMapping(int outputChannel, int inputBand);
105 * Accessors
108 /// Get the mean radius.
109 double meanRadius() const;
111 /// Get the altitude above sea level at a sample in a render state.
112 double altitudeAt(const tcSrtmModel::RenderState& state, int x, int y, tcGeo* outCoord, bool* isAccurate = 0) const;
114 /// Get the altitude above sea level at a coordinate.
115 double altitudeAt(const tcGeo& coord, bool* isAccurate = 0) const;
117 /// Get the radius at a coordinate.
118 double radiusAt(const tcGeo& coord) const;
120 /// Get the texture coordinate of the effective texture at a geographical coordinate.
121 maths::Vector<2,double> textureCoordOfGeo(const tcGeo& coord) const;
123 private:
126 * Rendering
129 /// Draw a line of latitude.
130 void drawLineOfLatitude(double latitude) const;
132 /// Render a cell.
133 void renderCell(tcObserver* const observer, const tcGeo& swCorner, const tcGeo& neCorner, int samples,
134 bool northEdge = false, bool eastEdge = false, bool southEdge = false, bool westEdge = false) const;
136 private:
139 * Variables
142 /// Mean radius in metres.
143 double m_meanRadius;
145 /// Elevation model.
146 tcSrtmModel* m_elevation;
148 /// Image data.
149 tcGeoImageData* m_imagery;
152 * Rendering options
155 /// Current elevation mode.
156 ElevationMode m_elevationMode;
158 /// Current level of elevation correction.
159 float m_elevationCorrection;
161 /// Colour coding method.
162 ColourCoding m_colourCoding;
164 /// Mapping of bands to colour channels.
165 int m_colourMapping[3];
168 #endif