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

« back to all changes in this revision

Viewing changes to src/display/curve.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:
2
2
#define SEEN_DISPLAY_CURVE_H
3
3
 
4
4
/** \file
5
 
 * Wrapper around an array of NArtBpath objects.
 
5
 * Wrapper around a Geom::PathVector objects.
6
6
 *
7
7
 * Author:
8
8
 *   Lauris Kaplinski <lauris@kaplinski.com>
10
10
 * Copyright (C) 2000 Lauris Kaplinski
11
11
 * Copyright (C) 2000-2001 Ximian, Inc.
12
12
 * Copyright (C) 2002 Lauris Kaplinski
 
13
 * Copyright (C) 2008 Johan Engelen
13
14
 *
14
15
 * Released under GNU GPL
15
16
 */
17
18
#include <glib/gtypes.h>
18
19
#include <glib/gslist.h>
19
20
 
20
 
#include "libnr/nr-forward.h"
21
 
#include "libnr/nr-point.h"
22
 
#include "libnr/nr-rect.h"
23
 
 
24
 
/// Wrapper around NArtBpath.
25
 
struct SPCurve {
26
 
    gint refcount;
27
 
    NArtBpath *_bpath;
28
 
    
29
 
    /// Index in bpath[] of NR_END element.
30
 
    gint end;
31
 
 
32
 
    /// Allocated size (i.e., capacity) of bpath[] array.  Not to be confused 
33
 
    /// with the SP_CURVE_LENGTH macro, which returns the logical length of 
34
 
    /// the path (i.e., index of NR_END).
35
 
    gint length;
36
 
 
37
 
    /// Index in bpath[] of the start (i.e., moveto element) of the last 
38
 
    /// subpath in this path.
39
 
    gint substart;
40
 
 
41
 
    /// Previous moveto position.
42
 
    /// \note This is used for coalescing moveto's, whereas if we're to 
43
 
    /// conform to the SVG spec then we mustn't coalesce movetos if we have 
44
 
    /// midpoint markers.  Ref:
45
 
    /// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
46
 
    /// (first subitem of the item about zero-length path segments)
47
 
    NR::Point movePos;
48
 
 
49
 
    /// True iff current point is defined.  Initially false for a new curve; 
50
 
    /// becomes true after moveto; becomes false on closepath.  Curveto, 
51
 
    /// lineto etc. require hascpt; hascpt remains true after lineto/curveto.
52
 
    bool hascpt : 1;
53
 
    
54
 
    /// True iff previous was moveto.
55
 
    bool posSet : 1;
56
 
 
57
 
    /// True iff bpath end is moving.
58
 
    bool moving : 1;
59
 
    
60
 
    /// True iff all subpaths are closed.
61
 
    bool closed : 1;
 
21
#include <2geom/forward.h>
 
22
 
 
23
#include <boost/optional.hpp>
 
24
 
 
25
class SPCurve {
 
26
public:
 
27
    /* Constructors */
 
28
    explicit SPCurve();
 
29
    explicit SPCurve(Geom::PathVector const& pathv);
 
30
    static SPCurve * new_from_rect(Geom::Rect const &rect);
 
31
 
 
32
    virtual ~SPCurve();
 
33
 
 
34
    void set_pathvector(Geom::PathVector const & new_pathv);
 
35
    Geom::PathVector const & get_pathvector() const;
 
36
 
 
37
    SPCurve * ref();
 
38
    SPCurve * unref();
 
39
 
 
40
    SPCurve * copy() const;
 
41
 
 
42
    guint get_segment_count() const;
 
43
    guint nodes_in_path() const;
 
44
 
 
45
    bool is_empty() const;
 
46
    bool is_closed() const;
 
47
    Geom::Curve const * last_segment() const;
 
48
    Geom::Path const * last_path() const;
 
49
    Geom::Curve const * first_segment() const;
 
50
    Geom::Path const * first_path() const;
 
51
    boost::optional<Geom::Point> first_point() const;
 
52
    boost::optional<Geom::Point> last_point() const;
 
53
    boost::optional<Geom::Point> second_point() const;
 
54
    boost::optional<Geom::Point> penultimate_point() const;
 
55
 
 
56
    void reset();
 
57
 
 
58
    void moveto(Geom::Point const &p);
 
59
    void moveto(gdouble x, gdouble y);
 
60
    void lineto(Geom::Point const &p);
 
61
    void lineto(gdouble x, gdouble y);
 
62
    void quadto(Geom::Point const &p1, Geom::Point const &p2);
 
63
    void quadto(gdouble x1, gdouble y1, gdouble x2, gdouble y2);
 
64
    void curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2);
 
65
    void curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
 
66
    void closepath();
 
67
    void closepath_current();
 
68
    void backspace();
 
69
 
 
70
    void transform(Geom::Matrix const &m);
 
71
    void stretch_endpoints(Geom::Point const &, Geom::Point const &);
 
72
    void move_endpoints(Geom::Point const &, Geom::Point const &);
 
73
    void last_point_additive_move(Geom::Point const & p);
 
74
 
 
75
    void append(SPCurve const *curve2, bool use_lineto);
 
76
    SPCurve * append_continuous(SPCurve const *c1, gdouble tolerance);
 
77
    SPCurve * create_reverse() const;
 
78
 
 
79
    GSList * split() const;
 
80
    static SPCurve * concat(GSList const *list);
 
81
 
 
82
protected:
 
83
    gint _refcount;
 
84
 
 
85
    Geom::PathVector _pathv;
 
86
 
 
87
private:
 
88
    // Don't implement these:
 
89
    SPCurve(const SPCurve&);
 
90
    SPCurve& operator=(const SPCurve&);
62
91
};
63
92
 
64
 
#define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->end)
65
 
#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->_bpath)
66
 
#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->_bpath + (i))
67
 
 
68
 
/* Constructors */
69
 
 
70
 
SPCurve *sp_curve_new();
71
 
SPCurve *sp_curve_new_sized(gint length);
72
 
SPCurve *sp_curve_new_from_bpath(NArtBpath *bpath);
73
 
SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]);
74
 
SPCurve *sp_curve_new_from_rect(NR::Maybe<NR::Rect> const &rect);
75
 
 
76
 
SPCurve *sp_curve_ref(SPCurve *curve);
77
 
SPCurve *sp_curve_unref(SPCurve *curve);
78
 
 
79
 
SPCurve *sp_curve_copy(SPCurve *curve);
80
 
SPCurve *sp_curve_concat(GSList const *list);
81
 
GSList *sp_curve_split(SPCurve const *curve);
82
 
void sp_curve_transform(SPCurve *curve, NR::Matrix const &);
83
 
void sp_curve_transform(SPCurve *curve, NR::translate const &);
84
 
void sp_curve_stretch_endpoints(SPCurve *curve, NR::Point const &, NR::Point const &);
85
 
void sp_curve_move_endpoints(SPCurve *curve, NR::Point const &,
86
 
        NR::Point const &);
87
 
 
88
 
/* Methods */
89
 
 
90
 
void sp_curve_reset(SPCurve *curve);
91
 
 
92
 
void sp_curve_moveto(SPCurve *curve, NR::Point const &p);
93
 
void sp_curve_moveto(SPCurve *curve, gdouble x, gdouble y);
94
 
void sp_curve_lineto(SPCurve *curve, NR::Point const &p);
95
 
void sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y);
96
 
void sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y);
97
 
void sp_curve_curveto(SPCurve *curve, NR::Point const &p0, NR::Point const &p1, NR::Point const &p2);
98
 
void sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
99
 
void sp_curve_closepath(SPCurve *curve);
100
 
void sp_curve_closepath_current(SPCurve *curve);
101
 
 
102
 
SPCurve *sp_curve_append_continuous(SPCurve *c0, SPCurve const *c1, gdouble tolerance);
103
 
 
104
 
#define sp_curve_is_empty sp_curve_empty
105
 
bool sp_curve_empty(SPCurve *curve);
106
 
NArtBpath *sp_curve_last_bpath(SPCurve const *curve);
107
 
NArtBpath *sp_curve_first_bpath(SPCurve const *curve);
108
 
NR::Point sp_curve_first_point(SPCurve const *curve);
109
 
NR::Point sp_curve_last_point(SPCurve const *curve);
110
 
NR::Point sp_curve_second_point(SPCurve const *curve);
111
 
NR::Point sp_curve_penultimate_point(SPCurve const *curve);
112
 
 
113
 
void sp_curve_append(SPCurve *curve, SPCurve const *curve2, bool use_lineto);
114
 
SPCurve *sp_curve_reverse(SPCurve const *curve);
115
 
void sp_curve_backspace(SPCurve *curve);
116
 
 
117
 
 
118
93
#endif /* !SEEN_DISPLAY_CURVE_H */
119
94
 
120
95
/*
126
101
  fill-column:99
127
102
  End:
128
103
*/
129
 
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
 
104
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :