Ejemplo n.º 1
0
Tag * AdhocTag::generateResponse(const std::string &action) {
    IQ _response(IQ::Result, m_from, m_id);
    _response.setFrom(Transport::instance()->jid());
    Tag *response = _response.tag();

    if (action != "") {
        response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), action) );
        return response;
    }

    if (hasAttribute("action", "cancel"))
        response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "canceled") );
    else
        response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "completed") );

    return response;
}
Ejemplo n.º 2
0
void Item::setID(uint16_t newid)
{
	const ItemType& prevIt = Item::items[id];
	id = newid;

	const ItemType& it = Item::items[newid];
	uint32_t newDuration = it.decayTime * 1000;

	if(newDuration == 0 && !it.stopTime && it.decayTo == -1){
		removeAttribute(ATTR_ITEM_DECAYING);
		removeAttribute(ATTR_ITEM_DURATION);
	}

	if(newDuration > 0 && (!prevIt.stopTime || !hasAttribute(ATTR_ITEM_DURATION)) ){
		setDecaying(DECAYING_FALSE);
		setDuration(newDuration);
	}
}
PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filterBuilder)
{
    FilterEffect* input1 = filterBuilder->getEffectById(in1());

    if (!input1)
        return 0;

    Vector<float> filterValues;
    SVGNumberList* numbers = values();
    const ColorMatrixType filterType(static_cast<const ColorMatrixType>(type()));

    // Use defaults if values is empty (SVG 1.1 15.10).
    if (!hasAttribute(SVGNames::valuesAttr)) {
        switch (filterType) {
        case FECOLORMATRIX_TYPE_MATRIX:
            for (size_t i = 0; i < 20; i++)
                filterValues.append((i % 6) ? 0.0f : 1.0f);
            break;
        case FECOLORMATRIX_TYPE_HUEROTATE:
            filterValues.append(0.0f);
            break;
        case FECOLORMATRIX_TYPE_SATURATE:
            filterValues.append(1.0f);
            break;
        default:
            break;
        }
    } else {
        size_t size = numbers->numberOfItems();
        for (size_t i = 0; i < size; i++) {
            ExceptionCode ec = 0;
            filterValues.append(numbers->getItem(i, ec));
        }
        size = filterValues.size();

        if ((filterType == FECOLORMATRIX_TYPE_MATRIX && size != 20)
            || (filterType == FECOLORMATRIX_TYPE_HUEROTATE && size != 1)
            || (filterType == FECOLORMATRIX_TYPE_SATURATE && (size != 1
                || filterValues[0] < 0.0f || filterValues[0] > 1.0f)))
            return 0;
    }

    return FEColorMatrix::create(input1, filterType, filterValues);
}
Ejemplo n.º 4
0
        //---------------------------------------------------------------------
        DocumentPtr SessionDeleteRequest::encode()
        {
          DocumentPtr ret = IMessageHelper::createDocumentWithRoot(*this);
          ElementPtr root = ret->getFirstChildElement();

          if (hasAttribute(AttributeType_Locations))
          {
            ElementPtr locationsEl = IMessageHelper::createElement("locations");
            root->adoptAsLastChild(locationsEl);

            for(StringList::const_iterator it = mLocations.begin(); it != mLocations.end(); ++it)
            {
              const String &loc = (*it);
              locationsEl->adoptAsLastChild(IMessageHelper::createElementWithID("location", loc));
            }
          }

          return ret;
        }
