KiCad PCB EDA Suite
APPEARANCE_CONTROLS Class Reference

#include <appearance_controls.h>

Inheritance diagram for APPEARANCE_CONTROLS:
APPEARANCE_CONTROLS_BASE BOARD_LISTENER

Classes

struct  APPEARANCE_SETTING
 Container for an appearance setting (can control a single board layer, or GAL layer, etc) More...
 

Public Member Functions

 APPEARANCE_CONTROLS (PCB_BASE_FRAME *aParent, wxWindow *aFocusOwner, bool aFpEditor=false)
 
 ~APPEARANCE_CONTROLS ()
 
wxSize GetBestSize () const
 Update the panel contents from the application and board models. More...
 
void OnBoardChanged ()
 
void OnBoardNetSettingsChanged (BOARD &aBoard) override
 
void OnBoardItemAdded (BOARD &aBoard, BOARD_ITEM *aItem) override
 
void OnBoardItemsAdded (BOARD &aBoard, std::vector< BOARD_ITEM * > &aItems) override
 
void OnBoardItemRemoved (BOARD &aBoard, BOARD_ITEM *aItem) override
 
void OnBoardItemsRemoved (BOARD &aBoard, std::vector< BOARD_ITEM * > &aItems) override
 
void OnBoardItemChanged (BOARD &aBoard, BOARD_ITEM *aItem) override
 
void OnBoardItemsChanged (BOARD &aBoard, std::vector< BOARD_ITEM * > &aItems) override
 Update the colors on all the widgets from the new chosen color theme. More...
 
void OnColorThemeChanged ()
 Update the widget when the active board layer is changed. More...
 
void OnLayerChanged ()
 
void OnNetVisibilityChanged (int aNetCode, bool aVisibility)
 Notifies the panel when a net has been hidden or shown via the external tool. More...
 
void SetLayerVisible (LAYER_NUM aLayer, bool isVisible)
 
void SetObjectVisible (GAL_LAYER_ID aLayer, bool isVisible=true)
 Update the manual layer alpha overrides. More...
 
void OnLayerAlphaChanged ()
 
void UpdateDisplayOptions ()
 Return a list of the layer presets created by the user. More...
 
std::vector< LAYER_PRESETGetUserLayerPresets () const
 Update the current layer presets from those saved in the project file. More...
 
void SetUserLayerPresets (std::vector< LAYER_PRESET > &aPresetList)
 
void ApplyLayerPreset (const wxString &aPresetName)
 
void ApplyLayerPreset (const LAYER_PRESET &aPreset)
 
wxString GetActiveLayerPreset () const
 
const wxArrayString & GetLayerPresetsMRU ()
 
void OnColorSwatchChanged (wxCommandEvent &aEvent)
 
void OnLayerContextMenu (wxCommandEvent &aEvent)
 Return the index of the current tab (0-2). More...
 
int GetTabIndex () const
 Set the current notebook tab. More...
 
void SetTabIndex (int aTab)
 
void RefreshCollapsiblePanes ()
 Function to force a redraw of the collapsible panes in this control. More...
 
void m_netsTabSplitterOnIdle (wxIdleEvent &)
 
virtual void OnBoardHighlightNetChanged (BOARD &aBoard)
 

Protected Member Functions

void OnNotebookPageChanged (wxNotebookEvent &event) override
 
void OnSetFocus (wxFocusEvent &aEvent) override
 
void OnSize (wxSizeEvent &aEvent) override
 
void OnNetGridClick (wxGridEvent &event) override
 
void OnNetGridDoubleClick (wxGridEvent &event) override
 
void OnNetGridRightClick (wxGridEvent &event) override
 
void OnNetGridMouseEvent (wxMouseEvent &aEvent)
 

Protected Attributes

wxBoxSizer * m_sizerOuter
 
wxNotebook * m_notebook
 
wxPanel * m_panelLayers
 
wxBoxSizer * m_panelLayersSizer
 
wxScrolledCanvas * m_windowLayers
 
wxPanel * m_panelObjects
 
wxBoxSizer * m_objectsPanelSizer
 
wxScrolledCanvas * m_windowObjects
 
wxPanel * m_panelNetsAndClasses
 
wxBoxSizer * m_netsTabOuterSizer
 
wxSplitterWindow * m_netsTabSplitter
 
wxPanel * m_panelNets
 
wxStaticText * m_staticTextNets
 
wxTextCtrl * m_txtNetFilter
 
BITMAP_BUTTONm_btnNetInspector
 
WX_GRIDm_netsGrid
 
wxPanel * m_panelNetclasses
 
wxStaticText * m_staticTextNetClasses
 
BITMAP_BUTTONm_btnConfigureNetClasses
 
wxScrolledWindow * m_netclassScrolledWindow
 
wxBoxSizer * m_netclassOuterSizer
 
wxStaticText * m_presetsLabel
 
wxChoice * m_cbLayerPresets
 

Private Types

enum  POPUP_ID {
  ID_CHANGE_COLOR = wxID_HIGHEST, ID_SET_NET_COLOR, ID_CLEAR_NET_COLOR, ID_SHOW_ALL_NETS,
  ID_HIDE_OTHER_NETS, ID_HIGHLIGHT_NET, ID_SELECT_NET, ID_DESELECT_NET,
  ID_SHOW_ALL_COPPER_LAYERS, ID_HIDE_ALL_COPPER_LAYERS, ID_HIDE_ALL_BUT_ACTIVE, ID_PRESET_NO_LAYERS,
  ID_PRESET_ALL_LAYERS, ID_PRESET_FRONT, ID_PRESET_FRONT_ASSEMBLY, ID_PRESET_INNER_COPPER,
  ID_PRESET_BACK, ID_PRESET_BACK_ASSEMBLY, ID_HIDE_ALL_NON_COPPER, ID_SHOW_ALL_NON_COPPER,
  ID_LAST_VALUE
}
 

Private Member Functions

void createControls ()
 
void rebuildLayers ()
 
void rebuildLayerContextMenu ()
 
void syncColorsAndVisibility ()
 
void rebuildObjects ()
 
void syncObjectSettings ()
 
void rebuildNets ()
 
void loadDefaultLayerPresets ()
 
void rebuildLayerPresetsWidget ()
 
void syncLayerPresetSelection ()
 
void onLayerLeftClick (wxMouseEvent &aEvent)
 
void rightClickHandler (wxMouseEvent &aEvent)
 
void onLayerVisibilityChanged (PCB_LAYER_ID aLayer, bool isVisible, bool isFinal)
 
void onObjectVisibilityChanged (GAL_LAYER_ID aLayer, bool isVisible, bool isFinal)
 
void setVisibleLayers (LSET aLayers)
 
void setVisibleObjects (GAL_SET aObjects)
 
LSET getVisibleLayers ()
 
GAL_SET getVisibleObjects ()
 
void onObjectOpacitySlider (int aLayer, float aOpacity)
 
void updateLayerPresetSelection (const wxString &aName)
 
void onLayerPresetChanged (wxCommandEvent &aEvent) override
 
void doApplyLayerPreset (const LAYER_PRESET &aPreset)
 
void onNetclassVisibilityChanged (wxCommandEvent &aEvent)
 
void showNetclass (const wxString &aClassName, bool aShow=true)
 
void onNetContextMenu (wxCommandEvent &aEvent)
 
void onNetclassColorChanged (wxCommandEvent &aEvent)
 
wxString netclassNameFromEvent (wxEvent &aEvent)
 
void onNetColorMode (wxCommandEvent &aEvent)
 
void onRatsnestMode (wxCommandEvent &aEvent)
 
void onNetclassContextMenu (wxCommandEvent &aEvent)
 
void handleBoardItemsChanged ()
 
void passOnFocus ()
 
void idleFocusHandler (wxIdleEvent &aEvent)
 
void onReadOnlySwatch ()
 
bool doesBoardItemNeedRebuild (BOARD_ITEM *aBoardItem)
 
bool doesBoardItemNeedRebuild (std::vector< BOARD_ITEM * > &aBoardItems)
 

Private Attributes

PCB_BASE_FRAMEm_frame
 
wxWindow * m_focusOwner
 
ROW_ICON_PROVIDERm_iconProvider
 
BOARDm_board
 
bool m_isFpEditor
 
NET_GRID_TABLEm_netsTable
 
GRID_BITMAP_TOGGLE_RENDERERm_toggleGridRenderer
 
wxGridCellCoords m_hoveredCell
 Grid cell that is being hovered over, for tooltips. More...
 
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_layerSettings
 
std::map< PCB_LAYER_ID, APPEARANCE_SETTING * > m_layerSettingsMap
 
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_objectSettings
 
std::map< GAL_LAYER_ID, APPEARANCE_SETTING * > m_objectSettingsMap
 
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_netclassSettings
 
std::map< wxString, APPEARANCE_SETTING * > m_netclassSettingsMap
 
std::map< wxString, LAYER_PRESETm_layerPresets
 
LAYER_PRESETm_currentPreset
 
LAYER_PRESETm_lastSelectedUserPreset
 The last user (non-read-only) preset selected by the user. More...
 
wxArrayString m_presetMRU
 
wxMenu * m_layerContextMenu
 
std::map< int, wxString > m_netclassIdMap
 Stores wxIDs for each netclass for control event mapping. More...
 
wxString m_contextMenuNetclass
 The name of the netclass that was right-clicked. More...
 
wxBoxSizer * m_layersOuterSizer
 
wxBoxSizer * m_objectsOuterSizer
 
int m_pointSize
 
wxColour m_layerPanelColour
 
WX_COLLAPSIBLE_PANEm_paneLayerDisplayOptions
 
wxStaticText * m_inactiveLayersLabel
 
wxRadioButton * m_rbHighContrastNormal
 
wxRadioButton * m_rbHighContrastDim
 
wxRadioButton * m_rbHighContrastOff
 
wxStaticLine * m_layerDisplaySeparator
 
wxCheckBox * m_cbFlipBoard
 
WX_COLLAPSIBLE_PANEm_paneNetDisplayOptions
 
wxStaticText * m_txtNetDisplayTitle
 
wxRadioButton * m_rbNetColorAll
 
wxRadioButton * m_rbNetColorRatsnest
 
wxRadioButton * m_rbNetColorOff
 
wxStaticText * m_txtRatsnestVisibility
 
wxRadioButton * m_rbRatsnestAllLayers
 
wxRadioButton * m_rbRatsnestVisLayers
 
wxRadioButton * m_rbRatsnestNone
 

Static Private Attributes

static const APPEARANCE_SETTING s_objectSettings []
 Template for object appearance settings. More...
 
static LAYER_PRESET presetNoLayers
 
static LAYER_PRESET presetAllLayers
 
static LAYER_PRESET presetAllCopper
 
static LAYER_PRESET presetInnerCopper
 
static LAYER_PRESET presetFront
 
static LAYER_PRESET presetFrontAssembly
 
static LAYER_PRESET presetBack
 
static LAYER_PRESET presetBackAssembly
 

Detailed Description

Definition at line 141 of file appearance_controls.h.

Member Enumeration Documentation

◆ POPUP_ID

Enumerator
ID_CHANGE_COLOR 
ID_SET_NET_COLOR 
ID_CLEAR_NET_COLOR 
ID_SHOW_ALL_NETS 
ID_HIDE_OTHER_NETS 
ID_HIGHLIGHT_NET 
ID_SELECT_NET 
ID_DESELECT_NET 
ID_SHOW_ALL_COPPER_LAYERS 
ID_HIDE_ALL_COPPER_LAYERS 
ID_HIDE_ALL_BUT_ACTIVE 
ID_PRESET_NO_LAYERS 
ID_PRESET_ALL_LAYERS 
ID_PRESET_FRONT 
ID_PRESET_FRONT_ASSEMBLY 
ID_PRESET_INNER_COPPER 
ID_PRESET_BACK 
ID_PRESET_BACK_ASSEMBLY 
ID_HIDE_ALL_NON_COPPER 
ID_SHOW_ALL_NON_COPPER 
ID_LAST_VALUE 

Definition at line 455 of file appearance_controls.h.

456  {
457  ID_CHANGE_COLOR = wxID_HIGHEST,
478  };

Constructor & Destructor Documentation

◆ APPEARANCE_CONTROLS()

APPEARANCE_CONTROLS::APPEARANCE_CONTROLS ( PCB_BASE_FRAME aParent,
wxWindow *  aFocusOwner,
bool  aFpEditor = false 
)

Definition at line 399 of file appearance_controls.cpp.

400  :
401  APPEARANCE_CONTROLS_BASE( aParent ),
402  m_frame( aParent ),
403  m_focusOwner( aFocusOwner ),
404  m_board( nullptr ),
405  m_isFpEditor( aFpEditorMode ),
406  m_currentPreset( nullptr ),
407  m_lastSelectedUserPreset( nullptr ),
408  m_layerContextMenu( nullptr )
409 {
410  int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x;
411  m_iconProvider = new ROW_ICON_PROVIDER( indicatorSize );
412  int pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
413  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
414 
415  m_layerPanelColour = m_panelLayers->GetBackgroundColour().ChangeLightness( 110 );
416 
417  m_layersOuterSizer = new wxBoxSizer( wxVERTICAL );
418  m_windowLayers->SetSizer( m_layersOuterSizer );
419  m_windowLayers->SetScrollRate( 0, 5 );
420  m_windowLayers->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
421 
422  m_objectsOuterSizer = new wxBoxSizer( wxVERTICAL );
424  m_windowObjects->SetScrollRate( 0, 5 );
425  m_windowObjects->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
426 
427  wxFont infoFont = KIUI::GetInfoFont( this );
428  m_staticTextNets->SetFont( infoFont );
429  m_staticTextNetClasses->SetFont( infoFont );
430  m_panelLayers->SetFont( infoFont );
431  m_windowLayers->SetFont( infoFont );
432  m_windowObjects->SetFont( infoFont );
433  m_presetsLabel->SetFont( infoFont );
434 
435  createControls();
436 
439 
442 
443  m_txtNetFilter->SetHint( _( "Filter nets" ) );
444 
445  if( screenHeight <= 900 && pointSize >= indicatorSize )
446  pointSize = pointSize * 8 / 10;
447 
448  m_pointSize = pointSize;
449  wxFont font = m_notebook->GetFont();
450 
451 #ifdef __WXMAC__
452  font.SetPointSize( m_pointSize );
453  m_notebook->SetFont( font );
454 #endif
455 
456  auto setHighContrastMode =
457  [&]( HIGH_CONTRAST_MODE aMode )
458  {
460  opts.m_ContrastModeDisplay = aMode;
461 
462  m_frame->SetDisplayOptions( opts );
463  passOnFocus();
464  };
465 
466  m_rbHighContrastNormal->Bind( wxEVT_RADIOBUTTON,
467  [=]( wxCommandEvent& aEvent )
468  {
469  setHighContrastMode( HIGH_CONTRAST_MODE::NORMAL );
470  } );
471 
472  m_rbHighContrastDim->Bind( wxEVT_RADIOBUTTON,
473  [=]( wxCommandEvent& aEvent )
474  {
475  setHighContrastMode( HIGH_CONTRAST_MODE::DIMMED );
476  } );
477 
478  m_rbHighContrastOff->Bind( wxEVT_RADIOBUTTON,
479  [=]( wxCommandEvent& aEvent )
480  {
481  setHighContrastMode( HIGH_CONTRAST_MODE::HIDDEN );
482  } );
483 
484  m_cbLayerPresets->Bind( wxEVT_CHOICE, &APPEARANCE_CONTROLS::onLayerPresetChanged, this );
485 
486  m_btnNetInspector->Bind( wxEVT_BUTTON,
487  [&]( wxCommandEvent& aEvent )
488  {
490  passOnFocus();
491  } );
492 
493  m_btnConfigureNetClasses->Bind( wxEVT_BUTTON,
494  [&]( wxCommandEvent& aEvent )
495  {
496  // This panel should only be visible in the PCB_EDIT_FRAME anyway
497  if( PCB_EDIT_FRAME* editframe = dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) )
498  editframe->ShowBoardSetupDialog( _( "Net Classes" ) );
499 
500  passOnFocus();
501  } );
502 
503  m_cbFlipBoard->SetValue( m_frame->GetCanvas()->GetView()->IsMirroredX() );
504  m_cbFlipBoard->Bind( wxEVT_CHECKBOX,
505  [&]( wxCommandEvent& aEvent )
506  {
508  } );
509 
512 
513  m_netsGrid->RegisterDataType( wxT( "bool" ), m_toggleGridRenderer, new wxGridCellBoolEditor );
514 
515  // TODO(JE) Update background color of swatch renderer when theme changes
516  m_netsGrid->RegisterDataType( wxT( "COLOR4D" ),
519 
520  m_netsTable = new NET_GRID_TABLE( m_frame, m_panelNets->GetBackgroundColour() );
521  m_netsGrid->SetTable( m_netsTable, true );
523 
524  m_netsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
525  m_netsGrid->SetSelectionForeground( m_netsGrid->GetDefaultCellTextColour() );
526  m_netsGrid->SetSelectionBackground( m_panelNets->GetBackgroundColour() );
527 
528  const int cellPadding = 6;
529 #ifdef __WXMAC__
530  const int rowHeightPadding = 5;
531 #else
532  const int rowHeightPadding = 3;
533 #endif
534 
535  wxSize size = ConvertDialogToPixels( SWATCH_SIZE_SMALL_DU );
536  m_netsGrid->SetColSize( NET_GRID_TABLE::COL_COLOR, size.x + cellPadding );
537 
538  size = KiBitmap( BITMAPS::visibility ).GetSize();
539  m_netsGrid->SetColSize( NET_GRID_TABLE::COL_VISIBILITY, size.x + cellPadding );
540 
541  m_netsGrid->SetDefaultCellFont( font );
542  m_netsGrid->SetDefaultRowSize( font.GetPixelSize().y + rowHeightPadding );
543 
544  m_netsGrid->GetGridWindow()->Bind( wxEVT_MOTION, &APPEARANCE_CONTROLS::OnNetGridMouseEvent,
545  this );
546 
547  // To handle middle click on color swatches
548  m_netsGrid->GetGridWindow()->Bind( wxEVT_MIDDLE_UP, &APPEARANCE_CONTROLS::OnNetGridMouseEvent,
549  this );
550 
551  m_netsGrid->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_DEFAULT );
552  m_netclassScrolledWindow->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_DEFAULT );
553 
554  if( m_isFpEditor )
555  m_notebook->RemovePage( 2 );
556 
558  rebuildObjects();
559  OnBoardChanged();
560 
561  // Grid visibility is loaded and set to the GAL before we are constructed
563 
564  Bind( wxEVT_COMMAND_MENU_SELECTED, &APPEARANCE_CONTROLS::OnLayerContextMenu, this,
566 }
void OnNetGridMouseEvent(wxMouseEvent &aEvent)
Icon provider for the "standard" row indicators, for example in layer selection lists.
LAYER_PRESET * m_lastSelectedUserPreset
The last user (non-read-only) preset selected by the user.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
wxRadioButton * m_rbHighContrastOff
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:72
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
wxScrolledWindow * m_netclassScrolledWindow
PCB_BASE_FRAME * m_frame
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
Container for display options like enable/disable some optional drawings.
Inactive layers are dimmed (old high-contrast mode)
GRID_BITMAP_TOGGLE_RENDERER * m_toggleGridRenderer
bool IsGridVisible() const
void OnSetFocus(wxFocusEvent &aEvent) override
ROW_ICON_PROVIDER * m_iconProvider
Inactive layers are shown normally (no high-contrast mode)
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
LAYER_PRESET * m_currentPreset
wxRadioButton * m_rbHighContrastNormal
void SetPadding(int aPadding)
Set the amount of padding present on each side of the bitmap.
#define _(s)
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
wxBoxSizer * m_objectsOuterSizer
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void onLayerPresetChanged(wxCommandEvent &aEvent) override
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:238
wxRadioButton * m_rbHighContrastDim
void SetBitmap(const wxBitmap &aBmp)
Set the bitmap shown when the button is enabled.
static TOOL_ACTION listNets
Definition: pcb_actions.h:343
A toggle button renderer for a wxGrid, similar to BITMAP_TOGGLE.
NET_GRID_TABLE * m_netsTable
The main frame for Pcbnew.
APPEARANCE_CONTROLS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(215, 400), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
static const wxSize SWATCH_SIZE_SMALL_DU(8, 6)
wxBoxSizer * m_layersOuterSizer
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
Inactive layers are hidden.
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:293
void OnLayerContextMenu(wxCommandEvent &aEvent)
Return the index of the current tab (0-2).
void SetColLabelSize(int aHeight)
Hide wxGrid's SetColLabelSize() method with one which makes sure the size is tall enough for the syst...
Definition: wx_grid.cpp:53
void SetObjectVisible(GAL_LAYER_ID aLayer, bool isVisible=true)
Update the manual layer alpha overrides.

References _, NET_GRID_TABLE::COL_COLOR, NET_GRID_TABLE::COL_VISIBILITY, createControls(), DIMMED, PCB_ACTIONS::flipBoard, PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), KIUI::GetInfoFont(), TOOLS_HOLDER::GetToolManager(), PCB_DRAW_PANEL_GAL::GetView(), HIDDEN, ID_CHANGE_COLOR, ID_LAST_VALUE, EDA_DRAW_FRAME::IsGridVisible(), KIGFX::VIEW::IsMirroredX(), KiBitmap(), LAYER_GRID, list_nets_16, PCB_ACTIONS::listNets, loadDefaultLayerPresets(), APPEARANCE_CONTROLS_BASE::m_btnConfigureNetClasses, APPEARANCE_CONTROLS_BASE::m_btnNetInspector, m_cbFlipBoard, APPEARANCE_CONTROLS_BASE::m_cbLayerPresets, PCB_DISPLAY_OPTIONS::m_ContrastModeDisplay, m_frame, m_iconProvider, m_isFpEditor, m_layerPanelColour, m_layersOuterSizer, APPEARANCE_CONTROLS_BASE::m_netclassScrolledWindow, APPEARANCE_CONTROLS_BASE::m_netsGrid, m_netsTable, APPEARANCE_CONTROLS_BASE::m_notebook, m_objectsOuterSizer, APPEARANCE_CONTROLS_BASE::m_panelLayers, APPEARANCE_CONTROLS_BASE::m_panelNets, m_pointSize, APPEARANCE_CONTROLS_BASE::m_presetsLabel, m_rbHighContrastDim, m_rbHighContrastNormal, m_rbHighContrastOff, APPEARANCE_CONTROLS_BASE::m_staticTextNetClasses, APPEARANCE_CONTROLS_BASE::m_staticTextNets, m_toggleGridRenderer, APPEARANCE_CONTROLS_BASE::m_txtNetFilter, APPEARANCE_CONTROLS_BASE::m_windowLayers, APPEARANCE_CONTROLS_BASE::m_windowObjects, NORMAL, OnBoardChanged(), OnLayerContextMenu(), onLayerPresetChanged(), OnNetGridMouseEvent(), OnSetFocus(), options_generic_16, passOnFocus(), rebuildObjects(), TOOL_MANAGER::RunAction(), BITMAP_BUTTON::SetBitmap(), WX_GRID::SetColLabelSize(), PCB_BASE_FRAME::SetDisplayOptions(), SetObjectVisible(), BITMAP_BUTTON::SetPadding(), WX_GRID::SetTable(), SWATCH_SIZE_SMALL_DU(), SWATCH_SMALL, visibility, and visibility_off.

◆ ~APPEARANCE_CONTROLS()

APPEARANCE_CONTROLS::~APPEARANCE_CONTROLS ( )

Definition at line 569 of file appearance_controls.cpp.

570 {
571  delete m_iconProvider;
572 }
ROW_ICON_PROVIDER * m_iconProvider

References m_iconProvider.

Member Function Documentation

◆ ApplyLayerPreset() [1/2]

void APPEARANCE_CONTROLS::ApplyLayerPreset ( const wxString &  aPresetName)

Definition at line 1372 of file appearance_controls.cpp.

1373 {
1374  updateLayerPresetSelection( aPresetName );
1375 
1376  wxCommandEvent dummy;
1378 }
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
void onLayerPresetChanged(wxCommandEvent &aEvent) override
void updateLayerPresetSelection(const wxString &aName)

References dummy(), onLayerPresetChanged(), and updateLayerPresetSelection().

Referenced by OnLayerContextMenu(), and PCB_BASE_EDIT_FRAME::TryBefore().

◆ ApplyLayerPreset() [2/2]

void APPEARANCE_CONTROLS::ApplyLayerPreset ( const LAYER_PRESET aPreset)

Definition at line 1381 of file appearance_controls.cpp.

1382 {
1383  if( m_layerPresets.count( aPreset.name ) )
1384  m_currentPreset = &m_layerPresets[aPreset.name];
1385  else
1386  m_currentPreset = nullptr;
1387 
1389  : nullptr;
1390 
1391  updateLayerPresetSelection( aPreset.name );
1392  doApplyLayerPreset( aPreset );
1393 }
LAYER_PRESET * m_lastSelectedUserPreset
The last user (non-read-only) preset selected by the user.
wxString name
A name for this layer set.
bool readOnly
True if this is a read-only (built-in) preset.
std::map< wxString, LAYER_PRESET > m_layerPresets
void doApplyLayerPreset(const LAYER_PRESET &aPreset)
LAYER_PRESET * m_currentPreset
void updateLayerPresetSelection(const wxString &aName)

References doApplyLayerPreset(), m_currentPreset, m_lastSelectedUserPreset, m_layerPresets, LAYER_PRESET::name, LAYER_PRESET::readOnly, and updateLayerPresetSelection().

◆ createControls()

void APPEARANCE_CONTROLS::createControls ( )
private

Definition at line 575 of file appearance_controls.cpp.

576 {
577  int hotkey;
578  wxString msg;
579  wxFont infoFont = KIUI::GetInfoFont( this );
580 
581  // Create layer display options
583  _( "Layer Display Options" ) );
585  m_paneLayerDisplayOptions->SetBackgroundColour( m_notebook->GetThemeBackgroundColour() );
586 
587  wxWindow* layerDisplayPane = m_paneLayerDisplayOptions->GetPane();
588 
589  wxBoxSizer* layerDisplayOptionsSizer;
590  layerDisplayOptionsSizer = new wxBoxSizer( wxVERTICAL );
591 
593 
594  if( hotkey )
595  msg = wxString::Format( _( "Inactive layers (%s):" ), KeyNameFromKeyCode( hotkey ) );
596  else
597  msg = _( "Inactive layers:" );
598 
599  m_inactiveLayersLabel = new wxStaticText( layerDisplayPane, wxID_ANY, msg );
600  m_inactiveLayersLabel->SetFont( infoFont );
601  m_inactiveLayersLabel->Wrap( -1 );
602  layerDisplayOptionsSizer->Add( m_inactiveLayersLabel, 0, wxEXPAND | wxBOTTOM | wxLEFT, 2 );
603 
604  wxBoxSizer* contrastModeSizer;
605  contrastModeSizer = new wxBoxSizer( wxHORIZONTAL );
606 
607  m_rbHighContrastNormal = new wxRadioButton( layerDisplayPane, wxID_ANY, _( "Normal" ),
608  wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
609  m_rbHighContrastNormal->SetFont( infoFont );
610  m_rbHighContrastNormal->SetValue( true );
611  m_rbHighContrastNormal->SetToolTip( _( "Inactive layers will be shown in full color" ) );
612 
613  contrastModeSizer->Add( m_rbHighContrastNormal, 0, wxRIGHT, 5 );
614  contrastModeSizer->AddStretchSpacer();
615 
616  m_rbHighContrastDim = new wxRadioButton( layerDisplayPane, wxID_ANY, _( "Dim" ) );
617  m_rbHighContrastDim->SetFont( infoFont );
618  m_rbHighContrastDim->SetToolTip( _( "Inactive layers will be dimmed" ) );
619 
620  contrastModeSizer->Add( m_rbHighContrastDim, 0, wxRIGHT, 5 );
621  contrastModeSizer->AddStretchSpacer();
622 
623  m_rbHighContrastOff = new wxRadioButton( layerDisplayPane, wxID_ANY, _( "Hide" ) );
624  m_rbHighContrastOff->SetFont( infoFont );
625  m_rbHighContrastOff->SetToolTip( _( "Inactive layers will be hidden" ) );
626 
627  contrastModeSizer->Add( m_rbHighContrastOff, 0, 0, 5 );
628  contrastModeSizer->AddStretchSpacer();
629 
630  layerDisplayOptionsSizer->Add( contrastModeSizer, 0, wxEXPAND, 5 );
631 
632  m_layerDisplaySeparator = new wxStaticLine( layerDisplayPane, wxID_ANY, wxDefaultPosition,
633  wxDefaultSize, wxLI_HORIZONTAL );
634  layerDisplayOptionsSizer->Add( m_layerDisplaySeparator, 0, wxEXPAND | wxTOP | wxBOTTOM, 5 );
635 
636  m_cbFlipBoard = new wxCheckBox( layerDisplayPane, wxID_ANY, _( "Flip board view" ) );
637  m_cbFlipBoard->SetFont( infoFont );
638  layerDisplayOptionsSizer->Add( m_cbFlipBoard, 0, 0, 5 );
639 
640  layerDisplayPane->SetSizer( layerDisplayOptionsSizer );
641  layerDisplayPane->Layout();
642  layerDisplayOptionsSizer->Fit( layerDisplayPane );
643 
644  m_panelLayersSizer->Add( m_paneLayerDisplayOptions, 0, wxEXPAND | wxTOP, 5 );
645 
646  m_paneLayerDisplayOptions->Bind( WX_COLLAPSIBLE_PANE_CHANGED,
647  [&]( wxCommandEvent& aEvent )
648  {
649  Freeze();
650  m_panelLayers->Fit();
651  m_sizerOuter->Layout();
652  Thaw();
653  } );
654 
655  // Create net display options
656 
658  _( "Net Display Options" ) );
660  m_paneNetDisplayOptions->SetBackgroundColour( m_notebook->GetThemeBackgroundColour() );
661 
662  wxWindow* netDisplayPane = m_paneNetDisplayOptions->GetPane();
663  wxBoxSizer* netDisplayOptionsSizer = new wxBoxSizer( wxVERTICAL );
664 
666 
668 
669  if( hotkey )
670  msg = wxString::Format( _( "Net colors (%s):" ), KeyNameFromKeyCode( hotkey ) );
671  else
672  msg = _( "Net colors:" );
673 
674  m_txtNetDisplayTitle = new wxStaticText( netDisplayPane, wxID_ANY, msg );
675  m_txtNetDisplayTitle->SetFont( infoFont );
676  m_txtNetDisplayTitle->Wrap( -1 );
677  m_txtNetDisplayTitle->SetToolTip( _( "Choose when to show net and netclass colors" ) );
678 
679  netDisplayOptionsSizer->Add( m_txtNetDisplayTitle, 0, wxEXPAND | wxBOTTOM | wxLEFT, 2 );
680 
681  wxBoxSizer* netColorSizer = new wxBoxSizer( wxHORIZONTAL );
682 
683  m_rbNetColorAll = new wxRadioButton( netDisplayPane, wxID_ANY, _( "All" ), wxDefaultPosition,
684  wxDefaultSize, wxRB_GROUP );
685  m_rbNetColorAll->SetFont( infoFont );
686  m_rbNetColorAll->SetToolTip( _( "Net and netclass colors are shown on all copper items" ) );
687 
688  netColorSizer->Add( m_rbNetColorAll, 0, wxRIGHT, 5 );
689  netColorSizer->AddStretchSpacer();
690 
691  m_rbNetColorRatsnest = new wxRadioButton( netDisplayPane, wxID_ANY, _( "Ratsnest" ) );
692  m_rbNetColorRatsnest->SetFont( infoFont );
693  m_rbNetColorRatsnest->SetValue( true );
694  m_rbNetColorRatsnest->SetToolTip( _( "Net and netclass colors are shown on the ratsnest only" ) );
695 
696  netColorSizer->Add( m_rbNetColorRatsnest, 0, wxRIGHT, 5 );
697  netColorSizer->AddStretchSpacer();
698 
699  m_rbNetColorOff = new wxRadioButton( netDisplayPane, wxID_ANY, _( "None" ) );
700  m_rbNetColorOff->SetFont( infoFont );
701  m_rbNetColorOff->SetToolTip( _( "Net and netclass colors are not shown" ) );
702 
703  netColorSizer->Add( m_rbNetColorOff, 0, 0, 5 );
704 
705  netDisplayOptionsSizer->Add( netColorSizer, 0, wxEXPAND | wxBOTTOM, 5 );
706 
708 
710 
711  if( hotkey )
712  msg = wxString::Format( _( "Ratsnest display (%s):" ), KeyNameFromKeyCode( hotkey ) );
713  else
714  msg = _( "Ratsnest display:" );
715 
716  m_txtRatsnestVisibility = new wxStaticText( netDisplayPane, wxID_ANY, msg );
717  m_txtRatsnestVisibility->SetFont( infoFont );
718  m_txtRatsnestVisibility->Wrap( -1 );
719  m_txtRatsnestVisibility->SetToolTip( _( "Choose which ratsnest lines to display" ) );
720 
721  netDisplayOptionsSizer->Add( m_txtRatsnestVisibility, 0, wxEXPAND | wxBOTTOM | wxLEFT, 2 );
722 
723  wxBoxSizer* ratsnestDisplayModeSizer = new wxBoxSizer( wxHORIZONTAL );
724 
725  m_rbRatsnestAllLayers = new wxRadioButton( netDisplayPane, wxID_ANY, _( "All" ),
726  wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
727  m_rbRatsnestAllLayers->SetFont( infoFont );
728  m_rbRatsnestAllLayers->SetValue( true );
729  m_rbRatsnestAllLayers->SetToolTip( _( "Show ratsnest lines to items on all layers" ) );
730 
731  ratsnestDisplayModeSizer->Add( m_rbRatsnestAllLayers, 0, wxRIGHT, 5 );
732  ratsnestDisplayModeSizer->AddStretchSpacer();
733 
734  m_rbRatsnestVisLayers = new wxRadioButton( netDisplayPane, wxID_ANY, _( "Visible layers" ) );
735  m_rbRatsnestVisLayers->SetFont( infoFont );
736  m_rbRatsnestVisLayers->SetToolTip( _( "Show ratsnest lines to items on visible layers" ) );
737 
738  ratsnestDisplayModeSizer->Add( m_rbRatsnestVisLayers, 0, wxRIGHT, 5 );
739  ratsnestDisplayModeSizer->AddStretchSpacer();
740 
741  m_rbRatsnestNone = new wxRadioButton( netDisplayPane, wxID_ANY, _( "None" ) );
742  m_rbRatsnestNone->SetFont( infoFont );
743  m_rbRatsnestNone->SetToolTip( _( "Hide all ratsnest lines" ) );
744 
745  ratsnestDisplayModeSizer->Add( m_rbRatsnestNone, 0, 0, 5 );
746 
747  netDisplayOptionsSizer->Add( ratsnestDisplayModeSizer, 0, wxEXPAND | wxBOTTOM, 5 );
748 
750 
751  netDisplayPane->SetSizer( netDisplayOptionsSizer );
752  netDisplayPane->Layout();
753  netDisplayOptionsSizer->Fit( netDisplayPane );
754 
755  m_netsTabOuterSizer->Add( m_paneNetDisplayOptions, 0, wxEXPAND | wxTOP, 5 );
756 
757  m_paneNetDisplayOptions->Bind( WX_COLLAPSIBLE_PANE_CHANGED,
758  [&]( wxCommandEvent& aEvent )
759  {
760  Freeze();
761  m_panelNetsAndClasses->Fit();
762  m_sizerOuter->Layout();
763  passOnFocus();
764  Thaw();
765  } );
766 
767  m_rbNetColorAll->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onNetColorMode, this );
768  m_rbNetColorOff->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onNetColorMode, this );
769  m_rbNetColorRatsnest->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onNetColorMode, this );
770 
771  m_rbRatsnestAllLayers->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onRatsnestMode, this );
772  m_rbRatsnestVisLayers->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onRatsnestMode, this );
773  m_rbRatsnestNone->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onRatsnestMode, this );
774 }
bool SetBackgroundColour(const wxColour &aColor) override
WX_COLLAPSIBLE_PANE * m_paneLayerDisplayOptions
void onNetColorMode(wxCommandEvent &aEvent)
void onRatsnestMode(wxCommandEvent &aEvent)
wxRadioButton * m_rbNetColorOff
wxStaticLine * m_layerDisplaySeparator
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
wxRadioButton * m_rbRatsnestAllLayers
wxRadioButton * m_rbHighContrastOff
wxRadioButton * m_rbHighContrastNormal
wxStaticText * m_txtNetDisplayTitle
#define _(s)
wxRadioButton * m_rbHighContrastDim
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxStaticText * m_inactiveLayersLabel
wxRadioButton * m_rbRatsnestNone
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:104
static TOOL_ACTION ratsnestModeCycle
Definition: pcb_actions.h:241
void Collapse(bool aCollapse=true)
wxStaticText * m_txtRatsnestVisibility
A better wxCollapsiblePane that.
int GetHotKey() const
Return the hotkey keycode which initiates the action.
Definition: tool_action.h:111
static TOOL_ACTION netColorModeCycle
Definition: pcb_actions.h:240
WX_COLLAPSIBLE_PANE * m_paneNetDisplayOptions
wxRadioButton * m_rbNetColorRatsnest
wxRadioButton * m_rbNetColorAll
wxRadioButton * m_rbRatsnestVisLayers

References _, WX_COLLAPSIBLE_PANE::Collapse(), Format(), TOOL_ACTION::GetHotKey(), KIUI::GetInfoFont(), WX_COLLAPSIBLE_PANE::GetPane(), ACTIONS::highContrastModeCycle, KeyNameFromKeyCode(), m_cbFlipBoard, m_inactiveLayersLabel, m_layerDisplaySeparator, APPEARANCE_CONTROLS_BASE::m_netsTabOuterSizer, APPEARANCE_CONTROLS_BASE::m_notebook, m_paneLayerDisplayOptions, APPEARANCE_CONTROLS_BASE::m_panelLayers, APPEARANCE_CONTROLS_BASE::m_panelLayersSizer, APPEARANCE_CONTROLS_BASE::m_panelNetsAndClasses, m_paneNetDisplayOptions, m_rbHighContrastDim, m_rbHighContrastNormal, m_rbHighContrastOff, m_rbNetColorAll, m_rbNetColorOff, m_rbNetColorRatsnest, m_rbRatsnestAllLayers, m_rbRatsnestNone, m_rbRatsnestVisLayers, APPEARANCE_CONTROLS_BASE::m_sizerOuter, m_txtNetDisplayTitle, m_txtRatsnestVisibility, PCB_ACTIONS::netColorModeCycle, onNetColorMode(), onRatsnestMode(), passOnFocus(), PCB_ACTIONS::ratsnestModeCycle, and WX_COLLAPSIBLE_PANE::SetBackgroundColour().

Referenced by APPEARANCE_CONTROLS().

◆ doApplyLayerPreset()

void APPEARANCE_CONTROLS::doApplyLayerPreset ( const LAYER_PRESET aPreset)
private

Definition at line 2513 of file appearance_controls.cpp.

2514 {
2515  BOARD* board = m_frame->GetBoard();
2516 
2517  setVisibleLayers( aPreset.layers );
2518  setVisibleObjects( aPreset.renderLayers );
2519 
2520  // If the preset doesn't have an explicit active layer to restore, we can at least
2521  // force the active layer to be something in the preset's layer set
2522  PCB_LAYER_ID activeLayer = UNSELECTED_LAYER;
2523 
2524  if( aPreset.activeLayer != UNSELECTED_LAYER )
2525  activeLayer = aPreset.activeLayer;
2526  else if( aPreset.layers.any() && !aPreset.layers.test( m_frame->GetActiveLayer() ) )
2527  activeLayer = *aPreset.layers.Seq().begin();
2528 
2529  LSET boardLayers = board->GetLayerSet();
2530 
2531  if( activeLayer != UNSELECTED_LAYER && boardLayers.Contains( activeLayer ) )
2532  m_frame->SetActiveLayer( activeLayer );
2533 
2534  if( !m_isFpEditor )
2535  m_frame->GetCanvas()->SyncLayersVisibility( board );
2536 
2537  m_frame->GetCanvas()->Refresh();
2538 
2540 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: layer_ids.h:575
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
GAL_SET renderLayers
Render layers (e.g. object types) that are visible.
PCB_LAYER_ID activeLayer
Optional layer to set active when this preset is loaded.
PCB_BASE_FRAME * m_frame
virtual PCB_LAYER_ID GetActiveLayer() const
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
void setVisibleLayers(LSET aLayers)
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
LSET layers
Board layers that are visible.
void SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void setVisibleObjects(GAL_SET aObjects)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
BOARD * GetBoard() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:145

References LAYER_PRESET::activeLayer, LSET::Contains(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD_ITEM::GetLayerSet(), LAYER_PRESET::layers, m_frame, m_isFpEditor, EDA_DRAW_PANEL_GAL::Refresh(), LAYER_PRESET::renderLayers, LSET::Seq(), PCB_BASE_FRAME::SetActiveLayer(), setVisibleLayers(), setVisibleObjects(), syncColorsAndVisibility(), PCB_DRAW_PANEL_GAL::SyncLayersVisibility(), and UNSELECTED_LAYER.

Referenced by ApplyLayerPreset(), and onLayerPresetChanged().

◆ doesBoardItemNeedRebuild() [1/2]

bool APPEARANCE_CONTROLS::doesBoardItemNeedRebuild ( BOARD_ITEM aBoardItem)
private

Definition at line 1016 of file appearance_controls.cpp.

1017 {
1018  return aBoardItem->Type() == PCB_NETINFO_T;
1019 }
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:107
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References PCB_NETINFO_T, and EDA_ITEM::Type().

Referenced by OnBoardItemAdded(), OnBoardItemChanged(), OnBoardItemRemoved(), OnBoardItemsAdded(), OnBoardItemsChanged(), and OnBoardItemsRemoved().

◆ doesBoardItemNeedRebuild() [2/2]

bool APPEARANCE_CONTROLS::doesBoardItemNeedRebuild ( std::vector< BOARD_ITEM * > &  aBoardItems)
private

Definition at line 1022 of file appearance_controls.cpp.

1023 {
1024  bool rebuild = std::any_of( aBoardItems.begin(), aBoardItems.end(),
1025  []( const BOARD_ITEM* a )
1026  {
1027  return a->Type() == PCB_NETINFO_T;
1028  } );
1029 
1030  return rebuild;
1031 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:107

References PCB_NETINFO_T.

◆ GetActiveLayerPreset()

wxString APPEARANCE_CONTROLS::GetActiveLayerPreset ( ) const
inline

Definition at line 250 of file appearance_controls.h.

251  {
252  if( m_currentPreset )
253  return m_currentPreset->name;
254  else
255  return wxEmptyString;
256  }
wxString name
A name for this layer set.
LAYER_PRESET * m_currentPreset

References m_currentPreset, and LAYER_PRESET::name.

Referenced by PCB_EDIT_FRAME::SaveProjectSettings(), and FOOTPRINT_EDIT_FRAME::SaveSettings().

◆ GetBestSize()

wxSize APPEARANCE_CONTROLS::GetBestSize ( ) const

Update the panel contents from the application and board models.

Definition at line 777 of file appearance_controls.cpp.

778 {
779  wxSize size( 220, 480 );
780  // TODO(JE) appropriate logic
781  return size;
782 }

◆ GetLayerPresetsMRU()

const wxArrayString& APPEARANCE_CONTROLS::GetLayerPresetsMRU ( )
inline

Definition at line 258 of file appearance_controls.h.

259  {
260  return m_presetMRU;
261  }

References m_presetMRU.

Referenced by PCB_BASE_EDIT_FRAME::TryBefore().

◆ GetTabIndex()

int APPEARANCE_CONTROLS::GetTabIndex ( ) const

Set the current notebook tab.

Definition at line 1804 of file appearance_controls.cpp.

1805 {
1806  return m_notebook->GetSelection();
1807 }

References APPEARANCE_CONTROLS_BASE::m_notebook.

◆ GetUserLayerPresets()

std::vector< LAYER_PRESET > APPEARANCE_CONTROLS::GetUserLayerPresets ( ) const

Update the current layer presets from those saved in the project file.

Definition at line 1321 of file appearance_controls.cpp.

1322 {
1323  std::vector<LAYER_PRESET> ret;
1324 
1325  for( const std::pair<const wxString, LAYER_PRESET>& pair : m_layerPresets )
1326  {
1327  if( !pair.second.readOnly )
1328  ret.emplace_back( pair.second );
1329  }
1330 
1331  return ret;
1332 }
std::map< wxString, LAYER_PRESET > m_layerPresets

References m_layerPresets.

Referenced by PCB_EDIT_FRAME::SaveProjectSettings(), and FOOTPRINT_EDIT_FRAME::SaveSettings().

◆ getVisibleLayers()

LSET APPEARANCE_CONTROLS::getVisibleLayers ( )
private

Definition at line 1206 of file appearance_controls.cpp.

1207 {
1208  if( m_isFpEditor )
1209  {
1210  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1211  LSET set;
1212 
1213  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1214  set.set( layer, view->IsLayerVisible( layer ) );
1215 
1216  return set;
1217  }
1218  else
1219  {
1220  return m_frame->GetBoard()->GetVisibleLayers();
1221  }
1222 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:481
PCB_BASE_FRAME * m_frame
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
static LSET AllLayersMask()
Definition: lset.cpp:787
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:405

References LSET::AllLayersMask(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), BOARD::GetVisibleLayers(), KIGFX::VIEW::IsLayerVisible(), m_frame, and m_isFpEditor.

Referenced by OnLayerContextMenu(), onLayerPresetChanged(), onLayerVisibilityChanged(), rebuildLayers(), SetLayerVisible(), syncColorsAndVisibility(), and syncLayerPresetSelection().

◆ getVisibleObjects()

GAL_SET APPEARANCE_CONTROLS::getVisibleObjects ( )
private

Definition at line 1225 of file appearance_controls.cpp.

1226 {
1227  if( m_isFpEditor )
1228  {
1229  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1230  GAL_SET set;
1231  set.reset();
1232 
1233  for( size_t i = 0; i < set.size(); i++ )
1234  set.set( i, view->IsLayerVisible( GAL_LAYER_ID_START + GAL_LAYER_ID( i ) ) );
1235 
1236  return set;
1237  }
1238  else
1239  {
1240  return m_frame->GetBoard()->GetVisibleElements();
1241  }
1242 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:185
PCB_BASE_FRAME * m_frame
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition: board.cpp:527
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:279
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
GAL_SET & set()
Definition: layer_ids.h:295
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:405

References GAL_LAYER_ID_START, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), BOARD::GetVisibleElements(), KIGFX::VIEW::IsLayerVisible(), m_frame, m_isFpEditor, and GAL_SET::set().

Referenced by onLayerPresetChanged(), onObjectVisibilityChanged(), rebuildObjects(), syncColorsAndVisibility(), syncLayerPresetSelection(), and syncObjectSettings().

◆ handleBoardItemsChanged()

void APPEARANCE_CONTROLS::handleBoardItemsChanged ( )
private

◆ idleFocusHandler()

void APPEARANCE_CONTROLS::idleFocusHandler ( wxIdleEvent &  aEvent)
private

Definition at line 809 of file appearance_controls.cpp.

810 {
811  passOnFocus();
812  Unbind( wxEVT_IDLE, &APPEARANCE_CONTROLS::idleFocusHandler, this );
813 }
void idleFocusHandler(wxIdleEvent &aEvent)

References passOnFocus().

Referenced by OnNotebookPageChanged().

◆ loadDefaultLayerPresets()

void APPEARANCE_CONTROLS::loadDefaultLayerPresets ( )
private

Definition at line 1354 of file appearance_controls.cpp.

1355 {
1356  m_layerPresets.clear();
1357  m_presetMRU.clear();
1358 
1359  // Load the read-only defaults
1362  presetBackAssembly } )
1363  {
1364  m_layerPresets[preset.name] = preset;
1365  m_layerPresets[preset.name].readOnly = true;
1366 
1367  m_presetMRU.Add( preset.name );
1368  }
1369 }
static LAYER_PRESET presetFrontAssembly
A saved set of layers that are visible.
std::map< wxString, LAYER_PRESET > m_layerPresets
static LAYER_PRESET presetInnerCopper
static LAYER_PRESET presetBackAssembly
static LAYER_PRESET presetFront
static LAYER_PRESET presetAllCopper
static LAYER_PRESET presetAllLayers
static LAYER_PRESET presetBack

References m_layerPresets, m_presetMRU, presetAllCopper, presetAllLayers, presetBack, presetBackAssembly, presetFront, presetFrontAssembly, and presetInnerCopper.

Referenced by APPEARANCE_CONTROLS(), and SetUserLayerPresets().

◆ m_netsTabSplitterOnIdle()

void APPEARANCE_CONTROLS_BASE::m_netsTabSplitterOnIdle ( wxIdleEvent &  )
inlineinherited

Definition at line 84 of file appearance_controls_base.h.

85  {
86  m_netsTabSplitter->SetSashPosition( 300 );
87  m_netsTabSplitter->Disconnect( wxEVT_IDLE, wxIdleEventHandler( APPEARANCE_CONTROLS_BASE::m_netsTabSplitterOnIdle ), NULL, this );
88  }
wxSplitterWindow * m_netsTabSplitter
void m_netsTabSplitterOnIdle(wxIdleEvent &)

References APPEARANCE_CONTROLS_BASE::m_netsTabSplitter.

Referenced by APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE().

◆ netclassNameFromEvent()

wxString APPEARANCE_CONTROLS::netclassNameFromEvent ( wxEvent &  aEvent)
private

Definition at line 2730 of file appearance_controls.cpp.

2731 {
2732  COLOR_SWATCH* s = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2733  int classId = s->GetId();
2734 
2735  wxASSERT( m_netclassIdMap.count( classId ) );
2736  return m_netclassIdMap.at( classId );
2737 }
std::map< int, wxString > m_netclassIdMap
Stores wxIDs for each netclass for control event mapping.
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:56

References m_netclassIdMap.

Referenced by onNetclassColorChanged(), and onNetclassVisibilityChanged().

◆ OnBoardChanged()

void APPEARANCE_CONTROLS::OnBoardChanged ( )

Definition at line 975 of file appearance_controls.cpp.

976 {
977  Freeze();
978  rebuildLayers();
982  rebuildNets();
985 
987 
988  m_board = m_frame->GetBoard();
989 
990  if( m_board )
991  m_board->AddListener( this );
992 
993  Thaw();
994  Refresh();
995 }
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
Definition: board.cpp:1960
PCB_BASE_FRAME * m_frame
void UpdateDisplayOptions()
Return a list of the layer presets created by the user.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
BOARD * GetBoard() const

References BOARD::AddListener(), PCB_BASE_FRAME::GetBoard(), m_board, m_frame, rebuildLayerContextMenu(), rebuildLayerPresetsWidget(), rebuildLayers(), rebuildNets(), Refresh(), syncColorsAndVisibility(), syncLayerPresetSelection(), syncObjectSettings(), and UpdateDisplayOptions().

Referenced by APPEARANCE_CONTROLS(), PCB_EDIT_FRAME::Clear_Pcb(), FOOTPRINT_EDIT_FRAME::ShowChangedLanguage(), and FOOTPRINT_EDIT_FRAME::UpdateUserInterface().

◆ OnBoardHighlightNetChanged()

virtual void BOARD_LISTENER::OnBoardHighlightNetChanged ( BOARD aBoard)
inlinevirtualinherited

Reimplemented in DIALOG_NET_INSPECTOR.

Definition at line 173 of file board.h.

173 { }

Referenced by BOARD::HighLightON(), BOARD::ResetNetHighLight(), and BOARD::SetHighLightNet().

◆ OnBoardItemAdded()

void APPEARANCE_CONTROLS::OnBoardItemAdded ( BOARD aBoard,
BOARD_ITEM aItem 
)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 1034 of file appearance_controls.cpp.

1035 {
1036  if( doesBoardItemNeedRebuild( aItem ) )
1038 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemChanged()

void APPEARANCE_CONTROLS::OnBoardItemChanged ( BOARD aBoard,
BOARD_ITEM aItem 
)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 1062 of file appearance_controls.cpp.

1063 {
1064  if( doesBoardItemNeedRebuild( aItem ) )
1066 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemRemoved()

void APPEARANCE_CONTROLS::OnBoardItemRemoved ( BOARD aBoard,
BOARD_ITEM aItem 
)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 1048 of file appearance_controls.cpp.

1049 {
1050  if( doesBoardItemNeedRebuild( aItem ) )
1052 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemsAdded()

void APPEARANCE_CONTROLS::OnBoardItemsAdded ( BOARD aBoard,
std::vector< BOARD_ITEM * > &  aItems 
)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 1041 of file appearance_controls.cpp.

1042 {
1043  if( doesBoardItemNeedRebuild( aItems ) )
1045 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemsChanged()

void APPEARANCE_CONTROLS::OnBoardItemsChanged ( BOARD aBoard,
std::vector< BOARD_ITEM * > &  aItems 
)
overridevirtual

Update the colors on all the widgets from the new chosen color theme.

Reimplemented from BOARD_LISTENER.

Definition at line 1069 of file appearance_controls.cpp.

1070 {
1071  if( doesBoardItemNeedRebuild( aItems ) )
1073 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemsRemoved()

void APPEARANCE_CONTROLS::OnBoardItemsRemoved ( BOARD aBoard,
std::vector< BOARD_ITEM * > &  aItems 
)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 1055 of file appearance_controls.cpp.

1056 {
1057  if( doesBoardItemNeedRebuild( aItems ) )
1059 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardNetSettingsChanged()

void APPEARANCE_CONTROLS::OnBoardNetSettingsChanged ( BOARD aBoard)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 998 of file appearance_controls.cpp.

999 {
1001 }

References handleBoardItemsChanged().

◆ OnColorSwatchChanged()

void APPEARANCE_CONTROLS::OnColorSwatchChanged ( wxCommandEvent &  aEvent)

Definition at line 2543 of file appearance_controls.cpp.

2544 {
2545  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2546  COLOR4D newColor = swatch->GetSwatchColor();
2547  LAYER_NUM layer = swatch->GetId();
2548 
2550  cs->SetColor( layer, newColor );
2551 
2553 
2554  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
2555  view->UpdateLayerColor( layer );
2556  view->UpdateLayerColor( GetNetnameLayer( layer ) );
2557 
2558  if( IsCopperLayer( layer ) )
2559  view->UpdateLayerColor( ZONE_LAYER_FOR( layer ) );
2560 
2561  // Update the bitmap of the layer box
2562  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
2563  static_cast<PCB_EDIT_FRAME*>( m_frame )->ReCreateLayerBox( false );
2564 
2565  m_frame->GetCanvas()->Refresh();
2566 
2567  if( layer == LAYER_PCB_BACKGROUND )
2568  m_frame->SetDrawBgColor( newColor );
2569 
2570  passOnFocus();
2571 }
void SetDrawBgColor(const COLOR4D &aColor) override
KIGFX::COLOR4D GetSwatchColor() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
void SetColor(int aLayer, const COLOR4D &aColor)
#define ZONE_LAYER_FOR(copperLayer)
Macro for getting the zone layer for a given copper layer.
Definition: layer_ids.h:252
PCB_BASE_FRAME * m_frame
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:941
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:796
void UpdateColors()
Update the color settings in the painter and GAL.
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:745
bool IsType(FRAME_T aType) const
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:56
PCB background color.
Definition: layer_ids.h:216
Color settings are a bit different than most of the settings objects in that there can be more than o...
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References FRAME_PCB_EDITOR, PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetColorSettings(), GetNetnameLayer(), COLOR_SWATCH::GetSwatchColor(), PCB_DRAW_PANEL_GAL::GetView(), IsCopperLayer(), EDA_BASE_FRAME::IsType(), LAYER_PCB_BACKGROUND, m_frame, passOnFocus(), EDA_DRAW_PANEL_GAL::Refresh(), COLOR_SETTINGS::SetColor(), PCB_BASE_FRAME::SetDrawBgColor(), PCB_DRAW_PANEL_GAL::UpdateColors(), KIGFX::VIEW::UpdateLayerColor(), and ZONE_LAYER_FOR.

Referenced by rebuildLayers(), and rebuildObjects().

◆ OnColorThemeChanged()

void APPEARANCE_CONTROLS::OnColorThemeChanged ( )

Update the widget when the active board layer is changed.

Definition at line 1084 of file appearance_controls.cpp.

References syncColorsAndVisibility(), and syncObjectSettings().

◆ OnLayerAlphaChanged()

void APPEARANCE_CONTROLS::OnLayerAlphaChanged ( )

Definition at line 1245 of file appearance_controls.cpp.

1246 {
1247  // TODO(JE) Is this even needed if the layer alphas are getting directly updated?
1248  // Maybe we just need the "down" arrow to indicate if the alpha is below 1
1249 
1250 #if 0
1251  static constexpr double alphaEpsilon = 0.04;
1252 
1253  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1255  KIGFX::PCB_PAINTER* painter =
1256  static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetCanvas()->GetView()->GetPainter() );
1257  KIGFX::PCB_RENDER_SETTINGS* rs = painter->GetSettings();
1258 
1259  for( APPEARANCE_SETTING& setting : m_layerSettings )
1260  {
1261  if( !setting.ctl_indicator )
1262  continue;
1263 
1264  COLOR4D layerColor = theme->GetColor( setting.id );
1265  COLOR4D screenColor = rs->GetLayerColor( setting.id );
1266 
1267  if( std::abs( screenColor.a - layerColor.a ) > alphaEpsilon )
1268  {
1269  if( screenColor.a < layerColor.a )
1270  setting.ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
1271  else
1272  setting.ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
1273  }
1274  else
1275  {
1276  setting.ctl_indicator->SetIndicatorState( setting.id == current ?
1278  ROW_ICON_PROVIDER::STATE::OFF );
1279  }
1280  }
1281 #endif
1282 }
#define ON
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_layerSettings
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:241
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
PCB_BASE_FRAME * m_frame
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
virtual PCB_LAYER_ID GetActiveLayer() const
PCB specific render settings.
Definition: pcb_painter.h:64
double a
Alpha component.
Definition: color4d.h:380
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:247
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
COLOR4D GetColor(int aLayer) const
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Color settings are a bit different than most of the settings objects in that there can be more than o...
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References KIGFX::COLOR4D::a, PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), KIGFX::VIEW::GetPainter(), KIGFX::PCB_PAINTER::GetSettings(), PCB_DRAW_PANEL_GAL::GetView(), m_frame, m_layerSettings, and ON.

Referenced by PCB_BASE_EDIT_FRAME::OnLayerAlphaChanged().

◆ OnLayerChanged()

void APPEARANCE_CONTROLS::OnLayerChanged ( )

Definition at line 1091 of file appearance_controls.cpp.

1092 {
1093  for( const std::unique_ptr<APPEARANCE_SETTING>& setting : m_layerSettings )
1094  {
1095  setting->ctl_panel->SetBackgroundColour( m_layerPanelColour );
1096  setting->ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );
1097  }
1098 
1099  wxChar r, g, b;
1100 
1101  r = m_layerPanelColour.Red();
1102  g = m_layerPanelColour.Green();
1103  b = m_layerPanelColour.Blue();
1104 
1105  if( r < 240 || g < 240 || b < 240 )
1106  {
1107  r = wxChar( std::min( (int) r + 15, 255 ) );
1108  g = wxChar( std::min( (int) g + 15, 255 ) );
1109  b = wxChar( std::min( (int) b + 15, 255 ) );
1110  }
1111  else
1112  {
1113  r = wxChar( std::max( (int) r - 15, 0 ) );
1114  g = wxChar( std::max( (int) g - 15, 0 ) );
1115  b = wxChar( std::max( (int) b - 15, 0 ) );
1116  }
1117 
1118  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1119 
1120  if( !m_layerSettingsMap.count( current ) )
1121  {
1122  wxASSERT( m_layerSettingsMap.count( F_Cu ) );
1123  current = F_Cu;
1124  }
1125 
1126  APPEARANCE_SETTING* newSetting = m_layerSettingsMap[ current ];
1127 
1128  newSetting->ctl_panel->SetBackgroundColour( wxColour( r, g, b ) );
1129  newSetting->ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::ON );
1130 
1131  Refresh();
1132 }
std::map< PCB_LAYER_ID, APPEARANCE_SETTING * > m_layerSettingsMap
#define ON
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_layerSettings
PCB_BASE_FRAME * m_frame
virtual PCB_LAYER_ID GetActiveLayer() const
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
E_SERIE r
Definition: eserie.cpp:41
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71

References APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_indicator, APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_panel, F_Cu, PCB_BASE_FRAME::GetActiveLayer(), m_frame, m_layerPanelColour, m_layerSettings, m_layerSettingsMap, ON, r, Refresh(), and INDICATOR_ICON::SetIndicatorState().

Referenced by syncColorsAndVisibility().

◆ OnLayerContextMenu()

void APPEARANCE_CONTROLS::OnLayerContextMenu ( wxCommandEvent &  aEvent)

Return the index of the current tab (0-2).

Definition at line 1714 of file appearance_controls.cpp.

1715 {
1716  BOARD* board = m_frame->GetBoard();
1717  LSET visible = getVisibleLayers();
1718 
1719  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1720 
1721  switch( aEvent.GetId() )
1722  {
1723  case ID_PRESET_NO_LAYERS:
1725  return;
1726 
1727  case ID_PRESET_ALL_LAYERS:
1729  return;
1730 
1732  {
1733  visible |= presetAllCopper.layers;
1734  setVisibleLayers( visible );
1735  break;
1736  }
1737 
1740  SetLayerVisible( current, true );
1741  break;
1742 
1744  {
1745  visible &= ~presetAllCopper.layers;
1746 
1747  if( !visible.test( current ) )
1748  m_frame->SetActiveLayer( *visible.Seq().begin() );
1749 
1750  setVisibleLayers( visible );
1751  break;
1752  }
1753 
1755  {
1756  visible &= presetAllCopper.layers;
1757 
1758  if( !visible.test( current ) )
1759  m_frame->SetActiveLayer( *visible.Seq().begin() );
1760 
1761  setVisibleLayers( visible );
1762  break;
1763  }
1764 
1766  {
1767  visible |= ~presetAllCopper.layers;
1768 
1769  setVisibleLayers( visible );
1770  break;
1771  }
1772 
1775  return;
1776 
1777  case ID_PRESET_FRONT:
1779  return;
1780 
1783  return;
1784 
1785  case ID_PRESET_BACK:
1787  return;
1788 
1791  return;
1792  }
1793 
1796 
1797  if( !m_isFpEditor )
1798  m_frame->GetCanvas()->SyncLayersVisibility( board );
1799 
1800  m_frame->GetCanvas()->Refresh();
1801 }
static LAYER_PRESET presetFrontAssembly
void ApplyLayerPreset(const wxString &aPresetName)
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
PCB_BASE_FRAME * m_frame
virtual PCB_LAYER_ID GetActiveLayer() const
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
static LAYER_PRESET presetNoLayers
void setVisibleLayers(LSET aLayers)
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
LSET layers
Board layers that are visible.
void SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
static LAYER_PRESET presetInnerCopper
static LAYER_PRESET presetBackAssembly
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
BOARD * GetBoard() const
static LAYER_PRESET presetFront
static LAYER_PRESET presetAllCopper
static LAYER_PRESET presetAllLayers
static LAYER_PRESET presetBack

References ApplyLayerPreset(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), getVisibleLayers(), ID_HIDE_ALL_BUT_ACTIVE, ID_HIDE_ALL_COPPER_LAYERS, ID_HIDE_ALL_NON_COPPER, ID_PRESET_ALL_LAYERS, ID_PRESET_BACK, ID_PRESET_BACK_ASSEMBLY, ID_PRESET_FRONT, ID_PRESET_FRONT_ASSEMBLY, ID_PRESET_INNER_COPPER, ID_PRESET_NO_LAYERS, ID_SHOW_ALL_COPPER_LAYERS, ID_SHOW_ALL_NON_COPPER, LAYER_PRESET::layers, m_frame, m_isFpEditor, presetAllCopper, presetAllLayers, presetBack, presetBackAssembly, presetFront, presetFrontAssembly, presetInnerCopper, presetNoLayers, EDA_DRAW_PANEL_GAL::Refresh(), LSET::Seq(), PCB_BASE_FRAME::SetActiveLayer(), SetLayerVisible(), setVisibleLayers(), syncColorsAndVisibility(), syncLayerPresetSelection(), and PCB_DRAW_PANEL_GAL::SyncLayersVisibility().

Referenced by APPEARANCE_CONTROLS().

◆ onLayerLeftClick()

void APPEARANCE_CONTROLS::onLayerLeftClick ( wxMouseEvent &  aEvent)
private

Definition at line 1867 of file appearance_controls.cpp.

1868 {
1869  auto eventSource = static_cast<wxWindow*>( aEvent.GetEventObject() );
1870 
1871  PCB_LAYER_ID layer = ToLAYER_ID( eventSource->GetId() );
1872 
1873  if( m_isFpEditor && LSET::ForbiddenFootprintLayers().test( layer ) )
1874  return;
1875 
1876  m_frame->SetActiveLayer( layer );
1877  passOnFocus();
1878 }
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:888
PCB_BASE_FRAME * m_frame
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905

References LSET::ForbiddenFootprintLayers(), m_frame, m_isFpEditor, passOnFocus(), PCB_BASE_FRAME::SetActiveLayer(), and ToLAYER_ID().

Referenced by rebuildLayers().

◆ onLayerPresetChanged()

void APPEARANCE_CONTROLS::onLayerPresetChanged ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 2391 of file appearance_controls.cpp.

2392 {
2393  int count = m_cbLayerPresets->GetCount();
2394  int index = m_cbLayerPresets->GetSelection();
2395 
2396  auto resetSelection =
2397  [&]()
2398  {
2399  if( m_currentPreset )
2400  m_cbLayerPresets->SetStringSelection( m_currentPreset->name );
2401  else
2402  m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 );
2403  };
2404 
2405  if( index == count - 3 )
2406  {
2407  // Separator: reject the selection
2408  resetSelection();
2409  return;
2410  }
2411  else if( index == count - 2 )
2412  {
2413  // Save current state to new preset
2414  wxString name;
2415 
2418 
2419  wxTextEntryDialog dlg( this, _( "Layer preset name:" ), _( "Save Layer Preset" ), name );
2420 
2421  if( dlg.ShowModal() != wxID_OK )
2422  {
2423  resetSelection();
2424  return;
2425  }
2426 
2427  name = dlg.GetValue();
2428  bool exists = m_layerPresets.count( name );
2429 
2430  if( !exists )
2431  {
2434  }
2435 
2436  LAYER_PRESET* preset = &m_layerPresets[name];
2437  m_currentPreset = preset;
2438 
2439  if( !exists )
2440  {
2441  index = m_cbLayerPresets->Insert( name, index - 1, static_cast<void*>( preset ) );
2442  }
2443  else
2444  {
2445  index = m_cbLayerPresets->FindString( name );
2446  m_presetMRU.Remove( name );
2447  }
2448 
2449  m_cbLayerPresets->SetSelection( index );
2450  m_presetMRU.Insert( name, 0 );
2451 
2452  return;
2453  }
2454  else if( index == count - 1 )
2455  {
2456  // Delete a preset
2457  wxArrayString headers;
2458  std::vector<wxArrayString> items;
2459 
2460  headers.Add( _( "Presets" ) );
2461 
2462  for( std::pair<const wxString, LAYER_PRESET>& pair : m_layerPresets )
2463  {
2464  if( !pair.second.readOnly )
2465  {
2466  wxArrayString item;
2467  item.Add( pair.first );
2468  items.emplace_back( item );
2469  }
2470  }
2471 
2472  EDA_LIST_DIALOG dlg( m_frame, _( "Delete Preset" ), headers, items );
2473  dlg.SetListLabel( _( "Select preset:" ) );
2474 
2475  if( dlg.ShowModal() == wxID_OK )
2476  {
2477  wxString presetName = dlg.GetTextSelection();
2478  int idx = m_cbLayerPresets->FindString( presetName );
2479 
2480  if( idx != wxNOT_FOUND )
2481  {
2482  m_layerPresets.erase( presetName );
2483 
2484  m_cbLayerPresets->Delete( idx );
2485  m_currentPreset = nullptr;
2486 
2487  m_presetMRU.Remove( presetName );
2488  }
2489  }
2490 
2491  resetSelection();
2492  return;
2493  }
2494 
2495  LAYER_PRESET* preset = static_cast<LAYER_PRESET*>( m_cbLayerPresets->GetClientData( index ) );
2496  m_currentPreset = preset;
2497 
2498  m_lastSelectedUserPreset = ( !preset || preset->readOnly ) ? nullptr : preset;
2499 
2500  if( preset )
2501  doApplyLayerPreset( *preset );
2502 
2503  if( !m_currentPreset->name.IsEmpty() )
2504  {
2505  m_presetMRU.Remove( m_currentPreset->name );
2506  m_presetMRU.Insert( m_currentPreset->name, 0 );
2507  }
2508 
2509  passOnFocus();
2510 }
A saved set of layers that are visible.
LAYER_PRESET * m_lastSelectedUserPreset
The last user (non-read-only) preset selected by the user.
A dialog which shows:
PCB_BASE_FRAME * m_frame
wxString name
A name for this layer set.
bool readOnly
True if this is a read-only (built-in) preset.
std::map< wxString, LAYER_PRESET > m_layerPresets
void doApplyLayerPreset(const LAYER_PRESET &aPreset)
LAYER_PRESET * m_currentPreset
#define _(s)
const char * name
Definition: DXF_plotter.cpp:56

References _, doApplyLayerPreset(), EDA_LIST_DIALOG::GetTextSelection(), getVisibleLayers(), getVisibleObjects(), APPEARANCE_CONTROLS_BASE::m_cbLayerPresets, m_currentPreset, m_frame, m_lastSelectedUserPreset, m_layerPresets, m_presetMRU, name, LAYER_PRESET::name, passOnFocus(), LAYER_PRESET::readOnly, EDA_LIST_DIALOG::SetListLabel(), and UNSELECTED_LAYER.

Referenced by APPEARANCE_CONTROLS(), and ApplyLayerPreset().

◆ onLayerVisibilityChanged()

void APPEARANCE_CONTROLS::onLayerVisibilityChanged ( PCB_LAYER_ID  aLayer,
bool  isVisible,
bool  isFinal 
)
private

Definition at line 1889 of file appearance_controls.cpp.

1891 {
1892  LSET visibleLayers = getVisibleLayers();
1893 
1894  if( visibleLayers.test( aLayer ) != isVisible )
1895  {
1896  visibleLayers.set( aLayer, isVisible );
1897 
1898  setVisibleLayers( visibleLayers );
1899 
1900  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1901  }
1902 
1904 
1905  if( isFinal )
1906  m_frame->GetCanvas()->Refresh();
1907 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * m_frame
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
void setVisibleLayers(LSET aLayers)
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:388
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...

References PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), getVisibleLayers(), m_frame, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::VIEW::SetLayerVisible(), setVisibleLayers(), and syncLayerPresetSelection().

Referenced by rebuildLayers().

◆ onNetclassColorChanged()

void APPEARANCE_CONTROLS::onNetclassColorChanged ( wxCommandEvent &  aEvent)
private

Definition at line 2712 of file appearance_controls.cpp.

2713 {
2714  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
2716 
2717  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2718 
2719  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2720  wxString className = netclassNameFromEvent( aEvent );
2721 
2722  netclassColors[className] = swatch->GetSwatchColor();
2723 
2726  m_frame->GetCanvas()->Refresh();
2727 }
KIGFX::COLOR4D GetSwatchColor() const
std::map< wxString, KIGFX::COLOR4D > & GetNetclassColorMap()
Definition: pcb_painter.h:183
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
PCB_BASE_FRAME * m_frame
PCB specific render settings.
Definition: pcb_painter.h:64
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
wxString netclassNameFromEvent(wxEvent &aEvent)
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:56
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:766

References PCB_BASE_FRAME::GetCanvas(), KIGFX::PCB_RENDER_SETTINGS::GetNetclassColorMap(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), COLOR_SWATCH::GetSwatchColor(), PCB_DRAW_PANEL_GAL::GetView(), m_frame, netclassNameFromEvent(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), EDA_DRAW_PANEL_GAL::Refresh(), and KIGFX::VIEW::UpdateAllLayersColor().

Referenced by rebuildNets().

◆ onNetclassContextMenu()

void APPEARANCE_CONTROLS::onNetclassContextMenu ( wxCommandEvent &  aEvent)
private

Definition at line 2782 of file appearance_controls.cpp.

2783 {
2784  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
2786  static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
2787 
2788  BOARD* board = m_frame->GetBoard();
2789  NETINFO_LIST& nets = board->GetNetInfo();
2790  NETCLASSES& classes = board->GetDesignSettings().GetNetClasses();
2791  NETCLASSPTR netclass = classes.Find( m_contextMenuNetclass );
2792 
2793  APPEARANCE_SETTING* setting = m_netclassSettingsMap.count( m_contextMenuNetclass ) ?
2795 
2796  NETCLASSPTR defaultClass = classes.GetDefault();
2797  wxString defaultClassName = defaultClass->GetName();
2798 
2799  auto runOnNetsOfClass =
2800  [&]( NETCLASSPTR aClass, std::function<void( NETINFO_ITEM* )> aFunction )
2801  {
2802  if( aClass == defaultClass )
2803  {
2804  for( NETINFO_ITEM* net : nets )
2805  if( net->GetNetClass() == defaultClass.get() )
2806  aFunction( net );
2807  }
2808  else
2809  {
2810  for( const wxString& netName : *aClass )
2811  aFunction( nets.GetNetItem( netName ) );
2812  }
2813  };
2814 
2815  switch( aEvent.GetId() )
2816  {
2817  case ID_SET_NET_COLOR:
2818  {
2819  if( setting )
2820  {
2821  setting->ctl_color->GetNewSwatchColor();
2822 
2823  COLOR4D color = setting->ctl_color->GetSwatchColor();
2824 
2825  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2826 
2827  if( color != COLOR4D::UNSPECIFIED )
2828  netclassColors[m_contextMenuNetclass] = color;
2829  else
2830  netclassColors.erase( m_contextMenuNetclass );
2831 
2832  view->UpdateAllLayersColor();
2833  }
2834 
2835  break;
2836  }
2837 
2838  case ID_HIGHLIGHT_NET:
2839  {
2840  if( netclass )
2841  {
2842  runOnNetsOfClass( netclass,
2843  [&]( NETINFO_ITEM* aItem )
2844  {
2845  if( !aItem )
2846  return;
2847 
2848  static bool first = true;
2849  int code = aItem->GetNetCode();
2850 
2851  if( first )
2852  {
2853  board->SetHighLightNet( code );
2854  rs->SetHighlight( true, code );
2855  first = false;
2856  }
2857  else
2858  {
2859  board->SetHighLightNet( code, true );
2860  rs->SetHighlight( true, code, true );
2861  }
2862  } );
2863 
2864  view->UpdateAllLayersColor();
2865  board->HighLightON();
2866  }
2867  break;
2868  }
2869 
2870  case ID_SELECT_NET:
2871  case ID_DESELECT_NET:
2872  {
2873  if( netclass )
2874  {
2875  TOOL_ACTION& action = aEvent.GetId() == ID_SELECT_NET ? PCB_ACTIONS::selectNet :
2877  runOnNetsOfClass( netclass,
2878  [&]( NETINFO_ITEM* aItem )
2879  {
2880  if( !aItem )
2881  return;
2882 
2883  intptr_t code = static_cast<intptr_t>( aItem->GetNetCode() );
2884  m_frame->GetToolManager()->RunAction( action, true, code );
2885  } );
2886  }
2887  break;
2888  }
2889 
2890  case ID_SHOW_ALL_NETS:
2891  {
2892  showNetclass( defaultClassName );
2893  wxASSERT( m_netclassSettingsMap.count( defaultClassName ) );
2894  m_netclassSettingsMap.at( defaultClassName )->ctl_visibility->SetValue( true );
2895 
2896  for( const auto& pair : classes.NetClasses() )
2897  {
2898  showNetclass( pair.first );
2899 
2900  if( m_netclassSettingsMap.count( pair.first ) )
2901  m_netclassSettingsMap.at( pair.first )->ctl_visibility->SetValue( true );
2902  }
2903 
2904  break;
2905  }
2906 
2907  case ID_HIDE_OTHER_NETS:
2908  {
2909  bool showDefault = m_contextMenuNetclass == defaultClassName;
2910  showNetclass( defaultClassName, showDefault );
2911  wxASSERT( m_netclassSettingsMap.count( defaultClassName ) );
2912  m_netclassSettingsMap.at( defaultClassName )->ctl_visibility->SetValue( showDefault );
2913 
2914  for( const auto& pair : classes.NetClasses() )
2915  {
2916  bool show = pair.first == m_contextMenuNetclass;
2917 
2918  showNetclass( pair.first, show );
2919 
2920  if( m_netclassSettingsMap.count( pair.first ) )
2921  m_netclassSettingsMap.at( pair.first )->ctl_visibility->SetValue( show );
2922  }
2923 
2924  break;
2925  }
2926 
2927  default:
2928  break;
2929  }
2930 
2932  m_frame->GetCanvas()->Refresh();
2933 
2934  m_contextMenuNetclass.clear();
2935 }
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
NETCLASS_MAP & NetClasses()
Provide public access to m_NetClasses so it gets swigged.
Definition: netclass.h:290
std::map< wxString, KIGFX::COLOR4D > & GetNetclassColorMap()
Definition: pcb_painter.h:183
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:77
int color
Definition: DXF_plotter.cpp:57
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
PCB_BASE_FRAME * m_frame
PCB specific render settings.
Definition: pcb_painter.h:64
void showNetclass(const wxString &aClassName, bool aShow=true)
A container for NETCLASS instances.
Definition: netclass.h:218
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:315
std::map< wxString, APPEARANCE_SETTING * > m_netclassSettingsMap
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Handle the data for a net.
Definition: netinfo.h:64
int GetId() const
Return the unique id of the TOOL_ACTION object.
Definition: tool_action.h:121
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
Represent a single user action.
Definition: tool_action.h:67
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:80
NETCLASSPTR GetDefault() const
Definition: netclass.h:253
wxString m_contextMenuNetclass
The name of the netclass that was right-clicked.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:766
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
int GetNetCode() const
Definition: netinfo.h:113

References color, APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_color, PCB_ACTIONS::deselectNet, NETCLASSES::Find(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), NETCLASSES::GetDefault(), TOOL_ACTION::GetId(), KIGFX::PCB_RENDER_SETTINGS::GetNetclassColorMap(), NETINFO_ITEM::GetNetCode(), NETINFO_LIST::GetNetItem(), COLOR_SWATCH::GetNewSwatchColor(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), COLOR_SWATCH::GetSwatchColor(), TOOLS_HOLDER::GetToolManager(), PCB_DRAW_PANEL_GAL::GetView(), ID_DESELECT_NET, ID_HIDE_OTHER_NETS, ID_HIGHLIGHT_NET, ID_SELECT_NET, ID_SET_NET_COLOR, ID_SHOW_ALL_NETS, m_contextMenuNetclass, m_frame, m_netclassSettingsMap, NETCLASSES::NetClasses(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), EDA_DRAW_PANEL_GAL::Refresh(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectNet, KIGFX::RENDER_SETTINGS::SetHighlight(), showNetclass(), and KIGFX::VIEW::UpdateAllLayersColor().

Referenced by rebuildNets().

◆ onNetclassVisibilityChanged()

void APPEARANCE_CONTROLS::onNetclassVisibilityChanged ( wxCommandEvent &  aEvent)
private

Definition at line 2650 of file appearance_controls.cpp.

2651 {
2652  wxString className = netclassNameFromEvent( aEvent );
2653  bool show = aEvent.GetInt();
2654  showNetclass( className, show );
2655  passOnFocus();
2656 }
void showNetclass(const wxString &aClassName, bool aShow=true)
wxString netclassNameFromEvent(wxEvent &aEvent)

References netclassNameFromEvent(), passOnFocus(), and showNetclass().

Referenced by rebuildNets().

◆ onNetColorMode()

void APPEARANCE_CONTROLS::onNetColorMode ( wxCommandEvent &  aEvent)
private

Definition at line 2740 of file appearance_controls.cpp.

2741 {
2743 
2744  if( m_rbNetColorAll->GetValue() )
2746  else if( m_rbNetColorRatsnest->GetValue() )
2748  else
2750 
2751  m_frame->SetDisplayOptions( options );
2753  passOnFocus();
2754 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Net/netclass colors are shown on all net copper.
Net/netclass colors are shown on ratsnest lines only.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCB_BASE_FRAME * m_frame
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
Container for display options like enable/disable some optional drawings.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Net (and netclass) colors are not shown.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:766
NET_COLOR_MODE m_NetColorMode
How to use color overrides on specific nets and netclasses.
wxRadioButton * m_rbNetColorRatsnest
wxRadioButton * m_rbNetColorAll

References ALL, PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), PCB_DRAW_PANEL_GAL::GetView(), m_frame, PCB_DISPLAY_OPTIONS::m_NetColorMode, m_rbNetColorAll, m_rbNetColorRatsnest, OFF, passOnFocus(), RATSNEST, PCB_BASE_FRAME::SetDisplayOptions(), and KIGFX::VIEW::UpdateAllLayersColor().

Referenced by createControls().

◆ onNetContextMenu()

void APPEARANCE_CONTROLS::onNetContextMenu ( wxCommandEvent &  aEvent)
private

Definition at line 2592 of file appearance_controls.cpp.

2593 {
2594  wxASSERT( m_netsGrid->GetSelectedRows().size() == 1 );
2595 
2596  int row = m_netsGrid->GetSelectedRows()[0];
2597  NET_GRID_ENTRY& net = m_netsTable->GetEntry( row );
2598 
2599  m_netsGrid->ClearSelection();
2600 
2601  switch( aEvent.GetId() )
2602  {
2603  case ID_SET_NET_COLOR:
2604  {
2605  wxGridCellEditor* editor = m_netsGrid->GetCellEditor( row, NET_GRID_TABLE::COL_COLOR );
2606  editor->BeginEdit( row, NET_GRID_TABLE::COL_COLOR, m_netsGrid );
2607  break;
2608  }
2609 
2610  case ID_HIGHLIGHT_NET:
2611  {
2613  static_cast<intptr_t>( net.code ) );
2614  m_frame->GetCanvas()->Refresh();
2615  break;
2616  }
2617 
2618  case ID_SELECT_NET:
2619  {
2621  static_cast<intptr_t>( net.code ) );
2622  m_frame->GetCanvas()->Refresh();
2623  break;
2624  }
2625 
2626  case ID_DESELECT_NET:
2627  {
2629  static_cast<intptr_t>( net.code ) );
2630  m_frame->GetCanvas()->Refresh();
2631  break;
2632  }
2633 
2634  case ID_SHOW_ALL_NETS:
2636  break;
2637 
2638  case ID_HIDE_OTHER_NETS:
2639  m_netsTable->HideOtherNets( net );
2640  break;
2641 
2642  default:
2643  break;
2644  }
2645 
2646  passOnFocus();
2647 }
void HideOtherNets(const NET_GRID_ENTRY &aNet)
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:77
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
int code
PCB_BASE_FRAME * m_frame
NET_GRID_ENTRY & GetEntry(int aRow)
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:451
NET_GRID_TABLE * m_netsTable
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:80
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54

References NET_GRID_ENTRY::code, NET_GRID_TABLE::COL_COLOR, PCB_ACTIONS::deselectNet, editor, PCB_BASE_FRAME::GetCanvas(), NET_GRID_TABLE::GetEntry(), TOOLS_HOLDER::GetToolManager(), NET_GRID_TABLE::HideOtherNets(), PCB_ACTIONS::highlightNet, ID_DESELECT_NET, ID_HIDE_OTHER_NETS, ID_HIGHLIGHT_NET, ID_SELECT_NET, ID_SET_NET_COLOR, ID_SHOW_ALL_NETS, m_frame, APPEARANCE_CONTROLS_BASE::m_netsGrid, m_netsTable, passOnFocus(), EDA_DRAW_PANEL_GAL::Refresh(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectNet, and NET_GRID_TABLE::ShowAllNets().

Referenced by OnNetGridRightClick().

◆ OnNetGridClick()

void APPEARANCE_CONTROLS::OnNetGridClick ( wxGridEvent &  event)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 839 of file appearance_controls.cpp.

840 {
841  int row = event.GetRow();
842  int col = event.GetCol();
843 
844  switch( col )
845  {
847  m_netsTable->SetValueAsBool( row, col, !m_netsTable->GetValueAsBool( row, col ) );
848  m_netsGrid->ForceRefresh();
849  break;
850 
851  default:
852  break;
853  }
854 }
bool GetValueAsBool(int aRow, int aCol) override
void SetValueAsBool(int aRow, int aCol, bool aValue) override
NET_GRID_TABLE * m_netsTable

References NET_GRID_TABLE::COL_VISIBILITY, NET_GRID_TABLE::GetValueAsBool(), APPEARANCE_CONTROLS_BASE::m_netsGrid, m_netsTable, and NET_GRID_TABLE::SetValueAsBool().

◆ OnNetGridDoubleClick()

void APPEARANCE_CONTROLS::OnNetGridDoubleClick ( wxGridEvent &  event)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 857 of file appearance_controls.cpp.

858 {
859  int row = event.GetRow();
860  int col = event.GetCol();
861 
862  switch( col )
863  {
865  m_netsGrid->GetCellEditor( row, col )->BeginEdit( row, col, m_netsGrid );
866  break;
867 
868  default:
869  break;
870  }
871 }

References NET_GRID_TABLE::COL_COLOR, and APPEARANCE_CONTROLS_BASE::m_netsGrid.

◆ OnNetGridMouseEvent()

void APPEARANCE_CONTROLS::OnNetGridMouseEvent ( wxMouseEvent &  aEvent)
protected

Definition at line 906 of file appearance_controls.cpp.

907 {
908  wxPoint pos = m_netsGrid->CalcUnscrolledPosition( aEvent.GetPosition() );
909  wxGridCellCoords cell = m_netsGrid->XYToCell( pos );
910 
911  if( aEvent.Moving() || aEvent.Entering() )
912  {
913  aEvent.Skip();
914 
915  if( !cell )
916  {
917  m_netsGrid->GetGridWindow()->UnsetToolTip();
918  return;
919  }
920 
921  if( cell == m_hoveredCell )
922  return;
923 
924  m_hoveredCell = cell;
925 
926  NET_GRID_ENTRY& net = m_netsTable->GetEntry( cell.GetRow() );
927 
928  wxString name = net.name;
929  wxString showOrHide = net.visible ? _( "Click to hide ratsnest for %s" )
930  : _( "Click to show ratsnest for %s" );
931  wxString tip;
932 
933  if( cell.GetCol() == NET_GRID_TABLE::COL_VISIBILITY )
934  {
935  tip.Printf( showOrHide, name );
936  }
937  else if( cell.GetCol() == NET_GRID_TABLE::COL_COLOR )
938  {
939  tip = _( "Double click (or middle click) to change color; "
940  "right click for more actions" );
941  }
942 
943  m_netsGrid->GetGridWindow()->SetToolTip( tip );
944  }
945  else if( aEvent.Leaving() )
946  {
947  m_netsGrid->UnsetToolTip();
948  aEvent.Skip();
949  }
950  else if( aEvent.Dragging() )
951  {
952  // not allowed
953  CallAfter( [&]()
954  {
955  m_netsGrid->ClearSelection();
956  } );
957  }
958  else if( aEvent.ButtonUp( wxMOUSE_BTN_MIDDLE ) && !!cell )
959  {
960  int row = cell.GetRow();
961  int col = cell.GetCol();
962 
963  if(col == NET_GRID_TABLE::COL_COLOR )
964  m_netsGrid->GetCellEditor( row, col )->BeginEdit( row, col, m_netsGrid );
965 
966  aEvent.Skip();
967  }
968  else
969  {
970  aEvent.Skip();
971  }
972 }
bool visible
#define _(s)
NET_GRID_ENTRY & GetEntry(int aRow)
const char * name
Definition: DXF_plotter.cpp:56
NET_GRID_TABLE * m_netsTable
wxString name
wxGridCellCoords m_hoveredCell
Grid cell that is being hovered over, for tooltips.

References _, NET_GRID_TABLE::COL_COLOR, NET_GRID_TABLE::COL_VISIBILITY, NET_GRID_TABLE::GetEntry(), m_hoveredCell, APPEARANCE_CONTROLS_BASE::m_netsGrid, m_netsTable, name, NET_GRID_ENTRY::name, and NET_GRID_ENTRY::visible.

Referenced by APPEARANCE_CONTROLS().

◆ OnNetGridRightClick()

void APPEARANCE_CONTROLS::OnNetGridRightClick ( wxGridEvent &  event)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 874 of file appearance_controls.cpp.

875 {
876  m_netsGrid->SelectRow( event.GetRow() );
877 
878  wxString netName = m_netsGrid->GetCellValue( event.GetRow(), NET_GRID_TABLE::COL_LABEL );
879  wxMenu menu;
880 
881  menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR, _( "Set Net Color" ), wxEmptyString,
882  wxITEM_NORMAL ) );
883  menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
884  wxString::Format( _( "Highlight %s" ), netName ), wxEmptyString,
885  wxITEM_NORMAL ) );
886  menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
887  wxString::Format( _( "Select Tracks and Vias in %s" ), netName ),
888  wxEmptyString, wxITEM_NORMAL ) );
889  menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
890  wxString::Format( _( "Unselect Tracks and Vias in %s" ), netName ),
891  wxEmptyString, wxITEM_NORMAL ) );
892 
893  menu.AppendSeparator();
894 
895  menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS, _( "Show All Nets" ), wxEmptyString,
896  wxITEM_NORMAL ) );
897  menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS, _( "Hide All Other Nets" ),
898  wxEmptyString, wxITEM_NORMAL ) );
899 
900  menu.Bind( wxEVT_COMMAND_MENU_SELECTED, &APPEARANCE_CONTROLS::onNetContextMenu, this );
901 
902  PopupMenu( &menu );
903 }
void onNetContextMenu(wxCommandEvent &aEvent)
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References _, NET_GRID_TABLE::COL_LABEL, Format(), ID_DESELECT_NET, ID_HIDE_OTHER_NETS, ID_HIGHLIGHT_NET, ID_SELECT_NET, ID_SET_NET_COLOR, ID_SHOW_ALL_NETS, APPEARANCE_CONTROLS_BASE::m_netsGrid, and onNetContextMenu().

