From ff6a3482ecdbfc75b3a2d5e7bc0b085e542d869a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 29 Nov 2018 18:59:38 +0000 Subject: [PATCH] Remove on-kill-focus-validation. Fixes: lp:1805361 * https://bugs.launchpad.net/kicad/+bug/1805361 --- common/dialogs/dialog_page_settings.cpp | 53 ++++++++++--------- common/widgets/unit_binder.cpp | 45 +++++----------- eeschema/dialogs/dialog_edit_label.cpp | 11 ++-- eeschema/dialogs/dialog_edit_line_style.cpp | 2 +- eeschema/dialogs/dialog_edit_one_field.cpp | 2 +- .../dialogs/dialog_lib_edit_draw_item.cpp | 2 +- eeschema/dialogs/dialog_lib_edit_pin.cpp | 6 +-- eeschema/dialogs/dialog_lib_edit_text.cpp | 2 +- include/widgets/unit_binder.h | 35 +++--------- pcbnew/class_track.h | 4 ++ pcbnew/dialogs/dialog_copper_zones.cpp | 23 ++++---- .../dialog_edit_footprint_for_BoardEditor.cpp | 2 +- .../dialog_edit_footprint_for_fp_editor.cpp | 4 +- pcbnew/dialogs/dialog_export_svg.cpp | 8 +-- .../dialog_global_edit_text_and_graphics.cpp | 14 ++--- .../dialog_non_copper_zones_properties.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 10 ++-- pcbnew/dialogs/dialog_plot.cpp | 4 +- .../dialog_pns_diff_pair_dimensions.cpp | 4 +- pcbnew/dialogs/dialog_set_grid.cpp | 16 ++---- pcbnew/dialogs/dialog_text_properties.cpp | 12 ++--- .../dialogs/dialog_track_via_properties.cpp | 13 +++-- .../panel_setup_feature_constraints.cpp | 12 ++--- pcbnew/dialogs/panel_setup_layers.cpp | 6 +-- pcbnew/target_edit.cpp | 8 ++- 25 files changed, 130 insertions(+), 170 deletions(-) diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 45b15b7cda..726c5b4079 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -120,10 +120,8 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent, wxSize aMaxUserSizeMils ) : DIALOG_PAGES_SETTINGS_BASE( parent ), m_initialized( false ), - m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false, - MIN_PAGE_SIZE * IU_PER_MILS, aMaxUserSizeMils.x * IU_PER_MILS ), - m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false, - MIN_PAGE_SIZE * IU_PER_MILS, aMaxUserSizeMils.y * IU_PER_MILS ) + m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ), + m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false ) { m_parent = parent; m_screen = m_parent->GetScreen(); @@ -234,6 +232,12 @@ void DIALOG_PAGES_SETTINGS::initDialog() void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event ) { + if( !m_customSizeX.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.x ) ) ) + return; + + if( !m_customSizeY.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.y ) ) ) + return; + if( SavePageSettings() ) { m_screen->SetModify(); @@ -423,7 +427,7 @@ void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event ) bool DIALOG_PAGES_SETTINGS::SavePageSettings() { - bool retSuccess = false; + bool success = false; wxString fileName = GetWksFileName(); @@ -453,13 +457,10 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings() { GetCustomSizeMilsFromDialog(); - retSuccess = m_pageInfo.SetType( PAGE_INFO::Custom ); + success = m_pageInfo.SetType( PAGE_INFO::Custom ); - if( retSuccess ) + if( success ) { - if( !m_customSizeX.Validate( true ) || !m_customSizeY.Validate( true ) ) - return false; - PAGE_INFO::SetCustomWidthMils( m_layout_size.x ); PAGE_INFO::SetCustomHeightMils( m_layout_size.y ); @@ -471,42 +472,42 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings() { // search for longest common string first, e.g. A4 before A if( paperType.Contains( PAGE_INFO::USLetter ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::USLetter ); + success = m_pageInfo.SetType( PAGE_INFO::USLetter ); else if( paperType.Contains( PAGE_INFO::USLegal ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::USLegal ); + success = m_pageInfo.SetType( PAGE_INFO::USLegal ); else if( paperType.Contains( PAGE_INFO::USLedger ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::USLedger ); + success = m_pageInfo.SetType( PAGE_INFO::USLedger ); else if( paperType.Contains( PAGE_INFO::GERBER ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::GERBER ); + success = m_pageInfo.SetType( PAGE_INFO::GERBER ); else if( paperType.Contains( PAGE_INFO::A4 ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::A4 ); + success = m_pageInfo.SetType( PAGE_INFO::A4 ); else if( paperType.Contains( PAGE_INFO::A3 ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::A3 ); + success = m_pageInfo.SetType( PAGE_INFO::A3 ); else if( paperType.Contains( PAGE_INFO::A2 ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::A2 ); + success = m_pageInfo.SetType( PAGE_INFO::A2 ); else if( paperType.Contains( PAGE_INFO::A1 ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::A1 ); + success = m_pageInfo.SetType( PAGE_INFO::A1 ); else if( paperType.Contains( PAGE_INFO::A0 ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::A0 ); + success = m_pageInfo.SetType( PAGE_INFO::A0 ); else if( paperType.Contains( PAGE_INFO::A ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::A ); + success = m_pageInfo.SetType( PAGE_INFO::A ); else if( paperType.Contains( PAGE_INFO::B ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::B ); + success = m_pageInfo.SetType( PAGE_INFO::B ); else if( paperType.Contains( PAGE_INFO::C ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::C ); + success = m_pageInfo.SetType( PAGE_INFO::C ); else if( paperType.Contains( PAGE_INFO::D ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::D ); + success = m_pageInfo.SetType( PAGE_INFO::D ); else if( paperType.Contains( PAGE_INFO::E ) ) - retSuccess = m_pageInfo.SetType( PAGE_INFO::E ); + success = m_pageInfo.SetType( PAGE_INFO::E ); - if( retSuccess ) + if( success ) { int choice = m_orientationComboBox->GetSelection(); m_pageInfo.SetPortrait( choice != 0 ); } } - if( !retSuccess ) + if( !success ) { wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) ); m_pageInfo.SetType( PAGE_INFO::A4 ); diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 16f26d1b84..4e7b7abd29 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -35,7 +35,7 @@ wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent ); UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValue, wxStaticText* aUnitLabel, - bool aUseMils, int aMin, int aMax, bool allowEval ) : + bool aUseMils, bool allowEval ) : m_label( aLabel ), m_value( aValue ), m_unitLabel( aUnitLabel ), @@ -44,8 +44,6 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, // Fix the units (to the current units) for the life of the binder m_units = aParent->GetUserUnits(); m_useMils = aUseMils; - m_min = aMin; - m_max = aMax; m_allowEval = allowEval && dynamic_cast( m_value ); m_needsEval = false; @@ -92,24 +90,14 @@ void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent ) void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent ) { - if( aEvent.GetWindow() && aEvent.GetWindow()->GetId() == wxID_CANCEL ) + auto textEntry = dynamic_cast( m_value ); + + if( m_allowEval && textEntry ) { - // Don't eval or validate when focus lost due to Cancel. While most platforms - // suppress KillFocus events after a Cancel, MSW (at least) does not. - } - else - { - auto textEntry = dynamic_cast( m_value ); + if( m_eval.Process( textEntry->GetValue() ) ) + textEntry->ChangeValue( m_eval.Result() ); - if( m_allowEval && textEntry ) - { - if( m_eval.Process( textEntry->GetValue() ) ) - textEntry->ChangeValue( m_eval.Result() ); - - m_needsEval = false; - } - - Validate( true ); + m_needsEval = false; } aEvent.Skip(); @@ -127,31 +115,26 @@ wxString valueDescriptionFromLabel( wxStaticText* aLabel ) void UNIT_BINDER::delayedFocusHandler( wxCommandEvent& ) { - // Kill focus event handler must be temporarily disconnected, as displaying a message box - // will trigger the event handler and validation again, effectively creating an infinite loop - m_value->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), NULL, this ); - if( !m_errorMessage.IsEmpty() ) DisplayError( m_value->GetParent(), m_errorMessage ); m_errorMessage = wxEmptyString; m_value->SetFocus(); - m_value->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), NULL, this ); } -bool UNIT_BINDER::Validate( bool setFocusOnError ) +bool UNIT_BINDER::Validate( int aMin, int aMax, bool setFocusOnError ) { auto textEntry = dynamic_cast( m_value ); if( !textEntry || textEntry->GetValue() == INDETERMINATE ) return true; - if( m_min > INT_MIN && GetValue() < m_min ) + if( GetValue() < aMin ) { - m_errorMessage = wxString::Format( _( "%s must be larger than %s or equal." ), + m_errorMessage = wxString::Format( _( "%s must be at least %s." ), valueDescriptionFromLabel( m_label ), - StringFromValue( m_units, m_min, true ) ); + StringFromValue( m_units, aMin, true ) ); if( setFocusOnError ) { @@ -163,11 +146,11 @@ bool UNIT_BINDER::Validate( bool setFocusOnError ) return false; } - if( m_max < INT_MAX && GetValue() > m_max ) + if( GetValue() > aMax ) { - m_errorMessage = wxString::Format( _( "%s must be smaller than %s." ), + m_errorMessage = wxString::Format( _( "%s must be less than %s." ), valueDescriptionFromLabel( m_label ), - StringFromValue( m_units, m_max, true ) ); + StringFromValue( m_units, aMax, true ) ); if( setFocusOnError ) { diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index db3c893211..929f5c25e6 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -101,14 +101,14 @@ void SCH_EDIT_FRAME::EditSchematicText( SCH_TEXT* aTextItem ) } -// Conservative limits 0.01 to 250mm -const int minSize = (int)( 0.01 * IU_PER_MM ); -const int maxSize = (int)( 250 * IU_PER_MM ); +// Don't allow text to disappear; it can be difficult to correct if you can't select it +const int MIN_TEXTSIZE = (int)( 0.01 * IU_PER_MM ); +const int MAX_TEXTSIZE = INT_MAX; DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : DIALOG_LABEL_EDITOR_BASE( aParent ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false, minSize, maxSize ) + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ) { m_Parent = aParent; m_CurrentText = aTextItem; @@ -291,6 +291,9 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; + if( !m_textSize.Validate( MIN_TEXTSIZE, MAX_TEXTSIZE ) ) + return false; + wxString text; /* save old text in undo list if not already in edit */ diff --git a/eeschema/dialogs/dialog_edit_line_style.cpp b/eeschema/dialogs/dialog_edit_line_style.cpp index 1f5e81ede4..efd955698c 100644 --- a/eeschema/dialogs/dialog_edit_line_style.cpp +++ b/eeschema/dialogs/dialog_edit_line_style.cpp @@ -35,7 +35,7 @@ DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( SCH_EDIT_FRAME* aParent, SCH_LIN DIALOG_EDIT_LINE_STYLE_BASE( aParent ), m_frame( aParent ), m_line( aLine ), - m_width( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits, true, 0 ) + m_width( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits, true ) { m_sdbSizerApply->SetLabel( _( "Default" ) ); diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index f96b568b35..43e089cc37 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -79,7 +79,7 @@ DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxS DIALOG_LIB_EDIT_TEXT_BASE( aParent ), m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ), m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true, 0 ) + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ) { SetTitle( aTitle ); diff --git a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp index 3d0f372782..1307efd839 100644 --- a/eeschema/dialogs/dialog_lib_edit_draw_item.cpp +++ b/eeschema/dialogs/dialog_lib_edit_draw_item.cpp @@ -34,7 +34,7 @@ DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( LIB_EDIT_FRAME* aParent, L DIALOG_LIB_EDIT_DRAW_ITEM_BASE( aParent ), m_frame( aParent ), m_item( aItem ), - m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true, 0 ) + m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true ) { SetTitle( aItem->GetTypeName() + wxT( " " ) + GetTitle() ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index 812d25004a..dfc2dd8087 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -41,9 +41,9 @@ DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( LIB_EDIT_FRAME* parent, LIB_PIN* aPin m_pin( aPin ), m_posX( parent, m_posXLabel, m_posXCtrl, m_posXUnits, true ), m_posY( parent, m_posYLabel, m_posYCtrl, m_posYUnits, true ), - m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits, true, 0 ), - m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits, true, 0 ), - m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits, true, 0 ) + m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits, true ), + m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits, true ), + m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits, true ) { // Creates a dummy pin to show on a panel, inside this dialog: m_dummyPin = new LIB_PIN( *m_pin ); diff --git a/eeschema/dialogs/dialog_lib_edit_text.cpp b/eeschema/dialogs/dialog_lib_edit_text.cpp index e549db11a2..90c7416f07 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text.cpp @@ -35,7 +35,7 @@ DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT( LIB_EDIT_FRAME* aParent, LIB_TEXT* a DIALOG_LIB_EDIT_TEXT_BASE( aParent ), m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ), m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true, 0 ) + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ) { m_parent = aParent; m_graphicText = aText; diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index d6a366d055..4cf935b9da 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -49,15 +49,11 @@ public: * wxComboBox, wxStaticText, etc.). * @param aUnitLabel is the units label displayed after the text input widget * @param aUseMils specifies the use of mils for imperial units (instead of inches) - * @param aMin a minimum value (in internal units) for validation - * @param aMax a maximum value (in internal units) for validation * @param aAllowEval indicates \a aTextInput's content should be eval'ed before storing */ UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValue, wxStaticText* aUnitLabel, - bool aUseMils = false, - int aMin = INT_MIN, int aMax = INT_MAX, - bool aAllowEval = true ); + bool aUseMils = false, bool aAllowEval = true ); /** * Function SetUnits @@ -66,24 +62,6 @@ public: */ virtual void SetUnits( EDA_UNITS_T aUnits, bool aUseMils = false ); - /** - * Set the minimal accepted value (in Internal Units). - */ - void SetMin( int aMin ) - { - wxASSERT( aMin < m_max ); - m_min = aMin; - } - - /** - * Set the maximal accepted value (in Internal Units). - */ - void SetMax( int aMax ) - { - wxASSERT( aMax > m_min ); - m_max = aMax; - } - /** * Function SetValue * Sets new value (in Internal Units) for the text field, taking care of units conversion. @@ -118,12 +96,13 @@ public: /** * Function Validate - * Validates the control, informing the user of any errors found. + * Validates the control against the given range, informing the user of any errors found. * - * When called from an OK handler, \a setFocusOnError should be set to true. A negative - * return value indicates an error. + * @param aMin a minimum value (in internal units) for validation + * @param aMax a maximum value (in internal units) for validation + * @return false on error. */ - virtual bool Validate( bool setFocusOnError = false ); + virtual bool Validate( int aMin, int aMax, bool setFocusOnError = true ); void SetLabel( const wxString& aLabel ); @@ -155,8 +134,6 @@ protected: bool m_useMils; ///> Validation support. - int m_min; - int m_max; wxString m_errorMessage; ///> Evaluator diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 5255913845..7f57511a2d 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -60,6 +60,10 @@ enum VIATYPE_T #define MIN_VIA_DRAW_SIZE 4 /// Minimum size in pixel for full drawing +// Used for tracks and vias for algorithmic safety, not to enforce constraints +#define GEOMETRY_MIN_SIZE ( int )( 0.001 * IU_PER_MM ) + + /** * Function GetTrack * is a helper function to locate a trace segment having an end point at \a aPosition diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index cebb206a1d..cded643077 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -99,11 +99,11 @@ int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings ) DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) : DIALOG_COPPER_ZONE_BASE( aParent ), m_cornerSmoothingType( ZONE_SETTINGS::SMOOTHING_UNDEFINED ), - m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits, true, 0 ), - m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits, true, 0, ZONE_CLEARANCE_MAX_VALUE_MIL*IU_PER_MILS ), - m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits, true, ZONE_THICKNESS_MIN_VALUE_MIL*IU_PER_MILS ), - m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits, true, 0 ), - m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true, 0 ) + m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits, true ), + m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits, true ), + m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits, true ), + m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits, true ), + m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true ) { m_Parent = aParent; m_Config = Kiface().KifaceSettings(); @@ -225,6 +225,15 @@ void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event ) bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly ) { + if( !m_clearance.Validate( 0, Mils2iu( ZONE_CLEARANCE_MAX_VALUE_MIL ) ) ) + return false; + if( !m_minWidth.Validate( Mils2iu( ZONE_THICKNESS_MIN_VALUE_MIL ), INT_MAX ) ) + return false; + if( !m_cornerRadius.Validate( 0, INT_MAX ) ) + return false; + if( !m_spokeWidth.Validate( 0, INT_MAX ) ) + return false; + if( m_settings.m_FillMode == ZFM_SEGMENTS ) { KIDIALOG dlg( this, _( "The legacy segment fill mode is not recommended." @@ -260,12 +269,8 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly ) m_netNameShowFilter = m_ShowNetNameFilter->GetValue(); - if( !m_clearance.Validate( true ) ) - return false; m_settings.m_ZoneClearance = m_clearance.GetValue(); - if( !m_minWidth.Validate( true ) ) - return false; m_settings.m_ZoneMinThickness = m_minWidth.GetValue(); m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index 72591e1f3d..0544213f20 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -576,7 +576,7 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::Validate() } } - if( !m_netClearance.Validate( true ) ) + if( !m_netClearance.Validate( 0, INT_MAX ) ) return false; return true; diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index c7b077f932..6999ba7e22 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -59,7 +59,7 @@ int DIALOG_FOOTPRINT_FP_EDITOR::m_page = 0; // remember the last open page d DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aParent, MODULE* aModule ) : DIALOG_FOOTPRINT_FP_EDITOR_BASE( aParent ), - m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits, false, 0 ), + m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits, false ), m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, m_SolderMaskMarginUnits ), m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, m_SolderPasteMarginUnits ), m_inSelect( false ) @@ -528,7 +528,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::Validate() } } - if( !m_netClearance.Validate( true ) ) + if( !m_netClearance.Validate( 0, INT_MAX ) ) return false; return true; diff --git a/pcbnew/dialogs/dialog_export_svg.cpp b/pcbnew/dialogs/dialog_export_svg.cpp index 4f70e40f23..5015b0a51f 100644 --- a/pcbnew/dialogs/dialog_export_svg.cpp +++ b/pcbnew/dialogs/dialog_export_svg.cpp @@ -81,18 +81,12 @@ private: #define PLOTSVG_LAYERBASE wxT( "PlotSVGLayer_%d" ) #define PLOTSVG_DIR_KEY wxT( "PlotSVGDirectory" ) -// reasonable values for default pen width -#define WIDTH_MAX_VALUE (2 * IU_PER_MM) -#define WIDTH_MIN_VALUE (0.05 * IU_PER_MM) - - /* * DIALOG_EXPORT_SVG functions */ DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_BASE_FRAME* aParent, BOARD* aBoard ) : DIALOG_EXPORT_SVG_BASE( aParent ), - m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true, - WIDTH_MIN_VALUE, WIDTH_MAX_VALUE) + m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true ) { m_board = aBoard; m_config = Kiface().KifaceSettings(); diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index be68d80490..0c706ea956 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -103,10 +103,10 @@ protected: DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_EDIT_FRAME* parent ) : DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE( parent ), - m_lineWidth( parent, m_lineWidthLabel, m_LineWidthCtrl, m_lineWidthUnits, true, 0 ), - m_textWidth( parent, m_SizeXlabel, m_SizeXCtrl, m_SizeXunit, true, TEXTS_MIN_SIZE ), - m_textHeight( parent, m_SizeYlabel, m_SizeYCtrl, m_SizeYunit, true, TEXTS_MIN_SIZE ), - m_thickness( parent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnit, true, 0 ) + m_lineWidth( parent, m_lineWidthLabel, m_LineWidthCtrl, m_lineWidthUnits, true ), + m_textWidth( parent, m_SizeXlabel, m_SizeXCtrl, m_SizeXunit, true ), + m_textHeight( parent, m_SizeYlabel, m_SizeYCtrl, m_SizeYunit, true ), + m_thickness( parent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnit, true ) { m_parent = parent; m_brdSettings = &m_parent->GetDesignSettings(); @@ -315,9 +315,11 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( BOARD_COMMIT& aCommit, BOA bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() { - if( !m_textWidth.Validate( true ) || !m_textHeight.Validate( true ) || - !m_thickness.Validate( true ) || !m_lineWidth.Validate( true ) ) + if( !m_textWidth.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) + || !m_textHeight.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ) + { return false; + } BOARD_COMMIT commit( m_parent ); diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp index 981c0ff040..7316752f6a 100644 --- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp +++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp @@ -66,7 +66,7 @@ int InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSetting DIALOG_NON_COPPER_ZONES_EDITOR::DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) : DIALOG_NONCOPPER_ZONES_PROPERTIES_BASE( aParent ), - m_minWidth( aParent, m_MinWidthLabel, m_MinWidthCtrl, m_MinWidthUnits, true, 10*IU_PER_MILS ) + m_minWidth( aParent, m_MinWidthLabel, m_MinWidthCtrl, m_MinWidthUnits, true ) { m_parent = aParent; diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 6f711d1b34..bccb0c5e90 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -113,14 +113,14 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP m_padToDie( aParent, m_padToDieLabel, m_padToDieCtrl, m_padToDieUnits, true ), m_trapDelta( aParent, m_trapDeltaLabel, m_trapDeltaCtrl, m_trapDeltaUnits, true ), m_cornerRadius( aParent, m_cornerRadiusLabel, m_tcCornerRadius, m_cornerRadiusUnits, true ), - m_holeX( aParent, m_holeXLabel, m_holeXCtrl, m_holeXUnits, true, 0 ), - m_holeY( aParent, m_holeYLabel, m_holeYCtrl, m_holeYUnits, true, 0 ), + m_holeX( aParent, m_holeXLabel, m_holeXCtrl, m_holeXUnits, true ), + m_holeY( aParent, m_holeYLabel, m_holeYCtrl, m_holeYUnits, true ), m_OrientValidator( 1, &m_OrientValue ), m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits, true ), m_maskClearance( aParent, m_maskClearanceLabel, m_maskClearanceCtrl, m_maskClearanceUnits, true ), m_pasteClearance( aParent, m_pasteClearanceLabel, m_pasteClearanceCtrl, m_pasteClearanceUnits, true ), - m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true, 0 ), - m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits, true, 0 ) + m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true ), + m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits, true ) { m_currentPad = aPad; // aPad can be NULL, if the dialog is called // from the footprint editor to set default pad setup @@ -1543,6 +1543,8 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad ) return true; if( !m_localSettingsPanel->Validate() ) return true; + if( !m_spokeWidth.Validate( 0, INT_MAX ) ) + return false; m_OrientValidator.TransferFromWindow(); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 95504647b0..f0a78f3f09 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -39,8 +39,8 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT_BASE( aParent ), m_parent( aParent ), - m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true, 0 ), - m_defaultPenSize( aParent, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits, true, 0 ), + m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ), + m_defaultPenSize( aParent, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits, true ), m_trackWidthCorrection( aParent, m_widthAdjustLabel, m_widthAdjustCtrl, m_widthAdjustUnits, true ) { SetName( DLG_WINDOW_NAME ); diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp index c9a63cd447..8d120912fe 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp @@ -32,8 +32,8 @@ 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, 0 ), - m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit, true, 0 ), + m_traceWidth( aParent, m_traceWidthLabel, m_traceWidthText, m_traceWidthUnit, true ), + m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit, true ), m_viaGap( aParent, m_viaGapLabel, m_viaGapText, m_viaGapUnit, true ), m_sizes( aSizes ) { diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index a8cc2a78d3..6aa73c4eeb 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -73,10 +73,8 @@ DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent, const wxArrayString& m_fast_grid_opts( aGridChoices ), m_gridOriginX( aParent, m_staticTextGridPosX, m_GridOriginXCtrl, m_TextPosXUnits ), m_gridOriginY( aParent, m_staticTextGridPosY, m_GridOriginYCtrl, m_TextPosYUnits ), - m_userGridX( aParent, m_staticTextSizeX, m_OptGridSizeX, m_TextSizeXUnits, - true, MIN_GRID_SIZE, MAX_GRID_SIZE ), - m_userGridY( aParent, m_staticTextSizeY, m_OptGridSizeY, m_TextSizeYUnits, - true, MIN_GRID_SIZE, MAX_GRID_SIZE ) + m_userGridX( aParent, m_staticTextSizeX, m_OptGridSizeX, m_TextSizeXUnits ), + m_userGridY( aParent, m_staticTextSizeY, m_OptGridSizeY, m_TextSizeYUnits ) { m_comboBoxGrid1->Append( m_fast_grid_opts ); m_comboBoxGrid2->Append( m_fast_grid_opts ); @@ -94,16 +92,10 @@ DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent, const wxArrayString& bool DIALOG_SET_GRID::TransferDataFromWindow() { // Validate new settings - if( !m_gridOriginX.Validate( true ) ) + if( !m_userGridX.Validate( MIN_GRID_SIZE, MAX_GRID_SIZE ) ) return false; - if( !m_gridOriginY.Validate( true ) ) - return false; - - if( !m_userGridX.Validate( true ) ) - return false; - - if( !m_userGridY.Validate( true ) ) + if( !m_userGridY.Validate( MIN_GRID_SIZE, MAX_GRID_SIZE ) ) return false; // Apply the new settings diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index 91885209a3..90762258f5 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -54,9 +54,9 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO DIALOG_TEXT_PROPERTIES_BASE( aParent ), m_Parent( aParent ), m_DC( aDC ), m_item( aItem ), m_edaText( nullptr ), m_modText( nullptr ), m_pcbText( nullptr ), - m_textWidth( aParent, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits, true, TEXTS_MIN_SIZE ), - m_textHeight( aParent, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits, true, TEXTS_MIN_SIZE ), - m_thickness( aParent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits, true, 0 ), + m_textWidth( aParent, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits, true ), + m_textHeight( aParent, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits, true ), + m_thickness( aParent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits, true ), m_posX( aParent, m_PositionXLabel, m_PositionXCtrl, m_PositionXUnits ), m_posY( aParent, m_PositionYLabel, m_PositionYCtrl, m_PositionYUnits ), m_OrientValidator( 1, &m_OrientValue ) @@ -315,10 +315,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() return false; } - if( !m_textWidth.Validate( true ) || !m_textHeight.Validate( true ) ) - return false; - - if( !m_thickness.Validate( true ) ) + if( !m_textWidth.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) + || !m_textHeight.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) ) return false; BOARD_COMMIT commit( m_Parent ); diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index fde50a0982..b2f35157cb 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -34,8 +34,6 @@ #include #include -#define MIN_SIZE ( int )( 0.001 * IU_PER_MM ) - DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems, COMMIT& aCommit ) : @@ -47,11 +45,11 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ), m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, m_TrackEndXUnit ), m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ), - m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit, true, MIN_SIZE ), + m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit, true ), m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, m_ViaXUnit ), m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ), - m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit, true, MIN_SIZE ), - m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit, true, MIN_SIZE ), + m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit, true ), + m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit, true ), m_tracks( false ), m_vias( false ) { @@ -367,7 +365,8 @@ bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow() if( m_vias ) { - if( !m_viaDiameter.Validate( true ) || !m_viaDrill.Validate( true ) ) + if( !m_viaDiameter.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) + || !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) ) return false; if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate() @@ -390,7 +389,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow() if( m_tracks ) { - if( !m_trackWidth.Validate( true ) ) + if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) ) return false; } diff --git a/pcbnew/dialogs/panel_setup_feature_constraints.cpp b/pcbnew/dialogs/panel_setup_feature_constraints.cpp index 93045d33be..a949a3592d 100644 --- a/pcbnew/dialogs/panel_setup_feature_constraints.cpp +++ b/pcbnew/dialogs/panel_setup_feature_constraints.cpp @@ -32,12 +32,12 @@ PANEL_SETUP_FEATURE_CONSTRAINTS::PANEL_SETUP_FEATURE_CONSTRAINTS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : PANEL_SETUP_FEATURE_CONSTRAINTS_BASE( aParent->GetTreebook() ), - m_trackMinWidth( aFrame, m_TrackMinWidthTitle, m_TrackMinWidthCtrl, m_TrackMinWidthUnits, true, 0 ), - m_viaMinSize( aFrame, m_ViaMinTitle, m_SetViasMinSizeCtrl, m_ViaMinUnits, true, 0 ), - m_viaMinDrill( aFrame, m_ViaMinDrillTitle, m_SetViasMinDrillCtrl, m_ViaMinDrillUnits, true, 0 ), - m_uviaMinSize( aFrame, m_uviaMinSizeLabel, m_uviaMinSizeCtrl, m_uviaMinSizeUnits, true, 0 ), - m_uviaMinDrill( aFrame, m_uviaMinDrillLabel, m_uviaMinDrillCtrl, m_uviaMinDrillUnits, true, 0 ), - m_holeToHoleMin( aFrame, m_HoleToHoleTitle, m_SetHoleToHoleCtrl, m_HoleToHoleUnits, true, 0 ) + m_trackMinWidth( aFrame, m_TrackMinWidthTitle, m_TrackMinWidthCtrl, m_TrackMinWidthUnits, true ), + m_viaMinSize( aFrame, m_ViaMinTitle, m_SetViasMinSizeCtrl, m_ViaMinUnits, true ), + m_viaMinDrill( aFrame, m_ViaMinDrillTitle, m_SetViasMinDrillCtrl, m_ViaMinDrillUnits, true ), + m_uviaMinSize( aFrame, m_uviaMinSizeLabel, m_uviaMinSizeCtrl, m_uviaMinSizeUnits, true ), + m_uviaMinDrill( aFrame, m_uviaMinDrillLabel, m_uviaMinDrillCtrl, m_uviaMinDrillUnits, true ), + m_holeToHoleMin( aFrame, m_HoleToHoleTitle, m_SetHoleToHoleCtrl, m_HoleToHoleUnits, true ) { m_Frame = aFrame; m_BrdSettings = &m_Frame->GetBoard()->GetDesignSettings(); diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index db57f00338..5262fae153 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -137,8 +137,7 @@ static const LSET presets[] = PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ), m_Parent( aParent ), m_frame( aFrame ), - m_pcbThickness( aFrame, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true, - Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ) ) + m_pcbThickness( aFrame, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true ) { m_pcb = aFrame->GetBoard(); @@ -487,9 +486,6 @@ void PANEL_SETUP_LAYERS::OnCopperLayersChoice( wxCommandEvent& event ) bool PANEL_SETUP_LAYERS::TransferDataFromWindow() { - if( !m_pcbThickness.Validate( true ) ) - return false; - if( !testLayerNames() ) return false; diff --git a/pcbnew/target_edit.cpp b/pcbnew/target_edit.cpp index 0bc3abaa5b..933da3c40d 100644 --- a/pcbnew/target_edit.cpp +++ b/pcbnew/target_edit.cpp @@ -94,8 +94,8 @@ DIALOG_TARGET_PROPERTIES::DIALOG_TARGET_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB m_Parent( aParent ), m_DC( aDC ), m_Target( aTarget ), - m_Size( aParent, m_sizeLabel, m_sizeCtrl, m_sizeUnits, true, 0 ), - m_Thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true, 0 ) + m_Size( aParent, m_sizeLabel, m_sizeCtrl, m_sizeUnits, true ), + m_Thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true ) { m_sdbSizerButtsOK->SetDefault(); @@ -119,6 +119,10 @@ bool DIALOG_TARGET_PROPERTIES::TransferDataToWindow() bool DIALOG_TARGET_PROPERTIES::TransferDataFromWindow() { + // Zero-size targets are hard to see/select. + if( !m_Size.Validate( Mils2iu( 1 ), INT_MAX ) ) + return false; + BOARD_COMMIT commit( m_Parent ); commit.Modify( m_Target );