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
 
void GetColor (SGCOLOR &aColor) const
 
void GetColor (SGCOLOR *aColor) const
 
bool SetColor (float aRedVal, float aGreenVal, float aBlueVal)
 
bool SetColor (const SGCOLOR &aColor)
 
bool SetColor (const SGCOLOR *aColor)
 

Protected Attributes

float red
 
float green
 
float blue
 

Private Member Functions

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

Detailed Description

Definition at line 43 of file sg_base.h.

Constructor & Destructor Documentation

SGCOLOR::SGCOLOR ( )

Definition at line 33 of file sg_base.cpp.

References blue, green, and red.

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
SGCOLOR::SGCOLOR ( float  aRVal,
float  aGVal,
float  aBVal 
)

Definition at line 42 of file sg_base.cpp.

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

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
Definition: sg_base.cpp:147

Member Function Documentation

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

Definition at line 147 of file sg_base.cpp.

Referenced by SetColor(), and SGCOLOR().

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 }
void SGCOLOR::GetColor ( float &  aRedVal,
float &  aGreenVal,
float &  aBlueVal 
) const

Definition at line 65 of file sg_base.cpp.

References blue, green, and red.

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

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
void SGCOLOR::GetColor ( SGCOLOR aColor) const

Definition at line 74 of file sg_base.cpp.

References blue, green, and red.

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
void SGCOLOR::GetColor ( SGCOLOR aColor) const

Definition at line 83 of file sg_base.cpp.

References blue, green, and red.

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
float green
Definition: sg_base.h:47
bool SGCOLOR::SetColor ( float  aRedVal,
float  aGreenVal,
float  aBlueVal 
)

Definition at line 104 of file sg_base.cpp.

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

Referenced by S3D::ReadColor(), SGAPPEARANCE::SetAmbient(), SGAPPEARANCE::SetDiffuse(), SGAPPEARANCE::SetEmissive(), SGAPPEARANCE::SetSpecular(), and SGAPPEARANCE::SGAPPEARANCE().

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
Definition: sg_base.cpp:147
bool SGCOLOR::SetColor ( const SGCOLOR aColor)

Definition at line 117 of file sg_base.cpp.

References blue, green, and red.

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
bool SGCOLOR::SetColor ( const SGCOLOR aColor)

Definition at line 126 of file sg_base.cpp.

References blue, green, and red.

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
float green
Definition: sg_base.h:47

Member Data Documentation

float SGCOLOR::blue
protected

Definition at line 48 of file sg_base.h.

Referenced by GetColor(), SetColor(), and SGCOLOR().

float SGCOLOR::green
protected

Definition at line 47 of file sg_base.h.

Referenced by GetColor(), SetColor(), and SGCOLOR().

float SGCOLOR::red
protected

Definition at line 46 of file sg_base.h.

Referenced by GetColor(), SetColor(), and SGCOLOR().


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