Commit 51fc26e1 authored by dickelbeck's avatar dickelbeck
Browse files

mouse synchronization from PCBNEW to EESCHEMA

parent b0b3a6d5
Loading
Loading
Loading
Loading
+153 −146
Original line number Original line Diff line number Diff line
@@ -23,8 +23,6 @@
#include "common.h"
#include "common.h"
#include "macros.h"
#include "macros.h"


#define ID_CONN "CAO_COM"

wxString HOSTNAME( wxT( "localhost" ) );
wxString HOSTNAME( wxT( "localhost" ) );


/* variables locales */
/* variables locales */
@@ -36,11 +34,11 @@ char server_ipc_buffer[IPC_BUF_SIZE];


wxServer* server;
wxServer* server;


void (* RemoteFct)(char * cmd);
void      (*RemoteFct)(const char* cmd);


char      buffcar[1024];
char      buffcar[1024];


void SetupServerFunction(void (* remotefct)(char * remotecmd) )
void SetupServerFunction( void (*remotefct)(const char* remotecmd) )
{
{
    RemoteFct = remotefct;
    RemoteFct = remotefct;
}
}
@@ -49,6 +47,7 @@ void SetupServerFunction(void (* remotefct)(char * remotecmd) )
/*****************************/
/*****************************/
/* Routines liees au SERVEUR */
/* Routines liees au SERVEUR */
/*****************************/
/*****************************/

/* Fonction d'initialisation d'un serveur socket
/* Fonction d'initialisation d'un serveur socket
 */
 */
WinEDA_Server* CreateServer( wxWindow* window, int service )
WinEDA_Server* CreateServer( wxWindow* window, int service )
@@ -73,6 +72,7 @@ wxIPV4address addr;
/********************************************************/
/********************************************************/
void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
/********************************************************/
/********************************************************/

/* Fonction appelee a chaque demande d'un client
/* Fonction appelee a chaque demande d'un client
 */
 */
{
{
@@ -83,11 +83,14 @@ wxSocketBase *sock = evt.GetSocket();
    {
    {
    case wxSOCKET_INPUT:
    case wxSOCKET_INPUT:
        sock->Read( server_ipc_buffer, 1 );
        sock->Read( server_ipc_buffer, 1 );
		if( sock->LastCount() == 0 ) break;	// No data: Occurs on open connection
        if( sock->LastCount() == 0 )
            break;                          // No data: Occurs on open connection
        
        sock->Read( server_ipc_buffer + 1, IPC_BUF_SIZE - 2 );
        sock->Read( server_ipc_buffer + 1, IPC_BUF_SIZE - 2 );
        len = 1 + sock->LastCount();
        len = 1 + sock->LastCount();
        server_ipc_buffer[len] = 0;
        server_ipc_buffer[len] = 0;
		if(RemoteFct ) RemoteFct(server_ipc_buffer);
        if( RemoteFct )
            RemoteFct( server_ipc_buffer );
        break;
        break;


    case wxSOCKET_LOST:
    case wxSOCKET_LOST:
@@ -100,9 +103,11 @@ wxSocketBase *sock = evt.GetSocket();
    }
    }
}
}



/**************************************************************/
/**************************************************************/
void WinEDA_DrawFrame::OnSockRequestServer( wxSocketEvent& evt )
void WinEDA_DrawFrame::OnSockRequestServer( wxSocketEvent& evt )
/**************************************************************/
/**************************************************************/

/* fonction appele lors d'une demande de connexion d'un client
/* fonction appele lors d'une demande de connexion d'un client
 */
 */
{
{
@@ -110,7 +115,8 @@ wxSocketBase *sock2;
    wxSocketServer* server = (wxSocketServer*) evt.GetSocket();
    wxSocketServer* server = (wxSocketServer*) evt.GetSocket();


    sock2 = server->Accept();
    sock2 = server->Accept();
    if (sock2 == NULL) return;
    if( sock2 == NULL )
        return;


    sock2->Notify( TRUE );
    sock2->Notify( TRUE );
    sock2->SetEventHandler( *this, ID_EDA_SOCKET_EVENT );
    sock2->SetEventHandler( *this, ID_EDA_SOCKET_EVENT );
@@ -122,15 +128,16 @@ wxSocketServer *server = (wxSocketServer *) evt.GetSocket();
/* Routines liees au CLIENT */
/* Routines liees au CLIENT */
/*****************************/
/*****************************/


/********************************************/
/**************************************************/
bool SendCommand( int service, char * cmdline)
bool SendCommand( int service, const char* cmdline )
/********************************************/
/**************************************************/
/* Used by a client to sent (by a socket connection) a data to a server.
	- Open a Socket Client connection
    - Send the buffer cmdline
    - Close the socket connection


    service is the service number for the TC/IP connection
/* Used by a client to sent (by a socket connection) a data to a server.
 *  - Open a Socket Client connection
 *  - Send the buffer cmdline
 *  - Close the socket connection
 * 
 *  service is the service number for the TC/IP connection
 */
 */
{
{
    wxSocketClient* sock_client;
    wxSocketClient* sock_client;
@@ -189,6 +196,7 @@ wxIPV4address addr;
    //   bool success = client->IsConnected();
    //   bool success = client->IsConnected();
    //
    //
    // And that's all :-)
    // And that's all :-)
    
    sock_client = new wxSocketClient();
    sock_client = new wxSocketClient();
    sock_client->SetTimeout( 2 ); // Time out in Seconds
    sock_client->SetTimeout( 2 ); // Time out in Seconds
    sock_client->Connect( addr, FALSE );
    sock_client->Connect( addr, FALSE );
@@ -205,4 +213,3 @@ wxIPV4address addr;
    sock_client->Destroy();
    sock_client->Destroy();
    return success;
    return success;
}
}
+362 −323
Original line number Original line Diff line number Diff line
@@ -21,7 +21,35 @@


/* variables externes */
/* variables externes */


#define MSG_TO_PCB KICAD_PCB_PORT_SERVICE_NUMBER


/**********************************/
void RemoteCommand( const char* cmdline )
/**********************************/

/* Read a remote command sent from pcbnew, so when user selects a module
 * or pin in pcbnew, eeschema shows that same component or pin.
 */
{
    char                line[1024];
    char*               idcmd;
    char*               text;

    strncpy( line, cmdline, sizeof(line) - 1 );

    idcmd = strtok( line, " \n\r" );
    text  = strtok( NULL, " \n\r" );
    if( (idcmd == NULL) || (text == NULL) )
        return;

    if( strcmp( idcmd, "$PART:" ) == 0 )
    {
        WinEDA_SchematicFrame* frame = EDA_Appl->SchematicFrame;
        
        wxString msg = CONV_FROM_UTF8( text );
        frame->FindSchematicItem( msg, 1, false );
    }
}




/**************************************************************/
/**************************************************************/
@@ -30,17 +58,17 @@ EDA_BaseStruct * WinEDA_SchematicFrame::
/**************************************************************/
/**************************************************************/


/* Routine de localisation et d'affichage des caract (si utile )
/* Routine de localisation et d'affichage des caract (si utile )
	de l'element pointe par la souris ou par le curseur pcb
 *  de l'element pointe par la souris ou par le curseur pcb
	- marqueur
 *  - marqueur
	- noconnect
 *  - noconnect
	- jonction
 *  - jonction
	- wire/bus/entry
 *  - wire/bus/entry
	- label
 *  - label
	- composant
 *  - composant
	- pin
 *  - pin
	retourne
 *  retourne
		un pointeur sur le composant
 *      un pointeur sur le composant
		Null sinon
 *      Null sinon
 */
 */
{
{
    EDA_BaseStruct*         DrawStruct;
    EDA_BaseStruct*         DrawStruct;
@@ -55,7 +83,8 @@ char Line[1024];
    {
    {
        DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur, IncludePin );
        DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur, IncludePin );
    }
    }
	if ( ! DrawStruct ) return NULL;
    if( !DrawStruct )
        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( DrawStruct->m_StructType )
    switch( DrawStruct->m_StructType )
@@ -71,7 +100,8 @@ char Line[1024];


    case DRAW_LIB_ITEM_STRUCT_TYPE:
    case DRAW_LIB_ITEM_STRUCT_TYPE:
        Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem );
        Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem );
			if ( Pin ) break;	// Priority is probing a pin first
        if( Pin )
            break;              // Priority is probing a pin first
        LibItem = (EDA_SchComponentStruct*) DrawStruct;
        LibItem = (EDA_SchComponentStruct*) DrawStruct;
        sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) );
        sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) );
        SendCommand( MSG_TO_PCB, Line );
        SendCommand( MSG_TO_PCB, Line );
