-
Notifications
You must be signed in to change notification settings - Fork 1
/
sgftree.h
126 lines (103 loc) · 3.12 KB
/
sgftree.h
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef SGFTREE_H
#define SGFTREE_H
#include <QtCore/QVector>
#include <QtCore/QMultiHash>
#include <QtCore/QString>
#include <QtCore/QSet>
#include "sgfvariant.h"
#include "common.h"
class SgfTree
{
public:
enum NodeAnnot { naNone = 0x0,
GoodForBlack, // GB
GoodForWhite, // GW
Even, // DM
Unclear // UC
};
enum MoveAnnot {
maNone,
Bad, // BM
Doubtful, // DO
Interesting, // IT
Tesuji // TE
};
private:
quint16 m_moveIndex; // MN
QVector <SgfTree*> m_children;
SgfTree *m_parent;
QMultiHash <QString, SgfVariant> m_attr;
// start new
// Stone m_move;
#ifdef FULL_MVC
NodeAnnot m_annot; // DM UC GB GW
QList <Point> m_terrBlack;
QList <Point> m_terrWhite;
bool m_force; // KO
// QVector <Stone> m_setting;
Color m_turn;
QString m_comment;
QString m_name; // N
//Annotation m_annot;
bool m_hotspot; // HO
double m_value; // V
bool m_bad; // BM
bool m_doubtfool; // DO
bool m_interesting; // IT
bool m_tesuji; // TE
QVector <Mark> m_marks;
QVector <Point> m_dimm;
QVector <Line> m_lines;
#endif
// end new
public:
SgfVariant attrValue(const QString& attrname)const;
QList<SgfVariant> attrValues(const QString& attrname)const;
void setAttribute(const QString& attrname, SgfVariant val);
void addAttribute(const QString& attrname, SgfVariant val);
QMultiHash <QString, SgfVariant>& attributes();
// getters and setters
#ifdef FULL_MVC
inline void setAnnotation(Annotation annot) { m_annot = annot; }
inline Annotation annotation() { return m_annot; }
#else
void setNodeAnnot(NodeAnnot annot); // TODO
NodeAnnot nodeAnnot();
void setMoveAnnot(MoveAnnot annot); // TODO
MoveAnnot moveAnnot();
inline bool hotspot() { return m_attr.contains("HO"); }
inline double value() { return m_attr.value("V").toReal(); }
#endif
Stone move();
inline quint16 moveIndex() { return m_moveIndex; }
inline void setMoveIndex(quint16 index) { m_moveIndex = index; }
inline QString moveName() { return attrValue("N").toString(); }
void addChild(SgfTree *child);
bool removeChild(SgfTree *child);
inline SgfTree* parent() { return m_parent; }
inline void setParent(SgfTree* newParent) { m_parent = newParent; }
inline QVector <SgfTree*> children()const { return m_children; }
SgfTree* child(int i);
inline Color turn() { return m_attr.value("PL").toColor(); }
inline void setTurn(Color color) { setAttribute("PL", color); }
void setLine(Point from, Point to);
void removeLine(Point p);
void setArrow(Point from, Point to);
void removeLineElement(Point from, Point to);
void setLabel(Label lbl);
void removeLabel(Point pnt);
QList <Mark> marks()const;
void setMark(Mark);
QList <Point> terrBlack() const;
QList <Point> terrWhite() const;
inline void addTerrBlack(Point s) { m_attr.insert("TB", s); }
inline void addTerrWhite(Point s) { m_attr.insert("TW", s); }
inline void removeTerrWhite(Point s) { m_attr.remove("TW", s); }
inline void removeTerrBlack(Point s) { m_attr.remove("TB", s); }
void setTerritory(Stone s);
inline void clearTerritory() { m_attr.remove("TB"); m_attr.remove("TW"); }
void setStone(Stone s);
SgfTree(SgfTree *p = NULL);
~SgfTree();
};
#endif // SGFTREE_H