← Back to team overview

kicad-developers team mailing list archive

[PATCH] Shortcut for fill all and unfill all zones for GAL

 

Hello

This is an acompanion patch to the fill all patch accepted on the bug
tracker [1], implementing the same behaivour for GAL. You will find
the patch attached.

I had to create a PCB_EDITOR_CONTROL::ZoneUnfillAll method. I think I
have done it correctly, it works at least. The GAL filling is about
4.1 times faster than the default framework. Filling 4096 of my random
zones in about 25 seconds for default and about six seconds for GAL.
Please review.

Maciej talked about doing with zone hiding/showing by using the
visibility buttons, but since [1] got accepted I decided to try this
out, and I think it work fairly good.

I did not change the labels for the tool actions to match the ones in
the legacy patch, because the labels in GAL was short and concise
already. I don't have an opinion on that.

Regards
Nick Østergaard

[1] https://bugs.launchpad.net/kicad/+bug/1084202
=== modified file 'pcbnew/tools/common_actions.cpp'
--- pcbnew/tools/common_actions.cpp	2014-11-21 10:50:13 +0000
+++ pcbnew/tools/common_actions.cpp	2014-12-08 18:43:42 +0000
@@ -308,13 +308,17 @@
         "Fill", "Fill zone(s)" );
 
 TOOL_ACTION COMMON_ACTIONS::zoneFillAll( "pcbnew.EditorControl.zoneFillAll",
-        AS_GLOBAL, 0,
+        AS_GLOBAL, int( 'B' ),
         "Fill all", "Fill all zones" );
 
 TOOL_ACTION COMMON_ACTIONS::zoneUnfill( "pcbnew.EditorControl.zoneUnfill",
         AS_GLOBAL, 0,
         "Unfill", "Unfill zone(s)" );
 
+TOOL_ACTION COMMON_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll",
+        AS_GLOBAL, int( 'N' ),
+        "Unfill all", "Unfill all zones" );
+
 
 // Module editor tools
 TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",

=== modified file 'pcbnew/tools/common_actions.h'
--- pcbnew/tools/common_actions.h	2014-11-21 10:50:13 +0000
+++ pcbnew/tools/common_actions.h	2014-12-08 18:42:47 +0000
@@ -195,6 +195,7 @@
     static TOOL_ACTION zoneFill;
     static TOOL_ACTION zoneFillAll;
     static TOOL_ACTION zoneUnfill;
+    static TOOL_ACTION zoneUnfillAll;
 
     // Module editor tools
     /// Activation of the drawing tool (placing a PAD)

=== modified file 'pcbnew/tools/pcb_editor_control.cpp'
--- pcbnew/tools/pcb_editor_control.cpp	2014-07-09 14:57:01 +0000
+++ pcbnew/tools/pcb_editor_control.cpp	2014-12-08 18:50:52 +0000
@@ -41,6 +41,7 @@
         Add( COMMON_ACTIONS::zoneFill );
         Add( COMMON_ACTIONS::zoneFillAll );
         Add( COMMON_ACTIONS::zoneUnfill );
+        Add( COMMON_ACTIONS::zoneUnfillAll );
     }
 };
 
@@ -219,6 +220,24 @@
 }
 
 
+int PCB_EDITOR_CONTROL::ZoneUnfillAll( TOOL_EVENT& aEvent )
+{
+    BOARD* board = getModel<BOARD>();
+
+    for( int i = 0; i < board->GetAreaCount(); ++i )
+    {
+        ZONE_CONTAINER* zone = board->GetArea( i );
+        zone->SetIsFilled( false );
+        zone->ClearFilledPolysList();
+        zone->ViewUpdate();
+    }
+
+    setTransitions();
+
+    return 0;
+}
+
+
 void PCB_EDITOR_CONTROL::setTransitions()
 {
     // Track & via size control
@@ -231,4 +250,5 @@
     Go( &PCB_EDITOR_CONTROL::ZoneFill,           COMMON_ACTIONS::zoneFill.MakeEvent() );
     Go( &PCB_EDITOR_CONTROL::ZoneFillAll,        COMMON_ACTIONS::zoneFillAll.MakeEvent() );
     Go( &PCB_EDITOR_CONTROL::ZoneUnfill,         COMMON_ACTIONS::zoneUnfill.MakeEvent() );
+    Go( &PCB_EDITOR_CONTROL::ZoneUnfillAll,      COMMON_ACTIONS::zoneUnfillAll.MakeEvent() );
 }

=== modified file 'pcbnew/tools/pcb_editor_control.h'
--- pcbnew/tools/pcb_editor_control.h	2014-07-09 14:57:01 +0000
+++ pcbnew/tools/pcb_editor_control.h	2014-12-08 19:38:43 +0000
@@ -55,6 +55,7 @@
     int ZoneFill( TOOL_EVENT& aEvent );
     int ZoneFillAll( TOOL_EVENT& aEvent );
     int ZoneUnfill( TOOL_EVENT& aEvent );
+    int ZoneUnfillAll( TOOL_EVENT& aEvent );
 
 private:
     ///> Sets up handlers for various events.


Follow ups