Ejemplo n.º 5
0
SUMOTime
SUMOSAXAttributes::getOptSUMOTimeReporting(int attr, const char* objectid,
        bool& ok, SUMOTime defaultValue, bool report) const {
    if (!hasAttribute(attr)) {
        return defaultValue;
    }
    try {
        return (SUMOTime)(getFloat(attr) * 1000.);
    } catch (NumberFormatException&) {
        if (report) {
            emitFormatError(getName(attr), "a real number", objectid);
        }
    } catch (EmptyData&) {
        if (report) {
            emitEmptyError(getName(attr), objectid);
        }
    }
    ok = false;
    return (SUMOTime) - 1;
}
Ejemplo n.º 6
0
int
SUMOSAXAttributes::getOptIntReporting(int attr, const char *objectid,
                                      bool &ok, int defaultValue, bool report) const throw() {
    if (!hasAttribute(attr)) {
        return defaultValue;
    }
    try {
        return getInt(attr);
    } catch (NumberFormatException &) {
        if (report) {
            emitFormatError(getName(attr), "an int", objectid);
        }
    } catch (EmptyData &) {
        if (report) {
            emitEmptyError(getName(attr), objectid);
        }
    }
    ok = false;
    return -1;
}
Ejemplo n.º 7
0
SVGAnimationElement::AnimationMode SVGAnimationElement::animationMode() const
{
    // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
    if (hasTagName(SVGNames::setTag)) {
        return ToAnimation;
    }
    if (!animationPath().isEmpty()) {
        return PathAnimation;
    }
    if (hasAttribute(SVGNames::valuesAttr)) {
        return ValuesAnimation;
    }
    if (!toValue().isEmpty()) {
        return fromValue().isEmpty() ? ToAnimation : FromToAnimation;
    }
    if (!byValue().isEmpty()) {
        return fromValue().isEmpty() ? ByAnimation : FromByAnimation;
    }
    return NoAnimation;
}
Ejemplo n.º 8
0
bool
SUMOSAXAttributes::getOptBoolReporting(int attr, const char *objectid,
                                       bool &ok, bool defaultValue, bool report) const throw() {
    if (!hasAttribute(attr)) {
        return defaultValue;
    }
    try {
        return getBool(attr);
    } catch (BoolFormatException &) {
        if (report) {
            emitFormatError(getName(attr), "a boolean", objectid);
        }
    } catch (EmptyData &) {
        if (report) {
            emitEmptyError(getName(attr), objectid);
        }
    }
    ok = false;
    return false;
}
PassRefPtr<FilterEffect> SVGFEColorMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)
{
    FilterEffect* input1 = filterBuilder->getEffectById(in1());

    if (!input1)
        return 0;

    Vector<float> filterValues;
    const ColorMatrixType filterType(static_cast<ColorMatrixType>(type()));

    // Use defaults if values is empty (SVG 1.1 15.10).
    if (!hasAttribute(SVGNames::valuesAttr)) {
        switch (filterType) {
        case FECOLORMATRIX_TYPE_MATRIX:
            for (size_t i = 0; i < 20; i++)
                filterValues.append((i % 6) ? 0.0f : 1.0f);
            break;
        case FECOLORMATRIX_TYPE_HUEROTATE:
            filterValues.append(0.0f);
            break;
        case FECOLORMATRIX_TYPE_SATURATE:
            filterValues.append(1.0f);
            break;
        default:
            break;
        }
    } else {
        filterValues = values();
        unsigned size = filterValues.size();

        if ((filterType == FECOLORMATRIX_TYPE_MATRIX && size != 20)
            || (filterType == FECOLORMATRIX_TYPE_HUEROTATE && size != 1)
            || (filterType == FECOLORMATRIX_TYPE_SATURATE && (size != 1
                || filterValues[0] < 0.0f || filterValues[0] > 1.0f)))
            return 0;
    }

    RefPtr<FilterEffect> effect = FEColorMatrix::create(filter, filterType, filterValues);
    effect->inputEffects().append(input1);
    return effect.release();
}
Ejemplo n.º 10
0
//
// Called to initialize a newly added node to the environment (not just read from the environment)
void EnvironmentNode::initialize()
{
    //
    // Add missing attributes
    addMissingAttributesFromConfig();

    //
    // If we are a component and there is a buildSet attribute, set the value to the configItem's type
    if (!(m_pSchemaItem->getProperty("itemType").empty()) && hasAttribute("buildSet"))
    {
        Status status;
        setAttributeValue("buildSet", m_pSchemaItem->getProperty("itemType"), status);
    }

    //
    // Initilize each attribute
    for (auto attrIt = m_attributes.begin(); attrIt != m_attributes.end(); ++attrIt)
    {
        attrIt->second->initialize();
    }
}
Ejemplo n.º 11
0
void Parser::sGesture() {
    if (m_reader.isEndElement() && m_reader.name() == "gesture") {
        state.removeLast();
        return;
    } else if (m_reader.isStartElement() && m_reader.name() == "action") {
        state.append("ACTION");
        auto attrs = m_reader.attributes();
        if (!attrs.hasAttribute("type"))
            throw(err("Attribute 'type' expected."));

        Group *g = Memory::getGroup(appKey);
        g->addGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction));
        Gesture *gest = g->getGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction));
        gest->setAction(Lists::aT(attrs.value("type").toString()));
        //sAction(g->getGest(ges->num, Lists::gT(ges->type), Lists::gD(ges->direction))->getAction());->setAction(Lists::aT(attrs.value("type").toString()))
        QStringList params = m_reader.readElementText().split(":");
        foreach(const QString &p, params)
            gest->getAction()->addParam(p.section("=",0,0),p.section("=",1));

        state.removeLast();
    } else
Ejemplo n.º 12
0
	void XmlSettingsDialog::UpdateXml (bool whole)
	{
		const auto& nodes = Document_->elementsByTagName ("item");
		if (whole)
			for (int i = 0; i < nodes.size (); ++i)
			{
				auto elem = nodes.at (i).toElement ();
				if (!elem.hasAttribute ("property"))
					continue;

				const auto& name = elem.attribute ("property");
				const auto& value = WorkingObject_->property (name.toLatin1 ().constData ());

				UpdateSingle (name, value, elem);
			}
		else
			for (const auto& pair : Util::Stlize (HandlersManager_->GetNewValues ()))
			{
				QDomElement element;
				const auto& name = pair.first;
				for (int j = 0, size = nodes.size (); j < size; ++j)
				{
					const auto& e = nodes.at (j).toElement ();
					if (e.isNull ())
						continue;
					if (e.attribute ("property") == name)
					{
						element = e;
						break;
					}
				}
				if (element.isNull ())
				{
					qWarning () << Q_FUNC_INFO << "element for property" << name << "not found";
					return;
				}

				UpdateSingle (name, pair.second, element);
			}
	}
