KiCad PCB EDA Suite
PCB_LAYER_WIDGET Class Reference

PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tied into the PCB_EDIT_FRAME's data and so we can add a popup menu which is specific to PCBNEW's needs. More...

#include <pcb_layer_widget.h>

Inheritance diagram for PCB_LAYER_WIDGET:
LAYER_WIDGET

Public Member Functions

 PCB_LAYER_WIDGET (PCB_BASE_FRAME *aParent, wxWindow *aFocusOwner, bool aFpEditorMode=false)
 Constructor. More...
 
void ReFill ()
 
void ReFillRender ()
 Function ReFillRender rebuilds Render for instance after the config is read. More...
 
void SyncLayerVisibilities ()
 Function SyncLayerVisibilities updates each "Layer" checkbox in this layer widget according to each layer's current visibility determined by IsLayerVisible(), and is helpful immediately after loading a BOARD which may have state information in it. More...
 
void SyncLayerAlphaIndicators ()
 Function SyncLayerAlphaIndicators updates each "Layer"s alpha indicator to show if the board is currently being rendered with more transparency or less. More...
 
void SyncLayerColors ()
 Updates the color for each layer and item from the active color theme. More...
 
void SetLayersManagerTabsText ()
 Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language or to set labels to a non default value. More...
 
void OnLayerColorChange (int aLayer, COLOR4D aColor) override
 Function OnLayerColorChange is called to notify client code about a layer color change. More...
 
bool OnLayerSelect (int aLayer) override
 Function OnLayerSelect is called to notify client code whenever the user selects a different layer. More...
 
void OnLayerVisible (int aLayer, bool isVisible, bool isFinal) override
 Function OnLayerVisible is called to notify client code about a layer visibility change. More...
 
void OnLayerRightClick (wxMenu &aMenu) override
 Function OnLayerRightClick is called to notify client code about a layer being right-clicked. More...
 
void OnRenderColorChange (int aId, COLOR4D aColor) override
 Function OnRenderColorChange is called to notify client code whenever the user changes a rendering color. More...
 
void OnRenderEnable (int aId, bool isEnabled) override
 Function OnRenderEnable is called to notify client code whenever the user changes an rendering enable in one of the rendering checkboxes. More...
 
bool OnLayerSelected ()
 Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwaysShowActiveLayer is true Otherwise do nothing. More...
 
void AddRightClickMenuItems (wxMenu &menu)
 Function addRightClickMenuItems add menu items to a menu that should be shown when right-clicking the PCB layer widget. More...
 
wxSize GetBestSize () const
 Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic content. More...
 
int GetLayerRowCount () const
 Function GetLayerRowCount returns the number of rows in the layer tab. More...
 
int GetRenderRowCount () const
 Function GetRenderRowCount returns the number of rows in the render tab. More...
 
void AppendLayerRow (const ROW &aRow)
 Function AppendLayerRow appends a new row in the layer portion of the widget. More...
 
void AppendLayerRows (const ROW *aRowsArray, int aRowCount)
 Function AppendLayerRows appends new rows in the layer portion of the widget. More...
 
void ClearLayerRows ()
 Function ClearLayerRows empties out the layer rows. More...
 
void AppendRenderRow (const ROW &aRow)
 Function AppendRenderRow appends a new row in the render portion of the widget. More...
 
void AppendRenderRows (const ROW *aRowsArray, int aRowCount)
 Function AppendRenderRows appends new rows in the render portion of the widget. More...
 
void ClearRenderRows ()
 Function ClearRenderRows empties out the render rows. More...
 
void SelectLayerRow (int aRow)
 Function SelectLayerRow changes the row selection in the layer list to the given row. More...
 
void SelectLayer (LAYER_NUM aLayer)
 Function SelectLayer changes the row selection in the layer list to aLayer provided. More...
 
LAYER_NUM GetSelectedLayer ()
 Function GetSelectedLayer returns the selected layer or -1 if none. More...
 
void SetLayerVisible (LAYER_NUM aLayer, bool isVisible)
 Function SetLayerVisible sets aLayer visible or not. More...
 
bool IsLayerVisible (LAYER_NUM aLayer)
 Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id. More...
 
void SetLayerColor (LAYER_NUM aLayer, COLOR4D aColor)
 Function SetLayerColor changes the color of aLayer. More...
 
COLOR4D GetLayerColor (LAYER_NUM aLayer) const
 Function GetLayerColor returns the color of the layer ROW associated with aLayer id. More...
 
void SetRenderState (int aId, bool isSet)
 Function SetRenderState sets the state of the checkbox associated with aId within the Render tab group of the widget. More...
 
bool GetRenderState (int aId)
 Function GetRenderState returns the state of the checkbox associated with aId. More...
 
void UpdateLayouts ()
 
void UpdateLayerIcons ()
 Function UpdateLayerIcons Update all layer manager icons (layers only) Useful when loading a file or clearing a layer because they change, and the indicator arrow icon needs to be updated. More...
 

Static Public Attributes

static const wxEventType EVT_LAYER_COLOR_CHANGE = wxNewEventType()
 

Protected Types

enum  POPUP_ID {
  ID_SHOW_ALL_COPPER_LAYERS = LAYER_WIDGET::ID_LAST_VALUE, ID_HIDE_ALL_COPPER_LAYERS, ID_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE, ID_ALWAYS_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE,
  ID_SHOW_NO_LAYERS, ID_SHOW_ALL_LAYERS, ID_SHOW_ONLY_FRONT, ID_SHOW_ONLY_INNER,
  ID_SHOW_ONLY_BACK, ID_SHOW_ONLY_FRONT_ASSEMBLY, ID_SHOW_ONLY_BACK_ASSEMBLY, ID_HIDE_ALL_NON_COPPER,
  ID_SHOW_ALL_NON_COPPER, ID_LAST_VALUE
}
 

Protected Member Functions

virtual COLOR4D getBackgroundLayerColor () override
 Subclasses can override this to provide accurate representation of transparent colour swatches. More...
 
bool isAllowedInFpMode (int aId)
 Function isAllowedInFpMode. More...
 
bool isLayerAllowedInFpMode (PCB_LAYER_ID aLayer)
 Function isLayerAllowedInFpMode. More...
 
void onRightDownLayers (wxMouseEvent &event)
 Function OnRightDownLayers puts up a popup menu for the layer panel. More...
 
void onPopupSelection (wxCommandEvent &event)
 
void installRightLayerClickHandler ()
 this is for the popup menu, the right click handler has to be installed on every child control within the layer panel. More...
 
virtual bool useAlternateBitmap (int aRow)
 Virtual Function useAlternateBitmap. More...
 
void OnLeftDownLayers (wxMouseEvent &event)
 
void OnRightDownLayer (wxMouseEvent &event, COLOR_SWATCH *aColorSwatch, const wxString &aLayerName)
 Function OnRightDownLayer Called when user right-clicks a layer. More...
 
void OnLayerSwatchChanged (wxCommandEvent &aEvent)
 Function OnSwatchChanged() is called when a user changes a swatch color. More...
 
void OnLayerCheckBox (wxCommandEvent &event)
 Function OnLayerCheckBox handles the "is layer visible" checkbox and propogates the event to the client's notification function. More...
 
void OnRightDownRender (wxMouseEvent &aEvent, COLOR_SWATCH *aColorSwatch, const wxString &aRenderName)
 Function OnRightDownRender Called when user right-clicks a render option. More...
 
void OnRenderSwatchChanged (wxCommandEvent &aEvent)
 Function OnRenderSwatchChanged Called when user has changed the swatch color of a render entry. More...
 
void OnRenderCheckBox (wxCommandEvent &event)
 
void OnTabChange (wxNotebookEvent &event)
 
wxWindow * getLayerComp (int aRow, int aColumn) const
 Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL if these parameters are out of range. More...
 
wxWindow * getRenderComp (int aRow, int aColumn) const
 
int findLayerRow (LAYER_NUM aLayer) const
 Function findLayerRow returns the row index that aLayer resides in, or -1 if not found. More...
 
int findRenderRow (int aId) const
 
void insertLayerRow (int aRow, const ROW &aSpec)
 Function insertLayerRow appends or inserts a new row in the layer portion of the widget. More...
 
void insertRenderRow (int aRow, const ROW &aSpec)
 
void setLayerCheckbox (LAYER_NUM aLayer, bool isVisible)
 
void updateLayerRow (int aRow, const wxString &aName)
 
void passOnFocus ()
 Function passOnFocus gives away the keyboard focus up to the main parent window. More...
 

Static Protected Member Functions

static int encodeId (int aColumn, int aId)
 Function encodeId is here to allow saving a layer index within a control as its wxControl id, but to do so in a way that all child wxControl ids within a wxWindow are unique, since this is required by Windows. More...
 
static LAYER_NUM getDecodedId (int aControlId)
 Function getDecodedId decodes aControlId to original un-encoded value. More...
 

Protected Attributes

bool m_alwaysShowActiveCopperLayer
 
bool m_fp_editor_mode
 
PCB_BASE_FRAMEmyframe
 
wxAuiNotebook * m_notebook
 
wxPanel * m_LayerPanel
 
wxScrolledWindow * m_LayerScrolledWindow
 
wxFlexGridSizer * m_LayersFlexGridSizer
 
wxPanel * m_RenderingPanel
 
wxScrolledWindow * m_RenderScrolledWindow
 
wxFlexGridSizer * m_RenderFlexGridSizer
 
wxWindow * m_FocusOwner
 
int m_CurrentRow
 selected row of layer list More...
 
int m_PointSize
 
ROW_ICON_PROVIDERm_IconProvider
 

Static Protected Attributes

static const LAYER_WIDGET::ROW s_render_rows []
 This is a read only template that is copied and modified before adding to LAYER_WIDGET. More...
 

Detailed Description

PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tied into the PCB_EDIT_FRAME's data and so we can add a popup menu which is specific to PCBNEW's needs.

Definition at line 42 of file pcb_layer_widget.h.

Member Enumeration Documentation

◆ POPUP_ID

Enumerator
ID_SHOW_ALL_COPPER_LAYERS 
ID_HIDE_ALL_COPPER_LAYERS 
ID_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE 
ID_ALWAYS_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE 
ID_SHOW_NO_LAYERS 
ID_SHOW_ALL_LAYERS 
ID_SHOW_ONLY_FRONT 
ID_SHOW_ONLY_INNER 
ID_SHOW_ONLY_BACK 
ID_SHOW_ONLY_FRONT_ASSEMBLY 
ID_SHOW_ONLY_BACK_ASSEMBLY 
ID_HIDE_ALL_NON_COPPER 
ID_SHOW_ALL_NON_COPPER 
ID_LAST_VALUE 

Definition at line 130 of file pcb_layer_widget.h.

131  {
146  };

Constructor & Destructor Documentation

◆ PCB_LAYER_WIDGET()

PCB_LAYER_WIDGET::PCB_LAYER_WIDGET ( PCB_BASE_FRAME aParent,
wxWindow *  aFocusOwner,
bool  aFpEditorMode = false 
)

Constructor.

Parameters
aParentis the parent window
aFocusOwneris the window that should be sent the focus after
aFpEditorModefalse for the board editor (default), true for fp editor when true, some options or layers which cannot be used in editor mode are not displayed

Definition at line 99 of file pcb_layer_widget.cpp.

100  :
101  LAYER_WIDGET( aParent, aFocusOwner ),
102  myframe( aParent )
103 {
105  m_fp_editor_mode = aFpEditorMode;
106 
107  // Update default tabs labels
109 
110  //-----<Popup menu>-------------------------------------------------
111  // handle the popup menu over the layer window.
112  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
113  wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
114 
115  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
116  // and not m_LayerScrolledWindow->Connect()
117 
119  wxEVT_COMMAND_MENU_SELECTED,
120  wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
121 }
PCB_BASE_FRAME * myframe
void SetLayersManagerTabsText()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
#define NULL
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:129
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
bool m_alwaysShowActiveCopperLayer
LAYER_WIDGET(wxWindow *aParent, wxWindow *aFocusOwner, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Constructor.
void onPopupSelection(wxCommandEvent &event)

References ID_LAST_VALUE, ID_SHOW_ALL_COPPER_LAYERS, m_alwaysShowActiveCopperLayer, m_fp_editor_mode, LAYER_WIDGET::m_LayerScrolledWindow, NULL, onPopupSelection(), onRightDownLayers(), and SetLayersManagerTabsText().

Member Function Documentation

◆ AddRightClickMenuItems()

void PCB_LAYER_WIDGET::AddRightClickMenuItems ( wxMenu &  menu)

Function addRightClickMenuItems add menu items to a menu that should be shown when right-clicking the PCB layer widget.

Definition at line 148 of file pcb_layer_widget.cpp.

149 {
151  _( "Show All Copper Layers" ),
154  _( "Hide All Copper Layers" ),
156 
157  menu.AppendSeparator();
158 
160  _( "Hide All Copper Layers But Active" ),
163  _( "Always Hide All Copper Layers But Active" ),
165 
166  menu.AppendSeparator();
167 
169  _( "Show All Non Copper Layers" ),
172  _( "Hide All Non Copper Layers" ),
174 
175  menu.AppendSeparator();
176 
177  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
179  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
181 
182  menu.AppendSeparator();
183 
184  AddMenuItem( &menu, ID_SHOW_ONLY_FRONT_ASSEMBLY, _( "Show Only Front Assembly Layers" ),
185  KiBitmap( shape_3d_xpm ) );
186 
187  AddMenuItem( &menu, ID_SHOW_ONLY_FRONT, _( "Show Only Front Layers" ),
189 
190  // Only show the internal layer option if internal layers are enabled
191  if( myframe->GetBoard()->GetCopperLayerCount() > 2 )
192  {
193  AddMenuItem( &menu, ID_SHOW_ONLY_INNER, _( "Show Only Inner Layers" ),
195  }
196 
197  AddMenuItem( &menu, ID_SHOW_ONLY_BACK, _( "Show Only Back Layers" ),
199 
200  AddMenuItem( &menu, ID_SHOW_ONLY_BACK_ASSEMBLY, _( "Show Only Back Assembly Layers" ),
202 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:232
const BITMAP_OPAQUE show_no_copper_layers_xpm[1]
const BITMAP_OPAQUE select_layer_pair_xpm[1]
PCB_BASE_FRAME * myframe
const BITMAP_OPAQUE show_all_copper_layers_xpm[1]
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
const BITMAP_OPAQUE show_all_back_layers_xpm[1]
const BITMAP_OPAQUE select_w_layer_xpm[1]
const BITMAP_OPAQUE shape_3d_back_xpm[1]
const BITMAP_OPAQUE show_all_layers_xpm[1]
const BITMAP_OPAQUE shape_3d_xpm[1]
Definition: shape_3d.cpp:35
#define _(s)
Definition: 3d_actions.cpp:33
int GetCopperLayerCount() const
Function GetCopperLayerCount.
const BITMAP_OPAQUE show_all_front_layers_xpm[1]
BOARD * GetBoard() const
const BITMAP_OPAQUE show_no_layers_xpm[1]

References _, AddMenuItem(), PCB_BASE_FRAME::GetBoard(), BOARD::GetCopperLayerCount(), ID_ALWAYS_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE, ID_HIDE_ALL_COPPER_LAYERS, ID_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE, ID_HIDE_ALL_NON_COPPER, ID_SHOW_ALL_COPPER_LAYERS, ID_SHOW_ALL_LAYERS, ID_SHOW_ALL_NON_COPPER, ID_SHOW_NO_LAYERS, ID_SHOW_ONLY_BACK, ID_SHOW_ONLY_BACK_ASSEMBLY, ID_SHOW_ONLY_FRONT, ID_SHOW_ONLY_FRONT_ASSEMBLY, ID_SHOW_ONLY_INNER, KiBitmap(), myframe, select_layer_pair_xpm, select_w_layer_xpm, shape_3d_back_xpm, shape_3d_xpm, show_all_back_layers_xpm, show_all_copper_layers_xpm, show_all_front_layers_xpm, show_all_layers_xpm, show_no_copper_layers_xpm, and show_no_layers_xpm.

Referenced by OnLayerRightClick(), and onRightDownLayers().

◆ AppendLayerRow()

void LAYER_WIDGET::AppendLayerRow ( const ROW aRow)
inherited

Function AppendLayerRow appends a new row in the layer portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 637 of file layer_widget.cpp.

638 {
639  int nextRow = GetLayerRowCount();
640  insertLayerRow( nextRow, aRow );
641 }
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
void insertLayerRow(int aRow, const ROW &aSpec)
Function insertLayerRow appends or inserts a new row in the layer portion of the widget.

References LAYER_WIDGET::GetLayerRowCount(), and LAYER_WIDGET::insertLayerRow().

Referenced by LAYER_WIDGET::AppendLayerRows(), ReFill(), and GERBER_LAYER_WIDGET::ReFill().

◆ AppendLayerRows()

void LAYER_WIDGET::AppendLayerRows ( const ROW aRowsArray,
int  aRowCount 
)
inlineinherited

Function AppendLayerRows appends new rows in the layer portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 306 of file layer_widget.h.

307  {
308  for( int row=0; row<aRowCount; ++row )
309  AppendLayerRow( aRowsArray[row] );
310 
311  UpdateLayouts();
312  }
void UpdateLayouts()
void AppendLayerRow(const ROW &aRow)
Function AppendLayerRow appends a new row in the layer portion of the widget.

References LAYER_WIDGET::AppendLayerRow(), and LAYER_WIDGET::UpdateLayouts().

◆ AppendRenderRow()

void LAYER_WIDGET::AppendRenderRow ( const ROW aRow)
inherited

Function AppendRenderRow appends a new row in the render portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 650 of file layer_widget.cpp.

651 {
652  int nextRow = GetRenderRowCount();
653  insertRenderRow( nextRow, aRow );
654 }
void insertRenderRow(int aRow, const ROW &aSpec)
int GetRenderRowCount() const
Function GetRenderRowCount returns the number of rows in the render tab.

References LAYER_WIDGET::GetRenderRowCount(), and LAYER_WIDGET::insertRenderRow().

Referenced by LAYER_WIDGET::AppendRenderRows(), and ReFillRender().

◆ AppendRenderRows()

void LAYER_WIDGET::AppendRenderRows ( const ROW aRowsArray,
int  aRowCount 
)
inlineinherited

Function AppendRenderRows appends new rows in the render portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 332 of file layer_widget.h.

333  {
334  for( int row=0; row<aRowCount; ++row )
335  AppendRenderRow( aRowsArray[row] );
336 
337  UpdateLayouts();
338  }
void UpdateLayouts()
void AppendRenderRow(const ROW &aRow)
Function AppendRenderRow appends a new row in the render portion of the widget.

References LAYER_WIDGET::AppendRenderRow(), and LAYER_WIDGET::UpdateLayouts().

Referenced by GERBER_LAYER_WIDGET::ReFillRender().

◆ ClearLayerRows()

void LAYER_WIDGET::ClearLayerRows ( )
inherited

Function ClearLayerRows empties out the layer rows.

Definition at line 644 of file layer_widget.cpp.

645 {
646  m_LayersFlexGridSizer->Clear( true );
647 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:130

References LAYER_WIDGET::m_LayersFlexGridSizer.

Referenced by ReFill().

◆ ClearRenderRows()

void LAYER_WIDGET::ClearRenderRows ( )
inherited

Function ClearRenderRows empties out the render rows.

Definition at line 657 of file layer_widget.cpp.

658 {
659  m_RenderFlexGridSizer->Clear( true );
660 }
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:133

References LAYER_WIDGET::m_RenderFlexGridSizer.

Referenced by ReFillRender(), and GERBER_LAYER_WIDGET::ReFillRender().

◆ encodeId()

int LAYER_WIDGET::encodeId ( int  aColumn,
int  aId 
)
staticprotectedinherited

Function encodeId is here to allow saving a layer index within a control as its wxControl id, but to do so in a way that all child wxControl ids within a wxWindow are unique, since this is required by Windows.

See also
getDecodedId()

Definition at line 63 of file layer_widget.cpp.

64 {
65  int id = aId * LYR_COLUMN_COUNT + aColumn;
66  return id;
67 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49

References LYR_COLUMN_COUNT.

Referenced by LAYER_WIDGET::insertLayerRow(), and LAYER_WIDGET::insertRenderRow().

◆ findLayerRow()

int LAYER_WIDGET::findLayerRow ( LAYER_NUM  aLayer) const
protectedinherited

Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.

Definition at line 268 of file layer_widget.cpp.

269 {
270  int count = GetLayerRowCount();
271 
272  for( int row = 0; row < count; ++row )
273  {
274  // column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
275  wxWindow* w = getLayerComp( row, 0 );
276  wxASSERT( w );
277 
278  if( aLayer == getDecodedId( w->GetId() ))
279  return row;
280  }
281 
282  return -1;
283 }
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.

References LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), and LAYER_WIDGET::GetLayerRowCount().

Referenced by LAYER_WIDGET::GetLayerColor(), LAYER_WIDGET::IsLayerVisible(), LAYER_WIDGET::OnLeftDownLayers(), GERBER_LAYER_WIDGET::ReFill(), LAYER_WIDGET::SelectLayer(), LAYER_WIDGET::setLayerCheckbox(), and LAYER_WIDGET::SetLayerColor().

◆ findRenderRow()

int LAYER_WIDGET::findRenderRow ( int  aId) const
protectedinherited

Definition at line 297 of file layer_widget.cpp.

298 {
299  int count = GetRenderRowCount();
300 
301  for( int row = 0; row < count; ++row )
302  {
303  // column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
304  wxWindow* w = getRenderComp( row, 0 );
305  wxASSERT( w );
306 
307  if( aId == getDecodedId( w->GetId() ))
308  return row;
309  }
310 
311  return -1;
312 }
wxWindow * getRenderComp(int aRow, int aColumn) const
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int GetRenderRowCount() const
Function GetRenderRowCount returns the number of rows in the render tab.

References LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getRenderComp(), and LAYER_WIDGET::GetRenderRowCount().

Referenced by LAYER_WIDGET::GetRenderState(), and LAYER_WIDGET::SetRenderState().

◆ getBackgroundLayerColor()

COLOR4D PCB_LAYER_WIDGET::getBackgroundLayerColor ( )
overrideprotectedvirtual

Subclasses can override this to provide accurate representation of transparent colour swatches.

Reimplemented from LAYER_WIDGET.

Definition at line 124 of file pcb_layer_widget.cpp.

125 {
127 }
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
PCB_BASE_FRAME * myframe
COLOR4D GetColor(int aLayer) const

References COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), LAYER_PCB_BACKGROUND, and myframe.

◆ GetBestSize()

wxSize LAYER_WIDGET::GetBestSize ( ) const
inherited

Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic content.

Nothing in wxWidgets was reliable enough so this overrides one of their functions.

Definition at line 568 of file layer_widget.cpp.

569 {
570  // size of m_LayerScrolledWindow --------------
571  wxArrayInt widths = m_LayersFlexGridSizer->GetColWidths();
572  int totWidth = 0;
573 
574  if( widths.GetCount() )
575  {
576  for( int i = 0; i < LYR_COLUMN_COUNT; ++i )
577  {
578  totWidth += widths[i] + m_LayersFlexGridSizer->GetHGap();
579  // printf("widths[%d]:%d\n", i, widths[i] );
580  }
581  }
582 
583  // Account for the parent's frame:
584  totWidth += 15;
585 
586 
587  /* The minimum height is a small size to properly force computation
588  * of the panel's scrollbars (otherwise it will assume it *has* all
589  * this space) */
590  unsigned totHeight = 32;
591 
592  wxSize layerz( totWidth, totHeight );
593 
594  layerz += m_LayerPanel->GetWindowBorderSize();
595 
596 
597  // size of m_RenderScrolledWindow --------------
598  widths = m_RenderFlexGridSizer->GetColWidths();
599  totWidth = 0;
600 
601  if( widths.GetCount() )
602  {
603  for( int i = 0; i < RND_COLUMN_COUNT; ++i )
604  {
605  totWidth += widths[i] + m_RenderFlexGridSizer->GetHGap();
606  // printf("widths[%d]:%d\n", i, widths[i] );
607  }
608  }
609  // account for the parent's frame, this one has void space of 10 PLUS a border:
610  totWidth += 15;
611 
612  // For totHeight re-use the previous small one
613  wxSize renderz( totWidth, totHeight );
614 
615  renderz += m_RenderingPanel->GetWindowBorderSize();
616 
617  wxSize clientz( std::max(renderz.x,layerz.x), std::max(renderz.y,layerz.y) );
618 
619  return clientz;
620 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:130
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:50
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:133
wxPanel * m_RenderingPanel
Definition: layer_widget.h:131
wxPanel * m_LayerPanel
Definition: layer_widget.h:128

References LYR_COLUMN_COUNT, LAYER_WIDGET::m_LayerPanel, LAYER_WIDGET::m_LayersFlexGridSizer, LAYER_WIDGET::m_RenderFlexGridSizer, LAYER_WIDGET::m_RenderingPanel, and RND_COLUMN_COUNT.

Referenced by GERBVIEW_FRAME::GERBVIEW_FRAME(), FOOTPRINT_EDIT_FRAME::ReFillLayerWidget(), and GERBVIEW_FRAME::ReFillLayerWidget().

◆ getDecodedId()

LAYER_NUM LAYER_WIDGET::getDecodedId ( int  aControlId)
staticprotectedinherited

Function getDecodedId decodes aControlId to original un-encoded value.

This of course holds iff encodedId was called with a LAYER_NUM (this box is used for other things than layers, too)

Definition at line 70 of file layer_widget.cpp.

71 {
72  int id = aControlId / LYR_COLUMN_COUNT; // rounding is OK.
73  return id;
74 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49

References LYR_COLUMN_COUNT.

Referenced by LAYER_WIDGET::findLayerRow(), LAYER_WIDGET::findRenderRow(), LAYER_WIDGET::GetSelectedLayer(), LAYER_WIDGET::OnLayerCheckBox(), LAYER_WIDGET::OnLayerSwatchChanged(), LAYER_WIDGET::OnLeftDownLayers(), GERBER_LAYER_WIDGET::onPopupSelection(), onPopupSelection(), LAYER_WIDGET::OnRenderCheckBox(), LAYER_WIDGET::OnRenderSwatchChanged(), SyncLayerAlphaIndicators(), SyncLayerColors(), and SyncLayerVisibilities().

◆ GetLayerColor()

COLOR4D LAYER_WIDGET::GetLayerColor ( LAYER_NUM  aLayer) const
inherited

Function GetLayerColor returns the color of the layer ROW associated with aLayer id.

Definition at line 762 of file layer_widget.cpp.

763 {
764  int row = findLayerRow( aLayer );
765  if( row >= 0 )
766  {
767  int col = 1; // bitmap button is column 1
768  auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
769  wxASSERT( swatch );
770 
771  return swatch->GetSwatchColor();
772  }
773 
774  return COLOR4D::UNSPECIFIED; // it's caller fault, gave me a bad layer
775 }
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...

References LAYER_WIDGET::findLayerRow(), and LAYER_WIDGET::getLayerComp().

◆ getLayerComp()

wxWindow * LAYER_WIDGET::getLayerComp ( int  aRow,
int  aColumn 
) const
protectedinherited

Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL if these parameters are out of range.

Parameters
aRowis the row index
aColumnis the column
Returns
wxWindow - the component installed within the sizer at given grid coordinate.

Definition at line 257 of file layer_widget.cpp.

258 {
259  unsigned ndx = aRow * LYR_COLUMN_COUNT + aColumn;
260 
261  if( ndx < m_LayersFlexGridSizer->GetChildren().GetCount() )
262  return m_LayersFlexGridSizer->GetChildren()[ndx]->GetWindow();
263 
264  return NULL;
265 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:130
#define NULL

References LYR_COLUMN_COUNT, LAYER_WIDGET::m_LayersFlexGridSizer, and NULL.

Referenced by LAYER_WIDGET::findLayerRow(), LAYER_WIDGET::GetLayerColor(), LAYER_WIDGET::GetSelectedLayer(), LAYER_WIDGET::IsLayerVisible(), LAYER_WIDGET::OnLeftDownLayers(), GERBER_LAYER_WIDGET::onPopupSelection(), onPopupSelection(), LAYER_WIDGET::OnRenderSwatchChanged(), ReFill(), LAYER_WIDGET::SelectLayerRow(), LAYER_WIDGET::setLayerCheckbox(), LAYER_WIDGET::SetLayerColor(), SyncLayerAlphaIndicators(), SyncLayerColors(), SyncLayerVisibilities(), LAYER_WIDGET::UpdateLayerIcons(), and LAYER_WIDGET::updateLayerRow().

◆ GetLayerRowCount()

int LAYER_WIDGET::GetLayerRowCount ( ) const
inherited

Function GetLayerRowCount returns the number of rows in the layer tab.

Definition at line 623 of file layer_widget.cpp.

624 {
625  int controlCount = m_LayersFlexGridSizer->GetChildren().GetCount();
626  return controlCount / LYR_COLUMN_COUNT;
627 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:130

References LYR_COLUMN_COUNT, and LAYER_WIDGET::m_LayersFlexGridSizer.

Referenced by LAYER_WIDGET::AppendLayerRow(), LAYER_WIDGET::findLayerRow(), LAYER_WIDGET::OnLeftDownLayers(), GERBER_LAYER_WIDGET::onPopupSelection(), onPopupSelection(), LAYER_WIDGET::OnRenderSwatchChanged(), ReFill(), SyncLayerAlphaIndicators(), SyncLayerColors(), SyncLayerVisibilities(), and LAYER_WIDGET::UpdateLayerIcons().

◆ getRenderComp()

wxWindow * LAYER_WIDGET::getRenderComp ( int  aRow,
int  aColumn 
) const
protectedinherited

Definition at line 286 of file layer_widget.cpp.

287 {
288  int ndx = aRow * RND_COLUMN_COUNT + aColumn;
289 
290  if( (unsigned) ndx < m_RenderFlexGridSizer->GetChildren().GetCount() )
291  return m_RenderFlexGridSizer->GetChildren()[ndx]->GetWindow();
292 
293  return NULL;
294 }
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:50
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:133
#define NULL

References LAYER_WIDGET::m_RenderFlexGridSizer, NULL, and RND_COLUMN_COUNT.

Referenced by LAYER_WIDGET::findRenderRow(), LAYER_WIDGET::GetRenderState(), LAYER_WIDGET::OnRenderSwatchChanged(), LAYER_WIDGET::SetRenderState(), and SyncLayerColors().

◆ GetRenderRowCount()

int LAYER_WIDGET::GetRenderRowCount ( ) const
inherited

Function GetRenderRowCount returns the number of rows in the render tab.

Definition at line 630 of file layer_widget.cpp.

631 {
632  int controlCount = m_RenderFlexGridSizer->GetChildren().GetCount();
633  return controlCount / RND_COLUMN_COUNT;
634 }
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:50
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:133

References LAYER_WIDGET::m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

Referenced by LAYER_WIDGET::AppendRenderRow(), LAYER_WIDGET::findRenderRow(), LAYER_WIDGET::OnRenderSwatchChanged(), and SyncLayerColors().

◆ GetRenderState()

bool LAYER_WIDGET::GetRenderState ( int  aId)
inherited

Function GetRenderState returns the state of the checkbox associated with aId.

Returns
bool - true if checked, else false.

Definition at line 792 of file layer_widget.cpp.

793 {
794  int row = findRenderRow( aId );
795 
796  if( row >= 0 )
797  {
798  int col = 1; // checkbox is column 1
799  wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
800  wxASSERT( cb );
801  return cb->GetValue();
802  }
803 
804  return false; // the value of a non-existent row
805 }
int findRenderRow(int aId) const
wxWindow * getRenderComp(int aRow, int aColumn) const

References LAYER_WIDGET::findRenderRow(), and LAYER_WIDGET::getRenderComp().

◆ GetSelectedLayer()

LAYER_NUM LAYER_WIDGET::GetSelectedLayer ( )
inherited

Function GetSelectedLayer returns the selected layer or -1 if none.

Definition at line 706 of file layer_widget.cpp.

707 {
708  wxWindow* w = getLayerComp( m_CurrentRow, 0 );
709  if( w )
710  return getDecodedId( w->GetId() );
711 
712  return UNDEFINED_LAYER;
713 }
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:136
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.

References LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::m_CurrentRow, and UNDEFINED_LAYER.

◆ insertLayerRow()

void LAYER_WIDGET::insertLayerRow ( int  aRow,
const ROW aSpec 
)
protectedinherited

Function insertLayerRow appends or inserts a new row in the layer portion of the widget.

Definition at line 315 of file layer_widget.cpp.

316 {
317  wxASSERT( aRow >= 0 );
318 
319  int col;
320  int index = aRow * LYR_COLUMN_COUNT;
321  const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
322 
323  // column 0
324  col = COLUMN_ICON_ACTIVE;
326  ROW_ICON_PROVIDER::STATE::OFF, encodeId( col, aSpec.id ) );
327  sbm->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
328  m_LayersFlexGridSizer->wxSizer::Insert( index+col, sbm, 0, flags );
329 
330  // column 1 (COLUMN_COLORBM)
331  col = COLUMN_COLORBM;
332 
333  auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
334  getBackgroundLayerColor(), aSpec.defaultColor, false );
335  bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
336  bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
337  bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) );
338  m_LayersFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
339 
340  // column 2 (COLUMN_COLOR_LYR_CB)
341  col = COLUMN_COLOR_LYR_CB;
342  wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow, encodeId( col, aSpec.id ), wxEmptyString );
343  cb->SetValue( aSpec.state );
344  cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnLayerCheckBox, this );
345  cb->SetToolTip( _( "Enable this for visibility" ) );
346  m_LayersFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
347 
348  // column 3 (COLUMN_COLOR_LYRNAME)
349  col = COLUMN_COLOR_LYRNAME;
350  wxStaticText* st = new wxStaticText( m_LayerScrolledWindow, encodeId( col, aSpec.id ), aSpec.rowName );
351  shrinkFont( st, m_PointSize );
352  st->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
353  st->SetToolTip( aSpec.tooltip );
354  m_LayersFlexGridSizer->wxSizer::Insert( index+col, st, 0, flags );
355 
356  // column 4 (COLUMN_ALPHA_INDICATOR)
359  ROW_ICON_PROVIDER::STATE::OFF, wxID_ANY );
360  m_LayersFlexGridSizer->wxSizer::Insert( index+col, sbm, 0, flags );
361 
362  // Bind right click eventhandler to all columns
363  wxString layerName( aSpec.rowName );
364 
365  sbm->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
366  {
367  OnRightDownLayer( aEvt, bmb, layerName );
368  } );
369  bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
370  {
371  OnRightDownLayer( aEvt, bmb, layerName );
372  } );
373  cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
374  {
375  OnRightDownLayer( aEvt, bmb, layerName );
376  } );
377  st->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
378  {
379  OnRightDownLayer( aEvt, bmb, layerName );
380  } );
381 }
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:55
void OnLeftDownLayers(wxMouseEvent &event)
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49
#define COLUMN_ALPHA_INDICATOR
Definition: layer_widget.h:56
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:130
static void shrinkFont(wxWindow *aControl, int aPointSize)
Function shrinkFont reduces the size of the wxFont associated with aControl.
void OnLayerCheckBox(wxCommandEvent &event)
Function OnLayerCheckBox handles the "is layer visible" checkbox and propogates the event to the clie...
static int encodeId(int aColumn, int aId)
Function encodeId is here to allow saving a layer index within a control as its wxControl id,...
representing a row indicator icon for use in places like the layer widget
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
#define COLUMN_COLORBM
Definition: layer_widget.h:53
#define OFF
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:129
void OnRightDownLayer(wxMouseEvent &event, COLOR_SWATCH *aColorSwatch, const wxString &aLayerName)
Function OnRightDownLayer Called when user right-clicks a layer.
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:54
#define _(s)
Definition: 3d_actions.cpp:33
virtual COLOR4D getBackgroundLayerColor()
Subclasses can override this to provide accurate representation of transparent colour swatches.
Definition: layer_widget.h:155
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
void OnLayerSwatchChanged(wxCommandEvent &aEvent)
Function OnSwatchChanged() is called when a user changes a swatch color.
ROW_ICON_PROVIDER * m_IconProvider
Definition: layer_widget.h:139

References _, LAYER_WIDGET::ROW::color, COLUMN_ALPHA_INDICATOR, COLUMN_COLOR_LYR_CB, COLUMN_COLOR_LYRNAME, COLUMN_COLORBM, COLUMN_ICON_ACTIVE, LAYER_WIDGET::ROW::defaultColor, LAYER_WIDGET::encodeId(), LAYER_WIDGET::getBackgroundLayerColor(), LAYER_WIDGET::ROW::id, LYR_COLUMN_COUNT, LAYER_WIDGET::m_IconProvider, LAYER_WIDGET::m_LayerScrolledWindow, LAYER_WIDGET::m_LayersFlexGridSizer, LAYER_WIDGET::m_PointSize, OFF, LAYER_WIDGET::OnLayerCheckBox(), LAYER_WIDGET::OnLayerSwatchChanged(), LAYER_WIDGET::OnLeftDownLayers(), LAYER_WIDGET::OnRightDownLayer(), LAYER_WIDGET::ROW::rowName, shrinkFont(), LAYER_WIDGET::ROW::state, and LAYER_WIDGET::ROW::tooltip.

Referenced by LAYER_WIDGET::AppendLayerRow().

◆ insertRenderRow()

void LAYER_WIDGET::insertRenderRow ( int  aRow,
const ROW aSpec 
)
protectedinherited

Definition at line 405 of file layer_widget.cpp.

406 {
407  wxASSERT( aRow >= 0 );
408 
409  int col;
410  int index = aRow * RND_COLUMN_COUNT;
411  const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
412 
413  wxString renderName( aSpec.rowName );
414  wxCheckBox* cb = nullptr;
415 
416  // column 1
417  if( !aSpec.spacer )
418  {
419  col = 1;
420  cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ),
421  aSpec.rowName, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
422  shrinkFont( cb, m_PointSize );
423  cb->SetValue( aSpec.state );
424  cb->Enable( aSpec.changeable );
425  cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
426  cb->SetToolTip( aSpec.tooltip );
427  }
428 
429  // column 0
430  col = 0;
431  if( aSpec.color != COLOR4D::UNSPECIFIED )
432  {
433  auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
434  getBackgroundLayerColor(), aSpec.defaultColor, false );
435  bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
436  bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
437  m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
438 
439  bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
440  OnRightDownRender( aEvt, bmb, renderName );
441  } );
442  cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
443  OnRightDownRender( aEvt, bmb, renderName );
444  } );
445 
446  // could add a left click handler on the color button that toggles checkbox.
447  }
448  else // == -1, no color selection wanted
449  {
450  // need a place holder within the sizer to keep grid full.
451  wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, encodeId( col, aSpec.id ) );
452  m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
453  }
454 
455  // Items have to be inserted in order
456  col = 1;
457 
458  if( aSpec.spacer )
459  {
460  wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, wxID_ANY );
461  m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
462  }
463  else
464  {
465  m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
466  }
467 }
wxScrolledWindow * m_RenderScrolledWindow
Definition: layer_widget.h:132
static void shrinkFont(wxWindow *aControl, int aPointSize)
Function shrinkFont reduces the size of the wxFont associated with aControl.
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:50
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:133
void OnRenderCheckBox(wxCommandEvent &event)
static int encodeId(int aColumn, int aId)
Function encodeId is here to allow saving a layer index within a control as its wxControl id,...
void OnRightDownRender(wxMouseEvent &aEvent, COLOR_SWATCH *aColorSwatch, const wxString &aRenderName)
Function OnRightDownRender Called when user right-clicks a render option.
void OnRenderSwatchChanged(wxCommandEvent &aEvent)
Function OnRenderSwatchChanged Called when user has changed the swatch color of a render entry.
#define _(s)
Definition: 3d_actions.cpp:33
virtual COLOR4D getBackgroundLayerColor()
Subclasses can override this to provide accurate representation of transparent colour swatches.
Definition: layer_widget.h:155
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38

References _, LAYER_WIDGET::ROW::changeable, LAYER_WIDGET::ROW::color, LAYER_WIDGET::ROW::defaultColor, LAYER_WIDGET::encodeId(), LAYER_WIDGET::getBackgroundLayerColor(), LAYER_WIDGET::ROW::id, LAYER_WIDGET::m_PointSize, LAYER_WIDGET::m_RenderFlexGridSizer, LAYER_WIDGET::m_RenderScrolledWindow, LAYER_WIDGET::OnRenderCheckBox(), LAYER_WIDGET::OnRenderSwatchChanged(), LAYER_WIDGET::OnRightDownRender(), RND_COLUMN_COUNT, LAYER_WIDGET::ROW::rowName, shrinkFont(), LAYER_WIDGET::ROW::spacer, LAYER_WIDGET::ROW::state, and LAYER_WIDGET::ROW::tooltip.

Referenced by LAYER_WIDGET::AppendRenderRow().

◆ installRightLayerClickHandler()

void PCB_LAYER_WIDGET::installRightLayerClickHandler ( )
protected

this is for the popup menu, the right click handler has to be installed on every child control within the layer panel.

◆ isAllowedInFpMode()

bool PCB_LAYER_WIDGET::isAllowedInFpMode ( int  aId)
protected

Function isAllowedInFpMode.

Returns
true if item aId has meaning in footprint editor mode. and therefore is shown in render panel

Definition at line 130 of file pcb_layer_widget.cpp.

131 {
132  for( unsigned ii = 0; ii < arrayDim( s_allowed_in_FpEditor ); ii++ )
133  if( s_allowed_in_FpEditor[ii] == aId )
134  return true;
135 
136  return false;
137 }
static int s_allowed_in_FpEditor[]
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160

References arrayDim(), and s_allowed_in_FpEditor.

Referenced by ReFillRender().

◆ isLayerAllowedInFpMode()

bool PCB_LAYER_WIDGET::isLayerAllowedInFpMode ( PCB_LAYER_ID  aLayer)
protected

Function isLayerAllowedInFpMode.

User layers, which are not paired, are not shown in layers manager. However a not listed layer can be reachable in the graphic item properties dialog.

Parameters
aLayeris the layer id to test
Returns
true if PCB_LAYER_ID aLayer has meaning in footprint editor mode. and therefore is shown in render panel

Definition at line 140 of file pcb_layer_widget.cpp.

141 {
142  static LSET allowed = LSET::AllTechMask();
143  allowed.set( F_Cu ).set( B_Cu );
144  return allowed.test( aLayer );
145 }
static LSET AllTechMask()
Function AllTechMask returns a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:782
LSET is a set of PCB_LAYER_IDs.

References LSET::AllTechMask(), B_Cu, and F_Cu.

◆ IsLayerVisible()

bool LAYER_WIDGET::IsLayerVisible ( LAYER_NUM  aLayer)
inherited

Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id.

Definition at line 735 of file layer_widget.cpp.

736 {
737  int row = findLayerRow( aLayer );
738  if( row >= 0 )
739  {
740  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
741  wxASSERT( cb );
742  return cb->GetValue();
743  }
744  return false;
745 }
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:54

References COLUMN_COLOR_LYR_CB, LAYER_WIDGET::findLayerRow(), and LAYER_WIDGET::getLayerComp().

Referenced by GERBVIEW_FRAME::IsLayerVisible().

◆ OnLayerCheckBox()

void LAYER_WIDGET::OnLayerCheckBox ( wxCommandEvent &  event)
protectedinherited

Function OnLayerCheckBox handles the "is layer visible" checkbox and propogates the event to the client's notification function.

Definition at line 166 of file layer_widget.cpp.

167 {
168  wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
169  LAYER_NUM layer = getDecodedId( eventSource->GetId() );
170  OnLayerVisible( layer, eventSource->IsChecked() );
171  passOnFocus();
172 }
virtual void OnLayerVisible(LAYER_NUM aLayer, bool isVisible, bool isFinal=true)=0
Function OnLayerVisible is called to notify client code about a layer visibility change.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.

References LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::OnLayerVisible(), and LAYER_WIDGET::passOnFocus().

Referenced by LAYER_WIDGET::insertLayerRow().

◆ OnLayerColorChange()

void PCB_LAYER_WIDGET::OnLayerColorChange ( int  aLayer,
COLOR4D  aColor 
)
overridevirtual

Function OnLayerColorChange is called to notify client code about a layer color change.

Derived es will handle this accordingly.

Parameters
aLayeris the board layer to change
aColoris the new color

Implements LAYER_WIDGET.

Definition at line 565 of file pcb_layer_widget.cpp.

566 {
568  cs->SetColor( aLayer, aColor );
569 
571 
572  KIGFX::VIEW* view = myframe->GetCanvas()->GetView();
573  view->UpdateLayerColor( aLayer );
574  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
575 
577 
578  myframe->GetCanvas()->Refresh();
579 
580  if( aLayer == LAYER_PCB_BACKGROUND )
581  myframe->SetDrawBgColor( aColor );
582 }
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * myframe
void SetDrawBgColor(COLOR4D aColor) override
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns 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()
Updates the color settings in the painter and GAL.
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:781
virtual void ReCreateHToolbar()=0
Color settings are a bit different than most of the settings objects in that there can be more than o...
VIEW.
Definition: view.h:61
void SetColor(int aLayer, COLOR4D aColor)

References PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetColorSettings(), GetNetnameLayer(), PCB_DRAW_PANEL_GAL::GetView(), LAYER_PCB_BACKGROUND, myframe, EDA_DRAW_FRAME::ReCreateHToolbar(), EDA_DRAW_PANEL_GAL::Refresh(), COLOR_SETTINGS::SetColor(), PCB_BASE_FRAME::SetDrawBgColor(), PCB_DRAW_PANEL_GAL::UpdateColors(), and KIGFX::VIEW::UpdateLayerColor().

◆ OnLayerRightClick()

void PCB_LAYER_WIDGET::OnLayerRightClick ( wxMenu &  aMenu)
overridevirtual

Function OnLayerRightClick is called to notify client code about a layer being right-clicked.

Parameters
aMenuis the right-click menu containing layer-scoped options. It can be used to add extra, wider scoped menu items.

Implements LAYER_WIDGET.

Definition at line 651 of file pcb_layer_widget.cpp.

652 {
653  AddRightClickMenuItems( aMenu );
654 }
void AddRightClickMenuItems(wxMenu &menu)
Function addRightClickMenuItems add menu items to a menu that should be shown when right-clicking the...

References AddRightClickMenuItems().

◆ OnLayerSelect()

bool PCB_LAYER_WIDGET::OnLayerSelect ( int  aLayer)
overridevirtual

Function OnLayerSelect is called to notify client code whenever the user selects a different layer.

Derived classes will handle this accordingly, and can deny the change by returning false.

Parameters
aLayeris the board layer to select

Implements LAYER_WIDGET.

Definition at line 585 of file pcb_layer_widget.cpp.

586 {
587  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
588  // false from this function.
589  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
590 
592  return false;
593 
594  myframe->SetActiveLayer( layer );
595 
598 
600  OnLayerSelected();
601  else if( hcm )
602  myframe->GetCanvas()->Refresh();
603 
604  return true;
605 }
static LSET ForbiddenFootprintLayers()
Function ForbiddenFootprintLayers Layers which are not allowed within footprint definitions.
Definition: lset.cpp:825
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * myframe
bool OnLayerSelected()
Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwa...
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
PCB_LAYER_ID
A quick note on layer IDs:
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
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 m_alwaysShowActiveCopperLayer
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849

References LSET::ForbiddenFootprintLayers(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), m_alwaysShowActiveCopperLayer, PCB_DISPLAY_OPTIONS::m_ContrastModeDisplay, m_fp_editor_mode, myframe, NORMAL, OnLayerSelected(), EDA_DRAW_PANEL_GAL::Refresh(), PCB_BASE_FRAME::SetActiveLayer(), and ToLAYER_ID().

◆ OnLayerSelected()

bool PCB_LAYER_WIDGET::OnLayerSelected ( )

Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwaysShowActiveLayer is true Otherwise do nothing.

Returns
true m_alwaysShowActiveLayer is true and the canvas is refreshed, and false if do nothing

Definition at line 608 of file pcb_layer_widget.cpp.

609 {
611  return false;
612 
613  // postprocess after an active layer selection
614  // ensure active layer visible
615  wxCommandEvent event;
617  onPopupSelection( event );
618 
619  return true;
620 }
bool m_alwaysShowActiveCopperLayer
void onPopupSelection(wxCommandEvent &event)

References ID_ALWAYS_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE, m_alwaysShowActiveCopperLayer, and onPopupSelection().

Referenced by OnLayerSelect(), and FOOTPRINT_EDIT_FRAME::UpdateUserInterface().

◆ OnLayerSwatchChanged()

void LAYER_WIDGET::OnLayerSwatchChanged ( wxCommandEvent &  aEvent)
protectedinherited

Function OnSwatchChanged() is called when a user changes a swatch color.

Definition at line 149 of file layer_widget.cpp.

150 {
151  COLOR_SWATCH* eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
152  COLOR4D newColor = eventSource->GetSwatchColor();
153  LAYER_NUM layer = getDecodedId( eventSource->GetId() );
154 
155  // tell the client code.
156  OnLayerColorChange( layer, newColor );
157 
158  // notify others
159  wxCommandEvent event( EVT_LAYER_COLOR_CHANGE );
160  wxPostEvent( this, event );
161 
162  passOnFocus();
163 }
KIGFX::COLOR4D GetSwatchColor() const
static const wxEventType EVT_LAYER_COLOR_CHANGE
Definition: layer_widget.h:123
virtual void OnLayerColorChange(int aLayer, COLOR4D aColor)=0
Function OnLayerColorChange is called to notify client code about a layer color change.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, LAYER_WIDGET::getDecodedId(), COLOR_SWATCH::GetSwatchColor(), LAYER_WIDGET::OnLayerColorChange(), and LAYER_WIDGET::passOnFocus().

Referenced by LAYER_WIDGET::insertLayerRow().

◆ OnLayerVisible()

void PCB_LAYER_WIDGET::OnLayerVisible ( int  aLayer,
bool  isVisible,
bool  isFinal 
)
overridevirtual

Function OnLayerVisible is called to notify client code about a layer visibility change.

Parameters
aLayeris the board layer to select
isVisibleis the new visible state
isFinalis true when this is the last of potentially several such calls, and can be used to decide when to update the screen only one time instead of several times in the midst of a multiple layer change.

Implements LAYER_WIDGET.

Definition at line 623 of file pcb_layer_widget.cpp.

624 {
625  // In other frames than board editor, the board is a dummy board.
626  // so changing board settings makes sense (and works) only for the board editor frame
628  {
629  BOARD* brd = myframe->GetBoard();
630 
631  LSET visibleLayers = brd->GetVisibleLayers();
632 
633  if( visibleLayers.test( aLayer ) != isVisible )
634  {
635  visibleLayers.set( aLayer, isVisible );
636  brd->SetVisibleLayers( visibleLayers );
637 
638  if( myframe->GetCanvas() )
639  myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
640  }
641  }
642  else
643  if( myframe->GetCanvas() )
644  myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
645 
646  if( isFinal )
647  myframe->GetCanvas()->Refresh();
648 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
PCB_BASE_FRAME * myframe
LSET is a set of PCB_LAYER_IDs.
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:399
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns 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
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
BOARD * GetBoard() const

References FRAME_PCB_EDITOR, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), BOARD::GetVisibleLayers(), EDA_BASE_FRAME::IsType(), myframe, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::VIEW::SetLayerVisible(), and BOARD::SetVisibleLayers().

Referenced by onPopupSelection().

◆ OnLeftDownLayers()

void LAYER_WIDGET::OnLeftDownLayers ( wxMouseEvent &  event)
protectedinherited

Definition at line 77 of file layer_widget.cpp.

78 {
79  int row;
80  LAYER_NUM layer;
81 
82  wxWindow* eventSource = (wxWindow*) event.GetEventObject();
83 
84  // if mouse event is coming from the m_LayerScrolledWindow and not one
85  // of its children, we have to find the row manually based on y coord.
86  if( eventSource == m_LayerScrolledWindow )
87  {
88  int y = event.GetY();
89 
90  wxArrayInt heights = m_LayersFlexGridSizer->GetRowHeights();
91 
92  int height = 0;
93 
94  int rowCount = GetLayerRowCount();
95  for( row = 0; row<rowCount; ++row )
96  {
97  if( y < height + heights[row] )
98  break;
99 
100  height += heights[row];
101  }
102 
103  if( row >= rowCount )
104  row = rowCount - 1;
105 
106  layer = getDecodedId( getLayerComp( row, 0 )->GetId() );
107  }
108 
109  else
110  {
111  // all nested controls on a given row will have their ID encoded with
112  // encodeId(), and the corresponding decoding is getDecodedId()
113  int id = eventSource->GetId();
114  layer = getDecodedId( id );
115  row = findLayerRow( layer );
116  }
117 
118  if( OnLayerSelect( layer ) ) // if client allows this change.
119  SelectLayerRow( row );
120 
121  passOnFocus();
122 }
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:130
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:129
void SelectLayerRow(int aRow)
Function SelectLayerRow changes the row selection in the layer list to the given row.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
virtual bool OnLayerSelect(int aLayer)=0
Function OnLayerSelect is called to notify client code whenever the user selects a different layer.

References LAYER_WIDGET::findLayerRow(), LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), LAYER_WIDGET::m_LayerScrolledWindow, LAYER_WIDGET::m_LayersFlexGridSizer, LAYER_WIDGET::OnLayerSelect(), LAYER_WIDGET::passOnFocus(), and LAYER_WIDGET::SelectLayerRow().

Referenced by LAYER_WIDGET::insertLayerRow().

◆ onPopupSelection()

void PCB_LAYER_WIDGET::onPopupSelection ( wxCommandEvent &  event)
protected

Definition at line 216 of file pcb_layer_widget.cpp.

217 {
218  // Force the active layer to be visible
219  bool forceActiveLayer = false;
220 
221  // Reset the always show property
223 
224  // Make a distinction between the layers we want to enable and those we
225  // want to disable explictly. That way we can either or the current layerset
226  // or operate on all layers.
227  LSET layersToShow;
228  LSET layersToHide;
229 
230  switch( event.GetId() )
231  {
232  case ID_SHOW_NO_LAYERS:
233  layersToHide = LSET::AllLayersMask();
234  break;
235 
236  case ID_SHOW_ALL_LAYERS:
237  layersToShow = LSET::AllLayersMask();
238  break;
239 
241  layersToShow = LSET::AllCuMask();
242  break;
243 
247 
249  forceActiveLayer = true;
251 
253  layersToHide = LSET::AllCuMask();
254  break;
255 
257  layersToHide = LSET::AllNonCuMask();
258  break;
259 
261  layersToShow = LSET::AllNonCuMask();
262  break;
263 
265  // Include the edgecuts layer as well as the front assembly layers and hide the other layers
266  layersToShow = LSET::FrontAssembly().set( Edge_Cuts );
267  layersToHide = ~layersToShow;
269  break;
270 
271  case ID_SHOW_ONLY_FRONT:
272  // Include the edgecuts layer as well as the front layers and hide the other layers
273  layersToShow = LSET::FrontMask().set( Edge_Cuts );
274  layersToHide = ~layersToShow;
275  break;
276 
277  case ID_SHOW_ONLY_INNER:
278  // Include the edgecuts layer as well as the internal layers and hide the other layers
279  layersToShow = LSET::InternalCuMask().set( Edge_Cuts );
280  layersToHide = ~layersToShow;
281  break;
282 
283  case ID_SHOW_ONLY_BACK:
284  // Include the edgecuts layer as well as the back layers and hide the other layers
285  layersToShow = LSET::BackMask().set( Edge_Cuts );
286  layersToHide = ~layersToShow;
287  break;
288 
290  // Include the edgecuts layer as well as the back assembly layers and hide the other layers
291  layersToShow = LSET::BackAssembly().set( Edge_Cuts );
292  layersToHide = ~layersToShow;
294  break;
295  }
296 
297  int rowCount = GetLayerRowCount();
298 
299  for( int row = 0; row < rowCount; ++row )
300  {
301  wxCheckBox* cb = static_cast<wxCheckBox*>( getLayerComp( row, COLUMN_COLOR_LYR_CB ) );
302  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
303 
304  bool visible = cb->GetValue();
305 
306  if( layersToShow.Contains( layer ) )
307  visible = true;
308 
309  if( layersToHide.Contains( layer ) )
310  visible = false;
311 
312  // Force the active layer in the editor to be visible
313  if( forceActiveLayer && ( layer == myframe->GetActiveLayer() ) )
314  visible = true;
315 
316  cb->SetValue( visible );
317  OnLayerVisible( layer, visible, false );
318  }
319 
320  // Refresh the drawing canvas
321  myframe->GetCanvas()->Refresh();
322 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
#define KI_FALLTHROUGH
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.
static LSET AllNonCuMask()
Function AllNonCuMask returns a mask holding all layer minus CU layers.
Definition: lset.cpp:735
PCB_BASE_FRAME * myframe
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
static LSET FrontMask()
Function FrontMask returns a mask holding all technical layers and the external CU layer on front sid...
Definition: lset.cpp:811
virtual PCB_LAYER_ID GetActiveLayer() const
static LSET BackAssembly()
Function BackAssembly() returns a complete set of all bottom assembly layers, which is all B_SilkS an...
Definition: lset.cpp:659
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
static LSET InternalCuMask()
Function InternalCuMask() returns a complete set of internal copper layers, which is all Cu layers ex...
Definition: lset.cpp:672
static LSET FrontAssembly()
Function FrontAssembly() returns a complete set of all top assembly layers, which is all F_SilkS and ...
Definition: lset.cpp:646
static LSET AllLayersMask()
Definition: lset.cpp:749
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
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 m_alwaysShowActiveCopperLayer
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
void OnLayerVisible(int aLayer, bool isVisible, bool isFinal) override
Function OnLayerVisible is called to notify client code about a layer visibility change.
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:54
static LSET BackMask()
Function BackMask returns a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:818
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849

References LSET::AllCuMask(), LSET::AllLayersMask(), LSET::AllNonCuMask(), B_SilkS, LSET::BackAssembly(), LSET::BackMask(), COLUMN_COLOR_LYR_CB, LSET::Contains(), Edge_Cuts, F_SilkS, LSET::FrontAssembly(), LSET::FrontMask(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), ID_ALWAYS_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE, ID_HIDE_ALL_COPPER_LAYERS, ID_HIDE_ALL_COPPER_LAYERS_BUT_ACTIVE, ID_HIDE_ALL_NON_COPPER, ID_SHOW_ALL_COPPER_LAYERS, ID_SHOW_ALL_LAYERS, ID_SHOW_ALL_NON_COPPER, ID_SHOW_NO_LAYERS, ID_SHOW_ONLY_BACK, ID_SHOW_ONLY_BACK_ASSEMBLY, ID_SHOW_ONLY_FRONT, ID_SHOW_ONLY_FRONT_ASSEMBLY, ID_SHOW_ONLY_INNER, LSET::InternalCuMask(), KI_FALLTHROUGH, m_alwaysShowActiveCopperLayer, myframe, OnLayerVisible(), EDA_DRAW_PANEL_GAL::Refresh(), PCB_BASE_FRAME::SetActiveLayer(), and ToLAYER_ID().

Referenced by OnLayerSelected(), and PCB_LAYER_WIDGET().

◆ OnRenderCheckBox()

void LAYER_WIDGET::OnRenderCheckBox ( wxCommandEvent &  event)
protectedinherited

Definition at line 239 of file layer_widget.cpp.

240 {
241  wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
242  LAYER_NUM id = getDecodedId( eventSource->GetId() );
243  OnRenderEnable( id, eventSource->IsChecked() );
244  passOnFocus();
245 }
virtual void OnRenderEnable(int aId, bool isEnabled)=0
Function OnRenderEnable is called to notify client code whenever the user changes an rendering enable...
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.

References LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::OnRenderEnable(), and LAYER_WIDGET::passOnFocus().

Referenced by LAYER_WIDGET::insertRenderRow().

◆ OnRenderColorChange()

void PCB_LAYER_WIDGET::OnRenderColorChange ( int  aId,
COLOR4D  aColor 
)
overridevirtual

Function OnRenderColorChange is called to notify client code whenever the user changes a rendering color.

Parameters
aIdis the same id that was established in a Rendering row via the AddRenderRow() function.
aColoris the new color

Implements LAYER_WIDGET.

Definition at line 657 of file pcb_layer_widget.cpp.

658 {
659  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
660 
661  myframe->GetColorSettings()->SetColor( aId, aColor );
663 
664  KIGFX::VIEW* view = myframe->GetCanvas()->GetView();
665  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
666  view->UpdateLayerColor( aId );
667 
668  // plated-through-holes don't have their own color; they use the background color
669  if( aId == LAYER_PCB_BACKGROUND )
671 
674  myframe->GetCanvas()->Refresh();
675 }
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * myframe
Add new GAL layers here.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns 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()
Updates the color settings in the painter and GAL.
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:781
virtual void ReCreateHToolbar()=0
VIEW.
Definition: view.h:61
void SetColor(int aLayer, COLOR4D aColor)

References EDA_DRAW_PANEL_GAL::ForceRefresh(), GAL_LAYER_ID_END, GAL_LAYER_ID_START, PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetColorSettings(), PCB_DRAW_PANEL_GAL::GetView(), LAYER_PADS_PLATEDHOLES, LAYER_PCB_BACKGROUND, KIGFX::VIEW::MarkTargetDirty(), myframe, EDA_DRAW_FRAME::ReCreateHToolbar(), EDA_DRAW_PANEL_GAL::Refresh(), COLOR_SETTINGS::SetColor(), KIGFX::TARGET_NONCACHED, PCB_DRAW_PANEL_GAL::UpdateColors(), and KIGFX::VIEW::UpdateLayerColor().

◆ OnRenderEnable()

void PCB_LAYER_WIDGET::OnRenderEnable ( int  aId,
bool  isEnabled 
)
overridevirtual

Function OnRenderEnable is called to notify client code whenever the user changes an rendering enable in one of the rendering checkboxes.

Parameters
aIdis the same id that was established in a Rendering row via the AddRenderRow() function.
isEnabledis the state of the checkbox, true if checked.

Implements LAYER_WIDGET.

Definition at line 678 of file pcb_layer_widget.cpp.

679 {
680  BOARD* brd = myframe->GetBoard();
681  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
682 
683  // Grid is not set through the board visibility
684  if( aId == LAYER_GRID )
685  myframe->SetGridVisibility( isEnabled );
686  else
687  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
688 
689  if( aId == LAYER_RATSNEST )
690  {
691  // don't touch the layers. ratsnest is enabled on per-item basis.
693  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, true );
694 
696  {
698  opt.m_ShowGlobalRatsnest = isEnabled;
700  }
701  }
702  else if( aId != LAYER_GRID )
703  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, isEnabled );
704 
705  myframe->GetCanvas()->Refresh();
706  myframe->GetCanvas()->Refresh();
707 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * myframe
Add new GAL layers here.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
Auxiliary rendering target (noncached)
Definition: definitions.h:49
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:116
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:399
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns 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
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
BOARD * GetBoard() const
virtual void SetGridVisibility(bool aVisible)

References FRAME_PCB_EDITOR, GAL_LAYER_ID_END, GAL_LAYER_ID_START, PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), PCB_DRAW_PANEL_GAL::GetView(), EDA_BASE_FRAME::IsType(), LAYER_GRID, LAYER_RATSNEST, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, KIGFX::VIEW::MarkTargetDirty(), myframe, EDA_DRAW_PANEL_GAL::Refresh(), BOARD::SetElementVisibility(), EDA_DRAW_FRAME::SetGridVisibility(), KIGFX::VIEW::SetLayerVisible(), KIGFX::TARGET_NONCACHED, and KIGFX::PCB_VIEW::UpdateDisplayOptions().

◆ OnRenderSwatchChanged()

void LAYER_WIDGET::OnRenderSwatchChanged ( wxCommandEvent &  aEvent)
protectedinherited

Function OnRenderSwatchChanged Called when user has changed the swatch color of a render entry.

Definition at line 197 of file layer_widget.cpp.

198 {
199  auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
200 
201  COLOR4D newColor = eventSource->GetSwatchColor();
202 
203  LAYER_NUM id = getDecodedId( eventSource->GetId() );
204 
205  if( id == LAYER_PCB_BACKGROUND )
206  {
207  // Update all swatch backgrounds
208  int count = GetLayerRowCount();
209  int row;
210  int col = 1; // bitmap button is column 1 in layers tab
211 
212  for( row = 0; row < count; ++row )
213  {
214  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
215 
216  if( swatch )
217  swatch->SetSwatchBackground( newColor );
218  }
219 
220  count = GetRenderRowCount();
221  col = 0; // bitmap button is column 0 in render tab
222 
223  for( row = 0; row < count; ++row )
224  {
225  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getRenderComp( row, col ) );
226 
227  if( swatch )
228  swatch->SetSwatchBackground( newColor );
229  }
230  }
231 
232  // tell the client code.
233  OnRenderColorChange( id, newColor );
234 
235  passOnFocus();
236 }
virtual void OnRenderColorChange(int aId, COLOR4D aColor)=0
Function OnRenderColorChange is called to notify client code whenever the user changes a rendering co...
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
void SetSwatchBackground(KIGFX::COLOR4D aBackground)
Set the swatch background color.
wxWindow * getRenderComp(int aRow, int aColumn) const
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
int GetRenderRowCount() const
Function GetRenderRowCount returns the number of rows in the render tab.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), LAYER_WIDGET::getRenderComp(), LAYER_WIDGET::GetRenderRowCount(), LAYER_PCB_BACKGROUND, LAYER_WIDGET::OnRenderColorChange(), LAYER_WIDGET::passOnFocus(), and COLOR_SWATCH::SetSwatchBackground().

Referenced by LAYER_WIDGET::insertRenderRow().

◆ OnRightDownLayer()

void LAYER_WIDGET::OnRightDownLayer ( wxMouseEvent &  event,
COLOR_SWATCH aColorSwatch,
const wxString &  aLayerName 
)
protectedinherited

Function OnRightDownLayer Called when user right-clicks a layer.

Definition at line 125 of file layer_widget.cpp.

126 {
127  wxMenu menu;
128 
130  _( "Change Layer Color for " ) + aLayerName,
132  menu.AppendSeparator();
133 
134  OnLayerRightClick( menu );
135 
136  menu.Bind( wxEVT_COMMAND_MENU_SELECTED, [aColorSwatch]( wxCommandEvent& event ) {
137  if ( event.GetId() == ID_CHANGE_LAYER_COLOR ) {
138  aColorSwatch->GetNewSwatchColor();
139  } else {
140  event.Skip();
141  }
142  } );
143 
144  PopupMenu( &menu );
145  passOnFocus();
146 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:232
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
const BITMAP_OPAQUE setcolor_copper_xpm[1]
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
#define _(s)
Definition: 3d_actions.cpp:33
virtual void OnLayerRightClick(wxMenu &aMenu)=0
Function OnLayerRightClick is called to notify client code about a layer being right-clicked.
void GetNewSwatchColor()
Prompt for a new colour, using the colour picker dialog.

References _, AddMenuItem(), COLOR_SWATCH::GetNewSwatchColor(), LAYER_WIDGET::ID_CHANGE_LAYER_COLOR, KiBitmap(), LAYER_WIDGET::OnLayerRightClick(), LAYER_WIDGET::passOnFocus(), and setcolor_copper_xpm.

Referenced by LAYER_WIDGET::insertLayerRow().

◆ onRightDownLayers()

void PCB_LAYER_WIDGET::onRightDownLayers ( wxMouseEvent &  event)
protected

Function OnRightDownLayers puts up a popup menu for the layer panel.

Definition at line 205 of file pcb_layer_widget.cpp.

206 {
207  wxMenu menu;
208 
209  AddRightClickMenuItems( menu );
210  PopupMenu( &menu );
211 
212  passOnFocus();
213 }
void AddRightClickMenuItems(wxMenu &menu)
Function addRightClickMenuItems add menu items to a menu that should be shown when right-clicking the...
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.

References AddRightClickMenuItems(), and LAYER_WIDGET::passOnFocus().

Referenced by PCB_LAYER_WIDGET().

◆ OnRightDownRender()

void LAYER_WIDGET::OnRightDownRender ( wxMouseEvent &  aEvent,
COLOR_SWATCH aColorSwatch,
const wxString &  aRenderName 
)
protectedinherited

Function OnRightDownRender Called when user right-clicks a render option.

Definition at line 175 of file layer_widget.cpp.

176 {
177  wxMenu menu;
178 
180  _( "Change Render Color for " ) + aRenderName,
182 
183  menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
184  [aColorSwatch]( wxCommandEvent& event )
185  {
186  if( event.GetId() == ID_CHANGE_RENDER_COLOR )
187  aColorSwatch->GetNewSwatchColor();
188  else
189  event.Skip();
190  } );
191 
192  PopupMenu( &menu );
193  passOnFocus();
194 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:232
const BITMAP_OPAQUE setcolor_board_body_xpm[1]
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
#define _(s)
Definition: 3d_actions.cpp:33
void GetNewSwatchColor()
Prompt for a new colour, using the colour picker dialog.

References _, AddMenuItem(), COLOR_SWATCH::GetNewSwatchColor(), LAYER_WIDGET::ID_CHANGE_RENDER_COLOR, KiBitmap(), LAYER_WIDGET::passOnFocus(), and setcolor_board_body_xpm.

Referenced by LAYER_WIDGET::insertRenderRow().

◆ OnTabChange()

void LAYER_WIDGET::OnTabChange ( wxNotebookEvent &  event)
protectedinherited

Definition at line 248 of file layer_widget.cpp.

249 {
250 // wxFocusEvent event( wxEVT_SET_FOCUS );
251 // m_FocusOwner->AddPendingEvent( event );
252 
253  passOnFocus(); // does not work in this context, probably because we have receive control here too early.
254 }
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.

References LAYER_WIDGET::passOnFocus().

Referenced by LAYER_WIDGET::LAYER_WIDGET().

◆ passOnFocus()

◆ ReFill()

void PCB_LAYER_WIDGET::ReFill ( )

Definition at line 472 of file pcb_layer_widget.cpp.

473 {
474  BOARD* brd = myframe->GetBoard();
475  LSET enabled = brd->GetEnabledLayers();
476 
477  ClearLayerRows();
478 
479  wxString dsc;
480 
481  // show all coppers first, with front on top, back on bottom, then technical layers
482  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
483  {
484  PCB_LAYER_ID layer = *cu_stack;
485 
486  switch( layer )
487  {
488  case F_Cu:
489  dsc = _( "Front copper layer" );
490  break;
491 
492  case B_Cu:
493  dsc = _( "Back copper layer" );
494  break;
495 
496  default:
497  dsc = _( "Inner copper layer" );
498  break;
499  }
500 
501  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
502  myframe->GetColorSettings()->GetColor( layer ), dsc, true, true,
503  myframe->GetColorSettings()->GetDefaultColor( layer ) ) );
504 
506  {
507  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
508  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
509  }
510  }
511 
512  UpdateLayouts();
513 
514 
515  // technical layers are shown in this order:
516  // Because they are static, wxGetTranslation must be explicitly
517  // called for tooltips.
518  static const struct {
519  PCB_LAYER_ID layerId;
520  wxString tooltip;
521  } non_cu_seq[] = {
522  { F_Adhes, _( "Adhesive on board's front" ) },
523  { B_Adhes, _( "Adhesive on board's back" ) },
524  { F_Paste, _( "Solder paste on board's front" ) },
525  { B_Paste, _( "Solder paste on board's back" ) },
526  { F_SilkS, _( "Silkscreen on board's front" ) },
527  { B_SilkS, _( "Silkscreen on board's back" ) },
528  { F_Mask, _( "Solder mask on board's front" ) },
529  { B_Mask, _( "Solder mask on board's back" ) },
530  { Dwgs_User, _( "Explanatory drawings" ) },
531  { Cmts_User, _( "Explanatory comments" ) },
532  { Eco1_User, _( "User defined meaning" ) },
533  { Eco2_User, _( "User defined meaning" ) },
534  { Edge_Cuts, _( "Board's perimeter definition" ) },
535  { Margin, _( "Board's edge setback outline" ) },
536  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
537  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
538  { F_Fab, _( "Footprint assembly on board's front" ) },
539  { B_Fab, _( "Footprint assembly on board's back" ) }
540  };
541 
542  for( unsigned i=0; i<arrayDim( non_cu_seq ); ++i )
543  {
544  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
545 
546  if( !enabled[layer] )
547  continue;
548 
549  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
550  myframe->GetColorSettings()->GetColor( layer ),
551  wxGetTranslation( non_cu_seq[i].tooltip ), true, true,
552  myframe->GetColorSettings()->GetDefaultColor( layer ) ) );
553 
555  {
556  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
557  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
558  }
559  }
560 }
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:55
LSEQ CuStack() const
Function CuStack returns a sequence of copper layers in starting from the front/top and extending to ...
Definition: lset.cpp:155
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer.
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:87
static LSET ForbiddenFootprintLayers()
Function ForbiddenFootprintLayers Layers which are not allowed within footprint definitions.
Definition: lset.cpp:825
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
void UpdateLayouts()
PCB_BASE_FRAME * myframe
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
void ClearLayerRows()
Function ClearLayerRows empties out the layer rows.
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
#define COLUMN_COLORBM
Definition: layer_widget.h:53
void AppendLayerRow(const ROW &aRow)
Function AppendLayerRow appends a new row in the layer portion of the widget.
COLOR4D GetDefaultColor(int aLayer)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
COLOR4D GetColor(int aLayer) const
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
#define _(s)
Definition: 3d_actions.cpp:33
BOARD * GetBoard() const

References _, LAYER_WIDGET::AppendLayerRow(), arrayDim(), B_Adhes, B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, LAYER_WIDGET::ClearLayerRows(), Cmts_User, COLUMN_COLOR_LYRNAME, COLUMN_COLORBM, 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(), COLOR_SETTINGS::GetDefaultColor(), BOARD::GetEnabledLayers(), LAYER_WIDGET::getLayerComp(), BOARD::GetLayerName(), LAYER_WIDGET::GetLayerRowCount(), m_fp_editor_mode, Margin, myframe, and LAYER_WIDGET::UpdateLayouts().

Referenced by FOOTPRINT_EDIT_FRAME::ReFillLayerWidget().

◆ ReFillRender()

void PCB_LAYER_WIDGET::ReFillRender ( )

Function ReFillRender rebuilds Render for instance after the config is read.

Definition at line 332 of file pcb_layer_widget.cpp.

333 {
334  BOARD* board = myframe->GetBoard();
335 
336  ClearRenderRows();
337 
338  // Add "Items" tab rows to LAYER_WIDGET, after setting color and checkbox state.
339  // Because s_render_rows is created static, we must explicitly call
340  // wxGetTranslation for texts which are internationalized (tool tips
341  // and item names)
342  for( unsigned row=0; row<arrayDim(s_render_rows); ++row )
343  {
344  LAYER_WIDGET::ROW renderRow = s_render_rows[row];
345 
346  if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
347  continue;
348 
349  if( !renderRow.spacer )
350  {
351  renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
352  renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
353 
354  if( renderRow.color != COLOR4D::UNSPECIFIED ) // does this row show a color?
355  {
356  // this window frame must have an established BOARD, i.e. after SetBoard()
357  renderRow.color = myframe->GetColorSettings()->GetColor(
358  static_cast<GAL_LAYER_ID>( renderRow.id ) );
360  static_cast<GAL_LAYER_ID>( renderRow.id ) );
361  }
362 
363  if( renderRow.id == LAYER_RATSNEST )
365  else if( renderRow.id == LAYER_GRID )
366  renderRow.state = myframe->IsGridVisible();
367  else
368  renderRow.state = board->IsElementVisible(
369  static_cast<GAL_LAYER_ID>( renderRow.id ) );
370  }
371 
372  AppendRenderRow( renderRow );
373  }
374 
375  UpdateLayouts();
376 }
COLOR4D defaultColor
The default color for the row.
Definition: layer_widget.h:96
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:87
bool spacer
if true, this row is a spacer
Definition: layer_widget.h:95
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
void UpdateLayouts()
PCB_BASE_FRAME * myframe
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
void ClearRenderRows()
Function ClearRenderRows empties out the render rows.
bool state
initial wxCheckBox state
Definition: layer_widget.h:92
wxString tooltip
if not empty, use this tooltip on row
Definition: layer_widget.h:93
void AppendRenderRow(const ROW &aRow)
Function AppendRenderRow appends a new row in the render portion of the widget.
COLOR4D color
COLOR4D::UNSPECIFIED if none.
Definition: layer_widget.h:91
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
bool IsGridVisible() const
COLOR4D GetDefaultColor(int aLayer)
static const LAYER_WIDGET::ROW s_render_rows[]
This is a read only template that is copied and modified before adding to LAYER_WIDGET.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
COLOR4D GetColor(int aLayer) const
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
wxString rowName
the prompt or layername
Definition: layer_widget.h:89
BOARD * GetBoard() const
int id
either a layer or "visible element" id
Definition: layer_widget.h:90

References LAYER_WIDGET::AppendRenderRow(), arrayDim(), LAYER_WIDGET::ClearRenderRows(), LAYER_WIDGET::ROW::color, LAYER_WIDGET::ROW::defaultColor, PCB_BASE_FRAME::GetBoard(), COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), COLOR_SETTINGS::GetDefaultColor(), PCB_BASE_FRAME::GetDisplayOptions(), LAYER_WIDGET::ROW::id, isAllowedInFpMode(), BOARD::IsElementVisible(), EDA_DRAW_FRAME::IsGridVisible(), LAYER_GRID, LAYER_RATSNEST, m_fp_editor_mode, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, myframe, LAYER_WIDGET::ROW::rowName, s_render_rows, LAYER_WIDGET::ROW::spacer, LAYER_WIDGET::ROW::state, LAYER_WIDGET::ROW::tooltip, and LAYER_WIDGET::UpdateLayouts().

Referenced by FOOTPRINT_EDIT_FRAME::UpdateUserInterface().

◆ SelectLayer()

void LAYER_WIDGET::SelectLayer ( LAYER_NUM  aLayer)
inherited

Function SelectLayer changes the row selection in the layer list to aLayer provided.

Definition at line 699 of file layer_widget.cpp.

700 {
701  int row = findLayerRow( aLayer );
702  SelectLayerRow( row );
703 }
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
void SelectLayerRow(int aRow)
Function SelectLayerRow changes the row selection in the layer list to the given row.

References LAYER_WIDGET::findLayerRow(), and LAYER_WIDGET::SelectLayerRow().

Referenced by GERBVIEW_FRAME::SetActiveLayer(), GERBVIEW_FRAME::syncLayerWidget(), and FOOTPRINT_EDIT_FRAME::UpdateUserInterface().

◆ SelectLayerRow()

void LAYER_WIDGET::SelectLayerRow ( int  aRow)
inherited

Function SelectLayerRow changes the row selection in the layer list to the given row.

Definition at line 663 of file layer_widget.cpp.

664 {
665  // enable the layer tab at index 0
666  m_notebook->SetSelection( 0 );
667 
668  INDICATOR_ICON* oldIndicator = (INDICATOR_ICON*) getLayerComp( m_CurrentRow, 0 );
669 
670  if( oldIndicator )
671  {
673  oldIndicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DIMMED );
674  else
676  }
677 
678  INDICATOR_ICON* newIndicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
679 
680  if( newIndicator )
681  {
683 
684  // Make sure the desired layer row is visible.
685  // It seems that as of 2.8.2, setting the focus does this.
686  // I don't expect the scrolling to be needed at all because
687  // the minimum window size may end up being established so that the
688  // scroll bars will not be visible.
689  getLayerComp( aRow, 1 )->SetFocus();
690  }
691 
692  m_CurrentRow = aRow;
693 
694  // give the focus back to the app.
695  passOnFocus();
696 }
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
wxAuiNotebook * m_notebook
Definition: layer_widget.h:127
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:136
#define ON
virtual bool useAlternateBitmap(int aRow)
Virtual Function useAlternateBitmap.
Definition: layer_widget.h:149
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
representing a row indicator icon for use in places like the layer widget
#define OFF
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.

References LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::m_CurrentRow, LAYER_WIDGET::m_notebook, OFF, ON, LAYER_WIDGET::passOnFocus(), INDICATOR_ICON::SetIndicatorState(), and LAYER_WIDGET::useAlternateBitmap().

Referenced by LAYER_WIDGET::OnLeftDownLayers(), and LAYER_WIDGET::SelectLayer().

◆ setLayerCheckbox()

void LAYER_WIDGET::setLayerCheckbox ( LAYER_NUM  aLayer,
bool  isVisible 
)
protectedinherited

Definition at line 723 of file layer_widget.cpp.

724 {
725  int row = findLayerRow( aLayer );
726  if( row >= 0 )
727  {
728  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
729  wxASSERT( cb );
730  cb->SetValue( isVisible ); // does not fire an event
731  }
732 }
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:54

References COLUMN_COLOR_LYR_CB, LAYER_WIDGET::findLayerRow(), and LAYER_WIDGET::getLayerComp().

Referenced by LAYER_WIDGET::SetLayerVisible(), and SyncLayerVisibilities().

◆ SetLayerColor()

void LAYER_WIDGET::SetLayerColor ( LAYER_NUM  aLayer,
COLOR4D  aColor 
)
inherited

Function SetLayerColor changes the color of aLayer.

Definition at line 748 of file layer_widget.cpp.

749 {
750  int row = findLayerRow( aLayer );
751  if( row >= 0 )
752  {
753  int col = 1; // bitmap button is column 1
754  auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
755  wxASSERT( swatch );
756 
757  swatch->SetSwatchColor( aColor, false );
758  }
759 }
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...

References LAYER_WIDGET::findLayerRow(), and LAYER_WIDGET::getLayerComp().

◆ SetLayersManagerTabsText()

void PCB_LAYER_WIDGET::SetLayersManagerTabsText ( )

Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language or to set labels to a non default value.

Definition at line 325 of file pcb_layer_widget.cpp.

326 {
327  m_notebook->SetPageText( 0, _( "Layers" ) );
328  m_notebook->SetPageText( 1, _( "Items" ) );
329 }
wxAuiNotebook * m_notebook
Definition: layer_widget.h:127
#define _(s)
Definition: 3d_actions.cpp:33

References _, and LAYER_WIDGET::m_notebook.

Referenced by PCB_LAYER_WIDGET(), and FOOTPRINT_EDIT_FRAME::ShowChangedLanguage().

◆ SetLayerVisible()

void LAYER_WIDGET::SetLayerVisible ( LAYER_NUM  aLayer,
bool  isVisible 
)
inherited

Function SetLayerVisible sets aLayer visible or not.

This does not invoke OnLayerVisible().

Definition at line 716 of file layer_widget.cpp.

717 {
718  setLayerCheckbox( aLayer, isVisible );
719  OnLayerVisible( aLayer, isVisible );
720 }
virtual void OnLayerVisible(LAYER_NUM aLayer, bool isVisible, bool isFinal=true)=0
Function OnLayerVisible is called to notify client code about a layer visibility change.
void setLayerCheckbox(LAYER_NUM aLayer, bool isVisible)

References LAYER_WIDGET::OnLayerVisible(), and LAYER_WIDGET::setLayerCheckbox().

Referenced by DIALOG_DRC::OnDRCItemSelected(), and ROUTER_TOOL::prepareInteractive().

◆ SetRenderState()

void LAYER_WIDGET::SetRenderState ( int  aId,
bool  isSet 
)
inherited

Function SetRenderState sets the state of the checkbox associated with aId within the Render tab group of the widget.

Does not fire an event, i.e. does not invoke OnRenderEnable().

Parameters
aIdis the same unique id used when adding a ROW to the Render tab.
isSet= the new checkbox state

Definition at line 778 of file layer_widget.cpp.

779 {
780  int row = findRenderRow( aId );
781 
782  if( row >= 0 )
783  {
784  int col = 1; // checkbox is column 1
785  wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
786  wxASSERT( cb );
787  cb->SetValue( isSet ); // does not fire an event
788  }
789 }
int findRenderRow(int aId) const
wxWindow * getRenderComp(int aRow, int aColumn) const

References LAYER_WIDGET::findRenderRow(), and LAYER_WIDGET::getRenderComp().

Referenced by GERBVIEW_FRAME::SetElementVisibility(), FOOTPRINT_EDIT_FRAME::SetElementVisibility(), PCB_BASE_EDIT_FRAME::SetGridVisibility(), and GERBVIEW_FRAME::SetGridVisibility().

◆ SyncLayerAlphaIndicators()

void PCB_LAYER_WIDGET::SyncLayerAlphaIndicators ( )

Function SyncLayerAlphaIndicators updates each "Layer"s alpha indicator to show if the board is currently being rendered with more transparency or less.

Definition at line 401 of file pcb_layer_widget.cpp.

402 {
403  int count = GetLayerRowCount();
405  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() );
406  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
407 
408  for( int row = 0; row < count; ++row )
409  {
410  // this utilizes more implementation knowledge than ideal, eventually
411  // add member ROW getRow() or similar to base LAYER_WIDGET.
412 
413  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
414  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
415  KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId );
416 
417  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) );
418  KIGFX::COLOR4D layerColor = swatch->GetSwatchColor();
419 
420  INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) );
421 
422  if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON )
423  {
424  if( screenColor.a < layerColor.a )
425  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
426  else
427  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
428  }
429  else
431  }
432 }
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:284
#define ALPHA_EPSILON
KIGFX::COLOR4D GetSwatchColor() const
#define COLUMN_ALPHA_INDICATOR
Definition: layer_widget.h:56
PCB_BASE_FRAME * myframe
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:274
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:63
TOOL_MANAGER.
Definition: tool_manager.h:51
PCB_LAYER_ID
A quick note on layer IDs:
representing a row indicator icon for use in places like the layer widget
double a
Alpha component.
Definition: color4d.h:369
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
#define COLUMN_COLORBM
Definition: layer_widget.h:53
virtual PCB_RENDER_SETTINGS * GetSettings() override
Definition: pcb_painter.h:286
#define OFF
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:74
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::COLOR4D::a, ALPHA_EPSILON, COLUMN_ALPHA_INDICATOR, COLUMN_COLORBM, COLUMN_ICON_ACTIVE, LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), KIGFX::VIEW::GetPainter(), KIGFX::PCB_PAINTER::GetSettings(), COLOR_SWATCH::GetSwatchColor(), TOOLS_HOLDER::GetToolManager(), TOOL_MANAGER::GetView(), myframe, OFF, INDICATOR_ICON::SetIndicatorState(), and ToLAYER_ID().

Referenced by FOOTPRINT_EDIT_FRAME::OnUpdateLayerAlpha().

◆ SyncLayerColors()

void PCB_LAYER_WIDGET::SyncLayerColors ( )

Updates the color for each layer and item from the active color theme.

Definition at line 435 of file pcb_layer_widget.cpp.

436 {
438 
440 
441  int count = GetLayerRowCount();
442  int row;
443  int col = 1; // bitmap button is column 1 in layers tab
444 
445  for( row = 0; row < count; ++row )
446  {
447  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
448 
449  if( swatch )
450  {
451  swatch->SetSwatchBackground( bg );
452  swatch->SetSwatchColor( cs->GetColor( getDecodedId( swatch->GetId() ) ), false );
453  }
454  }
455 
456  count = GetRenderRowCount();
457  col = 0; // bitmap button is column 0 in render tab
458 
459  for( row = 0; row < count; ++row )
460  {
461  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getRenderComp( row, col ) );
462 
463  if( swatch )
464  {
465  swatch->SetSwatchBackground( bg );
466  swatch->SetSwatchColor( cs->GetColor( getDecodedId( swatch->GetId() ) ), false );
467  }
468  }
469 }
void SetSwatchColor(KIGFX::COLOR4D aColor, bool sendEvent)
Set the current swatch color directly.
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
PCB_BASE_FRAME * myframe
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
void SetSwatchBackground(KIGFX::COLOR4D aBackground)
Set the swatch background color.
wxWindow * getRenderComp(int aRow, int aColumn) const
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
COLOR4D GetColor(int aLayer) const
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
Color settings are a bit different than most of the settings objects in that there can be more than o...
int GetRenderRowCount() const
Function GetRenderRowCount returns the number of rows in the render tab.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References COLOR_SETTINGS::GetColor(), PCB_BASE_FRAME::GetColorSettings(), LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), LAYER_WIDGET::getRenderComp(), LAYER_WIDGET::GetRenderRowCount(), LAYER_PCB_BACKGROUND, myframe, COLOR_SWATCH::SetSwatchBackground(), and COLOR_SWATCH::SetSwatchColor().

Referenced by PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow().

◆ SyncLayerVisibilities()

void PCB_LAYER_WIDGET::SyncLayerVisibilities ( )

Function SyncLayerVisibilities updates each "Layer" checkbox in this layer widget according to each layer's current visibility determined by IsLayerVisible(), and is helpful immediately after loading a BOARD which may have state information in it.

Definition at line 379 of file pcb_layer_widget.cpp.

380 {
381  BOARD* board = myframe->GetBoard();
382  int count = GetLayerRowCount();
383 
384  for( int row=0; row<count; ++row )
385  {
386  // this utilizes more implementation knowledge than ideal, eventually
387  // add member ROW getRow() or similar to base LAYER_WIDGET.
388 
389  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
390 
391  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
392 
393  // this does not fire a UI event
394  setLayerCheckbox( layerId, board->IsLayerVisible( layerId ) );
395  }
396 }
PCB_BASE_FRAME * myframe
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
PCB_LAYER_ID
A quick note on layer IDs:
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
void setLayerCheckbox(LAYER_NUM aLayer, bool isVisible)
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
BOARD * GetBoard() const
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849

References COLUMN_ICON_ACTIVE, PCB_BASE_FRAME::GetBoard(), LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), BOARD::IsLayerVisible(), myframe, LAYER_WIDGET::setLayerCheckbox(), and ToLAYER_ID().

Referenced by FOOTPRINT_EDIT_FRAME::UpdateUserInterface().

◆ UpdateLayerIcons()

void LAYER_WIDGET::UpdateLayerIcons ( )
inherited

Function UpdateLayerIcons Update all layer manager icons (layers only) Useful when loading a file or clearing a layer because they change, and the indicator arrow icon needs to be updated.

Definition at line 818 of file layer_widget.cpp.

819 {
820  int rowCount = GetLayerRowCount();
821 
822  for( int row = 0; row < rowCount ; row++ )
823  {
825 
826  if( indicator )
827  {
829 
830  if( row == m_CurrentRow )
832  else if( useAlternateBitmap( row ) )
833  state = ROW_ICON_PROVIDER::STATE::DIMMED;
834  else
836 
837  indicator->SetIndicatorState( state );
838  }
839  }
840 }
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:136
#define ON
virtual bool useAlternateBitmap(int aRow)
Virtual Function useAlternateBitmap.
Definition: layer_widget.h:149
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
representing a row indicator icon for use in places like the layer widget
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
#define OFF
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
STATE
State constants to select the right icons

References COLUMN_ICON_ACTIVE, LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), LAYER_WIDGET::m_CurrentRow, OFF, ON, INDICATOR_ICON::SetIndicatorState(), and LAYER_WIDGET::useAlternateBitmap().

Referenced by GERBVIEW_FRAME::LoadExcellonFiles(), GERBVIEW_FRAME::loadListOfGerberAndDrillFiles(), and GERBVIEW_FRAME::LoadZipArchiveFile().

◆ updateLayerRow()

void LAYER_WIDGET::updateLayerRow ( int  aRow,
const wxString &  aName 
)
protectedinherited

Definition at line 384 of file layer_widget.cpp.

385 {
386  wxStaticText* label = dynamic_cast<wxStaticText*>( getLayerComp( aRow, COLUMN_COLOR_LYRNAME ) );
387 
388  if( label )
389  label->SetLabel( aName );
390 
391  INDICATOR_ICON* indicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
392 
393  if( indicator )
394  {
395  if( aRow == m_CurrentRow )
397  if( useAlternateBitmap( aRow ) )
398  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DIMMED );
399  else
401  }
402 }
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:55
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:136
#define ON
virtual bool useAlternateBitmap(int aRow)
Virtual Function useAlternateBitmap.
Definition: layer_widget.h:149
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
representing a row indicator icon for use in places like the layer widget
#define OFF

References COLUMN_COLOR_LYRNAME, LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::m_CurrentRow, OFF, ON, INDICATOR_ICON::SetIndicatorState(), and LAYER_WIDGET::useAlternateBitmap().

Referenced by GERBER_LAYER_WIDGET::ReFill().

◆ UpdateLayouts()

void LAYER_WIDGET::UpdateLayouts ( )
inherited

Definition at line 808 of file layer_widget.cpp.

809 {
810  m_LayersFlexGridSizer->Layout();
811  m_RenderFlexGridSizer->Layout();
812  m_LayerPanel->Layout();
813  m_RenderingPanel->Layout();
814  FitInside();
815 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:130
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:133
wxPanel * m_RenderingPanel
Definition: layer_widget.h:131
wxPanel * m_LayerPanel
Definition: layer_widget.h:128

References LAYER_WIDGET::m_LayerPanel, LAYER_WIDGET::m_LayersFlexGridSizer, LAYER_WIDGET::m_RenderFlexGridSizer, and LAYER_WIDGET::m_RenderingPanel.

Referenced by LAYER_WIDGET::AppendLayerRows(), LAYER_WIDGET::AppendRenderRows(), ReFill(), GERBER_LAYER_WIDGET::ReFill(), and ReFillRender().

◆ useAlternateBitmap()

virtual bool LAYER_WIDGET::useAlternateBitmap ( int  aRow)
inlineprotectedvirtualinherited

Virtual Function useAlternateBitmap.

Returns
true if bitmaps shown in Render layer list are alternate bitmaps, or false if they are "normal" bitmaps This is a virtual function because Pcbnew uses normal bitmaps but GerbView uses both bitmaps (alternate bitmaps to show layers in use, normal fo others)

Reimplemented in GERBER_LAYER_WIDGET.

Definition at line 149 of file layer_widget.h.

149 { return false; }

Referenced by LAYER_WIDGET::SelectLayerRow(), LAYER_WIDGET::UpdateLayerIcons(), and LAYER_WIDGET::updateLayerRow().

Member Data Documentation

◆ EVT_LAYER_COLOR_CHANGE

const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType()
staticinherited

Definition at line 123 of file layer_widget.h.

Referenced by LAYER_WIDGET::OnLayerSwatchChanged().

◆ m_alwaysShowActiveCopperLayer

bool PCB_LAYER_WIDGET::m_alwaysShowActiveCopperLayer
protected

◆ m_CurrentRow

int LAYER_WIDGET::m_CurrentRow
protectedinherited

◆ m_FocusOwner

wxWindow* LAYER_WIDGET::m_FocusOwner
protectedinherited

Definition at line 135 of file layer_widget.h.

Referenced by LAYER_WIDGET::LAYER_WIDGET(), and LAYER_WIDGET::passOnFocus().

◆ m_fp_editor_mode

bool PCB_LAYER_WIDGET::m_fp_editor_mode
protected

Definition at line 125 of file pcb_layer_widget.h.

Referenced by OnLayerSelect(), PCB_LAYER_WIDGET(), ReFill(), and ReFillRender().

◆ m_IconProvider

ROW_ICON_PROVIDER* LAYER_WIDGET::m_IconProvider
protectedinherited

◆ m_LayerPanel

wxPanel* LAYER_WIDGET::m_LayerPanel
protectedinherited

◆ m_LayerScrolledWindow

wxScrolledWindow* LAYER_WIDGET::m_LayerScrolledWindow
protectedinherited

◆ m_LayersFlexGridSizer

◆ m_notebook

wxAuiNotebook* LAYER_WIDGET::m_notebook
protectedinherited

◆ m_PointSize

int LAYER_WIDGET::m_PointSize
protectedinherited

◆ m_RenderFlexGridSizer

◆ m_RenderingPanel

wxPanel* LAYER_WIDGET::m_RenderingPanel
protectedinherited

◆ m_RenderScrolledWindow

wxScrolledWindow* LAYER_WIDGET::m_RenderScrolledWindow
protectedinherited

Definition at line 132 of file layer_widget.h.

Referenced by LAYER_WIDGET::insertRenderRow(), and LAYER_WIDGET::LAYER_WIDGET().

◆ myframe

◆ s_render_rows

const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows
staticprotected

This is a read only template that is copied and modified before adding to LAYER_WIDGET.

Definition at line 122 of file pcb_layer_widget.h.

Referenced by ReFillRender().


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