2007-08-04 01:12:30 +00:00
|
|
|
/********************************************************/
|
|
|
|
/* Routines generales de gestion des commandes usuelles */
|
|
|
|
/********************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* controle.cpp */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2007-09-25 08:23:53 +00:00
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2009-10-10 17:27:53 +00:00
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
#include "collectors.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
//external funtions used here:
|
2011-03-01 19:26:17 +00:00
|
|
|
extern bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame,
|
2009-10-10 17:27:53 +00:00
|
|
|
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2007-09-14 16:15:27 +00:00
|
|
|
/**
|
|
|
|
* Function AllAreModulesAndReturnSmallestIfSo
|
|
|
|
* tests that all items in the collection are MODULEs and if so, returns the
|
|
|
|
* smallest MODULE.
|
|
|
|
* @return BOARD_ITEM* - The smallest or NULL.
|
2007-09-25 08:23:53 +00:00
|
|
|
*/
|
2011-02-01 15:46:25 +00:00
|
|
|
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector )
|
2007-09-14 16:15:27 +00:00
|
|
|
{
|
|
|
|
int count = aCollector->GetCount();
|
2007-09-25 08:23:53 +00:00
|
|
|
|
|
|
|
for( int i = 0; i<count; ++i )
|
2007-09-14 16:15:27 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( (*aCollector)[i]->Type() != TYPE_MODULE )
|
2007-09-14 16:15:27 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-09-14 16:15:27 +00:00
|
|
|
// all are modules, now find smallest MODULE
|
|
|
|
|
|
|
|
int minDim = 0x7FFFFFFF;
|
|
|
|
int minNdx = 0;
|
2007-09-25 08:23:53 +00:00
|
|
|
|
|
|
|
for( int i = 0; i<count; ++i )
|
2007-09-14 16:15:27 +00:00
|
|
|
{
|
|
|
|
MODULE* module = (MODULE*) (*aCollector)[i];
|
2007-09-25 08:23:53 +00:00
|
|
|
|
|
|
|
int lx = module->m_BoundaryBox.GetWidth();
|
|
|
|
int ly = module->m_BoundaryBox.GetHeight();
|
|
|
|
|
|
|
|
int lmin = MIN( lx, ly );
|
|
|
|
|
2007-09-14 16:15:27 +00:00
|
|
|
if( lmin <= minDim )
|
|
|
|
{
|
|
|
|
minDim = lmin;
|
|
|
|
minNdx = i;
|
|
|
|
}
|
|
|
|
}
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-09-14 16:15:27 +00:00
|
|
|
return (*aCollector)[minNdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-25 08:23:53 +00:00
|
|
|
BOARD_ITEM* item;
|
|
|
|
|
|
|
|
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();
|
2007-08-24 03:40:04 +00:00
|
|
|
|
2007-09-26 20:10:12 +00:00
|
|
|
// Assign to scanList the proper item types desired based on tool type
|
|
|
|
// or hotkey that is in play.
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
const KICAD_T* scanList = NULL;
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-09-25 15:10:01 +00:00
|
|
|
if( aHotKeyCode )
|
|
|
|
{
|
2007-09-26 20:10:12 +00:00
|
|
|
// @todo: add switch here and add calls to PcbGeneralLocateAndDisplay( int aHotKeyCode )
|
|
|
|
// when searching is needed from a hotkey handler
|
2007-09-25 15:10:01 +00:00
|
|
|
}
|
2011-02-24 20:22:12 +00:00
|
|
|
else if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
|
|
|
switch( m_HTOOL_current_state )
|
|
|
|
{
|
2010-08-17 10:41:44 +00:00
|
|
|
case ID_TOOLBARH_PCB_MODE_MODULE:
|
2007-09-12 02:14:07 +00:00
|
|
|
scanList = GENERAL_COLLECTOR::ModuleItems;
|
|
|
|
break;
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
default:
|
2008-12-12 21:30:07 +00:00
|
|
|
scanList = DisplayOpt.DisplayZonesMode == 0 ?
|
2007-10-01 15:37:42 +00:00
|
|
|
GENERAL_COLLECTOR::AllBoardItems :
|
|
|
|
GENERAL_COLLECTOR::AllButZones;
|
2007-09-12 02:14:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
|
|
|
case ID_PCB_SHOW_1_RATSNEST_BUTT:
|
|
|
|
scanList = GENERAL_COLLECTOR::PadsOrModules;
|
2007-09-25 08:23:53 +00:00
|
|
|
break;
|
2007-09-12 02:14:07 +00:00
|
|
|
|
|
|
|
case ID_TRACK_BUTT:
|
|
|
|
scanList = GENERAL_COLLECTOR::Tracks;
|
2007-09-25 08:23:53 +00:00
|
|
|
break;
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_PCB_MODULE_BUTT:
|
2007-09-12 02:14:07 +00:00
|
|
|
scanList = GENERAL_COLLECTOR::ModuleItems;
|
|
|
|
break;
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
default:
|
2008-12-12 21:30:07 +00:00
|
|
|
scanList = DisplayOpt.DisplayZonesMode == 0 ?
|
2007-10-01 15:37:42 +00:00
|
|
|
GENERAL_COLLECTOR::AllBoardItems :
|
|
|
|
GENERAL_COLLECTOR::AllButZones;
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-25 08:23:53 +00:00
|
|
|
m_Collector->Collect( m_Pcb, scanList, GetScreen()->RefPos( true ), guide );
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
#if 0
|
2007-09-25 15:10:01 +00:00
|
|
|
// debugging: print out the collected items, showing their priority order too.
|
2007-10-01 15:37:42 +00:00
|
|
|
for( int i = 0; i<m_Collector->GetCount(); ++i )
|
2007-09-25 15:10:01 +00:00
|
|
|
(*m_Collector)[i]->Show( 0, std::cout );
|
2007-10-01 15:37:42 +00:00
|
|
|
#endif
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2009-01-31 21:42:05 +00:00
|
|
|
/* Remove redundancies: sometime, zones are found twice,
|
2009-11-23 14:40:29 +00:00
|
|
|
* because zones can be filled by overlapping segments (this is a fill option)
|
2007-09-25 08:23:53 +00:00
|
|
|
*/
|
|
|
|
unsigned long timestampzone = 0;
|
2007-10-01 15:37:42 +00:00
|
|
|
|
2007-09-26 20:10:12 +00:00
|
|
|
for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
|
2007-09-25 08:23:53 +00:00
|
|
|
{
|
|
|
|
item = (*m_Collector)[ii];
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( item->Type() != TYPE_ZONE )
|
2007-09-25 08:23:53 +00:00
|
|
|
continue;
|
2007-10-01 15:37:42 +00:00
|
|
|
|
2007-09-25 08:23:53 +00:00
|
|
|
/* Found a TYPE ZONE */
|
|
|
|
if( item->m_TimeStamp == timestampzone ) // Remove it, redundant, zone already found
|
|
|
|
{
|
|
|
|
m_Collector->Remove( ii );
|
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
timestampzone = item->m_TimeStamp;
|
|
|
|
}
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2007-09-25 08:23:53 +00:00
|
|
|
if( m_Collector->GetCount() <= 1 )
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
|
|
|
item = (*m_Collector)[0];
|
2007-09-25 08:23:53 +00:00
|
|
|
SetCurItem( item );
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
2011-02-01 15:46:25 +00:00
|
|
|
|
|
|
|
// If the count is 2, and first item is a pad or moduletext, and the 2nd item is its
|
|
|
|
// parent module:
|
2007-09-25 08:23:53 +00:00
|
|
|
else if( m_Collector->GetCount() == 2
|
2008-12-04 04:28:11 +00:00
|
|
|
&& ( (*m_Collector)[0]->Type() == TYPE_PAD || (*m_Collector)[0]->Type() ==
|
|
|
|
TYPE_TEXTE_MODULE )
|
|
|
|
&& (*m_Collector)[1]->Type() == TYPE_MODULE && (*m_Collector)[0]->GetParent()==
|
2007-10-01 15:37:42 +00:00
|
|
|
(*m_Collector)[1] )
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
|
|
|
item = (*m_Collector)[0];
|
2007-09-25 08:23:53 +00:00
|
|
|
SetCurItem( item );
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
2007-09-14 16:15:27 +00:00
|
|
|
// if all are modules, find the smallest one amoung the primary choices
|
2007-09-25 08:23:53 +00:00
|
|
|
else if( ( item = AllAreModulesAndReturnSmallestIfSo( m_Collector ) ) != NULL )
|
2007-09-14 16:15:27 +00:00
|
|
|
{
|
2007-09-25 08:23:53 +00:00
|
|
|
SetCurItem( item );
|
2007-09-14 16:15:27 +00:00
|
|
|
}
|
2009-01-31 21:42:05 +00:00
|
|
|
|
2007-09-26 20:10:12 +00:00
|
|
|
else // we can't figure out which item user wants, do popup menu so user can choose
|
2007-08-24 03:40:04 +00:00
|
|
|
{
|
2007-09-25 08:23:53 +00:00
|
|
|
wxMenu itemMenu;
|
|
|
|
|
2007-10-10 04:45:26 +00:00
|
|
|
/* Give a title to the selection menu. This is also a cancel menu item */
|
|
|
|
wxMenuItem * item_title = new wxMenuItem(&itemMenu, -1, _( "Selection Clarification" ) );
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
#ifdef __WINDOWS__
|
2007-10-10 04:45:26 +00:00
|
|
|
wxFont bold_font(*wxNORMAL_FONT);
|
|
|
|
bold_font.SetWeight(wxFONTWEIGHT_BOLD);
|
|
|
|
bold_font.SetStyle( wxFONTSTYLE_ITALIC);
|
|
|
|
item_title->SetFont(bold_font);
|
2007-10-07 18:24:15 +00:00
|
|
|
#endif
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2007-10-10 04:45:26 +00:00
|
|
|
itemMenu.Append(item_title);
|
|
|
|
itemMenu.AppendSeparator();
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
|
|
|
|
|
2007-09-25 08:23:53 +00:00
|
|
|
for( int i = 0; i<limit; ++i )
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
2007-09-25 08:23:53 +00:00
|
|
|
wxString text;
|
|
|
|
const char** xpm;
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
item = (*m_Collector)[i];
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
text = item->MenuText( m_Pcb );
|
2007-09-12 02:14:07 +00:00
|
|
|
xpm = item->MenuIcon();
|
2007-09-25 08:23:53 +00:00
|
|
|
|
|
|
|
ADD_MENUITEM( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START + i, text, xpm );
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
/* @todo: rather than assignment to true, these should be increment and decrement
|
2011-02-01 15:46:25 +00:00
|
|
|
* operators throughout _everywhere_.
|
2007-10-01 15:37:42 +00:00
|
|
|
* That way we can handle nesting.
|
2011-02-03 19:27:28 +00:00
|
|
|
* But I tried that and found there cases where the assignment to true (converted to
|
2011-02-01 15:46:25 +00:00
|
|
|
* a m_IgnoreMouseEvents++ )
|
2011-02-03 19:27:28 +00:00
|
|
|
* was not balanced with the -- (now m_IgnoreMouseEvents=false), so I had to revert.
|
2007-10-01 15:37:42 +00:00
|
|
|
* Somebody should track down these and make them balanced.
|
2011-02-03 19:27:28 +00:00
|
|
|
* DrawPanel->m_IgnoreMouseEvents = true;
|
2007-10-01 15:37:42 +00:00
|
|
|
*/
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
// this menu's handler is void PCB_BASE_FRAME::ProcessItemSelection()
|
2009-04-17 08:51:02 +00:00
|
|
|
// and it calls SetCurItem() which in turn calls DisplayInfo() on the item.
|
2011-03-10 17:52:36 +00:00
|
|
|
DrawPanel->m_AbortRequest = true; // changed in false if an item is selected
|
|
|
|
PopupMenu( &itemMenu );
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
// The function ProcessItemSelection() has set the current item, return it.
|
2011-03-10 17:52:36 +00:00
|
|
|
if( DrawPanel->m_AbortRequest ) // Nothing selected
|
|
|
|
item = NULL;
|
|
|
|
else
|
|
|
|
item = GetCurItem();
|
2007-08-24 03:40:04 +00:00
|
|
|
}
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
return item;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-01 15:46:25 +00:00
|
|
|
wxRealPoint gridSize;
|
|
|
|
wxPoint oldpos;
|
2011-02-11 20:48:13 +00:00
|
|
|
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition );
|
2007-08-04 01:12:30 +00:00
|
|
|
|
|
|
|
// Save the board after the time out :
|
|
|
|
int CurrentTime = time( NULL );
|
2008-02-26 21:12:08 +00:00
|
|
|
|
2007-08-04 01:12:30 +00:00
|
|
|
if( !GetScreen()->IsModify() || GetScreen()->IsSave() )
|
2007-09-25 08:23:53 +00:00
|
|
|
{
|
2007-08-04 04:40:07 +00:00
|
|
|
/* If no change, reset the time out */
|
2007-08-04 01:12:30 +00:00
|
|
|
g_SaveTime = CurrentTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (CurrentTime - g_SaveTime) > g_TimeOut )
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
wxString tmpFileName = GetScreen()->GetFileName();
|
2010-05-17 20:35:46 +00:00
|
|
|
wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension );
|
2011-02-01 15:46:25 +00:00
|
|
|
bool flgmodify = GetScreen()->IsModify();
|
2007-08-04 04:40:07 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
SavePcbFile( fn.GetFullPath() );
|
2007-08-04 04:40:07 +00:00
|
|
|
|
2007-08-04 01:12:30 +00:00
|
|
|
if( flgmodify ) // Set the flags m_Modify cleared by SavePcbFile()
|
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-04 01:12:30 +00:00
|
|
|
GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify()
|
|
|
|
}
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
GetScreen()->SetFileName( tmpFileName );
|
|
|
|
SetTitle( GetScreen()->GetFileName() );
|
2007-08-04 01:12:30 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
oldpos = GetScreen()->GetCrossHairPosition();
|
2007-08-04 01:12:30 +00:00
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
gridSize = GetScreen()->GetGridSize();
|
2007-08-04 01:12:30 +00:00
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
switch( aHotKey )
|
2007-08-04 01:12:30 +00:00
|
|
|
{
|
|
|
|
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
|
|
|
|
case WXK_UP:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y -= wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-04 01:12:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
|
|
|
|
case WXK_DOWN:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.y += wxRound( gridSize.y );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-04 01:12:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
|
|
|
|
case WXK_LEFT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x -= wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-04 01:12:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
|
|
|
|
case WXK_RIGHT:
|
2011-02-01 15:46:25 +00:00
|
|
|
pos.x += wxRound( gridSize.x );
|
|
|
|
DrawPanel->MoveCursor( pos );
|
2007-08-04 01:12:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
// Put cursor in new position, according to the zoom keys (if any).
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos );
|
2007-08-04 01:12:30 +00:00
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
/* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the
|
|
|
|
* cursor is left off grid this is better to reach items to delete off grid,
|
2007-08-04 01:12:30 +00:00
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
bool keep_on_grid = true;
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT )
|
2011-02-03 19:27:28 +00:00
|
|
|
keep_on_grid = false;
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2007-08-04 01:12:30 +00:00
|
|
|
/* Cursor is left off grid if no block in progress and no moving object */
|
2009-07-25 04:53:39 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.m_State != STATE_NO_BLOCK )
|
2011-02-03 19:27:28 +00:00
|
|
|
keep_on_grid = true;
|
2007-09-25 08:23:53 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
|
|
|
|
|
2007-08-04 01:12:30 +00:00
|
|
|
if( DrawStruct && DrawStruct->m_Flags )
|
2011-02-03 19:27:28 +00:00
|
|
|
keep_on_grid = true;
|
2007-08-04 01:12:30 +00:00
|
|
|
|
2008-02-27 15:26:16 +00:00
|
|
|
if( keep_on_grid )
|
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
wxPoint on_grid = GetScreen()->GetNearestGridPosition( pos );
|
2007-08-04 01:12:30 +00:00
|
|
|
|
2009-02-07 08:33:25 +00:00
|
|
|
wxSize grid;
|
2009-10-14 19:43:31 +00:00
|
|
|
grid.x = (int) GetScreen()->GetGridSize().x;
|
|
|
|
grid.y = (int) GetScreen()->GetGridSize().y;
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( Magnetize( m_Pcb, this, GetToolId(), grid, on_grid, &pos ) )
|
2008-02-29 20:35:11 +00:00
|
|
|
{
|
2011-02-28 21:41:00 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos, false );
|
2008-02-29 20:35:11 +00:00
|
|
|
}
|
2008-02-27 15:26:16 +00:00
|
|
|
else
|
|
|
|
{
|
2008-02-29 20:35:11 +00:00
|
|
|
// If there's no intrusion and DRC is active, we pass the cursor
|
|
|
|
// "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
|
2009-01-17 20:31:19 +00:00
|
|
|
if( !Drc_On || !g_CurrentTrackSegment
|
|
|
|
|| g_CurrentTrackSegment != this->GetCurItem()
|
2011-01-30 22:22:38 +00:00
|
|
|
|| !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment,
|
|
|
|
GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) )
|
2008-02-29 20:35:11 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( on_grid );
|
2008-02-29 20:35:11 +00:00
|
|
|
}
|
2008-02-27 15:26:16 +00:00
|
|
|
}
|
2007-08-04 01:12:30 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( oldpos != GetScreen()->GetCrossHairPosition() )
|
2007-08-04 01:12:30 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
pos = GetScreen()->GetCrossHairPosition();
|
2011-02-28 21:41:00 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( oldpos, false );
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->CrossHairOff( aDC );
|
2011-02-28 21:41:00 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( pos, false );
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->CrossHairOn( aDC );
|
2007-08-04 01:12:30 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
2007-08-04 01:12:30 +00:00
|
|
|
{
|
2010-10-09 08:08:29 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2011-02-01 15:46:25 +00:00
|
|
|
wxDCOverlay oDC( DrawPanel->m_overlay, (wxWindowDC*)aDC );
|
|
|
|
oDC.Clear();
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, false );
|
2010-09-21 23:46:02 +00:00
|
|
|
#else
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, true );
|
2010-09-21 23:46:02 +00:00
|
|
|
#endif
|
2007-08-04 01:12:30 +00:00
|
|
|
}
|
2010-10-09 08:08:29 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2010-09-21 23:46:02 +00:00
|
|
|
else
|
2011-02-01 15:46:25 +00:00
|
|
|
DrawPanel->m_overlay.Reset();
|
2010-09-21 23:46:02 +00:00
|
|
|
#endif
|
2007-08-04 01:12:30 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 16:43:03 +00:00
|
|
|
if( aHotKey )
|
2007-08-20 10:55:09 +00:00
|
|
|
{
|
2011-02-22 16:43:03 +00:00
|
|
|
OnHotKey( aDC, aHotKey, aPosition );
|
2007-08-20 10:55:09 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
UpdateStatusBar(); /* Display new cursor coordinates */
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|