summaryrefslogtreecommitdiff
path: root/src/IGESDraw/IGESDraw_ToolSegmentedViewsVisible.cxx
blob: 8949cca91387bcf491e9e30415c78cf2870a3841 (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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
//--------------------------------------------------------------------
//
//  File Name : IGESDraw_SegmentedViewsVisible.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDraw_ToolSegmentedViewsVisible.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_ViewKindEntity.hxx>
#include <IGESGraph_Color.hxx>
#include <IGESGraph_HArray1OfColor.hxx>
#include <IGESData_LineFontEntity.hxx>
#include <IGESDraw_HArray1OfViewKindEntity.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <IGESBasic_HArray1OfLineFontEntity.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <Interface_Macros.hxx>


IGESDraw_ToolSegmentedViewsVisible::IGESDraw_ToolSegmentedViewsVisible ()  {  }


void IGESDraw_ToolSegmentedViewsVisible::ReadOwnParams
  (const Handle(IGESDraw_SegmentedViewsVisible)& 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(TColStd_HArray1OfReal)             breakpointParameters; 
  Handle(TColStd_HArray1OfInteger)          displayFlags;
  Handle(TColStd_HArray1OfInteger)          colorValues;
  Handle(IGESGraph_HArray1OfColor)          colorDefinitions;
  Handle(TColStd_HArray1OfInteger)          lineFontValues;
  Handle(IGESBasic_HArray1OfLineFontEntity) lineFontDefinitions;
  Handle(TColStd_HArray1OfInteger)          lineWeights;

  // Reading nbval(Integer)
  Standard_Boolean st = PR.ReadInteger( PR.Current(), "No. of View/segment blocks", nbval );
  if (st && nbval > 0) {
    views                = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
    breakpointParameters = new TColStd_HArray1OfReal(1, nbval);
    displayFlags         = new TColStd_HArray1OfInteger(1, nbval);
    colorValues          = new TColStd_HArray1OfInteger(1, nbval);
    colorDefinitions     = new IGESGraph_HArray1OfColor(1, nbval);
    lineFontValues       = new TColStd_HArray1OfInteger(1, nbval);
    lineFontDefinitions  = new IGESBasic_HArray1OfLineFontEntity(1, nbval);
    lineWeights          = new TColStd_HArray1OfInteger(1, nbval);
    
    Handle(IGESData_ViewKindEntity) tempView;
    Standard_Real                   tempBreak;
    Standard_Integer                tempDisplay;
    Standard_Integer                tempColorValue;
    Handle(IGESGraph_Color)         tempColorDef;
    Standard_Integer                tempLineFontValue;
    Handle(IGESData_LineFontEntity) tempLineFontDef;
    Standard_Integer                tempLine;
    
    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 breakpointParameters(HArray1OfReal)
	//st = PR.ReadReal(PR.Current(), "array breakpointParameters", tempBreak ); //szv#4:S4163:12Mar99 moved in if
	if (PR.ReadReal(PR.Current(), "array breakpointParameters", tempBreak ))
	  breakpointParameters->SetValue(i, tempBreak);
	
	// Reading displayFlags(HArray1OfInteger)
	//st = PR.ReadInteger( PR.Current(), "array displayFlags", tempDisplay ); //szv#4:S4163:12Mar99 moved in if
	if (PR.ReadInteger( PR.Current(), "array displayFlags", tempDisplay ))
	  displayFlags->SetValue(i, tempDisplay);

	Standard_Integer curnum = PR.CurrentNumber();

	//  Reading Color : Value (>0) or Definition (<0 = D.E. Pointer)
	PR.ReadInteger( PR.Current(), "array colorValues", tempColorValue); //szv#4:S4163:12Mar99 `st=` not needed
	if (tempColorValue < 0) {
	  colorValues->SetValue(i, -1);
	  tempColorDef = GetCasted(IGESGraph_Color,PR.ParamEntity(IR,curnum));
	  if (tempColorDef.IsNull()) PR.AddFail
	    ("A Color Definition Entity is incorrect");
	  else  colorDefinitions->SetValue(i, tempColorDef);
	}
	else
	  colorValues->SetValue(i, tempColorValue);

	curnum = PR.CurrentNumber();
	//  Reading Line Font : Value (>0) or Definition (<0 = D.E. Pointer)
	PR.ReadInteger( PR.Current(), "array lineFontValues", tempLineFontValue ); //szv#4:S4163:12Mar99 `st=` not needed
	if (tempLineFontValue < 0 ) {
	  lineFontValues->SetValue(i, -1);
	  tempLineFontDef = GetCasted(IGESData_LineFontEntity,
				      PR.ParamEntity(IR,curnum));
	  if (tempLineFontDef.IsNull()) PR.AddFail
	    ("A Line Font Definition Entity is incorrect");
	  lineFontDefinitions->SetValue(i,tempLineFontDef);
	}
	else
	  lineFontValues->SetValue(i, tempLineFontValue);
	
	// Reading lineWeights(HArray1OfInteger)
	//st = PR.ReadInteger( PR.Current(), "array lineWeights", tempLine ); //szv#4:S4163:12Mar99 moved in if
	if (PR.ReadInteger( PR.Current(), "array lineWeights", tempLine ))
	  lineWeights->SetValue(i, tempLine);
      }
  }
  else
    PR.AddFail("No. of View/segment blocks : Not Positive");

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init
    (views, breakpointParameters, displayFlags,colorValues, colorDefinitions,
     lineFontValues, lineFontDefinitions, lineWeights);
}

void IGESDraw_ToolSegmentedViewsVisible::WriteOwnParams
  (const Handle(IGESDraw_SegmentedViewsVisible)& ent, IGESData_IGESWriter& IW)  const
{
  Standard_Integer Up  = ent->NbSegmentBlocks();
  IW.Send( Up );
  for ( Standard_Integer i = 1; i <= Up; i++)
    {
      IW.Send( ent->ViewItem(i) );
      IW.Send( ent->BreakpointParameter(i) );
      IW.Send( ent->DisplayFlag(i) );

      if (ent->IsColorDefinition(i))
	IW.Send( ent->ColorDefinition(i), Standard_True );     // negative
      else
	IW.Send( ent->ColorValue(i) );

      if (ent->IsFontDefinition(i))
	IW.Send( ent->LineFontDefinition(i), Standard_True );  // negative
      else
	IW.Send( ent->LineFontValue(i) );

      IW.Send( ent->LineWeightItem(i) );
    }
}

void  IGESDraw_ToolSegmentedViewsVisible::OwnShared
  (const Handle(IGESDraw_SegmentedViewsVisible)& ent, Interface_EntityIterator& iter) const
{
  Standard_Integer Up  = ent->NbSegmentBlocks();
  for ( Standard_Integer i = 1; i <= Up; i++)
    {
      iter.GetOneItem( ent->ViewItem(i) );
      if (ent->IsColorDefinition(i))
	iter.GetOneItem( ent->ColorDefinition(i) );
      if (!ent->IsFontDefinition(i))
	iter.GetOneItem( ent->LineFontDefinition(i) );
    }
}

