0022627: Change OCCT memory management defaults
[occt.git] / src / IGESSelect / IGESSelect_SetGlobalParameter.cxx
CommitLineData
7fd59977 1#include <IGESSelect_SetGlobalParameter.ixx>
2#include <IGESData_GlobalSection.hxx>
3#include <Interface_ParamSet.hxx>
4#include <Interface_FileParameter.hxx>
5#include <stdio.h>
6#include <Interface_Check.hxx>
7
8
9 IGESSelect_SetGlobalParameter::IGESSelect_SetGlobalParameter
10 (const Standard_Integer numpar)
11 : IGESSelect_ModelModifier (Standard_False)
12 { thenum = numpar; }
13
14 Standard_Integer IGESSelect_SetGlobalParameter::GlobalNumber () const
15 { return thenum; }
16
17 void IGESSelect_SetGlobalParameter::SetValue
18 (const Handle(TCollection_HAsciiString)& text)
19 { theval = text; }
20
21 Handle(TCollection_HAsciiString) IGESSelect_SetGlobalParameter::Value
22 () const
23 { return theval; }
24
25
26 void IGESSelect_SetGlobalParameter::Performing
27 (IFSelect_ContextModif& ctx,
28 const Handle(IGESData_IGESModel)& target,
29 Interface_CopyTool& ) const
30{
31 if (theval.IsNull()) {
32 ctx.CCheck()->AddWarning("Set IGES Global Parameter, no value defined, ignored");
33 return;
34 }
35 IGESData_GlobalSection GS = target->GlobalSection();
36 Handle(Interface_ParamSet) oldset = GS.Params();
37 if (thenum <= 0 || thenum > oldset->NbParams()) {
38 char mess[80];
39 sprintf(mess,"Set IGES Global Parameter : Number %d incorrect",thenum);
40 ctx.CCheck()->AddFail(mess);
41 return;
42 }
43 Interface_FileParameter& FP = oldset->ChangeParam (thenum);
44 FP.Init (theval->ToCString(),FP.ParamType());
45 Handle(Interface_Check) check = new Interface_Check;
46 GS.Init (oldset,check);
47 ctx.AddCheck(check);
48 if (!check->HasFailed()) target->SetGlobalSection(GS);
49}
50
51 TCollection_AsciiString IGESSelect_SetGlobalParameter::Label () const
52{
53 char mess[80];
54 if (theval.IsNull()) sprintf(mess,"Set IGES Global Parameter (undefined)");
55 else sprintf(mess,"Set IGES Global Parameter Number %d to %s",
56 thenum,theval->ToCString());
57 return TCollection_AsciiString (mess);
58}