114 case GDK_KEY_KP_Down:
144 Effect::createAndApply(PATTERN_ALONG_PATH, document,
item);
145 Effect* lpe = cast<SPLPEItem>(
item)->getCurrentLPE();
148 double scale = prefs->
getDouble(
"/live_effects/skeletal/width", 1);
166 str += server->
getId();
196 if (SP_IS_PENCIL_CONTEXT(dc)) {
199 if ((elemref = document->
getObjectById(
"power_stroke_preview"))) {
201 auto successor = cast<SPItem>(elemref);
203 Glib::ustring(
"/tools/freehand/pencil").data(),
false);
218 Effect::createAndApply(POWERSTROKE, document,
item);
219 Effect* lpe = cast<SPLPEItem>(
item)->getCurrentLPE();
221 static_cast<LPEPowerStroke*
>(lpe)->offset_points.param_set_and_write_new_value(points);
238 if (is<SPUse>(
item)) {
246 auto lpeitem = cast<SPLPEItem>(
item);
250 if (!lpeitem->hasPathEffectOfType(BEND_PATH)){
251 Effect::createAndApply(BEND_PATH, document,
item);
253 auto lpe = lpeitem->getCurrentLPE();
257 double scale = prefs->getDouble(
"/live_effects/bend_path/width", 1);
263 lpe->getRepr()->setAttribute(
"prop_scale", os.
str());
264 lpe->getRepr()->setAttribute(
"scale_y_rel",
"false");
265 lpe->getRepr()->setAttribute(
"vertical",
"false");
266 static_cast<LPEBendPath*
>(lpe)->bend_path.paste_param_path(svgd);
278 Effect::createAndApply(SIMPLIFY, document,
item);
279 Effect* lpe = cast<SPLPEItem>(
item)->getCurrentLPE();
298 if (is<SPLPEItem>(
item)) {
300 auto const SHAPE_LENGTH = defsize;
301 auto const SHAPE_HEIGHT = defsize;
304 static SPItem *bend_item =
nullptr;
321 if(!bend_item || (!is<SPShape>(bend_item) && !is<SPGroup>(bend_item))){
331 bool shape_applied =
false;
332 bool simplify = prefs->getInt(dc->
getPrefsPath() +
"/simplify", 0);
334 guint
mode = prefs->
getInt(
"/tools/freehand/pencil/freehand-mode", 0);
335 if(simplify &&
mode != 2){
336 double tol = prefs->
getDoubleLimited(
"/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
337 tol = tol/(100.0*(102.0-tol));
349 if (
auto sp_shape = cast<SPShape>(
item)) {
350 curve = sp_shape->curve();
358 swidth = prefs->
getDouble(
"/live_effects/powerstroke/width", SHAPE_HEIGHT / 2);
362 swidth = std::abs(swidth);
363 guint curve_length =
curve->get_segment_count();
364 if (SP_IS_PENCIL_CONTEXT(dc)) {
367 shape_applied =
true;
380 shape_applied =
false;
385 shape_applied =
false;
391 constexpr double C1 = 0.552;
393 c.curveto(0, (1 - C1) * SHAPE_HEIGHT/2, (1 - C1) * SHAPE_LENGTH/2, 0, SHAPE_LENGTH/2, 0);
394 c.curveto((1 + C1) * SHAPE_LENGTH/2, 0, SHAPE_LENGTH, (1 - C1) * SHAPE_HEIGHT/2, SHAPE_LENGTH, SHAPE_HEIGHT/2);
395 c.curveto(SHAPE_LENGTH, (1 + C1) * SHAPE_HEIGHT/2, (1 + C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, SHAPE_LENGTH/2, SHAPE_HEIGHT);
396 c.curveto((1 - C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, 0, (1 + C1) * SHAPE_HEIGHT/2, 0, SHAPE_HEIGHT/2);
400 shape_applied =
true;
412 if ( path !=
nullptr ) {
413 gchar
const *svgd = path->
attribute(
"d");
416 previous_shape_pathv *= pasted_clipboard->transform;
420 shape_applied =
true;
421 pasted_clipboard->deleteObject();
436 if(bend_item && (is<SPShape>(bend_item) || is<SPGroup>(bend_item))){
438 if (is<SPRect>(bend_item) ) {
441 if ( sel && !sel->
isEmpty() ) {
464 if(previous_shape_pathv.
size() != 0){
466 shape_applied =
true;
472 if(bend_item !=
nullptr && bend_item->
getRepr() !=
nullptr){
506 if (!strcmp(cfill,
"none")) {
522 lc->switch_mode(INVALID_LPE);
525 if (SP_IS_PEN_CONTEXT(dc)) {
526 SP_PEN_CONTEXT(dc)->setPolylineMode();
552 if (is<SPPath>(
item)) {
560 if (!path->curveForEdit()) {
567 for (
auto &t : tmp) {
568 white_curves.emplace_back(std::make_shared<SPCurve>(std::move(t)));
573 g_return_if_fail(
c->get_segment_count() > 0 );
574 if ( !
c->is_closed() ) {
575 white_anchors.emplace_back(std::make_unique<SPDrawAnchor>(
this,
c,
true , *
c->first_point()));
576 white_anchors.emplace_back(std::make_unique<SPDrawAnchor>(
this,
c,
false, *
c->last_point()));
586 unsigned const snaps = abs(prefs->getInt(
"/options/rotationsnapsperpi/value", 12));
592 if (state & GDK_SHIFT_MASK) {
603 if (state & GDK_SHIFT_MASK) {
637 auto c = std::make_shared<SPCurve>();
659 (!dc->
sa || (dc->
sa && dc->
sa->
curve->is_empty()))) ||
664 c->closepath_current();
671 if ( dc->
sa && dc->
ea
673 && ( ( dc->
sa != dc->
ea )
674 || dc->
sa->
curve->is_closed() ) )
695 auto e = std::move(dc->
ea->
curve);
700 e = std::make_shared<SPCurve>(e->reversed());
705 e = std::make_shared<SPCurve>(e->reversed());
708 auto lastSeg = std::make_shared<SPCurve>();
709 lastSeg->moveto((*cubic)[0]);
710 lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
711 if ( e->get_segment_count() == 1) {
712 e = std::move(lastSeg);
717 e->append_continuous(*lastSeg);
720 e = std::make_shared<SPCurve>(e->reversed());
722 c->append_continuous(*e);
727 c->closepath_current();
734 std::shared_ptr<SPCurve>
c;
739 c = std::make_shared<SPCurve>();
763 if (!
c->is_empty()) {
766 bool has_lpe =
false;
771 has_lpe = cast<SPLPEItem>(dc->
white_item)->hasPathEffectRecursive();
787 dc->
white_item = cast<SPItem>(layer->appendChildRepr(repr));
793 auto item = cast<SPItem>(layer->appendChildRepr(repr));
809 auto lpeitem = cast<SPLPEItem>(dc->
white_item);
810 if (lpeitem && lpeitem->hasPathEffectRecursive()) {
813 DocumentUndo::done(doc, _(
"Draw path"), SP_IS_PEN_CONTEXT(dc)? INKSCAPE_ICON(
"draw-path") : INKSCAPE_ICON(
"draw-freehand"));
837 auto na = i->anchorTest(p, !active);
873 g_return_if_fail(!strcmp(path,
"/tools/freehand/pen") || !strcmp(path,
"/tools/freehand/pencil")
874 || !strcmp(path,
"/tools/calligraphic") );
875 Glib::ustring tool_path = path;
882 auto item = cast<SPItem>(layer->appendChildRepr(repr));
890 double stroke_width = 3.0;
891 gchar
const *style_str = repr->
attribute(
"style");
899 bool cali = strcmp(path,
"/tools/calligraphic");
916 double rad = 0.5 * prefs->getDouble(tool_path +
"/dot-size", 3.0);
917 if (!strcmp(path,
"/tools/calligraphic"))
919 if (event_state & GDK_ALT_MASK) {
923 double s = g_random_double_range(-0.5, 0.5);
926 if (event_state & GDK_SHIFT_MASK) {
3x3 matrix representing an affine transformation.
void setTranslation(Point const &loc)
Sets the translation imparted by the Affine.
Coord expansionX() const
Calculates the amount of x-scaling imparted by the Affine.
void setExpansionX(Coord val)
Affine inverse() const
Compute the inverse matrix.
void setExpansionY(Coord val)
Coord expansionY() const
Calculates the amount of y-scaling imparted by the Affine.
Bezier curve with compile-time specified order.
size_type size() const
Get the number of paths in the vector.
Two-dimensional point that doubles as a vector.
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
Inkscape::XML::Node * getRepr()
MessageId flash(MessageType type, char const *message)
Temporarily pushes a message onto the stack.
void duplicate(bool suppressDone=false, bool duplicateLayer=false)
void clear()
Unselects all selected objects.
bool isEmpty()
Returns true if no items are selected.
void toCurves(bool skip_undo=false, bool clonesjustunlink=false)
SPItem * singleItem()
Returns a single selected item.
Preference storage class.
double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit="")
Retrieve a floating point value.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
double getDoubleLimited(Glib::ustring const &pref_path, double def=0.0, double min=DBL_MIN, double max=DBL_MAX, Glib::ustring const &unit="")
Retrieve a limited floating point 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.
void set(XML::Node *repr)
Set the selection to an XML node's SPObject.
void remove(XML::Node *repr)
Removes an item from the set of selected objects.
sigc::connection connectChanged(sigc::slot< void(Selection *)> slot)
Connects a slot to be notified of selection changes.
sigc::connection connectModified(sigc::slot< void(Selection *, unsigned)> slot)
Connects a slot to be notified of selected object modifications.
Class to store data for points which are snap candidates, either as a source or as a target.
void addOrigin(Geom::Point pt)
void setSnapEnabledGlobally(bool enabled)
bool getSnapEnabledGlobally() const
Class describing the result of an attempt to snap.
Geom::Point getPoint() const
System-wide clipboard manager.
static ClipboardManager * get()
virtual bool paste(SPDesktop *desktop, bool in_place=false, bool on_page=false)=0
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Change an attribute of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
virtual void removeChild(Node *child)=0
Remove a child of this node.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Wrapper around a Geom::PathVector object.
void moveto(Geom::Point const &p)
Perform a moveto to a point, thus starting a new subpath.
void reset()
Set curve to empty curve.
bool is_empty() const
True if no paths are in curve.
SPCurve transformed(Geom::Affine const &m) const
Return a copy of the curve with all paths transformed by matrix.
std::optional< Geom::Point > last_point() const
Return last point of last subpath or nothing when the curve is empty.
To do: update description of desktop.
double current_zoom() const
SPDocument * getDocument() const
Inkscape::CanvasItemGroup * getCanvasSketch() const
Inkscape::MessageStack * messageStack() const
Geom::Affine const & dt2doc() const
SPNamedView * getNamedView() const
Inkscape::Selection * getSelection() const
Typed SVG document implementation.
SPObject * getObjectById(std::string const &id) const
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
int ensureUpToDate(unsigned int object_modified_tag=0)
Repeatedly works on getting the document updated, since sometimes it takes more than one pass to get ...
Geom::Scale getDocumentScale(bool computed=true) const
Returns document scale as defined by width/height (in pixels) and viewBox (real world to user-units).
std::shared_ptr< SPCurve > curve
Base class for visual SVG elements.
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
void moveTo(SPItem *target, bool intoafter)
Move this SPItem into or after another SPItem in the doc.
void doWriteTransform(Geom::Affine const &transform, Geom::Affine const *adv=nullptr, bool compensate=true)
Set a new transform on an object.
void setLocked(bool lock)
Geom::Affine dt2i_affine() const
Returns the transformation from desktop to item coords.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
char const * getId() const
Returns the objects current ID string.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
void setSuccessor(SPObject *successor)
Indicates that another object supercedes this one.
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
void deleteObject(bool propagate, bool propagate_descendants)
Deletes an object, unparenting it from its parent.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
SVG <path> implementation.
SPCurve const * curveForEdit() const
Return a borrowed pointer of the curve for edit.
T< SPAttr::STROKE, SPIPaint > stroke
stroke
SPPaintServer * getStrokePaintServer()
T< SPAttr::STROKE_WIDTH, SPILength > stroke_width
stroke-width
T< SPAttr::STROKE_OPACITY, SPIScale24 > stroke_opacity
stroke-opacity
void mergeString(char const *p)
Parses a style="..." string and merges it with an existing SPStyle.
Class to coordinate snapping operations.
void setup(SPDesktop const *desktop, bool snapindicator=true, SPObject const *item_to_ignore=nullptr, std::vector< Inkscape::SnapCandidatePoint > *unselected_nodes=nullptr)
Convenience shortcut when there is only one item to ignore.
Inkscape::SnappedPoint constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p, std::optional< Geom::Point > const &p_ref, Geom::Point const &o, unsigned const snaps) const
Try to snap a point to something at a specific angle.
Inkscape::SnapPreferences & snapprefs
Inkscape::SnappedPoint freeSnap(Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap=Geom::OptRect(), bool to_path_only=false) const
Try to snap a point to grids, guides or objects.
System-wide clipboard management - class declaration.
std::shared_ptr< Css const > css
void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool_path, bool with_text)
Apply the desktop's current style or the tool style to repr.
std::optional< Color > sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
void sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
Apply style on object and children, recursively.
The nodes at the ends of the path in the pen/pencil tools.
static Glib::ustring const prefs_path
double Coord
Floating point type used to store coordinates.
Macro for icon names used in Inkscape.
void rename_id(SPObject *elem, Glib::ustring const &new_name)
TODO: insert short description here.
PowerStroke LPE effect, see lpe-powerstroke.cpp.
Raw stack of active status messages.
static R & release(R &r)
Decrements the reference count of a anchored object.
void inspect_event(E &&event, Fs... funcs)
Perform pattern-matching on a CanvasEvent.
bool mod_ctrl_only(unsigned modifiers)
SPCSSAttr * sp_repr_css_attr_new()
Creates an empty SPCSSAttr (a class for manipulating CSS style properties).
void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr)
Sets an attribute (e.g.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
void sp_repr_css_set_property_string(SPCSSAttr *css, char const *name, std::string const &value)
Set a style property to a standard string.
char const * sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval)
Returns a character string of the value of a given style property or a default value if the attribute...
void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name)
Set a style property to "inkscape:unset".
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
Inkscape::XML::Node const * sp_repr_lookup_name(Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth)
void sp_lpe_item_update_patheffect(SPLPEItem *lpeitem, bool wholetree, bool write, bool with_satellites)
Calls any registered handlers for the update_patheffect action.
SPObject * sp_object_unref(SPObject *object, SPObject *owner)
Decrease reference count of object, with possible debugging and finalization.
SPObject * sp_object_ref(SPObject *object, SPObject *owner)
Increase reference count of object, with possible debugging.
Abstract base class for events.
Interface for XML documents.
virtual Node * createElement(char const *name)=0
static const unsigned SP_STYLE_FLAG_ALWAYS(1<< 2)
SPCSSAttr * sp_css_attr_from_object(SPObject *object, guint const flags)
SPStyle - a style object for SPItem objects.
unsigned int sp_svg_number_read_d(gchar const *str, double *val)
Geom::PathVector sp_svg_read_pathv(char const *str)
static void sp_svg_write_path(Inkscape::SVG::PathString &str, Geom::Path const &p, bool normalize=false)