Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkUSIGTLDevice.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY{} without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include <mitkUSIGTLDevice.h>
18 
19 mitk::USIGTLDevice::USIGTLDevice(std::string manufacturer, std::string model,
20  std::string host, int port, bool server)
21  : mitk::USDevice(manufacturer, model), m_Host(host), m_Port(port)
22 {
23  if (server)
24  {
25  m_Device = mitk::IGTLServer::New(true);
26  }
27  else
28  {
29  m_Device = mitk::IGTLClient::New(true);
30  }
31  m_Device->SetPortNumber(m_Port);
32  m_Device->SetHostname(m_Host);
33  m_Device->SetName(manufacturer + " - " + model);
34 
35  m_TransformDeviceSource = mitk::IGTLTransformDeviceSource::New();
36  m_TransformDeviceSource->SetIGTLDevice(m_Device);
37  m_TransformDeviceSource->RegisterAsMicroservice();
38 
39  m_DeviceSource = mitk::IGTL2DImageDeviceSource::New();
40  m_DeviceSource->SetIGTLDevice(m_Device);
41  m_DeviceSource->RegisterAsMicroservice();
42 
44  m_Filter->SetNumberOfExpectedOutputs(1);
45  m_Filter->ConnectTo(m_DeviceSource);
46 }
47 
48 std::string mitk::USIGTLDevice::GetDeviceClass() { return "IGTL Client"; }
49 
51 {
52  return m_Filter.GetPointer();
53 }
54 
55 bool mitk::USIGTLDevice::OnInitialization() { return true; }
56 
57 bool mitk::USIGTLDevice::OnConnection() { return m_Device->OpenConnection(); }
58 
60 {
61  return m_Device->CloseConnection();
62 }
63 
65 {
66  return m_Device->StartCommunication();
67 }
68 
70 {
71  return m_Device->StopCommunication();
72 }
A device holds information about it's model, make and the connected probes. It is the common super cl...
Definition: mitkUSDevice.h:77
itk::SmartPointer< Self > Pointer
virtual bool OnActivation()
Is called during the activation process. After this method is finished, the device should be generati...
virtual bool OnInitialization()
Is called during the initialization process. Override this method in a subclass to handle the actual ...
DataCollection - Class to facilitate loading/accessing structured data.
virtual bool OnDisconnection()
Is called during the disconnection process. Override this method in a subclass to handle the actual d...
USIGTLDevice(std::string manufacturer, std::string model, std::string host, int port, bool server)
virtual std::string GetDeviceClass()
Returns the Class of the Device. This Method must be reimplemented by every Inheriting Class...
virtual bool OnConnection()
Is called during the connection process. Override this method in a subclass to handle the actual conn...
virtual bool OnDeactivation()
Is called during the deactivation process. After a call to this method the device should still be con...
virtual USImageSource::Pointer GetUSImageSource()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.