OpenWalnut  1.5.0dev
WMCoordinateSystem.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 WMCOORDINATESYSTEM_H
26 #define WMCOORDINATESYSTEM_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <osg/Geode>
32 #include <osg/Node>
33 
34 #include "WCoordConverter.h"
35 #include "WRulerOrtho.h"
36 #include "core/dataHandler/WDataSet.h"
37 #include "core/graphicsEngine/WGEGroupNode.h"
38 #include "core/kernel/WModule.h"
39 #include "core/kernel/WModuleConnector.h"
40 #include "core/kernel/WModuleInputData.h"
41 
42 /**
43  * Forward declaration of WDataSetScalar.
44  */
45 class WDataSetScalar;
46 
47 /**
48  * class that implements the various coordinate systems as overlays within the 3D view
49  * \ingroup modules
50  */
52 {
53 public:
54  /**
55  * standard constructor
56  */
58 
59  /**
60  * destructor
61  */
62  virtual ~WMCoordinateSystem();
63 
64  /**
65  * Initialize the connectors this module is using.
66  */
67  virtual void connectors();
68 
69  /**
70  * callback for updating the geometry
71  */
73 
74  /**
75  * \par Description
76  * Gives back the name of this module.
77  * \return the module's name.
78  */
79  virtual const std::string getName() const;
80 
81  /**
82  * \par Description
83  * Gives back a description of this module.
84  * \return description to module.
85  */
86  virtual const std::string getDescription() const;
87 
88  /**
89  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
90  * should never be initialized or modified in some other way. A simple new instance is required.
91  *
92  * \return the prototype used to create every module in OpenWalnut.
93  */
94  virtual std::shared_ptr< WModule > factory() const;
95 
96  /**
97  * Get the icon for this module in XPM format.
98  * \return The icon.
99  */
100  virtual const char** getXPMIcon() const;
101 
102 protected:
103  /**
104  * \par Description
105  * Entry point after loading the module. Runs in separate thread.
106  */
107  virtual void moduleMain();
108 
109 private:
110  WPropPosition m_crosshair; //!< position of the navigation slices
111  WPropPosition m_flt; //!< lower boundary of the dataset
112  WPropPosition m_brb; //!< upper boundary of the dataset
113 
114  WPropPosition m_ac; //!< anterior commissure
115  WPropPosition m_pc; //!< posterior commissure
116  WPropPosition m_ihp; //!< inter hemispherical point
117 
118  WPropBool m_showNumbersOnRulers; //!< show/hide numbers on rulers
119 
120  WPropBool m_showAxial; //!< show rulers on the axial slice
121  WPropBool m_showCoronal; //!< show rulers on the coronal slice
122  WPropBool m_showSagittal; //!< show rulers on the sagittal slice
123 
124  WPropBool m_showGridAxial; //!< show grid on the axial slice
125  WPropBool m_showGridCoronal; //!< show grid on the coronal slice
126  WPropBool m_showGridSagittal; //!< show grid on the sagittal slice
127 
128  WPropTrigger m_acTrigger; //!< button to reset the ac point
129  WPropTrigger m_pcTrigger; //!< button to reset the pc point
130  WPropTrigger m_ihpTrigger; //!< button to reset the ihp point;
131 
132  WPropSelection m_csSelection; //!< selection for coordinate system mode
133  std::shared_ptr< WItemSelection > m_possibleSelections; //!< selection for coordinate system mode
134 
135  /**
136  * A condition used to notify about changes in several properties.
137  */
138  std::shared_ptr< WCondition > m_propCondition;
139 
140  std::shared_ptr< WModuleInputData< WDataSetScalar > > m_input; //!< Input connector required by this module.
141  std::shared_ptr< const WDataSetScalar > m_dataSet; //!< pointer to dataSet to be able to access it throughout the whole module.
142 
143  /**
144  * the root node for this module
145  */
146  osg::ref_ptr< WGEGroupNode > m_rootNode;
147 
148  /**
149  * node for the bounding box
150  */
151  osg::ref_ptr< osg::Group > m_rulerNode;
152 
153  bool m_dirty; //!< flag true if something happened that requires redrawing of gfx
154 
155  float m_drawOffset; //!< offset from slices to draw geometry on
156 
157  std::shared_ptr< WCoordConverter > m_coordConverter; //!< stores pointer
158 
159  int m_viewAngle; //!< stores the last view angle
160 
161  /**
162  * initialize the properties for this module
163  */
164  void properties();
165 
166  /**
167  * Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
168  */
169  virtual void activate();
170 
171  /**
172  * initial creation function for the slice geometry
173  */
174  void createGeometry();
175 
176  /**
177  * helper function that computes the innerBoundingBox for the actual data
178  */
179  void findBoundingBox();
180 
181 
182  void initTalairachConverter(); //!< creates and initializes a talairach converter object
183 
184  void addRulersSagittal(); //!< helper function to create rulers
185  void addRulersAxial(); //!< helper function to create rulers
186  void addRulersCoronal(); //!< helper function to create rulers
187 
188  /**
189  * helper function to create a grid overlay on the sagittal slice
190  * \param position
191  */
192  void addSagittalGrid( float position );
193 
194  /**
195  * helper function to create a grid overlay on the coronal slice
196  * \param position
197  */
198  void addCoronalGrid( float position );
199 
200  /**
201  * helper function to create a grid overlay on the axial slice
202  * \param position
203  */
204  void addAxialGrid( float position );
205 
206  /**
207  * Callback to listen for property changes
208  */
209  void propertyChanged();
210 
211  /**
212  * the shader object for this module
213  */
214  // std::shared_ptr< WGEShader >m_shader;
215 
216  /**
217  * update function, called with each update pass of the osg render loop
218  */
219  void updateCallback();
220 };
221 
222 #endif // WMCOORDINATESYSTEM_H
This data set type contains scalars as values.
class that implements the various coordinate systems as overlays within the 3D view
std::shared_ptr< WCoordConverter > m_coordConverter
stores pointer
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
void propertyChanged()
Callback to listen for property changes.
WPropPosition m_brb
upper boundary of the dataset
bool m_dirty
flag true if something happened that requires redrawing of gfx
void addRulersSagittal()
helper function to create rulers
osg::ref_ptr< osg::Group > m_rulerNode
node for the bounding box
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_input
Input connector required by this module.
virtual const std::string getName() const
void addRulersAxial()
helper function to create rulers
int m_viewAngle
stores the last view angle
WPropPosition m_ac
anterior commissure
WMCoordinateSystem()
standard constructor
virtual void moduleMain()
WPropBool m_showSagittal
show rulers on the sagittal slice
WPropTrigger m_ihpTrigger
button to reset the ihp point;
WPropPosition m_flt
lower boundary of the dataset
WPropBool m_showGridAxial
show grid on the axial slice
WPropBool m_showCoronal
show rulers on the coronal slice
WPropBool m_showAxial
show rulers on the axial slice
void updateCallback()
the shader object for this module
WPropPosition m_ihp
inter hemispherical point
WPropSelection m_csSelection
selection for coordinate system mode
std::shared_ptr< WItemSelection > m_possibleSelections
selection for coordinate system mode
void addSagittalGrid(float position)
helper function to create a grid overlay on the sagittal slice
void findBoundingBox()
helper function that computes the innerBoundingBox for the actual data
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...
void initTalairachConverter()
creates and initializes a talairach converter object
virtual ~WMCoordinateSystem()
destructor
osg::ref_ptr< WGEGroupNode > m_rootNode
the root node for this module
WPropTrigger m_pcTrigger
button to reset the pc point
std::shared_ptr< const WDataSetScalar > m_dataSet
pointer to dataSet to be able to access it throughout the whole module.
void updateGeometry()
callback for updating the geometry
virtual void connectors()
Initialize the connectors this module is using.
WPropBool m_showGridCoronal
show grid on the coronal slice
virtual const std::string getDescription() const
void addAxialGrid(float position)
helper function to create a grid overlay on the axial slice
WPropTrigger m_acTrigger
button to reset the ac point
WPropPosition m_crosshair
position of the navigation slices
virtual void activate()
Callback for m_active.
void properties()
initialize the properties for this module
WPropPosition m_pc
posterior commissure
void addRulersCoronal()
helper function to create rulers
void addCoronalGrid(float position)
helper function to create a grid overlay on the coronal slice
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
float m_drawOffset
offset from slices to draw geometry on
WPropBool m_showGridSagittal
show grid on the sagittal slice
WPropBool m_showNumbersOnRulers
show/hide numbers on rulers
void createGeometry()
initial creation function for the slice geometry
Class representing a single module of OpenWalnut.
Definition: WModule.h:72