void IGESDraw_ToolSegmentedViewsVisible::OwnCopy
  (const Handle(IGESDraw_SegmentedViewsVisible)& another,
   const Handle(IGESDraw_SegmentedViewsVisible)& ent, Interface_CopyTool& TC) const
{
  Standard_Integer                              nbval;
  Handle(IGESDraw_HArray1OfViewKindEntity) views;
  Handle(TColStd_HArray1OfReal)          breakpointParameters;
  Handle(TColStd_HArray1OfInteger)       displayFlags;
  Handle(TColStd_HArray1OfInteger)       colorValues;
  Handle(IGESGraph_HArray1OfColor)          colorDefinitions;
  Handle(TColStd_HArray1OfInteger)       lineFontValues;
  Handle(IGESBasic_HArray1OfLineFontEntity) lineFontDefinitions;
  Handle(TColStd_HArray1OfInteger)       lineWeights;
 
  Handle(IGESData_ViewKindEntity)               retView; 
  Handle(IGESGraph_Color)                       retColorDef; 
  Handle(IGESData_LineFontEntity)               retLineFontDef; 
 
  nbval                = another->NbSegmentBlocks();
  views                = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
  breakpointParameters = new TColStd_HArray1OfReal(1, nbval);
  displayFlags         = new TColStd_HArray1OfInteger(1, nbval);
  colorValues          = new TColStd_HArray1OfInteger(1, nbval);
  lineFontValues       = new TColStd_HArray1OfInteger(1, nbval);
  colorDefinitions     = new IGESGraph_HArray1OfColor(1, nbval);
  lineFontDefinitions  = new IGESBasic_HArray1OfLineFontEntity(1, nbval);
  lineWeights          = new TColStd_HArray1OfInteger(1, nbval);
 
  for (Standard_Integer i = 1; i <= nbval; i++)
    {
      retView = another->ViewItem(i);
      DeclareAndCast(IGESData_ViewKindEntity,
                     tempView, TC.Transferred(retView));
      views->SetValue( i, tempView );
 
      breakpointParameters->SetValue( i, another->BreakpointParameter(i) );
 
      displayFlags->SetValue( i, another->DisplayFlag(i) );
 
      if ( another->IsColorDefinition(i) )
	{
          retColorDef = another->ColorDefinition(i);
          DeclareAndCast(IGESGraph_Color, tempColorDef, 
			 TC.Transferred(retColorDef));
          colorDefinitions->SetValue( i, tempColorDef );
	}
      else
	{
          colorValues->SetValue( i, another->ColorValue(i) );
////          colorDefinitions->SetValue( i, NULL );    par defaut
	}
 
      if ( another->IsFontDefinition(i) )
	{
          retLineFontDef = another->LineFontDefinition(i);
          DeclareAndCast(IGESData_LineFontEntity, tempLineFontDef, 
			 TC.Transferred(retLineFontDef));
          lineFontDefinitions->SetValue( i, tempLineFontDef );
	}
      else
	{
          lineFontValues->SetValue( i, another->LineFontValue(i) );
////          lineFontDefinitions->SetValue( i, NULL );  par defaut
	}
 
      lineWeights->SetValue( i, another->LineWeightItem(i) );
    }

  ent->Init(views, breakpointParameters, displayFlags,
	    colorValues, colorDefinitions,
	    lineFontValues, lineFontDefinitions, lineWeights);
}

IGESData_DirChecker IGESDraw_ToolSegmentedViewsVisible::DirChecker
  (const Handle(IGESDraw_SegmentedViewsVisible)& /*ent*/)  const
{ 
  IGESData_DirChecker DC (402, 19);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefVoid);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefVoid);
  DC.BlankStatusIgnored();
  DC.SubordinateStatusRequired(0);
  DC.UseFlagRequired(1);
  DC.HierarchyStatusIgnored();
  return DC;
}

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

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

  S << "IGESDraw_SegmentedViewsVisible" << endl;

  S << "View Entities            : " << endl
    << "Breakpoint parameters    : " << endl
    << "Display flags            : " << endl
    << "Color Values             : " << endl
    << "Color Definitions        : " << endl
    << "LineFont Values          : " << endl
    << "LineFont Definitions     : " << endl
    << "Line Weights : " << endl;
  S << "Count Of Blocks = "      << ent->NbSegmentBlocks() << endl;
  switch (level)
    {
    case 4 : S << " [ for content, ask level > 4 ]" << endl;
      break; // Nothing to be dumped here
    case 5 :        // Presently level 5 and 6 have the same Dump
    case 6 :
      {
	Standard_Integer I;
	Standard_Integer up  = ent->NbSegmentBlocks();
	for (I = 1; I <= up; I++)
          {
	    S << "[" << I << "]:" << endl;
	    S << "View Entity : ";
	    dumper.Dump (ent->ViewItem(I),S, sublevel);
	    S << endl;
	    S << "Breakpoint parameter : " <<ent->BreakpointParameter(I)<<endl;
	    S << "Display Flag : " << ent->DisplayFlag(I) << endl;
	    if ( (ent->ColorDefinition(I)).IsNull() )
              {
		S << "Color Value : ";
		S << ent->ColorValue(I);
              }
	    else
              {
		S << "Color Definition : ";
		dumper.Dump (ent->ColorDefinition(I),S, sublevel);
              }
	    S << endl;
	    if ( (ent->LineFontDefinition(I)).IsNull() )
              {
		S << "LineFont Value : " << ent->LineFontValue(I);
              }
	    else
              {
		S << "LineFont Definition : ";
		dumper.Dump (ent->LineFontDefinition(I),S, sublevel);
              }
	    S << endl;
	    S << "Line Weight : " << ent->LineWeightItem(I) << endl;
          }
      }
      break;
    }
  S << endl;
}