예제 #1
0
	int HScrollBar::getValueFromPosition( int position ) const
	{
		//subtract the left arrow's width
		position -= pChildLeftArrow->getSize().getWidth();

		//what percent of the thumb size we have traveled
		float retVal =  ((float)position / (float)getAdjustedMaxThumbSize());

		//total possible number of values
		int numValues = getMaxValue() - getMinValue();

		//how many values we have passed
		retVal = retVal * numValues;

		//add the minimum to get the value
		retVal += (float)getMinValue();

		//bounds checking
		if (retVal > getMaxValue() - getLargeAmount())
		{
			retVal = (float)(getMaxValue() - getLargeAmount());
		}
		if(retVal < getMinValue())
		{
			retVal = (float)getMinValue();
		}

		return (int)retVal;
	}
예제 #2
0
	void HScrollBar::setRangeFromPage( int pageWidth, int contentWidth )
	{
		float percentage = (float)(pageWidth) / (float)(contentWidth);

		int y = (int)((contentWidth - pageWidth)
			/ (1.0f - percentage));
		int x = (int)((float)y * percentage);

		//should the thumb be brought to the bottom?
		bool isAtMax = getValue() > y - x;

		setMaxValue(y);
		setLargeAmount(x);

		y = getMaxValue();
		x = getLargeAmount();

		if(isAtMax)
		{
			setValue(getMaxValue() - getLargeAmount());
		}

		if(x <= 0 || y <= 0 || x >= y)
		{
			setMaxValue(1);
			setLargeAmount(1);

		}
	}
예제 #3
0
bool Slider::setPosition(float val) {
	float oldposition = position;

	position = min(val,getMaxValue());
	position = max(position,getMinValue());

	if (getShowValueHint()) {
		std::wstringstream s;
		s << L" " << position << L" ";
		button->setHintText(s.str().c_str());
		button->instantHintUpdate();
	}

		if (horizontal) {
				button->setPosX(getPosX()+
					getWidth()/(getMaxValue()-getMinValue())*(getPosition()-getMinValue())
					-button->getWidth()/2);
		       button->setPosY(getPosY()+getHeight()/2-button->getHeight()/2);
		} else {

			button->setPosY(getPosY()+getHeight()-
					getHeight()/(getMaxValue()-getMinValue())*(getPosition()-getMinValue())
					-button->getHeight()/2);

		       button->setPosX(getPosX()+getWidth()/2-button->getWidth()/2);

		}

		if (position != oldposition) return true;
		else return false;	
}
예제 #4
0
float Vibrator::getNormalizedValue() const
{
	float v = 0.f;
	if ( getMaxValue()!=0.f )
		v = static_cast<float>( getValue() ) /  static_cast<float>( getMaxValue() );
	return v;
}
예제 #5
0
	void HScrollBar::setValue( int val )
	{
		//store current value to compare later
		int targetVal = val;

		//perform bounds checking
		if (val <= getMinValue())
		{
			targetVal = getMinValue();
		}
		else if(val >= getMaxValue() - getLargeAmount())
		{

			targetVal = getMaxValue() - getLargeAmount();
		}


		//only reposition if there is a change
		if(targetVal != currentValue)
		{
			currentValue = targetVal;
			positionThumb();

			for(std::vector<HScrollBarListener*>::iterator it = 
				hScrollListeners.begin();
				it != hScrollListeners.end(); ++it)
			{
				if((*it))
					(*it)->valueChanged(this,currentValue);
			}

			dispatchActionEvent(ActionEvent(this));
		}
	}
예제 #6
0
int DefaultGenerator::toGenerate() {

  srand(getSeed());
  setSeed(getMinValue() + rand() % getMaxValue());
  while((getSeed() > getMaxValue()) || (getSeed() < getMinValue()))
    setSeed(getMinValue() + rand() % getMaxValue());
  print(cout);
  return getSeed();

}
예제 #7
0
void IntVec2Property::setVariant(const Variant& val, bool normalized) {
    if (normalized) {
        float ratio = val.getFloat();
        int x = static_cast<int>(ratio * (getMaxValue().x + getMinValue().x));
        int y = static_cast<int>(ratio * (getMaxValue().y + getMinValue().y));
        set(getMinValue() + tgt::ivec2(x,y));
    }
    else
        set(val.getIVec2());
}
예제 #8
0
	UInt16 ImageData::getMaxValue(int layer){
		int max0 = getMaxValue(layer,0);
		int max = max0;
		if (dbl==2){
			int max1 = getMaxValue(layer,1);
			if (max1>max0)
				max = max1;
		}
		return max;
	}
예제 #9
0
	void HScrollBar::resizeThumb()
	{
		//the width if 1 pixel = 1 value
		int width = getLargeAmount();

		int maxValSupport = getMaxValue() - getMinValue();
		//get the ratio
		float change = (float)getMaxThumbSize() / (float)maxValSupport;

		//make height proportional to ratio
		width = (int)((float)width * change);

		//make sure the thumb never gets too small
		if(width < getMinThumbWidth())
		{
			width = getMinThumbWidth();
		}

		if(width > getMaxThumbSize())
		{

			pChildThumb->setVisibility(false);
		}
		else if(pChildThumb->isVisible() == false)
		{
			pChildThumb->setVisibility(true);
		}

		pChildThumb->setSize(width,getInnerSize().getHeight());
	}
예제 #10
0
 int getMaxValue(TreeNode * root)
 {
     if (root == NULL) return 0;
     int l = getMaxValue(root -> left);
     int r = getMaxValue(root -> right);
     int maxValue = root -> val;
     if (l > 0) maxValue += l;
     if (r > 0) maxValue += r;
     if (maxValue > globalMaxPathSum)
     {
         globalMaxPathSum = maxValue;
     }
     if (l > 0 && l >= r) return l + root -> val;
     if (r > 0 && r > l) return r + root -> val;
     return root -> val;
 }
예제 #11
0
void LoudnessBarRangeSlider::valueChanged()
{
    const int minimalIntervalBetweenMinAndMax = 1;
    
    if (getMinValue() == getMaxValue())
    {
        if (getMaxValue() + minimalIntervalBetweenMinAndMax <= getMaximum())
        {
            setMaxValue(getMaxValue() + minimalIntervalBetweenMinAndMax);
        }
        else
        {
            setMinValue(getMinValue() - minimalIntervalBetweenMinAndMax);
        }
    }
}
예제 #12
0
/*----------------------------------------------------------------------------*/
static void tmrSetOverflow(void *object, uint32_t overflow)
{
  struct GpTimer * const timer = object;
  LPC_TIMER_Type * const reg = timer->base.reg;
  const uint32_t resolution = getMaxValue(timer);
  const uint32_t state = reg->TCR & TCR_CEN;

  /* Stop the timer before reconfiguration */
  reg->TCR = 0;

  assert((overflow - 1) <= resolution);
  overflow = (overflow - 1) & resolution;

  /* Setup the match register */
  reg->MR[timer->event] = overflow;

  if (overflow != resolution)
  {
    /* Reset the timer after reaching match register value */
    reg->MCR |= MCR_RESET(timer->event);
  }
  else
    reg->MCR &= ~MCR_RESET(timer->event);

  reg->TCR = state;
}
예제 #13
0
	float HScrollBar::getRelativeValue() const
	{
		float relVal = (float)(getValue() - getMinValue());
		float relMax =(float) (getMaxValue() - getMinValue());

		return relVal / relMax;
	}
예제 #14
0
Variant FloatVec3Property::getVariant(bool normalized) const {
    if (normalized) {
        float ratio = ((get() - getMinValue()) / (getMaxValue() - getMinValue())).x;
        return Variant(ratio);
    }
    else
        return Variant(get());
}
vector<float> HOGDetectorGPU::normalize(vector<float> array){
    double max = getMaxValue(array);
    vector<float> normalized(array.size());
    for(int i = 0; i < array.size(); ++i){
        normalized[i] = array[i] / max;
    }
    return normalized;
}
예제 #16
0
void FloatVec3Property::setVariant(const Variant& val, bool normalized) {
    if (normalized) {
        float ratio = val.getFloat();
        set(getMinValue() + ratio * (getMaxValue() - getMinValue()));
    }
    else
        set(val.getVec3());
}
예제 #17
0
int LinearGenerator::toGenerate() {

  setSeed(myRand());
  while((getSeed() > getMaxValue()) || (getSeed() < getMinValue()))
    setSeed(myRand());
  print(std::cout);
  return getSeed();
}
예제 #18
0
/**
 * Save the state of the color map widget to a project file.
 * @return string representing the current state of the color map widget.
 */
std::string ColorMapWidget::saveToProject() const {
  API::TSVSerialiser tsv;
  tsv.writeLine("ScaleType") << getScaleType();
  tsv.writeLine("Power") << getNth_power();
  tsv.writeLine("MinValue") << getMinValue();
  tsv.writeLine("MaxValue") << getMaxValue();
  return tsv.outputLines();
}
예제 #19
0
void Vibrator::setNormalizedValue( float value )
{
	if ( value>1.f )
		value = 1.f;
	else if ( value<0.f )
		value = 0.f;
	float v = floor( value*getMaxValue() );
	setValue( static_cast<unsigned int>(v) );
}
예제 #20
0
float MGuiSlide::getNormalizedValue(void)
{
	if(getVariableType())
	{
		if(getVariableType() == M_VAR_INT)
		{
			int iValue;
			if(m_value >= 0)
				iValue = (int)(m_value + 0.5f);
			else
				iValue = (int)(m_value - 0.5f);

			return (iValue - getMinValue()) / (getMaxValue() - getMinValue());
		}
	}

	return (getValue() - getMinValue()) / (getMaxValue() - getMinValue());
}
예제 #21
0
double FloatFormat::roundOut (double d, bool upward, bool roundUnderOverflow) const
{
	int	exp	= 0;
	deFractExp(d, &exp);

	if (roundUnderOverflow && exp > m_maxExp && (upward == (d < 0.0)))
		return deSign(d) * getMaxValue();
	else
		return round(d, upward);
}
예제 #22
0
MVector2 MGuiSlide::getPointfromValue(float value)
{
	float nValue;
	MVector2 point;

	// variable pointer
	if(getVariablePointer())
	{
		if(getVariableType() == M_VAR_INT)
		{
			int iValue;

			if(value >= 0)
				iValue = (int)(value+0.5f);
			else
				iValue = (int)(value-0.5f);

			nValue = (iValue - getMinValue()) / (getMaxValue() - getMinValue());

			if(nValue < 0)
				nValue = 0;

			if(nValue > 1)
				nValue = 1;

			point = getPosition() + (getDirection() * nValue);
			return point;
		}
	}

	// normal
	nValue = (value - getMinValue()) / (getMaxValue() - getMinValue());

	if(nValue < 0)
		nValue = 0;

	if(nValue > 1)
		nValue = 1;

	point = getPosition() + (getDirection() * nValue);
	return point;
}
예제 #23
0
파일: Image.cpp 프로젝트: reolac/3038
//----------------------------------------------------------------
void Image::normaliseImage() const // evenly spread the data between 0 and 255 maximizing all data points
//----------------------------------------------------------------
{
	unsigned int maxValue = getMaxValue(); // gets and stores the highest pixel in the image
	unsigned int minValue = getMinValue(); // gets and stores the lowest pixel in the image

	for (unsigned int i(0); i < m_width * m_height; i++)
	{ // makes the min value zero (minus all elements by the min value); divide it by the difference between the maximum and minimum value 
		m_p_image[i] = 255 * ((m_p_image[i] - minValue) / (maxValue - minValue)); // multiply that by the highest possible number for the data (255)
	}
}
예제 #24
0
int caTable::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTableWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 1)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 1;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getPVS(); break;
        case 1: *reinterpret_cast< QString*>(_v) = getColumnSizes(); break;
        case 2: *reinterpret_cast< colMode*>(_v) = getColorMode(); break;
        case 3: *reinterpret_cast< int*>(_v) = getPrecision(); break;
        case 4: *reinterpret_cast< SourceMode*>(_v) = getPrecisionMode(); break;
        case 5: *reinterpret_cast< SourceMode*>(_v) = getLimitsMode(); break;
        case 6: *reinterpret_cast< double*>(_v) = getMaxValue(); break;
        case 7: *reinterpret_cast< double*>(_v) = getMinValue(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPVS(*reinterpret_cast< QString*>(_v)); break;
        case 1: setColumnSizes(*reinterpret_cast< QString*>(_v)); break;
        case 2: setColorMode(*reinterpret_cast< colMode*>(_v)); break;
        case 3: setPrecision(*reinterpret_cast< int*>(_v)); break;
        case 4: setPrecisionMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 5: setLimitsMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 6: setMaxValue(*reinterpret_cast< double*>(_v)); break;
        case 7: setMinValue(*reinterpret_cast< double*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
예제 #25
0
int ZIntHistogram::getCount(int v) const
{
    int count = 0;

    if (!isEmpty()) {
        if (v >= getMinValue() && v <= getMaxValue()) {
            count = m_hist[v + 2 - m_hist[1]];
        }
    }

    return count;
}
예제 #26
0
// virtual
LLXMLNodePtr LLSlider::getXML(bool save_children) const
{
	LLXMLNodePtr node = LLUICtrl::getXML();

	node->createChild("initial_val", TRUE)->setFloatValue(getInitialValue());
	node->createChild("min_val", TRUE)->setFloatValue(getMinValue());
	node->createChild("max_val", TRUE)->setFloatValue(getMaxValue());
	node->createChild("increment", TRUE)->setFloatValue(getIncrement());
	node->createChild("volume", TRUE)->setBoolValue(mVolumeSlider);

	return node;
}
예제 #27
0
// virtual
LLXMLNodePtr LLMultiSlider::getXML(bool save_children) const
{
    LLXMLNodePtr node = LLUICtrl::getXML();

    node->setName(LL_MULTI_SLIDER_TAG);

    node->createChild("initial_val", TRUE)->setFloatValue(getInitialValue());
    node->createChild("min_val", TRUE)->setFloatValue(getMinValue());
    node->createChild("max_val", TRUE)->setFloatValue(getMaxValue());
    node->createChild("increment", TRUE)->setFloatValue(getIncrement());

    return node;
}
예제 #28
0
int ZIntHistogram::getUpperCount(int v) const
{
    int count = 0;
    if (!isEmpty()) {
        int minV = std::max(v, getMinValue());
        int maxV = getMaxValue();
        for (int i = minV; i <= maxV; ++i) {
            count += getCount(i);
        }
    }

    return count;
}
예제 #29
0
int caNumeric::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = ENumeric::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getPV(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = getForeground(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = getBackground(); break;
        case 3: *reinterpret_cast< SourceMode*>(_v) = getPrecisionMode(); break;
        case 4: *reinterpret_cast< bool*>(_v) = getFixedFormat(); break;
        case 5: *reinterpret_cast< SourceMode*>(_v) = getLimitsMode(); break;
        case 6: *reinterpret_cast< double*>(_v) = getMaxValue(); break;
        case 7: *reinterpret_cast< double*>(_v) = getMinValue(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPV(*reinterpret_cast< QString*>(_v)); break;
        case 1: setForeground(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setBackground(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setPrecisionMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 4: setFixedFormat(*reinterpret_cast< bool*>(_v)); break;
        case 5: setLimitsMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 6: setMaxValue(*reinterpret_cast< double*>(_v)); break;
        case 7: setMinValue(*reinterpret_cast< double*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
예제 #30
0
//! Return the range of numbers that `d` might be converted to in the
//! floatformat, given its limitations with infinities, subnormals and maximum
//! exponent.
Interval FloatFormat::clampValue (double d) const
{
	const double	rSign		= deSign(d);
	int				rExp		= 0;

	DE_ASSERT(!deIsNaN(d));

	deFractExp(d, &rExp);
	if (rExp < m_minExp)
		return chooseInterval(m_hasSubnormal, rSign * 0.0, d);
	else if (deIsInf(d) || rExp > m_maxExp)
		return chooseInterval(m_hasInf, rSign * getMaxValue(), rSign * TCU_INFINITY);

	return Interval(d);
}