b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
19 | #include <IGESData_DirChecker.hxx> |
20 | #include <IGESData_Dump.hxx> |
21 | #include <IGESData_IGESDumper.hxx> |
22 | #include <IGESData_IGESReaderData.hxx> |
23 | #include <IGESData_IGESWriter.hxx> |
7fd59977 |
24 | #include <IGESData_ParamCursor.hxx> |
42cf5bc1 |
25 | #include <IGESData_ParamReader.hxx> |
26 | #include <IGESGraph_LineFontDefPattern.hxx> |
27 | #include <IGESGraph_ToolLineFontDefPattern.hxx> |
28 | #include <Interface_Check.hxx> |
29 | #include <Interface_CopyTool.hxx> |
30 | #include <Interface_EntityIterator.hxx> |
31 | #include <Interface_Macros.hxx> |
32 | #include <Interface_ShareTool.hxx> |
33 | #include <Message_Messenger.hxx> |
34 | #include <Standard_DomainError.hxx> |
7fd59977 |
35 | #include <TCollection_HAsciiString.hxx> |
36 | #include <TColStd_HArray1OfReal.hxx> |
7fd59977 |
37 | |
38 | IGESGraph_ToolLineFontDefPattern::IGESGraph_ToolLineFontDefPattern () { } |
39 | |
40 | |
41 | void IGESGraph_ToolLineFontDefPattern::ReadOwnParams |
42 | (const Handle(IGESGraph_LineFontDefPattern)& ent, |
43 | const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const |
44 | { |
45 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
46 | |
47 | Standard_Integer tempNbSeg; |
48 | Handle(TCollection_HAsciiString) tempDisplayPattern; |
49 | Handle(TColStd_HArray1OfReal) tempSegmentLengths; |
50 | |
51 | if (PR.ReadInteger(PR.Current(), "Number of Visible-Blank Segments", tempNbSeg)) { //szv#4:S4163:12Mar99 `st=` not needed |
52 | // Initialise HArray1 only if there is no error reading its Length |
53 | if (tempNbSeg <= 0) PR.AddFail("Number of Visible-Blank Segments : Not Positive"); |
54 | else tempSegmentLengths = new TColStd_HArray1OfReal(1, tempNbSeg); |
55 | } |
56 | |
57 | // Read the HArray1 only if its Length was read without any Error |
58 | if (! tempSegmentLengths.IsNull()) { |
59 | Standard_Integer I; |
60 | for (I = 1; I <= tempNbSeg; I++) { |
61 | Standard_Real tempReal; |
62 | if (PR.ReadReal(PR.Current(), "Length of Segment", tempReal)) //szv#4:S4163:12Mar99 `st=` not needed |
63 | tempSegmentLengths->SetValue(I, tempReal); |
64 | } |
65 | } |
66 | |
67 | PR.ReadText(PR.Current(), "Visible-Blank Display Pattern", tempDisplayPattern); //szv#4:S4163:12Mar99 `st=` not needed |
68 | |
69 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
70 | ent->Init(tempSegmentLengths, tempDisplayPattern); |
71 | } |
72 | |
73 | void IGESGraph_ToolLineFontDefPattern::WriteOwnParams |
74 | (const Handle(IGESGraph_LineFontDefPattern)& ent, IGESData_IGESWriter& IW) const |
75 | { |
76 | Standard_Integer up = ent->NbSegments(); |
77 | IW.Send(up); |
78 | Standard_Integer I; |
79 | for (I = 1; I <= up; I++) |
80 | IW.Send(ent->Length(I)); |
81 | IW.Send(ent->DisplayPattern()); |
82 | } |
83 | |
84 | void IGESGraph_ToolLineFontDefPattern::OwnShared |
85 | (const Handle(IGESGraph_LineFontDefPattern)& /*ent*/, Interface_EntityIterator& /*iter*/) const |
86 | { |
87 | } |
88 | |
89 | void IGESGraph_ToolLineFontDefPattern::OwnCopy |
90 | (const Handle(IGESGraph_LineFontDefPattern)& another, |
91 | const Handle(IGESGraph_LineFontDefPattern)& ent, Interface_CopyTool& /*TC*/) const |
92 | { |
93 | Handle(TColStd_HArray1OfReal) tempSegmentLengths = |
94 | new TColStd_HArray1OfReal(1, another->NbSegments()); |
95 | Standard_Integer I; |
96 | Standard_Integer up = another->NbSegments(); |
97 | for (I = 1; I <= up; I++) |
98 | tempSegmentLengths->SetValue(I, another->Length(I)); |
99 | Handle(TCollection_HAsciiString) tempDisplayPattern = |
100 | new TCollection_HAsciiString(another->DisplayPattern()); |
101 | |
102 | ent->Init(tempSegmentLengths, tempDisplayPattern); |
103 | } |
104 | |
105 | IGESData_DirChecker IGESGraph_ToolLineFontDefPattern::DirChecker |
106 | (const Handle(IGESGraph_LineFontDefPattern)& /*ent*/) const |
107 | { |
108 | IGESData_DirChecker DC(304, 2); |
109 | DC.Structure(IGESData_DefVoid); |
110 | DC.LineFont(IGESData_DefValue); |
111 | DC.LineWeight(IGESData_DefVoid); |
112 | DC.Color(IGESData_DefVoid); |
113 | DC.BlankStatusIgnored(); |
114 | DC.SubordinateStatusRequired(0); |
115 | DC.UseFlagRequired(2); |
116 | DC.HierarchyStatusIgnored(); |
117 | |
118 | return DC; |
119 | } |
120 | |
121 | void IGESGraph_ToolLineFontDefPattern::OwnCheck |
122 | (const Handle(IGESGraph_LineFontDefPattern)& ent, |
123 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
124 | { |
125 | if (ent->RankLineFont() == 0) |
126 | ach->AddWarning("Line Font Rank is zero"); |
127 | else if (ent->RankLineFont() < 1 || ent->RankLineFont() > 5) |
128 | ach->AddWarning("Invalid Value As Line Font Rank(Valid Range 1 to 5)"); |
129 | } |
130 | |
131 | void IGESGraph_ToolLineFontDefPattern::OwnDump |
132 | (const Handle(IGESGraph_LineFontDefPattern)& ent, const IGESData_IGESDumper& /*dumper*/, |
133 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
134 | { |
135 | S << "IGESGraph_LineFontDefPattern" << endl; |
136 | |
137 | S << "Visible-Blank Segments : "; |
138 | Standard_Integer nb = ent->NbSegments(); |
139 | IGESData_DumpVals(S ,level,1, nb,ent->Length); |
140 | S <<endl << "Display Pattern : "; |
141 | IGESData_DumpString(S,ent->DisplayPattern()); |
142 | S << endl; |
143 | if (level > 4) { |
144 | S << " -> Which Segments are Visible (the others are Blank) : " << endl; |
145 | for (Standard_Integer I = 1; I <= nb; I ++) { |
146 | if (ent->IsVisible(I)) S << " " << I; |
147 | } |
148 | S << endl; |
149 | } |
150 | } |