Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-mesh-row.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/* Authors:
6 * Lauris Kaplinski <lauris@kaplinski.com>
7 * bulia byak
8 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
9 * Jon A. Cruz <jon@joncruz.org>
10 * Tavmjong Bah <tavjong@free.fr>
11 *
12 * Copyright (C) 1999,2005 authors
13 * Copyright (C) 2010 Jon A. Cruz
14 * Copyright (C) 2012 Tavmjong Bah
15 *
16 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
17 */
18#include "sp-mesh-row.h"
19#include "style.h"
20
22{
23 SPMeshrow *result = nullptr;
24
25 for (SPObject* obj = getNext(); obj && !result; obj = obj->getNext()) {
26 if (is<SPMeshrow>(obj)) {
27 result = cast<SPMeshrow>(obj);
28 }
29 }
30
31 return result;
32}
33
35{
36 SPMeshrow *result = nullptr;
37
38 for (SPObject* obj = getPrev(); obj; obj = obj->getPrev()) {
39 // The closest previous SPObject that is an SPMeshrow *should* be ourself.
40 if (is<SPMeshrow>(obj)) {
41 auto meshrow = cast<SPMeshrow>(obj);
42 // Sanity check to ensure we have a proper sibling structure.
43 if (meshrow->getNextMeshrow() == this) {
44 result = meshrow;
45 } else {
46 g_warning("SPMeshrow previous/next relationship broken");
47 }
48 break;
49 }
50 }
51
52 return result;
53}
54
55
56/*
57 * Mesh Row
58 */
61
62SPMeshrow::~SPMeshrow() = default;
63
67
68
72void SPMeshrow::set(SPAttr /*key*/, const gchar* /*value*/) {
73}
74
78void SPMeshrow::modified(unsigned int flags) {
79
80 flags &= SP_OBJECT_MODIFIED_CASCADE;
81 std::vector<SPObject *> l;
82 for (auto& child: children) {
84 l.push_back(&child);
85 }
86
87 for (auto child:l) {
88 if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
89 child->emitModified(flags);
90 }
92 }
93}
94
95
100 if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
101 repr = xml_doc->createElement("svg:meshrow");
102 }
103
104 SPObject::write(xml_doc, repr, flags);
105
106 return repr;
107}
108
113/*
114 Local Variables:
115 mode:c++
116 c-file-style:"stroustrup"
117 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
118 indent-tabs-mode:nil
119 fill-column:99
120 End:
121*/
122// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
Interface for refcounted XML nodes.
Definition node.h:80
Typed SVG document implementation.
Definition document.h:101
Gradient Meshrow.
Definition sp-mesh-row.h:18
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) override
Virtual set: set attribute to value.
~SPMeshrow() override
SPMeshrow * getPrevMeshrow()
SPMeshrow * getNextMeshrow()
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
void set(SPAttr key, const char *value) override
Virtual build: set meshrow attributes from its associated XML node.
void modified(unsigned int flags) override
modified
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
SPObject * getNext()
Inkscape::XML::Node * repr
Definition sp-object.h:193
virtual Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags)
SPObject * getPrev()
Returns previous object in sibling list or NULL.
virtual void build(SPDocument *doc, Inkscape::XML::Node *repr)
ChildrenList children
Definition sp-object.h:907
Css & result
Ocnode * child[8]
Definition quantize.cpp:33
SPMeshrow: SVG <meshrow> implementation.
SPObject * sp_object_unref(SPObject *object, SPObject *owner)
Decrease reference count of object, with possible debugging and finalization.
SPObject * sp_object_ref(SPObject *object, SPObject *owner)
Increase reference count of object, with possible debugging.
Interface for XML documents.
Definition document.h:43
virtual Node * createElement(char const *name)=0
SPStyle - a style object for SPItem objects.