Index: src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser.cpp
===================================================================
--- src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser.cpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
+++ src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser.cpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
@@ -0,0 +1,215 @@
+/*
+ * QSeisXMLParser.cpp
+ *
+ *  Created on: Apr 5, 2011
+ *      Author: bierbach
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <QtCore/QDir>
+#include <QtCore/QList>
+
+#include "UIElements/Views/Qt4/Plotting/QSeisPageRegistry.hpp"
+#include "UIElements/Views/Qt4/Plotting/QSeisPlotPage.hpp"
+
+#include "QSeisXMLParser.hpp"
+
+// property tree uses alignment new
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/xml_parser.hpp>
+
+// have this after(!) all Qt includes
+#include "CodePatterns/MemDebug.hpp"
+
+#include <boost/foreach.hpp>
+#include <string>
+#include <set>
+#include <exception>
+#include <iostream>
+#include <sstream>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "CodePatterns/Singleton_impl.hpp"
+
+/** Constructor for QSeisXMLParser.
+ *
+ */
+QSeisXMLParser::QSeisXMLParser()
+{
+	unitmap["mass"] = "mass";
+	unitmap["length"] = "length";
+	unitmap["time"] = "time";
+	unitmap["current"] = "current";
+	unitmap["temperature"] = "temperature";
+	unitnames.push_back("mass");
+	unitnames.push_back("length");
+	unitnames.push_back("time");
+	unitnames.push_back("current");
+	unitnames.push_back("temperature");
+}
+
+/** Destructor for QSeisXMLParser.
+ *
+ */
+QSeisXMLParser::~QSeisXMLParser()
+{
+  // remove all types
+  for(std::vector<plottype*>::iterator it=types.begin();it!=types.end();++it) {
+    delete *it;
+  }
+  types.clear();
+  // remove all curves
+  for(std::vector<plotcurve*>::iterator it=curves.begin();it!=curves.end();++it) {
+		delete *it;
+	}
+	curves.clear();
+}
+
+/** Returns list of desired files.
+ *
+ * Desired files are all listed in the parsed .xml file, with prefix full
+ * file names are constructed and returned.
+ *
+ * @param prefix prefix of filenames
+ * @return list of all desired files
+ */
+QStringList QSeisXMLParser::getFiles(QString prefix) {
+	    QStringList file_names;
+	    qDebug("List of desired curves:");
+	    for(size_t i=0;i<(curves.size());i++) {
+	      QString name = prefix+QString(".")+QString((*curves[i]).get_suffix().c_str());
+	      qDebug("\t%s", name.toAscii().constData());
+	    	file_names.append(name);
+	    }
+	    return file_names;
+}
+
+/** Loads an .xml file.
+ *
+ *  Loads the XML file, then parses types and curves contained.
+ *
+ * @param file file name
+ */
+void QSeisXMLParser::load(std::istream& file) {
+	curves_by_suffix.clear();
+	using boost::property_tree::ptree;
+	ptree pt;
+	qDebug("Parsing XML file ... ");
+	read_xml(file,pt);
+	qDebug("Parsing types ... ");
+	BOOST_FOREACH(ptree::value_type &i,pt.get_child("seismolo.plottypes")) {
+		std::string name=i.second.get<std::string>("name");
+		std::string style=i.second.get<std::string>("style");
+		std::string xlabel=i.second.get<std::string>("xlabel");
+		std::string ylabel=i.second.get<std::string>("ylabel");
+		std::vector<int> xunits;
+		xunits.push_back(i.second.get<int>("xunits.mass"));
+		xunits.push_back(i.second.get<int>("xunits.length"));
+		xunits.push_back(i.second.get<int>("xunits.time"));
+		xunits.push_back(i.second.get<int>("xunits.current"));
+		xunits.push_back(i.second.get<int>("xunits.temperature"));
+		std::vector<int> yunits;
+		yunits.push_back(i.second.get<int>("yunits.mass"));
+		yunits.push_back(i.second.get<int>("yunits.length"));
+		yunits.push_back(i.second.get<int>("yunits.time"));
+		yunits.push_back(i.second.get<int>("yunits.current"));
+		yunits.push_back(i.second.get<int>("yunits.temperature"));
+		plottype * tmp = new plottype(name,xlabel,ylabel,style,xunits,yunits, unitnames,unitmap);
+		types.push_back(tmp);
+		qDebug("\ttype: %s, %p", name.c_str(), types.back());
+		types_by_name.insert(std::make_pair(types.back()->get_name(),types.back()));
+	}
+	qDebug("Parsing curves ... ");
+	BOOST_FOREACH(ptree::value_type &i,pt.get_child("seismolo.plotcurves")) {
+		std::string name=i.second.get<std::string>("name");
+		std::string type=i.second.get<std::string>("type");
+		std::string suffix=i.second.get<std::string>("suffix");
+		std::string color=i.second.get<std::string>("color");
+		int column=i.second.get<int>("column");
+		// check that type exists
+		ASSERT(types_by_name.count(type),
+				"QSeisXMLParser::load() - type "+type+" for curve "+name+" not found.");
+
+		std::stringstream tmp;
+		tmp<<column;
+		if (suffix[0] == '.') // erase leading dot if present
+		  suffix.erase(suffix.begin());
+		plotcurve* curv=new plotcurve(name,type,suffix,color,column);
+		curves.push_back(curv);
+    qDebug("\tcurve: %s", curves.back()->get_name().c_str());
+		curves_suff.insert(std::make_pair(suffix+tmp.str(),curv));
+		curves_by_suffix.insert(std::make_pair(suffix+tmp.str(),type));
+		ASSERT(curves_by_suffix.size()!=0,"curves by suffix is empty!");
+	}
+}
+
+/** Creates plot page for each \a types.
+ *
+ */
+void QSeisXMLParser::createPlotPages() {
+	for(size_t i=0;i<types.size();i++) {
+		const std::string name=types[i]->get_name();
+		QSeisPageRegistry::getInstance().getByName(name);
+	}
+}
+
+/** Associates each curve in \a curves with its plot page.
+ *
+ */
+void QSeisXMLParser::associateCurves() {
+	for(quint32 i=0;i<(curves.size());i++) {
+		std::string temp=(*curves[i]).get_type();
+		int u=(*curves[i]).get_column();
+		std::stringstream ostrs;
+		QString watchPath; //=QSeisFileRegistry::getInstance().getWatchPath();
+		ostrs << prefix.toStdString() << (*curves[i]).get_suffix() << u;
+		QSeisPlotPage *instance = QSeisPageRegistry::getInstance().getByName(temp);
+		instance->addCurve(ostrs.str());
+	}
+}
+
+/** Getter for type for a given curve.
+ *
+ * @param name name of curve
+ * @return type of curve, i.e. the plot page
+ */
+QString QSeisXMLParser::getTypeOfName(const QString &name) {
+	std::string suffix(name.toStdString());
+	int found=suffix.find(".");
+	ASSERT(found!=-1,"Name of curve " + suffix + " is invalid.");
+	suffix=suffix.substr(found+1,suffix.size()-(found+1));
+
+//	Debugausgabe
+	std::map<std::string,std::string>::iterator m;
+	for(m=curves_by_suffix.begin();m!=curves_by_suffix.end();++m) {
+		std::cerr << m->first << "----" << m->second << std::endl;
+	}
+	if (curves_by_suffix.count(suffix))
+		return QString(curves_by_suffix[suffix].c_str());
+	else
+		return QString();
+}
+
+std::string QSeisXMLParser::getCurveColor(std::string suff_col) {
+	if(curves_suff.count(suff_col)!=0) {
+		return curves_suff[suff_col]->get_color();
+	}
+	else return std::string();
+}
+
+plottype* QSeisXMLParser::return_plottype_by_name(std::string name) {
+	if(types_by_name.count(name)!=0) {
+		return types_by_name[name];
+	} else return NULL;
+}
+
+void QSeisXMLParser::set_units(const std::vector<std::string>& unitnames_xml,const std::map<std::string,std::string>& unitmap_xml) {
+	unitmap=unitmap_xml;unitnames=unitnames_xml;
+}
+
+CONSTRUCT_SINGLETON(QSeisXMLParser)
Index: src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser.hpp
===================================================================
--- src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser.hpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
+++ src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser.hpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
@@ -0,0 +1,60 @@
+/*
+ * QSeisXMLParser.hpp
+ *
+ *  Created on: Apr 5, 2011
+ *      Author: bierbach
+ */
+
+#ifndef QSEISXMLPARSER_HPP_
+#define QSEISXMLPARSER_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <QtCore/QStringList>
+#include <QtCore/QString>
+#include <QtCore/QFileInfo>
+
+#include "UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.hpp"
+#include "UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plotcurve.hpp"
+
+#include <vector>
+#include <map>
+#include <iosfwd>
+#include <utility>
+
+#include "CodePatterns/Singleton.hpp"
+
+class QSeisXMLParser : public Singleton<QSeisXMLParser> {
+	friend class Singleton<QSeisXMLParser>;
+	friend class plotcurve;
+	friend class XMLParserTest;
+
+	public:
+	QStringList getFiles(QString);
+	void load(std::istream&);
+	void createPlotPages();
+	void associateCurves();
+	QString getTypeOfName(const QString &name);
+	std::string getCurveColor(std::string);
+	plottype* return_plottype_by_name(std::string name);
+	void set_units(const std::vector<std::string>&,const std::map<std::string,std::string>&);
+
+	protected:
+	QSeisXMLParser();
+	~QSeisXMLParser();
+
+	private:
+	QString prefix;
+	std::map<std::string, std::string> unitmap;
+	std::vector<std::string> unitnames;
+	std::vector<plottype*> types;
+	std::map<std::string,plottype*> types_by_name;
+	std::vector<plotcurve*> curves;
+	std::map<std::string,plotcurve*> curves_suff;
+	std::map<std::string,std::string> curves_by_suffix;
+};
+
+#endif /* QSEISXMLPARSER_HPP_ */
Index: src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plotcurve.cpp
===================================================================
--- src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plotcurve.cpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
+++ src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plotcurve.cpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
@@ -0,0 +1,62 @@
+/*
+ * QSeisXMLParser_plotcurve.cpp
+ *
+ *  Created on: Apr 5, 2011
+ *      Author: bierbach
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// have this after(!) all Qt includes
+#include "CodePatterns/MemDebug.hpp"
+
+#include <iostream>
+#include "QSeisXMLParser_plotcurve.hpp"
+
+plotcurve::plotcurve(std::string name_pc,std::string type_pc,std::string suffix_pc,std::string color_pc,int column_pc) :
+	name(name_pc),type(type_pc),suffix(suffix_pc),color(color_pc),column(column_pc)
+	{}
+
+/** Explicit copy constructor for class plotcurve.
+ *
+ * \note is made private to prevent accidental copying of the instance.
+ *
+ * @param ref instance to copy
+ */
+plotcurve::plotcurve(const plotcurve &ref) :
+	name(ref.name),type(ref.type),suffix(ref.suffix),color(ref.color),column(ref.column)
+{
+  std::cout << "plotcurve " << &ref << " has been copied." << std::endl;
+	std::cout << ref.name << " --- " << ref.type << " --- " << ref.suffix << std::flush;
+	std::cout << " --- " << ref.color << " --- " << ref.column <<  std::endl;
+}
+
+plotcurve::~plotcurve()
+{}
+
+void plotcurve::set_values(std::string name_pc,std::string type_pc,std::string suffix_pc,int column_pc) {
+	name=name_pc;type=type_pc;suffix=suffix_pc;column=column_pc;
+}
+
+std::string plotcurve::get_name() {
+	return name;
+}
+
+std::string plotcurve::get_type() {
+	return type;
+}
+
+std::string plotcurve::get_suffix() {
+	return suffix;
+}
+
+std::string plotcurve::get_color() {
+	return color;
+}
+
+int plotcurve::get_column() {
+	return column;
+}
Index: src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plotcurve.hpp
===================================================================
--- src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plotcurve.hpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
+++ src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plotcurve.hpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
@@ -0,0 +1,42 @@
+/*
+ * QSeisXMLParser_plotcurve.hpp
+ *
+ *  Created on: Apr 5, 2011
+ *      Author: bierbach
+ */
+
+#ifndef QSEISXMLPARSER_PLOTCURVE_HPP_
+#define QSEISXMLPARSER_PLOTCURVE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+
+class plottype;
+
+class plotcurve{
+public:
+	plotcurve(std::string name_pc,std::string type_pc,std::string suffix_pc,std::string color_pc,int column_pc);
+	~plotcurve();
+	void set_values(std::string,std::string,std::string,int);
+	std::string get_name();
+	std::string get_type();
+	std::string get_suffix();
+	std::string get_color();
+	int get_column();
+
+private:
+	//?> name of the plot
+	std::string name;
+	std::string type;
+	std::string suffix;
+	std::string color;
+	int column;
+
+  plotcurve(const plotcurve &ref);
+};
+
+#endif /* QSEISXMLPARSER_PLOTCURVE_HPP_ */
Index: src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.cpp
===================================================================
--- src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.cpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
+++ src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.cpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
@@ -0,0 +1,187 @@
+/*
+ * QSeisXMLParser_plottype.cpp
+ *
+ *  Created on: Apr 5, 2011
+ *      Author: bierbach
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// have this after(!) all Qt includes
+#include "CodePatterns/MemDebug.hpp"
+
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/toString.hpp"
+
+#include "QSeisXMLParser_plottype.hpp"
+
+
+/** Constructor for class plottype.
+ *
+ * @param name_pt name
+ * @param xlabel_pt label for X axis
+ * @param ylabel_pt label for Y axis
+ * @param style_pt style of plot
+ * @param xunits_pt unit vector for x axis
+ * @param yunits_pt unit vector for y axis
+ * @param unitnames_pt (unit) names for each unit vector coefficient
+ * @param unitmap_pt mapping to internal unit names
+ */
+plottype::plottype(
+    std::string name_pt,
+    std::string xlabel_pt,
+    std::string ylabel_pt,
+    std::string style_pt,
+    const UnitsVector &xunits_pt,
+    const UnitsVector &yunits_pt,
+    const std::vector<std::string> &unitnames_pt,
+    const std::map<std::string,std::string> &unitmap_pt) :
+  name(name_pt),
+  style(style_pt),
+  unitnames(unitnames_pt),
+  unitmap(unitmap_pt)
+{
+  labels.insert(make_pair(X, xlabel_pt));
+  labels.insert(make_pair(Y, ylabel_pt));
+  units.insert(make_pair(X, xunits_pt));
+  units.insert(make_pair(Y, yunits_pt));
+//  std::cout << "Labels: " << labels << std::endl;
+//  std::cout << "Units: " << units << std::endl;
+}
+
+/** Explicit copy constructor for class plottype.
+ *
+ * \note is made private to prevent accidental copying of the instance.
+ *
+ * @param ref instance to copy values from
+ */
+plottype::plottype(const plottype &ref) :
+    name(ref.name),
+    style(ref.style),
+    units(ref.units),
+    labels(ref.labels),
+    unitnames(ref.unitnames),
+    unitmap(ref.unitmap)
+{
+  std::cout << "plottype " << &ref << " has been copied." << std::endl;
+}
+
+/** Destructor for plottype.
+ *
+ */
+plottype::~plottype()
+{
+  labels.clear();
+  units.clear();
+  unitnames.clear();
+  unitmap.clear();
+}
+
+/** (Re)-set all values for this plottype instance.
+ *
+ * @param name_pt name
+ * @param xlabel_pt label for X axis
+ * @param ylabel_pt label for Y axis
+ * @param style_pt style of plot
+ * @param xunits_pt unit vector for x axis
+ * @param yunits_pt unit vector for y axis
+ * @param unitnames_pt (unit) names for each unit vector coefficient
+ * @param unitmap_pt mapping to internal unit names
+ */
+void plottype::set_values(
+		std::string name_pt,
+		std::string xlabel_pt,
+		std::string ylabel_pt,
+		std::string style_pt,
+		const std::vector<int> &xunits_pt,
+		const std::vector<int> &yunits_pt,
+		const std::vector<std::string> &unitnames_pt,
+		const std::map<std::string, std::string> &unitmap_pt)
+{
+  name = name_pt;
+  style = style_pt;
+  unitnames = unitnames_pt;
+  unitmap = unitmap_pt;
+  labels[X] = xlabel_pt;
+  labels[Y] = ylabel_pt;
+  units[X] = xunits_pt;
+  units[Y] = yunits_pt;
+}
+
+/** Comparison operator for two plottype's.
+ *
+ * We just compare the name against the given one.
+ *
+ * @param type name to compare against.
+ * @return true - name equals \a type, false - not
+ */
+bool plottype::operator==(std::string type)
+{
+ if(type==name) return true;
+ else return false;
+}
+
+/** Getter for name.
+ *
+ * @return \a name
+ */
+std::string plottype::get_name() const
+{
+	return name;
+}
+
+/** Getter for label.
+ *
+ * @param _axis label for which axis
+ * @return label description for the desired \a _axis
+ */
+std::string plottype::get_label(const enum axis _axis) const
+{
+  LabelPerAxis::const_iterator it = labels.find(_axis);
+  ASSERT(it != labels.end(),
+      "plottype::get_label() - unknown axis type "+toString(_axis)+".");
+	return it->second;
+}
+
+/** Getter for style string.
+ *
+ * @return \a style
+ */
+std::string plottype::get_style() const
+{
+	return style;
+}
+
+/** Returns a string with the unit for the given \a _axis.
+ *
+ * \note Because it is declared as a const member function we cannot use
+ *       operator[] on the maps, as this function is not const (it inserts
+ *       if the key is missing in the map). Hence, we have to operator with
+ *       find and const_iterator's.
+ *
+ * @param _axis
+ * @return string containing the full unit
+ */
+std::string plottype::get_units(const enum axis _axis) const
+{
+	std::string result;
+	UnitPerAxis::const_iterator UnitsArray = units.find(_axis);
+	ASSERT(UnitsArray != units.end(),
+	    "plottype::get_units() - unknown axis type "+toString(_axis)+".");
+	bool firstflag = true;
+	for (size_t it = 0; it < (UnitsArray->second).size(); ++it) {
+	  UnitNamesMap::const_iterator unitname = unitmap.find(unitnames[it]);
+	  ASSERT(unitname != unitmap.end(),
+	      "plottype::get_units() - unknown unit name "+unitnames[it]+".");
+		if(!(UnitsArray->second).at(it))
+		  continue;
+		result += ((!firstflag) ? std::string(" ") : std::string("")) + (unitname->second);
+		if ((UnitsArray->second)[it] != 1)
+		  result += std::string("^") + toString((UnitsArray->second)[it]);
+		firstflag = false;
+	}
+	return result;
+}
Index: src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.hpp
===================================================================
--- src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.hpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
+++ src/UIElements/Views/Qt4/Plotting/XMLParser/QSeisXMLParser_plottype.hpp	(revision 35302b57b5c489d9535c30527e3c33675ec2acb6)
@@ -0,0 +1,57 @@
+/*
+ * QSeisXMLParser_plottype.hpp
+ *
+ *  Created on: Apr 5, 2011
+ *      Author: bierbach
+ */
+
+#ifndef QSEISXMLPARSER_PLOTTYPE_HPP_
+#define QSEISXMLPARSER_PLOTTYPE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+#include <vector>
+#include <map>
+#include <sstream>
+
+
+class plottype{
+	public:
+  enum axis
+  {
+    X,
+    Y
+  };
+
+  plottype(std::string name_pt,std::string xlabel_pt,std::string ylabel_pt,std::string style_pt,const std::vector<int> &xunits_pt,const std::vector<int> &yunits_pt, const std::vector<std::string> &unitnames_pt,const std::map<std::string,std::string> &unitmap_pt);
+  ~plottype();
+
+	void set_values(std::string,std::string,std::string,std::string,const std::vector<int>&,const std::vector<int>&,const std::vector<std::string>&,const std::map<std::string,std::string>&);
+	bool operator==(std::string);
+	std::string get_name() const;
+	std::string get_label(const enum axis _axis) const;
+	std::string get_style() const;
+	std::string get_units(const enum axis _axis) const;
+
+	private:
+  typedef std::vector<int> UnitsVector;
+	typedef std::map<enum axis, std::string > LabelPerAxis;
+	typedef std::map<enum axis, UnitsVector > UnitPerAxis;
+	typedef std::map<std::string,std::string> UnitNamesMap;
+	typedef std::vector<std::string> UnitNamesVector;
+
+	std::string name,style;
+	UnitPerAxis units;
+	LabelPerAxis labels;
+	UnitNamesVector unitnames;
+	UnitNamesMap unitmap;
+
+	private:
+	plottype(const plottype& ref);
+};
+
+#endif /* QSEISXMLPARSER_PLOTTYPE_HPP_ */
