Orfeo Toolbox  3.16
otbRegionGlComponent.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 __otbRegionGlComponent_h
19 #define __otbRegionGlComponent_h
20 
21 #include "otbGlComponent.h"
22 #include "itkImageRegion.h"
23 
24 namespace otb
25 {
32  : public GlComponent
33 {
34 public:
41 
42  // affine transform
47 
49  itkTypeMacro(RegionGlComponent, GlComponent);
50 
52  itkNewMacro(Self);
53 
55  virtual void Render(const RegionType& /*extent*/, const AffineTransformType * space2ScreenTransform)
56  {
57  PointType ip1, ip2, sp1, sp2;
58 
59  // Get the input region points
60  ip1[0] = m_Region.GetIndex()[0] + 1;
61  ip1[1] = m_Region.GetIndex()[1] + 1;
62  ip2[0] = m_Region.GetIndex()[0] + m_Region.GetSize()[0] - 1;
63  ip2[1] = m_Region.GetIndex()[1] + m_Region.GetSize()[1] - 1;
64 
65  // Convert to screen points
66  sp1 = space2ScreenTransform->TransformPoint(ip1);
67  sp2 = space2ScreenTransform->TransformPoint(ip2);
68 
69  // draw the box
70  glEnable(GL_BLEND);
71  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
72  glColor4d(m_Color[0], m_Color[1], m_Color[2], m_Color[3]);
73 
74  glBegin(GL_LINE_LOOP);
75  glVertex2d(sp1[0], sp1[1]);
76  glVertex2d(sp1[0], sp2[1]);
77  glVertex2d(sp2[0], sp2[1]);
78  glVertex2d(sp2[0], sp1[1]);
79  glEnd();
80 
81  glDisable(GL_BLEND);
82  }
83 
85  itkSetMacro(Region, RegionType);
86  itkGetConstReferenceMacro(Region, RegionType);
87 
89  itkSetMacro(Color, ColorType);
90  itkGetConstReferenceMacro(Color, ColorType);
91 
92 protected:
95  {
96  m_Color.Fill(0);
97  m_Color[0] = 1.;
98  m_Color[3] = 1.;
99  }
101  virtual ~RegionGlComponent(){}
103  void PrintSelf(std::ostream& os, itk::Indent indent) const
104  {
105  Superclass::PrintSelf(os, indent);
106  }
107 
108 private:
109  RegionGlComponent(const Self&); // purposely not implemented
110  void operator =(const Self&); // purposely not implemented
111 
112  // The region to render
114 
115  // The color of the region to render
117 
118 }; // end class
119 } // end namespace otb
120 
121 #endif

Generated at Sun Feb 3 2013 00:44:22 for Orfeo Toolbox with doxygen 1.8.1.1