Interface for mapping between input bands and output channels
[tecorrec.git] / tcViewportWidget.h
blob7fdbf49c73de7826a55357b0184b2e74256e5876
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 quality to adaptive.
77 void setQualityAdaptive();
79 /// Change the quality to full resolution.
80 void setQualityFull();
82 /// Change the polygon mode to normal.
83 void setPolygonModeNormal();
85 /// Change the polygon mode to wireframe.
86 void setPolygonModeWireframe();
88 /// Remove colour coding.
89 void setColourCodingNone();
91 /// Set colour coding to elevation sample alignment.
92 void setColourCodingElevationSampleAlignment();
94 /// Set colour mapping for an output channel to an input band.
95 void setColourMapping(int output, int input);
98 * Elevation modification slots
101 /// Go to flat elevation mode.
102 void setElevationFlat();
104 /// Go to raw SRTM elevation mode.
105 void setElevationRaw();
107 /// Go to corrected elevation mode.
108 void setElevationCorrected();
110 /// Set the level of correction applied to the elevation data.
111 void setElevationCorrection(int correction);
113 /// Set the elevation data set name.
114 void setElevationDataSet(const QString& name);
116 signals:
119 * Signals
122 /// Emitted when the mouse moves to a new position on the globe.
123 void mouseGeoChanged(const tcGeo& geo);
125 /** Emitted when the mouse moves to a new position on the globe.
126 * This has an int so it is compatible with QStatusBar::showMessage slot.
128 void mouseGeoTextChanged(const QString& geo);
130 protected:
133 * Rendering
136 // Reimplemented
137 virtual void initializeGL();
139 // Reimplemented
140 virtual void resizeGL(int w, int h);
142 // Reimplemented
143 virtual void paintGL();
146 * Mouse events
149 // Reimplemented
150 virtual void mouseMoveEvent(QMouseEvent* event);
152 // Reimplemented
153 virtual void mousePressEvent(QMouseEvent* event);
155 // Reimplemented
156 virtual void mouseReleaseEvent(QMouseEvent* event);
158 // Reimplemented
159 virtual void wheelEvent(QWheelEvent* event);
161 private:
164 * Rendering options
167 /// Adaptive quality.
168 bool m_adaptiveQuality;
170 /// OpenGL polygon mode.
171 GLenum m_polygonMode;
174 * Variables
177 /// Observer.
178 tcObserver* m_observer;
180 /// Globe to display.
181 tcGlobe* m_globe;
184 * Interaction
187 /// Are we currently interacting?
188 bool m_mouseInteracting;
190 /// Previous mouse position.
191 QPointF m_mousePos;
193 /// Mouse intersecting globe?
194 bool m_mouseIntersecting;
196 /// Current mouse coordinate.
197 tcGeo m_mouseCoord;
199 /// Slicing with the mouse?
200 bool m_mouseSlicing;
202 /// Start of mouse slicing action.
203 tcGeo m_mouseStartCoord;
205 /// Sliced?
206 bool m_sliced;
208 /// Coordinates of slice.
209 tcGeo m_slice[2];
212 #endif