25 #ifndef WQTINTERVALEDIT_H 
   26 #define WQTINTERVALEDIT_H 
   35 #include <QGridLayout> 
   37 template< 
typename DataType, 
typename DisplayType >
 
   38 DisplayType toDisplayType( 
const DataType& value )
 
   40     return static_cast< DisplayType 
>( round( value ) );
 
  149 template< 
typename DataType, 
typename DisplayType >
 
  269 template< 
typename DataType, 
typename DisplayType >
 
  281 template< 
typename DataType, 
typename DisplayType >
 
  287 template< 
typename DataType, 
typename DisplayType >
 
  290     if( ( min > m_allowedMax ) || ( m_allowedMin == min ) )
 
  298     if( ( min > m_min ) || ( ( min < m_min ) && ( m_minSlider.value() == 0 ) ) )
 
  301         emit minimumChanged();
 
  307 template< 
typename DataType, 
typename DisplayType >
 
  310     if( ( max < m_allowedMin ) || ( m_allowedMax == max ) )
 
  318     if( ( max < m_max ) || ( ( max > m_max ) && ( m_maxSlider.value() == SliderResolution ) ) )
 
  321         emit maximumChanged();
 
  327 template< 
typename DataType, 
typename DisplayType >
 
  333 template< 
typename DataType, 
typename DisplayType >
 
  339 template< 
typename DataType, 
typename DisplayType >
 
  342     DataType newVal = ( min < m_allowedMin ) ? m_allowedMin : min;
 
  343     if( m_min == newVal )
 
  353         emit maximumChanged();
 
  355     emit minimumChanged();
 
  359 template< 
typename DataType, 
typename DisplayType >
 
  362     DataType newVal = ( max > m_allowedMax ) ? m_allowedMax : max;
 
  363     if( m_max == newVal )
 
  372         emit minimumChanged();
 
  374     emit maximumChanged();
 
  378 template< 
typename DataType, 
typename DisplayType >
 
  384 template< 
typename DataType, 
typename DisplayType >
 
  390 template< 
typename DataType, 
typename DisplayType >
 
  394     double percMin = 
static_cast< double >( SliderResolution ) *
 
  395                      ( 
static_cast< double >( m_min ) - 
static_cast< double >( m_allowedMin ) ) /
 
  396                      ( 
static_cast< double >( m_allowedMax ) - 
static_cast< double >( m_allowedMin ) );
 
  397     double percMax = 
static_cast< double >( SliderResolution ) *
 
  398                      ( 
static_cast< double >( m_max ) - 
static_cast< double >( m_allowedMin ) ) /
 
  399                      ( 
static_cast< double >( m_allowedMax ) - 
static_cast< double >( m_allowedMin ) );
 
  401     if( m_allowedMin == m_allowedMax )
 
  403         m_minSlider.setValue( 0 );
 
  404         m_maxSlider.setValue( SliderResolution );
 
  408         m_minSlider.setValue( percMin );
 
  409         m_maxSlider.setValue( percMax );
 
  413     m_minEdit.setText( QString::number( m_min ) );
 
  414     m_maxEdit.setText( QString::number( m_max ) );
 
  417 template< 
typename DataType, 
typename DisplayType >
 
  420     double perc = 
static_cast< double >( m_minSlider.value() ) / 
static_cast< double >( SliderResolution );
 
  422                             static_cast< double >( m_allowedMin ) + perc * ( 
static_cast< double >( m_allowedMax ) -
 
  423                                                                              static_cast< double >( m_allowedMin ) ) );
 
  427 template< 
typename DataType, 
typename DisplayType >
 
  430     float perc = 
static_cast< float >( m_maxSlider.value() ) / 
static_cast< float >( SliderResolution );
 
  432                             static_cast< double >( m_allowedMin ) + perc * ( 
static_cast< double >( m_allowedMax ) -
 
  433                                                                              static_cast< double >( m_allowedMin ) ) );
 
  438 template< 
typename DataType, 
typename DisplayType >
 
  443     double value = m_minEdit.text().toDouble( &valid );
 
  446         m_minEdit.setText( QString::number( 
static_cast< DataType >( m_min ) ) );
 
  453 template< 
typename DataType, 
typename DisplayType >
 
  458     double value = m_maxEdit.text().toDouble( &valid );
 
  461         m_maxEdit.setText( QString::number( 
static_cast< DataType >( m_max ) ) );
 
Base class for interval editing.
 
QLineEdit m_maxEdit
The maximum edit.
 
void minimumChanged()
Called whenever the user changes the current minimum OR setMin was called.
 
void maximumChanged()
Called whenever the user changes the current ,aximum OR setMax was called.
 
virtual void maxEditChanged()
Slot called when the maximum edit changes.
 
QGridLayout m_layout
The layout containing min and max layout.
 
virtual void update()=0
Update the current state.
 
QLabel m_maxLabel
A label for the maximum.
 
static int SliderResolution
Resolution of the sliders.
 
virtual ~WQtIntervalEditBase()
Destructor.
 
virtual void minSliderChanged()
Slot called when the minimum slider changes.
 
WQtIntervalEditBase(QWidget *parent)
Default constructor.
 
virtual void maxSliderChanged()
Slot called when the maximum slider changes.
 
QSlider m_maxSlider
The slider for the maximumum.
 
QSlider m_minSlider
The slider for the minimum.
 
virtual void minEditChanged()
Slot called when the minimum edit changes.
 
QLineEdit m_minEdit
The minimum edit.
 
QLabel m_minLabel
A label for the minimum.
 
Simple widget allowing to define a certain interval.
 
void setAllowedMin(DataType min=std::numeric_limits< DataType >::min())
Set the allowed minimum.
 
virtual void minEditChanged()
Slot called when the minimum edit changes.
 
DataType m_allowedMax
The allowed maximum.
 
virtual void maxEditChanged()
Slot called when the maximum edit changes.
 
void setMax(DataType max=std::numeric_limits< DataType >::max())
Set the currently selected max.
 
const DataType & getAllowedMin() const
Get the currently allowed min.
 
DataType m_max
The current maximum.
 
virtual void minSliderChanged()
Slot called when the minimum slider changes.
 
virtual void maxSliderChanged()
Slot called when the maximum slider changes.
 
const DataType & getMax() const
Get the currently selected maximum.
 
const DataType & getAllowedMax() const
Get the currently allowed max.
 
DataType m_allowedMin
The allowed minimum.
 
void setAllowedMax(DataType max=std::numeric_limits< DataType >::max())
Set the allowed maximum.
 
DataType m_min
The current minumum.
 
const DataType & getMin() const
Get the currently selected minimum.
 
WQtIntervalEdit(QWidget *parent)
Default constructor.
 
void setMin(DataType min=std::numeric_limits< DataType >::min())
Set the currently selected min.
 
virtual void update()
Update the current state.
 
virtual ~WQtIntervalEdit()
Destructor.
 
An object that knows an appropriate dataType flag for the typename T.