Commit 89dee467 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[MERGE]

parents a4fb966e 5ad374a6
......@@ -1010,7 +1010,6 @@ void WGridRegular3D::stretch( wmath::WPosition str )
m_matrixInverse = wmath::invertMatrix4x4( m_matrix );
}
// TODO(all): compiler warning: warning: unused parameter 'center'
void WGridRegular3D::rotate( osg::Matrixf osgrot, wmath::WPosition center )
{
switch ( m_matrixActive )
......@@ -1033,6 +1032,20 @@ void WGridRegular3D::rotate( osg::Matrixf osgrot, wmath::WPosition center )
wmath::WMatrix<double> rotmat( 4, 4 );
rotmat.makeIdentity();
wmath::WMatrix<double> transTo( 4, 4 );
transTo.makeIdentity();
wmath::WMatrix<double> transFrom( 4, 4 );
transFrom.makeIdentity();
transTo( 0, 3 ) = -center.x();
transTo( 1, 3 ) = -center.y();
transTo( 2, 3 ) = -center.z();
transFrom( 0, 3 ) = center.x();
transFrom( 1, 3 ) = center.y();
transFrom( 2, 3 ) = center.z();
rotmat( 0, 0 ) = osgrot( 0, 0 );
rotmat( 1, 0 ) = osgrot( 1, 0 );
rotmat( 2, 0 ) = osgrot( 2, 0 );
......@@ -1045,7 +1058,9 @@ void WGridRegular3D::rotate( osg::Matrixf osgrot, wmath::WPosition center )
rotmat( 1, 2 ) = osgrot( 1, 2 );
rotmat( 2, 2 ) = osgrot( 2, 2 );
m_rotMatrix = m_rotMatrix * transFrom;
m_rotMatrix = m_rotMatrix * rotmat;
m_rotMatrix = m_rotMatrix * transTo;
m_matrix = m_matrix * m_translateMatrix;
m_matrix = m_matrix * m_stretchMatrix;
......
......@@ -22,13 +22,19 @@
//
//---------------------------------------------------------------------------
#include <ctime>
#include <iostream>
#include "boost/date_time/posix_time/posix_time.hpp"
#include "WGEShaderAnimationCallback.h"
WGEShaderAnimationCallback::WGEShaderAnimationCallback( int ticksPerSecond ):
osg::Uniform::Callback(),
m_ticksPerSec( ticksPerSecond )
m_start( boost::posix_time::microsec_clock::local_time() ),
m_ticksPerSec( ticksPerSecond ),
m_tickMillisecRatio( static_cast< double >( ticksPerSecond ) / 1000.0 )
{
m_timer.restart();
}
WGEShaderAnimationCallback::~WGEShaderAnimationCallback()
......@@ -38,8 +44,15 @@ WGEShaderAnimationCallback::~WGEShaderAnimationCallback()
void WGEShaderAnimationCallback::operator() ( osg::Uniform* uniform, osg::NodeVisitor* /*nv*/ )
{
// boost::timer measures seconds ...
int ticks = static_cast< int >( m_timer.elapsed() * m_ticksPerSec );
// according to boost doc, this is available on windows too! From boost doc "Get the local time using a sub second resolution clock. On Unix
// systems this is implemented using GetTimeOfDay. On most Win32 platforms it is implemented using ftime. Win32 systems often do not achieve
// microsecond resolution via this API. If higher resolution is critical to your application test your platform to see the achieved resolution.
// -> fortunately, millisecond resolution is enough here.
boost::posix_time::ptime t = boost::posix_time::microsec_clock::local_time();
boost::posix_time::time_duration td = t - m_start;
int ticks = static_cast< int >( static_cast< double >( td.total_milliseconds() ) * m_tickMillisecRatio );
uniform->set( ticks );
}
......@@ -27,7 +27,8 @@
#include "stdint.h"
#include <boost/timer.hpp>
#include "boost/date_time/posix_time/posix_time.hpp"
#include <osg/Uniform>
#include "../WExportWGE.h"
......@@ -62,15 +63,20 @@ public:
protected:
/**
* Timer that stops the time hopefully OS independent
*/
boost::timer m_timer;
* Timer that stops the time hopefully OS independent
*/
boost::posix_time::ptime m_start;
/**
* Number of ticks to count per second.
*/
int m_ticksPerSec;
/**
* Ratio between milliseconds and m_ticksPerSec
*/
double m_tickMillisecRatio;
private:
};
......
......@@ -283,17 +283,23 @@ void WMDatasetManipulator::manipulatorMoved()
wmath::WPosition stretch( 1.0, 1.0, 1.0 );
m_grid->translate( wmath::WPosition( m_grid->getTranslate().x() + m_knobx1->getPosition().x() - m_posx1.x(),
m_grid->getTranslate().y() + m_knoby1->getPosition().y() - m_posy1.y(),
m_grid->getTranslate().z() + m_knobz1->getPosition().z() - m_posz1.z() ) );
float orgsizex = static_cast<float>( ( m_posx2Orig - m_posx1Orig ).x() );
float orgsizey = static_cast<float>( ( m_posy2Orig - m_posy1Orig ).y() );
float orgsizez = static_cast<float>( ( m_posz2Orig - m_posz1Orig ).z() );
m_grid->translate( wmath::WPosition( m_grid->getTranslate().x() + ( m_knobx1->getPosition().x() - m_posx1.x() ) *
( static_cast<float>( m_grid->getNbCoordsX() / orgsizex ) ),
m_grid->getTranslate().y() + ( m_knoby1->getPosition().y() - m_posy1.y() ) *
( static_cast<float>( m_grid->getNbCoordsY() / orgsizey ) ),
m_grid->getTranslate().z() + ( m_knobz1->getPosition().z() - m_posz1.z() ) *
( static_cast<float>( m_grid->getNbCoordsZ() / orgsizez ) ) ) );
m_translationX->set( m_grid->getTranslate().x(), true );
m_translationY->set( m_grid->getTranslate().y(), true );
m_translationZ->set( m_grid->getTranslate().z(), true );
stretch.x() = ( m_knobx2->getPosition().x() - m_knobx1->getPosition().x() ) / static_cast<float>( m_grid->getNbCoordsX() );
stretch.y() = ( m_knoby2->getPosition().y() - m_knoby1->getPosition().y() ) / static_cast<float>( m_grid->getNbCoordsY() );
stretch.z() = ( m_knobz2->getPosition().z() - m_knobz1->getPosition().z() ) / static_cast<float>( m_grid->getNbCoordsZ() );
stretch.x() = ( m_knobx2->getPosition().x() - m_knobx1->getPosition().x() ) / orgsizex;
stretch.y() = ( m_knoby2->getPosition().y() - m_knoby1->getPosition().y() ) / orgsizey;
stretch.z() = ( m_knobz2->getPosition().z() - m_knobz1->getPosition().z() ) / orgsizez;
m_grid->stretch( stretch );
......
......@@ -288,22 +288,21 @@ void WMEEGView::moduleMain()
{
debugLog() << "New event position: " << event->getTime();
if( boost::shared_ptr< WRMROIRepresentation > roi = m_roi.lock() )
if( m_roi )
{
WKernel::getRunningKernel()->getRoiManager()->removeRoi( roi );
WKernel::getRunningKernel()->getRoiManager()->removeRoi( m_roi );
}
if( WKernel::getRunningKernel()->getRoiManager()->getBitField() && m_sourceCalculator )
if( m_sourceCalculator )
{
wmath::WPosition position = m_sourceCalculator->calculate( event );
m_roi = WKernel::getRunningKernel()->getRoiManager()->addRoi( new WROIBox(
position - wmath::WVector3D( 5.0, 5.0, 5.0 ),
position + wmath::WVector3D( 5.0, 5.0, 5.0 ) ) );
m_roi = new WROIBox( position - wmath::WVector3D( 5.0, 5.0, 5.0 ),
position + wmath::WVector3D( 5.0, 5.0, 5.0 ) );
WKernel::getRunningKernel()->getRoiManager()->addRoi( m_roi );
}
else
{
m_roi.reset();
m_roi.release();
}
m_currentEventTime = event->getTime();
......@@ -600,7 +599,7 @@ osg::ref_ptr< osg::Node > WMEEGView::drawElectrodes()
boost::shared_ptr< WEEGChannelInfo > channelInfo = m_eeg->getChannelInfo( channelID );
try
{
osg::Vec3 pos = wge::osgVec3( channelInfo->getPosition() );
osg::Vec3 pos = channelInfo->getPosition();
// create sphere geode on electrode position
osg::ShapeDrawable* shape = new osg::ShapeDrawable( new osg::Sphere( pos, sphereSize ) );
......@@ -687,7 +686,7 @@ osg::ref_ptr< osg::Node > WMEEGView::drawLabels()
boost::shared_ptr< WEEGChannelInfo > channelInfo = m_eeg->getChannelInfo( channelID );
try
{
osg::Vec3 pos = wge::osgVec3( channelInfo->getPosition() );
osg::Vec3 pos = channelInfo->getPosition();
// create text geode for the channel label
osgText::Text* text = new osgText::Text;
......
......@@ -33,10 +33,11 @@
#include "../../dataHandler/WEEG2.h"
#include "../../graphicsEngine/WGEGroupNode.h"
#include "../../graphicsEngine/WROIBox.h"
#include "../../gui/WCustomWidget.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/modules/fiberDisplay/WRMROIRepresentation.h"
#include "../../kernel/WFiberSelector.h"
#include "WEEGEvent.h"
#include "WEEGSourceCalculator.h"
#include "WEEGViewHandler.h"
......@@ -235,7 +236,7 @@ private:
* m_event.
* Used to select the fibers around this dipole.
*/
boost::weak_ptr< WRMROIRepresentation > m_roi;
osg::ref_ptr< WROIBox > m_roi;
/**
* Bool flag which gets set when the data was changed.
......
# TODO(all): please enable this module again when ported to new ROI infrastructure.
#ADD_SUBDIRECTORY( eegView )
ADD_SUBDIRECTORY( eegView )
......@@ -286,10 +286,9 @@ void main()
// the current time step:
float timeStep = u_animationTime / 4.0; // scale 100th of a second to 25 times per second
//timeStep = 25;
// create a triangle function increasing time in 1/100 steps
float relativeSpeed1 = 2.5; //float( u_speed1 ) / 12.5;
float relativeSpeed2 = 2.5; // float( u_speed2 ) / 12.5;
float relativeSpeed1 = float( u_speed1 ) / 2.0;
float relativeSpeed2 = float( u_speed2 ) / 2.0;
float anim1 = ( int( timeStep * relativeSpeed1 ) % int( paramSpaceSize + maxSize + 30 ) ) - maxSize / 2.0;
float anim2 = ( int( timeStep * relativeSpeed2 ) % int( paramSpaceSize + maxSize + 30 ) ) - maxSize / 2.0;
......
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