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_ParamReader.hxx>
25 #include <IGESGraph_Color.hxx>
26 #include <IGESGraph_ToolColor.hxx>
27 #include <Interface_Check.hxx>
28 #include <Interface_CopyTool.hxx>
29 #include <Interface_EntityIterator.hxx>
30 #include <Interface_ShareTool.hxx>
31 #include <Message_Messenger.hxx>
32 #include <TCollection_HAsciiString.hxx>
34 IGESGraph_ToolColor::IGESGraph_ToolColor () { }
37 void IGESGraph_ToolColor::ReadOwnParams
38 (const Handle(IGESGraph_Color)& ent,
39 const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
41 Standard_Real tempRed, tempGreen, tempBlue;
42 Handle(TCollection_HAsciiString) tempColorName;
44 PR.ReadReal(PR.Current(), "RED as % Of Full Intensity", tempRed);
46 PR.ReadReal(PR.Current(), "GREEN as % Of Full Intensity", tempGreen);
48 PR.ReadReal(PR.Current(), "BLUE as % Of Full Intensity", tempBlue);
50 if ((PR.CurrentNumber() <= PR.NbParams()) &&
51 (PR.ParamType(PR.CurrentNumber()) == Interface_ParamText))
52 PR.ReadText(PR.Current(), "Color Name", tempColorName);
54 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
55 ent->Init(tempRed, tempGreen, tempBlue, tempColorName);
58 void IGESGraph_ToolColor::WriteOwnParams
59 (const Handle(IGESGraph_Color)& ent, IGESData_IGESWriter& IW) const
61 Standard_Real Red,Green,Blue;
62 ent->RGBIntensity(Red,Green,Blue);
66 // ATTENTION place a reserver (Null) silya des pointeurs additionnels
67 if (ent->HasColorName())
68 IW.Send(ent->ColorName());
69 else IW.SendVoid(); // placekeeper to be reserved for additional pointers
72 void IGESGraph_ToolColor::OwnShared
73 (const Handle(IGESGraph_Color)& /*ent*/, Interface_EntityIterator& /*iter*/) const
77 void IGESGraph_ToolColor::OwnCopy
78 (const Handle(IGESGraph_Color)& another,
79 const Handle(IGESGraph_Color)& ent, Interface_CopyTool& /*TC*/) const
81 Standard_Real tempRed, tempGreen, tempBlue;
82 Handle(TCollection_HAsciiString) tempColorName;
83 another->RGBIntensity(tempRed, tempGreen, tempBlue);
84 if (another->HasColorName())
85 tempColorName = new TCollection_HAsciiString(another->ColorName());
87 ent->Init(tempRed, tempGreen, tempBlue, tempColorName);
90 IGESData_DirChecker IGESGraph_ToolColor::DirChecker
91 (const Handle(IGESGraph_Color)& /*ent*/ ) const
93 IGESData_DirChecker DC(314, 0);
94 DC.Structure(IGESData_DefVoid);
95 DC.LineFont(IGESData_DefVoid);
96 DC.LineWeight(IGESData_DefVoid);
97 DC.Color(IGESData_DefAny);
98 DC.BlankStatusIgnored();
99 DC.SubordinateStatusRequired(0);
100 DC.UseFlagRequired(2);
101 DC.HierarchyStatusIgnored();
106 void IGESGraph_ToolColor::OwnCheck
107 (const Handle(IGESGraph_Color)& /*ent*/,
108 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
110 // if (ent->RankColor() == 0)
111 // ach.AddFail("Color Rank is zero");
112 // else if (ent->RankColor() < 1 || ent->RankColor() > 8)
113 // ach.AddFail("Color Rank not between 1 to 8");
116 void IGESGraph_ToolColor::OwnDump
117 (const Handle(IGESGraph_Color)& ent, const IGESData_IGESDumper& /*dumper*/,
118 Standard_OStream& S, const Standard_Integer /*level*/) const
120 S << "IGESGraph_Color\n";
122 Standard_Real Red,Green,Blue;
123 ent->RGBIntensity(Red,Green,Blue);
124 S << "Red (in % Of Full Intensity) : " << Red << "\n"
125 << "Green (in % Of Full Intensity) : " << Green << "\n"
126 << "Blue (in % Of Full Intensity) : " << Blue << "\n"
128 IGESData_DumpString(S,ent->ColorName());