1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 //Version Date Purpose
19 // 0.0 Feb 10 1997 Creation
22 #include <DDF_Data.hxx>
24 #include <Standard_GUID.hxx>
25 #include <TCollection_AsciiString.hxx>
26 #include <TColStd_HArray1OfInteger.hxx>
27 #include <TColStd_ListIteratorOfListOfInteger.hxx>
28 #include <TColStd_ListOfInteger.hxx>
29 #include <TDF_Attribute.hxx>
30 #include <TDF_ChildIterator.hxx>
31 #include <TDF_Data.hxx>
32 #include <TDF_Label.hxx>
33 #include <TDF_Tool.hxx>
35 //=======================================================================
38 //=======================================================================
39 Standard_Boolean DDF::AddLabel
42 const Handle(TDF_Data)& DF,
43 const Standard_CString Entry,
47 TDF_Tool::Label (DF,Entry,Label,Standard_True);
52 //=======================================================================
53 //function : FindLabel
55 //=======================================================================
57 Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF,
58 const Standard_CString Entry,
60 const Standard_Boolean Complain)
63 TDF_Tool::Label(DF,Entry,Label,Standard_False);
64 if (Label.IsNull() && Complain) std::cout << "No label for entry " << Entry <<std::endl;
65 return !Label.IsNull();
69 //=======================================================================
72 //=======================================================================
74 Standard_Boolean DDF::GetDF (Standard_CString& Name,
76 const Standard_Boolean Complain)
78 Handle(Standard_Transient) t = Draw::Get (Name);
79 Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t);
80 //Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain));
82 DF = DDF->DataFramework();
85 if (Complain) std::cout <<"framework "<<Name<<" not found "<< std::endl;
86 return Standard_False;
90 //=======================================================================
92 //purpose : Finds an attribute.
93 //=======================================================================
95 Standard_Boolean DDF::Find (const Handle(TDF_Data)& DF,
96 const Standard_CString Entry,
97 const Standard_GUID& ID,
98 Handle(TDF_Attribute)& A,
99 const Standard_Boolean Complain)
102 if (FindLabel(DF,Entry,L,Complain)) {
103 if (L.FindAttribute(ID,A)) return Standard_True;
104 if (Complain) std::cout <<"attribute not found for entry : "<< Entry <<std::endl;
106 return Standard_False;
110 //=======================================================================
111 //function : ReturnLabel
113 //=======================================================================
115 Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L)
117 TCollection_AsciiString S;
118 TDF_Tool::Entry(L,S);
124 //=======================================================================
125 //function : AllCommands
127 //=======================================================================
129 void DDF::AllCommands(Draw_Interpretor& theCommands)
131 static Standard_Boolean done = Standard_False;
133 done = Standard_True;
135 DDF::BasicCommands (theCommands);
136 DDF::DataCommands (theCommands);
137 DDF::TransactionCommands (theCommands);
138 DDF::BrowserCommands (theCommands);
139 // define the TCL variable DDF
140 const char* com = "set DDF";
141 theCommands.Eval(com);