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