1 // Created on: 1999-07-15
2 // Created by: Denis PASCAL
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <DDataStd.hxx>
23 #include <DDataStd_DrawPresentation.hxx>
25 #include <Draw_Interpretor.hxx>
26 #include <Draw_Appli.hxx>
27 #include <TDF_Data.hxx>
28 #include <TDF_Tool.hxx>
29 #include <TDF_ChildIterator.hxx>
30 #include <TDF_Label.hxx>
31 #include <Standard_GUID.hxx>
32 #include <TDataStd_Directory.hxx>
33 #include <TDataXtd_Shape.hxx>
38 #include <TDataStd_NoteBook.hxx>
39 #include <TDataXtd_Shape.hxx>
42 #include <TopoDS_Shape.hxx>
46 //=======================================================================
47 //function : NewDirectory (DF, entry )
48 //=======================================================================
49 static Standard_Integer DDataStd_NewDirectory (Draw_Interpretor& di,
54 di << "Too few arguments" << "\n";
58 if (!DDF::GetDF(arg[1],DF)) return 1;
60 DDF::AddLabel(DF, arg[2], label);
61 TDataStd_Directory::New(label );
66 //=======================================================================
67 //function : AddDirectory (DF, entry )
68 //=======================================================================
69 static Standard_Integer DDataStd_AddDirectory (Draw_Interpretor& di,
74 di << "Too few arguments" << "\n";
78 if (!DDF::GetDF(arg[1],DF)) return 1;
80 if( !DDF::FindLabel(DF, arg[2], label) ) {
81 di << "No label for entry" << "\n";
84 Handle(TDataStd_Directory) A;
85 if (TDataStd_Directory::Find(label, A)) {
86 Handle(TDataStd_Directory) Dir = TDataStd_Directory::AddDirectory (A);
87 TCollection_AsciiString entry;
88 TDF_Tool::Entry(Dir->Label(), entry);
89 di << entry.ToCString()<<" "; //return a label to draw
92 di << "No Object Attribute on label" << "\n";
96 //=======================================================================
97 //function : MakeObjectLabel (DF, entry )
98 //=======================================================================
99 static Standard_Integer DDataStd_MakeObjectLabel (Draw_Interpretor& di,
104 di << "Too few arguments" << "\n";
108 if (!DDF::GetDF(arg[1],DF)) return 1;
110 if( !DDF::FindLabel(DF, arg[2], label) ) {
111 di << "No label for entry" << "\n";
114 Handle(TDataStd_Directory) A;
115 if(TDataStd_Directory::Find(label,A)) {
116 TCollection_AsciiString entry;
117 TDF_Tool::Entry(TDataStd_Directory::MakeObjectLabel(A), entry);
118 di << entry.ToCString()<<" "; //return a label to draw
121 di << "No Object Attribute on label" << "\n";
127 //=======================================================================
128 //function : DDataStd_NewNoteBook
129 //purpose : NewNoteBook (DF, entry)
130 //=======================================================================
132 static Standard_Integer DDataStd_NewNoteBook (Draw_Interpretor& di,
138 if (!DDF::GetDF(arg[1],DF)) return 1;
140 DDF::AddLabel(DF, arg[2], L);
141 TDataStd_NoteBook::New(L);
144 di << "DDataStd_NewNoteBook : Error" << "\n";
148 //=======================================================================
149 //function : NewShape (DF, entry, [in_shape] )
150 //=======================================================================
151 static Standard_Integer DDataStd_NewShape (Draw_Interpretor& di,
155 //di << "nb = " <<nb << "\n";
157 di << "Too few arguments" << "\n";
161 if (!DDF::GetDF(arg[1],DF)) return 1;
163 DDF::AddLabel(DF, arg[2], label);
165 TopoDS_Shape shape = DBRep::Get( arg[3] );
166 if( shape.IsNull() ) {
167 di << "Shape argument is invalid" << "\n";
170 TDataXtd_Shape::Set(label, shape );
172 else TDataXtd_Shape::New(label);
177 //=======================================================================
178 //function : GetShape2 (DF, entry, out_shape )
179 //=======================================================================
180 static Standard_Integer DDataStd_GetShape2 (Draw_Interpretor& di,
185 di << "Too few arguments" << "\n";
189 if (!DDF::GetDF(arg[1],DF)) return 1;
191 if( !DDF::FindLabel(DF, arg[2], label) ) {
192 di << "No label for entry" << "\n";
195 DBRep::Set(arg[3], TDataXtd_Shape::Get(label));
202 //=======================================================================
203 //function : ObjectComands
205 //=======================================================================
207 void DDataStd::ObjectCommands (Draw_Interpretor& theCommands)
210 static Standard_Boolean done = Standard_False;
212 done = Standard_True;
213 const char* g = "DData : Standard Attribute Commands";
215 theCommands.Add ("NewNoteBook",
216 "NewNoteBook (DF, entry)",
217 __FILE__, DDataStd_NewNoteBook, g);
219 theCommands.Add ("NewShape",
220 "NewShape (DF, entry, [in_shape] )",
221 __FILE__, DDataStd_NewShape, g);
223 theCommands.Add ("GetShape2",
224 "GetShape2 (DF, entry, out_shape )",
225 __FILE__, DDataStd_GetShape2, g);
227 theCommands.Add ("NewDirectory",
228 "NewDirectory (DF, entry)",
229 __FILE__, DDataStd_NewDirectory, g);
231 theCommands.Add ("AddDirectory",
232 "AddDirectory (DF, entry)",
233 __FILE__, DDataStd_AddDirectory, g);
235 theCommands.Add ("MakeObjectLabel",
236 "MakeObjectLabel (DF, entry)",
237 __FILE__, DDataStd_MakeObjectLabel, g);