2011-12-12 14:02:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-05-18 08:33:57 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
2011-12-12 14:02:37 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
|
|
|
#include <class_gerber_draw_item.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-01-12 17:32:24 +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 )
|
2013-08-03 05:15:23 +00:00
|
|
|
ref = GetNearestGridPosition( ref );
|
2010-10-10 17:57:54 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer = getActiveLayer();
|
2010-10-10 17:57:54 +00:00
|
|
|
|
|
|
|
// Search first on active layer
|
2012-05-04 17:44:42 +00:00
|
|
|
GERBER_DRAW_ITEM* gerb_item = GetItemsList();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
for( ; gerb_item; gerb_item = gerb_item->Next() )
|
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
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
for( gerb_item = GetItemsList(); gerb_item; gerb_item = gerb_item->Next() )
|
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 )
|
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
gerb_item->GetMsgPanelInfo( items );
|
|
|
|
SetMsgPanel( items );
|
2010-10-10 17:57:54 +00:00
|
|
|
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
|
|
|
}
|