0024023: Revamp the OCCT Handle -- ambiguity
[occt.git] / src / DDF / DDF.cxx
CommitLineData
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
18// Version: 0.0
b311480e 19//Version Date Purpose
7fd59977 20// 0.0 Feb 10 1997 Creation
21
22
23
24#include <DDF.ixx>
25
26#include <DDF_Data.hxx>
27
28#include <Draw.hxx>
29
30#include <TColStd_HArray1OfInteger.hxx>
31#include <TColStd_ListIteratorOfListOfInteger.hxx>
32#include <TColStd_ListOfInteger.hxx>
33#include <TCollection_AsciiString.hxx>
34
35#include <TDF_ChildIterator.hxx>
36#include <TDF_Label.hxx>
37#include <TDF_Tool.hxx>
38
39//=======================================================================
40//function : AddLabel
41//purpose :
42//=======================================================================
43
44Standard_Boolean DDF::AddLabel
45
46(
47 const Handle(TDF_Data)& DF,
48 const Standard_CString Entry,
49 TDF_Label& Label
50)
51{
52 TDF_Tool::Label (DF,Entry,Label,Standard_True);
53 return Standard_True;
54}
55
56
57//=======================================================================
58//function : FindLabel
59//purpose :
60//=======================================================================
61
62Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF,
63 const Standard_CString Entry,
64 TDF_Label& Label,
65 const Standard_Boolean Complain)
66{
67 Label.Nullify();
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();
71}
72
73
74//=======================================================================
75//function : GetDF
76//purpose :
77//=======================================================================
78
79Standard_Boolean DDF::GetDF (Standard_CString& Name,
80 Handle(TDF_Data)& DF,
81 const Standard_Boolean Complain)
82{
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));
86 if (!DDF.IsNull()) {
87 DF = DDF->DataFramework();
88 return Standard_True;
89 }
90 if (Complain) cout <<"framework "<<Name<<" not found "<< endl;
91 return Standard_False;
92}
93
94
95//=======================================================================
96//function : Find
97//purpose : Finds an attribute.
98//=======================================================================
99
100Standard_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)
105{
106 TDF_Label L;
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;
110 }
111 return Standard_False;
112}
113
114
115//=======================================================================
116//function : ReturnLabel
117//purpose :
118//=======================================================================
119
120Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L)
121{
122 TCollection_AsciiString S;
123 TDF_Tool::Entry(L,S);
124 di << S.ToCString();
125 return di;
126}
127
128
129//=======================================================================
130//function : AllCommands
131//purpose :
132//=======================================================================
133
134void DDF::AllCommands(Draw_Interpretor& theCommands)
135{
136 static Standard_Boolean done = Standard_False;
137 if (done) return;
138 done = Standard_True;
139
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);
147}
148
149
150