2011-12-12 14:02:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file locate.cpp
|
|
|
|
*/
|
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-03-12 09:50:21 +00:00
|
|
|
GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-12-12 14:02:37 +00:00
|
|
|
m_messagePanel->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-03-14 21:19:13 +00:00
|
|
|
int layer = getActiveLayer();
|
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
|
|
|
}
|