From 72cf340119386c2557f75295aa1781a406d51b61 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 Sep 2018 14:01:42 +0100 Subject: [PATCH] Validate differential pair dimensions. Fixes: lp:1789293 * https://bugs.launchpad.net/kicad/+bug/1789293 --- .../dialog_pns_diff_pair_dimensions.cpp | 12 ++++- .../dialog_pns_diff_pair_dimensions_base.cpp | 31 ++++++------- .../dialog_pns_diff_pair_dimensions_base.fbp | 36 ++++++--------- .../dialog_pns_diff_pair_dimensions_base.h | 5 +-- .../dialogs/panel_setup_tracks_and_vias.cpp | 45 +++++++++++++++++++ ...p => panel_setup_tracks_and_vias_base.fbp} | 0 6 files changed, 84 insertions(+), 45 deletions(-) rename pcbnew/dialogs/{panel_setup_tracks_and_vias.fbp => panel_setup_tracks_and_vias_base.fbp} (100%) diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp index b7f0be397a..c9a63cd447 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp @@ -27,12 +27,13 @@ #include #include #include +#include DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( EDA_DRAW_FRAME* aParent, PNS::SIZES_SETTINGS& aSizes ) : DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE( aParent ), - m_traceWidth( aParent, m_traceWidthLabel, m_traceWidthText, m_traceWidthUnit, true ), - m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit, true ), + m_traceWidth( aParent, m_traceWidthLabel, m_traceWidthText, m_traceWidthUnit, true, 0 ), + m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit, true, 0 ), m_viaGap( aParent, m_viaGapLabel, m_viaGapText, m_viaGapUnit, true ), m_sizes( aSizes ) { @@ -49,6 +50,13 @@ bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; + if( m_traceGap.GetValue() <= 0 ) + { + DisplayErrorMessage( this, _( "Trace gap must be greater than 0." ) ); + m_traceGapText->SetFocus(); + return false; + } + // Save widgets' values to settings m_sizes.SetDiffPairGap( m_traceGap.GetValue() ); m_sizes.SetDiffPairViaGap( m_viaGap.GetValue() ); diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.cpp b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.cpp index e8eff1b2fa..581fae08ca 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.cpp +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jul 17 2016) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "widgets/text_ctrl_eval.h" @@ -19,62 +19,59 @@ DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE( wxWi bSizer7 = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 0, 3, 0, 0 ); + fgSizer1 = new wxFlexGridSizer( 0, 3, 5, 0 ); fgSizer1->AddGrowableCol( 1 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_traceWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_traceWidthLabel->Wrap( -1 ); - fgSizer1->Add( m_traceWidthLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); + fgSizer1->Add( m_traceWidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_traceWidthText = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_traceWidthText, 0, wxALL|wxEXPAND, 5 ); + fgSizer1->Add( m_traceWidthText, 0, wxEXPAND|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_traceWidthUnit = new wxStaticText( this, wxID_ANY, _("u"), wxDefaultPosition, wxDefaultSize, 0 ); m_traceWidthUnit->Wrap( -1 ); - fgSizer1->Add( m_traceWidthUnit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_traceWidthUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_traceGapLabel = new wxStaticText( this, wxID_ANY, _("Trace gap:"), wxDefaultPosition, wxDefaultSize, 0 ); m_traceGapLabel->Wrap( -1 ); - fgSizer1->Add( m_traceGapLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); + fgSizer1->Add( m_traceGapLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_traceGapText = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_traceGapText, 0, wxALL|wxEXPAND, 5 ); + fgSizer1->Add( m_traceGapText, 0, wxEXPAND|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_traceGapUnit = new wxStaticText( this, wxID_ANY, _("u"), wxDefaultPosition, wxDefaultSize, 0 ); m_traceGapUnit->Wrap( -1 ); - fgSizer1->Add( m_traceGapUnit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_traceGapUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_viaGapLabel = new wxStaticText( this, wxID_ANY, _("Via gap:"), wxDefaultPosition, wxDefaultSize, 0 ); m_viaGapLabel->Wrap( -1 ); m_viaGapLabel->Enable( false ); - fgSizer1->Add( m_viaGapLabel, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_viaGapLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_viaGapText = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_viaGapText->Enable( false ); - fgSizer1->Add( m_viaGapText, 0, wxALL|wxEXPAND, 5 ); + fgSizer1->Add( m_viaGapText, 0, wxEXPAND|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_viaGapUnit = new wxStaticText( this, wxID_ANY, _("u"), wxDefaultPosition, wxDefaultSize, 0 ); m_viaGapUnit->Wrap( -1 ); m_viaGapUnit->Enable( false ); - fgSizer1->Add( m_viaGapUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgSizer1->Add( m_viaGapUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - bSizer7->Add( fgSizer1, 0, wxEXPAND|wxALL, 5 ); + bSizer7->Add( fgSizer1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); m_viaTraceGapEqual = new wxCheckBox( this, wxID_ANY, _("Via gap same as trace gap"), wxDefaultPosition, wxDefaultSize, 0 ); m_viaTraceGapEqual->SetValue(true); bSizer7->Add( m_viaTraceGapEqual, 0, wxALL|wxEXPAND, 10 ); - - bSizer7->Add( 0, 0, 1, wxEXPAND, 5 ); - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer7->Add( m_staticline1, 0, wxEXPAND, 5 ); + bSizer7->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_stdButtons = new wxStdDialogButtonSizer(); m_stdButtonsOK = new wxButton( this, wxID_OK ); diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.fbp b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.fbp index 1105415299..4522c8ac50 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.fbp +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.fbp @@ -94,8 +94,8 @@ wxVERTICAL none - 5 - wxEXPAND|wxALL + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 3 @@ -108,10 +108,10 @@ wxFLEX_GROWMODE_SPECIFIED none 0 - 0 + 5 5 - wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -194,7 +194,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 1 @@ -285,7 +285,7 @@ 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -368,7 +368,7 @@ 5 - wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -451,7 +451,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 1 @@ -542,7 +542,7 @@ 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -625,7 +625,7 @@ 5 - wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -708,7 +708,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 1 @@ -799,7 +799,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -972,17 +972,7 @@ 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 1 diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.h b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.h index e4f2921624..52920dc935 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.h +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jul 17 2016) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE_H__ @@ -11,7 +11,6 @@ #include #include #include -class DIALOG_SHIM; class TEXT_CTRL_EVAL; #include "dialog_shim.h" diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp index 47e856b1c1..32620e2ff1 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp @@ -237,6 +237,51 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData() } } + // Test diff pairs + for( int row = 0; row < m_diffPairsGrid->GetNumberRows(); ++row ) + { + wxString tvalue = m_diffPairsGrid->GetCellValue( row, 0 ); + + if( tvalue.IsEmpty() ) + continue; + + if( ValueFromString( m_Frame->GetUserUnits(), tvalue ) < minTrackWidth ) + { + msg.Printf( _( "Differential pair track width less than minimum track width (%s)." ), + StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) ); + m_Parent->SetError( msg, this, m_diffPairsGrid, row, 0 ); + return false; + } + + wxString gap = m_diffPairsGrid->GetCellValue( row, 1 ); + + if( gap.IsEmpty() ) + { + msg = _( "No differential pair gap defined." ); + m_Parent->SetError( msg, this, m_diffPairsGrid, row, 1 ); + return false; + } + + if( ValueFromString( m_Frame->GetUserUnits(), gap ) < 0 ) + { + msg.Printf( _( "Differential pair gap cannot be negative." ) ); + m_Parent->SetError( msg, this, m_diffPairsGrid, row, 1 ); + return false; + } + + wxString viaGap = m_diffPairsGrid->GetCellValue( row, 2 ); + + if( viaGap.IsEmpty() ) + continue; + + if( ValueFromString( m_Frame->GetUserUnits(), viaGap ) < 0 ) + { + msg.Printf( _( "Differential pair via gap cannot be negative." ) ); + m_Parent->SetError( msg, this, m_diffPairsGrid, row, 2 ); + return false; + } + } + return true; } diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.fbp b/pcbnew/dialogs/panel_setup_tracks_and_vias_base.fbp similarity index 100% rename from pcbnew/dialogs/panel_setup_tracks_and_vias.fbp rename to pcbnew/dialogs/panel_setup_tracks_and_vias_base.fbp