Ejemplo n.º 13
0
AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const
{
    AffineTransform viewBoxTransform;
    if (hasAttribute(SVGNames::viewBoxAttr)) {
        FloatSize size = currentViewportSize();
        viewBoxTransform = viewBoxToViewTransform(size.width(), size.height());
    }

    AffineTransform transform;
    if (!isOutermostSVGSVGElement()) {
        SVGLengthContext lengthContext(this);
        transform.translate(x().value(lengthContext), y().value(lengthContext));
    } else if (mode == SVGLocatable::ScreenScope) {
        if (RenderObject* renderer = this->renderer()) {
            FloatPoint location;
            
            // At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderBoxTransform 
            // to map an element from SVG viewport coordinates to CSS box coordinates.
            // RenderSVGRoot's localToAbsolute method expects CSS box coordinates.
            if (renderer->isSVGRoot())
                location = toRenderSVGRoot(renderer)->localToBorderBoxTransform().mapPoint(location);
            
            // Translate in our CSS parent coordinate space
            // FIXME: This doesn't work correctly with CSS transforms.
            location = renderer->localToAbsolute(location, false, true);

            // Be careful here! localToBorderBoxTransform() included the x/y offset coming from the viewBoxToViewTransform(),
            // so we have to subtract it here (original cause of bug #27183)
            transform.translate(location.x() - viewBoxTransform.e(), location.y() - viewBoxTransform.f());

            // Respect scroll offset.
            if (FrameView* view = document()->view()) {
                LayoutSize scrollOffset = view->scrollOffset();
                transform.translate(-scrollOffset.width(), -scrollOffset.height());
            }
        }
    }

    return transform.multiply(viewBoxTransform);
}
Ejemplo n.º 14
0
void Object::setAttributeIncDB(BString key,std::string value)
{
    if(!hasAttribute(key))
    {
        addAttributeIncDB(key,value);
    }

    AttributeMap::iterator it = mAttributeMap.find(key.getCrc());

    if(it == mAttributeMap.end())
    {
        DLOG(INFO) << "Object::setAttribute: could not find " << key.getAnsi();
        return;
    }

    (*it).second = value;

    uint32 attributeID = gWorldManager->getAttributeId(key.getCrc());
    if(!attributeID)
    {
        DLOG(INFO) << "Object::addAttribute DB: no such attribute in the attribute table :" << key.getAnsi();
        return;
    }

    int8 sql[512],*sqlPointer,restStr[128];
//	int8 sql[1024]
    sprintf(sql,"UPDATE item_attributes SET value='");

    sqlPointer = sql + strlen(sql);
    sqlPointer += gWorldManager->getDatabase()->escapeString(sqlPointer,value.c_str(),value.length());
    sprintf(restStr,"'WHERE item_id=%"PRIu64" AND attribute_id=%u",this->getId(),attributeID);
    strcat(sql,restStr);

    //sprintf(sql,"UPDATE item_attributes SET value='%s' WHERE item_id=%"PRIu64" AND attribute_id=%u",value,this->getId(),attributeID);
    gWorldManager->getDatabase()->executeSqlAsync(0,0,sql);

}
Ejemplo n.º 15
0
SUMOTime
SUMOSAXAttributes::getSUMOTimeReporting(int attr, const char* objectid,
                                        bool& ok, bool report) const {
    if (!hasAttribute(attr)) {
        if (report) {
            emitUngivenError(getName(attr), objectid);
        }
        ok = false;
        return -1;
    }
    try {
        return TIME2STEPS(getFloat(attr));
    } catch (NumberFormatException&) {
        if (report) {
            emitFormatError(getName(attr), "a time value", objectid);
        }
    } catch (EmptyData&) {
        if (report) {
            emitEmptyError(getName(attr), objectid);
        }
    }
    ok = false;
    return (SUMOTime) - 1;
}
Ejemplo n.º 16
0
SUMOTime
SUMOSAXAttributes::getOptSUMOTimeReporting(int attr, const char *objectid,
        bool &ok, SUMOTime defaultValue, bool report) const throw() {
#ifdef HAVE_SUBSECOND_TIMESTEPS
    if (!hasAttribute(attr)) {
        return defaultValue;
    }
    try {
        return (SUMOTime)(getFloat(attr)*1000.);
    } catch (NumberFormatException &) {
        if (report) {
            emitFormatError(getName(attr), "a real number", objectid);
        }
    } catch (EmptyData &) {
        if (report) {
            emitEmptyError(getName(attr), objectid);
        }
    }
    ok = false;
    return (SUMOTime) -1;
#else
    return getOptIntReporting(attr, objectid, ok, defaultValue, report);
#endif
}
Ejemplo n.º 17
0
std::string
SUMOSAXAttributes::getStringReporting(int attr, const char *objectid,
                                      bool &ok, bool report) const throw() {
    if (!hasAttribute(attr)) {
        if (report) {
            emitUngivenError(getName(attr), objectid);
        }
        ok = false;
        return "";
    }
    try {
        std::string ret = getString(attr);
        if (ret=="") {
            throw EmptyData();
        }
        return ret;
    } catch (EmptyData &) {
        if (report) {
            emitEmptyError(getName(attr), objectid);
        }
    }
    ok = false;
    return "";
}
Ejemplo n.º 18
0
SUMOReal
SUMOSAXAttributes::getSUMORealReporting(int attr, const char *objectid,
                                        bool &ok, bool report) const throw() {
    if (!hasAttribute(attr)) {
        if (report) {
            emitUngivenError(getName(attr), objectid);
        }
        ok = false;
        return -1;
    }
    try {
        return getFloat(attr);
    } catch (NumberFormatException &) {
        if (report) {
            emitFormatError(getName(attr), "a real number", objectid);
        }
    } catch (EmptyData &) {
        if (report) {
            emitEmptyError(getName(attr), objectid);
        }
    }
    ok = false;
    return (SUMOReal) -1;
}
Ejemplo n.º 19
0
void ParametricAd::checkInputSandbox(std::vector<std::string>& extracted){
	GLITE_STACK_TRY("ParametricAd::checkInputSandbox(std::vector<std::string>&)");
	// This vector contains all ISB string extracted Values
	unsigned int iter_i = extracted.size();
	// This Vector will replace the old InputSanbox with the extracted values
	vector<ExprTree*> isVect ;
	ExprTree* isbTree = Lookup (JDL::INPUTSB);
	if (!isbTree){ /* No inputFiles found: return */ return; }
	// These variables are needed when extracting
	const string wmpURI = (hasAttribute(JDL::WMPISB_BASE_URI))? (getString(JDL::WMPISB_BASE_URI)):"";
	const string isbURI=   (hasAttribute(JDL::ISB_BASE_URI))  ? (getString(JDL::ISB_BASE_URI)   ):"";
	Value val ;
	string isb ;
	EvaluateExpr(isbTree,val);
	inputRemotes.clear();
	switch ( val.GetType() ){
		case Value::UNDEFINED_VALUE:
			inputRemotes.push_back(isbTree->Copy());
			isVect.push_back(isbTree->Copy());
			break;
		case Value::STRING_VALUE:
			val.IsStringValue(isb);
			toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
				lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
			// put the extracted files back into the InputSandbox attribute
			for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
				val.SetStringValue(extracted[iter_i]);	// create classad Value
				isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
			}
			break;
		case Value::LIST_VALUE:{
			const ExprList *el;
			val.IsListValue( el );
			vector<ExprTree*> vectList ;
			el->GetComponents(vectList) ;
			for ( unsigned int i = 0; i< vectList.size() ; i++){
				if (vectList[i]->GetKind()!=ExprTree::LITERAL_NODE){
					// not a literal node
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				else if (vectList[i]->Evaluate(val)){
					switch (val.GetType()){
						case Value::STRING_VALUE:
							val.IsStringValue(isb);
							toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
								lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
							// put the extracted files back into the InputSandbox attribute
							for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
								val.SetStringValue(extracted[iter_i]);	// create classad Value
								isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
							}
							break;
						case Value::UNDEFINED_VALUE:
							// It's an Expression evaluated
							inputRemotes.push_back( vectList[i]->Copy() );
							isVect.push_back(vectList[i]->Copy());
							break;
						default:
							throw AdMismatchException (__FILE__,__LINE__,
							METHOD,WMS_JDLMISMATCH , JDL::INPUTSB );
					}
				}else{
					// It's an Expression not evaluated, leave it unchanged
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				val.Clear() ;
			}
		}
		break;
		default:
			throw AdMismatchException (__FILE__ , __LINE__ ,METHOD, WMS_JDLMISMATCH , JDL::INPUTSB );
			break;
	}
	classad:ExprTree* tmp_expr = ExprList::MakeExprList(isVect);
	Insert (JDL::INPUTSB , tmp_expr) ;
	GLITE_STACK_JDL_CATCH_ALL() ; //Exiting from method: remove line from stack trace
}
Ejemplo n.º 20
0
 bool isDirty()
 {
   return (!m_drawn || transform()) && !hasAttribute(ATTRIB_DELETED);
 }
