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

[MERGE]

parents e48a5fae d5352af0
//---------------------------------------------------------------------------
//
// 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 "WDataSetTimeDependent.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/>.
//
//---------------------------------------------------------------------------
#ifndef WDATASETTIMEDEPENDENT_H
#define WDATASETTIMEDEPENDENT_H
#include "WDataSet.h"
/**
* TODO(math): Document this
* \ingroup dataHandler
*/
class WDataSetTimeDependent : public WDataSet
{
public:
/**
* Dummy constructor.
* TODO(wiebel): implement this
*/
explicit WDataSetTimeDependent()
: WDataSet()
{
// TODO(wiebel): implement this
};
};
#endif // WDATASETTIMEDEPENDENT_H
......@@ -139,9 +139,6 @@ void WLoaderNIfTI::operator()()
columns, rows, frames, header->dx, header->dy, header->dz ) );
}
// TODO(wiebel): fill this info into the subject instead
// fillMetaInfo( metaInfo, header );
boost::shared_ptr< WDataSet > newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSingle( newValueSet, newGrid ) );
newDataSet->setFileName( m_fileName );
commitDataSet( newDataSet );
......@@ -151,16 +148,10 @@ void WLoaderNIfTI::operator()()
// TODO(wiebel): fill this info into the subject instead
// void WLoaderNIfTI::fillMetaInfo( boost::shared_ptr< WMetaInfo > metaInfo, nifti_image* header )
// {
// metaInfo->setDataType( header->datatype );
// metaInfo->setValueDim( header->dim[4] );
// metaInfo->setNx( header->nx );
// metaInfo->setNy( header->ny );
// metaInfo->setNz( header->nz );
// metaInfo->setDx( header->dx );
// metaInfo->setDy( header->dy );
// metaInfo->setDz( header->dz );
// metaInfo->setXyzUnits( header->xyz_units );
// metaInfo->setQformCode( header->qform_code );
// metaInfo->setQuaternB( header->quatern_b );
// metaInfo->setQuaternC( header->quatern_c );
// metaInfo->setQuaternD( header->quatern_d );
......@@ -172,16 +163,6 @@ void WLoaderNIfTI::operator()()
// metaInfo->setPhaseDim( header->phase_dim );
// metaInfo->setSliceDim( header->slice_dim );
// std::vector<float>xyzMatrix( 16, 0 );
// for ( int i = 0; i < 4; ++i )
// {
// for ( int j = 0; j < 4; ++j)
// {
// xyzMatrix[ i * 4 + j ] = header->qto_xyz.m[i][j];
// }
// }
// metaInfo->setQtoXyzMatrix( xyzMatrix );
// std::vector<float>ijkMatrix( 16, 0 );
// for ( int i = 0; i < 4; ++i )
// {
......
//---------------------------------------------------------------------------
//
// 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 WDATASETTIMEDEPENDENT_TEST_H
#define WDATASETTIMEDEPENDENT_TEST_H
#include <cxxtest/TestSuite.h>
#include "../WDataSetTimeDependent.h"
class WDataSetTimeDependentTest : public CxxTest::TestSuite
{
public:
void testSomething( void )
{
}
};
#endif // WDATASETTIMEDEPENDENT_TEST_H
......@@ -42,7 +42,7 @@
#include "exceptions/WGEInitFailed.h"
#include "WGEViewer.h"
WGEViewer::WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height ):
WGEViewer::WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height, WGECamera::ProjectionMode projectionMode ):
WGEGraphicsWindow( wdata, x, y, width, height )
{
try
......@@ -54,9 +54,24 @@ 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()->setProjectionMatrixAsOrtho( -120, 120, -120, 120, -1000, +1000 );
m_View->getCamera()->setViewport( new osg::Viewport( 0, 0, 10, 10 ) );
switch( projectionMode )
{
case( WGECamera::ORTHOGRAPHIC ):
m_View->getCamera()->setProjectionMatrixAsOrtho(
-120.0 * width / height, 120.0 * width / height, -120.0, 120.0, -1000.0, +1000.0 );
break;
case( WGECamera::PERSPECTIVE ):
m_View->getCamera()->setProjectionMatrixAsPerspective(
30.0, static_cast< double >( width ) / static_cast< double >( height ), 1.0, 1000.0 );
break;
default:
throw WGEInitFailed( "Unknown projection mode" );
break;
}
m_View->getCamera()->setViewport( 0, 0, width, height );
m_View->getCamera()->setProjectionResizePolicy( osg::Camera::HORIZONTAL );
// add the stats handler
m_View->addEventHandler( new osgViewer::StatsHandler );
......@@ -64,6 +79,8 @@ WGEViewer::WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, i
// camera manipulator
m_View->setCameraManipulator( new osgGA::TrackballManipulator() );
m_View->setLightingMode( osg::View::SKY_LIGHT );
// finally add view
// there is the possibility to use ONE single composite viewer instance for every view, but
// currently this possibility is not used.
......@@ -128,9 +145,7 @@ 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()->setProjectionMatrixAsOrtho( -120, 120, -120, 120, -1000, +1000 );
m_View->getCamera()->setViewport( new osg::Viewport( 0, 0, width, height ) );
m_View->getCamera()->setViewport( 0, 0, width, height );
}
void WGEViewer::close()
......
......@@ -42,6 +42,7 @@
#include "../common/WThreadedRunner.h"
#include "WGEGraphicsWindow.h"
#include "WGECamera.h"
/**
* Class for managing one viewer to the scene. This includes viewport, camera and graphics context.
......@@ -52,7 +53,6 @@ class WGEViewer: public WGEGraphicsWindow,
public WThreadedRunner
{
public:
/**
* Default constructor.
*
......@@ -61,9 +61,11 @@ public:
* \param y Y coordinate of widget where to create the context.
* \param width Width of the widget.
* \param height Height of the Widget.
* \param projectionMode Projection mode of the viewer.
* \exception WGEInitFailed thrown if initialization of graphics context or graphics window has failed.
*/
WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height );
WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height,
WGECamera::ProjectionMode projectionMode = WGECamera::ORTHOGRAPHIC );
/**
* Destructor.
......@@ -157,4 +159,3 @@ private:
};
#endif // WGEVIEWER_H
......@@ -71,9 +71,10 @@ void WGraphicsEngine::threadMain()
// }
}
boost::shared_ptr<WGEViewer> WGraphicsEngine::createViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height )
boost::shared_ptr<WGEViewer> WGraphicsEngine::createViewer(
osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height, WGECamera::ProjectionMode projectionMode )
{
boost::shared_ptr<WGEViewer> viewer = boost::shared_ptr<WGEViewer>( new WGEViewer( wdata, x, y, width, height ) );
boost::shared_ptr<WGEViewer> viewer = boost::shared_ptr<WGEViewer>( new WGEViewer( wdata, x, y, width, height, projectionMode ) );
viewer->setScene( this->getScene() );
// start rendering
......
......@@ -84,10 +84,12 @@ public:
* \param y Y coordinate of widget where to create the context.
* \param width Width of the widget.
* \param height Height of the Widget.
* \param projectionMode Projection mode of the viewer.
* \return the new instance, ready to be used.
* \exception WGEInitFailed thrown if initialization of graphics context or graphics window has failed.
*/
boost::shared_ptr<WGEViewer> createViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height );
boost::shared_ptr<WGEViewer> createViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height,
WGECamera::ProjectionMode projectionMode = WGECamera::ORTHOGRAPHIC );
protected:
......
......@@ -69,7 +69,7 @@ void WMainWindow::setupGUI( QMainWindow *mainWindow )
mainWindow->setCentralWidget( m_centralwidget );
std::cout << "init main gl" << std::endl;
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( mainWindow ) );
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( mainWindow, WGECamera::PERSPECTIVE ) );
m_glWidgets.push_back( widget );
mainWindow->setCentralWidget( widget.get() );
......
......@@ -32,7 +32,7 @@
#include "../../kernel/WKernel.h"
WQtGLWidget::WQtGLWidget( QWidget* parent )
WQtGLWidget::WQtGLWidget( QWidget* parent, WGECamera::ProjectionMode projectionMode )
: QWidget( parent ),
m_recommendedSize()
{
......@@ -55,7 +55,7 @@ WQtGLWidget::WQtGLWidget( QWidget* parent )
#endif
// create viewer
m_Viewer = WKernel::getRunningKernel()->getGraphicsEngine()->createViewer( wdata, x(), y(), width(), height() );
m_Viewer = WKernel::getRunningKernel()->getGraphicsEngine()->createViewer( wdata, x(), y(), width(), height(), projectionMode );
// required
setAttribute( Qt::WA_PaintOnScreen );
......
......@@ -50,7 +50,7 @@ public:
*
* \return
*/
explicit WQtGLWidget( QWidget* parent = 0 );
explicit WQtGLWidget( QWidget* parent = 0, WGECamera::ProjectionMode projectionMode = WGECamera::ORTHOGRAPHIC );
/**
* Destructor.
......
......@@ -45,7 +45,7 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, int maxValue, std::string sliderT
QVBoxLayout* layout = new QVBoxLayout();
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( panel ) );
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( panel, WGECamera::ORTHOGRAPHIC ) );
layout->addWidget( m_glWidget.get() );
layout->addWidget( slider );
......
......@@ -66,6 +66,8 @@ WKernel::WKernel( int argc, char* argv[], boost::shared_ptr< WGUI > gui )
// get module factory
m_moduleFactory = WModuleFactory::getModuleFactory();
m_moduleContainer = boost::shared_ptr< WModuleContainer >( new WModuleContainer( "KernelRootContainer", "Root module\
container in Kernel." ) );
// init GE, DataHandler, ...
init();
......@@ -100,12 +102,12 @@ boost::shared_ptr< WGraphicsEngine > WKernel::getGraphicsEngine() const
return m_graphicsEngine;
}
boost::shared_ptr< WDataHandler > WKernel::getDataHandler() const
boost::shared_ptr< WModuleContainer > WKernel::getRootContainer() const
{
return m_dataHandler;
return m_moduleContainer;
}
boost::shared_ptr< WGUI > WKernel::getGui()
boost::shared_ptr< WGUI > WKernel::getGui() const
{
return m_gui;
}
......@@ -125,6 +127,11 @@ char** WKernel::getArguments() const
return m_ArgV;
}
void WKernel::stop()
{
getRootContainer()->stop();
}
int WKernel::run()
{
WLogger::getLogger()->addLogMessage( "Starting Kernel", "Kernel", LL_DEBUG );
......@@ -178,6 +185,15 @@ int WKernel::run()
( *list_iter )->wait( true );
}*/
// TODO(schurade): this must be moved somewhere else, and realize the wait loop in another fashion
while ( !m_gui->isInitalized() )
{
}
m_gui->getLoadButtonSignal()->connect( boost::bind( &WKernel::doLoadDataSets, this, _1 ) );
m_gui->wait( false );
m_FinishRequested = true;
// finally GE
m_graphicsEngine->wait( true );
......@@ -307,17 +323,17 @@ void WKernel::slotFinishLoadData( boost::shared_ptr< WDataSet > dataSet )
m_gui->addDatasetToBrowser( module, 0 );
}
boost::shared_ptr< WDataHandler > WKernel::getDataHandler()
boost::shared_ptr< WDataHandler > WKernel::getDataHandler() const
{
return m_dataHandler;
}
std::string WKernel::getAppPath()
std::string WKernel::getAppPath() const
{
return m_AppPath;
}
std::string WKernel::getShaderPath()
std::string WKernel::getShaderPath() const
{
return m_shaderPath;
}
......@@ -75,6 +75,12 @@ public:
*/
int run();
/**
* Stops execution of the modules in the root container. Note that this does not wait for the kernel thread since this could
* cause a dead lock. This is actually an alias for getRootContainer()->stop().
*/
void stop();
/**
* Returns pointer to currently running instance of graphics engine.
*
......@@ -123,14 +129,16 @@ public:
void doLoadDataSets( std::vector< std::string > fileNames );
/**
* getter for datahandler
* Returns the root module container. This is the actual module graph container.
*
* \return the root container.
*/
boost::shared_ptr< WDataHandler > getDataHandler();
boost::shared_ptr< WModuleContainer > getRootContainer() const;
/**
* getter for gui
*/
boost::shared_ptr< WGUI > getGui();
boost::shared_ptr< WGUI > getGui() const;
/**
*
......@@ -140,12 +148,12 @@ public:
/**
* get for application path
*/
std::string getAppPath();
std::string getAppPath() const;
/**
* getter for shader path
*/
std::string getShaderPath();
std::string getShaderPath() const;
protected:
......
......@@ -62,7 +62,7 @@ void WModuleInputConnector::connectSignals( boost::shared_ptr<WModuleConnector>
// connect dataChange signal with an internal handler to ensure we can add the "input" connector pointer, since the output
// connector does not set this information.
// NOTE: con will be an WModuleOutputConnector
// NOTE: con will be a WModuleOutputConnector
m_DataChangedConnection = con->subscribeSignal( DATA_CHANGED,
boost::bind( &WModuleInputConnector::notifyDataChange, this, _1, _2 )
);
......
......@@ -98,7 +98,7 @@ protected:
*/
virtual bool connectable( boost::shared_ptr<WModuleConnector> con )
{
if ( dynamic_cast<WModuleInputData<T>* >( con.get() ) ) // NOLINT - since we really need them here
if ( dynamic_cast< WModuleInputData< T >* >( con.get() ) ) // NOLINT - since we really need the dynamic cast here
{
// NOTE: the upper cast already checked the compatibility completely. WModuleOutputConnector::connectable does the
// same check again. But since we do not know what checks will be added to WModuleOutputConnector::connectable in the
......
......@@ -45,8 +45,9 @@
#include "../exceptions/WModuleException.h"
#include "../exceptions/WModuleConnectorUnconnected.h"
/**
* Class implementing a simple mod // required since pure virtualule, since proper testing of WModuleConnector itself is not usable.
/**
* Class implementing a simple module since WModuleConnector itself is not usable for proper
* testing itself because it is has pure virtual methods, i.e. is abstract.
*/
class WModuleImpl: public WModule
{
......@@ -106,6 +107,7 @@ protected:
*/
std::string n;
// required since pure virtual
virtual void threadMain()
{
// Since the modules run in a separate thread: such loops are possible
......@@ -133,8 +135,8 @@ protected:
virtual void notifyDataChange( boost::shared_ptr< WModuleConnector > /*input*/,
boost::shared_ptr< WModuleConnector > output )
{
// just copy the data
data=*( boost::shared_dynamic_cast< WModuleOutputData< int > >( output )->getData() ) + 1;
// just copy the data and add one
data = *( boost::shared_dynamic_cast< WModuleOutputData< int > >( output )->getData() ) + 1;
// std::cout << "change to " << data << " in " << input->getCanonicalName() << " from " << output->getCanonicalName()
// << std::endl;
......@@ -188,7 +190,7 @@ public:
*/
void createModules( void )
{
// init 2 separate test modules
// init 3 separate test modules
m1 = boost::shared_ptr< WModuleImpl >( new WModuleImpl( "m1" ) );
m2 = boost::shared_ptr< WModuleImpl >( new WModuleImpl( "m2" ) );
m3 = boost::shared_ptr< WModuleImpl >( new WModuleImpl( "m3" ) );
......@@ -220,7 +222,7 @@ public:
// check whether there are NO connectors.
// The constructor should now create connectors since shared_ptr are needed -> init in constructor leads to exception
// (its enough to test one of them)
// (it is enough to test one of them)
TS_ASSERT( m1->m_inputConnectors.size() == 0 );
TS_ASSERT( m1->m_outputConnectors.size() == 0 );
}
......@@ -299,7 +301,7 @@ public:
TS_ASSERT_THROWS_NOTHING( initConnections() );
// check that every connector has an connection count of 1
// check that every connector has a connection count of 1
TS_ASSERT( m1->m_output->m_Connected.size() == 1 );
TS_ASSERT( m1->m_input->m_Connected.size() == 1 );
TS_ASSERT( m2->m_output->m_Connected.size() == 1 );
......
......@@ -42,11 +42,6 @@ WFiberCluster::WFiberCluster( size_t index, const boost::shared_ptr< WDataSetFib
m_fibs = fibs;
}
bool WFiberCluster::empty() const
{
return m_memberIndices.empty();
}
void WFiberCluster::merge( WFiberCluster& other ) // NOLINT
{
std::list< size_t >::const_iterator cit = other.m_memberIndices.begin();
......@@ -90,26 +85,6 @@ void WFiberCluster::updateClusterIndices( std::vector< size_t >& cid, // NOLINT
}
}
void WFiberCluster::sort()
{
m_memberIndices.sort();
}
size_t WFiberCluster::size() const
{
return m_memberIndices.size();
}
void WFiberCluster::clear()
{
m_memberIndices.clear();
}
void WFiberCluster::setColor( WColor color )
{
m_color = color;
}
// void WFiberCluster::paintIntoFgePrimitive( FgeLineStrips *lstrips) const
// {
// typedef std::vector< FArray > Fiber;
......@@ -133,24 +108,3 @@ void WFiberCluster::setColor( WColor color )
// paintIntoFgePrimitive( lstrips );
// return lstrips;
// }
bool WFiberCluster::operator==( const WFiberCluster& other ) const
{
return m_memberIndices == other.m_memberIndices;
}
bool WFiberCluster::operator!=( const WFiberCluster& other ) const
{
return m_memberIndices != other.m_memberIndices;
}
const std::list< size_t > WFiberCluster::getIndices() const
{
return m_memberIndices;
}
std::ostream& operator<<( std::ostream& os, const WFiberCluster& c )
{
using string_utils::operator<<;
return os << c.getIndices();
}
......@@ -145,6 +145,50 @@ private:
WColor m_color;
};
std::ostream& operator<<( std::ostream& os, const WFiberCluster& c );
inline bool WFiberCluster::empty() const
{
return m_memberIndices.empty();
}
inline void WFiberCluster::sort()
{
m_memberIndices.sort();
}
inline size_t WFiberCluster::size() const
{
return m_memberIndices.size();
}
inline void WFiberCluster::clear()
{
m_memberIndices.clear();
}
inline void WFiberCluster::setColor( WColor color )