13 #include <boost/bind.hpp> 14 #include <boost/function.hpp> 16 #include <QVBoxLayout> 18 #include <QStackedWidget> 20 #include <QStringList> 38 mStackedWidget =
new QStackedWidget(
this);
39 mStackedWidget->setFocusPolicy(Qt::StrongFocus);
41 QVBoxLayout *layoutV =
new QVBoxLayout(
this);
46 "Select registration method",
53 layoutV->addWidget(mStackedWidget);
58 mMethodSelector->setValue(selectRegistrationMethod);
61 void RegistrationTypeWidget::onIndexChanged()
63 QString method = mMethodSelector->getValue();
64 int pos = mMethodSelector->getValueRange().indexOf(method);
65 mStackedWidget->setCurrentIndex(pos);
66 this->setObjectName(mStackedWidget->currentWidget()->objectName());
72 QStringList
values = mMethodSelector->getValueRange();
74 mMethodSelector->setValueRange(values);
77 if (mMethodSelector->getValue().isEmpty())
83 this->onIndexChanged();
88 this->removeWidgetFromStackedWidget(service->
getWidgetName());
90 QStringList
values = mMethodSelector->getValueRange();
93 mMethodSelector->setValueRange(values);
96 void RegistrationTypeWidget::removeWidgetFromStackedWidget(QString widgetName)
98 for(
int i = 0; i < mStackedWidget->count(); ++i)
100 QWidget* widget = mStackedWidget->widget(i);
101 if(widget->objectName() == widgetName)
103 mStackedWidget->removeWidget(widget);
116 TabbedWidget(parent,
"org_custusx_registration_gui_widget",
"Registration"),
117 mPluginContext(pluginContext),
118 mOptions(
profile()->getXmlSettings().descend(
"RegistrationWidget"))
120 connect(
mTabWidget, &QTabWidget::currentChanged,
this, &RegistrationWidget::onCurrentChanged);
121 this->initRegistrationTypesWidgets();
122 this->initServiceListener();
132 void RegistrationWidget::initRegistrationTypesWidgets()
134 mRegistrationTypes <<
"ImageToPatient" <<
"ImageToImage" <<
"ImageTransform";
135 QStringList typeDefaults;
136 typeDefaults <<
"Landmark" <<
"Landmark" <<
"";
138 for(
int i = 0; i < mRegistrationTypes.count(); ++i)
140 QString type = mRegistrationTypes[i];
146 mRegistrationTypeMap[type] = widget;
147 this->
addTab(widget, type);
154 "Registration Types",
155 "Select registration type",
159 if (mRegistrationTypeMap.count(mTypeSelector->getValue()))
160 mTabWidget->setCurrentWidget(mRegistrationTypeMap[mTypeSelector->getValue()]);
163 void RegistrationWidget::onCurrentChanged(
int index)
168 mTypeSelector->setValue(mRegistrationTypes[index]);
171 void RegistrationWidget::initServiceListener()
175 boost::bind(&RegistrationWidget::onServiceAdded,
this, _1),
177 boost::bind(&RegistrationWidget::onServiceRemoved,
this, _1)
179 mServiceListener->open();
185 if(!mRegistrationTypeMap.count(type))
190 mRegistrationTypeMap[type]->addMethod(service);
196 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.