1 // Created on: 2000-03-01
2 // Created by: Denis PASCAL
3 // Copyright (c) 2000-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
22 #include <DDocStd.hxx>
25 #include <Draw_Interpretor.hxx>
26 #include <TDocStd_Document.hxx>
27 #include <TDF_Label.hxx>
28 #include <TCollection_AsciiString.hxx>
29 #include <TDF_Tool.hxx>
30 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
31 #include <TDF_AttributeDelta.hxx>
32 #include <TDF_Delta.hxx>
33 #include <TDF_AttributeDelta.hxx>
34 #include <TDF_DeltaOnAddition.hxx>
35 #include <TDF_DeltaOnForget.hxx>
36 #include <TDF_DeltaOnResume.hxx>
37 #include <TDF_DeltaOnRemoval.hxx>
38 #include <TDF_DeltaOnModification.hxx>
39 #include <TDF_AttributeDeltaList.hxx>
40 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
41 #include <Standard_DomainError.hxx>
45 //=======================================================================
46 //function : UpdateXLinks
47 //=======================================================================
49 static Standard_Integer DDocStd_UpdateXLinks(Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
52 Handle(TDocStd_Document) D;
53 if (!DDocStd::GetDocument(a[1],D)) return 1;
54 TCollection_AsciiString Entry(a[2]);
55 D->UpdateReferences(Entry);
56 // DDocStd::DisplayModified(a[1]);
60 //=======================================================================
61 //function : DDocStd_DumpCommand
62 //purpose : DumpDocument (DOC)
63 //=======================================================================
65 static Standard_Integer DDocStd_DumpCommand (Draw_Interpretor& di,
70 Handle(TDocStd_Document) D;
71 if (!DDocStd::GetDocument(arg[1],D)) return 1;
73 TDF_AttributeDeltaList added, forgoten, resumed, removed, modified;
74 Handle(TDF_AttributeDelta) AD;
75 if (D->GetUndos().IsEmpty()) {
76 di << "no UNDO available" << "\n";
79 Handle(TDF_Delta) DELTA = D->GetUndos().Last();
80 TDF_ListIteratorOfAttributeDeltaList it (DELTA->AttributeDeltas());
81 for (;it.More();it.Next()) {
83 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {added.Append(AD);}
84 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnForget))) {forgoten.Append(AD);}
85 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnResume))) {resumed.Append(AD);}
86 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnRemoval))) {removed.Append(AD);}
87 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnModification))) {modified.Append(AD);}
89 Standard_DomainError::Raise("DDocStd_DumpCommand : unknown delta");
93 TCollection_AsciiString string;
95 TCollection_AsciiString name; // (D->Name());
98 if (it.More()) di << "\n";
99 else di << " empty" << "\n";
100 for (;it.More();it.Next()) {
101 TDF_Tool::Entry (it.Value()->Label(),string);
102 di << "- " << string.ToCString() << " ";
103 di << it.Value()->Attribute()->DynamicType()->Name();
109 it.Initialize(forgoten);
110 if (it.More()) di << "\n";
111 else di << " empty" << "\n";
112 for (;it.More();it.Next()) {
113 TDF_Tool::Entry (it.Value()->Label(),string);
114 di << "- " << string.ToCString() << " ";
115 di << it.Value()->Attribute()->DynamicType()->Name();
121 it.Initialize(resumed);
122 if (it.More()) di << "\n";
123 else di << " empty" << "\n";
124 for (;it.More();it.Next()) {
125 TDF_Tool::Entry (it.Value()->Label(),string);
126 di << "- " << string.ToCString() << " ";
127 di << it.Value()->Attribute()->DynamicType()->Name();
133 it.Initialize(removed);
134 if (it.More()) di << "\n";
135 else di << " empty" << "\n";
136 for (;it.More();it.Next()) {
137 TDF_Tool::Entry (it.Value()->Label(),string);
138 di << "- " << string.ToCString() << " ";
139 di << it.Value()->Attribute()->DynamicType()->Name();
145 it.Initialize(modified);
146 if (it.More()) di << "\n";
147 else di << " empty" << "\n";
148 for (;it.More();it.Next()) {
149 TDF_Tool::Entry (it.Value()->Label(),string);
150 di << "- " << string.ToCString() << " ";
151 di << it.Value()->Attribute()->DynamicType()->Name();
156 di << "TDocStd_DumpCommand : Error" << "\n";
162 //=======================================================================
163 //function : ModificationCommands
165 //=======================================================================
167 void DDocStd::ToolsCommands(Draw_Interpretor& theCommands)
169 static Standard_Boolean done = Standard_False;
171 done = Standard_True;
173 const char* g = "DDocStd commands";
176 theCommands.Add("UpdateXLinks","UpdateXLinks DocName DocEntry",
177 __FILE__, DDocStd_UpdateXLinks, g);
179 theCommands.Add ("DumpCommand",
181 __FILE__, DDocStd_DumpCommand, g);