diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index e2ddb64cb3..2ffa5a47f2 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -257,7 +257,14 @@ public: wxDC* DC ); void AddPad( MODULE* Module, bool draw ); - void DeletePad( D_PAD* Pad ); + /** Function DeletePad + * Delete the pad aPad. + * Refresh the modified screen area + * Refresh modified parameters of the parent module (bounding box, last date) + * @param aPad = the pad to delete + * @param aQuery = true to promt for confirmation, false to delete silently + */ + void DeletePad( D_PAD* aPad, bool aQuery = true ); void StartMovePad( D_PAD* Pad, wxDC* DC ); void RotatePad( D_PAD* Pad, wxDC* DC ); void PlacePad( D_PAD* Pad, wxDC* DC ); diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index e57bdeb734..075c139b3a 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -118,7 +118,7 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item ) switch( Item->Type() ) { case TYPE_PAD: - DeletePad( (D_PAD*) Item ); + DeletePad( (D_PAD*) Item, false ); break; case TYPE_TEXTE_MODULE: diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index bb79bcca5a..a079b750fd 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -518,7 +518,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_DELETE_PAD: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); - DeletePad( (D_PAD*) GetScreen()->GetCurItem() ); + DeletePad( (D_PAD*) GetScreen()->GetCurItem(), false ); SetCurItem( NULL ); DrawPanel->MouseToCursorSchema(); break; diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index f6e8dcf48d..bac1bf9be1 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -116,19 +116,13 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), break; case ID_MODEDIT_DELETE_ITEM_BUTT: - - // Item in edit, cannot delete it - if( DrawStruct && (DrawStruct->m_Flags != 0) ) + if( DrawStruct == NULL || // No item to delete + (DrawStruct->m_Flags != 0) ) // Item in edit, cannot delete it break; - DrawStruct = ModeditLocateAndDisplay(); - if( DrawStruct == NULL || (DrawStruct->m_Flags != 0) ) - break; - if( DrawStruct->Type() != TYPE_MODULE ) //GetBoard()->m_Modules ) + if( DrawStruct->Type() != TYPE_MODULE ) // Cannot delete the module itself { - // Cannot delete the module itself SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); RemoveStruct( DrawStruct ); - DrawStruct = NULL; SetCurItem( NULL ); } break; diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index 273c828667..9ddd692b65 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -227,30 +227,36 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw ) } -/* Function to delete the pad. */ -void WinEDA_BasePcbFrame::DeletePad( D_PAD* Pad ) +/** Function DeletePad + * Delete the pad aPad. + * Refresh the modified screen area + * Refresh modified parameters of the parent module (bounding box, last date) + * @param aPad = the pad to delete + * @param aQuery = true to promt for confirmation, false to delete silently + */ +void WinEDA_BasePcbFrame::DeletePad( D_PAD* aPad, bool aQuery ) { MODULE* Module; - wxString line; - - if( Pad == NULL ) + + if( aPad == NULL ) return; - Module = (MODULE*) Pad->GetParent(); + Module = (MODULE*) aPad->GetParent(); Module->m_LastEdit_Time = time( NULL ); - line.Printf( _( "Delete Pad (module %s %s) " ), - GetChars( Module->m_Reference->m_Text ), - GetChars( Module->m_Value->m_Text ) ); - if( !IsOK( this, line ) ) - return; + if( aQuery ) + { + wxString msg; + msg.Printf( _( "Delete Pad (module %s %s) " ), + GetChars( Module->m_Reference->m_Text ), + GetChars( Module->m_Value->m_Text ) ); + if( !IsOK( this, msg ) ) + return; + } m_Pcb->m_Status_Pcb = 0; - - Pad->DeleteStructure(); - + aPad->DeleteStructure(); DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); - Module->Set_Rectangle_Encadrement(); OnModify();