~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/livarot/Path.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Ted Gould, Kees Cook
  • Date: 2009-06-24 14:00:43 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624140043-07stp20mry48hqup
Tags: 0.47~pre0-0ubuntu1
* New upstream release

[ Ted Gould ]
* debian/control: Adding libgsl0 and removing version specifics on boost

[ Kees Cook ]
* debian/watch: updated to run uupdate and mangle pre-release versions.
* Dropped patches that have been taken upstream:
  - 01_mips
  - 02-poppler-0.8.3
  - 03-chinese-inkscape
  - 05_fix_latex_patch
  - 06_gcc-4.4
  - 07_cdr2svg
  - 08_skip-bad-utf-on-pdf-import
  - 09_gtk-clist
  - 10_belarussian
  - 11_libpng
  - 12_desktop
  - 13_slider
  - 100_svg_import_improvements
  - 102_sp_pattern_painter_free
  - 103_bitmap_type_print

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#include "livarot/livarot-forward.h"
15
15
#include "libnr/nr-point.h"
16
16
#include <libnr/nr-rect-l.h>
 
17
#include <2geom/forward.h>
17
18
 
18
19
struct SPStyle;
19
20
 
75
76
  // t=0 means it's at the start of the command's chunk, t=1 it's at the end
76
77
  struct path_lineto
77
78
  {
78
 
    path_lineto(bool m, NR::Point pp) : isMoveTo(m), p(pp), piece(-1), t(0) {}
79
 
    path_lineto(bool m, NR::Point pp, int pie, double tt) : isMoveTo(m), p(pp), piece(pie), t(tt) {}
 
79
    path_lineto(bool m, Geom::Point pp) : isMoveTo(m), p(pp), piece(-1), t(0), closed(false) {}
 
80
    path_lineto(bool m, Geom::Point pp, int pie, double tt) : isMoveTo(m), p(pp), piece(pie), t(tt), closed(false) {}
80
81
    
81
82
    int isMoveTo;
82
 
    NR::Point  p;
 
83
    Geom::Point  p;
83
84
    int piece;
84
85
    double t;
 
86
    bool closed; // true if subpath is closed (this point is the last point of a closed subpath)
85
87
  };
86
88
  
87
89
  std::vector<path_lineto> pts;
98
100
  // the commands...
99
101
  int ForcePoint();
100
102
  int Close();
101
 
  int MoveTo ( NR::Point const &ip);
102
 
  int LineTo ( NR::Point const &ip);
103
 
  int CubicTo ( NR::Point const &ip,  NR::Point const &iStD,  NR::Point const &iEnD);
104
 
  int ArcTo ( NR::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise);
105
 
  int IntermBezierTo ( NR::Point const &ip);    // add a quadratic bezier spline control point
106
 
  int BezierTo ( NR::Point const &ip);  // quadratic bezier spline to this point (control points can be added after this)
 
103
  int MoveTo ( Geom::Point const &ip);
 
104
  int LineTo ( Geom::Point const &ip);
 
105
  int CubicTo ( Geom::Point const &ip,  Geom::Point const &iStD,  Geom::Point const &iEnD);
 
106
  int ArcTo ( Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise);
 
107
  int IntermBezierTo ( Geom::Point const &ip);  // add a quadratic bezier spline control point
 
108
  int BezierTo ( Geom::Point const &ip);        // quadratic bezier spline to this point (control points can be added after this)
107
109
  int TempBezierTo();   // start a quadratic bezier spline (control points can be added after this)
108
110
  int EndBezierTo();
109
 
  int EndBezierTo ( NR::Point const &ip);       // ends a quadratic bezier spline (for curves started with TempBezierTo)
 
111
  int EndBezierTo ( Geom::Point const &ip);     // ends a quadratic bezier spline (for curves started with TempBezierTo)
110
112
 
111
113
  // transforms a description in a polyline (for stroking and filling)
112
114
  // treshhold is the max length^2 (sort of)
119
121
  // creation of the polyline (you can tinker with these function if you want)
120
122
  void SetBackData (bool nVal); // has back data?
121
123
  void ResetPoints(); // resets to the empty polyline
122
 
  int AddPoint ( NR::Point const &iPt, bool mvto = false);      // add point
123
 
  int AddPoint ( NR::Point const &iPt, int ip, double it, bool mvto = false);
124
 
  int AddForcedPoint ( NR::Point const &iPt);   // add point
125
 
  int AddForcedPoint ( NR::Point const &iPt, int ip, double it);
126
 
  int ReplacePoint(NR::Point const &iPt);  // replace point
 
124
  int AddPoint ( Geom::Point const &iPt, bool mvto = false);    // add point
 
125
  int AddPoint ( Geom::Point const &iPt, int ip, double it, bool mvto = false);
 
126
  int AddForcedPoint ( Geom::Point const &iPt); // add point
 
127
  int AddForcedPoint ( Geom::Point const &iPt, int ip, double it);
 
128
  int ReplacePoint(Geom::Point const &iPt);  // replace point
127
129
 
128
130
  // transform in a polygon (in a graph, in fact; a subsequent call to ConvertToShape is needed)
129
131
  //  - fills the polyline; justAdd=true doesn't reset the Shape dest, but simply adds the polyline into it
162
164
  // piece is a command no in the command list
163
165
  // "at" is an abcissis on the path portion associated with this command
164
166
  // 0=beginning of portion, 1=end of portion.
165
 
  void PointAt (int piece, double at, NR::Point & pos);
166
 
  void PointAndTangentAt (int piece, double at, NR::Point & pos, NR::Point & tgt);
 
167
  void PointAt (int piece, double at, Geom::Point & pos);
 
168
  void PointAndTangentAt (int piece, double at, Geom::Point & pos, Geom::Point & tgt);
167
169
 
168
170
  // last control point before the command i (i included)
169
171
  // used when dealing with quadratic bezier spline, cause these can contain arbitrarily many commands
170
 
  const NR::Point PrevPoint (const int i) const;
 
172
  const Geom::Point PrevPoint (const int i) const;
171
173
  
172
174
  // dash the polyline
173
175
  // the result is stored in the polyline, so you lose the original. make a copy before if needed
176
178
  void  DashPolylineFromStyle(SPStyle *style, float scale, float min_len);
177
179
  
178
180
  //utilitaire pour inkscape
179
 
  void  LoadArtBPath(void *iP,NR::Matrix const &tr,bool doTransformation);
180
 
        void* MakeArtBPath();
181
 
        
182
 
        void  Transform(const NR::Matrix &trans);
183
 
  
 
181
  void  LoadPath(Geom::Path const &path, Geom::Matrix const &tr, bool doTransformation, bool append = false);
 
182
  void  LoadPathVector(Geom::PathVector const &pv, Geom::Matrix const &tr, bool doTransformation);
 
183
  void  LoadPathVector(Geom::PathVector const &pv);
 
184
  Geom::PathVector* MakePathVector();
 
185
 
 
186
  void  Transform(const Geom::Matrix &trans);
 
187
 
184
188
  // decompose le chemin en ses sous-chemin
185
189
  // killNoSurf=true -> oublie les chemins de surface nulle
186
190
  Path**      SubPaths(int &outNb,bool killNoSurf);
203
207
    double        t;
204
208
  };
205
209
  cut_position*    CurvilignToPosition(int nbCv,double* cvAbs,int &nbCut);
206
 
  cut_position    PointToCurvilignPosition(NR::Point const &pos) const;
 
210
  cut_position    PointToCurvilignPosition(Geom::Point const &pos, unsigned seg = 0) const;
207
211
  //Should this take a cut_position as a param?
208
212
  double           PositionToLength(int piece, double t);
209
213
  
220
224
  // utilitary functions for the path contruction
221
225
  void CancelBezier ();
222
226
  void CloseSubpath();
