30 #include <osg/ShapeDrawable>
33 #include "WGraphicsEngine.h"
34 #include "WROISphere.h"
35 #include "callbacks/WGEFunctorCallback.h"
42 sphereId( maxSphereId++ ),
43 m_position( position ),
44 m_originalPosition( position ),
48 m_color( osg::Vec4( 0.f, 1.f, 1.f, 0.4f ) ),
49 m_notColor( osg::Vec4( 1.0f, 0.0f, 0.0f, 0.4f ) ),
50 m_lockPoint(
WVector3d( 0.0, 0.0, 0.0 ) ),
51 m_lockVector(
WVector3d( 1.0, 1.0, 1.0 ) ),
52 m_lockOnVector( false ),
59 std::shared_ptr< WGEViewer > viewer = ge->getViewerByName(
"Main View" );
85 shape->setName( ss.str() );
149 std::stringstream ss;
150 ss <<
"ROISphere" <<
sphereId <<
"";
151 bool mouseMove =
false;
158 osg::Vec3 in( newPixelPos.
x(), newPixelPos.
y(), 0.0 );
161 WPosition newPixelWorldPos( world[0], world[1], world[2] );
165 oldPixelWorldPos = newPixelWorldPos;
171 oldPixelWorldPos =
WPosition( world[0], world[1], world[2] );
174 WVector3d moveVec = newPixelWorldPos - oldPixelWorldPos;
176 osg::ref_ptr<osg::Vec3Array> vertices = osg::ref_ptr<osg::Vec3Array>(
new osg::Vec3Array );
This callback allows you a simple usage of callbacks in your module.
static std::shared_ptr< WGraphicsEngine > getGraphicsEngine()
Returns instance of the graphics engine.
ValueT & y()
Access y element of vector.
ValueT & x()
Access x element of vector.
static const std::string unpickString
The string indicating picking has stopped.
Encapsulates info for pick action.
WVector2d getPickPixel() const
Returns the picked pixel coordinates in screen-space.
std::string getName() const
Get name of picked object.
modifierKey getModifierKey() const
Get the modifier key associated with the pick.
This only is a 3d double vector.
bool m_lockX
flag indicatin wether the movement of the sphere is restricted
virtual ~WROISphere()
standard destructor
void redrawSphere()
removes the old drawable from the osg geode and adds a new one at the current position and size
osg::Vec4 m_notColor
the color of the box when negated
virtual void updateGFX()
updates the graphics
WVector3d m_pickNormal
Store the normal that occured when the pick action was started.
static size_t maxSphereId
Current maximum boxId over all spheres.
void setLockY(bool value=true)
sets the flag that allows or disallows movement along the y axis
osg::Vec4 m_color
the color of the box
void setLockVector(WVector3d vector)
setter
WPosition getPosition() const
getter
void registerRedrawRequest(WPickInfo pickInfo)
note that there was a pick
WVector3d m_lockVector
stores the lock vector
void setPosition(WPosition position)
setter
void setLockZ(bool value=true)
sets the flag that allows or disallows movement along the z axis
std::shared_ptr< WGEViewer > m_viewer
makes viewer available all over this class.
void setLockOnVector(bool value=true)
setter
bool m_lockZ
flag indicatin wether the movement of the sphere is restricted
bool m_isPicked
Indicates whether the box is currently picked or not.
float m_radius
The radius of the sphere.
void setLockX(bool value=true)
sets the flag that allows or disallows movement along the x axis
WPickInfo m_pickInfo
Stores the pick information for potential redraw.
size_t sphereId
Id of the current sphere.
WPosition m_position
The position of the sphere.
bool m_lockOnVector
flag indicatin wether the movement of the sphere is restricted
void setNotColor(osg::Vec4 color)
Setter for color in negated state.
bool m_lockY
flag indicatin wether the movement of the sphere is restricted
WROISphere(WPosition position, float radius=5.0)
Yields sphere with desired center point and radius.
WVector2d m_oldPixelPosition
Caches the old picked position to a allow for cmoparison.
void moveSphere(WVector3d offset)
move the sphere with a given offset
WVector3d m_lockPoint
stores to point of origin of the lock vector
WPosition m_originalPosition
The position of the sphere when created, used for locking.
void setColor(osg::Vec4 color)
Setter for standard color.
Superclass for different ROI (region of interest) types.
osg::ref_ptr< WPickHandler > m_pickHandler
A pointer to the pick handler used to get gui events for moving the box.
void signalRoiChange()
signals a roi change to all subscribers
WPropBool m_dirty
dirty flag, indicating the graphics needs updating, it is no longer used for bitfield updating since ...
osg::Vec3 unprojectFromScreen(const osg::Vec3 screen, osg::ref_ptr< WGECamera > camera)
Converts screen coordinates into Camera coordinates.