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