2011-12-12 14:02:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-08-19 07:45:59 +00:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2016 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>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gerber_file_image.h>
|
|
|
|
#include <gerber_file_image_list.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2016-05-26 11:57:43 +00:00
|
|
|
/* locate a gerber item and return a pointer to it.
|
2010-10-10 17:57:54 +00:00
|
|
|
* Display info about this item
|
2016-08-19 07:45:59 +00:00
|
|
|
* Items on non visible layers are not taken in account
|
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;
|
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
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
int layer = GetActiveLayer();
|
2016-06-18 09:37:36 +00:00
|
|
|
GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
|
2010-10-10 17:57:54 +00:00
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
GERBER_DRAW_ITEM* gerb_item = nullptr;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2016-08-19 07:45:59 +00:00
|
|
|
// Search first on active layer
|
|
|
|
// A not used graphic layer can be selected. So gerber can be NULL
|
2017-10-23 09:32:05 +00:00
|
|
|
if( gerber && gerber->m_IsVisible )
|
2010-10-10 17:57:54 +00:00
|
|
|
{
|
2017-10-23 09:32:05 +00:00
|
|
|
for( auto item = gerber->GetItemsList(); item; item = item->Next() )
|
2010-10-10 17:57:54 +00:00
|
|
|
{
|
2017-10-23 09:32:05 +00:00
|
|
|
if( item->HitTest( ref ) )
|
2016-05-26 11:57:43 +00:00
|
|
|
{
|
2017-10-23 09:32:05 +00:00
|
|
|
gerb_item = item;
|
2016-05-26 11:57:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-10-10 17:57:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
if( gerb_item == nullptr ) // Search on all layers
|
2010-10-10 17:57:54 +00:00
|
|
|
{
|
2016-06-18 09:37:36 +00:00
|
|
|
for( layer = 0; layer < (int)ImagesMaxCount(); ++layer )
|
2010-10-10 17:57:54 +00:00
|
|
|
{
|
2016-06-18 09:37:36 +00:00
|
|
|
gerber = GetGbrImage( layer );
|
2016-05-26 11:57:43 +00:00
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
if( gerber == nullptr ) // Graphic layer not yet used
|
2016-05-26 11:57:43 +00:00
|
|
|
continue;
|
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
if( !gerber->m_IsVisible )
|
2016-08-19 07:45:59 +00:00
|
|
|
continue;
|
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
if( layer == GetActiveLayer() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for( auto item = gerber->GetItemsList(); item; item = item->Next() )
|
2010-10-10 17:57:54 +00:00
|
|
|
{
|
2017-10-23 09:32:05 +00:00
|
|
|
if( item->HitTest( ref ) )
|
2016-05-26 11:57:43 +00:00
|
|
|
{
|
2017-10-23 09:32:05 +00:00
|
|
|
gerb_item = item;
|
2016-05-26 11:57:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-10-10 17:57:54 +00:00
|
|
|
}
|
2016-05-27 09:27:28 +00:00
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
if( gerb_item )
|
2016-05-27 09:27:28 +00:00
|
|
|
break;
|
2010-10-10 17:57:54 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
if( gerb_item )
|
2010-10-10 17:57:54 +00:00
|
|
|
{
|
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
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2017-10-23 09:32:05 +00:00
|
|
|
return gerb_item;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|