1 // SPDX-License-Identifier: GPL-2.0-or-later 2 #ifndef SEEN_CANVAS_ITEM_CURVE_H 3 #define SEEN_CANVAS_ITEM_CURVE_H 4 5 /** 6 * A class to represent a single Bezier control curve. 7 */ 8 9 /* 10 * Author: 11 * Tavmjong Bah 12 * 13 * Copyright (C) 2020 Tavmjong Bah 14 * 15 * Rewrite of SPCtrlLine and SPCtrlCurve 16 * 17 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 18 */ 19 20 #include <memory> 21 #include <2geom/path.h> 22 23 #include "canvas-item.h" 24 25 namespace Inkscape { 26 27 class CanvasItemGroup; // A canvas control that contains other canvas controls. 28 29 class CanvasItemCurve : public CanvasItem { 30 31 public: 32 CanvasItemCurve(CanvasItemGroup *group); 33 CanvasItemCurve(CanvasItemGroup *group, Geom::Point const &p0, Geom::Point const &p1); 34 CanvasItemCurve(CanvasItemGroup *group, Geom::Point const &p0, Geom::Point const &p1, 35 Geom::Point const &p2, Geom::Point const &p3); 36 37 // Geometry 38 void set_coords(Geom::Point const &p0, Geom::Point const &p1); 39 void set_coords(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2, Geom::Point const &p3); 40 void set(Geom::BezierCurve &curve); is_line()41 bool is_line() { return _curve->size() == 2; } 42 43 void update(Geom::Affine const &affine) override; 44 double closest_distance_to(Geom::Point const &p); // Maybe not needed 45 46 // Selection 47 bool contains(Geom::Point const &p, double tolerance = 0) override; 48 49 // Display 50 void render(Inkscape::CanvasItemBuffer *buf) override; 51 52 // Properties set_is_fill(bool is_fill)53 void set_is_fill(bool is_fill) { _is_fill = is_fill; } get_is_fill()54 bool get_is_fill() { return _is_fill; } set_corner0(int corner0)55 void set_corner0(int corner0) { _corner0 = corner0; } // Used for meshes get_corner0()56 int get_corner0() { return _corner0; } set_corner1(int corner1)57 void set_corner1(int corner1) { _corner1 = corner1; } get_corner1()58 int get_corner1() { return _corner1; } 59 60 protected: 61 std::unique_ptr<Geom::BezierCurve> _curve; 62 63 bool _is_fill = true; // Fill or stroke, used by meshes. 64 65 int _corner0 = -1; // For meshes 66 int _corner1 = -1; // For meshes 67 }; 68 69 70 } // namespace Inkscape 71 72 #endif // SEEN_CANVAS_ITEM_CURVE_H 73 74 /* 75 Local Variables: 76 mode:c++ 77 c-file-style:"stroustrup" 78 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 79 indent-tabs-mode:nil 80 fill-column:99 81 End: 82 */ 83 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : 84