Ejemplo n.º 1
0
	float HScrollBar::getRelativeValue() const
	{
		float relVal = (float)(getValue() - getMinValue());
		float relMax =(float) (getMaxValue() - getMinValue());

		return relVal / relMax;
	}
Ejemplo n.º 2
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;	
}
Ejemplo n.º 3
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;
	}
Ejemplo n.º 4
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));
		}
	}
void IntegerStyleRange1Out::checkProperty(QStringList & errorMsg)
{
    IntegerStyle1Out::checkProperty(errorMsg);

    if (isMinMaxSwapAllowed())
    {
        if (((getMinValue().value() <= getResetValue().value()) && (getResetValue().value() <= getMaxValue().value()))
                || ((getMinValue().value() >= getResetValue().value()) && (getResetValue().value() >= getMaxValue().value())))
        {
            // Okay
        }
        else
        {
            errorMsg.append(i18n("The reset, minimum and maximum values do not match!\n"
                                 "The values have to match following conditions:\n"
                                 "\tMinimum Value <= Reset Value <= Maximum Value\n"
                                 "or\n"
                                 "\tMinimum Value >= Reset Value >= Maximum Value\n"));
        }
    }
    else
    {
        if ((getMinValue().value() <= getResetValue().value()) && (getResetValue().value() <= getMaxValue().value()))
        {
            // Okay
        }
        else
        {
            errorMsg.append(i18n("The reset, minimum and maximum values do not match!\n"
                                 "The values have to match following condition:\n"
                                 "\tMinimum Value <= Reset Value <= Maximum Value\n"));
        }
    }
}
Ejemplo n.º 6
0
void FloatVec3Property::setVariant(const Variant& val, bool normalized) {
    if (normalized) {
        float ratio = val.getFloat();
        set(getMinValue() + ratio * (getMaxValue() - getMinValue()));
    }
    else
        set(val.getVec3());
}
Ejemplo n.º 7
0
Variant FloatVec3Property::getVariant(bool normalized) const {
    if (normalized) {
        float ratio = ((get() - getMinValue()) / (getMaxValue() - getMinValue())).x;
        return Variant(ratio);
    }
    else
        return Variant(get());
}
Ejemplo n.º 8
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());
}
Ejemplo n.º 9
0
int DefaultGenerator::toGenerate() {

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

}
Ejemplo n.º 10
0
QRect WizScreenShotWidget::getMoveControlSelectedRect(void)
{
    int x, y, w, h;
    QRect rect = getRect(beginPoint,endPoint);
    QRect result;
    switch (controlValue)
    {
    case moveControl1:
        result = getRect(rect.bottomRight(), moveEndPoint);
        return result;
        break;
    case moveControl2:
        x = rect.x();
        y = getMinValue(moveEndPoint.y(), rect.bottomLeft().y());
        w = rect.width();
        h = qAbs(moveEndPoint.y() - rect.bottomRight().y());
        break;
    case moveControl3:
        result = getRect(rect.bottomLeft(), moveEndPoint);
        return result;
        break;
    case moveControl4:
        x = getMinValue(rect.x(), moveEndPoint.x());
        y = rect.y();
        w = qAbs(rect.bottomLeft().x() - moveEndPoint.x());
        h = rect.height();
        break;
    case moveControl5:
        result = getRect(rect.topLeft(), moveEndPoint);
        return result;
        break;
    case moveControl6:
        x = rect.x();
        y = getMinValue(rect.y(), moveEndPoint.y());
        w = rect.width();
        h = qAbs(moveEndPoint.y() - rect.topLeft().y());
        break;
    case moveControl7:
        result = getRect(moveEndPoint, rect.topRight());
        return result;
        break;
    case moveControl8:
        x = getMinValue(moveEndPoint.x(), rect.bottomRight().x());
        y = rect.y();
        w = qAbs(rect.bottomRight().x() - moveEndPoint.x());
        h = rect.height();
        break;
    default:
        result = getRect(beginPoint, endPoint);
        return result;
        break;
    }

    return QRect(x, y, w, h);
}
Ejemplo n.º 11
0
	void HScrollBar::setMaxValue( int val )
	{
		if(val >= getMinValue())
		{
			for(std::vector<HScrollBarListener*>::iterator it = 
				hScrollListeners.begin();
				it != hScrollListeners.end(); ++it)
			{
				if((*it))
					(*it)->maxValueChanged(this,val);
			}
			maxValue = val;

			if(getLargeAmount() >= maxValue)
			{
				setLargeAmount(maxValue);
			}


			if(getValue() >= maxValue - largeAmount)
			{
				setValue(maxValue - largeAmount);
			}

			positionThumb();
			resizeThumb();
		}
	}
Ejemplo n.º 12
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());
	}
Ejemplo n.º 13
0
void LoudnessBarRangeSlider::valueChanged()
{
    const int minimalIntervalBetweenMinAndMax = 1;
    
    if (getMinValue() == getMaxValue())
    {
        if (getMaxValue() + minimalIntervalBetweenMinAndMax <= getMaximum())
        {
            setMaxValue(getMaxValue() + minimalIntervalBetweenMinAndMax);
        }
        else
        {
            setMinValue(getMinValue() - minimalIntervalBetweenMinAndMax);
        }
    }
}
Ejemplo n.º 14
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();
}
Ejemplo n.º 15
0
Variant IntVec4Property::getVariant(bool normalized) const {
    if (normalized) {
        float ratio = (static_cast<float>((get() - getMinValue()).x) / static_cast<float>((getMaxValue() - getMinValue()).x));
        return Variant(ratio);
    }
    else
        return Variant(get());
}
Ejemplo n.º 16
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FindMaxima::readFilterParameters(AbstractFilterParametersReader* reader, int index)
{
  reader->openFilterGroup(this, index);
  setSelectedCellArrayPath( reader->readDataArrayPath( "SelectedCellArrayPath", getSelectedCellArrayPath() ) );
  setMinValue( reader->readValue( "MinValue", getMinValue() ) );
  setNewCellArrayName( reader->readString( "NewCellArrayName", getNewCellArrayName() ) );
  reader->closeFilterGroup();
}
Ejemplo n.º 17
0
int LinearGenerator::toGenerate() {

  setSeed(myRand());
  while((getSeed() > getMaxValue()) || (getSeed() < getMinValue()))
    setSeed(myRand());
  print(std::cout);
  return getSeed();
}
Ejemplo n.º 18
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());
}
Ejemplo n.º 19
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;
}
Ejemplo n.º 20
0
//----------------------------------------------------------------
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)
	}
}
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
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;
}
Ejemplo n.º 24
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;
}
Ejemplo n.º 25
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;
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
0
float MGuiSlide::getValueFromPoint(const MVector2 & point)
{
	float pos;
	float val;

	if(getDirection().x > getDirection().y)
	{
		pos = getPosition().x + m_offset.x;
		val = (point.x - pos) / getDirection().x;
	}
	else
	{
		pos = getPosition().y + m_offset.y;
		val = (point.y - pos) / getDirection().y;
	}

	if(val < 0)
		val = 0;

	if(val > 1)
		val = 1;

	return getMinValue() + (val * (getMaxValue() - getMinValue()));
}
Ejemplo n.º 28
0
void AttributeAxis::mapMinMaxPoints()
{
	if (_dataPoints.empty()) {
		return;
	}
	PointOnAxis* minPoint = _dataPoints[getMinValue()];
	minPoint->setIsMappingPoint(true);
	minPoint->setFlag(QGraphicsItem::ItemIsMovable, false);
	minPoint->setPos(line().p1());

	PointOnAxis* maxPoint = _dataPoints[getMaxValue()];
	maxPoint->setIsMappingPoint(true);
	maxPoint->setFlag(QGraphicsItem::ItemIsMovable, false);
	maxPoint->setPos(line().p2());

}
short ElemDDLSGOptions::genSGA(SequenceGeneratorAttributes &sga)
{
  sga.setSGStartValue(getStartValue());
  sga.setSGIncrement(getIncrement());
  sga.setSGMinValue(getMinValue());
  sga.setSGMaxValue(getMaxValue());

  sga.setSGCache(getCache());
  sga.setSGCycleOption(isCycle());

  sga.setSGFSDataType(getFSDataType());

  sga.setSGResetOption(isReset());

  return 0;
}
Ejemplo n.º 30
0
int ZIntHistogram::getMode(int minV, int maxV) const
{
    minV = std::max(minV, getMinValue());
    maxV = std::min(maxV, getMaxValue());

    int m = minV;

    int maxCount = getCount(m);
    for (int i = minV; i <= maxV; ++i) {
        int c = getCount(i);
        if (c > maxCount) {
            maxCount = c;
            m = i;
        }
    }

    return m;
}