1 // Created on: 2000-03-01
2 // Created by: Denis PASCAL
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <DDocStd.hxx>
19 #include <Draw_Interpretor.hxx>
20 #include <TDocStd_Document.hxx>
21 #include <TDF_Label.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TDF_Tool.hxx>
24 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
25 #include <TDF_AttributeDelta.hxx>
26 #include <TDF_Delta.hxx>
27 #include <TDF_AttributeDelta.hxx>
28 #include <TDF_DeltaOnAddition.hxx>
29 #include <TDF_DeltaOnForget.hxx>
30 #include <TDF_DeltaOnResume.hxx>
31 #include <TDF_DeltaOnRemoval.hxx>
32 #include <TDF_DeltaOnModification.hxx>
33 #include <TDF_AttributeDeltaList.hxx>
34 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
35 #include <Standard_DomainError.hxx>
39 //=======================================================================
40 //function : UpdateXLinks
41 //=======================================================================
43 static Standard_Integer DDocStd_UpdateXLinks(Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
46 Handle(TDocStd_Document) D;
47 if (!DDocStd::GetDocument(a[1],D)) return 1;
48 TCollection_AsciiString Entry(a[2]);
49 D->UpdateReferences(Entry);
50 // DDocStd::DisplayModified(a[1]);
54 //=======================================================================
55 //function : DDocStd_DumpCommand
56 //purpose : DumpDocument (DOC)
57 //=======================================================================
59 static Standard_Integer DDocStd_DumpCommand (Draw_Interpretor& di,
64 Handle(TDocStd_Document) D;
65 if (!DDocStd::GetDocument(arg[1],D)) return 1;
67 TDF_AttributeDeltaList added, forgoten, resumed, removed, modified;
68 Handle(TDF_AttributeDelta) AD;
69 if (D->GetUndos().IsEmpty()) {
70 di << "no UNDO available" << "\n";
73 Handle(TDF_Delta) DELTA = D->GetUndos().Last();
74 TDF_ListIteratorOfAttributeDeltaList it (DELTA->AttributeDeltas());
75 for (;it.More();it.Next()) {
77 if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) {added.Append(AD);}
78 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnForget))) {forgoten.Append(AD);}
79 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnResume))) {resumed.Append(AD);}
80 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnRemoval))) {removed.Append(AD);}
81 else if (AD->IsKind(STANDARD_TYPE(TDF_DeltaOnModification))) {modified.Append(AD);}
83 Standard_DomainError::Raise("DDocStd_DumpCommand : unknown delta");
87 TCollection_AsciiString string;
89 TCollection_AsciiString name; // (D->Name());
92 if (it.More()) di << "\n";
93 else di << " empty" << "\n";
94 for (;it.More();it.Next()) {
95 TDF_Tool::Entry (it.Value()->Label(),string);
96 di << "- " << string.ToCString() << " ";
97 di << it.Value()->Attribute()->DynamicType()->Name();
103 it.Initialize(forgoten);
104 if (it.More()) di << "\n";
105 else di << " empty" << "\n";
106 for (;it.More();it.Next()) {
107 TDF_Tool::Entry (it.Value()->Label(),string);
108 di << "- " << string.ToCString() << " ";
109 di << it.Value()->Attribute()->DynamicType()->Name();
115 it.Initialize(resumed);
116 if (it.More()) di << "\n";
117 else di << " empty" << "\n";
118 for (;it.More();it.Next()) {
119 TDF_Tool::Entry (it.Value()->Label(),string);
120 di << "- " << string.ToCString() << " ";
121 di << it.Value()->Attribute()->DynamicType()->Name();
127 it.Initialize(removed);
128 if (it.More()) di << "\n";
129 else di << " empty" << "\n";
130 for (;it.More();it.Next()) {
131 TDF_Tool::Entry (it.Value()->Label(),string);
132 di << "- " << string.ToCString() << " ";
133 di << it.Value()->Attribute()->DynamicType()->Name();
139 it.Initialize(modified);
140 if (it.More()) di << "\n";
141 else di << " empty" << "\n";
142 for (;it.More();it.Next()) {
143 TDF_Tool::Entry (it.Value()->Label(),string);
144 di << "- " << string.ToCString() << " ";
145 di << it.Value()->Attribute()->DynamicType()->Name();
150 di << "TDocStd_DumpCommand : Error" << "\n";
156 //=======================================================================
157 //function : ModificationCommands
159 //=======================================================================
161 void DDocStd::ToolsCommands(Draw_Interpretor& theCommands)
163 static Standard_Boolean done = Standard_False;
165 done = Standard_True;
167 const char* g = "DDocStd commands";
170 theCommands.Add("UpdateXLinks","UpdateXLinks DocName DocEntry",
171 __FILE__, DDocStd_UpdateXLinks, g);
173 theCommands.Add ("DumpCommand",
175 __FILE__, DDocStd_DumpCommand, g);