Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-pattern.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Author:
6 * Lauris Kaplinski <lauris@kaplinski.com>
7 * Abhishek Sharma
8 *
9 * Copyright (C) 2002 Lauris Kaplinski
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#ifndef SEEN_SP_PATTERN_H
15#define SEEN_SP_PATTERN_H
16
17#include <memory>
18#include <vector>
19#include <cstddef>
20#include <glibmm/ustring.h>
21#include <sigc++/connection.h>
22
23#include "object-view.h"
24#include "svg/svg-length.h"
25#include "sp-paint-server.h"
26#include "uri-references.h"
27#include "viewbox.h"
28
29class SPPattern;
30class SPItem;
31
32namespace Inkscape {
33namespace XML {
34class Node;
35} // namespace XML
36} // namespace Inkscape
37
40{
41public:
43 SPPattern *getObject() const;
44
45protected:
46 bool _acceptObject(SPObject *obj) const override;
47};
48
49class SPPattern final
50 : public SPPaintServer
51 , public SPViewBox
52{
53public:
59
60 SPPattern();
61 ~SPPattern() override;
62 int tag() const override { return tag_of<decltype(*this)>; }
63
64 // Reference (href)
65 Glib::ustring href;
67
68 double x() const;
69 double y() const;
70 double width() const;
71 double height() const;
73 return Geom::Rect::from_xywh(x(), y(), width(), height());
74 }
75 Geom::OptRect viewbox() const;
78 Geom::Affine const &getTransform() const;
79 SPPattern const *rootPattern() const;
81 const Geom::Affine& get_this_transform() const;
82
83 SPPattern *clone_if_necessary(SPItem *item, char const *property);
85
90 static char const *produce(std::vector<Inkscape::XML::Node*> const &reprs, Geom::Rect const &bounds,
91 SPDocument *document, Geom::Affine const &transform, Geom::Affine const &move);
92
93 bool isValid() const override;
94 bool hasItemChildren() const;
95
96protected:
97 void build(SPDocument *doc, Inkscape::XML::Node *repr) override;
98 void release() override;
99 void set(SPAttr key, char const *value) override;
100 void update(SPCtx *ctx, unsigned flags) override;
101 void modified(unsigned flags) override;
102
104 void remove_child(Inkscape::XML::Node* child) override;
106
107 Inkscape::DrawingPattern *show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox) override;
108 void hide(unsigned key) override;
109 void setBBox(unsigned key, Geom::OptRect const &bbox) override;
110
111private:
112
113 SPPattern *_chain() const;
114
118 unsigned _countHrefs(SPObject *o) const;
119
124
128 void _onRefModified(SPObject *ref, unsigned flags);
129
130 /* patternUnits and patternContentUnits attribute */
135 /* patternTransform attribute */
138 /* Tile rectangle */
143
144 sigc::connection _modified_connection;
145
155
165 std::vector<AttachedView> attached_views;
168
170 std::vector<View> views;
171 void update_view(View &v);
172};
173
174#endif // SEEN_SP_PATTERN_H
175
176/*
177 Local Variables:
178 mode:c++
179 c-file-style:"stroustrup"
180 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
181 indent-tabs-mode:nil
182 fill-column:99
183 End:
184*/
185// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
Geom::IntRect bounds
Definition canvas.cpp:169
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
static CRect from_xywh(Coord x, Coord y, Coord w, Coord h)
Create rectangle from origin and dimensions.
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Axis aligned, non-empty rectangle.
Definition rect.h:92
Drawing tree node used for rendering paints.
A class encapsulating a reference to a particular URI; observers can be notified when the URI comes t...
Interface for refcounted XML nodes.
Definition node.h:80
Typed SVG document implementation.
Definition document.h:101
Base class for visual SVG elements.
Definition sp-item.h:109
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPDocument * document
Definition sp-object.h:188
bool _acceptObject(SPObject *obj) const override
SPPattern * getObject() const
void setBBox(unsigned key, Geom::OptRect const &bbox) override
void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) override
unsigned _countHrefs(SPObject *o) const
Count how many times pattern is used by the styles of o and its descendants.
SPPattern::PatternUnits patternUnits() const
static char const * produce(std::vector< Inkscape::XML::Node * > const &reprs, Geom::Rect const &bounds, SPDocument *document, Geom::Affine const &transform, Geom::Affine const &move)
create a new pattern in XML tree
void transform_multiply(Geom::Affine postmul, bool set)
sigc::connection shown_released_connection
Definition sp-pattern.h:153
void _onRefChanged(SPObject *old_ref, SPObject *ref)
Gets called when the pattern is reattached to another <pattern>
void release() override
double width() const
SPPattern::PatternUnits patternContentUnits() const
SPPattern const * rootPattern() const
SVGLength _width
Definition sp-pattern.h:141
Geom::Affine _pattern_transform
Definition sp-pattern.h:136
void unattach_view(Inkscape::DrawingPattern *di)
int tag() const override
Definition sp-pattern.h:62
SVGLength _y
Definition sp-pattern.h:140
bool hasItemChildren() const
SVGLength _x
Definition sp-pattern.h:139
sigc::connection _modified_connection
Definition sp-pattern.h:144
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
void set_shown(SPPattern *new_shown)
bool isValid() const override
double x() const
SPPattern * shown
The pattern at the end of the href chain, currently tasked with keeping our DrawingPattern up to date...
Definition sp-pattern.h:152
PatternUnits _pattern_units
Definition sp-pattern.h:131
void hide(unsigned key) override
double y() const
bool _pattern_units_set
Definition sp-pattern.h:132
SVGLength _height
Definition sp-pattern.h:142
Geom::Rect getBox() const
Definition sp-pattern.h:72
void attach_view(Inkscape::DrawingPattern *di, unsigned key)
Inkscape::DrawingPattern * show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox) override
void update_view(View &v)
void modified(unsigned flags) override
bool _pattern_transform_set
Definition sp-pattern.h:137
bool _pattern_content_units_set
Definition sp-pattern.h:134
std::vector< View > views
Definition sp-pattern.h:170
SPPattern * clone_if_necessary(SPItem *item, char const *property)
Geom::OptRect viewbox() const
std::vector< AttachedView > attached_views
Definition sp-pattern.h:165
void update(SPCtx *ctx, unsigned flags) override
void _onRefModified(SPObject *ref, unsigned flags)
Gets called when the referenced <pattern> is changed.
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
double height() const
PatternUnits _pattern_content_units
Definition sp-pattern.h:133
Geom::Affine const & getTransform() const
@ UNITS_OBJECTBOUNDINGBOX
Definition sp-pattern.h:57
@ UNITS_USERSPACEONUSE
Definition sp-pattern.h:56
Glib::ustring href
Definition sp-pattern.h:65
void remove_child(Inkscape::XML::Node *child) override
SPPatternReference ref
Definition sp-pattern.h:66
SPPattern * _chain() const
const Geom::Affine & get_this_transform() const
~SPPattern() override
SVG length type.
Definition svg-length.h:22
SPItem * item
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
View helper class used by hatch, clippath, mask and pattern.
Ocnode * child[8]
Definition quantize.cpp:33
Unused.
Definition sp-object.h:94
Drawing items belonging to other patterns with this pattern at the end of their href chain.
Definition sp-pattern.h:161
Inkscape::DrawingPattern * drawingitem
Definition sp-pattern.h:162