Fraxinus  18.10
An IGT application
cxGrabberSenderQTcpSocket.cpp
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 
13 #include "cxIGTLinkConversion.h"
16 
17 namespace cx
18 {
19 
21 {
22  mMaxBufferSize = 19200000; //800(width)*600(height)*4(bytes)*10(images)
23  mSocket = socket;
24 }
25 
27 {
28  if (!mSocket)
29  return false;
30  if (mSocket->bytesToWrite() > mMaxBufferSize)
31  return false;;
32  return true;
33 }
34 
35 void GrabberSenderQTcpSocket::send(igtl::ImageMessage::Pointer msg)
36 {
37  if (!msg || !this->isReady())
38  return;
39 
40  // Pack (serialize) and send
41  msg->Pack();
42  mSocket->write(reinterpret_cast<const char*> (msg->GetPackPointer()), msg->GetPackSize());
43 }
44 
46 {
47  if (!msg || !this->isReady())
48  return;
49 
50  // Pack (serialize) and send
51  msg->Pack();
52  mSocket->write(reinterpret_cast<const char*> (msg->GetPackPointer()), msg->GetPackSize());
53 }
54 
56 {
57  if (!this->isReady())
58  return;
59 
60  IGTLinkConversionImage converter;
61  this->send(converter.encode(msg, pcsLPS));
62 }
63 
65 {
66  if (!this->isReady())
67  return;
68 
69  IGTLinkConversion converter;
70  this->send(converter.encode(msg));
71 }
72 
73 
74 } /* namespace cx */
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
virtual void send(igtl::ImageMessage::Pointer msg)
pcsLPS
Left-Posterior-Superior, used internally by CustusX, also DICOM, ITK.
boost::shared_ptr< class ProbeDefinition > ProbeDefinitionPtr
Namespace for all CustusX production code.