OpenWalnut  1.4.0
WSelectionManager.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 WSELECTIONMANAGER_H
26 #define WSELECTIONMANAGER_H
27 
28 #include <vector>
29 
30 #include <boost/shared_ptr.hpp>
31 
32 #include "../common/WProperties.h"
33 #include "WCrosshair.h"
34 
35 
36 template< typename T>
38 
39 typedef enum
40 {
41  PAINTMODE_NONE = 0,
42  PAINTMODE_PAINT = 1
43 }
44 WPaintMode;
45 
46 /**
47  * manages the several selection tools
48  */
49 class WSelectionManager // NOLINT
50 {
51 public:
52  /**
53  * standard constructor
54  */
56 
57  /**
58  * destructor
59  */
60  virtual ~WSelectionManager();
61 
62  /**
63  * Return the current position of the point selection
64  *
65  * \return the crosshair
66  */
67  boost::shared_ptr< WCrosshair >getCrosshair();
68 
69  /**
70  * function returns an index of the direction one is currently looking at the scene
71  *
72  * \return index
73  */
74  int getFrontSector();
75 
76  /**
77  * setter for paint mode, also forwards it to the graphics engine
78  *
79  * \param mode
80  */
81  void setPaintMode( WPaintMode mode );
82 
83  /**
84  * getter for paint mode
85  *
86  * \return the mode
87  */
88  WPaintMode getPaintMode();
89 
90  /**
91  * setter for texture and grid
92  *
93  * \param texture
94  * \param grid
95  */
96  void setTexture( osg::ref_ptr< osg::Texture3D > texture, boost::shared_ptr< WGridRegular3D >grid );
97 
98  /**
99  * getter
100  * \return grid
101  */
102  boost::shared_ptr< WGridRegular3D >getGrid();
103 
104  /**
105  * setter
106  * \param flag
107  */
108  void setUseTexture( bool flag = true );
109 
110  /**
111  * getter
112  * \return flag
113  */
114  bool getUseTexture();
115 
116  /**
117  * getter
118  * \return the opacity
119  */
120  float getTextureOpacity();
121 
122  /**
123  * setter
124  * \param value the new opacity to use with the texture
125  */
126  void setTextureOpacity( float value );
127 
128  /**
129  * The property controlling the current axial position of slices.
130  *
131  * \return property as double
132  */
133  WPropDouble getPropAxialPos();
134 
135  /**
136  * The property controlling the current coronal position of slices.
137  *
138  * \return property as double
139  */
140  WPropDouble getPropCoronalPos();
141 
142  /**
143  * The property controlling the current sagittal position of slices.
144  *
145  * \return property as double
146  */
147  WPropDouble getPropSagittalPos();
148 
149 
150  /**
151  * The property controlling the current axial visible-flag.
152  *
153  * \return property as bool
154  */
155  WPropBool getPropAxialShow();
156 
157  /**
158  * The property controlling the current coronal visible-flag.
159  *
160  * \return property as bool
161  */
162  WPropBool getPropCoronalShow();
163 
164  /**
165  * The property controlling the current sagittal visible-flag.
166  *
167  * \return property as bool
168  */
169  WPropBool getPropSagittalShow();
170 
171  /**
172  * setter for the shader index to be used with the custom texture
173  * \param shader the index of the shader
174  */
175  void setShader( int shader );
176 
177  /**
178  * getter
179  * \return shader index
180  */
181  int getShader();
182 
183 protected:
184 private:
185  /**
186  * Updates the crosshair position
187  */
189 
190  boost::shared_ptr< WCrosshair >m_crosshair; //!< stores pointer to crosshair
191 
192  /**
193  * Contains the slice related properties
194  */
196 
197  /**
198  * Axial slice position.
199  */
200  WPropDouble m_axialPos;
201 
202  /**
203  * Coronal slice position.
204  */
205  WPropDouble m_coronalPos;
206 
207  /**
208  * Sagittal slice position.
209  */
210  WPropDouble m_sagittalPos;
211 
212  /**
213  * Axial visible-flag.
214  */
215  WPropBool m_axialShow;
216 
217  /**
218  * Coronal visible-flag.
219  */
220  WPropBool m_coronalShow;
221 
222  /**
223  * Sagittal visible-flag.
224  */
225  WPropBool m_sagittalShow;
226 
227  /**
228  * The connection for the axial property
229  */
230  boost::signals2::connection m_axialUpdateConnection;
231 
232  /**
233  * The connection for the coronal property
234  */
235  boost::signals2::connection m_coronalUpdateConnection;
236 
237  /**
238  * The connection for the sagittal property
239  */
240  boost::signals2::connection m_sagittalUpdateConnection;
241 
242  WPaintMode m_paintMode; //!< stores the currently selected paint mode
243 
244  /**
245  * stores a pointer to a texture 3d, this is used to provide a faster texture generation process
246  * than creating a new dataset for every texture change
247  */
248  osg::ref_ptr< osg::Texture3D > m_texture;
249 
250  /**
251  * stores a pointer to the grid to be used together with the texture
252  */
253  boost::shared_ptr< WGridRegular3D >m_textureGrid;
254 
255  /**
256  * the texture opacity
257  */
259 
260  /**
261  * flag indicating if this additional texture should be used.
262  */
264 
265  /**
266  * index of the shader to use with the texture
267  */
268  int m_shader;
269 };
270 
271 #endif // WSELECTIONMANAGER_H