Commit 9db1ef0a authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD #172] interval property widgets working so far.

parent cc71e027
......@@ -66,4 +66,6 @@
#include "popup_more.xpm"
#include "popup_close.xpm"
#include "undo.xpm"
#endif // WICONS_H
/* XPM */
const char * undo_xpm[] = {
"16 16 57 1",
" c None",
". c #C3A000",
"+ c #C4A000",
"@ c #DDC76A",
"# c #FDFBF4",
"$ c #C29E00",
"% c #DBC666",
"& c #FEFEFB",
"* c #C09E00",
"= c #BC9900",
"- c #D5BF58",
"; c #FDFBED",
"> c #BB9900",
", c #BA9B0E",
"' c #FAF6D4",
") c #FAF2AF",
"! c #F7EB89",
"~ c #F5E985",
"{ c #DFCB57",
"] c #C3A71E",
"^ c #B59400",
"/ c #AE9000",
"( c #C8AF36",
"_ c #F6EFB0",
": c #AF8F00",
"< c #B49607",
"[ c #CEB528",
"} c #EDDB50",
"| c #BEA213",
"1 c #A98B00",
"2 c #C1A924",
"3 c #F2E682",
"4 c #A98900",
"5 c #A98A00",
"6 c #C8AE12",
"7 c #D6BD19",
"8 c #A58400",
"9 c #BBA015",
"0 c #CEB629",
"a c #A48500",
"b c #AE8F01",
"c c #E9D004",
"d c #9E8000",
"e c #C3A80C",
"f c #D4BA11",
"g c #9D7F00",
"h c #9C7F00",
"i c #A38704",
"j c #C5AB16",
"k c #EED92C",
"l c #B0940B",
"m c #F9E648",
"n c #FAE747",
"o c #F7E445",
"p c #D8C12D",
"q c #B19610",
"r c #9B8000",
" ",
" ",
" .+ ",
" .@#+ ",
" $%&%* ",
"=-;->>>>>>>>> ",
",')!!!!!!!!~{]^ ",
"/(_(:::::::<[}| ",
" 12324 5675",
" 890a bca",
" dd defd",
" ghijkl ",
" mnopqr ",
" ghhh ",
" ",
" "};
......@@ -198,6 +198,7 @@ void WMainWindow::setupGUI()
m_iconManager.addIcon( std::string( "sagittal icon" ), sag_xpm );
m_iconManager.addIcon( std::string( "popup_more" ), popup_more_xpm );
m_iconManager.addIcon( std::string( "popup_close" ), popup_close_xpm );
m_iconManager.addIcon( std::string( "undo" ), undo_xpm );
try
{
......
......@@ -30,6 +30,7 @@
#include <string>
#include <QtGui/QInputDialog>
#include <QtGui/QAction>
#include "../WGuiConsts.h"
#include "../WQt4Gui.h"
......@@ -47,10 +48,24 @@ WPropertyIntervalWidget::WPropertyIntervalWidget( WPropInterval property, QGridL
m_vLayout( &m_parameterWidgets ),
m_asText( &m_informationWidgets ),
m_infoLayout( &m_informationWidgets ),
m_intervalEdit( &m_parameterWidgets )
m_minEdit( &m_parameterWidgets ),
m_maxEdit( &m_parameterWidgets ),
m_resetBtn( &m_parameterWidgets )
{
// layout all the elements
m_layout.addWidget( &m_intervalEdit );
m_layout.addWidget( new QLabel( "[") );
m_layout.addWidget( &m_minEdit );
m_layout.addWidget( new QLabel( ",") );
m_layout.addWidget( &m_maxEdit );
m_layout.addWidget( new QLabel( "]") );
m_layout.addWidget( &m_resetBtn );
// WPropertyVartiable does not yet provide a default value mechanism.
m_resetBtn.setHidden( true );
// create resetButton action
QAction* reset = new QAction( WQt4Gui::getIconManager()->getIcon( "undo" ), "Reset to defaults", &m_resetBtn );
m_resetBtn.setDefaultAction( reset );
m_layout.setMargin( WGLOBAL_MARGIN );
m_layout.setSpacing( WGLOBAL_SPACING );
......@@ -74,8 +89,9 @@ WPropertyIntervalWidget::WPropertyIntervalWidget( WPropInterval property, QGridL
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() ) );
connect( &m_minEdit, SIGNAL( textEdited( const QString& ) ), this, SLOT( minMaxUpdated() ) );
connect( &m_maxEdit, SIGNAL( textEdited( const QString& ) ), this, SLOT( minMaxUpdated() ) );
connect( reset, SIGNAL( triggered( bool ) ), this, SLOT( reset() ) );
}
WPropertyIntervalWidget::~WPropertyIntervalWidget()
......@@ -85,57 +101,34 @@ WPropertyIntervalWidget::~WPropertyIntervalWidget()
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 );
}
QString lowValStr = QString::number( m_intervalProperty->get().getLower() );
QString upValStr = QString::number( m_intervalProperty->get().getUpper() );
m_minEdit.setText( lowValStr );
m_maxEdit.setText( upValStr );
// do not forget to update the label
m_asText.setText( valStr );*/
m_asText.setText( "[" + lowValStr + ", " + upValStr + "]" );
}
void WPropertyIntervalWidget::minMaxUpdated()
{
/*m_min = m_intervalEdit.getMin();
m_max = m_intervalEdit.getMax();
bool validMin;
double minValue = m_minEdit.text().toDouble( &validMin );
bool validMax;
double maxValue = m_maxEdit.text().toDouble( &validMax );
if( m_min > m_integralProperty->get() )
if( !( validMin && validMax ) )
{
m_integralProperty->set( m_min );
}
if( m_max < m_integralProperty->get() )
{
m_integralProperty->set( m_max );
invalidate();
return;
}
m_slider.setValue( toSliderValue( m_integralProperty->get() ) );*/
// set to the property
invalidate( !m_intervalProperty->set( WIntervalDouble( minValue, maxValue ) ) ); // NOTE: set automatically checks the validity of the value
}
void WPropertyIntervalWidget::reset()
{
// WProperties does not really provide a default value mechanism.
}
......@@ -88,10 +88,19 @@ protected:
QHBoxLayout m_infoLayout;
/**
* The edit for the interval.
* Minimum Value.
*/
WQtIntervalEdit< double, double > m_intervalEdit;
QLineEdit m_minEdit;
/**
* Maximum Value.
*/
QLineEdit m_maxEdit;
/**
* Reset button
*/
QToolButton m_resetBtn;
private:
public slots:
......@@ -99,6 +108,11 @@ public slots:
* Called whenever the interval edit changes.
*/
void minMaxUpdated();
/**
* Reset to default
*/
void reset();
};
#endif // WPROPERTYINTERVALWIDGET_H
......
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