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_ContextModif.hxx>
16 #include <IGESData_IGESEntity.hxx>
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>
23 #include <TCollection_HAsciiString.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SetLabel,IGESSelect_ModelModifier)
27 IGESSelect_SetLabel::IGESSelect_SetLabel
28 (const Standard_Integer mode, const Standard_Boolean enforce)
29 : IGESSelect_ModelModifier (Standard_False) ,
30 themode (mode) , theforce (enforce) { }
32 void IGESSelect_SetLabel::Performing(IFSelect_ContextModif& ctx,
33 const Handle(IGESData_IGESModel)& target,
34 Interface_CopyTool& /*TC*/) const
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; }
42 // mode = 1 : mettre DEnnn , nnn est le DE Number
43 lab = iges->ShortLabel();
44 if (theforce) lab.Nullify();
46 if (lab->Length() > 2) {
47 if (lab->Value(1) == 'D' && lab->Value(2) == 'E' &&
48 atoi( &(lab->ToCString())[2] ) > 0)
52 // Si lab nul : le recalculer
54 lab = new TCollection_HAsciiString(target->Number(iges)*2-1);
61 TCollection_AsciiString IGESSelect_SetLabel::Label () const
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)");