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);
73 * General rendering slots
76 /// Change the polygon mode to normal.
77 void setPolygonModeNormal();
79 /// Change the polygon mode to wireframe.
80 void setPolygonModeWireframe();
82 /// Remove colour coding.
83 void setColourCodingNone();
85 /// Set colour coding to elevation sample alignment.
86 void setColourCodingElevationSampleAlignment();
89 * Elevation modification slots
92 /// Go to flat elevation mode.
93 void setElevationFlat();
95 /// Go to raw SRTM elevation mode.
96 void setElevationRaw();
98 /// Go to corrected elevation mode.
99 void setElevationCorrected();
101 /// Set the level of correction applied to the elevation data.
102 void setElevationCorrection(int correction
);
104 /// Set the elevation data set name.
105 void setElevationDataSet(const QString
& name
);
113 /// Emitted when the mouse moves to a new position on the globe.
114 void mouseGeoChanged(const tcGeo
& geo
);
116 /** Emitted when the mouse moves to a new position on the globe.
117 * This has an int so it is compatible with QStatusBar::showMessage slot.
119 void mouseGeoTextChanged(const QString
& geo
);
128 virtual void initializeGL();
131 virtual void resizeGL(int w
, int h
);
134 virtual void paintGL();
141 virtual void mouseMoveEvent(QMouseEvent
* event
);
144 virtual void mousePressEvent(QMouseEvent
* event
);
147 virtual void mouseReleaseEvent(QMouseEvent
* event
);
150 virtual void wheelEvent(QWheelEvent
* event
);
158 /// OpenGL polygon mode.
159 GLenum m_polygonMode
;
166 tcObserver
* m_observer
;
168 /// Globe to display.
175 /// Are we currently interacting?
176 bool m_mouseInteracting
;
178 /// Previous mouse position.
181 /// Mouse intersecting globe?
182 bool m_mouseIntersecting
;
184 /// Current mouse coordinate.
187 /// Slicing with the mouse?
190 /// Start of mouse slicing action.
191 tcGeo m_mouseStartCoord
;
196 /// Coordinates of slice.