Debian Codegraph @

PathPaintEngine.cpp

raw symbols SCIP
1 /***************************************************************************
2 * This file is part of Robocut. *
3 * Copyright (C) 2010 Tim Hutt <[email protected]> *
4 * Copyright (C) 2010 Markus Schulz <[email protected]> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
21
22 #include "PathPaintEngine.h"cxx . . $ `<file>/PathPaintEngine.h`/
23
24 #include <cmath>
25 #include <QDebug>
26
27 PathPaintEnginecxx . . $ PathPaintEngine#::PathPaintEnginecxx . . $ PathPaintEngine#PathPaintEngine(dd2eedc069b0ab5f).(QPaintDevicecxx . . $ QPaintDevice#* pdev)
28 : QPaintEnginecxx . . $ QPaintEngine#QPaintEngine(8a48cd3bf54e8e11).(AllFeaturescxx . . $ QFlags#QFlags(9b289cee16747614).)
29 {
30 devcxx . . $ PathPaintEngine#dev. = dynamic_cast<PathPaintDevicecxx . . $ PathPaintDevice#*>(pdev);
31 if (!devcxx . . $ PathPaintEngine#dev.)
32 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("PathPaintEngine: unsupported target device.");
33 }
34
35 bool PathPaintEnginecxx . . $ PathPaintEngine#::begincxx . . $ PathPaintEngine#begin(3d42010d693361d5).(QPaintDevicecxx . . $ QPaintDevice#* pdev)
36 {
37 devcxx . . $ PathPaintEngine#dev. = dynamic_cast<PathPaintDevicecxx . . $ PathPaintDevice#*>(pdev);
38 if (!devcxx . . $ PathPaintEngine#dev.)
39 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("PathPaintEngine: unsupported target device.");
40
41 // TODO: setActive?
42 return true;
43 }
44
45 bool approximatelyEqualcxx . . $ approximatelyEqual(c3c51e0645da350e).(qrealcxx . . $ qreal# a, qrealcxx . . $ qreal# b, qrealcxx . . $ qreal# epsilon)
46 {
47 return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
48 }
49
50 bool essentiallyEqualcxx . . $ essentiallyEqual(c3c51e0645da350e).(qrealcxx . . $ qreal# a, qrealcxx . . $ qreal# b, qrealcxx . . $ qreal# epsilon)
51 {
52 return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
53 }
54
55 bool definitelyGreaterThancxx . . $ definitelyGreaterThan(c3c51e0645da350e).(qrealcxx . . $ qreal# a, qrealcxx . . $ qreal# b, qrealcxx . . $ qreal# epsilon)
56 {
57 return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
58 }
59
60 bool definitelyLessThancxx . . $ definitelyLessThan(c3c51e0645da350e).(qrealcxx . . $ qreal# a, qrealcxx . . $ qreal# b, qrealcxx . . $ qreal# epsilon)
61 {
62 return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
63 }
64
65
66 void PathPaintEnginecxx . . $ PathPaintEngine#::drawPathcxx . . $ PathPaintEngine#drawPath(30c23ba204361e3b).(const QPainterPathcxx . . $ QPainterPath#& path)
67 {
68 if (!devcxx . . $ PathPaintEngine#dev.)
69 return;
70
71 if(!isCosmeticcxx . . $ PathPaintEngine#isCosmetic.)
72 {
73 QListcxx . . $ QList#<QPolygonFcxx . . $ QPolygonF#> polys = pathcxx . . $ QList#QList(b1a5d2b9a710f6d1)..toSubpathPolygonscxx . . $ QPainterPath#toSubpathPolygons(69b71f0289c703e4).();
74 for (int i = 0; i < polys.sizecxx . . $ QList#size(455f465bc33b4cdf).(); ++i)
75 {
76 if(dashPatterncxx . . $ PathPaintEngine#dashPattern..emptycxx . . $ QVector#empty(50ce9a9e25b4a850).()) devcxx . . $ PathPaintEngine#dev.->addPathcxx . . $ PathPaintDevice#addPath(e790b6e62144e8f9).(transformcxx . . $ PathPaintEngine#transform..mapcxx . . $ QTransform#map(5ac16835c2f6573a).(polys[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i]));
77 else
78 {
79 QPolygonFcxx . . $ QPolygonF# polytemp = transformcxx . . $ QPolygonF#QPolygonF(cae4aa04562998ff)..mapcxx . . $ QTransform#map(5ac16835c2f6573a).(polys[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i]), newpolycxx . . $ QPolygonF#QPolygonF(49f6e7a06ebc5aa8).;
80 int dashtoggle = 1, dashi=0, j = 0;
81 qrealcxx . . $ qreal# actualdashsize = dashPatterncxx . . $ PathPaintEngine#dashPattern.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).dashi];
82 QPointFcxx . . $ QPointF# origin = QPointFcxx . . $ QPointF#(polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j]), testpcxx . . $ QPointF#QPointF(49f6e7a06ebc5aa8).;
83 j++;
84 do
85 {
86 newpoly =cxx . . $ QPolygonF#`operator=`(f6c2537b072ea0cb). QPolygonFcxx . . $ QPolygonF#QPolygonF(49f6e7a06ebc5aa8).();
87 newpoly.appendcxx . . $ QVector#append(77d9f17553126ecb).(origin);
88 do
89 {
90 testp =cxx . . $ QPointF#`operator=`(b024836c2ac1a957). polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j];
91 origin =cxx . . $ QPointF#`operator=`(7e3640cc08969ae8). QPointFcxx . . $ QPointF#(getPointAtLenghtcxx . . $ PathPaintEngine#getPointAtLenght(39f5c5059530c0e3).(QPointFcxx . . $ QPointF#(origin), polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j], actualdashsize));
92 if (essentiallyEqualcxx . . $ essentiallyEqual(c3c51e0645da350e).(origin.xcxx . . $ QPointF#x(21b6c25e127938e2).(), polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j].xcxx . . $ QPointF#x(21b6c25e127938e2).(), 0.01 ) && approximatelyEqualcxx . . $ approximatelyEqual(c3c51e0645da350e).(origin.ycxx . . $ QPointF#y(21b6c25e127938e2).(), polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j].ycxx . . $ QPointF#y(21b6c25e127938e2).(),0.01) && j+1 < polytemp.sizecxx . . $ QVector#size(455f465bc33b4cdf).())
93 {
94 origin =cxx . . $ QPointF#`operator=`(b024836c2ac1a957). polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j];
95 int tempz = polytemp.sizecxx . . $ QVector#size(455f465bc33b4cdf).();
96 j++;
97 testp =cxx . . $ QPointF#`operator=`(b024836c2ac1a957). polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j];
98 }
99 newpoly.appendcxx . . $ QVector#append(77d9f17553126ecb).(origin);
100
101 }while(definitelyGreaterThancxx . . $ definitelyGreaterThan(c3c51e0645da350e).(actualdashsize,0.0,0.1) && testp!=cxx . . $ `operator!=`(e69eb9826ea1296c).origin);
102 if(dashtoggle == 1)
103 {
104 devcxx . . $ PathPaintEngine#dev.->addPathcxx . . $ PathPaintDevice#addPath(e790b6e62144e8f9).(newpoly);
105 }
106 dashtoggle = dashtoggle * -1;
107 dashi++;
108 if(dashi >= dashPatterncxx . . $ PathPaintEngine#dashPattern..sizecxx . . $ QVector#size(455f465bc33b4cdf).()) dashi=0;
109 actualdashsize = dashPatterncxx . . $ PathPaintEngine#dashPattern.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).dashi];
110 }while(!essentiallyEqualcxx . . $ essentiallyEqual(c3c51e0645da350e).(origin.xcxx . . $ QPointF#x(21b6c25e127938e2).(), polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j].xcxx . . $ QPointF#x(21b6c25e127938e2).(), 0.001 ) || !essentiallyEqualcxx . . $ essentiallyEqual(c3c51e0645da350e).(origin.ycxx . . $ QPointF#y(21b6c25e127938e2).(), polytemp[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).j].ycxx . . $ QPointF#y(21b6c25e127938e2).(),0.001));
111 }
112 }
113 }
114 }
115
116 void PathPaintEnginecxx . . $ PathPaintEngine#::drawPixmapcxx . . $ PathPaintEngine#drawPixmap(75213d7598e6f7bf).(const QRectFcxx . . $ QRectF#& r, const QPixmapcxx . . $ QPixmap#& pm, const QRectFcxx . . $ QRectF#& sr)
117 {
118 // Nop.
119 }
120
121 void PathPaintEnginecxx . . $ PathPaintEngine#::drawPolygoncxx . . $ PathPaintEngine#drawPolygon(6c5cabee4d370237).(const QPointFcxx . . $ QPointF#* points, int pointCount, PolygonDrawModecxx . . $ QPaintEngine#PolygonDrawMode# mode)
122 {
123 if (!devcxx . . $ PathPaintEngine#dev.)
124 return;
125
126 QPolygonFcxx . . $ QPolygonF# pcxx . . $ QPolygonF#QPolygonF(49f6e7a06ebc5aa8).;
127 for (int i = 0; i < pointCount; ++i)
128 p.appendcxx . . $ QVector#append(77d9f17553126ecb).(points[i]);
129 devcxx . . $ PathPaintEngine#dev.->addPathcxx . . $ PathPaintDevice#addPath(e790b6e62144e8f9).(transformcxx . . $ PathPaintEngine#transform..mapcxx . . $ QTransform#map(5ac16835c2f6573a).(p));
130 }
131
132 bool PathPaintEnginecxx . . $ PathPaintEngine#::endcxx . . $ PathPaintEngine#end(c9857a73d68e59ba).()
133 {
134 if (!devcxx . . $ PathPaintEngine#dev.)
135 return false;
136 return true;
137 }
138
139 QPaintEnginecxx . . $ QPaintEngine#::Typecxx . . $ QPaintEngine#Type# PathPaintEnginecxx . . $ PathPaintEngine#::typecxx . . $ PathPaintEngine#type(368383b1e95331b7).() const
140 {
141 return QPaintEnginecxx . . $ QPaintEngine#::Usercxx . . $ QPaintEngine#User.;
142 }
143 void PathPaintEnginecxx . . $ PathPaintEngine#::updateStatecxx . . $ PathPaintEngine#updateState(699f0c2cebb1474d).(const QPaintEngineStatecxx . . $ QPaintEngineState#& state)
144 {
145 if (state.statecxx . . $ QPaintEngineState#state(8e01f73c43d5dcc7).() &cxx . . $ QFlags#`operator&`(1933792fc5621fd5). DirtyTransformcxx . . $ QPaintEngine#DirtyTransform.)
146 transformcxx . . $ PathPaintEngine#transform. =cxx . . $ QTransform#`operator=`(940788f1150738e5). state.transformcxx . . $ QPaintEngineState#transform(89b51d5baeafd349).();
147 dashPatterncxx . . $ PathPaintEngine#dashPattern. =cxx . . $ QVector#`operator=`(a1d068f9d22786ee). state.pencxx . . $ QPaintEngineState#pen(30fcf0e42d084f28).().dashPatterncxx . . $ QPen#dashPattern(9895b81443f33b7a).();
148 isCosmeticcxx . . $ PathPaintEngine#isCosmetic. = state.pencxx . . $ QPaintEngineState#pen(30fcf0e42d084f28).().isCosmeticcxx . . $ QPen#isCosmetic(50ce9a9e25b4a850).();
149 }
150
151 qrealcxx . . $ qreal# PathPaintEnginecxx . . $ PathPaintEngine#::getDistancecxx . . $ PathPaintEngine#getDistance(20ac751146d29a5f).(const QPointFcxx . . $ QPointF# &p1, const QPointFcxx . . $ QPointF# &p2)
152 {
153 qrealcxx . . $ qreal# testx1 = p1.xcxx . . $ QPointF#x(21b6c25e127938e2).();
154 qrealcxx . . $ qreal# testy1 = p1.ycxx . . $ QPointF#y(21b6c25e127938e2).();
155 qrealcxx . . $ qreal# testx2 = p2.xcxx . . $ QPointF#x(21b6c25e127938e2).();
156 qrealcxx . . $ qreal# testy2 = p2.ycxx . . $ QPointF#y(21b6c25e127938e2).();
157 qrealcxx . . $ qreal# a = 0.0;
158 qrealcxx . . $ qreal# b = 0.0;
159 double c = 0.0;
160
161 if(testx1 >= testx2) a = testx1 - testx2;
162 else a = testx2 - testx1;
163 if(testy1 >= testy2) b = testy1 - testy2;
164 else b = testy2 - testy1;
165 c = sqrt((double)(a*a+b*b));
166 return (qrealcxx . . $ qreal#) c;
167 }
168
169 QPointFcxx . . $ QPointF# PathPaintEnginecxx . . $ PathPaintEngine#::getPointAtLenghtcxx . . $ PathPaintEngine#getPointAtLenght(39f5c5059530c0e3).(const QPointFcxx . . $ QPointF# &p1, const QPointFcxx . . $ QPointF# &p2, qrealcxx . . $ qreal# &l1)
170 {
171 qrealcxx . . $ qreal# testx1 = p1.xcxx . . $ QPointF#x(21b6c25e127938e2).();
172 qrealcxx . . $ qreal# testy1 = p1.ycxx . . $ QPointF#y(21b6c25e127938e2).();
173 qrealcxx . . $ qreal# testx2 = p2.xcxx . . $ QPointF#x(21b6c25e127938e2).();
174 qrealcxx . . $ qreal# testy2 = p2.ycxx . . $ QPointF#y(21b6c25e127938e2).();
175 qrealcxx . . $ qreal# lenghtp1p2 = getDistancecxx . . $ PathPaintEngine#getDistance(20ac751146d29a5f).(p1,p2);
176 qrealcxx . . $ qreal# lenghtdash = l1;
177 l1 = lenghtp1p2 - lenghtdash;
178 if (definitelyLessThancxx . . $ definitelyLessThan(c3c51e0645da350e).(lenghtp1p2, lenghtdash, 0.01))
179 {
180 l1 = lenghtdash - lenghtp1p2;
181 return p2;
182 }
183 if (definitelyGreaterThancxx . . $ definitelyGreaterThan(c3c51e0645da350e).(lenghtdash, lenghtp1p2, 0.01))
184 {
185 l1 = lenghtdash - lenghtp1p2;
186 return p1;
187 }
188 l1 = 0;
189 qrealcxx . . $ qreal# factor = lenghtp1p2/lenghtdash;
190 qrealcxx . . $ qreal# a = testx1-testx2;
191 qrealcxx . . $ qreal# b = testy1-testy2;
192 qrealcxx . . $ qreal# aa = a/factor;
193 qrealcxx . . $ qreal# bb = b/factor;
194 QPointFcxx . . $ QPointF# ret = QPointFcxx . . $ QPointF#QPointF(bc12c9ec15586e6a).(testx1-aa,testy1-bb);
195 return ret;
196
197 }
198