NorMIT-nav  18.04
An IGT application
cxCompactFilterSetupWidget.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 
13 
14 #include <QGroupBox>
17 #include "cxOptionsWidget.h"
18 
19 namespace cx {
20 
21 CompactFilterSetupWidget::CompactFilterSetupWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget* parent, XmlOptionFile options, bool addFrame) :
22  BaseWidget(parent, "FilterSetupWidget", "FilterSetup")
23 {
24  mFrame = NULL;
25 
26  QVBoxLayout* toptopLayout = new QVBoxLayout(this);
27  toptopLayout->setMargin(0);
28 
29  mOptionsWidget = new OptionsWidget(viewService, patientModelService, this);
30 
31  if (addFrame)
32  {
33  mFrame = this->wrapInGroupBox(mOptionsWidget, "Algorithm");
34  toptopLayout->addWidget(mFrame);
35  }
36  else
37  toptopLayout->addWidget(mOptionsWidget);
38 
39  mObscuredListener.reset(new WidgetObscuredListener(this));
40  connect(mObscuredListener.get(), SIGNAL(obscured(bool)), this, SLOT(obscuredSlot(bool)));
41 
42  mOptions = options;
43 }
44 
45 void CompactFilterSetupWidget::obscuredSlot(bool obscured)
46 {
47  if (mCurrentFilter)
48  mCurrentFilter->setActive(!obscured);
49 }
50 
52 {
53  QString name("None");
54  QString help("");
55  if (mCurrentFilter)
56  {
57  name = mCurrentFilter->getName();
58  help = mCurrentFilter->getHelp();
59  }
60  return QString("<html>"
61  "<h4>%1</h4>"
62  "<p>%2</p>"
63  "</html>").arg(name).arg(help);
64 }
65 
67 {
68  if (filter==mCurrentFilter)
69  return;
70 
71  if (mCurrentFilter)
72  mCurrentFilter->setActive(false);
73 
74  mCurrentFilter = filter;
75 
76  if (mFrame)
77  mFrame->setTitle(mCurrentFilter->getName());
78 
79  if (mCurrentFilter)
80  {
81  mCurrentFilter->setActive(!mObscuredListener->isObscured());
82 
83  std::vector<SelectDataStringPropertyBasePtr> inputTypes = mCurrentFilter->getInputTypes();
84  std::vector<SelectDataStringPropertyBasePtr> outputTypes = mCurrentFilter->getOutputTypes();
85  std::vector<PropertyPtr> options = mCurrentFilter->getOptions();
86 
87  std::vector<PropertyPtr> all;
88  std::remove_copy(inputTypes.begin(), inputTypes.end(), std::back_inserter(all), inputTypes[0]);
89  std::remove_copy(outputTypes.begin(), outputTypes.end(), std::back_inserter(all), outputTypes[0]);
90  std::copy(options.begin(), options.end(), std::back_inserter(all));
91 
92  mOptionsWidget->setOptions(mCurrentFilter->getUid(), all, false);
93  this->setToolTip(this->getHelpText());
94  }
95  else
96  mOptionsWidget->setOptions("", std::vector<PropertyPtr>(), false);
97 }
98 } /* namespace cx */
QGroupBox * wrapInGroupBox(QWidget *base, QString name)
boost::shared_ptr< class ViewService > ViewServicePtr
boost::shared_ptr< class Filter > FilterPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
CompactFilterSetupWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, XmlOptionFile options, bool addFrame)
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
void setOptions(QString uid, std::vector< PropertyPtr > options, bool showAdvanced)
Helper class for xml files used to store ssc/cx data.
Namespace for all CustusX production code.