Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-hatch.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/*
7 * Authors:
8 * Tomasz Boczkowski <penginsbacon@gmail.com>
9 * Jon A. Cruz <jon@joncruz.org>
10 *
11 * Copyright (C) 2014 Tomasz Boczkowski
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#ifndef SEEN_SP_HATCH_H
17#define SEEN_SP_HATCH_H
18
19#include <vector>
20#include <glibmm/ustring.h>
21#include <sigc++/connection.h>
22
23#include "object-view.h"
24#include "svg/svg-length.h"
25#include "svg/svg-angle.h"
26#include "sp-paint-server.h"
27#include "uri-references.h"
28
30class SPHatchPath;
31class SPItem;
32
33namespace Inkscape {
34class Drawing;
35class DrawingPattern;
36namespace XML { class Node; }
37} // namespace Inkscape
38
40{
41public:
43 SPHatch *getObject() const;
44
45protected:
46 bool _acceptObject(SPObject *obj) const override;
47};
48
49class SPHatch final : public SPPaintServer
50{
51public:
52 enum class HatchUnits
53 {
56 };
57
68
69 SPHatch();
70 ~SPHatch() override;
71 int tag() const override { return tag_of<decltype(*this)>; }
72
73 // Reference (href)
74 Glib::ustring href;
76
77 double x() const;
78 double y() const;
79 double pitch() const;
80 double rotate() const;
81 HatchUnits hatchUnits() const;
84 SPHatch const *rootHatch() const;
85 SPHatch *rootHatch() { return const_cast<SPHatch *>(std::as_const(*this).rootHatch()); }
86
87 std::vector<SPHatchPath *> hatchPaths();
88 std::vector<SPHatchPath const *> hatchPaths() const;
89
90 SPHatch *clone_if_necessary(SPItem *item, char const *property);
91 void transform_multiply(Geom::Affine const &postmul, bool set);
92
93 bool isValid() const override;
94
95 Inkscape::DrawingPattern *show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox) override;
96 void hide(unsigned key) override;
97
98 RenderInfo calculateRenderInfo(unsigned key) const;
99 Geom::Interval bounds() const;
100 void setBBox(unsigned int key, Geom::OptRect const &bbox) override;
101
102protected:
103 void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
104 void release() override;
106 void set(SPAttr key, char const *value) override;
107 void update(SPCtx* ctx, unsigned int flags) override;
108 void modified(unsigned int flags) override;
109
110private:
112 std::vector<View> views;
113
114 static bool _hasHatchPatchChildren(SPHatch const *hatch);
115
116 void _updateView(View &view);
117 RenderInfo _calculateRenderInfo(View const &view) const;
119
123 int _countHrefs(SPObject *o) const;
124
129
133 void _onRefModified(SPObject *ref, unsigned flags);
134
135 // patternUnits and patternContentUnits attribute
136 std::optional<HatchUnits> _hatch_units;
137 std::optional<HatchUnits> _hatch_content_units;
138
139 // hatchTransform attribute
140 std::optional<Geom::Affine> _hatch_transform;
141
142 // Strip
147
148 sigc::connection _modified_connection;
149};
150
151#endif // SEEN_SP_HATCH_H
152
153/*
154 Local Variables:
155 mode:c++
156 c-file-style:"stroustrup"
157 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
158 indent-tabs-mode:nil
159 fill-column:99
160 End:
161*/
162// 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
Range of real numbers that is never empty.
Definition interval.h:59
Range of real numbers that can be empty.
Definition interval.h:199
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
SPHatch * getObject() const
Definition sp-hatch.cpp:42
bool _acceptObject(SPObject *obj) const override
Definition sp-hatch.cpp:47
std::vector< View > views
Definition sp-hatch.h:112
Geom::Affine hatchTransform() const
Definition sp-hatch.cpp:396
SVGLength _x
Definition sp-hatch.h:143
void _onRefModified(SPObject *ref, unsigned flags)
Gets called when the referenced <hatch> is changed.
Definition sp-hatch.cpp:359
RenderInfo calculateRenderInfo(unsigned key) const
Definition sp-hatch.cpp:577
Glib::ustring href
Definition sp-hatch.h:74
static bool _hasHatchPatchChildren(SPHatch const *hatch)
Definition sp-hatch.cpp:218
void modified(unsigned int flags) override
Definition sp-hatch.cpp:293
void transform_multiply(Geom::Affine const &postmul, bool set)
Definition sp-hatch.cpp:499
void release() override
Definition sp-hatch.cpp:78
std::optional< Geom::Affine > _hatch_transform
Definition sp-hatch.h:140
SPHatch * clone_if_necessary(SPItem *item, char const *property)
Definition sp-hatch.cpp:469
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Definition sp-hatch.cpp:60
SVGLength _pitch
Definition sp-hatch.h:145
void _updateView(View &view)
Definition sp-hatch.cpp:588
void update(SPCtx *ctx, unsigned int flags) override
Definition sp-hatch.cpp:263
bool isValid() const override
Definition sp-hatch.cpp:505
Inkscape::DrawingPattern * show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox) override
Definition sp-hatch.cpp:521
void hide(unsigned key) override
Definition sp-hatch.cpp:542
SVGLength _y
Definition sp-hatch.h:144
void setBBox(unsigned int key, Geom::OptRect const &bbox) override
Definition sp-hatch.cpp:701
double rotate() const
Definition sp-hatch.cpp:436
double x() const
Definition sp-hatch.cpp:406
std::vector< SPHatchPath * > hatchPaths()
Definition sp-hatch.cpp:225
SPHatch * rootHatch()
Definition sp-hatch.h:85
double y() const
Definition sp-hatch.cpp:416
sigc::connection _modified_connection
Definition sp-hatch.h:148
std::optional< HatchUnits > _hatch_content_units
Definition sp-hatch.h:137
RenderInfo _calculateRenderInfo(View const &view) const
Definition sp-hatch.cpp:603
Geom::Interval bounds() const
Definition sp-hatch.cpp:562
SPHatchReference ref
Definition sp-hatch.h:75
int tag() const override
Definition sp-hatch.h:71
~SPHatch() override
Geom::OptInterval _calculateStripExtents(Geom::OptRect const &bbox) const
Definition sp-hatch.cpp:669
std::optional< HatchUnits > _hatch_units
Definition sp-hatch.h:136
HatchUnits hatchUnits() const
Definition sp-hatch.cpp:376
void _onRefChanged(SPObject *old_ref, SPObject *ref)
Gets called when the hatch is reattached to another <hatch>
Definition sp-hatch.cpp:310
HatchUnits hatchContentUnits() const
Definition sp-hatch.cpp:386
double pitch() const
Definition sp-hatch.cpp:426
int _countHrefs(SPObject *o) const
Count how many times hatch is used by the styles of o and its descendants.
Definition sp-hatch.cpp:446
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
Definition sp-hatch.cpp:100
SVGAngle _rotate
Definition sp-hatch.h:146
SPHatch const * rootHatch() const
Definition sp-hatch.cpp:364
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
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
Geom::Rect tile_rect
Definition sp-hatch.h:62
Geom::Affine overflow_step_transform
Definition sp-hatch.h:65
Geom::Affine overflow_initial_transform
Definition sp-hatch.h:66
Geom::Affine child_transform
Definition sp-hatch.h:60
Geom::Affine pattern_to_user_transform
Definition sp-hatch.h:61
SVG angle type.