From 23b7e766a65d6a9657cf618ff5c121403a8c25e3 Mon Sep 17 00:00:00 2001 From: Marco Mattila Date: Sun, 29 Aug 2010 16:31:27 -0500 Subject: [PATCH] https://lists.launchpad.net/kicad-developers/msg05245.html --- pcbnew/edit.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++++-- pcbnew/hotkeys.cpp | 20 ------------ 2 files changed, 77 insertions(+), 23 deletions(-) diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 8906ab28e7..2a923c3dda 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -38,6 +38,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) int itmp; INSTALL_DC( dc, DrawPanel ); BOARD_ITEM* DrawStruct = GetCurItem(); + MODULE* module; DrawPanel->CursorOff( &dc ); @@ -608,6 +609,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) g_Drag_Pistes_On = false; break; } + module = (MODULE*) GetCurItem(); + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "Footprint %s found, but it is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } GetScreen()->m_Curseur = ((MODULE*) GetCurItem())->m_Pos; DrawPanel->MouseToCursorSchema(); StartMove_Module( (MODULE*) GetCurItem(), &dc ); @@ -615,6 +625,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: /* get module by name and move it */ SetCurItem( GetModuleByName() ); + module = (MODULE*) GetCurItem(); + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "Footprint %s found, but it is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } if( GetCurItem() ) { DrawPanel->MouseToCursorSchema(); @@ -631,6 +650,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; + module = (MODULE*) GetCurItem(); + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "Footprint %s found, but it is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) ) { SetCurItem( NULL ); @@ -646,7 +674,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; - + module = (MODULE*) GetCurItem(); + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "Footprint %s found, but it is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */ SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos); Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, true ); @@ -661,6 +697,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; + module = (MODULE*) GetCurItem(); + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "Footprint %s found, but it is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */ SaveCopyInUndoList(GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->m_Pos); Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, true ); @@ -674,10 +719,17 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) SetCurItem( GetCurItem()->GetParent() ); if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; - + module = (MODULE*) GetCurItem(); + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "Footprint %s found, but it is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple flip, no other edition in progress */ SaveCopyInUndoList(GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->m_Pos); - Change_Side_Module( (MODULE*) GetCurItem(), &dc ); break; @@ -693,12 +745,34 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_DRAG_PAD_REQUEST: + module = (MODULE*) GetCurItem()->GetParent(); + if( !module || module->Type() != TYPE_MODULE ) + break; + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "The parent (%s) of the pad is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } g_Drag_Pistes_On = true; DrawPanel->MouseToCursorSchema(); StartMovePad( (D_PAD*) GetCurItem(), &dc ); break; case ID_POPUP_PCB_MOVE_PAD_REQUEST: + module = (MODULE*) GetCurItem()->GetParent(); + if( !module || module->Type() != TYPE_MODULE ) + break; + if( module->IsLocked() ) + { + wxString msg; + msg.Printf( _( "The parent (%s) of the pad is locked" ), + module->m_Reference->m_Text.GetData() ); + DisplayInfoMessage( this, msg ); + break; + } g_Drag_Pistes_On = false; DrawPanel->MouseToCursorSchema(); StartMovePad( (D_PAD*) GetCurItem(), &dc ); diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index e471b966d1..3c97e323cf 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -945,17 +945,6 @@ bool WinEDA_PcbFrame::OnHotkeyMoveItem( int aIdCommand ) case TYPE_MODULE: { - MODULE* module = (MODULE*) item; - - // a footprint is found, but locked or on an other layer - if( module->IsLocked() ) - { - wxString msg; - msg.Printf( _( "Footprint %s found, but locked" ), - module->m_Reference->m_Text.GetData() ); - DisplayInfoMessage( this, msg ); - break; - } if( aIdCommand == HK_MOVE_ITEM ) evt_type = ID_POPUP_PCB_MOVE_MODULE_REQUEST; if( aIdCommand == HK_DRAG_ITEM ) @@ -1040,15 +1029,6 @@ bool WinEDA_PcbFrame::OnHotkeyRotateItem( int aIdCommand ) { case TYPE_MODULE: { - MODULE* module = (MODULE*) item; - if( module->IsLocked() ) - { - wxString msg; - msg.Printf( _( "Footprint %s is locked" ), - module->m_Reference->m_Text.GetData() ); - DisplayInfoMessage( this, msg ); - break; - } if( aIdCommand == HK_ROTATE_ITEM ) // Rotation evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE; if( aIdCommand == HK_FLIP_FOOTPRINT ) // move to other side