0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / IGESSelect / IGESSelect_ChangeLevelList.cxx
CommitLineData
b311480e 1// Created on: 1994-08-25
2// Created by: Christian CAILLET
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
42cf5bc1 17
18#include <IFSelect_ContextModif.hxx>
19#include <IFSelect_IntParam.hxx>
7fd59977 20#include <IGESData_IGESEntity.hxx>
42cf5bc1 21#include <IGESData_IGESModel.hxx>
22#include <IGESData_LevelListEntity.hxx>
23#include <IGESSelect_ChangeLevelList.hxx>
7fd59977 24#include <Interface_Check.hxx>
42cf5bc1 25#include <Interface_CopyTool.hxx>
26#include <Interface_Macros.hxx>
27#include <Standard_Type.hxx>
28#include <TCollection_AsciiString.hxx>
7fd59977 29
42cf5bc1 30#include <stdio.h>
92efcf78 31IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_ChangeLevelList,IGESSelect_ModelModifier)
32
b311480e 33IGESSelect_ChangeLevelList::IGESSelect_ChangeLevelList ()
7fd59977 34 : IGESSelect_ModelModifier (Standard_True) { }
35
36 Standard_Boolean IGESSelect_ChangeLevelList::HasOldNumber () const
37 { return (!theold.IsNull()); }
38
39 Handle(IFSelect_IntParam) IGESSelect_ChangeLevelList::OldNumber () const
40 { return theold; }
41
42 void IGESSelect_ChangeLevelList::SetOldNumber
43 (const Handle(IFSelect_IntParam)& param)
44 { theold = param; }
45
46 Standard_Boolean IGESSelect_ChangeLevelList::HasNewNumber () const
47 { return (!thenew.IsNull()); }
48
49 Handle(IFSelect_IntParam) IGESSelect_ChangeLevelList::NewNumber () const
50 { return thenew; }
51
52 void IGESSelect_ChangeLevelList::SetNewNumber
53 (const Handle(IFSelect_IntParam)& param)
54 { thenew = param; }
55
56
57 void IGESSelect_ChangeLevelList::Performing
58 (IFSelect_ContextModif& ctx,
59 const Handle(IGESData_IGESModel)& ,
60 Interface_CopyTool& ) const
61{
62 Standard_Integer oldl = 0;
63 Standard_Boolean yaold = HasOldNumber();
64 if (yaold) oldl = theold->Value();
65 Standard_Boolean yanew = HasOldNumber();
66 Standard_Integer newl = 0;
67 if (yanew) newl = thenew->Value();
68 if (oldl < 0) ctx.CCheck()->AddFail("ChangeLevelList : OldNumber negative");
69 if (newl < 0) ctx.CCheck()->AddFail("ChangeLevelList : NewNumber negative");
70 if (oldl < 0 || newl < 0) return;
71
72 Handle(IGESData_LevelListEntity) nulist;
73 for (ctx.Start(); ctx.More(); ctx.Next()) {
74 DeclareAndCast(IGESData_IGESEntity,ent,ctx.ValueResult());
75 if (ent.IsNull()) continue;
76 if (ent->DefLevel() != IGESData_DefSeveral) continue;
77 if (yaold && ent->Level() != oldl) continue;
78 if (!yanew) {
79 Handle(IGESData_LevelListEntity) list = ent->LevelList();
80 if (list.IsNull()) continue;
81 newl = (list->NbLevelNumbers() > 0 ? list->LevelNumber(1) : 0);
82 if (newl < 0) newl = 0;
83 }
84 ent->InitLevel(nulist,newl);
85 ctx.Trace();
86 }
87}
88
89 TCollection_AsciiString IGESSelect_ChangeLevelList::Label () const
90{
91 char labl[100];
92 Standard_Integer oldl = 0;
93 Standard_Boolean yaold = HasOldNumber();
94 if (yaold) oldl = theold->Value();
95 Standard_Boolean yanew = HasOldNumber();
96 Standard_Integer newl = 0;
97 if (yanew) newl = thenew->Value();
98
99 if (yaold) sprintf(labl,"Changes Level Lists containing %d", oldl);
100 else sprintf(labl,"Changes all Level Lists in D.E. %d", oldl);
101 TCollection_AsciiString label(labl);
102 if (yanew) sprintf(labl," to Number %d",newl);
103 else sprintf(labl," to Number = first value in List");
104 label.AssignCat(labl);
105 return label;
106}