← Back to team overview

kicad-developers team mailing list archive

New feature for manual routing

 

I've devised this simple feature during a 3-week marathon in PCB layout
(customer keeps changing specifications:P). It solves the following
'problem' (more like the proverbial open source itch...):

In two-segment manual routing from pad to pad, it build first an
horizontal/vertical segment and then a diagonal one to reach the target
(when starting from an existing track node the behaviour is somewhat
different); alas, really often there is already something in the way (a
via, usually) so you need a different track 'posture' (term stolen from
robot kinematics). Usually you can simply abort the track and start from
the other side. I simply added a popup entry (with associated key) to
switch this behaviour (i.e. start with a diagonal segment and ther
hor/ver to the target).

There is a redraw glitch (I don't get *why*
ShowNewTrackWhenMovingCursor( DrawPanel, &dc, true ) doesn't erase the
old track, so you see both until you redraw), enlightenment on how to
fix it would be welcomed:D

Also I'm not really happy on how hotkeys are handled (requiring code
duplication :() but I suppose it's a wxWidget issue; OTOH refactoring
3 lines in a function seems somewhat overkill...

--
Lorenzo Marcantonio
Logos Srl
=== modified file 'pcbnew/edit.cpp'
--- pcbnew/edit.cpp	2010-05-27 10:23:29 +0000
+++ pcbnew/edit.cpp	2010-06-07 11:02:47 +0000
@@ -65,6 +65,7 @@
     case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
     case ID_POPUP_PCB_END_TRACK:
     case ID_POPUP_PCB_PLACE_VIA:
+    case ID_POPUP_PCB_SWITCH_TRACK_POSTURE:
     case ID_POPUP_PCB_PLACE_MICROVIA:
     case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
     case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
@@ -339,6 +340,13 @@
         }
         break;
 
+    case ID_POPUP_PCB_SWITCH_TRACK_POSTURE:
+	/* XXX POSTURE XXX */
+	ShowNewTrackWhenMovingCursor( DrawPanel, &dc, true );
+	g_Alternate_Track_Posture = !g_Alternate_Track_Posture;
+	ShowNewTrackWhenMovingCursor( DrawPanel, &dc, false );
+	break;
+
     case ID_POPUP_PCB_PLACE_MICROVIA:
         if( !IsMicroViaAcceptable() )
             break;

=== modified file 'pcbnew/editrack.cpp'
--- pcbnew/editrack.cpp	2010-05-27 10:23:29 +0000
+++ pcbnew/editrack.cpp	2010-06-07 06:52:01 +0000
@@ -906,11 +906,16 @@
     TRACK* lastTrack = track ? track->Back() : NULL;
     if( lastTrack )
     {
-        if( (lastTrack->m_End.x == lastTrack->m_Start.x)
+        if(( (lastTrack->m_End.x == lastTrack->m_Start.x)
            || (lastTrack->m_End.y == lastTrack->m_Start.y) )
+		&& !g_Alternate_Track_Posture)
         {
             iAngle = 45;
         }
+    } else {
+	if (g_Alternate_Track_Posture) {
+	    iAngle = 45;
+	}
     }
 
     if( iAngle == 0 )

=== modified file 'pcbnew/hotkeys.cpp'
--- pcbnew/hotkeys.cpp	2010-02-19 13:23:58 +0000
+++ pcbnew/hotkeys.cpp	2010-06-07 11:03:22 +0000
@@ -67,6 +67,7 @@
                                   WXK_BACK );
 static Ki_HotkeyInfo HkAddNewTrack( wxT( "Add new track" ), HK_ADD_NEW_TRACK, 'X' );
 static Ki_HotkeyInfo HkAddVia( wxT( "Add Via" ), HK_ADD_VIA, 'V' );
+static Ki_HotkeyInfo HkSwitchTrackPosture( wxT( "Switch Track Posture" ), HK_SWITCH_TRACK_POSTURE, '/' );
 static Ki_HotkeyInfo HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V'
                                     + GR_KB_CTRL );
 static Ki_HotkeyInfo HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END );
@@ -157,6 +158,7 @@
     &HkTrackDisplayMode,       &HkDelete,
     &HkBackspace,
     &HkAddNewTrack,            &HkAddVia,                    &HkAddMicroVia,
+    &HkSwitchTrackPosture,
     &HkEndTrack,               &HkMoveFootprint,
     &HkFlipFootprint,          &HkRotateFootprint,           &HkDragFootprint,
     &HkGetAndMoveFootprint,    &HkLock_Unlock_Footprint,     &HkSavefile,
@@ -423,7 +425,7 @@
         if( ItemFree )
         {
             wxCommandEvent evt;
-            evt.SetId( ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST );
+            evt.SetId( ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST  );
             Process_Special_Functions( evt );
         }
         break;
@@ -496,6 +498,13 @@
             DrawPanel->Refresh();
         break;
 
+    case HK_SWITCH_TRACK_POSTURE: 
+	/* XXX POSTURE XXX */
+	ShowNewTrackWhenMovingCursor( DrawPanel, DC, true );
+	g_Alternate_Track_Posture = !g_Alternate_Track_Posture;
+	ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
+	break;
+
     case HK_ADD_NEW_TRACK: // Start new track
         if( getActiveLayer() > LAYER_N_FRONT )
             break;
@@ -657,6 +666,8 @@
 
             // fall through
             case HK_MOVE_FOOTPRINT: // Start move module
+                GetScreen()->m_Curseur = module->m_Pos;
+                DrawPanel->MouseToCursorSchema();
                 StartMove_Module( module, DC );
                 break;
             }

=== modified file 'pcbnew/hotkeys.h'
--- pcbnew/hotkeys.h	2010-02-14 18:14:33 +0000
+++ pcbnew/hotkeys.h	2010-06-07 06:43:35 +0000
@@ -21,6 +21,7 @@
     HK_LOCK_UNLOCK_FOOTPRINT,
     HK_ADD_NEW_TRACK,
     HK_ADD_VIA,
+    HK_SWITCH_TRACK_POSTURE,
     HK_ADD_MICROVIA,
     HK_END_TRACK,
     HK_SAVE_BOARD, HK_LOAD_BOARD,

=== modified file 'pcbnew/onrightclick.cpp'
--- pcbnew/onrightclick.cpp	2010-04-23 09:54:40 +0000
+++ pcbnew/onrightclick.cpp	2010-06-07 06:41:35 +0000
@@ -448,6 +448,9 @@
         msg = AddHotkeyName( _( "Place Via" ), s_Board_Editor_Hokeys_Descr, HK_ADD_VIA );
         PopMenu->Append( ID_POPUP_PCB_PLACE_VIA, msg );
 
+        msg = AddHotkeyName( _( "Switch Track Posture" ), s_Board_Editor_Hokeys_Descr, HK_SWITCH_TRACK_POSTURE );
+        PopMenu->Append( ID_POPUP_PCB_SWITCH_TRACK_POSTURE, msg );
+
         // See if we can place a Micro Via (4 or more layers, and start from an external layer):
         if( IsMicroViaAcceptable() )
         {

=== modified file 'pcbnew/pcbnew.cpp'
--- pcbnew/pcbnew.cpp	2010-05-30 09:46:37 +0000
+++ pcbnew/pcbnew.cpp	2010-06-07 06:48:27 +0000
@@ -43,6 +43,7 @@
 bool           g_Show_Module_Ratsnest;
 bool           g_Show_Pads_Module_in_Move = true;
 bool           g_Raccord_45_Auto = true;
+bool 	       g_Alternate_Track_Posture = false;
 bool           g_Track_45_Only_Allowed = true;  // True to allow horiz, vert. and 45deg only tracks
 bool           Segments_45_Only;                // True to allow horiz, vert. and 45deg only graphic segments
 bool           g_TwoSegmentTrackBuild = true;

=== modified file 'pcbnew/pcbnew.h'
--- pcbnew/pcbnew.h	2010-05-01 09:22:12 +0000
+++ pcbnew/pcbnew.h	2010-06-07 06:47:54 +0000
@@ -61,6 +61,7 @@
 
 
 extern bool        g_Track_45_Only_Allowed;
+extern bool        g_Alternate_Track_Posture;
 extern bool        Segments_45_Only;
 extern wxString    g_Shapes3DExtBuffer;
 extern wxString    g_DocModulesFileName;

=== modified file 'pcbnew/pcbnew_id.h'
--- pcbnew/pcbnew_id.h	2010-05-04 15:58:46 +0000
+++ pcbnew/pcbnew_id.h	2010-06-07 06:44:11 +0000
@@ -101,6 +101,7 @@
     ID_POPUP_PCB_EDIT_DIMENSION,

     ID_POPUP_PCB_END_TRACK,

     ID_POPUP_PCB_PLACE_VIA,

+    ID_POPUP_PCB_SWITCH_TRACK_POSTURE,

     ID_POPUP_PCB_PLACE_MICROVIA,

 

     ID_POPUP_PCB_IMPORT_PAD_SETTINGS,