0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / IGESGraph / IGESGraph_ToolLineFontDefTemplate.cxx
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 <IGESBasic_SubfigureDef.hxx>
20 #include <IGESData_DirChecker.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_ParamCursor.hxx>
25 #include <IGESData_ParamReader.hxx>
26 #include <IGESGraph_LineFontDefTemplate.hxx>
27 #include <IGESGraph_ToolLineFontDefTemplate.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>
35
36 IGESGraph_ToolLineFontDefTemplate::IGESGraph_ToolLineFontDefTemplate ()    {  }
37
38
39 void IGESGraph_ToolLineFontDefTemplate::ReadOwnParams
40   (const Handle(IGESGraph_LineFontDefTemplate)& ent,
41    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
42 {
43   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
44
45   Standard_Integer tempOrientation;
46   Standard_Real    tempDistance, tempScale;
47   Handle(IGESBasic_SubfigureDef) tempTemplateEntity;
48
49   PR.ReadInteger(PR.Current(), "Template Orientation", tempOrientation); //szv#4:S4163:12Mar99 `st=` not needed
50
51   PR.ReadEntity(IR, PR.Current(),
52                 "Subfigure Definition Entity for Template Display",
53                 STANDARD_TYPE(IGESBasic_SubfigureDef), tempTemplateEntity); //szv#4:S4163:12Mar99 `st=` not needed
54
55   PR.ReadReal(PR.Current(), "Distance between successive Template",
56               tempDistance); //szv#4:S4163:12Mar99 `st=` not needed
57
58   PR.ReadReal(PR.Current(), "Scale Factor For Subfigure", tempScale); //szv#4:S4163:12Mar99 `st=` not needed
59
60   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
61   ent->Init (tempOrientation, tempTemplateEntity, tempDistance, tempScale);
62 }
63
64 void IGESGraph_ToolLineFontDefTemplate::WriteOwnParams
65   (const Handle(IGESGraph_LineFontDefTemplate)& ent, IGESData_IGESWriter& IW)  const
66 {
67   IW.Send(ent->Orientation());
68   IW.Send(ent->TemplateEntity());
69   IW.Send(ent->Distance());
70   IW.Send(ent->Scale());
71 }
72
73 void  IGESGraph_ToolLineFontDefTemplate::OwnShared
74   (const Handle(IGESGraph_LineFontDefTemplate)& ent, Interface_EntityIterator& iter) const
75 {
76   iter.GetOneItem(ent->TemplateEntity());
77 }
78
79 void IGESGraph_ToolLineFontDefTemplate::OwnCopy
80   (const Handle(IGESGraph_LineFontDefTemplate)& another,
81    const Handle(IGESGraph_LineFontDefTemplate)& ent, Interface_CopyTool& TC) const
82 {
83   Standard_Integer tempOrientation = another->Orientation();
84   DeclareAndCast(IGESBasic_SubfigureDef, tempTemplateSubfigure,
85                  TC.Transferred(another->TemplateEntity()));
86   Standard_Real tempDistance = another->Distance();
87   Standard_Real tempScale = another->Scale();
88
89   ent->Init(tempOrientation, tempTemplateSubfigure, tempDistance, tempScale);
90 }
91
92 IGESData_DirChecker IGESGraph_ToolLineFontDefTemplate::DirChecker
93   (const Handle(IGESGraph_LineFontDefTemplate)& /*ent*/)  const
94 {
95   IGESData_DirChecker DC(304, 1);
96   DC.Structure(IGESData_DefVoid);
97   DC.LineFont(IGESData_DefValue);
98   DC.LineWeight(IGESData_DefVoid);
99   DC.Color(IGESData_DefVoid);
100   DC.BlankStatusIgnored();
101   DC.SubordinateStatusRequired(0);
102   DC.UseFlagRequired(2);
103   DC.HierarchyStatusIgnored();
104
105   return DC;
106 }
107
108 void IGESGraph_ToolLineFontDefTemplate::OwnCheck
109   (const Handle(IGESGraph_LineFontDefTemplate)& ent,
110    const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
111 {
112   if (ent->RankLineFont() == 0)
113     ach->AddWarning("Line Font Rank is zero");
114   else if ((ent->RankLineFont() < 1) || (ent->RankLineFont() > 5))
115     ach->AddWarning("Invalid Value As Line Font Rank");
116 }
117
118 void IGESGraph_ToolLineFontDefTemplate::OwnDump
119   (const Handle(IGESGraph_LineFontDefTemplate)& ent, const IGESData_IGESDumper& dumper,
120   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
121 {
122   Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
123
124   S << "IGESGraph_LineFontDefTemplate" << endl;
125
126   S << "Orientation : " << ent->Orientation() << endl;
127   S << "Subfigure Display Entity For Template Display : ";
128   dumper.Dump(ent->TemplateEntity(),S, tempSubLevel);
129   S << endl;
130   S << "Length Between Successive Template Figure : " << ent->Distance()<<endl;
131   S << "Scale Factor for Subfigure : " << ent->Scale() << endl;
132   S << endl;
133 }
134