KiCad PCB EDA Suite
PCB_LAYER_WIDGET Class Reference

Class 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, int aPointSize=10, bool aFpEditorMode=false)
 Constructor. More...
 
void ReFill ()
 
void ReFillRender ()
 Function ReFillRender rebuilds Render for instance after the config is read. More...
 
void SyncRenderStates ()
 Function SyncRenderStates updates the checkboxes (checked or not) to be consistent with the current state of the visibility of the visible rendering elements. 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 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_SHOW_NO_COPPER_LAYERS, ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
  ID_SHOW_NO_LAYERS, ID_SHOW_ALL_LAYERS, ID_SHOW_ALL_FRONT, ID_SHOW_ALL_BACK,
  ID_HIDE_ALL_NON_COPPER, ID_SHOW_ALL_NON_COPPER, ID_LAST_VALUE
}
 

Protected Member Functions

virtual bool AreArbitraryColorsAllowed () override
 Subclasses can override this to provide logic for allowing arbitrary color selection via wxColourPicker instead of DisplayColorFrame. More...
 
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 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

Class 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

Enumerator
ID_SHOW_ALL_COPPER_LAYERS 
ID_SHOW_NO_COPPER_LAYERS 
ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE 
ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE 
ID_SHOW_NO_LAYERS 
ID_SHOW_ALL_LAYERS 
ID_SHOW_ALL_FRONT 
ID_SHOW_ALL_BACK 
ID_HIDE_ALL_NON_COPPER 
ID_SHOW_ALL_NON_COPPER 
ID_LAST_VALUE 

Definition at line 136 of file pcb_layer_widget.h.

Constructor & Destructor Documentation

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

Constructor.

Parameters
aParentis the parent window
aFocusOwneris the window that should be sent the focus after
aPointSizeis the font point size to use within the widget. This effectively sets the overall size of the widget via the row height and bitmap button sizes.
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 108 of file pcb_layer_widget.cpp.

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

109  :
110  LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
111  myframe( aParent )
112 {
114  m_fp_editor_mode = aFpEditorMode;
115  ReFillRender();
116 
117  // Update default tabs labels
119 
120  //-----<Popup menu>-------------------------------------------------
121  // handle the popup menu over the layer window.
122  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
123  wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
124 
125  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
126  // and not m_LayerScrolledWindow->Connect()
127 
129  wxEVT_COMMAND_MENU_SELECTED,
130  wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
131 }
PCB_BASE_FRAME * myframe
void SetLayersManagerTabsText()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
void ReFillRender()
Function ReFillRender rebuilds Render for instance after the config is read.
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:123
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
bool m_alwaysShowActiveCopperLayer
void onPopupSelection(wxCommandEvent &event)
LAYER_WIDGET(wxWindow *aParent, wxWindow *aFocusOwner, int aPointSize=-1, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Constructor.

Member Function Documentation

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 166 of file pcb_layer_widget.cpp.

References AddMenuItem(), ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, ID_HIDE_ALL_NON_COPPER, ID_SHOW_ALL_BACK, ID_SHOW_ALL_COPPER_LAYERS, ID_SHOW_ALL_FRONT, ID_SHOW_ALL_LAYERS, ID_SHOW_ALL_NON_COPPER, ID_SHOW_NO_COPPER_LAYERS, ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, ID_SHOW_NO_LAYERS, and KiBitmap().

Referenced by OnLayerRightClick(), and onRightDownLayers().

167 {
168  // menu text is capitalized:
169  // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
171  _( "Show All Copper Layers" ),
172  KiBitmap( select_layer_pair_xpm ) );
174  _( "Hide All Copper Layers But Active" ),
175  KiBitmap( select_w_layer_xpm ) );
177  _( "Always Hide All Copper Layers But Active" ),
178  KiBitmap( select_w_layer_xpm ) );
180  _( "Hide All Copper Layers" ),
181  KiBitmap( show_no_copper_layers_xpm ) );
182 
183  menu.AppendSeparator();
184 
186  _( "Show All Non Copper Layers" ),
187  KiBitmap( select_w_layer_xpm ) );
189  _( "Hide All Non Copper Layers" ),
190  KiBitmap( show_no_copper_layers_xpm ) );
191 
192  menu.AppendSeparator();
193 
194  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
195  KiBitmap( show_no_layers_xpm ) );
196  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
197  KiBitmap( show_all_layers_xpm ) );
198 
199  menu.AppendSeparator();
200 
201  AddMenuItem( &menu, ID_SHOW_ALL_FRONT, _( "Show All Front Layers" ),
202  KiBitmap( show_no_layers_xpm ) );
203 
204  AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
205  KiBitmap( show_all_layers_xpm ) );
206 }
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:174
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
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 610 of file layer_widget.cpp.

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

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

611 {
612  int nextRow = GetLayerRowCount();
613  insertLayerRow( nextRow, aRow );
614  UpdateLayouts();
615 }
void UpdateLayouts()
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.
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 305 of file layer_widget.h.

References LAYER_WIDGET::AppendLayerRow(), LAYER_WIDGET::AppendRenderRow(), and LAYER_WIDGET::ClearLayerRows().

306  {
307  for( int row=0; row<aRowCount; ++row )
308  AppendLayerRow( aRowsArray[row] );
309  }
void AppendLayerRow(const ROW &aRow)
Function AppendLayerRow appends a new row in the layer portion of the widget.
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 624 of file layer_widget.cpp.

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

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

625 {
626  int nextRow = GetRenderRowCount();
627  insertRenderRow( nextRow, aRow );
628  UpdateLayouts();
629 }
void insertRenderRow(int aRow, const ROW &aSpec)
void UpdateLayouts()
int GetRenderRowCount() const
Function GetRenderRowCount returns the number of rows in the render tab.
void LAYER_WIDGET::AppendRenderRows ( const ROW aRowsArray,
int  aRowCount 
)
inlineinherited
bool PCB_LAYER_WIDGET::AreArbitraryColorsAllowed ( )
overrideprotectedvirtual

Subclasses can override this to provide logic for allowing arbitrary color selection via wxColourPicker instead of DisplayColorFrame.

Reimplemented from LAYER_WIDGET.

Definition at line 134 of file pcb_layer_widget.cpp.

References EDA_DRAW_FRAME::IsGalCanvasActive(), and myframe.

135 {
136  return myframe->IsGalCanvasActive();
137 }
PCB_BASE_FRAME * myframe
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:874
void LAYER_WIDGET::ClearLayerRows ( )
inherited

Function ClearLayerRows empties out the layer rows.

Definition at line 618 of file layer_widget.cpp.

References LAYER_WIDGET::m_LayersFlexGridSizer.

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

619 {
620  m_LayersFlexGridSizer->Clear( true );
621 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:124
void LAYER_WIDGET::ClearRenderRows ( )
inherited

Function ClearRenderRows empties out the render rows.

Definition at line 632 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer.

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

633 {
634  m_RenderFlexGridSizer->Clear( true );
635 }
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:127
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.

References LYR_COLUMN_COUNT.

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

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
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 265 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::getBackgroundLayerColor(), LAYER_WIDGET::GetLayerColor(), LAYER_WIDGET::IsLayerVisible(), LAYER_WIDGET::OnLeftDownLayers(), LAYER_WIDGET::SelectLayer(), LAYER_WIDGET::SetLayerColor(), and LAYER_WIDGET::SetLayerVisible().

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

Definition at line 294 of file layer_widget.cpp.

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

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

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

References PCB_GENERAL_SETTINGS::Colors(), COLORS_DESIGN_SETTINGS::GetLayerColor(), myframe, and PCB_BASE_FRAME::Settings().

141 {
143 }
PCB_BASE_FRAME * myframe
PCB_GENERAL_SETTINGS & Settings()
COLORS_DESIGN_SETTINGS & Colors()
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
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 541 of file layer_widget.cpp.

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

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

542 {
543  // size of m_LayerScrolledWindow --------------
544  wxArrayInt widths = m_LayersFlexGridSizer->GetColWidths();
545  int totWidth = 0;
546 
547  if( widths.GetCount() )
548  {
549  for( int i = 0; i < LYR_COLUMN_COUNT; ++i )
550  {
551  totWidth += widths[i] + m_LayersFlexGridSizer->GetHGap();
552  // printf("widths[%d]:%d\n", i, widths[i] );
553  }
554  }
555 
556  // Account for the parent's frame:
557  totWidth += 32;
558 
559 
560  /* The minimum height is a small size to properly force computation
561  * of the panel's scrollbars (otherwise it will assume it *has* all
562  * this space) */
563  unsigned totHeight = 32;
564 
565  wxSize layerz( totWidth, totHeight );
566 
567  layerz += m_LayerPanel->GetWindowBorderSize();
568 
569 
570  // size of m_RenderScrolledWindow --------------
571  widths = m_RenderFlexGridSizer->GetColWidths();
572  totWidth = 0;
573 
574  if( widths.GetCount() )
575  {
576  for( int i = 0; i < RND_COLUMN_COUNT; ++i )
577  {
578  totWidth += widths[i] + m_RenderFlexGridSizer->GetHGap();
579  // printf("widths[%d]:%d\n", i, widths[i] );
580  }
581  }
582  // account for the parent's frame, this one has void space of 10 PLUS a border:
583  totWidth += 32;
584 
585  // For totHeight re-use the previous small one
586  wxSize renderz( totWidth, totHeight );
587 
588  renderz += m_RenderingPanel->GetWindowBorderSize();
589 
590  wxSize clientz( std::max(renderz.x,layerz.x), std::max(renderz.y,layerz.y) );
591 
592  return clientz;
593 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:124
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:50
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:127
wxPanel * m_RenderingPanel
Definition: layer_widget.h:125
#define max(a, b)
Definition: auxiliary.h:86
wxPanel * m_LayerPanel
Definition: layer_widget.h:122
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.

References LYR_COLUMN_COUNT.

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

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
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 728 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendRenderRows(), and GERBER_LAYER_WIDGET::onPopupSelection().

729 {
730  int row = findLayerRow( aLayer );
731  if( row >= 0 )
732  {
733  int col = 1; // bitmap button is column 1
734  auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
735  wxASSERT( swatch );
736 
737  return swatch->GetSwatchColor();
738  }
739 
740  return COLOR4D::UNSPECIFIED; // it's caller fault, gave me a bad layer
741 }
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...
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
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 254 of file layer_widget.cpp.

References LYR_COLUMN_COUNT, and LAYER_WIDGET::m_LayersFlexGridSizer.

Referenced by LAYER_WIDGET::findLayerRow(), LAYER_WIDGET::getBackgroundLayerColor(), 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::SetLayerColor(), LAYER_WIDGET::SetLayerVisible(), SyncLayerAlphaIndicators(), SyncLayerVisibilities(), and LAYER_WIDGET::UpdateLayerIcons().

255 {
256  unsigned ndx = aRow * LYR_COLUMN_COUNT + aColumn;
257 
258  if( ndx < m_LayersFlexGridSizer->GetChildren().GetCount() )
259  return m_LayersFlexGridSizer->GetChildren()[ndx]->GetWindow();
260 
261  return NULL;
262 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:124
int LAYER_WIDGET::GetLayerRowCount ( ) const
inherited

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

Definition at line 596 of file layer_widget.cpp.

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(), SyncLayerVisibilities(), and LAYER_WIDGET::UpdateLayerIcons().

597 {
598  int controlCount = m_LayersFlexGridSizer->GetChildren().GetCount();
599  return controlCount / LYR_COLUMN_COUNT;
600 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:49
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:124
wxWindow * LAYER_WIDGET::getRenderComp ( int  aRow,
int  aColumn 
) const
protectedinherited

Definition at line 283 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

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

284 {
285  int ndx = aRow * RND_COLUMN_COUNT + aColumn;
286 
287  if( (unsigned) ndx < m_RenderFlexGridSizer->GetChildren().GetCount() )
288  return m_RenderFlexGridSizer->GetChildren()[ndx]->GetWindow();
289 
290  return NULL;
291 }
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:50
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:127
int LAYER_WIDGET::GetRenderRowCount ( ) const
inherited

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

Definition at line 603 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

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

604 {
605  int controlCount = m_RenderFlexGridSizer->GetChildren().GetCount();
606  return controlCount / RND_COLUMN_COUNT;
607 }
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:50
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:127
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 758 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendRenderRows().

759 {
760  int row = findRenderRow( aId );
761 
762  if( row >= 0 )
763  {
764  int col = 1; // checkbox is column 1
765  wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
766  wxASSERT( cb );
767  return cb->GetValue();
768  }
769 
770  return false; // the value of a non-existent row
771 }
int findRenderRow(int aId) const
wxWindow * getRenderComp(int aRow, int aColumn) const
LAYER_NUM LAYER_WIDGET::GetSelectedLayer ( )
inherited

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

Definition at line 679 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendRenderRows().

680 {
681  wxWindow* w = getLayerComp( m_CurrentRow, 0 );
682  if( w )
683  return getDecodedId( w->GetId() );
684 
685  return UNDEFINED_LAYER;
686 }
int m_CurrentRow
selected row of layer list
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...
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
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 312 of file layer_widget.cpp.

References LAYER_WIDGET::AreArbitraryColorsAllowed(), LAYER_WIDGET::ROW::color, COLUMN_ALPHA_INDICATOR, COLUMN_COLOR_LYR_CB, COLUMN_COLOR_LYRNAME, COLUMN_COLORBM, COLUMN_ICON_ACTIVE, 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(), and LAYER_WIDGET::getBackgroundLayerColor().

313 {
314  wxASSERT( aRow >= 0 );
315 
316  int col;
317  int index = aRow * LYR_COLUMN_COUNT;
318  const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
319 
320  // column 0
321  col = COLUMN_ICON_ACTIVE;
323  ROW_ICON_PROVIDER::STATE::OFF, encodeId( col, aSpec.id ) );
324  sbm->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
325  m_LayersFlexGridSizer->wxSizer::Insert( index+col, sbm, 0, flags );
326 
327  // column 1 (COLUMN_COLORBM)
328  col = COLUMN_COLORBM;
329 
330  auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
332  bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
333  bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
334  bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) );
335  m_LayersFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
336 
337  // column 2 (COLUMN_COLOR_LYR_CB)
338  col = COLUMN_COLOR_LYR_CB;
339  wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow, encodeId( col, aSpec.id ), wxEmptyString );
340  cb->SetValue( aSpec.state );
341  cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnLayerCheckBox, this );
342  cb->SetToolTip( _( "Enable this for visibility" ) );
343  m_LayersFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
344 
345  // column 3 (COLUMN_COLOR_LYRNAME)
346  col = COLUMN_COLOR_LYRNAME;
347  wxStaticText* st = new wxStaticText( m_LayerScrolledWindow, encodeId( col, aSpec.id ), aSpec.rowName );
348  shrinkFont( st, m_PointSize );
349  st->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
350  st->SetToolTip( aSpec.tooltip );
351  m_LayersFlexGridSizer->wxSizer::Insert( index+col, st, 0, flags );
352 
353  // column 4 (COLUMN_ALPHA_INDICATOR)
356  ROW_ICON_PROVIDER::STATE::OFF, wxID_ANY );
357  m_LayersFlexGridSizer->wxSizer::Insert( index+col, sbm, 0, flags );
358 
359  // Bind right click eventhandler to all columns
360  wxString layerName( aSpec.rowName );
361 
362  sbm->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
363  OnRightDownLayer( aEvt, bmb, layerName );
364  } );
365  bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
366  OnRightDownLayer( aEvt, bmb, layerName );
367  } );
368  cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
369  OnRightDownLayer( aEvt, bmb, layerName );
370  } );
371  st->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt ) {
372  OnRightDownLayer( aEvt, bmb, layerName );
373  } );
374 }
#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
#define OFF
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:124
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...
Class 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
virtual bool AreArbitraryColorsAllowed()
Subclasses can override this to provide logic for allowing arbitrary color selection via wxColourPick...
Definition: layer_widget.h:149
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:123
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
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:133
void LAYER_WIDGET::insertRenderRow ( int  aRow,
const ROW aSpec 
)
protectedinherited

