← Back to team overview

kicad-developers team mailing list archive

[PATCH]: Calculator: Simplify color code tolerance chooser + typo

 

Hi,

Commit message:
"
Since for this tool the only difference for different tolerances
is the 4th band, which is present for tolerance <= 2% and not
present for 10%/5%, reduce radio choices to those two groups for
clarity.

Fix a typo (4rd -> 4th) and rename one variable to make it
more descriptive as well.
"

In my opinion, reducing the number of tolerance choices makes sense
and makes it easier to understand, however, I understand that this is
subjective and others may think differently.

If you didn't want to include these changes, please let me know and I'll
create another patch for the typo only.

Thanks,
Diego
From 03ee65284fdb24aea5eb8499b0044b3e56747ac7 Mon Sep 17 00:00:00 2001
From: Diego Herranz <diegoherranz@xxxxxxxxxxxxxxxx>
Date: Sat, 25 Feb 2017 06:22:17 +0000
Subject: [PATCH] Calculator: Simplify color code tolerance chooser + typo

Since for this tool the only difference for different tolerances
is the 4th band, which is present for tolerance <= 2% and not
present for 10%/5%, reduce radio choices to those two groups for
clarity.

Fix a typo (4rd -> 4th) and rename one variable to make it
more descriptive as well.
---
 pcb_calculator/colorcode.cpp                       | 24 ++++++++++++----------
 .../dialogs/pcb_calculator_frame_base.cpp          |  4 ++--
 .../dialogs/pcb_calculator_frame_base.fbp          |  4 ++--
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/pcb_calculator/colorcode.cpp b/pcb_calculator/colorcode.cpp
index d102461..a14569b 100644
--- a/pcb_calculator/colorcode.cpp
+++ b/pcb_calculator/colorcode.cpp
@@ -36,25 +36,27 @@ void PCB_CALCULATOR_FRAME::OnToleranceSelection( wxCommandEvent& event )
 
 void PCB_CALCULATOR_FRAME::ToleranceSelection( int aSelection )
 {
-    /* For tolerance = 5 or 10 %, there are 3 ring for the value
-     * but for tolerance < 5 %, there are 4 ring
+    /* For tolerance = 5 or 10 %, there are 3 bands for the value
+     * but for tolerance < 5 %, there are 4 bands
      */
-    bool enable = true;
+    bool show4thBand;
     switch( aSelection )
     {
-        case 0:
-        case 1:
-            enable = false;
+        case 0: // 5 or 10 %
+            show4thBand = false;
             break;
-
-        default:
+        case 1: // < 5 %
+            show4thBand = true;
+            break;
+        default: // Show 4th band if something went wrong
+            show4thBand = true;
             break;
     }
     bool oldstate = m_Band4Label->IsShown();
-    if( oldstate != enable )
+    if( oldstate != show4thBand )
     {
-        m_Band4bitmap->Show(enable);
-        m_Band4Label->Show(enable);
+        m_Band4bitmap->Show(show4thBand);
+        m_Band4Label->Show(show4thBand);
         // m_Band4Label visibility has changed:
         // The new size must be taken in account
         m_panelColorCode->GetSizer()->Layout();
diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp
index 93ca9dd..b90b423 100644
--- a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp
+++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp
@@ -1176,7 +1176,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
 	wxBoxSizer* bSizerPanelColorCode;
 	bSizerPanelColorCode = new wxBoxSizer( wxHORIZONTAL );
 	
-	wxString m_rbToleranceSelectionChoices[] = { _("10%"), _("5%"), _("2%"), _("1%"), _("0.5%"), _("0.25%"), _("0.1%"), _("0.05%") };
+	wxString m_rbToleranceSelectionChoices[] = { _("10% / 5%"), _("<= 2%") };
 	int m_rbToleranceSelectionNChoices = sizeof( m_rbToleranceSelectionChoices ) / sizeof( wxString );
 	m_rbToleranceSelection = new wxRadioBox( m_panelColorCode, wxID_ANY, _("Tolerance"), wxDefaultPosition, wxDefaultSize, m_rbToleranceSelectionNChoices, m_rbToleranceSelectionChoices, 1, wxRA_SPECIFY_COLS );
 	m_rbToleranceSelection->SetSelection( 0 );
@@ -1199,7 +1199,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
 	m_staticText35->Wrap( -1 );
 	fgSizerColoCode->Add( m_staticText35, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
 	
-	m_Band4Label = new wxStaticText( m_panelColorCode, wxID_ANY, _("4rd Band"), wxDefaultPosition, wxDefaultSize, 0 );
+	m_Band4Label = new wxStaticText( m_panelColorCode, wxID_ANY, _("4th Band"), wxDefaultPosition, wxDefaultSize, 0 );
 	m_Band4Label->Wrap( -1 );
 	fgSizerColoCode->Add( m_Band4Label, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
 	
diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp
index 96663d1..5267723 100644
--- a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp
+++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp
@@ -17732,7 +17732,7 @@
                                             <property name="caption"></property>
                                             <property name="caption_visible">1</property>
                                             <property name="center_pane">0</property>
-                                            <property name="choices">&quot;10%&quot; &quot;5%&quot; &quot;2%&quot; &quot;1%&quot; &quot;0.5%&quot; &quot;0.25%&quot; &quot;0.1%&quot; &quot;0.05%&quot;</property>
+                                            <property name="choices">&quot;10% / 5%&quot; &quot;&lt;= 2%&quot;</property>
                                             <property name="close_button">1</property>
                                             <property name="context_help"></property>
                                             <property name="context_menu">1</property>
@@ -18101,7 +18101,7 @@
                                                     <property name="gripper">0</property>
                                                     <property name="hidden">0</property>
                                                     <property name="id">wxID_ANY</property>
-                                                    <property name="label">4rd Band</property>
+                                                    <property name="label">4th Band</property>
                                                     <property name="max_size"></property>
                                                     <property name="maximize_button">0</property>
                                                     <property name="maximum_size"></property>
-- 
2.7.4


Follow ups