9 QString qpointToString (const QPoint &p)
11 return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
14 QString qpointfToString (const QPointF &p)
16 // FIXME check this QT4
17 return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
20 ostream &operator<< (ostream &stream, QPoint const &p)
22 stream << "("<<p.x()<<","<<p.y()<<")";
26 ostream &operator<< (ostream &stream, QPointF const &p)
28 stream << "("<<p.x()<<","<<p.y()<<")";
32 qreal getAngle(const QPointF &p)
34 // Calculate angle of vector to y-axis
44 return (qreal)(M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) );
47 return (qreal)( 2*M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) );
49 return (qreal)( - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) );
53 QPointF normalise(const QPointF &p)
55 // Calculate normalised position (fixed length)
83 return QPoint ((int) (x),(int) (y));
87 // returns masked "<" ">" "&"
88 QString quotemeta(const QString &s)
91 QRegExp rx("&(?!amp;)");
92 r.replace ( rx,"&");
94 r.replace ( rx,">");
96 r.replace ( rx,"<");
98 r.replace ( rx,""");
103 qreal max(qreal a, qreal b)
110 int xmlObj::actindent=0; // make instance of actindent
119 QString xmlObj::singleElement(QString s, QString at)
121 return indent() + "<" + s +" " + at +" " + "/>\n";
125 QString xmlObj::beginElement(QString s)
127 return indent() + "<" + s + ">\n";
131 QString xmlObj::beginElement(QString s, QString at)
133 return indent() + "<" + s + " " + at + ">\n";
137 QString xmlObj::endElement(QString s)
139 return indent() + "</" + s + ">\n";
143 QString xmlObj::attribut(QString at, QString val)
145 return " " + at + "=\"" + quotemeta (val) + "\"";
148 // returns <s> val </s>
149 QString xmlObj::valueElement(QString el, QString val)
151 return indent() + "<" + el + ">" + quotemeta(val) + "</" +el + ">\n";
154 // returns <s at> val </s>
155 QString xmlObj::valueElement(QString el, QString val, QString at)
157 return indent() + "<" + el + " " + at + ">" + quotemeta(val) + "</" +el + ">\n";
160 void xmlObj::incIndent()
165 void xmlObj::decIndent()
168 if (actindent<0) actindent=0;
171 QString xmlObj::indent()
175 for (i=0; i<actindent*indentwidth; i++)