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.
19 //Version Date Purpose
20 // 0.0 Feb 10 1997 Creation
26 #include <DDF_Data.hxx>
30 #include <TColStd_HArray1OfInteger.hxx>
31 #include <TColStd_ListIteratorOfListOfInteger.hxx>
32 #include <TColStd_ListOfInteger.hxx>
33 #include <TCollection_AsciiString.hxx>
35 #include <TDF_ChildIterator.hxx>
36 #include <TDF_Label.hxx>
37 #include <TDF_Tool.hxx>
39 //=======================================================================
42 //=======================================================================
44 Standard_Boolean DDF::AddLabel
47 const Handle(TDF_Data)& DF,
48 const Standard_CString Entry,
52 TDF_Tool::Label (DF,Entry,Label,Standard_True);
57 //=======================================================================
58 //function : FindLabel
60 //=======================================================================
62 Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF,
63 const Standard_CString Entry,
65 const Standard_Boolean Complain)
68 TDF_Tool::Label(DF,Entry,Label,Standard_False);
69 if (Label.IsNull() && Complain) cout << "No label for entry " << Entry <<endl;
70 return !Label.IsNull();
74 //=======================================================================
77 //=======================================================================
79 Standard_Boolean DDF::GetDF (Standard_CString& Name,
81 const Standard_Boolean Complain)
83 Handle(Standard_Transient) t = Draw::Get(Name, Complain);
84 Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t);
85 //Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain));
87 DF = DDF->DataFramework();
90 if (Complain) cout <<"framework "<<Name<<" not found "<< endl;
91 return Standard_False;
95 //=======================================================================
97 //purpose : Finds an attribute.
98 //=======================================================================
100 Standard_Boolean DDF::Find (const Handle(TDF_Data)& DF,
101 const Standard_CString Entry,
102 const Standard_GUID& ID,
103 Handle(TDF_Attribute)& A,
104 const Standard_Boolean Complain)
107 if (FindLabel(DF,Entry,L,Complain)) {
108 if (L.FindAttribute(ID,A)) return Standard_True;
109 if (Complain) cout <<"attribute not found for entry : "<< Entry <<endl;
111 return Standard_False;
115 //=======================================================================
116 //function : ReturnLabel
118 //=======================================================================
120 Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L)
122 TCollection_AsciiString S;
123 TDF_Tool::Entry(L,S);
129 //=======================================================================
130 //function : AllCommands
132 //=======================================================================
134 void DDF::AllCommands(Draw_Interpretor& theCommands)
136 static Standard_Boolean done = Standard_False;
138 done = Standard_True;
140 DDF::BasicCommands (theCommands);
141 DDF::DataCommands (theCommands);
142 DDF::TransactionCommands (theCommands);
143 DDF::BrowserCommands (theCommands);
144 // define the TCL variable DDF
145 const char* com = "set DDF";
146 theCommands.Eval(com);