| 1 | // Created by: DAUTRY Philippe |
| 2 | // Copyright (c) 1997-1999 Matra Datavision |
| 3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 4 | // |
| 5 | // This file is part of Open CASCADE Technology software library. |
| 6 | // |
| 7 | // This library is free software; you can redistribute it and/or modify it under |
| 8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 9 | // by the Free Software Foundation, with special exception defined in the file |
| 10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 11 | // distribution for complete text of the license and disclaimer of any warranty. |
| 12 | // |
| 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 14 | // commercial license or contractual agreement. |
| 15 | |
| 16 | // ------- |
| 17 | // Version: 0.0 |
| 18 | //Version Date Purpose |
| 19 | // 0.0 Feb 10 1997 Creation |
| 20 | |
| 21 | #include <DDF.hxx> |
| 22 | #include <DDF_Data.hxx> |
| 23 | #include <Draw.hxx> |
| 24 | #include <Standard_GUID.hxx> |
| 25 | #include <TCollection_AsciiString.hxx> |
| 26 | #include <TColStd_HArray1OfInteger.hxx> |
| 27 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
| 28 | #include <TColStd_ListOfInteger.hxx> |
| 29 | #include <TDF_Attribute.hxx> |
| 30 | #include <TDF_ChildIterator.hxx> |
| 31 | #include <TDF_Data.hxx> |
| 32 | #include <TDF_Label.hxx> |
| 33 | #include <TDF_Tool.hxx> |
| 34 | |
| 35 | //======================================================================= |
| 36 | //function : AddLabel |
| 37 | //purpose : |
| 38 | //======================================================================= |
| 39 | Standard_Boolean DDF::AddLabel |
| 40 | |
| 41 | ( |
| 42 | const Handle(TDF_Data)& DF, |
| 43 | const Standard_CString Entry, |
| 44 | TDF_Label& Label |
| 45 | ) |
| 46 | { |
| 47 | TDF_Tool::Label (DF,Entry,Label,Standard_True); |
| 48 | return Standard_True; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | //======================================================================= |
| 53 | //function : FindLabel |
| 54 | //purpose : |
| 55 | //======================================================================= |
| 56 | |
| 57 | Standard_Boolean DDF::FindLabel (const Handle(TDF_Data)& DF, |
| 58 | const Standard_CString Entry, |
| 59 | TDF_Label& Label, |
| 60 | const Standard_Boolean Complain) |
| 61 | { |
| 62 | Label.Nullify(); |
| 63 | TDF_Tool::Label(DF,Entry,Label,Standard_False); |
| 64 | if (Label.IsNull() && Complain) cout << "No label for entry " << Entry <<endl; |
| 65 | return !Label.IsNull(); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | //======================================================================= |
| 70 | //function : GetDF |
| 71 | //purpose : |
| 72 | //======================================================================= |
| 73 | |
| 74 | Standard_Boolean DDF::GetDF (Standard_CString& Name, |
| 75 | Handle(TDF_Data)& DF, |
| 76 | const Standard_Boolean Complain) |
| 77 | { |
| 78 | Handle(Standard_Transient) t = Draw::Get(Name, Complain); |
| 79 | Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (t); |
| 80 | //Handle(DDF_Data) DDF = Handle(DDF_Data)::DownCast (Draw::Get(Name, Complain)); |
| 81 | if (!DDF.IsNull()) { |
| 82 | DF = DDF->DataFramework(); |
| 83 | return Standard_True; |
| 84 | } |
| 85 | if (Complain) cout <<"framework "<<Name<<" not found "<< endl; |
| 86 | return Standard_False; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | //======================================================================= |
| 91 | //function : Find |
| 92 | //purpose : Finds an attribute. |
| 93 | //======================================================================= |
| 94 | |
| 95 | Standard_Boolean DDF::Find (const Handle(TDF_Data)& DF, |
| 96 | const Standard_CString Entry, |
| 97 | const Standard_GUID& ID, |
| 98 | Handle(TDF_Attribute)& A, |
| 99 | const Standard_Boolean Complain) |
| 100 | { |
| 101 | TDF_Label L; |
| 102 | if (FindLabel(DF,Entry,L,Complain)) { |
| 103 | if (L.FindAttribute(ID,A)) return Standard_True; |
| 104 | if (Complain) cout <<"attribute not found for entry : "<< Entry <<endl; |
| 105 | } |
| 106 | return Standard_False; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | //======================================================================= |
| 111 | //function : ReturnLabel |
| 112 | //purpose : |
| 113 | //======================================================================= |
| 114 | |
| 115 | Draw_Interpretor& DDF::ReturnLabel(Draw_Interpretor& di, const TDF_Label& L) |
| 116 | { |
| 117 | TCollection_AsciiString S; |
| 118 | TDF_Tool::Entry(L,S); |
| 119 | di << S.ToCString(); |
| 120 | return di; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | //======================================================================= |
| 125 | //function : AllCommands |
| 126 | //purpose : |
| 127 | //======================================================================= |
| 128 | |
| 129 | void DDF::AllCommands(Draw_Interpretor& theCommands) |
| 130 | { |
| 131 | static Standard_Boolean done = Standard_False; |
| 132 | if (done) return; |
| 133 | done = Standard_True; |
| 134 | |
| 135 | DDF::BasicCommands (theCommands); |
| 136 | DDF::DataCommands (theCommands); |
| 137 | DDF::TransactionCommands (theCommands); |
| 138 | DDF::BrowserCommands (theCommands); |
| 139 | // define the TCL variable DDF |
| 140 | const char* com = "set DDF"; |
| 141 | theCommands.Eval(com); |
| 142 | } |
| 143 | |
| 144 | |
| 145 | |