Scribus
Open source desktop publishing at your fingertips
fpointarray.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  fpointarray.h - description
9  -------------------
10  begin : Mit Jul 24 2002
11  copyright : (C) 2002 by Franz Schmid
12  email : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 
15 /***************************************************************************
16  * *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or *
20  * (at your option) any later version. *
21  * *
22  ***************************************************************************/
23 
24 #ifndef FPOINTARRAY_H
25 #define FPOINTARRAY_H
26 
27 #include <QTransform>
28 #include <QPainterPath>
29 #include <QPoint>
30 #include <QPointF>
31 #include <QVector>
32 
33 #include "fpoint.h"
34 #include "scribusapi.h"
35 
40 struct SVGState;
41 
42 class SCRIBUS_API FPointArray : public QVector<FPoint>
43 {
44 public:
45  FPointArray() : svgState(NULL) {};
46  FPointArray(int size) : QVector<FPoint>(size), svgState(NULL) {};
47  FPointArray(const FPointArray &a) : QVector<FPoint>(a), svgState(NULL) {};
48  int size() const { return QVector<FPoint>::count(); }
49  bool resize(int newCount);
50  void reverse();
51  void setPoint(int i, double x, double y) { FPoint& p = QVector<FPoint>::operator[](i); p.xp = x; p.yp = y; };
52  void setPoint(int i, FPoint p) { setPoint(i, p.xp, p.yp); }
53  bool setPoints( int nPoints, double firstx, double firsty, ... );
54  bool putPoints( int index, int nPoints, double firstx, double firsty, ... );
55  bool putPoints( int index, int nPoints, const FPointArray & from, int fromIndex = 0 );
56  void point(int i, double *x, double *y) const;
57  const FPoint& point(int i) const{ return QVector<FPoint>::at(i); }
58  QPoint pointQ(int i) const;
59  QPointF pointQF(int i) const;
60  void translate( double dx, double dy );
61  void scale( double sx, double sy );
62  QRectF boundingRect();
63  FPoint WidthHeight() const;
64  void map(QTransform m);
65  FPointArray &operator=( const FPointArray &a );
66  FPointArray copy() const;
67  void setMarker();
68  bool isMarker(int pos) const;
69  bool isMarkerI(ConstIterator p) const;
70  bool isMarkerD(double x, double y) const;
71  void addPoint(double x, double y);
72  void addPoint(FPoint p);
73  bool hasLastQuadPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) const;
74  void addQuadPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
75  void addQuadPoint(FPoint p1, FPoint p2, FPoint p3, FPoint p4);
76  double lenPathSeg(int seg) const;
77  double lenPathDist(int seg, double t1, double t2) const;
78  void pointTangentNormalAt( int seg, double t, FPoint* p, FPoint* tn, FPoint* n ) const;
79  void pointDerivativesAt( int seg, double t, FPoint* p, FPoint* d1, FPoint* d2 ) const;
80  ~FPointArray();
81  void svgInit();
82  void svgMoveTo(double x, double y);
83  void svgLineTo(double x, double y);
84  //void svgCurveTo(double x1, double y1, double x2, double y2);
85  void svgCurveToCubic(double x1, double y1, double x2, double y2, double x3, double y3);
86  void svgArcTo(double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, double x1, double y1);
87  void svgClosePath();
88  void calculateArc(bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);
89  bool parseSVG(const QString& svgPath);
90  QString svgPath(bool closed = false) const;
91  QPainterPath toQPainterPath(bool closed);
92  void fromQPainterPath(QPainterPath &path, bool close = false);
93 private:
94  SVGState * svgState;
95 };
96 
97 #endif
A point with floating point precision.
Definition: fpoint.h:43
Definition: fpointarray.cpp:470
Definition: fpointarray.h:42