CustusX  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_ */
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
igtlioLogicPointer mLogic
boost::shared_ptr< class NetworkHandler > NetworkHandlerPtr
vtkImageDataPtr mUSMask
igtlioSessionPointer mSession
ProbeDefinitionFromStringMessagesPtr mProbeDefinitionFromStringMessages
boost::shared_ptr< class ProbeDefinitionFromStringMessages > ProbeDefinitionFromStringMessagesPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
boost::shared_ptr< class ProbeDefinition > ProbeDefinitionPtr
ProbeDefinitionPtr mProbeDefinition
Namespace for all CustusX production code.