7 #include "uiImageQt/SliceIndexPositionEditor.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 11 #include <fwCom/Signals.hpp> 12 #include <fwCom/Slot.hpp> 13 #include <fwCom/Slot.hxx> 14 #include <fwCom/Slots.hpp> 15 #include <fwCom/Slots.hxx> 17 #include <fwCore/base.hpp> 19 #include <fwData/Composite.hpp> 20 #include <fwData/Image.hpp> 21 #include <fwData/Integer.hpp> 23 #include <fwDataTools/fieldHelper/Image.hpp> 24 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 26 #include <fwGuiQt/container/QtContainer.hpp> 28 #include <fwRuntime/ConfigurationElement.hpp> 29 #include <fwRuntime/operations.hpp> 31 #include <fwServices/macros.hpp> 33 #include <boost/algorithm/string/case_conv.hpp> 34 #include <boost/algorithm/string/trim.hpp> 35 #include <boost/lexical_cast.hpp> 37 #include <QVBoxLayout> 47 const std::string* SliceIndexPositionEditor::SLICE_INDEX_FIELDID[ 3 ] =
54 static const ::fwCom::Slots::SlotKeyType s_UPDATE_SLICE_INDEX_SLOT =
"updateSliceIndex";
55 static const ::fwCom::Slots::SlotKeyType s_UPDATE_SLICE_TYPE_SLOT =
"updateSliceType";
57 static const ::fwServices::IService::KeyType s_IMAGE_INOUT =
"image";
63 newSlot(s_UPDATE_SLICE_INDEX_SLOT, &SliceIndexPositionEditor::updateSliceIndex,
this);
64 newSlot(s_UPDATE_SLICE_TYPE_SLOT, &SliceIndexPositionEditor::updateSliceType,
this);
79 ::fwGuiQt::container::QtContainer::sptr qtContainer = ::fwGuiQt::container::QtContainer::dynamicCast(
80 this->getContainer() );
82 QVBoxLayout* layout =
new QVBoxLayout( );
84 m_sliceSelectorPanel = new ::fwGuiQt::SliceSelector();
85 m_sliceSelectorPanel->setEnable(
false);
87 ::fwGuiQt::SliceSelector::ChangeIndexCallback changeIndexCallback;
89 std::placeholders::_1);
90 m_sliceSelectorPanel->setChangeIndexCallback(changeIndexCallback);
92 ::fwGuiQt::SliceSelector::ChangeIndexCallback changeTypeCallback;
94 std::placeholders::_1);
95 m_sliceSelectorPanel->setChangeTypeCallback(changeTypeCallback);
96 layout->addWidget( m_sliceSelectorPanel );
97 layout->setContentsMargins(0, 0, 0, 0);
99 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
103 image = this->getObject< ::fwData::Image >();
108 qtContainer->setLayout( layout );
118 m_sliceSelectorPanel =
nullptr;
129 std::vector< ::fwRuntime::ConfigurationElement::sptr > slideIndexCfg =
m_configuration->find(
"sliceIndex");
130 SLM_ASSERT(
"Only one xml element \"sliceIndex\" is accepted.", slideIndexCfg.size() == 1 );
131 SLM_ASSERT(
"The xml element \"sliceIndex\" is empty.", !(*slideIndexCfg.begin())->getValue().empty() );
132 std::string orientation = (*slideIndexCfg.begin())->getValue();
133 ::boost::algorithm::trim(orientation);
134 ::boost::algorithm::to_lower(orientation);
136 if(orientation ==
"axial" )
140 else if(orientation ==
"frontal" )
144 else if(orientation ==
"sagittal" )
150 SLM_FATAL(
"The value for the xml element \"sliceIndex\" can only be axial, frontal or sagittal.");
159 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
163 image = this->getObject< ::fwData::Image >();
166 m_sliceSelectorPanel->setEnable(imageIsValid);
180 void SliceIndexPositionEditor::updateSliceIndex(
int axial,
int frontal,
int sagittal)
186 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
190 image = this->getObject< ::fwData::Image >();
193 image->setField( fwDataTools::fieldHelper::Image::m_axialSliceIndexId,
m_axialIndex);
201 void SliceIndexPositionEditor::updateSliceType(
int from,
int to)
224 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
228 image = this->getObject< ::fwData::Image >();
235 OSLM_ASSERT(
"Field "<<fieldID<<
" is missing", image->getField( fieldID ) );
244 m_sliceSelectorPanel->setSliceRange( 0, max );
245 m_sliceSelectorPanel->setSliceValue( index );
254 m_sliceSelectorPanel->setTypeSelection( static_cast< int >( type ) );
256 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
260 image = this->getObject< ::fwData::Image >();
269 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
273 image = this->getObject< ::fwData::Image >();
277 OSLM_ASSERT(
"Field "<<fieldID<<
" is missing", image->getField( fieldID ));
291 OSLM_ASSERT(
"Bad slice type "<<type, type == X_AXIS ||
300 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
304 image = this->getObject< ::fwData::Image >();
310 sig->asyncEmit(oldType, _type);
335 if (this->getInOut< ::fwData::Image >(s_IMAGE_INOUT))
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_INDEX_MODIFIED_SIG
Type of signal when image's buffer is added.
UIIMAGEQT_API void updateSliceTypeFromImg(Orientation type)
Update the editor slice type choice from the image slice type.
This class is a helper to define the connections of a service and its data.
virtual UIIMAGEQT_API KeyConnectionsType getObjSrvConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
virtual void swapping() override
Swap of image.
virtual UIIMAGEQT_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Class allowing to block a Connection.
This class contains an integer value. Integer object is essentially used as a field in other objects...
virtual void starting() override
Install the layout.
Defines the service interface managing the editor service for object.
FWGUI_API void destroy()
Stops sub-views and toobar services. Destroys view, sub-views and toolbar containers.
virtual void stopping() override
Destroy the layout.
The namespace uiImageQt contains several editors on image written with Qt. This namespace is included...
#define SLM_FATAL(message)
UIIMAGEQT_API void sliceTypeNotification(int type)
This method is called when the slice type selected change. Notify the slice type is modified...
virtual void updating() override
Update editor information from the image.
virtual UIIMAGEQT_API ~SliceIndexPositionEditor() noexcept
Destructor. Do nothing.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual void configuring() override
Configure the editor.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
::fwCom::helper::SigSlotConnection::KeyConnectionsType KeyConnectionsType
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_BUFFER_MODIFIED_SIG
Type of signal when image's buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
SliceIndexPositionEditor service allows to change the slice index of an image.
This class defines an image.
UIIMAGEQT_API void sliceIndexNotification(unsigned int index)
This method is called when the slider is move. Notify the slice index is modified.
UIIMAGEQT_API SliceIndexPositionEditor() noexcept
Constructor. Do nothing.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_TYPE_MODIFIED_SIG
Type of signal when image's buffer is added.
virtual UIIMAGEQT_API void info(std::ostream &_sstream) override
Overrides.
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
FWGUI_API void initialize()
Initialize managers.
UIIMAGEQT_API void updateSliceIndexFromImg()
Update the editor slider from the image slice index.