Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
parser.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2008 Aaron Spike <aaron@ekips.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it either under the terms of the GNU Lesser General Public
6 * License version 2.1 as published by the Free Software Foundation
7 * (the "LGPL") or, at your option, under the terms of the Mozilla
8 * Public License Version 1.1 (the "MPL"). If you do not alter this
9 * notice, a recipient may use your version of this file under either
10 * the MPL or the LGPL.
11 *
12 * You should have received a copy of the LGPL along with this library
13 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 * You should have received a copy of the MPL along with this library
16 * in the file COPYING-MPL-1.1
17 *
18 * The contents of this file are subject to the Mozilla Public License
19 * Version 1.1 (the "License"); you may not use this file except in
20 * compliance with the License. You may obtain a copy of the License at
21 * http://www.mozilla.org/MPL/
22 *
23 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
24 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
25 * the specific language governing rights and limitations.
26 *
27 */
28
29#include <boost/python.hpp>
30
31#include "py2geom.h"
32#include "helpers.h"
33
34#include "2geom/path-sink.h"
36
37
38using namespace boost::python;
39
42
43void (Geom::PathSink::*feed_path)(Geom::Path const &) = &Geom::PathSink::feed;
44void (Geom::PathSink::*feed_pathvector)(Geom::PathVector const &) = &Geom::PathSink::feed;
45
46class PathSinkWrap: public Geom::PathSink, public wrapper<Geom::PathSink> {
47 void moveTo(Geom::Point const &p) {this->get_override("moveTo")(p);}
48 void lineTo(Geom::Point const &p) {this->get_override("lineTo")(p);}
49 void curveTo(Geom::Point const &c0, Geom::Point const &c1, Geom::Point const &p) {this->get_override("curveTo")(c0, c1, p);}
50 void quadTo(Geom::Point const &c, Geom::Point const &p) {this->get_override("quadTo")(c, p);}
51 void arcTo(double rx, double ry, double angle, bool large_arc, bool sweep, Geom::Point const &p) {this->get_override("arcTo")(rx, ry, angle, large_arc, sweep, p);}
52 bool backspace() {return this->get_override("backspace")();}
53 void closePath() {this->get_override("closePath")();}
54 void flush() {this->get_override("flush")();}
55};
56
58 def("parse_svg_path", parse_svg_path_str_sink);
59 def("parse_svg_path", parse_svg_path_str);
60 def("read_svgd", Geom::read_svgd);
61
62 class_<PathSinkWrap, boost::noncopyable>("PathSink")
63 .def("moveTo", pure_virtual(&Geom::PathSink::moveTo))
64 .def("lineTo", pure_virtual(&Geom::PathSink::lineTo))
65 .def("curveTo", pure_virtual(&Geom::PathSink::curveTo))
66 .def("quadTo", pure_virtual(&Geom::PathSink::quadTo))
67 .def("arcTo", pure_virtual(&Geom::PathSink::arcTo))
68 .def("backspace", pure_virtual(&Geom::PathSink::backspace))
69 .def("closePath", pure_virtual(&Geom::PathSink::closePath))
70 .def("flush", pure_virtual(&Geom::PathSink::flush))
71 .def("feed", feed_path)
72 .def("feed", feed_pathvector)
73 ;
74};
75
76/*
77 Local Variables:
78 mode:c++
79 c-file-style:"stroustrup"
80 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
81 indent-tabs-mode:nil
82 fill-column:99
83 End:
84*/
85// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
void(Geom::PathSink::* feed_pathvector)(Geom::PathVector const &)
Definition parser.cpp:44
void(* parse_svg_path_str_sink)(char const *, Geom::PathSink &)
Definition parser.cpp:40
void(Geom::PathSink::* feed_path)(Geom::Path const &)
Definition parser.cpp:43
void wrap_parser()
Definition parser.cpp:57
Geom::PathVector(* parse_svg_path_str)(char const *)
Definition parser.cpp:41
Callback interface for processing path data.
Definition path-sink.h:56
virtual void arcTo(Coord rx, Coord ry, Coord angle, bool large_arc, bool sweep, Point const &p)=0
Output an elliptical arc segment.
virtual void flush()=0
Flush any internal state of the generator.
virtual void lineTo(Point const &p)=0
Output a line segment.
virtual void quadTo(Point const &c, Point const &p)=0
Output a cubic Bezier segment.
virtual void closePath()=0
Close the current path with a line segment.
virtual void curveTo(Point const &c0, Point const &c1, Point const &p)=0
Output a quadratic Bezier segment.
virtual bool backspace()
Undo the last segment.
Definition path-sink.h:86
virtual void moveTo(Point const &p)=0
Move to a different point without creating a segment.
Sequence of subpaths.
Definition pathvector.h:122
Two-dimensional point that doubles as a vector.
Definition point.h:66
Path and its polyline approximation.
Definition Path.h:93
double c[8][4]
void parse_svg_path(char const *str, PathSink &sink)
Feed SVG path data to the specified sink.
PathVector read_svgd(char const *filename)
Create path vector from SVG path data stored in a file.
Various utility functions.
Definition affine.h:22
callback interface for SVG path data
parse SVG path specifications