2009-11-09 14:00:22 +00:00
|
|
|
/************************************************/
|
|
|
|
/* Locate items at the current cursor position. */
|
|
|
|
/************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "gerbview.h"
|
2010-10-10 17:57:54 +00:00
|
|
|
#include "class_gerber_draw_item.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
/* localize a gerber item and return a pointer to it.
|
|
|
|
* Display info about this item
|
2007-08-20 19:33:15 +00:00
|
|
|
*/
|
2011-02-21 13:54:29 +00:00
|
|
|
GERBER_DRAW_ITEM* WinEDA_GerberFrame::Locate( const wxPoint& aPosition, int aTypeloc )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 19:33:15 +00:00
|
|
|
MsgPanel->EraseMsgBox();
|
2011-02-21 13:54:29 +00:00
|
|
|
wxPoint ref = aPosition;
|
2010-10-10 17:57:54 +00:00
|
|
|
bool found = false;
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
if( aTypeloc == CURSEUR_ON_GRILLE )
|
2011-02-21 13:54:29 +00:00
|
|
|
ref = GetScreen()->GetNearestGridPosition( ref );
|
2010-10-10 17:57:54 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
int layer = GetScreen()->m_Active_Layer;
|
2010-10-10 17:57:54 +00:00
|
|
|
|
|
|
|
// Search first on active layer
|
|
|
|
BOARD_ITEM* item = GetBoard()->m_Drawings;
|
|
|
|
GERBER_DRAW_ITEM* gerb_item = NULL;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
for( ; item; item = item->Next() )
|
|
|
|
{
|
|
|
|
gerb_item = (GERBER_DRAW_ITEM*) item;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
if( gerb_item->GetLayer()!= layer )
|
|
|
|
continue;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
if( gerb_item->HitTest( ref ) )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !found ) // Search on all layers
|
|
|
|
{
|
|
|
|
item = GetBoard()->m_Drawings;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
for( ; item; item = item->Next() )
|
|
|
|
{
|
|
|
|
gerb_item = (GERBER_DRAW_ITEM*) item;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
if( gerb_item->HitTest( ref ) )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
if( found )
|
|
|
|
{
|
|
|
|
gerb_item->DisplayInfo( this );
|
|
|
|
return gerb_item;
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|