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 | |
42cf5bc1 |
14 | |
15 | #include <IFSelect_ContextModif.hxx> |
7fd59977 |
16 | #include <IGESData_IGESEntity.hxx> |
42cf5bc1 |
17 | #include <IGESData_IGESModel.hxx> |
18 | #include <IGESSelect_SetLabel.hxx> |
19 | #include <Interface_CopyTool.hxx> |
20 | #include <Interface_Macros.hxx> |
21 | #include <Standard_Type.hxx> |
22 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
23 | #include <TCollection_HAsciiString.hxx> |
24 | |
92efcf78 |
25 | IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SetLabel,IGESSelect_ModelModifier) |
26 | |
b311480e |
27 | IGESSelect_SetLabel::IGESSelect_SetLabel |
7fd59977 |
28 | (const Standard_Integer mode, const Standard_Boolean enforce) |
29 | : IGESSelect_ModelModifier (Standard_False) , |
30 | themode (mode) , theforce (enforce) { } |
31 | |
35e08fe8 |
32 | void IGESSelect_SetLabel::Performing(IFSelect_ContextModif& ctx, |
33 | const Handle(IGESData_IGESModel)& target, |
34 | Interface_CopyTool& /*TC*/) const |
7fd59977 |
35 | { |
36 | Handle(TCollection_HAsciiString) lab; |
37 | for (ctx.Start(); ctx.More(); ctx.Next()) { |
38 | DeclareAndCast(IGESData_IGESEntity,iges,ctx.ValueResult()); |
39 | if (iges.IsNull()) continue; |
40 | if (themode == 0) { iges->SetLabel(lab); continue; } |
41 | |
42 | // mode = 1 : mettre DEnnn , nnn est le DE Number |
43 | lab = iges->ShortLabel(); |
44 | if (theforce) lab.Nullify(); |
45 | if (!lab.IsNull()) { |
46 | if (lab->Length() > 2) { |
47 | if (lab->Value(1) == 'D' && lab->Value(2) == 'E' && |
48 | atoi( &(lab->ToCString())[2] ) > 0) |
49 | lab.Nullify(); |
50 | } |
51 | } |
52 | // Si lab nul : le recalculer |
53 | if (lab.IsNull()) { |
54 | lab = new TCollection_HAsciiString(target->Number(iges)*2-1); |
55 | lab->Insert (1,"DE"); |
56 | } |
57 | iges->SetLabel(lab); |
58 | } |
59 | } |
60 | |
61 | TCollection_AsciiString IGESSelect_SetLabel::Label () const |
62 | { |
63 | TCollection_AsciiString lab; |
64 | if (themode == 0) lab.AssignCat ("Clear Short Label"); |
65 | if (themode == 1) lab.AssignCat ("Set Short Label to DE Number"); |
66 | if (theforce) lab.AssignCat (" (enforced)"); |
67 | return lab; |
68 | } |