Commit b9a2fa11 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[MERGE]

parents 947a448f 01e24d6e
......@@ -32,6 +32,7 @@
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread.hpp>
#include "WProperty.h"
......@@ -78,10 +79,15 @@ public:
template < typename T > void setValue( std::string prop, const T& arg )
{
boost::shared_lock<boost::shared_mutex> slock;
slock = boost::shared_lock<boost::shared_mutex>( m_updateLock );
if ( findProp( prop ) )
{
findProp( prop )->setValue( arg );
}
slock.unlock();
}
template < typename T > void setMin( std::string prop, const T& arg )
......@@ -134,6 +140,8 @@ private:
std::map < std::string, WProperty* >m_propertyList;
std::vector< WProperty* >m_propertyVector;
boost::shared_mutex m_updateLock;
};
#endif // WPROPERTIES_H
......@@ -27,10 +27,11 @@
#include <boost/shared_ptr.hpp>
#include "WDataSet.h"
#include "WGrid.h"
#include "WGridRegular3D.h"
#include "WValueSet.hpp"
class WValueSetBase;
class WGrid;
#include "WDataSet.h"
/**
* A data set consisting of a set of values based on a grid.
......@@ -60,6 +61,20 @@ public:
*/
boost::shared_ptr< WGrid > getGrid() const;
/**
*
*/
template < typename T > T getValueAt( int x, int y, int z )
{
boost::shared_ptr< WValueSet< T > > vs = boost::shared_dynamic_cast< WValueSet< T > >( m_valueSet );
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_grid );
size_t id = x + y * grid->getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
T v = vs->getScalar( id );
return v;
}
private:
/**
* Stores the reference of the WGrid of this DataSetSingle instance.
......
......@@ -94,7 +94,6 @@ public:
return m_data[i];
}
/**
* Sometimes we need raw access to the data array, for e.g. OpenGL.
*/
......@@ -103,6 +102,7 @@ public:
return &m_data[0];
}
protected:
private:
......
......@@ -54,7 +54,8 @@ WGEViewer::WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, i
m_View = osg::ref_ptr<osgViewer::Viewer>( new osgViewer::Viewer() );
m_View->getCamera()->setGraphicsContext( m_GraphicsContext );
m_View->getCamera()->setProjectionMatrixAsPerspective( 30.0f, 1.333, 1.0, 1000.0 );
// m_View->getCamera()->setProjectionMatrixAsPerspective( 30.0f, 1.333, 1.0, 1000.0 );
m_View->getCamera()->setProjectionMatrixAsOrtho( -120, 120, -120, 120, -1000, +1000 );
m_View->getCamera()->setViewport( new osg::Viewport( 0, 0, 10, 10 ) );
// add the stats handler
......@@ -127,7 +128,8 @@ void WGEViewer::resize( int width, int height )
WGEGraphicsWindow::resize( width, height );
// also update the camera
m_View->getCamera()->setProjectionMatrixAsPerspective( 30.0f, 1.333, 1.0, 1000.0 );
// m_View->getCamera()->setProjectionMatrixAsPerspective( 30.0f, 1.333, 1.0, 1000.0 );
m_View->getCamera()->setProjectionMatrixAsOrtho( -120, 120, -120, 120, -1000, +1000 );
m_View->getCamera()->setViewport( new osg::Viewport( 0, 0, width, height ) );
}
......
/* XPM */
static const char *logoIcon_xpm[] = {
static const char* const logoIcon_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 166 2",
" c gray25",
......
//---------------------------------------------------------------------------
//
// 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 <cassert>
#include <string>
#include "WIconManager.h"
WIconManager::WIconManager()
{
}
WIconManager::~WIconManager()
{
}
void WIconManager::addIcon( std::string name, const char* const xpm[] )
{
assert( ( m_iconList.count( name ) == 0 ) );
QIcon* icon = new QIcon( QPixmap( xpm ) );
m_iconList[name] = icon;
}
QIcon WIconManager::getIcon( const std::string name )
{
assert( ( m_iconList.count( name ) == 1 ) );
return *m_iconList[name];
}
//---------------------------------------------------------------------------
//
// 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 WICONMANAGER_H
#define WICONMANAGER_H
#include <map>
#include <string>
#include <QtGui/QIcon>
/**
* class to store and handle access to all available icons
*/
class WIconManager
{
public:
/**
* default constructor
*/
WIconManager();
/**
* destructor
*/
~WIconManager();
/**
* function to add an Icon to the icon store
*/
void addIcon( std::string name, const char* const xpm[] );
/**
* returns i previously stored icon
*/
QIcon getIcon( const std::string name );
protected:
private:
std::map< std::string, QIcon* >m_iconList;
};
#endif // WICONMANAGER_H
......@@ -39,9 +39,10 @@
#include "../icons/WIcons.h"
WMainWindow::WMainWindow()
WMainWindow::WMainWindow() :
m_iconManager(),
m_propertyManager()
{
m_propertyManager = new WPropertyManager();
}
WMainWindow::~WMainWindow()
......@@ -53,14 +54,14 @@ WMainWindow::~WMainWindow()
void WMainWindow::setupGUI( QMainWindow *mainWindow )
{
m_mainWindowIcon.addPixmap( QPixmap( logoIcon_xpm ) );
m_iconManager.addIcon( std::string( "logo" ), logoIcon_xpm );
if( mainWindow->objectName().isEmpty() )
{
mainWindow->setObjectName( QString::fromUtf8( "MainWindow" ) );
}
mainWindow->resize( 946, 632 );
mainWindow->setWindowIcon( m_mainWindowIcon );
mainWindow->setWindowIcon( m_iconManager.getIcon( "logo" ) );
mainWindow->setWindowTitle( QApplication::translate( "MainWindow", "OpenWalnut", 0, QApplication::UnicodeUTF8 ) );
m_centralwidget = new QWidget( mainWindow );
......@@ -88,15 +89,15 @@ void WMainWindow::setupGUI( QMainWindow *mainWindow )
m_glWidgets.push_back( m_navSagittal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal );
connect( m_navAxial, SIGNAL( navSliderValueChanged( QString, int ) ), m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
connect( m_navCoronal, SIGNAL( navSliderValueChanged( QString, int ) ), m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
connect( m_navSagittal, SIGNAL( navSliderValueChanged( QString, int ) ), m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
connect( m_navAxial, SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
connect( m_navCoronal, SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
connect( m_navSagittal, SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
m_datasetBrowser = new WQtDatasetBrowser();
mainWindow->addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
m_datasetBrowser->addSubject( "subject1" );
connect( m_datasetBrowser, SIGNAL( dataSetBrowserEvent( QString, bool ) ), m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
connect( m_datasetBrowser, SIGNAL( dataSetBrowserEvent( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
setupToolBar( mainWindow );
}
......@@ -105,14 +106,14 @@ void WMainWindow::setupToolBar( QMainWindow *mainWindow )
{
m_toolBar = new WQtRibbonMenu( mainWindow );
m_quitIcon.addPixmap( QPixmap( quit_xpm ) );
m_saveIcon.addPixmap( QPixmap( disc_xpm ) );
m_loadIcon.addPixmap( QPixmap( fileopen_xpm ) );
m_iconManager.addIcon( std::string( "quit" ), quit_xpm );
m_iconManager.addIcon( std::string( "save" ), disc_xpm );
m_iconManager.addIcon( std::string( "load" ), fileopen_xpm );
m_toolBar->addTab( QString( "File" ) );
m_toolBar->addPushButton( QString( "buttonLoad" ), QString( "File" ), m_loadIcon, QString( "load" ) );
m_toolBar->addPushButton( QString( "buttonSave" ), QString( "File" ), m_loadIcon, QString( "save" ) );
m_toolBar->addPushButton( QString( "buttonQuit" ), QString( "File" ), m_loadIcon, QString( "exit" ) );
m_toolBar->addPushButton( QString( "buttonLoad" ), QString( "File" ), m_iconManager.getIcon( "load" ), QString( "load" ) );
m_toolBar->addPushButton( QString( "buttonSave" ), QString( "File" ), m_iconManager.getIcon( "save" ), QString( "save" ) );
m_toolBar->addPushButton( QString( "buttonQuit" ), QString( "File" ), m_iconManager.getIcon( "quit" ), QString( "exit" ) );
m_toolBar->getButton( QString( "buttonLoad" ) )->setMaximumSize( 50, 24 );
m_toolBar->getButton( QString( "buttonSave" ) )->setMaximumSize( 50, 24 );
......@@ -124,13 +125,13 @@ void WMainWindow::setupToolBar( QMainWindow *mainWindow )
m_toolBar->addTab( QString( "Modules" ) );
m_toolBar->addTab( QString( "Help" ) );
m_axiIcon.addPixmap( QPixmap( axial_xpm ) );
m_corIcon.addPixmap( QPixmap( cor_xpm ) );
m_sagIcon.addPixmap( QPixmap( sag_xpm ) );
m_iconManager.addIcon( std::string( "axial" ), axial_xpm );
m_iconManager.addIcon( std::string( "coronal" ), cor_xpm );
m_iconManager.addIcon( std::string( "sagittal" ), sag_xpm );
m_toolBar->addPushButton( QString( "showAxial" ), QString( "Modules" ), m_axiIcon );
m_toolBar->addPushButton( QString( "showCoronal" ), QString( "Modules" ), m_corIcon );
m_toolBar->addPushButton( QString( "showSagittal" ), QString( "Modules" ), m_sagIcon );
m_toolBar->addPushButton( QString( "showAxial" ), QString( "Modules" ), m_iconManager.getIcon( "axial" ) );
m_toolBar->addPushButton( QString( "showCoronal" ), QString( "Modules" ), m_iconManager.getIcon( "coronal" ) );
m_toolBar->addPushButton( QString( "showSagittal" ), QString( "Modules" ), m_iconManager.getIcon( "sagittal" ) );
m_toolBar->getButton( QString( "showAxial" ) )->setMaximumSize( 24, 24 );
m_toolBar->getButton( QString( "showCoronal" ) )->setMaximumSize( 24, 24 );
......@@ -145,11 +146,11 @@ void WMainWindow::setupToolBar( QMainWindow *mainWindow )
m_toolBar->getButton( QString( "showSagittal" ) )->setChecked( true );
connect( m_toolBar->getButton( QString( "showAxial" ) ),
SIGNAL( pushButtonToggled( QString, bool ) ), m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
connect( m_toolBar->getButton( QString( "showCoronal" ) ),
SIGNAL( pushButtonToggled( QString, bool ) ), m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
connect( m_toolBar->getButton( QString( "showSagittal" ) ),
SIGNAL( pushButtonToggled( QString, bool ) ), m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
mainWindow->addToolBar( Qt::TopToolBarArea, m_toolBar );
}
......@@ -200,5 +201,10 @@ boost::signal1< void, std::vector< std::string > >* WMainWindow::getLoaderSignal
WPropertyManager* WMainWindow::getPropertyManager()
{
return m_propertyManager;
return &m_propertyManager;
}
WIconManager* WMainWindow::getIconManager()
{
return &m_iconManager;
}
......@@ -40,6 +40,7 @@
#include "WQtNavGLWidget.h"
#include "ribbonMenu/WQtRibbonMenu.h"
#include "WIconManager.h"
#include "WPropertyManager.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
// forward declarations
......@@ -80,10 +81,15 @@ public:
/**
*
* Return property manager
*/
WPropertyManager* getPropertyManager();
/**
* Return icon manager
*/
WIconManager* getIconManager();
/**
*
*/
......@@ -98,9 +104,9 @@ public slots:
private:
void setupToolBar( QMainWindow *mainWindow );
QIcon m_mainWindowIcon;
WIconManager m_iconManager;
WPropertyManager* m_propertyManager;
WPropertyManager m_propertyManager;
QWidget* m_centralwidget;
WQtRibbonMenu* m_toolBar;
......@@ -112,14 +118,6 @@ private:
WQtNavGLWidget* m_navCoronal;
WQtNavGLWidget* m_navSagittal;
QIcon m_quitIcon;
QIcon m_saveIcon;
QIcon m_loadIcon;
QIcon m_axiIcon;
QIcon m_corIcon;
QIcon m_sagIcon;
boost::signal1< void, std::vector< std::string > > m_loaderSignal;
};
......
......@@ -36,6 +36,7 @@
#include "WModule.h"
#include "../modules/data/WMData.hpp"
#include "../modules/navigationSlices/WMNavSlice.h"
#include "../modules/coordinateSystem/WCoordinateSystem.h"
#include "../modules/fiberDisplay/WMFiberDisplay.h"
#include "../modules/fiberCulling/WMFiberCulling.h"
#include "../modules/fiberClustering/WMFiberClustering.h"
......@@ -187,13 +188,15 @@ void WKernel::loadModules()
m_modules.clear();
using boost::shared_ptr;
shared_ptr< WModule > m = shared_ptr< WModule >( new WMNavSlice() );
// shared_ptr< WModule > m = shared_ptr< WModule >( new WMFiberDisplay() );
// shared_ptr< WModule > m = shared_ptr< WModule >( new WMFiberCulling() );
// shared_ptr< WModule > m = shared_ptr< WModule >( new WMFiberClustering() );
WLogger::getLogger()->addLogMessage( "Loading module: " + m->getName(), "Kernel", LL_DEBUG );
shared_ptr< WModule > m1 = shared_ptr< WModule >( new WNavigationSliceModule() );
// shared_ptr< WModule > m = shared_ptr< WModule >( new WFiberDisplay() );
WLogger::getLogger()->addLogMessage( "Loading module: " + m1->getName(), "Kernel", LL_DEBUG );
m_modules.push_back( m );
m_modules.push_back( m1 );
shared_ptr< WModule > m2 = shared_ptr< WModule >( new WCoordinateSystem() );
WLogger::getLogger()->addLogMessage( "Loading module: " + m2->getName(), "Kernel", LL_DEBUG );
m_modules.push_back( m2 );
}
void WKernel::init()
......
//---------------------------------------------------------------------------
//
// 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 <string>
#include <vector>
#include <osg/Geode>
#include <osg/Geometry>
#include "../../kernel/WKernel.h"
#include "WCoordinateSystem.h"
WCoordinateSystem::WCoordinateSystem() :
WModule()
{
properties();
}
WCoordinateSystem::~WCoordinateSystem()
{
}
void WCoordinateSystem::threadMain()
{
createGeometry();
// Since the modules run in a separate thread: such loops are possible
while ( !m_FinishRequested )
{
// do fancy stuff
sleep( 1 );
}
// clean up stuff
}
const std::string WCoordinateSystem::getName() const
{
return "Coordinate System Module";
}
const std::string WCoordinateSystem::getDescription() const
{
return "This module displays coordinate systems as overlay withn the main 3D view.";
}
void WCoordinateSystem::connectToGui()
{
WKernel::getRunningKernel()->getGui()->connectProperties( m_properties );
}
void WCoordinateSystem::properties()
{
m_properties->addBool( "textureChanged", false );
m_properties->addInt( "type", 1 );
// initialize the properties with a certain standard set
// those properties will be updatet as soon as the first dataset is looaded
m_properties->addFloat( "zeroX", 80.0 );
m_properties->addFloat( "zeroY", 100.0 );
m_properties->addFloat( "zeroZ", 80.0 );
m_properties->addFloat( "fltX", 0.0 );
m_properties->addFloat( "fltY", 0.0 );
m_properties->addFloat( "fltZ", 0.0 );
m_properties->addFloat( "brbX", 160.0 );
m_properties->addFloat( "brbY", 200.0 );
m_properties->addFloat( "brbZ", 160.0 );
}
void WCoordinateSystem::createGeometry()
{
float zeroX = m_properties->getValue<float>( "zeroX" );
float zeroY = m_properties->getValue<float>( "zeroY" );
float zeroZ = m_properties->getValue<float>( "zeroZ" );
float fltX = m_properties->getValue<float>( "fltX" );
float fltY = m_properties->getValue<float>( "fltY" );
float fltZ = m_properties->getValue<float>( "fltZ" );
float brbX = m_properties->getValue<float>( "brbX" );
float brbY = m_properties->getValue<float>( "brbY" );
float brbZ = m_properties->getValue<float>( "brbZ" );
m_rootNode = osg::ref_ptr<osg::Geode>( new osg::Geode() );
osg::ref_ptr<osg::Geometry> geometry = osg::ref_ptr<osg::Geometry>( new osg::Geometry() );
m_rootNode->addDrawable( geometry );
osg::Vec3Array* vertices = new osg::Vec3Array;
vertices->push_back( osg::Vec3( zeroX, zeroY, zeroZ ) );
vertices->push_back( osg::Vec3( fltX, fltY, fltZ ) );
vertices->push_back( osg::Vec3( fltX, brbY, fltZ ) );
vertices->push_back( osg::Vec3( fltX, brbY, brbZ ) );
vertices->push_back( osg::Vec3( fltX, fltY, brbZ ) );
vertices->push_back( osg::Vec3( brbX, fltY, fltZ ) );
vertices->push_back( osg::Vec3( brbX, brbY, fltZ ) );
vertices->push_back( osg::Vec3( brbX, brbY, brbZ ) );
vertices->push_back( osg::Vec3( brbX, fltY, brbZ ) );
vertices->push_back( osg::Vec3( zeroX, zeroY, fltZ ) );
vertices->push_back( osg::Vec3( zeroX, zeroY, brbZ ) );
vertices->push_back( osg::Vec3( zeroX, fltY, zeroZ ) );
vertices->push_back( osg::Vec3( zeroX, brbY, zeroZ ) );
vertices->push_back( osg::Vec3( fltX, zeroY, zeroZ ) );
vertices->push_back( osg::Vec3( brbX, zeroY, zeroZ ) );
geometry->setVertexArray( vertices );
osg::DrawElementsUInt* lines = new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
lines->push_back( 1 );
lines->push_back( 2 );
lines->push_back( 2 );
lines->push_back( 3 );
lines->push_back( 3 );
lines->push_back( 4 );
lines->push_back( 4 );
lines->push_back( 1 );
lines->push_back( 5 );
lines->push_back( 6 );
lines->push_back( 6 );
lines->push_back( 7 );
lines->push_back( 7 );
lines->push_back( 8 );
lines->push_back( 8 );
lines->push_back( 5 );
lines->push_back( 1 );
lines->push_back( 5 );
lines->push_back( 2 );
lines->push_back( 6 );
lines->push_back( 3 );
lines->push_back( 7 );
lines->push_back( 4 );
lines->push_back( 8 );
lines->push_back( 9 );
lines->push_back( 10 );
lines->push_back( 11 );
lines->push_back( 12 );
lines->push_back( 13 );
lines->push_back( 14 );
geometry->addPrimitiveSet( lines );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->addChild( m_rootNode );
// osg::StateSet* rootState = m_rootNode->getOrCreateStateSet();