Orfeo Toolbox  3.16
otbPixelDescriptionActionHandler.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 __otbPixelDescriptionActionHandler_h
19 #define __otbPixelDescriptionActionHandler_h
20 
22 
23 namespace otb
24 {
33 template <class TModel, class TView>
36 {
37 public:
43 
45  itkNewMacro(Self);
46 
49 
51  typedef TModel ModelType;
52  typedef typename ModelType::Pointer ModelPointerType;
53  typedef typename ModelType::IndexType IndexType;
54 
56  typedef TView ViewType;
57  typedef typename ViewType::Pointer ViewPointerType;
58  typedef typename ViewType::OffsetType OffsetType;
59  typedef typename ViewType::ImageWidgetPointerType WidgetPointerType;
60 
63  virtual bool HandleWidgetEvent(const std::string& widgetId, int event)
64  {
65  if (m_Model.IsNotNull() && m_View.IsNotNull() && this->GetIsActive())
66  {
67  // Find the source widget
68  WidgetPointerType sourceWidget;
69  bool handle = false;
70  if (widgetId == m_View->GetScrollWidget()->GetIdentifier())
71  {
72  sourceWidget = m_View->GetScrollWidget();
73  handle = true;
74  }
75  else if (widgetId == m_View->GetFullWidget()->GetIdentifier())
76  {
77  sourceWidget = m_View->GetFullWidget();
78  handle = true;
79  }
80  else if (widgetId == m_View->GetZoomWidget()->GetIdentifier())
81  {
82  sourceWidget = m_View->GetZoomWidget();
83  handle = true;
84  }
85  if (handle)
86  {
87  switch (event)
88  {
89  case FL_ENTER:
90  {
91  return true;
92  break;
93  }
94  case FL_LEAVE:
95  {
96  return true;
97  break;
98  }
99  case FL_MOVE:
100  {
101  // Get the clicked index
102  typename ViewType::ImageWidgetType::PointType screenPoint, imagePoint;
103  screenPoint = sourceWidget->GetMousePosition();
104 
105  // Transform to image point
106  imagePoint = sourceWidget->GetScreenToImageTransform()->TransformPoint(screenPoint);
107 
108  // Transform to index
109  typename ViewType::IndexType index;
110  index[0] = static_cast<int>(imagePoint[0]);
111  index[1] = static_cast<int>(imagePoint[1]);
112 
113  //Add the offset
114  index += m_Offset;
115 
116  // Communicate new index to model
117  m_Model->UpdatePixelDescription(index, m_UsePlaceName);
118 
119  return true;
120  break;
121  }
122  default:
123  {
124  break;
125  }
126  }
127  }
128  }
129  return false;
130  }
131 
133  itkSetObjectMacro(Model, ModelType);
134  itkGetObjectMacro(Model, ModelType);
135 
137  itkSetObjectMacro(View, ViewType);
138  itkGetObjectMacro(View, ViewType);
139 
141  itkSetMacro(Offset, OffsetType);
142  itkGetMacro(Offset, OffsetType);
143 
145  itkSetMacro(UsePlaceName, bool);
146  itkGetMacro(UsePlaceName, bool);
147 
148 protected:
151  m_UsePlaceName(true)
152  {
153  m_Offset.Fill(0);
154  }
155 
159  void PrintSelf(std::ostream& os, itk::Indent indent) const
160  {
161  Superclass::PrintSelf(os, indent);
162  }
163 
164 private:
165  PixelDescriptionActionHandler(const Self&); // purposely not implemented
166  void operator =(const Self&); // purposely not implemented
167 
168  //Offset
170 
171  // Pointer to the view
173 
174  // Pointer to the model
176 
177  // Flag to get the placename
179 
180 }; // end class
181 } // end namespace otb
182 #endif

Generated at Sun Feb 3 2013 00:41:45 for Orfeo Toolbox with doxygen 1.8.1.1