Fixed bug in arcToHgt where it wrote to end of file instead of last row of file
[tecorrec.git] / tcViewportWidget.h
blob070ad702ffadc64ce927c3457e846e0b5cf276b8
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 _tcViewportWidget_h_
21 #define _tcViewportWidget_h_
23 /**
24 * @file tcViewportWidget.h
25 * @brief OpenGL viewport widget.
28 #include <tcGeo.h>
29 #include <Vector.h>
31 #include <QGLWidget>
32 #include <QPointF>
34 class tcObserver;
35 class tcGlobe;
37 class QString;
39 /// OpenGL viewport widget.
40 class tcViewportWidget : public QGLWidget
42 Q_OBJECT
44 public:
47 * Constructors + destructor
50 /// Primary constructor.
51 tcViewportWidget(QWidget* parent);
53 /// Destructor.
54 virtual ~tcViewportWidget();
57 * Modifiers
60 /// Set the globe object.
61 void setGlobe(tcGlobe* globe);
64 * Accessors
67 /// Find the coordinates under the mouse.
68 tcGeo geoAt(float x, float y, bool* ok = 0);
70 public slots:
73 * Observer control
76 /// Change to sun view.
77 void sunView(int imagery);
80 * Interaction control
83 /// Enable navigation mode.
84 void navigationMode();
86 /// Enable texture point selection mode.
87 void texturePointMode(QObject* receiver, const char* member);
89 /// Set slice.
90 void setSlice(const tcGeo& sw, const tcGeo& ne);
93 * General rendering slots
96 /// Change the quality to adaptive.
97 void setQualityAdaptive();
99 /// Change the quality to full resolution.
100 void setQualityFull();
102 /// Change the polygon mode to normal.
103 void setPolygonModeNormal();
105 /// Change the polygon mode to wireframe.
106 void setPolygonModeWireframe();
108 /// Remove colour coding.
109 void setColourCodingNone();
111 /// Set colour coding to elevation sample alignment.
112 void setColourCodingElevationSampleAlignment();
114 /// Set colour mapping for an output channel to an input band.
115 void setColourMapping(int output, int input, int inputGroup);
118 * Elevation modification slots
121 /// Set the primary elevation data set name.
122 void setPrimaryElevationDataSet(const QString& name);
124 /// Set the secondary elevation data set name.
125 void setSecondaryElevationDataSet(const QString& name);
127 /// Go to flat primary elevation mode.
128 void setPrimaryElevationFlat();
130 /// Go to flat secondary elevation mode.
131 void setSecondaryElevationFlat();
133 /// Go to raw SRTM primary elevation mode.
134 void setPrimaryElevationRaw();
136 /// Go to raw SRTM secondary elevation mode.
137 void setSecondaryElevationRaw();
139 /// Go to corrected primary elevation mode.
140 void setPrimaryElevationCorrected();
142 /// Go to corrected secondary elevation mode.
143 void setSecondaryElevationCorrected();
145 /// Set the interpolation value.
146 void setElevationInterpolation(int interpolation);
148 signals:
151 * Signals
154 /// Emitted when the mouse moves to a new position on the globe.
155 void mouseGeoChanged(const tcGeo& geo);
157 /** Emitted when the mouse moves to a new position on the globe.
158 * This has an int so it is compatible with QStatusBar::showMessage slot.
160 void mouseGeoTextChanged(const QString& geo);
162 /// Emitted when a texture point is selected.
163 void texturePointSelected(const maths::Vector<2,float>& coord);
165 protected:
168 * Rendering
171 // Reimplemented
172 virtual void initializeGL();
174 // Reimplemented
175 virtual void resizeGL(int w, int h);
177 // Reimplemented
178 virtual void paintGL();
181 * Mouse events
184 // Reimplemented
185 virtual void mouseMoveEvent(QMouseEvent* event);
187 // Reimplemented
188 virtual void mousePressEvent(QMouseEvent* event);
190 // Reimplemented
191 virtual void mouseReleaseEvent(QMouseEvent* event);
193 // Reimplemented
194 virtual void wheelEvent(QWheelEvent* event);
196 private:
199 * Rendering options
202 /// Adaptive quality.
203 bool m_adaptiveQuality;
205 /// OpenGL polygon mode.
206 GLenum m_polygonMode;
209 * Variables
212 /// Observer.
213 tcObserver* m_observer;
215 /// Globe to display.
216 tcGlobe* m_globe;
219 * Interaction
222 /// Interaction mode.
223 enum
225 Navigation,
226 TexturePoint
227 } m_interactionMode;
229 /// Are we currently interacting?
230 bool m_mouseInteracting;
232 /// Previous mouse position.
233 QPointF m_mousePos;
235 /// Mouse intersecting globe?
236 bool m_mouseIntersecting;
238 /// Current mouse coordinate.
239 tcGeo m_mouseCoord;
241 /// Slicing with the mouse?
242 bool m_mouseSlicing;
244 /// Start of mouse slicing action.
245 tcGeo m_mouseStartCoord;
247 /// Sliced?
248 bool m_sliced;
250 /// Coordinates of slice.
251 tcGeo m_slice[2];
253 /// Texture point object.
254 QObject* m_texturePointObject;
256 /// Texture point slot/signal.
257 const char* m_texturePointMember;
260 #endif