2007-10-08 16:14:16 +00:00
|
|
|
/*********************/
|
|
|
|
/* cross-probing.cpp */
|
|
|
|
/*********************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-10-08 16:14:16 +00:00
|
|
|
#include "common.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "macros.h"
|
2007-10-08 16:14:16 +00:00
|
|
|
#include "eda_dde.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "general.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2007-10-08 16:14:16 +00:00
|
|
|
#include "protos.h"
|
2010-10-08 20:40:57 +00:00
|
|
|
#include "lib_draw_item.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_component.h"
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
void RemoteCommand( const char* cmdline )
|
|
|
|
/***************************************************************/
|
|
|
|
|
|
|
|
/** Read a remote command sent by pcbnew (via a socket connection) ,
|
|
|
|
* so when user selects a module or pin in pcbnew,
|
|
|
|
* eeschema shows that same component or pin.
|
|
|
|
* The cursor is put on the item
|
|
|
|
* port KICAD_SCH_PORT_SERVICE_NUMBER (currently 4243)
|
|
|
|
* @param cmdline = received command from pcbnew
|
|
|
|
* commands are:
|
|
|
|
* $PART: "reference" put cursor on component
|
|
|
|
* $PART: "reference" $REF: "ref" put cursor on reference component
|
|
|
|
* $PART: "reference" $VAL: "value" put cursor on value component
|
|
|
|
* $PART: "reference" $PAD: "pin name" put cursor on the component pin
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char line[1024];
|
|
|
|
char* idcmd;
|
|
|
|
char* text;
|
|
|
|
wxString part_ref, msg;
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME* frame;
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
frame = (SCH_EDIT_FRAME*)wxGetApp().GetTopWindow();
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
strncpy( line, cmdline, sizeof(line) - 1 );
|
|
|
|
|
|
|
|
idcmd = strtok( line, " \n\r" );
|
|
|
|
text = strtok( NULL, "\"\n\r" );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-10-08 16:14:16 +00:00
|
|
|
if( (idcmd == NULL) || (text == NULL) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( strcmp( idcmd, "$PART:" ) != 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
part_ref = CONV_FROM_UTF8( text );
|
|
|
|
|
|
|
|
/* look for a complement */
|
|
|
|
idcmd = strtok( NULL, " \n\r" );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-10-08 16:14:16 +00:00
|
|
|
if( idcmd == NULL ) // component only
|
|
|
|
{
|
|
|
|
frame->FindComponentAndItem( part_ref, true, 0, wxEmptyString, false );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
text = strtok( NULL, "\"\n\r" );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-10-08 16:14:16 +00:00
|
|
|
if( text == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
msg = CONV_FROM_UTF8( text );
|
|
|
|
|
|
|
|
if( strcmp( idcmd, "$REF:" ) == 0 )
|
|
|
|
{
|
|
|
|
frame->FindComponentAndItem( part_ref, true, 2, msg, false );
|
|
|
|
}
|
|
|
|
else if( strcmp( idcmd, "$VAL:" ) == 0 )
|
|
|
|
{
|
|
|
|
frame->FindComponentAndItem( part_ref, true, 3, msg, false );
|
|
|
|
}
|
|
|
|
else if( strcmp( idcmd, "$PAD:" ) == 0 )
|
|
|
|
{
|
|
|
|
frame->FindComponentAndItem( part_ref, true, 1, msg, false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
frame->FindComponentAndItem( part_ref, true, 0, wxEmptyString, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Send a remote command to eeschema via a socket,
|
|
|
|
* @param objectToSync = item to be located on board (footprint, pad or text)
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param LibItem = component in lib if objectToSync is a sub item of a component
|
2007-10-08 16:14:16 +00:00
|
|
|
* Commands are
|
|
|
|
* $PART: reference put cursor on footprint anchor
|
|
|
|
* $PIN: number $PART: reference put cursor on the footprint pad
|
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT* LibItem )
|
2007-10-08 16:14:16 +00:00
|
|
|
{
|
2007-10-09 13:10:58 +00:00
|
|
|
if( objectToSync == NULL )
|
|
|
|
return;
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin = NULL;
|
|
|
|
char Line[1024];
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
/* Cross probing to pcbnew if a pin or a component is found */
|
|
|
|
switch( objectToSync->Type() )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_FIELD_T:
|
|
|
|
case LIB_FIELD_T:
|
2008-12-08 15:27:13 +00:00
|
|
|
{
|
|
|
|
if( LibItem == NULL )
|
|
|
|
break;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
|
2008-12-08 15:27:13 +00:00
|
|
|
SendCommand( MSG_TO_PCB, Line );
|
|
|
|
}
|
|
|
|
break;
|
2007-10-08 16:14:16 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2008-03-20 01:50:21 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) objectToSync;
|
2010-12-08 20:12:46 +00:00
|
|
|
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
|
2007-10-08 16:14:16 +00:00
|
|
|
SendCommand( MSG_TO_PCB, Line );
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_PIN_T:
|
2007-10-09 13:10:58 +00:00
|
|
|
if( LibItem == NULL )
|
|
|
|
break;
|
2008-02-19 07:06:58 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
Pin = (LIB_PIN*) objectToSync;
|
2010-12-07 16:10:42 +00:00
|
|
|
|
|
|
|
if( Pin->GetNumber() )
|
2007-10-08 16:14:16 +00:00
|
|
|
{
|
|
|
|
wxString pinnum;
|
|
|
|
Pin->ReturnPinStringNum( pinnum );
|
|
|
|
sprintf( Line, "$PIN: %s $PART: %s", CONV_TO_UTF8( pinnum ),
|
2008-12-08 15:27:13 +00:00
|
|
|
CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
|
2007-10-08 16:14:16 +00:00
|
|
|
}
|
2007-10-09 13:10:58 +00:00
|
|
|
else
|
2010-12-08 20:12:46 +00:00
|
|
|
{
|
|
|
|
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
|
|
|
|
}
|
2007-10-09 13:10:58 +00:00
|
|
|
|
|
|
|
SendCommand( MSG_TO_PCB, Line );
|
|
|
|
break;
|
2007-10-08 16:14:16 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|