7fd59977 |
1 | #include <IGESSelect_SetLabel.ixx> |
2 | #include <Interface_Macros.hxx> |
3 | #include <IGESData_IGESEntity.hxx> |
4 | #include <TCollection_HAsciiString.hxx> |
5 | |
6 | IGESSelect_SetLabel::IGESSelect_SetLabel |
7 | (const Standard_Integer mode, const Standard_Boolean enforce) |
8 | : IGESSelect_ModelModifier (Standard_False) , |
9 | themode (mode) , theforce (enforce) { } |
10 | |
11 | void IGESSelect_SetLabel::Performing |
12 | (IFSelect_ContextModif& ctx, |
13 | const Handle(IGESData_IGESModel)& target, |
14 | Interface_CopyTool& TC) const |
15 | { |
16 | Handle(TCollection_HAsciiString) lab; |
17 | for (ctx.Start(); ctx.More(); ctx.Next()) { |
18 | DeclareAndCast(IGESData_IGESEntity,iges,ctx.ValueResult()); |
19 | if (iges.IsNull()) continue; |
20 | if (themode == 0) { iges->SetLabel(lab); continue; } |
21 | |
22 | // mode = 1 : mettre DEnnn , nnn est le DE Number |
23 | lab = iges->ShortLabel(); |
24 | if (theforce) lab.Nullify(); |
25 | if (!lab.IsNull()) { |
26 | if (lab->Length() > 2) { |
27 | if (lab->Value(1) == 'D' && lab->Value(2) == 'E' && |
28 | atoi( &(lab->ToCString())[2] ) > 0) |
29 | lab.Nullify(); |
30 | } |
31 | } |
32 | // Si lab nul : le recalculer |
33 | if (lab.IsNull()) { |
34 | lab = new TCollection_HAsciiString(target->Number(iges)*2-1); |
35 | lab->Insert (1,"DE"); |
36 | } |
37 | iges->SetLabel(lab); |
38 | } |
39 | } |
40 | |
41 | TCollection_AsciiString IGESSelect_SetLabel::Label () const |
42 | { |
43 | TCollection_AsciiString lab; |
44 | if (themode == 0) lab.AssignCat ("Clear Short Label"); |
45 | if (themode == 1) lab.AssignCat ("Set Short Label to DE Number"); |
46 | if (theforce) lab.AssignCat (" (enforced)"); |
47 | return lab; |
48 | } |