b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <STEPEdit_EditContext.ixx> |
19 | #include <Interface_TypedValue.hxx> |
20 | #include <TCollection_HAsciiString.hxx> |
21 | |
22 | #include <StepData_StepModel.hxx> |
23 | #include <STEPConstruct_ContextTool.hxx> |
24 | |
25 | |
26 | STEPEdit_EditContext::STEPEdit_EditContext () |
27 | : IFSelect_Editor (5) |
28 | { |
29 | Handle(Interface_TypedValue) ac_val = new Interface_TypedValue("Application Context",Interface_ParamIdent); |
30 | SetValue(1,ac_val,"AC",IFSelect_EditRead); |
31 | |
32 | Handle(Interface_TypedValue) ac_status = new Interface_TypedValue("AppliContext_Status"); |
33 | SetValue(2,ac_status,"AC_Status"); |
34 | Handle(Interface_TypedValue) ac_sche = new Interface_TypedValue("AppliContext_Schema"); |
35 | SetValue(3,ac_sche,"AC_Schema"); |
36 | Handle(Interface_TypedValue) ac_year = new Interface_TypedValue("AppliContext_Year",Interface_ParamInteger); |
37 | SetValue(4,ac_year,"AC_Year"); |
38 | Handle(Interface_TypedValue) ac_name = new Interface_TypedValue("AppliContext_Name"); |
39 | SetValue(5,ac_name,"AC_Name"); |
40 | |
41 | // Handle(Interface_TypedValue) prpc_val = new Interface_TypedValue("Product Related Product Category",Interface_ParamIdent); |
42 | // SetValue(6,ac_val,"PRPC",IFSelect_EditRead); |
43 | |
44 | // Handle(Interface_TypedValue) prpc_name = new Interface_TypedValue("PRPC_Name"); |
45 | // SetValue(7,prpc_name,"PRPC_Name"); |
46 | // Handle(Interface_TypedValue) prpc_descr = new Interface_TypedValue("PRPC_Description"); |
47 | // SetValue(8,prpc_descr,"PRPC_Descr"); |
48 | } |
49 | |
50 | TCollection_AsciiString STEPEdit_EditContext::Label () const |
51 | { return TCollection_AsciiString ("STEP : Product Definition Context"); } |
52 | |
53 | Standard_Boolean STEPEdit_EditContext::Recognize |
35e08fe8 |
54 | (const Handle(IFSelect_EditForm)& /*form*/) const |
7fd59977 |
55 | { |
56 | // il faut 17 parametres |
57 | return Standard_True; |
58 | } |
59 | |
60 | Handle(TCollection_HAsciiString) STEPEdit_EditContext::StringValue |
35e08fe8 |
61 | (const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const |
7fd59977 |
62 | { |
63 | Handle(TCollection_HAsciiString) str; |
64 | switch (num) { |
65 | case 2 : return new TCollection_HAsciiString("DIS"); |
66 | case 3 : return new TCollection_HAsciiString("automotive_design"); |
67 | case 4 : return new TCollection_HAsciiString("1998"); |
68 | case 5 : return new TCollection_HAsciiString("EUCLID"); |
69 | case 7 : return new TCollection_HAsciiString("Undefined Category"); |
70 | case 8 : return new TCollection_HAsciiString("Undefined Description"); |
71 | default : break; |
72 | } |
73 | return str; |
74 | } |
75 | |
76 | Standard_Boolean STEPEdit_EditContext::Load |
77 | (const Handle(IFSelect_EditForm)& form, |
35e08fe8 |
78 | const Handle(Standard_Transient)& /*ent*/, |
7fd59977 |
79 | const Handle(Interface_InterfaceModel)& model) const |
80 | { |
81 | Handle(StepData_StepModel) modl = |
82 | Handle(StepData_StepModel)::DownCast(model); |
83 | if (modl.IsNull()) return Standard_False; |
84 | |
85 | STEPConstruct_ContextTool ctx (modl); |
86 | |
87 | form->LoadValue (1, modl->StringLabel(ctx.GetAPD()) ); |
88 | |
89 | form->LoadValue (2, ctx.GetACstatus()); |
90 | form->LoadValue (3, ctx.GetACschemaName()); |
91 | form->LoadValue (4, new TCollection_HAsciiString(ctx.GetACyear()) ); |
92 | form->LoadValue (5, ctx.GetACname()); |
93 | |
94 | // form->LoadValue (6, modl->StringLabel(ctx.GetPRPC()) ); |
95 | |
96 | // form->LoadValue (7, ctx.GetPRPCName()); |
97 | // form->LoadValue (8, ctx.GetPRPCDescription()); |
98 | |
99 | return Standard_True; |
100 | } |
101 | |
102 | Standard_Boolean STEPEdit_EditContext::Apply |
103 | (const Handle(IFSelect_EditForm)& form, |
35e08fe8 |
104 | const Handle(Standard_Transient)& /*ent*/, |
7fd59977 |
105 | const Handle(Interface_InterfaceModel)& model) const |
106 | { |
107 | Handle(StepData_StepModel) modl = |
108 | Handle(StepData_StepModel)::DownCast(model); |
109 | if (modl.IsNull()) return Standard_False; |
110 | |
111 | STEPConstruct_ContextTool ctx (modl); |
112 | |
113 | ctx.AddAPD(); // on ne sait jamais |
114 | // ctx.AddPRPC(); |
115 | |
116 | if (form->IsModified(2)) ctx.SetACstatus (form->EditedValue(2)); |
117 | if (form->IsModified(3)) ctx.SetACschemaName (form->EditedValue(3)); |
118 | if (form->IsModified(4)) ctx.SetACyear(form->EditedValue(4)->IntegerValue()); |
119 | if (form->IsModified(5)) ctx.SetACname (form->EditedValue(5)); |
120 | |
121 | // if (form->IsModified(7)) ctx.SetPRPCName (form->EditedValue(7)); |
122 | // if (form->IsModified(8)) ctx.SetPRPCDescription (form->EditedValue(8)); |
123 | |
124 | return Standard_True; |
125 | } |