From 2fd7f4ca1439740e9c8283a0af30848403200504 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 16 Jan 2011 13:49:58 +0100 Subject: [PATCH] StrPurge( char* text ): Fix incorrect behavior when string text is void. Very minor enhancement in module edition dialogs. Fix a minor bug in design rules editor: in Global Rules Edition: drill values > via diameter not checked and the first item (track or via) in list was not checked (explains Bug 702177, that is not really a bug) --- common/string.cpp | 6 ++--- pcbnew/class_pad.cpp | 2 +- pcbnew/dialogs/dialog_design_rules.cpp | 27 +++++++++++++++---- .../dialog_edit_module_for_BoardEditor.cpp | 8 ++++++ .../dialog_edit_module_for_Modedit.cpp | 8 ++++++ 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/common/string.cpp b/common/string.cpp index d4181fce80..c59082a5ba 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -37,8 +37,8 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar ) } -/* Remove training spaces in text - * return a pointer on the first non space char in text +/* Remove leading and training spaces, tabs and end of line chars in text + * return a pointer on the first n char in text */ char* StrPurge( char* text ) { @@ -46,7 +46,7 @@ char* StrPurge( char* text ) if( text ) { - while( strchr( whitespace, *text ) ) + while( *text && strchr( whitespace, *text ) ) ++text; char* cp = text + strlen( text ) - 1; diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 2ba2a1c2d7..96b09f46bb 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -468,7 +468,7 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) /* read Netname */ ReadDelimitedText( BufLine, PtLine, sizeof(BufLine) ); SetNetname( CONV_FROM_UTF8( StrPurge( BufLine ) ) ); - break; + break; case 'P': nn = sscanf( PtLine, "%d %d", &m_Pos0.x, &m_Pos0.y ); diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index fb9bf20085..c7549f81fb 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -1069,7 +1069,8 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() } // Test list of values for specific vias and tracks - for( int row = 1; row < m_gridTrackWidthList->GetNumberRows(); ++row ) + // Test tracks + for( int row = 0; row < m_gridTrackWidthList->GetNumberRows(); ++row ) { wxString tvalue = m_gridTrackWidthList->GetCellValue( row, 0 ); if( tvalue.IsEmpty() ) @@ -1096,15 +1097,20 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() } } - for( int row = 1; row < m_gridViaSizeList->GetNumberRows(); ++row ) + // Test vias + for( int row = 0; row < m_gridViaSizeList->GetNumberRows(); ++row ) { wxString tvalue = m_gridViaSizeList->GetCellValue( row, 0 ); if( tvalue.IsEmpty() ) continue; - int viadia = ReturnValueFromString( g_UserUnit, - tvalue, + int viadia = ReturnValueFromString( g_UserUnit, tvalue, m_Parent->m_InternalUnits ); + int viadrill = 0; + wxString drlvalue = m_gridViaSizeList->GetCellValue( row, 1 ); + if( !drlvalue.IsEmpty() ) + viadrill = ReturnValueFromString( g_UserUnit, drlvalue, + m_Parent->m_InternalUnits ); if( viadia < minViaDia ) { result = false; @@ -1113,7 +1119,18 @@ bool DIALOG_DESIGN_RULES::TestDataValidity() m_MessagesList->AppendToPage( msg ); } - if( viadia > 10000 ) + + if( viadia < viadrill ) + { + result = false; + msg.Printf( _( "Extra Via %d Size %s < Drill Size %s
" ), + row + 1, GetChars( tvalue ), GetChars( drlvalue ) ); + + m_MessagesList->AppendToPage( msg ); + } + + // Test for a reasonnable via size: + if( viadia > 10000 ) // 1 inch! { result = false; msg.Printf( _( "Extra Via %d Size%s > 1 inch!
" ), diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index fa64804f5d..ab6ccb56bf 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -275,6 +275,14 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), BoxSizer, UNSCALED_UNITS, 1 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); + + // if m_3D_ShapeNameListBox is not empty, preselect first 3D shape + if( m_3D_ShapeNameListBox->GetCount() > 0 ) + { + m_LastSelected3DShapeIndex = 0; + m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex ); + Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] ); + } } diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index b00516f18f..3d1ccb5ad0 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -156,6 +156,14 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() else msg.Printf( wxT( "%.1f" ), m_CurrentModule->m_LocalSolderPasteMarginRatio * 100.0 ); m_SolderPasteMarginRatioCtrl->SetValue( msg ); + + // if m_3D_ShapeNameListBox is not empty, preselect first 3D shape + if( m_3D_ShapeNameListBox->GetCount() > 0 ) + { + m_LastSelected3DShapeIndex = 0; + m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex ); + Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] ); + } }