973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | #include <IGESSelect_SetGlobalParameter.ixx> |
15 | #include <IGESData_GlobalSection.hxx> |
16 | #include <Interface_ParamSet.hxx> |
17 | #include <Interface_FileParameter.hxx> |
18 | #include <stdio.h> |
19 | #include <Interface_Check.hxx> |
20 | |
21 | |
b311480e |
22 | IGESSelect_SetGlobalParameter::IGESSelect_SetGlobalParameter |
7fd59977 |
23 | (const Standard_Integer numpar) |
24 | : IGESSelect_ModelModifier (Standard_False) |
25 | { thenum = numpar; } |
26 | |
27 | Standard_Integer IGESSelect_SetGlobalParameter::GlobalNumber () const |
28 | { return thenum; } |
29 | |
30 | void IGESSelect_SetGlobalParameter::SetValue |
31 | (const Handle(TCollection_HAsciiString)& text) |
32 | { theval = text; } |
33 | |
34 | Handle(TCollection_HAsciiString) IGESSelect_SetGlobalParameter::Value |
35 | () const |
36 | { return theval; } |
37 | |
38 | |
39 | void IGESSelect_SetGlobalParameter::Performing |
40 | (IFSelect_ContextModif& ctx, |
41 | const Handle(IGESData_IGESModel)& target, |
42 | Interface_CopyTool& ) const |
43 | { |
44 | if (theval.IsNull()) { |
45 | ctx.CCheck()->AddWarning("Set IGES Global Parameter, no value defined, ignored"); |
46 | return; |
47 | } |
48 | IGESData_GlobalSection GS = target->GlobalSection(); |
49 | Handle(Interface_ParamSet) oldset = GS.Params(); |
50 | if (thenum <= 0 || thenum > oldset->NbParams()) { |
51 | char mess[80]; |
52 | sprintf(mess,"Set IGES Global Parameter : Number %d incorrect",thenum); |
53 | ctx.CCheck()->AddFail(mess); |
54 | return; |
55 | } |
56 | Interface_FileParameter& FP = oldset->ChangeParam (thenum); |
57 | FP.Init (theval->ToCString(),FP.ParamType()); |
58 | Handle(Interface_Check) check = new Interface_Check; |
59 | GS.Init (oldset,check); |
60 | ctx.AddCheck(check); |
61 | if (!check->HasFailed()) target->SetGlobalSection(GS); |
62 | } |
63 | |
64 | TCollection_AsciiString IGESSelect_SetGlobalParameter::Label () const |
65 | { |
66 | char mess[80]; |
67 | if (theval.IsNull()) sprintf(mess,"Set IGES Global Parameter (undefined)"); |
68 | else sprintf(mess,"Set IGES Global Parameter Number %d to %s", |
69 | thenum,theval->ToCString()); |
70 | return TCollection_AsciiString (mess); |
71 | } |