223
 
  void InsertMoveTo (NR::Point const &iPt,int at);
 
227
  void InsertMoveTo (Geom::Point const &iPt,int at);
224
228
  void InsertForcePoint (int at);
225
 
  void InsertLineTo (NR::Point const &iPt,int at);
226
 
  void InsertArcTo (NR::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise,int at);
227
 
  void InsertCubicTo (NR::Point const &ip,  NR::Point const &iStD,  NR::Point const &iEnD,int at);
228
 
  void InsertBezierTo (NR::Point const &iPt,int iNb,int at);
229
 
  void InsertIntermBezierTo (NR::Point const &iPt,int at);
 
229
  void InsertLineTo (Geom::Point const &iPt,int at);
 
230
  void InsertArcTo (Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise,int at);
 
231
  void InsertCubicTo (Geom::Point const &ip,  Geom::Point const &iStD,  Geom::Point const &iEnD,int at);
 
232
  void InsertBezierTo (Geom::Point const &iPt,int iNb,int at);
 
233
  void InsertIntermBezierTo (Geom::Point const &iPt,int at);
230
234
  
231
235
  // creation of dashes: take the polyline given by spP (length spL) and dash it according to head, body, etc. put the result in
232
236
  // the polyline of this instance
234
238
 
235
239
  // Functions used by the conversion.
236
240
  // they append points to the polyline
