tcElevationOptimization::loadSnapShot: simplify reliability expression
[tecorrec.git] / tcViewportWidget.h
blobe6e57f9209f50450b453358353c02b4ca74bd615
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);
92 /// Set cross section.
93 void setCrossSection(const tcGeo& p1, const tcGeo& p2);
96 * General rendering slots
99 /// Change the quality to adaptive.
100 void setQualityAdaptive();
102 /// Change the quality to full resolution.
103 void setQualityFull();
105 /// Change the polygon mode to normal.
106 void setPolygonModeNormal();
108 /// Change the polygon mode to wireframe.
109 void setPolygonModeWireframe();
111 /// Remove colour coding.
112 void setColourCodingNone();
114 /// Set colour coding to elevation sample alignment.
115 void setColourCodingElevationSampleAlignment();
117 /// Set colour mapping for an output channel to an input band.
118 void setColourMapping(int output, int input, int inputGroup);
121 * Elevation modification slots
124 /// Set the primary elevation data set name.
125 void setPrimaryElevationDataSet(const QString& name);
127 /// Set the secondary elevation data set name.
128 void setSecondaryElevationDataSet(const QString& name);
130 /// Go to flat primary elevation mode.
131 void setPrimaryElevationFlat();
133 /// Go to flat secondary elevation mode.
134 void setSecondaryElevationFlat();
136 /// Go to raw SRTM primary elevation mode.
137 void setPrimaryElevationRaw();
139 /// Go to raw SRTM secondary elevation mode.
140 void setSecondaryElevationRaw();
142 /// Go to corrected primary elevation mode.
143 void setPrimaryElevationCorrected();
145 /// Go to corrected secondary elevation mode.
146 void setSecondaryElevationCorrected();
148 /// Set the interpolation value.
149 void setElevationInterpolation(int interpolation);
151 signals:
154 * Signals
157 /// Emitted when the mouse moves to a new position on the globe.
158 void mouseGeoChanged(const tcGeo& geo);
160 /** Emitted when the mouse moves to a new position on the globe.
161 * This has an int so it is compatible with QStatusBar::showMessage slot.
163 void mouseGeoTextChanged(const QString& geo);
165 /// Emitted when a texture point is selected.
166 void texturePointSelected(const maths::Vector<2,float>& coord);
168 protected:
171 * Rendering
174 // Reimplemented
175 virtual void initializeGL();
177 // Reimplemented
178 virtual void resizeGL(int w, int h);
180 // Reimplemented
181 virtual void paintGL();
184 * Mouse events
187 // Reimplemented
188 virtual void mouseMoveEvent(QMouseEvent* event);
190 // Reimplemented
191 virtual void mousePressEvent(QMouseEvent* event);
193 // Reimplemented
194 virtual void mouseReleaseEvent(QMouseEvent* event);
196 // Reimplemented
197 virtual void wheelEvent(QWheelEvent* event);
199 private:
202 * Rendering options
205 /// Adaptive quality.
206 bool m_adaptiveQuality;
208 /// OpenGL polygon mode.
209 GLenum m_polygonMode;
212 * Variables
215 /// Observer.
216 tcObserver* m_observer;
218 /// Globe to display.
219 tcGlobe* m_globe;
222 * Interaction
225 /// Interaction mode.
226 enum
228 Navigation,
229 TexturePoint
230 } m_interactionMode;
232 /// Are we currently interacting?
233 bool m_mouseInteracting;
235 /// Previous mouse position.
236 QPointF m_mousePos;
238 /// Mouse intersecting globe?
239 bool m_mouseIntersecting;
241 /// Current mouse coordinate.
242 tcGeo m_mouseCoord;
244 /// Slicing with the mouse?
245 bool m_mouseSlicing;
247 /// Cross sectioning with mouse?
248 bool m_mouseCrossing;
250 /// Start of mouse slicing action.
251 tcGeo m_mouseStartCoord;
253 /// Sliced?
254 bool m_sliced;
256 /// Coordinates of slice.
257 tcGeo m_slice[2];
259 /// Whether a cross section is selected.
260 bool m_crossSectioned;
262 /// Cross section.
263 tcGeo m_crossSection[2];
265 /// Texture point object.
266 QObject* m_texturePointObject;
268 /// Texture point slot/signal.
269 const char* m_texturePointMember;
272 #endif