7 #include "uiImageQt/ImageInfo.hpp" 9 #include <fwCom/Slot.hpp> 10 #include <fwCom/Slot.hxx> 11 #include <fwCom/Slots.hpp> 12 #include <fwCom/Slots.hxx> 14 #include <fwCore/base.hpp> 16 #include <fwData/Image.hpp> 18 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 19 #include <fwDataTools/helper/ImageGetter.hpp> 21 #include <fwGuiQt/container/QtContainer.hpp> 23 #include <fwMath/IntrasecTypes.hpp> 25 #include <fwServices/IService.hpp> 26 #include <fwServices/macros.hpp> 28 #include <QHBoxLayout> 37 static const ::fwCom::Slots::SlotKeyType s_GET_INTERACTION_SLOT =
"getInteraction";
39 static const ::fwServices::IService::KeyType s_IMAGE_INPUT =
"image";
41 ImageInfo::ImageInfo() noexcept
43 newSlot(s_GET_INTERACTION_SLOT, &ImageInfo::getInteraction,
this);
48 ImageInfo::~ImageInfo() noexcept
58 ::fwGuiQt::container::QtContainer::sptr qtContainer
59 = ::fwGuiQt::container::QtContainer::dynamicCast(this->getContainer() );
61 QHBoxLayout* hLayout =
new QHBoxLayout();
63 QLabel* staticText =
new QLabel( QObject::tr(
"intensity:"));
64 hLayout->addWidget( staticText, 0, Qt::AlignVCenter );
66 m_valueText =
new QLineEdit();
67 m_valueText->setReadOnly(
true);
68 hLayout->addWidget( m_valueText, 1, Qt::AlignVCenter );
70 qtContainer->setLayout( hLayout );
91 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_IMAGE_INPUT);
95 image = this->getObject< ::fwData::Image >();
97 SLM_ASSERT(
"The input '" + s_IMAGE_INPUT +
"' is not defined", image);
99 m_valueText->setEnabled(imageIsValid);
106 if (info.
m_eventId == ::fwDataTools::PickingInfo::Event::MOUSE_MOVE)
108 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_IMAGE_INPUT);
112 image = this->getObject< ::fwData::Image >();
114 SLM_ASSERT(
"The input '" + s_IMAGE_INPUT +
"' is not defined", image);
117 m_valueText->setEnabled(imageIsValid);
121 const ::fwData::Image::SizeType size = image->getSize();
123 if (point[0] < 0 || point[1] < 0 || point[2] < 0)
125 SLM_ERROR(
"The received coordinates are not in image space, maybe you used the wrong picker " 126 "interactor (see ::visuVTKAdaptor::SImagePickerInteractor)");
130 const ::fwData::Image::SizeType coords =
131 {{
static_cast< ::fwData::Image::SizeType::value_type
>(point[0]),
132 static_cast< ::fwData::Image::SizeType::value_type >(point[1]),
133 static_cast< ::fwData::Image::SizeType::value_type
>(point[2])}};
135 bool isInside = (coords[0] < size[0] && coords[1] < size[1]);
136 if (image->getNumberOfDimensions() < 3)
138 isInside = (isInside && coords[2] == 0);
142 isInside = (isInside && coords[2] < size[2]);
147 SLM_ERROR(
"The received coordinates are not in image space, maybe you used the wrong picker " 148 "interactor (see ::visuVTKAdaptor::SImagePickerInteractor)");
154 const std::string intensity = imageHelper.
getPixelAsString(coords[0], coords[1], coords[2] );
155 m_valueText->setText(QString::fromStdString(intensity));
164 _sstream <<
"Image Info Editor";
#define FW_DEPRECATED_KEY(newKey, access, version)
Use this macro when deprecating a service key to warn the developer.
This class is a helper to define the connections of a service and its data.
virtual void stopping() override
Stops editor.
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 configuring() override
Initializes the editor.
virtual void starting() override
Starts editor.
The namespace uiImageQt contains several editors on image written with Qt. This namespace is included...
#define SLM_ERROR(message)
virtual void info(std::ostream &_sstream) override
Write information in a stream.
ImageInfo service allows to display image pixel information when it receives the mouse cursor coordin...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual KeyConnectionsMap getAutoConnections() const override
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.
This class defines an image.
virtual void updating() override
Check if the image is valid, if not the editor is disabled.
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
FWGUI_API void initialize()
Initialize managers.