25#include <sigc++/functors/ptr_fun.h>
26#include <sigc++/adaptors/bind.h>
46#define noSHAPE_VERBOSE
51 for (
auto & i : this->
_marker) {
71 if (is<SPPath>(
this)) {
72 if (
auto originald =
getAttribute(
"inkscape:original-d")) {
97 for (
auto &v :
views) {
144 if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
150 for (
auto &v :
views) {
151 auto sh = cast<Inkscape::DrawingShape>(v.drawingitem.get());
165 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) {
168 for (
auto &v :
views) {
169 if (flags & SP_OBJECT_MODIFIED_FLAG) {
179 for (
auto &v :
views) {
189 for (
auto &v :
views) {
194 for (
auto &v :
views) {
201 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
207 double const d = sqrt(
w*
w + h*h) * M_SQRT1_2;
209 double const ex = 0.5 * em;
249 std::vector<std::tuple<SPMarkerLoc, SPMarker *, Geom::Affine>> markers;
259 markers.emplace_back(marker_type, marker, marker->get_marker_transform(m,
width,
start));
267 add_marker(marker_type, m,
true);
275 if (path_it != pathv.
begin() && !((path_it == (pathv.
end() - 1)) && (path_it->size_default() == 0))) {
278 add_marker(marker_type, m,
false);
282 if (path_it->size_default() > 1) {
285 while (curve_it2 != path_it->end_default()) {
292 add_marker(marker_type, m,
false);
299 if (path_it != (pathv.
end() - 1) && !path_it->empty()) {
300 Geom::Curve const &lastcurve = path_it->back_default();
303 add_marker(marker_type, m,
false);
318 add_marker(marker_type, m,
false);
351 double ret_angle = .5 * (angle1 + angle2);
353 if ( fabs( angle2 - angle1 ) > M_PI ) {
371 if ( !
c.isDegenerate() ) {
388 if ( !
c.isDegenerate() ) {
419 unsigned int z_order = 0;
422 for (
auto const &[type, marker, tr] : shape->
get_markers()) {
431 if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
432 for (
auto &v :
views) {
433 auto sh = cast<Inkscape::DrawingShape>(v.drawingitem.get());
441 }
else if (this->
parent) {
448 if (flags & SP_OBJECT_MODIFIED_FLAG &&
style->
filter.set) {
450 filter->update_filter_all_regions();
462 g_warning(
"The shape has unknown LPE on it. Convert to path to make it editable preserving the appearance; "
463 "editing it will remove the bad LPE");
465 if (this->
getRepr()->attribute(
"d")) {
482 if (before && before->get_pathvector() !=
c->get_pathvector()) {
489 if (!before && this->
getRepr()->attribute(
"d")) {
531 if (cache_is_valid && bbox_cache &&
delta.isTranslation()) {
534 if (!
delta.isNonzeroTranslation()) {
538 return *bbox_cache *
delta;
541 if (!this->
_curve || this->
_curve->get_pathvector().empty()) {
554 if (!this->
style->
stroke.isNone() && !this->style->stroke_extensions.hairline) {
564 for (
auto const &[_, marker, tr] : this->
get_markers()) {
566 bbox |= marker_item->visualBounds(marker_item->transform * marker->c2p * tr *
transform);
628 for (
auto const &[_, marker, tr] : this->
get_markers()) {
630 auto const old_tr = marker_item->transform;
631 marker_item->transform = old_tr * marker->c2p * tr;
632 marker_item->invoke_print(ctx);
633 marker_item->transform = old_tr;
643 std::optional<Geom::PathVector>
result;
644 if (
auto const *
c =
curve()) {
662 bool success =
false;
677 if (
write && success) {
720 }
else if (this->
parent) {
738 for (
auto &v :
views) {
761 if (is<SPMarker>(
parent)) {
784 if (pathv.
size() == 0) {
793 for(
const auto & path_it : pathv) {
794 n += path_it.size_default() + 1;
809 for(
const auto & path_it : pathv) {
810 n += path_it.size_default() + 1;
812 n = (n > 1) ? (n - 2) : 0;
840 g_return_if_fail(
item !=
nullptr);
843 if (marker == shape->
_marker[i]) {
861 if ((flags & SP_OBJECT_MODIFIED_FLAG) &&
item && marker) {
881 auto marker = cast<SPMarker>(mrk);
890 for (
auto &v :
views) {
992 if (this->
_curve ==
nullptr) {
1012 for(
const auto & path_it : pathv) {
1021 while (curve_it1 != path_it.end_default())
1030 if (curve_it2 == path_it.end_default()) {
1065 p.emplace_back(curve_it1->finalPoint() * i2dt, sst, stt);
1079 cs = self_crossings(path_it);
1082 for (
const auto &
c : cs) {
curve_type new_curve(void)
Lookup dictionary for attributes/properties.
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
Affine inverse() const
Compute the inverse matrix.
Abstract continuous curve on a plane defined on [0,1].
virtual Curve * reverse() const
Create a reversed version of this curve.
virtual Point unitTangentAt(Coord t, unsigned n=3) const
Compute a vector tangent to the curve.
virtual Point pointAt(Coord t) const
Evaluate the curve at a specified time value.
static CRect from_xywh(Coord x, Coord y, Coord w, Coord h)
Create rectangle from origin and dimensions.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
Axis-aligned rectangle that can be empty.
size_type size() const
Get the number of paths in the vector.
Sequence::const_iterator const_iterator
bool empty() const
Check whether the vector contains any paths.
Sequence of contiguous curves, aka spline.
size_type size_default() const
Natural size of the path.
Curve const & front() const
Access the first curve in the path.
Two-dimensional point that doubles as a vector.
Rotation around the origin.
SVG drawing item for display.
void setPath(std::shared_ptr< SPCurve const > curve)
void setChildrenStyle(SPStyle const *context_style) override
Recursively update children style.
void setStyle(SPStyle const *style, SPStyle const *context_style=nullptr) override
Process information related to the new style.
unsigned int fill(Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
unsigned int stroke(Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
Storing of snapping preferences.
bool isSourceSnappable(Inkscape::SnapSourceType const source) const
bool isTargetSnappable(Inkscape::SnapTargetType const target) const
Interface for refcounted XML nodes.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
Wrapper around a Geom::PathVector object.
Geom::PathVector const & get_pathvector() const
Typed SVG document implementation.
SPRoot * getRoot()
Returns our SPRoot.
Geom::Point getDimensions() const
char const * value() const
Get value if set, or inherited value, or default value (may be NULL)
Base class for visual SVG elements.
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
Geom::OptRect desktopVisualBounds() const
Get item's visual bbox in desktop coordinate system.
Geom::OptRect geometricBounds(Geom::Affine const &transform=Geom::identity()) const
Get item's geometric bounding box in this item's coordinate system.
static unsigned ensure_key(Inkscape::DrawingItem *di)
Ensures that a drawing item's key is the first of a block of ITEM_KEY_SIZE keys, assigning it such a ...
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
std::vector< SPItemView > views
bool isOnClipboard()
The lpeitem is on clipboard.
void resetClipPathAndMaskLPE(bool fromrecurse=false)
void applyToMask(SPItem *to, Inkscape::LivePathEffect::Effect *lpe=nullptr)
bool hasBrokenPathEffect() const
used for shapes so they can see if they should also disable shape calculation and read from d=
bool hasPathEffect() const
void applyToClipPath(SPItem *to, Inkscape::LivePathEffect::Effect *lpe=nullptr)
bool hasPathEffectOnClipOrMaskRecursive(SPLPEItem *shape) const
returns true when any LPE apply to clip or mask.
bool pathEffectsEnabled() const
void update(SPCtx *ctx, unsigned int flags) override
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
bool performPathEffect(SPCurve *curve, SPShape *current, bool is_clip_or_mask=false)
returns true when LPE was successful.
void modified(unsigned int flags) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void set(SPAttr key, char const *value) override
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
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,...
SPStyle * context_style
Represents the style that should be used to resolve 'context-fill' and 'context-stroke'.
void unhrefObject(SPObject *owner=nullptr)
Decrease weak refcount.
void hrefObject(SPObject *owner=nullptr)
Increase weak refcount.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
char const * getAttribute(char const *name) const
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
struct SPRoot::@40 inkscape
Base class for shapes, including <path> element.
SPCurve const * curve() const
Return a borrowed pointer to the curve (if any exists) or NULL if there is no curve.
void update(SPCtx *ctx, unsigned int flags) override
void setCurveInsync(SPCurve const *)
Geom::OptRect bbox_geom_cache
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
std::optional< SPCurve > _curve_before_lpe
bool prepareShapeForLPE(SPCurve const *c)
void modified(unsigned int flags) override
Geom::Affine bbox_vis_cache_transform
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const override
void release() override
Removes, releases and unrefs all children of object.
void set(SPAttr key, char const *value) override
void setCurveBeforeLPE(SPCurve const *)
Geom::Affine bbox_geom_cache_transform
sigc::connection _release_connect[SP_MARKER_LOC_QTY]
Geom::OptRect bbox_vis_cache
void build(SPDocument *document, Inkscape::XML::Node *repr) override
bool bbox_geom_cache_is_valid
void set_marker(unsigned key, char const *value)
Adds a new marker to shape object at the location indicated by key.
void update_patheffect(bool write) override
std::shared_ptr< SPCurve const > _curve
SPMarker * _marker[SP_MARKER_LOC_QTY]
bool bbox_vis_cache_is_valid
int numberOfMarkers(int type) const
void print(SPPrintContext *ctx) override
sigc::connection _modified_connect[SP_MARKER_LOC_QTY]
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
SPCurve const * curveBeforeLPE() const
Return a borrowed pointer of the curve before LPE (if any exists) or NULL if there is no curve.
SPCurve const * curveForEdit() const
Return a borrowed pointer of the curve for edit.
std::optional< Geom::PathVector > documentExactBounds() const override
Get an exact geometric shape representing the visual bounds of the item in the document coordinates.
std::vector< std::tuple< SPMarkerLoc, SPMarker *, Geom::Affine > > get_markers() const
Lists every marker on this shape along with its transform and marker type.
bool checkBrokenPathEffect()
void setCurve(SPCurve const *)
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
Geom::OptRect either_bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype, bool cache_is_valid, Geom::OptRect bbox_cache, Geom::Affine const &transform_cache) const
void hide(unsigned int key) override
Sets style, path, and paintbox.
void merge(SPStyle const *parent)
Combine style and parent style specifications into a single style specification that preserves (as mu...
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::FILTER, SPIFilter > filter
Filter effect.
SPIString * marker_ptrs[SP_MARKER_LOC_QTY]
T< SPAttr::STROKE_DASHOFFSET, SPILength > stroke_dashoffset
stroke-dashoffset
T< SPAttr::SHAPE_RENDERING, SPIEnum< SPShapeRendering > > shape_rendering
T< SPAttr::FONT_SIZE, SPIFontSize > font_size
Size of the font.
Group belonging to an SVG drawing element.
Specific nodetype geometry functions for Inkscape, not provided my lib2geom.
Geom::OptRect bounds_exact_transformed(Geom::PathVector const &pv, Geom::Affine const &t)
Specific geometry functions for Inkscape, not provided my lib2geom.
double atan2(Point const &p)
NodeType
What kind of node is this? This is the value for the node->type field.
@ NODE_NONE
Discontinuous node, usually either start or endpoint of a path.
@ NODE_CUSP
This node continuously joins two segments, but the unit tangent is discontinuous.
@ NODE_SYMM
This node is symmetric.
@ NODE_SMOOTH
This node continuously joins two segments, with continuous unit tangent.
NodeType get_nodetype(Curve const &c_incoming, Curve const &c_outgoing)
std::vector< Crossing > Crossings
Point middle_point(LineSegment const &_segment)
SnapSourceType
enumerations of snap source types and snap target types.
@ SNAPSOURCE_PATH_INTERSECTION
@ SNAPSOURCE_OBJECT_MIDPOINT
@ SNAPSOURCE_LINE_MIDPOINT
void propagate_antialias(SPShapeRendering shape_rendering, DrawingItem &item)
Propagate element's shape rendering attribute into internal anti-aliasing setting of DrawingItem.
@ SNAPTARGET_LINE_MIDPOINT
@ SNAPTARGET_OBJECT_MIDPOINT
@ SNAPTARGET_PATH_INTERSECTION
static cairo_user_data_key_t key
Geom::PathVector * item_to_outline(SPItem const *item, bool exclude_markers)
Returns a pathvector that is the outline of the stroked item, with markers.
Two related object to path operations:
Inkscape::SVG::PathString - builder for SVG path strings.
PathVector - a sequence of subpaths.
Singleton class to access the preferences file in a convenient way.
Some utility classes to store various kinds of snap candidates.
SPItem const * sp_item_first_item_child(SPObject const *obj)
void sp_lpe_item_update_patheffect(SPLPEItem *lpeitem, bool wholetree, bool write, bool with_satellites)
Calls any registered handlers for the update_patheffect action.
SPMarkerLoc
These enums are to allow us to have 4-element arrays that represent a set of marker locations (all,...
void sp_marker_hide(SPMarker *marker, unsigned int key)
Hides/removes all views of the given marker that have key 'key'.
Inkscape::DrawingItem * sp_marker_show_instance(SPMarker *marker, Inkscape::DrawingItem *parent, unsigned int loc, unsigned int pos, unsigned int z_order, Geom::Affine const &marker_transform, float linewidth)
Shows an instance of a marker.
void sp_marker_show_dimension(SPMarker *marker, unsigned int key, unsigned int size)
Removes any SPMarkerViews that a marker has with a specific key.
SPRoot: SVG <svg> implementation.
static void sp_shape_marker_modified(SPObject *marker, guint flags, SPItem *item)
No-op.
Geom::Affine sp_shape_marker_get_transform_at_end(Geom::Curve const &c)
Geom::Affine sp_shape_marker_get_transform(Geom::Curve const &c1, Geom::Curve const &c2)
Calculate the transform required to get a marker's path object in the right place for particular path...
Geom::Affine sp_shape_marker_get_transform_at_start(Geom::Curve const &c)
static void sp_shape_marker_release(SPObject *marker, SPShape *shape)
Checks if the given marker is used in the shape, and if so, it releases it by calling sp_marker_hide.
static void sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
Updates the instances (views) of a given marker in a shape.
Geom::Affine sp_shape_marker_get_transform_at_end(Geom::Curve const &c)
Geom::Affine sp_shape_marker_get_transform(Geom::Curve const &c1, Geom::Curve const &c2)
Calculate the transform required to get a marker's path object in the right place for particular path...
Geom::Affine sp_shape_marker_get_transform_at_start(Geom::Curve const &c)
Interface for XML documents.
Contains transformations to document/viewport and the viewport size.
Geom::Affine i2vp
Item to viewport transformation.
Geom::Rect viewport
Viewport size.
unsigned int fill(Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
unsigned int stroke(Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
Inkscape::Extension::Print *SPItem * context_item
@ SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE
@ SP_CSS_PAINT_ORIGIN_CONTEXT_FILL
SPStyle - a style object for SPItem objects.
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)
SPObject * sp_css_uri_reference_resolve(SPDocument *document, const gchar *uri)