| 97 | } |
| 98 | |
| 99 | void mitk::ToolManager::InitializeTools() |
| 100 | { |
| 101 | // clear all previous tool pointers (tools may be still activated from another recently used plugin) |
| 102 | if (m_ActiveTool) |
| 103 | { |
| 104 | m_ActiveTool->Deactivated(); |
| 105 | m_ActiveToolRegistration.Unregister(); |
| 106 | |
| 107 | m_ActiveTool = nullptr; |
| 108 | m_ActiveToolID = -1; // no tool active |
| 109 | |
| 110 | ActiveToolChanged.Send(); |
| 111 | } |
| 112 | m_Tools.clear(); |
| 113 | // get a list of all known mitk::Tools |
| 114 | std::list<itk::LightObject::Pointer> thingsThatClaimToBeATool = itk::ObjectFactoryBase::CreateAllInstance("mitkTool"); |
| 115 | |
| 116 | // remember these tools |
| 117 | for (auto iter = thingsThatClaimToBeATool.begin(); |
| 118 | iter != thingsThatClaimToBeATool.end(); |
| 119 | ++iter) |
| 120 | { |
| 121 | if (auto *tool = dynamic_cast<Tool *>(iter->GetPointer())) |
| 122 | { |
| 123 | if (!tool->IsEligibleForAutoInit()) |
| 124 | continue; |
| 125 | |
| 126 | tool->InitializeStateMachine(); |
| 127 | tool->SetToolManager(this); // important to call right after instantiation |
| 128 | tool->ErrorMessage += MessageDelegate1<mitk::ToolManager, std::string>(this, &ToolManager::OnToolErrorMessage); |
| 129 | tool->GeneralMessage += |
| 130 | MessageDelegate1<mitk::ToolManager, std::string>(this, &ToolManager::OnGeneralToolMessage); |
| 131 | m_Tools.push_back(tool); |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | void mitk::ToolManager::OnToolErrorMessage(std::string s) |
| 137 | { |