/*
7 * Created by fred on Fri Dec 05 2003.
8 * tweaked endlessly by bulia byak <buliabyak@users.sf.net>
10 * Copyright (C) 2018 Authors
11 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
22#include <glibmm/i18n.h>
45#define MIN_OFFSET 0.01
56 double prefOffset = prefs->
getDouble(
"/options/defaultoffsetwidth/value", 1.0,
"px");
64 double prefOffset = prefs->
getDouble(
"/options/defaultoffsetwidth/value", 1.0,
"px");
116 if (
auto shape = cast<SPShape>(
item)) {
119 }
else if (is<SPText>(
item)) {
139 o_width = prefs->
getDouble(
"/options/defaultoffsetwidth/value", 1.0,
"px");
140 o_width /= scaling_factor;
141 if (scaling_factor == 0 || o_width < MIN_OFFSET) {
142 o_width = MIN_OFFSET;
158 orig->ConvertWithBackData(1.0);
159 orig->Fill(theShape, 0);
163 if (val && strcmp(val,
"nonzero") == 0)
167 else if (val && strcmp(val,
"evenodd") == 0)
188 (updating ? _(
"Create linked offset")
189 : _(
"Create dynamic offset")),
190 (updating ? INKSCAPE_ICON(
"path-offset-linked")
191 : INKSCAPE_ICON(
"path-offset-dynamic")));
223 char const *uri = g_strdup_printf(
"#%s",
id);
225 g_free((
void *) uri);
234 parent->addChildAtPos(repr, pos);
249 selection->
set(nitem);
253 (updating ? _(
"Create linked offset")
254 : _(
"Create dynamic offset")),
255 (updating ? INKSCAPE_ICON(
"path-offset-linked")
256 : INKSCAPE_ICON(
"path-offset-dynamic")));
278 std::vector<SPItem*> il(selection->
items().begin(), selection->
items().end());
279 for (
auto item : il){
280 if (
auto shape = cast<SPShape>(
item)) {
283 }
else if (is<SPText>(
item) || is<SPFlowtext>(
item)) {
315 o_width = prefOffset / scaling_factor;
317 if (scaling_factor == 0 || o_width < MIN_OFFSET) {
318 o_width = MIN_OFFSET;
335 orig->ConvertWithBackData(0.03);
336 orig->Fill(theShape, 0);
340 if (val && strcmp(val,
"nonzero") == 0)
344 else if (val && strcmp(val,
"evenodd") == 0)
384 theShape->
MakeOffset(theRes, o_width, o_join, o_miter);
388 theShape->
MakeOffset(theRes, -o_width, o_join, o_miter);
427 parent->addChildAtPos(repr, pos);
432 newitem->doWriteTransform(transform);
434 selection->
add(repr);
444 (expand ? _(
"Outset path") : _(
"Inset path")),
445 (expand ? INKSCAPE_ICON(
"path-outset") : INKSCAPE_ICON(
"path-inset")));
TODO: insert short description here.
TODO: insert short description here.
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
constexpr Coord get() const
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
MessageId flash(MessageType type, char const *message)
Temporarily pushes a message onto the stack.
SPItemRange items()
Returns a range of selected SPItems.
void clear()
Unselects all selected objects.
bool isEmpty()
Returns true if no items are selected.
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.
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.
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual unsigned position() const =0
Get the index of this node in parent's child order.
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.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Path and its polyline approximation.
void SetBackData(bool nVal)
Sets the back variable to the value passed in and clears the polyline approximation.
std::string svg_dump_path() const
void ConvertEvenLines(double treshhold)
Creates a polyline approximation of the path.
std::vector< PathDescr * > descr_cmd
void Simplify(double treshhold)
Simplify the path.
void Reset()
Clears all stored path commands and resets flags that are used by command functions while adding path...
To do: update description of desktop.
double current_zoom() const
SPDocument * getDocument() const
Inkscape::MessageStack * messageStack() const
Inkscape::Selection * getSelection() const
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
Base class for visual SVG elements.
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
void doWriteTransform(Geom::Affine const &transform, Geom::Affine const *adv=nullptr, bool compensate=true)
Set a new transform on an object.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
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.
T< SPAttr::STROKE_LINEJOIN, SPIEnum< SPStrokeJoinType > > stroke_linejoin
stroke-linejoin
T< SPAttr::STROKE_MITERLIMIT, SPIFloat > stroke_miterlimit
stroke-miterlimit
A class to store/manipulate directed graphs.
void ConvertToForme(Path *dest)
Extract contours from a directed graph.
int MakeOffset(Shape *of, double dec, JoinType join, double miter, bool do_profile=false, double cx=0, double cy=0, double radius=0, Geom::Affine *i2doc=nullptr)
int ConvertToShape(Shape *a, FillRule directed=fill_nonZero, bool invert=false)
Using a given fill rule, find all intersections in the shape given, create a new intersection free sh...
std::shared_ptr< Css const > css
static char const *const parent
TODO: insert short description here.
Macro for icon names used in Inkscape.
Raw stack of active status messages.
vector< vector< Point > > paths
Affine identity()
Create an identity matrix.
static R & release(R &r)
Decrements the reference count of a anchored object.
void copy_object_properties(XML::Node *dest, XML::Node const *src)
Copy generic object properties, like:
void sp_selected_path_create_updating_offset_object_zero(SPDesktop *desktop)
void sp_selected_path_offset(SPDesktop *desktop)
void sp_selected_path_create_updating_offset(SPDesktop *desktop)
void sp_selected_path_inset_screen(SPDesktop *desktop, double pixels)
void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating)
void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
Apply offset to selected paths.
void sp_selected_path_create_offset_object_zero(SPDesktop *desktop)
void sp_selected_path_offset_screen(SPDesktop *desktop, double pixels)
void sp_selected_path_inset(SPDesktop *desktop)
void sp_selected_path_create_offset(SPDesktop *desktop)
void sp_selected_path_create_updating_inset(SPDesktop *desktop)
void sp_selected_path_create_inset(SPDesktop *desktop)
std::unique_ptr< Path > Path_for_item(SPItem *item, bool doTransformation, bool transformFull)
Creates a Livarot Path object from an SPItem.
Singleton class to access the preferences file in a convenient way.
SPCSSAttr * sp_repr_css_attr(Node const *repr, gchar const *attr)
Creates a new SPCSSAttr with one attribute (i.e.
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...
TODO: insert short description here.
Interface for XML documents.
virtual Node * createElement(char const *name)=0
@ SP_STROKE_LINEJOIN_MITER
@ SP_STROKE_LINEJOIN_ROUND
SPStyle - a style object for SPItem objects.