| 26 | } |
| 27 | |
| 28 | void plotXMLVisitor::startElement (const char * name, const XMLAttributes &atts) |
| 29 | { |
| 30 | current_element = name; |
| 31 | |
| 32 | // defaults |
| 33 | plotType = lines; |
| 34 | |
| 35 | for (int i=0; i<atts.size();i++) { |
| 36 | string thisAttribute = atts.getName(i); |
| 37 | string thisValue = atts.getValue(i); |
| 38 | if (thisAttribute == string("axis")) { |
| 39 | if (thisValue == string("x")) axis = eX; |
| 40 | else if (thisValue == string("y2")) axis = eY2; |
| 41 | else axis = eY; |
| 42 | } else if (thisAttribute == string("type")) { |
| 43 | if (thisValue == string("lines")) { |
| 44 | plotType = lines; |
| 45 | } else if (thisValue == string("points")) { |
| 46 | plotType = points; |
| 47 | } else { |
| 48 | cerr << endl << "Plot type " << thisValue << " is not valid. Using lines type for default." << endl; |
| 49 | plotType = lines; |
| 50 | } |
| 51 | } else { |
| 52 | if (string(name) == "plotset") break; |
| 53 | cerr << "Unknown attribute " << thisAttribute << " encountered in element, " << name << endl; |
| 54 | exit (-1); |
| 55 | } |
| 56 | if (i == 1) { |
| 57 | cerr << "Too many attributes. Offending attribute (item:" << i << ") is " << thisAttribute << endl; |
| 58 | exit (-1); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if (!first_element_read) { |
| 63 | if (current_element != string("plotset")) { |
| 64 | cerr << endl << " This is not a valid plotset description (" << current_element << ")" << endl; |
| 65 | exit (-1); |
| 66 | } else { |
| 67 | first_element_read = true; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | if (current_element == "page") { |
| 72 | vPages.push_back(Page()); |
| 73 | inPage = true; |
| 74 | } else if (current_element == "plot") { |
| 75 | if (!inPage) { |
| 76 | vPlots.push_back(Plots()); |
| 77 | vPlots.back().plotType = plotType; |
| 78 | } else { |
| 79 | vPages.back().vPlots.push_back(Plots()); |
| 80 | vPages.back().vPlots.back().plotType = plotType; |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | void plotXMLVisitor::endElement (const char * name) |