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 ):
// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
// propogated upwards to parent windows if not handled below. Therefor the
// m_top window should receive all wxWindowDestroyEvents from originating
// from KIWAY_PLAYERs. It does anyways, but now playerDestroyHandler eavesdrops
// m_top window should receive all wxWindowDestroyEvents originating from
// KIWAY_PLAYERs. It does anyways, but now playerDestroyHandler eavesdrops
// on that event stream looking for KIWAY_PLAYERs being closed.
void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event )
......@@ -57,7 +57,7 @@ void KIWAY::playerDestroyHandler( wxWindowDestroyEvent& event )
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 )
{
// DBG(printf( "%s: marking m_player[%d] as destroyed\n", __func__, i );)
......@@ -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
// not pass a bad aFrameType.
......@@ -236,6 +236,8 @@ KIWAY_PLAYER* KIWAY::PlayerCreate( FRAME_T aFrameType )
if( m_player[aFrameType] )
return m_player[aFrameType];
if( doCreate )
{
FACE_T face_type = KifaceType( aFrameType );
wxASSERT( face_type != FACE_T(-1) );
......@@ -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 );
return m_player[aFrameType] = frame;
}
return NULL;
}
......
......@@ -78,7 +78,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
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() )
{
case SCH_FIELD_T:
......@@ -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)
MSG_PANEL_ITEMS items;
Pin->GetMsgPanelInfo( items );
if( LibItem )
......
......@@ -29,6 +29,7 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <macros.h>
#include <eda_dde.h>
#include <wxEeschemaStruct.h>
......@@ -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 )
return;
LIB_PIN* Pin = NULL;
char Line[1024];
/* Cross probing to Pcbnew if a pin or a component is found */
switch( objectToSync->Type() )
// Cross probing to Pcbnew if a pin or a component is found
switch( aComponent->Type() )
{
case SCH_FIELD_T:
case LIB_FIELD_T:
{
if( !LibItem )
if( !aPart )
break;
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
SendCommand( MSG_TO_PCB, Line );
return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
}
break;
case SCH_COMPONENT_T:
LibItem = (SCH_COMPONENT*) objectToSync;
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
SendCommand( MSG_TO_PCB, Line );
break;
aPart = (SCH_COMPONENT*) aComponent;
return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
case LIB_PIN_T:
if( !LibItem )
{
if( !aPart )
break;
Pin = (LIB_PIN*) objectToSync;
LIB_PIN* pin = (LIB_PIN*) aComponent;
if( Pin->GetNumber() )
if( pin->GetNumber() )
{
wxString pinnum;
Pin->PinStringNum( pinnum );
sprintf( Line, "$PIN: %s $PART: %s", TO_UTF8( pinnum ),
TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
pin->PinStringNum( pinnum );
return StrPrintf( "$PIN: %s $PART: %s", TO_UTF8( pinnum ),
TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
}
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;
default:
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 )
{
fn.SetExt( PcbFileExtension );
if( Kiface().IsSingle() )
{
wxString filename = QuoteFullPath( fn );
ExecuteFile( this, PCBNEW_EXE, filename );
}
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 );
}
......@@ -782,10 +796,25 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
fn.SetExt( NetlistFileExtension );
if( fn.IsOk() && fn.FileExists() )
{
if( Kiface().IsSingle() )
{
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
}
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 );
}
......@@ -802,13 +831,15 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
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;
}
component = (SCH_COMPONENT*) item;
}
// @todo: should be changed to use Kiway().Player()?
LIB_EDIT_FRAME* libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
if( libeditFrame )
{
......
......@@ -288,16 +288,19 @@ public:
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,
* 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.
* 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
* 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
......
......@@ -248,7 +248,7 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
kicad_board : legacy_board;
#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->Show( true );
......@@ -266,7 +266,7 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
fn.SetExt( NetlistFileExtension );
#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->Show( true );
......@@ -284,7 +284,7 @@ void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
fn.SetExt( SchematicFileExtension );
#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->Show( true );
......
......@@ -12,6 +12,7 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <wxPcbStruct.h>
#include <eda_dde.h>
#include <macros.h>
......@@ -141,7 +142,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
*/
void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
{
char cmd[1024];
std::string cmd;
const char* text_key;
MODULE* module = NULL;
D_PAD* pad;
......@@ -155,14 +156,14 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
{
case PCB_MODULE_T:
module = (MODULE*) objectToSync;
sprintf( cmd, "$PART: \"%s\"", TO_UTF8( module->GetReference() ) );
StrPrintf( &cmd, "$PART: \"%s\"", TO_UTF8( module->GetReference() ) );
break;
case PCB_PAD_T:
module = (MODULE*) objectToSync->GetParent();
pad = (D_PAD*) objectToSync;
msg = pad->GetPadName();
sprintf( cmd, "$PART: \"%s\" $PAD: \"%s\"",
StrPrintf( &cmd, "$PART: \"%s\" $PAD: \"%s\"",
TO_UTF8( module->GetReference() ),
TO_UTF8( msg ) );
break;
......@@ -178,7 +179,7 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
else
break;
sprintf( cmd, "$PART: \"%s\" %s \"%s\"",
StrPrintf( &cmd, "$PART: \"%s\" %s \"%s\"",
TO_UTF8( module->GetReference() ),
text_key,
TO_UTF8( text_mod->GetText() ) );
......@@ -188,8 +189,12 @@ void PCB_EDIT_FRAME::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
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()
_( "Clear current board and initialize a new one" ),
KiBitmap( new_pcb_xpm ) );
// Open
text = AddHotkeyName( _( "&Open" ), g_Board_Editor_Hokeys_Descr, HK_LOAD_BOARD );
AddMenuItem( filesMenu, ID_LOAD_FILE, text,
_( "Delete current board and load new board" ),
......
......@@ -85,6 +85,9 @@
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_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