35 std::string specificRenderer =
"(rendererName=" + rendererName +
")";
39 std::string anyRenderer =
"(!(rendererName=*))";
42 std::string classInteractionEventObserver =
47 us::LDAPFilter filter(
"(&(|" + specificRenderer + anyRenderer +
")" + classInteractionEventObserver +
")");
51 m_EventObserverTracker->Open();
56 RemoveDataInteractor(dataNode);
57 RemoveOrphanedInteractors();
61 if (dataInteractor !=
nullptr)
62 m_Interactors.push_back(dataInteractor);
75 for (ListInteractorType::iterator it = m_Interactors.begin(); it != m_Interactors.end();)
77 if ((*it).IsNull() || (*it)->GetDataNode() ==
nullptr || (*it)->GetDataNode() == dataNode)
79 it = m_Interactors.erase(it);
90 return m_Interactors.size();
95 m_EventObserverTracker->Close();
96 delete m_EventObserverTracker;
98 m_Interactors.clear();
104 bool eventIsHandled =
false;
107 if (internalEvent !=
nullptr)
109 eventIsHandled = HandleInternalEvent(internalEvent);
116 switch (m_ProcessingMode)
118 case CONNECTEDMOUSEACTION:
120 if (std::strcmp(p->GetNameOfClass(),
"MouseReleaseEvent") == 0)
122 m_ProcessingMode = REGULAR;
124 if (m_SelectedInteractor.IsNotNull())
125 eventIsHandled = m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode());
127 m_SelectedInteractor =
nullptr;
130 if (eventIsHandled ==
false && m_SelectedInteractor.IsNotNull())
131 eventIsHandled = m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode());
136 if (m_SelectedInteractor.IsNotNull())
138 eventIsHandled = m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode());
139 SetEventProcessingMode(m_SelectedInteractor);
145 if (m_SelectedInteractor.IsNotNull() &&
146 m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode()) ==
true)
148 SetEventProcessingMode(m_SelectedInteractor);
149 eventIsHandled =
true;
159 if (m_ProcessingMode == REGULAR || (m_ProcessingMode == PREFERINPUT && eventIsHandled ==
false))
161 if (std::strcmp(p->GetNameOfClass(),
"MousePressEvent") == 0)
163 m_Interactors.sort(cmp());
168 ListInteractorType::const_iterator it;
169 for (it = tmpInteractorList.cbegin(); it != tmpInteractorList.cend(); ++it)
171 if ((*it).IsNotNull() && (*it)->HandleEvent(event, (*it)->GetDataNode()))
174 if ((*it).IsNotNull())
178 SetEventProcessingMode(*it);
180 if (std::strcmp(p->GetNameOfClass(),
"MousePressEvent") == 0 && m_ProcessingMode == REGULAR)
182 m_SelectedInteractor = *it;
183 m_ProcessingMode = CONNECTEDMOUSEACTION;
185 eventIsHandled =
true;
192 const std::vector<us::ServiceReference<InteractionEventObserver>> listEventObserver =
193 m_EventObserverTracker->GetServiceReferences();
195 it != listEventObserver.cend();
199 if (interactionEventObserver !=
nullptr)
201 if (interactionEventObserver->
IsEnabled())
203 interactionEventObserver->
Notify(event, eventIsHandled);
209 if (!m_QueuedEvents.empty())
212 m_QueuedEvents.pop_front();
215 return eventIsHandled;
222 void mitk::Dispatcher::RemoveOrphanedInteractors()
224 for (ListInteractorType::iterator it = m_Interactors.begin(); it != m_Interactors.end();)
228 it = m_Interactors.erase(it);
236 it = m_Interactors.erase(it);
242 if (interactor != it->GetPointer())
244 it = m_Interactors.erase(it);
257 m_QueuedEvents.push_back(event);
260 void mitk::Dispatcher::SetEventProcessingMode(
DataInteractor *dataInteractor)
262 m_ProcessingMode = dataInteractor->
GetMode();
263 if (dataInteractor->
GetMode() != REGULAR)
265 m_SelectedInteractor = dataInteractor;
269 bool mitk::Dispatcher::HandleInternalEvent(InternalEvent *internalEvent)
272 internalEvent->GetTargetInteractor() !=
nullptr)
274 internalEvent->GetTargetInteractor()->GetDataNode()->SetDataInteractor(
nullptr);
275 internalEvent->GetTargetInteractor()->SetDataNode(
nullptr);
Base class to implement InteractionEventObservers.
BaseRenderer * GetSender() const
std::list< mitk::WeakPointer< DataInteractor > > ListInteractorType
virtual void Notify(InteractionEvent *interactionEvent, bool isHandled)=0
Class to create events from within the application to signal about internal events.
virtual DataInteractor::Pointer GetDataInteractor() const
bool ProcessEvent(InteractionEvent *event)
Base class from with interactors that handle DataNodes are to be derived.
itk::SmartPointer< Self > Pointer
vcl_size_t GetNumberOfInteractors()
static RenderingManager * GetInstance()
Dispatcher(const std::string &rendererName)
itk::SmartPointer< Self > Pointer
static const std::string IntDeactivateMe
ProcessEventMode GetMode() const
US_Core_EXPORT const std::string & OBJECTCLASS()
void AddDataInteractor(const DataNode *dataNode)
void QueueEvent(InteractionEvent *event)
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
void RemoveDataInteractor(const DataNode *dataNode)
Class for nodes of the DataTree.