index bf11192dd23cf5778947f4cf93260f310fb8595e..0c0c3d69ce360c157d0bba2862ea624f6f504330 100644 (file)
#include "ui/widget/registered-widget.h"
#include "inkscape.h"
#include "verbs.h"
#include "ui/widget/registered-widget.h"
#include "inkscape.h"
#include "verbs.h"
+#include "display/canvas-text.h"
+#include <2geom/sbasis-geometric.h>
namespace Inkscape {
namespace Inkscape {
value(default_value),
defvalue(default_value)
{
value(default_value),
defvalue(default_value)
{
- canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(inkscape_active_desktop()), Geom::Point(0,0), "");
+ SPDesktop *desktop = inkscape_active_desktop(); // FIXME: we shouldn't use this!
+ canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), "");
sp_canvastext_set_text (canvas_text, default_value.c_str());
sp_canvastext_set_coords (canvas_text, 0, 0);
}
sp_canvastext_set_text (canvas_text, default_value.c_str());
sp_canvastext_set_coords (canvas_text, 0, 0);
}
-TextParam::~TextParam()
-{
-}
-
void
TextParam::param_set_default()
{
void
TextParam::param_set_default()
{
sp_canvastext_set_coords (canvas_text, pos);
}
sp_canvastext_set_coords (canvas_text, pos);
}
+void
+TextParam::setPosAndAnchor(const Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
+ const double t, const double length, bool /*use_curvature*/)
+{
+ using namespace Geom;
+
+ Piecewise<D2<SBasis> > pwd2_reparam = arc_length_parametrization(pwd2, 2 , 0.1);
+ double t_reparam = pwd2_reparam.cuts.back() * t;
+ Point pos = pwd2_reparam.valueAt(t_reparam);
+ Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam));
+ Point n = -rot90(dir);
+ double angle = Geom::angle_between(dir, Point(1,0));
+
+ sp_canvastext_set_coords(canvas_text, pos + n * length);
+ sp_canvastext_set_anchor(canvas_text, std::sin(angle), -std::cos(angle));
+}
+
void
TextParam::setAnchor(double x_value, double y_value)
{
void
TextParam::setAnchor(double x_value, double y_value)
{