Commit 8d10d37f authored by schurade's avatar schurade
Browse files

[FIX] more work on loading multiple textures, and correct updating of the OSG node

parent cf4678c5
......@@ -89,7 +89,7 @@ void WLoaderNIfTI::operator()()
unsigned int vDim = header->dim[4];
unsigned int countVoxels = columns * rows * frames;
nifti_image_infodump( header );
// nifti_image_infodump( header );
switch( header->datatype )
{
......
......@@ -47,6 +47,11 @@ public:
virtual bool isInitalized() = 0;
/**
* function to create a main window on demand, so it doesn't happen in the constructor
*/
virtual void createMainWindow() = 0;
/**
* adds a dataset to the dataset browser for a give subject
*/
......
......@@ -70,22 +70,30 @@ void WMainWindow::setupGUI( QMainWindow *mainWindow )
m_toolBar = new WQtRibbonMenu( mainWindow );
mainWindow->addToolBar( Qt::TopToolBarArea, m_toolBar );
std::cout << "init main gl" << std::endl;
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( mainWindow ) );
m_glWidgets.push_back( widget );
mainWindow->setCentralWidget( widget.get() );
// initially 3 views
m_navAxial = new WQtNavGLWidget( "axial", 160, "axialPos" );
m_glWidgets.push_back( m_navAxial->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navAxial );
m_navCoronal = new WQtNavGLWidget( "coronal", 200, "coronalPos" );
m_glWidgets.push_back( m_navCoronal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal );
m_navSagittal = new WQtNavGLWidget( "sagittal", 160, "sagittalPos" );
m_glWidgets.push_back( m_navSagittal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal );
// // initially 3 views
// std::cout << "init nav gl 1" << std::endl;
// m_navAxial = new WQtNavGLWidget( "axial", 160, "axialPos" );
// m_glWidgets.push_back( m_navAxial->getGLWidget() );
// mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navAxial );
//
// std::cout << "init nav gl 2" << std::endl;
// m_navCoronal = new WQtNavGLWidget( "coronal", 200, "coronalPos" );
// m_glWidgets.push_back( m_navCoronal->getGLWidget() );
// mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal );
//
// std::cout << "init nav gl 3" << std::endl;
// m_navSagittal = new WQtNavGLWidget( "sagittal", 160, "sagittalPos" );
// 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 ) ) );
m_datasetBrowser = new WQtDatasetBrowser();
mainWindow->addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
......@@ -100,10 +108,6 @@ void WMainWindow::setupGUI( QMainWindow *mainWindow )
connect( m_toolBar->getCorButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleCoronal( bool ) ) );
connect( m_toolBar->getSagButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleSagittal( bool ) ) );
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_datasetBrowser, SIGNAL( dataSetBrowserEvent( QString, bool ) ), m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
}
......
......@@ -57,7 +57,6 @@ void WQt4Gui::threadMain()
QMainWindow* mainWindow = new QMainWindow;
m_gui = new WMainWindow;
m_gui->setupGUI( mainWindow );
mainWindow->show();
m_isInitialized = true;
......@@ -65,9 +64,14 @@ void WQt4Gui::threadMain()
int qtExecResult;
qtExecResult = appl.exec();
// TODO(ebaum): how to handle return codes?
}
void WQt4Gui::createMainWindow()
{
}
void WQt4Gui::addDatasetToBrowser( boost::shared_ptr< WModule > module, int subjectId )
{
m_gui->getDatasetBrowser()->addDataset( module, subjectId );
......
......@@ -49,6 +49,12 @@ public:
*/
virtual ~WQt4Gui();
/**
* function to create a main window on demand, so it doesn't happen in the constructor
*/
virtual void createMainWindow();
/**
* return trues when initialization is finished, otherwise false
*/
......
......@@ -81,8 +81,8 @@ void WQtDatasetBrowser::connectSlots()
{
connect( m_treeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( selectTreeItem() ) );
connect( m_treeWidget, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ), this, SLOT( changeTreeItem() ) );
connect( m_upButton, SIGNAL( pressed() ), m_treeWidget, SLOT( moveTreeItemUp() ) );
connect( m_downButton, SIGNAL( pressed() ), m_treeWidget, SLOT( moveTreeItemDown() ) );
connect( m_upButton, SIGNAL( pressed() ), this, SLOT( moveTreeItemUp() ) );
connect( m_downButton, SIGNAL( pressed() ), this, SLOT( moveTreeItemDown() ) );
}
......@@ -245,3 +245,16 @@ std::vector< boost::shared_ptr< WModule > >WQtDatasetBrowser::getDataSetList( in
}
return moduleList;
}
void WQtDatasetBrowser::moveTreeItemDown()
{
m_treeWidget->moveTreeItemDown();
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
void WQtDatasetBrowser::moveTreeItemUp()
{
m_treeWidget->moveTreeItemUp();
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
......@@ -117,6 +117,17 @@ private slots:
*/
void changeTreeItem();
/**
* change order of items, move currently selected item down
*/
void moveTreeItemDown();
/**
* change order of items, move currently selected item up
*/
void moveTreeItemUp();
signals:
void dataSetBrowserEvent( QString name, bool value );
};
......
......@@ -51,7 +51,7 @@ WKernel* kernel = NULL;
WKernel::WKernel( int argc, char* argv[], boost::shared_ptr< WGUI > gui )
: m_gui( gui )
{
std::cout << "Initializing Kernel" << std::endl;
WLogger::getLogger()->addLogMessage( "Initializing Kernel", "Kernel", LL_DEBUG );
kernel = this;
......@@ -194,7 +194,7 @@ void WKernel::loadModules()
void WKernel::init()
{
// initialize
// initialize
findAppPath();
// initialize graphics engine
......@@ -204,6 +204,8 @@ void WKernel::init()
// initialize Datahandler
m_dataHandler = boost::shared_ptr< WDataHandler >( new WDataHandler() );
// m_gui->createMainWindow();
m_dataHandler->getSignalAddDataset()->connect( boost::bind( &WKernel::slotFinishLoadData, this, _1 ) );
}
......
......@@ -91,7 +91,7 @@ public:
/**
* getter for the 3d texture, which will be created on demand
*/
virtual osg::Texture3D* getTexture3D();
virtual osg::ref_ptr<osg::Texture3D> getTexture3D();
protected:
......@@ -126,9 +126,9 @@ protected:
* \param components Number of values used in a Voxel, usually 1, 3 or 4
* \return Pointer to a new texture3D
*/
osg::Texture3D* createTexture3D( unsigned char* source, boost::shared_ptr<WGridRegular3D> grid, int components = 1 );
osg::Texture3D* createTexture3D( int16_t* source, boost::shared_ptr<WGridRegular3D> grid, int components = 1 );
osg::Texture3D* createTexture3D( float* source, boost::shared_ptr<WGridRegular3D> grid, int components = 1 );
osg::ref_ptr<osg::Texture3D> createTexture3D( unsigned char* source, boost::shared_ptr<WGridRegular3D> grid, int components = 1 );
osg::ref_ptr<osg::Texture3D> createTexture3D( int16_t* source, boost::shared_ptr<WGridRegular3D> grid, int components = 1 );
osg::ref_ptr<osg::Texture3D> createTexture3D( float* source, boost::shared_ptr<WGridRegular3D> grid, int components = 1 );
private:
......@@ -146,7 +146,7 @@ private:
/**
* pointer to the 3d texture
*/
osg::Texture3D* m_texture3D;
osg::ref_ptr<osg::Texture3D> m_texture3D;
};
// TODO(schurade, ebaum): do we still need/want that constructor?
......@@ -241,15 +241,13 @@ boost::shared_ptr< WDataSet > WDataModule<T>::getDataSet()
}
template < typename T >
osg::Texture3D* WDataModule<T>::getTexture3D()
osg::ref_ptr<osg::Texture3D> WDataModule<T>::getTexture3D()
{
if ( !m_texture3D )
{
boost::shared_ptr< WDataSetSingle > ds = boost::shared_dynamic_cast< WDataSetSingle >( m_dataSet );
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( ds->getGrid() );
std::cout << "type:" << ds->getValueSet()->getDataType() << std::endl;
if ( ds->getValueSet()->getDataType() == 2 )
{
boost::shared_ptr< WValueSet< unsigned char > > vs = boost::shared_dynamic_cast< WValueSet< unsigned char > >( ds->getValueSet() );
......@@ -275,7 +273,7 @@ osg::Texture3D* WDataModule<T>::getTexture3D()
}
template < typename T >
osg::Texture3D* WDataModule<T>::createTexture3D( unsigned char* source, boost::shared_ptr<WGridRegular3D> grid, int components )
osg::ref_ptr<osg::Texture3D> WDataModule<T>::createTexture3D( unsigned char* source, boost::shared_ptr<WGridRegular3D> grid, int components )
{
if ( components == 1 )
{
......@@ -288,7 +286,7 @@ osg::Texture3D* WDataModule<T>::createTexture3D( unsigned char* source, boost::s
{
data[i] = source[i];
}
osg::Texture3D* texture3D = new osg::Texture3D;
osg::ref_ptr<osg::Texture3D> texture3D = osg::ref_ptr<osg::Texture3D>( new osg::Texture3D );
texture3D->setFilter( osg::Texture3D::MIN_FILTER, osg::Texture3D::LINEAR );
texture3D->setFilter( osg::Texture3D::MAG_FILTER, osg::Texture3D::LINEAR );
texture3D->setWrap( osg::Texture3D::WRAP_R, osg::Texture3D::REPEAT );
......@@ -308,7 +306,7 @@ osg::Texture3D* WDataModule<T>::createTexture3D( unsigned char* source, boost::s
{
data[i] = source[i];
}
osg::Texture3D* texture3D = new osg::Texture3D;
osg::ref_ptr<osg::Texture3D> texture3D = osg::ref_ptr<osg::Texture3D>( new osg::Texture3D );
texture3D->setFilter( osg::Texture3D::MIN_FILTER, osg::Texture3D::LINEAR );
texture3D->setFilter( osg::Texture3D::MAG_FILTER, osg::Texture3D::LINEAR );
texture3D->setWrap( osg::Texture3D::WRAP_R, osg::Texture3D::REPEAT );
......@@ -322,7 +320,7 @@ osg::Texture3D* WDataModule<T>::createTexture3D( unsigned char* source, boost::s
}
template < typename T >
osg::Texture3D* WDataModule<T>::createTexture3D( int16_t* source, boost::shared_ptr<WGridRegular3D> grid, int components )
osg::ref_ptr<osg::Texture3D> WDataModule<T>::createTexture3D( int16_t* source, boost::shared_ptr<WGridRegular3D> grid, int components )
{
if ( components == 1)
{
......@@ -337,7 +335,7 @@ osg::Texture3D* WDataModule<T>::createTexture3D( int16_t* source, boost::shared_
{
data[i] = charSource[i];
}
osg::Texture3D* texture3D = new osg::Texture3D;
osg::ref_ptr<osg::Texture3D> texture3D = osg::ref_ptr<osg::Texture3D>( new osg::Texture3D );
texture3D->setFilter( osg::Texture3D::MIN_FILTER, osg::Texture3D::LINEAR );
texture3D->setFilter( osg::Texture3D::MAG_FILTER, osg::Texture3D::LINEAR );
texture3D->setWrap( osg::Texture3D::WRAP_R, osg::Texture3D::REPEAT );
......@@ -350,7 +348,7 @@ osg::Texture3D* WDataModule<T>::createTexture3D( int16_t* source, boost::shared_
}
template < typename T >
osg::Texture3D* WDataModule<T>::createTexture3D( float* source, boost::shared_ptr<WGridRegular3D> grid, int components )
osg::ref_ptr<osg::Texture3D> WDataModule<T>::createTexture3D( float* source, boost::shared_ptr<WGridRegular3D> grid, int components )
{
if ( components == 1)
{
......@@ -365,7 +363,7 @@ osg::Texture3D* WDataModule<T>::createTexture3D( float* source, boost::shared_pt
{
data[i] = charSource[i];
}
osg::Texture3D* texture3D = new osg::Texture3D;
osg::ref_ptr<osg::Texture3D> texture3D = osg::ref_ptr<osg::Texture3D>( new osg::Texture3D );
texture3D->setFilter( osg::Texture3D::MIN_FILTER, osg::Texture3D::LINEAR );
texture3D->setFilter( osg::Texture3D::MAG_FILTER, osg::Texture3D::LINEAR );
texture3D->setWrap( osg::Texture3D::WRAP_R, osg::Texture3D::REPEAT );
......
......@@ -97,7 +97,7 @@ void WNavigationSliceModule::connectors()
void WNavigationSliceModule::properties()
{
( m_properties.addBool( "textureChanged", true ) );
( m_properties.addBool( "textureChanged", false ) );
( m_properties.addInt( "axialPos", 80 ) );
( m_properties.addInt( "coronalPos", 100 ) );
......@@ -122,7 +122,7 @@ void WNavigationSliceModule::notifyDataChange( boost::shared_ptr<WModuleConnecto
void WNavigationSliceModule::threadMain()
{
createSlices();
createGeometry();
// Since the modules run in a separate thread: such loops are possible
while ( !m_FinishRequested )
......@@ -134,7 +134,7 @@ void WNavigationSliceModule::threadMain()
// clean up stuff
}
void WNavigationSliceModule::createSlices()
void WNavigationSliceModule::createGeometry()
{
float axialPos = ( float )( m_properties.getValue< int >( "axialPos" ) );
float coronalPos = ( float )( m_properties.getValue< int >( "coronalPos" ) );
......@@ -223,7 +223,7 @@ void WNavigationSliceModule::createSlices()
m_sliceNode->setUpdateCallback( new sliceNodeCallback( boost::shared_dynamic_cast<WNavigationSliceModule>( shared_from_this() ) ) );
}
void WNavigationSliceModule::updateSlices()
void WNavigationSliceModule::updateGeometry()
{
float axialPos = ( float )( m_properties.getValue< int >( "axialPos" ) );
float coronalPos = ( float )( m_properties.getValue< int >( "coronalPos" ) );
......@@ -331,7 +331,7 @@ void WNavigationSliceModule::updateTextures()
}
osg::StateSet* sliceState = m_sliceNode->getOrCreateStateSet();
int c = 0;
for ( size_t i = 0; i < datasetList.size(); ++i )
{
if ( datasetList[i]->getProperties()->getValue<bool>( "active" ) &&
......@@ -339,15 +339,17 @@ void WNavigationSliceModule::updateTextures()
{
osg::Texture3D* texture3D = boost::shared_dynamic_cast<WDataModule<int> >( datasetList[i] )->getTexture3D();
sliceState->setTextureAttributeAndModes( i, texture3D, osg::StateAttribute::ON );
sliceState->setTextureAttributeAndModes( c, texture3D, osg::StateAttribute::ON );
float t = ( float ) ( datasetList[i]->getProperties()->getValue<int>( "threshold" ) ) / 100.0;
float a = ( float ) ( datasetList[i]->getProperties()->getValue<int>( "alpha" ) ) / 100.0;
m_typeUniforms[i]->set( boost::shared_dynamic_cast<WDataSetSingle>(
m_typeUniforms[c]->set( boost::shared_dynamic_cast<WDataSetSingle>(
boost::shared_dynamic_cast<WDataModule<int> >( datasetList[i] )->getDataSet() )->getValueSet()->getDataType() );
m_thresholdUniforms[i]->set( t );
m_alphaUniforms[i]->set( a );
m_thresholdUniforms[c]->set( t );
m_alphaUniforms[c]->set( a );
++c;
}
}
......
......@@ -82,7 +82,7 @@ public:
/**
* updates the positions of the navigation slices
*/
void updateSlices();
void updateGeometry();
/**
* updates textures and shader parameters
......@@ -121,7 +121,7 @@ private:
/**
* initial creation function for the slice geometry
*/
void createSlices();
void createGeometry();
/**
* creates and initializes the uniform parameters for the shader
......@@ -162,7 +162,7 @@ public:
{
if ( m_module )
{
m_module->updateSlices();
m_module->updateGeometry();
m_module->updateTextures();
}
traverse( node, nv );
......
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