← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Locked modules locked in block operations

 

The following patch adds a separate checkbox for locked modules in the
block operation dialog window. It also enables the dialog window for
block flipping.

marco

On Sun, Oct 17, 2010 at 1:54 PM, Marco Mattila <marcom99@xxxxxxxxx> wrote:
>
> So the dialog should be added to block flip, too. I'll start working on this.
>
> On Sun, Oct 17, 2010 at 1:44 PM, jean-pierre charras <jp.charras@xxxxxxxxxx> wrote:
>>
>> Le 17/10/2010 12:32, Marco Mattila a écrit :
>>>
>>> Good point. However, sometimes it might be used also for moving footprints within a board. In that case there may be things that
>>> should not be moved. Maybe another checkbox (include locked modules) could be added to the dialog that comes up after block move,
>>> for example. It's not coming up for flip block, though.
>>>
>>> Marco
>>>
>> This is a better idea.
>> All block operations must have this checkbox.
>> Move, Copy and Flip block of the whole board are transforms useful to guys who want to print/plot on only one page the Front and Back layers of a board.
>> Many hobbyists do that.
>>
>>> On Sun, Oct 17, 2010 at 8:46 AM, jean-pierre charras <jp.charras@xxxxxxxxxx <mailto:jp.charras@xxxxxxxxxx>> wrote:
>>>
>>>    Le 17/10/2010 00:05, Marco Mattila a écrit :
>>>
>>>        Hi,
>>>
>>>        I have previously submitted a couple of patches that prevented direct manipulation of locked modules in pcbnew. However,
>>>        within a
>>>        block it remained possible to, e.g., move a locked module. This patch prevents locked modules from being added to the list of
>>>        selected items in a block operation. The downside of doing this in the Block_SelectItems function is that it also prevents the
>>>        block copy of locked items, if for some reason someone happens to need that.
>>>
>>>    I am not sure this is a good idea:
>>>    main usage of block move is to move the whole board, for instance to append a second board
>>>    or center it on the page (for printing...)
>>>
>>>
>>>    --
>>>    Jean-Pierre CHARRAS
>>>
>> --
>> Jean-Pierre CHARRAS
>>
>>
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>
=== modified file 'pcbnew/block.cpp'
--- pcbnew/block.cpp	2010-08-19 14:21:05 +0000
+++ pcbnew/block.cpp	2010-10-17 16:45:59 +0000
@@ -27,6 +27,7 @@
 
 
 static bool Block_Include_Modules     = TRUE;
+static bool BlockIncludeLockedModules = TRUE;
 static bool Block_Include_Tracks      = TRUE;
 static bool Block_Include_Zones       = TRUE;
 static bool Block_Include_Draw_Items  = TRUE;
@@ -44,6 +45,7 @@
 
     WinEDA_BasePcbFrame* m_Parent;
     wxCheckBox*          m_Include_Modules;
+    wxCheckBox*          m_IncludeLockedModules;
     wxCheckBox*          m_Include_Tracks;
     wxCheckBox*          m_Include_Zones;
     wxCheckBox*          m_Include_Draw_Items;
@@ -62,6 +64,7 @@
 private:
     void ExecuteCommand( wxCommandEvent& event );
     void Cancel( wxCommandEvent& event );
+    void checkBoxClicked( wxCommandEvent& aEvent );
 
     DECLARE_EVENT_TABLE()
 };
@@ -70,6 +73,7 @@
 BEGIN_EVENT_TABLE( WinEDA_ExecBlockCmdFrame, wxDialog )
     EVT_BUTTON( wxID_OK, WinEDA_ExecBlockCmdFrame::ExecuteCommand )
     EVT_BUTTON( wxID_CANCEL, WinEDA_ExecBlockCmdFrame::Cancel )
+    EVT_CHECKBOX( wxID_ANY, WinEDA_ExecBlockCmdFrame::checkBoxClicked )
 END_EVENT_TABLE()
 
 
@@ -125,31 +129,41 @@
     m_Include_Modules->SetValue( Block_Include_Modules );
     fgSizer1->Add( m_Include_Modules, 0, wxALL, 5 );
 
-    m_Include_Tracks = new wxCheckBox( this, -1, _( "Include tracks" ),
+    m_IncludeLockedModules = new wxCheckBox( this, -1, _( "Include Locked Modules" ),
+                                            wxDefaultPosition, wxDefaultSize,
+                                            0 );
+    m_IncludeLockedModules->SetValue( BlockIncludeLockedModules );
+    if( m_Include_Modules->GetValue() )
+        m_IncludeLockedModules->Enable();
+    else
+        m_IncludeLockedModules->Disable();
+    fgSizer1->Add( m_IncludeLockedModules, 0, wxALL, 5 );
+
+    m_Include_Tracks = new wxCheckBox( this, -1, _( "Include Tracks" ),
                                        wxDefaultPosition, wxDefaultSize, 0 );
     m_Include_Tracks->SetValue( Block_Include_Tracks );
     fgSizer1->Add( m_Include_Tracks, 0, wxALL, 5 );
 
-    m_Include_Zones = new wxCheckBox( this, -1, _( "Include zones" ),
+    m_Include_Zones = new wxCheckBox( this, -1, _( "Include Zones" ),
                                       wxDefaultPosition, wxDefaultSize, 0 );
     m_Include_Zones->SetValue( Block_Include_Zones );
     fgSizer1->Add( m_Include_Zones, 0, wxALL, 5 );
 
     m_Include_PcbTextes = new wxCheckBox( this, -1,
-                                          _( "Include Text on copper layers" ),
+                                          _( "Include Text on Copper Layers" ),
                                           wxDefaultPosition,
                                           wxDefaultSize, 0 );
     m_Include_PcbTextes->SetValue( Block_Include_PcbTextes );
     fgSizer1->Add( m_Include_PcbTextes, 0, wxALL, 5 );
 
-    m_Include_Draw_Items = new wxCheckBox( this, -1, _( "Include drawings" ),
+    m_Include_Draw_Items = new wxCheckBox( this, -1, _( "Include Drawings" ),
                                            wxDefaultPosition,
                                            wxDefaultSize, 0 );
     m_Include_Draw_Items->SetValue( Block_Include_Draw_Items );
     fgSizer1->Add( m_Include_Draw_Items, 0, wxALL, 5 );
 
     m_Include_Edges_Items = new wxCheckBox( this, -1,
-                                            _( "Include board outline layer" ),
+                                            _( "Include Board Outline Layer" ),
                                             wxDefaultPosition,
                                             wxDefaultSize, 0 );
     m_Include_Edges_Items->SetValue( Block_Include_Edges_Items );
@@ -181,10 +195,18 @@
     EndModal( -1 );
 }
 
+void WinEDA_ExecBlockCmdFrame::checkBoxClicked( wxCommandEvent& WXUNUSED (aEvent) )
+{
+    if( m_Include_Modules->GetValue() )
+        m_IncludeLockedModules->Enable();
+    else
+        m_IncludeLockedModules->Disable();
+}
 
 void WinEDA_ExecBlockCmdFrame::ExecuteCommand( wxCommandEvent& event )
 {
     Block_Include_Modules     = m_Include_Modules->GetValue();
+    BlockIncludeLockedModules = m_IncludeLockedModules->GetValue();
     Block_Include_Tracks      = m_Include_Tracks->GetValue();
     Block_Include_Zones       = m_Include_Zones->GetValue();
     Block_Include_Draw_Items  = m_Include_Draw_Items->GetValue();
@@ -414,7 +436,8 @@
         for( MODULE* module = m_Pcb->m_Modules; module != NULL;
              module = module->Next() )
         {
-            if( module->HitTest( GetScreen()->m_BlockLocate ) )
+            if( module->HitTest( GetScreen()->m_BlockLocate ) &&
+                ( !module->IsLocked() || BlockIncludeLockedModules ) )
             {
                 picker.m_PickedItem     = module;
                 picker.m_PickedItemType = module->Type();
@@ -730,6 +753,9 @@
     wxPoint memo;
     wxPoint center; /* Position of the axis for inversion of all elements */
 
+    if( !InstallBlockCmdFrame( this, _( "Flip Block" ) ) )
+        return;
+
     Block_SelectItems();
     if( GetScreen()->m_BlockLocate.GetCount() == 0 )
         return;


Follow ups

References