Gerbview, layer manager: add option (popup menu) to always keep layers not visible but the active layer, even when the active layer is changed.
Pcbnew: fix swig warning for operator EDA_COLOR_T::++ (changed to function EDA_COLOR_T:: NextColor)
This commit is contained in:
+14
-14
@@ -1456,7 +1456,7 @@ void GRBezier( EDA_RECT* ClipBox,
|
||||
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
|
||||
{
|
||||
/* Memoization storage. This could be potentially called for each
|
||||
* color merge so a cache is useful (there are few colours anyway) */
|
||||
* color merge so a cache is useful (there are few colours anyway) */
|
||||
static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];
|
||||
|
||||
// TODO how is alpha used? it's a mac only thing, I have no idea
|
||||
@@ -1469,7 +1469,7 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
|
||||
if( aColor2 == BLACK)
|
||||
return aColor1;
|
||||
|
||||
/* Now we are sure that black can't occur, so the rule is:
|
||||
/* Now we are sure that black can't occur, so the rule is:
|
||||
* BLACK means not computed yet. If we're lucky we already have
|
||||
* an answer */
|
||||
EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];
|
||||
@@ -1477,11 +1477,11 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
|
||||
return candidate;
|
||||
|
||||
// Blend the two colors (i.e. OR the RGB values)
|
||||
const StructColors &c1 = g_ColorRefs[aColor1];
|
||||
const StructColors &c2 = g_ColorRefs[aColor2];
|
||||
const StructColors &c1 = g_ColorRefs[aColor1];
|
||||
const StructColors &c2 = g_ColorRefs[aColor2];
|
||||
|
||||
// Ask the palette for the nearest color to the mix
|
||||
wxColour mixed( c1.m_Red | c2.m_Red,
|
||||
wxColour mixed( c1.m_Red | c2.m_Red,
|
||||
c1.m_Green | c2.m_Green,
|
||||
c1.m_Blue | c2.m_Blue );
|
||||
candidate = ColorFindNearest( mixed );
|
||||
@@ -1489,7 +1489,7 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
|
||||
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
|
||||
* Even theorically its not possible (with the current rules), but
|
||||
* maybe the metric will change in the future */
|
||||
if( candidate == BLACK)
|
||||
if( candidate == BLACK)
|
||||
candidate = DARKDARKGRAY;
|
||||
|
||||
// Store the result in the cache. The operation is commutative, too
|
||||
@@ -1502,12 +1502,12 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
|
||||
EDA_COLOR_T ColorByName( const wxChar *aName )
|
||||
{
|
||||
// look for a match in the palette itself
|
||||
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
|
||||
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
|
||||
{
|
||||
if( 0 == wxStricmp( aName, g_ColorRefs[trying].m_Name ) )
|
||||
return trying;
|
||||
}
|
||||
|
||||
|
||||
// Not found, no idea...
|
||||
return UNSPECIFIED_COLOR;
|
||||
}
|
||||
@@ -1525,23 +1525,23 @@ EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
|
||||
/* Find the 'nearest' color in the palette. This is fun. There is
|
||||
a gazilion of metrics for the color space and no one of the
|
||||
useful one is in the RGB color space. Who cares, this is a CAD,
|
||||
not a photosomething...
|
||||
|
||||
not a photosomething...
|
||||
|
||||
I hereby declare that the distance is the sum of the square of the
|
||||
component difference. Think about the RGB color cube. Now get the
|
||||
euclidean distance, but without the square root... for ordering
|
||||
euclidean distance, but without the square root... for ordering
|
||||
purposes it's the same, obviously. Also each component can't be
|
||||
less of the target one, since I found this currently work better...
|
||||
*/
|
||||
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
|
||||
|
||||
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
|
||||
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
|
||||
{
|
||||
const StructColors &c = g_ColorRefs[trying];
|
||||
const StructColors &c = g_ColorRefs[trying];
|
||||
int distance = (r - c.m_Red) * (r - c.m_Red) +
|
||||
(g - c.m_Green) * (g - c.m_Green) +
|
||||
(b - c.m_Blue) * (b - c.m_Blue);
|
||||
if( distance < nearest_distance && c.m_Red >= r &&
|
||||
if( distance < nearest_distance && c.m_Red >= r &&
|
||||
c.m_Green >= g && c.m_Blue >= b )
|
||||
{
|
||||
nearest_distance = distance;
|
||||
|
||||
Reference in New Issue
Block a user