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