0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IFSelect / IFSelect_SignMultiple.cxx
CommitLineData
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_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>
7fd59977 21
92efcf78 22IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SignMultiple,IFSelect_Signature)
23
7fd59977 24static TCollection_AsciiString theval; // temporaire pour construire Value
25
26 IFSelect_SignMultiple::IFSelect_SignMultiple (const Standard_CString name)
27 : IFSelect_Signature (name) { }
28
29 void IFSelect_SignMultiple::Add
30 (const Handle(IFSelect_Signature)& subsign,
31 const Standard_Integer tabul, const Standard_Boolean maxi)
32{
33 if (subsign.IsNull()) return;
34 thesubs.Append (subsign);
35 thetabs.Append (maxi ? -tabul : tabul);
36}
37
38 Standard_CString IFSelect_SignMultiple::Value
39 (const Handle(Standard_Transient)& ent,
40 const Handle(Interface_InterfaceModel)& model) const
41{
42 theval.Clear();
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,'.');
56 }
57 str.AssignCat(" ");
58 theval.AssignCat (str);
59 }
60 return theval.ToCString();
61}
62
63
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
68{
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;
75 }
76 return Standard_False;
77}