Orfeo Toolbox  3.16
otbImageWidgetController.cxx
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 =========================================================================*/
19 #include "otbMacro.h"
20 
21 namespace otb
22 {
24 {
25  // Instantiate action handlers list
27 }
28 
30 {}
31 
33 {
34  // Add the handler to the list
35  m_ActionHandlersList->PushBack(handler);
36 }
37 
38 void ImageWidgetController::InsertActionHandler(const unsigned int id, ActionHandlerType * handler)
39 {
40  // Insert the handler to the specified index in the list
41  m_ActionHandlersList->Insert(m_ActionHandlersList->Begin()+id, handler);
42 }
43 
45 {
46  // Remove the given handler
47  m_ActionHandlersList->Erase(index);
48 }
49 
51 {
52  // Clear the handlers list
53  m_ActionHandlersList->Clear();
54 }
55 
56 int ImageWidgetController::HandleWidgetEvent(const std::string& widgetId, int event)
57 {
58  // Define an iterator on the action handlers list
60 
61  // Found indicates if a handler was found to respond to this event
62  bool found = false;
63 
64  // The action handler found
65  ActionHandlerType * handler;
66 
67  while (it != m_ActionHandlersList->End())
68  {
69  // Get the current handler
70  handler = it.Get();
71  // Check if it listens to (widget, event)
72  bool newFound = handler->HandleWidgetEvent(widgetId, event);
73  found = found || newFound;
74  ++it;
75  }
76  // If an handler was found, use it
77  if (found)
78  {
79  return 1;
80  }
81  else
82  {
83  return 0;
84  }
85 }
86 
87 void ImageWidgetController::HandleWidgetResize(const std::string& widgetId, int w, int h)
88 {
89  // Define an iterator on the action handlers list
91 
92  // The action handler found
93  ActionHandlerType * handler;
94 
95  while (it != m_ActionHandlersList->End())
96  {
97  // Get the current handler
98  handler = it.Get();
99  // try to handle the event with the current handler
100  handler->HandleWidgetResize(widgetId, w, h);
101  ++it;
102  }
103 }
104 
105 void ImageWidgetController::HandleWidgetMove(const std::string& widgetId, int x, int y)
106 {
107  otbMsgDevMacro(<< "ImageWidgetController::HandleWidgetMove(): (" << widgetId << ", " << x << ", " << y << ")");
108  // Define an iterator on the action handlers list
110 
111  // The action handler found
112  ActionHandlerType * handler;
113 
114  while (it != m_ActionHandlersList->End())
115  {
116  // Get the current handler
117  handler = it.Get();
118  // Check if it listens to (widget, event)
119  handler->HandleWidgetMove(widgetId, x, y);
120  ++it;
121  }
122 }
123 
125 {
126 // otbMsgDevMacro(<<"ImageWidgetController::DectivateActionHandler(): ("<<widgetId<<")");
127 // Define an iterator on the action handlers list
129 
130  // The action handler found
131  ActionHandlerType * handler;
132 
133  while (it != m_ActionHandlersList->End())
134  {
135  // Get the current handler
136  handler = it.Get();
137  // Check if it listens to (widget, event)
138  handler->SetIsActive(true);
139  ++it;
140  }
141 }
142 
144 {
145 // otbMsgDevMacro(<<"ImageWidgetController::DectivateActionHandler(): ("<<widgetId<<")");
146 // Define an iterator on the action handlers list
148 
149  // The action handler found
150  ActionHandlerType * handler;
151 
152  while (it != m_ActionHandlersList->End())
153  {
154  // Get the current handler
155  handler = it.Get();
156  // Check if it listens to (widget, event)
157  handler->SetIsActive(false);
158  ++it;
159  }
160 }
161 
162 void ImageWidgetController::PrintSelf(std::ostream& os, itk::Indent indent) const
163 {
164  Superclass::PrintSelf(os, indent);
165  os << indent << "Number of action handlers: " << m_ActionHandlersList->Size() << std::endl;
166 }
167 
168 } // end namespace otb

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