Commit bd3f0230 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents 5f64e6c2 a5882c53
......@@ -108,6 +108,8 @@ protected:
boost::thread* m_Thread;
#else
OpenThreads::Thread *m_Thread;
bool m_firstRun;
#endif
/**
......
......@@ -71,6 +71,11 @@ bool WPickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
}
return false;
}
case osgGA::GUIEventAdapter::KEYUP : // Key on keyboard released.
{
m_shift = false;
return false;
}
case osgGA::GUIEventAdapter::KEYDOWN : // Key on keyboard pushed.
{
if ( ea.getKey() == 'c' )
......@@ -84,6 +89,10 @@ bool WPickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
pick( view, *event );
}
}
if ( ea.getKey() == osgGA::GUIEventAdapter::KEY_Shift_L )
{
m_shift = true;
}
return false;
}
default:
......@@ -155,7 +164,17 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
pickPos[0] = hitr->getWorldIntersectPoint()[0];
pickPos[1] = hitr->getWorldIntersectPoint()[1];
pickPos[2] = hitr->getWorldIntersectPoint()[2];
pickInfo = WPickInfo( extractSuitableName( hitr ), pickPos, std::make_pair( x, y ), WPickInfo::NONE );
wmath::WVector3D pickNormal;
pickNormal[0] = hitr->getWorldIntersectNormal()[0];
pickNormal[1] = hitr->getWorldIntersectNormal()[1];
pickNormal[2] = hitr->getWorldIntersectNormal()[2];
pickInfo = WPickInfo( extractSuitableName( hitr ), pickPos, std::make_pair( x, y ), WPickInfo::NONE, pickNormal );
}
if( m_shift )
{
pickInfo.setModifierKey( WPickInfo::SHIFT );
}
m_hitResult = pickInfo;
......
......@@ -98,6 +98,7 @@ protected:
WPickInfo m_hitResult; //!< Textual representation of the result of a pick.
WPickInfo m_startPick; //!< indicates what was first picked. Should be "" after unpick.
bool m_shift; //!< is shift pressed?
private:
boost::signals2::signal1<void, WPickInfo > m_pickSignal; //!< One can register to this signal to receive pick events.
......
......@@ -29,6 +29,7 @@
#include <utility>
#include "../math/WPosition.h"
#include "../math/WVector3D.h"
/**
* Encapsulates info for pick action.
......@@ -54,8 +55,13 @@ public:
* \param pickPosition position where object was hit
* \param pixelCoords pixel coordinates fo the mouse
* \param modKey relevant modifier key pressed during the pick
* \param pickNormal normal at position where object was hit. (0,0,0) means not set.
*/
inline WPickInfo( std::string name, wmath::WPosition pickPosition, std::pair< float, float > pixelCoords, modifierKey modKey );
inline WPickInfo( std::string name,
wmath::WPosition pickPosition,
std::pair< float, float > pixelCoords,
modifierKey modKey,
wmath::WVector3D pickNormal = wmath::WVector3D() );
/**
* Creates an object with the empty name, zero position and no modkey.
......@@ -65,34 +71,45 @@ public:
/**
* Get the modifier key associated with the pick
*/
inline modifierKey getModifierKey();
inline modifierKey getModifierKey() const;
/**
* Set the modifier key associated with the pick
* \param modKey new modifier key
*/
inline void setModifierKey( const modifierKey& modKey );
/**
* Get name of picked object.
*/
inline std::string getName();
inline std::string getName() const;
/**
* Get position where object was hit.
*/
inline wmath::WPosition getPickPosition();
inline wmath::WPosition getPickPosition() const;
/**
* Get normal at position where object was hit.
*/
inline wmath::WVector3D getPickNormal() const;
/**
* Get pixel coordinates where object was hit.
*/
inline std::pair< float, float > getPickPixelPosition();
inline std::pair< float, float > getPickPixelPosition() const;
/**
* Tests two pick infos for equality
* \param rhs right hand side of comparison
*/
inline bool operator==( WPickInfo rhs );
inline bool operator==( WPickInfo rhs ) const;
/**
* Tests two pick infos for inequality
* \param rhs right hand side of comparison
*/
inline bool operator!=( WPickInfo rhs );
inline bool operator!=( WPickInfo rhs ) const;
protected:
private:
......@@ -101,13 +118,19 @@ private:
wmath::WPosition m_pickPosition; //!< position where object was hit.
std::pair< float, float > m_pixelCoords; //!< Pixel coordinates of the mouse.
modifierKey m_modKey; //!< modifier key associated with the pick
wmath::WVector3D m_pickNormal; //!< normal at position where object was hit.
};
WPickInfo::WPickInfo( std::string name, wmath::WPosition pickPosition, std::pair< float, float > pixelCoords, modifierKey modKey ) :
WPickInfo::WPickInfo( std::string name,
wmath::WPosition pickPosition,
std::pair< float, float > pixelCoords,
modifierKey modKey,
wmath::WVector3D pickNormal ) :
m_name( name ),
m_pickPosition( pickPosition ),
m_pixelCoords( pixelCoords ),
m_modKey( modKey )
m_modKey( modKey ),
m_pickNormal( pickNormal )
{
}
......@@ -119,34 +142,45 @@ WPickInfo::WPickInfo() :
{
}
WPickInfo::modifierKey WPickInfo::getModifierKey()
WPickInfo::modifierKey WPickInfo::getModifierKey() const
{
return m_modKey;
}
std::string WPickInfo::getName()
void WPickInfo::setModifierKey( const modifierKey& modKey )
{
m_modKey = modKey;
}
std::string WPickInfo::getName() const
{
return m_name;
}
wmath::WPosition WPickInfo::getPickPosition()
wmath::WPosition WPickInfo::getPickPosition() const
{
return m_pickPosition;
}
std::pair< float, float > WPickInfo::getPickPixelPosition()
wmath::WVector3D WPickInfo::getPickNormal() const
{
return m_pickNormal;
}
std::pair< float, float > WPickInfo::getPickPixelPosition() const
{
return m_pixelCoords;
}
inline bool WPickInfo::operator==( WPickInfo rhs )
inline bool WPickInfo::operator==( WPickInfo rhs ) const
{
return ( this->m_name == rhs.m_name
&& this->m_pickPosition == rhs.m_pickPosition
&& this->m_modKey == rhs.m_modKey );
}
inline bool WPickInfo::operator!=( WPickInfo rhs )
inline bool WPickInfo::operator!=( WPickInfo rhs ) const
{
return !( *this == rhs );
}
......
......@@ -70,7 +70,7 @@ public:
protected:
osg::ref_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box.
osg::Geode* m_geode; //!< The graphical representation of the ROI.
osg::ref_ptr< osg::Geode> m_geode; //!< The graphical representation of the ROI.
bool m_isModified; //!< Indicates whether a changed ROI has already taken effect. Means: if true, still some updates needed.
/**
......
......@@ -127,17 +127,18 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
m_pickHandler = m_viewer->getPickHandler();
m_pickHandler->getPickSignal()->connect( boost::bind( &WROIBox::registerRedrawRequest, this, _1 ) );
osg::Geometry* surfaceGeometry = new osg::Geometry();
m_geode = new osg::Geode;
m_surfaceGeometry = osg::ref_ptr<osg::Geometry>( new osg::Geometry() );
m_surfaceGeometry->setDataVariance( osg::Object::DYNAMIC );
m_geode = osg::ref_ptr<osg::Geode>( new osg::Geode );
std::stringstream ss;
ss << "ROIBox" << boxId;
m_geode->setName( ss.str() );
osg::Vec3Array* vertices = new osg::Vec3Array;
osg::ref_ptr<osg::Vec3Array> vertices = osg::ref_ptr<osg::Vec3Array>( new osg::Vec3Array );
setVertices( vertices, minPos, maxPos );
surfaceGeometry->setVertexArray( vertices );
m_surfaceGeometry->setVertexArray( vertices );
osg::DrawElementsUInt* surfaceElements;
surfaceElements = new osg::DrawElementsUInt( osg::PrimitiveSet::QUADS, 0 );
......@@ -147,9 +148,9 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
lineElements = new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
buildLinesFromPoints( lineElements );
surfaceGeometry->addPrimitiveSet( surfaceElements );
surfaceGeometry->addPrimitiveSet( lineElements );
m_geode->addDrawable( surfaceGeometry );
m_surfaceGeometry->addPrimitiveSet( surfaceElements );
m_surfaceGeometry->addPrimitiveSet( lineElements );
m_geode->addDrawable( m_surfaceGeometry );
osg::StateSet* state = m_geode->getOrCreateStateSet();
state->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
......@@ -159,11 +160,11 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
// ------------------------------------------------
// colors
osg::Vec4Array* colors = new osg::Vec4Array;
osg::ref_ptr<osg::Vec4Array> colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );
colors->push_back( osg::Vec4( .0f, .0f, 1.f, 0.5f ) );
surfaceGeometry->setColorArray( colors );
surfaceGeometry->setColorBinding( osg::Geometry::BIND_OVERALL );
m_surfaceGeometry->setColorArray( colors );
m_surfaceGeometry->setColorBinding( osg::Geometry::BIND_OVERALL );
osg::ref_ptr< osg::LightModel > lightModel = new osg::LightModel();
lightModel->setTwoSided( true );
......@@ -238,17 +239,39 @@ void WROIBox::updateGFX()
wmath::WVector3D moveVec = newPixelWorldPos - oldPixelWorldPos;
osg::Vec3Array* vertices = new osg::Vec3Array;
m_minPos += moveVec;
m_maxPos += moveVec;
setVertices( vertices, m_minPos, m_maxPos );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setVertexArray( vertices );
osg::ref_ptr<osg::Vec3Array> vertices = osg::ref_ptr<osg::Vec3Array>( new osg::Vec3Array );
// resize Box
if( m_pickInfo.getModifierKey() == WPickInfo::SHIFT && m_pickInfo.getPickNormal() != wmath::WVector3D() )
{
wmath::WVector3D normal = m_pickInfo.getPickNormal();
if( normal[0] <= 0 && normal[1] <= 0 && normal[2] <= 0 )
{
m_maxPos += normal * ( moveVec * normal );
}
if( normal[0] >= 0 && normal[1] >= 0 && normal[2] >= 0 )
{
m_minPos += normal * ( moveVec * normal );
}
setVertices( vertices, m_minPos, m_maxPos );
m_surfaceGeometry->setVertexArray( vertices );
}
// move Box
if( m_pickInfo.getModifierKey() == WPickInfo::NONE )
{
m_minPos += moveVec;
m_maxPos += moveVec;
setVertices( vertices, m_minPos, m_maxPos );
m_surfaceGeometry->setVertexArray( vertices );
}
}
else
{
osg::Vec4Array* colors = new osg::Vec4Array;
osg::ref_ptr<osg::Vec4Array> colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );
colors->push_back( osg::Vec4( 1.f, .0f, .0f, 0.5f ) );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setColorArray( colors );
m_surfaceGeometry->setColorArray( colors );
}
m_pickedPosition = newPos;
m_oldPixelPosition = newPixelPos;
......@@ -259,9 +282,9 @@ void WROIBox::updateGFX()
}
if ( m_isPicked && m_pickInfo.getName() == "unpick" )
{
osg::Vec4Array* colors = new osg::Vec4Array;
osg::ref_ptr<osg::Vec4Array> colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );
colors->push_back( osg::Vec4( 0.f, 0.f, 1.f, 0.5f ) );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setColorArray( colors );
m_surfaceGeometry->setColorArray( colors );
m_isPicked = false;
}
......
......@@ -75,6 +75,7 @@ private:
wmath::WPosition m_pickedPosition; //!< Caches the old picked position to a allow for cmoparison
std::pair< float, float > m_oldPixelPosition; //!< Caches the old picked position to a allow for cmoparison
boost::shared_mutex m_updateLock; //!< Lock to prevent concurrent threads trying to update the osg node
osg::ref_ptr< osg::Geometry > m_surfaceGeometry; //!< store this pointer for use in updates
WPickInfo m_pickInfo; //!< Stores the pick information for potential redraw
......@@ -94,7 +95,7 @@ private:
/**
* Get wordl coordinates from screen coordinates.
* \return the world coordinates.
* \param screen the screen coordinates in pixels and z depth.
* \param screen the screen coordinates in pixels and z depth.
*/
osg::Vec3 unprojectFromScreen( const osg::Vec3 screen );
......
......@@ -31,8 +31,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/signals2/signal.hpp>
#include "../common/WThreadedRunner.h"
#include "../common/WFlag.h"
//#include "../common/WThreadedRunner.h"
//#include "../common/WFlag.h"
#include "../kernel/WModule.h"
#include "../graphicsEngine/WGECamera.h"
#include "WCustomWidget.h"
......
......@@ -39,7 +39,11 @@
WQtGLWidget::WQtGLWidget( std::string nameOfViewer, QWidget* parent, WGECamera::ProjectionMode projectionMode )
#ifdef _WIN32
: QWidget( parent ),
#else
: QGLWidget( parent ),
#endif
m_nameOfViewer( nameOfViewer ),
m_recommendedSize(),
m_isInitialized( new WConditionOneShot(), false ),
......@@ -224,7 +228,24 @@ int WQtGLWidget::translateButton( QMouseEvent* event )
void WQtGLWidget::keyPressEvent( QKeyEvent* event )
{
m_Viewer->keyEvent( WGEViewer::KEYPRESS, *event->text().toAscii().data() );
if( event->text() != "" )
{
m_Viewer->keyEvent( WGEViewer::KEYPRESS, *event->text().toAscii().data() );
}
else
{
switch( event->modifiers() )
{
case Qt::ShiftModifier :
m_Viewer->keyEvent( WGEViewer::KEYPRESS, osgGA::GUIEventAdapter::KEY_Shift_L );
break;
case Qt::ControlModifier :
m_Viewer->keyEvent( WGEViewer::KEYPRESS, osgGA::GUIEventAdapter::KEY_Control_L );
break;
default :
std::cout << "Modifier key has no meaning yet." << std::endl;
}
}
}
void WQtGLWidget::keyReleaseEvent( QKeyEvent* event )
......@@ -254,6 +275,16 @@ void WQtGLWidget::keyReleaseEvent( QKeyEvent* event )
break;
}
switch( event->modifiers() )
{
case Qt::ShiftModifier :
m_Viewer->keyEvent( WGEViewer::KEYRELEASE, osgGA::GUIEventAdapter::KEY_Shift_L );
break;
case Qt::ControlModifier :
m_Viewer->keyEvent( WGEViewer::KEYRELEASE, osgGA::GUIEventAdapter::KEY_Control_L );
break;
}
m_Viewer->keyEvent( WGEViewer::KEYRELEASE, *event->text().toAscii().data() );
}
......
......@@ -44,7 +44,12 @@ class WColor;
* engine.
* \ingroup gui
*/
class WQtGLWidget: public QGLWidget
class WQtGLWidget
#ifdef _WIN32
: public QWidget
#else
: public QGLWidget
#endif
{
public:
/**
......
......@@ -497,12 +497,10 @@ boost::shared_ptr< WRMROIRepresentation > WQtDatasetBrowser::getSelectedRoi()
if ( m_treeWidget->selectedItems().at( 0 )->type() == ROI )
{
roi =( static_cast< WQtRoiTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getRoi();
std::cout << "return this" << std::endl;
}
if ( m_treeWidget->selectedItems().at( 0 )->type() == SUBROI )
{
roi =( static_cast< WQtRoiTreeItem* >( m_treeWidget->selectedItems().at( 0 )->parent() ) )->getRoi();
std::cout << "return parent" << std::endl;
}
return roi;
}
......@@ -41,8 +41,8 @@
#include "../dataHandler/WDataHandler.h"
#include "../common/WPreferences.h"
#include "../common/WStringUtils.h"
#include "WBatchLoader.h"
#include "WModule.h"
#include "WBatchLoader.h"
#include "WModuleFactory.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......
......@@ -179,7 +179,7 @@ const std::set<boost::shared_ptr< WModuleOutputConnector > >& WModule::getOutput
return m_outputConnectors;
}
boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name ) const
boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name )
{
// simply search
for( std::set<boost::shared_ptr< WModuleInputConnector > >::iterator listIter = m_inputConnectors.begin();
......@@ -195,7 +195,7 @@ boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::stri
throw WModuleConnectorNotFound( "The connector \"" + name + "\" does not exist in the module \"" + getName() + "\"." );
}
boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name ) const
boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name )
{
// simply search
for( std::set<boost::shared_ptr< WModuleOutputConnector > >::iterator listIter = m_outputConnectors.begin();
......
......@@ -98,7 +98,7 @@ public:
* \return the connector.
* \throw WModuleConnectorNotFound thrown whenever the module does not provide the specified connector.
*/
boost::shared_ptr< WModuleInputConnector > getInputConnector( std::string name ) const;
boost::shared_ptr< WModuleInputConnector > getInputConnector( std::string name );
/**
* Gives back output connectors.
......@@ -115,7 +115,7 @@ public:
* \return the connector.
* \throw WModuleConnectorNotFound thrown whenever the module does not provide the specified connector.
*/
boost::shared_ptr< WModuleOutputConnector > getOutputConnector( std::string name ) const;
boost::shared_ptr< WModuleOutputConnector > getOutputConnector( std::string name );
/**
* Return a pointer to the properties object of the module.
......
......@@ -62,13 +62,11 @@ void WROIManagerFibers::addRoi( boost::shared_ptr< WROI > newRoi, boost::shared_
{
// find branch
boost::shared_ptr< WRMBranch > branch;
std::cout << "add roi" << std::endl;
for ( std::list< boost::shared_ptr< WRMBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
if ( ( *iter ).get()->getFirstRoi()->getROI() == parentRoi )
{
branch = ( *iter );
std::cout << "branch found" << std::endl;
}
}
// create roi
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <string>
......
......@@ -202,9 +202,11 @@ void WMHud::updatePickText( WPickInfo pickInfo )
lock = boost::unique_lock< boost::shared_mutex >( m_updateLock );
std::ostringstream os;
os << pickInfo.getName() << "\n"
<< pickInfo.getPickPosition() << "\n"
<< pickInfo.getPickPixelPosition().first << " " << pickInfo.getPickPixelPosition().second;
os << "Name: " << pickInfo.getName() << "\n"
<< "Position: " << pickInfo.getPickPosition() << "\n"
<< "Pixel coordinates: " << pickInfo.getPickPixelPosition().first << " " << pickInfo.getPickPixelPosition().second << "\n"
<< "Object normal: " << pickInfo.getPickNormal();
m_pickText = os.str();
lock.unlock();
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <string>
......@@ -198,7 +200,7 @@ void WMWriteNIfTI::writeToFile()
if( nifti_set_filenames( outField, m_filename->get().file_string().c_str(), 0, 1 ) )
{
throw WException( "NIfTI filename Problem" );
throw WException( std::string( "NIfTI filename Problem" ) );
}
nifti_image_write( outField );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment