<max> an optional upper limit for the input value to be clamped to. If
<min> equals <max> no limit is applied. (default: 0)
<wrap> instead of clamping to minimum and maximum limits, wrap values
- around. (default: false)
+ around. Values will be in [min, max[ (default: false)
(Usefull for eg. heading selector to start again with 1 for
values higher than 360)
if( prot.max > prot.min )
{
if( prot.wrap )
- {
- T range = prot.max - prot.min + 1;
- if( range > 0 )
- {
- while( new_val < prot.min )
- new_val += range;
- while( new_val > prot.max )
- new_val -= range;
- }
- }
+ new_val = SGMisc<double>::normalizePeriodic(prot.min, prot.max, new_val);
else
- new_val = std::min<T>(prot.max, std::max<T>(prot.min, new_val));
+ new_val = SGMisc<T>::clip(new_val, prot.min, prot.max);
}
setValue(prot.prop, new_val);