// File: DDesign_TreeNodeBrowser.cxx // -------------------- // Author: DAUTRY Philippe // // Copyright: Matra Datavision 1997 // Version: 0.0 // History: Version Date Purpose // 0.0 Nov 27 1997 Creation #include #include #include #include #include #include #include #include #include //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Communication convention with tcl: // tcl waits for a string of characters, being an information list. // In this list, each item is separated from another by a separator: '\'. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #define TDF_BrowserSeparator1 '\\' #define TDF_BrowserSeparator2 ' ' #define TDF_BrowserSeparator3 '#' #define TDF_BrowserSeparator4 ',' //======================================================================= //function : DDesign_TreeNodeBrowser //purpose : //======================================================================= DDataStd_TreeBrowser::DDataStd_TreeBrowser(const TDF_Label& aLabel) : myRoot(aLabel) {} //======================================================================= //function : DrawOn //purpose : //======================================================================= void DDataStd_TreeBrowser::DrawOn(Draw_Display& dis) const { cout<<"DDataStd_TreeBrowser"<First(); while (!current.IsNull()) { if (split) list.AssignCat(TDF_BrowserSeparator1); OpenNode(current,list); split = Standard_True; current = current->Next(); } } return list; } //======================================================================= //function : OpenNode //purpose : // An item is composed as follows: // "LabelEntry "Name" DynamicType Executable|Forgotten Failed|Success First|Null [ LabelFather]" // First/Null : has/has not child //======================================================================= void DDataStd_TreeBrowser::OpenNode (const Handle(TDataStd_TreeNode)& aTreeNode, TCollection_AsciiString& aList) const { // Label entry. -0 TCollection_AsciiString tmp; TDF_Tool::Entry(aTreeNode->Label(),tmp); aList.AssignCat(tmp); // Name -1 aList.AssignCat(TDF_BrowserSeparator2); Handle(TDataStd_Name) name; aList.AssignCat("\""); if (aTreeNode->Label().FindAttribute(TDataStd_Name::GetID(),name)) { TCollection_AsciiString tmpStr(name->Get(),'?'); tmpStr.ChangeAll(' ','_'); aList.AssignCat(tmpStr); } aList.AssignCat("\""); // Dynamic type. -2 aList.AssignCat(TDF_BrowserSeparator2); TCollection_ExtendedString ext; if (TDF::ProgIDFromGUID(aTreeNode->ID(), ext)) aList.AssignCat(TCollection_AsciiString(ext,'?')); else aList.AssignCat(aTreeNode->DynamicType()->Name()); // Executable or Forgotten? -3 // aList.AssignCat(TDF_BrowserSeparator2); // if (aTreeNode->IsExecutable()) aList.AssignCat("Executable"); // else aList.AssignCat("Forgotten"); // Failed or Success? -4 // aList.AssignCat(TDF_BrowserSeparator2); // if (aTreeNode->Failed()) aList.AssignCat("Failed"); // else aList.AssignCat("Success"); //Children? -3 aList.AssignCat(TDF_BrowserSeparator2); if (aTreeNode->First().IsNull()) aList.AssignCat("Null"); else aList.AssignCat("First"); // Father? -4 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasFather()) aList.AssignCat("Null"); else { TDF_Tool::Entry(aTreeNode->Father()->Label(),tmp); aList.AssignCat(tmp); } // First? -5 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasFirst()) aList.AssignCat("Null"); else { TDF_Tool::Entry(aTreeNode->First()->Label(),tmp); aList.AssignCat(tmp); } // Next? -6 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasNext()) aList.AssignCat("Null"); else { TDF_Tool::Entry(aTreeNode->Next()->Label(),tmp); aList.AssignCat(tmp); } // Previous? -7 aList.AssignCat(TDF_BrowserSeparator2); if (!aTreeNode->HasPrevious()) aList.AssignCat("Null"); else { TDF_Tool::Entry(aTreeNode->Previous()->Label(),tmp); aList.AssignCat(tmp); } }