OpenWalnut  1.5.0dev
WMNavigationSlices.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMNAVIGATIONSLICES_H
26 #define WMNAVIGATIONSLICES_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <boost/signals2.hpp>
33 #include <osg/Camera>
34 
35 #include "core/common/WPropertyTypes.h"
36 #include "core/common/math/linearAlgebra/WVectorFixed.h"
37 #include "core/graphicsEngine/WGECamera.h"
38 #include "core/graphicsEngine/WGEGroupNode.h"
39 #include "core/graphicsEngine/WGEManagedGroupNode.h"
40 #include "core/graphicsEngine/WPickInfo.h"
41 #include "core/kernel/WModule.h"
42 
43 /**
44  * This module provides simple slices that can be color-mapped. It is the default navigation tool for three-dimensional datasets.
45  *
46  * \ingroup modules
47  */
49 {
50 public:
51  /**
52  * Default constructor.
53  */
55 
56  /**
57  * Destructor.
58  */
59  virtual ~WMNavigationSlices();
60 
61  /**
62  * Gives back the name of this module.
63  * \return the module's name.
64  */
65  virtual const std::string getName() const;
66 
67  /**
68  * Gives back a description of this module.
69  * \return description to module.
70  */
71  virtual const std::string getDescription() const;
72 
73  /**
74  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
75  * should never be initialized or modified in some other way. A simple new instance is required.
76  *
77  * \return the prototype used to create every module in OpenWalnut.
78  */
79  virtual std::shared_ptr< WModule > factory() const;
80 
81  /**
82  * Get the icon for this module in XPM format.
83  * \return The icon.
84  */
85  virtual const char** getXPMIcon() const;
86 
87 protected:
88  /**
89  * Entry point after loading the module. Runs in separate thread.
90  */
91  virtual void moduleMain();
92 
93  /**
94  * Initialize the connectors this module is using.
95  */
96  virtual void connectors();
97 
98  /**
99  * Initialize the properties for this module.
100  */
101  virtual void properties();
102 
103 private:
104  /**
105  * Initializes the needed geodes, transformations and vertex arrays.
106  */
107  void initOSG();
108 
109  /**
110  * Handles picking events.
111  */
113  {
114  public:
115  /**
116  * For the lazy guys.
117  */
118  typedef std::shared_ptr< PickCallback > SPtr;
119 
120  /**
121  * The callback, controlling
122  *
123  * \param property the property controlling the position of the slice
124  * \param node the node getting controlled by this instance.
125  * \param negateDirection if true, the translation direction is switched.
126  */
127  PickCallback( osg::ref_ptr< osg::Node > node, WPropDouble property, bool negateDirection = false );
128 
129  private:
130  /**
131  * Pick event handler. Uses for dragging the slices
132  *
133  * \param pickInfo the pick information.
134  */
135  void pick( WPickInfo pickInfo );
136 
137  /**
138  * The pick connection for the pick() event handler.
139  */
140  boost::signals2::scoped_connection m_pickConnection;
141 
142  /**
143  * The slice node. Used for checking if picked.
144  */
145  osg::ref_ptr< osg::Node > m_node;
146 
147  /**
148  * The property controlling the position of the slice
149  */
150  WPropDouble m_property;
151 
152  /**
153  * The camera under which the node is placed. Needed for proper back-projection.
154  */
155  osg::ref_ptr< WGECamera > m_camera;
156 
157  /**
158  * If true, the item is still picked.
159  */
161 
162  /**
163  * This uniform is used to inform the shader about current pick-state
164  */
165  osg::ref_ptr< osg::Uniform > m_pickUniform;
166 
167  /**
168  * The stored pixel position of a previous drag event.
169  */
171 
172  /**
173  * The transformation direction. This is needed since the OSG coord system has a mirrored coronal direction.
174  */
175  float m_dir;
176  };
177 
178  /**
179  * X-Slice pick callback.
180  */
182 
183  /**
184  * Y-Slice pick callback.
185  */
187 
188  /**
189  * Z-Slice pick callback.
190  */
192 
193  /**
194  * The Geode containing all the slices and the mesh
195  */
196  osg::ref_ptr< WGEManagedGroupNode > m_output;
197 
198  /**
199  * The geode with the slice only for the nav widgets
200  */
201  osg::ref_ptr< WGEGroupNode > m_axialOutput;
202 
203  /**
204  * The geode with the slice only for the nav widgets
205  */
206  osg::ref_ptr< WGEGroupNode > m_coronalOutput;
207 
208  /**
209  * The geode with the slice only for the nav widgets
210  */
211  osg::ref_ptr< WGEGroupNode > m_sagittalOutput;
212 
213  WPropBool m_noTransparency; //!< if true, the whole slices are shown.
214 
215  WPropGroup m_sliceGroup; //!< the group contains several slice properties
216 
217  WPropDouble m_xPos; //!< x position of the slice
218 
219  WPropDouble m_yPos; //!< y position of the slice
220 
221  WPropDouble m_zPos; //!< z position of the slice
222 
223  WPropBool m_showonX; //!< indicates whether the vector should be shown on slice X
224 
225  WPropBool m_showonY; //!< indicates whether the vector should be shown on slice Y
226 
227  WPropBool m_showonZ; //!< indicates whether the vector should be shown on slice Z
228 };
229 
230 #endif // WMNAVIGATIONSLICES_H
231 
std::shared_ptr< PickCallback > SPtr
For the lazy guys.
void pick(WPickInfo pickInfo)
Pick event handler.
osg::ref_ptr< WGECamera > m_camera
The camera under which the node is placed.
WVector2d m_oldPixelPosition
The stored pixel position of a previous drag event.
boost::signals2::scoped_connection m_pickConnection
The pick connection for the pick() event handler.
WPropDouble m_property
The property controlling the position of the slice.
float m_dir
The transformation direction.
osg::ref_ptr< osg::Node > m_node
The slice node.
PickCallback(osg::ref_ptr< osg::Node > node, WPropDouble property, bool negateDirection=false)
The callback, controlling.
bool m_isPicked
If true, the item is still picked.
osg::ref_ptr< osg::Uniform > m_pickUniform
This uniform is used to inform the shader about current pick-state.
This module provides simple slices that can be color-mapped.
void initOSG()
Initializes the needed geodes, transformations and vertex arrays.
WPropBool m_showonZ
indicates whether the vector should be shown on slice Z
WPropDouble m_xPos
x position of the slice
WPropBool m_showonX
indicates whether the vector should be shown on slice X
osg::ref_ptr< WGEGroupNode > m_axialOutput
The geode with the slice only for the nav widgets.
virtual void moduleMain()
Entry point after loading the module.
virtual const std::string getDescription() const
Gives back a description of this module.
WMNavigationSlices()
Default constructor.
WPropBool m_noTransparency
if true, the whole slices are shown.
WPropDouble m_zPos
z position of the slice
PickCallback::SPtr m_xSlicePicker
X-Slice pick callback.
osg::ref_ptr< WGEGroupNode > m_sagittalOutput
The geode with the slice only for the nav widgets.
WPropDouble m_yPos
y position of the slice
osg::ref_ptr< WGEManagedGroupNode > m_output
The Geode containing all the slices and the mesh.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
PickCallback::SPtr m_zSlicePicker
Z-Slice pick callback.
virtual void connectors()
Initialize the connectors this module is using.
WPropGroup m_sliceGroup
the group contains several slice properties
virtual ~WMNavigationSlices()
Destructor.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
PickCallback::SPtr m_ySlicePicker
Y-Slice pick callback.
WPropBool m_showonY
indicates whether the vector should be shown on slice Y
virtual const std::string getName() const
Gives back the name of this module.
osg::ref_ptr< WGEGroupNode > m_coronalOutput
The geode with the slice only for the nav widgets.
virtual void properties()
Initialize the properties for this module.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
Encapsulates info for pick action.
Definition: WPickInfo.h:42