diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 08b901c0f4..0c842aaa6d 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -213,15 +213,6 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) { wxString msg; - if( !Sheet->GetEditFlags() ) - { - PopMenu->AppendSeparator(); - msg = AddHotkeyName( _( "Select Items On PCB" ), g_Schematic_Hotkeys_Descr, - HK_SELECT_ITEMS_ON_PCB ); - AddMenuItem( PopMenu, ID_POPUP_SCH_SELECT_ON_PCB, msg, KiBitmap( select_same_sheet_xpm ) ); - PopMenu->AppendSeparator(); - } - { AddMenuItem( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize" ), KiBitmap( resize_sheet_xpm ) ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 1f737c187e..e937145f33 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -225,7 +225,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_GEN_PLOT_SCHEMATIC, SCH_EDIT_FRAME::PlotSchematic ) EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, EDA_DRAW_FRAME::CopyToClipboard ) EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit ) - EVT_MENU( ID_POPUP_SCH_SELECT_ON_PCB, SCH_EDIT_FRAME::SelectAllFromSheet ) EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config ) diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index fdfb9968c8..a37b980753 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -777,12 +777,6 @@ public: private: - /** - * Handle the #ID_POPUP_SCH_SELECT_ON_PCB event used to select items in Pcbnew - * based on the sheet they are placed on. - */ - void SelectAllFromSheet( wxCommandEvent& aEvent ); - /** * Handles the keyboard hotkey for unfolding a bus */ diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 9867dd41ed..fc687b28f7 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -190,33 +190,6 @@ void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) } -void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent ) -{ - SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool(); - SCH_SCREEN* screen = GetScreen(); - SCH_ITEM* item = screen->GetCurItem(); - - if( item != NULL ) - { - item = selTool->SelectPoint( item->GetPosition() ); - SendMessageToPCBNEW( item, NULL ); - } - else - { - // If we didn't get here by a hot key, then something has gone wrong. - if( aEvent.GetInt() == 0 ) - return; - - EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject(); - - wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) ); - - item = selTool->SelectPoint( data->GetPosition() ); - SendMessageToPCBNEW( item, NULL ); - } -} - - void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent ) { SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool(); diff --git a/eeschema/tools/sch_actions.cpp b/eeschema/tools/sch_actions.cpp index 84214b8395..92fe32aa41 100644 --- a/eeschema/tools/sch_actions.cpp +++ b/eeschema/tools/sch_actions.cpp @@ -262,6 +262,9 @@ OPT SCH_ACTIONS::TranslateLegacyId( int aId ) case ID_POPUP_SCH_LEAVE_SHEET: return SCH_ACTIONS::leaveSheet.MakeEvent(); + + case ID_POPUP_SCH_SELECT_ON_PCB: + return SCH_ACTIONS::explicitCrossProbe.MakeEvent(); } return OPT(); diff --git a/eeschema/tools/sch_actions.h b/eeschema/tools/sch_actions.h index 8cdb134b8e..3d5ca9970c 100644 --- a/eeschema/tools/sch_actions.h +++ b/eeschema/tools/sch_actions.h @@ -148,6 +148,7 @@ public: static TOOL_ACTION updateUnits; static TOOL_ACTION deleteItemCursor; static TOOL_ACTION refreshPreview; + static TOOL_ACTION explicitCrossProbe; // SPICE static TOOL_ACTION simProbe; diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 976dd665ca..a765d61651 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -100,6 +100,11 @@ TOOL_ACTION SCH_ACTIONS::leaveSheet( "eeschema.EditorControl.leaveSheet", _( "Leave Sheet" ), _( "Display the parent sheet in the Eeschema window" ), leave_sheet_xpm ); +TOOL_ACTION SCH_ACTIONS::explicitCrossProbe( "eeschema.EditorControl.explicitCrossProbe", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_ITEMS_ON_PCB ), + _( "Highlight on PCB" ), _( "Highlight corresponding items in PCBNew" ), + select_same_sheet_xpm ); + SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() : TOOL_INTERACTIVE( "eeschema.EditorControl" ), @@ -156,6 +161,7 @@ bool SCH_EDITOR_CONTROL::Init() selToolMenu.AddSeparator( anySheetCondition, 600 ); selToolMenu.AddItem( SCH_ACTIONS::enterSheet, singleSheetCondition, 600 ); selToolMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 600 ); + selToolMenu.AddItem( SCH_ACTIONS::explicitCrossProbe, singleSheetCondition, 600 ); } SCH_DRAWING_TOOL* drawingTool = m_toolMgr->GetTool(); @@ -172,52 +178,83 @@ bool SCH_EDITOR_CONTROL::Init() } -int SCH_EDITOR_CONTROL::CrossProbeSchToPcb( const TOOL_EVENT& aEvent ) +int SCH_EDITOR_CONTROL::CrossProbeToPcb( const TOOL_EVENT& aEvent ) +{ + doCrossProbeSchToPcb( aEvent, false ); + return 0; +} + + +int SCH_EDITOR_CONTROL::ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent ) +{ + doCrossProbeSchToPcb( aEvent, true ); + return 0; +} + + +void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce ) { // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ... if( m_probingSchToPcb ) { m_probingSchToPcb = false; - return 0; + return; } SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); - const SELECTION& selection = selTool->GetSelection(); + SCH_ITEM* item = nullptr; + SCH_COMPONENT* component = nullptr; - if( selection.Size() == 1 ) + if( aForce ) { - SCH_ITEM* item = static_cast( selection.Front() ); - SCH_COMPONENT* component; + SELECTION& selection = selTool->RequestSelection(); - switch( item->Type() ) - { - case SCH_FIELD_T: - case LIB_FIELD_T: - component = (SCH_COMPONENT*) item->GetParent(); - m_frame->SendMessageToPCBNEW( item, component ); - break; + if( selection.GetSize() >= 1 ) + item = (SCH_ITEM*) selection.Front(); + } + else + { + SELECTION& selection = selTool->GetSelection(); - case SCH_COMPONENT_T: - component = (SCH_COMPONENT*) item; - m_frame->SendMessageToPCBNEW( item, component ); - break; + if( selection.GetSize() >= 1 ) + item = (SCH_ITEM*) selection.Front(); + } - case SCH_PIN_T: - component = (SCH_COMPONENT*) item->GetParent(); - m_frame->SendMessageToPCBNEW( static_cast( item ), component ); - break; + if( !item ) + { + if( aForce ) + m_frame->SendMessageToPCBNEW( nullptr, nullptr ); -#if 0 // This is too slow on larger projects - case SCH_SHEET_T: - SendMessageToPCBNEW( item, nullptr ); - break; -#endif - default: - ; - } + return; } - return 0; + + switch( item->Type() ) + { + case SCH_FIELD_T: + case LIB_FIELD_T: + component = (SCH_COMPONENT*) item->GetParent(); + m_frame->SendMessageToPCBNEW( item, component ); + break; + + case SCH_COMPONENT_T: + component = (SCH_COMPONENT*) item; + m_frame->SendMessageToPCBNEW( item, component ); + break; + + case SCH_PIN_T: + component = (SCH_COMPONENT*) item->GetParent(); + m_frame->SendMessageToPCBNEW( static_cast( item ), component ); + break; + + case SCH_SHEET_T: + if( aForce ) + m_frame->SendMessageToPCBNEW( item, nullptr ); + break; + + default: + break; + } } @@ -648,28 +685,6 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) } -int SCH_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) -{ - SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); - SELECTION& selection = selTool->GetSelection(); - - if( selection.GetSize() == 1 ) - { - SCH_ITEM* item = (SCH_ITEM*) selection.GetItem( 0 ); - - MSG_PANEL_ITEMS msgItems; - item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems ); - m_frame->SetMsgPanel( msgItems ); - } - else - { - m_frame->ClearMsgPanel(); - } - - return 0; -} - - int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent ) { SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); @@ -733,16 +748,10 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::UnlockSelected, SCH_ACTIONS::unlock.MakeEvent() ); */ - Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, EVENTS::SelectedEvent ); - Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, EVENTS::UnselectedEvent ); - Go( &SCH_EDITOR_CONTROL::CrossProbeSchToPcb, EVENTS::ClearedEvent ); - /* - Go( &SCH_EDITOR_CONTROL::CrossProbePcbToSch, SCH_ACTIONS::crossProbeSchToPcb.MakeEvent() ); - */ - - Go( &SCH_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent ); - Go( &SCH_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent ); - Go( &SCH_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent ); + Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::SelectedEvent ); + Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::UnselectedEvent ); + Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::ClearedEvent ); + Go( &SCH_EDITOR_CONTROL::ExplicitCrossProbeToPcb, SCH_ACTIONS::explicitCrossProbe.MakeEvent() ); #ifdef KICAD_SPICE Go( &SCH_EDITOR_CONTROL::SimProbe, SCH_ACTIONS::simProbe.MakeEvent() ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index ed8a503d34..980e2ee097 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -53,13 +53,12 @@ public: int LockSelected( const TOOL_EVENT& aEvent ); int UnlockSelected( const TOOL_EVENT& aEvent ); - ///> Reacts to selection change in pcbnew. - int CrossProbePcbToSch( const TOOL_EVENT& aEvent ); - ///> Notifies pcbnew about the selected item. - int CrossProbeSchToPcb( const TOOL_EVENT& aEvent ); + int CrossProbeToPcb( const TOOL_EVENT& aEvent ); - int UpdateMessagePanel( const TOOL_EVENT& aEvent ); + ///> Equivalent to the above, but initiated by the user. We also do SCH_SHEETs on this + ///> one (they're too slow on big projects for the auto version above). + int ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent ); #ifdef KICAD_SPICE int SimProbe( const TOOL_EVENT& aEvent ); @@ -92,6 +91,8 @@ private: ///> copy selection to clipboard bool doCopy(); + void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce ); + ///> Sets up handlers for various events. void setTransitions() override; diff --git a/eeschema/tools/sch_inspection_tool.cpp b/eeschema/tools/sch_inspection_tool.cpp index e165afa0a6..a94e01436d 100644 --- a/eeschema/tools/sch_inspection_tool.cpp +++ b/eeschema/tools/sch_inspection_tool.cpp @@ -140,10 +140,36 @@ int SCH_INSPECTION_TOOL::ShowMarkerInfo( const TOOL_EVENT& aEvent ) } +int SCH_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) +{ + SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); + SELECTION& selection = selTool->GetSelection(); + + if( selection.GetSize() == 1 ) + { + SCH_ITEM* item = (SCH_ITEM*) selection.GetItem( 0 ); + + MSG_PANEL_ITEMS msgItems; + item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems ); + m_frame->SetMsgPanel( msgItems ); + } + else + { + m_frame->ClearMsgPanel(); + } + + return 0; +} + + void SCH_INSPECTION_TOOL::setTransitions() { - Go( &SCH_INSPECTION_TOOL::ShowDatasheet, SCH_ACTIONS::showDatasheet.MakeEvent() ); - Go( &SCH_INSPECTION_TOOL::ShowMarkerInfo, SCH_ACTIONS::showMarkerInfo.MakeEvent() ); + Go( &SCH_INSPECTION_TOOL::ShowDatasheet, SCH_ACTIONS::showDatasheet.MakeEvent() ); + Go( &SCH_INSPECTION_TOOL::ShowMarkerInfo, SCH_ACTIONS::showMarkerInfo.MakeEvent() ); + + Go( &SCH_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::SelectedEvent ); + Go( &SCH_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::UnselectedEvent ); + Go( &SCH_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::ClearedEvent ); } diff --git a/eeschema/tools/sch_inspection_tool.h b/eeschema/tools/sch_inspection_tool.h index 17bea62b2b..c82e71e8b5 100644 --- a/eeschema/tools/sch_inspection_tool.h +++ b/eeschema/tools/sch_inspection_tool.h @@ -48,6 +48,8 @@ public: int ShowDatasheet( const TOOL_EVENT& aEvent ); int ShowMarkerInfo( const TOOL_EVENT& aEvent ); + int UpdateMessagePanel( const TOOL_EVENT& aEvent ); + private: ///> @copydoc TOOL_INTERACTIVE::setTransitions(); void setTransitions() override;