7fd59977 |
1 | // File: DDataStd_NamedShapeCommands.cxx |
2 | // Created: Wed Jul 30 16:47:00 1997 |
3 | // Author: Denis PASCAL |
4 | // <dp@dingox.paris1.matra-dtv.fr> |
5 | |
6 | #include <DDataStd.hxx> |
7 | #include <DDataStd_DrawPresentation.hxx> |
8 | #include <DDF.hxx> |
9 | #include <Draw_Interpretor.hxx> |
10 | #include <Draw_Appli.hxx> |
11 | |
12 | #include <TDF_Data.hxx> |
13 | #include <TDF_Label.hxx> |
14 | |
15 | #include <DBRep.hxx> |
16 | #include <TopAbs.hxx> |
17 | #include <TopoDS.hxx> |
18 | |
19 | |
20 | // LES ATTRIBUTES |
21 | |
22 | #include <TNaming_NamedShape.hxx> |
23 | #include <TNaming_Builder.hxx> |
24 | #include <TNaming_Tool.hxx> |
25 | |
26 | |
27 | //======================================================================= |
28 | //function : DDataStd_SetShape |
29 | //purpose : SetShape (DF, entry, drawshape) |
30 | //======================================================================= |
31 | |
32 | static Standard_Integer DDataStd_SetShape (Draw_Interpretor& di, |
33 | Standard_Integer nb, |
34 | const char** arg) |
35 | { |
36 | if (nb == 4) { |
37 | Handle(TDF_Data) DF; |
38 | if (!DDF::GetDF(arg[1],DF)) return 1; |
39 | TopoDS_Shape s = DBRep::Get(arg[3]); |
40 | if (s.IsNull()) { di <<"shape not found"<< "\n"; return 1;} |
41 | TDF_Label L; |
42 | DDF::AddLabel(DF, arg[2], L); |
43 | TNaming_Builder SI (L); |
44 | SI.Generated(s); |
45 | return 0; |
46 | } |
47 | di << "DDataStd_SetShape : Error" << "\n"; |
48 | return 1; |
49 | } |
50 | |
51 | |
52 | //======================================================================= |
53 | //function : NamedShapeCommands |
54 | //purpose : |
55 | //======================================================================= |
56 | |
57 | void DDataStd::NamedShapeCommands (Draw_Interpretor& theCommands) |
58 | { |
59 | |
60 | static Standard_Boolean done = Standard_False; |
61 | if (done) return; |
62 | done = Standard_True; |
63 | const char* g = "DData : Standard Attribute Commands"; |
64 | |
65 | |
66 | theCommands.Add ("SetShape", |
67 | "SetShape (DF, entry, drawname)", |
68 | __FILE__, DDataStd_SetShape, g); |
69 | |
70 | } |