Added gui options for wireframe, and colour coding
[tecorrec.git] / tcViewportWidget.h
blobbd7f2930f8fd3dc238e924419109e699c6ff5d9c
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 * 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);
107 signals:
110 * Signals
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);
121 protected:
124 * Rendering
127 // Reimplemented
128 virtual void initializeGL();
130 // Reimplemented
131 virtual void resizeGL(int w, int h);
133 // Reimplemented
134 virtual void paintGL();
137 * Mouse events
140 // Reimplemented
141 virtual void mouseMoveEvent(QMouseEvent* event);
143 // Reimplemented
144 virtual void mousePressEvent(QMouseEvent* event);
146 // Reimplemented
147 virtual void mouseReleaseEvent(QMouseEvent* event);
149 // Reimplemented
150 virtual void wheelEvent(QWheelEvent* event);
152 private:
155 * Rendering options
158 /// OpenGL polygon mode.
159 GLenum m_polygonMode;
162 * Variables
165 /// Observer.
166 tcObserver* m_observer;
168 /// Globe to display.
169 tcGlobe* m_globe;
172 * Interaction
175 /// Are we currently interacting?
176 bool m_mouseInteracting;
178 /// Previous mouse position.
179 QPointF m_mousePos;
181 /// Mouse intersecting globe?
182 bool m_mouseIntersecting;
184 /// Current mouse coordinate.
185 tcGeo m_mouseCoord;
187 /// Slicing with the mouse?
188 bool m_mouseSlicing;
190 /// Start of mouse slicing action.
191 tcGeo m_mouseStartCoord;
193 /// Sliced?
194 bool m_sliced;
196 /// Coordinates of slice.
197 tcGeo m_slice[2];
200 #endif