◆ OnNetVisibilityChanged()

void APPEARANCE_CONTROLS::OnNetVisibilityChanged ( int  aNetCode,
bool  aVisibility 
)

Notifies the panel when a net has been hidden or shown via the external tool.

Manually update visibility for a given layer

Definition at line 1004 of file appearance_controls.cpp.

1005 {
1006  int row = m_netsTable->GetRowByNetcode( aNetCode );
1007 
1008  if( row >= 0 )
1009  {
1011  m_netsGrid->ForceRefresh();
1012  }
1013 }
int GetRowByNetcode(int aCode) const
void SetValueAsBool(int aRow, int aCol, bool aValue) override
NET_GRID_TABLE * m_netsTable

References NET_GRID_TABLE::COL_VISIBILITY, NET_GRID_TABLE::GetRowByNetcode(), APPEARANCE_CONTROLS_BASE::m_netsGrid, m_netsTable, and NET_GRID_TABLE::SetValueAsBool().

Referenced by BOARD_INSPECTION_TOOL::doHideNet().

◆ OnNotebookPageChanged()

void APPEARANCE_CONTROLS::OnNotebookPageChanged ( wxNotebookEvent &  event)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 785 of file appearance_controls.cpp.

786 {
787  // Work around wxMac issue where the notebook pages are blank
788 #ifdef __WXMAC__
789  int page = aEvent.GetSelection();
790 
791  if( page >= 0 )
792  m_notebook->ChangeSelection( static_cast<unsigned>( page ) );
793 #endif
794 
795 #ifndef __WXMSW__
796  // Because wxWidgets is broken and will send click events to children of the collapsible
797  // panes even if they are collapsed without this
798  Freeze();
799  m_panelLayers->Fit();
800  m_panelNetsAndClasses->Fit();
801  m_sizerOuter->Layout();
802  Thaw();
803 #endif
804 
805  Bind( wxEVT_IDLE, &APPEARANCE_CONTROLS::idleFocusHandler, this );
806 }
void idleFocusHandler(wxIdleEvent &aEvent)

References idleFocusHandler(), APPEARANCE_CONTROLS_BASE::m_notebook, APPEARANCE_CONTROLS_BASE::m_panelLayers, APPEARANCE_CONTROLS_BASE::m_panelNetsAndClasses, and APPEARANCE_CONTROLS_BASE::m_sizerOuter.

◆ onObjectOpacitySlider()

void APPEARANCE_CONTROLS::onObjectOpacitySlider ( int  aLayer,
float  aOpacity 
)
private

Definition at line 2574 of file appearance_controls.cpp.

2575 {
2577 
2578  switch( aLayer )
2579  {
2580  case static_cast<int>( LAYER_TRACKS ): options.m_TrackOpacity = aOpacity; break;
2581  case static_cast<int>( LAYER_VIAS ): options.m_ViaOpacity = aOpacity; break;
2582  case static_cast<int>( LAYER_PADS ): options.m_PadOpacity = aOpacity; break;
2583  case static_cast<int>( LAYER_ZONES ): options.m_ZoneOpacity = aOpacity; break;
2584  default: return;
2585  }
2586 
2587  m_frame->SetDisplayOptions( options );
2588  passOnFocus();
2589 }
Meta control for all pads opacity/visibility (color ignored)
Definition: layer_ids.h:226
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
Control for copper zone opacity/visibility (color ignored)
Definition: layer_ids.h:227
PCB_BASE_FRAME * m_frame
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
Container for display options like enable/disable some optional drawings.
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:189

References PCB_BASE_FRAME::GetDisplayOptions(), LAYER_PADS, LAYER_TRACKS, LAYER_VIAS, LAYER_ZONES, m_frame, PCB_DISPLAY_OPTIONS::m_PadOpacity, PCB_DISPLAY_OPTIONS::m_TrackOpacity, PCB_DISPLAY_OPTIONS::m_ViaOpacity, PCB_DISPLAY_OPTIONS::m_ZoneOpacity, passOnFocus(), and PCB_BASE_FRAME::SetDisplayOptions().

Referenced by rebuildObjects().

◆ onObjectVisibilityChanged()

void APPEARANCE_CONTROLS::onObjectVisibilityChanged ( GAL_LAYER_ID  aLayer,
bool  isVisible,
bool  isFinal 
)
private

Definition at line 1910 of file appearance_controls.cpp.

1912 {
1913  // Special-case controls
1914  switch( aLayer )
1915  {
1916  case LAYER_RATSNEST:
1917  {
1918  // don't touch the layers. ratsnest is enabled on per-item basis.
1920  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, true );
1921 
1922  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
1923  {
1925  opt.m_ShowGlobalRatsnest = isVisible;
1926  m_frame->SetDisplayOptions( opt );
1927  m_frame->GetBoard()->SetElementVisibility( aLayer, isVisible );
1929  }
1930 
1931  break;
1932  }
1933 
1934  case LAYER_GRID:
1935  m_frame->SetGridVisibility( isVisible );
1936  m_frame->GetCanvas()->Refresh();
1938  break;
1939 
1940  case LAYER_MOD_TEXT_FR:
1941  // Because Footprint Text is a meta-control that also can disable values/references,
1942  // drag them along here so that the user is less likely to be confused.
1943  if( isFinal )
1944  {
1945  // Should only trigger when you actually click the Footprint Text button
1946  // Otherwise it goes into infinite recursive loop with the following case section
1947  onObjectVisibilityChanged( LAYER_MOD_REFERENCES, isVisible, false );
1948  onObjectVisibilityChanged( LAYER_MOD_VALUES, isVisible, false );
1949  m_objectSettingsMap[LAYER_MOD_REFERENCES]->ctl_visibility->SetValue( isVisible );
1950  m_objectSettingsMap[LAYER_MOD_VALUES]->ctl_visibility->SetValue( isVisible );
1951  }
1952  break;
1953 
1954  case LAYER_MOD_REFERENCES:
1955  case LAYER_MOD_VALUES:
1956  // In case that user changes Footprint Value/References when the Footprint Text
1957  // meta-control is disabled, we should put it back on.
1958  if( isVisible )
1959  {
1960  onObjectVisibilityChanged( LAYER_MOD_TEXT_FR, isVisible, false );
1961  m_objectSettingsMap[LAYER_MOD_TEXT_FR]->ctl_visibility->SetValue( isVisible );
1962  }
1963  break;
1964 
1965  default:
1966  break;
1967  }
1968 
1969  GAL_SET visible = getVisibleObjects();
1970 
1971  if( visible.Contains( aLayer ) != isVisible )
1972  {
1973  visible.set( aLayer, isVisible );
1974  setVisibleObjects( visible );
1975  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1977  }
1978 
1979  if( isFinal )
1980  {
1981  m_frame->GetCanvas()->Refresh();
1982  passOnFocus();
1983  }
1984 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:539
show footprints values (when texts are visible)
Definition: layer_ids.h:206
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
std::map< GAL_LAYER_ID, APPEARANCE_SETTING * > m_objectSettingsMap
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
PCB_BASE_FRAME * m_frame
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
Container for display options like enable/disable some optional drawings.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:279
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:388
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
show footprints references (when texts are visible)
Definition: layer_ids.h:207
bool IsType(FRAME_T aType) const
void setVisibleObjects(GAL_SET aObjects)
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void onObjectVisibilityChanged(GAL_LAYER_ID aLayer, bool isVisible, bool isFinal)
GAL_SET & set()
Definition: layer_ids.h:295
BOARD * GetBoard() const
virtual void SetGridVisibility(bool aVisible)
bool Contains(GAL_LAYER_ID aPos)
Definition: layer_ids.h:313

References GAL_SET::Contains(), FRAME_PCB_EDITOR, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), PCB_DRAW_PANEL_GAL::GetView(), getVisibleObjects(), EDA_BASE_FRAME::IsType(), LAYER_GRID, LAYER_MOD_REFERENCES, LAYER_MOD_TEXT_FR, LAYER_MOD_VALUES, LAYER_RATSNEST, m_frame, m_objectSettingsMap, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, KIGFX::VIEW::MarkTargetDirty(), passOnFocus(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), EDA_DRAW_PANEL_GAL::Refresh(), GAL_SET::set(), PCB_BASE_FRAME::SetDisplayOptions(), BOARD::SetElementVisibility(), EDA_DRAW_FRAME::SetGridVisibility(), KIGFX::VIEW::SetLayerVisible(), setVisibleObjects(), syncLayerPresetSelection(), and KIGFX::TARGET_NONCACHED.

Referenced by rebuildObjects().

◆ onRatsnestMode()

void APPEARANCE_CONTROLS::onRatsnestMode ( wxCommandEvent &  aEvent)
private

Definition at line 2757 of file appearance_controls.cpp.

2758 {
2760 
2761  if( m_rbRatsnestAllLayers->GetValue() )
2762  {
2763  options.m_ShowGlobalRatsnest = true;
2765  }
2766  else if( m_rbRatsnestVisLayers->GetValue() )
2767  {
2768  options.m_ShowGlobalRatsnest = true;
2770  }
2771  else
2772  {
2773  options.m_ShowGlobalRatsnest = false;
2774  }
2775 
2776  m_frame->SetDisplayOptions( options );
2778  passOnFocus();
2779 }
Ratsnest lines are drawn to items on visible layers only.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxRadioButton * m_rbRatsnestAllLayers
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
Ratsnest lines are drawn to items on all layers (default)
PCB_BASE_FRAME * m_frame
RATSNEST_MODE m_RatsnestMode
Ratsnest draw mode (all layers vs only visible layers)
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
Container for display options like enable/disable some optional drawings.
wxRadioButton * m_rbRatsnestVisLayers

References ALL, PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), m_frame, PCB_DISPLAY_OPTIONS::m_RatsnestMode, m_rbRatsnestAllLayers, m_rbRatsnestVisLayers, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, passOnFocus(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), PCB_BASE_FRAME::SetDisplayOptions(), and VISIBLE.

Referenced by createControls().

◆ onReadOnlySwatch()

void APPEARANCE_CONTROLS::onReadOnlySwatch ( )
private

Definition at line 2944 of file appearance_controls.cpp.

2945 {
2946  WX_INFOBAR* infobar = m_frame->GetInfoBar();
2947 
2948  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Open Preferences" ),
2949  wxEmptyString );
2950 
2951  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
2952  [&]( wxHyperlinkEvent& aEvent )
2953  {
2954  wxCommandEvent dummy;
2956  } ) );
2957 
2958  infobar->RemoveAllButtons();
2959  infobar->AddButton( button );
2960  infobar->AddCloseButton();
2961 
2962  infobar->ShowMessageFor( _( "The current color theme is read-only. Create a new theme in "
2963  "Preferences to enable color editing." ),
2964  10000, wxICON_INFORMATION );
2965 }
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:245
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:128
PCB_BASE_FRAME * m_frame
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
#define _(s)
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
void OnPreferences(wxCommandEvent &event)
Displays the preferences and settings of all opened editors paged dialog.
WX_INFOBAR * GetInfoBar()
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:276

References _, WX_INFOBAR::AddButton(), WX_INFOBAR::AddCloseButton(), dummy(), EDA_BASE_FRAME::GetInfoBar(), m_frame, EDA_BASE_FRAME::OnPreferences(), WX_INFOBAR::RemoveAllButtons(), and WX_INFOBAR::ShowMessageFor().

Referenced by rebuildLayers(), and rebuildObjects().

◆ OnSetFocus()

void APPEARANCE_CONTROLS::OnSetFocus ( wxFocusEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 816 of file appearance_controls.cpp.

817 {
818 #ifdef __WXMSW__
819  // In wxMSW, buttons won't process events unless they have focus, so we'll let it take the
820  // focus and give it back to the parent in the button event handler.
821  if( wxBitmapButton* btn = dynamic_cast<wxBitmapButton*>( aEvent.GetEventObject() ) )
822  {
823  wxCommandEvent evt( wxEVT_BUTTON );
824  wxPostEvent( btn, evt );
825  }
826 #endif
827 
828  passOnFocus();
829  aEvent.Skip();
830 }

References passOnFocus().

Referenced by APPEARANCE_CONTROLS(), and rebuildObjects().

◆ OnSize()

void APPEARANCE_CONTROLS::OnSize ( wxSizeEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 833 of file appearance_controls.cpp.

834 {
835  aEvent.Skip();
836 }

◆ passOnFocus()

◆ rebuildLayerContextMenu()

void APPEARANCE_CONTROLS::rebuildLayerContextMenu ( )
private

Definition at line 1656 of file appearance_controls.cpp.

1657 {
1658  delete m_layerContextMenu;
1659  m_layerContextMenu = new wxMenu;
1660 
1662  _( "Show All Copper Layers" ),
1665  _( "Hide All Copper Layers" ),
1667 
1668  m_layerContextMenu->AppendSeparator();
1669 
1671  _( "Hide All Layers But Active" ),
1673 
1674  m_layerContextMenu->AppendSeparator();
1675 
1676  AddMenuItem( m_layerContextMenu, ID_SHOW_ALL_NON_COPPER, _( "Show All Non Copper Layers" ),
1678 
1679  AddMenuItem( m_layerContextMenu, ID_HIDE_ALL_NON_COPPER, _( "Hide All Non Copper Layers" ),
1681 
1682  m_layerContextMenu->AppendSeparator();
1683 
1684  AddMenuItem( m_layerContextMenu, ID_PRESET_ALL_LAYERS, _( "Show All Layers" ),
1686 
1687  AddMenuItem( m_layerContextMenu, ID_PRESET_NO_LAYERS, _( "Hide All Layers" ),
1689 
1690  m_layerContextMenu->AppendSeparator();
1691 
1693  _( "Show Only Front Assembly Layers" ),
1695 
1696  AddMenuItem( m_layerContextMenu, ID_PRESET_FRONT, _( "Show Only Front Layers" ),
1698 
1699  // Only show the internal layer option if internal layers are enabled
1700  if( m_frame->GetBoard()->GetCopperLayerCount() > 2 )
1701  {
1702  AddMenuItem( m_layerContextMenu, ID_PRESET_INNER_COPPER, _( "Show Only Inner Layers" ),
1704  }
1705 
1706  AddMenuItem( m_layerContextMenu, ID_PRESET_BACK, _( "Show Only Back Layers" ),
1708 
1709  AddMenuItem( m_layerContextMenu, ID_PRESET_BACK_ASSEMBLY, _( "Show Only Back Assembly Layers" ),
1711 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
Definition: bitmap.cpp:257
PCB_BASE_FRAME * m_frame
#define _(s)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
int GetCopperLayerCount() const
Definition: board.cpp:455
BOARD * GetBoard() const

References _, AddMenuItem(), PCB_BASE_FRAME::GetBoard(), BOARD::GetCopperLayerCount(), ID_HIDE_ALL_BUT_ACTIVE, ID_HIDE_ALL_COPPER_LAYERS, ID_HIDE_ALL_NON_COPPER, ID_PRESET_ALL_LAYERS, ID_PRESET_BACK, ID_PRESET_BACK_ASSEMBLY, ID_PRESET_FRONT, ID_PRESET_FRONT_ASSEMBLY, ID_PRESET_INNER_COPPER, ID_PRESET_NO_LAYERS, ID_SHOW_ALL_COPPER_LAYERS, ID_SHOW_ALL_NON_COPPER, KiBitmap(), m_frame, m_layerContextMenu, select_w_layer, show_all_back_layers, show_all_copper_layers, show_all_front_layers, show_all_layers, show_back_assembly_layers, show_front_assembly_layers, show_no_copper_layers, and show_no_layers.

Referenced by OnBoardChanged().

◆ rebuildLayerPresetsWidget()

void APPEARANCE_CONTROLS::rebuildLayerPresetsWidget ( )
private

Definition at line 2332 of file appearance_controls.cpp.

2333 {
2334  m_cbLayerPresets->Clear();
2335 
2336  for( std::pair<const wxString, LAYER_PRESET>& pair : m_layerPresets )
2337  m_cbLayerPresets->Append( pair.first, static_cast<void*>( &pair.second ) );
2338 
2339  m_cbLayerPresets->Append( wxT( "-----" ) );
2340  m_cbLayerPresets->Append( _( "Save preset..." ) );
2341  m_cbLayerPresets->Append( _( "Delete preset..." ) );
2342 
2343  m_cbLayerPresets->SetSelection( 0 );
2344 
2345  // At least the build in presets should always be present
2346  wxASSERT( !m_layerPresets.empty() );
2347 
2348  // Default preset: all layers
2350 }
wxString name
A name for this layer set.
std::map< wxString, LAYER_PRESET > m_layerPresets
LAYER_PRESET * m_currentPreset
#define _(s)
static LAYER_PRESET presetAllLayers

References _, APPEARANCE_CONTROLS_BASE::m_cbLayerPresets, m_currentPreset, m_layerPresets, LAYER_PRESET::name, and presetAllLayers.

Referenced by OnBoardChanged(), and SetUserLayerPresets().

◆ rebuildLayers()

void APPEARANCE_CONTROLS::rebuildLayers ( )
private

Definition at line 1396 of file appearance_controls.cpp.

1397 {
1398  BOARD* board = m_frame->GetBoard();
1399  LSET enabled = board->GetEnabledLayers();
1400  LSET visible = getVisibleLayers();
1401 
1403  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
1404  bool readOnly = theme->IsReadOnly();
1405 
1406 #ifdef __WXMAC__
1407  wxSizerItem* m_windowLayersSizerItem = m_panelLayersSizer->GetItem( m_windowLayers );
1408  m_windowLayersSizerItem->SetFlag( m_windowLayersSizerItem->GetFlag() & ~wxTOP );
1409 #endif
1410 
1411  auto appendLayer =
1412  [&]( std::unique_ptr<APPEARANCE_SETTING>& aSetting )
1413  {
1414  int layer = aSetting->id;
1415 
1416  wxPanel* panel = new wxPanel( m_windowLayers, layer );
1417  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
1418  panel->SetSizer( sizer );
1419 
1420  panel->SetBackgroundColour( m_layerPanelColour );
1421 
1422  aSetting->visible = visible[layer];
1423 
1424  // TODO(JE) consider restyling this indicator
1425  INDICATOR_ICON* indicator = new INDICATOR_ICON( panel, *m_iconProvider,
1426  ROW_ICON_PROVIDER::STATE::OFF,
1427  layer );
1428 
1429  COLOR_SWATCH* swatch = new COLOR_SWATCH( panel, COLOR4D::UNSPECIFIED, layer,
1430  bgColor, theme->GetColor( layer ),
1431  SWATCH_SMALL );
1432  swatch->SetToolTip( _( "Double click or middle click for color change, "
1433  "right click for menu" ) );
1434 
1435  BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( panel, layer,
1438  aSetting->visible );
1439  btn_visible->SetToolTip( _( "Show or hide this layer" ) );
1440 
1441  wxStaticText* label = new wxStaticText( panel, layer, aSetting->label );
1442  label->Wrap( -1 );
1443  label->SetToolTip( aSetting->tooltip );
1444 
1445  sizer->AddSpacer( 1 );
1446  sizer->Add( indicator, 0, wxALIGN_CENTER_VERTICAL | wxTOP, 2 );
1447  sizer->AddSpacer( 5 );
1448  sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxTOP, 2 );
1449  sizer->AddSpacer( 6 );
1450  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxTOP, 2 );
1451  sizer->AddSpacer( 5 );
1452  sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxTOP, 2 );
1453 
1454  m_layersOuterSizer->Add( panel, 0, wxEXPAND, 0 );
1455 
1456  aSetting->ctl_panel = panel;
1457  aSetting->ctl_indicator = indicator;
1458  aSetting->ctl_visibility = btn_visible;
1459  aSetting->ctl_color = swatch;
1460  aSetting->ctl_text = label;
1461 
1462  panel->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1463  indicator->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1464  swatch->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1465  label->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1466 
1467  btn_visible->Bind( TOGGLE_CHANGED,
1468  [&]( wxCommandEvent& aEvent )
1469  {
1470  wxObject* btn = aEvent.GetEventObject();
1471  int layId = static_cast<wxWindow*>( btn )->GetId();
1472  bool isVisible = aEvent.GetInt();
1473 
1474  wxASSERT( layId >= 0 && layId < PCB_LAYER_ID_COUNT );
1475 
1477  {
1478  static_cast<BITMAP_TOGGLE*>( btn )->SetValue( !isVisible );
1479  return;
1480  }
1481 
1482  onLayerVisibilityChanged( static_cast<PCB_LAYER_ID>( layId ),
1483  isVisible, true );
1484  } );
1485 
1486  swatch->Bind( COLOR_SWATCH_CHANGED, &APPEARANCE_CONTROLS::OnColorSwatchChanged,
1487  this );
1489  this ) );
1490  swatch->SetReadOnly( readOnly );
1491 
1492  panel->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1493  indicator->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1494  swatch->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1495  btn_visible->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1496  label->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1497  };
1498 
1499  auto updateLayer =
1500  [&]( std::unique_ptr<APPEARANCE_SETTING>& aSetting )
1501  {
1502  int layer = aSetting->id;
1503  aSetting->visible = visible[layer];
1504  aSetting->ctl_panel->Show();
1505  aSetting->ctl_panel->SetId( layer );
1506  aSetting->ctl_indicator->SetWindowID( layer );
1507  aSetting->ctl_color->SetWindowID( layer );
1508  aSetting->ctl_color->SetSwatchColor( theme->GetColor( layer ), false );
1509  aSetting->ctl_visibility->SetWindowID( layer );
1510  aSetting->ctl_text->SetLabelText( aSetting->label );
1511  aSetting->ctl_text->SetId( layer );
1512  aSetting->ctl_text->SetToolTip( aSetting->tooltip );
1513  };
1514 
1515  // technical layers are shown in this order:
1516  // Because they are static, wxGetTranslation must be explicitly
1517  // called for tooltips.
1518  static const struct {
1519  PCB_LAYER_ID layerId;
1520  wxString tooltip;
1521  } non_cu_seq[] = {
1522  { F_Adhes, _( "Adhesive on board's front" ) },
1523  { B_Adhes, _( "Adhesive on board's back" ) },
1524  { F_Paste, _( "Solder paste on board's front" ) },
1525  { B_Paste, _( "Solder paste on board's back" ) },
1526  { F_SilkS, _( "Silkscreen on board's front" ) },
1527  { B_SilkS, _( "Silkscreen on board's back" ) },
1528  { F_Mask, _( "Solder mask on board's front" ) },
1529  { B_Mask, _( "Solder mask on board's back" ) },
1530  { Dwgs_User, _( "Explanatory drawings" ) },
1531  { Cmts_User, _( "Explanatory comments" ) },
1532  { Eco1_User, _( "User defined meaning" ) },
1533  { Eco2_User, _( "User defined meaning" ) },
1534  { Edge_Cuts, _( "Board's perimeter definition" ) },
1535  { Margin, _( "Board's edge setback outline" ) },
1536  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
1537  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
1538  { F_Fab, _( "Footprint assembly on board's front" ) },
1539  { B_Fab, _( "Footprint assembly on board's back" ) },
1540  { User_1, _( "User defined layer 1" ) },
1541  { User_2, _( "User defined layer 2" ) },
1542  { User_3, _( "User defined layer 3" ) },
1543  { User_4, _( "User defined layer 4" ) },
1544  { User_5, _( "User defined layer 5" ) },
1545  { User_6, _( "User defined layer 6" ) },
1546  { User_7, _( "User defined layer 7" ) },
1547  { User_8, _( "User defined layer 8" ) },
1548  { User_9, _( "User defined layer 9" ) },
1549  };
1550 
1551  // There is a spacer added to the end of the list that we need to remove and re-add
1552  // after possibly adding additional layers
1553  if( m_layersOuterSizer->GetItemCount() > 0 )
1554  {
1555  m_layersOuterSizer->Detach( m_layersOuterSizer->GetItemCount() - 1 );
1556  }
1557  // Otherwise, this is the first time we are updating the control, so we need to attach
1558  // the handler
1559  else
1560  {
1561  // Add right click handling to show the context menu when clicking to the free area in
1562  // m_windowLayers (below the layer items)
1563  m_windowLayers->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1564  }
1565 
1566  std::size_t total_layers = enabled.CuStack().size();
1567 
1568  for( const auto& entry : non_cu_seq )
1569  {
1570  if( enabled[entry.layerId] )
1571  total_layers++;
1572  }
1573 
1574  // Adds layers to the panel until we have enough to hold our total count
1575  while( total_layers > m_layerSettings.size() )
1576  m_layerSettings.push_back( std::make_unique<APPEARANCE_SETTING>() );
1577 
1578  // We never delete layers from the panel, only hide them. This saves us
1579  // having to recreate the (possibly) later with minimal overhead
1580  for( std::size_t ii = total_layers; ii < m_layerSettings.size(); ++ii )
1581  {
1582  if( m_layerSettings[ii]->ctl_panel )
1583  m_layerSettings[ii]->ctl_panel->Show( false );
1584  }
1585 
1586  auto layer_it = m_layerSettings.begin();
1587 
1588  // show all coppers first, with front on top, back on bottom, then technical layers
1589  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack, ++layer_it )
1590  {
1591  PCB_LAYER_ID layer = *cu_stack;
1592  wxString dsc;
1593 
1594  switch( layer )
1595  {
1596  case F_Cu: dsc = _( "Front copper layer" ); break;
1597  case B_Cu: dsc = _( "Back copper layer" ); break;
1598  default: dsc = _( "Inner copper layer" ); break;
1599  }
1600 
1601  std::unique_ptr<APPEARANCE_SETTING>& setting = *layer_it;
1602 
1603  setting->label = board->GetLayerName( layer );
1604  setting->id = layer;
1605  setting->tooltip = dsc;
1606 
1607  if( setting->ctl_panel == nullptr )
1608  appendLayer( setting );
1609  else
1610  updateLayer( setting );
1611 
1612  m_layerSettingsMap[layer] = setting.get();
1613 
1615  {
1616  setting->ctl_text->Disable();
1617  setting->ctl_color->SetToolTip( wxEmptyString );
1618  }
1619  }
1620 
1621  for( const auto& entry : non_cu_seq )
1622  {
1623  PCB_LAYER_ID layer = entry.layerId;
1624 
1625  if( !enabled[layer] )
1626  continue;
1627 
1628  std::unique_ptr<APPEARANCE_SETTING>& setting = *layer_it;
1629 
1630  setting->label = board->GetLayerName( layer );
1631  setting->id = layer;
1632  setting->tooltip = entry.tooltip;
1633 
1634  if( setting->ctl_panel == nullptr )
1635  appendLayer( setting );
1636  else
1637  updateLayer( setting );
1638 
1639  m_layerSettingsMap[layer] = setting.get();
1640 
1642  {
1643  setting->ctl_text->Disable();
1644  setting->ctl_color->SetToolTip( wxEmptyString );
1645  }
1646 
1647  ++layer_it;
1648  }
1649 
1650  m_layersOuterSizer->AddSpacer( 10 );
1651  m_windowLayers->SetBackgroundColour( m_layerPanelColour );
1652  m_windowLayers->Layout();
1653 }
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:170
std::map< PCB_LAYER_ID, APPEARANCE_SETTING * > m_layerSettingsMap
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:362
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:888
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_layerSettings
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:467
void SetReadOnly(bool aReadOnly=true)
Definition: color_swatch.h:119
void SetReadOnlyCallback(std::function< void()> aCallback)
Registers a handler for when the user tries to interact with a read-only swatch.
Definition: color_swatch.h:125
A checkbox control except with custom bitmaps for the checked and unchecked states.
Definition: bitmap_toggle.h:43
PCB_BASE_FRAME * m_frame
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
representing a row indicator icon for use in places like the layer widget
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
ROW_ICON_PROVIDER * m_iconProvider
#define _(s)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:465
COLOR4D GetColor(int aLayer) const
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:56
void onLayerLeftClick(wxMouseEvent &aEvent)
bool IsReadOnly() const
Definition: json_settings.h:82
PCB background color.
Definition: layer_ids.h:216
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxBoxSizer * m_layersOuterSizer
void rightClickHandler(wxMouseEvent &aEvent)
BOARD * GetBoard() const
void OnColorSwatchChanged(wxCommandEvent &aEvent)
void onLayerVisibilityChanged(PCB_LAYER_ID aLayer, bool isVisible, bool isFinal)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References _, B_Adhes, B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, Cmts_User, LSET::CuStack(), Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, LSET::ForbiddenFootprintLayers(), PCB_BASE_FRAME::GetBoard(), COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), BOARD::GetEnabledLayers(), BOARD::GetLayerName(), getVisibleLayers(), JSON_SETTINGS::IsReadOnly(), KiBitmap(), LAYER_PCB_BACKGROUND, m_frame, m_iconProvider, m_isFpEditor, m_layerPanelColour, m_layerSettings, m_layerSettingsMap, m_layersOuterSizer, APPEARANCE_CONTROLS_BASE::m_panelLayersSizer, APPEARANCE_CONTROLS_BASE::m_windowLayers, Margin, OnColorSwatchChanged(), onLayerLeftClick(), onLayerVisibilityChanged(), onReadOnlySwatch(), PCB_LAYER_ID_COUNT, rightClickHandler(), COLOR_SWATCH::SetReadOnly(), COLOR_SWATCH::SetReadOnlyCallback(), SWATCH_SMALL, User_1, User_2, User_3, User_4, User_5, User_6, User_7, User_8, User_9, visibility, and visibility_off.

Referenced by OnBoardChanged().

◆ rebuildNets()

void APPEARANCE_CONTROLS::rebuildNets ( )
private

Definition at line 2183 of file appearance_controls.cpp.

2184 {
2185  BOARD* board = m_frame->GetBoard();
2187  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
2188 
2189  // If the board isn't fully loaded, we can't yet rebuild
2190  if( !board->GetProject() )
2191  return;
2192 
2193  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
2195 
2196  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2197 
2198  m_netclassOuterSizer->Clear( true );
2199 
2200  auto appendNetclass =
2201  [&]( int aId, const NETCLASSPTR& aClass, bool isDefaultClass = false )
2202  {
2203  wxString name = aClass->GetName();
2204 
2205  m_netclassSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>() );
2206  APPEARANCE_SETTING* setting = m_netclassSettings.back().get();
2207  m_netclassSettingsMap[name] = setting;
2208 
2209  setting->ctl_panel = new wxPanel( m_netclassScrolledWindow, aId );
2210  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
2211  setting->ctl_panel->SetSizer( sizer );
2212  COLOR4D color = netclassColors.count( name ) ? netclassColors.at( name ) :
2213  COLOR4D::UNSPECIFIED;
2214 
2215  setting->ctl_color = new COLOR_SWATCH( setting->ctl_panel, color, aId, bgColor,
2216  COLOR4D::UNSPECIFIED, SWATCH_SMALL );
2217  setting->ctl_color->SetToolTip( _( "Left double click or middle click for color "
2218  "change, right click for menu" ) );
2219 
2220  setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
2222 
2223  // Default netclass can't have an override color
2224  if( isDefaultClass )
2225  setting->ctl_color->Hide();
2226 
2227  setting->ctl_visibility = new BITMAP_TOGGLE( setting->ctl_panel, aId,
2230  true );
2231 
2232  wxString tip;
2233  tip.Printf( _( "Show or hide ratsnest for nets in %s" ), name );
2234  setting->ctl_visibility->SetToolTip( tip );
2235 
2236  setting->ctl_text = new wxStaticText( setting->ctl_panel, aId, name );
2237  setting->ctl_text->Wrap( -1 );
2238 
2239  int flags = wxALIGN_CENTER_VERTICAL;
2240 
2241  sizer->Add( setting->ctl_color, 0, flags | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
2242  sizer->AddSpacer( 7 );
2243  sizer->Add( setting->ctl_visibility, 0, flags, 5 );
2244  sizer->AddSpacer( 3 );
2245  sizer->Add( setting->ctl_text, 1, flags, 5 );
2246 
2247  m_netclassOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 5 );
2248  m_netclassOuterSizer->AddSpacer( 2 );
2249 
2250  setting->ctl_visibility->Bind( TOGGLE_CHANGED,
2252  this );
2253 
2254  auto menuHandler =
2255  [&, name, isDefaultClass]( wxMouseEvent& aEvent )
2256  {
2258 
2259  wxMenu menu;
2260 
2261  if( !isDefaultClass)
2262  {
2263  menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
2264  _( "Set Netclass Color" ), wxEmptyString,
2265  wxITEM_NORMAL ) );
2266  }
2267 
2268  menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
2269  wxString::Format( _( "Highlight Nets in %s" ), name ),
2270  wxEmptyString, wxITEM_NORMAL ) );
2271  menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
2272  wxString::Format( _( "Select Tracks and Vias in %s" ),
2273  name ),
2274  wxEmptyString, wxITEM_NORMAL ) );
2275  menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
2276  wxString::Format( _( "Unselect Tracks and Vias in %s" ),
2277  name ),
2278  wxEmptyString, wxITEM_NORMAL ) );
2279 
2280  menu.AppendSeparator();
2281 
2282  menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS,
2283  _( "Show All Netclasses" ), wxEmptyString,
2284  wxITEM_NORMAL ) );
2285  menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS,
2286  _( "Hide All Other Netclasses" ), wxEmptyString,
2287  wxITEM_NORMAL ) );
2288 
2289  menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
2291 
2292  PopupMenu( &menu );
2293  };
2294 
2295  setting->ctl_panel->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2296  setting->ctl_visibility->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2297  setting->ctl_color->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2298  setting->ctl_text->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2299  };
2300 
2301  const NETCLASS_MAP& classes = board->GetDesignSettings().GetNetClasses().NetClasses();
2302 
2303  std::vector<wxString> names;
2304 
2305  for( const auto& pair : classes )
2306  names.emplace_back( pair.first );
2307 
2308  std::sort( names.begin(), names.end() );
2309 
2310  m_netclassIdMap.clear();
2311 
2312  int idx = wxID_HIGHEST;
2313 
2314  NETCLASSPTR defaultClass = board->GetDesignSettings().GetNetClasses().GetDefault();
2315 
2316  m_netclassIdMap[idx] = defaultClass->GetName();
2317  appendNetclass( idx++, defaultClass, true );
2318 
2319  for( const wxString& name : names )
2320  {
2321  m_netclassIdMap[idx] = name;
2322  appendNetclass( idx++, classes.at( name ) );
2323  }
2324 
2325  m_netclassOuterSizer->Layout();
2326 
2327  m_netsTable->Rebuild();
2328  m_panelNets->GetSizer()->Layout();
2329 }
NETCLASS_MAP & NetClasses()
Provide public access to m_NetClasses so it gets swigged.
Definition: netclass.h:290
std::map< wxString, KIGFX::COLOR4D > & GetNetclassColorMap()
Definition: pcb_painter.h:183
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
std::map< int, wxString > m_netclassIdMap
Stores wxIDs for each netclass for control event mapping.
int color
Definition: DXF_plotter.cpp:57
PROJECT * GetProject() const
Definition: board.h:360
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
A checkbox control except with custom bitmaps for the checked and unchecked states.
Definition: bitmap_toggle.h:43
wxScrolledWindow * m_netclassScrolledWindow
PCB_BASE_FRAME * m_frame
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
PCB specific render settings.
Definition: pcb_painter.h:64
void onNetclassVisibilityChanged(wxCommandEvent &aEvent)
std::map< wxString, APPEARANCE_SETTING * > m_netclassSettingsMap
#define _(s)
NETCLASSES & GetNetClasses() const
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_netclassSettings
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
COLOR4D GetColor(int aLayer) const
const char * name
Definition: DXF_plotter.cpp:56
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
NET_GRID_TABLE * m_netsTable
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:56
void onNetclassColorChanged(wxCommandEvent &aEvent)
PCB background color.
Definition: layer_ids.h:216
Color settings are a bit different than most of the settings objects in that there can be more than o...
NETCLASSPTR GetDefault() const
Definition: netclass.h:253
wxString m_contextMenuNetclass
The name of the netclass that was right-clicked.
void onNetclassContextMenu(wxCommandEvent &aEvent)
BOARD * GetBoard() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References _, color, APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_color, APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_panel, APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_text, APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_visibility, Format(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), NETCLASSES::GetDefault(), BOARD::GetDesignSettings(), KIGFX::PCB_RENDER_SETTINGS::GetNetclassColorMap(), BOARD_DESIGN_SETTINGS::GetNetClasses(), KIGFX::VIEW::GetPainter(), BOARD::GetProject(), KIGFX::PAINTER::GetSettings(), PCB_DRAW_PANEL_GAL::GetView(), ID_DESELECT_NET, ID_HIDE_OTHER_NETS, ID_HIGHLIGHT_NET, ID_SELECT_NET, ID_SET_NET_COLOR, ID_SHOW_ALL_NETS, KiBitmap(), LAYER_PCB_BACKGROUND, m_contextMenuNetclass, m_frame, m_netclassIdMap, APPEARANCE_CONTROLS_BASE::m_netclassOuterSizer, APPEARANCE_CONTROLS_BASE::m_netclassScrolledWindow, m_netclassSettings, m_netclassSettingsMap, m_netsTable, APPEARANCE_CONTROLS_BASE::m_panelNets, name, NETCLASSES::NetClasses(), onNetclassColorChanged(), onNetclassContextMenu(), onNetclassVisibilityChanged(), NET_GRID_TABLE::Rebuild(), SWATCH_SMALL, visibility, and visibility_off.

Referenced by handleBoardItemsChanged(), and OnBoardChanged().

◆ rebuildObjects()

void APPEARANCE_CONTROLS::rebuildObjects ( )
private

Definition at line 1987 of file appearance_controls.cpp.

1988 {
1990  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
1991  GAL_SET visible = getVisibleObjects();
1992  int swatchWidth = m_windowObjects->ConvertDialogToPixels( wxSize( 8, 0 ) ).x;
1993  int labelWidth = 0;
1994 
1995  m_objectSettings.clear();
1996  m_objectsOuterSizer->Clear( true );
1997  m_objectsOuterSizer->AddSpacer( 5 );
1998 
1999  auto appendObject =
2000  [&]( const std::unique_ptr<APPEARANCE_SETTING>& aSetting )
2001  {
2002  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
2003  int layer = aSetting->id;
2004 
2005  aSetting->visible = visible.Contains( ToGalLayer( layer ) );
2006  COLOR4D color = theme->GetColor( layer );
2007  COLOR4D defColor = theme->GetDefaultColor( layer );
2008 
2009  if( color != COLOR4D::UNSPECIFIED )
2010  {
2011  COLOR_SWATCH* swatch = new COLOR_SWATCH( m_windowObjects, color, layer,
2012  bgColor, defColor, SWATCH_SMALL );
2013  swatch->SetToolTip( _( "Left double click or middle click for color change, "
2014  "right click for menu" ) );
2015 
2016  sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL, 0 );
2017  aSetting->ctl_color = swatch;
2018 
2019  swatch->Bind( COLOR_SWATCH_CHANGED,
2021 
2023  this ) );
2024  }
2025  else
2026  {
2027  sizer->AddSpacer( swatchWidth );
2028  }
2029 
2030  BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( m_windowObjects, layer,
2033  aSetting->visible );
2034 
2035  wxString tip;
2036  tip.Printf( _( "Show or hide %s" ), aSetting->label.Lower() );
2037  btn_visible->SetToolTip( tip );
2038 
2039  aSetting->ctl_visibility = btn_visible;
2040 
2041  sizer->AddSpacer( 5 );
2042 
2043  btn_visible->Bind( TOGGLE_CHANGED,
2044  [&]( wxCommandEvent& aEvent )
2045  {
2046  int id = static_cast<wxWindow*>( aEvent.GetEventObject() )->GetId();
2047  bool isVisible = aEvent.GetInt();
2048  onObjectVisibilityChanged( ToGalLayer( id ), isVisible, true );
2049  } );
2050 
2051  wxStaticText* label = new wxStaticText( m_windowObjects, layer, aSetting->label );
2052  label->Wrap( -1 );
2053  label->SetToolTip( aSetting->tooltip );
2054 
2055  if( aSetting->can_control_opacity )
2056  {
2057  label->SetMinSize( wxSize( labelWidth, -1 ) );
2058 #ifdef __WXMAC__
2059  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
2060  sizer->AddSpacer( 5 );
2061  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
2062 #else
2063  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
2064  sizer->AddSpacer( 5 );
2065  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
2066 #endif
2067 
2068  wxSlider* slider = new wxSlider( m_windowObjects, wxID_ANY, 100, 0, 100,
2069  wxDefaultPosition, wxDefaultSize,
2070  wxSL_HORIZONTAL );
2071 #ifdef __WXMAC__
2072  slider->SetMinSize( wxSize( 80, 16 ) );
2073 #else
2074  slider->SetMinSize( wxSize( 80, -1 ) );
2075 #endif
2076 
2077  tip.Printf( _( "Set opacity of %s" ), aSetting->label.Lower() );
2078  slider->SetToolTip( tip );
2079 
2080  sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5 );
2081  aSetting->ctl_opacity = slider;
2082 
2083  auto opacitySliderHandler =
2084  [=]( wxCommandEvent& aEvent )
2085  {
2086  wxSlider* ctrl = static_cast<wxSlider*>( aEvent.GetEventObject() );
2087  int value = ctrl->GetValue();
2088  onObjectOpacitySlider( layer, value / 100.0f );
2089  };
2090 
2091  slider->Bind( wxEVT_SCROLL_CHANGED, opacitySliderHandler );
2092  slider->Bind( wxEVT_SCROLL_THUMBTRACK, opacitySliderHandler );
2093  slider->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
2094  }
2095  else
2096  {
2097  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
2098  sizer->AddSpacer( 5 );
2099  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
2100  }
2101 
2102  aSetting->ctl_text = label;
2103  m_objectsOuterSizer->Add( sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 5 );
2104 
2105  if( !aSetting->can_control_opacity )
2106  m_objectsOuterSizer->AddSpacer( 2 );
2107  };
2108 
2109  for( const APPEARANCE_SETTING& s_setting : s_objectSettings )
2110  {
2111  if( m_isFpEditor && !s_allowedInFpEditor.count( s_setting.id ) )
2112  continue;
2113 
2114  if( !s_setting.spacer )
2115  {
2116  m_objectSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>( s_setting ) );
2117 
2118  std::unique_ptr<APPEARANCE_SETTING>& setting = m_objectSettings.back();
2119 
2120  // Because s_render_rows is created static, we must explicitly call
2121  // wxGetTranslation for texts which are internationalized (tool tips
2122  // and item names)
2123  setting->tooltip = wxGetTranslation( s_setting.tooltip );
2124  setting->label = wxGetTranslation( s_setting.label );
2125 
2126  if( setting->can_control_opacity )
2127  {
2128  int width = m_windowObjects->GetTextExtent( setting->label ).x + 5;
2129  labelWidth = std::max( labelWidth, width );
2130  }
2131 
2132  m_objectSettingsMap[ToGalLayer( setting->id )] = setting.get();
2133  }
2134  }
2135 
2136  for( const std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
2137  {
2138  if( setting->spacer )
2139  m_objectsOuterSizer->AddSpacer( m_pointSize );
2140  else
2141  appendObject( setting );
2142  }
2143 
2144  m_objectsOuterSizer->Layout();
2145 }
static std::set< int > s_allowedInFpEditor
These GAL layers are shown in the Objects tab in the footprint editor.
void onObjectOpacitySlider(int aLayer, float aOpacity)
int color
Definition: DXF_plotter.cpp:57
GAL_LAYER_ID ToGalLayer(int aInteger)
Definition: layer_ids.h:262
void SetReadOnlyCallback(std::function< void()> aCallback)
Registers a handler for when the user tries to interact with a read-only swatch.
Definition: color_swatch.h:125
std::map< GAL_LAYER_ID, APPEARANCE_SETTING * > m_objectSettingsMap
A checkbox control except with custom bitmaps for the checked and unchecked states.
Definition: bitmap_toggle.h:43
PCB_BASE_FRAME * m_frame
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
void OnSetFocus(wxFocusEvent &aEvent) override
COLOR4D GetDefaultColor(int aLayer)
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:279
#define _(s)
wxBoxSizer * m_objectsOuterSizer
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
COLOR4D GetColor(int aLayer) const
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_objectSettings
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:56
void onObjectVisibilityChanged(GAL_LAYER_ID aLayer, bool isVisible, bool isFinal)
PCB background color.
Definition: layer_ids.h:216
Color settings are a bit different than most of the settings objects in that there can be more than o...
void OnColorSwatchChanged(wxCommandEvent &aEvent)
static const APPEARANCE_SETTING s_objectSettings[]
Template for object appearance settings.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
bool Contains(GAL_LAYER_ID aPos)
Definition: layer_ids.h:313

References _, color, GAL_SET::Contains(), COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), COLOR_SETTINGS::GetDefaultColor(), getVisibleObjects(), KiBitmap(), LAYER_PCB_BACKGROUND, m_frame, m_isFpEditor, m_objectSettings, m_objectSettingsMap, m_objectsOuterSizer, m_pointSize, APPEARANCE_CONTROLS_BASE::m_windowObjects, OnColorSwatchChanged(), onObjectOpacitySlider(), onObjectVisibilityChanged(), onReadOnlySwatch(), OnSetFocus(), s_allowedInFpEditor, s_objectSettings, COLOR_SWATCH::SetReadOnlyCallback(), SWATCH_SMALL, ToGalLayer(), visibility, and visibility_off.

Referenced by APPEARANCE_CONTROLS().

◆ RefreshCollapsiblePanes()

void APPEARANCE_CONTROLS::RefreshCollapsiblePanes ( )

Function to force a redraw of the collapsible panes in this control.

Definition at line 2968 of file appearance_controls.cpp.

2969 {
2970  m_paneLayerDisplayOptions->Refresh();
2971 }
WX_COLLAPSIBLE_PANE * m_paneLayerDisplayOptions

References m_paneLayerDisplayOptions.

Referenced by PCB_BASE_EDIT_FRAME::handleActivateEvent().

◆ rightClickHandler()

void APPEARANCE_CONTROLS::rightClickHandler ( wxMouseEvent &  aEvent)
private

Definition at line 1881 of file appearance_controls.cpp.

1882 {
1883  wxASSERT( m_layerContextMenu );
1884  PopupMenu( m_layerContextMenu );
1885  passOnFocus();
1886 };

References m_layerContextMenu, and passOnFocus().

Referenced by rebuildLayers().

◆ SetLayerVisible()

void APPEARANCE_CONTROLS::SetLayerVisible ( LAYER_NUM  aLayer,
bool  isVisible 
)

Definition at line 1135 of file appearance_controls.cpp.

1136 {
1137  LSET visible = getVisibleLayers();
1138  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
1139 
1140  if( visible.test( layer ) == isVisible )
1141  return;
1142 
1143  visible.set( layer, isVisible );
1144  setVisibleLayers( visible );
1145 
1146  m_frame->GetCanvas()->GetView()->SetLayerVisible( layer, isVisible );
1147 
1149 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * m_frame
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
void setVisibleLayers(LSET aLayers)
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:388
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905

References PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), getVisibleLayers(), m_frame, KIGFX::VIEW::SetLayerVisible(), setVisibleLayers(), syncColorsAndVisibility(), and ToLAYER_ID().

Referenced by DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), DIALOG_DRC::OnDRCItemSelected(), OnLayerContextMenu(), DIALOG_FOOTPRINT_CHECKER::OnSelectItem(), DRAWING_TOOL::PlaceText(), and ROUTER_TOOL::prepareInteractive().

◆ SetObjectVisible()

void APPEARANCE_CONTROLS::SetObjectVisible ( GAL_LAYER_ID  aLayer,
bool  isVisible = true 
)

Update the manual layer alpha overrides.

Definition at line 1152 of file appearance_controls.cpp.

1153 {
1154  if( m_objectSettingsMap.count( aLayer ) )
1155  {
1156  APPEARANCE_SETTING* setting = m_objectSettingsMap.at( aLayer );
1157  setting->ctl_visibility->SetValue( isVisible );
1158  }
1159 
1160  m_frame->GetBoard()->SetElementVisibility( aLayer, isVisible );
1161 
1162  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1163  m_frame->GetCanvas()->Refresh();
1164 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:539
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
std::map< GAL_LAYER_ID, APPEARANCE_SETTING * > m_objectSettingsMap
PCB_BASE_FRAME * m_frame
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:388
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
BOARD * GetBoard() const

References APPEARANCE_CONTROLS::APPEARANCE_SETTING::ctl_visibility, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), m_frame, m_objectSettingsMap, EDA_DRAW_PANEL_GAL::Refresh(), BOARD::SetElementVisibility(), KIGFX::VIEW::SetLayerVisible(), and BITMAP_TOGGLE::SetValue().

Referenced by APPEARANCE_CONTROLS(), PCB_BASE_EDIT_FRAME::SetGridVisibility(), and PCB_BASE_EDIT_FRAME::SetObjectVisible().

◆ SetTabIndex()

void APPEARANCE_CONTROLS::SetTabIndex ( int  aTab)

Definition at line 1810 of file appearance_controls.cpp.

1811 {
1812  size_t max = m_notebook->GetPageCount();
1813 
1814  if( aTab >= 0 && static_cast<size_t>( aTab ) < max )
1815  m_notebook->SetSelection( aTab );
1816 }

References APPEARANCE_CONTROLS_BASE::m_notebook.

◆ SetUserLayerPresets()

void APPEARANCE_CONTROLS::SetUserLayerPresets ( std::vector< LAYER_PRESET > &  aPresetList)

Definition at line 1335 of file appearance_controls.cpp.

1336 {
1337  // Reset to defaults
1339 
1340  for( const LAYER_PRESET& preset : aPresetList )
1341  {
1342  if( m_layerPresets.count( preset.name ) )
1343  continue;
1344 
1345  m_layerPresets[preset.name] = preset;
1346 
1347  m_presetMRU.Add( preset.name );
1348  }
1349 
1351 }
A saved set of layers that are visible.
std::map< wxString, LAYER_PRESET > m_layerPresets

References loadDefaultLayerPresets(), m_layerPresets, m_presetMRU, and rebuildLayerPresetsWidget().

Referenced by PCB_EDIT_FRAME::LoadProjectSettings().

◆ setVisibleLayers()

void APPEARANCE_CONTROLS::setVisibleLayers ( LSET  aLayers)
private

Definition at line 1167 of file appearance_controls.cpp.

1168 {
1169  if( m_isFpEditor )
1170  {
1171  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1172 
1173  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1174  view->SetLayerVisible( layer, aLayers.Contains( layer ) );
1175  }
1176  else
1177  {
1178  m_frame->GetBoard()->SetVisibleLayers( aLayers );
1179  }
1180 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: layer_ids.h:575
PCB_BASE_FRAME * m_frame
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:499
static LSET AllLayersMask()
Definition: lset.cpp:787
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:388
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68

References LSET::AllLayersMask(), LSET::Contains(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), m_frame, m_isFpEditor, KIGFX::VIEW::SetLayerVisible(), and BOARD::SetVisibleLayers().

Referenced by doApplyLayerPreset(), OnLayerContextMenu(), onLayerVisibilityChanged(), and SetLayerVisible().

◆ setVisibleObjects()

void APPEARANCE_CONTROLS::setVisibleObjects ( GAL_SET  aObjects)
private

Definition at line 1183 of file appearance_controls.cpp.

1184 {
1185  if( m_isFpEditor )
1186  {
1187  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1188 
1189  for( size_t i = 0; i < GAL_LAYER_INDEX( LAYER_ZONE_START ); i++ )
1190  view->SetLayerVisible( GAL_LAYER_ID_START + GAL_LAYER_ID( i ), aLayers.test( i ) );
1191  }
1192  else
1193  {
1194  // Ratsnest visibility is controlled by the ratsnest option, and not by the preset
1195  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
1196  {
1198  aLayers.set( LAYER_RATSNEST, opt.m_ShowGlobalRatsnest );
1199  }
1200 
1201  m_frame->GetBoard()->SetVisibleElements( aLayers );
1202  }
1203 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:185
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:506
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCB_BASE_FRAME * m_frame
Container for display options like enable/disable some optional drawings.
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
Definition: layer_ids.h:249
Virtual layers for stacking zones and tracks on a given copper layer.
Definition: layer_ids.h:242
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:388
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
bool IsType(FRAME_T aType) const
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68

References FRAME_PCB_EDITOR, GAL_LAYER_ID_START, GAL_LAYER_INDEX, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), PCB_DRAW_PANEL_GAL::GetView(), EDA_BASE_FRAME::IsType(), LAYER_RATSNEST, LAYER_ZONE_START, m_frame, m_isFpEditor, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, GAL_SET::set(), KIGFX::VIEW::SetLayerVisible(), and BOARD::SetVisibleElements().

Referenced by doApplyLayerPreset(), and onObjectVisibilityChanged().

◆ showNetclass()

void APPEARANCE_CONTROLS::showNetclass ( const wxString &  aClassName,
bool  aShow = true 
)
private

Definition at line 2659 of file appearance_controls.cpp.

2660 {
2661  BOARD* board = m_frame->GetBoard();
2662  NETINFO_LIST& nets = board->GetNetInfo();
2663  NETCLASSES& classes = board->GetDesignSettings().GetNetClasses();
2664  NETCLASSPTR netclass = classes.Find( aClassName );
2665  TOOL_MANAGER* manager = m_frame->GetToolManager();
2666 
2667  if( !netclass )
2668  return;
2669 
2670  NETCLASS* defaultClass = classes.GetDefaultPtr();
2671 
2672  if( netclass == classes.GetDefault() )
2673  {
2674  const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
2675 
2676  for( NETINFO_ITEM* net : nets )
2677  {
2678  if( net->GetNetClass() == defaultClass )
2679  {
2680  manager->RunAction( action, true, static_cast<intptr_t>( net->GetNetCode() ) );
2681 
2682  int row = m_netsTable->GetRowByNetcode( net->GetNetCode() );
2683 
2684  if( row >= 0 )
2686  }
2687  }
2688  }
2689  else
2690  {
2691  const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
2692 
2693  for( const wxString& member : *netclass )
2694  {
2695  if( NETINFO_ITEM* net = nets.GetNetItem( member ) )
2696  {
2697  int code = net->GetNetCode();
2698  manager->RunAction( action, true, static_cast<intptr_t>( code ) );
2699 
2700  int row = m_netsTable->GetRowByNetcode( code );
2701 
2702  if( row >= 0 )
2704  }
2705  }
2706  }
2707 
2708  m_netsGrid->ForceRefresh();
2709 }
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
static TOOL_ACTION hideNet
Definition: pcb_actions.h:456
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:679
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
PCB_BASE_FRAME * m_frame
Master controller class:
Definition: tool_manager.h:54
A container for NETCLASS instances.
Definition: netclass.h:218
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:315
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
NETCLASSES & GetNetClasses() const
NETCLASS * GetDefaultPtr() const
Definition: netclass.h:258
int GetRowByNetcode(int aCode) const
void SetValueAsBool(int aRow, int aCol, bool aValue) override
Handle the data for a net.
Definition: netinfo.h:64
static TOOL_ACTION showNet
Definition: pcb_actions.h:457
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
Represent a single user action.
Definition: tool_action.h:67
NET_GRID_TABLE * m_netsTable
NETCLASSPTR GetDefault() const
Definition: netclass.h:253
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
BOARD * GetBoard() const

References NET_GRID_TABLE::COL_VISIBILITY, NETCLASSES::Find(), PCB_BASE_FRAME::GetBoard(), NETCLASSES::GetDefault(), NETCLASSES::GetDefaultPtr(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetNetClasses(), BOARD::GetNetInfo(), NETINFO_LIST::GetNetItem(), NET_GRID_TABLE::GetRowByNetcode(), TOOLS_HOLDER::GetToolManager(), PCB_ACTIONS::hideNet, m_frame, APPEARANCE_CONTROLS_BASE::m_netsGrid, m_netsTable, TOOL_MANAGER::RunAction(), NET_GRID_TABLE::SetValueAsBool(), and PCB_ACTIONS::showNet.

Referenced by onNetclassContextMenu(), and onNetclassVisibilityChanged().

◆ syncColorsAndVisibility()

void APPEARANCE_CONTROLS::syncColorsAndVisibility ( )
private

Definition at line 1819 of file appearance_controls.cpp.

1820 {
1822  bool readOnly = theme->IsReadOnly();
1823  LSET visible = getVisibleLayers();
1824  GAL_SET objects = getVisibleObjects();
1825 
1826  Freeze();
1827 
1828  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_layerSettings )
1829  {
1830  LAYER_NUM layer = setting->id;
1831 
1832  if( setting->ctl_visibility )
1833  setting->ctl_visibility->SetValue( visible[layer] );
1834 
1835  if( setting->ctl_color )
1836  {
1837  const COLOR4D& color = theme->GetColor( layer );
1838  setting->ctl_color->SetSwatchColor( color, false );
1839  setting->ctl_color->SetReadOnly( readOnly );
1840  }
1841  }
1842 
1843  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
1844  {
1845  GAL_LAYER_ID layer = static_cast<GAL_LAYER_ID>( setting->id );
1846 
1847  if( setting->ctl_visibility )
1848  setting->ctl_visibility->SetValue( objects.Contains( layer ) );
1849 
1850  if( setting->ctl_color )
1851  {
1852  const COLOR4D& color = theme->GetColor( layer );
1853  setting->ctl_color->SetSwatchColor( color, false );
1854  setting->ctl_color->SetReadOnly( readOnly );
1855  }
1856  }
1857 
1858  // Update indicators and panel background colors
1859  OnLayerChanged();
1860 
1861  Thaw();
1862 
1863  m_windowLayers->Refresh();
1864 }
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_layerSettings
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:185
int color
Definition: DXF_plotter.cpp:57
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
PCB_BASE_FRAME * m_frame
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:279
COLOR4D GetColor(int aLayer) const
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_objectSettings
bool IsReadOnly() const
Definition: json_settings.h:82
Color settings are a bit different than most of the settings objects in that there can be more than o...
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
bool Contains(GAL_LAYER_ID aPos)
Definition: layer_ids.h:313

References color, GAL_SET::Contains(), COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), getVisibleLayers(), getVisibleObjects(), JSON_SETTINGS::IsReadOnly(), m_frame, m_layerSettings, m_objectSettings, APPEARANCE_CONTROLS_BASE::m_windowLayers, and OnLayerChanged().

Referenced by doApplyLayerPreset(), OnBoardChanged(), OnColorThemeChanged(), OnLayerContextMenu(), and SetLayerVisible().

◆ syncLayerPresetSelection()

void APPEARANCE_CONTROLS::syncLayerPresetSelection ( )
private

Definition at line 2353 of file appearance_controls.cpp.

2354 {
2355  LSET visibleLayers = getVisibleLayers();
2356  GAL_SET visibleObjects = getVisibleObjects();
2357 
2358  auto it = std::find_if( m_layerPresets.begin(), m_layerPresets.end(),
2359  [&]( const std::pair<const wxString, LAYER_PRESET>& aPair )
2360  {
2361  return ( aPair.second.layers == visibleLayers
2362  && aPair.second.renderLayers == visibleObjects );
2363  } );
2364 
2365  if( it != m_layerPresets.end() )
2366  m_cbLayerPresets->SetStringSelection( it->first );
2367  else
2368  m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 ); // separator
2369 
2370  m_currentPreset = static_cast<LAYER_PRESET*>(
2371  m_cbLayerPresets->GetClientData( m_cbLayerPresets->GetSelection() ) );
2372 }
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
std::map< wxString, LAYER_PRESET > m_layerPresets
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:279
LAYER_PRESET * m_currentPreset

References getVisibleLayers(), getVisibleObjects(), APPEARANCE_CONTROLS_BASE::m_cbLayerPresets, m_currentPreset, and m_layerPresets.

Referenced by OnBoardChanged(), OnLayerContextMenu(), onLayerVisibilityChanged(), and onObjectVisibilityChanged().

◆ syncObjectSettings()

void APPEARANCE_CONTROLS::syncObjectSettings ( )
private

Definition at line 2148 of file appearance_controls.cpp.

2149 {
2150  GAL_SET visible = getVisibleObjects();
2151 
2153 
2154  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
2155  {
2156  if( setting->spacer )
2157  continue;
2158 
2159  GAL_LAYER_ID layer = ToGalLayer( setting->id );
2160 
2161  if( setting->ctl_visibility )
2162  setting->ctl_visibility->SetValue( visible.Contains( layer ) );
2163 
2164  if( setting->ctl_color )
2165  {
2166  COLOR4D color = m_frame->GetColorSettings()->GetColor( setting->id );
2167  setting->ctl_color->SetSwatchColor( color, false );
2168  }
2169  }
2170 
2171  wxASSERT( m_objectSettingsMap.count( LAYER_TRACKS )
2172  && m_objectSettingsMap.count( LAYER_VIAS )
2173  && m_objectSettingsMap.count( LAYER_PADS )
2174  && m_objectSettingsMap.count( LAYER_ZONES ) );
2175 
2176  m_objectSettingsMap[LAYER_TRACKS]->ctl_opacity->SetValue( opts.m_TrackOpacity * 100 );
2177  m_objectSettingsMap[LAYER_VIAS]->ctl_opacity->SetValue( opts.m_ViaOpacity * 100 );
2178  m_objectSettingsMap[LAYER_PADS]->ctl_opacity->SetValue( opts.m_PadOpacity * 100 );
2179  m_objectSettingsMap[LAYER_ZONES]->ctl_opacity->SetValue( opts.m_ZoneOpacity * 100 );
2180 }
Meta control for all pads opacity/visibility (color ignored)
Definition: