72 if (!std::strcmp(value,
"userSpaceOnUse")) {
74 }
else if (!std::strcmp(value,
"objectBoundingBox")) {
99 for (
auto &v :
views) {
100 auto ac =
item->
invoke_show(v.drawingitem->drawing(), v.key, SP_ITEM_REFERENCE_FLAGS);
102 v.drawingitem->prependChild(ac);
113 if (cflags || (
c->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
114 c->updateDisplay(ctx, cflags);
119 for (
auto &v :
views) {
138 if (cflags || (
c->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
139 c->emitModified(cflags);
147 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
158 views.emplace_back(make_drawingitem<Inkscape::DrawingGroup>(drawing), bbox,
key);
159 auto &v =
views.back();
160 auto root = v.drawingitem.get();
187 auto it = std::find_if(
views.begin(),
views.end(), [=] (
auto &v) {
191 if (it ==
views.end()) {
200 auto it = std::find_if(
views.begin(),
views.end(), [=] (
auto &v) {
203 assert(it !=
views.end());
224 if (
auto item = cast<SPItem>(&
clip)) {
237 if (
auto item = cast<SPItem>(&
clip)) {
251 if (
auto shape = cast<SPShape>(obj)) {
252 if (!shape->curve()) {
255 for (
auto &path : *shape->curve()) {
257 ret.
push_back(path * (shape->transform * tr));
264 if (
auto use = cast<SPUse>(&
child)) {
265 if (
auto orig = use->get_original()) {
266 add_curve(
orig, use->transform * transform);
269 add_curve(&
child, transform);
280 SPText const *ret =
nullptr;
282 if (
auto text = cast<SPText>(&
child)) {
287 }
else if (is<SPShape>(&
child)) {
300 auto repr = xml_doc->createElement(
"svg:clipPath");
303 defsrepr->appendChild(
repr);
307 for (
auto node : reprs) {
317 if (!is<SPClipPath>(obj)) {
321 if (URIReference::_acceptObject(obj)) {
327 auto const owner_repr = owner->getRepr();
329 auto const obj_repr = obj->
getRepr();
330 char const *owner_name =
"";
331 char const *owner_clippath =
"";
332 char const *obj_name =
"";
333 char const *obj_id =
"";
335 owner_name = owner_repr->
name();
336 owner_clippath = owner_repr->attribute(
"clippath");
339 obj_name = obj_repr->name();
340 obj_id = obj_repr->attribute(
"id");
342 std::cerr <<
"WARNING: Ignoring recursive clippath reference "
343 <<
"<" << (owner_name ? owner_name :
"(null)") <<
" clippath=\"" << (owner_clippath ? owner_clippath :
"(null)") <<
"\">"
344 <<
" in <" << (obj_name ? obj_name :
"(null)") <<
" id=\"" << (obj_id ? obj_id :
"(null)") <<
"\">" << std::endl;
bool SP_ATTRIBUTE_IS_CSS(SPAttr k)
True iff k is a property in SVG, i.e.
Lookup dictionary for attributes/properties.
3x3 matrix representing an affine transformation.
void unionWith(CRect const &b)
Enlarge the rectangle to contain the argument.
Axis-aligned rectangle that can be empty.
void push_back(Path const &path)
Append a path at the end.
SVG drawing item for display.
void appendChild(DrawingItem *item)
SPObject * getOwner() const
Returns a pointer to the URIReference's owner.
Interface for refcounted XML nodes.
virtual char const * name() const =0
Get the name of the element 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.
bool _acceptObject(SPObject *obj) const override
If the owner element of this reference (the element with <... clippath="...">) is a child of the clip...
void modified(unsigned flags) override
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned flags) override
void setBBox(unsigned key, Geom::OptRect const &bbox)
void set(SPAttr key, char const *value) override
Geom::OptRect geometricBounds(Geom::Affine const &transform) const
void removeTransformsRecursively(SPObject const *root)
Geom::PathVector getPathVector(Geom::Affine const &transform) const
This gets a compiled path vector from all the objects.
void transform_multiply(Geom::Affine postmul, bool set=true)
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
SPText const * getTextObject() const
This gets a text object, if the clip path is made up of a single sp-text.
void update(SPCtx *ctx, unsigned flags) override
void update_view(View &v)
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
static char const * create(std::vector< Inkscape::XML::Node * > &reprs, SPDocument *document)
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox)
std::vector< View > views
Typed SVG document implementation.
bool removeResource(char const *key, SPObject *object)
bool addResource(char const *key, SPObject *object)
SPObject * getObjectById(std::string const &id) const
SPDefs * getDefs()
Return the main defs object for the document.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
void set_item_transform(Geom::Affine const &transform_matrix)
Sets item private transform (not propagated to repr), without compensating stroke widths,...
Inkscape::DrawingItem * invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags)
void invoke_hide(unsigned int key)
virtual void removeTransformsRecursively(SPObject const *root)
Geom::OptRect geometricBounds(Geom::Affine const &transform=Geom::identity()) const
Get item's geometric bounding box in this item's coordinate system.
void doWriteTransform(Geom::Affine const &transform, Geom::Affine const *adv=nullptr, bool compensate=true)
Set a new transform on an object.
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
std::vector< SPObject * > childList(bool add_ref, Action action=ActionGeneral)
Retrieves the children as a std vector object, optionally ref'ing the children in the process,...
virtual void set(SPAttr key, const char *value)
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
void readAttr(char const *key)
Read value of key attribute from XML node into object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
SPObject * appendChildRepr(Inkscape::XML::Node *repr)
Append repr as child of this object.
virtual void build(SPDocument *doc, Inkscape::XML::Node *repr)
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
Group belonging to an SVG drawing element.
Canvas item belonging to an SVG drawing element.
@ SP_CONTENT_UNITS_OBJECTBOUNDINGBOX
@ SP_CONTENT_UNITS_USERSPACEONUSE
Inkscape::XML::Node * node
Affine identity()
Create an identity matrix.
static R & release(R &r)
Decrements the reference count of a anchored object.
static T clip(T const &v, T const &a, T const &b)
static cairo_user_data_key_t key
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SPObject * sp_object_unref(SPObject *object, SPObject *owner)
Decrease reference count of object, with possible debugging and finalization.
unsigned cascade_flags(unsigned flags)
Interface for XML documents.
virtual Node * createElement(char const *name)=0
SPStyle - a style object for SPItem objects.