OpenWalnut  1.5.0dev
WMArbitraryPlane.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 WMARBITRARYPLANE_H
26 #define WMARBITRARYPLANE_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <osg/Geode>
33 
34 #include "core/graphicsEngine/WGEManagedGroupNode.h"
35 #include "core/graphicsEngine/WROISphere.h"
36 #include "core/kernel/WModule.h"
37 #include "core/kernel/WModuleInputData.h"
38 #include "core/kernel/WModuleOutputData.h"
39 
40 /**
41  * Forward declaration of WGEShader.
42  */
43 class WGEShader;
44 
45 /**
46  * Arbitrarily orientable cutting plane through the data.
47  *
48  * \ingroup modules
49  */
51 {
52 public:
53  /**
54  * standard constructor
55  */
57 
58  /**
59  * destructor
60  */
61  virtual ~WMArbitraryPlane();
62 
63  /**
64  * Gives back the name of this module.
65  * \return the module's name.
66  */
67  virtual const std::string getName() const;
68 
69  /**
70  * Gives back a description of this module.
71  * \return description to module.
72  */
73  virtual const std::string getDescription() const;
74 
75  /**
76  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
77  * should never be initialized or modified in some other way. A simple new instance is required.
78  *
79  * \return the prototype used to create every module in OpenWalnut.
80  */
81  virtual std::shared_ptr< WModule > factory() const;
82 
83  /**
84  * Get the icon for this module in XPM format.
85  * \return the icon.
86  */
87  virtual const char** getXPMIcon() const;
88 
89 protected:
90  /**
91  * Entry point after loading the module. Runs in separate thread.
92  */
93  virtual void moduleMain();
94 
95  /**
96  * Initialize the connectors this module is using.
97  */
98  virtual void connectors();
99 
100  /**
101  * Initialize the properties for this module.
102  */
103  virtual void properties();
104 
105  /**
106  * called once at the start of the module main loop
107  */
108  void initPlane();
109 
110  /**
111  * updates the plane with the current settings
112  */
113  void updatePlane();
114 
115  /**
116  * setter for dirty flag
117  */
118  void setDirty();
119 
120  /**
121  * getter
122  * \return dirty flag
123  */
124  bool isDirty();
125 
126  /**
127  * getter for the position of the center manipulator
128  *
129  * \return center position
130  */
132 
133  /**
134  * update function, called with each update pass of the osg render loop
135  */
136  void updateCallback();
137 
138 
139 private:
140  /**
141  * A condition used to notify about changes in several properties.
142  */
143  std::shared_ptr< WCondition > m_propCondition;
144 
145 
146  /**
147  * True if the shader shouldn't discard a fragment when the value is zero
148  */
149  WPropBool m_showComplete;
150 
151  /**
152  * True if the manipulator spheres should be shown
153  */
155 
156  /**
157  * If true the center position will move with the nav slice selection
158  */
160 
161 
162  /**
163  * When triggered the center manipulator is set to the nav slice position and the plane is aligned along
164  * the axial slice
165  */
166  WPropTrigger m_buttonReset2Axial;
167 
168  /**
169  * When triggered the center manipulator is set to the nav slice position and the plane is aligned along
170  * the coronal slice
171  */
172  WPropTrigger m_buttonReset2Coronal;
173 
174  /**
175  * When triggered the center manipulator is set to the nav slice position and the plane is aligned along
176  * the axial slice
177  */
179 
180 
181  /**
182  * The root node used for this modules graphics.
183  */
184  osg::ref_ptr< WGEManagedGroupNode > m_rootNode;
185 
186  /**
187  * The geometry rendered by this module.
188  */
189  osg::ref_ptr< osg::Geode > m_geode;
190 
191  WPosition m_p0; //!< stores the last position of the center manipulator
192  WPosition m_p1; //!< stores the last position of manipulator 1
193  WPosition m_p2; //!< stores the last position of manipulator 2
194 
195  osg::ref_ptr<WROISphere> m_s0; //!< stores pointer to the center manipulator
196  osg::ref_ptr<WROISphere> m_s1; //!< stores pointer to manipulator 1
197  osg::ref_ptr<WROISphere> m_s2; //!< stores pointer to manipulator 2
198 
199  bool m_dirty; //!< dirty flag, used when manipulator positions change
200 
201  /**
202  * the shader object for this module
203  */
204  osg::ref_ptr< WGEShader > m_shader;
205 
206  osg::ref_ptr<osg::Uniform> m_showCompleteUniform; //!< Determines whether the slice should be drawn completely
207 
208  std::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the plane
209 };
210 
211 #endif // WMARBITRARYPLANE_H
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
Definition: WGEShader.h:48
Arbitrarily orientable cutting plane through the data.
osg::ref_ptr< WROISphere > m_s2
stores pointer to manipulator 2
WPosition m_p2
stores the last position of manipulator 2
bool m_dirty
dirty flag, used when manipulator positions change
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual ~WMArbitraryPlane()
destructor
virtual const std::string getName() const
Gives back the name of this module.
WPropTrigger m_buttonReset2Axial
When triggered the center manipulator is set to the nav slice position and the plane is aligned along...
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
virtual void moduleMain()
Entry point after loading the module.
virtual const std::string getDescription() const
Gives back a description of this module.
void updateCallback()
update function, called with each update pass of the osg render loop
osg::ref_ptr< WGEShader > m_shader
the shader object for this module
virtual void properties()
Initialize the properties for this module.
osg::ref_ptr< osg::Geode > m_geode
The geometry rendered by this module.
osg::ref_ptr< WROISphere > m_s0
stores pointer to the center manipulator
WPropBool m_attach2Crosshair
If true the center position will move with the nav slice selection.
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...
osg::ref_ptr< osg::Uniform > m_showCompleteUniform
Determines whether the slice should be drawn completely.
void initPlane()
called once at the start of the module main loop
WPropTrigger m_buttonReset2Sagittal
When triggered the center manipulator is set to the nav slice position and the plane is aligned along...
WPosition m_p1
stores the last position of manipulator 1
virtual void connectors()
Initialize the connectors this module is using.
WPosition getCenterPosition()
getter for the position of the center manipulator
WPropBool m_showManipulators
True if the manipulator spheres should be shown.
std::shared_ptr< boost::function< void() > > m_changeRoiSignal
Signal that can be used to update the plane.
osg::ref_ptr< WROISphere > m_s1
stores pointer to manipulator 1
WPropTrigger m_buttonReset2Coronal
When triggered the center manipulator is set to the nav slice position and the plane is aligned along...
void updatePlane()
updates the plane with the current settings
WPosition m_p0
stores the last position of the center manipulator
WPropBool m_showComplete
True if the shader shouldn't discard a fragment when the value is zero.
WMArbitraryPlane()
standard constructor
void setDirty()
setter for dirty flag
osg::ref_ptr< WGEManagedGroupNode > m_rootNode
The root node used for this modules graphics.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
This only is a 3d double vector.