This file is indexed.

/usr/include/Wt/WPainterPath is in libwt-dev 3.3.6+dfsg-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WPAINTERPATH_H_
#define WPAINTERPATH_H_

#include <Wt/WJavaScriptExposableObject>
#include <Wt/WPointF>
#include <Wt/WRectF>
#include <Wt/WTransform>

#include <vector>

namespace Wt {

/*! \class WPainterPath Wt/WPainterPath Wt/WPainterPath
 *  \brief A path defining a shape.
 *
 * A painter path represents a (complex) path that may be composed of
 * lines, arcs and bezier curve segments, and painted onto a paint device
 * using WPainter::drawPath().
 *
 * The path that is composed in a painter path may consist of multiple
 * closed sub-paths. Only the last sub-path can be left open.
 *
 * To compose a path, this class maintains a current position, which
 * is the starting point for the next drawing operation. An operation
 * may draw a line (see lineTo()), arc (see arcTo()), or bezier curve
 * (see quadTo() and cubicTo()) from the current position to a new
 * position. A new sub path may be started by moving the current
 * position to a new location (see moveTo()), which automatically
 * closes the previous sub path.
 *
 * When sub paths overlap, the result is undefined (it is dependent on
 * the underlying painting device).
 *
 * Usage example:
 * \if cpp
 * \code
 * Wt::WPainter painter(...);
 *
 * Wt::WPainterPath path(Wt::WPointF(10, 10));
 * path.lineTo(10, 20);
 * path.lineTo(30, 20);
 * path.closeSubPath();
 *
 * painter.setPen(Wt::red);
 * painter.setBrush(Wt::blue);
 * painter.drawPath(path);
 * \endcode
 * \elseif java
 * \code
 * WPainter painter = new WPainter();
 *	 
 * WPainterPath path = new WPainterPath(new WPointF(10, 10));
 * path.lineTo(10, 20);
 * path.lineTo(30, 20);
 * path.closeSubPath();
 *		 
 * painter.setPen(new WPen(WColor.red));
 * painter.setBrush(new WBrush(WColor.blue));
 * painter.drawPath(path);
 * \endcode
 * \endif
 *
 * <h3>JavaScript exposability</h3>
 *
 * A %WPainterPath is JavaScript exposable. If a %WPainterPath \link isJavaScriptBound()
 * is JavaScript bound\endlink, it can be accessed in your custom JavaScript
 * code through \link WJavaScriptHandle::jsRef() its handle's jsRef()\endlink.
 *
 * A %WPainterPath is represented in JavaScript as an array of segments, where each segment
 * is defined by a three element array: [x,y,type], where type is the integer representation
 * of the type of a segment.
 *
 * For example, a 10 by 10 square with the top left at (10,10) is represented as:
 * \code
 * [
 *  [10,10,0], // move to (10,10)
 *  [20,10,1], // line to (20,10)
 *  [20,20,1], // line to (20,20)
 *  [10,20,1], // line to (10,20)
 *  [10,10,1]  // line to (10,10)
 * ]
 * \endcode
 *
 * \warning A %WPainterPath that is JavaScript exposed should be modified only through its \link WJavaScriptHandle handle\endlink.
 *	    Any attempt at modifying it will cause an exception to be thrown.
 *
 * \sa WPainter::drawPath(), WPaintedWidget::createJSPainterPath()
 *
 * \ingroup painting
 */
class WT_API WPainterPath : public WJavaScriptExposableObject
{
public:
  /*! \brief Default constructor.
   *
   * Creates an empty path, and sets the current position to (0, 0).
   */
  WPainterPath();

  /*! \brief Construct a new path, and set the initial position.
   *
   * Creates an empty path, and sets the current position to
   * \p startPoint.
   */
  WPainterPath(const WPointF& startPoint);

  /*! \brief Copy constructor.
   */
  WPainterPath(const WPainterPath& path);

