Chages to ogdf/fileformats/XmlParser.h in Snapshot 2013-04-16

58 views
Skip to first unread message

101...@gmail.com

unread,
Jun 17, 2013, 2:42:38 PM6/17/13
to ogdf-sn...@googlegroups.com

Dear Sirs.

I´m using the source code version of you library from the Snapshot 2013-04-16

Because this version has the “How-tos” synchronized.

I’m using the source code of the tool gml2pic as a reference to create a GML viewer in OpenGL

I´m trying to understand how gml2pic works so I can adapt the code to generate a 3D representation of the graphs generated by OGDF

In this source code there are some references to attributes and methods of an old version of the library ogdf/fileformats/XmlParser

Where can I find documentation explaining how to transform the old code to work with the new version of the library?

Can you give me your advice about the way I chose to achieve my goal (use gml2pic as reference)?

Do you think that there is any easier way?


Please help

1010836

Carsten Gutwenger

unread,
Jun 18, 2013, 2:37:45 AM6/18/13
to ogdf-sn...@googlegroups.com
Hi 1010836,

the How-tos should also work with later snapshots, I just omitted to duplicate them for the other snapshots.

Unfortunately, gml2pic is not yet ported to the new OGDF interface. Regarding the XmlParser in OGDF, if I remember correct, it has onl ybeen renamed from DinoXmlParser to XmlParser (same for ...Scanner etc). Documentation is in the source code and should also be considered by doxygen, so it should be in the html documentation.

Does this help already? I need to look into gml2pic to adapt it to the latest OGDF changes.

Regards
4361727374656e

101...@gmail.com

unread,
Jun 18, 2013, 4:47:04 AM6/18/13
to ogdf-sn...@googlegroups.com

Hi Carsten Gutwenger

 

1.  The file DinoXmlParser has been renamed to XmlParser but in the version 2007.07 (Skura) existed 2 files.

1.1.        One named DinoXmlParser and another called XmlParser

2.  On the Snapshot 2013-04-16 there is only one file named XmlParser that corresponds to the old DinoXmlParser.

2.1.       I’m sending you 1 picture where you can compare the list of files of the 2 versions

2.1.1.        A1_Header_Files_List_Comparation.png

3.  The gml2pic project uses the old class XmlParser to parse a string that contains label attributes like size and color.

3.1.        The string content is stored in XML format, and the function extracts all the attributes to individual variables

3.2.        I’m sending you 1 picture with the code of that function

3.2.1.         A2_Function_That_Uses_Old_XmlParser_File

4.  I don’t need gml2pic to work with the new version of the OGDF library

4.1.        I only want to know if in these new OGDF version exists any class that implements the functionality of the old XmlParser class

4.2.        If not I will join the old XmlParser class with another name to my project

Many Thanks

Evaristo Figueiredo

A1_Header_Files_List_Comparation.png
A2_Function_That_Uses_Old_XmlParser_File.png

Carsten Gutwenger

unread,
Jun 19, 2013, 6:18:24 AM6/19/13
to ogdf-sn...@googlegroups.com
Hi Evaristo,

I'm currently adapting gml2pic to new the OGDF and Qt 5.

The idea of removing XmlParser and renaming DinoXmlParser to XmlParser was to replace the old parser wherever needed. It was a little work to rewrite 
labelFromString in gml2pic, but now I'm done. The changed function implementation looks now as follows:

// retrieve text and formatting info from string representation
void GMLProcessor::labelFromString(const char *attrStrQColor &myTextColorQFont &myFontint &myAlignQString &myLabel)
{
	std::istringstream is(attrStr);

	try {
		XmlParser xml(is);
		xml.createParseTree();

		QColor textColor = myTextColor;
		QFont    font    = myFont;
		int      align   = myAlign;
		QString  text;

		const XmlTagObject *root = &xml.getRootTag();
		if(root->getName() == "label")
		{
			const XmlAttributeObject *son = root->m_pFirstAttribute;
			for(; son; son = son->m_pNextAttribute)
			{
				const string &n = son->getName();

				if(n == "font") {
					font.fromString(son->getValue().c_str());

				} else if(n == "align") {
					align = stoi(son->getValue());

				} else if(n == "textColor") {
					textColor = colorFromString(son->getValue().c_str());
				}
			}

			text = QString::fromLatin1(root->getValue().c_str());
		}

		if(text.isNull()) {
			// support for old format
			myLabel = attrStr;

		} else {
			myFont     = font;
			myAlign    = align;
			myTextColor = textColor;
			myLabel    = text;
		}

	} catch(AlgorithmFailureException ex) {
		// just ignore parse error
	}
}

So to answer your questions: Yes, there is a class providing that functionality, but it needs a little rewriting as the interface is not the same.

Regards,
Carsten
Message has been deleted

101...@gmail.com

unread,
Jun 21, 2013, 12:29:51 PM6/21/13
to ogdf-sn...@googlegroups.com

Carsten

Thank you very much for your precious help

Your project is managed and supported in a really professional way

Thanks

Evaristo

Reply all
Reply to author
Forward
0 new messages