fw4spl
STransferFunction.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_STRANSFERFUNCTION_HPP__
8 #define __SCENE2D_ADAPTOR_STRANSFERFUNCTION_HPP__
9 
10 #include "scene2D/config.hpp"
11 
12 #include <fwData/TransferFunction.hpp>
13 
14 #include <fwDataTools/helper/MedicalImageAdaptor.hpp>
15 
16 #include <fwRenderQt/IAdaptor.hpp>
17 
18 namespace scene2D
19 {
20 namespace adaptor
21 {
22 
49 class SCENE2D_CLASS_API STransferFunction : public ::fwRenderQt::IAdaptor
50 {
51 
52 public:
54 
56  SCENE2D_API STransferFunction() noexcept;
57 
59  SCENE2D_API virtual ~STransferFunction() noexcept;
60 
68  SCENE2D_API KeyConnectionsMap getAutoConnections() const override;
69 
70 protected:
71 
72  SCENE2D_API void configuring() override;
73 
76  SCENE2D_API void starting() override;
77 
80  SCENE2D_API void updating() override;
81 
84  SCENE2D_API void stopping() override;
85 
88  SCENE2D_API void processInteraction( ::fwRenderQt::data::Event& _event ) override;
89 
90 private:
91 
93  ::fwRenderQt::data::Coord coordViewToCoordItem( const ::fwRenderQt::data::Coord& _coord );
94 
97  void buildTFPoints();
98 
101  void buildCircles();
102 
105  QGraphicsEllipseItem* buildCircle(::fwData::TransferFunction::TFValueType value,
106  ::fwData::TransferFunction::TFColor color);
107 
110  void buildLinesAndPolygons();
111 
113  void buildLinearLinesAndPolygons();
114 
116  void buildNearestLinesAndPolygons();
117 
119  void buildBounds();
120 
123  void buildLayer();
124 
127  void updateImageTF();
128 
130  void doubleClickEvent(QGraphicsEllipseItem* circle, ::fwData::TransferFunction::TFColor& tfColor);
131 
133  void leftButtonEvent(QGraphicsEllipseItem* circle, ::fwRenderQt::data::Event& _event);
134 
138  void mouseMoveEvent(QGraphicsEllipseItem* circle,
139  ::fwData::TransferFunction::TFValueType tfPoint,
140  ::fwRenderQt::data::Event& _event);
141 
143  void mouseButtonReleaseEvent(QGraphicsEllipseItem* circle, ::fwRenderQt::data::Event& _event);
144 
146  void rightButtonEvent(::fwData::TransferFunction::TFValueType tfPoint,
147  ::fwRenderQt::data::Event& _event);
148 
151  void doubleClickEvent( ::fwRenderQt::data::Event& _event);
152 
154  double pointValue(QGraphicsEllipseItem* circle);
155 
157  QPen m_linePen, m_circlePen;
158 
161  std::vector< QGraphicsItem* > m_linesAndPolygons;
162 
164  std::vector< QGraphicsEllipseItem* > m_circles;
165 
167  QGraphicsItemGroup* m_layer;
168 
170  double m_circleWidth, m_circleHeight;
171 
173  ::fwData::TransferFunction::TFDataType m_TFPoints;
174 
176  ::fwRenderQt::data::Coord m_oldCoord;
177 
179  bool m_pointIsCaptured;
180 
182  QGraphicsEllipseItem* m_capturedCircle;
183 
184  float m_pointSize;
185 };
186 
187 } // namespace adaptor
188 } // namespace scene2D
189 
190 #endif // __SCENE2D_ADAPTOR_STRANSFERFUNCTION_HPP__
191 
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
STL namespace.
This bundles contains data and services used to display a 2D Qt scene.
IAdaptor implementation to display a transfer function.
#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