Tweaks and attempts to get shape from shading working
[tecorrec.git] / tcViewportWidget.h
blob757fbcee49361a04f13d1dd1e2ccf252e348289c
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);
90 * General rendering slots
93 /// Change the quality to adaptive.
94 void setQualityAdaptive();
96 /// Change the quality to full resolution.
97 void setQualityFull();
99 /// Change the polygon mode to normal.
100 void setPolygonModeNormal();
102 /// Change the polygon mode to wireframe.
103 void setPolygonModeWireframe();
105 /// Remove colour coding.
106 void setColourCodingNone();
108 /// Set colour coding to elevation sample alignment.
109 void setColourCodingElevationSampleAlignment();
111 /// Set colour mapping for an output channel to an input band.
112 void setColourMapping(int output, int input, int inputGroup);
115 * Elevation modification slots
118 /// Set the primary elevation data set name.
119 void setPrimaryElevationDataSet(const QString& name);
121 /// Set the secondary elevation data set name.
122 void setSecondaryElevationDataSet(const QString& name);
124 /// Go to flat primary elevation mode.
125 void setPrimaryElevationFlat();
127 /// Go to flat secondary elevation mode.
128 void setSecondaryElevationFlat();
130 /// Go to raw SRTM primary elevation mode.
131 void setPrimaryElevationRaw();
133 /// Go to raw SRTM secondary elevation mode.
134 void setSecondaryElevationRaw();
136 /// Go to corrected primary elevation mode.
137 void setPrimaryElevationCorrected();
139 /// Go to corrected secondary elevation mode.
140 void setSecondaryElevationCorrected();
142 /// Set the interpolation value.
143 void setElevationInterpolation(int interpolation);
145 signals:
148 * Signals
151 /// Emitted when the mouse moves to a new position on the globe.
152 void mouseGeoChanged(const tcGeo& geo);
154 /** Emitted when the mouse moves to a new position on the globe.
155 * This has an int so it is compatible with QStatusBar::showMessage slot.
157 void mouseGeoTextChanged(const QString& geo);
159 /// Emitted when a texture point is selected.
160 void texturePointSelected(const maths::Vector<2,float>& coord);
162 protected:
165 * Rendering
168 // Reimplemented
169 virtual void initializeGL();
171 // Reimplemented
172 virtual void resizeGL(int w, int h);
174 // Reimplemented
175 virtual void paintGL();
178 * Mouse events
181 // Reimplemented
182 virtual void mouseMoveEvent(QMouseEvent* event);
184 // Reimplemented
185 virtual void mousePressEvent(QMouseEvent* event);
187 // Reimplemented
188 virtual void mouseReleaseEvent(QMouseEvent* event);
190 // Reimplemented
191 virtual void wheelEvent(QWheelEvent* event);
193 private:
196 * Rendering options
199 /// Adaptive quality.
200 bool m_adaptiveQuality;
202 /// OpenGL polygon mode.
203 GLenum m_polygonMode;
206 * Variables
209 /// Observer.
210 tcObserver* m_observer;
212 /// Globe to display.
213 tcGlobe* m_globe;
216 * Interaction
219 /// Interaction mode.
220 enum
222 Navigation,
223 TexturePoint
224 } m_interactionMode;
226 /// Are we currently interacting?
227 bool m_mouseInteracting;
229 /// Previous mouse position.
230 QPointF m_mousePos;
232 /// Mouse intersecting globe?
233 bool m_mouseIntersecting;
235 /// Current mouse coordinate.
236 tcGeo m_mouseCoord;
238 /// Slicing with the mouse?
239 bool m_mouseSlicing;
241 /// Start of mouse slicing action.
242 tcGeo m_mouseStartCoord;
244 /// Sliced?
245 bool m_sliced;
247 /// Coordinates of slice.
248 tcGeo m_slice[2];
250 /// Texture point object.
251 QObject* m_texturePointObject;
253 /// Texture point slot/signal.
254 const char* m_texturePointMember;
257 #endif