From c33fde1b0c3af0279da1c58cfa88f8693e6591e7 Mon Sep 17 00:00:00 2001 From: Ronnie Gaensli Date: Wed, 10 Oct 2018 00:41:22 +0200 Subject: [PATCH] Changed default parameter of COLOR4D::ToHSV( ... , bool aAlwaysDefineHue = true) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.7.4" This is a multi-part message in MIME format. --------------2.7.4 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Further revised all calls to ToHSV() respecting the new default parameter Related to lp:1797006 * https://bugs.launchpad.net/kicad/+bug/1797006 --- common/dialogs/dialog_color_picker.cpp | 8 ++++---- common/gal/color4d.cpp | 8 ++++---- include/gal/color4d.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) --------------2.7.4 Content-Type: text/x-patch; name="0001-Changed-default-parameter-of-COLOR4D-ToHSV-.-bool-aA.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-Changed-default-parameter-of-COLOR4D-ToHSV-.-bool-aA.patch" diff --git a/common/dialogs/dialog_color_picker.cpp b/common/dialogs/dialog_color_picker.cpp index d85ef32..87fc6c1 100644 --- a/common/dialogs/dialog_color_picker.cpp +++ b/common/dialogs/dialog_color_picker.cpp @@ -32,7 +32,7 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCu m_previousColor4D = aCurrentColor; m_newColor4D = aCurrentColor; m_cursorsSize = 8; // Size of square cursors drawn on color bitmaps - m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); + m_newColor4D.ToHSV( m_hue, m_sat, m_val ); m_bitmapRGB = nullptr; m_bitmapHSV = nullptr; m_selectedCursor = nullptr; @@ -454,7 +454,7 @@ void DIALOG_COLOR_PICKER::SetEditVals( CHANGED_COLOR aChanged ) m_sliderTransparency->SetValue( normalizeToInt( m_newColor4D.a, ALPHA_MAX ) ); if( aChanged == RED_CHANGED || aChanged == GREEN_CHANGED || aChanged == BLUE_CHANGED ) - m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); + m_newColor4D.ToHSV( m_hue, m_sat, m_val ); if( aChanged != RED_CHANGED ) m_spinCtrlRed->SetValue( normalizeToInt( m_newColor4D.r ) ); @@ -503,7 +503,7 @@ void DIALOG_COLOR_PICKER::buttColorClick( wxCommandEvent& event ) m_newColor4D.g = color.g; m_newColor4D.b = color.b; - m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); + m_newColor4D.ToHSV( m_hue, m_sat, m_val ); SetEditVals( ALL_CHANGED ); drawAll(); @@ -603,7 +603,7 @@ void DIALOG_COLOR_PICKER::onRGBMouseDrag( wxMouseEvent& event ) return; } - m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); + m_newColor4D.ToHSV( m_hue, m_sat, m_val ); SetEditVals( ALL_CHANGED ); drawAll(); diff --git a/common/gal/color4d.cpp b/common/gal/color4d.cpp index b9d393c..bbdc988 100644 --- a/common/gal/color4d.cpp +++ b/common/gal/color4d.cpp @@ -176,7 +176,7 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor ) // "grid row" in the legacy palette. double h, s, v; - aColor.ToHSV( h, s, v ); + aColor.ToHSV( h, s, v, false ); double minDist = 360.0; double legacyHue = 0.0; @@ -197,7 +197,7 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor ) COLOR4D candidate4d( candidate ); double cs, cv; - candidate4d.ToHSV( ch, cs, cv ); + candidate4d.ToHSV( ch, cs, cv, false ); values[candidate] = cv; // Set the hue to non-zero for black so that we won't do this more than once @@ -226,7 +226,7 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor ) { double ch, cs, cv; COLOR4D candidate4d( candidate ); - candidate4d.ToHSV( ch, cs, cv ); + candidate4d.ToHSV( ch, cs, cv, false ); values[candidate] = cv; hues[candidate] = ( cv == 0.0 ) ? 1.0 : ch; } @@ -400,7 +400,7 @@ COLOR4D& COLOR4D::Saturate( double aFactor ) { double h, s, v; - ToHSV( h, s, v, true ); + ToHSV( h, s, v ); FromHSV( h, aFactor, 1.0 ); return *this; diff --git a/include/gal/color4d.h b/include/gal/color4d.h index c5ff3cc..d1e1602 100644 --- a/include/gal/color4d.h +++ b/include/gal/color4d.h @@ -269,13 +269,13 @@ public: * @param aOutHue is the conversion result for hue component, in degrees 0 ... 360.0 * @param aOutSaturation is the conversion result for saturation component (0 ... 1.0). * @param aOutValue is conversion result for value component (0 ... 1.0). - * @param aAlwaysDefineHue controls the way hue is defined when r = v = b - * @note saturation is set to 0.0 for black color (r = v = b = 0), and if r = v = b, + * @param aAlwaysDefineHue controls the way hue is defined when r = g = b + * @note saturation is set to 0.0 for white, grayish and black (r = g = b), * hue is set to 0.0 if aAlwaysDefineHue = true, and set to NAN if aAlwaysDefineHue = false. * this option is usefull to convert a 4D color to a legacy color, because Red has hue = 0, * therefore aAlwaysDefineHue = false makes difference between Red and Gray colors. */ - void ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue, bool aAlwaysDefineHue = false ) const; + void ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue, bool aAlwaysDefineHue = true ) const; /** * Function FromHSV() --------------2.7.4--