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"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "eda_dde.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "eeschema_id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "general.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
|
|
|
#include "viewlib_frame.h"
|
2010-10-08 20:40:57 +00:00
|
|
|
#include "lib_draw_item.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet.h"
|
|
|
|
#include "sch_sheet_path.h"
|
|
|
|
#include "sch_marker.h"
|
|
|
|
#include "sch_component.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SchematicGeneralLocateAndDisplay
|
2009-11-03 13:26:31 +00:00
|
|
|
* Overlaid function
|
2009-01-31 10:05:16 +00:00
|
|
|
* Find the schematic item at cursor position
|
|
|
|
* the priority order is:
|
|
|
|
* - marker
|
2007-08-14 19:24:48 +00:00
|
|
|
* - noconnect
|
2009-01-31 10:05:16 +00:00
|
|
|
* - junction
|
2007-08-14 19:24:48 +00:00
|
|
|
* - wire/bus/entry
|
|
|
|
* - label
|
|
|
|
* - pin
|
2009-01-31 10:05:16 +00:00
|
|
|
* - component
|
2010-12-08 20:12:46 +00:00
|
|
|
* @return an EDA_ITEM pointer on the item or NULL if no item found
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param IncludePin = true to search for pins, false to ignore them
|
2009-01-31 10:05:16 +00:00
|
|
|
*
|
2009-11-03 13:26:31 +00:00
|
|
|
* For some items, characteristics are displayed on the screen.
|
2007-08-14 19:24:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_ITEM* DrawStruct;
|
|
|
|
wxString msg;
|
|
|
|
wxPoint mouse_position = GetScreen()->m_MousePosition;
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin = NULL;
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_COMPONENT* LibItem = NULL;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
|
|
|
DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin );
|
|
|
|
if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) )
|
|
|
|
{
|
2009-10-14 19:43:31 +00:00
|
|
|
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur,
|
|
|
|
IncludePin );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_FIELD_T:
|
|
|
|
case LIB_FIELD_T:
|
2008-11-24 06:53:43 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) DrawStruct->GetParent();
|
2009-01-31 10:05:16 +00:00
|
|
|
SendMessageToPCBNEW( DrawStruct, LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2010-12-13 15:59:00 +00:00
|
|
|
Pin = GetScreen()->GetPin( GetScreen()->m_Curseur, &LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
2009-11-03 13:26:31 +00:00
|
|
|
break; // Priority is probing a pin first
|
2008-03-20 01:50:21 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) DrawStruct;
|
2008-02-29 20:35:11 +00:00
|
|
|
SendMessageToPCBNEW( DrawStruct, LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-12-13 15:59:00 +00:00
|
|
|
Pin = GetScreen()->GetPin( GetScreen()->m_Curseur, &LibItem );
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_PIN_T:
|
2009-10-08 13:19:28 +00:00
|
|
|
Pin = (LIB_PIN*) DrawStruct;
|
2007-08-14 19:24:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Pin )
|
|
|
|
{
|
2009-10-14 19:43:31 +00:00
|
|
|
/* Force display pin information (the previous display could be a
|
|
|
|
* component info) */
|
2009-04-17 08:51:02 +00:00
|
|
|
Pin->DisplayInfo( this );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( LibItem )
|
2009-10-14 19:43:31 +00:00
|
|
|
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
|
|
|
|
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
// Cross probing:2 - pin found, and send a locate pin command to
|
2009-11-03 13:26:31 +00:00
|
|
|
// pcbnew (highlight 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SchematicGeneralLocateAndDisplay
|
2009-11-03 13:26:31 +00:00
|
|
|
* Overlaid function
|
2009-01-31 10:05:16 +00:00
|
|
|
* Find the schematic item at a given position
|
2007-08-14 19:24:48 +00:00
|
|
|
* the priority order is:
|
|
|
|
* - marker
|
|
|
|
* - noconnect
|
|
|
|
* - junction
|
|
|
|
* - wire/bus/entry
|
|
|
|
* - label
|
|
|
|
* - pin
|
|
|
|
* - component
|
2010-12-08 20:12:46 +00:00
|
|
|
* @return an EDA_ITEM pointer on the item or NULL if no item found
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param refpoint = the wxPoint location where to search
|
|
|
|
* @param IncludePin = true to search for pins, false to ignore them
|
2007-10-01 15:37:42 +00:00
|
|
|
*
|
2009-11-03 13:26:31 +00:00
|
|
|
* For some items, characteristics are displayed on the screen.
|
2007-08-14 19:24:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpoint,
|
|
|
|
bool IncludePin )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_ITEM* DrawStruct;
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Pin;
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_COMPONENT* LibItem;
|
2009-01-31 10:05:16 +00:00
|
|
|
wxString Text;
|
|
|
|
wxString msg;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2009-07-10 12:29:31 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2009-07-10 12:29:31 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
2010-04-06 14:09:52 +00:00
|
|
|
DrawStruct->DisplayInfo( this );
|
2009-07-10 12:29:31 +00:00
|
|
|
return DrawStruct;
|
|
|
|
}
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2007-08-14 19:24:48 +00:00
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), JUNCTIONITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2007-08-14 19:24:48 +00:00
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(),
|
|
|
|
WIREITEM | BUSITEM | RACCORDITEM );
|
|
|
|
|
|
|
|
if( DrawStruct ) // We have found a wire: Search for a connected pin at the same location
|
2007-08-14 19:24:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
|
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
|
|
|
{
|
2009-04-17 08:51:02 +00:00
|
|
|
Pin->DisplayInfo( this );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( LibItem )
|
2009-10-14 19:43:31 +00:00
|
|
|
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
|
|
|
|
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), FIELDCMPITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD* Field = (SCH_FIELD*) DrawStruct;
|
2008-11-24 06:53:43 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) Field->GetParent();
|
2009-04-17 08:51:02 +00:00
|
|
|
LibItem->DisplayInfo( this );
|
2007-08-14 19:24:48 +00:00
|
|
|
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2010-08-29 18:15:19 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), LABELITEM | TEXTITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2010-07-21 01:37:34 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
ClearMsgPanel();
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
/* search for a pin */
|
2010-12-10 19:47:44 +00:00
|
|
|
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
|
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( Pin )
|
|
|
|
{
|
2009-04-17 08:51:02 +00:00
|
|
|
Pin->DisplayInfo( this );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( LibItem )
|
2009-10-14 19:43:31 +00:00
|
|
|
AppendMsgPanel( LibItem->GetRef( GetSheet() ),
|
|
|
|
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
|
2009-04-14 16:45:22 +00:00
|
|
|
if( IncludePin )
|
2007-08-14 19:24:48 +00:00
|
|
|
return LibItem;
|
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), LIBITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
DrawStruct = LocateSmallestComponent( GetScreen() );
|
2008-03-20 01:50:21 +00:00
|
|
|
LibItem = (SCH_COMPONENT*) DrawStruct;
|
2009-04-17 08:51:02 +00:00
|
|
|
LibItem->DisplayInfo( this );
|
2007-08-14 19:24:48 +00:00
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2009-01-31 10:05:16 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SHEETITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
( (SCH_SHEET*) DrawStruct )->DisplayInfo( this );
|
2007-08-14 19:24:48 +00:00
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2009-01-31 10:05:16 +00:00
|
|
|
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SEARCHALL );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2007-08-14 19:24:48 +00:00
|
|
|
if( DrawStruct )
|
|
|
|
{
|
|
|
|
return DrawStruct;
|
|
|
|
}
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
ClearMsgPanel();
|
2007-08-14 19:24:48 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxRealPoint delta;
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
wxPoint curpos, oldpos;
|
|
|
|
int hotkey = 0;
|
2010-02-22 16:45:35 +00:00
|
|
|
double scalar = screen->GetScalingFactor();
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
ActiveScreen = screen;
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
curpos = screen->m_MousePosition;
|
|
|
|
oldpos = screen->m_Curseur;
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
delta = screen->GetGridSize();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2010-02-22 16:45:35 +00:00
|
|
|
delta.x *= scalar;
|
|
|
|
delta.y *= scalar;
|
2008-04-21 06:34:56 +00:00
|
|
|
|
|
|
|
if( delta.x <= 0 )
|
|
|
|
delta.x = 1;
|
|
|
|
if( delta.y <= 0 )
|
|
|
|
delta.y = 1;
|
|
|
|
|
|
|
|
switch( g_KeyPressed )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD8:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_UP:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.y -= wxRound( delta.y );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD2:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_DOWN:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.y += wxRound( delta.y );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD4:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_LEFT:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.x -= wxRound( delta.x );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD6:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_RIGHT:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.x += wxRound( delta.x );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Update cursor position. */
|
2008-04-21 06:34:56 +00:00
|
|
|
screen->m_Curseur = curpos;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Snap cursor to grid. */
|
2008-04-21 06:34:56 +00:00
|
|
|
PutOnGrid( &(screen->m_Curseur) );
|
|
|
|
|
|
|
|
if( screen->IsRefreshReq() )
|
|
|
|
{
|
2010-01-13 13:43:36 +00:00
|
|
|
DrawPanel->Refresh( );
|
|
|
|
wxSafeYield();
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( oldpos != screen->m_Curseur )
|
|
|
|
{
|
|
|
|
curpos = screen->m_Curseur;
|
|
|
|
screen->m_Curseur = oldpos;
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
screen->m_Curseur = curpos;
|
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
|
2008-04-21 06:34:56 +00:00
|
|
|
OnHotKey( DC, hotkey, screen->GetCurItem() );
|
|
|
|
else
|
|
|
|
OnHotKey( DC, hotkey, NULL );
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
UpdateStatusBar(); /* Display cursor coordinates info */
|
2008-05-16 11:38:35 +00:00
|
|
|
SetToolbars();
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
wxRealPoint delta;
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
wxPoint curpos, oldpos;
|
|
|
|
int hotkey = 0;
|
2010-02-22 16:45:35 +00:00
|
|
|
double scalar = screen->GetScalingFactor();
|
2008-04-21 06:34:56 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
ActiveScreen = screen;
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
curpos = screen->m_MousePosition;
|
|
|
|
oldpos = screen->m_Curseur;
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
delta = screen->GetGridSize();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2010-02-22 16:45:35 +00:00
|
|
|
delta.x *= scalar;
|
|
|
|
delta.y *= scalar;
|
2008-04-21 06:34:56 +00:00
|
|
|
|
|
|
|
if( delta.x <= 0 )
|
|
|
|
delta.x = 1;
|
|
|
|
if( delta.y <= 0 )
|
|
|
|
delta.y = 1;
|
|
|
|
|
|
|
|
switch( g_KeyPressed )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD8:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_UP:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.y -= wxRound( delta.y );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD2:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_DOWN:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.y += wxRound( delta.y );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD4:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_LEFT:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.x -= wxRound( delta.x );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD6:
|
2008-04-21 06:34:56 +00:00
|
|
|
case WXK_RIGHT:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.x += wxRound( delta.x );
|
2008-04-21 06:34:56 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Update the cursor position. */
|
2008-04-21 06:34:56 +00:00
|
|
|
screen->m_Curseur = curpos;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Snap cursor to grid. */
|
2008-04-21 06:34:56 +00:00
|
|
|
PutOnGrid( &(screen->m_Curseur) );
|
|
|
|
|
|
|
|
if( screen->IsRefreshReq() )
|
|
|
|
{
|
2010-01-13 13:43:36 +00:00
|
|
|
DrawPanel->Refresh( );
|
|
|
|
wxSafeYield();
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( oldpos != screen->m_Curseur )
|
|
|
|
{
|
|
|
|
curpos = screen->m_Curseur;
|
|
|
|
screen->m_Curseur = oldpos;
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
screen->m_Curseur = curpos;
|
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
|
2008-04-21 06:34:56 +00:00
|
|
|
OnHotKey( DC, hotkey, screen->GetCurItem() );
|
|
|
|
else
|
|
|
|
OnHotKey( DC, hotkey, NULL );
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
UpdateStatusBar();
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2009-01-31 10:05:16 +00:00
|
|
|
|
2010-11-20 21:59:00 +00:00
|
|
|
void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
wxRealPoint delta;
|
2009-01-31 10:05:16 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
wxPoint curpos, oldpos;
|
|
|
|
int hotkey = 0;
|
2010-02-22 16:45:35 +00:00
|
|
|
double scalar = screen->GetScalingFactor();
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
ActiveScreen = screen;
|
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
curpos = screen->m_MousePosition;
|
|
|
|
oldpos = screen->m_Curseur;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
delta = screen->GetGridSize();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2010-02-22 16:45:35 +00:00
|
|
|
delta.x *= scalar;
|
|
|
|
delta.y *= scalar;
|
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;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD8:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_UP:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.y -= wxRound( delta.y );
|
2007-08-14 19:24:48 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD2:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_DOWN:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.y += wxRound( delta.y );
|
2007-08-14 19:24:48 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD4:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_LEFT:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.x -= wxRound( delta.x );
|
2007-08-14 19:24:48 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case WXK_NUMPAD6:
|
2007-08-14 19:24:48 +00:00
|
|
|
case WXK_RIGHT:
|
2009-11-03 13:26:31 +00:00
|
|
|
MousePositionInPixels.x += wxRound( delta.x );
|
2007-08-14 19:24:48 +00:00
|
|
|
DrawPanel->MouseTo( MousePositionInPixels );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hotkey = g_KeyPressed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Update cursor position. */
|
2008-02-29 20:35:11 +00:00
|
|
|
screen->m_Curseur = curpos;
|
2007-08-14 19:24:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Snap cursor to grid. */
|
2009-12-02 21:44:03 +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
|
|
|
{
|
2010-01-13 13:43:36 +00:00
|
|
|
DrawPanel->Refresh( );
|
|
|
|
wxSafeYield();
|
2007-08-14 19:24:48 +00:00
|
|
|
}
|
|
|
|
|
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-04-17 16:25:29 +00:00
|
|
|
screen->m_Curseur = curpos;
|
2007-08-14 19:24:48 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hotkey )
|
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
|
2008-02-29 20:35:11 +00:00
|
|
|
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
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
UpdateStatusBar();
|
2008-05-16 11:38:35 +00:00
|
|
|
SetToolbars();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|