Exemple #1
0
void XmlLoader::readPicture(QDomElement const &picture)
{
    QDomNodeList pictureAttributes = picture.childNodes();

    for (unsigned i = 0; i < pictureAttributes.length(); ++i) {
        QDomElement type = pictureAttributes.at(i).toElement();
        if (type.tagName() == "line")
            readLine(type);
        else if (type.tagName() == "ellipse")
            readEllipse(type);
        else if (type.tagName() == "arc")
            readArch(type);
        else if (type.tagName() == "rectangle")
            readRectangle(type);
        else if (type.tagName() == "stylus")
            readStylus(type);
        else if (type.tagName() == "path")
            readPath(type);
        else if (type.tagName() == "curve")
            readCurve(type);
        else if (type.tagName() == "text")
            readText(type);
        else
            qDebug() << "Incorrect picture tag";
    }
}
Exemple #2
0
// ---
void QGAMES::ObjectBuilder::preLoad ()
{
	if (_alreadyLoaded)
		return;

	TiXmlDocument doc (_fileName.c_str ());
	int e = doc.LoadFile ();
	assert (e); // Is it a valid doc?
	TiXmlElement* rootElement = doc.RootElement ();
	assert (rootElement); // One element minimum...

	// Reading all elements...
	for (TiXmlElement* groupElement = rootElement -> FirstChildElement ();
		groupElement != NULL; groupElement = groupElement -> NextSiblingElement ())
	{
		QGAMES::Object* obj = NULL;
		if (strcmp (groupElement -> Value (), __QGAMES_IMAGEBLOCK__) == 0)
			obj = readImage (groupElement); // An image...
		if (strcmp (groupElement -> Value (), __QGAMES_BACKGROUNDBLOCK__) == 0)
			obj = readBackground (groupElement); // A background...
		if (strcmp (groupElement -> Value (), __QGAMES_POLYLINEBLOCK__) == 0)
			obj = readGraphicalPolyline (groupElement); // A Polyline...
		if (strcmp (groupElement -> Value (), __QGAMES_POLYGONBLOCK__) == 0)
			obj = readGraphicalPolygon (groupElement); // A Polygon...
		if (strcmp (groupElement -> Value (), __QGAMES_ELLIPSEBLOCK__) == 0)
			obj = readEllipse (groupElement); // An ellipse...
		if (strcmp (groupElement -> Value (), __QGAMES_COMPOSITEBLOCK__) == 0)
			obj = readComposite (groupElement); // A composite made up of all of them...
		assert (obj != NULL);
		_objects.insert (std::map <int, QGAMES::Object*>::value_type (obj -> id (), obj));
	}

	_alreadyLoaded = true;
}