Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBezierMesh.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include "KisBezierMesh.h"
8
9#include <QDebug>
10
11#include "kis_dom_utils.h"
12
13QDebug KisBezierMeshDetails::operator<<(QDebug dbg, const BaseMeshNode &n) {
14 dbg.nospace() << "Node " << n.node << " "
15 << "(lC: " << n.leftControl << " "
16 << "tC: " << n.topControl << " "
17 << "rC: " << n.rightControl << " "
18 << "bC: " << n.bottomControl << ") ";
19 return dbg.nospace();
20}
21
22
23
24void KisBezierMeshDetails::saveValue(QDomElement *parent, const QString &tag, const KisBezierMeshDetails::BaseMeshNode &node)
25{
26 QDomDocument doc = parent->ownerDocument();
27 QDomElement e = doc.createElement(tag);
28 parent->appendChild(e);
29
30 e.setAttribute("type", "mesh-node");
31 KisDomUtils::saveValue(&e, "node", node.node);
32 KisDomUtils::saveValue(&e, "left-control", node.leftControl);
33 KisDomUtils::saveValue(&e, "right-control", node.rightControl);
34 KisDomUtils::saveValue(&e, "top-control", node.topControl);
35 KisDomUtils::saveValue(&e, "bottom-control", node.bottomControl);
36}
37
39{
40 if (!KisDomUtils::Private::checkType(parent, "mesh-node")) return false;
41
42 KisDomUtils::loadValue(parent, "node", &node->node);
43 KisDomUtils::loadValue(parent, "left-control", &node->leftControl);
44 KisDomUtils::loadValue(parent, "right-control", &node->rightControl);
45 KisDomUtils::loadValue(parent, "top-control", &node->topControl);
46 KisDomUtils::loadValue(parent, "bottom-control", &node->bottomControl);
47
48 return true;
49}
KRITAGLOBAL_EXPORT void saveValue(QDomElement *parent, const QString &tag, const BaseMeshNode &node)
QDebug operator<<(QDebug dbg, const Mesh< Node, Patch > &mesh)
KRITAGLOBAL_EXPORT bool loadValue(const QDomElement &parent, BaseMeshNode *node)
bool checkType(const QDomElement &e, const QString &expectedType)
void saveValue(QDomElement *parent, const QString &tag, const QSize &size)
bool loadValue(const QDomElement &e, float *v)