fw4spl
SViewportRangeSelector.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_SVIEWPORTRANGESELECTOR_HPP__
8 #define __SCENE2D_ADAPTOR_SVIEWPORTRANGESELECTOR_HPP__
9 
10 #include "scene2D/config.hpp"
11 
12 #include <fwRenderQt/IAdaptor.hpp>
13 
14 namespace scene2D
15 {
16 namespace adaptor
17 {
18 
56 class SCENE2D_CLASS_API SViewportRangeSelector : public ::fwRenderQt::IAdaptor
57 {
58 
59 public:
61  SCENE2D_API SViewportRangeSelector() noexcept;
62  SCENE2D_API ~SViewportRangeSelector() noexcept;
63 
64 protected:
65  SCENE2D_API void configuring() override;
66  SCENE2D_API void starting() override;
67  SCENE2D_API void updating() override;
68  SCENE2D_API void stopping() override;
69 
70  SCENE2D_API void processInteraction( ::fwRenderQt::data::Event& _event ) override;
71 
74  SCENE2D_API void updateViewportFromShutter( double x, double y, double width, double height );
75 
76  SCENE2D_API KeyConnectionsMap getAutoConnections() const override;
77 
78 private:
79 
80  QGraphicsRectItem* m_shutter;
81  bool m_isLeftInteracting; // interaction onto shutter's left border
82  bool m_isRightInteracting; // interaction onto shutter's right border
83  bool m_isInteracting; // interaction onto the whole shutter
84  ::fwRenderQt::data::Coord m_dragStartPoint; // dragging origin point
85  ::fwRenderQt::data::Coord m_dragStartShutterPos; // shutter position when dragging starts
86 
88  const int m_clickCatchRange;
89 
91  QGraphicsItemGroup* m_layer;
92 
94  float m_initialX;
95 
97  float m_initialWidth;
98 
100  bool mouseOnShutterLeft( ::fwRenderQt::data::Coord _coord);
101 
103  bool mouseOnShutterRight( ::fwRenderQt::data::Coord _coord);
104 
106  bool mouseOnShutterMiddle( ::fwRenderQt::data::Coord _coord);
107 };
108 
109 } // namespace adaptor
110 } // namespace scene2D
111 
112 #endif // __SCENE2D_ADAPTOR_SVIEWPORTRANGESELECTOR_HPP__
113 
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
This bundles contains data and services used to display a 2D Qt scene.
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
The viewport range selector adaptor allows to select a delimited range of a viewport. It uses a graphical delimiter (called shutter) that can be moved from both left to right and right to left directions (in those cases, shutter&#39;s width is changing).
The namespace fwRenderQt contains classes for rendering with Qt.
Definition: Axis.hpp:12