  /*! \brief Assignment operator.
   */
  WPainterPath& operator= (const WPainterPath& path);

#ifdef WT_TARGET_JAVA
  WPainterPath clone() const;
#endif

  /*! \brief Returns the current position.
   *
   * Returns the current position, which is the end point of the last
   * move or draw operation, and which well be the start point of the
   * next draw operation.
   */
  WPointF currentPosition() const;

  /*! \brief Returns whether the path is empty.
   *
   * Returns \c true if the path contains no drawing operations. Note that
   * move operations are not considered drawing operations.
   */
  bool isEmpty() const;

  /*! \brief Comparison operator.
   *
   * Returns \c true if the paths are exactly the same.
   */
  bool operator== (const WPainterPath& path) const;  

  /*! \brief Comparison operator.
   *
   * Returns \c true if the paths are different.
   */
  bool operator!= (const WPainterPath& path) const;

  /*! \brief Closes the last sub path.
   *
   * Draws a line from the current position to the start position of
   * the last sub path (which is the end point of the last move
   * operation), and sets the current position to (0, 0).
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   */
  void closeSubPath();
  
  /*! \brief Moves the current position to a new location.
   *
   * Moves the current position to a new point, implicitly closing the last
   * sub path, unless \link openSubPathsEnabled() open subpaths are enabled\endlink.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa closeSubPath(), moveTo(double, double), setOpenSubPathsEnabled(bool)
   */
  void moveTo(const WPointF& point);
  
  /*! \brief Moves the current position to a new location.
   *
   * Moves the current position to a new point, implicitly closing the last
   * sub path, unless \link openSubPathsEnabled() open subpaths are enabled\endlink.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa closeSubPath(), moveTo(const WPointF&), setOpenSubPathsEnabled(bool)
   */
  void moveTo(double x, double y);
  
  /*! \brief Draws a straight line.
   *
   * Draws a straight line from the current position to \p point,
   * which becomes the new current position.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa lineTo(double, double)
   */
  void lineTo(const WPointF& point);
  
  /*! \brief Draws a straight line.
   *
   * Draws a straight line from the current position to (\p x,
   * \p y), which becomes the new current position.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa lineTo(const WPointF&)
   */
  void lineTo(double x, double y);
  
  /*! \brief Draws a cubic bezier curve.
   *
   * Draws a cubic bezier curve from the current position to
   * \p endPoint, which becomes the new current position. The
   * bezier curve uses the two control points <i>c1</i> and \p c2.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa cubicTo(double, double, double, double, double, double)
   */
  void cubicTo(const WPointF& c1, const WPointF& c2, const WPointF& endPoint);
  
  /*! \brief Draws a cubic bezier curve.
   *
   * This is an overloaded method provided for convenience.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa cubicTo(const WPointF&, const WPointF&, const WPointF&)
   */
  void cubicTo(double c1x, double c1y, double c2x, double c2y,
	       double endPointx, double endPointy);
  
  /*! \brief Draws an arc.
   *
   * Draws an arc which is a segment of a circle. The circle is
   * defined with center (<i>cx</i>, <i>cy</i>) and \p radius. The
   * segment starts at \p startAngle, and spans an angle given by
   * \p spanAngle. These angles are expressed in degrees, and are
   * measured counter-clockwise starting from the 3 o'clock position.
   *
   * Implicitly draws a line from the current position to the start of
   * the arc, if the current position is different from the start.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa arcMoveTo()
   */
  void arcTo(double cx, double cy, double radius,
	     double startAngle, double spanAngle);

  /*! \brief Moves to a point on an arc.
   *
   * Moves to a point on a circle. The circle is defined with center
   * (<i>cx</i>, <i>cy</i>) and \p radius, and the point is at
   * \p angle degrees measured counter-clockwise starting from the
   * 3 o'clock position.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa arcTo()
   */
  void arcMoveTo(double cx, double cy, double radius, double angle);

