Commit a985255f authored by Dick Hollenbeck's avatar Dick Hollenbeck

add back missing pcbnew cross probing event handlers. eeschema launches...

add back missing pcbnew cross probing event handlers.  eeschema launches kiface versions of pcbnew & cvpcb if not single.
parent f9f3ff22
...@@ -47,8 +47,8 @@ KIWAY::KIWAY( PGM_BASE* aProgram, wxFrame* aTop ): ...@@ -47,8 +47,8 @@ KIWAY::KIWAY( PGM_BASE* aProgram, wxFrame* aTop ):
// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are // Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
// propogated upwards to parent windows if not handled below. Therefor the // propogated upwards to parent windows if not handled below. Therefor the
// m_top window should receive all wxWindowDestroyEvents from originating // m_top window should receive all wxWindowDestroyEvents originating from
// from KIWAY_PLAYERs. It does anyways, but now playerDestroyHandler eavesdrops // KIWAY_PLAYERs. It does anyways, but now playerDestroyHandler eavesdrops
// on that event stream looking for KIWAY_PLAYERs being closed. // on that event stream looking for KIWAY_PLAYERs being closed.
void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event ) void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event )
...@@ -57,7 +57,7 @@ void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event ) ...@@ -57,7 +57,7 @@ void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event )
for( unsigned i=0; i<DIM(m_player); ++i ) for( unsigned i=0; i<DIM(m_player); ++i )
{ {
// if destroying one of our flock, then mark it as diseased. // if destroying one of our flock, then mark it as deceased.
if( (wxWindow*) m_player[i] == w ) if( (wxWindow*) m_player[i] == w )
{ {
// DBG(printf( "%s: marking m_player[%d] as destroyed\n", __func__, i );) // DBG(printf( "%s: marking m_player[%d] as destroyed\n", __func__, i );)
...@@ -219,7 +219,7 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType ) ...@@ -219,7 +219,7 @@ KIWAY::FACE_T KIWAY::KifaceType( FRAME_T aFrameType )
} }
KIWAY_PLAYER* KIWAY::PlayerCreate( FRAME_T aFrameType ) KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate )
{ {
// Since this will be called from python, cannot assume that code will // Since this will be called from python, cannot assume that code will
// not pass a bad aFrameType. // not pass a bad aFrameType.
...@@ -236,6 +236,8 @@ KIWAY_PLAYER* KIWAY::PlayerCreate( FRAME_T aFrameType ) ...@@ -236,6 +236,8 @@ KIWAY_PLAYER* KIWAY::PlayerCreate( FRAME_T aFrameType )
if( m_player[aFrameType] ) if( m_player[aFrameType] )
return m_player[aFrameType]; return m_player[aFrameType];
if( doCreate )
{
FACE_T face_type = KifaceType( aFrameType ); FACE_T face_type = KifaceType( aFrameType );
wxASSERT( face_type != FACE_T(-1) ); wxASSERT( face_type != FACE_T(-1) );
...@@ -245,6 +247,9 @@ KIWAY_PLAYER* KIWAY::PlayerCreate( FRAME_T aFrameType ) ...@@ -245,6 +247,9 @@ KIWAY_PLAYER* KIWAY::PlayerCreate( FRAME_T aFrameType )
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow( m_top, aFrameType, this, KFCTL_PROJECT_SUITE ); KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow( m_top, aFrameType, this, KFCTL_PROJECT_SUITE );
return m_player[aFrameType] = frame; return m_player[aFrameType] = frame;
}
return NULL;
} }
......
...@@ -78,7 +78,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC ...@@ -78,7 +78,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
return NULL; return NULL;
} }
/* Cross probing to Pcbnew if a pin or a component is found */ // Cross probing to Pcbnew if a pin or a component is found
switch( item->Type() ) switch( item->Type() )
{ {
case SCH_FIELD_T: case SCH_FIELD_T:
...@@ -105,6 +105,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC ...@@ -105,6 +105,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
{ {
// Force display pin information (the previous display could be a component info) // Force display pin information (the previous display could be a component info)
MSG_PANEL_ITEMS items; MSG_PANEL_ITEMS items;
Pin->GetMsgPanelInfo( items ); Pin->GetMsgPanelInfo( items );
if( LibItem ) if( LibItem )
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <kiface_i.h>
#include <macros.h> #include <macros.h>
#include <eda_dde.h> #include <eda_dde.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
...@@ -107,56 +108,74 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) ...@@ -107,56 +108,74 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
} }
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT* LibItem ) std::string FormatProbeItem( EDA_ITEM* aComponent, SCH_COMPONENT* aPart )
{ {
if( objectToSync == NULL ) // Cross probing to Pcbnew if a pin or a component is found
return; switch( aComponent->Type() )
LIB_PIN* Pin = NULL;
char Line[1024];
/* Cross probing to Pcbnew if a pin or a component is found */
switch( objectToSync->Type() )
{ {
case SCH_FIELD_T: case SCH_FIELD_T:
case LIB_FIELD_T: case LIB_FIELD_T:
{ {
if( !LibItem ) if( !aPart )
break; break;
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) ); return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
SendCommand( MSG_TO_PCB, Line );
} }
break; break;
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
LibItem = (SCH_COMPONENT*) objectToSync; aPart = (SCH_COMPONENT*) aComponent;
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) ); return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
SendCommand( MSG_TO_PCB, Line );
break;
case LIB_PIN_T: case LIB_PIN_T:
if( !LibItem ) {
if( !aPart )
break; break;
Pin = (LIB_PIN*) objectToSync; LIB_PIN* pin = (LIB_PIN*) aComponent;
if( Pin->GetNumber() ) if( pin->GetNumber() )
{ {
wxString pinnum; wxString pinnum;
Pin->PinStringNum( pinnum );
sprintf( Line, "$PIN: %s $PART: %s", TO_UTF8( pinnum ), pin->PinStringNum( pinnum );
TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
return StrPrintf( "$PIN: %s $PART: %s", TO_UTF8( pinnum ),
TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
} }
else else
{ {
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) ); return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
}
} }
SendCommand( MSG_TO_PCB, Line );
break; break;
default: default:
break; break;
} }
return "";
}
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aComponent, SCH_COMPONENT* aPart )
{
#if 1
wxASSERT( aComponent ); // fix the caller
#else // WTF?
if( objectToSync == NULL ) // caller remains eternally stupid.
return;
#endif
std::string packet = FormatProbeItem( aComponent, aPart );
if( packet.size() )
{
if( Kiface().IsSingle() )
SendCommand( MSG_TO_PCB, packet.c_str() );
else
{
}
}
} }
This diff is collapsed.
...@@ -764,11 +764,25 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event ) ...@@ -764,11 +764,25 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
{ {
fn.SetExt( PcbFileExtension ); fn.SetExt( PcbFileExtension );
if( Kiface().IsSingle() )
{
wxString filename = QuoteFullPath( fn ); wxString filename = QuoteFullPath( fn );
ExecuteFile( this, PCBNEW_EXE, filename ); ExecuteFile( this, PCBNEW_EXE, filename );
} }
else else
{
KIWAY_PLAYER* player = Kiway().Player( FRAME_PCB, false ); // test open already.
if( !player )
{
player = Kiway().Player( FRAME_PCB, true );
player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
player->Show( true );
}
player->Raise();
}
}
else
{ {
ExecuteFile( this, PCBNEW_EXE ); ExecuteFile( this, PCBNEW_EXE );
} }
...@@ -782,10 +796,25 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) ...@@ -782,10 +796,25 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
fn.SetExt( NetlistFileExtension ); fn.SetExt( NetlistFileExtension );
if( fn.IsOk() && fn.FileExists() ) if( fn.IsOk() && fn.FileExists() )
{
if( Kiface().IsSingle() )
{ {
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) ); ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
} }
else else
{
KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
if( !player )
{
player = Kiway().Player( FRAME_CVPCB, true );
player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
player->Show( true );
}
player->Raise();
}
}
else
{ {
ExecuteFile( this, CVPCB_EXE ); ExecuteFile( this, CVPCB_EXE );
} }
...@@ -802,13 +831,15 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) ...@@ -802,13 +831,15 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
if( (item == NULL) || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) ) if( (item == NULL) || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) )
{ {
wxMessageBox( _("Error: not a component or no component" ) ); wxMessageBox( _( "Error: not a component or no component" ) );
return; return;
} }
component = (SCH_COMPONENT*) item; component = (SCH_COMPONENT*) item;
} }
// @todo: should be changed to use Kiway().Player()?
LIB_EDIT_FRAME* libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();; LIB_EDIT_FRAME* libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
if( libeditFrame ) if( libeditFrame )
{ {
......
...@@ -288,16 +288,19 @@ public: ...@@ -288,16 +288,19 @@ public:
VTBL_ENTRY KIFACE* KiFACE( FACE_T aFaceId, bool doLoad = true ); VTBL_ENTRY KIFACE* KiFACE( FACE_T aFaceId, bool doLoad = true );
/** /**
* Function PlayerCreate * Function Player
* returns the KIWAY_PLAYER* given a FRAME_T. If it is not already created, * returns the KIWAY_PLAYER* given a FRAME_T. If it is not already created,
* the required KIFACE is found and loaded and initialized if necessary, then * the required KIFACE is found and loaded and initialized if necessary, then
* the KIWAY_PLAYER window is created but not shown. Caller must Show() it. * the KIWAY_PLAYER window is created but not shown. Caller must Show() it.
* If it is already created, then the existing KIWAY_PLAYER* pointer is returned. * If it is already created, then the existing KIWAY_PLAYER* pointer is returned.
* *
* @param aFrameType is from enum #FRAME_T.
* @param doCreate when true asks that the player be created if it is not already created, false means do not create.
*
* @return KIWAY_PLAYER* - a valid opened KIWAY_PLAYER or NULL if there * @return KIWAY_PLAYER* - a valid opened KIWAY_PLAYER or NULL if there
* is something wrong. * is something wrong or doCreate was false and the player has yet to be created.
*/ */
VTBL_ENTRY KIWAY_PLAYER* PlayerCreate( FRAME_T aFrameType ); VTBL_ENTRY KIWAY_PLAYER* Player( FRAME_T aFrameType, bool doCreate = true );
/** /**
* Function PlayerClose * Function PlayerClose
......
...@@ -248,7 +248,7 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event ) ...@@ -248,7 +248,7 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
kicad_board : legacy_board; kicad_board : legacy_board;
#if USE_KIFACE #if USE_KIFACE
KIWAY_PLAYER* frame = Kiway.PlayerCreate( FRAME_PCB ); KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB );
frame->OpenProjectFiles( std::vector<wxString>( 1, board.GetFullPath() ) ); frame->OpenProjectFiles( std::vector<wxString>( 1, board.GetFullPath() ) );
frame->Show( true ); frame->Show( true );
...@@ -266,7 +266,7 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event ) ...@@ -266,7 +266,7 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
fn.SetExt( NetlistFileExtension ); fn.SetExt( NetlistFileExtension );
#if USE_KIFACE #if USE_KIFACE
KIWAY_PLAYER* frame = Kiway.PlayerCreate( FRAME_CVPCB ); KIWAY_PLAYER* frame = Kiway.Player( FRAME_CVPCB );
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ); frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
frame->Show( true ); frame->Show( true );
...@@ -284,7 +284,7 @@ void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event ) ...@@ -284,7 +284,7 @@ void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
fn.SetExt( SchematicFileExtension ); fn.SetExt( SchematicFileExtension );
#if USE_KIFACE #if USE_KIFACE
KIWAY_PLAYER* frame = Kiway.PlayerCreate( FRAME_SCH ); KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH );
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ); frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
frame->Show( true ); frame->Show( true );
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <kiface_i.h>
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
#include <eda_dde.h> #include <eda_dde.h>
#include <macros.h> #include <macros.h>
...@@ -141,7 +142,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) ...@@ -141,7 +142,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
*/ */
void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
{ {
char cmd[1024]; std::string cmd;
const char* text_key; const char* text_key;
MODULE* module = NULL; MODULE* module = NULL;
D_PAD* pad; D_PAD* pad;
...@@ -155,14 +156,14 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) ...@@ -155,14 +156,14 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
{ {
case PCB_MODULE_T: case PCB_MODULE_T:
module = (MODULE*) objectToSync; module = (MODULE*) objectToSync;
sprintf( cmd, "$PART: \"%s\"", TO_UTF8( module->GetReference() ) ); StrPrintf( &cmd, "$PART: \"%s\"", TO_UTF8( module->GetReference() ) );
break; break;
case PCB_PAD_T: case PCB_PAD_T:
module = (MODULE*) objectToSync->GetParent(); module = (MODULE*) objectToSync->GetParent();
pad = (D_PAD*) objectToSync; pad = (D_PAD*) objectToSync;
msg = pad->GetPadName(); msg = pad->GetPadName();
sprintf( cmd, "$PART: \"%s\" $PAD: \"%s\"", StrPrintf( &cmd, "$PART: \"%s\" $PAD: \"%s\"",
TO_UTF8( module->GetReference() ), TO_UTF8( module->GetReference() ),
TO_UTF8( msg ) ); TO_UTF8( msg ) );
break; break;
...@@ -178,7 +179,7 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) ...@@ -178,7 +179,7 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
else else
break; break;
sprintf( cmd, "$PART: \"%s\" %s \"%s\"", StrPrintf( &cmd, "$PART: \"%s\" %s \"%s\"",
TO_UTF8( module->GetReference() ), TO_UTF8( module->GetReference() ),
text_key, text_key,
TO_UTF8( text_mod->GetText() ) ); TO_UTF8( text_mod->GetText() ) );
...@@ -188,8 +189,12 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) ...@@ -188,8 +189,12 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
break; break;
} }
if( module ) if( module && cmd.size() )
{
if( Kiface().IsSingle() )
SendCommand( MSG_TO_SCH, cmd.c_str() );
else
{ {
SendCommand( MSG_TO_SCH, cmd ); }
} }
} }
...@@ -68,7 +68,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -68,7 +68,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Clear current board and initialize a new one" ), _( "Clear current board and initialize a new one" ),
KiBitmap( new_pcb_xpm ) ); KiBitmap( new_pcb_xpm ) );
// Open
text = AddHotkeyName( _( "&Open" ), g_Board_Editor_Hokeys_Descr, HK_LOAD_BOARD ); text = AddHotkeyName( _( "&Open" ), g_Board_Editor_Hokeys_Descr, HK_LOAD_BOARD );
AddMenuItem( filesMenu, ID_LOAD_FILE, text, AddMenuItem( filesMenu, ID_LOAD_FILE, text,
_( "Delete current board and load new board" ), _( "Delete current board and load new board" ),
......
...@@ -85,6 +85,9 @@ ...@@ -85,6 +85,9 @@
BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, PCB_EDIT_FRAME::OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT, PCB_EDIT_FRAME::OnSockRequest )
EVT_COMBOBOX( ID_ON_ZOOM_SELECT, PCB_EDIT_FRAME::OnSelectZoom ) EVT_COMBOBOX( ID_ON_ZOOM_SELECT, PCB_EDIT_FRAME::OnSelectZoom )
EVT_COMBOBOX( ID_ON_GRID_SELECT, PCB_EDIT_FRAME::OnSelectGrid ) EVT_COMBOBOX( ID_ON_GRID_SELECT, PCB_EDIT_FRAME::OnSelectGrid )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment