kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #07283
Alt+Mousewheel to change working copper layer
Hello,
I have created a nifty little patch to be able to change the working
copper layout while routing, *without* creating a via at the same
time. From what I see, there exists commands that can be bound to
hotkeys to switch layers, but these commands will create a via under
the mouse cursor as you change layers, and they will not work if you
use them over an already placed via (ie.: you didn't select the right
layer on the first try). The result of this is that you have to press
backspace if you didn't select the right layer right away (to delete
the via). This might not sound like a big deal and is just personal
taste, but perhaps adding an alternative that doesn't get it the way
could be possible.
Basically, the workflow could be as follows:
- you start routing (X)
- give a few clicks
- place a via (V)
- you switch layers AFTER the via is placed, using ALT+Mousewheel.
- place a via (V)
- you switch layers AFTER the via is placed, using ALT+Mousewheel.
- terminate the trace on a pad or otherwise
I stress that this workflow is parallel to the already existing one
and does not try to replace/remove it, it simply would be an
alternative (as Alt suggests).
I'm attaching the (nifty) patch to this email, just as a proof of
concept. Beware that if you apply it for testing *it will force
recompilation of every file* that uses id.h, which is mostly every
file out there.
A better way of implementing this feature would be to make
ALT+Mousewheel Up/Down available as a hotkey instead (any problem with
that ?), and defining functions NextCopperNoVia and
PreviousCopperNoVia, or something like that, so that the user has the
freedom required to bind or not this behaviour to the mousewheel or
elsewhere.
What do you think ?
--
Guillaume Simard
=== modified file 'common/drawpanel.cpp'
--- common/drawpanel.cpp 2011-12-08 18:23:44 +0000
+++ common/drawpanel.cpp 2011-12-15 04:28:02 +0000
@@ -811,6 +811,8 @@
cmd.SetId( ID_PAN_UP );
else if( event.ControlDown() && !event.ShiftDown() )
cmd.SetId( ID_PAN_LEFT );
+ else if( event.AltDown() )
+ cmd.SetId( ID_MOUSEWHEEL_ALT_UP );
else
cmd.SetId( ID_POPUP_ZOOM_IN );
}
@@ -820,6 +822,8 @@
cmd.SetId( ID_PAN_DOWN );
else if( event.ControlDown() && !event.ShiftDown() )
cmd.SetId( ID_PAN_RIGHT );
+ else if( event.AltDown() )
+ cmd.SetId( ID_MOUSEWHEEL_ALT_DOWN );
else
cmd.SetId( ID_POPUP_ZOOM_OUT );
}
=== modified file 'include/id.h'
--- include/id.h 2011-11-30 11:45:49 +0000
+++ include/id.h 2011-12-15 04:28:10 +0000
@@ -214,6 +214,9 @@
ID_ZOOM_PAGE,
ID_ZOOM_REDRAW,
+ ID_MOUSEWHEEL_ALT_UP,
+ ID_MOUSEWHEEL_ALT_DOWN,
+
/* Panning command event IDs. */
ID_PAN_UP,
ID_PAN_DOWN,
=== modified file 'include/wxPcbStruct.h'
--- include/wxPcbStruct.h 2011-12-12 14:02:37 +0000
+++ include/wxPcbStruct.h 2011-12-15 04:25:44 +0000
@@ -1503,6 +1503,8 @@
*/
void UpdateTitle();
+ void OnAltWheel( wxCommandEvent& event );
+
DECLARE_EVENT_TABLE()
};
=== modified file 'pcbnew/class_pcb_layer_widget.cpp'
--- pcbnew/class_pcb_layer_widget.cpp 2011-09-30 18:15:37 +0000
+++ pcbnew/class_pcb_layer_widget.cpp 2011-12-15 04:27:00 +0000
@@ -369,5 +369,3 @@
}
//-----</LAYER_WIDGET callbacks>------------------------------------------
-
-
=== modified file 'pcbnew/pcbframe.cpp'
--- pcbnew/pcbframe.cpp 2011-12-12 14:02:37 +0000
+++ pcbnew/pcbframe.cpp 2011-12-15 04:28:25 +0000
@@ -220,6 +220,10 @@
ID_POPUP_PCB_SELECT_WIDTH_END_RANGE,
PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
+ // Mousewheel + Alt event
+ EVT_MENU_RANGE( ID_MOUSEWHEEL_ALT_UP, ID_MOUSEWHEEL_ALT_DOWN,
+ PCB_EDIT_FRAME::OnAltWheel )
+
// popup menus
EVT_MENU( ID_POPUP_PCB_DELETE_TRACKSEG, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
@@ -750,3 +754,36 @@
SetTitle( title );
}
+
+void PCB_EDIT_FRAME::OnAltWheel( wxCommandEvent& event )
+{
+ int curLayer = getActiveLayer();
+ int newLayer;
+
+ switch( event.GetId() )
+ {
+ case ID_MOUSEWHEEL_ALT_UP:
+ if( curLayer < GetBoard()->GetCopperLayerCount() - 2 )
+ newLayer = curLayer + 1;
+ else
+ newLayer = LAYER_N_FRONT;
+
+ break;
+
+ case ID_MOUSEWHEEL_ALT_DOWN:
+ if( curLayer == LAYER_N_FRONT )
+ newLayer = GetBoard()->GetCopperLayerCount() - 2;
+ else if( curLayer > 0 )
+ newLayer = curLayer - 1;
+
+ break;
+
+ default:
+ wxLogDebug( wxT( "Unknown ID %d in PCB_EDIT_FRAME::OnAltWheel()." ), event.GetId() );
+ }
+
+ if( ( newLayer == LAYER_N_BACK ) || ( newLayer == LAYER_N_FRONT )
+ || ( newLayer < GetBoard()->GetCopperLayerCount() - 1
+ && newLayer >= 1 ) )
+ setActiveLayer( newLayer );
+}
Follow ups