summaryrefslogtreecommitdiff
path: root/src/DDF/DDF.cxx
blob: f9124aaae7a4ac92f566df9dc7abe6fcae6aaf00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// File:	DDF.cxx
//      	-------
// Author:	DAUTRY Philippe
// Copyright:	Matra Datavision 1997

// Version:	0.0
// History:	Version	Date		Purpose
//		0.0	Feb 10 1997	Creation



#include <DDF.ixx>

#include <DDF_Data.hxx>

#include <Draw.hxx>

#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TCollection_AsciiString.hxx>

#include <TDF_ChildIterator.hxx>
#include <TDF_Label.hxx>
#include <TDF_Tool.hxx>

//=======================================================================
//function : AddLabel
//purpose  : 
//=======================================================================

Standard_Boolean DDF::AddLabel 

(
 const Handle(TDF_Data)& DF,
 const Standard_CString  Entry,
 TDF_Label&              Label
) 
{
  TDF_Tool::Label (DF,Entry,Label,Standard_True);
  return Standard_True;
}


//=======================================================================
//function : FindLabel
//purpose  : 
//=======================================================================

Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF,
				const Standard_CString  Entry,
				      TDF_Label&        Label,   
                                const Standard_Boolean  Complain)
{
  Label.Nullify();
  TDF_Tool::Label(DF,Entry,Label,Standard_False);
  if (Label.IsNull() && Complain) cout << "No label for entry " << Entry <<endl;
  return !Label.IsNull();
}


//=======================================================================
//function : GetDF
//purpose  : 
//=======================================================================

Standard_Boolean DDF::GetDF (Standard_CString&       Name,
			     Handle(TDF_Data)&       DF,
                             const Standard_Boolean  Complain)
{ 
  Handle(Standard_Transient) t = Draw::Get(Name, Complain);
  Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t);
  //Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain)); 
  if (!DDF.IsNull()) {
    DF = DDF->DataFramework(); 
    return Standard_True;
  } 
  if (Complain) cout <<"framework "<<Name<<" not found "<< endl; 
  return Standard_False;
}


//=======================================================================
//function : Find
//purpose  : Finds an attribute.
//=======================================================================

Standard_Boolean DDF::Find (const Handle(TDF_Data)& DF,
			    const Standard_CString  Entry,
			    const Standard_GUID&    ID,
			    Handle(TDF_Attribute)&  A,
			    const Standard_Boolean  Complain) 
{
  TDF_Label L;
  if (FindLabel(DF,Entry,L,Complain)) {
    if (L.FindAttribute(ID,A)) return Standard_True;
    if (Complain) cout <<"attribute not found for entry : "<< Entry <<endl; 
  }
  return Standard_False;   
}


//=======================================================================
//function : ReturnLabel
//purpose  : 
//=======================================================================
 
Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L)
{
  TCollection_AsciiString S;
  TDF_Tool::Entry(L,S);
  di << S.ToCString();
  return di;
}


//=======================================================================
//function : AllCommands
//purpose  : 
//=======================================================================

void DDF::AllCommands(Draw_Interpretor& theCommands) 
{
  static Standard_Boolean done = Standard_False;
  if (done) return;
  done = Standard_True;

  DDF::BasicCommands         (theCommands);
  DDF::DataCommands          (theCommands);
  DDF::TransactionCommands   (theCommands);
  DDF::BrowserCommands       (theCommands);
  // define the TCL variable DDF
  const char* com = "set DDF";
  theCommands.Eval(com);
}