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.
This commit is contained in:
Diego Herranz 2017-02-25 06:22:17 +00:00 committed by Wayne Stambaugh
parent e96673ed8d
commit 0a29e94a60
3 changed files with 17 additions and 15 deletions

View File

@ -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();

View File

@ -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 );

View File

@ -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>