  /*! \brief Move to a point on an arc.
   *
   * Moves to a point on an ellipse. The ellipse fits in the
   * rectangle defined by top left position (\p x,
   * <i>y</i>), and size <i>width</i> x \p height, and the point is at
   * \p angle degrees measured counter-clockwise starting from the
   * 3 o'clock position.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa arcTo()
   */
  void arcMoveTo(double x, double y, double width, double height, double angle);

  /*! \brief Draws a quadratic bezier curve
   *
   * Draws a quadratic bezier curve from the current position to
   * \p endPoint, which becomes the new current position. The
   * bezier curve uses the single control point \p c.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa quadTo(double, double, double, double)
   */
  void quadTo(const WPointF& c, const WPointF& endPoint);

  /*! \brief Draws a quadratic bezier curve.
   *
   * This is an overloaded method provided for convenience.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa quadTo(const WPointF&, const WPointF&)
   */
  void quadTo(double cx, double cy, double endPointx, double endPointy);

  /*! \brief Draws an ellipse.
   *
   * This method closes the current sub path, and adds an ellipse that is
   * bounded by the rectangle \p boundingRectangle.
   *
   * \p Note: some renderers only support circles (width == height)
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa addEllipse(double, double, double, double), arcTo()
   */
  void addEllipse(const WRectF& boundingRectangle);

  /*! \brief Draws an ellipse.
   *
   * This method closes the current sub path, and adds an ellipse that is
   * bounded by the rectangle defined by top left position (\p x,
   * <i>y</i>), and size <i>width</i> x \p height.
   *
   * \note Some renderers only support circles (width == height)
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa addEllipse(const WRectF&), arcTo()
   */
  void addEllipse(double x, double y, double width, double height);

  /*! \brief Draws a rectangle.
   *
   * This method closes the current sub path, unless \link openSubPathsEnabled()
   * open subpaths are enabled\endlink, and adds a rectangle
   * that is defined by \p rectangle.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa addRect(double, double, double, double)
   */
  void addRect(const WRectF& rectangle);

  /*! \brief Draws a rectangle.
   *
   * This method closes the current sub path, unless \link openSubPathsEnabled()
   * open subpaths are enabled\endlink, and adds a rectangle
   * that is defined by top left position (<i>x</i>, \p y), and
   * size <i>width</i> x \p height.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa addRect(const WRectF&)
   */
  void addRect(double x, double y, double width, double height);

  /*! \brief Adds a polygon.
   *
   * If the first point is different from the current position, the last
   * sub path is first closed, unless \link openSubPathsEnabled() open
   * subpaths are enabled\endlink, otherwise the last sub path is extended
   * with the polygon.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa moveTo(), lineTo()
   */
  void addPolygon(const std::vector<WPointF>& points);

  /*! \brief Adds a path.
   *
   * Adds an entire \p path to the current path. If the path's
   * begin position is different from the current position, the last
   * sub path is first closed, unless \link openSubPathsEnabled() open
   * subpaths are enabled\endlink, otherwise the last sub path is extended
   * with the path's first sub path.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa connectPath(const WPainterPath&)
   */
  void addPath(const WPainterPath& path);

  /*! \brief Adds a path, connecting.
   *
   * Adds an entire \p path to the current path. If the path's
   * begin position is different from the current position, the last
   * sub path is first closed, unless \link openSubPathsEnabled() open
   * subpaths are enabled\endlink, otherwise the last sub path is extended
   * with the path's first sub path.
   *
   * \throws WException if the path \link isJavaScriptBound() is JavaScript bound\endlink
   *
   * \sa connectPath(const WPainterPath&)
   */
  void connectPath(const WPainterPath& path);

