0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / STEPEdit / STEPEdit_EditSDR.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>
20#include <STEPConstruct_Part.hxx>
7fd59977 21#include <StepData_StepModel.hxx>
42cf5bc1 22#include <STEPEdit_EditSDR.hxx>
7fd59977 23#include <StepShape_ShapeDefinitionRepresentation.hxx>
42cf5bc1 24#include <TCollection_AsciiString.hxx>
25#include <TCollection_HAsciiString.hxx>
7fd59977 26
27STEPEdit_EditSDR::STEPEdit_EditSDR ()
28: IFSelect_Editor (11)
29{
30 Handle(Interface_TypedValue) pdc_name = new Interface_TypedValue("PDC_Name");
31 SetValue (1,pdc_name,"PDC_Name");
32 Handle(Interface_TypedValue) pdc_lfs = new Interface_TypedValue("PDC_LifeCycleStage");
33 SetValue(2,pdc_lfs,"PDC_Stage");
34 Handle(Interface_TypedValue) pdc_descr = new Interface_TypedValue("PDC_Description");
35 SetValue(3,pdc_descr,"PDC_Descr");
36
37 Handle(Interface_TypedValue) pv_vid = new Interface_TypedValue("P_Version_Id");
38 SetValue(4,pv_vid,"PV_Id");
39 Handle(Interface_TypedValue) pv_descr = new Interface_TypedValue("P_Version_Description");
40 SetValue(5,pv_descr,"PV_Descr");
41
42 Handle(Interface_TypedValue) pid = new Interface_TypedValue("Product_Id");
43 SetValue(6,pid,"P_Id");
44 Handle(Interface_TypedValue) pname = new Interface_TypedValue("Product_Name");
45 SetValue(7,pname,"P_Name");
46 Handle(Interface_TypedValue) pdescr = new Interface_TypedValue("Product_Description");
47 SetValue(8,pdescr,"P_Descr");
48
49 Handle(Interface_TypedValue) pc_name = new Interface_TypedValue("P_Context_Name");
50 SetValue(9,pc_name,"PC_Name");
51 Handle(Interface_TypedValue) pc_disc = new Interface_TypedValue("P_Context_Discipline");
52 SetValue(10,pc_disc,"PC_Disc");
53
54 Handle(Interface_TypedValue) ac_ap = new Interface_TypedValue("Application");
55 SetValue(11,ac_ap,"Appli");
56
57
58// ?? :
59//Handle(TCollection_HAsciiString) StepPDR_SDRtool::PDSname() const
60//Handle(TCollection_HAsciiString) StepPDR_SDRtool::PDSdescription() const
61//Handle(TCollection_HAsciiString) StepPDR_SDRtool::PDdescription() const
62
63}
64
65TCollection_AsciiString STEPEdit_EditSDR::Label () const
66{ return TCollection_AsciiString ("STEP : Product Data (SDR)"); }
67
68Standard_Boolean STEPEdit_EditSDR::Recognize
35e08fe8 69(const Handle(IFSelect_EditForm)& /*form*/) const
7fd59977 70{
71// il faut 10 parametres
72 return Standard_True;
73}
74
75Handle(TCollection_HAsciiString) STEPEdit_EditSDR::StringValue
35e08fe8 76(const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer num) const
7fd59977 77{
78 Handle(TCollection_HAsciiString) str;
79 switch (num) {
80 case 1 : return new TCollection_HAsciiString("as proposed");
81 case 2 : return new TCollection_HAsciiString("First_Design");
82 case 3 : return new TCollection_HAsciiString("void");
83 case 4 : return new TCollection_HAsciiString("ID");
84 case 5 : return new TCollection_HAsciiString("void");
85 case 8 : return new TCollection_HAsciiString("void");
86 case 9 : return new TCollection_HAsciiString("Mechanical");
87 case 10 : return new TCollection_HAsciiString("Assembly");
88 case 11 : return new TCollection_HAsciiString("EUCLID");
89 default : break;
90 }
91 return str;
92}
93
94Standard_Boolean STEPEdit_EditSDR::Load
95(const Handle(IFSelect_EditForm)& form,
96 const Handle(Standard_Transient)& ent,
97 const Handle(Interface_InterfaceModel)& model) const
98{
99 Handle(StepShape_ShapeDefinitionRepresentation) sdr =
100 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast (ent);
101 Handle(StepData_StepModel) modl =
102 Handle(StepData_StepModel)::DownCast(model);
103 if (sdr.IsNull() || modl.IsNull()) return Standard_False;
104
105 STEPConstruct_Part ctx;
106 ctx.ReadSDR (sdr);
107
108 form->LoadValue (1, ctx.PDCname());
109 form->LoadValue (2, ctx.PDCstage());
110 form->LoadValue (3, ctx.PDdescription());
111
112 form->LoadValue (4, ctx.PDFid());
113 form->LoadValue (5, ctx.PDFdescription());
114
115 form->LoadValue (6, ctx.Pid());
116 form->LoadValue (7, ctx.Pname());
117 form->LoadValue (8, ctx.Pdescription());
118
119 form->LoadValue (9, ctx.PCname());
120 form->LoadValue (10, ctx.PCdisciplineType());
121
122 form->LoadValue (11, ctx.ACapplication());
123
124 return Standard_True;
125}
126
127Standard_Boolean STEPEdit_EditSDR::Apply
128(const Handle(IFSelect_EditForm)& form,
129 const Handle(Standard_Transient)& ent,
130 const Handle(Interface_InterfaceModel)& model) const
131{
132 Handle(StepShape_ShapeDefinitionRepresentation) sdr =
133 Handle(StepShape_ShapeDefinitionRepresentation)::DownCast (ent);
134 Handle(StepData_StepModel) modl =
135 Handle(StepData_StepModel)::DownCast(model);
136 if (sdr.IsNull() || modl.IsNull()) return Standard_False;
137
138 STEPConstruct_Part ctx;
139 ctx.ReadSDR (sdr);
140
141 if (form->IsModified(1)) ctx.SetPDCname (form->EditedValue(1));
142 if (form->IsModified(2)) ctx.SetPDCstage (form->EditedValue(2));
143 if (form->IsModified(3)) ctx.SetPDdescription (form->EditedValue(3));
144
145 if (form->IsModified(4)) ctx.SetPDFid (form->EditedValue(4));
146 if (form->IsModified(5)) ctx.SetPDFdescription (form->EditedValue(5));
147
148 if (form->IsModified(6)) ctx.SetPid (form->EditedValue(6));
149 if (form->IsModified(7)) ctx.SetPname (form->EditedValue(7));
150 if (form->IsModified(8)) ctx.SetPdescription (form->EditedValue(8));
151
152 if (form->IsModified(9)) ctx.SetPCname (form->EditedValue(9));
153 if (form->IsModified(10)) ctx.SetPCdisciplineType (form->EditedValue(10));
154
155 if (form->IsModified(11)) ctx.SetACapplication (form->EditedValue(11));
156
157 return Standard_True;
158}