b311480e |
1 | // Created by: DAUTRY Philippe |
2 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
7fd59977 |
16 | // ------- |
7fd59977 |
17 | // Version: 0.0 |
b311480e |
18 | //Version Date Purpose |
7fd59977 |
19 | // 0.0 Feb 10 1997 Creation |
20 | |
42cf5bc1 |
21 | #include <DDF.hxx> |
7fd59977 |
22 | #include <DDF_Data.hxx> |
7fd59977 |
23 | #include <Draw.hxx> |
42cf5bc1 |
24 | #include <Standard_GUID.hxx> |
25 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
26 | #include <TColStd_HArray1OfInteger.hxx> |
27 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
28 | #include <TColStd_ListOfInteger.hxx> |
42cf5bc1 |
29 | #include <TDF_Attribute.hxx> |
7fd59977 |
30 | #include <TDF_ChildIterator.hxx> |
42cf5bc1 |
31 | #include <TDF_Data.hxx> |
7fd59977 |
32 | #include <TDF_Label.hxx> |
33 | #include <TDF_Tool.hxx> |
34 | |
35 | //======================================================================= |
36 | //function : AddLabel |
37 | //purpose : |
38 | //======================================================================= |
7fd59977 |
39 | Standard_Boolean DDF::AddLabel |
40 | |
41 | ( |
42 | const Handle(TDF_Data)& DF, |
43 | const Standard_CString Entry, |
44 | TDF_Label& Label |
45 | ) |
46 | { |
47 | TDF_Tool::Label (DF,Entry,Label,Standard_True); |
48 | return Standard_True; |
49 | } |
50 | |
51 | |
52 | //======================================================================= |
53 | //function : FindLabel |
54 | //purpose : |
55 | //======================================================================= |
56 | |
57 | Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF, |
58 | const Standard_CString Entry, |
59 | TDF_Label& Label, |
60 | const Standard_Boolean Complain) |
61 | { |
62 | Label.Nullify(); |
63 | TDF_Tool::Label(DF,Entry,Label,Standard_False); |
04232180 |
64 | if (Label.IsNull() && Complain) std::cout << "No label for entry " << Entry <<std::endl; |
7fd59977 |
65 | return !Label.IsNull(); |
66 | } |
67 | |
68 | |
69 | //======================================================================= |
70 | //function : GetDF |
71 | //purpose : |
72 | //======================================================================= |
73 | |
74 | Standard_Boolean DDF::GetDF (Standard_CString& Name, |
75 | Handle(TDF_Data)& DF, |
76 | const Standard_Boolean Complain) |
77 | { |
1c8fc6be |
78 | Handle(Standard_Transient) t = Draw::Get (Name); |
7fd59977 |
79 | Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t); |
80 | //Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain)); |
81 | if (!DDF.IsNull()) { |
82 | DF = DDF->DataFramework(); |
83 | return Standard_True; |
84 | } |
04232180 |
85 | if (Complain) std::cout <<"framework "<<Name<<" not found "<< std::endl; |
7fd59977 |
86 | return Standard_False; |
87 | } |
88 | |
89 | |
90 | //======================================================================= |
91 | //function : Find |
92 | //purpose : Finds an attribute. |
93 | //======================================================================= |
94 | |
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) |
100 | { |
101 | TDF_Label L; |
102 | if (FindLabel(DF,Entry,L,Complain)) { |
103 | if (L.FindAttribute(ID,A)) return Standard_True; |
04232180 |
104 | if (Complain) std::cout <<"attribute not found for entry : "<< Entry <<std::endl; |
7fd59977 |
105 | } |
106 | return Standard_False; |
107 | } |
108 | |
109 | |
110 | //======================================================================= |
111 | //function : ReturnLabel |
112 | //purpose : |
113 | //======================================================================= |
114 | |
115 | Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L) |
116 | { |
117 | TCollection_AsciiString S; |
118 | TDF_Tool::Entry(L,S); |
119 | di << S.ToCString(); |
120 | return di; |
121 | } |
122 | |
123 | |
124 | //======================================================================= |
125 | //function : AllCommands |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | void DDF::AllCommands(Draw_Interpretor& theCommands) |
130 | { |
131 | static Standard_Boolean done = Standard_False; |
132 | if (done) return; |
133 | done = Standard_True; |
134 | |
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); |
142 | } |
143 | |
144 | |
145 | |