47 #include "boost/bind.hpp" 54 mOpenIGTLink(connection)
56 mOptions =
profile()->getXmlSettings().descend(this->getConfigUid());
64 connect(mOpenIGTLink->getNetworkConnection(), &
NetworkConnection::image,
this, &NetworkDataTransfer::onImageReceived);
65 connect(mOpenIGTLink->getNetworkConnection(), &
NetworkConnection::mesh,
this, &NetworkDataTransfer::onMeshReceived);
70 "Accept incoming data and add to Patient",
74 "Stream the active Video Source over the connection",
77 this, &NetworkDataTransfer::onStreamActiveVideoSourceChanged);
91 QString NetworkDataTransfer::getConfigUid()
const 93 return "org.custusx.core.openigtlink.datatransfer";
96 void NetworkDataTransfer::onImageReceived(
ImagePtr image)
98 this->onDataReceived(image);
101 void NetworkDataTransfer::onMeshReceived(
MeshPtr mesh)
103 this->onDataReceived(mesh);
106 void NetworkDataTransfer::onDataReceived(
DataPtr data)
108 QString actionText = mAcceptIncomingData->getValue() ?
"inserting" :
"ignoring";
109 QString nameText = data ? data->getName() :
"NULL";
110 CX_LOG_CHANNEL_INFO(this->getConfigUid()) << QString(
"Received image [%1] over IGTLink, %2")
114 if (mAcceptIncomingData->getValue())
116 mPatientModelService->insertData(data);
117 mViewService->autoShowData(data);
124 DataPtr data = mDataToSend->getData();
129 mOpenIGTLink->getNetworkConnection()->invoke(message);
132 MeshPtr mesh = boost::dynamic_pointer_cast<
Mesh>(data);
146 mOpenIGTLink->getNetworkConnection()->invoke(message);
150 QString name = data ? data->getName() :
"NULL";
151 CX_LOG_CHANNEL_INFO(this->getConfigUid()) << QString(
"Failed to send data %1 over igtl: Unsupported type")
155 void NetworkDataTransfer::onStreamActiveVideoSourceChanged()
157 if (mStreamActiveVideoSource->getValue())
168 void NetworkDataTransfer::startStream()
170 if (mStreamingVideoSource)
172 CX_LOG_WARNING() << QString(
"Already emitting VideoSource %1 on igtl").arg(mStreamingVideoSource->getName());
176 mStreamingVideoSource = mVideoService->getActiveVideoSource();
178 this, &NetworkDataTransfer::onNewStreamFrame);
179 CX_LOG_INFO() << QString(
"Started emitting VideoSource %1 on igtl").arg(mStreamingVideoSource->getName());
182 void NetworkDataTransfer::stopStream()
184 if (!mStreamingVideoSource)
187 CX_LOG_INFO() << QString(
"Stopped emitting VideoSource %1 on igtl").arg(mStreamingVideoSource->getName());
189 this, &NetworkDataTransfer::onNewStreamFrame);
190 mStreamingVideoSource.reset();
193 void NetworkDataTransfer::onNewStreamFrame()
197 ImagePtr image(
new Image(mStreamingVideoSource->getUid()+
"_snapshot",
199 mStreamingVideoSource->getName()));
202 mOpenIGTLink->getNetworkConnection()->invoke(message);
#define CX_LOG_CHANNEL_INFO(channel)
cxResource_EXPORT ProfilePtr profile()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
void image(ImagePtr image)
static StringPropertySelectDataPtr New(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
boost::shared_ptr< class Image > ImagePtr
NetworkDataTransfer(ctkPluginContext *context, NetworkConnectionHandlePtr connection, QObject *parent=NULL)
static VideoServicePtr create(ctkPluginContext *pluginContext)
QDomElement getElement()
return the current element
NetworkConnectionHandlePtr getOpenIGTLink()
void sendMesh(MeshPtr image)
not thread-safe: use invoke
static PatientModelServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class Data > DataPtr
void sendImage(ImagePtr image)
not thread-safe: use invoke
void changed()
emit when the underlying data value is changed: The user interface will be updated.
boost::shared_ptr< class NetworkConnectionHandle > NetworkConnectionHandlePtr
void streamImage(ImagePtr image)
not thread-safe: use invoke
static ViewServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class Mesh > MeshPtr
void newFrame()
emitted when a new frame has arrived (getVtkImageData() returns something new). info/status/name/vali...
Namespace for all CustusX production code.