00001
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00028 #include <exotkTree_Tree.hxx>
00029
00030 #ifndef _TCollection_AsciiString_HeaderFile
00031 #include <TCollection_AsciiString.hxx>
00032 #endif
00033 #ifndef _exotkTree_TreeNode_HeaderFile
00034 #include <exotkTree_TreeNode.hxx>
00035 #endif
00036 #ifndef _exotkTree_ListIteratorOfListOfTreeNode_HeaderFile
00037 #include <exotkTree_ListIteratorOfListOfTreeNode.hxx>
00038 #endif
00039 #ifndef _exotkTree_TreeUpdator_HeaderFile
00040 #include <exotkTree_TreeUpdator.hxx>
00041 #endif
00042
00043
00044
00045 IMPLEMENT_STANDARD_HANDLE(exotkTree_Tree, MMgt_TShared)
00046 IMPLEMENT_STANDARD_RTTI(exotkTree_Tree, MMgt_TShared)
00047
00048
00049
00050
00051
00052
00053
00054 IMPLEMENT_STANDARD_TYPE(exotkTree_Tree)
00055 IMPLEMENT_STANDARD_SUPERTYPE(MMgt_TShared)
00056 IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient)
00057 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
00058 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(MMgt_TShared)
00059 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient)
00060 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
00061 IMPLEMENT_STANDARD_TYPE_END(exotkTree_Tree)
00062
00063
00064
00065
00066
00067
00068
00069
00070 exotkTree_Tree::exotkTree_Tree()
00071 {
00072
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 exotkTree_Tree::~exotkTree_Tree()
00084 {
00085
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 Handle_exotkTree_TreeNode exotkTree_Tree::Root()
00097 {
00098 return myRoot;
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 void exotkTree_Tree::SetRoot(const Handle_exotkTree_TreeNode &aRoot)
00111 {
00112 myRoot = aRoot;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 void exotkTree_Tree::SetData(const Handle_Standard_Transient& aData)
00124 {
00125 myData = aData;
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135 Handle_Standard_Transient exotkTree_Tree::Data()
00136 {
00137 return myData;
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147 Standard_Boolean exotkTree_Tree::HasData()
00148 {
00149 return ( !myData.IsNull() );
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159 TCollection_AsciiString exotkTree_Tree::Dump()
00160 {
00161 TCollection_AsciiString theString;
00162 if ( !myRoot.IsNull() )
00163 {
00164 theString += DumpRec(myRoot);
00165 }
00166 else
00167 {
00168 theString += "No Root";
00169 }
00170 return theString;
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 TCollection_AsciiString exotkTree_Tree::DumpRec(const Handle_exotkTree_TreeNode& aNode,const Standard_Integer level)
00183 {
00184 TCollection_AsciiString theString;
00185 for ( int i = 0 ; i <= level ; i++ )
00186 {
00187 theString +=" ";
00188 }
00189 Handle_Standard_Type theType = aNode->DynamicType();
00190 theString += TCollection_AsciiString("\\") + aNode->Name() + TCollection_AsciiString("\t") + theType->Name() + TCollection_AsciiString("\r\n");
00191 exotkTree_ListIteratorOfListOfTreeNode iter;
00192 exotkTree_ListOfTreeNode list;
00193 aNode->Children(list);
00194 for ( iter.Initialize(list) ; iter.More() ; iter.Next() )
00195 {
00196 int i = level+1;
00197 theString += DumpRec(iter.Value(),i);
00198 }
00199 return theString;
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 Standard_Boolean exotkTree_Tree::AddUpdator(exotkTree_TreeUpdator* anUpdatorToAdd)
00212 {
00213 if ( anUpdatorToAdd==NULL)
00214 return Standard_False;
00215
00216 if ( UpdatorExists(anUpdatorToAdd) )
00217 return Standard_False;
00218 else
00219 myUpdators.insert(myUpdators.end(),anUpdatorToAdd);
00220
00221 return Standard_True;
00222 }
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233 Standard_Boolean exotkTree_Tree::RemoveUpdator(exotkTree_TreeUpdator *anUpdatorToRemove)
00234 {
00235 if ( anUpdatorToRemove==NULL)
00236 return Standard_False;
00237
00238 Standard_Boolean theUpdatorIsRemoved = Standard_False;
00239
00240 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00241 for ( theIterator = myUpdators.begin() ;( theIterator != myUpdators.end() ) && ( !theUpdatorIsRemoved ) ;++theIterator)
00242 {
00243 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00244 if ( theCurrentUpdator == anUpdatorToRemove )
00245 {
00246 myUpdators.erase(theIterator);
00247 theUpdatorIsRemoved = Standard_True;
00248 }
00249 }
00250
00251
00252 return theUpdatorIsRemoved;
00253 }
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 Standard_Boolean exotkTree_Tree::UpdatorExists(exotkTree_TreeUpdator *anUpdatorToCheck)
00265 {
00266 Standard_Boolean theUpdatorExists = Standard_False;
00267
00268 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00269 for ( theIterator = myUpdators.begin() ;( theIterator != myUpdators.end() ) && ( !theUpdatorExists ) ;++theIterator)
00270 {
00271 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00272 if ( theCurrentUpdator == anUpdatorToCheck )
00273 {
00274 theUpdatorExists = Standard_True;
00275 }
00276 }
00277
00278 return theUpdatorExists;
00279 }
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 Standard_Boolean exotkTree_Tree::Expand(const Handle_exotkTree_TreeNode &aNodeToExpand,const Standard_Boolean Recursive)
00292 {
00293 Standard_Boolean theSuccess = Standard_False;
00294 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00295 for ( theIterator = myUpdators.begin() ; theIterator != myUpdators.end() ;++theIterator)
00296 {
00297 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00298 if ( theCurrentUpdator->ExpandNode(aNodeToExpand,Recursive) )
00299 {
00300 theSuccess = Standard_True;
00301 }
00302 }
00303 return theSuccess;
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314 Standard_Boolean exotkTree_Tree::Collapse(const Handle_exotkTree_TreeNode& aNodeToCollapse)
00315 {
00316 Standard_Boolean theSuccess = Standard_False;
00317 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00318 for ( theIterator = myUpdators.begin() ; theIterator != myUpdators.end() ;++theIterator)
00319 {
00320 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00321 if ( theCurrentUpdator->CollapseNode(aNodeToCollapse) )
00322 {
00323 theSuccess = Standard_True;
00324 }
00325 }
00326 return theSuccess;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338 Standard_Boolean exotkTree_Tree::ToggleExpansion(const Handle_exotkTree_TreeNode& aNodeToToggle,const Standard_Boolean Recursive)
00339 {
00340 Standard_Boolean theSuccess = Standard_False;
00341 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00342 for ( theIterator = myUpdators.begin() ; theIterator != myUpdators.end() ;++theIterator)
00343 {
00344 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00345 if ( theCurrentUpdator->ToggleExpansion(aNodeToToggle,Recursive) )
00346 {
00347 theSuccess = Standard_True;
00348 }
00349 }
00350 return theSuccess;
00351 }
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 Standard_Boolean exotkTree_Tree::SetVisible(const Handle_exotkTree_TreeNode& aNode)
00363 {
00364 Standard_Boolean theSuccess = Standard_False;
00365 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00366 for ( theIterator = myUpdators.begin() ; theIterator != myUpdators.end() ;++theIterator)
00367 {
00368 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00369 if ( theCurrentUpdator->SetVisible(aNode) )
00370 {
00371 theSuccess = Standard_True;
00372 }
00373 }
00374 return theSuccess;
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386 Standard_Boolean exotkTree_Tree::UpdateNode(const Handle_exotkTree_TreeNode &aNodeToUpdate)
00387 {
00388 Standard_Boolean theSuccess = Standard_False;
00389 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00390 for ( theIterator = myUpdators.begin() ; theIterator != myUpdators.end() ;++theIterator)
00391 {
00392 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00393 if ( theCurrentUpdator->UpdateNode(aNodeToUpdate) )
00394 {
00395 theSuccess = Standard_True;
00396 }
00397 }
00398 return theSuccess;
00399 }
00400
00401 void exotkTree_Tree::NotifyInsertItem(const Handle_exotkTree_TreeNode& aParentNode,const Handle_exotkTree_TreeNode& anInsertedNode,const Handle_exotkTree_TreeNode& aPositionNode)
00402 {
00403 std::list<exotkTree_TreeUpdator*>::iterator theIterator;
00404 for ( theIterator = myUpdators.begin() ; theIterator != myUpdators.end() ;++theIterator)
00405 {
00406 exotkTree_TreeUpdator* theCurrentUpdator = *theIterator;
00407 theCurrentUpdator->NotifyInsertItem(aParentNode,anInsertedNode,aPositionNode);
00408 }
00409 }
00410