OpenWalnut  1.4.0
WROISphere.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 WROISPHERE_H
26 #define WROISPHERE_H
27 
28 #include <utility>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/thread.hpp>
32 #endif
33 
34 #include "../common/math/linearAlgebra/WPosition.h"
35 #include "WPickHandler.h"
36 #include "WGEViewer.h"
37 
38 #include "WROI.h"
39 
40 
41 
42 /**
43  * A sphere representing a region of interest.
44  */
45 class WROISphere : public WROI
46 {
47 public:
48  /**
49  * Yields sphere with desired center point and radius
50  * \param position position of the center of the sphere
51  * \param radius radius of the sphere
52  */
53  WROISphere( WPosition position, float radius = 5.0 );
54 
55  /**
56  * standard destructor
57  */
58  virtual ~WROISphere();
59 
60  /**
61  * getter
62  * \return position
63  */
64  WPosition getPosition() const;
65 
66  /**
67  * setter
68  * \param position
69  */
70  void setPosition( WPosition position );
71 
72  /**
73  * setter
74  * \param x
75  * \param y
76  * \param z
77  */
78  void setPosition( float x, float y, float z );
79 
80  /**
81  * Setter for standard color
82  * \param color The new color.
83  */
84  void setColor( osg::Vec4 color );
85 
86  /**
87  * Setter for color in negated state
88  * \param color The new color.
89  */
90  void setNotColor( osg::Vec4 color );
91 
92  /**
93  * removes the old drawable from the osg geode and adds a new one at the current position and size
94  */
95  void redrawSphere();
96 
97  /**
98  * sets the flag that allows or disallows movement along the x axis
99  *
100  * \param value the flag
101  */
102  void setLockX( bool value = true );
103 
104  /**
105  * sets the flag that allows or disallows movement along the y axis
106  *
107  * \param value the flag
108  */
109  void setLockY( bool value = true );
110 
111  /**
112  * sets the flag that allows or disallows movement along the z axis
113  *
114  * \param value the flag
115  */
116  void setLockZ( bool value = true );
117 
118  /**
119  * move the sphere with a given offset
120  *
121  * \param offset the distance to move
122  */
123  void moveSphere( WVector3d offset );
124 
125  /**
126  * setter
127  * \param x sets the x component of the position of this sphere
128  */
129  void setX( float x );
130 
131  /**
132  * setter
133  * \param y sets the y component of the position of this sphere
134  */
135  void setY( float y );
136 
137  /**
138  * setter
139  * \param z sets the z component of the position of this sphere
140  */
141  void setZ( float z );
142 
143  /**
144  * setter
145  * \param vector together witht he current position this sets line in space to which the movement of the
146  * sphere is restricted
147  */
148  void setLockVector( WVector3d vector );
149 
150  /**
151  * setter
152  * \param value if the the movement of the sphere is restricted to a given vector
153  */
154  void setLockOnVector( bool value = true );
155 
156 protected:
157 private:
158  static size_t maxSphereId; //!< Current maximum boxId over all spheres.
159  size_t sphereId; //!< Id of the current sphere.
160 
161  WPosition m_position; //!< The position of the sphere
162 
163  WPosition m_originalPosition; //!< The position of the sphere when created, used for locking
164 
165  float m_radius; //!< The radius of the sphere
166 
167  bool m_isPicked; //!< Indicates whether the box is currently picked or not.
168 
169  WPosition m_pickedPosition; //!< Caches the old picked position to a allow for comparison
170 
171  WVector3d m_pickNormal; //!< Store the normal that occured when the pick action was started.
172 
173  WVector2d m_oldPixelPosition; //!< Caches the old picked position to a allow for cmoparison
174 
175  WPickInfo m_pickInfo; //!< Stores the pick information for potential redraw
176 
177  boost::shared_ptr< WGEViewer > m_viewer; //!< makes viewer available all over this class.
178 
179  osg::Vec4 m_color; //!< the color of the box
180 
181  osg::Vec4 m_notColor; //!< the color of the box when negated
182 
183  WVector3d m_lockPoint; //!< stores to point of origin of the lock vector
184 
185  WVector3d m_lockVector; //!< stores the lock vector
186 
187  bool m_lockOnVector; //!< flag indicatin wether the movement of the sphere is restricted
188 
189  bool m_lockX; //!< flag indicatin wether the movement of the sphere is restricted
190  bool m_lockY; //!< flag indicatin wether the movement of the sphere is restricted
191  bool m_lockZ; //!< flag indicatin wether the movement of the sphere is restricted
192 
193 
194  /**
195  * note that there was a pick
196  * \param pickInfo info from pick
197  */
198  void registerRedrawRequest( WPickInfo pickInfo );
199 
200  /**
201  * updates the graphics
202  */
203  virtual void updateGFX();
204 };
205 
206 #endif // WROISPHERE_H
void registerRedrawRequest(WPickInfo pickInfo)
note that there was a pick
Definition: WROISphere.cpp:142
WROISphere(WPosition position, float radius=5.0)
Yields sphere with desired center point and radius.
Definition: WROISphere.cpp:40
float m_radius
The radius of the sphere.
Definition: WROISphere.h:165
bool m_lockZ
flag indicatin wether the movement of the sphere is restricted
Definition: WROISphere.h:191
void setLockZ(bool value=true)
sets the flag that allows or disallows movement along the z axis
Definition: WROISphere.cpp:250
WVector3d m_lockPoint
stores to point of origin of the lock vector
Definition: WROISphere.h:183
WPickInfo m_pickInfo
Stores the pick information for potential redraw.
Definition: WROISphere.h:175
static size_t maxSphereId
Current maximum boxId over all spheres.
Definition: WROISphere.h:158
Superclass for different ROI (region of interest) types.
Definition: WROI.h:47
void setLockVector(WVector3d vector)
setter
Definition: WROISphere.cpp:268
WPosition m_originalPosition
The position of the sphere when created, used for locking.
Definition: WROISphere.h:163
bool m_lockX
flag indicatin wether the movement of the sphere is restricted
Definition: WROISphere.h:189
WVector3d m_lockVector
stores the lock vector
Definition: WROISphere.h:185
WPosition m_pickedPosition
Caches the old picked position to a allow for comparison.
Definition: WROISphere.h:169
This only is a 3d double vector.
boost::shared_ptr< WGEViewer > m_viewer
makes viewer available all over this class.
Definition: WROISphere.h:177
WVector3d m_pickNormal
Store the normal that occured when the pick action was started.
Definition: WROISphere.h:171
bool m_lockOnVector
flag indicatin wether the movement of the sphere is restricted
Definition: WROISphere.h:187
void moveSphere(WVector3d offset)
move the sphere with a given offset
Definition: WROISphere.cpp:209
void setLockOnVector(bool value=true)
setter
Definition: WROISphere.cpp:274
osg::Vec4 m_color
the color of the box
Definition: WROISphere.h:179
A fixed size matrix class.
Definition: WMatrixFixed.h:153
void setZ(float z)
setter
Definition: WROISphere.cpp:134
void setLockY(bool value=true)
sets the flag that allows or disallows movement along the y axis
Definition: WROISphere.cpp:244
void setNotColor(osg::Vec4 color)
Setter for color in negated state.
Definition: WROISphere.cpp:263
void redrawSphere()
removes the old drawable from the osg geode and adds a new one at the current position and size ...
Definition: WROISphere.cpp:74
A sphere representing a region of interest.
Definition: WROISphere.h:45
void setLockX(bool value=true)
sets the flag that allows or disallows movement along the x axis
Definition: WROISphere.cpp:238
bool m_isPicked
Indicates whether the box is currently picked or not.
Definition: WROISphere.h:167
bool m_lockY
flag indicatin wether the movement of the sphere is restricted
Definition: WROISphere.h:190
Encapsulates info for pick action.
Definition: WPickInfo.h:41
osg::Vec4 m_notColor
the color of the box when negated
Definition: WROISphere.h:181
virtual void updateGFX()
updates the graphics
Definition: WROISphere.cpp:147
WVector2d m_oldPixelPosition
Caches the old picked position to a allow for cmoparison.
Definition: WROISphere.h:173
void setColor(osg::Vec4 color)
Setter for standard color.
Definition: WROISphere.cpp:257
virtual ~WROISphere()
standard destructor
Definition: WROISphere.cpp:90
void setPosition(WPosition position)
setter
Definition: WROISphere.cpp:103
size_t sphereId
Id of the current sphere.
Definition: WROISphere.h:159
void setY(float y)
setter
Definition: WROISphere.cpp:127
WPosition m_position
The position of the sphere.
Definition: WROISphere.h:161
WPosition getPosition() const
getter
Definition: WROISphere.cpp:98
void setX(float x)
setter
Definition: WROISphere.cpp:120