20#include <glibmm/i18n.h>
85 if (prefs->getBool(
"/tools/lpetool/selcue")) {
116 if (event.num_press != 1 || event.button != 1) {
148 if (event.num_press == 1 && event.button == 1) {
149 if (mode == LivePathEffect::INVALID_LPE) {
153 _desktop->messageStack()->flash(WARNING_MESSAGE, _(
"Choose a construction tool from the toolbar."));
161 int mode = prefs->getInt(
"/tools/lpetool/mode");
194 if (!is<SPLPEItem>(
item)) {
198 auto lpe = cast<SPLPEItem>(
item)->getCurrentLPE();
213 auto const item = selection->singleItem();
228 g_warning(
"Invalid mode selected: %d", type);
237 std::cerr <<
"Could not access LPE toolbar" << std::endl;
247 auto const ulx = prefs->getDouble(
"/tools/lpetool/bbox_upperleftx", 0);
248 auto const uly = prefs->getDouble(
"/tools/lpetool/bbox_upperlefty", 0);
249 auto const lrx = prefs->getDouble(
"/tools/lpetool/bbox_lowerrightx",
w);
250 auto const lry = prefs->getDouble(
"/tools/lpetool/bbox_lowerrighty", h);
252 return {{ulx, uly}, {lrx, lry}};
259void LpeTool::reset_limiting_bbox()
264 if (!prefs->getBool(
"/tools/lpetool/show_bbox",
true)) {
268 auto const document = _desktop->getDocument();
271 auto const doc2dt = _desktop->doc2dt();
275 canvas_bbox = make_canvasitem<CanvasItemRect>(_desktop->getCanvasControls(),
Geom::Rect(A, B));
276 canvas_bbox->set_stroke(0x0000ffff);
277 canvas_bbox->set_dashed(
true);
281 double t,
double length)
283 auto const pwd2_reparam = arc_length_parametrization(pwd2, 2, 0.1);
284 auto const t_reparam = pwd2_reparam.cuts.back() * t;
285 auto const pos = pwd2_reparam.valueAt(t_reparam);
286 auto const dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam));
287 auto const n = -rot90(dir);
290 canvas_text->
set_coord(pos + n * length);
294void LpeTool::create_measuring_items(
Selection *selection)
297 selection = _desktop->getSelection();
300 bool show = prefs->getBool(
"/tools/lpetool/show_measuring_info",
true);
302 auto tmpgrp = _desktop->getCanvasTemp();
307 if (prefs->getString(
"/tools/lpetool/unit").compare(
"")) {
308 unit = unit_table.getUnit(prefs->getString(
"/tools/lpetool/unit"));
310 unit = unit_table.getUnit(
"px");
314 if (
auto path = cast<SPPath>(
item)) {
316 auto const pwd2 = paths_to_pw(
curve->get_pathvector());
328 canvas_text->set_visible(
false);
331 measuring_items[path] = std::move(canvas_text);
336void LpeTool::delete_measuring_items()
338 measuring_items.clear();
341void LpeTool::update_measuring_items()
347 if (prefs->getString(
"/tools/lpetool/unit").compare(
"")) {
348 unit = unit_table.getUnit(prefs->getString(
"/tools/lpetool/unit"));
350 unit = unit_table.getUnit(
"px");
353 for (
auto &i : measuring_items) {
369void LpeTool::show_measuring_info(
bool show)
371 for (
auto &i : measuring_items) {
372 i.second->set_visible(show);
double arc_length(double t, void *params)
Adaptor that creates 2D functions from 1D ones.
Function defined as discrete pieces.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
void set_anchor(Geom::Point const &anchor_pt)
Set the anchor point, x and y between 0.0 and 1.0.
void set_coord(Geom::Point const &p)
Set a text position.
int acceptsNumClicks() const
static void createAndApply(const char *name, SPDocument *doc, SPItem *item)
SPItemRange items()
Returns a range of selected SPItems.
void clear()
Unselects all selected objects.
SPItem * singleItem()
Returns a single selected item.
Data type representing a typeless value of a preference.
Glib::ustring getEntryName() const
Get the last component of the preference's path.
static Preferences * get()
Access the singleton Preferences object.
void setString(Glib::ustring const &pref_path, Glib::ustring const &value)
Set an UTF-8 string value.
The set of selected SPObjects for a given document and layer model.
void add(XML::Node *repr)
Add an XML node's SPObject to the set of selected objects.
sigc::connection connectChanged(sigc::slot< void(Selection *)> slot)
Connects a slot to be notified of selection changes.
double value(Unit const *u) const
Return the quantity's value in the specified unit.
static double convert(double from_dist, Unit const *from, Unit const *to)
Convert distances.
Wrapper around a Geom::PathVector object.
To do: update description of desktop.
SPDocument * getDocument() const
Inkscape::Selection * getSelection() const
Typed SVG document implementation.
Inkscape::Util::Quantity getWidth() const
Inkscape::Util::Quantity getHeight() const
Base class for visual SVG elements.
SVG <path> implementation.
SPCurve const * curve() const
Return a borrowed pointer to the curve (if any exists) or NULL if there is no curve.
Editable view implementation.
Raw stack of active status messages.
Coord length(LineSegment const &seg)
Piecewise< D2< SBasis > > paths_to_pw(PathVector const &paths)
double angle_between(Line const &l1, Line const &l2)
Glib::ustring format_classic(T const &... args)
void inspect_event(E &&event, Fs... funcs)
Perform pattern-matching on a CanvasEvent.
two-dimensional geometric operators.
Inkscape::ShapeEditor This is a container class which contains a knotholder for shapes.
Abstract base class for events.
Inkscape::LivePathEffect::EffectType type