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);
77 void RegistrationTypeWidget::onIndexChanged()
79 QString method = mMethodSelector->getValue();
80 int pos = mMethodSelector->getValueRange().indexOf(method);
81 mStackedWidget->setCurrentIndex(pos);
82 this->setObjectName(mStackedWidget->currentWidget()->objectName());
88 QStringList values = mMethodSelector->getValueRange();
90 mMethodSelector->setValueRange(values);
93 if (mMethodSelector->getValue().isEmpty())
99 this->onIndexChanged();
104 this->removeWidgetFromStackedWidget(service->
getWidgetName());
106 QStringList values = mMethodSelector->getValueRange();
109 mMethodSelector->setValueRange(values);
112 void RegistrationTypeWidget::removeWidgetFromStackedWidget(QString widgetName)
114 for(
int i = 0; i < mStackedWidget->count(); ++i)
116 QWidget* widget = mStackedWidget->widget(i);
117 if(widget->objectName() == widgetName)
119 mStackedWidget->removeWidget(widget);
132 TabbedWidget(parent,
"org_custusx_registration_gui_widget",
"Registration"),
133 mPluginContext(pluginContext),
134 mOptions(
profile()->getXmlSettings().descend(
"RegistrationWidget"))
136 connect(
mTabWidget, &QTabWidget::currentChanged,
this, &RegistrationWidget::onCurrentChanged);
137 this->initRegistrationTypesWidgets();
138 this->initServiceListener();
141 void RegistrationWidget::initRegistrationTypesWidgets()
143 mRegistrationTypes <<
"ImageToPatient" <<
"ImageToImage" <<
"ImageTransform";
144 QStringList typeDefaults;
145 typeDefaults <<
"Landmark" <<
"Landmark" <<
"";
148 "Registration Types",
149 "Select registration type",
153 this->blockSignals(
true);
155 for(
int i = 0; i < mRegistrationTypes.count(); ++i)
157 QString type = mRegistrationTypes[i];
163 mRegistrationTypeMap[type] = widget;
164 this->
addTab(widget, type);
166 if (mTypeSelector->getValue() == type)
170 this->blockSignals(
false);
173 void RegistrationWidget::onCurrentChanged(
int index)
177 mTypeSelector->setValue(mRegistrationTypes[index]);
180 void RegistrationWidget::initServiceListener()
182 mServiceListener.reset(
new ServiceTrackerListener<RegistrationMethodService>(
184 boost::bind(&RegistrationWidget::onServiceAdded,
this, _1),
185 boost::function<
void (RegistrationMethodService*)>(),
186 boost::bind(&RegistrationWidget::onServiceRemoved,
this, _1)
188 mServiceListener->open();
191 void RegistrationWidget::onServiceAdded(RegistrationMethodService* service)
193 QString type = service->getRegistrationType();
194 if(!mRegistrationTypeMap.count(type))
199 mRegistrationTypeMap[type]->addMethod(service);
202 void RegistrationWidget::onServiceRemoved(RegistrationMethodService *service)
204 QString type = service->getRegistrationType();
205 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
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 xml files used to store ssc/cx data.