summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-fill-between-many.cpp
blob: 7cf354044fac33aad29e37f8f3c71f5887ca2825 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright (C) Theodore Janeczko 2012 <flutterguy317@gmail.com>
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#include <gtkmm/box.h>

#include "live_effects/lpe-fill-between-many.h"

#include "display/curve.h"
#include "sp-item.h"
#include "2geom/path.h"
#include "sp-shape.h"
#include "sp-text.h"
#include "2geom/bezier-curve.h"

#include <glibmm/i18n.h>

namespace Inkscape {
namespace LivePathEffect {

LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) :
    Effect(lpeobject),
    linked_paths(_("Linked path:"), _("Paths from which to take the original path data"), "linkedpaths", &wr, this)
{
    registerParameter( dynamic_cast<Parameter *>(&linked_paths) );
    //perceived_path = true;
}

LPEFillBetweenMany::~LPEFillBetweenMany()
{

}

void LPEFillBetweenMany::doEffect (SPCurve * curve)
{
    std::vector<Geom::Path> res_pathv;
    SPItem * firstObj = NULL;
    for (std::vector<PathAndDirection*>::iterator iter = linked_paths._vector.begin(); iter != linked_paths._vector.end(); iter++) {
        SPObject *obj;
        if ((*iter)->ref.isAttached() && (obj = (*iter)->ref.getObject()) && SP_IS_ITEM(obj) && !(*iter)->_pathvector.empty()) {
            Geom::Path linked_path;
            if ((*iter)->reversed) {
                linked_path = (*iter)->_pathvector.front().reverse();
            } else {
                linked_path = (*iter)->_pathvector.front();
            }
            
            if (!res_pathv.empty()) {
                linked_path = linked_path * SP_ITEM(obj)->getRelativeTransform(firstObj);
                res_pathv.front().appendNew<Geom::LineSegment>(linked_path.initialPoint());
                res_pathv.front().append(linked_path);
            } else {
                firstObj = SP_ITEM(obj);
                res_pathv.push_back(linked_path);
            }
        }
    }
    if (!res_pathv.empty()) {
        res_pathv.front().close();
    }
    curve->set_pathvector(res_pathv);
}

} // namespace LivePathEffect
} /* namespace Inkscape */

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :