1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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_
24 * @file tcViewportWidget.h
25 * @brief OpenGL viewport widget.
39 /// OpenGL viewport widget.
40 class tcViewportWidget
: public QGLWidget
47 * Constructors + destructor
50 /// Primary constructor.
51 tcViewportWidget(QWidget
* parent
);
54 virtual ~tcViewportWidget();
60 /// Set the globe object.
61 void setGlobe(tcGlobe
* globe
);
67 /// Find the coordinates under the mouse.
68 tcGeo
geoAt(float x
, float y
, bool* ok
= 0);
76 /// Change to sun view.
77 void sunView(int imagery
);
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
);
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
);
169 virtual void initializeGL();
172 virtual void resizeGL(int w
, int h
);
175 virtual void paintGL();
182 virtual void mouseMoveEvent(QMouseEvent
* event
);
185 virtual void mousePressEvent(QMouseEvent
* event
);
188 virtual void mouseReleaseEvent(QMouseEvent
* event
);
191 virtual void wheelEvent(QWheelEvent
* event
);
199 /// Adaptive quality.
200 bool m_adaptiveQuality
;
202 /// OpenGL polygon mode.
203 GLenum m_polygonMode
;
210 tcObserver
* m_observer
;
212 /// Globe to display.
219 /// Interaction mode.
226 /// Are we currently interacting?
227 bool m_mouseInteracting
;
229 /// Previous mouse position.
232 /// Mouse intersecting globe?
233 bool m_mouseIntersecting
;
235 /// Current mouse coordinate.
238 /// Slicing with the mouse?
241 /// Start of mouse slicing action.
242 tcGeo m_mouseStartCoord
;
247 /// Coordinates of slice.
250 /// Texture point object.
251 QObject
* m_texturePointObject
;
253 /// Texture point slot/signal.
254 const char* m_texturePointMember
;