ome-qtwidgets 5.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

TexelProperties.h
1 /*
2 * #%L
3 * OME-QTWIDGETS C++ library for display of OME-Files pixel data and metadata.
4 * Copyright © 2014 - 2015 Open Microscopy Environment:
5 * - Massachusetts Institute of Technology
6 * - National Institutes of Health
7 * - University of Dundee
8 * - Board of Regents of the University of Wisconsin-Madison
9 * - Glencoe Software, Inc.
10 * %%
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * The views and conclusions contained in the software and documentation are
33 * those of the authors and should not be interpreted as representing official
34 * policies, either expressed or implied, of any organization.
35 * #L%
36 */
37
38 #ifndef OME_QTWIDGETS_TEXELPROPERTIES_H
39 #define OME_QTWIDGETS_TEXELPROPERTIES_H
40
41 #include <ome/files/PixelProperties.h>
42
43 #include <ome/xml/model/enums/PixelType.h>
44
45 #include <QtGui/qopengl.h>
46
47 namespace ome
48 {
49 namespace qtwidgets
50 {
51
84 template<int>
85 struct TexelProperties;
86
88 template<>
89 struct TexelProperties< ::ome::xml::model::enums::PixelType::INT8> :
90 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::INT8>
91 {
93 static const GLenum internal_format = GL_R8;
95 static const GLenum external_format = GL_RED;
97 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::INT8;
99 static const GLint external_type = GL_BYTE;
101 static const bool conversion_required = false;
103 static const bool normalization_required = false;
105 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
107 static const GLint magnification_filter = GL_LINEAR;
108 };
109
111 template<>
112 struct TexelProperties< ::ome::xml::model::enums::PixelType::INT16> :
113 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::INT16>
114 {
116 static const GLenum internal_format = GL_R16;
118 static const GLenum external_format = GL_RED;
120 static const GLint external_type = GL_SHORT;
122 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::INT8;
124 static const bool conversion_required = false;
126 static const bool normalization_required = false;
128 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
130 static const GLint magnification_filter = GL_LINEAR;
131 };
132
134 template<>
135 struct TexelProperties< ::ome::xml::model::enums::PixelType::INT32> :
136 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::INT32>
137 {
139 static const GLenum internal_format = GL_R16;
141 static const GLenum external_format = GL_RED;
143 static const GLint external_type = GL_INT;
145 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::INT16;
147 static const bool conversion_required = false;
149 static const bool normalization_required = false;
151 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
153 static const GLint magnification_filter = GL_LINEAR;
154 };
155
157 template<>
158 struct TexelProperties< ::ome::xml::model::enums::PixelType::UINT8> :
159 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::UINT8>
160 {
162 static const GLenum internal_format = GL_R8;
164 static const GLenum external_format = GL_RED;
166 static const GLint external_type = GL_UNSIGNED_BYTE;
168 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::UINT8;
170 static const bool conversion_required = false;
172 static const bool normalization_required = false;
174 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
176 static const GLint magnification_filter = GL_LINEAR;
177 };
178
180 template<>
181 struct TexelProperties< ::ome::xml::model::enums::PixelType::UINT16> :
182 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::UINT16>
183 {
185 static const GLenum internal_format = GL_R16;
187 static const GLenum external_format = GL_RED;
189 static const GLint external_type = GL_UNSIGNED_SHORT;
191 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::UINT8;
193 static const bool conversion_required = false;
195 static const bool normalization_required = false;
197 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
199 static const GLint magnification_filter = GL_LINEAR;
200 };
201
203 template<>
204 struct TexelProperties< ::ome::xml::model::enums::PixelType::UINT32> :
205 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::UINT32>
206 {
208 static const GLenum internal_format = GL_R16;
210 static const GLenum external_format = GL_RED;
212 static const GLint external_type = GL_UNSIGNED_INT;
214 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::UINT16;
216 static const bool conversion_required = false;
218 static const bool normalization_required = false;
220 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
222 static const GLint magnification_filter = GL_LINEAR;
223 };
224
226 template<>
227 struct TexelProperties< ::ome::xml::model::enums::PixelType::FLOAT> :
228 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>
229 {
231 static const GLenum internal_format = GL_R32F;
233 static const GLenum external_format = GL_RED;
235 static const GLint external_type = GL_FLOAT;
237 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::INT32;
239 static const bool conversion_required = false;
241 static const bool normalization_required = true;
243 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
245 static const GLint magnification_filter = GL_LINEAR;
246 };
247
249 template<>
250 struct TexelProperties< ::ome::xml::model::enums::PixelType::DOUBLE> :
251 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE>
252 {
254 static const GLenum internal_format = GL_R32F;
256 static const GLenum external_format = GL_RED;
258 static const GLint external_type = GL_DOUBLE;
260 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::FLOAT;
262 static const bool conversion_required = false;
264 static const bool normalization_required = true;
266 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
268 static const GLint magnification_filter = GL_LINEAR;
269 };
270
272 template<>
273 struct TexelProperties< ::ome::xml::model::enums::PixelType::BIT> :
274 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::BIT>
275 {
277 static const GLenum internal_format = GL_R8;
279 static const GLenum external_format = GL_RED;
281 static const GLint external_type = GL_UNSIGNED_BYTE;
283 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::BIT;
285 static const bool conversion_required = true;
287 static const bool normalization_required = false;
289 static const GLint minification_filter = GL_NEAREST_MIPMAP_LINEAR;
291 static const GLint magnification_filter = GL_NEAREST;
292 };
293
295 template<>
296 struct TexelProperties< ::ome::xml::model::enums::PixelType::COMPLEX> :
297 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX>
298 {
300 static const GLenum internal_format = GL_RG32F;
302 static const GLenum external_format = GL_RG;
304 static const GLint external_type = GL_FLOAT;
306 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::COMPLEX;
308 static const bool conversion_required = false;
310 static const bool normalization_required = true;
312 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
314 static const GLint magnification_filter = GL_LINEAR;
315 };
316
318 template<>
319 struct TexelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX> :
320 public ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX>
321 {
323 static const GLenum internal_format = GL_RG32F;
325 static const GLenum external_format = GL_RG;
327 static const GLint external_type = GL_DOUBLE;
329 static const ::ome::xml::model::enums::PixelType::enum_value fallback_pixeltype = ome::xml::model::enums::PixelType::COMPLEX;
331 static const bool conversion_required = false;
333 static const bool normalization_required = true;
335 static const GLint minification_filter = GL_LINEAR_MIPMAP_LINEAR;
337 static const GLint magnification_filter = GL_LINEAR;
338 };
339
347 GLenum
348 textureInternalFormat(::ome::xml::model::enums::PixelType pixeltype);
349
360 GLenum
361 textureInternalFormatFallback(GLenum format);
362
370 GLenum
371 textureExternalFormat(::ome::xml::model::enums::PixelType pixeltype);
372
380 GLint
381 textureExternalType(::ome::xml::model::enums::PixelType pixeltype);
382
393 ::ome::xml::model::enums::PixelType
394 texturePixelTypeFallback(::ome::xml::model::enums::PixelType pixeltype);
395
405 bool
406 textureConversionRequired(::ome::xml::model::enums::PixelType pixeltype);
407
421 bool
422 textureNormalizationRequired(::ome::xml::model::enums::PixelType pixeltype);
423
430 GLint
431 textureMinificationFilter(::ome::xml::model::enums::PixelType pixeltype);
432
439 GLint
440 textureMagnificationFilter(::ome::xml::model::enums::PixelType pixeltype);
441
442 }
443 }
444
445 #endif // OME_QTWIDGETS_TEXELPROPERTIES_H
446
447 /*
448 * Local Variables:
449 * mode:C++
450 * End:
451 */
ome::xml::model::enums::PixelType::UINT32
UINT32
ome::xml::model::enums::PixelType::UINT8
UINT8
ome::xml::model::enums::PixelType::BIT
BIT
ome::qtwidgets::textureMagnificationFilter
GLint textureMagnificationFilter(::ome::xml::model::enums::PixelType pixeltype)
Get the default magnification filter.
Definition: TexelProperties.cpp:200
ome::xml::model::enums::PixelType::INT8
INT8
ome::files::PixelProperties
ome::qtwidgets::textureConversionRequired
bool textureConversionRequired(::ome::xml::model::enums::PixelType pixeltype)
Check if type conversion is required.
Definition: TexelProperties.cpp:141
ome::xml::model::enums::PixelType::INT16
INT16
ome::xml::model::enums::PixelType::UINT16
UINT16
ome::qtwidgets::textureExternalType
GLint textureExternalType(::ome::xml::model::enums::PixelType pixeltype)
Get the default external (GL) type of a PixelType.
Definition: TexelProperties.cpp:101
ome::xml::model::enums::PixelType::FLOAT
FLOAT
ome::qtwidgets::textureNormalizationRequired
bool textureNormalizationRequired(::ome::xml::model::enums::PixelType pixeltype)
Check if normalization is required.
Definition: TexelProperties.cpp:161
ome
ome::qtwidgets::textureInternalFormatFallback
GLenum textureInternalFormatFallback(GLenum format)
Get a fallback internal (GL) pixel format.
Definition: TexelProperties.cpp:218
ome::xml::model::enums::PixelType::COMPLEX
COMPLEX
ome::xml::model::enums::PixelType::DOUBLE
DOUBLE
ome::xml::model::enums::PixelType
ome::qtwidgets::textureMinificationFilter
GLint textureMinificationFilter(::ome::xml::model::enums::PixelType pixeltype)
Get the default minification filter.
Definition: TexelProperties.cpp:181
ome::qtwidgets::textureExternalFormat
GLenum textureExternalFormat(::ome::xml::model::enums::PixelType pixeltype)
Get the default external (GL) pixel format of a PixelType.
Definition: TexelProperties.cpp:81
ome::qtwidgets::textureInternalFormat
GLenum textureInternalFormat(::ome::xml::model::enums::PixelType pixeltype)
Get the default internal (GL) pixel format of a PixelType.
Definition: TexelProperties.cpp:61
ome::xml::model::enums::PixelType::INT32
INT32
ome::qtwidgets::TexelProperties
Map a given PixelType enum to the corresponding GL texel definitions.
Definition: TexelProperties.h:85
ome::xml::model::enums::PixelType::DOUBLECOMPLEX
DOUBLECOMPLEX
ome::qtwidgets::texturePixelTypeFallback
::ome::xml::model::enums::PixelType texturePixelTypeFallback(::ome::xml::model::enums::PixelType pixeltype)
Get a fallback pixel type.
Definition: TexelProperties.cpp:121