-
Notifications
You must be signed in to change notification settings - Fork 0
/
bnode.cpp
216 lines (172 loc) · 3.5 KB
/
bnode.cpp
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#include <iostream>
#include "bnode.h"
#include <ctime>
#include <cstdlib>
#include <sstream>
BNode::BNode(Node* aNode){
init(aNode);
}
BNode::BNode(){
init(NULL);
}
void BNode::init(Node *aNode){
m_node = aNode;
m_uid = clock();
m_parent = NULL;
m_constraint = "";
m_predicate = "";
m_mode = "";
m_isCollapsed = false;
m_isConstraint = false;
m_isMode = false;
m_isPredicate = false;
m_isDoubleClicked = false;
}
Node* BNode::getNode(){
return m_node;
}
int BNode::getX(){
return m_x;
}
void BNode::setX(int aX){
m_x = aX;
}
int BNode::getY(){
return m_y;
}
void BNode::setY(int aY){
m_y = aY;
}
int BNode::getSX(){
return m_sX;
}
void BNode::setSX(int aX){
m_sX = aX;
}
int BNode::getSY(){
return m_sY;
}
void BNode::setSY(int aY){
m_sY = aY;
}
int BNode::getId(){
return m_uid;
}
void BNode::setId(int aId){
m_uid = aId;
}
int BNode::getWidth(){
return m_width;
}
void BNode::setWidth(int aWidth){
m_width = aWidth;
}
int BNode::getHeight(){
return m_height;
}
void BNode::setHeight(int aHeight){
m_height = aHeight;
}
bool BNode::isCollapsed(){
return m_isCollapsed;
}
void BNode::setIsCollapsed(bool aIsCollapsed){
m_isCollapsed = aIsCollapsed;
}
bool BNode::isDoubleClicked(){
return m_isDoubleClicked;
}
void BNode::setIsDoubleClicked(bool aIsDoubleClicked){
m_isDoubleClicked = aIsDoubleClicked;
}
BNode* BNode::getParent(){
return m_parent;
}
bool BNode::isMode(){
return m_isMode;
}
void BNode::setIsMode(bool aIsMode){
m_isMode = aIsMode;
}
bool BNode::isConstraint(){
return m_isConstraint;
}
void BNode::setIsConstraint(bool aIsConstraint){
m_isConstraint = aIsConstraint;
}
bool BNode::isPredicate(){
return m_isPredicate;
}
void BNode::setIsPredicate(bool aIsPredicate){
m_isPredicate = aIsPredicate;
}
bool BNode::isType(){
return m_isType;
}
void BNode::setIsType(bool aIsType){
m_isType = aIsType;
}
std::string BNode::getMode(){
return m_mode;
}
void BNode::setMode(std::string aMode){
m_mode = aMode;
}
std::string BNode::getConstraint(){
return m_constraint;
}
void BNode::setConstraint(std::string aConstraint){
m_constraint = aConstraint;
}
std::string BNode::getPredicate(){
return m_predicate;
}
void BNode::setPredicate(std::string aPredicate){
m_predicate = aPredicate;
}
std::string BNode::getAppropriateText(){
std::string s = "";
std::ostringstream sstream;
Node* innerNode=getNode();
if(innerNode->isLeafNode()){
if(isMode())
s += getMode() + "\n";
if(isConstraint())
s += getConstraint() + "\n";
if(isPredicate())
s += getPredicate() + "\n";
if(isType())
s += getType();
//sstream << s << " " << getId();
return s;//sstream.str();
}
else{
sstream << getNode()->getName(); //<< " " << m_node->getId();
return sstream.str();
}
}
std::string BNode::getType(){
return m_type;
}
void BNode::setType(std::string aType){
m_type = aType;
}
void BNode::setParent(BNode* aParent){
m_parent = aParent;
}
std::string BNode::getClippedText(){
std::string s = getAppropriateText();
if(isAttributeNode()){
return s.substr(0,s.find("::")+3)+"...";
}
return s;
}
bool BNode::isAttributeNode(){
std::string s = getAppropriateText();
if(s.find("::") != std::string::npos)
return true;
return false;
}
BNode::~BNode(){
delete m_node;
}