summaryrefslogtreecommitdiffstats
path: root/src/object/filters/mergenode.cpp
blob: 59f0d3f269177f2542d8547d2952d9916049f004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// SPDX-License-Identifier: GPL-2.0-or-later
/** \file
 * feMergeNode implementation. A feMergeNode contains the name of one
 * input image for feMerge.
 */
/*
 * Authors:
 *   Kees Cook <kees@outflux.net>
 *   Niko Kiirala <niko@kiirala.com>
 *   Abhishek Sharma
 *
 * Copyright (C) 2004,2007 authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include "mergenode.h"
#include "merge.h"

#include "attributes.h"

#include "display/nr-filter-types.h"

#include "xml/repr.h"

SPFeMergeNode::SPFeMergeNode()
    : SPObject(), input(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) {
}

SPFeMergeNode::~SPFeMergeNode() = default;

/**
 * Reads the Inkscape::XML::Node, and initializes SPFeMergeNode variables.  For this to get called,
 * our name must be associated with a repr via "sp_object_type_register".  Best done through
 * sp-object-repr.cpp's repr_name_entries array.
 */
void SPFeMergeNode::build(SPDocument */*document*/, Inkscape::XML::Node */*repr*/) {
	this->readAttr(SPAttr::IN_);
}

/**
 * Drops any allocated memory.
 */
void SPFeMergeNode::release() {
	SPObject::release();
}

/**
 * Sets a specific value in the SPFeMergeNode.
 */
void SPFeMergeNode::set(SPAttr key, gchar const *value) {
    SPFeMerge *parent = SP_FEMERGE(this->parent);

    if (key == SPAttr::IN_) {
        int input = parent->read_in(value);
        if (input != this->input) {
            this->input = input;
            this->requestModified(SP_OBJECT_MODIFIED_FLAG);
        }
    }

    /* See if any parents need this value. */
    SPObject::set(key, value);
}

/**
 * Receives update notifications.
 */
void SPFeMergeNode::update(SPCtx *ctx, guint flags) {
    if (flags & SP_OBJECT_MODIFIED_FLAG) {
        this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
    }

    SPObject::update(ctx, flags);
}

/**
 * Writes its settings to an incoming repr object, if any.
 */
Inkscape::XML::Node* SPFeMergeNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
    // Inkscape-only this, not copied during an "plain SVG" dump:
    if (flags & SP_OBJECT_WRITE_EXT) {
        if (repr) {
            // is this sane?
            //repr->mergeFrom(object->getRepr(), "id");
        } else {
            repr = this->getRepr()->duplicate(doc);
        }
    }

    SPObject::write(doc, repr, flags);

    return repr;
}


/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :