KiCad PCB EDA Suite
DIFF_PAIR_MENU Class Reference
Inheritance diagram for DIFF_PAIR_MENU:
CONTEXT_MENU

Public Member Functions

 DIFF_PAIR_MENU (PCB_EDIT_FRAME &aFrame)
 
void SetTitle (const wxString &aTitle) override
 Function SetTitle() Sets title for the context menu. More...
 
void DisplayTitle (bool aDisplay=true)
 Function DisplayTitle() Decides whether a title for a pop up menu should be displayed. More...
 
void SetIcon (const BITMAP_OPAQUE *aIcon)
 Function SetIcon() Assigns an icon for the entry. More...
 
wxMenuItem * Add (const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon=NULL)
 Function Add() Adds an entry to the menu. More...
 
wxMenuItem * Add (const TOOL_ACTION &aAction)
 Function Add() Adds an entry to the menu, basing on the TOOL_ACTION object. More...
 
std::list< wxMenuItem * > Add (CONTEXT_MENU *aMenu, bool aExpand=false)
 Function Add() Adds a context menu as a submenu. More...
 
void Clear ()
 Function Clear() Removes all the entries from the menu (as well as its title). More...
 
bool HasEnabledItems () const
 Function HasEnabledItems();. More...
 
int GetSelected () const
 Function GetSelected() Returns the position of selected item. More...
 
void UpdateAll ()
 Function UpdateAll() Runs update handlers for the menu and its submenus. More...
 
void SetTool (TOOL_INTERACTIVE *aTool)
 Function SetTool() Sets a tool that is the creator of the menu. More...
 
CONTEXT_MENUClone () const
 Creates a deep, recursive copy of this CONTEXT_MENU. More...
 

Protected Member Functions

CONTEXT_MENUcreate () const override
 

Returns an instance of this class. It has to be overridden in inheriting classes.

More...
 
void update () override
 Update menu state stub. More...
 
OPT_TOOL_EVENT eventHandler (const wxMenuEvent &aEvent) override
 Event handler stub. More...
 
TOOL_MANAGERgetToolManager () const
 

Returns an instance of TOOL_MANAGER class.

More...
 
void copyFrom (const CONTEXT_MENU &aMenu)
 Copies another menus data to this instance. More...
 

Static Protected Member Functions

static int getMenuId (const TOOL_ACTION &aAction)
 

Returns the corresponding wxMenuItem identifier for a TOOL_ACTION object.

More...
 

Private Attributes

PCB_EDIT_FRAMEm_frame
 

Detailed Description

Definition at line 327 of file router_tool.cpp.

Constructor & Destructor Documentation

DIFF_PAIR_MENU::DIFF_PAIR_MENU ( PCB_EDIT_FRAME aFrame)
inline

Definition at line 330 of file router_tool.cpp.

330  :
331  m_frame( aFrame )
332  {
333  SetIcon( width_track_via_xpm );
334  SetTitle( _( "Select Differential Pair Dimensions" ) );
335  }
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
PCB_EDIT_FRAME & m_frame
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the context menu.

Member Function Documentation

wxMenuItem * CONTEXT_MENU::Add ( const wxString &  aLabel,
int  aId,
const BITMAP_OPAQUE aIcon = NULL 
)
inherited

Function Add() Adds an entry to the menu.

After highlighting/selecting the entry, a TOOL_EVENT command is sent that contains ID of the entry.

Parameters
aLabelis the text label show in the menu.
aIdis the ID that is sent in the TOOL_EVENT. It should be unique for every entry.
aIconis an optional icon.

Definition at line 136 of file context_menu.cpp.

References set_wxMenuIcon().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), CONDITIONAL_MENU::Generate(), and PAD_CONTEXT_MENU::PAD_CONTEXT_MENU().

137 {
138 #ifdef DEBUG
139  if( FindItem( aId ) != NULL )
140  wxLogWarning( wxT( "Adding more than one menu entry with the same ID may result in"
141  "undefined behaviour" ) );
142 #endif
143 
144  wxMenuItem* item = new wxMenuItem( this, aId, aLabel, wxEmptyString, wxITEM_NORMAL );
145  set_wxMenuIcon( item, aIcon );
146 
147  return Append( item );
148 }
static void set_wxMenuIcon(wxMenuItem *aMenu, const BITMAP_OPAQUE *aIcon)
wxMenuItem * CONTEXT_MENU::Add ( const TOOL_ACTION aAction)
inherited

Function Add() Adds an entry to the menu, basing on the TOOL_ACTION object.

After selecting the entry, a TOOL_EVENT command containing name of the action is sent.

Parameters
aActionis the action to be added to menu entry.

ID numbers for tool actions need to have a value higher than ACTION_ID

Definition at line 151 of file context_menu.cpp.

References TOOL_ACTION::GetDescription(), TOOL_ACTION::GetIcon(), CONTEXT_MENU::getMenuId(), TOOL_ACTION::GetMenuItem(), i, CONTEXT_MENU::m_toolActions, and set_wxMenuIcon().

152 {
154  const BITMAP_OPAQUE* icon = aAction.GetIcon();
155 
156  wxMenuItem* item = new wxMenuItem( this, getMenuId( aAction ), aAction.GetMenuItem(),
157  aAction.GetDescription(), wxITEM_NORMAL );
158 
159  set_wxMenuIcon( item, icon );
160 
161  m_toolActions[getMenuId( aAction )] = &aAction;
162 
163  wxMenuItem* i = Append( item );
164  return i;
165 }
PNG memory record (file in memory).
Definition: bitmap_types.h:43
const wxString & GetDescription() const
Definition: tool_action.h:124
std::map< int, const TOOL_ACTION * > m_toolActions
Associates tool actions with menu item IDs. Non-owning.
Definition: context_menu.h:225
const wxString & GetMenuItem() const
Definition: tool_action.h:114
static int getMenuId(const TOOL_ACTION &aAction)
Returns the corresponding wxMenuItem identifier for a TOOL_ACTION object.
Definition: context_menu.h:155
size_t i
Definition: json11.cpp:597
const BITMAP_OPAQUE * GetIcon() const
Returns an icon associated with the action.
Definition: tool_action.h:165
static void set_wxMenuIcon(wxMenuItem *aMenu, const BITMAP_OPAQUE *aIcon)
std::list< wxMenuItem * > CONTEXT_MENU::Add ( CONTEXT_MENU aMenu,
bool  aExpand = false 
)
inherited

Function Add() Adds a context menu as a submenu.

The difference between this function and wxMenu::AppendSubMenu() is the capability to handle icons.

Parameters
aMenuis the submenu to be added.
aExpandallows one to add all entries from the menu as individual entries rather than add everything as a submenu.

Definition at line 168 of file context_menu.cpp.

References CONTEXT_MENU::appendCopy(), CONTEXT_MENU::Clone(), i, CONTEXT_MENU::m_icon, CONTEXT_MENU::m_submenus, CONTEXT_MENU::m_title, and set_wxMenuIcon().

169 {
170  std::list<wxMenuItem*> items;
171  CONTEXT_MENU* menuCopy = aMenu->Clone();
172  m_submenus.push_back( menuCopy );
173 
174  if( aExpand )
175  {
176  for( int i = 0; i < (int) aMenu->GetMenuItemCount(); ++i )
177  {
178  wxMenuItem* item = aMenu->FindItemByPosition( i );
179  items.push_back( appendCopy( item ) );
180  }
181  }
182  else
183  {
184  wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for CONTEXT_MENU using SetTitle()" );
185 
186  if( aMenu->m_icon )
187  {
188  wxMenuItem* newItem = new wxMenuItem( this, -1, menuCopy->m_title );
189  set_wxMenuIcon( newItem, aMenu->m_icon );
190  newItem->SetSubMenu( menuCopy );
191  items.push_back( Append( newItem ) );
192  }
193  else
194  {
195  items.push_back( AppendSubMenu( menuCopy, menuCopy->m_title ) );
196  }
197  }
198 
199  return items;
200 }
Class CONTEXT_MENU.
Definition: context_menu.h:44
const BITMAP_OPAQUE * m_icon
Optional icon
Definition: context_menu.h:231
CONTEXT_MENU * Clone() const
Creates a deep, recursive copy of this CONTEXT_MENU.
size_t i
Definition: json11.cpp:597
std::list< CONTEXT_MENU * > m_submenus
List of submenus.
Definition: context_menu.h:228
wxMenuItem * appendCopy(const wxMenuItem *aSource)
Function appendCopy Appends a copy of wxMenuItem.
wxString m_title
Menu title
Definition: context_menu.h:213
static void set_wxMenuIcon(wxMenuItem *aMenu, const BITMAP_OPAQUE *aIcon)
void CONTEXT_MENU::Clear ( )
inherited

Function Clear() Removes all the entries from the menu (as well as its title).

It leaves the menu in the initial state.

Definition at line 203 of file context_menu.cpp.

References i, CONTEXT_MENU::m_submenus, CONTEXT_MENU::m_titleDisplayed, and CONTEXT_MENU::m_toolActions.

Referenced by CONTEXT_MENU::Clone().

204 {
205  m_titleDisplayed = false;
206 
207  for( int i = GetMenuItemCount() - 1; i >= 0; --i )
208  Destroy( FindItemByPosition( i ) );
209 
210  m_toolActions.clear();
211  m_submenus.clear();
212 
213  wxASSERT( GetMenuItemCount() == 0 );
214 }
std::map< int, const TOOL_ACTION * > m_toolActions
Associates tool actions with menu item IDs. Non-owning.
Definition: context_menu.h:225
size_t i
Definition: json11.cpp:597
std::list< CONTEXT_MENU * > m_submenus
List of submenus.
Definition: context_menu.h:228
bool m_titleDisplayed
Flag indicating that the menu title was set up.
Definition: context_menu.h:210
CONTEXT_MENU * CONTEXT_MENU::Clone ( ) const
inherited

Creates a deep, recursive copy of this CONTEXT_MENU.

Definition at line 261 of file context_menu.cpp.

References CONTEXT_MENU::Clear(), CONTEXT_MENU::copyFrom(), and CONTEXT_MENU::create().

Referenced by CONTEXT_MENU::Add(), CONTEXT_MENU::appendCopy(), TOOL_MANAGER::dispatchContextMenu(), and CONTEXT_MENU::GetSelected().

262 {
263  CONTEXT_MENU* clone = create();
264  clone->Clear();
265  clone->copyFrom( *this );
266  return clone;
267 }
Class CONTEXT_MENU.
Definition: context_menu.h:44
void copyFrom(const CONTEXT_MENU &aMenu)
Copies another menus data to this instance.
void Clear()
Function Clear() Removes all the entries from the menu (as well as its title).
virtual CONTEXT_MENU * create() const
Returns an instance of this class. It has to be overridden in inheriting classes. ...
void CONTEXT_MENU::copyFrom ( const CONTEXT_MENU aMenu)
protectedinherited

Copies another menus data to this instance.

Old entries are preserved, and ones form aMenu are copied.

Definition at line 436 of file context_menu.cpp.

References CONTEXT_MENU::appendCopy(), i, CONTEXT_MENU::m_icon, CONTEXT_MENU::m_selected, CONTEXT_MENU::m_title, CONTEXT_MENU::m_titleDisplayed, CONTEXT_MENU::m_tool, and CONTEXT_MENU::m_toolActions.

Referenced by CONTEXT_MENU::Clone(), and CONTEXT_MENU::eventHandler().

