Orfeo Toolbox  3.16
otbImageWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbImageWidget_h
19 #define __otbImageWidget_h
20 
21 #include "otbGlWidget.h"
22 
23 // This is included for the default template
24 #include "otbImage.h"
25 #include "itkRGBAPixel.h"
26 #include "itkFixedArray.h"
27 #include "otbGlComponent.h"
28 #include "otbObjectList.h"
29 
30 namespace otb
31 {
42 template <class TInputImage = otb::Image<itk::RGBAPixel<unsigned char>, 2> >
44  : public GlWidget
45 {
46 public:
48  typedef ImageWidget Self;
52 
54  itkNewMacro(Self);
55 
57  itkTypeMacro(ImageWidget, GlWidget);
59  typedef TInputImage InputImageType;
61  typedef typename InputImageType::RegionType RegionType;
63  typedef typename RegionType::SizeType SizeType;
64  typedef typename RegionType::IndexType IndexType;
65 
77 
86  virtual void ReadBuffer(const InputImageType * image, const RegionType& region);
87 
89  void ClearBuffer();
90 
92  itkSetMacro(IsotropicZoom, double);
93  itkGetMacro(IsotropicZoom, double);
94 
97  {
98  m_InterpolationMethod = GL_LINEAR;
99  this->Modified();
100  }
101 
103  {
104  m_InterpolationMethod = GL_NEAREST;
105  this->Modified();
106  }
107 
109  itkSetMacro(SubsamplingRate, unsigned int);
110  itkGetMacro(SubsamplingRate, unsigned int);
111 
113  itkGetObjectMacro(ImageToScreenTransform, AffineTransformType);
114  itkGetObjectMacro(ScreenToImageTransform, AffineTransformType);
115 
117  itkGetConstMacro(OpenGlBuffer, unsigned char *);
118 
120  itkGetMacro(OpenGlBufferedRegion, RegionType);
121 
123  itkGetMacro(Extent, RegionType);
124 
126  unsigned int AddGlComponent(GlComponent * glComponent)
127  {
128  m_GlComponents->PushBack(glComponent);
129  return m_GlComponents->Size() - 1;
130  }
131 
133  GlComponent * GetNthGlComponent(unsigned int index)
134  {
135  return m_GlComponents->GetNthElement(index);
136  }
137 
139  void RemoveGlComponent(unsigned int index)
140  {
141  m_GlComponents->Erase(index);
142  }
143 
146  {
147  m_GlComponents->Clear();
148  }
149 
151  unsigned int GetNumberOfGlComponents()
152  {
153  return m_GlComponents->Size();
154  }
155 
156 protected:
158  ImageWidget();
160  virtual ~ImageWidget();
162  void PrintSelf(std::ostream& os, itk::Indent indent) const;
163 
169  void UpdateTransforms();
170 
171  virtual void draw(void);
172 
178  static inline unsigned int ComputeBufferIndex(const IndexType& index, const RegionType& region)
179  {
180  return (index[1] - region.GetIndex()[1]) * 3 * region.GetSize()[0] + 3 * (index[0] - region.GetIndex()[0]);
181  }
182 
189  static inline unsigned int ComputeXAxisFlippedBufferIndex(const IndexType& index, const RegionType& region)
190  {
191  return (region.GetSize()[1] - 1 + region.GetIndex()[1] -
192  index[1]) * 3 * region.GetSize()[0] + 3 * (index[0] - region.GetIndex()[0]);
193  }
194 
195 private:
196  ImageWidget(const Self&); // purposely not implemented
197  void operator =(const Self&); // purposely not implemented
198 
201 
204 
206  unsigned char * m_OpenGlBuffer;
207 
210 
213 
216  unsigned int m_SubsamplingRate;
217 
221 
224 
225 }; // end class
226 } // end namespace otb
227 
228 #ifndef OTB_MANUAL_INSTANTIATION
229 #include "otbImageWidget.txx"
230 #endif
231 
232 #endif

Generated at Sun Feb 3 2013 00:31:20 for Orfeo Toolbox with doxygen 1.8.1.1