File indexing completed on 2024-12-22 04:12:31

0001 /*
0002  *  SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_dummies_facade.h"
0008 
0009 #include "kis_image.h"
0010 #include "kis_node_dummies_graph.h"
0011 
0012 
0013 struct KisDummiesFacade::Private
0014 {
0015 public:
0016     KisNodeDummiesGraph dummiesGraph;
0017 };
0018 
0019 KisDummiesFacade::KisDummiesFacade(QObject *parent)
0020     : KisDummiesFacadeBase(parent),
0021       m_d(new Private())
0022 {
0023 }
0024 
0025 KisDummiesFacade::~KisDummiesFacade()
0026 {
0027     setImage(0);
0028     delete m_d;
0029 }
0030 
0031 void KisDummiesFacade::addNodeImpl(KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis)
0032 {
0033     KisNodeDummy *parentDummy = parent ? dummyForNode(parent) : 0;
0034     KisNodeDummy *aboveThisDummy = aboveThis ? dummyForNode(aboveThis) : 0;
0035     KisNodeDummy *newDummy = new KisNodeDummy(0, node);
0036 
0037     m_d->dummiesGraph.addNode(newDummy, parentDummy, aboveThisDummy);
0038 }
0039 
0040 void KisDummiesFacade::removeNodeImpl(KisNodeSP node)
0041 {
0042     KisNodeDummy *nodeDummy = dummyForNode(node);
0043     m_d->dummiesGraph.removeNode(nodeDummy);
0044 
0045     delete nodeDummy;
0046     // this dummy had no nodeShape pointer, so no cleaning here
0047 }
0048 
0049 bool KisDummiesFacade::hasDummyForNode(KisNodeSP node) const
0050 {
0051     return m_d->dummiesGraph.containsNode(node);
0052 }
0053 
0054 KisNodeDummy* KisDummiesFacade::dummyForNode(KisNodeSP node) const
0055 {
0056     return m_d->dummiesGraph.nodeToDummy(node);
0057 }
0058 
0059 KisNodeDummy* KisDummiesFacade::rootDummy() const
0060 {
0061     return m_d->dummiesGraph.rootDummy();
0062 }
0063 
0064 int KisDummiesFacade::dummiesCount() const
0065 {
0066     return m_d->dummiesGraph.dummiesCount();
0067 }