1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <RWStepVisual_RWTextLiteral.hxx>
18 #include <StepData_StepReaderData.hxx>
19 #include <StepData_StepWriter.hxx>
20 #include <StepGeom_Axis2Placement.hxx>
21 #include <StepVisual_FontSelect.hxx>
22 #include <StepVisual_TextLiteral.hxx>
23 #include <StepVisual_TextPath.hxx>
24 #include <TCollection_AsciiString.hxx>
25
26 // --- Enum : TextPath ---
27 static TCollection_AsciiString tpUp(".UP.");
28 static TCollection_AsciiString tpRight(".RIGHT.");
29 static TCollection_AsciiString tpDown(".DOWN.");
30 static TCollection_AsciiString tpLeft(".LEFT.");
31
RWStepVisual_RWTextLiteral()32 RWStepVisual_RWTextLiteral::RWStepVisual_RWTextLiteral () {}
33
ReadStep(const Handle (StepData_StepReaderData)& data,const Standard_Integer num,Handle (Interface_Check)& ach,const Handle (StepVisual_TextLiteral)& ent) const34 void RWStepVisual_RWTextLiteral::ReadStep
35 (const Handle(StepData_StepReaderData)& data,
36 const Standard_Integer num,
37 Handle(Interface_Check)& ach,
38 const Handle(StepVisual_TextLiteral)& ent) const
39 {
40
41
42 // --- Number of Parameter Control ---
43
44 if (!data->CheckNbParams(num,6,ach,"text_literal has not 6 parameter(s)")) return;
45
46 // --- inherited field : name ---
47
48 Handle(TCollection_HAsciiString) aName;
49 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
50 data->ReadString (num,1,"name",ach,aName);
51
52 // --- own field : literal ---
53
54 Handle(TCollection_HAsciiString) aLiteral;
55 //szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
56 data->ReadString (num,2,"literal",ach,aLiteral);
57
58 // --- own field : placement ---
59
60 StepGeom_Axis2Placement aPlacement;
61 //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
62 data->ReadEntity(num,3,"placement",ach,aPlacement);
63
64 // --- own field : alignment ---
65
66 Handle(TCollection_HAsciiString) aAlignment;
67 //szv#4:S4163:12Mar99 `Standard_Boolean stat4 =` not needed
68 data->ReadString (num,4,"alignment",ach,aAlignment);
69
70 // --- own field : path ---
71
72 StepVisual_TextPath aPath = StepVisual_tpUp;
73 if (data->ParamType(num,5) == Interface_ParamEnum) {
74 Standard_CString text = data->ParamCValue(num,5);
75 if (tpUp.IsEqual(text)) aPath = StepVisual_tpUp;
76 else if (tpRight.IsEqual(text)) aPath = StepVisual_tpRight;
77 else if (tpDown.IsEqual(text)) aPath = StepVisual_tpDown;
78 else if (tpLeft.IsEqual(text)) aPath = StepVisual_tpLeft;
79 else ach->AddFail("Enumeration text_path has not an allowed value");
80 }
81 else ach->AddFail("Parameter #5 (path) is not an enumeration");
82
83 // --- own field : font ---
84
85 StepVisual_FontSelect aFont;
86 //szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed
87 data->ReadEntity(num,6,"font",ach,aFont);
88
89 //--- Initialisation of the read entity ---
90
91
92 ent->Init(aName, aLiteral, aPlacement, aAlignment, aPath, aFont);
93 }
94
95
WriteStep(StepData_StepWriter & SW,const Handle (StepVisual_TextLiteral)& ent) const96 void RWStepVisual_RWTextLiteral::WriteStep
97 (StepData_StepWriter& SW,
98 const Handle(StepVisual_TextLiteral)& ent) const
99 {
100
101 // --- inherited field name ---
102
103 SW.Send(ent->Name());
104
105 // --- own field : literal ---
106
107 SW.Send(ent->Literal());
108
109 // --- own field : placement ---
110
111 SW.Send(ent->Placement().Value());
112
113 // --- own field : alignment ---
114
115 SW.Send(ent->Alignment());
116
117 // --- own field : path ---
118
119 switch(ent->Path()) {
120 case StepVisual_tpUp : SW.SendEnum (tpUp); break;
121 case StepVisual_tpRight : SW.SendEnum (tpRight); break;
122 case StepVisual_tpDown : SW.SendEnum (tpDown); break;
123 case StepVisual_tpLeft : SW.SendEnum (tpLeft); break;
124 }
125
126 // --- own field : font ---
127
128 SW.Send(ent->Font().Value());
129 }
130
131
Share(const Handle (StepVisual_TextLiteral)& ent,Interface_EntityIterator & iter) const132 void RWStepVisual_RWTextLiteral::Share(const Handle(StepVisual_TextLiteral)& ent, Interface_EntityIterator& iter) const
133 {
134
135 iter.GetOneItem(ent->Placement().Value());
136
137
138 iter.GetOneItem(ent->Font().Value());
139 }
140
141