summaryrefslogtreecommitdiff
path: root/src/IGESGraph/IGESGraph_ToolLineFontDefPattern.cxx
blob: 2794d726706ebbab85e844920c1435636a2db251 (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
//--------------------------------------------------------------------
//
//  File Name : IGESGraph_LineFontDefPattern.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGraph_ToolLineFontDefPattern.ixx>
#include <IGESData_ParamCursor.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <IGESData_Dump.hxx>
#include <Interface_Macros.hxx>


IGESGraph_ToolLineFontDefPattern::IGESGraph_ToolLineFontDefPattern ()    {  }


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

  Standard_Integer                 tempNbSeg;
  Handle(TCollection_HAsciiString) tempDisplayPattern;
  Handle(TColStd_HArray1OfReal)    tempSegmentLengths;

  if (PR.ReadInteger(PR.Current(), "Number of Visible-Blank Segments", tempNbSeg)) { //szv#4:S4163:12Mar99 `st=` not needed
    // Initialise HArray1 only if there is no error reading its Length
    if (tempNbSeg <= 0)  PR.AddFail("Number of Visible-Blank Segments : Not Positive");
    else  tempSegmentLengths = new TColStd_HArray1OfReal(1, tempNbSeg);
  }

  // Read the HArray1 only if its Length was read without any Error
  if (! tempSegmentLengths.IsNull()) {
    Standard_Integer I;
    for (I = 1; I <= tempNbSeg; I++) {
      Standard_Real tempReal;
      if (PR.ReadReal(PR.Current(), "Length of Segment", tempReal)) //szv#4:S4163:12Mar99 `st=` not needed
	tempSegmentLengths->SetValue(I, tempReal);
    }
  }

  PR.ReadText(PR.Current(), "Visible-Blank Display Pattern", tempDisplayPattern); //szv#4:S4163:12Mar99 `st=` not needed

  DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
  ent->Init(tempSegmentLengths, tempDisplayPattern);
}

void IGESGraph_ToolLineFontDefPattern::WriteOwnParams
  (const Handle(IGESGraph_LineFontDefPattern)& ent, IGESData_IGESWriter& IW)  const
{
  Standard_Integer up  = ent->NbSegments();
  IW.Send(up);
  Standard_Integer I;
  for (I = 1; I <= up; I++)
    IW.Send(ent->Length(I));
  IW.Send(ent->DisplayPattern());
}

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

void IGESGraph_ToolLineFontDefPattern::OwnCopy
  (const Handle(IGESGraph_LineFontDefPattern)& another,
   const Handle(IGESGraph_LineFontDefPattern)& ent, Interface_CopyTool& /*TC*/) const
{
  Handle(TColStd_HArray1OfReal) tempSegmentLengths =
    new TColStd_HArray1OfReal(1, another->NbSegments());
  Standard_Integer I;
  Standard_Integer up  = another->NbSegments();
  for (I = 1; I <= up; I++)
    tempSegmentLengths->SetValue(I, another->Length(I));
  Handle(TCollection_HAsciiString) tempDisplayPattern =
    new TCollection_HAsciiString(another->DisplayPattern());

  ent->Init(tempSegmentLengths, tempDisplayPattern);
}

IGESData_DirChecker IGESGraph_ToolLineFontDefPattern::DirChecker
  (const Handle(IGESGraph_LineFontDefPattern)& /*ent*/)  const
{
  IGESData_DirChecker DC(304, 2);
  DC.Structure(IGESData_DefVoid);
  DC.LineFont(IGESData_DefValue);
  DC.LineWeight(IGESData_DefVoid);
  DC.Color(IGESData_DefVoid);
  DC.BlankStatusIgnored();
  DC.SubordinateStatusRequired(0);
  DC.UseFlagRequired(2);
  DC.HierarchyStatusIgnored();

  return DC;
}

void IGESGraph_ToolLineFontDefPattern::OwnCheck
  (const Handle(IGESGraph_LineFontDefPattern)& ent,
   const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
{
  if (ent->RankLineFont() == 0)
    ach->AddWarning("Line Font Rank is zero");
  else if (ent->RankLineFont() < 1 || ent->RankLineFont() > 5)
    ach->AddWarning("Invalid Value As Line Font Rank(Valid Range 1 to 5)");
}

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

  S << "Visible-Blank Segments : ";
  Standard_Integer nb = ent->NbSegments();
  IGESData_DumpVals(S ,level,1, nb,ent->Length);
  S <<endl << "Display Pattern : ";
  IGESData_DumpString(S,ent->DisplayPattern());
  S << endl;
  if (level > 4) {
    S << " -> Which Segments are Visible (the others are Blank) : " << endl;
    for (Standard_Integer I = 1; I <= nb; I ++) {
      if (ent->IsVisible(I)) S << "  " << I;
    }
    S << endl;
  }
}