Raytracing to determine whether a pixel is lit or not
[tecorrec.git] / tcViewportWidget.h
blob6537659ef452651e24933f8c3fb494c5698f0664
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();
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);
115 * Elevation modification slots
118 /// Go to flat elevation mode.
119 void setElevationFlat();
121 /// Go to raw SRTM elevation mode.
122 void setElevationRaw();
124 /// Go to corrected elevation mode.
125 void setElevationCorrected();
127 /// Set the level of correction applied to the elevation data.
128 void setElevationCorrection(int correction);
130 /// Set the elevation data set name.
131 void setElevationDataSet(const QString& name);
133 signals:
136 * Signals
139 /// Emitted when the mouse moves to a new position on the globe.
140 void mouseGeoChanged(const tcGeo& geo);
142 /** Emitted when the mouse moves to a new position on the globe.
143 * This has an int so it is compatible with QStatusBar::showMessage slot.
145 void mouseGeoTextChanged(const QString& geo);
147 /// Emitted when a texture point is selected.
148 void texturePointSelected(const maths::Vector<2,float>& coord);
150 protected:
153 * Rendering
156 // Reimplemented
157 virtual void initializeGL();
159 // Reimplemented
160 virtual void resizeGL(int w, int h);
162 // Reimplemented
163 virtual void paintGL();
166 * Mouse events
169 // Reimplemented
170 virtual void mouseMoveEvent(QMouseEvent* event);
172 // Reimplemented
173 virtual void mousePressEvent(QMouseEvent* event);
175 // Reimplemented
176 virtual void mouseReleaseEvent(QMouseEvent* event);
178 // Reimplemented
179 virtual void wheelEvent(QWheelEvent* event);
181 private:
184 * Rendering options
187 /// Adaptive quality.
188 bool m_adaptiveQuality;
190 /// OpenGL polygon mode.
191 GLenum m_polygonMode;
194 * Variables
197 /// Observer.
198 tcObserver* m_observer;
200 /// Globe to display.
201 tcGlobe* m_globe;
204 * Interaction
207 /// Interaction mode.
208 enum
210 Navigation,
211 TexturePoint
212 } m_interactionMode;
214 /// Are we currently interacting?
215 bool m_mouseInteracting;
217 /// Previous mouse position.
218 QPointF m_mousePos;
220 /// Mouse intersecting globe?
221 bool m_mouseIntersecting;
223 /// Current mouse coordinate.
224 tcGeo m_mouseCoord;
226 /// Slicing with the mouse?
227 bool m_mouseSlicing;
229 /// Start of mouse slicing action.
230 tcGeo m_mouseStartCoord;
232 /// Sliced?
233 bool m_sliced;
235 /// Coordinates of slice.
236 tcGeo m_slice[2];
238 /// Texture point object.
239 QObject* m_texturePointObject;
241 /// Texture point slot/signal.
242 const char* m_texturePointMember;
245 #endif