0030480: Visualization - Clear of Select3D_SensitiveGroup does not update internal...
[occt.git] / src / IFSelect / IFSelect_WorkLibrary.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
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>
26
27 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_WorkLibrary,Standard_Transient)
28
29 //  all deferred but Copy (virtual default)
30 IFSelect_WorkLibrary::IFSelect_WorkLibrary ()  {  thelevdef = 0;  }
31
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
37 {
38   for (list.Start(); list.More(); list.Next())
39     TC.TransferEntity (list.Value());
40
41   TC.FillModel(newmodel);
42
43   return Standard_True;
44 }
45
46
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
52 {
53   if (thelevhlp.IsNull()) DumpEntity (model,protocol,entity,S,0);
54   else                    DumpEntity (model,protocol,entity,S,thelevdef);
55 }
56
57
58     void  IFSelect_WorkLibrary::SetDumpLevels
59   (const Standard_Integer def, const Standard_Integer max)
60 {
61   thelevdef = def;
62   thelevhlp.Nullify();
63   if (max >= 0) thelevhlp = new Interface_HArray1OfHAsciiString (0,max);
64 }
65
66     void  IFSelect_WorkLibrary::DumpLevels
67   (Standard_Integer& def, Standard_Integer& max) const
68 {
69   def = thelevdef;
70   if (thelevhlp.IsNull()) {  def = 0;  max = -1;  }
71   else max = thelevhlp->Upper();
72 }
73
74     void  IFSelect_WorkLibrary::SetDumpHelp
75   (const Standard_Integer level, const Standard_CString help)
76 {
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);
81 }
82
83     Standard_CString  IFSelect_WorkLibrary::DumpHelp
84   (const Standard_Integer level) const
85 {
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();
91 }