0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IGESDimen / IGESDimen_ToolDimensionUnits.cxx
CommitLineData
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 <IGESDimen_DimensionUnits.hxx>
27#include <IGESDimen_ToolDimensionUnits.hxx>
28#include <Interface_Check.hxx>
29#include <Interface_CopyTool.hxx>
30#include <Interface_EntityIterator.hxx>
7fd59977 31#include <Interface_Macros.hxx>
42cf5bc1 32#include <Interface_ShareTool.hxx>
33#include <Message_Messenger.hxx>
34#include <Standard_DomainError.hxx>
35#include <TCollection_HAsciiString.hxx>
7fd59977 36
37IGESDimen_ToolDimensionUnits::IGESDimen_ToolDimensionUnits () { }
38
39
40void IGESDimen_ToolDimensionUnits::ReadOwnParams
41 (const Handle(IGESDimen_DimensionUnits)& ent,
42 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
43{
44 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
45 Standard_Integer tempNbProps;
46 Standard_Integer tempSecondDimenPos;
47 Standard_Integer tempUnitsIndic;
48 Standard_Integer tempCharSet;
49 Standard_Integer tempFracFlag;
50 Standard_Integer tempPrecision;
51 Handle(TCollection_HAsciiString) tempFormatString;
52
53 if (PR.DefinedElseSkip())
54 PR.ReadInteger(PR.Current(), "Number of Properties", tempNbProps); //szv#4:S4163:12Mar99 `st=` not needed
55 else
56 tempNbProps = 6;
57
58 PR.ReadInteger(PR.Current(), "Secondary Dimension Position",
59 tempSecondDimenPos); //szv#4:S4163:12Mar99 `st=` not needed
60 PR.ReadInteger(PR.Current(), "Units Indicator", tempUnitsIndic); //szv#4:S4163:12Mar99 `st=` not needed
61 if (PR.DefinedElseSkip())
62 PR.ReadInteger(PR.Current(), "Character Set", tempCharSet); //szv#4:S4163:12Mar99 `st=` not needed
63 else
64 tempCharSet = 1;
65
66 PR.ReadText(PR.Current(), "Format String", tempFormatString); //szv#4:S4163:12Mar99 `st=` not needed
67 PR.ReadInteger(PR.Current(), "Fraction Flag", tempFracFlag); //szv#4:S4163:12Mar99 `st=` not needed
68 PR.ReadInteger(PR.Current(), "Precision", tempPrecision); //szv#4:S4163:12Mar99 `st=` not needed
69
70 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
71 ent->Init
72 (tempNbProps, tempSecondDimenPos, tempUnitsIndic, tempCharSet,
73 tempFormatString, tempFracFlag, tempPrecision);
74}
75
76void IGESDimen_ToolDimensionUnits::WriteOwnParams
77 (const Handle(IGESDimen_DimensionUnits)& ent, IGESData_IGESWriter& IW) const
78{
79 IW.Send(ent->NbPropertyValues());
80 IW.Send(ent->SecondaryDimenPosition());
81 IW.Send(ent->UnitsIndicator());
82 IW.Send(ent->CharacterSet());
83 IW.Send(ent->FormatString());
84 IW.Send(ent->FractionFlag());
85 IW.Send(ent->PrecisionOrDenominator());
86}
87
88void IGESDimen_ToolDimensionUnits::OwnShared
89 (const Handle(IGESDimen_DimensionUnits)& /* ent */, Interface_EntityIterator& /* iter */) const
90{
91}
92
93void IGESDimen_ToolDimensionUnits::OwnCopy
94 (const Handle(IGESDimen_DimensionUnits)& another,
95 const Handle(IGESDimen_DimensionUnits)& ent, Interface_CopyTool& /* TC */) const
96{
97 Standard_Integer tempNbProps = another->NbPropertyValues();
98 Standard_Integer tempSecondDimenPos = another->SecondaryDimenPosition();
99 Standard_Integer tempUnitsIndic = another->UnitsIndicator();
100 Standard_Integer tempCharSet = another->CharacterSet();
101 Handle(TCollection_HAsciiString) tempFormatString =
102 new TCollection_HAsciiString(another->FormatString());
103 Standard_Integer tempFracFlag = another->FractionFlag();
104 Standard_Integer tempPrecision = another->PrecisionOrDenominator();
105 ent->Init (tempNbProps, tempSecondDimenPos, tempUnitsIndic, tempCharSet,
106 tempFormatString, tempFracFlag, tempPrecision);
107}
108
109Standard_Boolean IGESDimen_ToolDimensionUnits::OwnCorrect
110 (const Handle(IGESDimen_DimensionUnits)& ent) const
111{
112 Standard_Boolean res = (ent->NbPropertyValues() != 6);
113 if (res) ent->Init
114 (6,ent->SecondaryDimenPosition(),ent->UnitsIndicator(),ent->CharacterSet(),
115 ent->FormatString(),ent->FractionFlag(),ent->PrecisionOrDenominator());
116 return res; // nbpropertyvalues = 6
117}
118
119IGESData_DirChecker IGESDimen_ToolDimensionUnits::DirChecker
120 (const Handle(IGESDimen_DimensionUnits)& /* ent */) const
121{
122 IGESData_DirChecker DC(406, 28);
123 DC.Structure(IGESData_DefVoid);
124 DC.GraphicsIgnored();
125 DC.LineFont(IGESData_DefVoid);
126 DC.LineWeight(IGESData_DefVoid);
127 DC.Color(IGESData_DefVoid);
128 DC.BlankStatusIgnored();
129 DC.SubordinateStatusRequired(2);
130 DC.UseFlagRequired(2);
131 DC.HierarchyStatusIgnored();
132 return DC;
133}
134
135void IGESDimen_ToolDimensionUnits::OwnCheck
136 (const Handle(IGESDimen_DimensionUnits)& ent,
137 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
138{
139 if (ent->NbPropertyValues() != 6)
140 ach->AddFail("Number of properties != 6");
141 if (ent->SecondaryDimenPosition() < 0 || ent->SecondaryDimenPosition() > 4)
142 ach->AddFail("Secondary Dimension Position != 0-4");
143 if ( (ent->CharacterSet() != 1) &&
144 ((ent->CharacterSet() < 1001) || (ent->CharacterSet() > 1003)) )
145 ach->AddFail("Character Set != 1,1001-1003");
146 if ((ent->FractionFlag() != 0) && (ent->FractionFlag() != 1))
147 ach->AddFail("Fraction Flag != 0,1");
148}
149
150void IGESDimen_ToolDimensionUnits::OwnDump
151 (const Handle(IGESDimen_DimensionUnits)& ent, const IGESData_IGESDumper& /* dumper */,
0ebe5b0a 152 Standard_OStream& S, const Standard_Integer /* level */) const
7fd59977 153{
0ebe5b0a 154 S << "IGESDimen_DimensionUnits\n"
155 << "Number of property values : " << ent->NbPropertyValues() << "\n"
156 << "Secondary Dimension Position : " << ent->SecondaryDimenPosition() << "\n"
157 << "Units Indicator : " << ent->UnitsIndicator() << "\n"
158 << "Character Set : " << ent->CharacterSet() << "\n"
159 << "Format String : ";
7fd59977 160 IGESData_DumpString(S,ent->FormatString());
0ebe5b0a 161 S << "\n"
162 << "Fraction Flag : " << ent->FractionFlag();
7fd59977 163 if (ent->FractionFlag() == 0) S << " Decimal , Precision : ";
164 else S << " Fraction , Denominator : ";
0ebe5b0a 165 S << ent->PrecisionOrDenominator() << std::endl;
7fd59977 166}