KiCad PCB EDA Suite
gerbview/onrightclick.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <fctsys.h>
26 #include <class_drawpanel.h>
27 #include <id.h>
28 #include <gerbview_id.h>
29 
30 #include <gerbview.h>
31 #include <gerbview_frame.h>
32 #include <menus_helpers.h>
33 
34 
35 /* Prepare the right-click pullup menu.
36  * The menu already has a list of zoom commands.
37  */
38 bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* aPopMenu )
39 {
41  wxString msg;
42  bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle();
43  bool busy = currItem && currItem->GetFlags();
44 
45  // Do not initiate a start block validation on menu.
47 
48  // Simple location of elements where possible.
49  if( !busy )
50  {
51  currItem = Locate( aPosition, CURSEUR_OFF_GRILLE );
52  busy = currItem && currItem->GetFlags();
53  }
54 
55  // If command in progress, end command.
57  {
58  if( busy )
60  _( "Cancel" ), KiBitmap( cancel_xpm ) );
61  else
63  _( "End Tool" ), KiBitmap( cursor_xpm ) );
64 
65  aPopMenu->AppendSeparator();
66  }
67  else
68  {
69  if( busy || BlockActive )
70  {
71  if( BlockActive )
72  {
74  _( "Cancel Block" ), KiBitmap( cancel_xpm ) );
75  aPopMenu->AppendSeparator();
77  _( "Place Block" ), KiBitmap( checked_ok_xpm ) );
78  }
79  else
80  {
82  _( "Cancel" ), KiBitmap( cancel_xpm ) );
83  }
84 
85  aPopMenu->AppendSeparator();
86  }
87  }
88 
89  if( BlockActive )
90  return true;
91 
92  if( currItem )
93  {
94  GetScreen()->SetCurItem( currItem );
95  bool add_separator = false;
96 
97  // Now, display a context menu
98  // to allow highlighting items which share the same attributes
99  // as the selected item (net attributes and aperture attributes)
100  const GBR_NETLIST_METADATA& net_attr = currItem->GetNetAttributes();
101 
104  {
106  wxString::Format( _( "Highlight items of component '%s'" ),
107  GetChars( net_attr.m_Cmpref ) ),
108  KiBitmap( file_footprint_xpm ) );
109  add_separator = true;
110  }
111 
113  {
115  wxString::Format( _( "Highlight items of net '%s'" ),
116  GetChars( net_attr.m_Netname ) ),
117  KiBitmap( general_ratsnest_xpm ) );
118  add_separator = true;
119  }
120 
121  D_CODE* apertDescr = currItem->GetDcodeDescr();
122 
123  if( !apertDescr->m_AperFunction.IsEmpty() )
124  {
126  wxString::Format( _( "Highlight aperture type '%s'" ),
127  GetChars( apertDescr->m_AperFunction ) ),
128  KiBitmap( flag_xpm ) );
129  add_separator = true;
130  }
131 
132  if( add_separator )
133  aPopMenu->AppendSeparator();
134  }
135 
137  _( "Clear highlight" ),
138  KiBitmap( gerbview_clear_layers_xpm ) );
139 
140  aPopMenu->AppendSeparator();
141 
142  return true;
143 }
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:269
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
EDA_ITEM * GetCurItem() const
print info associated to a component (TO.C attribute)
D_CODE * GetDcodeDescr()
Function GetDcodeDescr returns the GetDcodeDescr of this object, or NULL.
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:55
void SetCanStartBlock(int aStartBlock)
wxString m_Cmpref
the component reference parent of the data
this class handle info which can be added in a gerber file as attribute of an obtect the GBR_INFO_TYP...
bool OnRightClick(const wxPoint &aMousePos, wxMenu *aPopMenu) override
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:314
wxString m_Netname
for items associated to a net: the netname
GERBER_DRAW_ITEM * Locate(const wxPoint &aPosition, int typeloc)
Definition: locate.cpp:43
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE ...
Definition: dcode.h:109
bool IsIdle() const
Function IsIdle returns true if there is currently no block operation in progress.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:81
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
int GetToolId() const
Definition: draw_frame.h:438
#define CURSEUR_OFF_GRILLE
Definition: pcbnew.h:47
print info associated to a flashed pad (TO.P attribute)
print info associated to a net (TO.N attribute)
const GBR_NETLIST_METADATA & GetNetAttributes()
int m_NetAttribType
the type of net info (used to define the gerber string to create)