29 #include <osg/LineWidth>
30 #include <osg/LightModel>
31 #include <osg/Geometry>
33 #include "../common/WLogger.h"
34 #include "shaders/WGEShader.h"
37 #include "WGraphicsEngine.h"
39 #include "WGEGeodeUtils.h"
48 m_oldScrollWheel( 0 ),
49 m_color( osg::Vec4( 0.391f, 0.594f, 0.828f, 0.5f ) ),
50 m_notColor( osg::Vec4( 0.828f, 0.391f, 0.391f, 0.5f ) )
53 m_minPos =
m_propGrp->addProperty(
"Min Position",
"When a box is described by its diagonal, this is the lower, left, front corner of it.",
55 m_maxPos =
m_propGrp->addProperty(
"Max Position",
"When a box is described by its diagonal, this is the upper, right, back corner of it.",
60 boost::shared_ptr< WGEViewer > viewer = ge->getViewerByName(
"Main View" );
67 ss <<
"ROIBox" <<
boxId;
70 osg::StateSet* state = getOrCreateStateSet();
71 state->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
73 osg::LineWidth* linewidth =
new osg::LineWidth();
74 linewidth->setWidth( 2.0f );
75 state->setAttributeAndModes( linewidth, osg::StateAttribute::ON );
77 osg::ref_ptr< osg::LightModel > lightModel =
new osg::LightModel();
78 lightModel->setTwoSided(
true );
80 state->setMode( GL_BLEND, osg::StateAttribute::ON );
125 boost::unique_lock< boost::shared_mutex > lock;
126 lock = boost::unique_lock< boost::shared_mutex >(
m_updateLock );
140 boost::unique_lock< boost::shared_mutex > lock;
141 lock = boost::unique_lock< boost::shared_mutex >(
m_updateLock );
143 std::stringstream ss;
144 ss <<
"ROIBox" <<
boxId <<
"";
150 osg::Vec3 in( newPixelPos.x(), newPixelPos.y(), 0.0 );
157 WPosition toDepthWorld( toDepth[0], toDepth[1], toDepth[2] );
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;
193 m_minPos->set(
m_minPos->get() + moveVec + ( 2.0 * toDepthWorld * depthMove ) );
194 m_maxPos->set(
m_maxPos->get() + moveVec + ( 2.0 * toDepthWorld * depthMove ) );
215 updateColor( osg::Vec4( 0.0f, 1.0f, 0.0f, 0.4f ) );
252 m_surfaceGeometry->addPrimitiveSet(
new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 0, 4 ) );
253 m_surfaceGeometry->addPrimitiveSet(
new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 4, 4 ) );
254 m_surfaceGeometry->addPrimitiveSet(
new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 8, 4 ) );
255 m_surfaceGeometry->addPrimitiveSet(
new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 12, 4 ) );
256 m_surfaceGeometry->addPrimitiveSet(
new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 16, 4 ) );
257 m_surfaceGeometry->addPrimitiveSet(
new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 20, 4 ) );
297 osg::ref_ptr<osg::Vec4Array> colors = osg::ref_ptr<osg::Vec4Array>(
new osg::Vec4Array );
298 colors->push_back( color );
300 WColor outline( 0.0, 0.0, 0.0, 1.0 );
302 colors->push_back( outline );
303 colors->push_back( outline );
304 colors->push_back( outline );
305 colors->push_back( outline );
306 colors->push_back( outline );
307 colors->push_back( outline );