Simple program to read arcinfo ascii files and convert into hgt elevation data (for...
[tecorrec.git] / geo / tcChannel.h
blob5539f4c2b5b989c233eefe50816400886148226c
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 _tcChannel_h_
21 #define _tcChannel_h_
23 /**
24 * @file tcChannel.h
25 * @brief A single abstract image channel.
28 #include "tcPixelData.h"
30 #include <QObject>
31 #include <QString>
32 #include <QList>
34 #include <GL/gl.h>
36 class tcChannelConfigWidget;
37 class tcChannelManager;
39 /// A single abstract image channel.
40 class tcChannel : public QObject
42 Q_OBJECT
44 public:
47 * Constructors + destructor
50 /// Primary constructor.
51 tcChannel(const QString& name, const QString& description);
53 /// Destructor.
54 virtual ~tcChannel();
57 * Metadata
60 /// Get the channel manager.
61 tcChannelManager* channelManager() const;
63 /// Set the channel manager.
64 void setChannelManager(tcChannelManager* channelManager);
66 /// Get the channel name.
67 const QString& name() const;
69 /// Get the channel description;
70 const QString& description() const;
72 /// Set the channel name.
73 void setName(const QString& name);
75 /// Set the channel description.
76 void setDescription(const QString& description);
78 /// Set radiance offset and gain.
79 void setRadianceTransform(float offset, float gain);
82 * Dependencies
85 /// Add derivitive of this channel.
86 void addDerivitive(tcChannel* derivitive);
88 /// Remove a derivitive of this channel.
89 void removeDerivitive(tcChannel* derivitive);
92 * Main image interface
95 /// Get configuration widget.
96 virtual tcChannelConfigWidget* configWidget();
98 /// Get GL texture ID of thumbnail of the channel.
99 virtual GLuint thumbnailTexture();
101 /// Get a reference to the pixel data of the current portion of the image.
102 Reference<tcAbstractPixelData> portion() const;
104 /// Get a reference to the pixel data of a portion of the image.
105 Reference<tcAbstractPixelData> portion(double* x1, double* y1, double* x2, double* y2);
107 /// Get a reference to the pixel data of a portion of the image.
108 Reference<tcAbstractPixelData> portion(double x1, double y1, double x2, double y2);
110 /// Get GL texture ID of portion of the channel.
111 GLuint portionTexture(double* x1, double* y1, double* x2, double* y2);
113 /// Radiance scaling.
114 float valueToRadiance(float value)
116 return m_radianceOffset + value*m_radianceGain;
119 //protected:
122 * Interface for derived class to implement
125 /// Round coordinates to sensible values.
126 virtual void roundPortion(double* x1, double* y1, double* x2, double* y2) = 0;
128 /// Load a portion of pixel data from the channel source, wherever that may be.
129 virtual tcAbstractPixelData* loadPortion(double x1, double y1, double x2, double y2, bool changed) = 0;
131 public slots:
134 * Interface for derived classes
137 /** Invalidate this channel.
138 * For example if one of the inputs has changed.
140 void invalidate();
142 signals:
145 * Signals
148 /// Emitted to indicate progress of processing.
149 void progressing(const QString& message);
151 protected:
154 * Progress functions
157 /// Start a processing step.
158 void startProcessing(const QString& step);
160 /// Update progress.
161 void progress(float progress);
163 /// Update progress.
164 void progress(const QString& info);
166 /// End processing step.
167 void endProcessing();
169 private:
172 * Variables
175 /// Channel manager.
176 tcChannelManager* m_channelManager;
178 /// Name of the channel.
179 QString m_name;
181 /// Description of the channel.
182 QString m_description;
184 /// List of channels which are derived from this channel.
185 QList<tcChannel*> m_derivitives;
187 /// Pixel data of a portion of the channel.
188 Reference<tcAbstractPixelData> m_portion;
190 /// Portion coordinates.
191 double m_portionPosition[2][2];
193 /// Radiance scaling information.
194 float m_radianceOffset, m_radianceGain;
197 * Static variables
200 /// Current processing step.
201 static QString s_processingStep;
203 /// Last progress percent.
204 static int s_processingLastPercent;
207 #endif