Back to index

scribus-ng  1.3.4.dfsg+svn20071115
fpointarray.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           fpointarray.h  -  description
00009                              -------------------
00010     begin                : Mit Jul 24 2002
00011     copyright            : (C) 2002 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #ifndef FPOINTARRAY_H
00025 #define FPOINTARRAY_H
00026 
00027 #include <qmemarray.h>
00028 #include <qwmatrix.h>
00029 #include <qpoint.h>
00030 #include "scribusapi.h"
00031 #include "fpoint.h"
00032 
00037 struct SVGState;
00038 
00039 class SCRIBUS_API FPointArray : private QMemArray<FPoint>
00040 {
00041 public: 
00042        FPointArray() : count(0), capacity(0), svgState(NULL) {};
00043        FPointArray(int size) : QMemArray<FPoint>(size), count(size), capacity(size), svgState(NULL) {};
00044        FPointArray(const FPointArray &a) : QMemArray<FPoint>(a), count(a.count), capacity(a.capacity), svgState(NULL) {};
00045        uint size() const { return count; };
00046        bool resize(uint newCount);
00047        void setPoint(uint i, double x, double y) { Iterator p = begin(); p+=i; p->xp = x; p->yp = y; };
00048        void setPoint(uint i, FPoint p) {  setPoint(i, p.xp, p.yp); };
00049        bool setPoints( int nPoints, double firstx, double firsty, ... );
00050        bool putPoints( int index, int nPoints, double firstx, double firsty,  ... );
00051        bool putPoints( int index, int nPoints, const FPointArray & from, int fromIndex = 0 );
00052        void point(uint i, double *x, double *y) const;
00053        const FPoint & point(uint i)  const{ ConstIterator p = begin(); p+=i; return *p; };
00054        QPoint pointQ(uint i) const;
00055        void translate( double dx, double dy );
00056        void scale( double sx, double sy );
00057        FPoint WidthHeight() const;
00058        void map(QWMatrix m);
00059        FPointArray &operator=( const FPointArray &a );
00060        FPointArray copy() const;
00061        void setMarker();
00062        void addPoint(double x, double y);
00063        void addPoint(FPoint p);
00064        bool hasLastQuadPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) const;
00065        void addQuadPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
00066        void addQuadPoint(FPoint p1, FPoint p2, FPoint p3, FPoint p4);
00067        double lenPathSeg(int seg) const;
00068        double lenPathDist(int seg, double t1, double t2) const;
00069        void pointTangentNormalAt( int seg, double t, FPoint* p, FPoint* tn, FPoint* n ) const;
00070        void pointDerivativesAt( int seg, double t, FPoint* p, FPoint* d1, FPoint* d2 ) const;
00071        bool operator==(const FPointArray &rhs) const;
00072        bool operator!=(const FPointArray &rhs) const;
00073        ~FPointArray();
00074        void svgInit();
00075        void svgMoveTo(double x, double y);
00076        void svgLineTo(double x, double y);
00077        //void svgCurveTo(double x1, double y1, double x2, double y2);
00078        void svgCurveToCubic(double x1, double y1, double x2, double y2, double x3, double y3);
00079        void svgArcTo(double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, double x1, double y1);
00080        void svgClosePath();
00081        void calculateArc(bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);
00082        bool parseSVG(const QString& svgPath);
00083        QString svgPath() const;
00084 private:
00085        uint count;
00086        uint capacity;
00087        SVGState * svgState;
00088 };
00089 
00090 #endif