|
|
|
@ -73,10 +73,13 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) |
|
|
|
wxString modName; |
|
|
|
char* idcmd; |
|
|
|
char* text; |
|
|
|
int netcode = -1; |
|
|
|
MODULE* module = NULL; |
|
|
|
D_PAD* pad = NULL; |
|
|
|
BOARD* pcb = GetBoard(); |
|
|
|
wxPoint pos; |
|
|
|
|
|
|
|
KIGFX::VIEW* view = m_toolManager->GetView(); |
|
|
|
KIGFX::RENDER_SETTINGS* renderSettings = view->GetPainter()->GetSettings(); |
|
|
|
|
|
|
|
strncpy( line, cmdline, sizeof(line) - 1 ); |
|
|
|
line[sizeof(line) - 1] = 0; |
|
|
|
@ -89,96 +92,51 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) |
|
|
|
|
|
|
|
if( strcmp( idcmd, "$NET:" ) == 0 ) |
|
|
|
{ |
|
|
|
if( IsCurrentTool( PCB_ACTIONS::highlightNetTool ) ) |
|
|
|
{ |
|
|
|
wxString net_name = FROM_UTF8( text ); |
|
|
|
NETINFO_ITEM* netinfo = pcb->FindNet( net_name ); |
|
|
|
int netcode = -1; |
|
|
|
wxString net_name = FROM_UTF8( text ); |
|
|
|
|
|
|
|
if( netinfo ) |
|
|
|
netcode = netinfo->GetNet(); |
|
|
|
NETINFO_ITEM* netinfo = pcb->FindNet( net_name ); |
|
|
|
|
|
|
|
if( netcode > 0 ) |
|
|
|
{ |
|
|
|
pcb->SetHighLightNet( netcode ); |
|
|
|
|
|
|
|
if( netinfo ) |
|
|
|
{ |
|
|
|
MSG_PANEL_ITEMS items; |
|
|
|
netinfo->GetMsgPanelInfo( GetUserUnits(), items ); |
|
|
|
SetMsgPanel( items ); |
|
|
|
} |
|
|
|
} |
|
|
|
if( netinfo ) |
|
|
|
{ |
|
|
|
netcode = netinfo->GetNet(); |
|
|
|
|
|
|
|
auto view = m_toolManager->GetView(); |
|
|
|
auto rs = view->GetPainter()->GetSettings(); |
|
|
|
rs->SetHighlight( ( netcode >= 0 ), netcode ); |
|
|
|
view->UpdateAllLayersColor(); |
|
|
|
MSG_PANEL_ITEMS items; |
|
|
|
netinfo->GetMsgPanelInfo( GetUserUnits(), items ); |
|
|
|
SetMsgPanel( items ); |
|
|
|
} |
|
|
|
} |
|
|
|
else if( strcmp( idcmd, "$PIN:" ) == 0 ) |
|
|
|
{ |
|
|
|
wxString pinName = FROM_UTF8( text ); |
|
|
|
|
|
|
|
BOX2I bbox; |
|
|
|
bool first = true; |
|
|
|
text = strtok( NULL, " \n\r" ); |
|
|
|
|
|
|
|
auto merge_area = [netcode, &bbox, &first]( BOARD_CONNECTED_ITEM* aItem ) |
|
|
|
{ |
|
|
|
if( aItem->GetNetCode() == netcode ) |
|
|
|
{ |
|
|
|
if( first ) |
|
|
|
{ |
|
|
|
bbox = aItem->GetBoundingBox(); |
|
|
|
first = false; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
bbox.Merge( aItem->GetBoundingBox() ); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
for( auto zone : pcb->Zones() ) |
|
|
|
merge_area( zone ); |
|
|
|
|
|
|
|
for( auto track : pcb->Tracks() ) |
|
|
|
merge_area( track ); |
|
|
|
|
|
|
|
for( auto mod : pcb->Modules() ) |
|
|
|
for ( auto mod_pad : mod->Pads() ) |
|
|
|
merge_area( mod_pad ); |
|
|
|
|
|
|
|
if( netcode > 0 && bbox.GetWidth() > 0 && bbox.GetHeight() > 0 ) |
|
|
|
{ |
|
|
|
auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize(); |
|
|
|
auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false ); |
|
|
|
double ratio = std::max( fabs( bbSize.x / screenSize.x ), |
|
|
|
fabs( bbSize.y / screenSize.y ) ); |
|
|
|
double scale = view->GetScale() / ratio; |
|
|
|
|
|
|
|
view->SetScale( scale ); |
|
|
|
view->SetCenter( bbox.Centre() ); |
|
|
|
} |
|
|
|
if( text && strcmp( text, "$PART:" ) == 0 ) |
|
|
|
text = strtok( NULL, "\"\n\r" ); |
|
|
|
|
|
|
|
GetCanvas()->Refresh(); |
|
|
|
} |
|
|
|
modName = FROM_UTF8( text ); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
else if( strcmp( idcmd, "$CLEAR" ) == 0 ) |
|
|
|
{ |
|
|
|
auto view = m_toolManager->GetView(); |
|
|
|
auto rs = view->GetPainter()->GetSettings(); |
|
|
|
rs->SetHighlight( false ); |
|
|
|
view->UpdateAllLayersColor(); |
|
|
|
module = pcb->FindModuleByReference( modName ); |
|
|
|
|
|
|
|
pcb->ResetHighLight(); |
|
|
|
SetMsgPanel( pcb ); |
|
|
|
if( module ) |
|
|
|
pad = module->FindPadByName( pinName ); |
|
|
|
|
|
|
|
GetCanvas()->Refresh(); |
|
|
|
} |
|
|
|
if( pad ) |
|
|
|
netcode = pad->GetNetCode(); |
|
|
|
|
|
|
|
if( text == NULL ) |
|
|
|
return; |
|
|
|
if( module == NULL ) |
|
|
|
msg.Printf( _( "%s not found" ), modName ); |
|
|
|
else if( pad == NULL ) |
|
|
|
msg.Printf( _( "%s pin %s not found" ), modName, pinName ); |
|
|
|
else |
|
|
|
msg.Printf( _( "%s pin %s found" ), modName, pinName ); |
|
|
|
|
|
|
|
if( strcmp( idcmd, "$PART:" ) == 0 ) |
|
|
|
SetStatusText( msg ); |
|
|
|
} |
|
|
|
else if( strcmp( idcmd, "$PART:" ) == 0 ) |
|
|
|
{ |
|
|
|
pcb->ResetNetHighLight(); |
|
|
|
|
|
|
|
modName = FROM_UTF8( text ); |
|
|
|
|
|
|
|
module = pcb->FindModuleByReference( modName ); |
|
|
|
@ -189,9 +147,6 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) |
|
|
|
msg.Printf( _( "%s not found" ), modName ); |
|
|
|
|
|
|
|
SetStatusText( msg ); |
|
|
|
|
|
|
|
if( module ) |
|
|
|
pos = module->GetPosition(); |
|
|
|
} |
|
|
|
else if( strcmp( idcmd, "$SHEET:" ) == 0 ) |
|
|
|
{ |
|
|
|
@ -202,59 +157,84 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) |
|
|
|
static_cast<void*>( &sheetStamp ) ); |
|
|
|
return; |
|
|
|
} |
|
|
|
else if( strcmp( idcmd, "$PIN:" ) == 0 ) |
|
|
|
else if( strcmp( idcmd, "$CLEAR" ) == 0 ) |
|
|
|
{ |
|
|
|
wxString pinName; |
|
|
|
int netcode = -1; |
|
|
|
renderSettings->SetHighlight( false ); |
|
|
|
view->UpdateAllLayersColor(); |
|
|
|
|
|
|
|
pinName = FROM_UTF8( text ); |
|
|
|
pcb->ResetNetHighLight(); |
|
|
|
SetMsgPanel( pcb ); |
|
|
|
|
|
|
|
text = strtok( NULL, " \n\r" ); |
|
|
|
GetCanvas()->Refresh(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if( text && strcmp( text, "$PART:" ) == 0 ) |
|
|
|
text = strtok( NULL, "\"\n\r" ); |
|
|
|
if( module ) |
|
|
|
{ |
|
|
|
renderSettings->SetHighlight( true, -1, true ); |
|
|
|
|
|
|
|
modName = FROM_UTF8( text ); |
|
|
|
for( MODULE* mod : pcb->Modules() ) |
|
|
|
{ |
|
|
|
mod->ClearHighlighted(); |
|
|
|
mod->RunOnChildren( []( BOARD_ITEM* child ) { child->ClearHighlighted(); } ); |
|
|
|
} |
|
|
|
|
|
|
|
module = pcb->FindModuleByReference( modName ); |
|
|
|
module->SetHighlighted(); |
|
|
|
module->RunOnChildren( []( BOARD_ITEM* child ) { child->SetHighlighted(); } ); |
|
|
|
|
|
|
|
if( module ) |
|
|
|
pad = module->FindPadByName( pinName ); |
|
|
|
view->SetCenter( VECTOR2D( module->GetPosition() ) ); |
|
|
|
} |
|
|
|
else if( netcode > 0 ) |
|
|
|
{ |
|
|
|
renderSettings->SetHighlight( ( netcode >= 0 ), netcode ); |
|
|
|
|
|
|
|
if( pad ) |
|
|
|
{ |
|
|
|
netcode = pad->GetNetCode(); |
|
|
|
pcb->SetHighLightNet( netcode ); |
|
|
|
|
|
|
|
// put cursor on the pad:
|
|
|
|
pos = pad->GetPosition(); |
|
|
|
} |
|
|
|
BOX2I bbox; |
|
|
|
|
|
|
|
if( netcode > 0 ) // highlight the pad net
|
|
|
|
{ |
|
|
|
pcb->HighLightON(); |
|
|
|
pcb->SetHighLightNet( netcode ); |
|
|
|
} |
|
|
|
else |
|
|
|
auto merge_area = [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem ) |
|
|
|
{ |
|
|
|
pcb->HighLightOFF(); |
|
|
|
pcb->SetHighLightNet( -1 ); |
|
|
|
} |
|
|
|
if( aItem->GetNetCode() == netcode ) |
|
|
|
{ |
|
|
|
if( bbox.GetWidth() == 0 ) |
|
|
|
bbox = aItem->GetBoundingBox(); |
|
|
|
else |
|
|
|
bbox.Merge( aItem->GetBoundingBox() ); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
if( module == NULL ) |
|
|
|
msg.Printf( _( "%s not found" ), modName ); |
|
|
|
else if( pad == NULL ) |
|
|
|
msg.Printf( _( "%s pin %s not found" ), modName, pinName ); |
|
|
|
else |
|
|
|
msg.Printf( _( "%s pin %s found" ), modName, pinName ); |
|
|
|
for( auto zone : pcb->Zones() ) |
|
|
|
merge_area( zone ); |
|
|
|
|
|
|
|
SetStatusText( msg ); |
|
|
|
} |
|
|
|
for( auto track : pcb->Tracks() ) |
|
|
|
merge_area( track ); |
|
|
|
|
|
|
|
if( module ) // if found, center the module on screen, and redraw the screen.
|
|
|
|
for( auto mod : pcb->Modules() ) |
|
|
|
for ( auto mod_pad : mod->Pads() ) |
|
|
|
merge_area( mod_pad ); |
|
|
|
|
|
|
|
if( bbox.GetWidth() > 0 && bbox.GetHeight() > 0 ) |
|
|
|
{ |
|
|
|
auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize(); |
|
|
|
auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false ); |
|
|
|
double ratio = std::max( fabs( bbSize.x / screenSize.x ), |
|
|
|
fabs( bbSize.y / screenSize.y ) ); |
|
|
|
double scale = view->GetScale() / ratio; |
|
|
|
|
|
|
|
view->SetScale( scale ); |
|
|
|
view->SetCenter( bbox.Centre() ); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
GetToolManager()->RunAction( PCB_ACTIONS::crossProbeSchToPcb, true, |
|
|
|
pad ? (BOARD_ITEM*) pad : (BOARD_ITEM*) module ); |
|
|
|
renderSettings->SetHighlight( false ); |
|
|
|
} |
|
|
|
|
|
|
|
view->UpdateAllLayersColor(); |
|
|
|
// Ensure the display is refreshed, because in some installs the refresh is done only
|
|
|
|
// when the gal canvas has the focus, and that is not the case when crossprobing from
|
|
|
|
// Eeschema:
|
|
|
|
GetCanvas()->Refresh(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|