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

[ADD #172] basiic, non-functional interval widget added

parent 76bd32cd
......@@ -183,3 +183,8 @@ boost::shared_ptr< WCondition > WPropertyBase::getUpdateCondition() const
return m_updateCondition;
}
WPropInterval WPropertyBase::toPropInterval()
{
return boost::shared_static_cast< WPVInterval >( shared_from_this() );
}
......@@ -265,7 +265,7 @@ public:
/**
* Helper converts this instance to its native type.
*
* \return the property as matrix4x4 property
* \return the property as transfer function property
*/
WPropTransferFunction toPropTransferFunction();
......@@ -276,6 +276,13 @@ public:
*/
WPropGroup toPropGroup();
/**
* Helper converts this instance to its native type.
*
* \return the property as interval property
*/
WPropInterval toPropInterval();
/**
* Convert the property to a WPropertyGroupBase. This can be done with property structs and groups-
*
......
//---------------------------------------------------------------------------
//
// 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 <algorithm>
#include <cmath>
#include <limits>
#include <sstream>
#include <iostream>
#include <string>
#include <QtGui/QInputDialog>
#include "../WGuiConsts.h"
#include "../WQt4Gui.h"
#include "../guiElements/WQtIntervalEdit.h"
#include "core/common/WLogger.h"
#include "core/common/WPropertyVariable.h"
#include "WPropertyIntervalWidget.h"
#include "WPropertyIntervalWidget.moc"
WPropertyIntervalWidget::WPropertyIntervalWidget( WPropInterval property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_intervalProperty( property ),
m_layout(),
m_vLayout( &m_parameterWidgets ),
m_asText( &m_informationWidgets ),
m_infoLayout( &m_informationWidgets ),
m_intervalEdit( &m_parameterWidgets )
{
// layout all the elements
m_layout.addWidget( &m_intervalEdit );
m_layout.setMargin( WGLOBAL_MARGIN );
m_layout.setSpacing( WGLOBAL_SPACING );
m_vLayout.setMargin( WGLOBAL_MARGIN );
m_vLayout.setSpacing( WGLOBAL_SPACING );
// add the m_layout to the vlayout
QWidget* layoutContainer = new QWidget();
layoutContainer->setLayout( &m_layout );
m_vLayout.addWidget( layoutContainer );
m_parameterWidgets.setLayout( &m_vLayout );
// Information Output ( Property Purpose = PV_PURPOSE_INFORMATION )
m_infoLayout.addWidget( &m_asText );
m_infoLayout.setMargin( WGLOBAL_MARGIN );
m_infoLayout.setSpacing( WGLOBAL_SPACING );
m_informationWidgets.setLayout( &m_infoLayout );
update();
// connect the modification signal of the edit and slider with our callback
connect( &m_intervalEdit, SIGNAL( minimumChanged() ), this, SLOT( minMaxUpdated() ) );
connect( &m_intervalEdit, SIGNAL( maximumChanged() ), this, SLOT( minMaxUpdated() ) );
}
WPropertyIntervalWidget::~WPropertyIntervalWidget()
{
// cleanup
}
void WPropertyIntervalWidget::update()
{
/* // // calculate maximum size of the text widget.
// // XXX: this is not the optimal way but works for now
// NO, it doesn't work on Mac OS X: You won't be able to any digits in it!, So I reset it to default which should work on other platforms too
QString valStr = QString::number( m_integralProperty->get() );
m_edit.setText( valStr );
// get the min constraint
WPVDouble::PropertyConstraintMin minC = m_integralProperty->getMin();
WPVDouble::PropertyConstraintMax maxC = m_integralProperty->getMax();
bool minMaxConstrained = minC && maxC;
if( minMaxConstrained )
{
// setup the slider
m_slider.setMinimum( 0 );
m_slider.setMaximum( SliderResolution );
// update the interval edit too
m_intervalEdit.setAllowedMin( minC->getMin() );
m_intervalEdit.setAllowedMax( maxC->getMax() );
m_min = m_intervalEdit.getMin();
m_max = m_intervalEdit.getMax();
// updating the interval edit causes the proper values to be set in m_min and m_max
m_slider.setHidden( false );
m_intervalEdit.setHidden( !WQt4Gui::getSettings().value( "qt4gui/sliderMinMaxEdit", false ).toBool() );
m_slider.setValue( toSliderValue( m_integralProperty->get() ) );
}
else
{
m_slider.setHidden( true );
m_intervalEdit.setHidden( true );
}
// do not forget to update the label
m_asText.setText( valStr );*/
}
void WPropertyIntervalWidget::minMaxUpdated()
{
/*m_min = m_intervalEdit.getMin();
m_max = m_intervalEdit.getMax();
if( m_min > m_integralProperty->get() )
{
m_integralProperty->set( m_min );
}
if( m_max < m_integralProperty->get() )
{
m_integralProperty->set( m_max );
}
m_slider.setValue( toSliderValue( m_integralProperty->get() ) );*/
}
//---------------------------------------------------------------------------
//
// 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 WPROPERTYINTERVALWIDGET_H
#define WPROPERTYINTERVALWIDGET_H
#include <string>
#include <QtGui/QLineEdit>
#include <QtGui/QSlider>
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include "../guiElements/WQtIntervalEdit.h"
#include "WPropertyWidget.h"
/**
* Implements a property widget for WPropInterval.
*/
class WPropertyIntervalWidget: 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
*/
WPropertyIntervalWidget( WPropInterval property, QGridLayout* propertyGrid, QWidget* parent = 0 );
/**
* Destructor.
*/
virtual ~WPropertyIntervalWidget();
protected:
/**
* Called whenever the widget should update.
*/
virtual void update();
/**
* The property represented by this widget.
*/
WPropInterval m_intervalProperty;
/**
* Layout used to position the label and the checkbox
*/
QHBoxLayout m_layout;
/**
* Layout used to combine the property widgets with the WQtIntervalEdit.
*/
QVBoxLayout m_vLayout;
/**
* Used to show the property as text.
*/
QLabel m_asText;
/**
* The layout used for the pure output (information properties)
*/
QHBoxLayout m_infoLayout;
/**
* The edit for the interval.
*/
WQtIntervalEdit< double, double > m_intervalEdit;
private:
public slots:
/**
* Called whenever the interval edit changes.
*/
void minMaxUpdated();
};
#endif // WPROPERTYINTERVALWIDGET_H
......@@ -41,6 +41,7 @@
#include "WPropertyStructWidget.h"
#include "WPropertyTransferFunctionWidget.h"
#include "WPropertyTriggerWidget.h"
#include "WPropertyIntervalWidget.h"
#include "WPropertyWidget.h"
#include "WPropertyWidget.moc"
#include "WQtPropertyGroupWidget.h"
......@@ -199,6 +200,9 @@ WPropertyWidget* WPropertyWidget::construct( WPropertyBase::SPtr property, QGrid
case PV_TRANSFERFUNCTION:
return new WPropertyTransferFunctionWidget( property->toPropTransferFunction(), propertyGrid, parent );
break;
case PV_INTERVAL:
return new WPropertyIntervalWidget( property->toPropInterval(), propertyGrid, parent );
break;
default: // NOTE:: WPropGroup will be handled in WQtConrolPanel::buildPropWidget
WLogger::getLogger()->addLogMessage( "This property type is not yet supported.", "WPropertyWidget", LL_WARNING );
break;
......
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