  /*! \brief A segment.
   */
  class Segment {
  public:
    /*! The segment type
     */
    enum Type {
      MoveTo = 0,  //!< moveTo segment
      LineTo = 1,  //!< lineTo segment
      CubicC1 = 2, //!< first control point of cubic bezier curve, always followed by a CubicC2 and CubicEnd segment
      CubicC2 = 3, //!< second control point of cubic bezier curve, always followed by a CubicEnd segment
      CubicEnd = 4, //!< end point of cubic bezier curve
      QuadC = 5, //!< control point of quadratic bezier curve
      QuadEnd = 6, //!< end point of quadratic bezier curve
      ArcC = 7, //!< center of an arc, always followed by an ArcR and ArcAngleSweep segment
      ArcR = 8, //!< radius of an arc, always followed by an ArcAngleSweep segment
      ArcAngleSweep = 9 //!< the sweep of an arc, x = startAngle, y = spanAngle
    };

    /*! The x parameter
     *
     * Depending on the type(), this is either
     * the x position of the point, or something
     * else.
     */
    double x() const { return x_; }

    /*! The y parameter
     *
     * Depending on the type(), this is either
     * the y position of the point, or something
     * else.
     */
    double y() const { return y_; }
    
    /*! The type of the segment
     */
    Type   type() const { return type_; }

    bool operator== (const Segment& other) const;
    bool operator!= (const Segment& other) const;

  private:
    Segment(double x, double y, Type type);

    double x_, y_;
    Type   type_;

    friend class WPainterPath;
    friend WPainterPath WTransform::map(const WPainterPath& path) const;
  };

  const std::vector<Segment>& segments() const { return segments_; }

  /* Returns the start position before drawing segment i */
  WPointF positionAtSegment(int i) const;

  bool asRect(WRectF& result) const;

  /*! \brief Returns the bounding box of the control points.
   *
   * Returns the bounding box of all control points. This is guaranteed to
   * be a superset of the actual bounding box.
   *
   * The \p transform is applied to the path first.
   */
  WRectF controlPointRect(const WTransform& transform = WTransform::Identity)
    const;

  /*! \brief Returns a copy of the path where straight lines are moved to be rendered crisply.
   *
   * This is intended to be used on rectangles, or other paths consisting of only
   * straight line, and will nudge every edge a little bit, so that 1px straight lines are
   * rendered as a crisp line.
   *
   * This will also work if the path \link isJavaScriptBound() is JavaScript bound\endlink.
   */
  WPainterPath crisp() const;

  /*! \brief Disables automatically closing subpaths on moveTo
   *
   * By default, open sub paths are disabled, and moveTo and any operation that
   * relies on moveTo will automatically close the last subpath. Enabling this
   * option disables that feature.
   *
   * \sa moveTo(), addPath(), connectPath(), addRect()
   */
  void setOpenSubPathsEnabled(bool enabled = true);

  /*! \brief Returns whether open subpaths are enabled.
   *
   * \sa setOpenSubPathsEnabled(bool)
   */
  bool openSubPathsEnabled() const { return openSubPathsEnabled_; }

  bool isPointInPath(const WPointF &p) const;

  virtual std::string jsValue() const WT_CXX11ONLY(override) ;

protected:
  void assignFromJSON(const Json::Value &value) WT_CXX11ONLY(override) ;

private:
  bool isRect_;
  bool openSubPathsEnabled_;
  std::vector<Segment> segments_;

  WPointF getSubPathStart() const;
  WPointF beginPosition() const;

  static WPointF getArcPosition(double cx, double cy, double rx, double ry,
				double angle);

  /* Draws an arc (<b>deprecated</b>).
   *
   * Draws an arc which is a segment of an ellipse, which fits in the
   * rectangle defined by top left position (\p x,
   * <i>y</i>), and size <i>width</i> x \p height. The segment starts at
   * \p startAngle, and spans an angle given by
   * \p spanAngle. These angles are expressed in degrees, and are
   * measured counter-clockwise starting from the 3 o'clock position.
   *
   * \sa arcMoveTo(double cx, double cy, double radius, double startAngle, double sweepLength)
   */
  void arcTo(double x, double y, double width, double height,
	     double startAngle, double sweepLength);

  friend class WSvgImage;
  friend WPainterPath WTransform::map(const WPainterPath& path) const;
};

}

#endif // WPAINTERPATH_H_