Integration of OCCT 6.5.0 from SVN
[occt.git] / src / DDF / DDF.cxx
1 // File:        DDF.cxx
2 //              -------
3 // Author:      DAUTRY Philippe
4 // Copyright:   Matra Datavision 1997
5
6 // Version:     0.0
7 // History:     Version Date            Purpose
8 //              0.0     Feb 10 1997     Creation
9
10
11
12 #include <DDF.ixx>
13
14 #include <DDF_Data.hxx>
15
16 #include <Draw.hxx>
17
18 #include <TColStd_HArray1OfInteger.hxx>
19 #include <TColStd_ListIteratorOfListOfInteger.hxx>
20 #include <TColStd_ListOfInteger.hxx>
21 #include <TCollection_AsciiString.hxx>
22
23 #include <TDF_ChildIterator.hxx>
24 #include <TDF_Label.hxx>
25 #include <TDF_Tool.hxx>
26
27 //=======================================================================
28 //function : AddLabel
29 //purpose  : 
30 //=======================================================================
31
32 Standard_Boolean DDF::AddLabel 
33
34 (
35  const Handle(TDF_Data)& DF,
36  const Standard_CString  Entry,
37  TDF_Label&              Label
38
39 {
40   TDF_Tool::Label (DF,Entry,Label,Standard_True);
41   return Standard_True;
42 }
43
44
45 //=======================================================================
46 //function : FindLabel
47 //purpose  : 
48 //=======================================================================
49
50 Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF,
51                                 const Standard_CString  Entry,
52                                       TDF_Label&        Label,   
53                                 const Standard_Boolean  Complain)
54 {
55   Label.Nullify();
56   TDF_Tool::Label(DF,Entry,Label,Standard_False);
57   if (Label.IsNull() && Complain) cout << "No label for entry " << Entry <<endl;
58   return !Label.IsNull();
59 }
60
61
62 //=======================================================================
63 //function : GetDF
64 //purpose  : 
65 //=======================================================================
66
67 Standard_Boolean DDF::GetDF (Standard_CString&       Name,
68                              Handle(TDF_Data)&       DF,
69                              const Standard_Boolean  Complain)
70
71   Handle(Standard_Transient) t = Draw::Get(Name, Complain);
72   Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t);
73   //Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain)); 
74   if (!DDF.IsNull()) {
75     DF = DDF->DataFramework(); 
76     return Standard_True;
77   } 
78   if (Complain) cout <<"framework "<<Name<<" not found "<< endl; 
79   return Standard_False;
80 }
81
82
83 //=======================================================================
84 //function : Find
85 //purpose  : Finds an attribute.
86 //=======================================================================
87
88 Standard_Boolean DDF::Find (const Handle(TDF_Data)& DF,
89                             const Standard_CString  Entry,
90                             const Standard_GUID&    ID,
91                             Handle(TDF_Attribute)&  A,
92                             const Standard_Boolean  Complain) 
93 {
94   TDF_Label L;
95   if (FindLabel(DF,Entry,L,Complain)) {
96     if (L.FindAttribute(ID,A)) return Standard_True;
97     if (Complain) cout <<"attribute not found for entry : "<< Entry <<endl; 
98   }
99   return Standard_False;   
100 }
101
102
103 //=======================================================================
104 //function : ReturnLabel
105 //purpose  : 
106 //=======================================================================
107  
108 Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L)
109 {
110   TCollection_AsciiString S;
111   TDF_Tool::Entry(L,S);
112   di << S.ToCString();
113   return di;
114 }
115
116
117 //=======================================================================
118 //function : AllCommands
119 //purpose  : 
120 //=======================================================================
121
122 void DDF::AllCommands(Draw_Interpretor& theCommands) 
123 {
124   static Standard_Boolean done = Standard_False;
125   if (done) return;
126   done = Standard_True;
127
128   DDF::BasicCommands         (theCommands);
129   DDF::DataCommands          (theCommands);
130   DDF::TransactionCommands   (theCommands);
131   DDF::BrowserCommands       (theCommands);
132   // define the TCL variable DDF
133   const char* com = "set DDF";
134   theCommands.Eval(com);
135 }
136
137
138