0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / IGESDraw / IGESDraw_ToolRectArraySubfigure.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 <gp_Pnt.hxx>
20 #include <gp_XYZ.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESEntity.hxx>
25 #include <IGESData_IGESReaderData.hxx>
26 #include <IGESData_IGESWriter.hxx>
27 #include <IGESData_ParamCursor.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESDraw_RectArraySubfigure.hxx>
30 #include <IGESDraw_ToolRectArraySubfigure.hxx>
31 #include <Interface_Check.hxx>
32 #include <Interface_CopyTool.hxx>
33 #include <Interface_EntityIterator.hxx>
34 #include <Interface_Macros.hxx>
35 #include <Interface_ShareTool.hxx>
36 #include <Message_Messenger.hxx>
37 #include <Standard_DomainError.hxx>
38 #include <TColStd_HArray1OfInteger.hxx>
39
40 IGESDraw_ToolRectArraySubfigure::IGESDraw_ToolRectArraySubfigure ()    {  }
41
42
43 void IGESDraw_ToolRectArraySubfigure::ReadOwnParams
44   (const Handle(IGESDraw_RectArraySubfigure)& ent,
45    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
46 {
47   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
48
49   gp_XYZ tempLowerLeftCorner;
50   Standard_Real tempScaleFactor;
51   Handle(IGESData_IGESEntity) tempBaseEntity;
52   Handle(TColStd_HArray1OfInteger) tempPositions;
53   Standard_Real tempColumnSeparation, tempRowSeparation, tempRotationAngle;
54   Standard_Integer tempNbColumns, tempNbRows, tempDoDontFlag, tempListCount;
55
56   PR.ReadEntity(IR, PR.Current(), "Base Entity", tempBaseEntity); //szv#4:S4163:12Mar99 `st=` not needed
57
58   if (PR.DefinedElseSkip())
59     PR.ReadReal(PR.Current(), "Scale Factor", tempScaleFactor); //szv#4:S4163:12Mar99 `st=` not needed
60   else
61     tempScaleFactor = 1.0;      // Setting to default value of 1.0
62
63   //szv#4:S4163:12Mar99 `st=` not needed
64   PR.ReadXYZ(PR.CurrentList(1, 3), "Lower Left Coordinate Of Array", tempLowerLeftCorner);
65   PR.ReadInteger(PR.Current(), "Number Of Columns", tempNbColumns);
66   PR.ReadInteger(PR.Current(), "Number Of Rows", tempNbRows);
67   PR.ReadReal(PR.Current(), "Horizontal Distance Between Columns", tempColumnSeparation);
68   PR.ReadReal(PR.Current(), "Vertical Distance Between Rows", tempRowSeparation);
69   PR.ReadReal(PR.Current(), "Rotation Angle", tempRotationAngle);
70
71   //st = PR.ReadInteger(PR.Current(), "DO-DONT List Count", tempListCount); //szv#4:S4163:12Mar99 moved in if
72   if (PR.ReadInteger(PR.Current(), "DO-DONT List Count", tempListCount)) {
73     // Initialise HArray1 only if there is no error reading its Length
74     if (tempListCount > 0)
75       tempPositions = new TColStd_HArray1OfInteger (1, tempListCount);
76     else if (tempListCount < 0)
77       PR.AddFail("DO-DONT List Count : Less than Zero");
78   }
79
80   PR.ReadInteger(PR.Current(), "DO-DONT Flag", tempDoDontFlag); //szv#4:S4163:12Mar99 `st=` not needed
81
82   // Read the HArray1 only if its Length was read without any Error
83   if (! tempPositions.IsNull()) {
84     Standard_Integer I;
85     for (I = 1; I <= tempListCount; I++) {
86       Standard_Integer tempPos;
87       //st = PR.ReadInteger(PR.Current(), "Number Of Position To Process",
88                             //tempPos); //szv#4:S4163:12Mar99 moved in if
89       if (PR.ReadInteger(PR.Current(), "Number Of Position To Process", tempPos))
90         tempPositions->SetValue(I, tempPos);
91     }
92   }
93
94   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
95   ent->Init
96     (tempBaseEntity, tempScaleFactor, tempLowerLeftCorner,
97      tempNbColumns, tempNbRows, tempColumnSeparation, tempRowSeparation,
98      tempRotationAngle, tempDoDontFlag, tempPositions);
99 }
100
101 void IGESDraw_ToolRectArraySubfigure::WriteOwnParams
102   (const Handle(IGESDraw_RectArraySubfigure)& ent, IGESData_IGESWriter& IW)  const
103 {
104   IW.Send(ent->BaseEntity());
105   IW.Send(ent->ScaleFactor());
106   IW.Send(ent->LowerLeftCorner().X());
107   IW.Send(ent->LowerLeftCorner().Y());
108   IW.Send(ent->LowerLeftCorner().Z());
109   IW.Send(ent->NbColumns());
110   IW.Send(ent->NbRows());
111   IW.Send(ent->ColumnSeparation());
112   IW.Send(ent->RowSeparation());
113   IW.Send(ent->RotationAngle());
114   IW.Send(ent->ListCount());
115   IW.SendBoolean(ent->DoDontFlag());
116   Standard_Integer I;
117   Standard_Integer up  = ent->ListCount();
118   for (I = 1; I <= up; I++)
119     IW.Send(ent->ListPosition(I));
120 }
121
122 void  IGESDraw_ToolRectArraySubfigure::OwnShared
123   (const Handle(IGESDraw_RectArraySubfigure)& ent, Interface_EntityIterator& iter) const
124 {
125   iter.GetOneItem(ent->BaseEntity());
126 }
127
128 void IGESDraw_ToolRectArraySubfigure::OwnCopy
129   (const Handle(IGESDraw_RectArraySubfigure)& another,
130    const Handle(IGESDraw_RectArraySubfigure)& ent, Interface_CopyTool& TC) const
131 {
132   DeclareAndCast(IGESData_IGESEntity, tempBaseEntity,
133                  TC.Transferred(another->BaseEntity()));
134   Standard_Real tempScaleFactor = another->ScaleFactor();
135   gp_XYZ tempLowerLeftCorner = (another->LowerLeftCorner()).XYZ();
136   Standard_Integer tempNbColumns = another->NbColumns();
137   Standard_Integer tempNbRows = another->NbRows();
138   Standard_Real tempColumnSeparation = another->ColumnSeparation();
139   Standard_Real tempRowSeparation = another->RowSeparation();
140   Standard_Real tempRotationAngle = another->RotationAngle();
141   Standard_Integer tempListCount = another->ListCount();
142   Standard_Integer tempDoDontFlag = (another->DoDontFlag() ? 1 : 0);
143   Handle(TColStd_HArray1OfInteger) tempPositions;
144   if (tempListCount != 0) {
145     tempPositions = new TColStd_HArray1OfInteger (1,tempListCount);
146     Standard_Integer I;
147     for (I = 1; I <= tempListCount; I++)
148       tempPositions->SetValue(I, another->ListPosition(I));
149   }
150
151   ent->Init(tempBaseEntity, tempScaleFactor, tempLowerLeftCorner,
152             tempNbColumns, tempNbRows, tempColumnSeparation, tempRowSeparation,
153             tempRotationAngle, tempDoDontFlag, tempPositions);
154 }
155
156 IGESData_DirChecker IGESDraw_ToolRectArraySubfigure::DirChecker
157   (const Handle(IGESDraw_RectArraySubfigure)& /*ent*/)  const
158 {
159   IGESData_DirChecker DC(412, 0);
160   DC.Structure(IGESData_DefVoid);
161   DC.LineFont(IGESData_DefAny);
162   DC.LineWeight(IGESData_DefValue);
163   DC.Color(IGESData_DefAny);
164   DC.GraphicsIgnored(1);
165
166   return DC;
167 }
168
169 void IGESDraw_ToolRectArraySubfigure::OwnCheck
170   (const Handle(IGESDraw_RectArraySubfigure)& /*ent*/,
171    const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/)  const
172 {
173 }
174
175 void IGESDraw_ToolRectArraySubfigure::OwnDump
176   (const Handle(IGESDraw_RectArraySubfigure)& ent, const IGESData_IGESDumper& dumper,
177    const Handle(Message_Messenger)& S, const Standard_Integer level)  const
178 {
179   Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1;
180
181   S << "IGESDraw_RectArraySubfigure" << endl;
182
183   S << "Base Entity : ";
184   dumper.Dump(ent->BaseEntity(),S, tempSubLevel);
185   S << endl;
186   S << "Scale Factor : " << ent->ScaleFactor() << "  ";
187   S << "Lower Left Corner Of Array : ";
188   IGESData_DumpXYZL(S,level, ent->LowerLeftCorner(),gp_GTrsf()); // no location
189   S << "Number Of Columns : " << ent->NbColumns()   << "  ";
190   S << "Number Of Rows    : " << ent->NbRows()      << endl;
191   S << "Horizontal Distance Between Columns : " << ent->ColumnSeparation()<<endl;
192   S << "Vertical Distance Between Rows      : " << ent->RowSeparation() <<endl;
193   S << "Rotation Angle (in radians)         : " << ent->RotationAngle() <<endl;
194   S << "Do-Dont Flag : ";
195   if (ent->DoDontFlag()) S << "(1)Dont  ";
196   else                   S << "(0)Do  ";
197   S << "Do-Dont List : ";
198   IGESData_DumpVals(S ,level,1, ent->ListCount(),ent->ListPosition);
199   S << endl;
200 }