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

[ADD] added qt module control for double variables and used it in

WMMarchingCubes
parent 2f67218a
......@@ -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
......@@ -42,7 +42,7 @@ WQtSliderWithEdit::WQtSliderWithEdit( QString name, QWidget* parent )
setLayout( &m_layout );
connect( &m_slider, SIGNAL( valueChanged( int ) ), &m_edit, SLOT( setInt( int ) ) );
connect( &m_slider, SIGNAL( valueChanged( int ) ), &m_edit, SLOT( setNumber( double ) ) );
connect( &m_slider, SIGNAL( valueChanged( int ) ), this, SLOT( emitValue() ) );
connect( &m_edit, SIGNAL( signalNumber( int ) ), &m_slider, SLOT( setValue( int ) ) );
}
......
......@@ -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;
......
......@@ -154,7 +154,7 @@ 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->addDouble( "Iso Value", 100 )->connect( boost::bind( &WMMarchingCubes::slotPropertyChanged, this, _1 ) );
}
void WMMarchingCubes::slotPropertyChanged( std::string propertyName )
......@@ -162,9 +162,12 @@ 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" );
infoLog() << "Update isosurface for isovalue: " << isoValue << std::endl;
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->removeChild( m_geode );
generateSurfacePre( m_properties->getValue< int >( "Iso Value" ) );
generateSurfacePre( isoValue );
renderSurface();
infoLog() << "Updating done." << std::endl;
// updateTextures();
}
else
......@@ -194,6 +197,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;
......
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