diff --git a/src/display/curve.h b/src/display/curve.h
index 5be8f5a4e48497157556b898acfc9489cca97e34..79a385b09f2a9e5eee526e8e6a269b10077d90b8 100644 (file)
--- a/src/display/curve.h
+++ b/src/display/curve.h
#define SEEN_DISPLAY_CURVE_H
/** \file
#define SEEN_DISPLAY_CURVE_H
/** \file
- * Wrapper around an array of NArtBpath objects.
+ * Wrapper around a Geom::PathVector objects.
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
+ * Copyright (C) 2008 Johan Engelen
*
* Released under GNU GPL
*/
*
* Released under GNU GPL
*/
#include <glib/gtypes.h>
#include <glib/gslist.h>
#include <glib/gtypes.h>
#include <glib/gslist.h>
-#include "libnr/nr-forward.h"
-#include "libnr/nr-point.h"
-
-/// Wrapper around NArtBpath.
-struct SPCurve {
- gint refcount;
- NArtBpath *_bpath;
-
- /// Index in bpath[] of NR_END element.
- gint end;
-
- /// Allocated size (i.e., capacity) of bpath[] array. Not to be confused
- /// with the SP_CURVE_LENGTH macro, which returns the logical length of
- /// the path (i.e., index of NR_END).
- gint length;
-
- /// Index in bpath[] of the start (i.e., moveto element) of the last
- /// subpath in this path.
- gint substart;
-
- /// Previous moveto position.
- /// \note This is used for coalescing moveto's, whereas if we're to
- /// conform to the SVG spec then we mustn't coalesce movetos if we have
- /// midpoint markers. Ref:
- /// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
- /// (first subitem of the item about zero-length path segments)
- NR::Point movePos;
-
- /// True iff current point is defined. Initially false for a new curve;
- /// becomes true after moveto; becomes false on closepath. Curveto,
- /// lineto etc. require hascpt; hascpt remains true after lineto/curveto.
- bool hascpt : 1;
-
- /// True iff previous was moveto.
- bool posSet : 1;
-
- /// True iff bpath end is moving.
- bool moving : 1;
-
- /// True iff all subpaths are closed.
- bool closed : 1;
-};
+#include <2geom/forward.h>
+
+#include <boost/optional.hpp>
+
+class SPCurve {
+public:
+ /* Constructors */
+ explicit SPCurve();
+ explicit SPCurve(Geom::PathVector const& pathv);
+ static SPCurve * new_from_rect(Geom::Rect const &rect);
-#define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->end)
-#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->_bpath)
-#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->_bpath + (i))
+ virtual ~SPCurve();
-/* Constructors */
+ void set_pathvector(Geom::PathVector const & new_pathv);
+ Geom::PathVector const & get_pathvector() const;
-SPCurve *sp_curve_new();
-SPCurve *sp_curve_new_sized(gint length);
-SPCurve *sp_curve_new_from_bpath(NArtBpath *bpath);
-SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]);
+ SPCurve * ref();
+ SPCurve * unref();
-SPCurve *sp_curve_ref(SPCurve *curve);
-SPCurve *sp_curve_unref(SPCurve *curve);
+ SPCurve * copy() const;
-SPCurve *sp_curve_copy(SPCurve *curve);
-SPCurve *sp_curve_concat(GSList const *list);
-GSList *sp_curve_split(SPCurve const *curve);
-void sp_curve_transform(SPCurve *curve, NR::Matrix const &);
-void sp_curve_transform(SPCurve *curve, NR::translate const &);
-void sp_curve_stretch_endpoints(SPCurve *curve, NR::Point const &, NR::Point const &);
-void sp_curve_move_endpoints(SPCurve *curve, NR::Point const &,
- NR::Point const &);
+ guint get_segment_count() const;
+ guint nodes_in_path() const;
-/* Methods */
+ bool is_empty() const;
+ bool is_closed() const;
+ Geom::Curve const * last_segment() const;
+ Geom::Path const * last_path() const;
+ Geom::Curve const * first_segment() const;
+ Geom::Path const * first_path() const;
+ boost::optional<Geom::Point> first_point() const;
+ boost::optional<Geom::Point> last_point() const;
+ boost::optional<Geom::Point> second_point() const;
+ boost::optional<Geom::Point> penultimate_point() const;
-void sp_curve_reset(SPCurve *curve);
+ void reset();
-void sp_curve_moveto(SPCurve *curve, NR::Point const &p);
-void sp_curve_moveto(SPCurve *curve, gdouble x, gdouble y);
-void sp_curve_lineto(SPCurve *curve, NR::Point const &p);
-void sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y);
-void sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y);
-void sp_curve_curveto(SPCurve *curve, NR::Point const &p0, NR::Point const &p1, NR::Point const &p2);
-void sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
-void sp_curve_closepath(SPCurve *curve);
-void sp_curve_closepath_current(SPCurve *curve);
+ void moveto(Geom::Point const &p);
+ void moveto(gdouble x, gdouble y);
+ void lineto(Geom::Point const &p);
+ void lineto(gdouble x, gdouble y);
+ void quadto(Geom::Point const &p1, Geom::Point const &p2);
+ void quadto(gdouble x1, gdouble y1, gdouble x2, gdouble y2);
+ void curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2);
+ void curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
+ void closepath();
+ void closepath_current();
+ void backspace();
-SPCurve *sp_curve_append_continuous(SPCurve *c0, SPCurve const *c1, gdouble tolerance);
+ void transform(Geom::Matrix const &m);
+ void stretch_endpoints(Geom::Point const &, Geom::Point const &);
+ void move_endpoints(Geom::Point const &, Geom::Point const &);
+ void last_point_additive_move(Geom::Point const & p);
-#define sp_curve_is_empty sp_curve_empty
-bool sp_curve_empty(SPCurve *curve);
-NArtBpath *sp_curve_last_bpath(SPCurve const *curve);
-NArtBpath *sp_curve_first_bpath(SPCurve const *curve);
-NR::Point sp_curve_first_point(SPCurve const *curve);
-NR::Point sp_curve_last_point(SPCurve const *curve);
-NR::Point sp_curve_second_point(SPCurve const *curve);
-NR::Point sp_curve_penultimate_point(SPCurve const *curve);
+ void append(SPCurve const *curve2, bool use_lineto);
+ SPCurve * append_continuous(SPCurve const *c1, gdouble tolerance);
+ SPCurve * create_reverse() const;
-void sp_curve_append(SPCurve *curve, SPCurve const *curve2, bool use_lineto);
-SPCurve *sp_curve_reverse(SPCurve const *curve);
-void sp_curve_backspace(SPCurve *curve);
+ GSList * split() const;
+ static SPCurve * concat(GSList const *list);
+protected:
+ gint _refcount;
+
+ Geom::PathVector _pathv;
+
+private:
+ // Don't implement these:
+ SPCurve(const SPCurve&);
+ SPCurve& operator=(const SPCurve&);
+};
#endif /* !SEEN_DISPLAY_CURVE_H */
#endif /* !SEEN_DISPLAY_CURVE_H */
fill-column:99
End:
*/
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :