summaryrefslogtreecommitdiff
path: root/src/IGESDraw/IGESDraw_ToolPerspectiveView.cxx
blob: 26ff701b060bf71fb6ff7b07971274f9004c3733 (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
//--------------------------------------------------------------------
//
//  File Name : IGESDraw_PerspectiveView.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESDraw_ToolPerspectiveView.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_TransfEntity.hxx>
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESDraw_ToolPerspectiveView::IGESDraw_ToolPerspectiveView ()    {  }


void IGESDraw_ToolPerspectiveView::ReadOwnParams
  (const Handle(IGESDraw_PerspectiveView)& ent,
   const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
{
  //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed

  gp_XY tempTopLeft, tempBottomRight;
  Standard_Real tempLeft, tempRight, tempTop, tempBottom;
  gp_XYZ tempCenterOfProjection, tempViewUpVector;
  gp_XYZ tempViewNormalVector, tempViewReferencePoint;
  Standard_Integer tempViewNumber, tempDepthClip;
  Standard_Real tempScaleFactor, tempViewPlaneDistance;
  Standard_Real tempBackPlaneDistance, tempFrontPlaneDistance;

  //szv#4:S4163:12Mar99 `st=` not needed
  PR.ReadInteger(PR.Current(), "View Number", tempViewNumber);
  PR.ReadReal(PR.Current(), "Scale Number", tempScaleFactor);
  PR.ReadXYZ(PR.CurrentList(1, 3), "View Plane Normal Vector", tempViewNormalVector);
  PR.ReadXYZ(PR.CurrentList(1, 3), "View Reference Point", tempViewReferencePoint);
  PR.ReadXYZ(PR.CurrentList(1, 3), "Center Of Projection", tempCenterOfProjection);
  PR.ReadXYZ(PR.CurrentList(1, 3), "View Up Vector", tempViewUpVector);
  PR.ReadReal(PR.Current(), "View Plane Distance", tempViewPlaneDistance);

  //st = PR.ReadReal(PR.Current(), "Left Side Of Clipping Window", tempLeft); //szv#4:S4163:12Mar99 moved in if
  if (PR.ReadReal(PR.Current(), "Left Side Of Clipping Window", tempLeft))
    tempTopLeft.SetX(tempLeft);

  //st = PR.ReadReal(PR.Current(), "Right Side Of Clipping Window", tempRight); //szv#4:S4163:12Mar99 moved in if
  if (PR.ReadReal(PR.Current(), "Right Side Of Clipping Window", tempRight))
    tempBottomRight.SetX(tempRight);

  //st = PR.ReadReal(PR.Current(), "Bottom Of Clipping Window", tempBottom); //szv#4:S4163:12Mar99 moved in if
  if (PR.ReadReal(PR.Current(), "Bottom Of Clipping Window", tempBottom))
    tempBottomRight.SetY(tempBottom);

  //st = PR.ReadReal(PR.Current(), "Top Of Clipping Window", tempTop); //szv#4:S4163:12Mar99 moved in if
  if (PR.ReadReal(PR.Current(), "Top Of Clipping Window", tempTop))
    tempTopLeft.SetY(tempTop);

  //szv#4:S4163:12Mar99 `st=` not needed
  PR.ReadInteger(PR.Current(), "Depth Clipping Indicator", tempDepthClip);
  PR.ReadReal(PR.Current(), "Back Plane Distance", tempBackPlaneDistance);
  PR.ReadReal(PR.Current(), "Front Plane Distance", tempFrontPlaneDistance);

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init
    (tempViewNumber, tempScaleFactor, tempViewNormalVector,
     tempViewReferencePoint, tempCenterOfProjection, tempViewUpVector,
     tempViewPlaneDistance, tempTopLeft, tempBottomRight, tempDepthClip,
     tempBackPlaneDistance, tempFrontPlaneDistance);
}

void IGESDraw_ToolPerspectiveView::WriteOwnParams
  (const Handle(IGESDraw_PerspectiveView)& ent, IGESData_IGESWriter& IW)  const
{
  IW.Send(ent->ViewNumber());
  IW.Send(ent->ScaleFactor());
  IW.Send(ent->ViewNormalVector().X());
  IW.Send(ent->ViewNormalVector().Y());
  IW.Send(ent->ViewNormalVector().Z());
  IW.Send(ent->ViewReferencePoint().X());
  IW.Send(ent->ViewReferencePoint().Y());
  IW.Send(ent->ViewReferencePoint().Z());
  IW.Send(ent->CenterOfProjection().X());
  IW.Send(ent->CenterOfProjection().Y());
  IW.Send(ent->CenterOfProjection().Z());
  IW.Send(ent->ViewUpVector().X());
  IW.Send(ent->ViewUpVector().Y());
  IW.Send(ent->ViewUpVector().Z());
  IW.Send(ent->ViewPlaneDistance());
  IW.Send(ent->TopLeft().X());
  IW.Send(ent->BottomRight().X());
  IW.Send(ent->BottomRight().Y());
  IW.Send(ent->TopLeft().Y());
  IW.Send(ent->DepthClip());
  IW.Send(ent->BackPlaneDistance());
  IW.Send(ent->FrontPlaneDistance());
}

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

void IGESDraw_ToolPerspectiveView::OwnCopy
  (const Handle(IGESDraw_PerspectiveView)& another,
   const Handle(IGESDraw_PerspectiveView)& ent, Interface_CopyTool& /*TC*/) const
{
  ent->Init
    (another->ViewNumber(), another->ScaleFactor(),
     another->ViewNormalVector().XYZ(),   another->ViewReferencePoint().XYZ(),
     another->CenterOfProjection().XYZ(), another->ViewUpVector().XYZ(),
     another->ViewPlaneDistance(),
     another->TopLeft().XY(),another->BottomRight().XY(), another->DepthClip(),
     another->BackPlaneDistance(), another->FrontPlaneDistance());
}


IGESData_DirChecker IGESDraw_ToolPerspectiveView::DirChecker
  (const Handle(IGESDraw_PerspectiveView)& /*ent*/)  const
{
  IGESData_DirChecker DC(410, 1);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefVoid);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefVoid);
  DC.BlankStatusIgnored();
  DC.UseFlagRequired(1);
  DC.HierarchyStatusIgnored();

  return DC;
}

