1
#define INKSCAPE_LPE_LINE_SEGMENT_CPP
4
* LPE <line_segment> implementation
11
* Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
13
* Released under GNU GPL, read the file 'COPYING' for more information
16
#include "live_effects/lpe-line_segment.h"
17
#include "lpe-tool-context.h"
19
#include <2geom/pathvector.h>
20
#include <2geom/geom.h>
21
#include <2geom/bezier-curve.h>
24
namespace LivePathEffect {
26
static const Util::EnumData<EndType> EndTypeData[] = {
27
{END_CLOSED , N_("Closed"), "closed"},
28
{END_OPEN_INITIAL , N_("Open start"), "open_start"},
29
{END_OPEN_FINAL , N_("Open end"), "open_end"},
30
{END_OPEN_BOTH , N_("Open both"), "open_both"},
32
static const Util::EnumDataConverter<EndType> EndTypeConverter(EndTypeData, sizeof(EndTypeData)/sizeof(*EndTypeData));
34
LPELineSegment::LPELineSegment(LivePathEffectObject *lpeobject) :
36
end_type(_("End type"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH)
38
/* register all your parameters here, so Inkscape knows which parameters this effect has: */
39
registerParameter( dynamic_cast<Parameter *>(&end_type) );
42
LPELineSegment::~LPELineSegment()
48
LPELineSegment::doBeforeEffect (SPLPEItem *lpeitem)
50
lpetool_get_limiting_bbox_corners(SP_OBJECT_DOCUMENT(lpeitem), bboxA, bboxB);
53
std::vector<Geom::Path>
54
LPELineSegment::doEffect_path (std::vector<Geom::Path> const & path_in)
56
std::vector<Geom::Path> output;
58
A = initialPoint(path_in);
59
B = finalPoint(path_in);
61
Geom::Rect dummyRect(bboxA, bboxB);
62
boost::optional<Geom::LineSegment> intersection_segment = Geom::rect_line_intersect(dummyRect, Geom::Line(A, B));
64
if (!intersection_segment) {
65
g_print ("Possible error - no intersection with limiting bounding box.\n");
69
if (end_type == END_OPEN_INITIAL || end_type == END_OPEN_BOTH) {
70
A = (*intersection_segment).initialPoint();
73
if (end_type == END_OPEN_FINAL || end_type == END_OPEN_BOTH) {
74
B = (*intersection_segment).finalPoint();
78
path.appendNew<Geom::LineSegment>(B);
80
output.push_back(path);
85
} //namespace LivePathEffect
86
} /* namespace Inkscape */
91
c-file-style:"stroustrup"
92
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
97
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :