X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=misc.cpp;fp=misc.cpp;h=0000000000000000000000000000000000000000;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=31225e15b9f9589fbeb2fc274e0a8f9522515389;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/misc.cpp b/misc.cpp deleted file mode 100644 index 31225e1..0000000 --- a/misc.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include "misc.h" - -#include "geometry.h" - -#include -#include - -#include -#include -#include - -QString richTextToPlain (QString r, const QString &indent, const int &width) -{ - Q_UNUSED( width ); - - // Avoid failing assert with mingw - if (r.isEmpty()) return r; - - QRegExp rx; - rx.setMinimal(true); - - // Remove all ... - rx.setPattern(".*"); - r.replace (rx,""); - - // convert all "" to "\n" - rx.setPattern (""); - r.replace (rx,"\n"); - - // convert all "

" to "\n" - rx.setPattern ("

"); - r.replace (rx,"\n"); - - // remove all remaining tags - rx.setPattern ("<.*>"); - r.replace (rx,""); - - // If string starts with \n now, remove it. - // It would be wrong in an OOo export for example - while (r.length() > 0 && r.at(0)=='\n') r.remove (0,1); - - // convert "&", "<" and ">" - rx.setPattern (">"); - r.replace (rx,">"); - rx.setPattern ("<"); - r.replace (rx,"<"); - rx.setPattern ("&"); - r.replace (rx,"&"); - rx.setPattern ("""); - r.replace (rx,"\""); - - // Indent everything - rx.setPattern ("^\n"); - r.replace (rx,indent); - r = indent + r; // Don't forget first line - - return r; -} - -QString qpointToString (const QPoint &p) -{ return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")"; } - -QString qpointFToString (const QPointF &p) -{ return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")"; } - -QString VectorToString (const Vector &p) -{ return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")"; } - -ostream &operator<< (ostream &stream, QPoint const &p) -{ - stream << "("<=0) - return M_PI_2; - else - return 3* M_PI_2; - } else - { - if (p.x()>0) - { - if (p.y()<0) - return (qreal)( - atan ( (qreal)(p.y()) / (qreal)(p.x()) ) ); - else - return (qreal)( 2*M_PI - atan ( (qreal)(p.y()) / (qreal)(p.x()) ) ); - } - else - return (qreal)(M_PI -atan ( (qreal)(p.y()) / (qreal)(p.x()) ) ); - } - /* - // Calculate angle of vector to y-axis - if (p.y()==0) - { - if (p.x()>=0) - return M_PI_2; - else - return 3* M_PI_2; - } else - { - if (p.y()>0) - return (qreal)(M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) ); - else - if (p.x()<0) - return (qreal)( 2*M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) ); - else - return (qreal)( - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) ); - } - */ -} - -qreal min(qreal a, qreal b) -{ - if (ab) - return a; - return b; -} - -qreal roof (qreal x) -{ - if (x<=0.5) - return x; - else - return 1-x; -} - -int round_int (qreal x) -{ - return (x > 0.0) ? (x + 0.5) : (x - 0.5); -} - -Qt::PenStyle penStyle (const QString &s, bool &ok) -{ - ok=true; - Qt::PenStyle p(Qt::NoPen); - if (s=="Qt::NoPen") - p=Qt::SolidLine; - if (s=="Qt::SolidLine") - p=Qt::SolidLine; - else if (s=="Qt::DashLine") - p=Qt::DashLine; - else if (s=="Qt::DotLine") - p=Qt::DotLine; - else if (s=="Qt::DashDotLine") - p=Qt::DashDotLine; - else if (s=="Qt::DashDotDotLine") - p=Qt::DashDotDotLine; - else - { - qWarning()<<"misc.cpp penStyle - Unknown style s="<move(QCursor::pos() - 0.5 * QPoint(dia->rect().width(),dia->rect().height() ) ); -} -