Commit 51fc26e1 authored by dickelbeck's avatar dickelbeck

mouse synchronization from PCBNEW to EESCHEMA

parent b0b3a6d5
/////////////////////// ///////////////////////
// Name: eda_dde.cpp // // Name: eda_dde.cpp //
/////////////////////// ///////////////////////
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h> #include <wx/wxprec.h>
...@@ -23,9 +23,7 @@ ...@@ -23,9 +23,7 @@
#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 */
...@@ -34,36 +32,37 @@ wxString HOSTNAME(wxT("localhost")); ...@@ -34,36 +32,37 @@ wxString HOSTNAME(wxT("localhost"));
char client_ipc_buffer[IPC_BUF_SIZE]; char client_ipc_buffer[IPC_BUF_SIZE];
char server_ipc_buffer[IPC_BUF_SIZE]; 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;
} }
/*****************************/ /*****************************/
/* 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 )
{ {
wxIPV4address addr; wxIPV4address addr;
// Create a new server // Create a new server
addr.Service(service); addr.Service( service );
server = new wxServer(addr); server = new wxServer( addr );
if(server) if( server )
{ {
server->SetNotify(wxSOCKET_CONNECTION_FLAG); server->SetNotify( wxSOCKET_CONNECTION_FLAG );
server->SetEventHandler(*window, ID_EDA_SOCKET_EVENT_SERV); server->SetEventHandler( *window, ID_EDA_SOCKET_EVENT_SERV );
server->Notify(TRUE); server->Notify( TRUE );
} }
return server; return server;
...@@ -71,23 +70,27 @@ wxIPV4address addr; ...@@ -71,23 +70,27 @@ 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
*/ */
{ {
size_t len; size_t len;
wxSocketBase *sock = evt.GetSocket(); wxSocketBase* sock = evt.GetSocket();
switch (evt.GetSocketEvent()) switch( evt.GetSocketEvent() )
{ {
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 )
sock->Read(server_ipc_buffer+1,IPC_BUF_SIZE-2); break; // No data: Occurs on open connection
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:
...@@ -95,51 +98,55 @@ wxSocketBase *sock = evt.GetSocket(); ...@@ -95,51 +98,55 @@ wxSocketBase *sock = evt.GetSocket();
break; break;
default: default:
wxPrintf( wxT("WinEDA_DrawFrame::OnSockRequest() error: Invalid event !")); wxPrintf( wxT( "WinEDA_DrawFrame::OnSockRequest() error: Invalid event !" ) );
break; break;
} }
} }
/**************************************************************/ /**************************************************************/
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
*/ */
{ {
wxSocketBase *sock2; 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 );
sock2->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG); sock2->SetNotify( wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG );
} }
/****************************/ /****************************/
/* 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;
bool success = FALSE; bool success = FALSE;
wxIPV4address addr; wxIPV4address addr;
// Create a connexion // Create a connexion
addr.Hostname(HOSTNAME); addr.Hostname( HOSTNAME );
addr.Service(service); addr.Service( service );
// Mini-tutorial for Connect() :-) (JP CHARRAS Note: see wxWidgets: sockets/client.cpp sample) // Mini-tutorial for Connect() :-) (JP CHARRAS Note: see wxWidgets: sockets/client.cpp sample)
// --------------------------- // ---------------------------
...@@ -189,20 +196,20 @@ wxIPV4address addr; ...@@ -189,20 +196,20 @@ 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 );
sock_client->WaitOnConnect(0, 100); sock_client->WaitOnConnect( 0, 100 );
if (sock_client->Ok() && sock_client->IsConnected()) if( sock_client->Ok() && sock_client->IsConnected() )
{ {
success = TRUE; success = TRUE;
sock_client->SetFlags(wxSOCKET_NOWAIT /*wxSOCKET_WAITALL*/); sock_client->SetFlags( wxSOCKET_NOWAIT /*wxSOCKET_WAITALL*/ );
sock_client->Write(cmdline, strlen(cmdline)); sock_client->Write( cmdline, strlen( cmdline ) );
} }
sock_client->Close(); sock_client->Close();
sock_client->Destroy(); sock_client->Destroy();
return success; return success;
} }
/****************/ /****************/
/* controle.cpp */ /* controle.cpp */
/****************/ /****************/
#include "fctsys.h" #include "fctsys.h"
...@@ -21,64 +21,94 @@ ...@@ -21,64 +21,94 @@
/* 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 );
}
}
/**************************************************************/ /**************************************************************/
EDA_BaseStruct * WinEDA_SchematicFrame:: EDA_BaseStruct* WinEDA_SchematicFrame::
SchematicGeneralLocateAndDisplay(bool IncludePin) SchematicGeneralLocateAndDisplay( bool IncludePin )
/**************************************************************/ /**************************************************************/
/* 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;
wxString msg; wxString msg;
wxPoint mouse_position = GetScreen()->m_MousePosition; wxPoint mouse_position = GetScreen()->m_MousePosition;
LibDrawPin * Pin = NULL; LibDrawPin* Pin = NULL;
EDA_SchComponentStruct * LibItem = NULL; EDA_SchComponentStruct* LibItem = NULL;
char Line[1024]; char Line[1024];
DrawStruct = SchematicGeneralLocateAndDisplay(mouse_position, IncludePin); DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin );
if(! DrawStruct && ( mouse_position != GetScreen()->m_Curseur) ) if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) )
{ {
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 )
{ {
case COMPONENT_FIELD_DRAW_TYPE: case COMPONENT_FIELD_DRAW_TYPE:
{ {
PartTextStruct * Field = (PartTextStruct *) DrawStruct; PartTextStruct* Field = (PartTextStruct*) DrawStruct;
LibItem = (EDA_SchComponentStruct * )Field->m_Parent; LibItem = (EDA_SchComponentStruct*) Field->m_Parent;
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 );
} }
break; break;
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 )
LibItem = (EDA_SchComponentStruct *) DrawStruct; break; // Priority is probing a pin first
sprintf(Line,"$PART: %s", CONV_TO_UTF8(LibItem->m_Field[REFERENCE].m_Text) ); LibItem = (EDA_SchComponentStruct*) DrawStruct;
SendCommand(MSG_TO_PCB, Line); sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) );
SendCommand( MSG_TO_PCB, Line );
break; break;
default: default:
Pin = LocateAnyPin(m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem); Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem );
break; break;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
...@@ -86,24 +116,24 @@ char Line[1024]; ...@@ -86,24 +116,24 @@ char Line[1024];
break; break;
} }
if ( Pin ) if( Pin )
{ {
/* Force display pin infos (the previous display could be a component info) */ /* Force display pin infos (the previous display could be a component info) */
Pin->Display_Infos(this); Pin->Display_Infos( this );
if ( LibItem ) if( LibItem )
Affiche_1_Parametre( this, 1, Affiche_1_Parametre( this, 1,
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 );
// Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net) // Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net)
if(Pin->m_PinNum) if( Pin->m_PinNum )
{ {
wxString pinnum; wxString pinnum;
Pin->ReturnPinStringNum(pinnum); Pin->ReturnPinStringNum( pinnum );
sprintf(Line,"$PIN: %s $PART: %s", CONV_TO_UTF8(pinnum), sprintf( Line, "$PIN: %s $PART: %s", CONV_TO_UTF8( pinnum ),
CONV_TO_UTF8(LibItem->m_Field[REFERENCE].m_Text)); CONV_TO_UTF8( LibItem->m_Field[REFERENCE].m_Text ) );
SendCommand(MSG_TO_PCB, Line); SendCommand( MSG_TO_PCB, Line );
} }
} }
return DrawStruct; return DrawStruct;
...@@ -111,144 +141,145 @@ char Line[1024]; ...@@ -111,144 +141,145 @@ char Line[1024];
/************************************************************************************/ /************************************************************************************/
EDA_BaseStruct * WinEDA_SchematicFrame:: EDA_BaseStruct* WinEDA_SchematicFrame::
SchematicGeneralLocateAndDisplay(const wxPoint & refpoint, bool IncludePin) SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
/************************************************************************************/ /************************************************************************************/
/* 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;
LibDrawPin * Pin; LibDrawPin* Pin;
EDA_SchComponentStruct * LibItem; EDA_SchComponentStruct* LibItem;
wxString Text; wxString Text;
wxString msg; wxString msg;
int ii; int ii;
DrawStruct = PickStruct(refpoint, GetScreen()->EEDrawList, MARKERITEM); DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, MARKERITEM );
if( DrawStruct ) if( DrawStruct )
{ {
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() )
msg = NameMarqueurType[ii]; msg << wxT(" << ") << Text; Text = wxT( "NoComment" );
Affiche_Message(msg); msg = NameMarqueurType[ii]; msg << wxT( " << " ) << Text;
return(DrawStruct); Affiche_Message( msg );
return DrawStruct;
} }
DrawStruct = PickStruct(refpoint, GetScreen()->EEDrawList, DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
NOCONNECTITEM); NOCONNECTITEM );
if( DrawStruct ) if( DrawStruct )
{ {
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
return(DrawStruct); return DrawStruct;
} }
DrawStruct = PickStruct(refpoint, GetScreen()->EEDrawList, DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
JUNCTIONITEM); JUNCTIONITEM );
if( DrawStruct ) if( DrawStruct )
{ {
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
return(DrawStruct); return DrawStruct;
} }
DrawStruct = PickStruct(refpoint, GetScreen()->EEDrawList, DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
WIREITEM|BUSITEM|RACCORDITEM); WIREITEM | BUSITEM | RACCORDITEM );
if( DrawStruct ) // Search for a pin if( DrawStruct ) // Search for a pin
{ {
Pin = LocateAnyPin(m_CurrentScreen->EEDrawList,refpoint, &LibItem); Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, refpoint, &LibItem );
if( Pin ) if( Pin )
{ {
Pin->Display_Infos(this); Pin->Display_Infos( this );
if ( LibItem ) if( LibItem )
Affiche_1_Parametre( this, 1, Affiche_1_Parametre( this, 1,
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 );
if( DrawStruct ) if( DrawStruct )
{ {
PartTextStruct * Field = (PartTextStruct *) DrawStruct; PartTextStruct* Field = (PartTextStruct*) DrawStruct;
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 */
Pin = LocateAnyPin(m_CurrentScreen->EEDrawList, refpoint, &LibItem); Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, refpoint, &LibItem );
if( Pin ) if( Pin )
{ {
Pin->Display_Infos(this); Pin->Display_Infos( this );
if ( LibItem ) if( LibItem )
Affiche_1_Parametre( this, 1, Affiche_1_Parametre( this, 1,
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 );
if( DrawStruct ) if( DrawStruct )
{ {
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,
SHEETITEM); SHEETITEM );
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
DrawStruct = PickStruct(refpoint, GetScreen()->EEDrawList, DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
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 )
/***********************************************************************/ /***********************************************************************/
{ {
wxSize delta; wxSize delta;
int zoom = m_CurrentScreen->GetZoom(); int zoom = m_CurrentScreen->GetZoom();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
int hotkey = 0; int hotkey = 0;
ActiveScreen = (SCH_SCREEN *) m_CurrentScreen; ActiveScreen = (SCH_SCREEN*) m_CurrentScreen;
curpos = m_CurrentScreen->m_MousePosition; curpos = m_CurrentScreen->m_MousePosition;
oldpos = m_CurrentScreen->m_Curseur; oldpos = m_CurrentScreen->m_Curseur;
...@@ -256,40 +287,49 @@ int hotkey = 0; ...@@ -256,40 +287,49 @@ 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 )
{ {
case EDA_PANNING_UP_KEY : case EDA_PANNING_UP_KEY:
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 :
OnZoom(ID_ZOOM_PANNING_DOWN); case EDA_PANNING_DOWN_KEY:
OnZoom( ID_ZOOM_PANNING_DOWN );
curpos = m_CurrentScreen->m_Curseur; curpos = m_CurrentScreen->m_Curseur;
break; break;
case EDA_PANNING_LEFT_KEY :
OnZoom(ID_ZOOM_PANNING_LEFT); case EDA_PANNING_LEFT_KEY:
OnZoom( ID_ZOOM_PANNING_LEFT );
curpos = m_CurrentScreen->m_Curseur; curpos = m_CurrentScreen->m_Curseur;
break; break;
case EDA_PANNING_RIGHT_KEY :
OnZoom(ID_ZOOM_PANNING_RIGHT); case EDA_PANNING_RIGHT_KEY:
OnZoom( ID_ZOOM_PANNING_RIGHT );
curpos = m_CurrentScreen->m_Curseur; curpos = m_CurrentScreen->m_Curseur;
break; break;
case WXK_F1 :
OnZoom(ID_ZOOM_PLUS_KEY); case WXK_F1:
OnZoom( ID_ZOOM_PLUS_KEY );
curpos = m_CurrentScreen->m_Curseur; curpos = m_CurrentScreen->m_Curseur;
break; break;
case WXK_F2 :
OnZoom(ID_ZOOM_MOINS_KEY); case WXK_F2:
OnZoom( ID_ZOOM_MOINS_KEY );
curpos = m_CurrentScreen->m_Curseur; curpos = m_CurrentScreen->m_Curseur;
break; break;
case WXK_F3 :
OnZoom(ID_ZOOM_REDRAW_KEY); case WXK_F3:
OnZoom( ID_ZOOM_REDRAW_KEY );
break; break;
case WXK_F4 :
OnZoom(ID_ZOOM_CENTER_KEY); case WXK_F4:
OnZoom( ID_ZOOM_CENTER_KEY );
curpos = m_CurrentScreen->m_Curseur; curpos = m_CurrentScreen->m_Curseur;
break; break;
...@@ -297,69 +337,68 @@ int hotkey = 0; ...@@ -297,69 +337,68 @@ int hotkey = 0;
m_CurrentScreen->m_O_Curseur = m_CurrentScreen->m_Curseur; m_CurrentScreen->m_O_Curseur = m_CurrentScreen->m_Curseur;
break; break;
case WXK_NUMPAD8 : /* Deplacement curseur vers le haut */ case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
case WXK_UP : case WXK_UP:
MousePositionInPixels.y -= delta.y; MousePositionInPixels.y -= delta.y;
DrawPanel->MouseTo(MousePositionInPixels); DrawPanel->MouseTo( MousePositionInPixels );
break ; break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_DOWN: case WXK_DOWN:
MousePositionInPixels.y += delta.y; MousePositionInPixels.y += delta.y;
DrawPanel->MouseTo(MousePositionInPixels); DrawPanel->MouseTo( MousePositionInPixels );
break ; break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
case WXK_LEFT : case WXK_LEFT:
MousePositionInPixels.x -= delta.x; MousePositionInPixels.x -= delta.x;
DrawPanel->MouseTo(MousePositionInPixels); DrawPanel->MouseTo( MousePositionInPixels );
break ; break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
case WXK_RIGHT: case WXK_RIGHT:
MousePositionInPixels.x += delta.x; MousePositionInPixels.x += delta.x;
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 );
if( m_CurrentScreen->IsRefreshReq() ) if( m_CurrentScreen->IsRefreshReq() )
{ {
RedrawActiveWindow(DC, TRUE); RedrawActiveWindow( DC, TRUE );
} }
if ( oldpos != m_CurrentScreen->m_Curseur ) if( oldpos != m_CurrentScreen->m_Curseur )
{ {
curpos = m_CurrentScreen->m_Curseur; curpos = m_CurrentScreen->m_Curseur;
m_CurrentScreen->m_Curseur = oldpos; m_CurrentScreen->m_Curseur = oldpos;
DrawPanel->CursorOff(DC); DrawPanel->CursorOff( DC );
m_CurrentScreen->m_Curseur = curpos; m_CurrentScreen->m_Curseur = curpos;
DrawPanel->CursorOn(DC); DrawPanel->CursorOn( DC );
if(DrawPanel->ManageCurseur) if( DrawPanel->ManageCurseur )
{ {
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
} }
} }
Affiche_Status_Box(); /* Affichage des coord curseur */ Affiche_Status_Box(); /* Affichage des coord curseur */
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 );
} }
} }
...@@ -20,10 +20,10 @@ ...@@ -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; ...@@ -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. */
......
/****************************************************************/ /****************************************************************/
/* EESchema: find.cpp (functions for seraching a schematic item */ /* EESchema: find.cpp (functions for seraching a schematic item */
/****************************************************************/ /****************************************************************/
/* /*
Search a text (text, value, reference) withing e composent or * Search a text (text, value, reference) withing e composent or
search a composant in libraries, a marker ..., * search a composant in libraries, a marker ...,
in current sheet or whole the project * in current sheet or whole the project
*/ */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -24,70 +25,77 @@ static wxString s_OldStringFound; ...@@ -24,70 +25,77 @@ static wxString s_OldStringFound;
#include "protos.h" #include "protos.h"
/**************************************************************/ /**************************************************************/
void InstallFindFrame(WinEDA_SchematicFrame *parent, wxPoint & pos) void InstallFindFrame( WinEDA_SchematicFrame* parent, wxPoint& pos )
/**************************************************************/ /**************************************************************/
{ {
parent->DrawPanel->m_IgnoreMouseEvents = TRUE; parent->DrawPanel->m_IgnoreMouseEvents = TRUE;
WinEDA_FindFrame * frame = new WinEDA_FindFrame(parent); WinEDA_FindFrame* frame = new WinEDA_FindFrame( parent );
frame->ShowModal(); frame->Destroy(); frame->ShowModal(); frame->Destroy();
parent->DrawPanel->m_IgnoreMouseEvents = FALSE; parent->DrawPanel->m_IgnoreMouseEvents = FALSE;
} }
/**************************************************************/ /**************************************************************/
void WinEDA_FindFrame::FindMarker(wxCommandEvent& event) void WinEDA_FindFrame::FindMarker( wxCommandEvent& event )
/**************************************************************/ /**************************************************************/
/* Search de markers in whole the hierarchy. /* Search de markers in whole the hierarchy.
Mouse cursor is put on the marker * Mouse cursor is put on the marker
search the first marker, or next marker * search the first marker, or next marker
*/ */
{ {
int id = event.GetId(); int id = event.GetId();
if( id != FIND_NEXT_MARKER ) m_Parent->FindMarker(0);
else m_Parent->FindMarker(1);
Close(); if( id != FIND_NEXT_MARKER )
m_Parent->FindMarker( 0 );
else
m_Parent->FindMarker( 1 );
Close();
} }
/*****************************************************************/ /*****************************************************************/
EDA_BaseStruct * WinEDA_SchematicFrame::FindMarker(int SearchType) EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType )
/*****************************************************************/ /*****************************************************************/
/* Search markers in whole the hierarchy. /* Search markers in whole the hierarchy.
Mouse cursor is put on the marker * Mouse cursor is put on the marker
SearchType = 0: search the first marker, else search next marker * SearchType = 0: search the first marker, else search next marker
*/ */
{ {
SCH_SCREEN * Screen, * FirstScreen = NULL; SCH_SCREEN* Screen, * FirstScreen = NULL;
EDA_BaseStruct *DrawList, *FirstStruct = NULL, *Struct = NULL; EDA_BaseStruct* DrawList, * FirstStruct = NULL, * Struct = NULL;
DrawMarkerStruct * Marker = NULL; DrawMarkerStruct* Marker = NULL;
int StartCount; int StartCount;
bool NotFound; bool NotFound;
wxPoint firstpos, pos; wxPoint firstpos, pos;
wxSize size = DrawPanel->GetClientSize(); wxSize size = DrawPanel->GetClientSize();
wxPoint curpos, old_cursor_position; wxPoint curpos, old_cursor_position;
bool force_recadre = FALSE; bool force_recadre = FALSE;
wxString msg, WildText; wxString msg, WildText;
g_LastSearchIsMarker = TRUE; g_LastSearchIsMarker = TRUE;
/* Set s_MarkerCount to 0 if we are look for the first marker */ /* Set s_MarkerCount to 0 if we are look for the first marker */
if( SearchType == 0 ) s_MarkerCount = 0; if( SearchType == 0 )
s_MarkerCount = 0;
EDA_ScreenList ScreenList( NULL );
EDA_ScreenList ScreenList(NULL);
NotFound = TRUE; StartCount = 0; NotFound = TRUE; StartCount = 0;
/* Search for s_MarkerCount markers */ /* Search for s_MarkerCount markers */
for ( Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() ) for( Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() )
{ {
DrawList = Screen->EEDrawList; DrawList = Screen->EEDrawList;
while ( DrawList && NotFound ) while( DrawList && NotFound )
{ {
if(DrawList->m_StructType == DRAW_MARKER_STRUCT_TYPE ) if( DrawList->m_StructType == DRAW_MARKER_STRUCT_TYPE )
{ {
Marker = (DrawMarkerStruct *) DrawList; Marker = (DrawMarkerStruct*) DrawList;
NotFound = FALSE; NotFound = FALSE;
pos = Marker->m_Pos; pos = Marker->m_Pos;
if ( FirstScreen == NULL ) /* First item found */ if( FirstScreen == NULL ) /* First item found */
{ {
FirstScreen = Screen; firstpos = pos; FirstScreen = Screen; firstpos = pos;
FirstStruct = DrawList; FirstStruct = DrawList;
...@@ -100,12 +108,14 @@ wxString msg, WildText; ...@@ -100,12 +108,14 @@ wxString msg, WildText;
} }
else /* We have found s_MarkerCount markers -> Ok */ else /* We have found s_MarkerCount markers -> Ok */
{ {
Struct = DrawList; s_MarkerCount++; break ; Struct = DrawList; s_MarkerCount++; break;
} }
} }
DrawList = DrawList->Pnext; DrawList = DrawList->Pnext;
} }
if( NotFound == FALSE ) break;
if( NotFound == FALSE )
break;
} }
if( NotFound && FirstScreen ) // markers are found, but we have reach the last marker */ if( NotFound && FirstScreen ) // markers are found, but we have reach the last marker */
...@@ -115,11 +125,11 @@ wxString msg, WildText; ...@@ -115,11 +125,11 @@ wxString msg, WildText;
pos = firstpos; s_MarkerCount = 1; pos = firstpos; s_MarkerCount = 1;
} }
if( NotFound == FALSE) if( NotFound == FALSE )
{ {
if ( Screen != GetScreen() ) if( Screen != GetScreen() )
{ {
Screen->SetZoom(GetScreen()->GetZoom() ); Screen->SetZoom( GetScreen()->GetZoom() );
m_CurrentScreen = ActiveScreen = Screen; m_CurrentScreen = ActiveScreen = Screen;
force_recadre = TRUE; force_recadre = TRUE;
} }
...@@ -127,38 +137,39 @@ wxString msg, WildText; ...@@ -127,38 +137,39 @@ wxString msg, WildText;
old_cursor_position = Screen->m_Curseur; old_cursor_position = Screen->m_Curseur;
Screen->m_Curseur = pos; Screen->m_Curseur = pos;
curpos = DrawPanel->CursorScreenPosition(); curpos = DrawPanel->CursorScreenPosition();
// calcul des coord curseur avec origine = screen // calcul des coord curseur avec origine = screen
DrawPanel->GetViewStart(&m_CurrentScreen->m_StartVisu.x, DrawPanel->GetViewStart( &m_CurrentScreen->m_StartVisu.x,
&m_CurrentScreen->m_StartVisu.y); &m_CurrentScreen->m_StartVisu.y );
curpos.x -= m_CurrentScreen->m_StartVisu.x; curpos.x -= m_CurrentScreen->m_StartVisu.x;
curpos.y -= m_CurrentScreen->m_StartVisu.y; curpos.y -= m_CurrentScreen->m_StartVisu.y;
/* Il y a peut-etre necessite de recadrer le dessin: */ /* Il y a peut-etre necessite de recadrer le dessin: */
if( (curpos.x <= 0) || (curpos.x >= size.x-1) || if( (curpos.x <= 0) || (curpos.x >= size.x - 1)
(curpos.y <= 0) || (curpos.y >= size.y) || force_recadre ) || (curpos.y <= 0) || (curpos.y >= size.y) || force_recadre )
{ {
Recadre_Trace(TRUE); Recadre_Trace( TRUE );
} }
else else
{ {
wxClientDC dc(DrawPanel); wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext(&dc);
EXCHG(old_cursor_position, Screen->m_Curseur);
DrawPanel->CursorOff(&dc);
GRMouseWarp(DrawPanel, curpos );
EXCHG(old_cursor_position, Screen->m_Curseur);
DrawPanel->CursorOn(&dc);
}
msg.Printf( _("Marker %d found in %s"), s_MarkerCount, Screen->m_FileName.GetData()); DrawPanel->PrepareGraphicContext( &dc );
Affiche_Message(msg); EXCHG( old_cursor_position, Screen->m_Curseur );
DrawPanel->CursorOff( &dc );
GRMouseWarp( DrawPanel, curpos );
EXCHG( old_cursor_position, Screen->m_Curseur );
DrawPanel->CursorOn( &dc );
} }
msg.Printf( _( "Marker %d found in %s" ), s_MarkerCount, Screen->m_FileName.GetData() );
Affiche_Message( msg );
}
else else
{ {
Affiche_Message(wxEmptyString); Affiche_Message( wxEmptyString );
msg = _("Marker Not Found"); msg = _( "Marker Not Found" );
DisplayError(this,msg, 10); DisplayError( this, msg, 10 );
} }
return Marker; return Marker;
...@@ -166,45 +177,51 @@ wxString msg, WildText; ...@@ -166,45 +177,51 @@ wxString msg, WildText;
/**************************************************************/ /**************************************************************/
void WinEDA_FindFrame::FindSchematicItem(wxCommandEvent& event) void WinEDA_FindFrame::FindSchematicItem( wxCommandEvent& event )
/**************************************************************/ /**************************************************************/
/* Find a string in schematic. /* Find a string in schematic.
Call to WinEDA_SchematicFrame::FindSchematicItem() * Call to WinEDA_SchematicFrame::FindSchematicItem()
*/ */
{ {
int id = event.GetId(); int id = event.GetId();
if( id == FIND_SHEET ) if( id == FIND_SHEET )
m_Parent->FindSchematicItem(m_NewTextCtrl->GetValue(), 0); m_Parent->FindSchematicItem( m_NewTextCtrl->GetValue(), 0 );
else if( id == FIND_HIERARCHY ) else if( id == FIND_HIERARCHY )
m_Parent->FindSchematicItem(m_NewTextCtrl->GetValue(), 1); m_Parent->FindSchematicItem( m_NewTextCtrl->GetValue(), 1 );
else if( id == FIND_NEXT ) else if( id == FIND_NEXT )
m_Parent->FindSchematicItem(wxEmptyString, 2); m_Parent->FindSchematicItem( wxEmptyString, 2 );
Close(); Close();
} }
/************************************************************************/ /************************************************************************/
EDA_BaseStruct * WinEDA_SchematicFrame::FindSchematicItem( EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem(
const wxString & pattern, int SearchType) const wxString& pattern, int SearchType, bool mouseWarp )
/************************************************************************/ /************************************************************************/
/* Find a string in schematic.
Search is made in current sheet (SearchType = 0), /**
or the whole hierarchy (SearchType = 1), * Function FindSchematicItem
or for the next item (SearchType = 2). * finds a string in the schematic.
Mouse cursor is put on item * @param pattern The text to search for, either in value, reference or elsewhere.
*/ * @param SearchType: 0 => Search is made in current sheet
* 1 => the whole hierarchy
* 2 => or for the next item
* @param mouseWarp If true, then move the mouse cursor to the item.
*/
{ {
SCH_SCREEN * Screen, * FirstScreen = NULL; SCH_SCREEN* Screen, * FirstScreen = NULL;
EDA_BaseStruct *DrawList = NULL, *FirstStruct = NULL, *Struct = NULL; EDA_BaseStruct* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL;
int StartCount, ii, jj; int StartCount, ii, jj;
bool NotFound; bool NotFound;
wxPoint firstpos, pos, old_cursor_position; wxPoint firstpos, pos, old_cursor_position;
static int Find_in_hierarchy; static int Find_in_hierarchy;
wxSize size = DrawPanel->GetClientSize(); wxSize size = DrawPanel->GetClientSize();
wxPoint curpos; wxPoint curpos;
bool force_recadre = FALSE; bool force_recadre = FALSE;
wxString msg, WildText; wxString msg, WildText;
g_LastSearchIsMarker = FALSE; g_LastSearchIsMarker = FALSE;
...@@ -220,47 +237,51 @@ wxString msg, WildText; ...@@ -220,47 +237,51 @@ wxString msg, WildText;
Find_in_hierarchy = TRUE; Find_in_hierarchy = TRUE;
} }
if( SearchType != 2 ) s_ItemsCount = 0; if( SearchType != 2 )
s_ItemsCount = 0;
WildText = s_OldStringFound; WildText = s_OldStringFound;
NotFound = TRUE; StartCount = 0; NotFound = TRUE;
StartCount = 0;
EDA_ScreenList ScreenList( NULL );
EDA_ScreenList ScreenList(NULL);
Screen = ScreenList.GetFirst(); Screen = ScreenList.GetFirst();
if ( ! Find_in_hierarchy ) Screen = (SCH_SCREEN*) m_CurrentScreen; if( !Find_in_hierarchy )
Screen = (SCH_SCREEN*) m_CurrentScreen;
for ( ; Screen != NULL; Screen = ScreenList.GetNext() ) for( ; Screen != NULL; Screen = ScreenList.GetNext() )
{ {
DrawList = Screen->EEDrawList; DrawList = Screen->EEDrawList;
while ( DrawList ) while( DrawList )
{ {
switch (DrawList->m_StructType) switch( DrawList->m_StructType )
{ {
case DRAW_LIB_ITEM_STRUCT_TYPE : case DRAW_LIB_ITEM_STRUCT_TYPE:
#undef STRUCT EDA_SchComponentStruct* pSch;
#define STRUCT ((EDA_SchComponentStruct*)DrawList) pSch = (EDA_SchComponentStruct*) DrawList;
if( WildCompareString( WildText, STRUCT->m_Field[REFERENCE].m_Text, FALSE ) ) if( WildCompareString( WildText, pSch->m_Field[REFERENCE].m_Text, FALSE ) )
{ {
NotFound = FALSE; NotFound = FALSE;
pos = STRUCT->m_Field[REFERENCE].m_Pos; pos = pSch->m_Field[REFERENCE].m_Pos;
break; break;
} }
if( WildCompareString( WildText, STRUCT->m_Field[VALUE].m_Text, FALSE ) ) if( WildCompareString( WildText, pSch->m_Field[VALUE].m_Text, FALSE ) )
{ {
NotFound = FALSE; NotFound = FALSE;
pos = STRUCT->m_Field[VALUE].m_Pos; pos = pSch->m_Field[VALUE].m_Pos;
} }
break; break;
case DRAW_LABEL_STRUCT_TYPE : case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE : case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE : case DRAW_TEXT_STRUCT_TYPE:
#undef STRUCT DrawTextStruct* pDraw;
#define STRUCT ((DrawTextStruct*)DrawList) pDraw = (DrawTextStruct*) DrawList;
if( WildCompareString( WildText, STRUCT->m_Text, FALSE ) ) if( WildCompareString( WildText, pDraw->m_Text, FALSE ) )
{ {
NotFound = FALSE; NotFound = FALSE;
pos = STRUCT->m_Pos; pos = pDraw->m_Pos;
} }
break; break;
...@@ -268,11 +289,12 @@ wxString msg, WildText; ...@@ -268,11 +289,12 @@ wxString msg, WildText;
break; break;
} }
if(NotFound == FALSE) /* Element trouve */ if( NotFound == FALSE ) /* Element trouve */
{ {
if ( FirstScreen == NULL ) /* 1er element trouve */ if( FirstScreen == NULL ) /* 1er element trouve */
{ {
FirstScreen = Screen; firstpos = pos; FirstScreen = Screen;
firstpos = pos;
FirstStruct = DrawList; FirstStruct = DrawList;
} }
...@@ -283,80 +305,109 @@ wxString msg, WildText; ...@@ -283,80 +305,109 @@ wxString msg, WildText;
} }
else else
{ {
Struct = DrawList; s_ItemsCount++; break ; Struct = DrawList;
s_ItemsCount++;
break;
} }
} }
if( NotFound == FALSE ) break; if( NotFound == FALSE )
break;
DrawList = DrawList->Pnext; DrawList = DrawList->Pnext;
} }
if( NotFound == FALSE ) break;
if( Find_in_hierarchy == FALSE ) break; if( NotFound == FALSE )
break;
if( Find_in_hierarchy == FALSE )
break;
} }
if( NotFound && FirstScreen ) if( NotFound && FirstScreen )
{ {
NotFound = FALSE; Screen = FirstScreen; Struct = FirstStruct; NotFound = FALSE;
pos = firstpos; s_ItemsCount = 1; Screen = FirstScreen;
Struct = FirstStruct;
pos = firstpos;
s_ItemsCount = 1;
} }
if( NotFound == FALSE) if( NotFound == FALSE )
{ {
if ( Screen != GetScreen() ) if( Screen != GetScreen() )
{ {
Screen->SetZoom(GetScreen()->GetZoom() ); Screen->SetZoom( GetScreen()->GetZoom() );
m_CurrentScreen = ActiveScreen = Screen; m_CurrentScreen = ActiveScreen = Screen;
force_recadre = TRUE; force_recadre = TRUE;
} }
/* Si la struct localisee est du type DRAW_LIB_ITEM_STRUCT_TYPE, /* Si la struct localisee est du type DRAW_LIB_ITEM_STRUCT_TYPE,
Les coordonnes sont a recalculer en fonction de la matrice * Les coordonnes sont a recalculer en fonction de la matrice
d'orientation */ * d'orientation */
if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE ) if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
{ {
#undef STRUCT EDA_SchComponentStruct* pSch = (EDA_SchComponentStruct*) Struct;
#define STRUCT ((EDA_SchComponentStruct*)Struct)
pos.x -= STRUCT->m_Pos.x; pos.y -= STRUCT->m_Pos.y; pos.x -= pSch->m_Pos.x;
ii = STRUCT->m_Transform[0][0] * pos.x + STRUCT->m_Transform[0][1] * pos.y; pos.y -= pSch->m_Pos.y;
jj = STRUCT->m_Transform[1][0] * pos.x + STRUCT->m_Transform[1][1] * pos.y;
pos.x = ii + STRUCT->m_Pos.x; pos.y = jj + STRUCT->m_Pos.y; ii = pSch->m_Transform[0][0] * pos.x + pSch->m_Transform[0][1] * pos.y;
jj = pSch->m_Transform[1][0] * pos.x + pSch->m_Transform[1][1] * pos.y;
pos.x = ii + pSch->m_Pos.x;
pos.y = jj + pSch->m_Pos.y;
} }
old_cursor_position = Screen->m_Curseur; old_cursor_position = Screen->m_Curseur;
Screen->m_Curseur = pos; Screen->m_Curseur = pos;
curpos = DrawPanel->CursorScreenPosition(); curpos = DrawPanel->CursorScreenPosition();
DrawPanel->GetViewStart(&m_CurrentScreen->m_StartVisu.x,
&m_CurrentScreen->m_StartVisu.y); DrawPanel->GetViewStart(
&m_CurrentScreen->m_StartVisu.x,
&m_CurrentScreen->m_StartVisu.y );
// calcul des coord curseur avec origine = screen // calcul des coord curseur avec origine = screen
curpos.x -= m_CurrentScreen->m_StartVisu.x; curpos.x -= m_CurrentScreen->m_StartVisu.x;
curpos.y -= m_CurrentScreen->m_StartVisu.y; curpos.y -= m_CurrentScreen->m_StartVisu.y;
/* Il y a peut-etre necessite de recadrer le dessin: */ /* Il y a peut-etre necessite de recadrer le dessin: */
if( (curpos.x <= 0) || (curpos.x >= size.x-1) || if( (curpos.x <= 0) || (curpos.x >= size.x - 1)
(curpos.y <= 0) || (curpos.y >= size.y) || force_recadre ) || (curpos.y <= 0) || (curpos.y >= size.y) || force_recadre )
{ {
Recadre_Trace(TRUE); Recadre_Trace( mouseWarp );
} }
else else
{ {
wxClientDC dc(DrawPanel); wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext(&dc);
EXCHG(old_cursor_position, Screen->m_Curseur); DrawPanel->PrepareGraphicContext( &dc );
DrawPanel->CursorOff(&dc);
GRMouseWarp(DrawPanel, curpos ); EXCHG( old_cursor_position, Screen->m_Curseur );
EXCHG(old_cursor_position, Screen->m_Curseur); DrawPanel->CursorOff( &dc );
DrawPanel->CursorOn(&dc);
} if( mouseWarp )
GRMouseWarp( DrawPanel, curpos );
msg = WildText + _(" Found in ") + Screen->m_FileName; EXCHG( old_cursor_position, Screen->m_Curseur );
Affiche_Message(msg);
DrawPanel->CursorOn( &dc );
} }
msg = WildText + _( " Found in " ) + Screen->m_FileName;
Affiche_Message( msg );
}
else else
{ {
Affiche_Message(wxEmptyString); Affiche_Message( wxEmptyString );
msg = WildText + _(" Not Found");
DisplayError(this,msg, 10); if( !mouseWarp )
{
// if called from RemoteCommand() don't popup the dialog which
// needs to be dismissed, user is in PCBNEW, and does'nt want to
// bother with dismissing the dialog in EESCHEMA.
msg = WildText + _( " Not Found" );
DisplayError( this, msg, 10 );
}
} }
return DrawList; return DrawList;
...@@ -364,130 +415,144 @@ wxString msg, WildText; ...@@ -364,130 +415,144 @@ wxString msg, WildText;
/*************************************************************/ /*************************************************************/
void WinEDA_FindFrame::LocatePartInLibs(wxCommandEvent& event) void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
/*************************************************************/ /*************************************************************/
/* Recherche exhaustive d'un composant en librairies, meme non chargees /* Recherche exhaustive d'un composant en librairies, meme non chargees
*/ */
{ {
wxString Text, FindList; wxString Text, FindList;
const wxChar ** ListNames; const wxChar** ListNames;
LibraryStruct *Lib = NULL; LibraryStruct* Lib = NULL;
EDA_LibComponentStruct * LibEntry; EDA_LibComponentStruct* LibEntry;
bool FoundInLib = FALSE; // True si reference trouvee ailleurs qu'en cache bool FoundInLib = FALSE; // True si reference trouvee ailleurs qu'en cache
Text = m_NewTextCtrl->GetValue(); Text = m_NewTextCtrl->GetValue();
if ( Text.IsEmpty() ) if( Text.IsEmpty() )
{ {
Close(); return; Close(); return;
} }
s_OldStringFound = Text; s_OldStringFound = Text;
int ii, nbitems, NumOfLibs = NumOfLibraries(); int ii, nbitems, NumOfLibs = NumOfLibraries();
if (NumOfLibs == 0) if( NumOfLibs == 0 )
{ {
DisplayError(this, _("No libraries are loaded")); DisplayError( this, _( "No libraries are loaded" ) );
Close(); return; Close(); return;
} }
ListNames = GetLibNames(); ListNames = GetLibNames();
nbitems = 0; nbitems = 0;
for (ii = 0; ii < NumOfLibs; ii++ ) /* Recherche de la librairie */ for( ii = 0; ii < NumOfLibs; ii++ ) /* Recherche de la librairie */
{ {
bool IsLibCache; bool IsLibCache;
Lib = FindLibrary(ListNames[ii]); Lib = FindLibrary( ListNames[ii] );
if ( Lib == NULL ) break; if( Lib == NULL )
if ( Lib->m_Name.Contains( wxT(".cache")) ) IsLibCache = TRUE; break;
else IsLibCache = FALSE; if( Lib->m_Name.Contains( wxT( ".cache" ) ) )
LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE); IsLibCache = TRUE;
else
IsLibCache = FALSE;
LibEntry = (EDA_LibComponentStruct*) PQFirst( &Lib->m_Entries, FALSE );
while( LibEntry ) while( LibEntry )
{ {
if( WildCompareString(Text, LibEntry->m_Name.m_Text, FALSE) ) if( WildCompareString( Text, LibEntry->m_Name.m_Text, FALSE ) )
{ {
nbitems ++; nbitems++;
if ( ! IsLibCache ) FoundInLib = TRUE; if( !IsLibCache )
if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); FoundInLib = TRUE;
FindList << _("Found ") if( !FindList.IsEmpty() )
FindList += wxT( "\n" );
FindList << _( "Found " )
+ LibEntry->m_Name.m_Text + LibEntry->m_Name.m_Text
+ _(" in lib ") + Lib->m_Name; + _( " in lib " ) + Lib->m_Name;
} }
LibEntry = (EDA_LibComponentStruct *) PQNext(Lib->m_Entries, LibEntry, NULL); LibEntry = (EDA_LibComponentStruct*) PQNext( Lib->m_Entries, LibEntry, NULL );
} }
} }
free (ListNames); free( ListNames );
if ( ! FoundInLib ) if( !FoundInLib )
{ {
if ( nbitems ) FindList = wxT("\n") + Text + _(" found only in cache"); if( nbitems )
else FindList = Text + _(" not found"); FindList = wxT( "\n" ) + Text + _( " found only in cache" );
FindList += _("\nExplore All Libraries?"); else
if ( IsOK(this, FindList) ) FindList = Text + _( " not found" );
FindList += _( "\nExplore All Libraries?" );
if( IsOK( this, FindList ) )
{ {
FindList.Empty(); FindList.Empty();
ExploreAllLibraries(Text, FindList); ExploreAllLibraries( Text, FindList );
if ( FindList.IsEmpty() ) DisplayInfo(this, _("Nothing found") ); if( FindList.IsEmpty() )
else DisplayInfo(this, FindList); DisplayInfo( this, _( "Nothing found" ) );
else
DisplayInfo( this, FindList );
} }
} }
else DisplayInfo(this, FindList); else
DisplayInfo( this, FindList );
Close(); Close();
} }
/***************************************************************************************/ /***************************************************************************************/
int WinEDA_FindFrame::ExploreAllLibraries(const wxString & wildmask, wxString & FindList) int WinEDA_FindFrame::ExploreAllLibraries( const wxString& wildmask, wxString& FindList )
/***************************************************************************************/ /***************************************************************************************/
{ {
wxString FullFileName; wxString FullFileName;
FILE * file; FILE* file;
int nbitems = 0, LineNum = 0; int nbitems = 0, LineNum = 0;
char Line[2048], *name; char Line[2048], * name;
FullFileName = MakeFileName(g_RealLibDirBuffer, wxT("*"), g_LibExtBuffer); FullFileName = MakeFileName( g_RealLibDirBuffer, wxT( "*" ), g_LibExtBuffer );
FullFileName = wxFindFirstFile(FullFileName); FullFileName = wxFindFirstFile( FullFileName );
while ( ! FullFileName.IsEmpty() ) while( !FullFileName.IsEmpty() )
{ {
file = wxFopen(FullFileName, wxT("rt")); file = wxFopen( FullFileName, wxT( "rt" ) );
if (file == NULL) continue; if( file == NULL )
continue;
while (GetLine(file, Line, &LineNum, sizeof(Line)) ) while( GetLine( file, Line, &LineNum, sizeof(Line) ) )
{ {
if (strnicmp(Line, "DEF", 3) == 0) if( strnicmp( Line, "DEF", 3 ) == 0 )
{ /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */ { /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */
strtok(Line, " \t\r\n"); strtok( Line, " \t\r\n" );
name = strtok(NULL, " \t\r\n"); name = strtok( NULL, " \t\r\n" );
wxString st_name = CONV_FROM_UTF8(name); wxString st_name = CONV_FROM_UTF8( name );
if( WildCompareString(wildmask, st_name, FALSE) ) if( WildCompareString( wildmask, st_name, FALSE ) )
{ {
nbitems ++; nbitems++;
if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); if( !FindList.IsEmpty() )
FindList << _("Found ") << CONV_FROM_UTF8(name) FindList += wxT( "\n" );
<< _(" in lib ") << FullFileName; FindList << _( "Found " ) << CONV_FROM_UTF8( name )
<< _( " in lib " ) << FullFileName;
} }
} }
else if (strnicmp(Line, "ALIAS", 5) == 0) else if( strnicmp( Line, "ALIAS", 5 ) == 0 )
{ /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */ { /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */
strtok(Line, " \t\r\n"); strtok( Line, " \t\r\n" );
while ( (name = strtok(NULL, " \t\r\n")) != NULL ) while( ( name = strtok( NULL, " \t\r\n" ) ) != NULL )
{ {
wxString st_name = CONV_FROM_UTF8(name); wxString st_name = CONV_FROM_UTF8( name );
if( WildCompareString( wildmask, st_name, FALSE) ) if( WildCompareString( wildmask, st_name, FALSE ) )
{ {
nbitems ++; nbitems++;
if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); if( !FindList.IsEmpty() )
FindList << _("Found ") << CONV_FROM_UTF8(name) FindList += wxT( "\n" );
<< _(" in lib ") << FullFileName; FindList << _( "Found " ) << CONV_FROM_UTF8( name )
<< _( " in lib " ) << FullFileName;
} }
} }
} }
} }
fclose(file);
fclose( file );
FullFileName = wxFindNextFile(); FullFileName = wxFindNextFile();
} }
return nbitems; return nbitems;
} }
...@@ -456,4 +456,8 @@ void InstallFindFrame(WinEDA_SchematicFrame *parent, wxPoint &pos); ...@@ -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 );
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
BEGIN_EVENT_TABLE(WinEDA_SchematicFrame, wxFrame) BEGIN_EVENT_TABLE(WinEDA_SchematicFrame, wxFrame)
COMMON_EVENTS_DRAWFRAME COMMON_EVENTS_DRAWFRAME
EVT_SOCKET(ID_EDA_SOCKET_EVENT_SERV, WinEDA_DrawFrame::OnSockRequestServer)
EVT_SOCKET(ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest)
EVT_CLOSE(WinEDA_SchematicFrame::OnCloseWindow) EVT_CLOSE(WinEDA_SchematicFrame::OnCloseWindow)
EVT_SIZE(WinEDA_SchematicFrame::OnSize) EVT_SIZE(WinEDA_SchematicFrame::OnSize)
......
/************************************************************/ /************************************************************/
/* appl_wxstruct.h: */ /* appl_wxstruct.h: */
/* descriptions des principales classes derivees utilisees: */ /* descriptions des principales classes derivees utilisees: */
/* Class "EDA_Appl: classe de l'application generale */ /* Class "EDA_Appl: classe de l'application generale */
/************************************************************/ /************************************************************/
/* Ce fichier doit etre inclus dans "wxstruct.h" /* Ce fichier doit etre inclus dans "wxstruct.h"
*/ */
#ifndef APPL_WXSTRUCT_H #ifndef APPL_WXSTRUCT_H
#define APPL_WXSTRUCT_H #define APPL_WXSTRUCT_H
...@@ -15,79 +15,77 @@ ...@@ -15,79 +15,77 @@
#endif #endif
/**********************************************/ /**********************************************/
/* Class representing the entire Application */ /* Class representing the entire Application */
/**********************************************/ /**********************************************/
eda_global WinEDA_App * EDA_Appl; /* application representant le programme */ eda_global WinEDA_App* EDA_Appl; /* application representant le programme */
class WinEDA_App: public wxApp class WinEDA_App : public wxApp
{ {
public: public:
wxString m_Project; wxString m_Project;
wxSingleInstanceChecker * m_Checker; wxSingleInstanceChecker* m_Checker;
WinEDA_MainFrame * m_MainFrame; WinEDA_MainFrame* m_MainFrame;
WinEDA_PcbFrame * m_PcbFrame; WinEDA_PcbFrame* m_PcbFrame;
WinEDA_ModuleEditFrame * m_ModuleEditFrame; WinEDA_ModuleEditFrame* m_ModuleEditFrame;
WinEDA_GerberFrame * m_GerberFrame; WinEDA_GerberFrame* m_GerberFrame;
WinEDA_SchematicFrame * SchematicFrame; // Edition des Schemas WinEDA_SchematicFrame* SchematicFrame; // Edition des Schemas
WinEDA_LibeditFrame * LibeditFrame; // Edition des composants WinEDA_LibeditFrame* LibeditFrame; // Edition des composants
WinEDA_ViewlibFrame * ViewlibFrame; // Visualisation des composants WinEDA_ViewlibFrame* ViewlibFrame; // Visualisation des composants
WinEDA_CvpcbFrame * m_CvpcbFrame; WinEDA_CvpcbFrame* m_CvpcbFrame;
wxPoint m_HelpPos; wxPoint m_HelpPos;
wxSize m_HelpSize; wxSize m_HelpSize;
wxHtmlHelpController * m_HtmlCtrl; wxHtmlHelpController* m_HtmlCtrl;
wxConfig * m_EDA_Config; // Config courante (tailles et positions fenetres ...*/ wxConfig* m_EDA_Config; // Config courante (tailles et positions fenetres ...*/
wxConfig * m_EDA_CommonConfig; // common setup (language ...) */ wxConfig* m_EDA_CommonConfig; // common setup (language ...) */
wxString m_HelpFileName; wxString m_HelpFileName;
wxString m_CurrentOptionFile; // dernier fichier .cnf utilis wxString m_CurrentOptionFile; // dernier fichier .cnf utilis
wxString m_CurrentOptionFileDateAndTime; wxString m_CurrentOptionFileDateAndTime;
wxString m_BinDir; /* Chemin ou reside l'executable wxString m_BinDir; /* Chemin ou reside l'executable
(utilis si KICAD non dfini)*/ * (utilis si KICAD non dfini)*/
wxArrayString m_LastProject; /* liste des derniers projets chargs */ wxArrayString m_LastProject; /* liste des derniers projets chargs */
unsigned int m_LastProjectMaxCount; /* Max histhory file length */ unsigned int m_LastProjectMaxCount; /* Max histhory file length */
wxString m_KicadEnv; /* Chemin de kicad dfini dans la variable wxString m_KicadEnv;/* Chemin de kicad dfini dans la variable
d'environnement KICAD, * d'environnement KICAD,
typiquement /usr/local/kicad ou c:\kicad */ * typiquement /usr/local/kicad ou c:\kicad */
bool m_Env_Defined; // TRUE si variable d'environnement KICAD definie bool m_Env_Defined; // TRUE si variable d'environnement KICAD definie
wxLocale * m_Locale; // Gestion de la localisation wxLocale* m_Locale; // Gestion de la localisation
int m_LanguageId; // indicateur de choix du langage ( 0 = defaut) int m_LanguageId; // indicateur de choix du langage ( 0 = defaut)
wxMenu * m_Language_Menu; // List menu for languages wxMenu* m_Language_Menu; // List menu for languages
wxString m_PdfBrowser; // Name of the selected browser, for browsing pdf datasheets wxString m_PdfBrowser; // Name of the selected browser, for browsing pdf datasheets
bool m_PdfBrowserIsDefault; // True if the pdf browser is the default (m_PdfBrowser not used) bool m_PdfBrowserIsDefault; // True if the pdf browser is the default (m_PdfBrowser not used)
public: public:
WinEDA_App(void); WinEDA_App( void );
~WinEDA_App(void); ~WinEDA_App( void );
bool OnInit(void); bool OnInit( void );
int OnRun(void); int OnRun( void );
bool SetBinDir(void); bool SetBinDir( void );
void InitEDA_Appl(const wxString & name); void InitEDA_Appl( const wxString& name );
bool SetLanguage(bool first_time = FALSE); bool SetLanguage( bool first_time = FALSE );
wxMenu * SetLanguageList(wxMenu * MasterMenu); wxMenu* SetLanguageList( wxMenu* MasterMenu );
void SetLanguageIdentifier(int menu_id); void SetLanguageIdentifier( int menu_id );
void InitOnLineHelp(void); void InitOnLineHelp( void );
// Sauvegarde de configurations et options: // Sauvegarde de configurations et options:
void GetSettings(void); void GetSettings( void );
void SaveSettings(void); void SaveSettings( void );
void SetLastProject(const wxString & FullFileName); void SetLastProject( const wxString& FullFileName );
void WriteProjectConfig(const wxString & local_config_filename, void WriteProjectConfig( const wxString& local_config_filename,
const wxString & GroupName, PARAM_CFG_BASE ** List); const wxString& GroupName, PARAM_CFG_BASE** List );
bool ReadProjectConfig(const wxString & local_config_filename, bool ReadProjectConfig( const wxString& local_config_filename,
const wxString & GroupName, PARAM_CFG_BASE ** List, const wxString& GroupName, PARAM_CFG_BASE** List,
bool Load_Only_if_New); bool Load_Only_if_New );
void ReadPdfBrowserInfos(void); void ReadPdfBrowserInfos( void );
void WritePdfBrowserInfos(void); void WritePdfBrowserInfos( void );
}; };
#endif /* APPL_WXSTRUCT_H */ #endif /* APPL_WXSTRUCT_H */
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
#define COMMON_GLOBL extern #define COMMON_GLOBL extern
#endif #endif
/* Numero de ports TCP/IP utilis�s par KICAD */
#define KICAD_PCB_PORT_SERVICE_NUMBER 4242
/* Etat des touches speciales du clavier */ /* Etat des touches speciales du clavier */
......
...@@ -11,17 +11,20 @@ ...@@ -11,17 +11,20 @@
#define WinEDA_Server wxSocketServer #define WinEDA_Server wxSocketServer
/********************/ // TCP/IP ports used by PCBNEW and EESCHEMA respectively.
/* autres fonctions */ #define KICAD_PCB_PORT_SERVICE_NUMBER 4242 ///< PCBNEW listens on this port for commands from EESCHEMA
/********************/ #define KICAD_SCH_PORT_SERVICE_NUMBER 4243 ///< EESCHEMA listens on this port for commands from PCBNEW
WinEDA_Server * CreateServer(wxWindow * window, int service);
bool SendCommand( int service, char * cmdline);
void SetupServerFunction(void (* remotefct)(char * remotecmd) );
#define MSG_TO_PCB KICAD_PCB_PORT_SERVICE_NUMBER
#define MSG_TO_SCH KICAD_SCH_PORT_SERVICE_NUMBER
/********************/
/* autres fonctions */
/********************/
WinEDA_Server * CreateServer( wxWindow * window, int port );
bool SendCommand( int port, const char* cmdline );
void SetupServerFunction( void (*remotefct) (const char* remotecmd) );
...@@ -700,6 +700,14 @@ public: ...@@ -700,6 +700,14 @@ public:
// divers // divers
void InstallFindFrame( const wxPoint& pos, wxDC* DC ); void InstallFindFrame( const wxPoint& pos, wxDC* DC );
/**
* Function SendMessageToEESCHEMA
* sends a message to the schematic editor so that it may move its cursor
* to a part with the same reference as the objectToSync
* @param objectToSync The object whose reference is used to syncronize eeschema.
*/
void SendMessageToEESCHEMA( EDA_BaseStruct* objectToSync );
/* Special micro_ondes */ /* Special micro_ondes */
void Edit_Gap( wxDC* DC, MODULE* Module ); void Edit_Gap( wxDC* DC, MODULE* Module );
MODULE* Create_MuWaveBasicShape( wxDC* DC, const wxString& name, int pad_count ); MODULE* Create_MuWaveBasicShape( wxDC* DC, const wxString& name, int pad_count );
...@@ -974,7 +982,17 @@ public: ...@@ -974,7 +982,17 @@ public:
bool LoadOneSheet( SCH_SCREEN* screen, const wxString& FullFileName ); bool LoadOneSheet( SCH_SCREEN* screen, const wxString& FullFileName );
// General search: // General search:
EDA_BaseStruct* FindSchematicItem( const wxString& pattern, int SearchType ); /**
* Function FindSchematicItem
* finds a string in the schematic.
* @param pattern The text to search for, either in value, reference or elsewhere.
* @param SearchType: 0 => Search is made in current sheet
* 1 => the whole hierarchy
* 2 => or for the next item
* @param mouseWarp If true, then move the mouse cursor to the item.
*/
EDA_BaseStruct* FindSchematicItem( const wxString& pattern, int SearchType, bool mouseWarp=true );
EDA_BaseStruct* FindMarker( int SearchType ); EDA_BaseStruct* FindMarker( int SearchType );
private: private:
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
/* class_text_module.h : texts module description */ /* class_text_module.h : texts module description */
/***************************************************/ /***************************************************/
#ifndef TEXT_MODULE_H
#define TEXT_MODULE_H
/* Description des Textes sur Modules : */ /* Description des Textes sur Modules : */
#define TEXT_is_REFERENCE 0 #define TEXT_is_REFERENCE 0
#define TEXT_is_VALUE 1 #define TEXT_is_VALUE 1
...@@ -80,3 +85,6 @@ public: ...@@ -80,3 +85,6 @@ public:
virtual void Show( int nestLevel, std::ostream& os ); virtual void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
#endif // TEXT_MODULE_H
...@@ -22,52 +22,56 @@ ...@@ -22,52 +22,56 @@
/* Variables Locales */ /* Variables Locales */
/**********************************/ /**********************************/
void RemoteCommand( char* cmdline ) void RemoteCommand( const char* cmdline )
/**********************************/ /**********************************/
/* Read a remote command send by eeschema via a socket, /* Read a remote command send by eeschema via a socket,
* port KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242) * port KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242)
*/ */
{ {
char Line[1024]; char line[1024];
wxString msg; wxString msg;
char* idcmd, * text; char* idcmd, * text;
WinEDA_PcbFrame* frame = EDA_Appl->m_PcbFrame; WinEDA_PcbFrame* frame = EDA_Appl->m_PcbFrame;
strncpy( Line, cmdline, sizeof(Line) - 1 ); strncpy( line, cmdline, sizeof(line) - 1 );
msg = CONV_FROM_UTF8( Line ); msg = CONV_FROM_UTF8( line );
idcmd = strtok( Line, " \n\r" ); idcmd = strtok( line, " \n\r" );
text = strtok( NULL, " \n\r" ); text = strtok( NULL, " \n\r" );
if( (idcmd == NULL) || (text == NULL) ) if( (idcmd == NULL) || (text == NULL) )
return; return;
if( strcmp( idcmd, "$PART:" ) == 0 ) if( strcmp( idcmd, "$PART:" ) == 0 )
{ {
MODULE* Module;
msg = CONV_FROM_UTF8( text ); msg = CONV_FROM_UTF8( text );
Module = ReturnModule( frame->m_Pcb, msg );
MODULE* module = ReturnModule( frame->m_Pcb, msg );
msg.Printf( _( "Locate module %s %s" ), msg.GetData(), msg.Printf( _( "Locate module %s %s" ), msg.GetData(),
Module ? wxT( "Ok" ) : wxT( "not found" ) ); module ? wxT( "Ok" ) : wxT( "not found" ) );
frame->Affiche_Message( msg ); frame->Affiche_Message( msg );
if( Module ) if( module )
{ {
wxClientDC dc( frame->DrawPanel ); wxClientDC dc( frame->DrawPanel );
frame->DrawPanel->PrepareGraphicContext( &dc ); frame->DrawPanel->PrepareGraphicContext( &dc );
frame->DrawPanel->CursorOff( &dc ); frame->DrawPanel->CursorOff( &dc );
frame->GetScreen()->m_Curseur = Module->m_Pos; frame->GetScreen()->m_Curseur = module->m_Pos;
frame->DrawPanel->CursorOn( &dc ); frame->DrawPanel->CursorOn( &dc );
} }
} }
if( idcmd && strcmp( idcmd, "$PIN:" ) == 0 ) if( idcmd && strcmp( idcmd, "$PIN:" ) == 0 )
{ {
wxString PinName, ModName; wxString pinName, modName;
MODULE* Module; MODULE* module;
D_PAD* Pad = NULL; D_PAD* pad = NULL;
int netcode = -1; int netcode = -1;
PinName = CONV_FROM_UTF8( text );
pinName = CONV_FROM_UTF8( text );
text = strtok( NULL, " \n\r" ); text = strtok( NULL, " \n\r" );
if( text && strcmp( text, "$PART:" ) == 0 ) if( text && strcmp( text, "$PART:" ) == 0 )
text = strtok( NULL, "\n\r" ); text = strtok( NULL, "\n\r" );
...@@ -76,30 +80,34 @@ void RemoteCommand( char* cmdline ) ...@@ -76,30 +80,34 @@ void RemoteCommand( char* cmdline )
frame->DrawPanel->PrepareGraphicContext( &dc ); frame->DrawPanel->PrepareGraphicContext( &dc );
ModName = CONV_FROM_UTF8( text ); modName = CONV_FROM_UTF8( text );
Module = ReturnModule( frame->m_Pcb, ModName ); module = ReturnModule( frame->m_Pcb, modName );
if( Module ) if( module )
Pad = ReturnPad( Module, PinName ); pad = ReturnPad( module, pinName );
if( Pad )
netcode = Pad->m_NetCode; if( pad )
netcode = pad->m_NetCode;
if( netcode > 0 ) if( netcode > 0 )
{ {
/* effacement surbrillance ancienne */ /* effacement surbrillance ancienne */
if( g_HightLigt_Status ) if( g_HightLigt_Status )
frame->Hight_Light( &dc ); frame->Hight_Light( &dc );
g_HightLigth_NetCode = netcode; g_HightLigth_NetCode = netcode;
frame->Hight_Light( &dc ); frame->Hight_Light( &dc );
frame->DrawPanel->CursorOff( &dc ); frame->DrawPanel->CursorOff( &dc );
frame->GetScreen()->m_Curseur = Pad->m_Pos; frame->GetScreen()->m_Curseur = pad->m_Pos;
frame->DrawPanel->CursorOn( &dc ); frame->DrawPanel->CursorOn( &dc );
} }
if( Module == NULL ) if( module == NULL )
msg.Printf( _( "module %s not found" ), text ); msg.Printf( _( "module %s not found" ), text );
else if( Pad == NULL ) else if( pad == NULL )
msg.Printf( _( "Pin %s (module %s) not found" ), PinName.GetData(), ModName.GetData() ); msg.Printf( _( "Pin %s (module %s) not found" ), pinName.GetData(), modName.GetData() );
else else
msg.Printf( _( "Locate Pin %s (module %s)" ), PinName.GetData(), ModName.GetData() ); msg.Printf( _( "Locate Pin %s (module %s)" ), pinName.GetData(), modName.GetData() );
frame->Affiche_Message( msg ); frame->Affiche_Message( msg );
} }
} }
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
#include "autorout.h" #include "autorout.h"
#include "id.h" #include "id.h"
#include "protos.h" #include "protos.h"
#include "eda_dde.h"
#define CURRENT_ITEM (GetScreen()->m_CurrentItem) #define CURRENT_ITEM (GetScreen()->m_CurrentItem)
...@@ -94,6 +95,8 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -94,6 +95,8 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
else else
{ {
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct );
} }
} }
...@@ -128,6 +131,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -128,6 +131,9 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = m_Pcb->FindPadOrModule( GetScreen()->RefPos(true), DrawStruct = m_Pcb->FindPadOrModule( GetScreen()->RefPos(true),
GetScreen()->m_Active_Layer ); GetScreen()->m_Active_Layer );
Show_1_Ratsnest( DrawStruct, DC ); Show_1_Ratsnest( DrawStruct, DC );
if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct );
break; break;
case ID_PCB_MIRE_BUTT: case ID_PCB_MIRE_BUTT:
...@@ -311,6 +317,27 @@ out: ...@@ -311,6 +317,27 @@ out:
} }
// see wxstruct.h
void WinEDA_PcbFrame::SendMessageToEESCHEMA( EDA_BaseStruct* objectToSync )
{
char cmd[1024];
MODULE* module = NULL;
if( objectToSync->m_StructType == TYPEMODULE )
module = (MODULE*) objectToSync;
else if( objectToSync->m_StructType == TYPEPAD )
module = (MODULE*)((D_PAD*)objectToSync)->m_Parent;
// ask only for the reference for now, maybe pins later.
if( module )
{
sprintf( cmd, "$PART: %s", CONV_TO_UTF8(module->m_Reference->m_Text) );
SendCommand( MSG_TO_SCH, cmd );
}
}
/*********************************************************************/ /*********************************************************************/
void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
/*********************************************************************/ /*********************************************************************/
......
...@@ -235,7 +235,9 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC* DC, boo ...@@ -235,7 +235,9 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC* DC, boo
g_SaveTime = time( NULL ); g_SaveTime = time( NULL );
#if defined(DEBUG) #if 0 && defined(DEBUG)
// note this seems to freeze up pcbnew when run under the kicad project
// manager. runs fine from command prompt.
// output the board object tree to stdout: // output the board object tree to stdout:
m_Pcb->Show( 0, std::cout ); m_Pcb->Show( 0, std::cout );
#endif #endif
......
...@@ -394,7 +394,7 @@ TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm); ...@@ -394,7 +394,7 @@ TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm);
/****************/ /****************/
/* CONTROLE.CPP */ /* CONTROLE.CPP */
/****************/ /****************/
void RemoteCommand(char * cmdline); void RemoteCommand( const char* cmdline );
/*************/ /*************/
/* STRUCT.CPP */ /* STRUCT.CPP */
......
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