b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
19 | #include <IGESGraph_Color.hxx> |
20 | #include <Standard_Type.hxx> |
21 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
22 | |
92efcf78 |
23 | IMPLEMENT_STANDARD_RTTIEXT(IGESGraph_Color,IGESData_ColorEntity) |
24 | |
b311480e |
25 | IGESGraph_Color::IGESGraph_Color () { } |
7fd59977 |
26 | |
27 | |
28 | // This class inherits from IGESData_ColorEntity |
29 | |
30 | void IGESGraph_Color::Init |
31 | (const Standard_Real red, |
32 | const Standard_Real green, |
33 | const Standard_Real blue, |
34 | const Handle(TCollection_HAsciiString)& aColorName) |
35 | { |
36 | theRed = red; |
37 | theGreen = green; |
38 | theBlue = blue; |
39 | theColorName = aColorName; |
40 | InitTypeAndForm(314,0); |
41 | } |
42 | |
43 | void IGESGraph_Color::RGBIntensity |
44 | (Standard_Real& Red, Standard_Real& Green, Standard_Real& Blue) const |
45 | { |
46 | Red = theRed; |
47 | Green = theGreen; |
48 | Blue = theBlue; |
49 | } |
50 | |
51 | void IGESGraph_Color::CMYIntensity |
52 | (Standard_Real& Cyan, Standard_Real& Magenta, Standard_Real& Yellow) const |
53 | { |
54 | Cyan = 100.0 - theRed; |
55 | Magenta = 100.0 - theGreen; |
56 | Yellow = 100.0 - theBlue; |
57 | } |
58 | |
59 | void IGESGraph_Color::HLSPercentage |
60 | (Standard_Real& Hue, Standard_Real& Lightness, Standard_Real& Saturation) const |
61 | { |
c6541a0c |
62 | Hue = ((1.0 / (2.0 * M_PI)) * |
7fd59977 |
63 | (ATan(((2 * theRed) - theGreen - theBlue) / |
64 | (Sqrt(3) * (theGreen - theBlue))))); |
65 | Lightness = ((1.0 / 3.0) * (theRed + theGreen + theBlue)); |
66 | Saturation = (Sqrt((theRed * theRed ) + |
67 | (theGreen * theGreen) + |
68 | (theBlue * theBlue ) - |
69 | (theRed * theGreen) - |
70 | (theRed * theBlue ) - |
71 | (theBlue * theGreen))); |
72 | } |
73 | |
74 | Standard_Boolean IGESGraph_Color::HasColorName () const |
75 | { |
76 | return (! theColorName.IsNull()); |
77 | } |
78 | |
79 | Handle(TCollection_HAsciiString) IGESGraph_Color::ColorName () const |
80 | { |
81 | return theColorName; |
82 | } |