2007-08-14 19:24:48 +00:00
|
|
|
/****************/
|
|
|
|
/* controle.cpp */
|
|
|
|
/****************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "eda_dde.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
#include "schframe.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2007-08-14 19:24:48 +00:00
|
|
|
EDA_BaseStruct* WinEDA_SchematicFrame::
|
|
|
|
SchematicGeneralLocateAndDisplay( bool IncludePin )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
|
|
|
|
|
|
|
/* Routine de localisation et d'affichage des caract (si utile )
|
2007-08-14 19:24:48 +00:00
|
|
|
* de l'element pointe par la souris ou par le curseur pcb
|
|
|
|
* - marqueur
|
|
|
|
* - noconnect
|
|
|
|
* - jonction
|
|
|
|
* - wire/bus/entry
|
|
|
|
* - label
|
|
|
|
* - composant
|
|
|
|
* - pin
|
|
|
|
* retourne
|
|
|
|
* un pointeur sur le composant
|
|
|
|
* Null sinon
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-14 19:24:48 +00:00
|
|
|
EDA_BaseStruct* DrawStruct;
|
|
|
|
wxString msg;
|
|
|
|
wxPoint mouse_position = GetScreen()->m_MousePosition;
|
|
|
|
LibDrawPin* Pin = NULL;
|
|
|
|
EDA_SchComponentStruct* LibItem = NULL;
|
|
|
|
|
|
|
|
DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin );
|
|
|
|
if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) )
|
|
|
|
{
|
|
|
|
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur, IncludePin );
|
|
|
|
}
|
|
|
|
if( !DrawStruct )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Cross probing to pcbnew if a pin or a component is found */
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawStruct->Type() )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2008-02-29 20:35:11 +00:00
|
|
|
case DRAW_PART_TEXT_STRUCT_TYPE:
|
2007-08-14 19:24:48 +00:00
|
|
|
case COMPONENT_FIELD_DRAW_TYPE:
|
2007-10-09 14:28:22 +00:00
|
|
|
LibItem = (EDA_SchComponentStruct*) DrawStruct->m_Parent;
|
2008-02-29 20:35:11 +00:00
|
|
|
SendMessageToPCBNEW( DrawStruct,LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_LIB_ITEM_STRUCT_TYPE:
|
2008-02-29 20:35:11 +00:00
|
|
|
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
2007-10-01 15:37:42 +00:00
|
|
|
break; // Priority is probing a pin first
|
2007-10-09 14:28:22 +00:00
|
|
|
LibItem = (EDA_SchComponentStruct*) DrawStruct;
|
2008-02-29 20:35:11 +00:00
|
|
|
SendMessageToPCBNEW( DrawStruct, LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-02-29 20:35:11 +00:00
|
|
|
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_PIN_DRAW_TYPE:
|
|
|
|
Pin = (LibDrawPin*) DrawStruct;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Pin )
|
|
|
|
{
|
|
|
|
/* Force display pin infos (the previous display could be a component info) */
|
|
|
|
Pin->Display_Infos( this );
|
|
|
|
if( LibItem )
|
|
|
|
Affiche_1_Parametre( this, 1,
|
2008-02-12 21:12:46 +00:00
|
|
|
LibItem->GetRef(GetSheet()),
|
2007-08-14 19:24:48 +00:00
|
|
|
LibItem->m_Field[VALUE].m_Text,
|
|
|
|
CYAN );
|
|
|
|
|
|
|
|
// Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net)
|
2008-02-29 20:35:11 +00:00
|
|
|
SendMessageToPCBNEW( Pin, LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
return DrawStruct;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************************/
|
2007-08-14 19:24:48 +00:00
|
|
|
EDA_BaseStruct* WinEDA_SchematicFrame::
|
|
|
|
SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************************************/
|
|
|
|
|
|
|
|
/* Find the schematic item at position "refpoint"
|
2007-08-14 19:24:48 +00:00
|
|
|
* the priority order is:
|
|
|
|
* - marker
|
|
|
|
* - noconnect
|
|
|
|
* - junction
|
|
|
|
* - wire/bus/entry
|
|
|
|
* - label
|
|
|
|
* - pin
|
|
|
|
* - component
|
|
|
|
* return:
|
|
|
|
* an EDA_BaseStruct pointer on the item
|
|
|
|
* a Null pointer if no item found
|
2007-10-01 15:37:42 +00:00
|
|
|
*
|
2007-08-14 19:24:48 +00:00
|
|
|
* For some items, caracteristics are displayed on the screen.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-14 19:24:48 +00:00
|
|
|
EDA_BaseStruct* DrawStruct;
|
|
|
|
LibDrawPin* Pin;
|
|
|
|
EDA_SchComponentStruct* LibItem;
|
2007-10-01 15:37:42 +00:00
|
|
|
wxString Text;
|
|
|
|
wxString msg;
|
|
|
|
int ii;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(), MARKERITEM );
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
DrawMarkerStruct* Marker = (DrawMarkerStruct*) DrawStruct;
|
|
|
|
ii = Marker->m_Type;
|
|
|
|
Text = Marker->GetComment();
|
|
|
|
if( Text.IsEmpty() )
|
|
|
|
Text = wxT( "NoComment" );
|
|
|
|
msg = NameMarqueurType[ii]; msg << wxT( " << " ) << Text;
|
|
|
|
Affiche_Message( msg );
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(),
|
2007-08-14 19:24:48 +00:00
|
|
|
NOCONNECTITEM );
|
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
MsgPanel->EraseMsgBox();
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(),
|
2007-08-14 19:24:48 +00:00
|
|
|
JUNCTIONITEM );
|
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
MsgPanel->EraseMsgBox();
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(),
|
2007-08-14 19:24:48 +00:00
|
|
|
WIREITEM | BUSITEM | RACCORDITEM );
|
|
|
|
if( DrawStruct ) // Search for a pin
|
|
|
|
{
|
2008-02-29 20:35:11 +00:00
|
|
|
Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
|
|
|
{
|
|
|
|
Pin->Display_Infos( this );
|
|
|
|
if( LibItem )
|
|
|
|
Affiche_1_Parametre( this, 1,
|
2008-02-12 21:12:46 +00:00
|
|
|
LibItem->GetRef(GetSheet()),
|
2007-08-14 19:24:48 +00:00
|
|
|
LibItem->m_Field[VALUE].m_Text,
|
|
|
|
CYAN );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MsgPanel->EraseMsgBox();
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(), FIELDCMPITEM );
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
PartTextStruct* Field = (PartTextStruct*) DrawStruct;
|
|
|
|
LibItem = (EDA_SchComponentStruct*) Field->m_Parent;
|
|
|
|
LibItem->Display_Infos( this );
|
|
|
|
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search for a pin */
|
2008-02-29 20:35:11 +00:00
|
|
|
Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
|
|
|
{
|
|
|
|
Pin->Display_Infos( this );
|
|
|
|
if( LibItem )
|
|
|
|
Affiche_1_Parametre( this, 1,
|
2008-02-12 21:12:46 +00:00
|
|
|
LibItem->GetRef(GetSheet()),
|
2007-08-14 19:24:48 +00:00
|
|
|
LibItem->m_Field[VALUE].m_Text,
|
|
|
|
CYAN );
|
|
|
|
if( IncludePin == TRUE )
|
|
|
|
return LibItem;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(), LIBITEM );
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
|
2007-08-14 19:24:48 +00:00
|
|
|
LibItem = (EDA_SchComponentStruct*) DrawStruct;
|
|
|
|
LibItem->Display_Infos( this );
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(),
|
2007-08-14 19:24:48 +00:00
|
|
|
SHEETITEM );
|
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
( (DrawSheetStruct*) DrawStruct )->Display_Infos( this );
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recherche des autres elements
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = PickStruct( refpoint, GetScreen(),
|
2007-08-14 19:24:48 +00:00
|
|
|
SEARCHALL );
|
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgPanel->EraseMsgBox();
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2007-08-14 19:24:48 +00:00
|
|
|
void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
{
|
2007-08-14 19:24:48 +00:00
|
|
|
wxSize delta;
|
2008-02-29 20:35:11 +00:00
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*)GetScreen();
|
|
|
|
int zoom = screen->GetZoom();
|
2007-08-14 19:24:48 +00:00
|
|
|
wxPoint curpos, oldpos;
|
|
|
|
int hotkey = 0;
|
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_MousePosition;
|
|
|
|
oldpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
delta.x = screen->GetGrid().x / zoom;
|
|
|
|
delta.y = screen->GetGrid().y / zoom;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
|
|
|
if( delta.x <= 0 )
|
|
|
|
delta.x = 1;
|
|
|
|
if( delta.y <= 0 )
|
|
|
|
delta.y = 1;
|
|
|
|
|
|
|
|
switch( g_KeyPressed )
|
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
case EDA_PANNING_UP_KEY:
|
|
|
|
OnZoom( ID_ZOOM_PANNING_UP );
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EDA_PANNING_DOWN_KEY:
|
|
|
|
OnZoom( ID_ZOOM_PANNING_DOWN );
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EDA_PANNING_LEFT_KEY:
|
|
|
|
OnZoom( ID_ZOOM_PANNING_LEFT );
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EDA_PANNING_RIGHT_KEY:
|
|
|
|
OnZoom( ID_ZOOM_PANNING_RIGHT );
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
case EDA_ZOOM_IN_FROM_MOUSE:
|
2008-02-17 21:19:13 +00:00
|
|
|
OnZoom( ID_ZOOM_IN_KEY );
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
case EDA_ZOOM_OUT_FROM_MOUSE:
|
2008-02-17 21:19:13 +00:00
|
|
|
OnZoom( ID_ZOOM_OUT_KEY );
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
case EDA_ZOOM_CENTER_FROM_MOUSE:
|
2007-08-14 19:24:48 +00:00
|
|
|
OnZoom( ID_ZOOM_CENTER_KEY );
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
|
|
|
|
case WXK_UP:
|
|
|
|
MousePositionInPixels.y -= delta.y;
|
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
|
|
|
|
case WXK_DOWN:
|
2008-02-29 20:35:11 +00:00
|
|
|
D(printf("DOWN\n");)
|
2007-08-14 19:24:48 +00:00
|
|
|
MousePositionInPixels.y += delta.y;
|
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
|
|
|
|
case WXK_LEFT:
|
|
|
|
MousePositionInPixels.x -= delta.x;
|
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
|
|
|
|
case WXK_RIGHT:
|
|
|
|
MousePositionInPixels.x += delta.x;
|
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Recalcul de la position du curseur schema */
|
2008-02-29 20:35:11 +00:00
|
|
|
screen->m_Curseur = curpos;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
|
|
|
/* Placement sur la grille generale */
|
2008-02-29 20:35:11 +00:00
|
|
|
PutOnGrid( &(screen->m_Curseur) );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
if( screen->IsRefreshReq() )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
|
|
|
RedrawActiveWindow( DC, TRUE );
|
|
|
|
}
|
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
if( oldpos != screen->m_Curseur )
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_Curseur;
|
2008-02-12 21:12:46 +00:00
|
|
|
screen->m_Curseur = oldpos;
|
2007-08-14 19:24:48 +00:00
|
|
|
DrawPanel->CursorOff( DC );
|
2008-02-29 20:35:11 +00:00
|
|
|
GetScreen()->m_Curseur = curpos;
|
2007-08-14 19:24:48 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
{
|
2008-02-29 20:35:11 +00:00
|
|
|
if( screen->GetCurItem()
|
|
|
|
&& screen->GetCurItem()->m_Flags )
|
|
|
|
OnHotKey( DC, hotkey, screen->GetCurItem() );
|
2007-08-14 19:24:48 +00:00
|
|
|
else
|
|
|
|
OnHotKey( DC, hotkey, NULL );
|
|
|
|
}
|
2007-08-21 19:37:31 +00:00
|
|
|
|
|
|
|
Affiche_Status_Box(); /* Affichage des coord curseur */
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|