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 33 of file sg_base.cpp.

34 {
35  red = 0.0;
36  green = 0.0;
37  blue = 0.0;
38 
39  return;
40 }
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 42 of file sg_base.cpp.

43 {
44  if( !checkRange( aRVal, aGVal, aBVal ) )
45  {
46 #ifdef DEBUG
47  std::ostringstream ostr;
48  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
49  ostr << " * [BUG] invalid value passed to constructor";
50  wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
51 #endif
52  red = 0.0;
53  green = 0.0;
54  blue = 0.0;
55  return;
56  }
57 
58  red = aRVal;
59  green = aGVal;
60  blue = aBVal;
61  return;
62 }
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:147

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

Member Function Documentation

◆ checkRange()

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

Definition at line 147 of file sg_base.cpp.

148 {
149  bool ok = true;
150 
151  if( aRedVal < 0.0 || aRedVal > 1.0 )
152  {
153 #ifdef DEBUG
154  std::ostringstream ostr;
155  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
156  ostr << " * [BUG] invalid RED value: " << aRedVal;
157  wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
158 #endif
159  ok = false;
160  }
161 
162  if( aGreenVal < 0.0 || aGreenVal > 1.0 )
163  {
164 #ifdef DEBUG
165  if( ok )
166  {
167  wxLogTrace( MASK_3D_SG, "%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__ );
168  }
169  wxLogTrace( MASK_3D_SG, " * [BUG] invalid GREEN value: %f\n", aGreenVal );
170 #endif
171  ok = false;
172  }
173 
174  if( aBlueVal < 0.0 || aBlueVal > 1.0 )
175  {
176 #ifdef DEBUG
177  if( ok )
178  {
179  wxLogTrace( MASK_3D_SG, "%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__ );
180  }
181  wxLogTrace( MASK_3D_SG, " * [BUG] invalid BLUE value: %f\n", aBlueVal );
182 #endif
183  ok = false;
184  }
185 
186  return ok;
187 }

Referenced by SetColor(), and SGCOLOR().

◆ GetColor() [1/3]

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

Definition at line 65 of file sg_base.cpp.

66 {
67  aRedVal = red;
68  aGreenVal = green;
69  aBlueVal = blue;
70  return;
71 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

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 74 of file sg_base.cpp.

75 {
76  aColor.red = red;
77  aColor.green = green;
78  aColor.blue = blue;
79  return;
80 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

◆ GetColor() [3/3]

void SGCOLOR::GetColor ( SGCOLOR aColor) const
noexcept

Definition at line 83 of file sg_base.cpp.

84 {
85  if( NULL == aColor )
86  {
87  #ifdef DEBUG
88  std::ostringstream ostr;
89  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
90  ostr << " * [BUG] NULL pointer passed for aColor";
91  wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
92  #endif
93 
94  return;
95  }
96 
97  aColor->red = red;
98  aColor->green = green;
99  aColor->blue = blue;
100  return;
101 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
#define NULL
float green
Definition: sg_base.h:47

References NULL.

◆ SetColor() [1/3]

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

Definition at line 104 of file sg_base.cpp.

105 {
106  if( !checkRange( aRedVal, aGreenVal, aBlueVal ) )
107  return false;
108 
109  red = aRedVal;
110  green = aGreenVal;
111  blue = aBlueVal;
112 
113  return true;
114 }
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:147

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 117 of file sg_base.cpp.

118 {
119  red = aColor.red;
120  green = aColor.green;
121  blue = aColor.blue;
122  return true;
123 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
float green
Definition: sg_base.h:47

◆ SetColor() [3/3]

bool SGCOLOR::SetColor ( const SGCOLOR aColor)
noexcept

Definition at line 126 of file sg_base.cpp.

127 {
128  if( NULL == aColor )
129  {
130  #ifdef DEBUG
131  std::ostringstream ostr;
132  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
133  ostr << " * [BUG] NULL pointer passed for aColor";
134  wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
135  #endif
136 
137  return false;
138  }
139 
140  red = aColor->red;
141  green = aColor->green;
142  blue = aColor->blue;
143  return true;
144 }
float blue
Definition: sg_base.h:48
float red
Definition: sg_base.h:46
#define NULL
float green
Definition: sg_base.h:47

References NULL.

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: