Add bidirectional net highlight cross-probing

Fixes: lp:1738875
* https://bugs.launchpad.net/kicad/+bug/1738875
This commit is contained in:
Jon Evans 2018-01-06 15:50:49 -05:00 committed by Wayne Stambaugh
parent a4bb6ec3e4
commit ca264f8982
6 changed files with 116 additions and 2 deletions

View File

@ -56,6 +56,7 @@
* \li \c \$PART: \c "reference" \c \$REF: \c "ref" Put cursor on component reference.
* \li \c \$PART: \c "reference" \c \$VAL: \c "value" Put cursor on component value.
* \li \c \$PART: \c "reference" \c \$PAD: \c "pin name" Put cursor on the component pin.
* \li \c \$NET: \c "netname" Highlight a specified net
* <p>
* @param cmdline = received command from Pcbnew
*/
@ -69,7 +70,24 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
char* idcmd = strtok( line, " \n\r" );
char* text = strtok( NULL, "\"\n\r" );
if( (idcmd == NULL) || (text == NULL) )
if( idcmd == NULL )
return;
if( strcmp( idcmd, "$NET:" ) == 0 )
{
if( GetToolId() == ID_HIGHLIGHT )
{
m_SelectedNetName = FROM_UTF8( text );
SetStatusText( _( "Selected net: " ) + m_SelectedNetName );
SetCurrentSheetHighlightFlags();
m_canvas->Refresh();
}
return;
}
if( text == NULL )
return;
if( strcmp( idcmd, "$PART:" ) != 0 )
@ -185,6 +203,25 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT
}
void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
{
std::string packet = StrPrintf( "$NET: %s", TO_UTF8( aNetName ) );
if( packet.size() )
{
if( Kiface().IsSingle() )
SendCommand( MSG_TO_PCB, packet.c_str() );
else
{
// Typically ExpressMail is going to be s-expression packets, but since
// we have existing interpreter of the cross probe packet on the other
// side in place, we use that here.
Kiway().ExpressMail( FRAME_PCB, MAIL_CROSS_PROBE, packet, this );
}
}
}
void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
const std::string& payload = mail.GetPayload();

View File

@ -66,6 +66,7 @@ bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition )
}
}
SendCrossProbeNetName( m_SelectedNetName );
SetStatusText( "selected net: " + m_SelectedNetName );
SetCurrentSheetHighlightFlags();
m_canvas->Refresh();

View File

@ -511,6 +511,13 @@ public:
*/
void SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aPart );
/**
* Sends a net name to eeschema for highlighting
*
* @param aNetName is the name of a net, or empty string to clear highlight
*/
void SendCrossProbeNetName( const wxString& aNetName );
/**
* Create a flat list which stores all connected objects.
*

View File

@ -32,6 +32,7 @@
#include <tool/tool_manager.h>
#include <tools/selection_tool.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_painter.h>
/* Execute a remote command send by Eeschema via a socket,
* port KICAD_PCB_PORT_SERVICE_NUMBER
@ -39,6 +40,7 @@
* Commands are
* $PART: "reference" put cursor on component
* $PIN: "pin name" $PART: "reference" put cursor on the footprint pin
* $NET: "net name" highlight the given net (if highlight tool is active)
*/
void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
{
@ -58,7 +60,46 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
idcmd = strtok( line, " \n\r" );
text = strtok( NULL, " \n\r" );
if( !idcmd || !text )
if( idcmd == NULL )
return;
if( strcmp( idcmd, "$NET:" ) == 0 )
{
if( GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
{
wxString net_name = FROM_UTF8( text );
NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
int netcode = 0;
if( netinfo )
netcode = netinfo->GetNet();
if( IsGalCanvasActive() )
{
auto rs = m_toolManager->GetView()->GetPainter()->GetSettings();
rs->SetHighlight( true, netcode );
m_toolManager->GetView()->UpdateAllLayersColor();
GetGalCanvas()->Refresh();
}
else
{
if( netcode > 0 )
{
pcb->HighLightON();
pcb->SetHighLightNet( netcode );
}
else
{
pcb->HighLightOFF();
pcb->SetHighLightNet( -1 );
}
}
}
return;
}
if( text == NULL )
return;
if( strcmp( idcmd, "$PART:" ) == 0 )
@ -246,6 +287,25 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* aSyncItem )
}
void PCB_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
{
std::string packet = StrPrintf( "$NET: \"%s\"", TO_UTF8( aNetName ) );
if( packet.size() )
{
if( Kiface().IsSingle() )
SendCommand( MSG_TO_SCH, packet.c_str() );
else
{
// Typically ExpressMail is going to be s-expression packets, but since
// we have existing interpreter of the cross probe packet on the other
// side in place, we use that here.
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
}
}
}
void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
const std::string& payload = mail.GetPayload();

View File

@ -902,12 +902,14 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
MSG_PANEL_ITEMS items;
netinfo->GetMsgPanelInfo( items );
frame->SetMsgPanel( items );
frame->SendCrossProbeNetName( netinfo->GetNetname() );
}
}
else
{
board->ResetHighLight();
frame->SetMsgPanel( board );
frame->SendCrossProbeNetName( "" );
}
return true;

View File

@ -1667,6 +1667,13 @@ public:
*/
void SendMessageToEESCHEMA( BOARD_ITEM* objectToSync );
/**
* Sends a net name to eeschema for highlighting
*
* @param aNetName is the name of a net, or empty string to clear highlight
*/
void SendCrossProbeNetName( const wxString& aNetName );
/**
* Function Edit_Gap
* edits the GAP module if it has changed the position and/or size of the pads that