437 {
438  m_icon = aMenu.m_icon;
439  m_title = aMenu.m_title;
441  m_selected = -1; // aMenu.m_selected;
442  m_tool = aMenu.m_tool;
444 
445  // Copy all menu entries
446  for( int i = 0; i < (int) aMenu.GetMenuItemCount(); ++i )
447  {
448  wxMenuItem* item = aMenu.FindItemByPosition( i );
449  appendCopy( item );
450  }
451 }
TOOL_INTERACTIVE * m_tool
Creator of the menu
Definition: context_menu.h:219
int m_selected
Stores the id number of selected item.
Definition: context_menu.h:216
const BITMAP_OPAQUE * m_icon
Optional icon
Definition: context_menu.h:231
std::map< int, const TOOL_ACTION * > m_toolActions
Associates tool actions with menu item IDs. Non-owning.
Definition: context_menu.h:225
size_t i
Definition: json11.cpp:597
wxMenuItem * appendCopy(const wxMenuItem *aSource)
Function appendCopy Appends a copy of wxMenuItem.
wxString m_title
Menu title
Definition: context_menu.h:213
bool m_titleDisplayed
Flag indicating that the menu title was set up.
Definition: context_menu.h:210
CONTEXT_MENU* DIFF_PAIR_MENU::create ( ) const
inlineoverrideprotectedvirtual

Returns an instance of this class. It has to be overridden in inheriting classes.

Reimplemented from CONTEXT_MENU.

Definition at line 338 of file router_tool.cpp.

339  {
340  return new DIFF_PAIR_MENU( m_frame );
341  }
DIFF_PAIR_MENU(PCB_EDIT_FRAME &aFrame)
PCB_EDIT_FRAME & m_frame
void CONTEXT_MENU::DisplayTitle ( bool  aDisplay = true)
inherited

Function DisplayTitle() Decides whether a title for a pop up menu should be displayed.

Definition at line 99 of file context_menu.cpp.

References CONTEXT_MENU::m_icon, CONTEXT_MENU::m_title, CONTEXT_MENU::m_titleDisplayed, and set_wxMenuIcon().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), and CONTEXT_MENU::SetTitle().

100 {
101  if( ( !aDisplay || m_title.IsEmpty() ) && m_titleDisplayed )
102  {
103  // Destroy the menu entry keeping the title..
104  wxMenuItem* item = FindItemByPosition( 0 );
105  wxASSERT( item->GetItemLabelText() == GetTitle() );
106  Destroy( item );
107  // ..and separator
108  item = FindItemByPosition( 0 );
109  wxASSERT( item->IsSeparator() );
110  Destroy( item );
111  m_titleDisplayed = false;
112  }
113 
114  else if( aDisplay && !m_title.IsEmpty() )
115  {
116  if( m_titleDisplayed )
117  {
118  // Simply update the title
119  FindItemByPosition( 0 )->SetItemLabel( m_title );
120  }
121  else
122  {
123  // Add a separator and a menu entry to display the title
124  InsertSeparator( 0 );
125  Insert( 0, new wxMenuItem( this, wxID_NONE, m_title, wxEmptyString, wxITEM_NORMAL ) );
126 
127  if( m_icon )
128  set_wxMenuIcon( FindItemByPosition( 0 ), m_icon );
129 
130  m_titleDisplayed = true;
131  }
132  }
133 }
const BITMAP_OPAQUE * m_icon
Optional icon
Definition: context_menu.h:231
wxString m_title
Menu title
Definition: context_menu.h:213
static void set_wxMenuIcon(wxMenuItem *aMenu, const BITMAP_OPAQUE *aIcon)
bool m_titleDisplayed
Flag indicating that the menu title was set up.
Definition: context_menu.h:210
OPT_TOOL_EVENT DIFF_PAIR_MENU::eventHandler ( const wxMenuEvent &  )
inlineoverrideprotectedvirtual

Event handler stub.

It should be used if you want to generate a TOOL_EVENT from a wxMenuEvent. It will be called when a menu entry is clicked.

Reimplemented from CONTEXT_MENU.

Definition at line 383 of file router_tool.cpp.

References ID_POPUP_PCB_SELECT_CUSTOM_DIFFPAIR, ID_POPUP_PCB_SELECT_DIFFPAIR1, ID_POPUP_PCB_SELECT_DIFFPAIR16, ID_POPUP_PCB_SELECT_USE_NETCLASS_DIFFPAIR, PCB_ACTIONS::routerActivateDpDimensionsDialog, TOOL_MANAGER::RunAction(), BOARD_DESIGN_SETTINGS::SetDiffPairIndex(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomDiffPairDimensions().

384  {
386  int id = aEvent.GetId();
387 
388  // On Windows, this handler can be called with an event ID not existing in any
389  // menuitem, so only set flags when we have an ID match.
390 
392  {
393  bds.UseCustomDiffPairDimensions( true );
394  TOOL_MANAGER* toolManager = m_frame.GetToolManager();
396  }
398  {
399  bds.UseCustomDiffPairDimensions( false );
400  bds.SetDiffPairIndex( 0 );
401  }
403  {
404  bds.UseCustomDiffPairDimensions( false );
405  // remember that the menu doesn't contain index 0 (which is the netclass values)
407  }
408 
409  return OPT_TOOL_EVENT( PCB_ACTIONS::trackViaSizeChanged.MakeEvent() );
410  }
void UseCustomDiffPairDimensions(bool aEnabled)
Function UseCustomDiffPairDimensions Enables/disables custom differential pair dimensions.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
BOARD * GetBoard() const
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:294
Class TOOL_MANAGER.
Definition: tool_manager.h:49
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
void SetDiffPairIndex(unsigned aIndex)
Function SetDiffPairIndex.
PCB_EDIT_FRAME & m_frame
TOOL_MANAGER * GetToolManager() const
Return the tool manager instance, if any.
Definition: draw_frame.h:914
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
static TOOL_ACTION routerActivateDpDimensionsDialog
Definition: pcb_actions.h:214
static int CONTEXT_MENU::getMenuId ( const TOOL_ACTION aAction)
inlinestaticprotectedinherited

Returns the corresponding wxMenuItem identifier for a TOOL_ACTION object.

Definition at line 155 of file context_menu.h.

References CONTEXT_MENU::ACTION_ID, and TOOL_ACTION::GetId().

Referenced by CONTEXT_MENU::Add(), and PAD_CONTEXT_MENU::update().

156  {
157  return aAction.GetId() + ACTION_ID;
158  }
static const int ACTION_ID
Menu items with ID higher than that are considered TOOL_ACTIONs
Definition: context_menu.h:222
int GetId() const
Function GetId() Returns the unique id of the TOOL_ACTION object.
Definition: tool_action.h:85
int CONTEXT_MENU::GetSelected ( ) const
inlineinherited

Function GetSelected() Returns the position of selected item.

If the returned value is negative, that means that menu was dismissed.

Returns
The position of selected item in the context menu.

Definition at line 124 of file context_menu.h.

References CONTEXT_MENU::Clone(), CONTEXT_MENU::create(), CONTEXT_MENU::getToolManager(), CONTEXT_MENU::m_selected, CONTEXT_MENU::SetTool(), and CONTEXT_MENU::UpdateAll().

Referenced by LIB_EDIT_FRAME::OnViewEntryDoc().

125  {
126  return m_selected;
127  }
int m_selected
Stores the id number of selected item.
Definition: context_menu.h:216
TOOL_MANAGER * CONTEXT_MENU::getToolManager ( ) const
protectedinherited

Returns an instance of TOOL_MANAGER class.

Definition at line 281 of file context_menu.cpp.

References TOOL_BASE::GetManager(), and CONTEXT_MENU::m_tool.

Referenced by CONTEXT_MENU::GetSelected(), PAD_CONTEXT_MENU::update(), and CONTEXT_MENU::updateHotKeys().

282 {
283  wxASSERT( m_tool );
284  return m_tool ? m_tool->GetManager() : nullptr;
285 }
TOOL_INTERACTIVE * m_tool
Creator of the menu
Definition: context_menu.h:219
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool...
Definition: tool_base.h:144
bool CONTEXT_MENU::HasEnabledItems ( ) const
inherited

Function HasEnabledItems();.

Returns true if the menu has any enabled items

Definition at line 217 of file context_menu.cpp.

218 {
219  bool hasEnabled = false;
220 
221  auto& items = GetMenuItems();
222 
223  for( auto item : items )
224  {
225  if( item->IsEnabled() && !item->IsSeparator() )
226  {
227  hasEnabled = true;
228  break;
229  }
230  }
231 
232  return hasEnabled;
233 }
void CONTEXT_MENU::SetIcon ( const BITMAP_OPAQUE aIcon)
inherited

Function SetIcon() Assigns an icon for the entry.

Parameters
aIconis the icon to be assigned. NULL is used to remove icon.

Definition at line 75 of file context_menu.cpp.

References CONTEXT_MENU::m_icon.

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), GRID_MENU::GRID_MENU(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_CONTEXT_MENU::PAD_CONTEXT_MENU(), and ZOOM_MENU::ZOOM_MENU().

76 {
77  m_icon = aIcon;
78 }
const BITMAP_OPAQUE * m_icon
Optional icon
Definition: context_menu.h:231
void CONTEXT_MENU::SetTitle ( const wxString &  aTitle)
overrideinherited

Function SetTitle() Sets title for the context menu.

The title is shown as a text label shown on the top of the menu.

Parameters
aTitleis the new title.

Definition at line 88 of file context_menu.cpp.

References CONTEXT_MENU::DisplayTitle(), CONTEXT_MENU::m_title, and CONTEXT_MENU::m_titleDisplayed.

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), GRID_MENU::GRID_MENU(), PAD_CONTEXT_MENU::PAD_CONTEXT_MENU(), and ZOOM_MENU::ZOOM_MENU().

89 {
90  // Unfortunately wxMenu::SetTitle() does not work very well, so this is an alternative version
91  m_title = aTitle;
92 
93  // Update the menu title
94  if( m_titleDisplayed )
95  DisplayTitle( true );
96 }
void DisplayTitle(bool aDisplay=true)
Function DisplayTitle() Decides whether a title for a pop up menu should be displayed.
wxString m_title
Menu title
Definition: context_menu.h:213
bool m_titleDisplayed
Flag indicating that the menu title was set up.
Definition: context_menu.h:210
void CONTEXT_MENU::SetTool ( TOOL_INTERACTIVE aTool)
inherited

Function SetTool() Sets a tool that is the creator of the menu.

Parameters
aToolis the tool that created the menu.

Definition at line 254 of file context_menu.cpp.

References CONTEXT_MENU::m_tool, and CONTEXT_MENU::runOnSubmenus().

Referenced by CONDITIONAL_MENU::Generate(), CONTEXT_MENU::GetSelected(), and TOOL_INTERACTIVE::SetContextMenu().

255 {
256  m_tool = aTool;
257  runOnSubmenus( std::bind( &CONTEXT_MENU::SetTool, _1, aTool ) );
258 }
TOOL_INTERACTIVE * m_tool
Creator of the menu
Definition: context_menu.h:219
void runOnSubmenus(std::function< void(CONTEXT_MENU *)> aFunction)
Runs a function on the menu and all its submenus.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void DIFF_PAIR_MENU::update ( )
inlineoverrideprotectedvirtual

Update menu state stub.

It is called before a menu is shown, in order to update its state. Here you can tick current settings, enable/disable entries, etc.

Reimplemented from CONTEXT_MENU.

Definition at line 343 of file router_tool.cpp.

References BOARD_DESIGN_SETTINGS::GetDiffPairIndex(), i, ID_POPUP_PCB_SELECT_CUSTOM_DIFFPAIR, ID_POPUP_PCB_SELECT_DIFFPAIR1, ID_POPUP_PCB_SELECT_USE_NETCLASS_DIFFPAIR, BOARD_DESIGN_SETTINGS::m_DiffPairDimensionsList, DIFF_PAIR_DIMENSION::m_Gap, DIFF_PAIR_DIMENSION::m_ViaGap, DIFF_PAIR_DIMENSION::m_Width, MessageTextFromValue(), and BOARD_DESIGN_SETTINGS::UseCustomDiffPairDimensions().

344  {
345  EDA_UNITS_T units = m_frame.GetUserUnits();
347 
348  Clear();
349 
350  Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_DIFFPAIR, _( "Use Net Class Values" ),
351  _( "Use differential pair dimensions from the net class" ), wxITEM_CHECK );
353  !bds.UseCustomDiffPairDimensions() && bds.GetDiffPairIndex() == 0 );
354 
355  Append( ID_POPUP_PCB_SELECT_CUSTOM_DIFFPAIR, _( "Use Custom Values..." ),
356  _( "Specify custom differential pair dimensions" ), wxITEM_CHECK );
358 
359  AppendSeparator();
360 
361  // Append the list of differential pair dimensions
362 
363  // Drop index 0 which is the current netclass dimensions (which are handled above)
364  for( unsigned i = 1; i < bds.m_DiffPairDimensionsList.size(); ++i )
365  {
367  wxString msg;
368 
369  msg << _( "Width " ) << MessageTextFromValue( units, diffPair.m_Width, true );
370 
371  if( diffPair.m_Gap > 0 )
372  msg << _( ", gap " ) << MessageTextFromValue( units, diffPair.m_Gap, true );
373 
374  if( diffPair.m_ViaGap > 0 )
375  msg << _( ", via gap " ) << MessageTextFromValue( units, diffPair.m_ViaGap, true );
376 
377  int menuIdx = ID_POPUP_PCB_SELECT_DIFFPAIR1 + i - 1;
378  Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
379  Check( menuIdx, !bds.UseCustomDiffPairDimensions() && bds.GetDiffPairIndex() == i );
380  }
381  }
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
void UseCustomDiffPairDimensions(bool aEnabled)
Function UseCustomDiffPairDimensions Enables/disables custom differential pair dimensions.
BOARD * GetBoard() const
Struct DIFF_PAIR_DIMENSION is a small helper container to handle a stock of specific differential pai...
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
void Clear()
Function Clear() Removes all the entries from the menu (as well as its title).
PCB_EDIT_FRAME & m_frame
unsigned GetDiffPairIndex() const
Function GetDiffPairIndex.
size_t i
Definition: json11.cpp:597
EDA_UNITS_T
Definition: common.h:159
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void CONTEXT_MENU::UpdateAll ( )
inherited

Function UpdateAll() Runs update handlers for the menu and its submenus.

Definition at line 236 of file context_menu.cpp.

References Format(), CONTEXT_MENU::m_tool, CONTEXT_MENU::runOnSubmenus(), CONTEXT_MENU::update(), and CONTEXT_MENU::updateHotKeys().

Referenced by CONTEXT_MENU::GetSelected().

237 {
238  try
239  {
240  update();
241  }
242  catch( std::exception& e )
243  {
244  wxLogDebug( wxString::Format( "CONTEXT_MENU update handler exception: %s", e.what() ) );
245  }
246 
247  if( m_tool )
248  updateHotKeys();
249 
250  runOnSubmenus( std::bind( &CONTEXT_MENU::UpdateAll, _1 ) );
251 }
TOOL_INTERACTIVE * m_tool
Creator of the menu
Definition: context_menu.h:219
void updateHotKeys()
Updates hot key settings for TOOL_ACTIONs in this menu.
virtual void update()
Update menu state stub.
Definition: context_menu.h:164
void runOnSubmenus(std::function< void(CONTEXT_MENU *)> aFunction)
Runs a function on the menu and all its submenus.
void UpdateAll()
Function UpdateAll() Runs update handlers for the menu and its submenus.
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

Member Data Documentation

PCB_EDIT_FRAME& DIFF_PAIR_MENU::m_frame
private

Definition at line 413 of file router_tool.cpp.


The documentation for this class was generated from the following file: