973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <IFSelect_ContextWrite.hxx> |
16 | #include <IFSelect_WorkLibrary.hxx> |
17 | #include <Interface_CopyTool.hxx> |
18 | #include <Interface_EntityIterator.hxx> |
19 | #include <Interface_InterfaceModel.hxx> |
20 | #include <Interface_Protocol.hxx> |
7fd59977 |
21 | #include <Message.hxx> |
42cf5bc1 |
22 | #include <Message_Messenger.hxx> |
23 | #include <Standard_Transient.hxx> |
24 | #include <Standard_Type.hxx> |
25 | #include <TCollection_HAsciiString.hxx> |
b311480e |
26 | |
7fd59977 |
27 | // all deferred but Copy (virtual default) |
b311480e |
28 | IFSelect_WorkLibrary::IFSelect_WorkLibrary () { thelevdef = 0; } |
7fd59977 |
29 | |
30 | Standard_Boolean IFSelect_WorkLibrary::CopyModel |
31 | (const Handle(Interface_InterfaceModel)& /*original*/, |
32 | const Handle(Interface_InterfaceModel)& newmodel, |
33 | const Interface_EntityIterator& list, |
34 | Interface_CopyTool& TC) const |
35 | { |
36 | for (list.Start(); list.More(); list.Next()) |
37 | TC.TransferEntity (list.Value()); |
38 | |
39 | TC.FillModel(newmodel); |
40 | |
41 | return Standard_True; |
42 | } |
43 | |
44 | |
45 | void IFSelect_WorkLibrary::DumpEntity |
46 | (const Handle(Interface_InterfaceModel)& model, |
47 | const Handle(Interface_Protocol)& protocol, |
48 | const Handle(Standard_Transient)& entity, |
49 | const Handle(Message_Messenger)& S) const |
50 | { |
51 | if (thelevhlp.IsNull()) DumpEntity (model,protocol,entity,S,0); |
52 | else DumpEntity (model,protocol,entity,S,thelevdef); |
53 | } |
54 | |
55 | |
56 | void IFSelect_WorkLibrary::SetDumpLevels |
57 | (const Standard_Integer def, const Standard_Integer max) |
58 | { |
59 | thelevdef = def; |
60 | thelevhlp.Nullify(); |
61 | if (max >= 0) thelevhlp = new Interface_HArray1OfHAsciiString (0,max); |
62 | } |
63 | |
64 | void IFSelect_WorkLibrary::DumpLevels |
65 | (Standard_Integer& def, Standard_Integer& max) const |
66 | { |
67 | def = thelevdef; |
68 | if (thelevhlp.IsNull()) { def = 0; max = -1; } |
69 | else max = thelevhlp->Upper(); |
70 | } |
71 | |
72 | void IFSelect_WorkLibrary::SetDumpHelp |
73 | (const Standard_Integer level, const Standard_CString help) |
74 | { |
75 | if (thelevhlp.IsNull()) return; |
76 | if (level < 0 || level > thelevhlp->Upper()) return; |
77 | Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString (help); |
78 | thelevhlp->SetValue (level,str); |
79 | } |
80 | |
81 | Standard_CString IFSelect_WorkLibrary::DumpHelp |
82 | (const Standard_Integer level) const |
83 | { |
84 | if (thelevhlp.IsNull()) return ""; |
85 | if (level < 0 || level > thelevhlp->Upper()) return ""; |
86 | Handle(TCollection_HAsciiString) str = thelevhlp->Value (level); |
87 | if (str.IsNull()) return ""; |
88 | return str->ToCString(); |
89 | } |