summaryrefslogtreecommitdiff
path: root/src/IGESDimen/IGESDimen_ToolLeaderArrow.cxx
blob: 059f36e7113f7accf6a5cb5255a720c3597df57e (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
//--------------------------------------------------------------------
//
//  File Name : IGESDimen_LeaderArrow.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDimen_ToolLeaderArrow.ixx>
#include <IGESData_ParamCursor.hxx>
#include <TColgp_HArray1OfXY.hxx>
#include <gp_XY.hxx>
#include <gp_Pnt2d.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESDimen_ToolLeaderArrow::IGESDimen_ToolLeaderArrow ()    {  }


void  IGESDimen_ToolLeaderArrow::ReadOwnParams
  (const Handle(IGESDimen_LeaderArrow)& ent,
   const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
{ 
  //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down

  Standard_Real arrowHeadHeight; 
  Standard_Real arrowHeadWidth; 
  Standard_Real zDepth; 
  gp_XY arrowHead; 
  Handle(TColgp_HArray1OfXY) segmentTails;
  Standard_Integer nbval;

  Standard_Boolean st = PR.ReadInteger( PR.Current(), "Count of Segments", nbval);
  if (st && nbval > 0)
    segmentTails = new TColgp_HArray1OfXY(1,nbval);
  else  PR.AddFail("Count of Segments: Not Positive");

  //szv#4:S4163:12Mar99 `st=` not needed
  PR.ReadReal(PR.Current(), "Arrow Head Height", arrowHeadHeight);
  PR.ReadReal(PR.Current(), "Arrow Head Width", arrowHeadWidth);
  PR.ReadReal(PR.Current(), "Z Depth", zDepth);
  PR.ReadXY(PR.CurrentList(1, 2), "Arrow Head Position", arrowHead);

  if (! segmentTails.IsNull())
    {
      for (Standard_Integer i = 1; i <= nbval; i++)
	{
          gp_XY tempXY;
          //st = PR.ReadXY(PR.CurrentList(1, 2), "Segment Co-ords.", tempXY); //szv#4:S4163:12Mar99 moved in if
	  if (PR.ReadXY(PR.CurrentList(1, 2), "Segment Co-ords.", tempXY))
	    segmentTails->SetValue(i, tempXY);
	}
      DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
      ent->Init (arrowHeadHeight, arrowHeadWidth, zDepth, arrowHead, segmentTails);
    } //segmentTails.IsNull() crash in ent->Init( ...

}

void  IGESDimen_ToolLeaderArrow::WriteOwnParams
  (const Handle(IGESDimen_LeaderArrow)& ent, IGESData_IGESWriter& IW) const 
{ 
  Standard_Integer upper = ent->NbSegments();
  IW.Send(upper);
  IW.Send(ent->ArrowHeadHeight());
  IW.Send(ent->ArrowHeadWidth());
  IW.Send(ent->ZDepth());
  IW.Send(ent->ArrowHead().X());
  IW.Send(ent->ArrowHead().Y());
  for (Standard_Integer i = 1; i <= upper; i++)
    {
      IW.Send((ent->SegmentTail(i)).X());
      IW.Send((ent->SegmentTail(i)).Y());
    }
}

void  IGESDimen_ToolLeaderArrow::OwnShared
  (const Handle(IGESDimen_LeaderArrow)& /* ent */, Interface_EntityIterator& /* iter */) const
{
}

void  IGESDimen_ToolLeaderArrow::OwnCopy
  (const Handle(IGESDimen_LeaderArrow)& another,
   const Handle(IGESDimen_LeaderArrow)& ent, Interface_CopyTool& /* TC */) const
{ 
  Standard_Integer nbval = another->NbSegments();
  Standard_Real arrowHeadHeight = another->ArrowHeadHeight();
  Standard_Real arrowHeadWidth = another->ArrowHeadWidth();
  Standard_Real zDepth = another->ZDepth();
  gp_XY arrowHead = another->ArrowHead().XY();

  Handle(TColgp_HArray1OfXY) segmentTails = new TColgp_HArray1OfXY(1, nbval);

  for (Standard_Integer i = 1; i <= nbval; i++)
    {
      segmentTails->SetValue(i, (another->SegmentTail(i)).XY());
    }

  ent->Init(arrowHeadHeight, arrowHeadWidth, zDepth, arrowHead, segmentTails);
  ent->SetFormNumber (another->FormNumber());
}

IGESData_DirChecker  IGESDimen_ToolLeaderArrow::DirChecker
  (const Handle(IGESDimen_LeaderArrow)& /* ent */ ) const 
{ 
  IGESData_DirChecker DC (214, 1, 12);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefAny);
  DC.LineWeight(IGESData_DefValue);
  DC.Color(IGESData_DefAny);
  DC.UseFlagRequired(1);
  DC.HierarchyStatusIgnored();
  return DC;
}

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

void  IGESDimen_ToolLeaderArrow::OwnDump
  (const Handle(IGESDimen_LeaderArrow)& ent, const IGESData_IGESDumper& /* dumper */,
   const Handle(Message_Messenger)& S, const Standard_Integer level) const 
{ 
  S << "IGESDimen_LeaderArrow" << endl;
  S << "Number of Segments : " << ent->NbSegments() << endl;
  S << "Arrowhead Height   : " << ent->ArrowHeadHeight() << endl;
  S << "Arrowhead Width    : " << ent->ArrowHeadWidth() << endl;
  S << "Z depth            : " << ent->ZDepth() << endl;
  S << "Arrowhead co-ords  : ";
  IGESData_DumpXYLZ(S,level,ent->ArrowHead(),ent->Location(),ent->ZDepth());
  S << endl << "Segment Tails : "; 
  IGESData_DumpListXYLZ(S ,level,1, ent->NbSegments(),ent->SegmentTail,
			ent->Location(), ent->ZDepth());
  S << endl;
}