9 QString qpointToString (const QPoint &p)
11 return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
14 ostream &operator<< (ostream &stream, QPoint const &p)
16 stream << "("<<p.x()<<","<<p.y()<<")";
20 float getAngle(const QPoint &p)
22 // Calculate angle of vector to y-axis
32 return (float)(M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
35 return (float)( 2*M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
37 return (float)( - atan ( (double)(p.x()) / (double)(p.y()) ) );
41 QPoint normalise(const QPoint &p)
43 // Calculate normalised position (fixed length)
71 return QPoint ((int) (x),(int) (y));
75 // returns masked "<" ">" "&"
76 QString quotemeta(const QString &s)
79 QRegExp rx("&(?!amp;)");
80 r.replace ( rx,"&");
82 r.replace ( rx,">");
84 r.replace ( rx,"<");
86 r.replace ( rx,""");
97 int xmlObj::actindent=0; // make instance of actindent
106 QString xmlObj::singleElement(QString s, QString at)
108 return indent() + "<" + s +" " + at +" " + "/>\n";
112 QString xmlObj::beginElement(QString s)
114 return indent() + "<" + s + ">\n";
118 QString xmlObj::beginElement(QString s, QString at)
120 return indent() + "<" + s + " " + at + ">\n";
124 QString xmlObj::endElement(QString s)
126 return indent() + "</" + s + ">\n";
130 QString xmlObj::attribut(QString at, QString val)
132 return " " + at + "=\"" + quotemeta (val) + "\"";
135 // returns <s> val </s>
136 QString xmlObj::valueElement(QString el, QString val)
138 return indent() + "<" + el + ">" + quotemeta(val) + "</" +el + ">\n";
141 // returns <s at> val </s>
142 QString xmlObj::valueElement(QString el, QString val, QString at)
144 return indent() + "<" + el + " " + at + ">" + quotemeta(val) + "</" +el + ">\n";
147 void xmlObj::incIndent()
152 void xmlObj::decIndent()
155 if (actindent<0) actindent=0;
158 QString xmlObj::indent()
162 for (i=0; i<actindent*indentwidth; i++)