OpenWalnut
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
src
core
graphicsEngine
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
#include <boost/thread.hpp>
31
32
#include "../common/math/linearAlgebra/WPosition.h"
33
#include "WPickHandler.h"
34
#include "WGEViewer.h"
35
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
boost::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
Generated by
1.8.1.2