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 ***************************************************************************/
25 * @brief A single abstract image channel.
28 #include "tcPixelData.h"
37 class tcChannelConfigWidget
;
38 class tcChannelManager
;
40 /// A single abstract image channel.
41 class tcChannel
: public QObject
48 * Constructors + destructor
51 /// Primary constructor.
52 tcChannel(const QString
& name
, const QString
& description
);
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
);
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;
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;
141 * Interface for derived classes
144 /** Invalidate this channel.
145 * For example if one of the inputs has changed.
155 /// Emitted to indicate progress of processing.
156 void progressing(const QString
& message
);
164 /// Start a processing step.
165 void startProcessing(const QString
& step
);
168 void progress(float progress
);
171 void progress(const QString
& info
);
173 /// End processing step.
174 void endProcessing();
183 tcChannelManager
* m_channelManager
;
185 /// Name of the channel.
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
;
205 /// Whether cross sectioned.
206 bool m_crossSectioned
;
208 /// Current cross section.
209 tcGeo m_crossSection
[2];
217 /// Current processing step.
218 static QString s_processingStep
;
220 /// Last progress percent.
221 static int s_processingLastPercent
;