20 #include "igtlImageMessage.h"
21 #include "igtlTransformMessage.h"
22 #include "igtlPositionMessage.h"
23 #include "igtlStatusMessage.h"
24 #include "igtlImageMetaMessage.h"
25 #include "igtlPointMessage.h"
26 #include "igtlTrajectoryMessage.h"
27 #include "igtlStringMessage.h"
28 #include "igtlSensorMessage.h"
29 #include "igtlBindMessage.h"
30 #include "igtlPolyDataMessage.h"
31 #include "igtlQuaternionTrackingDataMessage.h"
32 #include "igtlCapabilityMessage.h"
33 #include "igtlNDArrayMessage.h"
34 #include "igtlTrackingDataMessage.h"
35 #include "igtlColorTableMessage.h"
36 #include "igtlLabelMetaMessage.h"
43 #include "itksys/SystemTools.hxx"
65 bool copySuccess =
false;
71 igtl::TransformMessage* original = (igtl::TransformMessage*)original_;
74 copySuccess = clone_->Copy(original);
82 original->GetMatrix(mat);
83 clone_->SetMatrix(mat);
87 original->GetNormals(normals);
88 clone_->SetNormals(normals);
92 original->GetPosition(position);
93 clone_->SetPosition(position);
172 this->AddMessageNewMethod(messageTypeName, messageTypeNewPointer);
173 this->AddMessageCloneHandler(messageTypeName, cloneHandler);
179 this->m_NewMethods[messageTypeName] = messageTypeNewPointer;
185 this->m_CloneHandlers[msgTypeName] = cloneHandler;
191 if (this->m_CloneHandlers.find(messageTypeName) !=
192 this->m_CloneHandlers.end())
194 return m_CloneHandlers[messageTypeName];
197 MITK_ERROR(
"IGTLMessageFactory") << messageTypeName <<
198 " message type is not registered to factory!";
200 mitkThrow() << messageTypeName <<
" message type is not registered to factory!";
208 return this->GetCloneHandler(msg->GetDeviceType())->
Clone(msg);
214 if (this->m_NewMethods.find(messageTypeName) != this->m_NewMethods.end())
216 return m_NewMethods[messageTypeName];
219 MITK_ERROR(
"IGTLMessageFactory") << messageTypeName <<
220 " message type is not registered to factory!";
228 this->GetMessageTypeNewPointer(messageTypeName);
229 if (newPointer !=
nullptr)
239 std::list<std::string>
242 std::list<std::string> allGetMessages;
243 for (std::map<std::string, PointerToMessageBaseNew>::const_iterator it =
244 this->m_NewMethods.begin();
245 it != this->m_NewMethods.end(); ++it)
247 if (it->first.find(
"GET_") != std::string::npos ||
248 it->first.find(
"STT_") != std::string::npos ||
249 it->first.find(
"STP_") != std::string::npos ||
250 it->first.find(
"RTS_") != std::string::npos)
252 allGetMessages.push_back(it->first);
256 return allGetMessages;
262 std::string messageType;
265 if (msgHeader.IsNull())
267 messageType =
"NONE";
271 messageType = msgHeader->GetDeviceType();
275 messageType = itksys::SystemTools::UpperCase(messageType);
278 if (this->m_NewMethods.find(messageType)
279 != this->m_NewMethods.end())
281 if (this->m_NewMethods[messageType] !=
nullptr)
284 return (*this->m_NewMethods[messageType])();
291 MITK_ERROR(
"IGTLMessageFactory") <<
"Unknown IGT message type: "
virtual IGTLMessageFactory::PointerToMessageBaseNew GetMessageTypeNewPointer(std::string messageTypeName)
Get pointer to message type new function, or NULL if the message type not registered Usage: igtl::Mes...
std::list< std::string > GetAvailableMessageRequestTypes()
Returns available get messages.
itk::SmartPointer< Self > Pointer
igtl::MessageBase::Pointer CreateInstance(std::string messageTypeName)
Creates a new message instance fitting to the given type.
void AddMessageType(std::string messageTypeName, IGTLMessageFactory::PointerToMessageBaseNew messageTypeNewPointer, mitk::IGTLMessageCloneHandler::Pointer cloneHandler)
Add message type name and pointer to IGTL message new function and the clone handler.
#define mitkIGTMessageCloneClassMacro(messagetype, classname)
virtual void AddMessageNewMethod(std::string messageTypeName, IGTLMessageFactory::PointerToMessageBaseNew messageTypeNewPointer)
Add message type name and pointer to IGTL message new function Usage: AddMessageType("IMAGE", (PointerToMessageBaseNew)&igtl::ImageMessage::New);.
virtual void AddMessageCloneHandler(std::string msgTypeName, mitk::IGTLMessageCloneHandler::Pointer msgCloneHandler)
Adds a clone function for the specified message type.
virtual ~IGTLMessageFactory()
igtl::MessageBase::Pointer(* PointerToMessageBaseNew)()
Function pointer for storing New() static methods of igtl::MessageBase classes.
virtual mitk::IGTLMessageCloneHandler::Pointer GetCloneHandler(std::string messageTypeName)
Get pointer to message type clone function, or NULL if the message type is not registered Usage: igtl...
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.