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 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
);
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
);
175 virtual void initializeGL();
178 virtual void resizeGL(int w
, int h
);
181 virtual void paintGL();
188 virtual void mouseMoveEvent(QMouseEvent
* event
);
191 virtual void mousePressEvent(QMouseEvent
* event
);
194 virtual void mouseReleaseEvent(QMouseEvent
* event
);
197 virtual void wheelEvent(QWheelEvent
* event
);
205 /// Adaptive quality.
206 bool m_adaptiveQuality
;
208 /// OpenGL polygon mode.
209 GLenum m_polygonMode
;
216 tcObserver
* m_observer
;
218 /// Globe to display.
225 /// Interaction mode.
232 /// Are we currently interacting?
233 bool m_mouseInteracting
;
235 /// Previous mouse position.
238 /// Mouse intersecting globe?
239 bool m_mouseIntersecting
;
241 /// Current mouse coordinate.
244 /// Slicing with the mouse?
247 /// Cross sectioning with mouse?
248 bool m_mouseCrossing
;
250 /// Start of mouse slicing action.
251 tcGeo m_mouseStartCoord
;
256 /// Coordinates of slice.
259 /// Whether a cross section is selected.
260 bool m_crossSectioned
;
263 tcGeo m_crossSection
[2];
265 /// Texture point object.
266 QObject
* m_texturePointObject
;
268 /// Texture point slot/signal.
269 const char* m_texturePointMember
;