7 #include "fwGuiQt/SliceSelector.hpp" 9 #include <fwCore/base.hpp> 11 #include <boost/lambda/lambda.hpp> 14 #include <QHBoxLayout> 17 #include <QStringList> 29 m_fctChangeIndexCallback = std::bind( &::fwGuiQt::SliceSelector::printIndex,
this, std::placeholders:: _1);
30 m_fctChangeTypeCallback = std::bind( &::fwGuiQt::SliceSelector::printType,
this, std::placeholders:: _1);
32 m_sliceType =
new QComboBox(
this );
34 QStringList sliceTypesArray;
35 sliceTypesArray << tr(
"Sagittal") << tr(
"Frontal") << tr(
"Axial");
36 m_sliceType->addItems(sliceTypesArray);
38 m_sliceIndex =
new QSlider(Qt::Horizontal,
this);
40 m_pSliceIndexText =
new QLineEdit(
this);
41 m_pSliceIndexText->setReadOnly(
true);
42 m_pSliceIndexText->setMaximumWidth(80);
44 QHBoxLayout* layout =
new QHBoxLayout(
this);
45 layout->addWidget(m_sliceType, 0);
46 layout->addWidget(m_sliceIndex, 1);
47 layout->addWidget(m_pSliceIndexText, 0);
48 layout->setContentsMargins(0, 0, 0, 0);
50 QObject::connect(m_sliceIndex, SIGNAL(valueChanged(
int)),
this, SLOT(onSliceIndexChange(
int)));
51 QObject::connect(m_sliceType, SIGNAL(currentIndexChanged(
int)),
this, SLOT(onSliceTypeChange(
int)));
53 this->setLayout( layout );
60 QObject::disconnect(m_sliceIndex, SIGNAL(valueChanged(
int)),
this, SLOT(
onSliceIndexChange(
int)));
61 QObject::disconnect(m_sliceType, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
onSliceTypeChange(
int)));
66 void SliceSelector::setSliceRange(
int min,
int max )
68 QObject::disconnect(m_sliceIndex, SIGNAL(valueChanged(
int)),
this, SLOT(
onSliceIndexChange(
int)));
69 this->m_sliceIndex->setRange(min, max);
70 QObject::connect(m_sliceIndex, SIGNAL(valueChanged(
int)),
this, SLOT(
onSliceIndexChange(
int)));
75 void SliceSelector::setSliceValue(
int index )
77 QObject::disconnect(m_sliceIndex, SIGNAL(valueChanged(
int)),
this, SLOT(
onSliceIndexChange(
int)));
78 this->m_sliceIndex->setValue(index);
79 QObject::connect(m_sliceIndex, SIGNAL(valueChanged(
int)),
this, SLOT(
onSliceIndexChange(
int)));
82 ss << index <<
" / " << this->m_sliceIndex->maximum();
83 this->m_pSliceIndexText->setText( QString::fromStdString(ss.str()));
88 void SliceSelector::setTypeSelection(
int type )
90 this->m_sliceType->setCurrentIndex(type);
98 m_fctChangeIndexCallback( value );
99 this->setSliceValue( value );
104 void SliceSelector::setChangeIndexCallback(ChangeIndexCallback fct)
106 m_fctChangeIndexCallback = fct;
111 void SliceSelector::setChangeTypeCallback(ChangeTypeCallback fct)
113 m_fctChangeTypeCallback = fct;
118 void SliceSelector::printIndex(
int index)
125 void SliceSelector::printType(
int type)
132 void SliceSelector::setEnable(
bool enable)
134 m_sliceType->setEnabled(enable);
135 m_sliceIndex->setEnabled(enable);
136 m_pSliceIndexText->setEnabled(enable);
142 m_fctChangeTypeCallback(index);
143 this->setSliceValue( this->m_sliceIndex->value());
FWGUIQT_API void onSliceIndexChange(int value) noexcept
Event handler for a slice index change.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
virtual FWGUIQT_API ~SliceSelector() noexcept
Destructor.
#define OSLM_TRACE(message)
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
FWGUIQT_API void onSliceTypeChange(int index)
Event handler for a slice type change.
FWGUIQT_API SliceSelector(QWidget *const parent=nullptr) noexcept
Constructor.