tcElevationOptimization: fix typo s/write/read/
[tecorrec.git] / geo / tcChannel.h
blobcc87108652d0c7f93651b69832e5882804731e38
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"
29 #include "tcGeo.h"
31 #include <QObject>
32 #include <QString>
33 #include <QList>
35 #include <GL/gl.h>
37 class tcChannelConfigWidget;
38 class tcChannelManager;
40 /// A single abstract image channel.
41 class tcChannel : public QObject
43 Q_OBJECT
45 public:
48 * Constructors + destructor
51 /// Primary constructor.
52 tcChannel(const QString& name, const QString& description);
54 /// Destructor.
55 virtual ~tcChannel();
58 * Metadata
61 /// Get the channel manager.
62 tcChannelManager* channelManager() const;
64 /// Set the channel manager.
65 void setChannelManager(tcChannelManager* channelManager);
67 /// Get the channel name.
68 const QString& name() const;
70 /// Get the channel description;
71 const QString& description() const;
73 /// Set the channel name.
74 void setName(const QString& name);
76 /// Set the channel description.
77 void setDescription(const QString& description);
79 /// Set radiance offset and gain.
80 void setRadianceTransform(float offset, float gain);
82 /// New cross section selected.
83 void newCrossSection(const tcGeo& p1, const tcGeo& p2);
86 * Dependencies
89 /// Add derivitive of this channel.
90 void addDerivitive(tcChannel* derivitive);
92 /// Remove a derivitive of this channel.
93 void removeDerivitive(tcChannel* derivitive);
96 * Main image interface
99 /// Get configuration widget.
100 virtual tcChannelConfigWidget* configWidget();
102 /// Get GL texture ID of thumbnail of the channel.
103 virtual GLuint thumbnailTexture();
105 /// Get a reference to the pixel data of the current portion of the image.
106 Reference<tcAbstractPixelData> portion() const;
108 /// Get a reference to the pixel data of a portion of the image.
109 Reference<tcAbstractPixelData> portion(double* x1, double* y1, double* x2, double* y2);
111 /// Get a reference to the pixel data of a portion of the image.
112 Reference<tcAbstractPixelData> portion(double x1, double y1, double x2, double y2);
114 /// Get GL texture ID of portion of the channel.
115 GLuint portionTexture(double* x1, double* y1, double* x2, double* y2);
117 /// Radiance scaling.
118 float valueToRadiance(float value)
120 return m_radianceOffset + value*m_radianceGain;
123 /// Get the last portion position.
124 const double* portionPosition() const;
126 //protected:
129 * Interface for derived class to implement
132 /// Round coordinates to sensible values.
133 virtual void roundPortion(double* x1, double* y1, double* x2, double* y2) = 0;
135 /// Load a portion of pixel data from the channel source, wherever that may be.
136 virtual tcAbstractPixelData* loadPortion(double x1, double y1, double x2, double y2, bool changed) = 0;
138 public slots:
141 * Interface for derived classes
144 /** Invalidate this channel.
145 * For example if one of the inputs has changed.
147 void invalidate();
149 signals:
152 * Signals
155 /// Emitted to indicate progress of processing.
156 void progressing(const QString& message);
158 protected:
161 * Progress functions
164 /// Start a processing step.
165 void startProcessing(const QString& step);
167 /// Update progress.
168 void progress(float progress);
170 /// Update progress.
171 void progress(const QString& info);
173 /// End processing step.
174 void endProcessing();
176 private:
179 * Variables
182 /// Channel manager.
183 tcChannelManager* m_channelManager;
185 /// Name of the channel.
186 QString m_name;
188 /// Description of the channel.
189 QString m_description;
191 /// List of channels which are derived from this channel.
192 QList<tcChannel*> m_derivitives;
194 /// Pixel data of a portion of the channel.
195 Reference<tcAbstractPixelData> m_portion;
197 /// Portion coordinates.
198 double m_portionPosition[2][2];
200 /// Radiance scaling information.
201 float m_radianceOffset, m_radianceGain;
203 protected:
205 /// Whether cross sectioned.
206 bool m_crossSectioned;
208 /// Current cross section.
209 tcGeo m_crossSection[2];
211 private:
214 * Static variables
217 /// Current processing step.
218 static QString s_processingStep;
220 /// Last progress percent.
221 static int s_processingLastPercent;
224 #endif