NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxNetworkHandler.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CX_NETWORKHANDLER_H_
13 #define CX_NETWORKHANDLER_H_
14 
15 #include "org_custusx_core_openigtlink3_Export.h"
16 #include "igtlioLogic.h"
17 #include "igtlioSession.h"
18 
19 #include "cxTransform3D.h"
20 #include "cxImage.h"
21 #include "cxMesh.h"
23 
24 #include "ctkVTKObject.h"
25 
26 namespace cx
27 {
28 
29 typedef boost::shared_ptr<class NetworkHandler> NetworkHandlerPtr;
30 
31 class org_custusx_core_openigtlink3_EXPORT NetworkHandler : public QObject
32 {
33  Q_OBJECT
34  QVTK_OBJECT
35 
36 public:
37  NetworkHandler(igtlioLogicPointer logic);
38  ~NetworkHandler();
39 
40  igtlioSessionPointer requestConnectToServer(std::string serverHost, int serverPort=-1, IGTLIO_SYNCHRONIZATION_TYPE sync=IGTLIO_BLOCKING, double timeout_s=5);
41  void disconnectFromServer();
42 
43  void clearTimestampSynchronization();
44 
45 signals:
46  void connected();
47  void disconnected();
48 
49  void transform(QString devicename, Transform3D transform, double timestamp);
50  void image(ImagePtr image);
51  void commandRespons(QString devicename, QString xml);
52  void string_message(QString message);
53  //void mesh(MeshPtr image);
54  void probedefinition(QString devicename, ProbeDefinitionPtr definition);
55  //void calibration(QString devicename, Transform3D calibration);
56 
57 private slots:
58  void onConnectionEvent(vtkObject* caller, void* connector, unsigned long event, void*);
59  void onDeviceAddedOrRemoved(vtkObject* caller, void* connector, unsigned long event, void*callData);
60  void onDeviceReceived(vtkObject * caller_device, void * unknown, unsigned long event, void *);
61  void periodicProcess();
62 
63 protected:
64  void connectToConnectionEvents();
65  void connectToDeviceEvents();
66  void processImageAndEmitProbeDefinition(ImagePtr cximage, QString deviceName);
67  bool emitProbeDefinitionIfChanged(QString deviceName);
68  bool convertZeroesInsideSectorToOnes(ImagePtr cximage, int threshold = 0, int newValue = 1);
69  bool createMask();
70  double synchronizedTimestamp(double receivedTimestampSec);
71  bool verifyTimestamp(double &timestampMS);
72 
73  igtlioLogicPointer mLogic;
74  igtlioSessionPointer mSession;
75  QTimer *mTimer;
77 
81 
86 };
87 
88 } // namespace cx
89 
90 #endif /* CX_NETWORKHANDLER_H_ */
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxImage.h
cx::NetworkHandler::mTimer
QTimer * mTimer
Definition: cxNetworkHandler.h:75
cx::NetworkHandler::mSession
igtlioSessionPointer mSession
Definition: cxNetworkHandler.h:74
cx::NetworkHandler::mZeroesInImage
bool mZeroesInImage
Definition: cxNetworkHandler.h:83
cx::NetworkHandler::mGotMoreThanOneImage
bool mGotMoreThanOneImage
Definition: cxNetworkHandler.h:79
cx::NetworkHandler::mProbeDefinition
ProbeDefinitionPtr mProbeDefinition
Definition: cxNetworkHandler.h:82
cx::NetworkHandler::mProbeDefinitionFromStringMessages
ProbeDefinitionFromStringMessagesPtr mProbeDefinitionFromStringMessages
Definition: cxNetworkHandler.h:76
vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxVideoConnectionWidget.h:30
cx::ProbeDefinitionFromStringMessagesPtr
boost::shared_ptr< class ProbeDefinitionFromStringMessages > ProbeDefinitionFromStringMessagesPtr
Definition: cxProbeDefinitionFromStringMessages.h:26
cx::ProbeDefinitionPtr
boost::shared_ptr< class ProbeDefinition > ProbeDefinitionPtr
Definition: cxImageReceiverThread.h:32
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxProbeDefinitionFromStringMessages.h
cx::NetworkHandler
Definition: cxNetworkHandler.h:31
cx::NetworkHandler::mLogic
igtlioLogicPointer mLogic
Definition: cxNetworkHandler.h:73
cx::ImagePtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
cx::NetworkHandler::mUSMask
vtkImageDataPtr mUSMask
Definition: cxNetworkHandler.h:84
cx::NetworkHandler::mGotTimeOffset
bool mGotTimeOffset
Definition: cxNetworkHandler.h:78
cx::NetworkHandler::mTimestampOffsetMS
double mTimestampOffsetMS
Definition: cxNetworkHandler.h:80
cx::transform
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
Definition: cxTransform3D.cpp:150
cxTransform3D.h
cx::NetworkHandler::mSkippedImages
int mSkippedImages
Definition: cxNetworkHandler.h:85
cxMesh.h
cx::NetworkHandlerPtr
boost::shared_ptr< class NetworkHandler > NetworkHandlerPtr
Definition: cxNetworkHandler.h:29