Definition at line 377 of file layer_widget.cpp.

References LAYER_WIDGET::AreArbitraryColorsAllowed(), LAYER_WIDGET::ROW::changeable, LAYER_WIDGET::ROW::color, 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(), and LAYER_WIDGET::getBackgroundLayerColor().

378 {
379  wxASSERT( aRow >= 0 );
380 
381  int col;
382  int index = aRow * RND_COLUMN_COUNT;
383  const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
384 
385  wxString renderName( aSpec.rowName );
386  wxCheckBox* cb = nullptr;
387 
388  // column 1
389  if( !aSpec.spacer )
390  {
391  col = 1;
392  cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ),
393  aSpec.rowName, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
394  shrinkFont( cb, m_PointSize );
395  cb->SetValue( aSpec.state );
396  cb->Enable( aSpec.changeable );
397  cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
398  cb->SetToolTip( aSpec.tooltip );
399  }
400 
401  // column 0
402  col = 0;
403  if( aSpec.color != COLOR4D::UNSPECIFIED )
404  {
405  auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
407  bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
408  bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
409  m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
410 
411  bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
412  OnRightDownRender( aEvt, bmb, renderName );
413  } );
414  cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
415  OnRightDownRender( aEvt, bmb, renderName );
416  } );
417 
418  // could add a left click handler on the color button that toggles checkbox.
419  }
420  else // == -1, no color selection wanted
421  {
422  // need a place holder within the sizer to keep grid full.
423  wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, encodeId( col, aSpec.id ) );
424  m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
425  }
426 
427  // Items have to be inserted in order
428  col = 1;
429 
430  if( aSpec.spacer )
431  {
432  wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, wxID_ANY );
433  m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
434  }
435  else
436  {
437  m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
438  }
439 }
wxScrolledWindow * m_RenderScrolledWindow
Definition: layer_widget.h:126
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:127
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.
virtual bool AreArbitraryColorsAllowed()
Subclasses can override this to provide logic for allowing arbitrary color selection via wxColourPick...
Definition: layer_widget.h:149
void OnRenderSwatchChanged(wxCommandEvent &aEvent)
Function OnRenderSwatchChanged Called when user has changed the swatch color of a render entry...
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 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.

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 146 of file pcb_layer_widget.cpp.

References DIM.

Referenced by ReFillRender(), and SyncRenderStates().

