1 // Created on: 1999-07-15
2 // Created by: Denis PASCAL
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <DDataStd.hxx>
18 #include <DDataStd_DrawPresentation.hxx>
20 #include <Draw_Interpretor.hxx>
21 #include <Draw_Appli.hxx>
22 #include <TDF_Data.hxx>
23 #include <TDF_Tool.hxx>
24 #include <TDF_ChildIterator.hxx>
25 #include <TDF_Label.hxx>
26 #include <Standard_GUID.hxx>
27 #include <TDataStd_Directory.hxx>
28 #include <TDataXtd_Shape.hxx>
33 #include <TDataStd_NoteBook.hxx>
34 #include <TDataXtd_Shape.hxx>
37 #include <TopoDS_Shape.hxx>
41 //=======================================================================
42 //function : NewDirectory (DF, entry )
43 //=======================================================================
44 static Standard_Integer DDataStd_NewDirectory (Draw_Interpretor& di,
49 di << "Too few arguments" << "\n";
53 if (!DDF::GetDF(arg[1],DF)) return 1;
55 DDF::AddLabel(DF, arg[2], label);
56 TDataStd_Directory::New(label );
61 //=======================================================================
62 //function : AddDirectory (DF, entry )
63 //=======================================================================
64 static Standard_Integer DDataStd_AddDirectory (Draw_Interpretor& di,
69 di << "Too few arguments" << "\n";
73 if (!DDF::GetDF(arg[1],DF)) return 1;
75 if( !DDF::FindLabel(DF, arg[2], label) ) {
76 di << "No label for entry" << "\n";
79 Handle(TDataStd_Directory) A;
80 if (TDataStd_Directory::Find(label, A)) {
81 Handle(TDataStd_Directory) Dir = TDataStd_Directory::AddDirectory (A);
82 TCollection_AsciiString entry;
83 TDF_Tool::Entry(Dir->Label(), entry);
84 di << entry.ToCString()<<" "; //return a label to draw
87 di << "No Object Attribute on label" << "\n";
91 //=======================================================================
92 //function : MakeObjectLabel (DF, entry )
93 //=======================================================================
94 static Standard_Integer DDataStd_MakeObjectLabel (Draw_Interpretor& di,
99 di << "Too few arguments" << "\n";
103 if (!DDF::GetDF(arg[1],DF)) return 1;
105 if( !DDF::FindLabel(DF, arg[2], label) ) {
106 di << "No label for entry" << "\n";
109 Handle(TDataStd_Directory) A;
110 if(TDataStd_Directory::Find(label,A)) {
111 TCollection_AsciiString entry;
112 TDF_Tool::Entry(TDataStd_Directory::MakeObjectLabel(A), entry);
113 di << entry.ToCString()<<" "; //return a label to draw
116 di << "No Object Attribute on label" << "\n";
122 //=======================================================================
123 //function : DDataStd_NewNoteBook
124 //purpose : NewNoteBook (DF, entry)
125 //=======================================================================
127 static Standard_Integer DDataStd_NewNoteBook (Draw_Interpretor& di,
133 if (!DDF::GetDF(arg[1],DF)) return 1;
135 DDF::AddLabel(DF, arg[2], L);
136 TDataStd_NoteBook::New(L);
139 di << "DDataStd_NewNoteBook : Error\n";
143 //=======================================================================
144 //function : NewShape (DF, entry, [in_shape] )
145 //=======================================================================
146 static Standard_Integer DDataStd_NewShape (Draw_Interpretor& di,
150 //di << "nb = " <<nb << "\n";
152 di << "Too few arguments" << "\n";
156 if (!DDF::GetDF(arg[1],DF)) return 1;
158 DDF::AddLabel(DF, arg[2], label);
160 TopoDS_Shape shape = DBRep::Get( arg[3] );
161 if( shape.IsNull() ) {
162 di << "Shape argument is invalid" << "\n";
165 TDataXtd_Shape::Set(label, shape );
167 else TDataXtd_Shape::New(label);
172 //=======================================================================
173 //function : GetShape2 (DF, entry, out_shape )
174 //=======================================================================
175 static Standard_Integer DDataStd_GetShape2 (Draw_Interpretor& di,
180 di << "Too few arguments" << "\n";
184 if (!DDF::GetDF(arg[1],DF)) return 1;
186 if( !DDF::FindLabel(DF, arg[2], label) ) {
187 di << "No label for entry" << "\n";
190 DBRep::Set(arg[3], TDataXtd_Shape::Get(label));
197 //=======================================================================
198 //function : ObjectComands
200 //=======================================================================
202 void DDataStd::ObjectCommands (Draw_Interpretor& theCommands)
205 static Standard_Boolean done = Standard_False;
207 done = Standard_True;
208 const char* g = "DData : Standard Attribute Commands";
210 theCommands.Add ("NewNoteBook",
211 "NewNoteBook (DF, entry)",
212 __FILE__, DDataStd_NewNoteBook, g);
214 theCommands.Add ("NewShape",
215 "NewShape (DF, entry, [in_shape] )",
216 __FILE__, DDataStd_NewShape, g);
218 theCommands.Add ("GetShape2",
219 "GetShape2 (DF, entry, out_shape )",
220 __FILE__, DDataStd_GetShape2, g);
222 theCommands.Add ("NewDirectory",
223 "NewDirectory (DF, entry)",
224 __FILE__, DDataStd_NewDirectory, g);
226 theCommands.Add ("AddDirectory",
227 "AddDirectory (DF, entry)",
228 __FILE__, DDataStd_AddDirectory, g);
230 theCommands.Add ("MakeObjectLabel",
231 "MakeObjectLabel (DF, entry)",
232 __FILE__, DDataStd_MakeObjectLabel, g);