-
Notifications
You must be signed in to change notification settings - Fork 21
/
qSlicerOpenIGTLinkIFModuleWidget.cxx
143 lines (117 loc) · 4.72 KB
/
qSlicerOpenIGTLinkIFModuleWidget.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Qt includes
#include <QDebug>
#include <QStandardItemModel>
#include <QTreeView>
// SlicerQt includes
#include "qSlicerOpenIGTLinkIFModuleWidget.h"
#include "ui_qSlicerOpenIGTLinkIFModule.h"
// qMRMLWidgets includes
#include <qMRMLNodeFactory.h>
// OpenIGTLinkIF Logic includes
#include "vtkSlicerOpenIGTLinkIFLogic.h"
// OpenIGTLinkIF MRML includes
#include "vtkMRMLIGTLConnectorNode.h"
//-----------------------------------------------------------------------------
/// \ingroup Slicer_QtModules_OpenIGTLinkIF
class qSlicerOpenIGTLinkIFModuleWidgetPrivate: public Ui_qSlicerOpenIGTLinkIFModule
{
Q_DECLARE_PUBLIC(qSlicerOpenIGTLinkIFModuleWidget);
protected:
qSlicerOpenIGTLinkIFModuleWidget* const q_ptr;
public:
qSlicerOpenIGTLinkIFModuleWidgetPrivate(qSlicerOpenIGTLinkIFModuleWidget& object);
vtkSlicerOpenIGTLinkIFLogic * logic();
};
//-----------------------------------------------------------------------------
// qSlicerOpenIGTLinkIFModuleWidgetPrivate methods
//-----------------------------------------------------------------------------
qSlicerOpenIGTLinkIFModuleWidgetPrivate::qSlicerOpenIGTLinkIFModuleWidgetPrivate(qSlicerOpenIGTLinkIFModuleWidget& object)
: q_ptr(&object)
{
}
//-----------------------------------------------------------------------------
vtkSlicerOpenIGTLinkIFLogic * qSlicerOpenIGTLinkIFModuleWidgetPrivate::logic()
{
Q_Q(qSlicerOpenIGTLinkIFModuleWidget);
return vtkSlicerOpenIGTLinkIFLogic::SafeDownCast(q->logic());
}
//-----------------------------------------------------------------------------
// qSlicerOpenIGTLinkIFModuleWidget methods
//-----------------------------------------------------------------------------
qSlicerOpenIGTLinkIFModuleWidget::qSlicerOpenIGTLinkIFModuleWidget(QWidget* _parent)
: Superclass( _parent )
, d_ptr( new qSlicerOpenIGTLinkIFModuleWidgetPrivate(*this) )
{
}
//-----------------------------------------------------------------------------
qSlicerOpenIGTLinkIFModuleWidget::~qSlicerOpenIGTLinkIFModuleWidget()
{
}
//-----------------------------------------------------------------------------
void qSlicerOpenIGTLinkIFModuleWidget::setup()
{
Q_D(qSlicerOpenIGTLinkIFModuleWidget);
d->setupUi(this);
this->Superclass::setup();
// --------------------------------------------------
// Connectors section
// Connector List View
connect(d->ConnectorListView, SIGNAL(currentNodeChanged(vtkMRMLNode*)),
d->ConnectorPropertyWidget, SLOT(setMRMLIGTLConnectorNode(vtkMRMLNode*)));
d->ConnectorPropertyWidget->setMRMLIGTLConnectorNode(static_cast<vtkMRMLNode*>(0));
// Add(+) / Remove(-) Connector Buttons
connect(d->AddConnectorButton, SIGNAL(clicked()), this,
SLOT(onAddConnectorButtonClicked()));
connect(d->RemoveConnectorButton, SIGNAL(clicked()), this,
SLOT(onRemoveConnectorButtonClicked()));
// --------------------------------------------------
// I/O Configuration Section
connect(this, SIGNAL(mrmlSceneChanged(vtkMRMLScene*)),
d->IGTIONodeSelectorWidget, SLOT(setMRMLScene(vtkMRMLScene*)));
connect(d->IOTreeView, SIGNAL(ioTreeViewUpdated(int,vtkMRMLIGTLConnectorNode*,int, vtkMRMLNode*)),
d->IGTIONodeSelectorWidget, SLOT(updateEnabledStatus(int,vtkMRMLIGTLConnectorNode*,int, vtkMRMLNode*)));
}
//-----------------------------------------------------------------------------
void qSlicerOpenIGTLinkIFModuleWidget::setMRMLScene(vtkMRMLScene* scene)
{
Q_D(qSlicerOpenIGTLinkIFModuleWidget);
this->Superclass::setMRMLScene(scene);
if (scene == NULL)
{
return;
}
d->ConnectorListView->setMRMLScene(scene);
d->IOTreeView->setMRMLScene(scene);
}
//-----------------------------------------------------------------------------
void qSlicerOpenIGTLinkIFModuleWidget::onAddConnectorButtonClicked()
{
Q_D(qSlicerOpenIGTLinkIFModuleWidget);
if (this->mrmlScene())
{
vtkMRMLIGTLConnectorNode* node =
vtkMRMLIGTLConnectorNode::SafeDownCast(this->mrmlScene()->CreateNodeByClass("vtkMRMLIGTLConnectorNode"));
if (node)
{
this->mrmlScene()->AddNode(node);
d->ConnectorListView->setSelectedNode(node->GetID());
node->SetType(vtkMRMLIGTLConnectorNode::TYPE_CLIENT);
node->Delete();
}
}
//qMRMLNodeFactory::createNode(this->mrmlScene(), "vtkMRMLIGTLConnectorNode");
}
//-----------------------------------------------------------------------------
void qSlicerOpenIGTLinkIFModuleWidget::onRemoveConnectorButtonClicked()
{
Q_D(qSlicerOpenIGTLinkIFModuleWidget);
vtkMRMLNode * node = d->ConnectorListView->currentNode();
if (!node)
{
return;
}
vtkMRMLIGTLConnectorNode * connectorNode = vtkMRMLIGTLConnectorNode::SafeDownCast(node);
Q_ASSERT(connectorNode);
connectorNode->Stop();
this->mrmlScene()->RemoveNode(connectorNode);
}