b311480e |
1 | // Created on: 2000-03-01 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 2000-2012 OPEN CASCADE SAS |
4 | // |
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. |
9 | // |
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. |
12 | // |
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. |
19 | |
7fd59977 |
20 | |
21 | |
22 | #include <DDocStd.hxx> |
23 | |
24 | #include <Draw.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> |
42 | |
43 | |
44 | |
45 | //======================================================================= |
46 | //function : UpdateXLinks |
47 | //======================================================================= |
48 | |
49 | static Standard_Integer DDocStd_UpdateXLinks(Draw_Interpretor& /*di*/,Standard_Integer n, const char** a) |
50 | { |
51 | if (n < 3) return 1; |
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]); |
57 | return 0; |
58 | } |
59 | |
60 | //======================================================================= |
61 | //function : DDocStd_DumpCommand |
62 | //purpose : DumpDocument (DOC) |
63 | //======================================================================= |
64 | |
65 | static Standard_Integer DDocStd_DumpCommand (Draw_Interpretor& di, |
66 | Standard_Integer nb, |
67 | const char** arg) |
68 | { |
69 | if (nb == 2) { |
70 | Handle(TDocStd_Document) D; |
71 | if (!DDocStd::GetDocument(arg[1],D)) return 1; |
72 | // |
73 | TDF_AttributeDeltaList added, forgoten, resumed, removed, modified; |
74 | Handle(TDF_AttributeDelta) AD; |
75 | if (D->GetUndos().IsEmpty()) { |
76 | di << "no UNDO available" << "\n"; |
77 | return 0; |
78 | } |
79 | Handle(TDF_Delta) DELTA = D->GetUndos().Last(); |
80 | TDF_ListIteratorOfAttributeDeltaList it (DELTA->AttributeDeltas()); |
81 | for (;it.More();it.Next()) { |
82 | AD = it.Value(); |
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);} |
88 | else { |
89 | Standard_DomainError::Raise("DDocStd_DumpCommand : unknown delta"); |
90 | } |
91 | } |
92 | // |
93 | TCollection_AsciiString string; |
94 | // |
95 | TCollection_AsciiString name; // (D->Name()); |
96 | di << "ADDED :"; |
97 | it.Initialize(added); |
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(); |
104 | di << "\n"; |
105 | } |
106 | // |
107 | // forgoten |
108 | di << "FORGOTEN :"; |
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(); |
116 | di << "\n"; |
117 | } |
118 | // |
119 | // resumed |
120 | di << "RESUMED :"; |
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(); |
128 | di << "\n"; |
129 | } |
130 | // |
131 | // removed |
132 | di << "REMOVED :"; |
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(); |
140 | di << "\n"; |
141 | } |
142 | // |
143 | // modified |
144 | di << "MODIFIED :"; |
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(); |
152 | di << "\n"; |
153 | } |
154 | return 0; |
155 | } |
156 | di << "TDocStd_DumpCommand : Error" << "\n"; |
157 | return 1; |
158 | } |
159 | |
160 | |
161 | |
162 | //======================================================================= |
163 | //function : ModificationCommands |
164 | //purpose : |
165 | //======================================================================= |
166 | |
167 | void DDocStd::ToolsCommands(Draw_Interpretor& theCommands) |
168 | { |
169 | static Standard_Boolean done = Standard_False; |
170 | if (done) return; |
171 | done = Standard_True; |
172 | |
173 | const char* g = "DDocStd commands"; |
174 | |
175 | |
176 | theCommands.Add("UpdateXLinks","UpdateXLinks DocName DocEntry", |
177 | __FILE__, DDocStd_UpdateXLinks, g); |
178 | |
179 | theCommands.Add ("DumpCommand", |
180 | "DumpCommand (DOC)", |
181 | __FILE__, DDocStd_DumpCommand, g); |
182 | |
183 | } |
184 | |