0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / IGESGraph / IGESGraph_ToolColor.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
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>
36
37 IGESGraph_ToolColor::IGESGraph_ToolColor ()    {  }
38
39
40 void IGESGraph_ToolColor::ReadOwnParams
41   (const Handle(IGESGraph_Color)& ent,
42    const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const
43 {
44   Standard_Real tempRed, tempGreen, tempBlue;
45   Handle(TCollection_HAsciiString) tempColorName;
46
47   PR.ReadReal(PR.Current(), "RED as % Of Full Intensity", tempRed);
48
49   PR.ReadReal(PR.Current(), "GREEN as % Of Full Intensity", tempGreen);
50
51   PR.ReadReal(PR.Current(), "BLUE as % Of Full Intensity", tempBlue);
52
53   if ((PR.CurrentNumber() <= PR.NbParams()) &&
54       (PR.ParamType(PR.CurrentNumber()) == Interface_ParamText))
55     PR.ReadText(PR.Current(), "Color Name", tempColorName);
56
57   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
58   ent->Init(tempRed, tempGreen, tempBlue, tempColorName);
59 }
60
61 void IGESGraph_ToolColor::WriteOwnParams
62   (const Handle(IGESGraph_Color)& ent, IGESData_IGESWriter& IW)  const
63 {
64   Standard_Real Red,Green,Blue;
65   ent->RGBIntensity(Red,Green,Blue);
66   IW.Send(Red);
67   IW.Send(Green);
68   IW.Send(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
73 }
74
75 void  IGESGraph_ToolColor::OwnShared
76   (const Handle(IGESGraph_Color)& /*ent*/, Interface_EntityIterator& /*iter*/) const
77 {
78 }
79
80 void IGESGraph_ToolColor::OwnCopy
81   (const Handle(IGESGraph_Color)& another,
82    const Handle(IGESGraph_Color)& ent, Interface_CopyTool& /*TC*/) const
83 {
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());
89
90   ent->Init(tempRed, tempGreen, tempBlue, tempColorName);
91 }
92
93 IGESData_DirChecker  IGESGraph_ToolColor::DirChecker
94   (const Handle(IGESGraph_Color)& /*ent*/ )  const
95 {
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();
105
106   return DC;
107 }
108
109 void IGESGraph_ToolColor::OwnCheck
110   (const Handle(IGESGraph_Color)& /*ent*/,
111    const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/)  const
112 {
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");
117 }
118
119 void IGESGraph_ToolColor::OwnDump
120   (const Handle(IGESGraph_Color)& ent, const IGESData_IGESDumper& /*dumper*/,
121    const Handle(Message_Messenger)& S, const Standard_Integer /*level*/)  const
122 {
123   S << "IGESGraph_Color" << endl;
124
125   Standard_Real Red,Green,Blue;
126   ent->RGBIntensity(Red,Green,Blue);
127   S << "Red   (in % Of Full Intensity) : " << Red   << endl;
128   S << "Green (in % Of Full Intensity) : " << Green << endl;
129   S << "Blue  (in % Of Full Intensity) : " << Blue  << endl;
130   S << "Color Name : ";
131   IGESData_DumpString(S,ent->ColorName());
132   S << endl;
133 }