7fd59977 |
1 | #include <STEPEdit_EditContext.ixx> |
2 | #include <Interface_TypedValue.hxx> |
3 | #include <TCollection_HAsciiString.hxx> |
4 | |
5 | #include <StepData_StepModel.hxx> |
6 | #include <STEPConstruct_ContextTool.hxx> |
7 | |
8 | |
9 | STEPEdit_EditContext::STEPEdit_EditContext () |
10 | : IFSelect_Editor (5) |
11 | { |
12 | Handle(Interface_TypedValue) ac_val = new Interface_TypedValue("Application Context",Interface_ParamIdent); |
13 | SetValue(1,ac_val,"AC",IFSelect_EditRead); |
14 | |
15 | Handle(Interface_TypedValue) ac_status = new Interface_TypedValue("AppliContext_Status"); |
16 | SetValue(2,ac_status,"AC_Status"); |
17 | Handle(Interface_TypedValue) ac_sche = new Interface_TypedValue("AppliContext_Schema"); |
18 | SetValue(3,ac_sche,"AC_Schema"); |
19 | Handle(Interface_TypedValue) ac_year = new Interface_TypedValue("AppliContext_Year",Interface_ParamInteger); |
20 | SetValue(4,ac_year,"AC_Year"); |
21 | Handle(Interface_TypedValue) ac_name = new Interface_TypedValue("AppliContext_Name"); |
22 | SetValue(5,ac_name,"AC_Name"); |
23 | |
24 | // Handle(Interface_TypedValue) prpc_val = new Interface_TypedValue("Product Related Product Category",Interface_ParamIdent); |
25 | // SetValue(6,ac_val,"PRPC",IFSelect_EditRead); |
26 | |
27 | // Handle(Interface_TypedValue) prpc_name = new Interface_TypedValue("PRPC_Name"); |
28 | // SetValue(7,prpc_name,"PRPC_Name"); |
29 | // Handle(Interface_TypedValue) prpc_descr = new Interface_TypedValue("PRPC_Description"); |
30 | // SetValue(8,prpc_descr,"PRPC_Descr"); |
31 | } |
32 | |
33 | TCollection_AsciiString STEPEdit_EditContext::Label () const |
34 | { return TCollection_AsciiString ("STEP : Product Definition Context"); } |
35 | |
36 | Standard_Boolean STEPEdit_EditContext::Recognize |
37 | (const Handle(IFSelect_EditForm)& form) const |
38 | { |
39 | // il faut 17 parametres |
40 | return Standard_True; |
41 | } |
42 | |
43 | Handle(TCollection_HAsciiString) STEPEdit_EditContext::StringValue |
44 | (const Handle(IFSelect_EditForm)& form, const Standard_Integer num) const |
45 | { |
46 | Handle(TCollection_HAsciiString) str; |
47 | switch (num) { |
48 | case 2 : return new TCollection_HAsciiString("DIS"); |
49 | case 3 : return new TCollection_HAsciiString("automotive_design"); |
50 | case 4 : return new TCollection_HAsciiString("1998"); |
51 | case 5 : return new TCollection_HAsciiString("EUCLID"); |
52 | case 7 : return new TCollection_HAsciiString("Undefined Category"); |
53 | case 8 : return new TCollection_HAsciiString("Undefined Description"); |
54 | default : break; |
55 | } |
56 | return str; |
57 | } |
58 | |
59 | Standard_Boolean STEPEdit_EditContext::Load |
60 | (const Handle(IFSelect_EditForm)& form, |
61 | const Handle(Standard_Transient)& ent, |
62 | const Handle(Interface_InterfaceModel)& model) const |
63 | { |
64 | Handle(StepData_StepModel) modl = |
65 | Handle(StepData_StepModel)::DownCast(model); |
66 | if (modl.IsNull()) return Standard_False; |
67 | |
68 | STEPConstruct_ContextTool ctx (modl); |
69 | |
70 | form->LoadValue (1, modl->StringLabel(ctx.GetAPD()) ); |
71 | |
72 | form->LoadValue (2, ctx.GetACstatus()); |
73 | form->LoadValue (3, ctx.GetACschemaName()); |
74 | form->LoadValue (4, new TCollection_HAsciiString(ctx.GetACyear()) ); |
75 | form->LoadValue (5, ctx.GetACname()); |
76 | |
77 | // form->LoadValue (6, modl->StringLabel(ctx.GetPRPC()) ); |
78 | |
79 | // form->LoadValue (7, ctx.GetPRPCName()); |
80 | // form->LoadValue (8, ctx.GetPRPCDescription()); |
81 | |
82 | return Standard_True; |
83 | } |
84 | |
85 | Standard_Boolean STEPEdit_EditContext::Apply |
86 | (const Handle(IFSelect_EditForm)& form, |
87 | const Handle(Standard_Transient)& ent, |
88 | const Handle(Interface_InterfaceModel)& model) const |
89 | { |
90 | Handle(StepData_StepModel) modl = |
91 | Handle(StepData_StepModel)::DownCast(model); |
92 | if (modl.IsNull()) return Standard_False; |
93 | |
94 | STEPConstruct_ContextTool ctx (modl); |
95 | |
96 | ctx.AddAPD(); // on ne sait jamais |
97 | // ctx.AddPRPC(); |
98 | |
99 | if (form->IsModified(2)) ctx.SetACstatus (form->EditedValue(2)); |
100 | if (form->IsModified(3)) ctx.SetACschemaName (form->EditedValue(3)); |
101 | if (form->IsModified(4)) ctx.SetACyear(form->EditedValue(4)->IntegerValue()); |
102 | if (form->IsModified(5)) ctx.SetACname (form->EditedValue(5)); |
103 | |
104 | // if (form->IsModified(7)) ctx.SetPRPCName (form->EditedValue(7)); |
105 | // if (form->IsModified(8)) ctx.SetPRPCDescription (form->EditedValue(8)); |
106 | |
107 | return Standard_True; |
108 | } |