237
 
  void DoArc ( NR::Point const &iS,  NR::Point const &iE, double rx, double ry,
 
241
  void DoArc ( Geom::Point const &iS,  Geom::Point const &iE, double rx, double ry,
238
242
              double angle, bool large, bool wise, double tresh);
239
 
  void RecCubicTo ( NR::Point const &iS,  NR::Point const &iSd,  NR::Point const &iE,  NR::Point const &iEd, double tresh, int lev,
 
243
  void RecCubicTo ( Geom::Point const &iS,  Geom::Point const &iSd,  Geom::Point const &iE,  Geom::Point const &iEd, double tresh, int lev,
240
244
                   double maxL = -1.0);
241
 
  void RecBezierTo ( NR::Point const &iPt,  NR::Point const &iS,  NR::Point const &iE, double treshhold, int lev, double maxL = -1.0);
 
245
  void RecBezierTo ( Geom::Point const &iPt,  Geom::Point const &iS,  Geom::Point const &iE, double treshhold, int lev, double maxL = -1.0);
242
246
 
243
 
  void DoArc ( NR::Point const &iS,  NR::Point const &iE, double rx, double ry,
 
247
  void DoArc ( Geom::Point const &iS,  Geom::Point const &iE, double rx, double ry,
244
248
              double angle, bool large, bool wise, double tresh, int piece);
245
 
  void RecCubicTo ( NR::Point const &iS,  NR::Point const &iSd,  NR::Point const &iE,  NR::Point const &iEd, double tresh, int lev,
 
249
  void RecCubicTo ( Geom::Point const &iS,  Geom::Point const &iSd,  Geom::Point const &iE,  Geom::Point const &iEd, double tresh, int lev,
246
250
                   double st, double et, int piece);
247
 
  void RecBezierTo ( NR::Point const &iPt,  NR::Point const &iS, const  NR::Point &iE, double treshhold, int lev, double st, double et,
 
251
  void RecBezierTo ( Geom::Point const &iPt,  Geom::Point const &iS, const  Geom::Point &iE, double treshhold, int lev, double st, double et,
248
252
                    int piece);
249
253
 
250
254
  // don't pay attention
255
259
    double tSt, tEn;
256
260
    double off_dec;
257
261
  };
258
 
  void DoArc ( NR::Point const &iS,  NR::Point const &iE, double rx, double ry,
 
262
  void DoArc ( Geom::Point const &iS,  Geom::Point const &iE, double rx, double ry,
259
263
              double angle, bool large, bool wise, double tresh, int piece,
260
264
              offset_orig & orig);
261
 
  void RecCubicTo ( NR::Point const &iS,  NR::Point const &iSd,  NR::Point const &iE,  NR::Point const &iEd, double tresh, int lev,
 
265
  void RecCubicTo ( Geom::Point const &iS,  Geom::Point const &iSd,  Geom::Point const &iE,  Geom::Point const &iEd, double tresh, int lev,
262
266
                   double st, double et, int piece, offset_orig & orig);
263
 
  void RecBezierTo ( NR::Point const &iPt,  NR::Point const &iS,  NR::Point const &iE, double treshhold, int lev, double st, double et,
 
267
  void RecBezierTo ( Geom::Point const &iPt,  Geom::Point const &iS,  Geom::Point const &iE, double treshhold, int lev, double st, double et,
264
268
                    int piece, offset_orig & orig);
265
269
 
266
 
  static void ArcAngles ( NR::Point const &iS,  NR::Point const &iE, double rx,
 
270
  static void ArcAngles ( Geom::Point const &iS,  Geom::Point const &iE, double rx,
267
271
                         double ry, double angle, bool large, bool wise,
268
272
                         double &sang, double &eang);
269
 
  static void QuadraticPoint (double t,  NR::Point &oPt,   NR::Point const &iS,   NR::Point const &iM,   NR::Point const &iE);
270
 
  static void CubicTangent (double t,  NR::Point &oPt,  NR::Point const &iS,
271
 
                             NR::Point const &iSd,  NR::Point const &iE,
272
 
                             NR::Point const &iEd);
 
273
  static void QuadraticPoint (double t,  Geom::Point &oPt,   Geom::Point const &iS,   Geom::Point const &iM,   Geom::Point const &iE);
 
274
  static void CubicTangent (double t,  Geom::Point &oPt,  Geom::Point const &iS,
 
275
                             Geom::Point const &iSd,  Geom::Point const &iE,
 
276
                             Geom::Point const &iEd);
273
277
 
274
278
  struct outline_callback_data
275
279
  {
313
317
                           Path * dest, outline_callbacks & calls,
314
318
                           double tolerance, double width, JoinType join,
315
319
                           ButtType butt, double miter, bool closeIfNeeded,
316
 
                           bool skipMoveto, NR::Point & lastP, NR::Point & lastT);
 
320
                           bool skipMoveto, Geom::Point & lastP, Geom::Point & lastT);
317
321
  void DoStroke(int off, int N, Shape *dest, bool doClose, double width, JoinType join,
318
322
                ButtType butt, double miter, bool justAdd = false);
319
323
 
320
 
  static void TangentOnSegAt(double at, NR::Point const &iS, PathDescrLineTo const &fin,
321
 
                             NR::Point &pos, NR::Point &tgt, double &len);
322
 
  static void TangentOnArcAt(double at, NR::Point const &iS, PathDescrArcTo const &fin,
323
 
                             NR::Point &pos, NR::Point &tgt, double &len, double &rad);
324
 
  static void TangentOnCubAt (double at, NR::Point const &iS, PathDescrCubicTo const &fin, bool before,
325
 
                              NR::Point &pos, NR::Point &tgt, double &len, double &rad);
326
 
  static void TangentOnBezAt (double at, NR::Point const &iS,
 
324
  static void TangentOnSegAt(double at, Geom::Point const &iS, PathDescrLineTo const &fin,
 
325
                             Geom::Point &pos, Geom::Point &tgt, double &len);
 
326
  static void TangentOnArcAt(double at, Geom::Point const &iS, PathDescrArcTo const &fin,
 
327
                             Geom::Point &pos, Geom::Point &tgt, double &len, double &rad);
 
328
  static void TangentOnCubAt (double at, Geom::Point const &iS, PathDescrCubicTo const &fin, bool before,
 
329
                              Geom::Point &pos, Geom::Point &tgt, double &len, double &rad);
 
330
  static void TangentOnBezAt (double at, Geom::Point const &iS,
327
331
                              PathDescrIntermBezierTo & mid,
328
332
                              PathDescrBezierTo & fin, bool before,
329
 
                              NR::Point & pos, NR::Point & tgt, double &len, double &rad);
330
 
  static void OutlineJoin (Path * dest, NR::Point pos, NR::Point stNor, NR::Point enNor,
 
333
                              Geom::Point & pos, Geom::Point & tgt, double &len, double &rad);
 
334
  static void OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor,
331
335
                           double width, JoinType join, double miter);
332
336
 
333
 
  static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, NR::Point const &curX);
 
337
  static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, Geom::Point const &curX);
334
338
 
335
339
  static void RecStdCubicTo (outline_callback_data * data, double tol,
336
340
                             double width, int lev);
344
348
 
345
349
 
346
350
  // fonctions annexes pour le stroke
347
 
  static void DoButt (Shape * dest, double width, ButtType butt, NR::Point pos,
348
 
                      NR::Point dir, int &leftNo, int &rightNo);
349
 
  static void DoJoin (Shape * dest, double width, JoinType join, NR::Point pos,
350
 
                      NR::Point prev, NR::Point next, double miter, double prevL,
 
351
  static void DoButt (Shape * dest, double width, ButtType butt, Geom::Point pos,
 
352
                      Geom::Point dir, int &leftNo, int &rightNo);
 
353
  static void DoJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
 
354
                      Geom::Point prev, Geom::Point next, double miter, double prevL,
351
355
                      double nextL, int *stNo, int *enNo);
352
 
  static void DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos,
353
 
                          NR::Point prev, NR::Point next, double miter, double prevL,
 
356
  static void DoLeftJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
 
357
                          Geom::Point prev, Geom::Point next, double miter, double prevL,
354
358
                          double nextL, int &leftStNo, int &leftEnNo,int pathID=-1,int pieceID=0,double tID=0.0);
355
 
  static void DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos,
356
 
                           NR::Point prev, NR::Point next, double miter, double prevL,
 
359
  static void DoRightJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
 
360
                           Geom::Point prev, Geom::Point next, double miter, double prevL,
357
361
                           double nextL, int &rightStNo, int &rightEnNo,int pathID=-1,int pieceID=0,double tID=0.0);
358
362
    static void RecRound (Shape * dest, int sNo, int eNo,
359
 
            NR::Point const &iS, NR::Point const &iE,
360
 
            NR::Point const &nS, NR::Point const &nE,
361
 
            NR::Point &origine,float width);
 
363
            Geom::Point const &iS, Geom::Point const &iE,
 
364
            Geom::Point const &nS, Geom::Point const &nE,
 
365
            Geom::Point &origine,float width);
362
366
 
363
367
 
364
368
  void DoSimplify(int off, int N, double treshhold);
365
369
  bool AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &res, int &worstP);
366
 
  static bool FitCubic(NR::Point const &start,
 
370
  static bool FitCubic(Geom::Point const &start,
367
371
                       PathDescrCubicTo &res,
368
372
                       double *Xk, double *Yk, double *Qk, double *tk, int nbPt);
369
373
  
379
383
  };
380
384
  bool   AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubicTo & res,int &worstP);
381
385
  bool   ExtendFit(int off, int N, fitting_tables &data,double treshhold, PathDescrCubicTo & res,int &worstP);
382
 
  double RaffineTk (NR::Point pt, NR::Point p0, NR::Point p1, NR::Point p2, NR::Point p3, double it);
 
386
  double RaffineTk (Geom::Point pt, Geom::Point p0, Geom::Point p1, Geom::Point p2, Geom::Point p3, double it);
383
387
  void   FlushPendingAddition(Path* dest,PathDescr *lastAddition,PathDescrCubicTo &lastCubic,int lastAD);
 
388
 
 
389
private:
 
390
    void  AddCurve(Geom::Curve const &c);
 
391
 
384
392
};
385
393
#endif
386
394