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 *aBoardItem) override
 
void OnBoardItemsAdded (BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
 
void OnBoardItemRemoved (BOARD &aBoard, BOARD_ITEM *aBoardItem) override
 
void OnBoardItemsRemoved (BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
 
void OnBoardItemChanged (BOARD &aBoard, BOARD_ITEM *aBoardItem) override
 
void OnBoardItemsChanged (BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) 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_staticText14
 
BITMAP_BUTTONm_btnConfigureNetClasses
 
wxScrolledWindow * m_netclassScrolledWindow
 
wxBoxSizer * m_netclassOuterSizer
 
wxStaticText * presetsLabel
 
wxStaticText * presetsHotkey
 
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 onNetColorModeChanged (wxCommandEvent &aEvent)
 
void onRatsnestModeChanged (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_staticTextContrastModeTitle
 
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_rbRatsnestVisibleLayers
 

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 454 of file appearance_controls.h.

455  {
456  ID_CHANGE_COLOR = wxID_HIGHEST,
477  };

Constructor & Destructor Documentation

◆ APPEARANCE_CONTROLS()

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

Definition at line 403 of file appearance_controls.cpp.

404  :
405  APPEARANCE_CONTROLS_BASE( aParent ),
406  m_frame( aParent ),
407  m_focusOwner( aFocusOwner ),
408  m_board( nullptr ),
409  m_isFpEditor( aFpEditorMode ),
410  m_currentPreset( nullptr ),
411  m_lastSelectedUserPreset( nullptr ),
412  m_layerContextMenu( nullptr )
413 {
414  int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x;
415  m_iconProvider = new ROW_ICON_PROVIDER( indicatorSize );
416  int pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
417  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
418 
419  m_layerPanelColour = m_panelLayers->GetBackgroundColour().ChangeLightness( 110 );
420 
421  m_layersOuterSizer = new wxBoxSizer( wxVERTICAL );
422  m_windowLayers->SetSizer( m_layersOuterSizer );
423  m_windowLayers->SetScrollRate( 0, 5 );
424  m_windowLayers->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
425 
426  m_objectsOuterSizer = new wxBoxSizer( wxVERTICAL );
428  m_windowObjects->SetScrollRate( 0, 5 );
429  m_windowObjects->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
430 
431  createControls();
432 
435 
438 
439  m_txtNetFilter->SetHint( _( "Filter nets" ) );
440 
441  if( screenHeight <= 900 && pointSize >= indicatorSize )
442  pointSize = pointSize * 8 / 10;
443 
444  m_pointSize = pointSize;
445  wxFont font = m_notebook->GetFont();
446 
447 #ifdef __WXMAC__
448  font.SetPointSize( m_pointSize );
449  m_notebook->SetFont( font );
450 #endif
451 
452  auto setHighContrastMode =
453  [&]( HIGH_CONTRAST_MODE aMode )
454  {
456  opts.m_ContrastModeDisplay = aMode;
457 
458  m_frame->SetDisplayOptions( opts );
459  passOnFocus();
460  };
461 
462  m_rbHighContrastNormal->Bind( wxEVT_RADIOBUTTON,
463  [=]( wxCommandEvent& aEvent )
464  {
465  setHighContrastMode( HIGH_CONTRAST_MODE::NORMAL );
466  } );
467 
468  m_rbHighContrastDim->Bind( wxEVT_RADIOBUTTON,
469  [=]( wxCommandEvent& aEvent )
470  {
471  setHighContrastMode( HIGH_CONTRAST_MODE::DIMMED );
472  } );
473 
474  m_rbHighContrastOff->Bind( wxEVT_RADIOBUTTON,
475  [=]( wxCommandEvent& aEvent )
476  {
477  setHighContrastMode( HIGH_CONTRAST_MODE::HIDDEN );
478  } );
479 
480  m_cbLayerPresets->Bind( wxEVT_CHOICE, &APPEARANCE_CONTROLS::onLayerPresetChanged, this );
481 
482  m_btnNetInspector->Bind( wxEVT_BUTTON,
483  [&]( wxCommandEvent& aEvent )
484  {
486  passOnFocus();
487  } );
488 
489  m_btnConfigureNetClasses->Bind( wxEVT_BUTTON,
490  [&]( wxCommandEvent& aEvent )
491  {
492  // This panel should only be visible in the PCB_EDIT_FRAME anyway
493  if( PCB_EDIT_FRAME* editframe = dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) )
494  editframe->ShowBoardSetupDialog( _( "Net Classes" ) );
495 
496  passOnFocus();
497  } );
498 
499  m_cbFlipBoard->SetValue( m_frame->GetCanvas()->GetView()->IsMirroredX() );
500  m_cbFlipBoard->Bind( wxEVT_CHECKBOX,
501  [&]( wxCommandEvent& aEvent )
502  {
504  } );
505 
508 
509  m_netsGrid->RegisterDataType( wxT( "bool" ), m_toggleGridRenderer, new wxGridCellBoolEditor );
510 
511  // TODO(JE) Update background color of swatch renderer when theme changes
512  m_netsGrid->RegisterDataType( wxT( "COLOR4D" ),
515 
516  m_netsTable = new NET_GRID_TABLE( m_frame, m_panelNets->GetBackgroundColour() );
517  m_netsGrid->SetTable( m_netsTable, true );
519 
520  m_netsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
521  m_netsGrid->SetSelectionForeground( m_netsGrid->GetDefaultCellTextColour() );
522  m_netsGrid->SetSelectionBackground( m_panelNets->GetBackgroundColour() );
523 
524  const int cellPadding = 6;
525 #ifdef __WXMAC__
526  const int rowHeightPadding = 5;
527 #else
528  const int rowHeightPadding = 3;
529 #endif
530 
531  wxSize size = ConvertDialogToPixels( SWATCH_SIZE_SMALL_DU );
532  m_netsGrid->SetColSize( NET_GRID_TABLE::COL_COLOR, size.x + cellPadding );
533 
534  size = KiBitmap( BITMAPS::visibility ).GetSize();
535  m_netsGrid->SetColSize( NET_GRID_TABLE::COL_VISIBILITY, size.x + cellPadding );
536 
537  m_netsGrid->SetDefaultCellFont( font );
538  m_netsGrid->SetDefaultRowSize( font.GetPixelSize().y + rowHeightPadding );
539 
540  m_netsGrid->GetGridWindow()->Bind( wxEVT_MOTION,
542 
543  // To handle middle click on color swatches
544  m_netsGrid->GetGridWindow()->Bind( wxEVT_MIDDLE_UP,
546 
547  m_netsGrid->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_DEFAULT );
548  m_netclassScrolledWindow->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_DEFAULT );
549 
550  if( m_isFpEditor )
551  m_notebook->RemovePage( 2 );
552 
554  rebuildObjects();
555  OnBoardChanged();
556 
557  // Grid visibility is loaded and set to the GAL before we are constructed
559 
560  Bind( wxEVT_COMMAND_MENU_SELECTED, &APPEARANCE_CONTROLS::OnLayerContextMenu, this,
562 }
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.
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:65
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:237
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:345
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:295
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:49
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(), 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, m_rbHighContrastDim, m_rbHighContrastNormal, m_rbHighContrastOff, 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 565 of file appearance_controls.cpp.

566 {
567  delete m_iconProvider;
568 }
ROW_ICON_PROVIDER * m_iconProvider

References m_iconProvider.

Member Function Documentation

◆ ApplyLayerPreset() [1/2]

void APPEARANCE_CONTROLS::ApplyLayerPreset ( const wxString &  aPresetName)

Definition at line 1334 of file appearance_controls.cpp.

1335 {
1336  updateLayerPresetSelection( aPresetName );
1337 
1338  wxCommandEvent dummy;
1340 }
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:71
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 1343 of file appearance_controls.cpp.

1344 {
1345  if( m_layerPresets.count( aPreset.name ) )
1346  m_currentPreset = &m_layerPresets[aPreset.name];
1347  else
1348  m_currentPreset = nullptr;
1349 
1351  : nullptr;
1352 
1353  updateLayerPresetSelection( aPreset.name );
1354  doApplyLayerPreset( aPreset );
1355 }
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 571 of file appearance_controls.cpp.

572 {
573  // Create layer display options
575  _( "Layer Display Options" ) );
577  m_paneLayerDisplayOptions->SetBackgroundColour( m_notebook->GetThemeBackgroundColour() );
578 
579  wxWindow* layerDisplayPane = m_paneLayerDisplayOptions->GetPane();
580 
581  wxBoxSizer* layerDisplayOptionsSizer;
582  layerDisplayOptionsSizer = new wxBoxSizer( wxVERTICAL );
583 
584  m_staticTextContrastModeTitle = new wxStaticText( layerDisplayPane, wxID_ANY,
585  _( "Inactive layers:" ), wxDefaultPosition,
586  wxDefaultSize, 0 );
587  m_staticTextContrastModeTitle->Wrap( -1 );
588  layerDisplayOptionsSizer->Add( m_staticTextContrastModeTitle, 0,
589  wxEXPAND | wxBOTTOM | wxLEFT, 2 );
590 
591  wxBoxSizer* contrastModeSizer;
592  contrastModeSizer = new wxBoxSizer( wxHORIZONTAL );
593 
594  m_rbHighContrastNormal = new wxRadioButton( layerDisplayPane, wxID_ANY, _( "Normal" ),
595  wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
596  m_rbHighContrastNormal->SetValue( true );
597  m_rbHighContrastNormal->SetToolTip( _( "Inactive layers will be shown in full color" ) );
598 
599  contrastModeSizer->Add( m_rbHighContrastNormal, 0, wxRIGHT, 4 );
600 
601  m_rbHighContrastDim = new wxRadioButton( layerDisplayPane, wxID_ANY, _( "Dim" ),
602  wxDefaultPosition, wxDefaultSize, 0 );
603  m_rbHighContrastDim->SetToolTip( _( "Inactive layers will be dimmed" ) );
604 
605  contrastModeSizer->Add( m_rbHighContrastDim, 0, wxRIGHT | wxLEFT, 10 );
606 
607  m_rbHighContrastOff = new wxRadioButton( layerDisplayPane, wxID_ANY, _( "Hide" ),
608  wxDefaultPosition, wxDefaultSize, 0 );
609  m_rbHighContrastOff->SetToolTip( _( "Inactive layers will be hidden" ) );
610 
611  contrastModeSizer->Add( m_rbHighContrastOff, 0, 0, 5 );
612 
613  layerDisplayOptionsSizer->Add( contrastModeSizer, 0, wxEXPAND, 5 );
614 
615  m_layerDisplaySeparator = new wxStaticLine( layerDisplayPane, wxID_ANY, wxDefaultPosition,
616  wxDefaultSize, wxLI_HORIZONTAL );
617  layerDisplayOptionsSizer->Add( m_layerDisplaySeparator, 0, wxEXPAND | wxTOP | wxBOTTOM, 5 );
618 
619  m_cbFlipBoard = new wxCheckBox( layerDisplayPane, wxID_ANY, _( "Flip board view" ),
620  wxDefaultPosition, wxDefaultSize, 0 );
621  layerDisplayOptionsSizer->Add( m_cbFlipBoard, 0, 0, 5 );
622 
623  layerDisplayPane->SetSizer( layerDisplayOptionsSizer );
624  layerDisplayPane->Layout();
625  layerDisplayOptionsSizer->Fit( layerDisplayPane );
626 
627  m_panelLayersSizer->Add( m_paneLayerDisplayOptions, 0, wxEXPAND | wxTOP, 5 );
628 
629  m_paneLayerDisplayOptions->Bind( WX_COLLAPSIBLE_PANE_CHANGED,
630  [&]( wxCommandEvent& aEvent )
631  {
632  Freeze();
633  m_panelLayers->Fit();
634  m_sizerOuter->Layout();
635  Thaw();
636  } );
637 
638  // Create net display options
639 
641  _( "Net Display Options" ) );
643  m_paneNetDisplayOptions->SetBackgroundColour( m_notebook->GetThemeBackgroundColour() );
644 
645  wxWindow* netDisplayPane = m_paneNetDisplayOptions->GetPane();
646  wxBoxSizer* netDisplayOptionsSizer = new wxBoxSizer( wxVERTICAL );
647 
649 
650  m_txtNetDisplayTitle = new wxStaticText( netDisplayPane, wxID_ANY, _( "Net colors:" ),
651  wxDefaultPosition, wxDefaultSize, 0 );
652  m_txtNetDisplayTitle->Wrap( -1 );
653  m_txtNetDisplayTitle->SetToolTip( _( "Choose when to show net and netclass colors" ) );
654 
655  netDisplayOptionsSizer->Add( m_txtNetDisplayTitle, 0, wxEXPAND | wxBOTTOM | wxLEFT, 2 );
656 
657  wxBoxSizer* netColorSizer = new wxBoxSizer( wxHORIZONTAL );
658 
659  m_rbNetColorAll = new wxRadioButton( netDisplayPane, wxID_ANY, _( "All" ), wxDefaultPosition,
660  wxDefaultSize, wxRB_GROUP );
661  m_rbNetColorAll->SetToolTip( _( "Net and netclass colors are shown on all copper items" ) );
662 
663  netColorSizer->Add( m_rbNetColorAll, 0, wxRIGHT, 10 );
664 
665  m_rbNetColorRatsnest = new wxRadioButton( netDisplayPane, wxID_ANY, _( "Ratsnest" ),
666  wxDefaultPosition, wxDefaultSize, 0 );
667  m_rbNetColorRatsnest->SetValue( true );
668  m_rbNetColorRatsnest->SetToolTip( _( "Net and netclass colors are shown on the ratsnest only" ) );
669 
670  netColorSizer->Add( m_rbNetColorRatsnest, 0, wxRIGHT, 4 );
671 
672  m_rbNetColorOff = new wxRadioButton( netDisplayPane, wxID_ANY, _( "None" ), wxDefaultPosition,
673  wxDefaultSize, 0 );
674  m_rbNetColorOff->SetToolTip( _( "Net and netclass colors are not shown" ) );
675 
676  netColorSizer->Add( m_rbNetColorOff, 0, 0, 5 );
677 
678  netDisplayOptionsSizer->Add( netColorSizer, 0, wxEXPAND | wxBOTTOM, 5 );
679 
681 
682  m_txtRatsnestVisibility = new wxStaticText( netDisplayPane, wxID_ANY, _( "Ratsnest display:" ),
683  wxDefaultPosition, wxDefaultSize, 0 );
684  m_txtRatsnestVisibility->Wrap( -1 );
685  m_txtRatsnestVisibility->SetToolTip( _( "Choose what ratsnest lines to display" ) );
686 
687  netDisplayOptionsSizer->Add( m_txtRatsnestVisibility, 0, wxEXPAND | wxBOTTOM | wxLEFT, 2 );
688 
689  wxBoxSizer* ratsnestDisplayModeSizer = new wxBoxSizer( wxHORIZONTAL );
690 
691  m_rbRatsnestAllLayers = new wxRadioButton( netDisplayPane, wxID_ANY, _( "All layers" ),
692  wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
693  m_rbRatsnestAllLayers->SetToolTip( _( "Ratsnest lines are shown to items on all layers" ) );
694  m_rbRatsnestAllLayers->SetValue( true );
695 
696  ratsnestDisplayModeSizer->Add( m_rbRatsnestAllLayers, 0, wxRIGHT, 10 );
697 
698  m_rbRatsnestVisibleLayers = new wxRadioButton( netDisplayPane, wxID_ANY, _( "Visible layers" ),
699  wxDefaultPosition, wxDefaultSize, 0 );
700  m_rbRatsnestVisibleLayers->SetToolTip( _( "Ratsnest lines are shown to items on visible layers" ) );
701 
702  ratsnestDisplayModeSizer->Add( m_rbRatsnestVisibleLayers, 0, wxRIGHT, 4 );
703 
704  netDisplayOptionsSizer->Add( ratsnestDisplayModeSizer, 0, wxEXPAND | wxBOTTOM, 5 );
705 
707 
708  netDisplayPane->SetSizer( netDisplayOptionsSizer );
709  netDisplayPane->Layout();
710  netDisplayOptionsSizer->Fit( netDisplayPane );
711 
712  m_netsTabOuterSizer->Add( m_paneNetDisplayOptions, 0, wxEXPAND | wxTOP, 5 );
713 
714  m_paneNetDisplayOptions->Bind( WX_COLLAPSIBLE_PANE_CHANGED,
715  [&]( wxCommandEvent& aEvent )
716  {
717  Freeze();
718  m_panelNetsAndClasses->Fit();
719  m_sizerOuter->Layout();
720  passOnFocus();
721  Thaw();
722  } );
723 
724  m_rbNetColorAll->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onNetColorModeChanged, this );
725  m_rbNetColorOff->Bind( wxEVT_RADIOBUTTON, &APPEARANCE_CONTROLS::onNetColorModeChanged, this );
726  m_rbNetColorRatsnest->Bind( wxEVT_RADIOBUTTON,
728 
729  m_rbRatsnestAllLayers->Bind( wxEVT_RADIOBUTTON,
731  m_rbRatsnestVisibleLayers->Bind( wxEVT_RADIOBUTTON,
733 }
bool SetBackgroundColour(const wxColour &aColor) override
WX_COLLAPSIBLE_PANE * m_paneLayerDisplayOptions
void onNetColorModeChanged(wxCommandEvent &aEvent)
wxRadioButton * m_rbNetColorOff
wxStaticLine * m_layerDisplaySeparator
wxRadioButton * m_rbRatsnestAllLayers
wxRadioButton * m_rbHighContrastOff
void onRatsnestModeChanged(wxCommandEvent &aEvent)
wxRadioButton * m_rbHighContrastNormal
wxStaticText * m_txtNetDisplayTitle
#define _(s)
wxRadioButton * m_rbHighContrastDim
void Collapse(bool aCollapse=true)
wxStaticText * m_txtRatsnestVisibility
A better wxCollapsiblePane that.
wxStaticText * m_staticTextContrastModeTitle
WX_COLLAPSIBLE_PANE * m_paneNetDisplayOptions
wxRadioButton * m_rbRatsnestVisibleLayers
wxRadioButton * m_rbNetColorRatsnest
wxRadioButton * m_rbNetColorAll

References _, WX_COLLAPSIBLE_PANE::Collapse(), WX_COLLAPSIBLE_PANE::GetPane(), m_cbFlipBoard, 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_rbRatsnestVisibleLayers, APPEARANCE_CONTROLS_BASE::m_sizerOuter, m_staticTextContrastModeTitle, m_txtNetDisplayTitle, m_txtRatsnestVisibility, onNetColorModeChanged(), onRatsnestModeChanged(), passOnFocus(), and WX_COLLAPSIBLE_PANE::SetBackgroundColour().

Referenced by APPEARANCE_CONTROLS().

◆ doApplyLayerPreset()

void APPEARANCE_CONTROLS::doApplyLayerPreset ( const LAYER_PRESET aPreset)
private

Definition at line 2419 of file appearance_controls.cpp.

2420 {
2421  BOARD* board = m_frame->GetBoard();
2422 
2423  setVisibleLayers( aPreset.layers );
2424  setVisibleObjects( aPreset.renderLayers );
2425 
2426  // If the preset doesn't have an explicit active layer to restore, we can at least
2427  // force the active layer to be something in the preset's layer set
2428  PCB_LAYER_ID activeLayer = UNSELECTED_LAYER;
2429 
2430  if( aPreset.activeLayer != UNSELECTED_LAYER )
2431  activeLayer = aPreset.activeLayer;
2432  else if( aPreset.layers.any() && !aPreset.layers.test( m_frame->GetActiveLayer() ) )
2433  activeLayer = *aPreset.layers.Seq().begin();
2434 
2435  LSET boardLayers = board->GetLayerSet();
2436 
2437  if( activeLayer != UNSELECTED_LAYER && boardLayers.Contains( activeLayer ) )
2438  m_frame->SetActiveLayer( activeLayer );
2439 
2440  if( !m_isFpEditor )
2441  m_frame->GetCanvas()->SyncLayersVisibility( board );
2442 
2443  m_frame->GetCanvas()->Refresh();
2444 
2446 }
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.
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
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
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)
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:176

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 973 of file appearance_controls.cpp.

974 {
975  return aBoardItem->Type() == PCB_NETINFO_T;
976 }
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 979 of file appearance_controls.cpp.

980 {
981  bool rebuild = std::any_of( aBoardItems.begin(), aBoardItems.end(),
982  []( const BOARD_ITEM* a )
983  {
984  return a->Type() == PCB_NETINFO_T;
985  } );
986 
987 
988  return rebuild;
989 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
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 736 of file appearance_controls.cpp.

737 {
738  wxSize size( 220, 480 );
739  // TODO(JE) appropriate logic
740  return size;
741 }

◆ 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 1715 of file appearance_controls.cpp.

1716 {
1717  return m_notebook->GetSelection();
1718 }

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 1285 of file appearance_controls.cpp.

1286 {
1287  std::vector<LAYER_PRESET> ret;
1288 
1289  for( const auto& pair : m_layerPresets )
1290  if( !pair.second.readOnly )
1291  ret.emplace_back( pair.second );
1292 
1293  return ret;
1294 }
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 1172 of file appearance_controls.cpp.

1173 {
1174  if( m_isFpEditor )
1175  {
1176  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1177  LSET set;
1178 
1179  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1180  set.set( layer, view->IsLayerVisible( layer ) );
1181 
1182  return set;
1183  }
1184  else
1185  {
1186  return m_frame->GetBoard()->GetVisibleLayers();
1187  }
1188 }
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:479
PCB_BASE_FRAME * m_frame
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
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.
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404

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 1191 of file appearance_controls.cpp.

1192 {
1193  if( m_isFpEditor )
1194  {
1195  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1196  GAL_SET set;
1197  set.reset();
1198 
1199  for( size_t i = 0; i < set.size(); i++ )
1200  set.set( i, view->IsLayerVisible( GAL_LAYER_ID_START + GAL_LAYER_ID( i ) ) );
1201 
1202  return set;
1203  }
1204  else
1205  {
1206  return m_frame->GetBoard()->GetVisibleElements();
1207  }
1208 }
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.
PCB_BASE_FRAME * m_frame
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition: board.cpp:525
Helper for storing and iterating over GAL_LAYER_IDs.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404

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 768 of file appearance_controls.cpp.

769 {
770  passOnFocus();
771  Unbind( wxEVT_IDLE, &APPEARANCE_CONTROLS::idleFocusHandler, this );
772 }
void idleFocusHandler(wxIdleEvent &aEvent)

References passOnFocus().

Referenced by OnNotebookPageChanged().

◆ loadDefaultLayerPresets()

void APPEARANCE_CONTROLS::loadDefaultLayerPresets ( )
private

Definition at line 1316 of file appearance_controls.cpp.

1317 {
1318  m_layerPresets.clear();
1319  m_presetMRU.clear();
1320 
1321  // Load the read-only defaults
1324  presetBackAssembly } )
1325  {
1326  m_layerPresets[preset.name] = preset;
1327  m_layerPresets[preset.name].readOnly = true;
1328 
1329  m_presetMRU.Add( preset.name );
1330  }
1331 }
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 85 of file appearance_controls_base.h.

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

References APPEARANCE_CONTROLS_BASE::m_netsTabSplitter, and NULL.

Referenced by APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE().

◆ netclassNameFromEvent()

wxString APPEARANCE_CONTROLS::netclassNameFromEvent ( wxEvent &  aEvent)
private

Definition at line 2636 of file appearance_controls.cpp.

2637 {
2638  COLOR_SWATCH* s = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2639  int classId = s->GetId();
2640 
2641  wxASSERT( m_netclassIdMap.count( classId ) );
2642  return m_netclassIdMap.at( classId );
2643 }
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 932 of file appearance_controls.cpp.

933 {
934  Freeze();
935  rebuildLayers();
939  rebuildNets();
942 
944 
945  m_board = m_frame->GetBoard();
946 
947  if( m_board )
948  m_board->AddListener( this );
949 
950  Thaw();
951  Refresh();
952 }
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:1989
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 aBoardItem 
)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 992 of file appearance_controls.cpp.

993 {
994  if( doesBoardItemNeedRebuild( aBoardItem ) )
996 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemChanged()

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

Reimplemented from BOARD_LISTENER.

Definition at line 1025 of file appearance_controls.cpp.

1026 {
1027  if( doesBoardItemNeedRebuild( aBoardItem ) )
1029 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemRemoved()

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

Reimplemented from BOARD_LISTENER.

Definition at line 1008 of file appearance_controls.cpp.

1009 {
1010  if( doesBoardItemNeedRebuild( aBoardItem ) )
1012 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemsAdded()

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

Reimplemented from BOARD_LISTENER.

Definition at line 999 of file appearance_controls.cpp.

1000 {
1001  if( doesBoardItemNeedRebuild( aBoardItems ) )
1002  {
1004  }
1005 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemsChanged()

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

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

Reimplemented from BOARD_LISTENER.

Definition at line 1032 of file appearance_controls.cpp.

1034 {
1035  if( doesBoardItemNeedRebuild( aBoardItems ) )
1036  {
1038  }
1039 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardItemsRemoved()

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

Reimplemented from BOARD_LISTENER.

Definition at line 1015 of file appearance_controls.cpp.

1017 {
1018  if( doesBoardItemNeedRebuild( aBoardItems ) )
1019  {
1021  }
1022 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardNetSettingsChanged()

void APPEARANCE_CONTROLS::OnBoardNetSettingsChanged ( BOARD aBoard)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 955 of file appearance_controls.cpp.

956 {
958 }

References handleBoardItemsChanged().

◆ OnColorSwatchChanged()

void APPEARANCE_CONTROLS::OnColorSwatchChanged ( wxCommandEvent &  aEvent)

Definition at line 2449 of file appearance_controls.cpp.

2450 {
2451  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2452  COLOR4D newColor = swatch->GetSwatchColor();
2453  LAYER_NUM layer = swatch->GetId();
2454 
2456  cs->SetColor( layer, newColor );
2457 
2459 
2460  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
2461  view->UpdateLayerColor( layer );
2462  view->UpdateLayerColor( GetNetnameLayer( layer ) );
2463 
2464  if( IsCopperLayer( layer ) )
2465  view->UpdateLayerColor( ZONE_LAYER_FOR( layer ) );
2466 
2467  // Update the bitmap of the layer box
2468  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
2469  static_cast<PCB_EDIT_FRAME*>( m_frame )->ReCreateLayerBox( false );
2470 
2471  m_frame->GetCanvas()->Refresh();
2472 
2473  if( layer == LAYER_PCB_BACKGROUND )
2474  m_frame->SetDrawBgColor( newColor );
2475 
2476  passOnFocus();
2477 }
void SetDrawBgColor(const COLOR4D &aColor) override
KIGFX::COLOR4D GetSwatchColor() const
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
#define ZONE_LAYER_FOR(copperLayer)
Macro for getting the zone layer for a given copper layer.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetColor(int aLayer, const COLOR4D &aColor)
PCB_BASE_FRAME * m_frame
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.
void UpdateColors()
Update the color settings in the painter and GAL.
int LAYER_NUM
This can be replaced with int and removed.
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:752
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
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
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:67
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 1050 of file appearance_controls.cpp.

References syncColorsAndVisibility(), and syncObjectSettings().

◆ OnLayerAlphaChanged()

void APPEARANCE_CONTROLS::OnLayerAlphaChanged ( )

Definition at line 1211 of file appearance_controls.cpp.

1212 {
1213  // TODO(JE) Is this even needed if the layer alphas are getting directly updated?
1214  // Maybe we just need the "down" arrow to indicate if the alpha is below 1
1215 
1216 #if 0
1217  static constexpr double alphaEpsilon = 0.04;
1218 
1219  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1221  KIGFX::PCB_PAINTER* painter =
1222  static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetCanvas()->GetView()->GetPainter() );
1223  KIGFX::PCB_RENDER_SETTINGS* rs = painter->GetSettings();
1224 
1225  for( APPEARANCE_SETTING& setting : m_layerSettings )
1226  {
1227  if( !setting.ctl_indicator )
1228  continue;
1229 
1230  COLOR4D layerColor = theme->GetColor( setting.id );
1231  COLOR4D screenColor = rs->GetLayerColor( setting.id );
1232 
1233  if( std::abs( screenColor.a - layerColor.a ) > alphaEpsilon )
1234  {
1235  if( screenColor.a < layerColor.a )
1236  setting.ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
1237  else
1238  setting.ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
1239  }
1240  else
1241  {
1242  setting.ctl_indicator->SetIndicatorState( setting.id == current ?
1244  ROW_ICON_PROVIDER::STATE::OFF );
1245  }
1246  }
1247 #endif
1248 }
#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:207
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
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:366
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
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 1057 of file appearance_controls.cpp.

1058 {
1059  for( const std::unique_ptr<APPEARANCE_SETTING>& setting : m_layerSettings )
1060  {
1061  setting->ctl_panel->SetBackgroundColour( m_layerPanelColour );
1062  setting->ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );
1063  }
1064 
1065  wxChar r, g, b;
1066 
1067  r = m_layerPanelColour.Red();
1068  g = m_layerPanelColour.Green();
1069  b = m_layerPanelColour.Blue();
1070 
1071  if( r < 240 || g < 240 || b < 240 )
1072  {
1073  r = wxChar( std::min( (int) r + 15, 255 ) );
1074  g = wxChar( std::min( (int) g + 15, 255 ) );
1075  b = wxChar( std::min( (int) b + 15, 255 ) );
1076  }
1077  else
1078  {
1079  r = wxChar( std::max( (int) r - 15, 0 ) );
1080  g = wxChar( std::max( (int) g - 15, 0 ) );
1081  b = wxChar( std::max( (int) b - 15, 0 ) );
1082  }
1083 
1084  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1085 
1086  if( !m_layerSettingsMap.count( current ) )
1087  {
1088  wxASSERT( m_layerSettingsMap.count( F_Cu ) );
1089  current = F_Cu;
1090  }
1091 
1092  APPEARANCE_SETTING* newSetting = m_layerSettingsMap[ current ];
1093 
1094  newSetting->ctl_panel->SetBackgroundColour( wxColour( r, g, b ) );
1095  newSetting->ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::ON );
1096 
1097  Refresh();
1098 }
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
PCB_LAYER_ID
A quick note on layer IDs:
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

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, 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 1625 of file appearance_controls.cpp.

1626 {
1627  BOARD* board = m_frame->GetBoard();
1628  LSET visible = getVisibleLayers();
1629 
1630  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1631 
1632  switch( aEvent.GetId() )
1633  {
1634  case ID_PRESET_NO_LAYERS:
1636  return;
1637 
1638  case ID_PRESET_ALL_LAYERS:
1640  return;
1641 
1643  {
1644  visible |= presetAllCopper.layers;
1645  setVisibleLayers( visible );
1646  break;
1647  }
1648 
1651  SetLayerVisible( current, true );
1652  break;
1653 
1655  {
1656  visible &= ~presetAllCopper.layers;
1657 
1658  if( !visible.test( current ) )
1659  m_frame->SetActiveLayer( *visible.Seq().begin() );
1660 
1661  setVisibleLayers( visible );
1662  break;
1663  }
1664 
1666  {
1667  visible &= presetAllCopper.layers;
1668 
1669  if( !visible.test( current ) )
1670  m_frame->SetActiveLayer( *visible.Seq().begin() );
1671 
1672  setVisibleLayers( visible );
1673  break;
1674  }
1675 
1677  {
1678  visible |= ~presetAllCopper.layers;
1679 
1680  setVisibleLayers( visible );
1681  break;
1682  }
1683 
1686  return;
1687 
1688  case ID_PRESET_FRONT:
1690  return;
1691 
1694  return;
1695 
1696  case ID_PRESET_BACK:
1698  return;
1699 
1702  return;
1703  }
1704 
1707 
1708  if( !m_isFpEditor )
1709  m_frame->GetCanvas()->SyncLayersVisibility( board );
1710 
1711  m_frame->GetCanvas()->Refresh();
1712 }
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
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
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
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 1778 of file appearance_controls.cpp.

1779 {
1780  auto eventSource = static_cast<wxWindow*>( aEvent.GetEventObject() );
1781 
1782  PCB_LAYER_ID layer = ToLAYER_ID( eventSource->GetId() );
1783 
1784  if( m_isFpEditor && LSET::ForbiddenFootprintLayers().test( layer ) )
1785  return;
1786 
1787  m_frame->SetActiveLayer( layer );
1788  passOnFocus();
1789 }
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:888
PCB_BASE_FRAME * m_frame
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
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 2299 of file appearance_controls.cpp.

2300 {
2301  int count = m_cbLayerPresets->GetCount();
2302  int index = m_cbLayerPresets->GetSelection();
2303 
2304  auto resetSelection =
2305  [&]()
2306  {
2307  if( m_currentPreset )
2308  m_cbLayerPresets->SetStringSelection( m_currentPreset->name );
2309  else
2310  m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 );
2311  };
2312 
2313  if( index == count - 3 )
2314  {
2315  // Separator: reject the selection
2316  resetSelection();
2317  return;
2318  }
2319  else if( index == count - 2 )
2320  {
2321  // Save current state to new preset
2322  wxString name;
2323 
2326 
2327  wxTextEntryDialog dlg( this, _( "Layer preset name:" ), _( "Save Layer Preset" ), name );
2328 
2329  if( dlg.ShowModal() != wxID_OK )
2330  {
2331  resetSelection();
2332  return;
2333  }
2334 
2335  name = dlg.GetValue();
2336  bool exists = m_layerPresets.count( name );
2337 
2338  if( !exists )
2341 
2342  LAYER_PRESET* preset = &m_layerPresets[name];
2343  m_currentPreset = preset;
2344 
2345  if( !exists )
2346  {
2347  index = m_cbLayerPresets->Insert( name, index - 1, static_cast<void*>( preset ) );
2348  }
2349  else
2350  {
2351  index = m_cbLayerPresets->FindString( name );
2352  m_presetMRU.Remove( name );
2353  }
2354 
2355  m_cbLayerPresets->SetSelection( index );
2356  m_presetMRU.Insert( name, 0 );
2357 
2358  return;
2359  }
2360  else if( index == count - 1 )
2361  {
2362  // Delete a preset
2363  wxArrayString headers;
2364  std::vector<wxArrayString> items;
2365 
2366  headers.Add( _( "Presets" ) );
2367 
2368  for( std::pair<const wxString, LAYER_PRESET>& pair : m_layerPresets )
2369  {
2370  if( !pair.second.readOnly )
2371  {
2372  wxArrayString item;
2373  item.Add( pair.first );
2374  items.emplace_back( item );
2375  }
2376  }
2377 
2378  EDA_LIST_DIALOG dlg( m_frame, _( "Delete Preset" ), headers, items );
2379  dlg.SetListLabel( _( "Select preset:" ) );
2380 
2381  if( dlg.ShowModal() == wxID_OK )
2382  {
2383  wxString presetName = dlg.GetTextSelection();
2384  int idx = m_cbLayerPresets->FindString( presetName );
2385 
2386  if( idx != wxNOT_FOUND )
2387  {
2388  m_layerPresets.erase( presetName );
2389 
2390  m_cbLayerPresets->Delete( idx );
2391  m_currentPreset = nullptr;
2392 
2393  m_presetMRU.Remove( presetName );
2394  }
2395  }
2396 
2397  resetSelection();
2398  return;
2399  }
2400 
2401  LAYER_PRESET* preset = static_cast<LAYER_PRESET*>( m_cbLayerPresets->GetClientData( index ) );
2402  m_currentPreset = preset;
2403 
2404  m_lastSelectedUserPreset = ( !preset || preset->readOnly ) ? nullptr : preset;
2405 
2406  if( preset )
2407  doApplyLayerPreset( *preset );
2408 
2409  if( !m_currentPreset->name.IsEmpty() )
2410  {
2411  m_presetMRU.Remove( m_currentPreset->name );
2412  m_presetMRU.Insert( m_currentPreset->name, 0 );
2413  }
2414 
2415  passOnFocus();
2416 }
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:59

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 1800 of file appearance_controls.cpp.

1802 {
1803  LSET visibleLayers = getVisibleLayers();
1804 
1805  if( visibleLayers.test( aLayer ) != isVisible )
1806  {
1807  visibleLayers.set( aLayer, isVisible );
1808 
1809  setVisibleLayers( visibleLayers );
1810 
1811  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1812  }
1813 
1815 
1816  if( isFinal )
1817  m_frame->GetCanvas()->Refresh();
1818 }
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.
void setVisibleLayers(LSET aLayers)
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
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 2618 of file appearance_controls.cpp.

2619 {
2620  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
2622 
2623  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2624 
2625  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2626  wxString className = netclassNameFromEvent( aEvent );
2627 
2628  netclassColors[className] = swatch->GetSwatchColor();
2629 
2632  m_frame->GetCanvas()->Refresh();
2633 }
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:207
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:773

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 2678 of file appearance_controls.cpp.

2679 {
2680  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
2682  static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
2683 
2684  BOARD* board = m_frame->GetBoard();
2685  NETINFO_LIST& nets = board->GetNetInfo();
2686  NETCLASSES& classes = board->GetDesignSettings().GetNetClasses();
2687  NETCLASSPTR netclass = classes.Find( m_contextMenuNetclass );
2688 
2689  APPEARANCE_SETTING* setting = m_netclassSettingsMap.count( m_contextMenuNetclass ) ?
2691 
2692  NETCLASSPTR defaultClass = classes.GetDefault();
2693  wxString defaultClassName = defaultClass->GetName();
2694 
2695  auto runOnNetsOfClass =
2696  [&]( NETCLASSPTR aClass, std::function<void( NETINFO_ITEM* )> aFunction )
2697  {
2698  if( aClass == defaultClass )
2699  {
2700  for( NETINFO_ITEM* net : nets )
2701  if( net->GetNetClass() == defaultClass.get() )
2702  aFunction( net );
2703  }
2704  else
2705  {
2706  for( const wxString& netName : *aClass )
2707  aFunction( nets.GetNetItem( netName ) );
2708  }
2709  };
2710 
2711  switch( aEvent.GetId() )
2712  {
2713  case ID_SET_NET_COLOR:
2714  {
2715  if( setting )
2716  {
2717  setting->ctl_color->GetNewSwatchColor();
2718 
2719  COLOR4D color = setting->ctl_color->GetSwatchColor();
2720 
2721  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2722 
2723  if( color != COLOR4D::UNSPECIFIED )
2724  netclassColors[m_contextMenuNetclass] = color;
2725  else
2726  netclassColors.erase( m_contextMenuNetclass );
2727 
2728  view->UpdateAllLayersColor();
2729  }
2730 
2731  break;
2732  }
2733 
2734  case ID_HIGHLIGHT_NET:
2735  {
2736  if( netclass )
2737  {
2738  runOnNetsOfClass( netclass,
2739  [&]( NETINFO_ITEM* aItem )
2740  {
2741  if( !aItem )
2742  return;
2743 
2744  static bool first = true;
2745  int code = aItem->GetNetCode();
2746 
2747  if( first )
2748  {
2749  board->SetHighLightNet( code );
2750  rs->SetHighlight( true, code );
2751  first = false;
2752  }
2753  else
2754  {
2755  board->SetHighLightNet( code, true );
2756  rs->SetHighlight( true, code, true );
2757  }
2758  } );
2759 
2760  view->UpdateAllLayersColor();
2761  board->HighLightON();
2762  }
2763  break;
2764  }
2765 
2766  case ID_SELECT_NET:
2767  case ID_DESELECT_NET:
2768  {
2769  if( netclass )
2770  {
2771  TOOL_ACTION& action = aEvent.GetId() == ID_SELECT_NET ? PCB_ACTIONS::selectNet :
2773  runOnNetsOfClass( netclass,
2774  [&]( NETINFO_ITEM* aItem )
2775  {
2776  if( !aItem )
2777  return;
2778 
2779  intptr_t code = static_cast<intptr_t>( aItem->GetNetCode() );
2780  m_frame->GetToolManager()->RunAction( action, true, code );
2781  } );
2782  }
2783  break;
2784  }
2785 
2786  case ID_SHOW_ALL_NETS:
2787  {
2788  showNetclass( defaultClassName );
2789  wxASSERT( m_netclassSettingsMap.count( defaultClassName ) );
2790  m_netclassSettingsMap.at( defaultClassName )->ctl_visibility->SetValue( true );
2791 
2792  for( const auto& pair : classes.NetClasses() )
2793  {
2794  showNetclass( pair.first );
2795 
2796  if( m_netclassSettingsMap.count( pair.first ) )
2797  m_netclassSettingsMap.at( pair.first )->ctl_visibility->SetValue( true );
2798  }
2799 
2800  break;
2801  }
2802 
2803  case ID_HIDE_OTHER_NETS:
2804  {
2805  bool showDefault = m_contextMenuNetclass == defaultClassName;
2806  showNetclass( defaultClassName, showDefault );
2807  wxASSERT( m_netclassSettingsMap.count( defaultClassName ) );
2808  m_netclassSettingsMap.at( defaultClassName )->ctl_visibility->SetValue( showDefault );
2809 
2810  for( const auto& pair : classes.NetClasses() )
2811  {
2812  bool show = pair.first == m_contextMenuNetclass;
2813 
2814  showNetclass( pair.first, show );
2815 
2816  if( m_netclassSettingsMap.count( pair.first ) )
2817  m_netclassSettingsMap.at( pair.first )->ctl_visibility->SetValue( show );
2818  }
2819 
2820  break;
2821  }
2822 
2823  default:
2824  break;
2825  }
2826 
2828  m_frame->GetCanvas()->Refresh();
2829 
2830  m_contextMenuNetclass.clear();
2831 }
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:60
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:207
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:67
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:773
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 2556 of file appearance_controls.cpp.

2557 {
2558  wxString className = netclassNameFromEvent( aEvent );
2559  bool show = aEvent.GetInt();
2560  showNetclass( className, show );
2561  passOnFocus();
2562 }
void showNetclass(const wxString &aClassName, bool aShow=true)
wxString netclassNameFromEvent(wxEvent &aEvent)

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

Referenced by rebuildNets().

◆ onNetColorModeChanged()

void APPEARANCE_CONTROLS::onNetColorModeChanged ( wxCommandEvent &  aEvent)
private

Definition at line 2646 of file appearance_controls.cpp.

2647 {
2649 
2650  if( m_rbNetColorAll->GetValue() )
2652  else if( m_rbNetColorRatsnest->GetValue() )
2654  else
2656 
2657  m_frame->SetDisplayOptions( options );
2659  passOnFocus();
2660 }
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:773
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 2498 of file appearance_controls.cpp.

2499 {
2500  wxASSERT( m_netsGrid->GetSelectedRows().size() == 1 );
2501 
2502  int row = m_netsGrid->GetSelectedRows()[0];
2503  NET_GRID_ENTRY& net = m_netsTable->GetEntry( row );
2504 
2505  m_netsGrid->ClearSelection();
2506 
2507  switch( aEvent.GetId() )
2508  {
2509  case ID_SET_NET_COLOR:
2510  {
2511  wxGridCellEditor* editor = m_netsGrid->GetCellEditor( row, NET_GRID_TABLE::COL_COLOR );
2512  editor->BeginEdit( row, NET_GRID_TABLE::COL_COLOR, m_netsGrid );
2513  break;
2514  }
2515 
2516  case ID_HIGHLIGHT_NET:
2517  {
2519  static_cast<intptr_t>( net.code ) );
2520  m_frame->GetCanvas()->Refresh();
2521  break;
2522  }
2523 
2524  case ID_SELECT_NET:
2525  {
2527  static_cast<intptr_t>( net.code ) );
2528  m_frame->GetCanvas()->Refresh();
2529  break;
2530  }
2531 
2532  case ID_DESELECT_NET:
2533  {
2535  static_cast<intptr_t>( net.code ) );
2536  m_frame->GetCanvas()->Refresh();
2537  break;
2538  }
2539 
2540  case ID_SHOW_ALL_NETS:
2542  break;
2543 
2544  case ID_HIDE_OTHER_NETS:
2545  m_netsTable->HideOtherNets( net );
2546  break;
2547 
2548  default:
2549  break;
2550  }
2551 
2552  passOnFocus();
2553 }
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 798 of file appearance_controls.cpp.

799 {
800  int row = event.GetRow();
801  int col = event.GetCol();
802 
803  switch( col )
804  {
806  m_netsTable->SetValueAsBool( row, col, !m_netsTable->GetValueAsBool( row, col ) );
807  m_netsGrid->ForceRefresh();
808  break;
809 
810  default:
811  break;
812  }
813 }
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 816 of file appearance_controls.cpp.

817 {
818  int row = event.GetRow();
819  int col = event.GetCol();
820 
821  switch( col )
822  {
824  m_netsGrid->GetCellEditor( row, col )->BeginEdit( row, col, m_netsGrid );
825  break;
826 
827  default:
828  break;
829  }
830 }

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

◆ OnNetGridMouseEvent()

void APPEARANCE_CONTROLS::OnNetGridMouseEvent ( wxMouseEvent &  aEvent)
protected

Definition at line 867 of file appearance_controls.cpp.

868 {
869  wxPoint pos = m_netsGrid->CalcUnscrolledPosition( aEvent.GetPosition() );
870  wxGridCellCoords cell = m_netsGrid->XYToCell( pos );
871 
872  if( aEvent.Moving() || aEvent.Entering() )
873  {
874  aEvent.Skip();
875 
876  if( !cell )
877  {
878  m_netsGrid->GetGridWindow()->UnsetToolTip();
879  return;
880  }
881 
882  if( cell == m_hoveredCell )
883  return;
884 
885  m_hoveredCell = cell;
886 
887  NET_GRID_ENTRY& net = m_netsTable->GetEntry( cell.GetRow() );
888 
889  wxString name = net.name;
890  wxString showOrHide = net.visible ? _( "Click to hide ratsnest for %s" )
891  : _( "Click to show ratsnest for %s" );
892  wxString tip;
893 
894  if( cell.GetCol() == NET_GRID_TABLE::COL_VISIBILITY )
895  tip.Printf( showOrHide, name );
896  else if( cell.GetCol() == NET_GRID_TABLE::COL_COLOR )
897  tip = _( "Double click (or middle click) to change color; "
898  "right click for more actions" );
899 
900  m_netsGrid->GetGridWindow()->SetToolTip( tip );
901  }
902  else if( aEvent.Leaving() )
903  {
904  m_netsGrid->UnsetToolTip();
905  aEvent.Skip();
906  }
907  else if( aEvent.Dragging() )
908  {
909  // not allowed
910  CallAfter( [&]()
911  {
912  m_netsGrid->ClearSelection();
913  } );
914  }
915  else if( aEvent.ButtonUp( wxMOUSE_BTN_MIDDLE ) && !!cell )
916  {
917  int row = cell.GetRow();
918  int col = cell.GetCol();
919 
920  if(col == NET_GRID_TABLE::COL_COLOR )
921  m_netsGrid->GetCellEditor( row, col )->BeginEdit( row, col, m_netsGrid );
922 
923  aEvent.Skip();
924  }
925  else
926  {
927  aEvent.Skip();
928  }
929 }
bool visible
#define _(s)
NET_GRID_ENTRY & GetEntry(int aRow)
const char * name
Definition: DXF_plotter.cpp:59
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, NET_GRID_ENTRY::name, 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 833 of file appearance_controls.cpp.

834 {
835  m_netsGrid->SelectRow( event.GetRow() );
836 
837  wxString netName = m_netsGrid->GetCellValue( event.GetRow(), NET_GRID_TABLE::COL_LABEL );
838  wxMenu menu;
839 
840  menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
841  _( "Set Net Color" ), wxEmptyString, wxITEM_NORMAL ) );
842  menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
843  wxString::Format( _( "Highlight %s" ), netName ),
844  wxEmptyString, wxITEM_NORMAL ) );
845  menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
846  wxString::Format( _( "Select Tracks and Vias in %s" ), netName ),
847  wxEmptyString, wxITEM_NORMAL ) );
848  menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
849  wxString::Format( _( "Unselect Tracks and Vias in %s" ), netName ),
850  wxEmptyString, wxITEM_NORMAL ) );
851 
852  menu.AppendSeparator();
853 
854  menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS,
855  _( "Show All Nets" ), wxEmptyString, wxITEM_NORMAL ) );
856  menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS,
857  _( "Hide All Other Nets" ), wxEmptyString,
858  wxITEM_NORMAL ) );
859 
860  menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
862 
863  PopupMenu( &menu );
864 }
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 961 of file appearance_controls.cpp.

962 {
963  int row = m_netsTable->GetRowByNetcode( aNetCode );
964 
965  if( row >= 0 )
966  {
968  m_netsGrid->ForceRefresh();
969  }
970 }
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 744 of file appearance_controls.cpp.

745 {
746  // Work around wxMac issue where the notebook pages are blank
747 #ifdef __WXMAC__
748  int page = aEvent.GetSelection();
749 
750  if( page >= 0 )
751  m_notebook->ChangeSelection( static_cast<unsigned>( page ) );
752 #endif
753 
754 #ifndef __WXMSW__
755  // Because wxWidgets is broken and will send click events to children of the collapsible
756  // panes even if they are collapsed without this
757  Freeze();
758  m_panelLayers->Fit();
759  m_panelNetsAndClasses->Fit();
760  m_sizerOuter->Layout();
761  Thaw();
762 #endif
763 
764  Bind( wxEVT_IDLE, &APPEARANCE_CONTROLS::idleFocusHandler, this );
765 }
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 2480 of file appearance_controls.cpp.

2481 {
2483 
2484  switch( aLayer )
2485  {
2486  case static_cast<int>( LAYER_TRACKS ): options.m_TrackOpacity = aOpacity; break;
2487  case static_cast<int>( LAYER_VIAS ): options.m_ViaOpacity = aOpacity; break;
2488  case static_cast<int>( LAYER_PADS ): options.m_PadOpacity = aOpacity; break;
2489  case static_cast<int>( LAYER_ZONES ): options.m_ZoneOpacity = aOpacity; break;
2490  default: return;
2491  }
2492 
2493  m_frame->SetDisplayOptions( options );
2494  passOnFocus();
2495 }
Control for copper zone opacity/visibility (color ignored)
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.
Meta control for all pads opacity/visibility (color ignored)
Meta control for all vias opacity/visibility.

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 1821 of file appearance_controls.cpp.

1823 {
1824  // Special-case controls
1825  switch( aLayer )
1826  {
1827  case LAYER_RATSNEST:
1828  {
1829  // don't touch the layers. ratsnest is enabled on per-item basis.
1831  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, true );
1832 
1833  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
1834  {
1836  opt.m_ShowGlobalRatsnest = isVisible;
1837  m_frame->SetDisplayOptions( opt );
1838  m_frame->GetBoard()->SetElementVisibility( aLayer, isVisible );
1840  }
1841 
1842  break;
1843  }
1844 
1845  case LAYER_GRID:
1846  m_frame->SetGridVisibility( isVisible );
1847  m_frame->GetCanvas()->Refresh();
1849  break;
1850 
1851  case LAYER_MOD_TEXT_FR:
1852  // Because Footprint Text is a meta-control that also can disable values/references,
1853  // drag them along here so that the user is less likely to be confused.
1854  if( isFinal )
1855  {
1856  // Should only trigger when you actually click the Footprint Text button
1857  // Otherwise it goes into infinite recursive loop with the following case section
1858  onObjectVisibilityChanged( LAYER_MOD_REFERENCES, isVisible, false );
1859  onObjectVisibilityChanged( LAYER_MOD_VALUES, isVisible, false );
1860  m_objectSettingsMap[LAYER_MOD_REFERENCES]->ctl_visibility->SetValue( isVisible );
1861  m_objectSettingsMap[LAYER_MOD_VALUES]->ctl_visibility->SetValue( isVisible );
1862  }
1863  break;
1864 
1865  case LAYER_MOD_REFERENCES:
1866  case LAYER_MOD_VALUES:
1867  // In case that user changes Footprint Value/References when the Footprint Text
1868  // meta-control is disabled, we should put it back on.
1869  if( isVisible )
1870  {
1871  onObjectVisibilityChanged( LAYER_MOD_TEXT_FR, isVisible, false );
1872  m_objectSettingsMap[LAYER_MOD_TEXT_FR]->ctl_visibility->SetValue( isVisible );
1873  }
1874  break;
1875 
1876  default:
1877  break;
1878  }
1879 
1880  GAL_SET visible = getVisibleObjects();
1881 
1882  if( visible.Contains( aLayer ) != isVisible )
1883  {
1884  visible.set( aLayer, isVisible );
1885  setVisibleObjects( visible );
1886  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1888  }
1889 
1890  if( isFinal )
1891  {
1892  m_frame->GetCanvas()->Refresh();
1893  passOnFocus();
1894  }
1895 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:537
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
show footprints values (when texts are visible)
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:572
Helper for storing and iterating over GAL_LAYER_IDs.
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
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)
BOARD * GetBoard() const
virtual void SetGridVisibility(bool aVisible)
show footprints references (when texts are visible)
bool Contains(GAL_LAYER_ID aPos)

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().

◆ onRatsnestModeChanged()

void APPEARANCE_CONTROLS::onRatsnestModeChanged ( wxCommandEvent &  aEvent)
private

Definition at line 2663 of file appearance_controls.cpp.

2664 {
2666 
2667  if( m_rbRatsnestAllLayers->GetValue() )
2669  else
2671 
2672  m_frame->SetDisplayOptions( options );
2674  passOnFocus();
2675 }
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.

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

Referenced by createControls().

◆ onReadOnlySwatch()

void APPEARANCE_CONTROLS::onReadOnlySwatch ( )
private

Definition at line 2840 of file appearance_controls.cpp.

2841 {
2842  WX_INFOBAR* infobar = m_frame->GetInfoBar();
2843 
2844  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Open Preferences" ),
2845  wxEmptyString );
2846 
2847  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
2848  [&]( wxHyperlinkEvent& aEvent )
2849  {
2850  wxCommandEvent dummy;
2852  } ) );
2853 
2854  infobar->RemoveAllButtons();
2855  infobar->AddButton( button );
2856  infobar->AddCloseButton();
2857 
2858  infobar->ShowMessageFor( _( "The current color theme is read-only. Create a new theme in "
2859  "Preferences to enable color editing." ),
2860  10000, wxICON_INFORMATION );
2861 }
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:123
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:246
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:71
#define _(s)
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:287
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:277

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 775 of file appearance_controls.cpp.

776 {
777 #ifdef __WXMSW__
778  // In wxMSW, buttons won't process events unless they have focus, so we'll let it take the
779  // focus and give it back to the parent in the button event handler.
780  if( wxBitmapButton* btn = dynamic_cast<wxBitmapButton*>( aEvent.GetEventObject() ) )
781  {
782  wxCommandEvent evt( wxEVT_BUTTON );
783  wxPostEvent( btn, evt );
784  }
785 #endif
786 
787  passOnFocus();
788  aEvent.Skip();
789 }

References passOnFocus().

Referenced by APPEARANCE_CONTROLS(), and rebuildObjects().

◆ OnSize()

void APPEARANCE_CONTROLS::OnSize ( wxSizeEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 792 of file appearance_controls.cpp.

793 {
794  aEvent.Skip();
795 }

◆ passOnFocus()

◆ rebuildLayerContextMenu()

void APPEARANCE_CONTROLS::rebuildLayerContextMenu ( )
private

Definition at line 1568 of file appearance_controls.cpp.

1569 {
1570  delete m_layerContextMenu;
1571  m_layerContextMenu = new wxMenu;
1572 
1574  _( "Show All Copper Layers" ),
1577  _( "Hide All Copper Layers" ),
1579 
1580  m_layerContextMenu->AppendSeparator();
1581 
1583  _( "Hide All Layers But Active" ),
1585 
1586  m_layerContextMenu->AppendSeparator();
1587 
1588  AddMenuItem( m_layerContextMenu, ID_SHOW_ALL_NON_COPPER, _( "Show All Non Copper Layers" ),
1590 
1591  AddMenuItem( m_layerContextMenu, ID_HIDE_ALL_NON_COPPER, _( "Hide All Non Copper Layers" ),
1593 
1594  m_layerContextMenu->AppendSeparator();
1595 
1596  AddMenuItem( m_layerContextMenu, ID_PRESET_ALL_LAYERS, _( "Show All Layers" ),
1598 
1599  AddMenuItem( m_layerContextMenu, ID_PRESET_NO_LAYERS, _( "Hide All Layers" ),
1601 
1602  m_layerContextMenu->AppendSeparator();
1603 
1605  _( "Show Only Front Assembly Layers" ), KiBitmap( BITMAPS::show_front_assembly_layers ) );
1606 
1607  AddMenuItem( m_layerContextMenu, ID_PRESET_FRONT, _( "Show Only Front Layers" ),
1609 
1610  // Only show the internal layer option if internal layers are enabled
1611  if( m_frame->GetBoard()->GetCopperLayerCount() > 2 )
1612  {
1613  AddMenuItem( m_layerContextMenu, ID_PRESET_INNER_COPPER, _( "Show Only Inner Layers" ),
1615  }
1616 
1617  AddMenuItem( m_layerContextMenu, ID_PRESET_BACK, _( "Show Only Back Layers" ),
1619 
1620  AddMenuItem( m_layerContextMenu, ID_PRESET_BACK_ASSEMBLY, _( "Show Only Back Assembly Layers" ),
1622 }
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:254
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:453
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 2240 of file appearance_controls.cpp.

2241 {
2242  m_cbLayerPresets->Clear();
2243 
2244  for( std::pair<const wxString, LAYER_PRESET>& pair : m_layerPresets )
2245  m_cbLayerPresets->Append( pair.first, static_cast<void*>( &pair.second ) );
2246 
2247  m_cbLayerPresets->Append( wxT( "-----" ) );
2248  m_cbLayerPresets->Append( _( "Save preset..." ) );
2249  m_cbLayerPresets->Append( _( "Delete preset..." ) );
2250 
2251  m_cbLayerPresets->SetSelection( 0 );
2252 
2253  // At least the build in presets should always be present
2254  wxASSERT( !m_layerPresets.empty() );
2255 
2256  // Default preset: all layers
2258 }
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 1358 of file appearance_controls.cpp.

1359 {
1360  BOARD* board = m_frame->GetBoard();
1361  LSET enabled = board->GetEnabledLayers();
1362  LSET visible = getVisibleLayers();
1363 
1365  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
1366  bool firstLayer = true;
1367  bool readOnly = theme->IsReadOnly();
1368 
1369 #ifdef __WXMAC__
1370  wxSizerItem* m_windowLayersSizerItem = m_panelLayersSizer->GetItem( m_windowLayers );
1371  m_windowLayersSizerItem->SetFlag( m_windowLayersSizerItem->GetFlag() & ~wxTOP );
1372 #endif
1373 
1374  m_layerSettings.clear();
1375  m_layerSettingsMap.clear();
1376  m_layersOuterSizer->Clear( true );
1377 
1378  auto appendLayer =
1379  [&]( std::unique_ptr<APPEARANCE_SETTING>& aSetting )
1380  {
1381  int layer = aSetting->id;
1382 
1383  wxPanel* panel = new wxPanel( m_windowLayers, layer );
1384  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
1385  panel->SetSizer( sizer );
1386 
1387  panel->SetBackgroundColour( m_layerPanelColour );
1388 
1389  aSetting->visible = visible[layer];
1390 
1391  // TODO(JE) consider restyling this indicator
1392  INDICATOR_ICON* indicator = new INDICATOR_ICON( panel, *m_iconProvider,
1393  ROW_ICON_PROVIDER::STATE::OFF,
1394  layer );
1395 
1396  COLOR_SWATCH* swatch = new COLOR_SWATCH( panel, COLOR4D::UNSPECIFIED, layer,
1397  bgColor, theme->GetColor( layer ),
1398  SWATCH_SMALL );
1399  swatch->SetToolTip( _( "Double click or middle click for color change, "
1400  "right click for menu" ) );
1401 
1402  BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( panel, layer,
1405  aSetting->visible );
1406  btn_visible->SetToolTip( _( "Show or hide this layer" ) );
1407 
1408  wxStaticText* label = new wxStaticText( panel, layer, aSetting->label );
1409  label->Wrap( -1 );
1410  label->SetToolTip( aSetting->tooltip );
1411 
1412  int topMargin = firstLayer ? 2 : 1;
1413  firstLayer = false;
1414 
1415  sizer->AddSpacer( 1 );
1416  sizer->Add( indicator, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1417  sizer->AddSpacer( 5 );
1418  sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1419  sizer->AddSpacer( 6 );
1420  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1421  sizer->AddSpacer( 5 );
1422  sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1423 
1424  m_layersOuterSizer->Add( panel, 0, wxEXPAND, 0 );
1425 
1426  aSetting->ctl_panel = panel;
1427  aSetting->ctl_indicator = indicator;
1428  aSetting->ctl_visibility = btn_visible;
1429  aSetting->ctl_color = swatch;
1430  aSetting->ctl_text = label;
1431 
1432  panel->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1433  indicator->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1434  swatch->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1435  label->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this );
1436 
1437  btn_visible->Bind( TOGGLE_CHANGED,
1438  [&]( wxCommandEvent& aEvent )
1439  {
1440  wxObject* btn = aEvent.GetEventObject();
1441  int layId = static_cast<wxWindow*>( btn )->GetId();
1442  bool isVisible = aEvent.GetInt();
1443 
1444  wxASSERT( layId >= 0 && layId < PCB_LAYER_ID_COUNT );
1445 
1447  {
1448  static_cast<BITMAP_TOGGLE*>( btn )->SetValue( !isVisible );
1449  return;
1450  }
1451 
1452  onLayerVisibilityChanged( static_cast<PCB_LAYER_ID>( layId ),
1453  isVisible, true );
1454  } );
1455 
1456  swatch->Bind( COLOR_SWATCH_CHANGED, &APPEARANCE_CONTROLS::OnColorSwatchChanged,
1457  this );
1459  this ) );
1460  swatch->SetReadOnly( readOnly );
1461 
1462  panel->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1463  indicator->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1464  swatch->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1465  btn_visible->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1466  label->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1467  };
1468 
1469  // Add right click handling to show the conterxt menu when clicking to the free area in
1470  // m_windowLayers (below the layer items)
1471  m_windowLayers->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this );
1472 
1473  wxString dsc;
1474 
1475  // show all coppers first, with front on top, back on bottom, then technical layers
1476  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
1477  {
1478  PCB_LAYER_ID layer = *cu_stack;
1479 
1480  switch( layer )
1481  {
1482  case F_Cu: dsc = _( "Front copper layer" ); break;
1483  case B_Cu: dsc = _( "Back copper layer" ); break;
1484  default: dsc = _( "Inner copper layer" ); break;
1485  }
1486 
1487  m_layerSettings.emplace_back(
1488  std::make_unique<APPEARANCE_SETTING>( board->GetLayerName( layer ), layer, dsc ) );
1489 
1490  std::unique_ptr<APPEARANCE_SETTING>& setting = m_layerSettings.back();
1491 
1492  m_layerSettingsMap[layer] = setting.get();
1493 
1494  appendLayer( setting );
1495 
1497  {
1498  setting->ctl_text->Disable();
1499  setting->ctl_color->SetToolTip( wxEmptyString );
1500  }
1501  }
1502 
1503  // technical layers are shown in this order:
1504  // Because they are static, wxGetTranslation must be explicitly
1505  // called for tooltips.
1506  static const struct {
1507  PCB_LAYER_ID layerId;
1508  wxString tooltip;
1509  } non_cu_seq[] = {
1510  { F_Adhes, _( "Adhesive on board's front" ) },
1511  { B_Adhes, _( "Adhesive on board's back" ) },
1512  { F_Paste, _( "Solder paste on board's front" ) },
1513  { B_Paste, _( "Solder paste on board's back" ) },
1514  { F_SilkS, _( "Silkscreen on board's front" ) },
1515  { B_SilkS, _( "Silkscreen on board's back" ) },
1516  { F_Mask, _( "Solder mask on board's front" ) },
1517  { B_Mask, _( "Solder mask on board's back" ) },
1518  { Dwgs_User, _( "Explanatory drawings" ) },
1519  { Cmts_User, _( "Explanatory comments" ) },
1520  { Eco1_User, _( "User defined meaning" ) },
1521  { Eco2_User, _( "User defined meaning" ) },
1522  { Edge_Cuts, _( "Board's perimeter definition" ) },
1523  { Margin, _( "Board's edge setback outline" ) },
1524  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
1525  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
1526  { F_Fab, _( "Footprint assembly on board's front" ) },
1527  { B_Fab, _( "Footprint assembly on board's back" ) },
1528  { User_1, _( "User defined layer 1" ) },
1529  { User_2, _( "User defined layer 2" ) },
1530  { User_3, _( "User defined layer 3" ) },
1531  { User_4, _( "User defined layer 4" ) },
1532  { User_5, _( "User defined layer 5" ) },
1533  { User_6, _( "User defined layer 6" ) },
1534  { User_7, _( "User defined layer 7" ) },
1535  { User_8, _( "User defined layer 8" ) },
1536  { User_9, _( "User defined layer 9" ) },
1537  };
1538 
1539  for( const auto& entry : non_cu_seq )
1540  {
1541  PCB_LAYER_ID layer = entry.layerId;
1542 
1543  if( !enabled[layer] )
1544  continue;
1545 
1546  m_layerSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>(
1547  board->GetLayerName( layer ), layer, wxGetTranslation( entry.tooltip ) ) );
1548 
1549  std::unique_ptr<APPEARANCE_SETTING>& setting = m_layerSettings.back();
1550 
1551  m_layerSettingsMap[layer] = setting.get();
1552 
1553  appendLayer( setting );
1554 
1556  {
1557  setting->ctl_text->Disable();
1558  setting->ctl_color->SetToolTip( wxEmptyString );
1559  }
1560  }
1561 
1562  m_layersOuterSizer->AddSpacer( 10 );
1563  m_windowLayers->SetBackgroundColour( m_layerPanelColour );
1564  m_windowLayers->Layout();
1565 }
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:360
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:465
void SetReadOnly(bool aReadOnly=true)
Definition: color_swatch.h:109
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:115
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.
PCB_LAYER_ID
A quick note on layer IDs:
representing a row indicator icon for use in places like the layer widget
LSET is a set of PCB_LAYER_IDs.
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.
COLOR4D GetColor(int aLayer) const
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
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:81
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 2092 of file appearance_controls.cpp.

2093 {
2094  BOARD* board = m_frame->GetBoard();
2096  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
2097 
2098  // If the board isn't fully loaded, we can't yet rebuild
2099  if( !board->GetProject() )
2100  return;
2101 
2102  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
2104 
2105  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2106 
2107  m_netclassOuterSizer->Clear( true );
2108 
2109  auto appendNetclass =
2110  [&]( int aId, const NETCLASSPTR& aClass, bool isDefaultClass = false )
2111  {
2112  wxString name = aClass->GetName();
2113 
2114  m_netclassSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>() );
2115  APPEARANCE_SETTING* setting = m_netclassSettings.back().get();
2116  m_netclassSettingsMap[name] = setting;
2117 
2118  setting->ctl_panel = new wxPanel( m_netclassScrolledWindow, aId );
2119  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
2120  setting->ctl_panel->SetSizer( sizer );
2121  COLOR4D color = netclassColors.count( name ) ? netclassColors.at( name ) :
2122  COLOR4D::UNSPECIFIED;
2123 
2124  setting->ctl_color = new COLOR_SWATCH( setting->ctl_panel, color, aId, bgColor,
2125  COLOR4D::UNSPECIFIED, SWATCH_SMALL );
2126  setting->ctl_color->SetToolTip( _( "Left double click or middle click for color "
2127  "change, right click for menu" ) );
2128 
2129  setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
2131 
2132  // Default netclass can't have an override color
2133  if( isDefaultClass )
2134  setting->ctl_color->Hide();
2135 
2136  setting->ctl_visibility =
2137  new BITMAP_TOGGLE( setting->ctl_panel, aId, KiBitmap( BITMAPS::visibility ),
2138  KiBitmap( BITMAPS::visibility_off ), true );
2139 
2140  wxString tip;
2141  tip.Printf( _( "Show or hide ratsnest for nets in %s" ), name );
2142  setting->ctl_visibility->SetToolTip( tip );
2143 
2144  setting->ctl_text = new wxStaticText( setting->ctl_panel, aId, name );
2145  setting->ctl_text->Wrap( -1 );
2146 
2147  int flags = wxALIGN_CENTER_VERTICAL;
2148 
2149  sizer->Add( setting->ctl_color, 0, flags | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
2150  sizer->AddSpacer( 7 );
2151  sizer->Add( setting->ctl_visibility, 0, flags, 5 );
2152  sizer->AddSpacer( 3 );
2153  sizer->Add( setting->ctl_text, 1, flags, 5 );
2154 
2155  m_netclassOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 5 );
2156  m_netclassOuterSizer->AddSpacer( 1 );
2157 
2158  setting->ctl_visibility->Bind( TOGGLE_CHANGED,
2160  this );
2161 
2162  auto menuHandler =
2163  [&, name, isDefaultClass]( wxMouseEvent& aEvent )
2164  {
2166 
2167  wxMenu menu;
2168 
2169  if( !isDefaultClass)
2170  {
2171  menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
2172  _( "Set Netclass Color" ), wxEmptyString,
2173  wxITEM_NORMAL ) );
2174  }
2175 
2176  menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
2177  wxString::Format( _( "Highlight Nets in %s" ), name ),
2178  wxEmptyString, wxITEM_NORMAL ) );
2179  menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
2180  wxString::Format( _( "Select Tracks and Vias in %s" ),
2181  name ),
2182  wxEmptyString, wxITEM_NORMAL ) );
2183  menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
2184  wxString::Format( _( "Unselect Tracks and Vias in %s" ),
2185  name ),
2186  wxEmptyString, wxITEM_NORMAL ) );
2187 
2188  menu.AppendSeparator();
2189 
2190  menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS,
2191  _( "Show All Netclasses" ), wxEmptyString,
2192  wxITEM_NORMAL ) );
2193  menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS,
2194  _( "Hide All Other Netclasses" ), wxEmptyString,
2195  wxITEM_NORMAL ) );
2196 
2197  menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
2199 
2200  PopupMenu( &menu );
2201  };
2202 
2203  setting->ctl_panel->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2204  setting->ctl_visibility->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2205  setting->ctl_color->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2206  setting->ctl_text->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2207  };
2208 
2209  const NETCLASS_MAP& classes = board->GetDesignSettings().GetNetClasses().NetClasses();
2210 
2211  std::vector<wxString> names;
2212 
2213  for( const auto& pair : classes )
2214  names.emplace_back( pair.first );
2215 
2216  std::sort( names.begin(), names.end() );
2217 
2218  m_netclassIdMap.clear();
2219 
2220  int idx = wxID_HIGHEST;
2221 
2222  NETCLASSPTR defaultClass = board->GetDesignSettings().GetNetClasses().GetDefault();
2223 
2224  m_netclassIdMap[idx] = defaultClass->GetName();
2225  appendNetclass( idx++, defaultClass, true );
2226 
2227  for( const wxString& name : names )
2228  {
2229  m_netclassIdMap[idx] = name;
2230  appendNetclass( idx++, classes.at( name ) );
2231  }
2232 
2233  m_netclassOuterSizer->Layout();
2234 
2235  m_netsTable->Rebuild();
2236  m_panelNets->GetSizer()->Layout();
2237 }
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:60
PROJECT * GetProject() const
Definition: board.h:360
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
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:59
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)
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 1898 of file appearance_controls.cpp.

1899 {
1901  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
1902  GAL_SET visible = getVisibleObjects();
1903  int swatchWidth = m_windowObjects->ConvertDialogToPixels( wxSize( 8, 0 ) ).x;
1904  int labelWidth = 0;
1905 
1906  m_objectSettings.clear();
1907  m_objectsOuterSizer->Clear( true );
1908  m_objectsOuterSizer->AddSpacer( 5 );
1909 
1910  auto appendObject =
1911  [&]( const std::unique_ptr<APPEARANCE_SETTING>& aSetting )
1912  {
1913  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
1914  int layer = aSetting->id;
1915 
1916  aSetting->visible = visible.Contains( ToGalLayer( layer ) );
1917  COLOR4D color = theme->GetColor( layer );
1918  COLOR4D defColor = theme->GetDefaultColor( layer );
1919 
1920  if( color != COLOR4D::UNSPECIFIED )
1921  {
1922  COLOR_SWATCH* swatch = new COLOR_SWATCH( m_windowObjects, color, layer,
1923  bgColor, defColor, SWATCH_SMALL );
1924  swatch->SetToolTip( _( "Left double click or middle click for color change, "
1925  "right click for menu" ) );
1926 
1927  sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL, 0 );
1928  aSetting->ctl_color = swatch;
1929 
1930  swatch->Bind( COLOR_SWATCH_CHANGED,
1932 
1934  this ) );
1935  }
1936  else
1937  {
1938  sizer->AddSpacer( swatchWidth );
1939  }
1940 
1941  BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( m_windowObjects, layer,
1944  aSetting->visible );
1945 
1946  wxString tip;
1947  tip.Printf( _( "Show or hide %s" ), aSetting->label.Lower() );
1948  btn_visible->SetToolTip( tip );
1949 
1950  aSetting->ctl_visibility = btn_visible;
1951 
1952  sizer->AddSpacer( 5 );
1953 
1954  btn_visible->Bind( TOGGLE_CHANGED,
1955  [&]( wxCommandEvent& aEvent )
1956  {
1957  int id = static_cast<wxWindow*>( aEvent.GetEventObject() )->GetId();
1958  bool isVisible = aEvent.GetInt();
1959  onObjectVisibilityChanged( ToGalLayer( id ), isVisible, true );
1960  } );
1961 
1962  wxStaticText* label = new wxStaticText( m_windowObjects, layer, aSetting->label );
1963  label->Wrap( -1 );
1964  label->SetToolTip( aSetting->tooltip );
1965 
1966  if( aSetting->can_control_opacity )
1967  {
1968  label->SetMinSize( wxSize( labelWidth, -1 ) );
1969 #ifdef __WXMAC__
1970  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
1971  sizer->AddSpacer( 5 );
1972  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
1973 #else
1974  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
1975  sizer->AddSpacer( 5 );
1976  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
1977 #endif
1978 
1979  wxSlider* slider = new wxSlider( m_windowObjects, wxID_ANY, 100, 0, 100,
1980  wxDefaultPosition, wxDefaultSize,
1981  wxSL_HORIZONTAL );
1982 #ifdef __WXMAC__
1983  slider->SetMinSize( wxSize( 80, 22 ) );
1984 #else
1985  slider->SetMinSize( wxSize( 80, -1 ) );
1986 #endif
1987 
1988  tip.Printf( _( "Set opacity of %s" ), aSetting->label.Lower() );
1989  slider->SetToolTip( tip );
1990 
1991  sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5 );
1992  aSetting->ctl_opacity = slider;
1993 
1994  auto opacitySliderHandler =
1995  [=]( wxCommandEvent& aEvent )
1996  {
1997  wxSlider* ctrl = static_cast<wxSlider*>( aEvent.GetEventObject() );
1998  int value = ctrl->GetValue();
1999  onObjectOpacitySlider( layer, value / 100.0f );
2000  };
2001 
2002  slider->Bind( wxEVT_SCROLL_CHANGED, opacitySliderHandler );
2003  slider->Bind( wxEVT_SCROLL_THUMBTRACK, opacitySliderHandler );
2004  slider->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
2005  }
2006  else
2007  {
2008  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
2009  sizer->AddSpacer( 5 );
2010  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
2011  }
2012 
2013  aSetting->ctl_text = label;
2014  m_objectsOuterSizer->Add( sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 5 );
2015  m_objectsOuterSizer->AddSpacer( 1 );
2016  };
2017 
2018  for( const APPEARANCE_SETTING& s_setting : s_objectSettings )
2019  {
2020  if( m_isFpEditor && !s_allowedInFpEditor.count( s_setting.id ) )
2021  continue;
2022 
2023  if( !s_setting.spacer )
2024  {
2025  m_objectSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>( s_setting ) );
2026 
2027  std::unique_ptr<APPEARANCE_SETTING>& setting = m_objectSettings.back();
2028 
2029  // Because s_render_rows is created static, we must explicitly call
2030  // wxGetTranslation for texts which are internationalized (tool tips
2031  // and item names)
2032  setting->tooltip = wxGetTranslation( s_setting.tooltip );
2033  setting->label = wxGetTranslation( s_setting.label );
2034 
2035  if( setting->can_control_opacity )
2036  {
2037  int width = m_windowObjects->GetTextExtent( setting->label ).x;
2038  labelWidth = std::max( labelWidth, width );
2039  }
2040 
2041  m_objectSettingsMap[ToGalLayer( setting->id )] = setting.get();
2042  }
2043  }
2044 
2045  for( const std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
2046  {
2047  if( setting->spacer )
2048  m_objectsOuterSizer->AddSpacer( m_pointSize );
2049  else
2050  appendObject( setting );
2051  }
2052 
2053  m_objectsOuterSizer->Layout();
2054 }
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)
GAL_LAYER_ID ToGalLayer(int aInteger)
int color
Definition: DXF_plotter.cpp:60
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:115
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.
#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)
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)

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 2864 of file appearance_controls.cpp.

2865 {
2866  m_paneLayerDisplayOptions->Refresh();
2867 }
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 1792 of file appearance_controls.cpp.

1793 {
1794  wxASSERT( m_layerContextMenu );
1795  PopupMenu( m_layerContextMenu );
1796  passOnFocus();
1797 };

References m_layerContextMenu, and passOnFocus().

Referenced by rebuildLayers().

◆ SetLayerVisible()

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

Definition at line 1101 of file appearance_controls.cpp.

1102 {
1103  LSET visible = getVisibleLayers();
1104  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
1105 
1106  if( visible.test( layer ) == isVisible )
1107  return;
1108 
1109  visible.set( layer, isVisible );
1110  setVisibleLayers( visible );
1111 
1112  m_frame->GetCanvas()->GetView()->SetLayerVisible( layer, isVisible );
1113 
1115 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * m_frame
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
void setVisibleLayers(LSET aLayers)
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
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 1118 of file appearance_controls.cpp.

1119 {
1120  if( m_objectSettingsMap.count( aLayer ) )
1121  {
1122  APPEARANCE_SETTING* setting = m_objectSettingsMap.at( aLayer );
1123  setting->ctl_visibility->SetValue( isVisible );
1124  }
1125 
1126  m_frame->GetBoard()->SetElementVisibility( aLayer, isVisible );
1127 
1128  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1129  m_frame->GetCanvas()->Refresh();
1130 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:537
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:387
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 1721 of file appearance_controls.cpp.

1722 {
1723  size_t max = m_notebook->GetPageCount();
1724 
1725  if( aTab >= 0 && static_cast<size_t>( aTab ) < max )
1726  m_notebook->SetSelection( aTab );
1727 }

References APPEARANCE_CONTROLS_BASE::m_notebook.

◆ SetUserLayerPresets()

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

Definition at line 1297 of file appearance_controls.cpp.

1298 {
1299  // Reset to defaults
1301 
1302  for( const LAYER_PRESET& preset : aPresetList )
1303  {
1304  if( m_layerPresets.count( preset.name ) )
1305  continue;
1306 
1307  m_layerPresets[preset.name] = preset;
1308 
1309  m_presetMRU.Add( preset.name );
1310  }
1311 
1313 }
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 1133 of file appearance_controls.cpp.

1134 {
1135  if( m_isFpEditor )
1136  {
1137  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1138 
1139  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1140  view->SetLayerVisible( layer, aLayers.Contains( layer ) );
1141  }
1142  else
1143  {
1144  m_frame->GetBoard()->SetVisibleLayers( aLayers );
1145  }
1146 }
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.
PCB_BASE_FRAME * m_frame
PCB_LAYER_ID
A quick note on layer IDs:
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:497
static LSET AllLayersMask()
Definition: lset.cpp:787
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
BOARD * GetBoard() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67

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 1149 of file appearance_controls.cpp.

1150 {
1151  if( m_isFpEditor )
1152  {
1153  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1154 
1155  for( size_t i = 0; i < GAL_LAYER_INDEX( LAYER_ZONE_START ); i++ )
1156  view->SetLayerVisible( GAL_LAYER_ID_START + GAL_LAYER_ID( i ), aLayers.test( i ) );
1157  }
1158  else
1159  {
1160  // Ratsnest visibility is controlled by the ratsnest option, and not by the preset
1161  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
1162  {
1164  aLayers.set( LAYER_RATSNEST, opt.m_ShowGlobalRatsnest );
1165  }
1166 
1167  m_frame->GetBoard()->SetVisibleElements( aLayers );
1168  }
1169 }
Virtual layers for stacking zones and tracks on a given copper layer.
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.
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:504
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.
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
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:67

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 2565 of file appearance_controls.cpp.

2566 {
2567  BOARD* board = m_frame->GetBoard();
2568  NETINFO_LIST& nets = board->GetNetInfo();
2569  NETCLASSES& classes = board->GetDesignSettings().GetNetClasses();
2570  NETCLASSPTR netclass = classes.Find( aClassName );
2571  TOOL_MANAGER* manager = m_frame->GetToolManager();
2572 
2573  if( !netclass )
2574  return;
2575 
2576  NETCLASS* defaultClass = classes.GetDefaultPtr();
2577 
2578  if( netclass == classes.GetDefault() )
2579  {
2580  const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
2581 
2582  for( NETINFO_ITEM* net : nets )
2583  {
2584  if( net->GetNetClass() == defaultClass )
2585  {
2586  manager->RunAction( action, true, static_cast<intptr_t>( net->GetNetCode() ) );
2587 
2588  int row = m_netsTable->GetRowByNetcode( net->GetNetCode() );
2589 
2590  if( row >= 0 )
2592  }
2593  }
2594  }
2595  else
2596  {
2597  const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
2598 
2599  for( const wxString& member : *netclass )
2600  {
2601  if( NETINFO_ITEM* net = nets.GetNetItem( member ) )
2602  {
2603  int code = net->GetNetCode();
2604  manager->RunAction( action, true, static_cast<intptr_t>( code ) );
2605 
2606  int row = m_netsTable->GetRowByNetcode( code );
2607 
2608  if( row >= 0 )
2610  }
2611  }
2612  }
2613 
2614  m_netsGrid->ForceRefresh();
2615 }
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:684
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
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 1730 of file appearance_controls.cpp.

1731 {
1733  bool readOnly = theme->IsReadOnly();
1734  LSET visible = getVisibleLayers();
1735  GAL_SET objects = getVisibleObjects();
1736 
1737  Freeze();
1738 
1739  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_layerSettings )
1740  {
1741  LAYER_NUM layer = setting->id;
1742 
1743  if( setting->ctl_visibility )
1744  setting->ctl_visibility->SetValue( visible[layer] );
1745 
1746  if( setting->ctl_color )
1747  {
1748  const COLOR4D& color = theme->GetColor( layer );
1749  setting->ctl_color->SetSwatchColor( color, false );
1750  setting->ctl_color->SetReadOnly( readOnly );
1751  }
1752  }
1753 
1754  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
1755  {
1756  GAL_LAYER_ID layer = static_cast<GAL_LAYER_ID>( setting->id );
1757 
1758  if( setting->ctl_visibility )
1759  setting->ctl_visibility->SetValue( objects.Contains( layer ) );
1760 
1761  if( setting->ctl_color )
1762  {
1763  const COLOR4D& color = theme->GetColor( layer );
1764  setting->ctl_color->SetSwatchColor( color, false );
1765  setting->ctl_color->SetReadOnly( readOnly );
1766  }
1767  }
1768 
1769  // Update indicators and panel background colors
1770  OnLayerChanged();
1771 
1772  Thaw();
1773 
1774  m_windowLayers->Refresh();
1775 }
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_layerSettings
int color
Definition: DXF_plotter.cpp:60
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
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.
Helper for storing and iterating over GAL_LAYER_IDs.
int LAYER_NUM
This can be replaced with int and removed.
COLOR4D GetColor(int aLayer) const
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_objectSettings
bool IsReadOnly() const
Definition: json_settings.h:81
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)

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 2261 of file appearance_controls.cpp.

2262 {
2263  LSET visibleLayers = getVisibleLayers();
2264  GAL_SET visibleObjects = getVisibleObjects();
2265 
2266  auto it = std::find_if( m_layerPresets.begin(), m_layerPresets.end(),
2267  [&]( const std::pair<const wxString, LAYER_PRESET>& aPair )
2268  {
2269  return ( aPair.second.layers == visibleLayers
2270  && aPair.second.renderLayers == visibleObjects );
2271  } );
2272 
2273  if( it != m_layerPresets.end() )
2274  m_cbLayerPresets->SetStringSelection( it->first );
2275  else
2276  m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 ); // separator
2277 
2278  m_currentPreset = static_cast<LAYER_PRESET*>(
2279  m_cbLayerPresets->GetClientData( m_cbLayerPresets->GetSelection() ) );
2280 }
LSET is a set of PCB_LAYER_IDs.
std::map< wxString, LAYER_PRESET > m_layerPresets
Helper for storing and iterating over GAL_LAYER_IDs.
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 2057 of file appearance_controls.cpp.

2058 {
2059  GAL_SET visible = getVisibleObjects();
2060 
2062 
2063  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
2064  {
2065  if( setting->spacer )
2066  continue;
2067 
2068  GAL_LAYER_ID layer = ToGalLayer( setting->id );
2069 
2070  if( setting->ctl_visibility )
2071  setting->ctl_visibility->SetValue( visible.Contains( layer ) );
2072 
2073  if( setting->ctl_color )
2074  {
2075  COLOR4D color = m_frame->GetColorSettings()->GetColor( setting->id );
2076  setting->ctl_color->SetSwatchColor( color, false );
2077  }
2078  }
2079 
2080  wxASSERT( m_objectSettingsMap.count( LAYER_TRACKS )
2081  && m_objectSettingsMap.count( LAYER_VIAS )
2082  && m_objectSettingsMap.count( LAYER_PADS )
2083  && m_objectSettingsMap.count( LAYER_ZONES ) );
2084 
2085  m_objectSettingsMap[LAYER_TRACKS]->ctl_opacity->SetValue( opts.m_TrackOpacity * 100 );
2086  m_objectSettingsMap[LAYER_VIAS]->ctl_opacity->SetValue( opts.m_ViaOpacity * 100 );
2087  m_objectSettingsMap[LAYER_PADS]->ctl_opacity->SetValue( opts.m_PadOpacity * 100 );
2088  m_objectSettingsMap[LAYER_ZONES]->ctl_opacity->SetValue( opts.m_ZoneOpacity * 100 );
2089 }
GAL_LAYER_ID ToGalLayer(int aInteger)
double m_TrackOpacity
Opacity override for all tracks.
Control for copper zone opacity/visibility (color ignored)
int color
Definition: DXF_plotter.cpp:60
double m_ViaOpacity
Opacity override for all types of via.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
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
PCB_BASE_FRAME * m_frame
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
Container for display options like enable/disable some optional drawings.
Meta control for all pads opacity/visibility (color ignored)
Helper for storing and iterating over GAL_LAYER_IDs.
double m_ZoneOpacity
Opacity override for filled zone areas.
COLOR4D GetColor(int aLayer) const
double m_PadOpacity
Opacity override for SMD pads and PTHs.
Meta control for all vias opacity/visibility.
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_objectSettings
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
bool Contains(GAL_LAYER_ID aPos)

References color, GAL_SET::Contains(), COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), PCB_BASE_FRAME::GetDisplayOptions(), getVisibleObjects(), LAYER_PADS, LAYER_TRACKS, LAYER_VIAS, LAYER_ZONES, m_frame, m_objectSettings, m_objectSettingsMap, PCB_DISPLAY_OPTIONS::m_PadOpacity, PCB_DISPLAY_OPTIONS::m_TrackOpacity, PCB_DISPLAY_OPTIONS::m_ViaOpacity, PCB_DISPLAY_OPTIONS::m_ZoneOpacity, and ToGalLayer().

Referenced by OnBoardChanged(), and OnColorThemeChanged().

◆ UpdateDisplayOptions()

void APPEARANCE_CONTROLS::UpdateDisplayOptions ( )

Return a list of the layer presets created by the user.

Definition at line 1251 of file appearance_controls.cpp.

1252 {
1253  const PCB_DISPLAY_OPTIONS& options = m_frame->GetDisplayOptions();
1254 
1255  switch( options.m_ContrastModeDisplay )
1256  {
1257  case HIGH_CONTRAST_MODE::NORMAL: m_rbHighContrastNormal->SetValue( true ); break;
1258  case HIGH_CONTRAST_MODE::DIMMED: m_rbHighContrastDim->SetValue( true ); break;