0024234: occt master is not compiled by VC++ 2005 (vc8 32/64 bit TKBO)
[occt.git] / src / DDF / DDF.cxx
CommitLineData
b311480e 1// Created by: DAUTRY Philippe
2// Copyright (c) 1997-1999 Matra Datavision
3// Copyright (c) 1999-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20// -------
7fd59977 21
22// Version: 0.0
b311480e 23//Version Date Purpose
7fd59977 24// 0.0 Feb 10 1997 Creation
25
26
27
28#include <DDF.ixx>
29
30#include <DDF_Data.hxx>
31
32#include <Draw.hxx>
33
34#include <TColStd_HArray1OfInteger.hxx>
35#include <TColStd_ListIteratorOfListOfInteger.hxx>
36#include <TColStd_ListOfInteger.hxx>
37#include <TCollection_AsciiString.hxx>
38
39#include <TDF_ChildIterator.hxx>
40#include <TDF_Label.hxx>
41#include <TDF_Tool.hxx>
42
43//=======================================================================
44//function : AddLabel
45//purpose :
46//=======================================================================
47
48Standard_Boolean DDF::AddLabel
49
50(
51 const Handle(TDF_Data)& DF,
52 const Standard_CString Entry,
53 TDF_Label& Label
54)
55{
56 TDF_Tool::Label (DF,Entry,Label,Standard_True);
57 return Standard_True;
58}
59
60
61//=======================================================================
62//function : FindLabel
63//purpose :
64//=======================================================================
65
66Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF,
67 const Standard_CString Entry,
68 TDF_Label& Label,
69 const Standard_Boolean Complain)
70{
71 Label.Nullify();
72 TDF_Tool::Label(DF,Entry,Label,Standard_False);
73 if (Label.IsNull() && Complain) cout << "No label for entry " << Entry <<endl;
74 return !Label.IsNull();
75}
76
77
78//=======================================================================
79//function : GetDF
80//purpose :
81//=======================================================================
82
83Standard_Boolean DDF::GetDF (Standard_CString& Name,
84 Handle(TDF_Data)& DF,
85 const Standard_Boolean Complain)
86{
87 Handle(Standard_Transient) t = Draw::Get(Name, Complain);
88 Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t);
89 //Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain));
90 if (!DDF.IsNull()) {
91 DF = DDF->DataFramework();
92 return Standard_True;
93 }
94 if (Complain) cout <<"framework "<<Name<<" not found "<< endl;
95 return Standard_False;
96}
97
98
99//=======================================================================
100//function : Find
101//purpose : Finds an attribute.
102//=======================================================================
103
104Standard_Boolean DDF::Find (const Handle(TDF_Data)& DF,
105 const Standard_CString Entry,
106 const Standard_GUID& ID,
107 Handle(TDF_Attribute)& A,
108 const Standard_Boolean Complain)
109{
110 TDF_Label L;
111 if (FindLabel(DF,Entry,L,Complain)) {
112 if (L.FindAttribute(ID,A)) return Standard_True;
113 if (Complain) cout <<"attribute not found for entry : "<< Entry <<endl;
114 }
115 return Standard_False;
116}
117
118
119//=======================================================================
120//function : ReturnLabel
121//purpose :
122//=======================================================================
123
124Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L)
125{
126 TCollection_AsciiString S;
127 TDF_Tool::Entry(L,S);
128 di << S.ToCString();
129 return di;
130}
131
132
133//=======================================================================
134//function : AllCommands
135//purpose :
136//=======================================================================
137
138void DDF::AllCommands(Draw_Interpretor& theCommands)
139{
140 static Standard_Boolean done = Standard_False;
141 if (done) return;
142 done = Standard_True;
143
144 DDF::BasicCommands (theCommands);
145 DDF::DataCommands (theCommands);
146 DDF::TransactionCommands (theCommands);
147 DDF::BrowserCommands (theCommands);
148 // define the TCL variable DDF
149 const char* com = "set DDF";
150 theCommands.Eval(com);
151}
152
153
154