fw4spl
SNegato.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __SCENE2D_ADAPTOR_SNEGATO_HPP__
8 #define __SCENE2D_ADAPTOR_SNEGATO_HPP__
9 
10 #include "scene2D/config.hpp"
11 
12 #include <fwDataTools/helper/MedicalImageAdaptor.hpp>
13 
14 #include <fwRenderQt/data/Coord.hpp>
15 #include <fwRenderQt/IAdaptor.hpp>
16 
17 #include <QGraphicsItemGroup>
18 #include <QImage>
19 #include <QPointF>
20 
21 namespace scene2D
22 {
23 namespace adaptor
24 {
25 
63 class SCENE2D_CLASS_API SNegato : public ::fwDataTools::helper::MedicalImageAdaptor,
65 {
66 
67 public:
68 
70 
71  SCENE2D_API SNegato() noexcept;
72  SCENE2D_API virtual ~SNegato() noexcept;
73 
84  SCENE2D_API ::fwServices::IService::KeyConnectionsMap getAutoConnections() const override;
85 
86 protected:
87 
88  SCENE2D_API void configuring() override;
89  SCENE2D_API void starting() override;
90  SCENE2D_API void updating() override;
91  SCENE2D_API void stopping() override;
93  SCENE2D_API void swapping(const KeyType& key) override;
94  SCENE2D_API void processInteraction( ::fwRenderQt::data::Event& _event ) override;
95 
97  SCENE2D_API virtual void updateTFPoints() override;
98 
100  SCENE2D_API virtual void updateTFWindowing(double window, double level) override;
101 
102 private:
103 
108  void updateSliceIndex(int axial, int frontal, int sagittal);
110 
112  void updateSliceType(int from, int to);
113 
115  void updateBuffer();
116 
118  void updateVisibility(bool isVisible);
123  QImage* createQImage();
124  void updateBufferFromImage( QImage* qimg );
125  void changeImageMinMaxFromCoord( ::fwRenderQt::data::Coord& oldCoord, ::fwRenderQt::data::Coord& newCoord );
126 
127  static QRgb getQImageVal(const size_t index, const short* buffer, double wlMin,
128  double tfWin, const ::fwData::TransferFunction::sptr& tf);
129 
130  QImage* m_qimg;
131  QGraphicsPixmapItem* m_pixmapItem;
132  QGraphicsItemGroup* m_layer;
133 
135  ::fwDataTools::helper::MedicalImageAdaptor::Orientation m_orientation;
136 
138  bool m_pointIsCaptured;
139 
141  ::fwRenderQt::data::Coord m_oldCoord;
142 
144  bool m_changeSliceTypeAllowed;
145 };
146 
147 } // namespace adaptor
148 } // namespace scene2D
149 
150 #endif // __SCENE2D_ADAPTOR_SNEGATO_HPP__
151 
Root class for all scene2d adaptors.
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
IAdaptor implementation to display one slice of an image.
Definition: SNegato.hpp:63
The namespace fwDataTools contains classes which provide helpers to manipulate fwData::Object. *.
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
This bundles contains data and services used to display a 2D Qt scene.
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
Contains the representation of the data objects used in the framework.
The namespace fwRenderQt contains classes for rendering with Qt.
Definition: Axis.hpp:12