Commit 8102fd2b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] - added string and double property widgets

parent 08bd7658
......@@ -18,6 +18,8 @@ SET(GUI_QT4_MOC_HDRS
datasetbrowser/WPropertyWidget.h
datasetbrowser/WPropertyBoolWidget.h
datasetbrowser/WPropertyIntWidget.h
datasetbrowser/WPropertyDoubleWidget.h
datasetbrowser/WPropertyStringWidget.h
datasetbrowser/WQtDatasetBrowser.h
datasetbrowser/WQtDSBWidget.h
datasetbrowser/WQtLineEdit.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/>.
//
//---------------------------------------------------------------------------
#include <cmath>
#include <boost/lexical_cast.hpp>
#include "../../../common/WLogger.h"
#include "../../../common/WPropertyVariable.h"
#include "WPropertyDoubleWidget.h"
WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_doubleProperty( property ),
m_spin( this ),
m_layout()
{
// initialize members
setLayout( &m_layout );
// layout both against each other
m_layout.addWidget( &m_spin );
// get the min constraint
WPVDouble::PropertyConstraintMin minC = m_doubleProperty->getMin();
double min = 0.0;
if ( minC.get() )
{
min = minC->getMin();
}
else
{
WLogger::getLogger()->addLogMessage(
std::string( "The property has no minimum constraint. You should define it to avoid unexpected behaviour. ") +
std::string( "Using default (" + boost::lexical_cast< std::string >( min ) + ")." ),
"PropertyWidget( " + m_doubleProperty->getName() + " )", LL_WARNING );
}
// get the max constraint
WPVDouble::PropertyConstraintMax maxC = m_doubleProperty->getMax();
double max = 100.0;
if ( maxC.get() )
{
max = maxC->getMax();
}
else
{
WLogger::getLogger()->addLogMessage(
std::string( "The property has no maximum constraint. You should define it to avoid unexpected behaviour. ") +
std::string( "Using default (" + boost::lexical_cast< std::string >( max ) + ")." ),
"PropertyWidget( " + m_doubleProperty->getName() + " )", LL_WARNING );
}
// setup the slider
m_spin.setMinimum( min );
m_spin.setMaximum( max );
// set the initial values
m_spin.setValue( m_doubleProperty->get() );
m_spin.setSingleStep( ( max - min ) / 100.0 );
// connect the modification signal of the edit and slider with our callback
connect( &m_spin, SIGNAL( valueChanged( double ) ), this, SLOT( spinChanged( double ) ) );
}
WPropertyDoubleWidget::~WPropertyDoubleWidget()
{
// cleanup
}
void WPropertyDoubleWidget::spinChanged( double value )
{
// set to the property
if ( !m_doubleProperty->accept( value ) )
{
// this is not a valid value!
invalidate();
}
else
{
invalidate( false );
m_doubleProperty->set( value );
}
}
//---------------------------------------------------------------------------
//
// 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 WPROPERTYDOUBLEWIDGET_H
#define WPROPERTYDOUBLEWIDGET_H
#include <string>
#include <QtGui/QDoubleSpinBox>
#include <QtGui/QHBoxLayout>
#include "WPropertyWidget.h"
/**
* Implements a property widget for WPropDouble.
*/
class WPropertyDoubleWidget: public WPropertyWidget
{
Q_OBJECT
public:
/**
* Constructor. Creates a new widget appropriate for the specified property.
*
* \param property the property to handle
* \param parent the parent widget.
* \param propertyGrid the grid used to layout the labels and property widgets
*/
WPropertyDoubleWidget( WPropDouble property, QGridLayout* propertyGrid, QWidget* parent = 0 );
/**
* Destructor.
*/
virtual ~WPropertyDoubleWidget();
protected:
/**
* The integer property represented by this widget.
*/
WPropDouble m_doubleProperty;
/**
* Spin box for doubles
*/
QDoubleSpinBox m_spin;
/**
* Layout used to position the label and the checkbox
*/
QHBoxLayout m_layout;
private:
public slots:
/**
* Called whenever the spin box changes
*
* \param value the new value
*/
void spinChanged( double value );
};
#endif // WPROPERTYDOUBLEWIDGET_H
......@@ -23,7 +23,6 @@
//---------------------------------------------------------------------------
#include <iostream>
#include <sstream>
#include <cmath>
#include <boost/lexical_cast.hpp>
......@@ -98,9 +97,7 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property
m_edit.resize( m_edit.minimumSizeHint().width() * length / 2, m_edit.size().height() );
// set the initial values
std::ostringstream s;
s << m_intProperty->get();
m_edit.setText( QString( s.str().c_str() ) );
m_edit.setText( QString( boost::lexical_cast< std::string >( m_intProperty->get() ).c_str() ) );
m_slider.setValue( m_intProperty->get() );
// connect the modification signal of the edit and slider with our callback
......
//---------------------------------------------------------------------------
//
// 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 <iostream>
#include <cmath>
#include <boost/lexical_cast.hpp>
#include "../../../common/WLogger.h"
#include "../../../common/WPropertyVariable.h"
#include "WPropertyStringWidget.h"
WPropertyStringWidget::WPropertyStringWidget( WPropString property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_stringProperty( property ),
m_edit( this ),
m_layout()
{
// initialize members
setLayout( &m_layout );
// layout both against each other
m_layout.addWidget( &m_edit );
// set the initial values
m_edit.setText( QString( m_stringProperty->get().c_str() ) );
// connect the modification signal of the edit and slider with our callback
connect( &m_edit, SIGNAL( returnPressed() ), this, SLOT( editChanged() ) );
}
WPropertyStringWidget::~WPropertyStringWidget()
{
// cleanup
}
void WPropertyStringWidget::editChanged()
{
std::string value = m_edit.text().toStdString();
// now: is the value acceptable by the property?
if ( !m_stringProperty->accept( value ) )
{
invalidate();
}
else
{
invalidate( false );
m_stringProperty->set( value );
}
}
//---------------------------------------------------------------------------
//
// 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 WPROPERTYSTRINGWIDGET_H
#define WPROPERTYSTRINGWIDGET_H
#include <string>
#include <QtGui/QLineEdit>
#include <QtGui/QSlider>
#include <QtGui/QHBoxLayout>
#include "WPropertyWidget.h"
/**
* Implements a property widget for WPropString.
*/
class WPropertyStringWidget: public WPropertyWidget
{
Q_OBJECT
public:
/**
* Constructor. Creates a new widget appropriate for the specified property.
*
* \param property the property to handle
* \param parent the parent widget.
* \param propertyGrid the grid used to layout the labels and property widgets
*/
WPropertyStringWidget( WPropString property, QGridLayout* propertyGrid, QWidget* parent = 0 );
/**
* Destructor.
*/
virtual ~WPropertyStringWidget();
protected:
/**
* The integer property represented by this widget.
*/
WPropString m_stringProperty;
/**
* The edit field showing the value
*/
QLineEdit m_edit;
/**
* Layout used to position the label and the checkbox
*/
QHBoxLayout m_layout;
private:
public slots:
/**
* Called whenever the edit field changes
*/
void editChanged();
};
#endif // WPROPERTYSTRINGWIDGET_H
......@@ -49,14 +49,14 @@ WPropertyIntWidget* WQtDSBWidget::addPropInt( WPropInt property )
return new WPropertyIntWidget( property, &m_controlLayout, this );
}
WPropertyIntWidget* WQtDSBWidget::addPropDouble( WPropDouble property )
WPropertyDoubleWidget* WQtDSBWidget::addPropDouble( WPropDouble property )
{
return NULL;
return new WPropertyDoubleWidget( property, &m_controlLayout, this );
}
WPropertyIntWidget* WQtDSBWidget::addPropString( WPropString property )
WPropertyStringWidget* WQtDSBWidget::addPropString( WPropString property )
{
return NULL;
return new WPropertyStringWidget( property, &m_controlLayout, this );
}
void WQtDSBWidget::addSpacer()
......
......@@ -36,6 +36,8 @@
#include "WPropertyBoolWidget.h"
#include "WPropertyIntWidget.h"
#include "WPropertyStringWidget.h"
#include "WPropertyDoubleWidget.h"
#include "../../../common/WPropertyVariable.h"
......@@ -90,7 +92,7 @@ public:
*
* \return the widget that has been added.
*/
WPropertyIntWidget* addPropDouble( WPropDouble property );
WPropertyDoubleWidget* addPropDouble( WPropDouble property );
/**
* Adds a new int property to the DSB.
......@@ -99,7 +101,7 @@ public:
*
* \return the widget that has been added.
*/
WPropertyIntWidget* addPropString( WPropString property );
WPropertyStringWidget* addPropString( WPropString property );
/**
* helper function to add a spacer at the end
......
......@@ -102,8 +102,8 @@ void WMConnectomeView::connectors()
addConnector( m_mrtInput );
// this is the scalar field input
m_fiberInput = boost::shared_ptr< WModuleInputForwardData< WDataSetFibers2 > >(
new WModuleInputForwardData< WDataSetFibers2 >( shared_from_this(),
m_fiberInput = boost::shared_ptr< WModuleInputForwardData< WDataSetFibers > >(
new WModuleInputForwardData< WDataSetFibers >( shared_from_this(),
"fibers", "The fiber dataset used to find connection path." )
);
......
......@@ -33,7 +33,7 @@
#include <osg/Geode>
#include <osg/Uniform>
#include "../../dataHandler/WDataSetFibers2.h"
#include "../../dataHandler/WDataSetFibers.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleContainer.h"
......@@ -116,7 +116,7 @@ private:
/**
* The fiber dataset used.
*/
boost::shared_ptr< WModuleInputForwardData< WDataSetFibers2 > > m_fiberInput;
boost::shared_ptr< WModuleInputForwardData< WDataSetFibers > > m_fiberInput;
/**
* the current dataset
......
......@@ -141,6 +141,12 @@ void WMNavSlices::properties()
m_maxAxial = m_properties2->addProperty( "maxAxial", "Max position of axial slice.", 160, true );
m_maxCoronal = m_properties2->addProperty( "maxCoronal", "Max position of coronal slice.", 200, true );
m_maxSagittal = m_properties2->addProperty( "maxSagittal", "Max position of sagittal slice.", 160, true );
WPropDouble d = m_properties2->addProperty( "hallo", "Position of axial slice.", 5.0 );
d->setMin( 0.5 );
d->setMax( 10.2 );
WPropString s = m_properties2->addProperty( "hallo2", "Position of axial slice.", std::string( "hallo du" ) );
}
void WMNavSlices::notifyDataChange( boost::shared_ptr<WModuleConnector> input,
......
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