-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
37 lines (29 loc) · 935 Bytes
/
node.cpp
File metadata and controls
37 lines (29 loc) · 935 Bytes
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
#include "node.h"
Node::Node(Node* par): parent(par)
{}
Node::~Node()
{
qDeleteAll(children);
children.clear();
}
Node* Node::getParent() const {return parent;}
void Node::setParent(Node* par){parent = par;}
QPointF Node::getPosition() const {return position;}
void Node::setPosition(const QPointF& pos){position = pos;}
QPointF Node::getPreviousPosition() const {return previousPosition;}
void Node::setPreviousPosition(const QPointF& pos){previousPosition = pos;}
QList<Node*> Node::getChildren() const {return children;}
void Node::addChild(Node* child)
{
if (!child) return;
children.append(child);
}
void Node::removeChild(Node* child)
{
if (!child)
return;
children.removeOne(child);
child->setParent(nullptr);
}
QList<Node*> Node::getNeighborNodes() const {return neighborNodes;}
void Node::addNeighborNodes(Node* node){if (!neighborNodes.contains(node)) neighborNodes.append(node);}