Warnings on vc14 were eliminated
[occt.git] / src / IGESSelect / IGESSelect_ChangeLevelNumber.cxx
1 // Created on: 1994-08-25
2 // Created by: Christian CAILLET
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <IFSelect_ContextModif.hxx>
19 #include <IFSelect_IntParam.hxx>
20 #include <IGESData_IGESEntity.hxx>
21 #include <IGESData_IGESModel.hxx>
22 #include <IGESData_LevelListEntity.hxx>
23 #include <IGESSelect_ChangeLevelNumber.hxx>
24 #include <Interface_Check.hxx>
25 #include <Interface_CopyTool.hxx>
26 #include <Interface_Macros.hxx>
27 #include <Standard_Type.hxx>
28 #include <TCollection_AsciiString.hxx>
29
30 #include <stdio.h>
31 IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_ChangeLevelNumber,IGESSelect_ModelModifier)
32
33 IGESSelect_ChangeLevelNumber::IGESSelect_ChangeLevelNumber ()
34     :  IGESSelect_ModelModifier (Standard_False)    {  }
35
36     Standard_Boolean  IGESSelect_ChangeLevelNumber::HasOldNumber () const
37       {  return (!theold.IsNull());  }
38
39     Handle(IFSelect_IntParam)  IGESSelect_ChangeLevelNumber::OldNumber () const
40       {  return theold;  }
41
42     void  IGESSelect_ChangeLevelNumber::SetOldNumber
43   (const Handle(IFSelect_IntParam)& param)
44       {  theold = param;  }
45
46     Handle(IFSelect_IntParam)  IGESSelect_ChangeLevelNumber::NewNumber () const
47       {  return thenew;  }
48
49     void  IGESSelect_ChangeLevelNumber::SetNewNumber
50   (const Handle(IFSelect_IntParam)& param)
51       {  thenew = param;  }
52
53
54     void  IGESSelect_ChangeLevelNumber::Performing
55   (IFSelect_ContextModif& ctx,
56    const Handle(IGESData_IGESModel)& ,
57    Interface_CopyTool& ) const
58 {
59   Standard_Integer oldl = 0;
60   Standard_Boolean yaold = HasOldNumber();
61   if (yaold) oldl = theold->Value();
62   Standard_Integer newl = 0;
63   if (!thenew.IsNull()) newl = thenew->Value();
64   if (oldl < 0) ctx.CCheck()->AddFail("ChangeLevelNumber : OldNumber negative");
65   if (newl < 0) ctx.CCheck()->AddFail("ChangeLevelNumber : NewNumber negative");
66   if (oldl < 0 || newl < 0) return;
67
68   Handle(IGESData_LevelListEntity) nulist;
69   for (ctx.Start(); ctx.More(); ctx.Next()) {
70     DeclareAndCast(IGESData_IGESEntity,ent,ctx.ValueResult());
71     if (ent.IsNull()) continue;
72     if (ent->DefLevel() == IGESData_DefSeveral) continue;
73     if (yaold && ent->Level() != oldl) continue;
74     ent->InitLevel(nulist,newl);
75     ctx.Trace();
76   }
77 }
78
79     TCollection_AsciiString  IGESSelect_ChangeLevelNumber::Label () const
80 {
81   char labl[100];
82   Standard_Integer oldl = 0;
83   Standard_Boolean yaold = HasOldNumber();
84   if (yaold) oldl = theold->Value();
85   Standard_Integer newl = 0;
86   if (!thenew.IsNull()) newl = thenew->Value();
87
88   if (yaold) sprintf(labl,"Changes Level Number %d to %d",oldl,newl);
89   else       sprintf(labl,"Changes all Level Numbers positive and zero to %d",
90                      newl);
91   return TCollection_AsciiString(labl);
92 }