34 #include <boost/bind.hpp> 35 #include <boost/function.hpp> 37 #include <QVBoxLayout> 39 #include <QStackedWidget> 41 #include <QStringList> 59 mStackedWidget =
new QStackedWidget(
this);
60 mStackedWidget->setFocusPolicy(Qt::StrongFocus);
62 QVBoxLayout *layoutV =
new QVBoxLayout(
this);
67 "Select registration method",
74 layoutV->addWidget(mStackedWidget);
79 mMethodSelector->setValue(selectRegistrationMethod);
82 void RegistrationTypeWidget::onIndexChanged()
84 QString method = mMethodSelector->getValue();
85 int pos = mMethodSelector->getValueRange().indexOf(method);
86 mStackedWidget->setCurrentIndex(pos);
87 this->setObjectName(mStackedWidget->currentWidget()->objectName());
93 QStringList
values = mMethodSelector->getValueRange();
95 mMethodSelector->setValueRange(values);
98 if (mMethodSelector->getValue().isEmpty())
104 this->onIndexChanged();
109 this->removeWidgetFromStackedWidget(service->
getWidgetName());
111 QStringList
values = mMethodSelector->getValueRange();
114 mMethodSelector->setValueRange(values);
117 void RegistrationTypeWidget::removeWidgetFromStackedWidget(QString widgetName)
119 for(
int i = 0; i < mStackedWidget->count(); ++i)
121 QWidget* widget = mStackedWidget->widget(i);
122 if(widget->objectName() == widgetName)
124 mStackedWidget->removeWidget(widget);
137 TabbedWidget(parent,
"org_custusx_registration_gui_widget",
"Registration"),
138 mPluginContext(pluginContext),
139 mOptions(
profile()->getXmlSettings().descend(
"RegistrationWidget"))
141 connect(
mTabWidget, &QTabWidget::currentChanged,
this, &RegistrationWidget::onCurrentChanged);
142 this->initRegistrationTypesWidgets();
143 this->initServiceListener();
153 void RegistrationWidget::initRegistrationTypesWidgets()
155 mRegistrationTypes <<
"ImageToPatient" <<
"ImageToImage" <<
"ImageTransform";
156 QStringList typeDefaults;
157 typeDefaults <<
"Landmark" <<
"Landmark" <<
"";
159 for(
int i = 0; i < mRegistrationTypes.count(); ++i)
161 QString type = mRegistrationTypes[i];
167 mRegistrationTypeMap[type] = widget;
168 this->
addTab(widget, type);
175 "Registration Types",
176 "Select registration type",
180 if (mRegistrationTypeMap.count(mTypeSelector->getValue()))
181 mTabWidget->setCurrentWidget(mRegistrationTypeMap[mTypeSelector->getValue()]);
184 void RegistrationWidget::onCurrentChanged(
int index)
189 mTypeSelector->setValue(mRegistrationTypes[index]);
192 void RegistrationWidget::initServiceListener()
196 boost::bind(&RegistrationWidget::onServiceAdded,
this, _1),
198 boost::bind(&RegistrationWidget::onServiceRemoved,
this, _1)
200 mServiceListener->open();
206 if(!mRegistrationTypeMap.count(type))
211 mRegistrationTypeMap[type]->addMethod(service);
217 mRegistrationTypeMap[type]->removeMethod(service);
cxResource_EXPORT ProfilePtr profile()
void reportError(QString msg)
virtual QWidget * createWidget()=0
virtual QString getRegistrationMethod()=0
QDomElement getElement()
return the current element
virtual QString getRegistrationType()=0
Registration Method services.
void reportWarning(QString msg)
virtual QString getWidgetName()=0
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
Helper class for listening to services being added, modified and removed.
CompositeGenerator< T > values(T val1, T val2)
Helper class for xml files used to store ssc/cx data.
Namespace for all CustusX production code.