Commit a7e940dd authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[MERGE]

parents 18387771 86eec83b
......@@ -47,8 +47,6 @@ WThreadedRunner::WThreadedRunner():
WThreadedRunner::~WThreadedRunner()
{
// cleanup
// XXX is this working if thread already has finished?
// wait( true ); <-- no
}
const WBoolFlag& WThreadedRunner::isCrashed() const
......
......@@ -31,8 +31,6 @@
#include "WVectorFixed.h"
#include "WPosition.h"
//TODO(ebaum): move this somewhere else
/**
* The new dynamic vector type. It is a heap-allocated double vector with dynamic size.
*
......
......@@ -399,7 +399,6 @@ void WModuleProjectFileCombiner::save( std::ostream& output ) // NOLINT
for( WModule::OutputConnectorList::const_iterator citer = outs.begin(); citer != outs.end(); ++citer )
{
// iterate over all connections:
// TODO(ebaum): iterating over a protected member variable? Thats ugly. This should be adopted to WSharedObject
boost::unique_lock<boost::shared_mutex> lock( ( *citer )->m_connectionListLock );
for( std::set<boost::shared_ptr<WModuleConnector> >::const_iterator iciter = ( *citer )->m_connected.begin();
iciter != ( *citer )->m_connected.end(); ++iciter )
......
......@@ -124,22 +124,37 @@ void WMEEGView::properties()
"Use proof of concept (POC) ROI positioning instead of real dipoles position.",
true,
m_propCondition );
m_labelsWidth = m_properties->addProperty( "Labels width",
m_butterfly = m_properties->addProperty( "Butterfly plot",
"Overlay all curves in one row.",
false,
m_propCondition );
m_ROIsize = m_properties->addProperty( "ROI size",
"The width ROI box.",
10.0,
m_propCondition );
m_ROIsize->setMin( 0.0 );
m_ROIsize->setMax( 50.0 );
m_appearanceGroup = m_properties->addPropertyGroup( "Appearance",
"Modification of the appearance of the EEG View widget" );
m_labelsWidth = m_appearanceGroup->addProperty( "Labels width",
"The width of the label display in pixel.",
24 );
m_graphWidth = m_properties->addProperty( "Graph width",
m_graphWidth = m_appearanceGroup->addProperty( "Graph width",
"The width of the graph in pixel.",
992 );
m_ySpacing = m_properties->addProperty( "Spacing",
m_ySpacing = m_appearanceGroup->addProperty( "Spacing",
"The distance between two curves of the graph in pixel.",
23.0 );
m_colorSensitivity = m_properties->addProperty( "Color sensitivity",
m_colorSensitivity = m_appearanceGroup->addProperty( "Color sensitivity",
"The sensitivity of the color map. It ranges from -Color Sensitivity to +Color Sensitivity in microvolt.",
23.0 );
m_manualNavigationGroup = m_properties->addPropertyGroup( "Manual Navigation",
"Manually modify the parameters that are usually changes by mouse"
" actions in th EEG view." );
......@@ -204,6 +219,7 @@ void WMEEGView::moduleMain()
createColorMap();
m_ROIsize->get( true ); // reset changed state
// signal ready
ready();
......@@ -211,7 +227,7 @@ void WMEEGView::moduleMain()
while( !m_shutdownFlag() ) // loop until the module container requests the module to quit
{
// data changed?
if( m_dataChanged() )
if( m_dataChanged() || m_butterfly->changed( true ) )
{
debugLog() << "Data changed";
m_dataChanged.set( false );
......@@ -281,7 +297,8 @@ void WMEEGView::moduleMain()
// event position changed?
boost::shared_ptr< WEEGEvent > event = m_event->get();
if( event && event->getTime() != m_currentEventTime )
if( ( event && event->getTime() != m_currentEventTime )
|| m_ROIsize->changed() )
{
debugLog() << "New event position: " << event->getTime();
......@@ -295,17 +312,19 @@ void WMEEGView::moduleMain()
if( m_proofOfConcept->get() )
{
WPosition position = m_sourceCalculator->calculate( event );
m_roi = new WROIBox( position - WVector3d( 5.0, 5.0, 5.0 ),
position + WVector3d( 5.0, 5.0, 5.0 ) );
float halfWidth = m_ROIsize->get( true ) * 0.5;
m_roi = new WROIBox( position - WVector3d( halfWidth, halfWidth, halfWidth ),
position + WVector3d( halfWidth, halfWidth, halfWidth ) );
WKernel::getRunningKernel()->getRoiManager()->addRoi( m_roi );
}
else if( m_dipoles->getData() )
{
if( m_dipoles->getData()->getMagnitude( event->getTime() ) != 0 )
{
float halfWidth = m_ROIsize->get( true ) * 0.5;
WPosition position = m_dipoles->getData()->getPosition();
m_roi = new WROIBox( position - WVector3d( 5.0, 5.0, 5.0 ),
position + WVector3d( 5.0, 5.0, 5.0 ) );
m_roi = new WROIBox( position - WVector3d( halfWidth, halfWidth, halfWidth ),
position + WVector3d( halfWidth, halfWidth, halfWidth ) );
WKernel::getRunningKernel()->getRoiManager()->addRoi( m_roi );
}
}
......@@ -456,10 +475,10 @@ void WMEEGView::redraw()
// reset event position
m_event->set( boost::shared_ptr< WEEGEvent >( new WEEGEvent ) );
if( m_eeg.get() && 0 < m_eeg->getNumberOfSegments() )
if( m_eeg.get() && m_eeg->getNumberOfSegments() > 0 )
{
const float text2dOffset = 2.0f;
const float text2dSize = 32.0f;
const float text2dSize = 12.0f;
const osg::Vec4 text2dColor( 0.0, 0.0, 0.0, 1.0 );
const osg::Vec4 linesColor( 0.0, 0.0, 0.0, 1.0 );
......@@ -480,9 +499,18 @@ void WMEEGView::redraw()
size_t nbSamples = segment->getNumberOfSamples();
debugLog() << " Number of Samples: " << nbSamples;
const float heightConstant = 736.0;
// reset and adjust properties to given dataset
m_ySpacing->set( 736.0 / nbChannels );
m_yPos->set( 368.0 / nbChannels - 736.0 );
if( m_butterfly->get() )
{
m_ySpacing->set( 0 );
m_yPos->set( -heightConstant / nbChannels );
}
else
{
m_ySpacing->set( heightConstant / nbChannels );
m_yPos->set( ( heightConstant * 0.5 ) / nbChannels - heightConstant );
}
m_timePos->set( 0.0 );
m_timePos->setMax( nbSamples / rate );
......@@ -717,7 +745,7 @@ osg::ref_ptr< osg::Node > WMEEGView::drawLabels()
// draw electrode labels in 3d
const float sphereSize = 4.0f;
const osg::Vec3 text3dOffset( 0.0, 0.0, sphereSize );
const double text3dSize = 32.0;
const double text3dSize = 14.0;
const osg::Vec4 text3dColor( 0.0, 0.0, 0.0, 1.0 );
osg::ref_ptr< osg::Group > labels( new osg::Group );
......
......@@ -141,6 +141,11 @@ private:
*/
WPropGroup m_manualNavigationGroup;
/**
* Group for parameters that adjust the appearance of the EEG widget
*/
WPropGroup m_appearanceGroup;
/**
* Property determining whether electode positions should be drawn.
*/
......@@ -157,10 +162,20 @@ private:
WPropBool m_drawLabels;
/**
* Property determining whetherwe only show the proof of concept or the real dipoles
* Property determining whether we only show the proof of concept or the real dipoles
*/
WPropBool m_proofOfConcept;
/**
* Property switching between standard and butterfly plot of curves (overlay of all curves in one row)
*/
WPropBool m_butterfly;
/**
* Size of the region of interest
*/
WPropDouble m_ROIsize;
/**
* the width of the label display in pixel as property
*/
......
......@@ -452,12 +452,6 @@ void WMainWindow::setupGUI()
showSagittal->setText( "Toggle Sagittal Slice" );
showSagittal->setIcon( m_iconManager.getIcon( "sagittal icon" ) );
// Temporarily disabled. We need a proper command prompt implementation first.
// create command prompt toolbar
// m_commandPrompt = new WQtCommandPromptToolbar( "Command Prompt", this );
// addToolBar( Qt::TopToolBarArea, m_commandPrompt );
// this->addAction( m_commandPrompt->toggleViewAction() ); // this enables the action even if the menu bar is invisible
// setup permanent toolbar
m_permanentToolBar->addAction( m_loadButton );
m_permanentToolBar->addAction( projectSaveButton );
......
......@@ -41,7 +41,6 @@
#include "WQtGLWidget.h"
#include "WSettingAction.h"
#include "networkEditor/WQtNetworkEditor.h"
#include "commandPrompt/WQtCommandPromptToolbar.h"
// forward declarations
class QMenuBar;
......@@ -349,8 +348,6 @@ private:
WQtNetworkEditor* m_networkEditor; //!< network editor
WQtCommandPromptToolbar* m_commandPrompt; //!< command prompt
boost::shared_ptr< WQtGLWidget > m_mainGLWidget; //!< the main GL widget of the GUI
WQtGLScreenCapture* m_mainGLWidgetScreenCapture; //!< screen recorder in m_mainGLWidget
......
......@@ -82,17 +82,25 @@ WQtGLScreenCapture::WQtGLScreenCapture( WGEViewer::SPtr viewer, WMainWindow* par
m_resolutionCombo = new QComboBox();
m_resolutionCombo->addItem( "640x480" );
m_resolutionCombo->addItem( "800x600" );
m_resolutionCombo->addItem( "850x650" );
m_resolutionCombo->addItem( "1024x768" );
m_resolutionCombo->addItem( "1280x1024" );
m_resolutionCombo->addItem( "1330x1074" );
m_resolutionCombo->addItem( "1280x720 (720p)" );
m_resolutionCombo->addItem( "1920x1080 (1080p)" );
m_resolutionCombo->addItem( "Custom" );
m_customWidth = new QLineEdit( "1980", this );
m_customHeight = new QLineEdit( "1080", this );
m_customWidth->setValidator( new QIntValidator( 0, 4096, m_customWidth ) );
m_customHeight->setValidator( new QIntValidator( 0, 4096, m_customHeight ) );
QPushButton* resolutionButton = new QPushButton( "Set" );
resolutionButton->setCheckable( true );
resolutionGroupLayout->addWidget( m_resolutionCombo, 0, 0 );
resolutionGroupLayout->addWidget( resolutionButton, 0, 1 );
resolutionGroupLayout->addWidget( m_resolutionCombo, 0, 0, 1, 2 );
resolutionGroupLayout->addWidget( resolutionButton, 0, 2 );
resolutionGroupLayout->addWidget( new QLabel( "Custom Resolution" ), 1, 0, 1, 3 );
resolutionGroupLayout->addWidget( m_customWidth, 2, 0 );
resolutionGroupLayout->addWidget( m_customHeight, 2, 1 );
connect( resolutionButton, SIGNAL( toggled( bool ) ), this, SLOT( resolutionChange( bool ) ) );
// filename config
......@@ -392,7 +400,6 @@ void WQtGLScreenCapture::resolutionChange( bool force )
{
wlog::debug( "WQtGLScreenCapture" ) << "Forcing resolution";
// TODO(ebaum): this magic number stuff is ugly.
switch( m_resolutionCombo->currentIndex() )
{
case 0:
......@@ -401,24 +408,21 @@ void WQtGLScreenCapture::resolutionChange( bool force )
case 1:
m_mainWindow->forceMainGLWidgetSize( 800, 600 );
break;
case 2: // TODO(ebaum): add offset edits
m_mainWindow->forceMainGLWidgetSize( 800 + 50, 600 + 50 );
break;
case 3:
case 2:
m_mainWindow->forceMainGLWidgetSize( 1024, 768 );
break;
case 4:
case 3:
m_mainWindow->forceMainGLWidgetSize( 1280, 1024 );
break;
case 5: // TODO(ebaum): add offset edits
m_mainWindow->forceMainGLWidgetSize( 1280 + 50, 1024 + 50 );
break;
case 6:
case 4:
m_mainWindow->forceMainGLWidgetSize( 1280, 720 );
break;
case 7:
case 5:
m_mainWindow->forceMainGLWidgetSize( 1920, 1080 );
break;
case 6: // custom size
m_mainWindow->forceMainGLWidgetSize( m_customWidth->text().toInt(), m_customHeight->text().toInt() );
break;
}
}
else
......
......@@ -257,6 +257,16 @@ private:
* Stores the resolution the user wants to have.
*/
QComboBox* m_resolutionCombo;
/**
* Widget for entering a custom resolution width
*/
QLineEdit* m_customWidth;
/**
* Widget for entering a custom resolution height
*/
QLineEdit* m_customHeight;
};
#endif // WQTGLSCREENCAPTURE_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <iostream>
#include <QtGui/QAction>
#include <QtGui/QLineEdit>
#include <QtGui/QKeyEvent>
#include "../WMainWindow.h"
#include "WQtCommandPrompt.h"
#include "WQtCommandPrompt.moc"
WQtCommandPrompt::WQtCommandPrompt( QWidget* parent ):
QLineEdit( parent )
{
// some nice style
// TODO(ebaum): make this configurable
setStyleSheet( "color: white;"
"border: 0px solid gray;"
"border-radius: 0px;"
"border-color: #080808;"
"padding: 0 0px;"
"background: #080808;"
"selection-background-color: gray;" );
setText( "Not yet implemented. But as you tried the command prompt I assume you are a cool VIM user ;-)." );
connect( this, SIGNAL( returnPressed() ), this, SLOT( commit() ) );
}
WQtCommandPrompt::~WQtCommandPrompt()
{
// cleanup
}
void WQtCommandPrompt::abort()
{
setText( "" );
emit done();
}
void WQtCommandPrompt::commit()
{
setText( "" );
emit done();
}
void WQtCommandPrompt::keyPressEvent( QKeyEvent* event )
{
QLineEdit::keyPressEvent( event );
}
bool WQtCommandPrompt::event( QEvent* event )
{
// we need to override this to be able to grab the escape key
if( event->type() == QEvent::KeyRelease )
{
QKeyEvent* keyEvent = dynamic_cast< QKeyEvent* >( event );
// escape quits the prompt
if( keyEvent && ( keyEvent->key() == Qt::Key_Escape ) )
{
abort();
event->accept();
return true;
}
}
return QLineEdit::event( event );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WQTCOMMANDPROMPT_H
#define WQTCOMMANDPROMPT_H
#include <QtGui/QLineEdit>
/**
* This is a toolbar. It provides a command prompt -like interface for adding, removing and connecting modules
*/
class WQtCommandPrompt: public QLineEdit
{
Q_OBJECT
public:
/**
* Constructs the prompt.
*
* \param parent the parent widget of this widget, i.e. the widget that manages it.
*/
explicit WQtCommandPrompt( QWidget* parent );
/**
* destructor
*/
virtual ~WQtCommandPrompt();
signals:
/**
* Emited if the prompt should quit. On ESC or after commiting a command.
*/
void done();
protected:
/**
* Converts the given key press event into a line edit action.
*
* \param event the key
*/
virtual void keyPressEvent( QKeyEvent* event );
/**
* Event handler
*
* \param event the event
*
* \return true if event was handled.
*/
bool event( QEvent* event );
private slots:
/**
* This aborts. The typed command will not be sent.
*/
void abort();
/**
* Commit the current command.
*/
void commit();
private:
};
#endif // WQTCOMMANDPROMPT_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <QtGui/QAction>
#include <QtGui/QLabel>
#include "../WMainWindow.h"
#include "WQtCommandPrompt.h"
#include "WQtCommandPromptToolbar.h"
#include "WQtCommandPromptToolbar.moc"
WQtCommandPromptToolbar::WQtCommandPromptToolbar( const QString& title, WMainWindow* parent ):
QToolBar( title, parent ),
m_mainWindow( parent )
{
setObjectName( title );
this->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
setMinimumWidth( 50 );
setMinimumHeight( 20 );
setVisible( false );
// toggle it using ":"
QList< QKeySequence > commandPromptShortcut;
commandPromptShortcut.append( QKeySequence( Qt::Key_Colon ) );
toggleViewAction()->setShortcuts( commandPromptShortcut );
QLabel* label = new QLabel( this );
label->setText( "<b>:</b>" );
label->setStyleSheet( "background: #080808;" );
addWidget( label );
m_prompt = new WQtCommandPrompt( this );
addWidget( m_prompt );
// some nice style
// TODO(ebaum): make this configurable
setStyleSheet( "background: #080808;"
"border: 2px solid #080808;"
"margin: 0px;"
"padding: 0px;"
"spacing: 0;"
"color: white;"
);
// if the toolbar is triggered:
connect( toggleViewAction(), SIGNAL( triggered( bool ) ), this, SLOT( show() ) );
connect( m_prompt, SIGNAL( done() ), this, SLOT( exit() ) );
}
WQtCommandPromptToolbar::~WQtCommandPromptToolbar()
{
// cleanup
}
void WQtCommandPromptToolbar::show()
{
setVisible( true );
m_prompt->setFocus();
}
void WQtCommandPromptToolbar::exit()
{
setVisible( false );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//