Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-mesh-patch.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-patch.h"
19#include "style.h"
20
21#include "attributes.h"
22
24{
25 SPMeshpatch *result = nullptr;
26
27 for (SPObject* obj = getNext(); obj && !result; obj = obj->getNext()) {
28 if (is<SPMeshpatch>(obj)) {
29 result = cast<SPMeshpatch>(obj);
30 }
31 }
32
33 return result;
34}
35
37{
38 SPMeshpatch *result = nullptr;
39
40 for (SPObject* obj = getPrev(); obj; obj = obj->getPrev()) {
41 // The closest previous SPObject that is an SPMeshpatch *should* be ourself.
42 if (is<SPMeshpatch>(obj)) {
43 auto meshpatch = cast<SPMeshpatch>(obj);
44 // Sanity check to ensure we have a proper sibling structure.
45 if (meshpatch->getNextMeshpatch() == this) {
46 result = meshpatch;
47 } else {
48 g_warning("SPMeshpatch previous/next relationship broken");
49 }
50 break;
51 }
52 }
53
54 return result;
55}
56
57
58/*
59 * Mesh Patch
60 */
62 this->tensor_string = nullptr;
63}
64
66
72
76void SPMeshpatch::set(SPAttr key, const gchar* value) {
77 switch (key) {
78 case SPAttr::TENSOR: {
79 if (value) {
80 this->tensor_string = new Glib::ustring( value );
81 // std::cout << "sp_meshpatch_set: Tensor string: " << patch->tensor_string->c_str() << std::endl;
82 }
83 break;
84 }
85 default: {
86 // Do nothing
87 }
88 }
89}
90
94void SPMeshpatch::modified(unsigned int flags) {
95
96 flags &= SP_OBJECT_MODIFIED_CASCADE;
97 std::vector<SPObject *> l;
98 for (auto& child: children) {
100 l.push_back(&child);
101 }
102
103 for (auto child:l) {
104 if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
105 child->emitModified(flags);
106 }
108 }
109}
110
111
116 if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
117 repr = xml_doc->createElement("svg:meshpatch");
118 }
119
120 SPObject::write(xml_doc, repr, flags);
121
122 return repr;
123}
124
129/*
130 Local Variables:
131 mode:c++
132 c-file-style:"stroustrup"
133 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
134 indent-tabs-mode:nil
135 fill-column:99
136 End:
137*/
138// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Lookup dictionary for attributes/properties.
SPAttr
Definition attributes.h:27
Interface for refcounted XML nodes.
Definition node.h:80
Typed SVG document implementation.
Definition document.h:101
Gradient Meshpatch.
void modified(unsigned int flags) override
modified
SPMeshpatch * getNextMeshpatch()
SPMeshpatch * getPrevMeshpatch()
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) override
Virtual set: set attribute to value.
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
void set(SPAttr key, const char *value) override
Virtual build: set meshpatch attributes from its associated XML node.
Glib::ustring * tensor_string
~SPMeshpatch() override
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.
void readAttr(char const *key)
Read value of key attribute from XML node into object.
virtual void build(SPDocument *doc, Inkscape::XML::Node *repr)
ChildrenList children
Definition sp-object.h:907
Css & result
static cairo_user_data_key_t key
Ocnode * child[8]
Definition quantize.cpp:33
SPMeshpatch: SVG <meshpatch> 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.