CustusX  15.8
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  VisServicesPtr vs(new VisServices(services));
60  this->setToolTip("Prepare data for vessel I2I registration");
61 
62  XmlOptionFile options = profile()->getXmlSettings().descend("registration").descend("PrepareVesselsWidget");
63  // fill the pipeline with filters:
64  mPipeline.reset(new Pipeline(services.patientModelService));
65  FilterGroupPtr filters(new FilterGroup(options.descend("pipeline")));
66  filters->append(FilterPtr(new ResampleImageFilter(vs)));
67  filters->append(FilterPtr(new SmoothingImageFilter(vs)));
68  filters->append(FilterPtr(new BinaryThresholdImageFilter(vs)));
69  filters->append(FilterPtr(new BinaryThinningImageFilter3DFilter(vs)));
70  mPipeline->initialize(filters);
71 
72 // mPipeline->getNodes()[0]->setValueName("US Image:");
73 // mPipeline->getNodes()[0]->setHelp("Select an US volume acquired from the wire phantom.");
74  mPipeline->setOption("Color", QVariant(QColor("red")));
75 
76  mLayout = new QVBoxLayout(this);
77 
79  mLayout->addWidget(mPipelineWidget);
80 
82  "Color of all generated data.",
83  QColor("green"), options.getElement());
84  connect(mColorProperty.get(), SIGNAL(changed()), this, SLOT(setColorSlot()));
85 
86  QPushButton* fixedButton = new QPushButton("Set as Fixed");
87  fixedButton->setToolTip("Set output of centerline generation as the Fixed Volume in Registration");
88  connect(fixedButton, SIGNAL(clicked()), this, SLOT(toFixedSlot()));
89  QPushButton* movingButton = new QPushButton("Set as Moving");
90  movingButton->setToolTip("Set output of centerline generation as the Moving Volume in Registration");
91  connect(movingButton, SIGNAL(clicked()), this, SLOT(toMovingSlot()));
92 
93  QLayout* buttonsLayout = new QHBoxLayout;
94  buttonsLayout->addWidget(fixedButton);
95  buttonsLayout->addWidget(movingButton);
96 
97  mLayout->addWidget(sscCreateDataWidget(this, mColorProperty));
98  mLayout->addWidget(mPipelineWidget);
99  mLayout->addStretch();
100  mLayout->addLayout(buttonsLayout);
101 // mLayout->addStretch();
102 
103  this->setColorSlot();
104 
105 }
106 
107 void PrepareVesselsWidget::setColorSlot()
108 {
109  mPipeline->setOption(mColorProperty->getDisplayName(), QVariant(mColorProperty->getValue()));
110 }
111 
112 void PrepareVesselsWidget::toMovingSlot()
113 {
114  DataPtr data = mPipeline->getNodes().back()->getData();
115  if (data)
116  mServices.registrationService->setMovingData(data);
117 }
118 
119 void PrepareVesselsWidget::toFixedSlot()
120 {
121  DataPtr data = mPipeline->getNodes().back()->getData();
122  if (data)
123  mServices.registrationService->setFixedData(data);
124 }
125 
127 {}
128 
129 
130 //------------------------------------------------------------------------------
131 }//namespace cx
cxResource_EXPORT ProfilePtr profile()
Definition: cxProfile.cpp:169
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:62
PrepareVesselsWidget(RegServices services, QWidget *parent)
ColorPropertyBasePtr mColorProperty
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
VisualizationServicePtr visualizationService
Definition: cxVisServices.h:60
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())
PatientModelServicePtr patientModelService
Helper class for xml files used to store ssc/cx data.
RegistrationServicePtr registrationService
Definition: cxRegServices.h:60
XmlOptionFile descend(QString element) const
step one level down in the xml tree