Fraxinus  16.5.0-fx-rc6
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 =========================================================================*/
32 
33 #include "cxPrepareVesselsWidget.h"
34 
35 #include <QVBoxLayout>
36 #include <QPushButton>
38 #include "cxTypeConversions.h"
39 #include "cxColorSelectButton.h"
40 #include "cxMesh.h"
41 #include "cxProfile.h"
42 
43 #include "cxPipelineWidget.h"
44 #include "cxHelperWidgets.h"
45 #include "cxColorProperty.h"
46 
47 #include "cxResampleImageFilter.h"
48 #include "cxSmoothingImageFilter.h"
52 
53 namespace cx
54 {
55 //------------------------------------------------------------------------------
57  RegistrationBaseWidget(services, parent, "org_custusx_registration_method_vessel_prepare_widget", "PrepareVesselsWidget")
58 {
59  this->setToolTip("Prepare data for vessel I2I registration");
60 
61  XmlOptionFile options = profile()->getXmlSettings().descend("registration").descend("PrepareVesselsWidget");
62  // fill the pipeline with filters:
63  mPipeline.reset(new Pipeline(services->patient()));
64  FilterGroupPtr filters(new FilterGroup(options.descend("pipeline")));
65  filters->append(FilterPtr(new ResampleImageFilter(services)));
66  filters->append(FilterPtr(new SmoothingImageFilter(services)));
67  filters->append(FilterPtr(new BinaryThresholdImageFilter(services)));
68  filters->append(FilterPtr(new BinaryThinningImageFilter3DFilter(services)));
69  mPipeline->initialize(filters);
70 
71 // mPipeline->getNodes()[0]->setValueName("US Image:");
72 // mPipeline->getNodes()[0]->setHelp("Select an US volume acquired from the wire phantom.");
73  mPipeline->setOption("Color", QVariant(QColor("red")));
74 
75  mLayout = new QVBoxLayout(this);
76 
77  mPipelineWidget = new PipelineWidget(services->view(), services->patient(), NULL, mPipeline);
78  mLayout->addWidget(mPipelineWidget);
79 
81  "Color of all generated data.",
82  QColor("green"), options.getElement());
83  connect(mColorProperty.get(), SIGNAL(changed()), this, SLOT(setColorSlot()));
84 
85  QPushButton* fixedButton = new QPushButton("Set as Fixed");
86  fixedButton->setToolTip("Set output of centerline generation as the Fixed Data in Registration");
87  connect(fixedButton, SIGNAL(clicked()), this, SLOT(toFixedSlot()));
88  QPushButton* movingButton = new QPushButton("Set as Moving");
89  movingButton->setToolTip("Set output of centerline generation as the Moving Data in Registration");
90  connect(movingButton, SIGNAL(clicked()), this, SLOT(toMovingSlot()));
91 
92  QLayout* buttonsLayout = new QHBoxLayout;
93  buttonsLayout->addWidget(fixedButton);
94  buttonsLayout->addWidget(movingButton);
95 
96  mLayout->addWidget(sscCreateDataWidget(this, mColorProperty));
97  mLayout->addWidget(mPipelineWidget);
98  mLayout->addStretch();
99  mLayout->addLayout(buttonsLayout);
100 // mLayout->addStretch();
101 
102  this->setColorSlot();
103 
104 }
105 
106 void PrepareVesselsWidget::setColorSlot()
107 {
108  mPipeline->setOption(mColorProperty->getDisplayName(), QVariant(mColorProperty->getValue()));
109 }
110 
111 void PrepareVesselsWidget::toMovingSlot()
112 {
113  DataPtr data = mPipeline->getNodes().back()->getData();
114  if (data)
115  mServices->registration()->setMovingData(data);
116 }
117 
118 void PrepareVesselsWidget::toFixedSlot()
119 {
120  DataPtr data = mPipeline->getNodes().back()->getData();
121  if (data)
122  mServices->registration()->setFixedData(data);
123 }
124 
126 {}
127 
128 
129 //------------------------------------------------------------------------------
130 }//namespace cx
cxResource_EXPORT ProfilePtr profile()
Definition: cxProfile.cpp:176
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:41
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:86
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