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_Signature.hxx>
16 #include <IFSelect_SignMultiple.hxx>
17 #include <Interface_InterfaceModel.hxx>
18 #include <Standard_Transient.hxx>
19 #include <Standard_Type.hxx>
20 #include <TCollection_AsciiString.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SignMultiple,IFSelect_Signature)
24 static TCollection_AsciiString theval; // temporaire pour construire Value
26 IFSelect_SignMultiple::IFSelect_SignMultiple (const Standard_CString name)
27 : IFSelect_Signature (name) { }
29 void IFSelect_SignMultiple::Add
30 (const Handle(IFSelect_Signature)& subsign,
31 const Standard_Integer tabul, const Standard_Boolean maxi)
33 if (subsign.IsNull()) return;
34 thesubs.Append (subsign);
35 thetabs.Append (maxi ? -tabul : tabul);
38 Standard_CString IFSelect_SignMultiple::Value
39 (const Handle(Standard_Transient)& ent,
40 const Handle(Interface_InterfaceModel)& model) const
43 Standard_Integer i, nb = thesubs.Length();
44 for (i = 1; i <= nb; i ++) {
45 Standard_Integer tabul = thetabs.Value(i);
46 Standard_Boolean maxi = (tabul < 0);
47 if (maxi) tabul = -tabul;
48 Handle(IFSelect_Signature) sign = Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
49 Standard_CString val = sign->Value (ent,model);
50 TCollection_AsciiString str(val);
51 Standard_Integer sl = str.Length();
52 str.LeftJustify (tabul,' ');
53 if (sl > tabul && maxi) {
54 str.Remove (sl+1,tabul-sl);
55 str.SetValue (sl,'.');
58 theval.AssignCat (str);
60 return theval.ToCString();
64 Standard_Boolean IFSelect_SignMultiple::Matches
65 (const Handle(Standard_Transient)& ent,
66 const Handle(Interface_InterfaceModel)& model,
67 const TCollection_AsciiString& text, const Standard_Boolean exact) const
69 if (exact) return IFSelect_Signature::Matches (ent,model,text,exact);
70 Standard_Integer i, nb = thesubs.Length();
71 for (i = 1; i <= nb; i ++) {
72 Handle(IFSelect_Signature) sign =
73 Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
74 if (sign->Matches (ent,model,text,exact)) return Standard_True;
76 return Standard_False;