libs/flake

KoPathShapeLoader.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include "KoPathShapeLoader.h"
00021 #include "KoPathShape.h"
00022 
00023 class KoPathShapeLoader::Private
00024 {
00025 public:
00026     Private(KoPathShape * p) : path(p) {
00027         Q_ASSERT(path);
00028         path->clear();
00029     }
00030 
00031     KoPathShape * path; 
00032     QPointF lastPoint;
00033 };
00034 
00035 KoPathShapeLoader::KoPathShapeLoader(KoPathShape * path)
00036         : d(new Private(path))
00037 {
00038 }
00039 
00040 KoPathShapeLoader::~KoPathShapeLoader()
00041 {
00042     delete d;
00043 }
00044 
00045 void KoPathShapeLoader::svgMoveTo(qreal x1, qreal y1, bool abs)
00046 {
00047     if (abs)
00048         d->lastPoint = QPointF(x1, y1);
00049     else
00050         d->lastPoint += QPointF(x1, y1);
00051     d->path->moveTo(d->lastPoint);
00052 }
00053 
00054 void KoPathShapeLoader::svgLineTo(qreal x1, qreal y1, bool abs)
00055 {
00056     if (abs)
00057         d->lastPoint = QPointF(x1, y1);
00058     else
00059         d->lastPoint += QPointF(x1, y1);
00060 
00061     d->path->lineTo(d->lastPoint);
00062 }
00063 
00064 void KoPathShapeLoader::svgLineToHorizontal(qreal x, bool abs)
00065 {
00066     if (abs)
00067         d->lastPoint.setX(x);
00068     else
00069         d->lastPoint.rx() += x;
00070 
00071     d->path->lineTo(d->lastPoint);
00072 }
00073 
00074 void KoPathShapeLoader::svgLineToVertical(qreal y, bool abs)
00075 {
00076     if (abs)
00077         d->lastPoint.setY(y);
00078     else
00079         d->lastPoint.ry() += y;
00080 
00081     d->path->lineTo(d->lastPoint);
00082 }
00083 
00084 void KoPathShapeLoader::svgCurveToCubic(qreal x1, qreal y1, qreal x2, qreal y2, qreal x, qreal y, bool abs)
00085 {
00086     QPointF p1, p2;
00087     if (abs) {
00088         p1 = QPointF(x1, y1);
00089         p2 = QPointF(x2, y2);
00090         d->lastPoint = QPointF(x, y);
00091     } else {
00092         p1 = d->lastPoint + QPointF(x1, y1);
00093         p2 = d->lastPoint + QPointF(x2, y2);
00094         d->lastPoint += QPointF(x, y);
00095     }
00096 
00097     d->path->curveTo(p1, p2, d->lastPoint);
00098 }
00099 
00100 void KoPathShapeLoader::svgCurveToCubicSmooth(qreal x, qreal y, qreal x2, qreal y2, bool abs)
00101 {
00102     Q_UNUSED(x);
00103     Q_UNUSED(y);
00104     Q_UNUSED(x2);
00105     Q_UNUSED(y2);
00106     Q_UNUSED(abs);
00107     // TODO implement
00108 }
00109 
00110 void KoPathShapeLoader::svgCurveToQuadratic(qreal x, qreal y, qreal x1, qreal y1, bool abs)
00111 {
00112     Q_UNUSED(x);
00113     Q_UNUSED(y);
00114     Q_UNUSED(x1);
00115     Q_UNUSED(y1);
00116     Q_UNUSED(abs);
00117     // TODO implement
00118 }
00119 
00120 void KoPathShapeLoader::svgCurveToQuadraticSmooth(qreal x, qreal y, bool abs)
00121 {
00122     Q_UNUSED(x);
00123     Q_UNUSED(y);
00124     Q_UNUSED(abs);
00125     // TODO implement
00126 }
00127 
00128 void KoPathShapeLoader::svgArcTo(qreal x, qreal y, qreal r1, qreal r2, qreal angle, bool largeArcFlag, bool sweepFlag, bool abs)
00129 {
00130     Q_UNUSED(x);
00131     Q_UNUSED(y);
00132     Q_UNUSED(r1);
00133     Q_UNUSED(r2);
00134     Q_UNUSED(angle);
00135     Q_UNUSED(largeArcFlag);
00136     Q_UNUSED(sweepFlag);
00137     Q_UNUSED(abs);
00138     // TODO implement
00139 }
00140 
00141 void KoPathShapeLoader::svgClosePath()
00142 {
00143     d->path->closeMerge();
00144 }