Code

GSoC C++-ificiation merge and cleanup.
[inkscape.git] / src / live_effects / lpe-text_label.cpp
1 #define INKSCAPE_LPE_TEXT_LABEL_CPP
2 /** \file
3  * LPE <text_label> implementation
4  */
5 /*
6  * Authors:
7  *   Maximilian Albert
8  *   Johan Engelen
9  *
10  * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include "live_effects/lpe-text_label.h"
17 namespace Inkscape {
18 namespace LivePathEffect {
20 LPETextLabel::LPETextLabel(LivePathEffectObject *lpeobject) :
21     Effect(lpeobject),
22     label(_("Label"), _("Text label attached to the path"), "label", &wr, this, "This is a label")
23 {
24     registerParameter( dynamic_cast<Parameter *>(&label) );
25 }
27 LPETextLabel::~LPETextLabel()
28 {
30 }
32 Geom::Piecewise<Geom::D2<Geom::SBasis> >
33 LPETextLabel::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
34 {
35     using namespace Geom;
37     double t = (pwd2_in.cuts.front() + pwd2_in.cuts.back()) / 2;
38     Point pos(pwd2_in.valueAt(t));
39     Point dir(unit_vector(derivative(pwd2_in).valueAt(t)));
40     Point n(-rot90(dir) * 30);
42     double angle = angle_between(dir, Point(1,0));
43     label.setPos(pos + n);
44     label.setAnchor(std::sin(angle), -std::cos(angle));
46     return pwd2_in;
47 }
49 } //namespace LivePathEffect
50 } /* namespace Inkscape */
52 /*
53   Local Variables:
54   mode:c++
55   c-file-style:"stroustrup"
56   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
57   indent-tabs-mode:nil
58   fill-column:99
59   End:
60 */
61 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :