kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #16532
Re: [PATCH] Hotkey for editing module with module editor (Ctrl-E)
On Sun, 2014-12-07 at 21:54 +0000, John Beard wrote:
> Here is an amended patch, where Ctrl-E over an item in
> either legacy or GAL will launch the footprint editor. A single
> selection works as before.
That patch no longer applies, please find attached a new patch for the
current product tip.
Thanks for reviewing,
John
diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h
index 74d03e6..1ddec00 100644
--- a/include/wxPcbStruct.h
+++ b/include/wxPcbStruct.h
@@ -1039,6 +1039,9 @@ public:
// Footprint edition (see also PCB_BASE_FRAME)
void InstallModuleOptionsFrame( MODULE* Module, wxDC* DC );
+ // Directly open module editor
+ void ShowModuleEditorForModule( MODULE* aModule );
+
/**
* Function StartMoveModule
* Initialize a drag or move pad command
diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp
index cc0db92..c4a0396 100644
--- a/pcbnew/edit.cpp
+++ b/pcbnew/edit.cpp
@@ -843,6 +843,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT:
+
+ // If we don't have a current item, there's nothing we can do here
+ if( !GetCurItem() )
+ break;
+
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != PCB_MODULE_T )
SetCurItem( GetCurItem()->GetParent() );
@@ -856,16 +861,8 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
OnModify();
}
- {
- FOOTPRINT_EDIT_FRAME* editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
+ ShowModuleEditorForModule( static_cast<MODULE*>( GetCurItem() ) );
- editor->Load_Module_From_BOARD( (MODULE*)GetCurItem() );
- SetCurItem( NULL ); // the current module could be deleted by
-
- editor->Show( true );
-
- editor->Raise(); // Iconize( false );
- }
m_canvas->MoveCursorToCrossHair();
break;
diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp
index 1046888..abe39c1 100644
--- a/pcbnew/editmod.cpp
+++ b/pcbnew/editmod.cpp
@@ -75,16 +75,22 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
if( retvalue == 2 )
{
- FOOTPRINT_EDIT_FRAME* editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
-
- editor->Load_Module_From_BOARD( Module );
- SetCurItem( NULL );
-
- editor->Show( true );
- editor->Raise(); // Iconize( false );
+ ShowModuleEditorForModule( Module );
}
}
+void PCB_EDIT_FRAME::ShowModuleEditorForModule( MODULE* aModule )
+{
+ FOOTPRINT_EDIT_FRAME* editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player(
+ FRAME_PCB_MODULE_EDITOR, true );
+
+ editor->Load_Module_From_BOARD( aModule );
+ SetCurItem( NULL );
+
+ editor->Show( true );
+ editor->Raise();
+ // Iconize( false );
+}
void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
{
diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp
index 006c0b2..b6ea7b4 100644
--- a/pcbnew/hotkeys.cpp
+++ b/pcbnew/hotkeys.cpp
@@ -105,6 +105,7 @@ static EDA_HOTKEY HkSwitchTrackPosture( wxT( "Switch Track Posture" ), HK_SWITC
static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag Track Keep Slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' );
static EDA_HOTKEY HkPlaceItem( wxT( "Place Item" ), HK_PLACE_ITEM, 'P' );
static EDA_HOTKEY HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' );
+static EDA_HOTKEY HkEditWithModedit( wxT( "Edit with Footprint Editor" ), HK_EDIT_MODULE_WITH_MODEDIT, 'E' + GR_KB_CTRL );
static EDA_HOTKEY HkFlipItem( wxT( "Flip Item" ), HK_FLIP_ITEM, 'F' );
static EDA_HOTKEY HkRotateItem( wxT( "Rotate Item" ), HK_ROTATE_ITEM, 'R' );
static EDA_HOTKEY HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' );
@@ -280,6 +281,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] =
&HkRotateItem, &HkDragFootprint,
&HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, &HkSavefileAs,
&HkLoadfile, &HkFindItem, &HkEditBoardItem,
+ &HkEditWithModedit,
&HkSwitch2CopperLayer, &HkSwitch2InnerLayer1,
&HkSwitch2InnerLayer2, &HkSwitch2InnerLayer3, &HkSwitch2InnerLayer4,
&HkSwitch2InnerLayer5, &HkSwitch2InnerLayer6, &HkSwitch2ComponentLayer,
diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h
index ca58a7f..a344ad0 100644
--- a/pcbnew/hotkeys.h
+++ b/pcbnew/hotkeys.h
@@ -86,6 +86,7 @@ enum hotkey_id_commnand {
HK_SWITCH_LAYER_TO_INNER13,
HK_SWITCH_LAYER_TO_INNER14,
HK_ADD_MODULE,
+ HK_EDIT_MODULE_WITH_MODEDIT,
HK_SLIDE_TRACK,
HK_MACRO_ID_BEGIN,
HK_RECORD_MACROS_0, // keep these id ordered from 0 to 9
diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp
index 02ecf4f..0f35bee 100644
--- a/pcbnew/hotkeys_board_editor.cpp
+++ b/pcbnew/hotkeys_board_editor.cpp
@@ -509,6 +509,10 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
OnHotkeyEditItem( HK_EDIT_ITEM );
break;
+ case HK_EDIT_MODULE_WITH_MODEDIT: // Edit module with module editor
+ OnHotkeyEditItem( HK_EDIT_MODULE_WITH_MODEDIT );
+ break;
+
// Footprint edition:
case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
// get any module, locked or not locked and toggle its locked status
@@ -693,6 +697,8 @@ bool PCB_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand )
case PCB_MODULE_T:
if( aIdCommand == HK_EDIT_ITEM )
evt_type = ID_POPUP_PCB_EDIT_MODULE_PRMS;
+ else if( aIdCommand == HK_EDIT_MODULE_WITH_MODEDIT )
+ evt_type = ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT;
break;
diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp
index 9de056f..91b34d4 100644
--- a/pcbnew/onrightclick.cpp
+++ b/pcbnew/onrightclick.cpp
@@ -761,9 +761,11 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu
g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE_PRMS, msg,
KiBitmap( edit_module_xpm ) );
+
+ msg = AddHotkeyName( _( "Edit with Footprint Editor" ),
+ g_Board_Editor_Hokeys_Descr, HK_EDIT_MODULE_WITH_MODEDIT );
AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT,
- _( "Edit with Footprint Editor" ),
- KiBitmap( module_editor_xpm ) );
+ msg, KiBitmap( module_editor_xpm ) );
sub_menu_footprint->AppendSeparator();
msg = AddHotkeyName( _( "Delete Footprint" ),
g_Board_Editor_Hokeys_Descr, HK_DELETE );
diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp
index c35372e..1d77894 100644
--- a/pcbnew/tools/common_actions.cpp
+++ b/pcbnew/tools/common_actions.cpp
@@ -301,7 +301,6 @@ TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaS
AS_GLOBAL, 0,
"", "", AF_NOTIFY );
-
// Zone actions
TOOL_ACTION COMMON_ACTIONS::zoneFill( "pcbnew.EditorControl.zoneFill",
AS_GLOBAL, 0,
@@ -320,6 +319,12 @@ TOOL_ACTION COMMON_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll",
"Unfill all", "Unfill all zones" );
+// PCB editor module tools
+TOOL_ACTION COMMON_ACTIONS::editWithModedit( "pcbnew.EditorControl.editWithModedit",
+ AS_GLOBAL, MD_CTRL + int('E'),
+ "Edit with module editor", "Edit with module editor", AF_ACTIVATE );
+
+
// Module editor tools
TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",
AS_GLOBAL, 0,
diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h
index 73849a7..32b068f 100644
--- a/pcbnew/tools/common_actions.h
+++ b/pcbnew/tools/common_actions.h
@@ -65,6 +65,9 @@ public:
/// Activation of the edit tool
static TOOL_ACTION properties;
+ /// Edit a module in the module editor
+ static TOOL_ACTION editWithModedit;
+
/// Deleting a BOARD_ITEM
static TOOL_ACTION remove;
diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp
index 827fd44..3e67296 100644
--- a/pcbnew/tools/pcb_editor_control.cpp
+++ b/pcbnew/tools/pcb_editor_control.cpp
@@ -29,6 +29,7 @@
#include <wxPcbStruct.h>
#include <class_board.h>
+#include <class_module.h>
#include <class_zone.h>
#include <class_draw_panel_gal.h>
@@ -66,6 +67,11 @@ bool PCB_EDITOR_CONTROL::Init()
{
selTool->AddSubMenu( new ZONE_CONTEXT_MENU, wxT( "Zones" ),
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
+
+ selTool->AddMenuItem( COMMON_ACTIONS::editWithModedit,
+ SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
+ && SELECTION_CONDITIONS::Count( 1 )
+ );
}
setTransitions();
@@ -238,6 +244,42 @@ int PCB_EDITOR_CONTROL::ZoneUnfillAll( TOOL_EVENT& aEvent )
}
+int PCB_EDITOR_CONTROL::EditWithModedit( TOOL_EVENT& aEvent )
+{
+ SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
+ const SELECTION& selection = selTool->GetSelection();
+
+ if( selection.Empty() )
+ m_toolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
+
+ // we can only edit a single module at once
+ if( selection.Size() != 1 )
+ {
+ setTransitions();
+ return 0;
+ }
+
+ BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 );
+
+ MODULE* selectedModule = NULL;
+
+ if( item->Type() == PCB_MODULE_T )
+ selectedModule = static_cast<MODULE*>( item );
+ else
+ selectedModule = static_cast<MODULE*>( item->GetParent() );
+
+ wxASSERT_MSG( selectedModule, wxT("Failed to get a module to edit with modedit") );
+
+ m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
+
+ m_frame->ShowModuleEditorForModule( selectedModule );
+
+ setTransitions();
+
+ return 0;
+}
+
+
void PCB_EDITOR_CONTROL::setTransitions()
{
// Track & via size control
@@ -251,4 +293,7 @@ void PCB_EDITOR_CONTROL::setTransitions()
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() );
+
+ // Module editor
+ Go( &PCB_EDITOR_CONTROL::EditWithModedit, COMMON_ACTIONS::editWithModedit.MakeEvent() );
}
diff --git a/pcbnew/tools/pcb_editor_control.h b/pcbnew/tools/pcb_editor_control.h
index 9e4dc8f..1d7eaa0 100644
--- a/pcbnew/tools/pcb_editor_control.h
+++ b/pcbnew/tools/pcb_editor_control.h
@@ -57,6 +57,13 @@ public:
int ZoneUnfill( TOOL_EVENT& aEvent );
int ZoneUnfillAll( TOOL_EVENT& aEvent );
+ /**
+ * Function EditModuleWithModedit()
+ *
+ * Opens a currently selected module in modedit
+ */
+ int EditWithModedit( TOOL_EVENT& aEvent );
+
private:
///> Sets up handlers for various events.
void setTransitions();
References