Warnings on vc14 were eliminated
[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
42cf5bc1 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>
c04c30b3 20#include <StepBasic_ApplicationProtocolDefinition.hxx>
42cf5bc1 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>
7fd59977 26
92efcf78 27IMPLEMENT_STANDARD_RTTIEXT(STEPEdit_EditContext,IFSelect_Editor)
28
7fd59977 29STEPEdit_EditContext::STEPEdit_EditContext ()
30: IFSelect_Editor (5)
31{
32 Handle(Interface_TypedValue) ac_val = new Interface_TypedValue("Application Context",Interface_ParamIdent);
33 SetValue(1,ac_val,"AC",IFSelect_EditRead);
34
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");
43
44// Handle(Interface_TypedValue) prpc_val = new Interface_TypedValue("Product Related Product Category",Interface_ParamIdent);
45// SetValue(6,ac_val,"PRPC",IFSelect_EditRead);
46
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");
51}
52
53TCollection_AsciiString STEPEdit_EditContext::Label () const
54{ return TCollection_AsciiString ("STEP : Product Definition Context"); }
55
56Standard_Boolean STEPEdit_EditContext::Recognize
35e08fe8 57(const Handle(IFSelect_EditForm)& /*form*/) const
7fd59977 58{
59// il faut 17 parametres
60 return Standard_True;
61}
62
63Handle(TCollection_HAsciiString) STEPEdit_EditContext::StringValue
35e08fe8 64(const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const
7fd59977 65{
66 Handle(TCollection_HAsciiString) str;
67 switch (num) {
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");
74 default : break;
75 }
76 return str;
77}
78
79Standard_Boolean STEPEdit_EditContext::Load
80(const Handle(IFSelect_EditForm)& form,
35e08fe8 81 const Handle(Standard_Transient)& /*ent*/,
7fd59977 82 const Handle(Interface_InterfaceModel)& model) const
83{
84 Handle(StepData_StepModel) modl =
85 Handle(StepData_StepModel)::DownCast(model);
86 if (modl.IsNull()) return Standard_False;
87
88 STEPConstruct_ContextTool ctx (modl);
89
90 form->LoadValue (1, modl->StringLabel(ctx.GetAPD()) );
91
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());
96
97// form->LoadValue (6, modl->StringLabel(ctx.GetPRPC()) );
98
99// form->LoadValue (7, ctx.GetPRPCName());
100// form->LoadValue (8, ctx.GetPRPCDescription());
101
102 return Standard_True;
103}
104
105Standard_Boolean STEPEdit_EditContext::Apply
106(const Handle(IFSelect_EditForm)& form,
35e08fe8 107 const Handle(Standard_Transient)& /*ent*/,
7fd59977 108 const Handle(Interface_InterfaceModel)& model) const
109{
110 Handle(StepData_StepModel) modl =
111 Handle(StepData_StepModel)::DownCast(model);
112 if (modl.IsNull()) return Standard_False;
113
114 STEPConstruct_ContextTool ctx (modl);
115
116 ctx.AddAPD(); // on ne sait jamais
117// ctx.AddPRPC();
118
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));
123
124// if (form->IsModified(7)) ctx.SetPRPCName (form->EditedValue(7));
125// if (form->IsModified(8)) ctx.SetPRPCDescription (form->EditedValue(8));
126
127 return Standard_True;
128}