2014-10-21 18:36:45 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2014 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
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <id.h>
|
2016-08-16 10:56:20 +00:00
|
|
|
#include <gerbview_id.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-03 19:38:24 +00:00
|
|
|
/* Prepare the right-click pullup menu.
|
|
|
|
* The menu already has a list of zoom commands.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2016-08-16 10:56:20 +00:00
|
|
|
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* aPopMenu )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2016-06-18 09:37:36 +00:00
|
|
|
GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
|
2009-11-09 14:00:22 +00:00
|
|
|
wxString msg;
|
2012-03-26 23:47:08 +00:00
|
|
|
bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle();
|
2016-06-18 09:37:36 +00:00
|
|
|
bool busy = currItem && currItem->GetFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// Do not initiate a start block validation on menu.
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetCanStartBlock( -1 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// Simple location of elements where possible.
|
2012-03-20 14:17:58 +00:00
|
|
|
if( !busy )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2016-06-18 09:37:36 +00:00
|
|
|
currItem = Locate( aPosition, CURSEUR_OFF_GRILLE );
|
|
|
|
busy = currItem && currItem->GetFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// If command in progress, end command.
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_NO_TOOL_SELECTED )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-03-20 14:17:58 +00:00
|
|
|
if( busy )
|
2016-08-16 10:56:20 +00:00
|
|
|
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel" ), KiBitmap( cancel_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2016-08-16 10:56:20 +00:00
|
|
|
AddMenuItem( aPopMenu, ID_POPUP_CLOSE_CURRENT_TOOL,
|
2012-03-20 14:17:58 +00:00
|
|
|
_( "End Tool" ), KiBitmap( cursor_xpm ) );
|
2011-02-24 20:22:12 +00:00
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
aPopMenu->AppendSeparator();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-20 14:17:58 +00:00
|
|
|
if( busy || BlockActive )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( BlockActive )
|
|
|
|
{
|
2016-08-16 10:56:20 +00:00
|
|
|
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel Block" ), KiBitmap( cancel_xpm ) );
|
2016-08-16 10:56:20 +00:00
|
|
|
aPopMenu->AppendSeparator();
|
|
|
|
AddMenuItem( aPopMenu, ID_POPUP_PLACE_BLOCK,
|
2014-02-07 19:32:08 +00:00
|
|
|
_( "Place Block" ), KiBitmap( checked_ok_xpm ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-01 12:54:34 +00:00
|
|
|
{
|
2016-08-16 10:56:20 +00:00
|
|
|
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
|
2011-09-08 05:58:45 +00:00
|
|
|
_( "Cancel" ), KiBitmap( cancel_xpm ) );
|
2011-09-01 12:54:34 +00:00
|
|
|
}
|
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
aPopMenu->AppendSeparator();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( BlockActive )
|
2007-10-07 18:24:15 +00:00
|
|
|
return true;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2016-06-18 09:37:36 +00:00
|
|
|
if( currItem )
|
2016-08-16 10:56:20 +00:00
|
|
|
{
|
2016-06-18 09:37:36 +00:00
|
|
|
GetScreen()->SetCurItem( currItem );
|
2016-08-16 10:56:20 +00:00
|
|
|
bool add_separator = false;
|
|
|
|
|
|
|
|
// Now, display a context menu
|
|
|
|
// to allow highlighting items which share the same attributes
|
|
|
|
// as the selected item (net attributes and aperture attributes)
|
|
|
|
const GBR_NETLIST_METADATA& net_attr = currItem->GetNetAttributes();
|
|
|
|
|
|
|
|
if( ( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_PAD ) ||
|
|
|
|
( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_CMP ) )
|
|
|
|
{
|
|
|
|
AddMenuItem( aPopMenu, ID_HIGHLIGHT_CMP_ITEMS,
|
|
|
|
wxString::Format( _( "Highlight items of component '%s'" ),
|
|
|
|
GetChars( net_attr.m_Cmpref ) ),
|
|
|
|
KiBitmap( file_footprint_xpm ) );
|
|
|
|
add_separator = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_NET ) )
|
|
|
|
{
|
|
|
|
AddMenuItem( aPopMenu, ID_HIGHLIGHT_NET_ITEMS,
|
|
|
|
wxString::Format( _( "Highlight items of net '%s'" ),
|
|
|
|
GetChars( net_attr.m_Netname ) ),
|
|
|
|
KiBitmap( general_ratsnest_xpm ) );
|
|
|
|
add_separator = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
D_CODE* apertDescr = currItem->GetDcodeDescr();
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
if( apertDescr && !apertDescr->m_AperFunction.IsEmpty() )
|
2016-08-16 10:56:20 +00:00
|
|
|
{
|
|
|
|
AddMenuItem( aPopMenu, ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS,
|
|
|
|
wxString::Format( _( "Highlight aperture type '%s'" ),
|
|
|
|
GetChars( apertDescr->m_AperFunction ) ),
|
|
|
|
KiBitmap( flag_xpm ) );
|
|
|
|
add_separator = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( add_separator )
|
|
|
|
aPopMenu->AppendSeparator();
|
|
|
|
}
|
|
|
|
|
|
|
|
AddMenuItem( aPopMenu, ID_HIGHLIGHT_REMOVE_ALL,
|
|
|
|
_( "Clear highlight" ),
|
|
|
|
KiBitmap( gerbview_clear_layers_xpm ) );
|
|
|
|
|
|
|
|
aPopMenu->AppendSeparator();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
return true;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|