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

[MERGE]

parents 66281a5b 60c3a05e
......@@ -109,6 +109,14 @@ boost::shared_ptr< WDataSet > WLoaderNIfTI::load()
break;
}
case DT_INT32:
{
std::vector< int32_t > data = copyArray( reinterpret_cast< int32_t* >( filedata->data ), countVoxels, vDim );
newValueSet = boost::shared_ptr< WValueSetBase >( new WValueSet< int32_t >( order, vDim, data, W_DT_SIGNED_INT ) );
break;
}
case DT_FLOAT:
{
std::vector< float > data = copyArray( reinterpret_cast< float* >( filedata->data ), countVoxels, vDim );
......
......@@ -21,6 +21,7 @@ SET(GUI_QT4_MOC_HDRS
datasetbrowser/WQtLineEdit.h
datasetbrowser/WQtSliderWithEdit.h
datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtNumberEditDouble.h
datasetbrowser/WQtTreeWidget.h
)
......
......@@ -112,6 +112,23 @@ WQtSliderWithEdit* WQtDSBWidget::addSliderInt( QString label, int value, int min
return slider;
}
WQtNumberEditDouble* WQtDSBWidget::addNumberEditDouble( QString label, double value )
{
int row = m_controlLayout.rowCount();
QLabel* qlabel = new QLabel( label );
WQtNumberEditDouble* numberEdit = new WQtNumberEditDouble( label );
numberEdit->setDouble( value );
m_controlLayout.addWidget( qlabel, row, 0 );
m_controlLayout.addWidget( numberEdit, row, 1 );
setLayout( &m_pageLayout );
return numberEdit;
}
void WQtDSBWidget::addSpacer()
{
m_pageLayout.addStretch();
......
......@@ -36,6 +36,7 @@
#include "WQtCheckBox.h"
#include "WQtLineEdit.h"
#include "WQtNumberEditDouble.h"
#include "WQtSliderWithEdit.h"
......@@ -72,6 +73,13 @@ public:
*/
WQtLineEdit* addLineEdit( QString label, QString text = QString( "" ) );
/**
* helper function to add a double number edit control
* \param label name of the control
* \param value value of the control
*/
WQtNumberEditDouble* addNumberEditDouble( QString label, double value );
/**
* helper function to add a slider with a connect line edit
*/
......
......@@ -36,6 +36,7 @@
#include "WQtDatasetBrowser.h"
#include "WQtNumberEdit.h"
#include "WQtNumberEditDouble.h"
#include "WQtCheckBox.h"
#include "WQtModuleHeaderTreeItem.h"
......@@ -208,7 +209,12 @@ void WQtDatasetBrowser::selectTreeItem()
case P_FLOAT:
break;
case P_DOUBLE:
{
QString name = QString( props.at( i )->getName().c_str() );
WQtNumberEditDouble* numberEdit = tab1->addNumberEditDouble( name, props.at( i )->getValue<double>() );
connect( numberEdit, SIGNAL( signalNumberWithName( QString, double ) ), this, SLOT( slotSetDoubleProperty( QString, double ) ) );
break;
}
case P_STRING:
{
QString name = QString( props.at( i )->getName().c_str() );
......@@ -270,6 +276,14 @@ void WQtDatasetBrowser::slotSetIntProperty( QString name, int value )
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
void WQtDatasetBrowser::slotSetDoubleProperty( QString name, double value )
{
boost::shared_ptr< WModule >module =( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
module->getProperties()->setValue<double>( name.toStdString(), value );
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
void WQtDatasetBrowser::slotSetBoolProperty( QString name, bool value )
{
boost::shared_ptr< WModule >module =( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
......
......@@ -129,6 +129,14 @@ public slots:
*/
void slotSetIntProperty( QString name, int value );
/**
* slot to connect dynamically created controls
*
* \param name The name of the control
* \param value The value of the property
*/
void slotSetDoubleProperty( QString name, double value );
/**
* slot to connect dynamically created controls
*
......
//---------------------------------------------------------------------------
//
// 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 "WQtNumberEditDouble.h"
WQtNumberEditDouble::WQtNumberEditDouble( QString name, QWidget* parent )
: QLineEdit( parent ),
m_name( name )
{
connect( this, SIGNAL( returnPressed() ), this, SLOT( numberChanged() ) );
}
WQtNumberEditDouble::~WQtNumberEditDouble()
{
}
void WQtNumberEditDouble::setName( QString name )
{
m_name = name;
}
void WQtNumberEditDouble::setDouble( double number )
{
setText( QString::number( number ) );
emit signalNumberWithName( m_name, number );
}
void WQtNumberEditDouble::numberChanged()
{
bool ok;
double number = text().toDouble( &ok );
if ( ok )
{
emit signalNumberWithName( m_name, number );
}
else
{
setText( QString::number( 0 ) );
emit signalNumberWithName( m_name, 0 );
}
}
//---------------------------------------------------------------------------
//
// 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 WQTNUMBEREDITDOUBLE_H
#define WQTNUMBEREDITDOUBLE_H
#include <string>
#include <QtGui/QLineEdit>
/**
* a QLineEdit modified to deal only with double numbers
*/
class WQtNumberEditDouble : public QLineEdit
{
Q_OBJECT
public:
/**
* Default constructor, that connects the slot of the edit
*/
explicit WQtNumberEditDouble( QString name, QWidget* parent = 0 );
/**
* setter for name
*/
void setName( QString name );
/**
* destructor
*/
virtual ~WQtNumberEditDouble();
public slots:
/**
* Sets the edit field to a certain number.
* \param number The double to be put into the field.
*/
void setDouble( double number );
/**
* Updated the number in the lineEdit if the number has changed.
*/
void numberChanged();
signals:
/**
* Signal to distribute the number set in the lineEdit.
*/
void signalNumberWithName( QString name, double number );
protected:
private:
QString m_name;
};
#endif // WQTNUMBEREDITDOUBLE_H
......@@ -232,41 +232,14 @@ osg::ref_ptr<osg::Geometry> WMCoordinateSystem::createGeometryNode()
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 );
// TODO(schurade): Hi, here is math, I really don't now what this is for, so maybe you can give "data" and "rawData" a better
// name? Thanks.
unsigned int rawData[] = { 1, 2, 2, 3, 3, 4, 4, 1,
5, 6, 6, 7, 7, 8, 8, 5,
1, 5, 2, 6, 3, 7, 4, 8,
9, 10, 11, 12, 13, 14 };
std::vector< unsigned int > data( rawData, rawData + sizeof( rawData ) / sizeof( unsigned int ) );
osg::DrawElementsUInt* lines = new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, data.begin(), data.end() );
geometry->addPrimitiveSet( lines );
......
......@@ -151,6 +151,9 @@ boost::shared_ptr< WValueSet< float > > makeFloatValueSet( boost::shared_ptr< WV
case W_DT_INT16:
return makeFloatValueSetHelper( boost::shared_dynamic_cast< WValueSet< int16_t > >( inSet ) );
break;
case W_DT_SIGNED_INT:
return makeFloatValueSetHelper( boost::shared_dynamic_cast< WValueSet< int32_t > >( inSet ) );
break;
case W_DT_FLOAT:
return boost::shared_dynamic_cast< WValueSet< float > >( inSet );
break;
......
......@@ -157,7 +157,9 @@ void WMMarchingCubes::connectors()
void WMMarchingCubes::properties()
{
m_properties->addBool( "textureChanged", false, true );
m_properties->addInt( "Iso Value", 100 )->connect( boost::bind( &WMMarchingCubes::slotPropertyChanged, this, _1 ) );
m_properties->addBool( "active", true, true )->connect( boost::bind( &WMMarchingCubes::slotPropertyChanged, this, _1 ) );
m_properties->addDouble( "Iso Value", 100 )->connect( boost::bind( &WMMarchingCubes::slotPropertyChanged, this, _1 ) );
m_properties->addBool( "Use Texture", true )->connect( boost::bind( &WMMarchingCubes::slotPropertyChanged, this, _1 ) );
}
void WMMarchingCubes::slotPropertyChanged( std::string propertyName )
......@@ -165,20 +167,40 @@ void WMMarchingCubes::slotPropertyChanged( std::string propertyName )
// TODO(wiebel): MC improve this method when corresponding infrastructure is ready
if( propertyName == "Iso Value" )
{
double isoValue = m_properties->getValue< double >( "Iso Value" );
debugLog() << "Update isosurface for isovalue: " << isoValue << std::endl;
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->removeChild( m_geode );
generateSurfacePre( m_properties->getValue< int >( "Iso Value" ) );
generateSurfacePre( isoValue );
renderSurface();
// updateTextures();
debugLog() << "Updating done." << std::endl;
}
else if( propertyName == "Use Texture" )
{
debugLog() << "Change Texture property." << std::endl;
m_shaderUseTexture = m_properties->getValue< bool >( "Use Texture" );
updateTextures();
}
else if( propertyName == "active" )
{
if ( m_properties->getValue<bool>( "active" ) )
{
m_geode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_geode->setNodeMask( 0x0 );
}
}
else
{
std::cout << propertyName << std::endl;
assert( 0 && "This property name is not supported by this function yet." );
}
}
void WMMarchingCubes::generateSurfacePre( double isoValue )
{
infoLog() << "Isovalue: " << isoValue << std::endl;
debugLog() << "Isovalue: " << isoValue << std::endl;
switch( (*m_dataSet).getValueSet()->getDataType() )
{
case W_DT_UNSIGNED_CHAR:
......@@ -197,6 +219,14 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
generateSurface( ( *m_dataSet ).getGrid(), vals, isoValue );
break;
}
case W_DT_SIGNED_INT:
{
boost::shared_ptr< WValueSet< int32_t > > vals;
vals = boost::shared_dynamic_cast< WValueSet< int32_t > >( ( *m_dataSet ).getValueSet() );
assert( vals );
generateSurface( ( *m_dataSet ).getGrid(), vals, isoValue );
break;
}
case W_DT_FLOAT:
{
boost::shared_ptr< WValueSet< float > > vals;
......@@ -944,6 +974,9 @@ void WMMarchingCubes::updateTextures()
}
osg::StateSet* rootState = m_geode->getOrCreateStateSet();
rootState->addUniform( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useTexture", m_shaderUseTexture ) ) );
rootState->addUniform( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useLighting", m_shaderUseLighting ) ) );
int c = 0;
for ( size_t i = 0; i < dsl.size(); ++i )
{
......
......@@ -55,7 +55,7 @@ void lookupTex(inout vec4 col, in int type, in sampler3D tex, in vec3 v, in floa
void main()
{
vec4 col = vec4(0.0, 0.0, 0.0, 0.0);
vec4 col = vec4(0.3, 0.3, 0.3, 0.0);
vec4 ambient = vec4(0.0);
vec4 diffuse = vec4(0.0);
......
......@@ -23,32 +23,29 @@
//---------------------------------------------------------------------------
#include <iostream>
#include <list>
#include <string>
#include <vector>
#include <list>
#include <boost/shared_ptr.hpp>
#include <osg/Group>
#include <osg/Geode>
#include <osg/Geometry>
#include "WMNavSlices.h"
#include "../../kernel/WKernel.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleConnector.h"
#include "../../kernel/WModuleInputData.h"
#include <osg/Group>
#include "../../dataHandler/WDataSet.h"
#include "../../dataHandler/WDataSetSingle.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../../dataHandler/WGridRegular3D.h"
#include "../../dataHandler/WSubject.h"
#include "../../dataHandler/WValueSet.h"
#include "../../dataHandler/WGridRegular3D.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../data/WMData.h"
#include "../../graphicsEngine/WShader.h"
#include "../../kernel/WKernel.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleConnector.h"
#include "../../kernel/WModuleInputData.h"
#include "../data/WMData.h"
#include "WMNavSlices.h"
WMNavSlices::WMNavSlices():
WModule()
......
......@@ -32,11 +32,10 @@
#include <osg/Node>
#include "../../dataHandler/WDataSet.h"
#include "../../graphicsEngine/WShader.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleConnector.h"
#include "../../kernel/WModuleInputData.h"
#include "../../graphicsEngine/WShader.h"
/**
* \par Description:
......
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