1 // File : SALOMEDS_AttributeTreeNode.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDS_AttributeTreeNode.hxx"
8 #include <TCollection_AsciiString.hxx>
9 #include <TCollection_ExtendedString.hxx>
10 #include <Standard_GUID.hxx>
11 #include <TDF_Label.hxx>
12 #include <TDF_Tool.hxx>
14 #include "SALOMEDSImpl_AttributeTreeNode.hxx"
15 #include "SALOMEDS_AttributeTreeNode.hxx"
17 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(const Handle(SALOMEDSImpl_AttributeTreeNode)& theAttr)
18 :SALOMEDS_GenericAttribute(theAttr)
21 SALOMEDS_AttributeTreeNode::SALOMEDS_AttributeTreeNode(SALOMEDS::AttributeTreeNode_ptr theAttr)
22 :SALOMEDS_GenericAttribute(theAttr)
25 SALOMEDS_AttributeTreeNode::~SALOMEDS_AttributeTreeNode()
28 void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value)
30 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
32 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFather;
33 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
34 aFather = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
35 aNode->SetFather(aFather);
38 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
39 SALOMEDS::AttributeTreeNode_var aFather = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
40 aNode->SetFather(aFather);
44 bool SALOMEDS_AttributeTreeNode::HasFather()
48 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
49 ret = aNode->HasFather();
52 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
53 ret = aNode->HasFather();
58 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather()
60 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
62 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
63 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
66 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
67 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather());
69 return _PTR(AttributeTreeNode)(aTN);
72 void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& value)
74 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
76 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aPrev;
77 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
78 aPrev = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
79 aNode->SetPrevious(aPrev);
82 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
83 SALOMEDS::AttributeTreeNode_var aPrev = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
84 aNode->SetPrevious(aPrev);
88 bool SALOMEDS_AttributeTreeNode::HasPrevious()
92 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
93 ret = aNode->HasPrevious();
96 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
97 ret = aNode->HasPrevious();
102 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious()
104 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
106 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
107 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
110 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
111 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious());
113 return _PTR(AttributeTreeNode)(aTN);
116 void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value)
118 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
120 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aNext;
121 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
122 aNext = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
123 aNode->SetNext(aNext);
126 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
127 SALOMEDS::AttributeTreeNode_var aNext = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
128 aNode->SetNext(aNext);
132 bool SALOMEDS_AttributeTreeNode::HasNext()
136 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
137 ret = aNode->HasNext();
140 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
141 ret = aNode->HasNext();
146 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext()
148 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
150 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
151 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
154 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
155 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext());
157 return _PTR(AttributeTreeNode)(aTN);
160 void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value)
162 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
164 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFirst;
165 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
166 aFirst = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
167 aNode->SetFirst(aFirst);
170 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
171 SALOMEDS::AttributeTreeNode_var aFirst = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
172 aNode->SetFirst(aFirst);
176 bool SALOMEDS_AttributeTreeNode::HasFirst()
180 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
181 ret = aNode->HasFirst();
184 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
185 ret = aNode->HasFirst();
190 _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst()
192 SALOMEDSClient_AttributeTreeNode* aTN = NULL;
194 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
195 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
198 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
199 aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst());
201 return _PTR(AttributeTreeNode)(aTN);
204 void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
207 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
208 aNode->SetTreeID(Standard_GUID((char*)value.c_str()));
211 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
212 aNode->SetTreeID(value.c_str());
216 std::string SALOMEDS_AttributeTreeNode::GetTreeID()
218 TCollection_AsciiString aGUID;
220 Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
222 aNode->GetTreeID().ToCString(guid);
223 aGUID = TCollection_AsciiString(guid);
226 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
227 aGUID = TCollection_AsciiString(aNode->GetTreeID());
230 return std::string(aGUID.ToCString());
233 void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value)
235 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
237 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
238 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
239 anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
240 aNode->Append(anOther);
243 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
244 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
245 aNode->Append(anOther);
249 void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value)
251 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
253 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
254 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
255 anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
256 aNode->Prepend(anOther);
259 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
260 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
261 aNode->Prepend(anOther);
265 void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& value)
267 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
269 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
270 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
271 anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
272 aNode->InsertBefore(anOther);
275 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
276 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
277 aNode->InsertBefore(anOther);
281 void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& value)
283 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
285 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
286 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
287 anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
288 aNode->InsertAfter(anOther);
291 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
292 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
293 aNode->InsertAfter(anOther);
297 void SALOMEDS_AttributeTreeNode::Remove()
299 if(_isLocal) Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Remove();
300 else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove();
303 int SALOMEDS_AttributeTreeNode::Depth()
306 if(_isLocal) aDepth = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Depth();
307 else aDepth = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth();
311 bool SALOMEDS_AttributeTreeNode::IsRoot()
314 if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->IsRoot();
315 else ret = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot();
319 bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& value)
322 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
324 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
325 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
326 anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
327 ret = aNode->IsDescendant(anOther);
330 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
331 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
332 ret = aNode->IsDescendant(anOther);
337 bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value)
340 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
342 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
343 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
344 anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
345 ret = aNode->IsFather(anOther);
348 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
349 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
350 ret = aNode->IsFather(anOther);
355 bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value)
358 SALOMEDS_AttributeTreeNode* aTN = dynamic_cast<SALOMEDS_AttributeTreeNode*>(value.get());
360 Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther;
361 aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl);
362 anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl);
363 ret = aNode->IsChild(anOther);
366 SALOMEDS::AttributeTreeNode_var aNode = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl);
367 SALOMEDS::AttributeTreeNode_var anOther = SALOMEDS::AttributeTreeNode::_narrow(aTN->_corba_impl);
368 ret = aNode->IsChild(anOther);
373 std::string SALOMEDS_AttributeTreeNode::Label()
375 TCollection_AsciiString aLabel;
376 if(_isLocal) TDF_Tool::Entry(_local_impl->Label(), aLabel);
377 else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label();
378 return std::string(aLabel.ToCString());