(学习笔记,错误难免,请指正;私人劳动,转载请注明出处)
事件被mitk::Dispathcer接收后,又被分发给一个mitk::DataInteractor,由它决定是否能够处理该事件。在高层上讲,这由mitk::EventStateMachine完成。首先,该状态机会问所收事件是否在configuration里。如果在,返回variant name。然后状态机检查目前状态下是否存在能够被该 event variant触发的transition。这些条件都满足后,与该transition相关的所有行为都会被查询和执行。这些行为则运行在mitk::DataInteractor层。整个过程如下图所示:
每个mitk::BaseRender创建一个mitk::BindDispatcherInteractor(封装了mitk::DataStorage和mitk::Dispatcher之间的联系)对象,因此允许 mitk::DataInteractor在只知道mitk::DataNode的情况下向mitk::Dispatcher登记。
mitk::BindDispatcherInteractor为mitk::DataNode在mitk::DataStorage里创建一个新的mitk::Dispatcher对象和注册器。AddDataInteractor()和RemoveDataInteractor() 是谁的?
这样,只要是在mitk::BaseRenderer里显示的DataNodes,所有变化都能通知到mitk::Dispatcher。当一个node增加、删除或被修改时,mitk::Dispatcher会检查mitk::DataInterator是否已被设置,以便从internal list中增加或删除这个mitk::DataInterator
mitk::BaseRenderer范围内生成的事件会送到相对应的mitk::Dispatcher进行分发。
Event Distribution
一个mitk::Dispatcher可以有不同的,处理模式(决定如何选择接收到事件的interactor)。这些模式的设置和管理由 mitk::Dispatcher自己完成。
Regular:
DataInteractors据其自己的layer排序,事件的分发从排头开始。Connected Mouse Action:
A connected mouse action由 Mouse-Press, (optionally) Mouse-Move , Mouse-ReleaseEvents的队列描述。这个队列中,所有事件都被送到同一个mitk::DataInteractor—— 从Mouse-Pressaction接收事件的家伙.m_ConnectedMouseAction
当Mouse-Down Event
发生时,设为真。一个DataInterator接受该事件,然后m_SelectedInteractor赋给这个。DataInteractor.m_ConnectedMouseAction is reset to false, after the Mouse-Release
Event occurs, while it is true, the m_SelectedInteractor is the only
one that receives Mouse-Events.Grab Input: Whenever a mitk::DataInteractor performs a state change
into a state that is marked by the grab input-tag, the
mitk::Dispatcher switches into this mode. As long as it is in this
mode ONLY the selected mitk::DataInteractor will receive the event.
This mode is ended when the mitk::DataInteractor switches back to a
state without a tag/ or the REGULAR-tag.