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