Implement explicit cross-probing (mainly for sheets which are too slow to do automatically).

Also moves the message panel updaters to SCH_INSPECTION_TOOL.
This commit is contained in:
Jeff Young 2019-04-30 19:36:11 +01:00
parent 588d13a912
commit bbd8659f69
10 changed files with 114 additions and 115 deletions

View File

@ -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 ) );

View File

@ -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 )

View File

@ -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
*/

View File

@ -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_SELECTION_TOOL>();
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<SCH_SELECTION_TOOL>();

View File

@ -262,6 +262,9 @@ OPT<TOOL_EVENT> 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<TOOL_EVENT>();

View File

@ -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;

View File

@ -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<SCH_DRAWING_TOOL>();
@ -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<SCH_SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
SCH_ITEM* item = nullptr;
SCH_COMPONENT* component = nullptr;
if( selection.Size() == 1 )
if( aForce )
{
SCH_ITEM* item = static_cast<SCH_ITEM*>( 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;
case SCH_PIN_T:
component = (SCH_COMPONENT*) item->GetParent();
m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
break;
#if 0 // This is too slow on larger projects
case SCH_SHEET_T:
SendMessageToPCBNEW( item, nullptr );
break;
#endif
default:
;
}
if( selection.GetSize() >= 1 )
item = (SCH_ITEM*) selection.Front();
}
return 0;
if( !item )
{
if( aForce )
m_frame->SendMessageToPCBNEW( nullptr, nullptr );
return;
}
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<SCH_PIN*>( 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<SCH_SELECTION_TOOL>();
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<SCH_SELECTION_TOOL>();
@ -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() );

View File

@ -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;

View File

@ -140,10 +140,36 @@ int SCH_INSPECTION_TOOL::ShowMarkerInfo( const TOOL_EVENT& aEvent )
}
void SCH_INSPECTION_TOOL::setTransitions()
int SCH_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{
Go( &SCH_INSPECTION_TOOL::ShowDatasheet, SCH_ACTIONS::showDatasheet.MakeEvent() );
Go( &SCH_INSPECTION_TOOL::ShowMarkerInfo, SCH_ACTIONS::showMarkerInfo.MakeEvent() );
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
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::UpdateMessagePanel, EVENTS::SelectedEvent );
Go( &SCH_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::UnselectedEvent );
Go( &SCH_INSPECTION_TOOL::UpdateMessagePanel, EVENTS::ClearedEvent );
}

View File

@ -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;