equal
deleted
inserted
replaced
85 |
85 |
86 bool intersect(); |
86 bool intersect(); |
87 bool contains(); |
87 bool contains(); |
88 |
88 |
89 static bool pathToRect(const QPainterPath &path, QRectF *rect = 0); |
89 static bool pathToRect(const QPainterPath &path, QRectF *rect = 0); |
|
90 static QPainterPath intersect(const QPainterPath &path, const QRectF &rect); |
90 |
91 |
91 private: |
92 private: |
92 Q_DISABLE_COPY(QPathClipper) |
93 Q_DISABLE_COPY(QPathClipper) |
93 |
94 |
94 enum ClipperMode { |
95 enum ClipperMode { |
148 int second; |
149 int second; |
149 |
150 |
150 qreal angle; |
151 qreal angle; |
151 qreal invAngle; |
152 qreal invAngle; |
152 |
153 |
153 const QBezier *bezier; |
|
154 qreal t0; |
|
155 qreal t1; |
|
156 |
|
157 int next(Traversal traversal, Direction direction) const; |
154 int next(Traversal traversal, Direction direction) const; |
158 |
155 |
159 void setNext(Traversal traversal, Direction direction, int next); |
156 void setNext(Traversal traversal, Direction direction, int next); |
160 void setNext(Direction direction, int next); |
157 void setNext(Direction direction, int next); |
161 |
158 |
179 return t < o.t; |
176 return t < o.t; |
180 } |
177 } |
181 }; |
178 }; |
182 |
179 |
183 struct Segment { |
180 struct Segment { |
184 Segment(int pathId, int vertexA, int vertexB, int bezierIndex = -1) |
181 Segment(int pathId, int vertexA, int vertexB) |
185 : path(pathId) |
182 : path(pathId) |
186 , bezier(bezierIndex) |
|
187 , va(vertexA) |
183 , va(vertexA) |
188 , vb(vertexB) |
184 , vb(vertexB) |
189 , intersection(-1) |
185 , intersection(-1) |
190 { |
186 { |
191 } |
187 } |
192 |
188 |
193 int path; |
189 int path; |
194 int bezier; |
|
195 |
190 |
196 // vertices |
191 // vertices |
197 int va; |
192 int va; |
198 int vb; |
193 int vb; |
199 |
194 |
202 |
197 |
203 QRectF bounds; |
198 QRectF bounds; |
204 }; |
199 }; |
205 |
200 |
206 |
201 |
207 QPathSegments(); |
202 QPathSegments(int reserve); |
208 |
203 |
209 void setPath(const QPainterPath &path); |
204 void setPath(const QPainterPath &path); |
210 void addPath(const QPainterPath &path); |
205 void addPath(const QPainterPath &path); |
211 |
206 |
212 int intersections() const; |
207 int intersections() const; |
213 int segments() const; |
208 int segments() const; |
214 int points() const; |
209 int points() const; |
215 |
210 |
216 const Segment &segmentAt(int index) const; |
211 const Segment &segmentAt(int index) const; |
217 const QLineF lineAt(int index) const; |
212 const QLineF lineAt(int index) const; |
218 const QBezier *bezierAt(int index) const; |
|
219 const QRectF &elementBounds(int index) const; |
213 const QRectF &elementBounds(int index) const; |
220 int pathId(int index) const; |
214 int pathId(int index) const; |
221 |
215 |
222 const QPointF &pointAt(int vertex) const; |
216 const QPointF &pointAt(int vertex) const; |
223 int addPoint(const QPointF &point); |
217 int addPoint(const QPointF &point); |
228 void mergePoints(); |
222 void mergePoints(); |
229 |
223 |
230 private: |
224 private: |
231 QDataBuffer<QPointF> m_points; |
225 QDataBuffer<QPointF> m_points; |
232 QDataBuffer<Segment> m_segments; |
226 QDataBuffer<Segment> m_segments; |
233 QDataBuffer<QBezier> m_beziers; |
|
234 QDataBuffer<Intersection> m_intersections; |
227 QDataBuffer<Intersection> m_intersections; |
235 |
228 |
236 int m_pathId; |
229 int m_pathId; |
237 }; |
230 }; |
238 |
231 |
269 QPathVertex *vertex(int vertex); |
262 QPathVertex *vertex(int vertex); |
270 const QPathVertex *vertex(int vertex) const; |
263 const QPathVertex *vertex(int vertex) const; |
271 |
264 |
272 TraversalStatus next(const TraversalStatus &status) const; |
265 TraversalStatus next(const TraversalStatus &status) const; |
273 |
266 |
274 int addEdge(const QPointF &a, const QPointF &b, const QBezier *bezier = 0, qreal t0 = 0, qreal t1 = 1); |
267 int addEdge(const QPointF &a, const QPointF &b); |
275 int addEdge(int vertexA, int vertexB, const QBezier *bezier = 0, qreal t0 = 0, qreal t1 = 1); |
268 int addEdge(int vertexA, int vertexB); |
276 |
269 |
277 bool isInside(qreal x, qreal y) const; |
270 bool isInside(qreal x, qreal y) const; |
278 |
271 |
279 static QPathEdge::Traversal flip(QPathEdge::Traversal traversal); |
272 static QPathEdge::Traversal flip(QPathEdge::Traversal traversal); |
280 static QPathEdge::Direction flip(QPathEdge::Direction direction); |
273 static QPathEdge::Direction flip(QPathEdge::Direction direction); |
282 private: |
275 private: |
283 void intersectAndAdd(); |
276 void intersectAndAdd(); |
284 |
277 |
285 void printNode(int i, FILE *handle); |
278 void printNode(int i, FILE *handle); |
286 |
279 |
287 QBezier bezierFromIndex(int index) const; |
|
288 |
|
289 void removeEdge(int ei); |
280 void removeEdge(int ei); |
290 void addBezierEdge(const QBezier *bezier, const QPointF &a, const QPointF &b, qreal alphaA, qreal alphaB, int path); |
|
291 void addBezierEdge(const QBezier *bezier, int vertexA, int vertexB, qreal alphaA, qreal alphaB, int path); |
|
292 |
281 |
293 int insert(const QPathVertex &vertex); |
282 int insert(const QPathVertex &vertex); |
294 TraversalStatus findInsertStatus(int vertex, int edge) const; |
283 TraversalStatus findInsertStatus(int vertex, int edge) const; |
295 |
284 |
296 qreal delta(int vertex, int a, int b) const; |
285 qreal delta(int vertex, int a, int b) const; |
309 , windingB(0) |
298 , windingB(0) |
310 , first(a) |
299 , first(a) |
311 , second(b) |
300 , second(b) |
312 , angle(0) |
301 , angle(0) |
313 , invAngle(0) |
302 , invAngle(0) |
314 , bezier(0) |
|
315 , t0(0) |
|
316 , t1(0) |
|
317 { |
303 { |
318 m_next[0][0] = -1; |
304 m_next[0][0] = -1; |
319 m_next[1][0] = -1; |
305 m_next[1][0] = -1; |
320 m_next[0][0] = -1; |
306 m_next[0][0] = -1; |
321 m_next[1][0] = -1; |
307 m_next[1][0] = -1; |
357 inline QPathVertex::operator QPointF() const |
343 inline QPathVertex::operator QPointF() const |
358 { |
344 { |
359 return QPointF(x, y); |
345 return QPointF(x, y); |
360 } |
346 } |
361 |
347 |
362 inline QPathSegments::QPathSegments() |
348 inline QPathSegments::QPathSegments(int reserve) : |
|
349 m_points(reserve), |
|
350 m_segments(reserve), |
|
351 m_intersections(reserve) |
363 { |
352 { |
364 } |
353 } |
365 |
354 |
366 inline int QPathSegments::segments() const |
355 inline int QPathSegments::segments() const |
367 { |
356 { |
391 |
380 |
392 inline const QLineF QPathSegments::lineAt(int index) const |
381 inline const QLineF QPathSegments::lineAt(int index) const |
393 { |
382 { |
394 const Segment &segment = m_segments.at(index); |
383 const Segment &segment = m_segments.at(index); |
395 return QLineF(m_points.at(segment.va), m_points.at(segment.vb)); |
384 return QLineF(m_points.at(segment.va), m_points.at(segment.vb)); |
396 } |
|
397 |
|
398 inline const QBezier *QPathSegments::bezierAt(int index) const |
|
399 { |
|
400 const Segment &segment = m_segments.at(index); |
|
401 if (segment.bezier >= 0) |
|
402 return &m_beziers.at(segment.bezier); |
|
403 else |
|
404 return 0; |
|
405 } |
385 } |
406 |
386 |
407 inline const QRectF &QPathSegments::elementBounds(int index) const |
387 inline const QRectF &QPathSegments::elementBounds(int index) const |
408 { |
388 { |
409 return m_segments.at(index).bounds; |
389 return m_segments.at(index).bounds; |