diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 3175038aed..d0e71d2fca 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -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 *

* @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(); diff --git a/eeschema/highlight_connection.cpp b/eeschema/highlight_connection.cpp index 367bd3e354..78f50b2d23 100644 --- a/eeschema/highlight_connection.cpp +++ b/eeschema/highlight_connection.cpp @@ -66,6 +66,7 @@ bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition ) } } + SendCrossProbeNetName( m_SelectedNetName ); SetStatusText( "selected net: " + m_SelectedNetName ); SetCurrentSheetHighlightFlags(); m_canvas->Refresh(); diff --git a/eeschema/schframe.h b/eeschema/schframe.h index 78410407ba..bee8da0f11 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -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. * diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index e552482ae1..b914cd3105 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -32,6 +32,7 @@ #include #include #include +#include /* 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(); diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 96ca451e5c..b43301b68b 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -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; diff --git a/pcbnew/wxPcbStruct.h b/pcbnew/wxPcbStruct.h index b1fe57c989..0ca3bcee0d 100644 --- a/pcbnew/wxPcbStruct.h +++ b/pcbnew/wxPcbStruct.h @@ -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