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