1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
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>
21 #include <Message.hxx>
22 #include <Message_Messenger.hxx>
23 #include <Standard_Transient.hxx>
24 #include <Standard_Type.hxx>
25 #include <TCollection_HAsciiString.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_WorkLibrary,Standard_Transient)
29 // all deferred but Copy (virtual default)
30 IFSelect_WorkLibrary::IFSelect_WorkLibrary () { thelevdef = 0; }
32 Standard_Boolean IFSelect_WorkLibrary::CopyModel
33 (const Handle(Interface_InterfaceModel)& /*original*/,
34 const Handle(Interface_InterfaceModel)& newmodel,
35 const Interface_EntityIterator& list,
36 Interface_CopyTool& TC) const
38 for (list.Start(); list.More(); list.Next())
39 TC.TransferEntity (list.Value());
41 TC.FillModel(newmodel);
47 void IFSelect_WorkLibrary::DumpEntity
48 (const Handle(Interface_InterfaceModel)& model,
49 const Handle(Interface_Protocol)& protocol,
50 const Handle(Standard_Transient)& entity,
51 const Handle(Message_Messenger)& S) const
53 if (thelevhlp.IsNull()) DumpEntity (model,protocol,entity,S,0);
54 else DumpEntity (model,protocol,entity,S,thelevdef);
58 void IFSelect_WorkLibrary::SetDumpLevels
59 (const Standard_Integer def, const Standard_Integer max)
63 if (max >= 0) thelevhlp = new Interface_HArray1OfHAsciiString (0,max);
66 void IFSelect_WorkLibrary::DumpLevels
67 (Standard_Integer& def, Standard_Integer& max) const
70 if (thelevhlp.IsNull()) { def = 0; max = -1; }
71 else max = thelevhlp->Upper();
74 void IFSelect_WorkLibrary::SetDumpHelp
75 (const Standard_Integer level, const Standard_CString help)
77 if (thelevhlp.IsNull()) return;
78 if (level < 0 || level > thelevhlp->Upper()) return;
79 Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString (help);
80 thelevhlp->SetValue (level,str);
83 Standard_CString IFSelect_WorkLibrary::DumpHelp
84 (const Standard_Integer level) const
86 if (thelevhlp.IsNull()) return "";
87 if (level < 0 || level > thelevhlp->Upper()) return "";
88 Handle(TCollection_HAsciiString) str = thelevhlp->Value (level);
89 if (str.IsNull()) return "";
90 return str->ToCString();