1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <IFSelect_EditForm.hxx>
16 #include <Interface_InterfaceModel.hxx>
17 #include <Interface_TypedValue.hxx>
18 #include <Standard_Transient.hxx>
19 #include <Standard_Type.hxx>
20 #include <StepBasic_ApplicationProtocolDefinition.hxx>
21 #include <STEPConstruct_ContextTool.hxx>
22 #include <StepData_StepModel.hxx>
23 #include <STEPEdit_EditContext.hxx>
24 #include <TCollection_AsciiString.hxx>
25 #include <TCollection_HAsciiString.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(STEPEdit_EditContext,IFSelect_Editor)
29 STEPEdit_EditContext::STEPEdit_EditContext ()
32 Handle(Interface_TypedValue) ac_val = new Interface_TypedValue("Application Context",Interface_ParamIdent);
33 SetValue(1,ac_val,"AC",IFSelect_EditRead);
35 Handle(Interface_TypedValue) ac_status = new Interface_TypedValue("AppliContext_Status");
36 SetValue(2,ac_status,"AC_Status");
37 Handle(Interface_TypedValue) ac_sche = new Interface_TypedValue("AppliContext_Schema");
38 SetValue(3,ac_sche,"AC_Schema");
39 Handle(Interface_TypedValue) ac_year = new Interface_TypedValue("AppliContext_Year",Interface_ParamInteger);
40 SetValue(4,ac_year,"AC_Year");
41 Handle(Interface_TypedValue) ac_name = new Interface_TypedValue("AppliContext_Name");
42 SetValue(5,ac_name,"AC_Name");
44 // Handle(Interface_TypedValue) prpc_val = new Interface_TypedValue("Product Related Product Category",Interface_ParamIdent);
45 // SetValue(6,ac_val,"PRPC",IFSelect_EditRead);
47 // Handle(Interface_TypedValue) prpc_name = new Interface_TypedValue("PRPC_Name");
48 // SetValue(7,prpc_name,"PRPC_Name");
49 // Handle(Interface_TypedValue) prpc_descr = new Interface_TypedValue("PRPC_Description");
50 // SetValue(8,prpc_descr,"PRPC_Descr");
53 TCollection_AsciiString STEPEdit_EditContext::Label () const
54 { return TCollection_AsciiString ("STEP : Product Definition Context"); }
56 Standard_Boolean STEPEdit_EditContext::Recognize
57 (const Handle(IFSelect_EditForm)& /*form*/) const
59 // il faut 17 parametres
63 Handle(TCollection_HAsciiString) STEPEdit_EditContext::StringValue
64 (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const
66 Handle(TCollection_HAsciiString) str;
68 case 2 : return new TCollection_HAsciiString("DIS");
69 case 3 : return new TCollection_HAsciiString("automotive_design");
70 case 4 : return new TCollection_HAsciiString("1998");
71 case 5 : return new TCollection_HAsciiString("EUCLID");
72 case 7 : return new TCollection_HAsciiString("Undefined Category");
73 case 8 : return new TCollection_HAsciiString("Undefined Description");
79 Standard_Boolean STEPEdit_EditContext::Load
80 (const Handle(IFSelect_EditForm)& form,
81 const Handle(Standard_Transient)& /*ent*/,
82 const Handle(Interface_InterfaceModel)& model) const
84 Handle(StepData_StepModel) modl =
85 Handle(StepData_StepModel)::DownCast(model);
86 if (modl.IsNull()) return Standard_False;
88 STEPConstruct_ContextTool ctx (modl);
90 form->LoadValue (1, modl->StringLabel(ctx.GetAPD()) );
92 form->LoadValue (2, ctx.GetACstatus());
93 form->LoadValue (3, ctx.GetACschemaName());
94 form->LoadValue (4, new TCollection_HAsciiString(ctx.GetACyear()) );
95 form->LoadValue (5, ctx.GetACname());
97 // form->LoadValue (6, modl->StringLabel(ctx.GetPRPC()) );
99 // form->LoadValue (7, ctx.GetPRPCName());
100 // form->LoadValue (8, ctx.GetPRPCDescription());
102 return Standard_True;
105 Standard_Boolean STEPEdit_EditContext::Apply
106 (const Handle(IFSelect_EditForm)& form,
107 const Handle(Standard_Transient)& /*ent*/,
108 const Handle(Interface_InterfaceModel)& model) const
110 Handle(StepData_StepModel) modl =
111 Handle(StepData_StepModel)::DownCast(model);
112 if (modl.IsNull()) return Standard_False;
114 STEPConstruct_ContextTool ctx (modl);
116 ctx.AddAPD(); // on ne sait jamais
119 if (form->IsModified(2)) ctx.SetACstatus (form->EditedValue(2));
120 if (form->IsModified(3)) ctx.SetACschemaName (form->EditedValue(3));
121 if (form->IsModified(4)) ctx.SetACyear(form->EditedValue(4)->IntegerValue());
122 if (form->IsModified(5)) ctx.SetACname (form->EditedValue(5));
124 // if (form->IsModified(7)) ctx.SetPRPCName (form->EditedValue(7));
125 // if (form->IsModified(8)) ctx.SetPRPCDescription (form->EditedValue(8));
127 return Standard_True;