manages a list of BaseRenderer. More...
#include <mitkFocusManager.h>
Public Types | |
typedef mitk::BaseRenderer | FocusElement |
Element, that can be focused and held here. | |
typedef itk::WeakPointer < FocusElement > | FocusElementWeakPointer |
typedef std::vector < FocusElementWeakPointer > | FocusElementList |
typedef std::vector < FocusElementWeakPointer > ::iterator | FocusListIterator |
Public Member Functions | |
mitkClassMacro (FocusManager, itk::Object) | |
~FocusManager () | |
bool | AddElement (FocusElement *element) |
bool | RemoveElement (FocusElement *element) |
FocusElement * | GetFocused () const |
bool | SetFocused (FocusElement *element) |
bool | IsLast () |
bool | IsFirst () |
const FocusElement * | GetFirst () const |
const FocusElement * | GetLast () const |
bool | GoToNext () |
FocusListIterator | GetIter () |
void | SetLoop (bool loop) |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
FocusManager () | |
Friends | |
class | GlobalInteraction |
manages a list of BaseRenderer.
A focuspointer can be set and read. GoToNext can be used to switch through the list. if the switch m_Loop is set to true, GetNext loops through the list; after the last it goes to the first. if it is not set, it returnes NULL if it steps behind the last Widget.
Definition at line 38 of file mitkFocusManager.h.
Element, that can be focused and held here.
has to be an itk-Objekct in order to use itk-Smartpointer!
Definition at line 42 of file mitkFocusManager.h.
typedef std::vector<FocusElementWeakPointer> mitk::FocusManager::FocusElementList |
Definition at line 52 of file mitkFocusManager.h.
typedef itk::WeakPointer<FocusElement> mitk::FocusManager::FocusElementWeakPointer |
Definition at line 50 of file mitkFocusManager.h.
typedef std::vector<FocusElementWeakPointer>::iterator mitk::FocusManager::FocusListIterator |
Definition at line 54 of file mitkFocusManager.h.
mitk::FocusManager::~FocusManager | ( | ) |
mitk::FocusManager::FocusManager | ( | ) | [protected] |
Constructor
Definition at line 21 of file mitkFocusManager.cpp.
{ m_Loop = true;//default m_FocusList.clear(); m_FocElement = NULL; }
bool mitk::FocusManager::AddElement | ( | FocusElement * | element ) |
Adds the widget into the set of managed Widgets after the focused widget and sets the focus to the added one if the list was empty before
Definition at line 32 of file mitkFocusManager.cpp.
{ // Try find mitk::FocusManager::FocusListIterator position = std::find(m_FocusList.begin(),m_FocusList.end(),element); if (position != m_FocusList.end()) return false; m_FocusList.push_back(element); if (m_FocElement.GetPointer() == NULL) m_FocElement = element; return true; }
const mitk::FocusManager::FocusElement * mitk::FocusManager::GetFirst | ( | ) | const |
returns the first widget in list
Definition at line 99 of file mitkFocusManager.cpp.
{
return (m_FocusList.front()).GetPointer();
}
mitk::FocusManager::FocusElement * mitk::FocusManager::GetFocused | ( | ) | const |
returns the focused Widget
Definition at line 71 of file mitkFocusManager.cpp.
Referenced by QmitkViewInitializationView::UpdateRendererList().
{
return m_FocElement.GetPointer();
}
mitk::FocusManager::FocusListIterator mitk::FocusManager::GetIter | ( | ) |
returns an iterator, that points to the beginning of the list no changes are made to the current focused element
returns an iterator, that points to the beginning of the list
Definition at line 138 of file mitkFocusManager.cpp.
{
return m_FocusList.begin();
}
const mitk::FocusManager::FocusElement * mitk::FocusManager::GetLast | ( | ) | const |
returns the last widget in list
Definition at line 104 of file mitkFocusManager.cpp.
{
return (m_FocusList.back()).GetPointer();
}
bool mitk::FocusManager::GoToNext | ( | ) |
sets the focus to the next in list loops the list, if switch loop is true returns true if successful, else false
Definition at line 109 of file mitkFocusManager.cpp.
{ //find the m_FocElement FocusListIterator position = std::find(m_FocusList.begin(),m_FocusList.end(),m_FocElement); if (position == m_FocusList.end())//not found return false; else if (*position == m_FocusList.back())//last in row { if (m_Loop) { m_FocElement = *(m_FocusList.begin()); return true; } else { return false;//last in row and loop == false, so GoToNext == false } } else //not last in row { m_FocElement = *(++position);//increase position and set m_FocElement return true; } return false; }
bool mitk::FocusManager::IsFirst | ( | ) |
returns true, if the focused widget is the first in the list
Definition at line 94 of file mitkFocusManager.cpp.
{
return (m_FocElement == m_FocusList.front());
}
bool mitk::FocusManager::IsLast | ( | ) |
returns, if this focused widget points behind the end of the List
Definition at line 89 of file mitkFocusManager.cpp.
{
return (m_FocElement == m_FocusList.back());
}
mitk::FocusManager::mitkClassMacro | ( | FocusManager | , |
itk::Object | |||
) |
static Pointer mitk::FocusManager::New | ( | ) | [static] |
Referenced by mitk::GlobalInteraction::Initialize(), and mitkFocusManagerTest().
bool mitk::FocusManager::RemoveElement | ( | FocusElement * | element ) |
removes the given widget from the list. true if found and removed, else false afterwards the focused widget is the one behind the deleted or if the deleted was the last, then the one before the deleted that way you can delete sequentialy from the back on or from front to back
Definition at line 45 of file mitkFocusManager.cpp.
{ // Try find mitk::FocusManager::FocusListIterator position = std::find(m_FocusList.begin(),m_FocusList.end(),element); if (position == m_FocusList.end()) return false; position = m_FocusList.erase(position); // first delete the one on the position, and store the one afterewards into position if ( m_FocusList.size() == 0 ) { // no more FocusElements available m_FocElement = NULL; } else if ( position == m_FocusList.end() ) { // deleted was the last in row, then take the one before m_FocElement = m_FocusList.back(); } else { // m_FocElement is equal to the next one in row m_FocElement = *position; } return true; }
bool mitk::FocusManager::SetFocused | ( | FocusElement * | element ) |
searches the given Widget in List; if found, sets the focus to this widget and returns true
Definition at line 76 of file mitkFocusManager.cpp.
{ if (m_FocElement == element) return true; FocusListIterator position = std::find(m_FocusList.begin(),m_FocusList.end(),element); if (position == m_FocusList.end())//not found return false; m_FocElement = *position; ((const itk::Object*)this)->InvokeEvent(FocusEvent()); return true; }
void mitk::FocusManager::SetLoop | ( | bool | loop ) |
Sets the LoopMode. if set to true-> the one after the last is the first
Definition at line 143 of file mitkFocusManager.cpp.
{ m_Loop = loop; }
friend class GlobalInteraction [friend] |
Definition at line 115 of file mitkFocusManager.h.