1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <IGESData_DirChecker.hxx>
20 #include <IGESData_Dump.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_ParamCursor.hxx>
25 #include <IGESData_ParamReader.hxx>
26 #include <IGESGraph_Color.hxx>
27 #include <IGESGraph_ToolColor.hxx>
28 #include <Interface_Check.hxx>
29 #include <Interface_CopyTool.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_Macros.hxx>
32 #include <Interface_ShareTool.hxx>
33 #include <Message_Messenger.hxx>
34 #include <Standard_DomainError.hxx>
35 #include <TCollection_HAsciiString.hxx>
37 IGESGraph_ToolColor::IGESGraph_ToolColor () { }
40 void IGESGraph_ToolColor::ReadOwnParams
41 (const Handle(IGESGraph_Color)& ent,
42 const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
44 Standard_Real tempRed, tempGreen, tempBlue;
45 Handle(TCollection_HAsciiString) tempColorName;
47 PR.ReadReal(PR.Current(), "RED as % Of Full Intensity", tempRed);
49 PR.ReadReal(PR.Current(), "GREEN as % Of Full Intensity", tempGreen);
51 PR.ReadReal(PR.Current(), "BLUE as % Of Full Intensity", tempBlue);
53 if ((PR.CurrentNumber() <= PR.NbParams()) &&
54 (PR.ParamType(PR.CurrentNumber()) == Interface_ParamText))
55 PR.ReadText(PR.Current(), "Color Name", tempColorName);
57 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
58 ent->Init(tempRed, tempGreen, tempBlue, tempColorName);
61 void IGESGraph_ToolColor::WriteOwnParams
62 (const Handle(IGESGraph_Color)& ent, IGESData_IGESWriter& IW) const
64 Standard_Real Red,Green,Blue;
65 ent->RGBIntensity(Red,Green,Blue);
69 // ATTENTION place a reserver (Null) silya des pointeurs additionnels
70 if (ent->HasColorName())
71 IW.Send(ent->ColorName());
72 else IW.SendVoid(); // placekeeper to be reserved for additional pointers
75 void IGESGraph_ToolColor::OwnShared
76 (const Handle(IGESGraph_Color)& /*ent*/, Interface_EntityIterator& /*iter*/) const
80 void IGESGraph_ToolColor::OwnCopy
81 (const Handle(IGESGraph_Color)& another,
82 const Handle(IGESGraph_Color)& ent, Interface_CopyTool& /*TC*/) const
84 Standard_Real tempRed, tempGreen, tempBlue;
85 Handle(TCollection_HAsciiString) tempColorName;
86 another->RGBIntensity(tempRed, tempGreen, tempBlue);
87 if (another->HasColorName())
88 tempColorName = new TCollection_HAsciiString(another->ColorName());
90 ent->Init(tempRed, tempGreen, tempBlue, tempColorName);
93 IGESData_DirChecker IGESGraph_ToolColor::DirChecker
94 (const Handle(IGESGraph_Color)& /*ent*/ ) const
96 IGESData_DirChecker DC(314, 0);
97 DC.Structure(IGESData_DefVoid);
98 DC.LineFont(IGESData_DefVoid);
99 DC.LineWeight(IGESData_DefVoid);
100 DC.Color(IGESData_DefAny);
101 DC.BlankStatusIgnored();
102 DC.SubordinateStatusRequired(0);
103 DC.UseFlagRequired(2);
104 DC.HierarchyStatusIgnored();
109 void IGESGraph_ToolColor::OwnCheck
110 (const Handle(IGESGraph_Color)& /*ent*/,
111 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
113 // if (ent->RankColor() == 0)
114 // ach.AddFail("Color Rank is zero");
115 // else if (ent->RankColor() < 1 || ent->RankColor() > 8)
116 // ach.AddFail("Color Rank not between 1 to 8");
119 void IGESGraph_ToolColor::OwnDump
120 (const Handle(IGESGraph_Color)& ent, const IGESData_IGESDumper& /*dumper*/,
121 Standard_OStream& S, const Standard_Integer /*level*/) const
123 S << "IGESGraph_Color\n";
125 Standard_Real Red,Green,Blue;
126 ent->RGBIntensity(Red,Green,Blue);
127 S << "Red (in % Of Full Intensity) : " << Red << "\n"
128 << "Green (in % Of Full Intensity) : " << Green << "\n"
129 << "Blue (in % Of Full Intensity) : " << Blue << "\n"
131 IGESData_DumpString(S,ent->ColorName());