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

« back to all changes in this revision

Viewing changes to src/live_effects/lpe-line_segment.cpp

  • 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:
 
1
#define INKSCAPE_LPE_LINE_SEGMENT_CPP
 
2
 
 
3
/** \file
 
4
 * LPE <line_segment> implementation
 
5
 */
 
6
 
 
7
/*
 
8
 * Authors:
 
9
 *   Maximilian Albert
 
10
 *
 
11
 * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
 
12
 *
 
13
 * Released under GNU GPL, read the file 'COPYING' for more information
 
14
 */
 
15
 
 
16
#include "live_effects/lpe-line_segment.h"
 
17
#include "lpe-tool-context.h"
 
18
 
 
19
#include <2geom/pathvector.h>
 
20
#include <2geom/geom.h>
 
21
#include <2geom/bezier-curve.h>
 
22
 
 
23
namespace Inkscape {
 
24
namespace LivePathEffect {
 
25
 
 
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"},
 
31
};
 
32
static const Util::EnumDataConverter<EndType> EndTypeConverter(EndTypeData, sizeof(EndTypeData)/sizeof(*EndTypeData));
 
33
 
 
34
LPELineSegment::LPELineSegment(LivePathEffectObject *lpeobject) :
 
35
    Effect(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)
 
37
{
 
38
    /* register all your parameters here, so Inkscape knows which parameters this effect has: */
 
39
    registerParameter( dynamic_cast<Parameter *>(&end_type) );
 
40
}
 
41
 
 
42
LPELineSegment::~LPELineSegment()
 
43
{
 
44
 
 
45
}
 
46
 
 
47
void
 
48
LPELineSegment::doBeforeEffect (SPLPEItem *lpeitem)
 
49
{
 
50
    lpetool_get_limiting_bbox_corners(SP_OBJECT_DOCUMENT(lpeitem), bboxA, bboxB);
 
51
}
 
52
 
 
53
std::vector<Geom::Path>
 
54
LPELineSegment::doEffect_path (std::vector<Geom::Path> const & path_in)
 
55
{
 
56
    std::vector<Geom::Path> output;
 
57
 
 
58
    A = initialPoint(path_in);
 
59
    B = finalPoint(path_in);
 
60
 
 
61
    Geom::Rect dummyRect(bboxA, bboxB);
 
62
    boost::optional<Geom::LineSegment> intersection_segment = Geom::rect_line_intersect(dummyRect, Geom::Line(A, B));
 
63
 
 
64
    if (!intersection_segment) {
 
65
        g_print ("Possible error - no intersection with limiting bounding box.\n");
 
66
        return path_in;
 
67
    }
 
68
 
 
69
    if (end_type == END_OPEN_INITIAL || end_type == END_OPEN_BOTH) {
 
70
        A = (*intersection_segment).initialPoint();
 
71
    }
 
72
 
 
73
    if (end_type == END_OPEN_FINAL || end_type == END_OPEN_BOTH) {
 
74
        B = (*intersection_segment).finalPoint();
 
75
    }
 
76
 
 
77
    Geom::Path path(A);
 
78
    path.appendNew<Geom::LineSegment>(B);
 
79
 
 
80
    output.push_back(path);
 
81
 
 
82
    return output;
 
83
}
 
84
 
 
85
} //namespace LivePathEffect
 
86
} /* namespace Inkscape */
 
87
 
 
88
/*
 
89
  Local Variables:
 
90
  mode:c++
 
91
  c-file-style:"stroustrup"
 
92
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
93
  indent-tabs-mode:nil
 
94
  fill-column:99
 
95
  End:
 
96
*/
 
97
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :