56 auto shape = cast<SPShape>(
item);
57 auto text = cast<SPText>(
item);
59 if (!shape && !text) {
63 std::optional<SPCurve>
curve;
67 curve = text->getNormalizedBpath();
69 std::cerr <<
"item_find_paths: item not shape or text!" << std::endl;
74 std::cerr <<
"item_find_paths: no curve!" << std::endl;
78 if (
curve->get_pathvector().empty()) {
79 std::cerr <<
"item_find_paths: curve empty!" << std::endl;
83 fill =
curve->get_pathvector();
87 std::cerr <<
"item_find_paths: item with no style!" << std::endl;
140 origin->LoadPathVector(pathv);
141 offset->SetBackData(
false);
145 origin->ConvertWithBackData(0.005);
155 origin->Outline(
offset, 0.5 * stroke_width, join, butt, 0.5 * miter);
158 stroke =
offset->MakePathVector();
162 offset->ConvertWithBackData(1.0);
165 offset->Fill(theShape, 0);
171 stroke =
origin->MakePathVector();
192 if (is<SPGroup>(
item)) {
195 if (
auto childitem = cast<SPItem>(&o)) {
203 for (
const auto & j : *marker_pathv) {
227 std::cerr <<
"item_to_outline: fill path has no segments!" << std::endl;
231 if (stroke.
size() > 0) {
238 if (exclude_markers) {
242 auto shape = cast<SPShape>(
item);
243 if (shape && shape->hasMarkers()) {
244 for (
auto const &[_, marker, tr] : shape->get_markers()) {
259 for (
auto &obj : marker->
children) {
260 if (
auto item = cast<SPItem>(&obj)) {
268 if (
auto m_item = cast<SPItem>(doc->getObjectByRepr(m_repr))) {
269 m_item->doWriteTransform(tr);
294 auto lpeitem = cast<SPLPEItem>(
item);
295 if (lpeitem && lpeitem->hasPathEffect()) {
296 lpeitem->removeAllPathEffects(
true);
298 if (elemref && elemref !=
item) {
301 item = cast<SPItem>(elemref);
303 auto flat_item = cast<SPLPEItem>(elemref);
304 if (!flat_item || !flat_item->hasPathEffect()) {
309 if (is<SPText>(
item) || is<SPFlowtext>(
item) || is<SPBox3D>(
item)) {
315 original_objects.add(
item);
316 original_objects.toCurves(
true);
317 SPItem * new_item = original_objects.singleItem();
318 if (new_item && new_item !=
item) {
322 g_warning(
"item_to_paths: flattening text or 3D box failed.");
327 auto group = cast<SPGroup>(
item);
332 std::vector<SPItem*>
const item_list = group->item_list();
334 for (
auto subitem : item_list) {
341 return group->getRepr();
347 auto shape = cast<SPShape>(
item);
444 parent->addChildAtPos(g_repr, pos);
448 if (s_val && g_strcmp0(s_val,
"none") != 0 && stroke_path.
size() > 0) {
449 auto stroke_style = std::make_unique<SPStyle>(doc);
450 stroke_style->mergeCSS(ncss);
460 if (f_val && g_strcmp0(f_val,
"none") != 0 && !legacy) {
461 auto fill_style = std::make_unique<SPStyle>(doc);
462 fill_style->mergeCSS(ncsf);
473 if (shape->hasMarkers()) {
481 for (
auto const &[_, marker, tr] : shape->get_markers()) {
488 temp.
read( paint_order );
490 if ((!fill && !markers) || (!fill && !stroke) || (!markers && !stroke)) {
563 }
else if (!unique) {
577 if (stroke || markers) {
583 if (!fill && !markers && did) {
585 }
else if (!fill && !stroke && did) {
608 if (unique && out != markers) {
609 g_assert(out != g_repr);
610 parent->addChild(out, g_repr);
611 parent->removeChild(g_repr);
TODO: insert short description here.
TODO: insert short description here.
TODO: insert short description here.
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
CPoint dimensions() const
Get rectangle's width and height as a point.
size_type size() const
Get the number of paths in the vector.
void push_back(Path const &path)
Append a path at the end.
size_type curveCount() const
Get the total number of curves in the vector.
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
virtual void setPosition(int pos)=0
Set the position of this node in parent's child order.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
void addChildAtPos(Node *child, unsigned pos)
Insert another node as a child of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * duplicate(Document *doc) const =0
Create a duplicate 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.
virtual void removeChild(Node *child)=0
Remove a child of this node.
Path and its polyline approximation.
static std::optional< SPCurve > ptr_to_opt(T const &p)
Typed SVG document implementation.
SPObject * getObjectById(std::string const &id) const
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
Paint order type internal to SPStyle.
void read(gchar const *str) override
SPPaintOrderLayer layer[PAINT_ORDER_LAYERS]
Base class for visual SVG elements.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
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.
char const * getAttribute(char const *name) const
T< SPAttr::FILL, SPIPaint > fill
fill
T< SPAttr::STROKE_DASHARRAY, SPIDashArray > stroke_dasharray
stroke-dasharray
T< SPAttr::STROKE, SPIPaint > stroke
stroke
T< SPAttr::STROKE_WIDTH, SPILength > stroke_width
stroke-width
T< SPAttr::STROKE_LINEJOIN, SPIEnum< SPStrokeJoinType > > stroke_linejoin
stroke-linejoin
T< SPAttr::STROKE_MITERLIMIT, SPIFloat > stroke_miterlimit
stroke-miterlimit
T< SPAttr::STROKE_LINECAP, SPIEnum< SPStrokeCapType > > stroke_linecap
stroke-linecap
A class to store/manipulate directed graphs.
void ConvertToForme(Path *dest)
Extract contours from a directed graph.
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...
static char const *const parent
constexpr Coord EPSILON
Default "acceptably small" value.
Geom::PathVector pathv_to_linear_and_cubic_beziers(Geom::PathVector const &pathv)
Specific geometry functions for Inkscape, not provided my lib2geom.
Raw stack of active status messages.
SBasis L2(D2< SBasis > const &a, unsigned k)
OptInterval bounds_fast(Bezier const &b)
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 flatten(Geom::PathVector &pathv, FillRule fill_rule)
bool item_find_paths(const SPItem *item, Geom::PathVector &fill, Geom::PathVector &stroke, bool bbox_only)
Given an item, find a path representing the fill and a path representing the stroke.
static void item_to_outline_add_marker_child(SPItem const *item, Geom::Affine marker_transform, Geom::PathVector *pathv_in)
Inkscape::XML::Node * item_to_paths(SPItem *item, bool legacy, SPItem *context)
Replace item by path objects (a.k.a.
Geom::PathVector * item_to_outline(SPItem const *item, bool exclude_markers)
Returns a pathvector that is the outline of the stroked item, with markers.
static void item_to_paths_add_marker(SPItem *context, SPMarker const *marker, Geom::Affine const &marker_transform, Inkscape::XML::Node *g_repr, bool legacy)
Two related object to path operations:
SPCSSAttr * sp_repr_css_attr_new()
Creates an empty SPCSSAttr (a class for manipulating CSS style properties).
void sp_repr_css_change(Node *repr, SPCSSAttr *css, gchar const *attr)
Creates a new SPCSAttr with the values filled from a repr, merges in properties from the given SPCSAt...
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
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.
TODO: insert short description here.
SPItem const * sp_item_first_item_child(SPObject const *obj)
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
Interface for XML documents.
virtual Node * createElement(char const *name)=0
@ SP_STROKE_LINEJOIN_MITER
@ SP_STROKE_LINEJOIN_ROUND
@ SP_STROKE_LINECAP_SQUARE
@ SP_STROKE_LINECAP_ROUND
@ SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE
@ SP_CSS_PAINT_ORIGIN_CONTEXT_FILL
@ SP_CSS_PAINT_ORDER_STROKE
@ SP_CSS_PAINT_ORDER_FILL
@ SP_CSS_PAINT_ORDER_NORMAL
static const unsigned SP_STYLE_FLAG_ALWAYS(1<< 2)
SPCSSAttr * sp_css_attr_from_style(SPStyle const *const style, guint const flags)
SPStyle - a style object for SPItem objects.
static void sp_svg_write_path(Inkscape::SVG::PathString &str, Geom::Path const &p, bool normalize=false)