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