147 {
148  for( unsigned ii = 0; ii < DIM( s_allowed_in_FpEditor ); ii++ )
149  if( s_allowed_in_FpEditor[ii] == aId )
150  return true;
151 
152  return false;
153 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
static int s_allowed_in_FpEditor[]
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 156 of file pcb_layer_widget.cpp.

References LSET::AllTechMask().

Referenced by OnLayerSelect(), and ReFill().

157 {
158  static LSET allowed = LSET::AllTechMask();
159  // Currently not in use because putting a graphic item on a copper layer
160  // is not currently supported by DRC.
161  // allowed.set( F_Cu ).set( B_Cu );
162  return allowed.test( aLayer );
163 }
static LSET AllTechMask()
Function AllTechMask returns a mask holding all technical layers (no CU layer) on both side...
Definition: lset.cpp:743
Class LSET is a set of PCB_LAYER_IDs.
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 701 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendRenderRows(), and GERBVIEW_FRAME::IsLayerVisible().

702 {
703  int row = findLayerRow( aLayer );
704  if( row >= 0 )
705  {
706  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
707  wxASSERT( cb );
708  return cb->GetValue();
709  }
710  return false;
711 }
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
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 168 of file layer_widget.cpp.

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

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

169 {
170  wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
171  LAYER_NUM layer = getDecodedId( eventSource->GetId() );
172  OnLayerVisible( layer, eventSource->IsChecked() );
173  passOnFocus();
174 }
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.
void PCB_LAYER_WIDGET::OnLayerColorChange ( int  aLayer,
COLOR4D  aColor 
)
overridevirtual

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

Derived classes will handle this accordingly.

Parameters
aLayeris the board layer to change
aColoris the new color

Implements LAYER_WIDGET.

Definition at line 596 of file pcb_layer_widget.cpp.

References KIGFX::COLOR4D::a, PCB_GENERAL_SETTINGS::Colors(), EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetGalCanvas(), COLORS_DESIGN_SETTINGS::GetLayerColor(), GetNetnameLayer(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), EDA_DRAW_PANEL_GAL::GetView(), KIGFX::RENDER_SETTINGS::ImportLegacyColors(), EDA_DRAW_FRAME::IsGalCanvasActive(), myframe, PCB_BASE_FRAME::ReCreateHToolbar(), EDA_DRAW_PANEL::Refresh(), COLORS_DESIGN_SETTINGS::SetLayerColor(), PCB_BASE_FRAME::Settings(), ToLAYER_ID(), and KIGFX::VIEW::UpdateLayerColor().

597 {
598  // Avoid setting the alpha channel, when we are in legacy mode,
599  // because in legacy mode the alpha channel is not used, but changing it
600  // destroys the GAL color setup
601  if( !myframe->IsGalCanvasActive() )
602  {
603  COLOR4D oldColor = myframe->Settings().Colors().GetLayerColor( ToLAYER_ID( aLayer ) );
604  aColor.a = oldColor.a;
605  }
606 
607  myframe->Settings().Colors().SetLayerColor( ToLAYER_ID( aLayer ), aColor );
608 
609  if( myframe->IsGalCanvasActive() )
610  {
611  KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
613  view->UpdateLayerColor( aLayer );
614  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
615  }
616 
618 
619  myframe->GetCanvas()->Refresh();
620 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:342
virtual void ReCreateHToolbar() override=0
PCB_BASE_FRAME * myframe
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
double a
Alpha component.
Definition: color4d.h:294
PCB_GENERAL_SETTINGS & Settings()
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:874
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
COLORS_DESIGN_SETTINGS & Colors()
virtual void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings)=0
Function ImportLegacyColors Loads a list of color settings for layers.
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:654
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
Class VIEW.
Definition: view.h:58
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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 681 of file pcb_layer_widget.cpp.

References AddRightClickMenuItems().

682 {
683  AddRightClickMenuItems( aMenu );
684 }
void AddRightClickMenuItems(wxMenu &menu)
Function addRightClickMenuItems add menu items to a menu that should be shown when right-clicking the...
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 623 of file pcb_layer_widget.cpp.

References EDA_DRAW_FRAME::GetCanvas(), PCB_BASE_FRAME::GetDisplayOptions(), isLayerAllowedInFpMode(), m_alwaysShowActiveCopperLayer, PCB_DISPLAY_OPTIONS::m_ContrastModeDisplay, m_fp_editor_mode, myframe, OnLayerSelected(), EDA_DRAW_PANEL::Refresh(), PCB_BASE_FRAME::SetActiveLayer(), and ToLAYER_ID().

624 {
625  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
626  // false from this function.
627  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
628 
629  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
630  return false;
631 
632  myframe->SetActiveLayer( layer );
634 
636  OnLayerSelected();
637  else if( displ_opts->m_ContrastModeDisplay )
638  myframe->GetCanvas()->Refresh();
639 
640  return true;
641 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:342
bool isLayerAllowedInFpMode(PCB_LAYER_ID aLayer)
Function isLayerAllowedInFpMode.
PCB_BASE_FRAME * myframe
bool OnLayerSelected()
Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwa...
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
bool m_alwaysShowActiveCopperLayer
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
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 644 of file pcb_layer_widget.cpp.

References ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, m_alwaysShowActiveCopperLayer, and onPopupSelection().

Referenced by OnLayerSelect().

645 {
647  return false;
648 
649  // postprocess after an active layer selection
650  // ensure active layer visible
651  wxCommandEvent event;
653  onPopupSelection( event );
654 
655  return true;
656 }
bool m_alwaysShowActiveCopperLayer
void onPopupSelection(wxCommandEvent &event)
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.

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

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

150 {
151  auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
152 
153  COLOR4D newColor = eventSource->GetSwatchColor();
154 
155  LAYER_NUM layer = getDecodedId( eventSource->GetId() );
156 
157  // tell the client code.
158  OnLayerColorChange( layer, newColor );
159 
160  // notify others
161  wxCommandEvent event( EVT_LAYER_COLOR_CHANGE );
162  wxPostEvent( this, event );
163 
164  passOnFocus();
165 }
static const wxEventType EVT_LAYER_COLOR_CHANGE
Definition: layer_widget.h:117
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
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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 659 of file pcb_layer_widget.cpp.

References PCB_BASE_FRAME::GetBoard(), EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_DRAW_PANEL_GAL::GetView(), BOARD::GetVisibleLayers(), myframe, PCB_BASE_FRAME::OnModify(), EDA_DRAW_PANEL::Refresh(), KIGFX::VIEW::SetLayerVisible(), and BOARD::SetVisibleLayers().

Referenced by onPopupSelection().

660 {
661  BOARD* brd = myframe->GetBoard();
662 
663  LSET visibleLayers = brd->GetVisibleLayers();
664 
665  visibleLayers.set( aLayer, isVisible );
666 
667  brd->SetVisibleLayers( visibleLayers );
668 
669  myframe->OnModify();
670 
671  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
672 
673  if( galCanvas )
674  galCanvas->GetView()->SetLayerVisible( aLayer, isVisible );
675 
676  if( isFinal )
677  myframe->GetCanvas()->Refresh();
678 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:342
PCB_BASE_FRAME * myframe
BOARD * GetBoard() const
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Class 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:387
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
void LAYER_WIDGET::OnLeftDownLayers ( wxMouseEvent &  event)
protectedinherited

Definition at line 77 of file layer_widget.cpp.

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::getBackgroundLayerColor(), and LAYER_WIDGET::insertLayerRow().

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 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:124
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:123
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
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.
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...
void PCB_LAYER_WIDGET::onPopupSelection ( wxCommandEvent &  event)
protected

Definition at line 220 of file pcb_layer_widget.cpp.

References B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, COLUMN_COLOR_LYR_CB, Edge_Cuts, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, PCB_BASE_FRAME::GetActiveLayer(), LAYER_WIDGET::getDecodedId(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, ID_HIDE_ALL_NON_COPPER, ID_SHOW_ALL_BACK, ID_SHOW_ALL_COPPER_LAYERS, ID_SHOW_ALL_FRONT, ID_SHOW_ALL_LAYERS, ID_SHOW_ALL_NON_COPPER, ID_SHOW_NO_COPPER_LAYERS, ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, ID_SHOW_NO_LAYERS, IsCopperLayer(), isLast(), m_alwaysShowActiveCopperLayer, myframe, OnLayerVisible(), and ToLAYER_ID().

Referenced by OnLayerSelected(), and PCB_LAYER_WIDGET().

221 {
222  int rowCount;
223  int menuId = event.GetId();
224  bool visible;
225  bool force_active_layer_visible;
226 
228  force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ||
230 
231  switch( menuId )
232  {
233  case ID_SHOW_NO_LAYERS:
234  case ID_SHOW_ALL_LAYERS:
235  {
236  visible = ( menuId == ID_SHOW_ALL_LAYERS );
237  rowCount = GetLayerRowCount();
238 
239  for( int row=0; row<rowCount; ++row )
240  {
241  bool isLast;
242  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
243  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
244  cb->SetValue( visible );
245 
246  isLast = row == rowCount-1;
247 
248  OnLayerVisible( layer, visible, isLast );
249 
250  if( isLast )
251  break;
252  }
253  break;
254  }
255 
262  {
263 
264  // Search the last copper layer row index:
265  int lastCu = -1;
266  rowCount = GetLayerRowCount();
267  for( int row = rowCount-1; row>=0; --row )
268  {
269  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
270  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
271 
272  if( IsCopperLayer( layer ) )
273  {
274  lastCu = row;
275  break;
276  }
277  }
278 
279  // Enable/disable the copper layers visibility:
280  int startrow = 0;
281 
282  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
283  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
284  {
285  startrow = lastCu + 1;
286  }
287 
288  for( int row = startrow; row<rowCount; ++row )
289  {
290  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
291  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
292 
293  visible = ( ( menuId == ID_SHOW_ALL_COPPER_LAYERS ) || ( menuId == ID_SHOW_ALL_NON_COPPER ) );
294 
295  if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
296  visible = true;
297 
298  cb->SetValue( visible );
299 
300  bool isLastLayer = (row == lastCu);
301 
302  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
303  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
304  {
305  isLastLayer = false;
306  }
307  OnLayerVisible( layer, visible, isLastLayer );
308 
309  if( isLastLayer )
310  break;
311  }
312  break;
313  }
314 
315  case ID_SHOW_ALL_FRONT:
316  {
317  visible = false;
318  rowCount = GetLayerRowCount();
319 
320  for( int row=0; row<rowCount; ++row )
321  {
322  bool isLast;
323  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
324  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
325  isLast = ( row == rowCount-1 );
326 
327  if( layer == F_Paste || layer == F_SilkS ||
328  layer == F_Mask || layer == F_Cu ||
329  layer == F_Fab || layer == F_CrtYd || layer == Edge_Cuts )
330  {
331  visible = true;
332  }
333  else
334  {
335  visible = false;
336  }
337 
338  cb->SetValue( visible );
339  OnLayerVisible( layer, visible, isLast );
340 
341  if( isLast )
342  break;
343  }
344  break;
345  }
346  case ID_SHOW_ALL_BACK:
347  {
348  visible = false;
349  rowCount = GetLayerRowCount();
350 
351  for( int row=0; row<rowCount; ++row )
352  {
353  bool isLast;
354  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
355  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
356  isLast = ( row == rowCount-1 );
357 
358  if( layer == B_Paste || layer == B_SilkS ||
359  layer == B_Mask || layer == B_Cu ||
360  layer == B_Fab || layer == B_CrtYd || layer == Edge_Cuts )
361  {
362  visible = true;
363  }
364  else
365  {
366  visible = false;
367  }
368 
369  cb->SetValue( visible );
370  OnLayerVisible( layer, visible, isLast );
371 
372  if( isLast )
373  break;
374  }
375  break;
376  }
377  }
378 }
bool isLast(CPTREE &aTree, CITER it)
Definition: ptree.cpp:122
PCB_BASE_FRAME * myframe
PCB_LAYER_ID
A quick note on layer IDs:
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
bool m_alwaysShowActiveCopperLayer
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
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
void LAYER_WIDGET::OnRenderCheckBox ( wxCommandEvent &  event)
protectedinherited

Definition at line 236 of file layer_widget.cpp.

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

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

237 {
238  wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
239  LAYER_NUM id = getDecodedId( eventSource->GetId() );
240  OnRenderEnable( id, eventSource->IsChecked() );
241  passOnFocus();
242 }
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.
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 687 of file pcb_layer_widget.cpp.

References PCB_GENERAL_SETTINGS::Colors(), EDA_DRAW_PANEL_GAL::ForceRefresh(), GAL_LAYER_ID_END, GAL_LAYER_ID_START, EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetGAL(), EDA_DRAW_FRAME::GetGalCanvas(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), EDA_DRAW_PANEL_GAL::GetView(), KIGFX::RENDER_SETTINGS::ImportLegacyColors(), EDA_DRAW_FRAME::IsGalCanvasActive(), LAYER_GRID, LAYER_PADS_PLATEDHOLES, KIGFX::VIEW::MarkTargetDirty(), myframe, PCB_BASE_FRAME::ReCreateHToolbar(), EDA_DRAW_PANEL::Refresh(), KIGFX::GAL::SetGridColor(), COLORS_DESIGN_SETTINGS::SetItemColor(), PCB_BASE_FRAME::Settings(), KIGFX::TARGET_NONCACHED, and KIGFX::VIEW::UpdateLayerColor().

688 {
689  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
690 
691  myframe->Settings().Colors().SetItemColor( static_cast<GAL_LAYER_ID>( aId ), aColor );
692 
693  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
694 
695  if( galCanvas && myframe->IsGalCanvasActive() )
696  {
697  if( aId == LAYER_GRID )
698  galCanvas->GetGAL()->SetGridColor( aColor );
699 
700  KIGFX::VIEW* view = galCanvas->GetView();
702  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
703  view->UpdateLayerColor( aId );
704 
705  // plated-through-holes don't have their own color; they use the background color
706  if( aId == LAYER_PCB_BACKGROUND )
708 
709  galCanvas->ForceRefresh();
710  }
711 
713 
714  myframe->GetCanvas()->Refresh();
715 }
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
void SetItemColor(int aItemIdx, COLOR4D aColor)
Function SetItemColor sets the color for an item which is one of the item indices given in enum PCB_L...
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:342
virtual void ReCreateHToolbar() override=0
PCB_BASE_FRAME * myframe
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Add new GAL layers here.
Auxiliary rendering target (noncached)
Definition: definitions.h:42
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:568
PCB_GENERAL_SETTINGS & Settings()
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:874
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
COLORS_DESIGN_SETTINGS & Colors()
virtual void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings)=0
Function ImportLegacyColors Loads a list of color settings for layers.
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:654
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
Class VIEW.
Definition: view.h:58
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 718 of file pcb_layer_widget.cpp.

References FRAME_PCB, GAL_LAYER_ID_END, GAL_LAYER_ID_START, PCB_BASE_FRAME::GetBoard(), EDA_DRAW_FRAME::GetCanvas(), EDA_DRAW_PANEL_GAL::GetGAL(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_DRAW_PANEL_GAL::GetView(), BOARD::IsElementVisible(), EDA_DRAW_FRAME::IsGalCanvasActive(), EDA_DRAW_FRAME::IsGridVisible(), EDA_BASE_FRAME::IsType(), LAYER_GRID, LAYER_RATSNEST, KIGFX::VIEW::MarkTargetDirty(), myframe, PCB_BASE_FRAME::OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), EDA_DRAW_PANEL::Refresh(), BOARD::SetElementVisibility(), KIGFX::GAL::SetGridVisibility(), KIGFX::VIEW::SetLayerVisible(), and KIGFX::TARGET_NONCACHED.

719 {
720  BOARD* brd = myframe->GetBoard();
721  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
722 
723  if( myframe->IsType( FRAME_PCB ) )
724  {
725  // The layer visibility status is saved in the board file so set the board
726  // modified state so the user has the option to save the changes.
727  if( brd->IsElementVisible( static_cast<GAL_LAYER_ID>( aId ) ) != isEnabled )
728  myframe->OnModify();
729  }
730 
731  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
732 
733  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
734 
735  if( galCanvas && myframe->IsGalCanvasActive() )
736  {
737  if( aId == LAYER_GRID )
738  {
739  galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
741  }
742  else if ( aId == LAYER_RATSNEST )
743  {
744  // don't touch the layers. ratsnest is enabled on per-item basis.
746  galCanvas->GetView()->SetLayerVisible( aId, true );
747  }
748  else
749  galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
750 
751  galCanvas->Refresh();
752  }
753 
754  myframe->GetCanvas()->Refresh();
755 }
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:342
PCB_BASE_FRAME * myframe
BOARD * GetBoard() const
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Add new GAL layers here.
virtual bool IsGridVisible() const
Function IsGridVisible() , virtual.
Definition: draw_frame.h:486
Auxiliary rendering target (noncached)
Definition: definitions.h:42
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:568
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:874
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:387
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
bool IsType(FRAME_T aType) const
void LAYER_WIDGET::OnRenderSwatchChanged ( wxCommandEvent &  aEvent)
protectedinherited

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

Definition at line 198 of file layer_widget.cpp.

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::getBackgroundLayerColor(), and LAYER_WIDGET::insertRenderRow().

199 {
200  auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
201 
202  COLOR4D newColor = eventSource->GetSwatchColor();
203 
204  LAYER_NUM id = getDecodedId( eventSource->GetId() );
205 
206  if( id == LAYER_PCB_BACKGROUND )
207  {
208  // Update all swatch backgrounds
209  int count = GetLayerRowCount();
210  int row;
211  int col = 1; // bitmap button is column 1 in layers tab
212  for( row = 0; row < count; ++row )
213  {
214  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
215  if( swatch )
216  swatch->SetSwatchBackground( newColor );
217  }
218 
219  count = GetRenderRowCount();
220  col = 0; // bitmap button is column 0 in render tab
221  for( row = 0; row < count; ++row )
222  {
223  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getRenderComp( row, col ) );
224  if( swatch )
225  swatch->SetSwatchBackground( newColor );
226  }
227  }
228 
229  // tell the client code.
230  OnRenderColorChange( id, newColor );
231 
232  passOnFocus();
233 }
virtual void OnRenderColorChange(int aId, COLOR4D aColor)=0
Function OnRenderColorChange is called to notify client code whenever the user changes a rendering co...
void SetSwatchBackground(KIGFX::COLOR4D aBackground)
Set the swatch background color.
int GetRenderRowCount() const
Function GetRenderRowCount returns the number of rows in the render tab.
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
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
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxWindow * getRenderComp(int aRow, int aColumn) const
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.

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

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

126 {
127  wxMenu menu;
128 
130  _( "Change Layer Color for " ) + aLayerName,
131  KiBitmap( setcolor_copper_xpm ) );
132  menu.AppendSeparator();
133 
134  OnLayerRightClick( menu );
135 
136  menu.Bind( wxEVT_COMMAND_MENU_SELECTED, [this, 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:174
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
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.
void PCB_LAYER_WIDGET::onRightDownLayers ( wxMouseEvent &  event)
protected

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

Definition at line 209 of file pcb_layer_widget.cpp.

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

Referenced by PCB_LAYER_WIDGET().

210 {
211  wxMenu menu;
212 
213  AddRightClickMenuItems( menu );
214  PopupMenu( &menu );
215 
216  passOnFocus();
217 }
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.
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 177 of file layer_widget.cpp.

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

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

178 {
179  wxMenu menu;
180 
182  _( "Change Render Color for " ) + aRenderName,
183  KiBitmap( setcolor_board_body_xpm ) );
184 
185  menu.Bind( wxEVT_COMMAND_MENU_SELECTED, [this, aColorSwatch]( wxCommandEvent& event ) {
186  if ( event.GetId() == ID_CHANGE_RENDER_COLOR ) {
187  aColorSwatch->GetNewSwatchColor();
188  } else {
189  event.Skip();
190  }
191  } );
192 
193  PopupMenu( &menu );
194  passOnFocus();
195 }
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:174
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
void GetNewSwatchColor()
Prompt for a new colour, using the colour picker dialog.
void LAYER_WIDGET::OnTabChange ( wxNotebookEvent &  event)
protectedinherited

Definition at line 245 of file layer_widget.cpp.

References LAYER_WIDGET::passOnFocus().

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

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

Definition at line 504 of file pcb_layer_widget.cpp.

References LAYER_WIDGET::AppendLayerRow(), B_Adhes, B_CrtYd, B_Cu, B_Fab, B_Mask, B_Paste, B_SilkS, LAYER_WIDGET::ClearLayerRows(), Cmts_User, PCB_GENERAL_SETTINGS::Colors(), COLUMN_COLOR_LYRNAME, COLUMN_COLORBM, LSET::CuStack(), DIM, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_CrtYd, F_Cu, F_Fab, F_Mask, F_Paste, F_SilkS, PCB_BASE_FRAME::GetBoard(), BOARD::GetEnabledLayers(), COLORS_DESIGN_SETTINGS::GetLayerColor(), LAYER_WIDGET::getLayerComp(), BOARD::GetLayerName(), LAYER_WIDGET::GetLayerRowCount(), isLayerAllowedInFpMode(), m_fp_editor_mode, Margin, myframe, and PCB_BASE_FRAME::Settings().

505 {
506  BOARD* brd = myframe->GetBoard();
507  LSET enabled = brd->GetEnabledLayers();
508 
509  ClearLayerRows();
510 
511  wxString dsc;
512 
513  // show all coppers first, with front on top, back on bottom, then technical layers
514  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
515  {
516  PCB_LAYER_ID layer = *cu_stack;
517 
518  switch( layer )
519  {
520  case F_Cu:
521  dsc = _( "Front copper layer" );
522  break;
523 
524  case B_Cu:
525  dsc = _( "Back copper layer" );
526  break;
527 
528  default:
529  dsc = _( "Inner copper layer" );
530  break;
531  }
532 
534  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
535  dsc, true ) );
536 
537  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
538  {
539  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
541  COLUMN_COLORBM )->SetToolTip( wxEmptyString );
542  }
543  }
544 
545 
546  // technical layers are shown in this order:
547  // Because they are static, wxGetTranslation must be explicitly
548  // called for tooltips.
549  static const struct {
550  PCB_LAYER_ID layerId;
551  wxString tooltip;
552  } non_cu_seq[] = {
553  { F_Adhes, _( "Adhesive on board's front" ) },
554  { B_Adhes, _( "Adhesive on board's back" ) },
555  { F_Paste, _( "Solder paste on board's front" ) },
556  { B_Paste, _( "Solder paste on board's back" ) },
557  { F_SilkS, _( "Silkscreen on board's front" ) },
558  { B_SilkS, _( "Silkscreen on board's back" ) },
559  { F_Mask, _( "Solder mask on board's front" ) },
560  { B_Mask, _( "Solder mask on board's back" ) },
561  { Dwgs_User, _( "Explanatory drawings" ) },
562  { Cmts_User, _( "Explanatory comments" ) },
563  { Eco1_User, _( "User defined meaning" ) },
564  { Eco2_User, _( "User defined meaning" ) },
565  { Edge_Cuts, _( "Board's perimeter definition" ) },
566  { Margin, _( "Board's edge setback outline" ) },
567  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
568  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
569  { F_Fab, _( "Footprint assembly on board's front" ) },
570  { B_Fab, _( "Footprint assembly on board's back" ) }
571  };
572 
573  for( unsigned i=0; i<DIM( non_cu_seq ); ++i )
574  {
575  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
576 
577  if( !enabled[layer] )
578  continue;
579 
581  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
582  wxGetTranslation( non_cu_seq[i].tooltip ), true ) );
583 
584  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
585  {
586  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
588  COLUMN_COLORBM )->SetToolTip( wxEmptyString );
589  }
590  }
591 }
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:55
#define DIM(x)
of elements in an array
Definition: macros.h:98
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:87
LSEQ CuStack() const
Function CuStack returns a sequence of copper layers in starting from the front/top and extending to ...
Definition: lset.cpp:147
bool isLayerAllowedInFpMode(PCB_LAYER_ID aLayer)
Function isLayerAllowedInFpMode.
PCB_BASE_FRAME * myframe
BOARD * GetBoard() const
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:
Class LSET is a set of PCB_LAYER_IDs.
#define COLUMN_COLORBM
Definition: layer_widget.h:53
PCB_GENERAL_SETTINGS & Settings()
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
void AppendLayerRow(const ROW &aRow)
Function AppendLayerRow appends a new row in the layer portion of the widget.
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
COLORS_DESIGN_SETTINGS & Colors()
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
void PCB_LAYER_WIDGET::ReFillRender ( )

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

Definition at line 388 of file pcb_layer_widget.cpp.

References LAYER_WIDGET::AppendRenderRow(), LAYER_WIDGET::ClearRenderRows(), LAYER_WIDGET::ROW::color, PCB_GENERAL_SETTINGS::Colors(), DIM, PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), COLORS_DESIGN_SETTINGS::GetItemColor(), LAYER_WIDGET::ROW::id, isAllowedInFpMode(), BOARD::IsElementVisible(), LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, m_fp_editor_mode, myframe, LAYER_WIDGET::ROW::rowName, s_render_rows, PCB_BASE_FRAME::Settings(), LAYER_WIDGET::ROW::state, and LAYER_WIDGET::ROW::tooltip.

Referenced by PCB_LAYER_WIDGET().

389 {
390  BOARD* board = myframe->GetBoard();
391  auto settings = board->GetDesignSettings();
392 
393  ClearRenderRows();
394 
395  // Add "Items" tab rows to LAYER_WIDGET, after setting color and checkbox state.
396  // Because s_render_rows is created static, we must explicitly call
397  // wxGetTranslation for texts which are internationalized (tool tips
398  // and item names)
399  for( unsigned row=0; row<DIM(s_render_rows); ++row )
400  {
401  LAYER_WIDGET::ROW renderRow = s_render_rows[row];
402 
403  if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
404  continue;
405 
406  if( renderRow.id == LAYER_VIA_MICROVIA && !settings.m_MicroViasAllowed )
407  continue;
408 
409  if( renderRow.id == LAYER_VIA_BBLIND && !settings.m_BlindBuriedViaAllowed )
410  continue;
411 
412  renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
413  renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
414 
415  if( renderRow.color != COLOR4D::UNSPECIFIED ) // does this row show a color?
416  {
417  // this window frame must have an established BOARD, i.e. after SetBoard()
418  renderRow.color = myframe->Settings().Colors().GetItemColor( static_cast<GAL_LAYER_ID>( renderRow.id ) );
419  }
420 
421  renderRow.state = board->IsElementVisible( static_cast<GAL_LAYER_ID>( renderRow.id ) );
422 
423  AppendRenderRow( renderRow );
424  }
425 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
to draw blind/buried vias
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:87
PCB_BASE_FRAME * myframe
BOARD * GetBoard() const
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
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
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.
PCB_GENERAL_SETTINGS & Settings()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
COLORS_DESIGN_SETTINGS & Colors()
static const LAYER_WIDGET::ROW s_render_rows[]
This is a read only template that is copied and modified before adding to LAYER_WIDGET.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
wxString rowName
the prompt or layername
Definition: layer_widget.h:89
int id
either a layer or "visible element" id
Definition: layer_widget.h:90
void LAYER_WIDGET::SelectLayer ( LAYER_NUM  aLayer)
inherited

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

Definition at line 672 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendRenderRows(), GERBVIEW_FRAME::SetActiveLayer(), and GERBVIEW_FRAME::syncLayerWidget().

673 {
674  int row = findLayerRow( aLayer );
675  SelectLayerRow( row );
676 }
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.
void LAYER_WIDGET::SelectLayerRow ( int  aRow)
inherited

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

Definition at line 638 of file layer_widget.cpp.

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::AppendRenderRows(), LAYER_WIDGET::OnLeftDownLayers(), and LAYER_WIDGET::SelectLayer().

639 {
640  // enable the layer tab at index 0
641  m_notebook->SetSelection( 0 );
642 
643  INDICATOR_ICON* oldIndicator = (INDICATOR_ICON*) getLayerComp( m_CurrentRow, 0 );
644  if( oldIndicator )
645  {
647  oldIndicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DIMMED );
648  else
650  }
651 
652  INDICATOR_ICON* newIndicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
653  if( newIndicator )
654  {
656 
657  // Make sure the desired layer row is visible.
658  // It seems that as of 2.8.2, setting the focus does this.
659  // I don't expect the scrolling to be needed at all because
660  // the minimum window size may end up being established so that the
661  // scroll bars will not be visible.
662  getLayerComp( aRow, 1 )->SetFocus();
663  }
664 
665  m_CurrentRow = aRow;
666 
667  // give the focus back to the app.
668  passOnFocus();
669 }
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
wxAuiNotebook * m_notebook
Definition: layer_widget.h:121
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:130
#define OFF
virtual bool useAlternateBitmap(int aRow)
Virtual Function useAlternateBitmap.
Definition: layer_widget.h:143
Class representing a row indicator icon for use in places like the layer widget.
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
#define ON
void LAYER_WIDGET::SetLayerColor ( LAYER_NUM  aLayer,
COLOR4D  aColor 
)
inherited