void IGESDraw_ToolPerspectiveView::OwnCheck
  (const Handle(IGESDraw_PerspectiveView)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
{
  if ((ent->DepthClip() < 0) || (ent->DepthClip() > 3))
    ach->AddFail("DepthClip has invalid value");
  if (ent->HasTransf()) {
    if (ent->Transf()->FormNumber() != 0)
      ach->AddFail("Associated Matrix has not Form Number 0");
  }
}

void IGESDraw_ToolPerspectiveView::OwnDump
  (const Handle(IGESDraw_PerspectiveView)& ent, const IGESData_IGESDumper& /*dumper*/,
   const Handle(Message_Messenger)& S, const Standard_Integer level)  const
{
  S << "IGESDraw_PerspectiveView" << endl;

  S << "View Number  : " << ent->ViewNumber()  << "  ";
  S << "Scale Factor : " << ent->ScaleFactor() << endl;
  S         << "View Plane Normal Vector : ";
  IGESData_DumpXYZL(S,level, ent->ViewNormalVector(), ent->Location());
  S << endl << "View Reference Point     : ";
  IGESData_DumpXYZL(S,level, ent->ViewReferencePoint() , ent->Location());
  S << endl << "Center Of Projection     : ";
  IGESData_DumpXYZL(S,level, ent->CenterOfProjection() , ent->Location());
  S << endl << "View Up Vector           : ";
  IGESData_DumpXYZL(S,level, ent->ViewUpVector() , ent->Location());
  S << endl << "View Plane Distance      : " << ent->ViewPlaneDistance()<<endl;
  S << "Left   Side Of Clipping Window : " << ent->TopLeft().X()     << endl;
  S << "Right  Side Of Clipping Window : " << ent->BottomRight().X() << endl;
  S << "Bottom Side Of Clipping Window : " << ent->BottomRight().Y() << endl;
  S << "Top    Side Of Clipping Window : " << ent->TopLeft().Y()     << endl;
  S << "Depth Clipping : " << ent->DepthClip();
  switch (ent->DepthClip()) {
    case 0 :  S << " (No Depth Clipping)" << endl;                    break;
    case 1 :  S << " (Back Clipping Plane ON)" << endl;               break;
    case 2 :  S << " (Front Clipping Plane ON)" << endl;              break;
    case 3 :  S << " (Front and Back Clipping Planes ON)" << endl;    break;
    default : S << " (Invalid Value)" << endl;                        break;
  }
  S << "Back Plane Distance  : " << ent->BackPlaneDistance()  << "  ";
  S << "Front Plane Distance : " << ent->FrontPlaneDistance() << endl;
  S << endl;
}