Ejemplo n.º 21
0
	bool ZoneProcessor::processNode(const TiXmlElement* zonesElem, const Ogre::String& resourceGroup, bool loadGameObjects)
	{
		if (zonesElem == NULL)
		{
			return false; // no zones
		}

        for (const TiXmlNode* cur = zonesElem->FirstChild(); cur != NULL; cur = cur->NextSibling())
        {
            if (cur->Type() == TiXmlNode::ELEMENT
				&& hasNodeName(cur, "zone"))
            {
            	const TiXmlElement* curZoneElem = cur->ToElement();
				if (hasAttribute(curZoneElem, "name"))
				{
					Ogre::String name = getAttributeValueAsStdString(curZoneElem, "name");
                    Zone* zone = NULL;
                    if (name == "default")
                    {
                        zone = ZoneManager::getSingleton().getDefaultZone();
                    }
                    else
                    {
                        // get the zone with that name or create one
                        zone = ZoneManager::getSingleton().getZone(name);
                        if (!zone)
                        {
                            zone = ZoneManager::getSingleton().createZone(name, false);
                        }

                        // multiple areas
                        for (const TiXmlNode* curArea = cur->FirstChild(); curArea != NULL; curArea = curArea->NextSibling())
                        {
                            if (curArea->Type() == TiXmlNode::ELEMENT
                                && hasNodeName(curArea, "area"))
                            {
                            	const TiXmlElement *curAreaElem = curArea->ToElement();
                                if (hasAttribute(curAreaElem, "type"))
                                {
                                    // type
                                    Ogre::String type;
                                    type = getAttributeValueAsStdString(curAreaElem, "type");

                                    // add or subtract?
                                    bool subtract = false;
                                    if (hasAttribute(curAreaElem, "subtract"))
                                    {
                                        subtract = getAttributeValueAsBool(curAreaElem, "subtract");
                                    }

                                    // position
                                    Vector3 position = Vector3::ZERO;
                                    const TiXmlElement* positionElem = getChildNamed(curAreaElem, "position");
                                    if (positionElem)
                                    {
                                        position = getValueAsVector3(positionElem);
                                    }

                                    //scale, rotation, offset
                                    Vector3 scale = Vector3::UNIT_SCALE;
                                    const TiXmlElement* scaleElem = getChildNamed(curAreaElem, "scale");
                                    if (!scaleElem)
                                    {
                                        scaleElem = getChildNamed(curAreaElem, "size");
                                    }
                                    
                                    if (scaleElem)
                                    {
                                        scale = getValueAsVector3(scaleElem);
                                    }

                                    Vector3 offset = Vector3::ZERO;
                                    const TiXmlElement* offsetElem = getChildNamed(curAreaElem, "offset");
                                    if (offsetElem)
                                    {
                                        offset = getValueAsVector3(offsetElem);
                                    }

                                    Quaternion rotation = Quaternion::IDENTITY;
                                    const TiXmlElement* rotationElem = getChildNamed(curAreaElem, "rotation");
                                    if (rotationElem)
                                    {
                                        rotation = getValueAsQuaternion(rotationElem);
                                    }

                                    //transition distance
                                    Real transitionDistance = 0;
                                    const TiXmlElement* transitionElem = getChildNamed(curAreaElem, "transition_distance");
                                    if (transitionElem)
                                    {
                                        transitionDistance = getValueAsReal(transitionElem);
                                    }
					            
                                    if (type == "mesh")
    					            {
                                        Ogre::String meshName;
                                        if (hasAttribute(curAreaElem, "meshfile"))
                                        {
                                            meshName = getAttributeValueAsStdString(curAreaElem, "meshfile");
                                            if (subtract)
                                            {
                                                ZoneManager::getSingleton().subtractMeshAreaFromZone(name,
                                                    meshName, GT_CONVEXHULL, position, scale, offset, rotation, transitionDistance, QUERYFLAG_PLAYER);
                                            }
                                            else
                                            {
                                                ZoneManager::getSingleton().addMeshAreaToZone(name,
                                                    meshName, GT_CONVEXHULL, position, scale, offset, rotation, transitionDistance, QUERYFLAG_PLAYER);
                                            }
                                        }
                                        else
                                        {
                                            LOG_ERROR(Logger::SCRIPT, "an <area> element with type=\"mesh\" must have attribute 'meshfile'");
                                        }
                                    }
    					            else
                                    {
                                        GeometryType geom = GT_NONE;
                                        if (type == "sphere")
                                        {
                                            geom = GT_SPHERE;
                                        }
                                        else if (type == "box")
                                        {
                                            geom = GT_BOX;
                                        }
                                        else if (type == "ellipsoid")
                                        {
                                            geom = GT_ELLIPSOID;
                                        }
                                        else if (type == "pyramid")
                                        {
                                            geom = GT_PYRAMID;
                                        }
                                        else if (type == "capsule")
                                        {
                                            geom = GT_CAPSULE;
                                        }
                                        else
                                        {
                                            LOG_ERROR(Logger::SCRIPT, "Unknown area type '" + type + "' !");
                                        }
                                        
                                        if ( geom != GT_NONE)
                                        {
                                            Ogre::AxisAlignedBox aabb;
                                            aabb.setMinimum( - scale / 2.0f);
                                            aabb.setMaximum( + scale / 2.0f);

                                            if (subtract)
                                                ZoneManager::getSingleton().subtractAreaFromZone(name,
                                                    aabb, geom, position, offset, rotation, transitionDistance, QUERYFLAG_PLAYER);
                                            else
                                                ZoneManager::getSingleton().addAreaToZone(name,
                                                    aabb, geom, position, offset, rotation, transitionDistance, QUERYFLAG_PLAYER);
                                        }
                                    }
                                }
                                else
                                {
                                    LOG_ERROR(Logger::SCRIPT, "<area> elemt must have attribute 'type'");
                                }
                            }
                        }
                    }

					if (zone)
					{
						for (const TiXmlNode* cur = curZoneElem->FirstChild(); cur != NULL; cur = cur->NextSibling())
						{
							if (cur->Type() == TiXmlNode::ELEMENT)
							{
								const TiXmlElement* curElem = cur->ToElement();
								if (hasNodeName(curElem, "light"))
								{
									Ogre::String name = getAttributeValueAsStdString(curElem, "name");
									zone->addLight(ActorManager::getSingleton().getActor(name));
								}
								else if (hasNodeName(curElem, "sound"))
								{
									Ogre::String name = getAttributeValueAsStdString(curElem, "name");
									zone->addSound(name);
								}
								else if (hasNodeName(curElem, "trigger"))
								{
									Ogre::String classname =
										getAttributeValueAsStdString(curElem, "classname");

									Ogre::String name =
										getAttributeValueAsStdString(curElem, "name");

									Trigger* trigger = ScriptSubsystem::getSingleton().getTriggerFactory()
										->createTrigger(classname, name);

                                    // add trigger properties
                                    for (const TiXmlNode* curProperty = cur->FirstChild(); curProperty != NULL; curProperty = curProperty->NextSibling())
                                    {
                                        if (hasNodeName(curProperty, "property"))
                                        {
                                            PropertyEntry propEntry = processProperty(curProperty->ToElement());
                                            if (propEntry.first != "")
                                            {
                                                trigger->setProperty(propEntry.first, propEntry.second);
                                            }
                                        }
                                    }

                                    zone->addTrigger(trigger);
								}
                                else if (hasNodeName(curElem, "eaxpreset"))
                                {
									Ogre::String name = getAttributeValueAsStdString(curElem, "name");
                                    zone->setEaxPreset(name);
                                }
							}
						}
					}
					else
					{
						LOG_ERROR(Logger::SCRIPT, "Zone named '"+name+"' could not be processes.");
					}
				}
				else
				{
					LOG_ERROR(Logger::SCRIPT, "<zone> element must have attribute 'name'.");
				}
			}
		}

        ZoneManager::getSingleton().update();
		return true;
	}
Ejemplo n.º 22
0
char *wb_nrep::nameName(const char *n, int ntype, char *res)
{
  static char result[512];
  int colon_added = 0;

  if ( !res)
    res = result;
  if ( ntype & cdh_mName_volume && ntype & cdh_mName_object)
    ntype |= cdh_mName_path;
  if ( ntype & cdh_mName_path && ntype & cdh_mName_attribute)
    ntype |= cdh_mName_object;
  if ( ntype & cdh_mName_volume && ntype & cdh_mName_attribute)
    ntype = ntype | cdh_mName_path | cdh_mName_object;
  strcpy( res, "");

  if ( ntype & cdh_mName_idString) {
#if 0
    if ( ntype & cdh_mName_volume) printf( "wname: volume\n");
    if ( ntype & cdh_mName_object) printf( "wname: object\n");
    if ( ntype & cdh_mName_attribute) printf( "wname: attribute\n");
#endif
    if ( !(ntype & cdh_mName_attribute)) {
      if ( ntype & cdh_mName_volume && !(ntype & cdh_mName_object))
        strcat( res, "_V");
      else if ( !(ntype & cdh_mName_volume))
        strcat( res, "_X");
      else
        strcat( res, "_O");
    }
    else
      strcat( res, "_A");
  }
  if ( ntype & cdh_mName_volume)
    volumeName( n, res + strlen(res));
  else if ( ntype & cdh_mName_ref)
    volumeName( n, res + strlen(res));
  if ( ntype & cdh_mName_path) {
    if ( ntype & cdh_mName_volume && hasVolume()) {
      strcat( res, ":");
      colon_added = 1;
    }
    pathName( n, res + strlen(res));
  }
  if ( ntype & cdh_mName_object) {
    if ( ntype & cdh_mName_path && hasPath())
      strcat( res, "-");
    else if ( ntype & cdh_mName_volume && !hasPath() && hasVolume() && !colon_added)
      strcat( res, ":");
    objectName( n, res + strlen(res));
  }
  if ( ntype & cdh_mName_attribute && hasAttribute()) {
    if ( !m_hasSuper || m_shadowed || ntype & cdh_mName_trueAttr) {
      strcat( res, ".");
      strcat( res, n + attr[0].offs);
    }
    else {
      for ( int i = 0; i < num_attr; i++) {
	if ( !attr[i].isSuper) {
	  strcat( res, ".");
	  int l = strlen(res);
	  strncat( res, n + attr[i].offs, attr[i].len);
	  if ( attr[i].index != -1)
	    sprintf( &res[ l + attr[i].len], "[%d]", attr[i].index);
	  else
	  res[ l + attr[i].len] = 0;
	}
      }
    }
  }
  return res;
}
Ejemplo n.º 23
0
bool MaintainingReader<TokenLookupClass, LookupKey>::hasAttribute(const QString &localName) const
{
    return hasAttribute(QString(), localName);
}
PropertyEntry XmlPropertyReader::processProperty(XERCES_CPP_NAMESPACE::DOMElement* domElem) const
{
    if (!hasAttribute(domElem, "type"))
    {
        return std::make_pair("", Property(0));
    }

    Ogre::String key = "";
	if (hasAttribute(domElem, "name"))
	{
		key = getAttributeValueAsStdString(domElem, "name");
	}
	Ogre::String type = getAttributeValueAsStdString(domElem, "type");
    CeGuiString value = "";
    if (hasAttribute(domElem, "data"))
    {
        value = getAttributeValueAsString(domElem, "data");
    }

    Property prop;
    if (type == "STRING")
    {
        prop = Property(value);
    }
    else if (type == "INT")
    {
        const int intVal = CEGUI::PropertyHelper::stringToInt(value);
        prop = Property(intVal);
    }
    else if (type == "REAL" || type == "FLOAT")
    {
        const Ogre::Real realVal = CEGUI::PropertyHelper::stringToFloat(value);
        prop = Property(realVal);
    }
    else if (type == "VECTOR3")
    {
        CeGuiString::size_type comma1 = value.find(",");
        CeGuiString::size_type comma2 = value.find(",", comma1 + 1);

        Ogre::Vector3 vec(Ogre::Vector3::ZERO);
        if (comma1 != CeGuiString::npos && comma2 != CeGuiString::npos)
        {
            vec.x = CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1));
            vec.y = CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1));
            vec.z = CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1));
        }
        prop = Property(vec);
    }
    else if (type == "QUATERNION")
    {
        CeGuiString::size_type comma1 = value.find(",");
        CeGuiString::size_type comma2 = value.find(",", comma1 + 1);
        CeGuiString::size_type comma3 = value.find(",", comma2 + 1);

        Ogre::Quaternion quat(Ogre::Quaternion::IDENTITY);
        if (comma1 != CeGuiString::npos 
            && comma2 != CeGuiString::npos 
            && comma3 != CeGuiString::npos)
        {
            quat.w = CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1));
            quat.x = CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1));
            quat.y = CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1, comma3 - comma2 - 1));
            quat.z = CEGUI::PropertyHelper::stringToFloat(value.substr(comma3 + 1));
        }
        else if (comma1 != CeGuiString::npos 
            && comma2 != CeGuiString::npos 
            && comma3 == CeGuiString::npos)
        {
            Quaternion rotX, rotY, rotZ;

            rotX.FromAngleAxis(
			    Ogre::Degree(CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1))), 
			    Ogre::Vector3::UNIT_X);
            rotY.FromAngleAxis(
			    Ogre::Degree(CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1))), 
			    Ogre::Vector3::UNIT_Y);
            rotZ.FromAngleAxis(
			    Ogre::Degree(CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1))), 
			    Ogre::Vector3::UNIT_Z);

            quat = rotX * rotY * rotZ;
        }
        prop = Property(quat);
    }
    else if (type == "BOOL")
    {
        const bool boolVal = CEGUI::PropertyHelper::stringToBool(value);
        prop = Property(boolVal);
    }
	else if (type == "ARRAY")
	{
		std::vector<Property> vecVal;
		for (DOMNode* curChild  = domElem->getFirstChild(); curChild != NULL;
			curChild = curChild->getNextSibling())
		{
			if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
			{
				PropertyEntry entry = processProperty(static_cast<DOMElement*>(curChild));
				vecVal.push_back(entry.second);
			}
		}
		prop = Property(vecVal);
	}
	else if (type == "INTPAIR")
    {
        CeGuiString::size_type comma1 = value.find(",");

		std::pair<int,int> intpairVal = std::make_pair(0, 0);
        if (comma1 != CeGuiString::npos)
        {
			intpairVal = std::make_pair(
				CEGUI::PropertyHelper::stringToInt(value.substr(0, comma1)),
				CEGUI::PropertyHelper::stringToInt(value.substr(comma1 + 1)));
        }
        prop = Property(intpairVal);
    }
    else if (type == "INTTRIPLE")
    {
        CeGuiString::size_type comma1 = value.find(",");
        CeGuiString::size_type comma2 = value.find(",", comma1 + 1);

        Tripel<int> intTripel(0,0,0);
        if (comma1 != CeGuiString::npos && comma2 != CeGuiString::npos)
        {
            intTripel.first = CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1));
            intTripel.second = CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1));
            intTripel.third = CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1));
        }
        prop = Property(intTripel);
    }
	else if (type == "MAP")
	{
		PropertyMap mapVal;
		for (DOMNode* curChild  = domElem->getFirstChild(); curChild != NULL;
			curChild = curChild->getNextSibling())
		{
			if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
			{
				DOMElement* curElem = static_cast<DOMElement*>(curChild);
				CeGuiString key = getAttributeValueAsString(curElem, "name");
				PropertyEntry entry = processProperty(curElem);
				mapVal[key] = entry.second;
			}
		}
		prop = Property(mapVal);
	}

    return std::make_pair(key, prop);
}
Ejemplo n.º 25
0
bool SVGScriptElement::hasSourceAttribute() const
{
    return hasAttribute(XLinkNames::hrefAttr);
}
Ejemplo n.º 26
0
bool PANEElement::hasDesiredWidth() {
	return hasAttribute( AttrNameWidth );
}
Ejemplo n.º 27
0
	void XmlSettingsDialog::ParseEntity (const QDomElement& entity, QWidget *baseWidget)
	{
		QDomElement item = entity.firstChildElement ("item");
		while (!item.isNull ())
		{
			ParseItem (item, baseWidget);
			item = item.nextSiblingElement ("item");
		}

		auto gbox = entity.firstChildElement ("groupbox");
		while (!gbox.isNull ())
		{
			const auto box = new QGroupBox (GetLabel (gbox));
			box->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
			const auto groupLayout = new QGridLayout ();
			groupLayout->setContentsMargins (2, 2, 2, 2);
			box->setLayout (groupLayout);

			ParseEntity (gbox, box);

			const auto lay = qobject_cast<QGridLayout*> (baseWidget->layout ());
			lay->addWidget (box, lay->rowCount (), 0, 1, 2);

			gbox = gbox.nextSiblingElement ("groupbox");
		}

		auto scroll = entity.firstChildElement ("scrollarea");
		while (!scroll.isNull ())
		{
			const auto area = new QScrollArea ();
			if (scroll.hasAttribute ("horizontalScroll"))
			{
				const auto& attr = scroll.attribute ("horizontalScroll");
				if (attr == "on")
					area->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
				else if (attr == "off")
					area->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
			}
			if (scroll.hasAttribute ("verticalScroll"))
			{
				const auto& attr = scroll.attribute ("verticalScroll");
				if (attr == "on")
					area->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
				else if (attr == "off")
					area->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
			}

			area->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);

			const auto areaWidget = new QFrame;
			areaWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
			const auto areaLayout = new QGridLayout;
			areaWidget->setLayout (areaLayout);
			ParseEntity (scroll, areaWidget);
			area->setWidget (areaWidget);
			area->setWidgetResizable (true);
			areaWidget->show ();

			const auto lay = qobject_cast<QGridLayout*> (baseWidget->layout ());
			const auto thisRow = lay->rowCount ();
			lay->addWidget (area, thisRow, 0, 1, 2);
			lay->setRowStretch (thisRow, 1);

			scroll = scroll.nextSiblingElement ("scrollarea");
		}

		auto tab = entity.firstChildElement ("tab");
		if (!tab.isNull ())
		{
			const auto tabs = new QTabWidget;
			const auto lay = qobject_cast<QGridLayout*> (baseWidget->layout ());
			lay->addWidget (tabs, lay->rowCount (), 0, 1, 2);
			while (!tab.isNull ())
			{
				const auto page = new QWidget;
				const auto widgetLay = new QGridLayout;
				widgetLay->setContentsMargins (0, 0, 0, 0);
				page->setLayout (widgetLay);
				tabs->addTab (page, GetLabel (tab));
				ParseEntity (tab, page);
				tab = tab.nextSiblingElement ("tab");

				widgetLay->addItem (new QSpacerItem (0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding),
						widgetLay->rowCount (), 0, 1, 1);
			}
		}
	}
