Example #1
0
static QVariant fcnLog( const QVariantList& values, QgsFeature* , QgsExpression* parent )
{
  double b = getDoubleValue( values.at( 0 ), parent );
  double x = getDoubleValue( values.at( 1 ), parent );
  if ( x <= 0 || b <= 0 )
    return QVariant();
  return QVariant( log( x ) / log( b ) );
}
double CSSPrimitiveValue::computeSeconds()
{
    ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime));
    UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->typeWithCalcResolved() : type();
    if (currentType == UnitType::Seconds)
        return getDoubleValue();
    if (currentType == UnitType::Milliseconds)
        return getDoubleValue() / 1000;
    ASSERT_NOT_REACHED();
    return 0;
}
Example #3
0
bool CSSPrimitiveValue::getDoubleValueInternal(UnitTypes requestedUnitType, double* result) const
{
    if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitTypes>(m_primitiveUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType))
        return false;

    UnitTypes sourceUnitType = static_cast<UnitTypes>(primitiveType());
    if (requestedUnitType == sourceUnitType || requestedUnitType == CSS_DIMENSION) {
        *result = getDoubleValue();
        return true;
    }

    UnitCategory sourceCategory = unitCategory(sourceUnitType);
    ASSERT(sourceCategory != UOther);

    UnitTypes targetUnitType = requestedUnitType;
    UnitCategory targetCategory = unitCategory(targetUnitType);
    ASSERT(targetCategory != UOther);

    // Cannot convert between unrelated unit categories if one of them is not UNumber.
    if (sourceCategory != targetCategory && sourceCategory != UNumber && targetCategory != UNumber)
        return false;

    if (targetCategory == UNumber) {
        // We interpret conversion to CSS_NUMBER as conversion to a canonical unit in this value's category.
        targetUnitType = canonicalUnitTypeForCategory(sourceCategory);
        if (targetUnitType == CSS_UNKNOWN)
            return false;
    }

    if (sourceUnitType == CSS_NUMBER) {
        // We interpret conversion from CSS_NUMBER in the same way as CSSParser::validUnit() while using non-strict mode.
        sourceUnitType = canonicalUnitTypeForCategory(targetCategory);
        if (sourceUnitType == CSS_UNKNOWN)
            return false;
    }

    double convertedValue = getDoubleValue();

    // First convert the value from m_primitiveUnitType to canonical type.
    double factor = conversionToCanonicalUnitsScaleFactor(sourceUnitType);
    convertedValue *= factor;

    // Now convert from canonical type to the target unitType.
    factor = conversionToCanonicalUnitsScaleFactor(targetUnitType);
    convertedValue /= factor;

    *result = convertedValue;
    return true;
}
//!
//! Processes the node's input data to generate the node's output table.
//!
void VTKGraphLayoutNode::refreshOutput()
{
	if (!m_inGraph)
	{
	    Log::info(QString("No graph defined."), "VTKGraphLayoutNode::~refreshOutput");
		return;
	}

	vtkGraphLayout *layout = vtkGraphLayout::New();
	int zRange = getDoubleValue(m_zRangeParameterName);
	layout->SetZRange(zRange);
	layout->SetInput( m_inGraph );

	if (!m_layoutInstance)
	{
	    Log::info(QString("No layout strategy defined."), "VTKGraphLayoutNode::~refreshOutput");
		return;
	}

	layout->SetLayoutStrategy(m_layoutInstance);
	layout->Update();

	m_outputTable = createTableFromGraph(layout->GetOutput(0));

	// process the output vtk table
	VTKTableParameter * outputParameter = dynamic_cast<VTKTableParameter*>(getParameter(m_ouputVTKTableParameterName));

	if (outputParameter && outputParameter->getVTKTable() != m_outputTable) 
	{
		outputParameter->setVTKTable(m_outputTable);
		outputParameter->propagateDirty(0);
	}
}
Example #5
0
double CSSPrimitiveValue::computeDegrees()
{
    switch (m_primitiveUnitType) {
    case CSS_DEG:
        return getDoubleValue();
    case CSS_RAD:
        return rad2deg(getDoubleValue());
    case CSS_GRAD:
        return grad2deg(getDoubleValue());
    case CSS_TURN:
        return turn2deg(getDoubleValue());
    default:
        ASSERT_NOT_REACHED();
        return 0;
    }
}
        void binary_operation(VarType type, R (*binaryFunction)(T const &, T const &)) {
            auto left = popVariable();
            auto right = popVariable();

            T leftValue, rightValue;
            if (type == VT_DOUBLE) {
                leftValue = left.getDoubleValue();
                rightValue = right.getDoubleValue();
            }
            else {
                leftValue = left.getIntValue();
                rightValue = right.getIntValue();
            }

            pushVariable(binaryFunction(leftValue, rightValue));
        }
Example #7
0
string Object::getValue()
{
    if (isArray == 1)
    {
        getMapValue();
    }
    
    if (value=="") return "";
    
    if (type=="bool")
    {
        return to_string(getBoolValue());
    }
    else if (type=="int")
    {
        return to_string(getIntValue());
    }
    else if (type=="double")
    {
        std::ostringstream os;
        os << getDoubleValue();
        return os.str();
    }
    return getStringValue();
}
Example #8
0
//!
//! Change size scale of the entity.
//!
void Model2SceneNode::sizeChanged()
{
	m_size.x = m_size.y = m_size.z = getDoubleValue("Size");

	if (m_sceneNode)
		resizeNodes(m_sceneNode);
}
Example #9
0
void OrientedPoint::UseInformationPercent(const double Percent)
{
	assert(Percent >= 0.0);
	assert(Percent <= 1.0);
	
	double total = getDoubleValue("TotalInformation");
	double update = Percent * total;
	
	double remain = getDoubleValue("RemainingInformation");
	
	if(remain < 0.0)
		remain = 0.0;
	
	setDoubleValue("RemainingInformation", remain);
	//RemainingInformation_ -= Percent * TotalInformation_;
	
}
Example #10
0
Equation* createEquation(HWND window, TCHAR operand)
{
	Equation* equation = new Equation;
	equation->operand = operand;
	equation->value1 = getDoubleValue(window, IDC_VALUE1);
	equation->value2 = getDoubleValue(window, IDC_VALUE2);
	equation->value3 = getDoubleValue(window, IDC_VALUE3);
	equation->value4 = getDoubleValue(window, IDC_VALUE4);
	equation->value5 = getDoubleValue(window, IDC_VALUE5);
	equation->value6 = getDoubleValue(window, IDC_VALUE6);
	equation->value7 = getDoubleValue(window, IDC_VALUE7);
	equation->value8 = getDoubleValue(window, IDC_VALUE8);
	equation->value9 = getDoubleValue(window, IDC_VALUE9);
	equation->value10 = getDoubleValue(window, IDC_VALUE10);

	return equation;
}
double CSSPrimitiveValue::computeDegrees() const
{
    ASSERT(isAngle() || (isCalculated() && cssCalcValue()->category() == CalcAngle));
    UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->typeWithCalcResolved() : type();
    switch (currentType) {
    case UnitType::Degrees:
        return getDoubleValue();
    case UnitType::Radians:
        return rad2deg(getDoubleValue());
    case UnitType::Gradians:
        return grad2deg(getDoubleValue());
    case UnitType::Turns:
        return turn2deg(getDoubleValue());
    default:
        ASSERT_NOT_REACHED();
        return 0;
    }
}
Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conversionData)
{
    if (isLength())
        return computeLength<Length>(conversionData);
    if (isPercentage())
        return Length(getDoubleValue(), Percent);
    ASSERT(isCalculated());
    return Length(cssCalcValue()->toCalcValue(conversionData));
}
Example #13
0
double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multiplier, bool computingFontSize)
{
    unsigned short type = primitiveType();

    // We do not apply the zoom factor when we are computing the value of the font-size property.  The zooming
    // for font sizes is much more complicated, since we have to worry about enforcing the minimum font size preference
    // as well as enforcing the implicit "smart minimum."  In addition the CSS property text-size-adjust is used to
    // prevent text from zooming at all.  Therefore we will not apply the zoom here if we are computing font-size.
    bool applyZoomMultiplier = !computingFontSize;

    double factor = 1.0;
    switch (type) {
        case CSS_EMS:
            applyZoomMultiplier = false;
            factor = computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize();
            break;
        case CSS_EXS:
            // FIXME: We have a bug right now where the zoom will be applied twice to EX units.
            // We really need to compute EX using fontMetrics for the original specifiedSize and not use
            // our actual constructed rendering font.
            applyZoomMultiplier = false;
            factor = style->font().xHeight();
            break;
        case CSS_PX:
            break;
        case CSS_CM:
            factor = cssPixelsPerInch / 2.54; // (2.54 cm/in)
            break;
        case CSS_MM:
            factor = cssPixelsPerInch / 25.4;
            break;
        case CSS_IN:
            factor = cssPixelsPerInch;
            break;
        case CSS_PT:
            factor = cssPixelsPerInch / 72.0;
            break;
        case CSS_PC:
            // 1 pc == 12 pt
            factor = cssPixelsPerInch * 12.0 / 72.0;
            break;
        default:
            return -1.0;
    }

    double result = getDoubleValue() * factor;
    if (!applyZoomMultiplier || multiplier == 1.0)
        return result;
     
    // Any original result that was >= 1 should not be allowed to fall below 1.  This keeps border lines from
    // vanishing.
    double zoomedResult = result * multiplier;
    if (result >= 1.0)
        zoomedResult = max(1.0, zoomedResult);
    return zoomedResult;
}
Example #14
0
void CGridDlg::OnEnChangeEditCellSizeMM() {
  if(m_changeHandlerActive) return;
  m_changeHandlerActive = true;

  double value;
  if(getDoubleValue(IDC_EDITCELLSIZEMM, value)) {
    setCellSizeMM(value);
  }
  m_changeHandlerActive = false;
}
void ConeTreeLayouterNode::setSpacing ()
{
	double spacing = getDoubleValue(m_SpacingNameParameter);
	if (m_Spacing == spacing)
		return;

	m_Spacing = spacing;

	M_LAYOUT->SetSpacing(m_Spacing);
}
//!
//! Set the various parameters from property editor
//!
void ConeTreeLayouterNode::setCompactness ()
{
	double compactness = getDoubleValue(m_CompactnessNameParameter);
	if (m_Compactness == compactness)
		return;

	m_Compactness = compactness;

	M_LAYOUT->SetCompactness(m_Compactness);
}
void ClusteringLayouterNode::setRestDistance ()
{
	int restDistance = getDoubleValue("Set Rest Distance");
	if (m_restDistance == restDistance)
		return;

	m_restDistance = restDistance;

	M_LAYOUT->SetRestDistance(m_restDistance);
}
void ClusteringLayouterNode::setInitialTemperature ()
{
	int initialTemperature = getDoubleValue("Set Initial Temperature");
	if (m_initialTemperature == initialTemperature)
		return;

	m_initialTemperature = initialTemperature;

	M_LAYOUT->SetInitialTemperature(m_initialTemperature);
}
Example #19
0
AMNumber CLSValueEditor::getValue()
{
	AMNumber newValue = AMNumber(AMNumber::InvalidError);

	if (values_.isEmpty())
		newValue = getDoubleValue();
	else
		newValue = getEnumValue();

	return newValue;
}
/*****************************************************
**
**   DateInputField   ---   formatValue
**
******************************************************/
void DateInputField::formatValue()
{
	Formatter *formatter = Formatter::get();
	if ( Validate())
	{
		value = getDoubleValue();
		SetValue( formatter->getDateStringFromJD( value ));
	}
	else
	{
		SetValue( formatter->getDateStringFromJD( value ));
	}
}
/*****************************************************
**
**   DegMinSecInputField   ---   formatValue
**
******************************************************/
void DegMinSecInputField::formatValue()
{
	Formatter *formatter = Formatter::get();
	if ( Validate())
	{
		value = getDoubleValue();
		SetValue( formatter->getDegreesFormatted( value, format ));
	}
	else
	{
		SetValue( formatter->getDegreesFormatted( value, format ));
	}
}
Example #22
0
double OrientedPoint::getDoubleValue(const std::string &ValueName) const
{
	double value;
	bool valid = getDoubleValue(ValueName, value);	
	if(valid)
	{
		return value;
	}
	else
	{
		std::cout << "There is no value named " << ValueName << "!" << std::endl;
		assert(0);
		exit(-1);
	}
}
Example #23
0
//!
//! Callback when instance of this class is registered as Ogre::CompositorListener.
//! 
//! \param pass_id Id to identifiy current compositor pass.
//! \param mat Material this pass is currently using.
//!
void ScratchedFilmNode::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
    Ogre::TexturePtr inputTexture = getTextureValue("Input Map");
    if (inputTexture.isNull())
        return;

    // watercolor pass
    if (pass_id == 0000) {
        // set shader parameters
        Ogre::GpuProgramParametersSharedPtr fpParams = getShaderParameters(mat);
        if (!fpParams.isNull()) {
            
			setShaderParameter(fpParams, "speed1", (Ogre::Real)(getDoubleValue("Speed1") / 100.0));
			setShaderParameter(fpParams, "speed2", (Ogre::Real)(getDoubleValue("Speed2") / 100.0));
			setShaderParameter(fpParams, "speed1", (Ogre::Real)(getDoubleValue("Speed1") / 100.0));
			setShaderParameter(fpParams, "scratchIntensity", (Ogre::Real)(getDoubleValue("ScratchIntensity") / 100.0));
			setShaderParameter(fpParams, "is", (Ogre::Real)(getDoubleValue("IS") / 100.0));
			
        }

        // set texture name
        setTexture(mat, inputTexture, 0);
    }
}
Example #24
0
void Var::print() {
    switch (_type) {
    case VT_DOUBLE:
        cout << getDoubleValue();
        break;
    case VT_INT:
        cout << getIntValue();
        break;
    case VT_STRING:
        cout << getStringValue();
        break;
        default:
            assert(false);
    }
}
 static R run(SimpleInterpreter *inter, void* f, T a) {
     auto p = inter->loadVariable(index);
     switch (p._type) {
         case VT_DOUBLE:
             return Collector<index + 1, size, R, decltype(tuple_cat(a, make_tuple(p.getDoubleValue())))>::
                     run(inter, f, tuple_cat(a, make_tuple(p.getDoubleValue())));
         case VT_INT:
             return Collector<index + 1, size, R, decltype(tuple_cat(a, make_tuple(p.getIntValue())))>::
                     run(inter, f, tuple_cat(a, make_tuple(p.getIntValue())));
         case VT_STRING:
             return Collector<index + 1, size, R, decltype(tuple_cat(a, make_tuple(p.getStringValue())))>::
                     run(inter, f, tuple_cat(a, make_tuple(p.getStringValue())));
         default:
             throw InterpretationError("Unknown type of " + to_string(index) + " function parameter");
     }
 }
        void unary_operation(VarType type, T (*unaryFunction)(T const &)) {
            auto var = popVariable();
            TypedVariable result(type);

            T value;
            if (type == (VT_DOUBLE)) {
                value = var.getDoubleValue();
            }
            else {
                value = var.getIntValue();
            }
            T resultValue = unaryFunction(value);
            if (type == VT_DOUBLE) {
                result.setDoubleValue(resultValue);
            }
            else {
                result.setIntValue(resultValue);
            }
            pushVariable(result);
        }
