Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-use.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_SP_USE_H
3#define SEEN_SP_USE_H
4
5/*
6 * SVG <use> implementation
7 *
8 * Authors:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 * Jon A. Cruz <jon@joncruz.org>
11 *
12 * Copyright (C) 1999-2014 Authors
13 * Copyright (C) 1999-2002 Lauris Kaplinski
14 * Copyright (C) 2000-2001 Ximian, Inc.
15 *
16 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
17 */
18
19
20#include "sp-dimensions.h"
21#include "sp-item.h"
22
23class SPUseReference;
24
25class SPUse final : public SPItem, public SPDimensions {
26public:
27 SPUse();
28 ~SPUse() override;
29 int tag() const override { return tag_of<decltype(*this)>; }
30
31 // item built from the original's repr (the visible clone)
32 // relative to the SPUse itself, it is treated as a child, similar to a grouped item relative to its group
34
35 // SVG attrs
36 char *href;
37
38 // the reference to the original object
40
41 // a sigc connection for delete notifications
42 sigc::connection _delete_connection;
43 sigc::connection _changed_connection;
44
45 // a sigc connection for transformed signal, used to do move compensation
46 sigc::connection _transformed_connection;
47
48 void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
49 void release() override;
50 void set(SPAttr key, char const *value) override;
52 void update(SPCtx* ctx, unsigned int flags) override;
53 void modified(unsigned int flags) override;
54
56 std::optional<Geom::PathVector> documentExactBounds() const override;
57 const char* typeName() const override;
58 const char* displayName() const override;
59 char* description() const override;
60 void print(SPPrintContext *ctx) override;
61 Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override;
62 void hide(unsigned int key) override;
63 void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const override;
64
65 SPItem *root();
66 SPItem const *root() const;
67 int cloneDepth() const;
68
69 SPItem *unlink();
70 SPItem *get_original() const;
73 bool has_xy_offset() const;
75 SPItem *trueOriginal() const;
76 bool anyInChain(bool (*predicate)(SPItem const *)) const;
77
78 void getLinked(std::vector<SPObject *> &objects, LinkedObjectNature direction = LinkedObjectNature::ANY) const override;
79private:
80 void href_changed();
81 void move_compensate(Geom::Affine const *mp);
82 void delete_self();
83};
84
85#endif
86
87/*
88 Local Variables:
89 mode:c++
90 c-file-style:"stroustrup"
91 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
92 indent-tabs-mode:nil
93 fill-column:99
94 End:
95*/
96// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Translation by a vector.
Definition transforms.h:115
SVG drawing item for display.
Storing of snapping preferences.
Interface for refcounted XML nodes.
Definition node.h:80
SVGLength x
Typed SVG document implementation.
Definition document.h:101
Base class for visual SVG elements.
Definition sp-item.h:109
Geom::Affine transform
Definition sp-item.h:138
Inkscape::XML::Node * repr
Definition sp-object.h:193
LinkedObjectNature
Definition sp-object.h:168
Definition sp-use.h:25
~SPUse() override
Definition sp-use.cpp:74
Geom::Affine get_root_transform() const
Returns the effective transform that goes from the ultimate original to given SPUse,...
Definition sp-use.cpp:433
const char * typeName() const override
The item's type name, not node tag name.
Definition sp-use.cpp:247
SPItem * unlink()
Definition sp-use.cpp:727
SPItem * get_original() const
Definition sp-use.cpp:826
SPUseReference * ref
Definition sp-use.h:39
SPItem * trueOriginal() const
Returns the ultimate original of a SPUse, i.e., the first object in the chain of uses which is not it...
Definition sp-use.cpp:358
void update(SPCtx *ctx, unsigned int flags) override
Definition sp-use.cpp:655
int tag() const override
Definition sp-use.h:29
void getLinked(std::vector< SPObject * > &objects, LinkedObjectNature direction=LinkedObjectNature::ANY) const override
Get objects which are linked to this object as either a source or a target.
Definition sp-use.cpp:862
void move_compensate(Geom::Affine const *mp)
Sensing a movement of the original, this function attempts to compensate for it in such a way that th...
Definition sp-use.cpp:496
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Definition sp-use.cpp:85
SPItem * child
Definition sp-use.h:33
sigc::connection _delete_connection
Definition sp-use.h:42
bool has_xy_offset() const
Definition sp-use.cpp:483
SPUse()
Definition sp-use.cpp:54
Geom::Affine get_parent_transform() const
Returns the transform that leads to the use from its immediate original.
Definition sp-use.cpp:471
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
Definition sp-use.cpp:837
void hide(unsigned int key) override
Definition sp-use.cpp:320
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
Definition sp-use.cpp:298
std::optional< Geom::PathVector > documentExactBounds() const override
Get an exact geometric shape representing the visual bounds of the item in the document coordinates.
Definition sp-use.cpp:211
int cloneDepth() const
Get the number of dereferences or calls to get_original() needed to get an object which is not an svg...
Definition sp-use.cpp:413
void href_changed()
Definition sp-use.cpp:590
void print(SPPrintContext *ctx) override
Definition sp-use.cpp:233
const char * displayName() const override
The item's type name as a translated human string.
Definition sp-use.cpp:255
SPItem * root()
Returns the ultimate original of a SPUse (i.e.
Definition sp-use.cpp:337
void release() override
Definition sp-use.cpp:99
Geom::Translate get_xy_offset() const
Definition sp-use.cpp:487
sigc::connection _changed_connection
Definition sp-use.h:43
void modified(unsigned int flags) override
Definition sp-use.cpp:703
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const override
Definition sp-use.cpp:199
char * href
Definition sp-use.h:36
void delete_self()
Definition sp-use.cpp:637
sigc::connection _transformed_connection
Definition sp-use.h:46
bool anyInChain(bool(*predicate)(SPItem const *)) const
Test the passed predicate on all items in a chain of uses.
Definition sp-use.cpp:384
char * description() const override
Definition sp-use.cpp:263
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
Definition sp-use.cpp:170
ObserverPredicate predicate
static cairo_user_data_key_t key
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94