Function SetLayerColor changes the color of aLayer.

Definition at line 714 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendRenderRows().

715 {
716  int row = findLayerRow( aLayer );
717  if( row >= 0 )
718  {
719  int col = 1; // bitmap button is column 1
720  auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
721  wxASSERT( swatch );
722 
723  swatch->SetSwatchColor( aColor, false );
724  }
725 }
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...
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
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 381 of file pcb_layer_widget.cpp.

References LAYER_WIDGET::m_notebook.

Referenced by PCB_LAYER_WIDGET().

382 {
383  m_notebook->SetPageText( 0, _( "Layers" ) );
384  m_notebook->SetPageText( 1, _( "Items" ) );
385 }
wxAuiNotebook * m_notebook
Definition: layer_widget.h:121
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 689 of file layer_widget.cpp.

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

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

690 {
691  int row = findLayerRow( aLayer );
692  if( row >= 0 )
693  {
694  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
695  wxASSERT( cb );
696  cb->SetValue( isVisible ); // does not fire an event
697  }
698 }
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
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 744 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendRenderRows(), GERBVIEW_FRAME::SetElementVisibility(), FOOTPRINT_EDIT_FRAME::SetElementVisibility(), GERBVIEW_FRAME::SetGridVisibility(), and SyncRenderStates().

745 {
746  int row = findRenderRow( aId );
747 
748  if( row >= 0 )
749  {
750  int col = 1; // checkbox is column 1
751  wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
752  wxASSERT( cb );
753  cb->SetValue( isSet ); // does not fire an event
754  }
755 }
int findRenderRow(int aId) const
wxWindow * getRenderComp(int aRow, int aColumn) const
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 470 of file pcb_layer_widget.cpp.

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

Referenced by FOOTPRINT_EDIT_FRAME::OnUpdateLayerAlpha().

471 {
472  int count = GetLayerRowCount();
474  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() );
475  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
476 
477  for( int row = 0; row < count; ++row )
478  {
479  // this utilizes more implementation knowledge than ideal, eventually
480  // add member ROW getRow() or similar to base LAYER_WIDGET.
481 
482  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
483  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
484  KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId );
485 
486  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) );
487  KIGFX::COLOR4D layerColor = swatch->GetSwatchColor();
488 
489  INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) );
490 
491  if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON )
492  {
493  if( screenColor.a < layerColor.a )
494  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
495  else
496  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
497  }
498  else
500  }
501 }
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
#define ALPHA_EPSILON
#define COLUMN_ALPHA_INDICATOR
Definition: layer_widget.h:56
PCB_BASE_FRAME * myframe
#define OFF
KIGFX::COLOR4D GetSwatchColor() const
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:186
#define abs(a)
Definition: auxiliary.h:84
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:206
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
Class TOOL_MANAGER.
Definition: tool_manager.h:49
PCB_LAYER_ID
A quick note on layer IDs:
Class representing a row indicator icon for use in places like the layer widget.
double a
Alpha component.
Definition: color4d.h:294
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
#define COLUMN_COLORBM
Definition: layer_widget.h:53
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:198
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
TOOL_MANAGER * GetToolManager() const
Function GetToolManager returns the tool manager instance, if any.
Definition: draw_frame.h:889
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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 448 of file pcb_layer_widget.cpp.

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

449 {
450  BOARD* board = myframe->GetBoard();
451  int count = GetLayerRowCount();
452 
453  for( int row=0; row<count; ++row )
454  {
455  // this utilizes more implementation knowledge than ideal, eventually
456  // add member ROW getRow() or similar to base LAYER_WIDGET.
457 
458  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
459 
460  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
461 
462  // this does not fire a UI event
463  SetLayerVisible( layerId, board->IsLayerVisible( layerId ) );
464  }
465 }
PCB_BASE_FRAME * myframe
BOARD * GetBoard() const
PCB_LAYER_ID
A quick note on layer IDs:
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
Function SetLayerVisible sets aLayer visible or not.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:451
void PCB_LAYER_WIDGET::SyncRenderStates ( )

Function SyncRenderStates updates the checkboxes (checked or not) to be consistent with the current state of the visibility of the visible rendering elements.

Definition at line 428 of file pcb_layer_widget.cpp.

References DIM, PCB_BASE_FRAME::GetBoard(), LAYER_WIDGET::ROW::id, isAllowedInFpMode(), BOARD::IsElementVisible(), m_fp_editor_mode, myframe, s_render_rows, and LAYER_WIDGET::SetRenderState().

429 {
430  BOARD* board = myframe->GetBoard();
431 
432  for( unsigned row=0; row<DIM(s_render_rows); ++row )
433  {
434  int rowId = s_render_rows[row].id;
435 
436  if( m_fp_editor_mode && !isAllowedInFpMode( rowId ) )
437  continue;
438 
439  if( s_render_rows[row].spacer )
440  continue;
441 
442  // this does not fire a UI event
443  SetRenderState( rowId, board->IsElementVisible( static_cast<GAL_LAYER_ID>( rowId ) ) );
444  }
445 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
PCB_BASE_FRAME * myframe
BOARD * GetBoard() const
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
static const LAYER_WIDGET::ROW s_render_rows[]
This is a read only template that is copied and modified before adding to LAYER_WIDGET.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
int id
either a layer or "visible element" id
Definition: layer_widget.h:90
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 784 of file layer_widget.cpp.

References BLUE, BROWN, COLUMN_ICON_ACTIVE, DIM, LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), GREEN, LAYER_WIDGET::LAYER_WIDGET(), LAYER_WIDGET::m_CurrentRow, OFF, ON, LAYER_WIDGET::OnLayerColorChange(), LAYER_WIDGET::OnLayerSelect(), LAYER_WIDGET::OnLayerVisible(), LAYER_WIDGET::OnRenderColorChange(), LAYER_WIDGET::OnRenderEnable(), RED, INDICATOR_ICON::SetIndicatorState(), LAYER_WIDGET::useAlternateBitmap(), and YELLOW.

Referenced by LAYER_WIDGET::AppendRenderRows(), GERBVIEW_FRAME::LoadExcellonFiles(), GERBVIEW_FRAME::loadListOfGerberFiles(), and GERBVIEW_FRAME::LoadZipArchiveFile().

785 {
786  int rowCount = GetLayerRowCount();
787 
788  for( int row = 0; row < rowCount ; row++ )
789  {
791 
792  if( indicator )
793  {
795 
796  if( row == m_CurrentRow )
798  else if( useAlternateBitmap( row ) )
799  state = ROW_ICON_PROVIDER::STATE::DIMMED;
800  else
802 
803  indicator->SetIndicatorState( state );
804  }
805  }
806 }
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:130
#define OFF
virtual bool useAlternateBitmap(int aRow)
Virtual Function useAlternateBitmap.
Definition: layer_widget.h:143
Class representing a row indicator icon for use in places like the layer widget.
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
STATE
State constants to select the right icons
#define ON
void LAYER_WIDGET::UpdateLayouts ( )
inherited

Definition at line 774 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::AppendLayerRow(), LAYER_WIDGET::AppendRenderRow(), and LAYER_WIDGET::AppendRenderRows().

775 {
776  m_LayersFlexGridSizer->Layout();
777  m_RenderFlexGridSizer->Layout();
778  m_LayerPanel->Layout();
779  m_RenderingPanel->Layout();
780  FitInside();
781 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:124
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:127
wxPanel * m_RenderingPanel
Definition: layer_widget.h:125
wxPanel * m_LayerPanel
Definition: layer_widget.h:122
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 143 of file layer_widget.h.

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

143 { return false; }

Member Data Documentation

const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType()
staticinherited

Definition at line 117 of file layer_widget.h.

Referenced by LAYER_WIDGET::OnLayerSwatchChanged().

bool PCB_LAYER_WIDGET::m_alwaysShowActiveCopperLayer
protected
int LAYER_WIDGET::m_CurrentRow
protectedinherited
wxWindow* LAYER_WIDGET::m_FocusOwner
protectedinherited

Definition at line 129 of file layer_widget.h.

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

bool PCB_LAYER_WIDGET::m_fp_editor_mode
protected
ROW_ICON_PROVIDER* LAYER_WIDGET::m_IconProvider
protectedinherited
wxPanel* LAYER_WIDGET::m_LayerPanel
protectedinherited
wxScrolledWindow* LAYER_WIDGET::m_LayerScrolledWindow
protectedinherited
wxAuiNotebook* LAYER_WIDGET::m_notebook
protectedinherited
int LAYER_WIDGET::m_PointSize
protectedinherited
wxPanel* LAYER_WIDGET::m_RenderingPanel
protectedinherited
wxScrolledWindow* LAYER_WIDGET::m_RenderScrolledWindow
protectedinherited

Definition at line 126 of file layer_widget.h.

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

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 128 of file pcb_layer_widget.h.

Referenced by ReFillRender(), and SyncRenderStates().


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