Highlight a net when crossprobing with eeschema and highlight net tool is enabled.

This commit is contained in:
Maciej Suminski 2016-01-25 16:16:05 +01:00
parent 3e2b4244f9
commit e51adaeefd
3 changed files with 44 additions and 13 deletions

View File

@ -38,14 +38,15 @@
*/
void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
{
char line[1024];
wxString msg;
wxString modName;
char* idcmd;
char* text;
MODULE* module = 0;
BOARD* pcb = GetBoard();
wxPoint pos;
char line[1024];
wxString msg;
wxString modName;
char* idcmd;
char* text;
MODULE* module = NULL;
D_PAD* pad = NULL;
BOARD* pcb = GetBoard();
wxPoint pos;
strncpy( line, cmdline, sizeof(line) - 1 );
line[sizeof(line) - 1] = 0;
@ -75,7 +76,6 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
else if( strcmp( idcmd, "$PIN:" ) == 0 )
{
wxString pinName;
D_PAD* pad = NULL;
int netcode = -1;
pinName = FROM_UTF8( text );
@ -132,7 +132,12 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
{
if( IsGalCanvasActive() )
{
GetToolManager()->RunAction( COMMON_ACTIONS::crossProbeSchToPcb, true, module );
GetToolManager()->RunAction( COMMON_ACTIONS::crossProbeSchToPcb,
true,
pad ?
static_cast<BOARD_ITEM*>( pad ) :
static_cast<BOARD_ITEM*>( module )
);
}
else
{

View File

@ -642,7 +642,18 @@ int PCB_EDITOR_CONTROL::CrossProbeSchToPcb( const TOOL_EVENT& aEvent )
m_probingSchToPcb = true;
getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, item );
// If it is a pad and the net highlighting tool is enabled, highlight the net
if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
{
int net = static_cast<D_PAD*>( item )->GetNetCode();
m_toolMgr->RunAction( COMMON_ACTIONS::highlightNet, false, net );
}
else
// Otherwise simply select the corresponding item
{
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, item );
}
}
return 0;
@ -714,7 +725,19 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
int PCB_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
{
highlightNet( m_toolMgr, getView()->ToWorld( getViewControls()->GetMousePosition() ) );
int netcode = aEvent.Parameter<long>();
if( netcode > 0 )
{
KIGFX::RENDER_SETTINGS* render = m_toolMgr->GetView()->GetPainter()->GetSettings();
render->SetHighlight( true, netcode );
m_toolMgr->GetView()->UpdateAllLayersColor();
}
else
{
// No net code specified, pick the net code belonging to the item under the cursor
highlightNet( m_toolMgr, getView()->ToWorld( getViewControls()->GetMousePosition() ) );
}
return 0;
}

View File

@ -69,11 +69,14 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
if( !getNext )
break;
else
setControls();
m_toolMgr->PassEvent();
}
else if( evt->IsCancel() || evt->IsActivate() )
break;
else
m_toolMgr->PassEvent();
}
reset();