Fraxinus  18.10
An IGT application
cxPrepareVesselsWidget.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 
12 #include "cxPrepareVesselsWidget.h"
13 
14 #include <QVBoxLayout>
15 #include <QPushButton>
17 #include "cxTypeConversions.h"
18 #include "cxColorSelectButton.h"
19 #include "cxMesh.h"
20 #include "cxProfile.h"
21 
22 #include "cxPipelineWidget.h"
23 #include "cxHelperWidgets.h"
24 #include "cxColorProperty.h"
25 
26 #include "cxResampleImageFilter.h"
27 #include "cxSmoothingImageFilter.h"
31 
32 namespace cx
33 {
34 //------------------------------------------------------------------------------
36  RegistrationBaseWidget(services, parent, "org_custusx_registration_method_vessel_prepare_widget", "PrepareVesselsWidget")
37 {
38  this->setToolTip("Prepare data for vessel I2I registration");
39 
40  XmlOptionFile options = profile()->getXmlSettings().descend("registration").descend("PrepareVesselsWidget");
41  // fill the pipeline with filters:
42  mPipeline.reset(new Pipeline(services->patient()));
43  FilterGroupPtr filters(new FilterGroup(options.descend("pipeline")));
44  filters->append(FilterPtr(new ResampleImageFilter(services)));
45  filters->append(FilterPtr(new SmoothingImageFilter(services)));
46  filters->append(FilterPtr(new BinaryThresholdImageFilter(services)));
47  filters->append(FilterPtr(new BinaryThinningImageFilter3DFilter(services)));
48  mPipeline->initialize(filters);
49 
50 // mPipeline->getNodes()[0]->setValueName("US Image:");
51 // mPipeline->getNodes()[0]->setHelp("Select an US volume acquired from the wire phantom.");
52  mPipeline->setOption("Color", QVariant(QColor("red")));
53 
54  mLayout = new QVBoxLayout(this);
55 
56  mPipelineWidget = new PipelineWidget(services->view(), services->patient(), NULL, mPipeline);
57  mLayout->addWidget(mPipelineWidget);
58 
60  "Color of all generated data.",
61  QColor("green"), options.getElement());
62  connect(mColorProperty.get(), SIGNAL(changed()), this, SLOT(setColorSlot()));
63 
64  QPushButton* fixedButton = new QPushButton("Set as Fixed");
65  fixedButton->setToolTip("Set output of centerline generation as the Fixed Data in Registration");
66  connect(fixedButton, SIGNAL(clicked()), this, SLOT(toFixedSlot()));
67  QPushButton* movingButton = new QPushButton("Set as Moving");
68  movingButton->setToolTip("Set output of centerline generation as the Moving Data in Registration");
69  connect(movingButton, SIGNAL(clicked()), this, SLOT(toMovingSlot()));
70 
71  QLayout* buttonsLayout = new QHBoxLayout;
72  buttonsLayout->addWidget(fixedButton);
73  buttonsLayout->addWidget(movingButton);
74 
75  mLayout->addWidget(sscCreateDataWidget(this, mColorProperty));
76  mLayout->addWidget(mPipelineWidget);
77  mLayout->addStretch();
78  mLayout->addLayout(buttonsLayout);
79 // mLayout->addStretch();
80 
81  this->setColorSlot();
82 
83 }
84 
85 void PrepareVesselsWidget::setColorSlot()
86 {
87  mPipeline->setOption(mColorProperty->getDisplayName(), QVariant(mColorProperty->getValue()));
88 }
89 
90 void PrepareVesselsWidget::toMovingSlot()
91 {
92  DataPtr data = mPipeline->getNodes().back()->getData();
93  if (data)
94  mServices->registration()->setMovingData(data);
95 }
96 
97 void PrepareVesselsWidget::toFixedSlot()
98 {
99  DataPtr data = mPipeline->getNodes().back()->getData();
100  if (data)
101  mServices->registration()->setFixedData(data);
102 }
103 
105 {}
106 
107 
108 //------------------------------------------------------------------------------
109 }//namespace cx
cxResource_EXPORT ProfilePtr profile()
Definition: cxProfile.cpp:160
ColorPropertyBasePtr mColorProperty
PrepareVesselsWidget(RegServicesPtr services, QWidget *parent)
QDomElement getElement()
return the current element
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class Filter > FilterPtr
boost::shared_ptr< FilterGroup > FilterGroupPtr
Definition: cxFilterGroup.h:65
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
class PipelineWidget * mPipelineWidget
QWidget * sscCreateDataWidget(QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
static ColorPropertyPtr initialize(const QString &uid, QString name, QString help, QColor value, QDomNode root=QDomNode())
Helper class for xml files used to store ssc/cx data.
XmlOptionFile descend(QString element) const
step one level down in the xml tree
Namespace for all CustusX production code.