1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15 
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18 
19 #include <IGESData_DirChecker.hxx>
20 #include <IGESData_IGESDumper.hxx>
21 #include <IGESData_IGESReaderData.hxx>
22 #include <IGESData_IGESWriter.hxx>
23 #include <IGESData_ParamCursor.hxx>
24 #include <IGESData_ParamReader.hxx>
25 #include <IGESGraph_Pick.hxx>
26 #include <IGESGraph_ToolPick.hxx>
27 #include <Interface_Check.hxx>
28 #include <Interface_CopyTool.hxx>
29 #include <Interface_EntityIterator.hxx>
30 #include <Interface_ShareTool.hxx>
31 #include <Message_Messenger.hxx>
32 #include <Standard_DomainError.hxx>
33 
IGESGraph_ToolPick()34 IGESGraph_ToolPick::IGESGraph_ToolPick ()    {  }
35 
36 
ReadOwnParams(const Handle (IGESGraph_Pick)& ent,const Handle (IGESData_IGESReaderData)&,IGESData_ParamReader & PR) const37 void IGESGraph_ToolPick::ReadOwnParams
38   (const Handle(IGESGraph_Pick)& ent,
39    const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
40 {
41   Standard_Integer nbPropertyValues;
42   Standard_Integer pickStatus;
43 
44   // Reading nbPropertyValues(Integer)
45   PR.ReadInteger(PR.Current(), "No. of property values", nbPropertyValues);
46   if (nbPropertyValues != 1)
47     PR.AddFail("No. of Property values : Value is not 1");
48 
49   if (PR.DefinedElseSkip())
50     // Reading pickStatus(Integer)
51     PR.ReadInteger( PR.Current(), "Pick Flag", pickStatus);
52   else
53     pickStatus = 0; // Default Value
54 
55   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
56   ent->Init(nbPropertyValues, pickStatus);
57 }
58 
WriteOwnParams(const Handle (IGESGraph_Pick)& ent,IGESData_IGESWriter & IW) const59 void IGESGraph_ToolPick::WriteOwnParams
60   (const Handle(IGESGraph_Pick)& ent, IGESData_IGESWriter& IW)  const
61 {
62   IW.Send( ent->NbPropertyValues() );
63   IW.Send( ent->PickFlag() );
64 }
65 
OwnShared(const Handle (IGESGraph_Pick)&,Interface_EntityIterator &) const66 void  IGESGraph_ToolPick::OwnShared
67   (const Handle(IGESGraph_Pick)& /*ent*/, Interface_EntityIterator& /*iter*/) const
68 {
69 }
70 
OwnCopy(const Handle (IGESGraph_Pick)& another,const Handle (IGESGraph_Pick)& ent,Interface_CopyTool &) const71 void IGESGraph_ToolPick::OwnCopy
72   (const Handle(IGESGraph_Pick)& another,
73    const Handle(IGESGraph_Pick)& ent, Interface_CopyTool& /*TC*/) const
74 {
75   ent->Init(1,another->PickFlag());
76 }
77 
OwnCorrect(const Handle (IGESGraph_Pick)& ent) const78 Standard_Boolean  IGESGraph_ToolPick::OwnCorrect
79   (const Handle(IGESGraph_Pick)& ent) const
80 {
81   Standard_Boolean res = (ent->NbPropertyValues() != 1);
82   if (res) ent->Init(1,ent->PickFlag());    // nbpropertyvalues=1
83   return res;
84 }
85 
DirChecker(const Handle (IGESGraph_Pick)&) const86 IGESData_DirChecker IGESGraph_ToolPick::DirChecker
87   (const Handle(IGESGraph_Pick)& /*ent*/)  const
88 {
89   IGESData_DirChecker DC (406, 21);
90   DC.Structure(IGESData_DefVoid);
91   DC.LineFont(IGESData_DefVoid);
92   DC.LineWeight(IGESData_DefVoid);
93   DC.Color(IGESData_DefVoid);
94   DC.BlankStatusIgnored();
95   DC.UseFlagIgnored();
96   DC.HierarchyStatusIgnored();
97   return DC;
98 }
99 
OwnCheck(const Handle (IGESGraph_Pick)& ent,const Interface_ShareTool &,Handle (Interface_Check)& ach) const100 void IGESGraph_ToolPick::OwnCheck
101   (const Handle(IGESGraph_Pick)& ent,
102    const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
103 {
104   if (ent->NbPropertyValues() != 1)
105     ach->AddFail("No. of Property values : Value != 1");
106   if ( (ent->PickFlag() != 0) && (ent->PickFlag() != 1) )
107     ach->AddFail("Pick Flag : Value != 0/1");
108 }
109 
OwnDump(const Handle (IGESGraph_Pick)& ent,const IGESData_IGESDumper &,Standard_OStream & S,const Standard_Integer) const110 void IGESGraph_ToolPick::OwnDump
111   (const Handle(IGESGraph_Pick)& ent, const IGESData_IGESDumper& /*dumper*/,
112    Standard_OStream& S, const Standard_Integer /*level*/)  const
113 {
114   S << "IGESGraph_Pick\n"
115     << "No. of property values : " << ent->NbPropertyValues() << "\n"
116     << "Pick flag : " << ent->PickFlag()
117     << (ent->PickFlag() == 0 ? " NO" : " YES" )
118     << std::endl;
119 }
120