Ejemplo n.º 28
0
double HTMLProgressElement::position() const
{
    if (!hasAttribute(valueAttr))
        return -1;
    return value() / max();
}
Ejemplo n.º 29
0
bool PANEElement::hasDesiredHeight() {
	return hasAttribute( AttrNameHeight );
}
PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)
{
    FilterEffect* input1 = filterBuilder->getEffectById(in1());

    if (!input1)
        return 0;

    int orderXValue = orderX();
    int orderYValue = orderY();
    if (!hasAttribute(SVGNames::orderAttr)) {
        orderXValue = 3;
        orderYValue = 3;
    }
    // Spec says order must be > 0. Bail if it is not.
    if (orderXValue < 1 || orderYValue < 1)
        return 0;
    SVGNumberList& kernelMatrix = this->kernelMatrix();
    int kernelMatrixSize = kernelMatrix.size();
    // The spec says this is a requirement, and should bail out if fails
    if (orderXValue * orderYValue != kernelMatrixSize)
        return 0;

    int targetXValue = targetX();
    int targetYValue = targetY();
    if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue >= orderXValue))
        return 0;
    // The spec says the default value is: targetX = floor ( orderX / 2 ))
    if (!hasAttribute(SVGNames::targetXAttr))
        targetXValue = static_cast<int>(floorf(orderXValue / 2));
    if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue >= orderYValue))
        return 0;
    // The spec says the default value is: targetY = floor ( orderY / 2 ))
    if (!hasAttribute(SVGNames::targetYAttr))
        targetYValue = static_cast<int>(floorf(orderYValue / 2));

    // Spec says default kernelUnitLength is 1.0, and a specified length cannot be 0.
    int kernelUnitLengthXValue = kernelUnitLengthX();
    int kernelUnitLengthYValue = kernelUnitLengthY();
    if (!hasAttribute(SVGNames::kernelUnitLengthAttr)) {
        kernelUnitLengthXValue = 1;
        kernelUnitLengthYValue = 1;
    }
    if (kernelUnitLengthXValue <= 0 || kernelUnitLengthYValue <= 0)
        return 0;

    float divisorValue = divisor();
    if (hasAttribute(SVGNames::divisorAttr) && !divisorValue)
        return 0;
    if (!hasAttribute(SVGNames::divisorAttr)) {
        for (int i = 0; i < kernelMatrixSize; ++i)
            divisorValue += kernelMatrix.at(i);
        if (!divisorValue)
            divisorValue = 1;
    }

    RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter,
                    IntSize(orderXValue, orderYValue), divisorValue,
                    bias(), IntPoint(targetXValue, targetYValue), edgeMode(),
                    FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue), preserveAlpha(), kernelMatrix);
    effect->inputEffects().append(input1);
    return effect.release();
}