0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / DDocStd / DDocStd_ToolsCommands.cxx
CommitLineData
b311480e 1// Created on: 2000-03-01
2// Created by: Denis PASCAL
973c2be1 3// Copyright (c) 2000-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <DDocStd.hxx>
17
18#include <Draw.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>
36
37
38
39//=======================================================================
40//function : UpdateXLinks
41//=======================================================================
42
43static Standard_Integer DDocStd_UpdateXLinks(Draw_Interpretor& /*di*/,Standard_Integer n, const char** a)
44{
45 if (n < 3) return 1;
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]);
51 return 0;
52}
53
54//=======================================================================
55//function : DDocStd_DumpCommand
56//purpose : DumpDocument (DOC)
57//=======================================================================
58
59static Standard_Integer DDocStd_DumpCommand (Draw_Interpretor& di,
60 Standard_Integer nb,
61 const char** arg)
62{
63 if (nb == 2) {
64 Handle(TDocStd_Document) D;
65 if (!DDocStd::GetDocument(arg[1],D)) return 1;
66 //
67 TDF_AttributeDeltaList added, forgoten, resumed, removed, modified;
68 Handle(TDF_AttributeDelta) AD;
69 if (D->GetUndos().IsEmpty()) {
70 di << "no UNDO available" << "\n";
71 return 0;
72 }
73 Handle(TDF_Delta) DELTA = D->GetUndos().Last();
74 TDF_ListIteratorOfAttributeDeltaList it (DELTA->AttributeDeltas());
75 for (;it.More();it.Next()) {
76 AD = it.Value();
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);}
82 else {
83 Standard_DomainError::Raise("DDocStd_DumpCommand : unknown delta");
84 }
85 }
86 //
87 TCollection_AsciiString string;
88 //
89 TCollection_AsciiString name; // (D->Name());
90 di << "ADDED :";
91 it.Initialize(added);
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();
98 di << "\n";
99 }
100 //
101 // forgoten
102 di << "FORGOTEN :";
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();
110 di << "\n";
111 }
112 //
113 // resumed
114 di << "RESUMED :";
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();
122 di << "\n";
123 }
124 //
125 // removed
126 di << "REMOVED :";
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();
134 di << "\n";
135 }
136 //
137 // modified
138 di << "MODIFIED :";
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();
146 di << "\n";
147 }
148 return 0;
149 }
150 di << "TDocStd_DumpCommand : Error" << "\n";
151 return 1;
152}
153
154
155
156//=======================================================================
157//function : ModificationCommands
158//purpose :
159//=======================================================================
160
161void DDocStd::ToolsCommands(Draw_Interpretor& theCommands)
162{
163 static Standard_Boolean done = Standard_False;
164 if (done) return;
165 done = Standard_True;
166
167 const char* g = "DDocStd commands";
168
169
170 theCommands.Add("UpdateXLinks","UpdateXLinks DocName DocEntry",
171 __FILE__, DDocStd_UpdateXLinks, g);
172
173 theCommands.Add ("DumpCommand",
174 "DumpCommand (DOC)",
175 __FILE__, DDocStd_DumpCommand, g);
176
177}
178