Allow clearing PcbNew highlight through cross-probing
Fixes: lp:1821486 * https://bugs.launchpad.net/kicad/+bug/1821486
This commit is contained in:
parent
3e4913adce
commit
e0ada1379f
|
@ -244,6 +244,22 @@ void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
|
|||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::SendCrossProbeClearHighlight()
|
||||
{
|
||||
std::string packet = "$CLEAR\n";
|
||||
|
||||
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 )
|
||||
{
|
||||
std::string& payload = mail.GetPayload();
|
||||
|
|
|
@ -465,6 +465,11 @@ public:
|
|||
*/
|
||||
void SendCrossProbeNetName( const wxString& aNetName );
|
||||
|
||||
/**
|
||||
* Tells PcbNew to clear the existing highlighted net, if one exists
|
||||
*/
|
||||
void SendCrossProbeClearHighlight();
|
||||
|
||||
const wxString& GetSelectedNetName() const { return m_SelectedNetName; }
|
||||
void SetSelectedNetName( const wxString& aNetName ) { m_SelectedNetName = aNetName; }
|
||||
|
||||
|
|
|
@ -310,9 +310,19 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
|||
}
|
||||
}
|
||||
|
||||
if( netName.empty() )
|
||||
{
|
||||
editFrame->SetStatusText( wxT( "" ) );
|
||||
editFrame->SendCrossProbeClearHighlight();
|
||||
}
|
||||
else
|
||||
{
|
||||
editFrame->SendCrossProbeNetName( netName );
|
||||
editFrame->SetStatusText( wxString::Format( _( "Selected net: %s" ),
|
||||
UnescapeString( netName ) ) );
|
||||
}
|
||||
|
||||
editFrame->SetSelectedNetName( netName );
|
||||
editFrame->SendCrossProbeNetName( netName );
|
||||
editFrame->SetStatusText( wxString::Format( _( "Selected net: %s" ), UnescapeString( netName ) ) );
|
||||
|
||||
aToolMgr->RunAction( SCH_ACTIONS::highlightNetSelection, true );
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
* $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)
|
||||
* $CLEAR Clear existing highlight
|
||||
* They are a keyword followed by a quoted string.
|
||||
*/
|
||||
void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
||||
|
@ -95,16 +96,28 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
{
|
||||
wxString net_name = FROM_UTF8( text );
|
||||
NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
|
||||
int netcode = 0;
|
||||
int netcode = -1;
|
||||
|
||||
if( netinfo )
|
||||
netcode = netinfo->GetNet();
|
||||
|
||||
if( netcode > 0 )
|
||||
{
|
||||
pcb->SetHighLightNet( netcode );
|
||||
|
||||
if( netinfo )
|
||||
{
|
||||
MSG_PANEL_ITEMS items;
|
||||
netinfo->GetMsgPanelInfo( GetUserUnits(), items );
|
||||
SetMsgPanel( items );
|
||||
}
|
||||
}
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
{
|
||||
auto view = m_toolManager->GetView();
|
||||
auto rs = view->GetPainter()->GetSettings();
|
||||
rs->SetHighlight( true, netcode );
|
||||
rs->SetHighlight( ( netcode >= 0 ), netcode );
|
||||
view->UpdateAllLayersColor();
|
||||
|
||||
BOX2I bbox;
|
||||
|
@ -167,6 +180,18 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
|
||||
return;
|
||||
}
|
||||
else if( strcmp( idcmd, "$CLEAR" ) == 0 )
|
||||
{
|
||||
auto view = m_toolManager->GetView();
|
||||
auto rs = view->GetPainter()->GetSettings();
|
||||
rs->SetHighlight( false );
|
||||
view->UpdateAllLayersColor();
|
||||
|
||||
pcb->ResetHighLight();
|
||||
SetMsgPanel( pcb );
|
||||
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
||||
if( text == NULL )
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue