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 onLayerClick (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 452 of file appearance_controls.h.

453  {
454  ID_CHANGE_COLOR = wxID_HIGHEST,
475  };

Constructor & Destructor Documentation

◆ APPEARANCE_CONTROLS()

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

Definition at line 396 of file appearance_controls.cpp.

397  :
398  APPEARANCE_CONTROLS_BASE( aParent ),
399  m_frame( aParent ),
400  m_focusOwner( aFocusOwner ),
401  m_board( nullptr ),
402  m_isFpEditor( aFpEditorMode ),
403  m_currentPreset( nullptr ),
404  m_lastSelectedUserPreset( nullptr ),
405  m_layerContextMenu( nullptr )
406 {
407  int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x;
408  m_iconProvider = new ROW_ICON_PROVIDER( indicatorSize );
409  int pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
410  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
411 
412  m_layerPanelColour = m_panelLayers->GetBackgroundColour().ChangeLightness( 110 );
413 
414  m_layersOuterSizer = new wxBoxSizer( wxVERTICAL );
415  m_windowLayers->SetSizer( m_layersOuterSizer );
416  m_windowLayers->SetScrollRate( 0, 5 );
417  m_windowLayers->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
418 
419  m_objectsOuterSizer = new wxBoxSizer( wxVERTICAL );
421  m_windowObjects->SetScrollRate( 0, 5 );
422  m_windowObjects->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
423 
424  createControls();
425 
428 
431 
432  m_txtNetFilter->SetHint( _( "Filter nets" ) );
433 
434  if( screenHeight <= 900 && pointSize >= indicatorSize )
435  pointSize = pointSize * 8 / 10;
436 
437  m_pointSize = pointSize;
438  wxFont font = m_notebook->GetFont();
439 
440 #ifdef __WXMAC__
441  font.SetPointSize( m_pointSize );
442  m_notebook->SetFont( font );
443 #endif
444 
445  auto setHighContrastMode =
446  [&]( HIGH_CONTRAST_MODE aMode )
447  {
449  opts.m_ContrastModeDisplay = aMode;
450 
451  m_frame->SetDisplayOptions( opts );
452  passOnFocus();
453  };
454 
455  m_rbHighContrastNormal->Bind( wxEVT_RADIOBUTTON,
456  [=]( wxCommandEvent& aEvent )
457  {
458  setHighContrastMode( HIGH_CONTRAST_MODE::NORMAL );
459  } );
460 
461  m_rbHighContrastDim->Bind( wxEVT_RADIOBUTTON,
462  [=]( wxCommandEvent& aEvent )
463  {
464  setHighContrastMode( HIGH_CONTRAST_MODE::DIMMED );
465  } );
466 
467  m_rbHighContrastOff->Bind( wxEVT_RADIOBUTTON,
468  [=]( wxCommandEvent& aEvent )
469  {
470  setHighContrastMode( HIGH_CONTRAST_MODE::HIDDEN );
471  } );
472 
473  m_cbLayerPresets->Bind( wxEVT_CHOICE, &APPEARANCE_CONTROLS::onLayerPresetChanged, this );
474 
475  m_btnNetInspector->Bind( wxEVT_BUTTON,
476  [&]( wxCommandEvent& aEvent )
477  {
479  passOnFocus();
480  } );
481 
482  m_btnConfigureNetClasses->Bind( wxEVT_BUTTON,
483  [&]( wxCommandEvent& aEvent )
484  {
485  // This panel should only be visible in the PCB_EDIT_FRAME anyway
486  if( PCB_EDIT_FRAME* editframe = dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) )
487  editframe->ShowBoardSetupDialog( _( "Net Classes" ) );
488 
489  passOnFocus();
490  } );
491 
492  m_cbFlipBoard->SetValue( m_frame->GetCanvas()->GetView()->IsMirroredX() );
493  m_cbFlipBoard->Bind( wxEVT_CHECKBOX,
494  [&]( wxCommandEvent& aEvent )
495  {
497  } );
498 
501 
502  m_netsGrid->RegisterDataType( wxT( "bool" ), m_toggleGridRenderer, new wxGridCellBoolEditor );
503 
504  // TODO(JE) Update background color of swatch renderer when theme changes
505  m_netsGrid->RegisterDataType( wxT( "COLOR4D" ),
508 
509  m_netsTable = new NET_GRID_TABLE( m_frame, m_panelNets->GetBackgroundColour() );
510  m_netsGrid->SetTable( m_netsTable, true );
512 
513  m_netsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
514  m_netsGrid->SetSelectionForeground( m_netsGrid->GetDefaultCellTextColour() );
515  m_netsGrid->SetSelectionBackground( m_panelNets->GetBackgroundColour() );
516 
517  const int cellPadding = 6;
518 #ifdef __WXMAC__
519  const int rowHeightPadding = 5;
520 #else
521  const int rowHeightPadding = 3;
522 #endif
523 
524  wxSize size = ConvertDialogToPixels( SWATCH_SIZE_SMALL_DU );
525  m_netsGrid->SetColSize( NET_GRID_TABLE::COL_COLOR, size.x + cellPadding );
526 
527  size = KiBitmap( BITMAPS::visibility ).GetSize();
528  m_netsGrid->SetColSize( NET_GRID_TABLE::COL_VISIBILITY, size.x + cellPadding );
529 
530  m_netsGrid->SetDefaultCellFont( font );
531  m_netsGrid->SetDefaultRowSize( font.GetPixelSize().y + rowHeightPadding );
532 
533  m_netsGrid->GetGridWindow()->Bind( wxEVT_MOTION,
535 
536  // To handle middle click on color swatches
537  m_netsGrid->GetGridWindow()->Bind( wxEVT_MIDDLE_UP,
539 
540  m_netsGrid->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_DEFAULT );
541  m_netclassScrolledWindow->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_DEFAULT );
542 
543  if( m_isFpEditor )
544  m_notebook->RemovePage( 2 );
545 
547  rebuildObjects();
548  OnBoardChanged();
549 
550  Bind( wxEVT_COMMAND_MENU_SELECTED, &APPEARANCE_CONTROLS::OnLayerContextMenu, this,
552 }
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:141
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
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.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
wxBoxSizer * m_objectsOuterSizer
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.
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION listNets
Definition: pcb_actions.h:343
A toggle button renderer for a wxGrid, similar to BITMAP_TOGGLE.
NET_GRID_TABLE * m_netsTable
The main frame for Pcbnew.
APPEARANCE_CONTROLS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(215, 400), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
static const wxSize SWATCH_SIZE_SMALL_DU(8, 6)
wxBoxSizer * m_layersOuterSizer
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
Inactive layers are hidden.
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:297
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
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104

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, KIGFX::VIEW::IsMirroredX(), KiBitmap(), 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(), 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 555 of file appearance_controls.cpp.

556 {
557  delete m_iconProvider;
558 }
ROW_ICON_PROVIDER * m_iconProvider

References m_iconProvider.

Member Function Documentation

◆ ApplyLayerPreset() [1/2]

void APPEARANCE_CONTROLS::ApplyLayerPreset ( const wxString &  aPresetName)

Definition at line 1324 of file appearance_controls.cpp.

1325 {
1326  updateLayerPresetSelection( aPresetName );
1327 
1328  wxCommandEvent dummy;
1330 }
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
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 1333 of file appearance_controls.cpp.

1334 {
1335  if( m_layerPresets.count( aPreset.name ) )
1336  m_currentPreset = &m_layerPresets[aPreset.name];
1337  else
1338  m_currentPreset = nullptr;
1339 
1341  : nullptr;
1342 
1343  updateLayerPresetSelection( aPreset.name );
1344  doApplyLayerPreset( aPreset );
1345 }
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 561 of file appearance_controls.cpp.

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

2390 {
2391  BOARD* board = m_frame->GetBoard();
2392 
2393  setVisibleLayers( aPreset.layers );
2394  setVisibleObjects( aPreset.renderLayers );
2395 
2396  // If the preset doesn't have an explicit active layer to restore, we can at least
2397  // force the active layer to be something in the preset's layer set
2398  PCB_LAYER_ID activeLayer = UNSELECTED_LAYER;
2399 
2400  if( aPreset.activeLayer != UNSELECTED_LAYER )
2401  activeLayer = aPreset.activeLayer;
2402  else if( aPreset.layers.any() && !aPreset.layers.test( m_frame->GetActiveLayer() ) )
2403  activeLayer = *aPreset.layers.Seq().begin();
2404 
2405  LSET boardLayers = board->GetLayerSet();
2406 
2407  if( activeLayer != UNSELECTED_LAYER && boardLayers.Contains( activeLayer ) )
2408  m_frame->SetActiveLayer( activeLayer );
2409 
2410  if( !m_isFpEditor )
2411  m_frame->GetCanvas()->SyncLayersVisibility( board );
2412 
2413  m_frame->GetCanvas()->Refresh();
2414 
2416 }
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void setVisibleObjects(GAL_SET aObjects)
BOARD * GetBoard() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:178

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

964 {
965  return aBoardItem->Type() == PCB_NETINFO_T;
966 }
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:163

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

970 {
971  bool rebuild = std::any_of( aBoardItems.begin(), aBoardItems.end(),
972  []( const BOARD_ITEM* a )
973  {
974  return a->Type() == PCB_NETINFO_T;
975  } );
976 
977 
978  return rebuild;
979 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
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 726 of file appearance_controls.cpp.

727 {
728  wxSize size( 220, 480 );
729  // TODO(JE) appropriate logic
730  return size;
731 }

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

1710 {
1711  return m_notebook->GetSelection();
1712 }

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

1276 {
1277  std::vector<LAYER_PRESET> ret;
1278 
1279  for( const auto& pair : m_layerPresets )
1280  if( !pair.second.readOnly )
1281  ret.emplace_back( pair.second );
1282 
1283  return ret;
1284 }
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 1162 of file appearance_controls.cpp.

1163 {
1164  if( m_isFpEditor )
1165  {
1166  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1167  LSET set;
1168 
1169  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1170  set.set( layer, view->IsLayerVisible( layer ) );
1171 
1172  return set;
1173  }
1174  else
1175  {
1176  return m_frame->GetBoard()->GetVisibleLayers();
1177  }
1178 }
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 Returns a bit-mask of all t...
Definition: board.cpp:461
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 1181 of file appearance_controls.cpp.

1182 {
1183  if( m_isFpEditor )
1184  {
1185  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1186  GAL_SET set;
1187  set.reset();
1188 
1189  for( size_t i = 0; i < set.size(); i++ )
1190  set.set( i, view->IsLayerVisible( GAL_LAYER_ID_START + GAL_LAYER_ID( i ) ) );
1191 
1192  return set;
1193  }
1194  else
1195  {
1196  return m_frame->GetBoard()->GetVisibleElements();
1197  }
1198 }
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
Returns a set of all the element categories that are visible.
Definition: board.cpp:501
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 758 of file appearance_controls.cpp.

759 {
760  passOnFocus();
761  Unbind( wxEVT_IDLE, &APPEARANCE_CONTROLS::idleFocusHandler, this );
762 }
void idleFocusHandler(wxIdleEvent &aEvent)

References passOnFocus().

Referenced by OnNotebookPageChanged().

◆ loadDefaultLayerPresets()

void APPEARANCE_CONTROLS::loadDefaultLayerPresets ( )
private

Definition at line 1306 of file appearance_controls.cpp.

1307 {
1308  m_layerPresets.clear();
1309  m_presetMRU.clear();
1310 
1311  // Load the read-only defaults
1314  presetBackAssembly } )
1315  {
1316  m_layerPresets[preset.name] = preset;
1317  m_layerPresets[preset.name].readOnly = true;
1318 
1319  m_presetMRU.Add( preset.name );
1320  }
1321 }
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 2603 of file appearance_controls.cpp.

2604 {
2605  COLOR_SWATCH* s = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2606  int classId = s->GetId();
2607 
2608  wxASSERT( m_netclassIdMap.count( classId ) );
2609  return m_netclassIdMap.at( classId );
2610 }
std::map< int, wxString > m_netclassIdMap
Stores wxIDs for each netclass for control event mapping.
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57

References m_netclassIdMap.

Referenced by onNetclassColorChanged(), and onNetclassVisibilityChanged().

◆ OnBoardChanged()

void APPEARANCE_CONTROLS::OnBoardChanged ( )

Definition at line 922 of file appearance_controls.cpp.

923 {
924  Freeze();
925  rebuildLayers();
929  rebuildNets();
932 
934 
935  m_board = m_frame->GetBoard();
936 
937  if( m_board )
938  m_board->AddListener( this );
939 
940  Thaw();
941  Refresh();
942 }
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:2006
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 167 of file board.h.

167 { }

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

983 {
984  if( doesBoardItemNeedRebuild( aBoardItem ) )
986 }
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 1015 of file appearance_controls.cpp.

1016 {
1017  if( doesBoardItemNeedRebuild( aBoardItem ) )
1019 }
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 998 of file appearance_controls.cpp.

999 {
1000  if( doesBoardItemNeedRebuild( aBoardItem ) )
1002 }
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 989 of file appearance_controls.cpp.

990 {
991  if( doesBoardItemNeedRebuild( aBoardItems ) )
992  {
994  }
995 }
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 1022 of file appearance_controls.cpp.

1024 {
1025  if( doesBoardItemNeedRebuild( aBoardItems ) )
1026  {
1028  }
1029 }
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 1005 of file appearance_controls.cpp.

1007 {
1008  if( doesBoardItemNeedRebuild( aBoardItems ) )
1009  {
1011  }
1012 }
bool doesBoardItemNeedRebuild(BOARD_ITEM *aBoardItem)

References doesBoardItemNeedRebuild(), and handleBoardItemsChanged().

◆ OnBoardNetSettingsChanged()

void APPEARANCE_CONTROLS::OnBoardNetSettingsChanged ( BOARD aBoard)
overridevirtual

Reimplemented from BOARD_LISTENER.

Definition at line 945 of file appearance_controls.cpp.

946 {
948 }

References handleBoardItemsChanged().

◆ OnColorSwatchChanged()

void APPEARANCE_CONTROLS::OnColorSwatchChanged ( wxCommandEvent &  aEvent)

Definition at line 2419 of file appearance_controls.cpp.

2420 {
2421  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2422  COLOR4D newColor = swatch->GetSwatchColor();
2423  LAYER_NUM layer = swatch->GetId();
2424 
2426  cs->SetColor( layer, newColor );
2427 
2429 
2430  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
2431  view->UpdateLayerColor( layer );
2432  view->UpdateLayerColor( GetNetnameLayer( layer ) );
2433 
2434  if( IsCopperLayer( layer ) )
2435  view->UpdateLayerColor( ZONE_LAYER_FOR( layer ) );
2436 
2437  // Update the bitmap of the layer box
2438  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
2439  static_cast<PCB_EDIT_FRAME*>( m_frame )->ReCreateLayerBox( false );
2440 
2441  m_frame->GetCanvas()->Refresh();
2442 
2443  if( layer == LAYER_PCB_BACKGROUND )
2444  m_frame->SetDrawBgColor( newColor );
2445 
2446  passOnFocus();
2447 }
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 SetDrawBgColor(COLOR4D aColor) override
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
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
void SetColor(int aLayer, COLOR4D aColor)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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

References syncColorsAndVisibility(), and syncObjectSettings().

◆ OnLayerAlphaChanged()

void APPEARANCE_CONTROLS::OnLayerAlphaChanged ( )

Definition at line 1201 of file appearance_controls.cpp.

1202 {
1203  // TODO(JE) Is this even needed if the layer alphas are getting directly updated?
1204  // Maybe we just need the "down" arrow to indicate if the alpha is below 1
1205 
1206 #if 0
1207  static constexpr double alphaEpsilon = 0.04;
1208 
1209  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1211  KIGFX::PCB_PAINTER* painter =
1212  static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetCanvas()->GetView()->GetPainter() );
1213  KIGFX::PCB_RENDER_SETTINGS* rs = painter->GetSettings();
1214 
1215  for( APPEARANCE_SETTING& setting : m_layerSettings )
1216  {
1217  if( !setting.ctl_indicator )
1218  continue;
1219 
1220  COLOR4D layerColor = theme->GetColor( setting.id );
1221  COLOR4D screenColor = rs->GetLayerColor( setting.id );
1222 
1223  if( std::abs( screenColor.a - layerColor.a ) > alphaEpsilon )
1224  {
1225  if( screenColor.a < layerColor.a )
1226  setting.ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
1227  else
1228  setting.ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
1229  }
1230  else
1231  {
1232  setting.ctl_indicator->SetIndicatorState( setting.id == current ?
1234  ROW_ICON_PROVIDER::STATE::OFF );
1235  }
1236  }
1237 #endif
1238 }
#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:361
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:98

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

1048 {
1049  for( const std::unique_ptr<APPEARANCE_SETTING>& setting : m_layerSettings )
1050  {
1051  setting->ctl_panel->SetBackgroundColour( m_layerPanelColour );
1052  setting->ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );
1053  }
1054 
1055  wxChar r, g, b;
1056 
1057  r = m_layerPanelColour.Red();
1058  g = m_layerPanelColour.Green();
1059  b = m_layerPanelColour.Blue();
1060 
1061  if( r < 240 || g < 240 || b < 240 )
1062  {
1063  r = wxChar( std::min( (int) r + 15, 255 ) );
1064  g = wxChar( std::min( (int) g + 15, 255 ) );
1065  b = wxChar( std::min( (int) b + 15, 255 ) );
1066  }
1067  else
1068  {
1069  r = wxChar( std::max( (int) r - 15, 0 ) );
1070  g = wxChar( std::max( (int) g - 15, 0 ) );
1071  b = wxChar( std::max( (int) b - 15, 0 ) );
1072  }
1073 
1074  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1075 
1076  if( !m_layerSettingsMap.count( current ) )
1077  {
1078  wxASSERT( m_layerSettingsMap.count( F_Cu ) );
1079  current = F_Cu;
1080  }
1081 
1082  APPEARANCE_SETTING* newSetting = m_layerSettingsMap[ current ];
1083 
1084  newSetting->ctl_panel->SetBackgroundColour( wxColour( r, g, b ) );
1085  newSetting->ctl_indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::ON );
1086 
1087  Refresh();
1088 }
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().

◆ onLayerClick()

void APPEARANCE_CONTROLS::onLayerClick ( wxMouseEvent &  aEvent)
private

Definition at line 1772 of file appearance_controls.cpp.

1773 {
1774  auto eventSource = static_cast<wxWindow*>( aEvent.GetEventObject() );
1775 
1776  PCB_LAYER_ID layer = ToLAYER_ID( eventSource->GetId() );
1777 
1778  if( m_isFpEditor && LSET::ForbiddenFootprintLayers().test( layer ) )
1779  return;
1780 
1781  m_frame->SetActiveLayer( layer );
1782  passOnFocus();
1783 }
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().

◆ OnLayerContextMenu()

void APPEARANCE_CONTROLS::OnLayerContextMenu ( wxCommandEvent &  aEvent)

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

Definition at line 1619 of file appearance_controls.cpp.

1620 {
1621  BOARD* board = m_frame->GetBoard();
1622  LSET visible = getVisibleLayers();
1623 
1624  PCB_LAYER_ID current = m_frame->GetActiveLayer();
1625 
1626  switch( aEvent.GetId() )
1627  {
1628  case ID_PRESET_NO_LAYERS:
1630  return;
1631 
1632  case ID_PRESET_ALL_LAYERS:
1634  return;
1635 
1637  {
1638  visible |= presetAllCopper.layers;
1639  setVisibleLayers( visible );
1640  break;
1641  }
1642 
1645  SetLayerVisible( current, true );
1646  break;
1647 
1649  {
1650  visible &= ~presetAllCopper.layers;
1651 
1652  if( !visible.test( current ) )
1653  m_frame->SetActiveLayer( *visible.Seq().begin() );
1654 
1655  setVisibleLayers( visible );
1656  break;
1657  }
1658 
1660  {
1661  visible &= presetAllCopper.layers;
1662 
1663  if( !visible.test( current ) )
1664  m_frame->SetActiveLayer( *visible.Seq().begin() );
1665 
1666  setVisibleLayers( visible );
1667  break;
1668  }
1669 
1671  {
1672  visible |= ~presetAllCopper.layers;
1673 
1674  setVisibleLayers( visible );
1675  break;
1676  }
1677 
1680  return;
1681 
1682  case ID_PRESET_FRONT:
1684  return;
1685 
1688  return;
1689 
1690  case ID_PRESET_BACK:
1692  return;
1693 
1696  return;
1697  }
1698 
1701 
1702  if( !m_isFpEditor )
1703  m_frame->GetCanvas()->SyncLayersVisibility( board );
1704 
1705  m_frame->GetCanvas()->Refresh();
1706 }
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static LAYER_PRESET presetInnerCopper
static LAYER_PRESET presetBackAssembly
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
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().

◆ onLayerPresetChanged()

void APPEARANCE_CONTROLS::onLayerPresetChanged ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 2269 of file appearance_controls.cpp.

2270 {
2271  int count = m_cbLayerPresets->GetCount();
2272  int index = m_cbLayerPresets->GetSelection();
2273 
2274  auto resetSelection =
2275  [&]()
2276  {
2277  if( m_currentPreset )
2278  m_cbLayerPresets->SetStringSelection( m_currentPreset->name );
2279  else
2280  m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 );
2281  };
2282 
2283  if( index == count - 3 )
2284  {
2285  // Separator: reject the selection
2286  resetSelection();
2287  return;
2288  }
2289  else if( index == count - 2 )
2290  {
2291  // Save current state to new preset
2292  wxString name;
2293 
2296 
2297  wxTextEntryDialog dlg( this, _( "Layer preset name:" ), _( "Save Layer Preset" ), name );
2298 
2299  if( dlg.ShowModal() != wxID_OK )
2300  {
2301  resetSelection();
2302  return;
2303  }
2304 
2305  name = dlg.GetValue();
2306  bool exists = m_layerPresets.count( name );
2307 
2308  if( !exists )
2311 
2312  LAYER_PRESET* preset = &m_layerPresets[name];
2313  m_currentPreset = preset;
2314 
2315  if( !exists )
2316  {
2317  index = m_cbLayerPresets->Insert( name, index - 1, static_cast<void*>( preset ) );
2318  }
2319  else
2320  {
2321  index = m_cbLayerPresets->FindString( name );
2322  m_presetMRU.Remove( name );
2323  }
2324 
2325  m_cbLayerPresets->SetSelection( index );
2326  m_presetMRU.Insert( name, 0 );
2327 
2328  return;
2329  }
2330  else if( index == count - 1 )
2331  {
2332  // Delete a preset
2333  wxArrayString headers;
2334  std::vector<wxArrayString> items;
2335 
2336  headers.Add( _( "Presets" ) );
2337 
2338  for( std::pair<const wxString, LAYER_PRESET>& pair : m_layerPresets )
2339  {
2340  if( !pair.second.readOnly )
2341  {
2342  wxArrayString item;
2343  item.Add( pair.first );
2344  items.emplace_back( item );
2345  }
2346  }
2347 
2348  EDA_LIST_DIALOG dlg( m_frame, _( "Delete Preset" ), headers, items, wxEmptyString );
2349  dlg.SetListLabel( _( "Select preset:" ) );
2350 
2351  if( dlg.ShowModal() == wxID_OK )
2352  {
2353  wxString presetName = dlg.GetTextSelection();
2354  int idx = m_cbLayerPresets->FindString( presetName );
2355 
2356  if( idx != wxNOT_FOUND )
2357  {
2358  m_layerPresets.erase( presetName );
2359 
2360  m_cbLayerPresets->Delete( idx );
2361  m_currentPreset = nullptr;
2362 
2363  m_presetMRU.Remove( presetName );
2364  }
2365  }
2366 
2367  resetSelection();
2368  return;
2369  }
2370 
2371  LAYER_PRESET* preset = static_cast<LAYER_PRESET*>( m_cbLayerPresets->GetClientData( index ) );
2372  m_currentPreset = preset;
2373 
2374  m_lastSelectedUserPreset = ( !preset || preset->readOnly ) ? nullptr : preset;
2375 
2376  if( preset )
2377  doApplyLayerPreset( *preset );
2378 
2379  if( !m_currentPreset->name.IsEmpty() )
2380  {
2381  m_presetMRU.Remove( m_currentPreset->name );
2382  m_presetMRU.Insert( m_currentPreset->name, 0 );
2383  }
2384 
2385  passOnFocus();
2386 }
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
const char * name
Definition: DXF_plotter.cpp:59
#define _(s)
Definition: 3d_actions.cpp:33

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

1788 {
1789  LSET visibleLayers = getVisibleLayers();
1790 
1791  if( visibleLayers.test( aLayer ) != isVisible )
1792  {
1793  visibleLayers.set( aLayer, isVisible );
1794 
1795  setVisibleLayers( visibleLayers );
1796 
1797  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1798  }
1799 
1801 
1802  if( isFinal )
1803  m_frame->GetCanvas()->Refresh();
1804 }
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=NULL) 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 2585 of file appearance_controls.cpp.

2586 {
2587  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
2589 
2590  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2591 
2592  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
2593  wxString className = netclassNameFromEvent( aEvent );
2594 
2595  netclassColors[className] = swatch->GetSwatchColor();
2596 
2599  m_frame->GetCanvas()->Refresh();
2600 }
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 void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
wxString netclassNameFromEvent(wxEvent &aEvent)
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
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 2645 of file appearance_controls.cpp.

2646 {
2647  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
2649  static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
2650 
2651  BOARD* board = m_frame->GetBoard();
2652  NETINFO_LIST& nets = board->GetNetInfo();
2653  NETCLASSES& classes = board->GetDesignSettings().GetNetClasses();
2654  NETCLASSPTR netclass = classes.Find( m_contextMenuNetclass );
2655 
2656  APPEARANCE_SETTING* setting = m_netclassSettingsMap.count( m_contextMenuNetclass ) ?
2658 
2659  NETCLASSPTR defaultClass = classes.GetDefault();
2660  wxString defaultClassName = defaultClass->GetName();
2661 
2662  auto runOnNetsOfClass =
2663  [&]( NETCLASSPTR aClass, std::function<void( NETINFO_ITEM* )> aFunction )
2664  {
2665  if( aClass == defaultClass )
2666  {
2667  for( NETINFO_ITEM* net : nets )
2668  if( net->GetNetClass() == defaultClass.get() )
2669  aFunction( net );
2670  }
2671  else
2672  {
2673  for( const wxString& netName : *aClass )
2674  aFunction( nets.GetNetItem( netName ) );
2675  }
2676  };
2677 
2678  switch( aEvent.GetId() )
2679  {
2680  case ID_SET_NET_COLOR:
2681  {
2682  if( setting )
2683  {
2684  setting->ctl_color->GetNewSwatchColor();
2685 
2686  COLOR4D color = setting->ctl_color->GetSwatchColor();
2687 
2688  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2689 
2690  if( color != COLOR4D::UNSPECIFIED )
2691  netclassColors[m_contextMenuNetclass] = color;
2692  else
2693  netclassColors.erase( m_contextMenuNetclass );
2694 
2695  view->UpdateAllLayersColor();
2696  }
2697 
2698  break;
2699  }
2700 
2701  case ID_HIGHLIGHT_NET:
2702  {
2703  if( netclass )
2704  {
2705  runOnNetsOfClass( netclass,
2706  [&]( NETINFO_ITEM* aItem )
2707  {
2708  if( !aItem )
2709  return;
2710 
2711  static bool first = true;
2712  int code = aItem->GetNetCode();
2713 
2714  if( first )
2715  {
2716  board->SetHighLightNet( code );
2717  rs->SetHighlight( true, code );
2718  first = false;
2719  }
2720  else
2721  {
2722  board->SetHighLightNet( code, true );
2723  rs->SetHighlight( true, code, true );
2724  }
2725  } );
2726 
2727  view->UpdateAllLayersColor();
2728  board->HighLightON();
2729  }
2730  break;
2731  }
2732 
2733  case ID_SELECT_NET:
2734  case ID_DESELECT_NET:
2735  {
2736  if( netclass )
2737  {
2738  TOOL_ACTION& action = aEvent.GetId() == ID_SELECT_NET ? PCB_ACTIONS::selectNet :
2740  runOnNetsOfClass( netclass,
2741  [&]( NETINFO_ITEM* aItem )
2742  {
2743  if( !aItem )
2744  return;
2745 
2746  int code = aItem->GetNetCode();
2747  m_frame->GetToolManager()->RunAction( action, true, code );
2748  } );
2749  }
2750  break;
2751  }
2752 
2753  case ID_SHOW_ALL_NETS:
2754  {
2755  showNetclass( defaultClassName );
2756  wxASSERT( m_netclassSettingsMap.count( defaultClassName ) );
2757  m_netclassSettingsMap.at( defaultClassName )->ctl_visibility->SetValue( true );
2758 
2759  for( const auto& pair : classes.NetClasses() )
2760  {
2761  showNetclass( pair.first );
2762 
2763  if( m_netclassSettingsMap.count( pair.first ) )
2764  m_netclassSettingsMap.at( pair.first )->ctl_visibility->SetValue( true );
2765  }
2766 
2767  break;
2768  }
2769 
2770  case ID_HIDE_OTHER_NETS:
2771  {
2772  bool showDefault = m_contextMenuNetclass == defaultClassName;
2773  showNetclass( defaultClassName, showDefault );
2774  wxASSERT( m_netclassSettingsMap.count( defaultClassName ) );
2775  m_netclassSettingsMap.at( defaultClassName )->ctl_visibility->SetValue( showDefault );
2776 
2777  for( const auto& pair : classes.NetClasses() )
2778  {
2779  bool show = pair.first == m_contextMenuNetclass;
2780 
2781  showNetclass( pair.first, show );
2782 
2783  if( m_netclassSettingsMap.count( pair.first ) )
2784  m_netclassSettingsMap.at( pair.first )->ctl_visibility->SetValue( show );
2785  }
2786 
2787  break;
2788  }
2789 
2790  default:
2791  break;
2792  }
2793 
2795  m_frame->GetCanvas()->Refresh();
2796 
2797  m_contextMenuNetclass.clear();
2798 }
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:81
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:141
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 void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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:103
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:49
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:84
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:55
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:98
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 2523 of file appearance_controls.cpp.

2524 {
2525  wxString className = netclassNameFromEvent( aEvent );
2526  bool show = aEvent.GetInt();
2527  showNetclass( className, show );
2528  passOnFocus();
2529 }
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 2613 of file appearance_controls.cpp.

2614 {
2616 
2617  if( m_rbNetColorAll->GetValue() )
2619  else if( m_rbNetColorRatsnest->GetValue() )
2621  else
2623 
2624  m_frame->SetDisplayOptions( options );
2626  passOnFocus();
2627 }
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 2468 of file appearance_controls.cpp.

2469 {
2470  wxASSERT( m_netsGrid->GetSelectedRows().size() == 1 );
2471 
2472  int row = m_netsGrid->GetSelectedRows()[0];
2473  NET_GRID_ENTRY& net = m_netsTable->GetEntry( row );
2474 
2475  m_netsGrid->ClearSelection();
2476 
2477  switch( aEvent.GetId() )
2478  {
2479  case ID_SET_NET_COLOR:
2480  {
2481  wxGridCellEditor* editor = m_netsGrid->GetCellEditor( row, NET_GRID_TABLE::COL_COLOR );
2482  editor->BeginEdit( row, NET_GRID_TABLE::COL_COLOR, m_netsGrid );
2483  break;
2484  }
2485 
2486  case ID_HIGHLIGHT_NET:
2487  {
2489  m_frame->GetCanvas()->Refresh();
2490  break;
2491  }
2492 
2493  case ID_SELECT_NET:
2494  {
2496  m_frame->GetCanvas()->Refresh();
2497  break;
2498  }
2499 
2500  case ID_DESELECT_NET:
2501  {
2503  m_frame->GetCanvas()->Refresh();
2504  break;
2505  }
2506 
2507  case ID_SHOW_ALL_NETS:
2509  break;
2510 
2511  case ID_HIDE_OTHER_NETS:
2512  m_netsTable->HideOtherNets( net );
2513  break;
2514 
2515  default:
2516  break;
2517  }
2518 
2519  passOnFocus();
2520 }
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:81
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
int code
PCB_BASE_FRAME * m_frame
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
NET_GRID_ENTRY & GetEntry(int aRow)
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:449
NET_GRID_TABLE * m_netsTable
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:84
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55

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

789 {
790  int row = event.GetRow();
791  int col = event.GetCol();
792 
793  switch( col )
794  {
796  m_netsTable->SetValueAsBool( row, col, !m_netsTable->GetValueAsBool( row, col ) );
797  m_netsGrid->ForceRefresh();
798  break;
799 
800  default:
801  break;
802  }
803 }
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 806 of file appearance_controls.cpp.

807 {
808  int row = event.GetRow();
809  int col = event.GetCol();
810 
811  switch( col )
812  {
814  m_netsGrid->GetCellEditor( row, col )->BeginEdit( row, col, m_netsGrid );
815  break;
816 
817  default:
818  break;
819  }
820 }

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

◆ OnNetGridMouseEvent()

void APPEARANCE_CONTROLS::OnNetGridMouseEvent ( wxMouseEvent &  aEvent)
protected

Definition at line 857 of file appearance_controls.cpp.

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

824 {
825  m_netsGrid->SelectRow( event.GetRow() );
826 
827  wxString netName = m_netsGrid->GetCellValue( event.GetRow(), NET_GRID_TABLE::COL_LABEL );
828  wxMenu menu;
829 
830  menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
831  _( "Set Net Color" ), wxEmptyString, wxITEM_NORMAL ) );
832  menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
833  wxString::Format( _( "Highlight %s" ), netName ),
834  wxEmptyString, wxITEM_NORMAL ) );
835  menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
836  wxString::Format( _( "Select Tracks and Vias in %s" ), netName ),
837  wxEmptyString, wxITEM_NORMAL ) );
838  menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
839  wxString::Format( _( "Unselect Tracks and Vias in %s" ), netName ),
840  wxEmptyString, wxITEM_NORMAL ) );
841 
842  menu.AppendSeparator();
843 
844  menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS,
845  _( "Show All Nets" ), wxEmptyString, wxITEM_NORMAL ) );
846  menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS,
847  _( "Hide All Other Nets" ), wxEmptyString,
848  wxITEM_NORMAL ) );
849 
850  menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
852 
853  PopupMenu( &menu );
854 }
void onNetContextMenu(wxCommandEvent &aEvent)
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
#define _(s)
Definition: 3d_actions.cpp:33

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

952 {
953  int row = m_netsTable->GetRowByNetcode( aNetCode );
954 
955  if( row >= 0 )
956  {
958  m_netsGrid->ForceRefresh();
959  }
960 }
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 734 of file appearance_controls.cpp.

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

2451 {
2453 
2454  switch( aLayer )
2455  {
2456  case static_cast<int>( LAYER_TRACKS ): options.m_TrackOpacity = aOpacity; break;
2457  case static_cast<int>( LAYER_VIAS ): options.m_ViaOpacity = aOpacity; break;
2458  case static_cast<int>( LAYER_PADS ): options.m_PadOpacity = aOpacity; break;
2459  case static_cast<int>( LAYER_ZONES ): options.m_ZoneOpacity = aOpacity; break;
2460  default: return;
2461  }
2462 
2463  m_frame->SetDisplayOptions( options );
2464  passOnFocus();
2465 }
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 1807 of file appearance_controls.cpp.

1809 {
1810  // Special-case controls
1811  switch( aLayer )
1812  {
1813  case LAYER_RATSNEST:
1814  {
1815  // don't touch the layers. ratsnest is enabled on per-item basis.
1817  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, true );
1818 
1819  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
1820  {
1822  opt.m_ShowGlobalRatsnest = isVisible;
1823  m_frame->SetDisplayOptions( opt );
1824  m_frame->GetBoard()->SetElementVisibility( aLayer, isVisible );
1826  }
1827 
1828  break;
1829  }
1830 
1831  case LAYER_GRID:
1832  m_frame->SetGridVisibility( isVisible );
1833  m_frame->GetCanvas()->Refresh();
1835  break;
1836 
1837  case LAYER_MOD_TEXT_FR:
1838  // Because Footprint Text is a meta-control that also can disable values/references,
1839  // drag them along here so that the user is less likely to be confused.
1840  onObjectVisibilityChanged( LAYER_MOD_REFERENCES, isVisible, false );
1841  onObjectVisibilityChanged( LAYER_MOD_VALUES, isVisible, false );
1842  m_objectSettingsMap[LAYER_MOD_REFERENCES]->ctl_visibility->SetValue( isVisible );
1843  m_objectSettingsMap[LAYER_MOD_VALUES]->ctl_visibility->SetValue( isVisible );
1844  break;
1845 
1846  default:
1847  break;
1848  }
1849 
1850  GAL_SET visible = getVisibleObjects();
1851 
1852  if( visible.Contains( aLayer ) != isVisible )
1853  {
1854  visible.set( aLayer, isVisible );
1855  setVisibleObjects( visible );
1856  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1858  }
1859 
1860  if( isFinal )
1861  {
1862  m_frame->GetCanvas()->Refresh();
1863  passOnFocus();
1864  }
1865 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:513
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 visibles)
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:574
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
bool IsType(FRAME_T aType) const
void setVisibleObjects(GAL_SET aObjects)
void onObjectVisibilityChanged(GAL_LAYER_ID aLayer, bool isVisible, bool isFinal)
BOARD * GetBoard() const
virtual void SetGridVisibility(bool aVisible)
show footprints references (when texts are visibles)
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 2630 of file appearance_controls.cpp.

2631 {
2633 
2634  if( m_rbRatsnestAllLayers->GetValue() )
2636  else
2638 
2639  m_frame->SetDisplayOptions( options );
2641  passOnFocus();
2642 }
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 2807 of file appearance_controls.cpp.

2808 {
2809  WX_INFOBAR* infobar = m_frame->GetInfoBar();
2810 
2811  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Open Preferences" ),
2812  wxEmptyString );
2813 
2814  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
2815  [&]( wxHyperlinkEvent& aEvent )
2816  {
2817  wxCommandEvent dummy;
2819  } ) );
2820 
2821  infobar->RemoveAllButtons();
2822  infobar->AddButton( button );
2823  infobar->AddCloseButton();
2824 
2825  infobar->ShowMessageFor( _( "The current color theme is read-only. Create a new theme in "
2826  "Preferences to enable color editing." ),
2827  10000, wxICON_INFORMATION );
2828 }
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:118
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:241
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
PCB_BASE_FRAME * m_frame
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:282
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:71
#define _(s)
Definition: 3d_actions.cpp:33
void OnPreferences(wxCommandEvent &event)
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:272

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

766 {
767 #ifdef __WXMSW__
768  // In wxMSW, buttons won't process events unless they have focus, so we'll let it take the
769  // focus and give it back to the parent in the button event handler.
770  if( wxBitmapButton* btn = dynamic_cast<wxBitmapButton*>( aEvent.GetEventObject() ) )
771  {
772  wxCommandEvent evt( wxEVT_BUTTON );
773  wxPostEvent( btn, evt );
774  }
775 #endif
776 
777  passOnFocus();
778  aEvent.Skip();
779 }

References passOnFocus().

Referenced by APPEARANCE_CONTROLS(), and rebuildObjects().

◆ OnSize()

void APPEARANCE_CONTROLS::OnSize ( wxSizeEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from APPEARANCE_CONTROLS_BASE.

Definition at line 782 of file appearance_controls.cpp.

783 {
784  aEvent.Skip();
785 }

◆ passOnFocus()

◆ rebuildLayerContextMenu()

void APPEARANCE_CONTROLS::rebuildLayerContextMenu ( )
private

Definition at line 1562 of file appearance_controls.cpp.

1563 {
1564  delete m_layerContextMenu;
1565  m_layerContextMenu = new wxMenu;
1566 
1568  _( "Show All Copper Layers" ),
1571  _( "Hide All Copper Layers" ),
1573 
1574  m_layerContextMenu->AppendSeparator();
1575 
1577  _( "Hide All Layers But Active" ),
1579 
1580  m_layerContextMenu->AppendSeparator();
1581 
1582  AddMenuItem( m_layerContextMenu, ID_SHOW_ALL_NON_COPPER, _( "Show All Non Copper Layers" ),
1584 
1585  AddMenuItem( m_layerContextMenu, ID_HIDE_ALL_NON_COPPER, _( "Hide All Non Copper Layers" ),
1587 
1588  m_layerContextMenu->AppendSeparator();
1589 
1590  AddMenuItem( m_layerContextMenu, ID_PRESET_ALL_LAYERS, _( "Show All Layers" ),
1592 
1593  AddMenuItem( m_layerContextMenu, ID_PRESET_NO_LAYERS, _( "Hide All Layers" ),
1595 
1596  m_layerContextMenu->AppendSeparator();
1597 
1599  _( "Show Only Front Assembly Layers" ), KiBitmap( BITMAPS::show_front_assembly_layers ) );
1600 
1601  AddMenuItem( m_layerContextMenu, ID_PRESET_FRONT, _( "Show Only Front Layers" ),
1603 
1604  // Only show the internal layer option if internal layers are enabled
1605  if( m_frame->GetBoard()->GetCopperLayerCount() > 2 )
1606  {
1607  AddMenuItem( m_layerContextMenu, ID_PRESET_INNER_COPPER, _( "Show Only Inner Layers" ),
1609  }
1610 
1611  AddMenuItem( m_layerContextMenu, ID_PRESET_BACK, _( "Show Only Back Layers" ),
1613 
1614  AddMenuItem( m_layerContextMenu, ID_PRESET_BACK_ASSEMBLY, _( "Show Only Back Assembly Layers" ),
1616 }
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:245
PCB_BASE_FRAME * m_frame
#define _(s)
Definition: 3d_actions.cpp:33
int GetCopperLayerCount() const
Definition: board.cpp:435
BOARD * GetBoard() const
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104

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

2211 {
2212  m_cbLayerPresets->Clear();
2213 
2214  for( std::pair<const wxString, LAYER_PRESET>& pair : m_layerPresets )
2215  m_cbLayerPresets->Append( pair.first, static_cast<void*>( &pair.second ) );
2216 
2217  m_cbLayerPresets->Append( wxT( "-----" ) );
2218  m_cbLayerPresets->Append( _( "Save preset..." ) );
2219  m_cbLayerPresets->Append( _( "Delete preset..." ) );
2220 
2221  m_cbLayerPresets->SetSelection( 0 );
2222 
2223  // At least the build in presets should always be present
2224  wxASSERT( !m_layerPresets.empty() );
2225 
2226  // Default preset: all layers
2228 }
wxString name
A name for this layer set.
std::map< wxString, LAYER_PRESET > m_layerPresets
LAYER_PRESET * m_currentPreset
#define _(s)
Definition: 3d_actions.cpp:33
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 1348 of file appearance_controls.cpp.

1349 {
1350  BOARD* board = m_frame->GetBoard();
1351  LSET enabled = board->GetEnabledLayers();
1352  LSET visible = getVisibleLayers();
1353 
1355  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
1356  bool firstLayer = true;
1357  bool readOnly = theme->IsReadOnly();
1358 
1359 #ifdef __WXMAC__
1360  wxSizerItem* m_windowLayersSizerItem = m_panelLayersSizer->GetItem( m_windowLayers );
1361  m_windowLayersSizerItem->SetFlag( m_windowLayersSizerItem->GetFlag() & ~wxTOP );
1362 #endif
1363 
1364  m_layerSettings.clear();
1365  m_layerSettingsMap.clear();
1366  m_layersOuterSizer->Clear( true );
1367 
1368  auto appendLayer =
1369  [&]( std::unique_ptr<APPEARANCE_SETTING>& aSetting )
1370  {
1371  int layer = aSetting->id;
1372 
1373  wxPanel* panel = new wxPanel( m_windowLayers, layer );
1374  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
1375  panel->SetSizer( sizer );
1376 
1377  panel->SetBackgroundColour( m_layerPanelColour );
1378 
1379  aSetting->visible = visible[layer];
1380 
1381  // TODO(JE) consider restyling this indicator
1382  INDICATOR_ICON* indicator = new INDICATOR_ICON( panel, *m_iconProvider,
1383  ROW_ICON_PROVIDER::STATE::OFF,
1384  layer );
1385 
1386  COLOR_SWATCH* swatch = new COLOR_SWATCH( panel, COLOR4D::UNSPECIFIED, layer,
1387  bgColor, theme->GetColor( layer ),
1388  SWATCH_SMALL );
1389  swatch->SetToolTip( _( "Double click or middle click for color change, "
1390  "right click for menu" ) );
1391 
1392  BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( panel, layer,
1395  aSetting->visible );
1396  btn_visible->SetToolTip( _( "Show or hide this layer" ) );
1397 
1398  wxStaticText* label = new wxStaticText( panel, layer, aSetting->label );
1399  label->Wrap( -1 );
1400  label->SetToolTip( aSetting->tooltip );
1401 
1402  int topMargin = firstLayer ? 2 : 1;
1403  firstLayer = false;
1404 
1405  sizer->AddSpacer( 1 );
1406  sizer->Add( indicator, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1407  sizer->AddSpacer( 5 );
1408  sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1409  sizer->AddSpacer( 6 );
1410  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1411  sizer->AddSpacer( 5 );
1412  sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxTOP, topMargin );
1413 
1414  m_layersOuterSizer->Add( panel, 0, wxEXPAND, 0 );
1415 
1416  aSetting->ctl_panel = panel;
1417  aSetting->ctl_indicator = indicator;
1418  aSetting->ctl_visibility = btn_visible;
1419  aSetting->ctl_color = swatch;
1420  aSetting->ctl_text = label;
1421 
1422  panel->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this );
1423  indicator->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this );
1424  swatch->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this );
1425  label->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this );
1426 
1427  btn_visible->Bind( TOGGLE_CHANGED,
1428  [&]( wxCommandEvent& aEvent )
1429  {
1430  wxObject* btn = aEvent.GetEventObject();
1431  int layId = static_cast<wxWindow*>( btn )->GetId();
1432  bool isVisible = aEvent.GetInt();
1433 
1434  wxASSERT( layId >= 0 && layId < PCB_LAYER_ID_COUNT );
1435 
1437  {
1438  static_cast<BITMAP_TOGGLE*>( btn )->SetValue( !isVisible );
1439  return;
1440  }
1441 
1442  onLayerVisibilityChanged( static_cast<PCB_LAYER_ID>( layId ),
1443  isVisible, true );
1444  } );
1445 
1446  swatch->Bind( COLOR_SWATCH_CHANGED, &APPEARANCE_CONTROLS::OnColorSwatchChanged,
1447  this );
1449  this ) );
1450  swatch->SetReadOnly( readOnly );
1451 
1452  auto rightClickHandler =
1453  [&]( wxMouseEvent& aEvent )
1454  {
1455  wxASSERT( m_layerContextMenu );
1456  PopupMenu( m_layerContextMenu );
1457  passOnFocus();
1458  };
1459 
1460  panel->Bind( wxEVT_RIGHT_DOWN, rightClickHandler );
1461  indicator->Bind( wxEVT_RIGHT_DOWN, rightClickHandler );
1462  swatch->Bind( wxEVT_RIGHT_DOWN, rightClickHandler );
1463  btn_visible->Bind( wxEVT_RIGHT_DOWN, rightClickHandler );
1464  label->Bind( wxEVT_RIGHT_DOWN, rightClickHandler );
1465  };
1466 
1467  wxString dsc;
1468 
1469  // show all coppers first, with front on top, back on bottom, then technical layers
1470  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
1471  {
1472  PCB_LAYER_ID layer = *cu_stack;
1473 
1474  switch( layer )
1475  {
1476  case F_Cu: dsc = _( "Front copper layer" ); break;
1477  case B_Cu: dsc = _( "Back copper layer" ); break;
1478  default: dsc = _( "Inner copper layer" ); break;
1479  }
1480 
1481  m_layerSettings.emplace_back(
1482  std::make_unique<APPEARANCE_SETTING>( board->GetLayerName( layer ), layer, dsc ) );
1483 
1484  std::unique_ptr<APPEARANCE_SETTING>& setting = m_layerSettings.back();
1485 
1486  m_layerSettingsMap[layer] = setting.get();
1487 
1488  appendLayer( setting );
1489 
1491  {
1492  setting->ctl_text->Disable();
1493  setting->ctl_color->SetToolTip( wxEmptyString );
1494  }
1495  }
1496 
1497  // technical layers are shown in this order:
1498  // Because they are static, wxGetTranslation must be explicitly
1499  // called for tooltips.
1500  static const struct {
1501  PCB_LAYER_ID layerId;
1502  wxString tooltip;
1503  } non_cu_seq[] = {
1504  { F_Adhes, _( "Adhesive on board's front" ) },
1505  { B_Adhes, _( "Adhesive on board's back" ) },
1506  { F_Paste, _( "Solder paste on board's front" ) },
1507  { B_Paste, _( "Solder paste on board's back" ) },
1508  { F_SilkS, _( "Silkscreen on board's front" ) },
1509  { B_SilkS, _( "Silkscreen on board's back" ) },
1510  { F_Mask, _( "Solder mask on board's front" ) },
1511  { B_Mask, _( "Solder mask on board's back" ) },
1512  { Dwgs_User, _( "Explanatory drawings" ) },
1513  { Cmts_User, _( "Explanatory comments" ) },
1514  { Eco1_User, _( "User defined meaning" ) },
1515  { Eco2_User, _( "User defined meaning" ) },
1516  { Edge_Cuts, _( "Board's perimeter definition" ) },
1517  { Margin, _( "Board's edge setback outline" ) },
1518  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
1519  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
1520  { F_Fab, _( "Footprint assembly on board's front" ) },
1521  { B_Fab, _( "Footprint assembly on board's back" ) },
1522  { User_1, _( "User defined layer 1" ) },
1523  { User_2, _( "User defined layer 2" ) },
1524  { User_3, _( "User defined layer 3" ) },
1525  { User_4, _( "User defined layer 4" ) },
1526  { User_5, _( "User defined layer 5" ) },
1527  { User_6, _( "User defined layer 6" ) },
1528  { User_7, _( "User defined layer 7" ) },
1529  { User_8, _( "User defined layer 8" ) },
1530  { User_9, _( "User defined layer 9" ) },
1531  };
1532 
1533  for( const auto& entry : non_cu_seq )
1534  {
1535  PCB_LAYER_ID layer = entry.layerId;
1536 
1537  if( !enabled[layer] )
1538  continue;
1539 
1540  m_layerSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>(
1541  board->GetLayerName( layer ), layer, wxGetTranslation( entry.tooltip ) ) );
1542 
1543  std::unique_ptr<APPEARANCE_SETTING>& setting = m_layerSettings.back();
1544 
1545  m_layerSettingsMap[layer] = setting.get();
1546 
1547  appendLayer( setting );
1548 
1550  {
1551  setting->ctl_text->Disable();
1552  setting->ctl_color->SetToolTip( wxEmptyString );
1553  }
1554  }
1555 
1556  m_layersOuterSizer->AddSpacer( 10 );
1557  m_windowLayers->SetBackgroundColour( m_layerPanelColour );
1558  m_windowLayers->Layout();
1559 }
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:342
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 Returns a bit-mask of all t...
Definition: board.cpp:447
void SetReadOnly(bool aReadOnly=true)
Definition: color_swatch.h:104
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:108
A checkbox control except with custom bitmaps for the checked and unchecked states.
Definition: bitmap_toggle.h:41
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
void onLayerClick(wxMouseEvent &aEvent)
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
#define _(s)
Definition: 3d_actions.cpp:33
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
bool IsReadOnly() const
Definition: json_settings.h:76
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxBoxSizer * m_layersOuterSizer
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:98
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104

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_layerContextMenu, m_layerPanelColour, m_layerSettings, m_layerSettingsMap, m_layersOuterSizer, APPEARANCE_CONTROLS_BASE::m_panelLayersSizer, APPEARANCE_CONTROLS_BASE::m_windowLayers, Margin, OnColorSwatchChanged(), onLayerClick(), onLayerVisibilityChanged(), onReadOnlySwatch(), passOnFocus(), PCB_LAYER_ID_COUNT, 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 2062 of file appearance_controls.cpp.

2063 {
2064  BOARD* board = m_frame->GetBoard();
2066  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
2067 
2068  // If the board isn't fully loaded, we can't yet rebuild
2069  if( !board->GetProject() )
2070  return;
2071 
2072  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
2074 
2075  std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
2076 
2077  m_netclassOuterSizer->Clear( true );
2078 
2079  auto appendNetclass =
2080  [&]( int aId, const NETCLASSPTR& aClass, bool isDefaultClass = false )
2081  {
2082  wxString name = aClass->GetName();
2083 
2084  m_netclassSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>() );
2085  APPEARANCE_SETTING* setting = m_netclassSettings.back().get();
2086  m_netclassSettingsMap[name] = setting;
2087 
2088  setting->ctl_panel = new wxPanel( m_netclassScrolledWindow, aId );
2089  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
2090  setting->ctl_panel->SetSizer( sizer );
2091  COLOR4D color = netclassColors.count( name ) ? netclassColors.at( name ) :
2092  COLOR4D::UNSPECIFIED;
2093 
2094  setting->ctl_color = new COLOR_SWATCH( setting->ctl_panel, color, aId, bgColor,
2095  COLOR4D::UNSPECIFIED, SWATCH_SMALL );
2096  setting->ctl_color->SetToolTip( _( "Left double click or middle click for color "
2097  "change, right click for menu" ) );
2098 
2099  setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
2101 
2102  // Default netclass can't have an override color
2103  if( isDefaultClass )
2104  setting->ctl_color->Hide();
2105 
2106  setting->ctl_visibility =
2107  new BITMAP_TOGGLE( setting->ctl_panel, aId, KiBitmap( BITMAPS::visibility ),
2108  KiBitmap( BITMAPS::visibility_off ), true );
2109 
2110  wxString tip;
2111  tip.Printf( _( "Show or hide ratsnest for nets in %s" ), name );
2112  setting->ctl_visibility->SetToolTip( tip );
2113 
2114  setting->ctl_text = new wxStaticText( setting->ctl_panel, aId, name );
2115  setting->ctl_text->Wrap( -1 );
2116 
2117  int flags = wxALIGN_CENTER_VERTICAL;
2118 
2119  sizer->Add( setting->ctl_color, 0, flags | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
2120  sizer->AddSpacer( 7 );
2121  sizer->Add( setting->ctl_visibility, 0, flags, 5 );
2122  sizer->AddSpacer( 3 );
2123  sizer->Add( setting->ctl_text, 1, flags, 5 );
2124 
2125  m_netclassOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 5 );
2126  m_netclassOuterSizer->AddSpacer( 1 );
2127 
2128  setting->ctl_visibility->Bind( TOGGLE_CHANGED,
2130  this );
2131 
2132  auto menuHandler =
2133  [&, name, isDefaultClass]( wxMouseEvent& aEvent )
2134  {
2136 
2137  wxMenu menu;
2138 
2139  if( !isDefaultClass)
2140  {
2141  menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
2142  _( "Set Netclass Color" ), wxEmptyString,
2143  wxITEM_NORMAL ) );
2144  }
2145 
2146  menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
2147  wxString::Format( _( "Highlight Nets in %s" ), name ),
2148  wxEmptyString, wxITEM_NORMAL ) );
2149  menu.Append( new wxMenuItem( &menu, ID_SELECT_NET,
2150  wxString::Format( _( "Select Tracks and Vias in %s" ),
2151  name ),
2152  wxEmptyString, wxITEM_NORMAL ) );
2153  menu.Append( new wxMenuItem( &menu, ID_DESELECT_NET,
2154  wxString::Format( _( "Unselect Tracks and Vias in %s" ),
2155  name ),
2156  wxEmptyString, wxITEM_NORMAL ) );
2157 
2158  menu.AppendSeparator();
2159 
2160  menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_NETS,
2161  _( "Show All Netclasses" ), wxEmptyString,
2162  wxITEM_NORMAL ) );
2163  menu.Append( new wxMenuItem( &menu, ID_HIDE_OTHER_NETS,
2164  _( "Hide All Other Netclasses" ), wxEmptyString,
2165  wxITEM_NORMAL ) );
2166 
2167  menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
2169 
2170  PopupMenu( &menu );
2171  };
2172 
2173  setting->ctl_panel->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2174  setting->ctl_visibility->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2175  setting->ctl_color->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2176  setting->ctl_text->Bind( wxEVT_RIGHT_DOWN, menuHandler );
2177  };
2178 
2179  const NETCLASS_MAP& classes = board->GetDesignSettings().GetNetClasses().NetClasses();
2180 
2181  std::vector<wxString> names;
2182 
2183  for( const auto& pair : classes )
2184  names.emplace_back( pair.first );
2185 
2186  std::sort( names.begin(), names.end() );
2187 
2188  m_netclassIdMap.clear();
2189 
2190  int idx = wxID_HIGHEST;
2191 
2192  NETCLASSPTR defaultClass = board->GetDesignSettings().GetNetClasses().GetDefault();
2193 
2194  m_netclassIdMap[idx] = defaultClass->GetName();
2195  appendNetclass( idx++, defaultClass, true );
2196 
2197  for( const wxString& name : names )
2198  {
2199  m_netclassIdMap[idx] = name;
2200  appendNetclass( idx++, classes.at( name ) );
2201  }
2202 
2203  m_netclassOuterSizer->Layout();
2204 
2205  m_netsTable->Rebuild();
2206  m_panelNets->GetSizer()->Layout();
2207 }
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:432
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
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:41
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
NETCLASSES & GetNetClasses() const
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
#define _(s)
Definition: 3d_actions.cpp:33
NET_GRID_TABLE * m_netsTable
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
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:98
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104

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

1869 {
1871  COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
1872  GAL_SET visible = getVisibleObjects();
1873  int swatchWidth = m_windowObjects->ConvertDialogToPixels( wxSize( 8, 0 ) ).x;
1874  int labelWidth = 0;
1875 
1876  m_objectSettings.clear();
1877  m_objectsOuterSizer->Clear( true );
1878  m_objectsOuterSizer->AddSpacer( 5 );
1879 
1880  auto appendObject =
1881  [&]( const std::unique_ptr<APPEARANCE_SETTING>& aSetting )
1882  {
1883  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
1884  int layer = aSetting->id;
1885 
1886  aSetting->visible = visible.Contains( ToGalLayer( layer ) );
1887  COLOR4D color = theme->GetColor( layer );
1888  COLOR4D defColor = theme->GetDefaultColor( layer );
1889 
1890  if( color != COLOR4D::UNSPECIFIED )
1891  {
1892  COLOR_SWATCH* swatch = new COLOR_SWATCH( m_windowObjects, color, layer,
1893  bgColor, defColor, SWATCH_SMALL );
1894  swatch->SetToolTip( _( "Left double click or middle click for color change, "
1895  "right click for menu" ) );
1896 
1897  sizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL, 0 );
1898  aSetting->ctl_color = swatch;
1899 
1900  swatch->Bind( COLOR_SWATCH_CHANGED,
1902 
1904  this ) );
1905  }
1906  else
1907  {
1908  sizer->AddSpacer( swatchWidth );
1909  }
1910 
1911  BITMAP_TOGGLE* btn_visible = new BITMAP_TOGGLE( m_windowObjects, layer,
1914  aSetting->visible );
1915 
1916  wxString tip;
1917  tip.Printf( _( "Show or hide %s" ), aSetting->label.Lower() );
1918  btn_visible->SetToolTip( tip );
1919 
1920  aSetting->ctl_visibility = btn_visible;
1921 
1922  sizer->AddSpacer( 5 );
1923 
1924  btn_visible->Bind( TOGGLE_CHANGED,
1925  [&]( wxCommandEvent& aEvent )
1926  {
1927  int id = static_cast<wxWindow*>( aEvent.GetEventObject() )->GetId();
1928  bool isVisible = aEvent.GetInt();
1929  onObjectVisibilityChanged( ToGalLayer( id ), isVisible, true );
1930  } );
1931 
1932  wxStaticText* label = new wxStaticText( m_windowObjects, layer, aSetting->label );
1933  label->Wrap( -1 );
1934  label->SetToolTip( aSetting->tooltip );
1935 
1936  if( aSetting->can_control_opacity )
1937  {
1938  label->SetMinSize( wxSize( labelWidth, -1 ) );
1939 #ifdef __WXMAC__
1940  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
1941  sizer->AddSpacer( 5 );
1942  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 10 );
1943 #else
1944  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
1945  sizer->AddSpacer( 5 );
1946  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
1947 #endif
1948 
1949  wxSlider* slider = new wxSlider( m_windowObjects, wxID_ANY, 100, 0, 100,
1950  wxDefaultPosition, wxDefaultSize,
1951  wxSL_HORIZONTAL );
1952 #ifdef __WXMAC__
1953  slider->SetMinSize( wxSize( 80, 22 ) );
1954 #else
1955  slider->SetMinSize( wxSize( 80, -1 ) );
1956 #endif
1957 
1958  tip.Printf( _( "Set opacity of %s" ), aSetting->label.Lower() );
1959  slider->SetToolTip( tip );
1960 
1961  sizer->Add( slider, 1, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5 );
1962  aSetting->ctl_opacity = slider;
1963 
1964  auto opacitySliderHandler =
1965  [=]( wxCommandEvent& aEvent )
1966  {
1967  wxSlider* ctrl = static_cast<wxSlider*>( aEvent.GetEventObject() );
1968  int value = ctrl->GetValue();
1969  onObjectOpacitySlider( layer, value / 100.0f );
1970  };
1971 
1972  slider->Bind( wxEVT_SCROLL_CHANGED, opacitySliderHandler );
1973  slider->Bind( wxEVT_SCROLL_THUMBTRACK, opacitySliderHandler );
1974  slider->Bind( wxEVT_SET_FOCUS, &APPEARANCE_CONTROLS::OnSetFocus, this );
1975  }
1976  else
1977  {
1978  sizer->Add( btn_visible, 0, wxALIGN_CENTER_VERTICAL, 0 );
1979  sizer->AddSpacer( 5 );
1980  sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL, 0 );
1981  }
1982 
1983  aSetting->ctl_text = label;
1984  m_objectsOuterSizer->Add( sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 5 );
1985  m_objectsOuterSizer->AddSpacer( 1 );
1986  };
1987 
1988  for( const APPEARANCE_SETTING& s_setting : s_objectSettings )
1989  {
1990  if( m_isFpEditor && !s_allowedInFpEditor.count( s_setting.id ) )
1991  continue;
1992 
1993  if( !s_setting.spacer )
1994  {
1995  m_objectSettings.emplace_back( std::make_unique<APPEARANCE_SETTING>( s_setting ) );
1996 
1997  std::unique_ptr<APPEARANCE_SETTING>& setting = m_objectSettings.back();
1998 
1999  // Because s_render_rows is created static, we must explicitly call
2000  // wxGetTranslation for texts which are internationalized (tool tips
2001  // and item names)
2002  setting->tooltip = wxGetTranslation( s_setting.tooltip );
2003  setting->label = wxGetTranslation( s_setting.label );
2004 
2005  if( setting->can_control_opacity )
2006  {
2007  int width = m_windowObjects->GetTextExtent( setting->label ).x;
2008  labelWidth = std::max( labelWidth, width );
2009  }
2010 
2011  m_objectSettingsMap[ToGalLayer( setting->id )] = setting.get();
2012  }
2013  }
2014 
2015  for( const std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
2016  {
2017  if( setting->spacer )
2018  m_objectsOuterSizer->AddSpacer( m_pointSize );
2019  else
2020  appendObject( setting );
2021  }
2022 
2023  m_objectsOuterSizer->Layout();
2024 }
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:108
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:41
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.
wxBoxSizer * m_objectsOuterSizer
COLOR4D GetColor(int aLayer) const
std::vector< std::unique_ptr< APPEARANCE_SETTING > > m_objectSettings
#define _(s)
Definition: 3d_actions.cpp:33
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
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:98
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
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 2831 of file appearance_controls.cpp.

2832 {
2833  m_paneLayerDisplayOptions->Refresh();
2834 }
WX_COLLAPSIBLE_PANE * m_paneLayerDisplayOptions

References m_paneLayerDisplayOptions.

Referenced by PCB_BASE_EDIT_FRAME::handleActivateEvent().

◆ SetLayerVisible()

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

Definition at line 1091 of file appearance_controls.cpp.

1092 {
1093  LSET visible = getVisibleLayers();
1094  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
1095 
1096  if( visible.test( layer ) == isVisible )
1097  return;
1098 
1099  visible.set( layer, isVisible );
1100  setVisibleLayers( visible );
1101 
1102  m_frame->GetCanvas()->GetView()->SetLayerVisible( layer, isVisible );
1103 
1105 }
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(), and DRAWING_TOOL::PlaceText().

◆ SetObjectVisible()

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

Update the manual layer alpha overrides.

Definition at line 1108 of file appearance_controls.cpp.

1109 {
1110  if( m_objectSettingsMap.count( aLayer ) )
1111  {
1112  APPEARANCE_SETTING* setting = m_objectSettingsMap.at( aLayer );
1113  setting->ctl_visibility->SetValue( isVisible );
1114  }
1115 
1116  m_frame->GetBoard()->SetElementVisibility( aLayer, isVisible );
1117 
1118  m_frame->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
1119  m_frame->GetCanvas()->Refresh();
1120 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:513
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=NULL) 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 PCB_BASE_EDIT_FRAME::SetGridVisibility(), and PCB_BASE_EDIT_FRAME::SetObjectVisible().

◆ SetTabIndex()

void APPEARANCE_CONTROLS::SetTabIndex ( int  aTab)

Definition at line 1715 of file appearance_controls.cpp.

1716 {
1717  size_t max = m_notebook->GetPageCount();
1718 
1719  if( aTab >= 0 && static_cast<size_t>( aTab ) < max )
1720  m_notebook->SetSelection( aTab );
1721 }

References APPEARANCE_CONTROLS_BASE::m_notebook.

◆ SetUserLayerPresets()

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

Definition at line 1287 of file appearance_controls.cpp.

1288 {
1289  // Reset to defaults
1291 
1292  for( const LAYER_PRESET& preset : aPresetList )
1293  {
1294  if( m_layerPresets.count( preset.name ) )
1295  continue;
1296 
1297  m_layerPresets[preset.name] = preset;
1298 
1299  m_presetMRU.Add( preset.name );
1300  }
1301 
1303 }
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 1123 of file appearance_controls.cpp.

1124 {
1125  if( m_isFpEditor )
1126  {
1127  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1128 
1129  for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1130  view->SetLayerVisible( layer, aLayers.Contains( layer ) );
1131  }
1132  else
1133  {
1134  m_frame->GetBoard()->SetVisibleLayers( aLayers );
1135  }
1136 }
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:473
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 1139 of file appearance_controls.cpp.

1140 {
1141  if( m_isFpEditor )
1142  {
1143  KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
1144 
1145  for( size_t i = 0; i < GAL_LAYER_INDEX( LAYER_ZONE_START ); i++ )
1146  view->SetLayerVisible( GAL_LAYER_ID_START + GAL_LAYER_ID( i ), aLayers.test( i ) );
1147  }
1148  else
1149  {
1150  // Ratsnest visibility is controlled by the ratsnest option, and not by the preset
1151  if( m_frame->IsType( FRAME_PCB_EDITOR ) )
1152  {
1154  aLayers.set( LAYER_RATSNEST, opt.m_ShowGlobalRatsnest );
1155  }
1156 
1157  m_frame->GetBoard()->SetVisibleElements( aLayers );
1158  }
1159 }
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 changes the bit-mask of vis...
Definition: board.cpp:480
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 2532 of file appearance_controls.cpp.

2533 {
2534  BOARD* board = m_frame->GetBoard();
2535  NETINFO_LIST& nets = board->GetNetInfo();
2536  NETCLASSES& classes = board->GetDesignSettings().GetNetClasses();
2537  NETCLASSPTR netclass = classes.Find( aClassName );
2538  TOOL_MANAGER* manager = m_frame->GetToolManager();
2539 
2540  if( !netclass )
2541  return;
2542 
2543  NETCLASS* defaultClass = classes.GetDefaultPtr();
2544 
2545  if( netclass == classes.GetDefault() )
2546  {
2547  const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
2548 
2549  for( NETINFO_ITEM* net : nets )
2550  {
2551  if( net->GetNetClass() == defaultClass )
2552  {
2553  manager->RunAction( action, true, net->GetNetCode() );
2554 
2555  int row = m_netsTable->GetRowByNetcode( net->GetNetCode() );
2556 
2557  if( row >= 0 )
2559  }
2560  }
2561  }
2562  else
2563  {
2564  const TOOL_ACTION& action = aShow ? PCB_ACTIONS::showNet : PCB_ACTIONS::hideNet;
2565 
2566  for( const wxString& member : *netclass )
2567  {
2568  if( NETINFO_ITEM* net = nets.GetNetItem( member ) )
2569  {
2570  int code = net->GetNetCode();
2571  manager->RunAction( action, true, code );
2572 
2573  int row = m_netsTable->GetRowByNetcode( code );
2574 
2575  if( row >= 0 )
2577  }
2578  }
2579  }
2580 
2581  m_netsGrid->ForceRefresh();
2582 }
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:454
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:754
PCB_BASE_FRAME * m_frame
Master controller class:
Definition: tool_manager.h:52
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:455
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
Represent a single user action.
Definition: tool_action.h:49
NET_GRID_TABLE * m_netsTable
NETCLASSPTR GetDefault() const
Definition: netclass.h:253
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
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 1724 of file appearance_controls.cpp.

1725 {
1727  bool readOnly = theme->IsReadOnly();
1728  LSET visible = getVisibleLayers();
1729  GAL_SET objects = getVisibleObjects();
1730 
1731  Freeze();
1732 
1733  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_layerSettings )
1734  {
1735  LAYER_NUM layer = setting->id;
1736 
1737  if( setting->ctl_visibility )
1738  setting->ctl_visibility->SetValue( visible[layer] );
1739 
1740  if( setting->ctl_color )
1741  {
1742  const COLOR4D& color = theme->GetColor( layer );
1743  setting->ctl_color->SetSwatchColor( color, false );
1744  setting->ctl_color->SetReadOnly( readOnly );
1745  }
1746  }
1747 
1748  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
1749  {
1750  GAL_LAYER_ID layer = static_cast<GAL_LAYER_ID>( setting->id );
1751 
1752  if( setting->ctl_visibility )
1753  setting->ctl_visibility->SetValue( objects.Contains( layer ) );
1754 
1755  if( setting->ctl_color )
1756  {
1757  const COLOR4D& color = theme->GetColor( layer );
1758  setting->ctl_color->SetSwatchColor( color, false );
1759  setting->ctl_color->SetReadOnly( readOnly );
1760  }
1761  }
1762 
1763  // Update indicators and panel background colors
1764  OnLayerChanged();
1765 
1766  Thaw();
1767 
1768  m_windowLayers->Refresh();
1769 }
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:76
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:98
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 2231 of file appearance_controls.cpp.

2232 {
2233  LSET visibleLayers = getVisibleLayers();
2234  GAL_SET visibleObjects = getVisibleObjects();
2235 
2236  auto it = std::find_if( m_layerPresets.begin(), m_layerPresets.end(),
2237  [&]( const std::pair<const wxString, LAYER_PRESET>& aPair )
2238  {
2239  return ( aPair.second.layers == visibleLayers
2240  && aPair.second.renderLayers == visibleObjects );
2241  } );
2242 
2243  if( it != m_layerPresets.end() )
2244  m_cbLayerPresets->SetStringSelection( it->first );
2245  else
2246  m_cbLayerPresets->SetSelection( m_cbLayerPresets->GetCount() - 3 ); // separator
2247 
2248  m_currentPreset = static_cast<LAYER_PRESET*>(
2249  m_cbLayerPresets->GetClientData( m_cbLayerPresets->GetSelection() ) );
2250 }
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 2027 of file appearance_controls.cpp.

2028 {
2029  GAL_SET visible = getVisibleObjects();
2030 
2032 
2033  for( std::unique_ptr<APPEARANCE_SETTING>& setting : m_objectSettings )
2034  {
2035  if( setting->spacer )
2036  continue;
2037 
2038  GAL_LAYER_ID layer = ToGalLayer( setting->id );
2039 
2040  if( setting->ctl_visibility )
2041  setting->ctl_visibility->SetValue( visible.Contains( layer ) );
2042 
2043  if( setting->ctl_color )
2044  {
2045  COLOR4D color = m_frame->GetColorSettings()->GetColor( setting->id );
2046  setting->ctl_color->SetSwatchColor( color, false );
2047  }
2048  }
2049 
2050  wxASSERT( m_objectSettingsMap.count( LAYER_TRACKS )
2051  && m_objectSettingsMap.count( LAYER_VIAS )
2052  && m_objectSettingsMap.count( LAYER_PADS )
2053  && m_objectSettingsMap.count( LAYER_ZONES ) );
2054 
2055  m_objectSettingsMap[LAYER_TRACKS]->ctl_opacity->SetValue( opts.m_TrackOpacity * 100 );
2056  m_objectSettingsMap[LAYER_VIAS]->ctl_opacity->SetValue( opts.m_ViaOpacity * 100 );
2057  m_objectSettingsMap[LAYER_PADS]->ctl_opacity->SetValue( opts.m_PadOpacity * 100 );
2058  m_objectSettingsMap[LAYER_ZONES]->ctl_opacity->SetValue( opts.m_ZoneOpacity * 100 );
2059 }
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:98
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 1241 of file appearance_controls.cpp.

1242 {
1243  const PCB_DISPLAY_OPTIONS& options = m_frame->GetDisplayOptions();
1244 
1245  switch( options.m_ContrastModeDisplay )
1246  {
1247  case HIGH_CONTRAST_MODE::NORMAL: m_rbHighContrastNormal->SetValue( true ); break;
1248  case HIGH_CONTRAST_MODE::DIMMED: m_rbHighContrastDim->SetValue( true ); break;
1249  case HIGH_CONTRAST_MODE::HIDDEN: m_rbHighContrastOff->SetValue( true ); break;
1250  }
1251 
1252  switch( options.m_NetColorMode )
1253  {
1254  case NET_COLOR_MODE::ALL: m_rbNetColorAll->SetValue( true ); break;
1255  case NET_COLOR_MODE::RATSNEST: m_rbNetColorRatsnest->SetValue( true ); break;
1256  case NET_COLOR_MODE::OFF: m_rbNetColorOff->SetValue( true ); break;
1257  }
1258 
1259  m_cbFlipBoard->SetValue( m_frame->GetCanvas()->GetView()->IsMirroredX() );
1260 
1261  if( !m_isFpEditor )
1262  {
1263  if( options.m_RatsnestMode == RATSNEST_MODE::ALL )
1264  m_rbRatsnestAllLayers->SetValue( true );
1265  else
1266  m_rbRatsnestVisibleLayers->SetValue( true );
1267 
1268  wxASSERT( m_objectSettingsMap.count( LAYER_RATSNEST ) );
1269  APPEARANCE_SETTING* ratsnest = m_objectSettingsMap.at( LAYER_RATSNEST );
1270  ratsnest->ctl_visibility->SetValue( options.m_ShowGlobalRatsnest );
1271  }
1272 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxRadioButton * m_rbNetColorOff
Net/netclass colors are shown on all net copper.
Net/netclass colors are shown on ratsnest lines only.
wxRadioButton * m_rbRatsnestAllLayers
wxRadioButton * m_rbHighContrastOff
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...