@@ -116,19 +146,19 @@ EDA_BaseStruct * WinEDA_SchematicFrame::
/************************************************************************************/
/************************************************************************************/


/* Find the schematic item at position "refpoint"
/* Find the schematic item at position "refpoint"
	the priority order is:
 *  the priority order is:
	- marker
 *  - marker
	- noconnect
 *  - noconnect
	- junction
 *  - junction
	- wire/bus/entry
 *  - wire/bus/entry
	- label
 *  - label
	- pin
 *  - pin
	- component
 *  - component
	return:
 *  return:
		an EDA_BaseStruct pointer on the item
 *      an EDA_BaseStruct pointer on the item
		a Null pointer if no item found
 *      a Null pointer if no item found

 * 
	For some items, caracteristics are displayed on the screen.
 *  For some items, caracteristics are displayed on the screen.
 */
 */
{
{
    EDA_BaseStruct*         DrawStruct;
    EDA_BaseStruct*         DrawStruct;
@@ -144,10 +174,11 @@ int ii;
        DrawMarkerStruct* Marker = (DrawMarkerStruct*) DrawStruct;
        DrawMarkerStruct* Marker = (DrawMarkerStruct*) DrawStruct;
        ii   = Marker->m_Type;
        ii   = Marker->m_Type;
        Text = Marker->GetComment();
        Text = Marker->GetComment();
		if(Text.IsEmpty() ) Text = wxT("NoComment");
        if( Text.IsEmpty() )
            Text = wxT( "NoComment" );
        msg = NameMarqueurType[ii]; msg << wxT( " << " ) << Text;
        msg = NameMarqueurType[ii]; msg << wxT( " << " ) << Text;
        Affiche_Message( msg );
        Affiche_Message( msg );
		return(DrawStruct);
        return DrawStruct;
    }
    }


    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
@@ -155,7 +186,7 @@ int ii;
    if( DrawStruct )
    if( DrawStruct )
    {
    {
        MsgPanel->EraseMsgBox();
        MsgPanel->EraseMsgBox();
		return(DrawStruct);
        return DrawStruct;
    }
    }


    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
@@ -163,7 +194,7 @@ int ii;
    if( DrawStruct )
    if( DrawStruct )
    {
    {
        MsgPanel->EraseMsgBox();
        MsgPanel->EraseMsgBox();
		return(DrawStruct);
        return DrawStruct;
    }
    }


    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
@@ -179,10 +210,10 @@ int ii;
                                     LibItem->m_Field[REFERENCE].m_Text,
                                     LibItem->m_Field[REFERENCE].m_Text,
                                     LibItem->m_Field[VALUE].m_Text,
                                     LibItem->m_Field[VALUE].m_Text,
                                     CYAN );
                                     CYAN );
	
        }
        }
		else  MsgPanel->EraseMsgBox();
        else
		return(DrawStruct);
            MsgPanel->EraseMsgBox();
        return DrawStruct;
    }
    }


    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, FIELDCMPITEM );
    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, FIELDCMPITEM );
@@ -192,7 +223,7 @@ int ii;
        LibItem = (EDA_SchComponentStruct*) Field->m_Parent;
        LibItem = (EDA_SchComponentStruct*) Field->m_Parent;
        LibItem->Display_Infos( this );
        LibItem->Display_Infos( this );


		return(DrawStruct);
        return DrawStruct;
    }
    }


    /* search for a pin */
    /* search for a pin */
@@ -205,7 +236,8 @@ int ii;
                                 LibItem->m_Field[REFERENCE].m_Text,
                                 LibItem->m_Field[REFERENCE].m_Text,
                                 LibItem->m_Field[VALUE].m_Text,
                                 LibItem->m_Field[VALUE].m_Text,
                                 CYAN );
                                 CYAN );
		if ( IncludePin == TRUE ) return(LibItem);
        if( IncludePin == TRUE )
            return LibItem;
    }
    }


    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, LIBITEM );
    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, LIBITEM );
@@ -214,7 +246,7 @@ int ii;
        DrawStruct = LocateSmallestComponent( GetScreen() );
        DrawStruct = LocateSmallestComponent( GetScreen() );
        LibItem    = (EDA_SchComponentStruct*) DrawStruct;
        LibItem    = (EDA_SchComponentStruct*) DrawStruct;
        LibItem->Display_Infos( this );
        LibItem->Display_Infos( this );
		return(DrawStruct);
        return DrawStruct;
    }
    }


    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
    DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
@@ -222,7 +254,7 @@ int ii;
    if( DrawStruct )
    if( DrawStruct )
    {
    {
        ( (DrawSheetStruct*) DrawStruct )->Display_Infos( this );
        ( (DrawSheetStruct*) DrawStruct )->Display_Infos( this );
		return(DrawStruct);
        return DrawStruct;
    }
    }


    // Recherche des autres elements
    // Recherche des autres elements
@@ -230,15 +262,14 @@ int ii;
                             SEARCHALL );
                             SEARCHALL );
    if( DrawStruct )
    if( DrawStruct )
    {
    {
		return(DrawStruct);
        return DrawStruct;
    }
    }


    MsgPanel->EraseMsgBox();
    MsgPanel->EraseMsgBox();
	return(NULL);
    return NULL;
}
}





/***********************************************************************/
/***********************************************************************/
void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
/***********************************************************************/
/***********************************************************************/
@@ -256,8 +287,10 @@ int hotkey = 0;
    delta.x = m_CurrentScreen->GetGrid().x / zoom;
    delta.x = m_CurrentScreen->GetGrid().x / zoom;
    delta.y = m_CurrentScreen->GetGrid().y / zoom;
    delta.y = m_CurrentScreen->GetGrid().y / zoom;


	if( delta.x <= 0 ) delta.x = 1;
    if( delta.x <= 0 )
	if( delta.y <= 0 ) delta.y = 1;
        delta.x = 1;
    if( delta.y <= 0 )
        delta.y = 1;


    switch( g_KeyPressed )
    switch( g_KeyPressed )
    {
    {
@@ -265,29 +298,36 @@ int hotkey = 0;
        OnZoom( ID_ZOOM_PANNING_UP );
        OnZoom( ID_ZOOM_PANNING_UP );
        curpos = m_CurrentScreen->m_Curseur;
        curpos = m_CurrentScreen->m_Curseur;
        break;
        break;

    case EDA_PANNING_DOWN_KEY:
    case EDA_PANNING_DOWN_KEY:
        OnZoom( ID_ZOOM_PANNING_DOWN );
        OnZoom( ID_ZOOM_PANNING_DOWN );
        curpos = m_CurrentScreen->m_Curseur;
        curpos = m_CurrentScreen->m_Curseur;
        break;
        break;

    case EDA_PANNING_LEFT_KEY:
    case EDA_PANNING_LEFT_KEY:
        OnZoom( ID_ZOOM_PANNING_LEFT );
        OnZoom( ID_ZOOM_PANNING_LEFT );
        curpos = m_CurrentScreen->m_Curseur;
        curpos = m_CurrentScreen->m_Curseur;
        break;
        break;

    case EDA_PANNING_RIGHT_KEY:
    case EDA_PANNING_RIGHT_KEY:
        OnZoom( ID_ZOOM_PANNING_RIGHT );
        OnZoom( ID_ZOOM_PANNING_RIGHT );
        curpos = m_CurrentScreen->m_Curseur;
        curpos = m_CurrentScreen->m_Curseur;
        break;
        break;

    case WXK_F1:
    case WXK_F1:
        OnZoom( ID_ZOOM_PLUS_KEY );
        OnZoom( ID_ZOOM_PLUS_KEY );
        curpos = m_CurrentScreen->m_Curseur;
        curpos = m_CurrentScreen->m_Curseur;
        break;
        break;

    case WXK_F2:
    case WXK_F2:
        OnZoom( ID_ZOOM_MOINS_KEY );
        OnZoom( ID_ZOOM_MOINS_KEY );
        curpos = m_CurrentScreen->m_Curseur;
        curpos = m_CurrentScreen->m_Curseur;
        break;
        break;

    case WXK_F3:
    case WXK_F3:
        OnZoom( ID_ZOOM_REDRAW_KEY );
        OnZoom( ID_ZOOM_REDRAW_KEY );
        break;
        break;

    case WXK_F4:
    case WXK_F4:
        OnZoom( ID_ZOOM_CENTER_KEY );
        OnZoom( ID_ZOOM_CENTER_KEY );
        curpos = m_CurrentScreen->m_Curseur;
        curpos = m_CurrentScreen->m_Curseur;
@@ -321,13 +361,14 @@ int hotkey = 0;
        DrawPanel->MouseTo( MousePositionInPixels );
        DrawPanel->MouseTo( MousePositionInPixels );
        break;
        break;


		default: hotkey = g_KeyPressed;
    default:
        hotkey = g_KeyPressed;
        break;
        break;
			
    }
    }


    /* Recalcul de la position du curseur schema */
    /* Recalcul de la position du curseur schema */
    m_CurrentScreen->m_Curseur = curpos;
    m_CurrentScreen->m_Curseur = curpos;

    /* Placement sur la grille generale */
    /* Placement sur la grille generale */
    PutOnGrid( &m_CurrentScreen->m_Curseur );
    PutOnGrid( &m_CurrentScreen->m_Curseur );


@@ -354,12 +395,10 @@ int hotkey = 0;


    if( hotkey )
    if( hotkey )
    {
    {
		if( m_CurrentScreen->m_CurrentItem  &&
        if( m_CurrentScreen->m_CurrentItem
			m_CurrentScreen->m_CurrentItem->m_Flags )
            && m_CurrentScreen->m_CurrentItem->m_Flags )
            OnHotKey( DC, hotkey, m_CurrentScreen->m_CurrentItem );
            OnHotKey( DC, hotkey, m_CurrentScreen->m_CurrentItem );
		else OnHotKey(DC, hotkey, NULL);
        else
            OnHotKey( DC, hotkey, NULL );
    }
    }

}
}

+9 −2
Original line number Original line Diff line number Diff line
@@ -20,10 +20,10 @@
#include "netlist.h"
#include "netlist.h"
#include "worksheet.h"
#include "worksheet.h"
#include "trigo.h"
#include "trigo.h"

#include "protos.h"
#include "protos.h"

#include "bitmaps.h"
#include "bitmaps.h"
#include "eda_dde.h"



/* Routines locales */
/* Routines locales */
static void CreateScreens(void);
static void CreateScreens(void);
@@ -72,6 +72,13 @@ wxString FFileName;
	SetTopWindow(SchematicFrame);
	SetTopWindow(SchematicFrame);
	SchematicFrame->Show(TRUE);
	SchematicFrame->Show(TRUE);


    if( CreateServer( SchematicFrame, KICAD_SCH_PORT_SERVICE_NUMBER ) )
    {
        // RemoteCommand is in controle.cpp and is called when PCBNEW
        // sends EESCHEMA a command
        SetupServerFunction( RemoteCommand );
    }
   
	SchematicFrame->Zoom_Automatique(TRUE);
	SchematicFrame->Zoom_Automatique(TRUE);


	/* Load file specified in the command line. */
	/* Load file specified in the command line. */
+496 −431

File changed.

Preview size limit exceeded, changes collapsed.

+4 −0
Original line number Original line Diff line number Diff line
@@ -456,4 +456,8 @@ void InstallFindFrame(WinEDA_SchematicFrame *parent, wxPoint &pos);
/***************/
/***************/
void DisplayOptionFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos);
void DisplayOptionFrame(WinEDA_DrawFrame * parent, const wxPoint & framepos);


/****************/
/* CONTROLE.CPP */
/****************/
void RemoteCommand( const char* cmdline );
Loading