← Back to team overview

kicad-developers team mailing list archive

Locked module really locked patch

 

Hi again,

Currently it is not allowed to transform a module using hotkeys. However,
moving it through the menu is fine. The attached patch adds checking for
locked state in menu operations, too.

Regards,

Marco
=== modified file 'pcbnew/edit.cpp'
--- pcbnew/edit.cpp	2010-08-10 18:34:26 +0000
+++ pcbnew/edit.cpp	2010-08-24 22:12:13 +0000
@@ -38,6 +38,7 @@
     int         itmp;
     INSTALL_DC( dc, DrawPanel );
     BOARD_ITEM* DrawStruct = GetCurItem();
+    MODULE* module;
 
     DrawPanel->CursorOff( &dc );
 
@@ -605,9 +606,21 @@
             g_Drag_Pistes_On = false;
             break;
         }
-        GetScreen()->m_Curseur = ((MODULE*) GetCurItem())->m_Pos;
-        DrawPanel->MouseToCursorSchema();
-        StartMove_Module( (MODULE*) GetCurItem(), &dc );
+	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;
+	}
+	else
+	{
+	    GetScreen()->m_Curseur = ((MODULE*) GetCurItem())->m_Pos;
+	    DrawPanel->MouseToCursorSchema();
+	    StartMove_Module( (MODULE*) GetCurItem(), &dc );
+	}
         break;
 
     case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST:      /* get module by name and move it */
@@ -628,10 +641,22 @@
 
         if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
             break;
-        if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) )
-        {
-            SetCurItem( NULL );
-        }
+	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;
+	}
+	else
+	{
+	    if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) )
+	    {
+	        SetCurItem( NULL );
+	    }
+	}
         break;
 
     case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
@@ -643,11 +668,22 @@
 
         if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
             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 );
-        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;
+	}
+	else
+	{
+	    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 );
+	}
+	break;
 
     case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
         DrawPanel->MouseToCursorSchema();
@@ -658,9 +694,21 @@
 
         if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
             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 );
+	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;
+	}
+	else
+	{
+	    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 );
+	}
         break;
 
     case ID_POPUP_PCB_CHANGE_SIDE_MODULE:
@@ -671,11 +719,21 @@
             SetCurItem( GetCurItem()->GetParent() );
         if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
             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 );
+	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;
+	}
+	else
+	{
+	    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;
 
     case ID_POPUP_PCB_EDIT_MODULE:
@@ -690,15 +748,43 @@
         break;
 
     case ID_POPUP_PCB_DRAG_PAD_REQUEST:
-        g_Drag_Pistes_On = true;
-        DrawPanel->MouseToCursorSchema();
-        StartMovePad( (D_PAD*) GetCurItem(), &dc );
+        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;
+	}
+	else
+	{
+	    g_Drag_Pistes_On = true;
+	    DrawPanel->MouseToCursorSchema();
+	    StartMovePad( (D_PAD*) GetCurItem(), &dc );
+	}
         break;
 
     case ID_POPUP_PCB_MOVE_PAD_REQUEST:
-        g_Drag_Pistes_On = false;
-        DrawPanel->MouseToCursorSchema();
-        StartMovePad( (D_PAD*) GetCurItem(), &dc );
+        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;
+	}
+	else
+	{
+	    g_Drag_Pistes_On = false;
+	    DrawPanel->MouseToCursorSchema();
+	    StartMovePad( (D_PAD*) GetCurItem(), &dc );
+	}
         break;
 
     case ID_POPUP_PCB_EDIT_PAD:

Follow ups