Fraxinus  16.5.0-fx-rc5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxNetworkDataTransferWidget.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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
33 
34 #include <QPushButton>
35 #include <QGroupBox>
36 #include "cxNetworkConnection.h"
38 #include "cxBoolProperty.h"
39 #include "cxHelperWidgets.h"
41 #include "cxStringProperty.h"
42 #include "cxNetworkDataTransfer.h"
44 #include "cxHelperWidgets.h"
46 
47 namespace cx {
48 
50  BaseWidget(parent, "NetworkDataTransferWidget", "Network Data Transfer"),
51  mDataTransfer(backend)
52 {
53 
54  mConnectionWidget = new NetworkConnectionWidget(mDataTransfer->getOpenIGTLink());
55 
56  // handled by dialect - remove (kept cause might be useful in export/import dialogs)
57 // mCoordinateSystem = StringProperty::initialize("igltcoords", "Coordinate System",
58 // "Select which space to interpret/represent the iglink data in\n"
59 // "RAS is used by Slicer and others,\n"
60 // "LPS by CustusX and DICOM.",
61 // "RAS",
62 // QStringList() << "RAS" << "LPS",
63 // mOptions.getElement());
64 // std::map<QString,QString> names;
65 // names["LPS"] = "LPS (DICOM)";
66 // names["RAS"] = "RAS (Slicer)";
67 // mCoordinateSystem->setDisplayNames(names);
68 
69  QPushButton* sendButton = new QPushButton("Send", this);
70  connect(sendButton, &QPushButton::clicked, mDataTransfer.get(), &NetworkDataTransfer::onSend);
71 
72  QVBoxLayout* layout = new QVBoxLayout(this);
73 // layout->setMargin(0);
74 
75  QString uid = mDataTransfer->getOpenIGTLink()->getNetworkConnection()->getUid();
76  QVBoxLayout* connectionLayout = this->createVBoxInGroupBox(layout, QString("Connection/%1").arg(uid));
77  connectionLayout->addWidget(mConnectionWidget);
78 
79  QVBoxLayout* receiveLayout = this->createVBoxInGroupBox(layout, "Receive");
80  receiveLayout->addWidget(createDataWidget(mDataTransfer->getViewService(),
81  mDataTransfer->getPatientModelService(),
82  this, mDataTransfer->getAcceptIncomingData()));
83 
84  QVBoxLayout* sendLayout = this->createVBoxInGroupBox(layout, "Send");
85  sendLayout->addWidget(createDataWidget(mDataTransfer->getViewService(),
86  mDataTransfer->getPatientModelService(),
87  this, mDataTransfer->getDataToSend()));
88  sendLayout->addWidget(sendButton);
89  sendLayout->addWidget(createDataWidget(mDataTransfer->getViewService(),
90  mDataTransfer->getPatientModelService(),
91  this, StringPropertyActiveVideoSource::create(mDataTransfer->getVideoService())));
92  sendLayout->addWidget(createDataWidget(mDataTransfer->getViewService(),
93  mDataTransfer->getPatientModelService(),
94  this, mDataTransfer->getStreamActiveVideoSource()));
95 }
96 
98 {
99  mDataTransfer.reset();
100 }
101 
102 QVBoxLayout* NetworkDataTransferWidget::createVBoxInGroupBox(QVBoxLayout* parent, QString header)
103 {
104  QWidget* widget = new QWidget(this);
105  QVBoxLayout* layout = new QVBoxLayout(widget);
106  layout->setMargin(0);
107 
108  QGroupBox* groupBox = this->wrapInGroupBox(widget, header);
109  parent->addWidget(groupBox);
110 
111  return layout;
112 }
113 
114 } // namespace cx
boost::shared_ptr< class NetworkDataTransfer > NetworkDataTransferPtr
QGroupBox * wrapInGroupBox(QWidget *base, QString name)
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
static StringPropertyActiveVideoSourcePtr create(VideoServicePtr service)
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
NetworkDataTransferWidget(NetworkDataTransferPtr backend, QWidget *parent=NULL)