summaryrefslogtreecommitdiff
path: root/src/IGESDraw/IGESDraw_ToolLabelDisplay.cxx
blob: 59abe396f866efe4fa3beb2bf6d33b535e3f0c87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//--------------------------------------------------------------------
//
//  File Name : IGESDraw_LabelDisplay.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDraw_ToolLabelDisplay.ixx>
#include <IGESData_ParamCursor.hxx>
#include <gp_XYZ.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_ViewKindEntity.hxx>
#include <IGESDimen_LeaderArrow.hxx>
#include <IGESDraw_HArray1OfViewKindEntity.hxx>
#include <TColgp_HArray1OfXYZ.hxx>
#include <IGESDimen_HArray1OfLeaderArrow.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <IGESData_Dump.hxx>
#include <IGESDraw_View.hxx>
#include <IGESDraw_PerspectiveView.hxx>
#include <Interface_Macros.hxx>


IGESDraw_ToolLabelDisplay::IGESDraw_ToolLabelDisplay ()    {  }


void IGESDraw_ToolLabelDisplay::ReadOwnParams
  (const Handle(IGESDraw_LabelDisplay)& ent,
   const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{ 
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
  Standard_Integer nbval;

  Handle(IGESDraw_HArray1OfViewKindEntity) views; 
  Handle(TColgp_HArray1OfXYZ)                   textLocations; 
  Handle(IGESDimen_HArray1OfLeaderArrow)    leaderEntities; 
  Handle(TColStd_HArray1OfInteger)       labelLevels;
  Handle(IGESData_HArray1OfIGESEntity)     displayedEntities; 

  // Reading nbval(No. of Label placements)
  Standard_Boolean st = PR.ReadInteger(PR.Current(), "No. of Label placements", nbval);
  if (st && nbval > 0)
    {
      views             = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
      textLocations     = new TColgp_HArray1OfXYZ(1, nbval);
      leaderEntities    = new IGESDimen_HArray1OfLeaderArrow(1, nbval);
      labelLevels       = new TColStd_HArray1OfInteger(1, nbval);
      displayedEntities = new IGESData_HArray1OfIGESEntity(1, nbval);
      
      Handle(IGESData_ViewKindEntity) tempView;
      gp_XYZ                          tempXYZ;
      Handle(IGESDimen_LeaderArrow)   tempLeaderArrow;
      Standard_Integer                tempLabel;
      Handle(IGESData_IGESEntity)     tempDisplayedEntity;
      
      for (Standard_Integer i = 1; i <= nbval; i++)
	{
          // Reading views(HArray1OfView)
          //st = PR.ReadEntity (IR, PR.Current(), "Instance of views",
				//STANDARD_TYPE(IGESData_ViewKindEntity), tempView); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadEntity (IR, PR.Current(), "Instance of views",
			     STANDARD_TYPE(IGESData_ViewKindEntity), tempView))
	    views->SetValue(i, tempView);
	  
          // Reading textLocations(HArray1OfXYZ)
          //st = PR.ReadXYZ(PR.CurrentList(1, 3), "array textLocations", tempXYZ); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadXYZ(PR.CurrentList(1, 3), "array textLocations", tempXYZ))
	    textLocations->SetValue(i, tempXYZ);

          // Reading leaderEntities(HArray1OfLeaderArrow)
          //st = PR.ReadEntity (IR, PR.Current(), "Instance of LeaderArrow",
				//STANDARD_TYPE(IGESDimen_LeaderArrow), tempLeaderArrow); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadEntity (IR, PR.Current(), "Instance of LeaderArrow",
			     STANDARD_TYPE(IGESDimen_LeaderArrow), tempLeaderArrow))
	    leaderEntities->SetValue(i, tempLeaderArrow);
	  
          // Reading labelLevels(HArray1OfInteger)
          //st = PR.ReadInteger(PR.Current(), "array labelLevels", tempLabel); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadInteger(PR.Current(), "array labelLevels", tempLabel))
	    labelLevels->SetValue(i, tempLabel);
	  
          // Reading displayedEntities(HArray1OfIGESEntity)
          //st = PR.ReadEntity (IR, PR.Current(), "displayedEntities entity",
				//tempDisplayedEntity); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadEntity (IR, PR.Current(), "displayedEntities entity", tempDisplayedEntity))
	    displayedEntities->SetValue(i, tempDisplayedEntity);
	}
    }
  else  PR.AddFail("No. of Label placements : Not Positive");

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init
    (views, textLocations, leaderEntities, labelLevels, displayedEntities);
}

void IGESDraw_ToolLabelDisplay::WriteOwnParams
  (const Handle(IGESDraw_LabelDisplay)& ent, IGESData_IGESWriter& IW)  const
{
  Standard_Integer Up  = ent->NbLabels();
  IW.Send( Up );
  for ( Standard_Integer i = 1; i <= Up; i++)
    {
      IW.Send( ent->ViewItem(i) );
      IW.Send( (ent->TextLocation(i)).X() );
      IW.Send( (ent->TextLocation(i)).Y() );
      IW.Send( (ent->TextLocation(i)).Z() );
      IW.Send( ent->LeaderEntity(i) );
      IW.Send( ent->LabelLevel(i) );
      IW.Send( ent->DisplayedEntity(i) );
    }
}

void  IGESDraw_ToolLabelDisplay::OwnShared
  (const Handle(IGESDraw_LabelDisplay)& ent, Interface_EntityIterator& iter) const
{
  Standard_Integer Up  = ent->NbLabels();
  for ( Standard_Integer i = 1; i <= Up; i++)
    {
      iter.GetOneItem( ent->ViewItem(i) );
      iter.GetOneItem( ent->LeaderEntity(i) );
      iter.GetOneItem( ent->DisplayedEntity(i) );
    }
}

void IGESDraw_ToolLabelDisplay::OwnCopy
  (const Handle(IGESDraw_LabelDisplay)& another,
   const Handle(IGESDraw_LabelDisplay)& ent, Interface_CopyTool& TC) const
{
  Standard_Integer                              nbval;
  Handle(IGESDraw_HArray1OfViewKindEntity) views;
  Handle(TColgp_HArray1OfXYZ)                   textLocations;
  Handle(IGESDimen_HArray1OfLeaderArrow)    leaderEntities;
  Handle(TColStd_HArray1OfInteger)       labelLevels;
  Handle(IGESData_HArray1OfIGESEntity)     displayedEntities;
 
  nbval             = another->NbLabels();
  views             = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
  textLocations     = new TColgp_HArray1OfXYZ(1, nbval);
  leaderEntities    = new IGESDimen_HArray1OfLeaderArrow(1, nbval);
  labelLevels       = new TColStd_HArray1OfInteger(1, nbval);
  displayedEntities = new IGESData_HArray1OfIGESEntity(1, nbval);
 
  for (Standard_Integer i = 1; i <= nbval; i++)
    {
      DeclareAndCast(IGESData_ViewKindEntity, tempView,
                     TC.Transferred(another->ViewItem(i)));
      views->SetValue( i, tempView );
 
      textLocations->SetValue( i, (another->TextLocation(i)).XYZ() );
 
      DeclareAndCast(IGESDimen_LeaderArrow, tempArrow, 
                     TC.Transferred(another->LeaderEntity(i)));
      leaderEntities->SetValue( i, tempArrow );
 
      labelLevels->SetValue( i, another->LabelLevel(i) );
 
      DeclareAndCast(IGESData_IGESEntity, tempEntity, 
                     TC.Transferred(another->DisplayedEntity(i)));
      displayedEntities->SetValue( i, tempEntity );
    }

  ent->Init(views, textLocations, leaderEntities, 
	    labelLevels, displayedEntities);
}

IGESData_DirChecker IGESDraw_ToolLabelDisplay::DirChecker
  (const Handle(IGESDraw_LabelDisplay)& /*ent*/)  const
{ 
  IGESData_DirChecker DC (402, 5);
  DC.Structure(IGESData_DefVoid);
  DC.HierarchyStatusIgnored();
  DC.BlankStatusIgnored();
  return DC;
}

void IGESDraw_ToolLabelDisplay::OwnCheck
  (const Handle(IGESDraw_LabelDisplay)& /*ent*/,
   const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/)  const
{
}

void IGESDraw_ToolLabelDisplay::OwnDump
  (const Handle(IGESDraw_LabelDisplay)& ent, const IGESData_IGESDumper& dumper,
   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
{
  Standard_Integer sublevel = (level <= 4) ? 0 : 1;

  S << "IGESDraw_LabelDisplay" << endl;

  S << "View Entities       : " << endl
    << "Text Locations      : " << endl
    << "Leader Entities     : " << endl
    << "Label Level Numbers : " << endl
    << "Displayed Entities  : ";
  S << "Count = "      << ent->NbLabels() << endl;
  if (level > 4)  // Level = 4 : no Dump. Level = 5 & 6 : same Dump
    {
      Standard_Integer I;
      Standard_Integer up  = ent->NbLabels();
      for (I = 1; I <= up; I ++)
	{
	  S << "[" << I << "]:" << endl;
	  S << "View Entity : ";
	  dumper.Dump (ent->ViewItem(I),S, sublevel);
	  S << endl;
	  S << "Text Location in View : ";
	  IGESData_DumpXYZL(S,level, ent->TextLocation(I), ent->Location());
	  S << "  Leader Entity in View : ";
	  dumper.Dump (ent->LeaderEntity(I),S, sublevel);
	  S << endl;
	  S << "Entity Label Level Number : ";
	  S << ent->LabelLevel(I) << "  ";
	  S << "Displayed Entity : ";
	  dumper.Dump (ent->DisplayedEntity(I),S, sublevel);
	  S << endl;
	}
    }
  S << endl;
}