double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& conversionData)
{
    // The logic in this function is duplicated in MediaValues::computeLength
    // because MediaValues::computeLength needs nearly identical logic, but we haven't found a way to make
    // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases) without hurting performance.
    if (type() == UnitType::Calc)
        return m_value.calc->computeLengthPx(conversionData);

    double factor;

    switch (type()) {
    case UnitType::Ems:
        factor = conversionData.emFontSize();
        break;
    case UnitType::Exs:
        factor = conversionData.exFontSize();
        break;
    case UnitType::Rems:
        factor = conversionData.remFontSize();
        break;
    case UnitType::Chs:
        factor = conversionData.chFontSize();
        break;
    case UnitType::Pixels:
        factor = 1.0;
        break;
    case UnitType::Centimeters:
        factor = cssPixelsPerCentimeter;
        break;
    case UnitType::Millimeters:
        factor = cssPixelsPerMillimeter;
        break;
    case UnitType::Inches:
        factor = cssPixelsPerInch;
        break;
    case UnitType::Points:
        factor = cssPixelsPerPoint;
        break;
    case UnitType::Picas:
        factor = cssPixelsPerPica;
        break;
    case UnitType::ViewportWidth:
        factor = conversionData.viewportWidthPercent();
        break;
    case UnitType::ViewportHeight:
        factor = conversionData.viewportHeightPercent();
        break;
    case UnitType::ViewportMin:
        factor = conversionData.viewportMinPercent();
        break;
    case UnitType::ViewportMax:
        factor = conversionData.viewportMaxPercent();
        break;
    case UnitType::CalcPercentageWithLength:
    case UnitType::CalcPercentageWithNumber:
        ASSERT_NOT_REACHED();
        return -1.0;
    default:
        ASSERT_NOT_REACHED();
        return -1.0;
    }

    // We do not apply the zoom factor when we are computing the value of the font-size property. The zooming
    // for font sizes is much more complicated, since we have to worry about enforcing the minimum font size preference
    // as well as enforcing the implicit "smart minimum."
    double result = getDoubleValue() * factor;
    if (isFontRelativeLength())
        return result;

    return result * conversionData.zoom();
}
Example #28
0
void OrientedPoint::ResetInformation()
{
	double total = getDoubleValue("TotalInformation");
	setDoubleValue("RemainingInformation", total);
	//RemainingInformation_ = TotalInformation_;
}
/*****************************************************
**
**   IntegerInputField   ---   formatValue
**
******************************************************/
void IntegerInputField::formatValue()
{
	value = getDoubleValue();
	setDoubleValue( value );
}
/*****************************************************
**
**   DoubleInputField   ---   formatValue
**
******************************************************/
void DoubleInputField::formatValue()
{
	value = getDoubleValue();
	setDoubleValue( value );
}