diff --git a/src/gui/qt4/CMakeLists.txt b/src/gui/qt4/CMakeLists.txt index 9e5b96ffe829c679472c82756c49e3ed59945c70..ff55395e8972d92a02b18f2aa4d202a73d06e961 100644 --- a/src/gui/qt4/CMakeLists.txt +++ b/src/gui/qt4/CMakeLists.txt @@ -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 diff --git a/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3298b953da3bc4a53f16622d4ff6cf228b39928f --- /dev/null +++ b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.cpp @@ -0,0 +1,107 @@ +//--------------------------------------------------------------------------- +// +// 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 . +// +//--------------------------------------------------------------------------- + +#include + +#include + +#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 ); + } +} + diff --git a/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..bf55d8ab4d9d8d87922e0ef54d90e3fd1803a80d --- /dev/null +++ b/src/gui/qt4/datasetbrowser/WPropertyDoubleWidget.h @@ -0,0 +1,87 @@ +//--------------------------------------------------------------------------- +// +// 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 . +// +//--------------------------------------------------------------------------- + +#ifndef WPROPERTYDOUBLEWIDGET_H +#define WPROPERTYDOUBLEWIDGET_H + +#include + +#include +#include + +#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 + diff --git a/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp index 3bc3afd2411c0425d67fec9e7dcc7f95874e1586..e9530d32de859883336a2703e621688251dc68f7 100644 --- a/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WPropertyIntWidget.cpp @@ -23,7 +23,6 @@ //--------------------------------------------------------------------------- #include -#include #include #include @@ -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 diff --git a/src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..805f75c1d68eda9f19a9d7c448354dc4aa716267 --- /dev/null +++ b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.cpp @@ -0,0 +1,73 @@ +//--------------------------------------------------------------------------- +// +// 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 . +// +//--------------------------------------------------------------------------- + +#include +#include + +#include + +#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 ); + } +} + diff --git a/src/gui/qt4/datasetbrowser/WPropertyStringWidget.h b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..baa25183a1c18f5ba0a99450e777836cfc76c03e --- /dev/null +++ b/src/gui/qt4/datasetbrowser/WPropertyStringWidget.h @@ -0,0 +1,86 @@ +//--------------------------------------------------------------------------- +// +// 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 . +// +//--------------------------------------------------------------------------- + +#ifndef WPROPERTYSTRINGWIDGET_H +#define WPROPERTYSTRINGWIDGET_H + +#include + +#include +#include +#include + +#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 + diff --git a/src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp b/src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp index 095f05578bb4c84f6ffd7dc35a8ed79e9245e588..3d266f1a9c833c2bd4b22f57c5631b398bc3766b 100644 --- a/src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp +++ b/src/gui/qt4/datasetbrowser/WQtDSBWidget.cpp @@ -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() diff --git a/src/gui/qt4/datasetbrowser/WQtDSBWidget.h b/src/gui/qt4/datasetbrowser/WQtDSBWidget.h index 303e4b0efbf5e0b370b16851f6930d49b0e4731c..ca395d6b4ed7762a29c7669c34e3f4e82fe2aa12 100644 --- a/src/gui/qt4/datasetbrowser/WQtDSBWidget.h +++ b/src/gui/qt4/datasetbrowser/WQtDSBWidget.h @@ -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 diff --git a/src/modules/connectomeView/WMConnectomeView.cpp b/src/modules/connectomeView/WMConnectomeView.cpp index a10922c106ba15475b0c78cbe5388bbbf29c3452..be3aa3cb4baac032c9107675aca0206b9a9877cd 100644 --- a/src/modules/connectomeView/WMConnectomeView.cpp +++ b/src/modules/connectomeView/WMConnectomeView.cpp @@ -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." ) ); diff --git a/src/modules/connectomeView/WMConnectomeView.h b/src/modules/connectomeView/WMConnectomeView.h index 574377d680558976b67a0822ab3b25a247add862..8559165158353fe97e7754b0c74c7c9bf2968ba5 100644 --- a/src/modules/connectomeView/WMConnectomeView.h +++ b/src/modules/connectomeView/WMConnectomeView.h @@ -33,7 +33,7 @@ #include #include -#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 diff --git a/src/modules/navSlices/WMNavSlices.cpp b/src/modules/navSlices/WMNavSlices.cpp index e859daebb54600882c99fa15f49e0610a02c871b..9302a130e6c8fc43c9bb11d69865e9581507e90d 100644 --- a/src/modules/navSlices/WMNavSlices.cpp +++ b/src/modules/navSlices/WMNavSlices.cpp @@ -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 input,