KiCad PCB EDA Suite
SGCOLOR Class Reference

#include <sg_base.h>

Public Member Functions

 SGCOLOR ()
 
 SGCOLOR (float aRVal, float aGVal, float aBVal)
 
void GetColor (float &aRedVal, float &aGreenVal, float &aBlueVal) const noexcept
 
void GetColor (SGCOLOR &aColor) const noexcept
 
void GetColor (SGCOLOR *aColor) const noexcept
 
bool SetColor (float aRedVal, float aGreenVal, float aBlueVal)
 
bool SetColor (const SGCOLOR &aColor) noexcept
 
bool SetColor (const SGCOLOR *aColor) noexcept
 

Protected Attributes

float red
 
float green
 
float blue
 

Private Member Functions

bool checkRange (float aRedVal, float aGreenVal, float aBlueVal) const noexcept
 

Detailed Description

Definition at line 43 of file sg_base.h.

Constructor & Destructor Documentation

◆ SGCOLOR() [1/2]

SGCOLOR::SGCOLOR ( )

Definition at line 34 of file sg_base.cpp.

35 {
36  red = 0.0;
37  green = 0.0;
38  blue = 0.0;
39 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

References blue, green, and red.

◆ SGCOLOR() [2/2]

SGCOLOR::SGCOLOR ( float  aRVal,
float  aGVal,
float  aBVal 
)

Definition at line 41 of file sg_base.cpp.

42 {
43  if( !checkRange( aRVal, aGVal, aBVal ) )
44  {
45  wxLogTrace( MASK_3D_SG, "%s:%s:%d * [BUG] invalid value passed to constructor",
46  __FILE__, __FUNCTION__, __LINE__ );
47  red = 0.0;
48  green = 0.0;
49  blue = 0.0;
50  return;
51  }
52 
53  red = aRVal;
54  green = aGVal;
55  blue = aBVal;
56 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47
bool checkRange(float aRedVal, float aGreenVal, float aBlueVal) const noexcept
Definition: sg_base.cpp:118

References blue, checkRange(), green, and red.

Member Function Documentation

◆ checkRange()

bool SGCOLOR::checkRange ( float  aRedVal,
float  aGreenVal,
float  aBlueVal 
) const
privatenoexcept

Definition at line 118 of file sg_base.cpp.

119 {
120  bool ok = true;
121 
122  if( aRedVal < 0.0 || aRedVal > 1.0 )
123  {
124  wxLogTrace( MASK_3D_SG, "%s:%s:%d * [BUG] invalid RED value: %g",
125  __FILE__, __FUNCTION__, __LINE__, aRedVal );
126 
127  ok = false;
128  }
129 
130  if( aGreenVal < 0.0 || aGreenVal > 1.0 )
131  {
132  wxLogTrace( MASK_3D_SG, "%s:%s:%d * [BUG] invalid GREEN value: %g",
133  __FILE__, __FUNCTION__, __LINE__, aGreenVal );
134 
135  ok = false;
136  }
137 
138  if( aBlueVal < 0.0 || aBlueVal > 1.0 )
139  {
140  wxLogTrace( MASK_3D_SG, "%s:%s:%d * [BUG] invalid BLUE value: %g",
141  __FILE__, __FUNCTION__, __LINE__, aBlueVal );
142 
143  ok = false;
144  }
145 
146  return ok;
147 }

Referenced by SetColor(), and SGCOLOR().

◆ GetColor() [1/3]

void SGCOLOR::GetColor ( float &  aRedVal,
float &  aGreenVal,
float &  aBlueVal 
) const
noexcept

Definition at line 59 of file sg_base.cpp.

60 {
61  aRedVal = red;
62  aGreenVal = green;
63  aBlueVal = blue;
64 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

References red.

Referenced by S3D::FormatColor(), formatMaterial(), SGSHAPE::Prepare(), S3D::WriteColor(), and SGAPPEARANCE::WriteVRML().

◆ GetColor() [2/3]

void SGCOLOR::GetColor ( SGCOLOR aColor) const
noexcept

Definition at line 67 of file sg_base.cpp.

68 {
69  aColor.red = red;
70  aColor.green = green;
71  aColor.blue = blue;
72 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

References red.

◆ GetColor() [3/3]

void SGCOLOR::GetColor ( SGCOLOR aColor) const
noexcept

Definition at line 75 of file sg_base.cpp.

76 {
77  wxCHECK_MSG( aColor, /* void */, "NULL pointer passed for aRGBColor" );
78 
79  aColor->red = red;
80  aColor->green = green;
81  aColor->blue = blue;
82 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

References red.

◆ SetColor() [1/3]

bool SGCOLOR::SetColor ( float  aRedVal,
float  aGreenVal,
float  aBlueVal 
)

Definition at line 85 of file sg_base.cpp.

86 {
87  if( !checkRange( aRedVal, aGreenVal, aBlueVal ) )
88  return false;
89 
90  red = aRedVal;
91  green = aGreenVal;
92  blue = aBlueVal;
93 
94  return true;
95 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47
bool checkRange(float aRedVal, float aGreenVal, float aBlueVal) const noexcept
Definition: sg_base.cpp:118

References blue, checkRange(), green, and red.

Referenced by WRL1MATERIAL::GetColor(), S3D::ReadColor(), SGAPPEARANCE::SetAmbient(), SGAPPEARANCE::SetDiffuse(), SGAPPEARANCE::SetEmissive(), SGAPPEARANCE::SetSpecular(), SGAPPEARANCE::SGAPPEARANCE(), and WRL2FACESET::TranslateToSG().

◆ SetColor() [2/3]

bool SGCOLOR::SetColor ( const SGCOLOR aColor)
noexcept

Definition at line 98 of file sg_base.cpp.

99 {
100  red = aColor.red;
101  green = aColor.green;
102  blue = aColor.blue;
103  return true;
104 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

References red.

◆ SetColor() [3/3]

bool SGCOLOR::SetColor ( const SGCOLOR aColor)
noexcept

Definition at line 107 of file sg_base.cpp.

108 {
109  wxCHECK_MSG( aColor, false, "NULL pointer passed for aRGBColor" );
110 
111  red = aColor->red;
112  green = aColor->green;
113  blue = aColor->blue;
114  return true;
115 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

References red.

Member Data Documentation

◆ blue

float SGCOLOR::blue
protected

Definition at line 48 of file sg_base.h.

Referenced by SetColor(), and SGCOLOR().

◆ green

float SGCOLOR::green
protected

Definition at line 47 of file sg_base.h.

Referenced by SetColor(), and SGCOLOR().

◆ red

float SGCOLOR::red
protected

Definition at line 46 of file sg_base.h.

Referenced by SetColor(), and SGCOLOR().


The documentation for this class was generated from the following files: