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 <class_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 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 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...
 
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 = wxID_HIGHEST, 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...
 
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 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 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
 

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 class_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 121 of file class_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 94 of file class_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().

95  :
96  LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
97  myframe( aParent )
98 {
100  m_fp_editor_mode = aFpEditorMode;
101  ReFillRender();
102 
103  // Update default tabs labels
105 
106  //-----<Popup menu>-------------------------------------------------
107  // handle the popup menu over the layer window.
108  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
109  wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
110 
111  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
112  // and not m_LayerScrolledWindow->Connect()
113 
115  wxEVT_COMMAND_MENU_SELECTED,
116  wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
117  // install the right click handler into each control at end of ReFill()
118  // using installRightLayerClickHandler
119 }
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:111
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
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 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 498 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().

499 {
500  int nextRow = GetLayerRowCount();
501  insertLayerRow( nextRow, aRow );
502  UpdateLayouts();
503 }
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 265 of file layer_widget.h.

References LAYER_WIDGET::AppendLayerRow().

266  {
267  for( int row=0; row<aRowCount; ++row )
268  AppendLayerRow( aRowsArray[row] );
269  }
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 512 of file layer_widget.cpp.

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

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

513 {
514  int nextRow = GetRenderRowCount();
515  insertRenderRow( nextRow, aRow );
516  UpdateLayouts();
517 }
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

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

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

Definition at line 289 of file layer_widget.h.

References LAYER_WIDGET::AppendRenderRow().

Referenced by GERBER_LAYER_WIDGET::ReFillRender().

290  {
291  for( int row=0; row<aRowCount; ++row )
292  AppendRenderRow( aRowsArray[row] );
293  }
void AppendRenderRow(const ROW &aRow)
Function AppendRenderRow appends a new row in the render portion of the widget.
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 122 of file class_pcb_layer_widget.cpp.

References EDA_DRAW_FRAME::IsGalCanvasActive(), and myframe.

123 {
124  return myframe->IsGalCanvasActive();
125 }
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:809
void LAYER_WIDGET::ClearLayerRows ( )
inherited

Function ClearLayerRows empties out the layer rows.

Definition at line 506 of file layer_widget.cpp.

References LAYER_WIDGET::m_LayersFlexGridSizer.

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

507 {
508  m_LayersFlexGridSizer->Clear( true );
509 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:112
void LAYER_WIDGET::ClearRenderRows ( )
inherited

Function ClearRenderRows empties out the render rows.

Definition at line 520 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer.

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

521 {
522  m_RenderFlexGridSizer->Clear( true );
523 }
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:115
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 67 of file layer_widget.cpp.

References LYR_COLUMN_COUNT.

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

68 {
69  int id = aId * LYR_COLUMN_COUNT + aColumn;
70  return id;
71 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
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 201 of file layer_widget.cpp.

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

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

202 {
203  int count = GetLayerRowCount();
204 
205  for( int row = 0; row < count; ++row )
206  {
207  // column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
208  wxWindow* w = getLayerComp( row, 0 );
209  wxASSERT( w );
210 
211  if( aLayer == getDecodedId( w->GetId() ))
212  return row;
213  }
214 
215  return -1;
216 }
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 230 of file layer_widget.cpp.

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

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

231 {
232  int count = GetRenderRowCount();
233 
234  for( int row = 0; row < count; ++row )
235  {
236  // column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
237  wxWindow* w = getRenderComp( row, 0 );
238  wxASSERT( w );
239 
240  if( aId == getDecodedId( w->GetId() ))
241  return row;
242  }
243 
244  return -1;
245 }
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
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 429 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().

430 {
431  // size of m_LayerScrolledWindow --------------
432  wxArrayInt widths = m_LayersFlexGridSizer->GetColWidths();
433  int totWidth = 0;
434 
435  if( widths.GetCount() )
436  {
437  for( int i = 0; i < LYR_COLUMN_COUNT; ++i )
438  {
439  totWidth += widths[i] + m_LayersFlexGridSizer->GetHGap();
440  // printf("widths[%d]:%d\n", i, widths[i] );
441  }
442  }
443 
444  // Account for the parent's frame:
445  totWidth += 10;
446 
447 
448  /* The minimum height is a small size to properly force computation
449  * of the panel's scrollbars (otherwise it will assume it *has* all
450  * this space) */
451  unsigned totHeight = 32;
452 
453  wxSize layerz( totWidth, totHeight );
454 
455  layerz += m_LayerPanel->GetWindowBorderSize();
456 
457 
458  // size of m_RenderScrolledWindow --------------
459  widths = m_RenderFlexGridSizer->GetColWidths();
460  totWidth = 0;
461 
462  if( widths.GetCount() )
463  {
464  for( int i = 0; i < RND_COLUMN_COUNT; ++i )
465  {
466  totWidth += widths[i] + m_RenderFlexGridSizer->GetHGap();
467  // printf("widths[%d]:%d\n", i, widths[i] );
468  }
469  }
470  // account for the parent's frame, this one has void space of 10 PLUS a border:
471  totWidth += 20;
472 
473  // For totHeight re-use the previous small one
474  wxSize renderz( totWidth, totHeight );
475 
476  renderz += m_RenderingPanel->GetWindowBorderSize();
477 
478  wxSize clientz( std::max(renderz.x,layerz.x), std::max(renderz.y,layerz.y) );
479 
480  return clientz;
481 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:112
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:48
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:115
wxPanel * m_RenderingPanel
Definition: layer_widget.h:113
#define max(a, b)
Definition: auxiliary.h:86
wxPanel * m_LayerPanel
Definition: layer_widget.h:110
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 74 of file layer_widget.cpp.

References LYR_COLUMN_COUNT.

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

75 {
76  int id = aControlId / LYR_COLUMN_COUNT; // rounding is OK.
77  return id;
78 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
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 611 of file layer_widget.cpp.

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

612 {
613  int row = findLayerRow( aLayer );
614  if( row >= 0 )
615  {
616  int col = 1; // bitmap button is column 1
617  wxBitmapButton* bmb = (wxBitmapButton*) getLayerComp( row, col );
618  wxASSERT( bmb );
619 
620  wxString colorTxt = bmb->GetName();
621  return ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) );
622  }
623 
624  return COLOR4D::UNSPECIFIED; // it's caller fault, gave me a bad layer
625 }
EDA_COLOR_T ColorFromInt(int aColor)
Checked cast. Use only when necessary (usually I/O)
Definition: colors.h:81
int findLayerRow(LAYER_NUM aLayer) const
Function findLayerRow returns the row index that aLayer resides in, or -1 if not found.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
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 190 of file layer_widget.cpp.

References LYR_COLUMN_COUNT, and LAYER_WIDGET::m_LayersFlexGridSizer.

Referenced by LAYER_WIDGET::findLayerRow(), LAYER_WIDGET::GetLayerColor(), LAYER_WIDGET::GetSelectedLayer(), GERBER_LAYER_WIDGET::installRightLayerClickHandler(), installRightLayerClickHandler(), LAYER_WIDGET::IsLayerVisible(), LAYER_WIDGET::OnLeftDownLayers(), GERBER_LAYER_WIDGET::onPopupSelection(), onPopupSelection(), ReFill(), LAYER_WIDGET::SelectLayerRow(), LAYER_WIDGET::SetLayerColor(), LAYER_WIDGET::SetLayerVisible(), SyncLayerVisibilities(), and LAYER_WIDGET::UpdateLayerIcons().

191 {
192  unsigned ndx = aRow * LYR_COLUMN_COUNT + aColumn;
193 
194  if( ndx < m_LayersFlexGridSizer->GetChildren().GetCount() )
195  return m_LayersFlexGridSizer->GetChildren()[ndx]->GetWindow();
196 
197  return NULL;
198 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:112
int LAYER_WIDGET::GetLayerRowCount ( ) const
inherited

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

Definition at line 484 of file layer_widget.cpp.

References LYR_COLUMN_COUNT, and LAYER_WIDGET::m_LayersFlexGridSizer.

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

485 {
486  int controlCount = m_LayersFlexGridSizer->GetChildren().GetCount();
487  return controlCount / LYR_COLUMN_COUNT;
488 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:112
wxWindow * LAYER_WIDGET::getRenderComp ( int  aRow,
int  aColumn 
) const
protectedinherited

Definition at line 219 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

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

220 {
221  int ndx = aRow * RND_COLUMN_COUNT + aColumn;
222 
223  if( (unsigned) ndx < m_RenderFlexGridSizer->GetChildren().GetCount() )
224  return m_RenderFlexGridSizer->GetChildren()[ndx]->GetWindow();
225 
226  return NULL;
227 }
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:48
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:115
int LAYER_WIDGET::GetRenderRowCount ( ) const
inherited

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

Definition at line 491 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

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

492 {
493  int controlCount = m_RenderFlexGridSizer->GetChildren().GetCount();
494  return controlCount / RND_COLUMN_COUNT;
495 }
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:48
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:115
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 642 of file layer_widget.cpp.

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

643 {
644  int row = findRenderRow( aId );
645 
646  if( row >= 0 )
647  {
648  int col = 1; // checkbox is column 1
649  wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
650  wxASSERT( cb );
651  return cb->GetValue();
652  }
653 
654  return false; // the value of a non-existent row
655 }
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 562 of file layer_widget.cpp.

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

563 {
564  wxWindow* w = getLayerComp( m_CurrentRow, 0 );
565  if( w )
566  return getDecodedId( w->GetId() );
567 
568  return UNDEFINED_LAYER;
569 }
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:118
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 248 of file layer_widget.cpp.

References alternativeRowIcons, LAYER_WIDGET::AreArbitraryColorsAllowed(), LAYER_WIDGET::ROW::color, COLUMN_COLOR_LYR_CB, COLUMN_COLOR_LYRNAME, COLUMN_COLORBM, COLUMN_ICON_ACTIVE, defaultRowIcons, LAYER_WIDGET::encodeId(), LAYER_WIDGET::ROW::id, LYR_COLUMN_COUNT, LAYER_WIDGET::m_LayerScrolledWindow, LAYER_WIDGET::m_LayersFlexGridSizer, LAYER_WIDGET::m_PointSize, OFF, LAYER_WIDGET::OnLayerCheckBox(), LAYER_WIDGET::OnLayerSwatchChanged(), LAYER_WIDGET::OnLeftDownLayers(), LAYER_WIDGET::ROW::rowName, shrinkFont(), LAYER_WIDGET::ROW::state, LAYER_WIDGET::ROW::tooltip, and LAYER_WIDGET::useAlternateBitmap().

Referenced by LAYER_WIDGET::AppendLayerRow().

249 {
250  wxASSERT( aRow >= 0 );
251 
252  int col;
253  int index = aRow * LYR_COLUMN_COUNT;
254  const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
255 
256  auto& iconProvider = useAlternateBitmap(aRow) ? alternativeRowIcons : defaultRowIcons;
257 
258  // column 0
259  col = COLUMN_ICON_ACTIVE;
260  auto sbm = new INDICATOR_ICON( m_LayerScrolledWindow, iconProvider,
262  encodeId( col, aSpec.id ) );
263  sbm->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
264  m_LayersFlexGridSizer->wxSizer::Insert( index+col, sbm, 0, flags );
265 
266  // column 1 (COLUMN_COLORBM)
267  col = COLUMN_COLORBM;
268 
269  auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
271  bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
272  bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
273  bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) );
274  m_LayersFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
275 
276  // column 2 (COLUMN_COLOR_LYR_CB)
277  col = COLUMN_COLOR_LYR_CB;
278  wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow, encodeId( col, aSpec.id ), wxEmptyString );
279  cb->SetValue( aSpec.state );
280  cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnLayerCheckBox, this );
281  cb->SetToolTip( _( "Enable this for visibility" ) );
282  m_LayersFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
283 
284  // column 3 (COLUMN_COLOR_LYRNAME)
285  col = COLUMN_COLOR_LYRNAME;
286  wxStaticText* st = new wxStaticText( m_LayerScrolledWindow, encodeId( col, aSpec.id ), aSpec.rowName );
287  shrinkFont( st, m_PointSize );
288  st->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
289  st->SetToolTip( aSpec.tooltip );
290  m_LayersFlexGridSizer->wxSizer::Insert( index+col, st, 0, flags );
291 }
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:53
void OnLeftDownLayers(wxMouseEvent &event)
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
#define OFF
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:112
virtual bool useAlternateBitmap(int aRow)
Virtual Function useAlternateBitmap.
Definition: layer_widget.h:129
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:50
#define COLUMN_COLORBM
Definition: layer_widget.h:51
static ROW_ICON_PROVIDER alternativeRowIcons(true)
virtual bool AreArbitraryColorsAllowed()
Subclasses can override this to provide logic for allowing arbitrary color selection via wxColourPick...
Definition: layer_widget.h:135
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:111
static ROW_ICON_PROVIDER defaultRowIcons(false)
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:52
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.
void LAYER_WIDGET::insertRenderRow ( int  aRow,
const ROW aSpec 
)
protectedinherited

Definition at line 294 of file layer_widget.cpp.

References LAYER_WIDGET::AreArbitraryColorsAllowed(), LAYER_WIDGET::ROW::changeable, LAYER_WIDGET::ROW::color, LAYER_WIDGET::encodeId(), LAYER_WIDGET::ROW::id, LAYER_WIDGET::m_PointSize, LAYER_WIDGET::m_RenderFlexGridSizer, LAYER_WIDGET::m_RenderScrolledWindow, LAYER_WIDGET::OnRenderCheckBox(), LAYER_WIDGET::OnRenderSwatchChanged(), RND_COLUMN_COUNT, LAYER_WIDGET::ROW::rowName, shrinkFont(), LAYER_WIDGET::ROW::state, and LAYER_WIDGET::ROW::tooltip.

Referenced by LAYER_WIDGET::AppendRenderRow().

295 {
296  wxASSERT( aRow >= 0 );
297 
298  int col;
299  int index = aRow * RND_COLUMN_COUNT;
300  const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
301 
302  // column 0
303  col = 0;
304  if( aSpec.color != COLOR4D::UNSPECIFIED )
305  {
306  auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
308  bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
309  bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
310  m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
311 
312  // could add a left click handler on the color button that toggles checkbox.
313  }
314  else // == -1, no color selection wanted
315  {
316  // need a place holder within the sizer to keep grid full.
317  wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, encodeId( col, aSpec.id ) );
318  m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
319  }
320 
321  // column 1
322  col = 1;
323  wxCheckBox* cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ),
324  aSpec.rowName, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
325  shrinkFont( cb, m_PointSize );
326  cb->SetValue( aSpec.state );
327  cb->Enable( aSpec.changeable );
328  cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
329  cb->SetToolTip( aSpec.tooltip );
330  m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
331 }
wxScrolledWindow * m_RenderScrolledWindow
Definition: layer_widget.h:114
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:48
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:115
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...
virtual bool AreArbitraryColorsAllowed()
Subclasses can override this to provide logic for allowing arbitrary color selection via wxColourPick...
Definition: layer_widget.h:135
void OnRenderSwatchChanged(wxCommandEvent &aEvent)
Function OnRenderSwatchChanged Called when user has changed the swatch color of a render entry...
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.

Definition at line 148 of file class_pcb_layer_widget.cpp.

References LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), LYR_COLUMN_COUNT, and onRightDownLayers().

Referenced by ReFill().

149 {
150  int rowCount = GetLayerRowCount();
151 
152  for( int row=0; row < rowCount; ++row )
153  {
154  for( int col=0; col<LYR_COLUMN_COUNT; ++col )
155  {
156  wxWindow* w = getLayerComp( row, col );
157 
158  w->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler(
159  PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
160  }
161  }
162 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
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 128 of file class_pcb_layer_widget.cpp.

References DIM.

Referenced by ReFillRender(), and SyncRenderStates().

129 {
130  for( unsigned ii = 0; ii < DIM( s_allowed_in_FpEditor ); ii++ )
131  if( s_allowed_in_FpEditor[ii] == aId )
132  return true;
133 
134  return false;
135 }
#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 138 of file class_pcb_layer_widget.cpp.

References LSET::AllTechMask().

Referenced by OnLayerSelect(), and ReFill().

139 {
140  static LSET allowed = LSET::AllTechMask();
141  // Currently not in use because putting a graphic item on a copper layer
142  // is not currently supported by DRC.
143  // allowed.set( F_Cu ).set( B_Cu );
144  return allowed.test( aLayer );
145 }
static LSET AllTechMask()
Function AllTechMask returns a mask holding all technical layers (no CU layer) on both side...
Definition: lset.cpp:709
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 584 of file layer_widget.cpp.

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

Referenced by GERBVIEW_FRAME::IsLayerVisible().

585 {
586  int row = findLayerRow( aLayer );
587  if( row >= 0 )
588  {
589  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
590  wxASSERT( cb );
591  return cb->GetValue();
592  }
593  return false;
594 }
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:52
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 148 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::insertLayerRow().

149 {
150  wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
151  LAYER_NUM layer = getDecodedId( eventSource->GetId() );
152  OnLayerVisible( layer, eventSource->IsChecked() );
153  passOnFocus();
154 }
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 546 of file class_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, EDA_DRAW_PANEL::Refresh(), COLORS_DESIGN_SETTINGS::SetLayerColor(), PCB_BASE_FRAME::Settings(), ToLAYER_ID(), and KIGFX::VIEW::UpdateLayerColor().

547 {
548  // Avoid setting the alpha channel, when we are in legacy mode,
549  // because in legacy mode the alpha channel is not used, but changing it
550  // destroys the GAL color setup
551  if( !myframe->IsGalCanvasActive() )
552  {
553  COLOR4D oldColor = myframe->Settings().Colors().GetLayerColor( ToLAYER_ID( aLayer ) );
554  aColor.a = oldColor.a;
555  }
556 
557  myframe->Settings().Colors().SetLayerColor( ToLAYER_ID( aLayer ), aColor );
558 
559  if( myframe->IsGalCanvasActive() )
560  {
561  KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
563  view->UpdateLayerColor( aLayer );
564  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
565  }
566 
567  myframe->GetCanvas()->Refresh();
568 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
PCB_BASE_FRAME * myframe
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer which is one of the layer indices given in pcbstruct...
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
double a
Alpha component.
Definition: color4d.h:289
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:809
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:656
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:817
Class VIEW.
Definition: view.h:58
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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 571 of file class_pcb_layer_widget.cpp.

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

572 {
573  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
574  // false from this function.
575  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
576 
577  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
578  return false;
579 
580  myframe->SetActiveLayer( layer );
582 
584  OnLayerSelected();
585  else if( displ_opts->m_ContrastModeDisplay )
586  myframe->GetCanvas()->Refresh();
587 
588  return true;
589 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
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...
PCB_LAYER_ID
A quick note on layer IDs:
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
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 592 of file class_pcb_layer_widget.cpp.

References ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, m_alwaysShowActiveCopperLayer, and onPopupSelection().

Referenced by OnLayerSelect().

593 {
595  return false;
596 
597  // postprocess after an active layer selection
598  // ensure active layer visible
599  wxCommandEvent event;
601  onPopupSelection( event );
602 
603  return true;
604 }
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 129 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::insertLayerRow().

130 {
131  auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
132 
133  COLOR4D newColor = eventSource->GetSwatchColor();
134 
135  LAYER_NUM layer = getDecodedId( eventSource->GetId() );
136 
137  // tell the client code.
138  OnLayerColorChange( layer, newColor );
139 
140  // notify others
141  wxCommandEvent event( EVT_LAYER_COLOR_CHANGE );
142  wxPostEvent( this, event );
143 
144  passOnFocus();
145 }
static const wxEventType EVT_LAYER_COLOR_CHANGE
Definition: layer_widget.h:105
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 607 of file class_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, EDA_DRAW_PANEL::Refresh(), KIGFX::VIEW::SetLayerVisible(), and BOARD::SetVisibleLayers().

Referenced by onPopupSelection().

608 {
609  BOARD* brd = myframe->GetBoard();
610 
611  LSET visibleLayers = brd->GetVisibleLayers();
612 
613  visibleLayers.set( aLayer, isVisible );
614 
615  brd->SetVisibleLayers( visibleLayers );
616 
617  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
618 
619  if( galCanvas )
620  galCanvas->GetView()->SetLayerVisible( aLayer, isVisible );
621 
622  if( isFinal )
623  myframe->GetCanvas()->Refresh();
624 }
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
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
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:817
void LAYER_WIDGET::OnLeftDownLayers ( wxMouseEvent &  event)
protectedinherited

Definition at line 81 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::insertLayerRow().

82 {
83  int row;
84  LAYER_NUM layer;
85 
86  wxWindow* eventSource = (wxWindow*) event.GetEventObject();
87 
88  // if mouse event is coming from the m_LayerScrolledWindow and not one
89  // of its children, we have to find the row manually based on y coord.
90  if( eventSource == m_LayerScrolledWindow )
91  {
92  int y = event.GetY();
93 
94  wxArrayInt heights = m_LayersFlexGridSizer->GetRowHeights();
95 
96  int height = 0;
97 
98  int rowCount = GetLayerRowCount();
99  for( row = 0; row<rowCount; ++row )
100  {
101  if( y < height + heights[row] )
102  break;
103 
104  height += heights[row];
105  }
106 
107  if( row >= rowCount )
108  row = rowCount - 1;
109 
110  layer = getDecodedId( getLayerComp( row, 0 )->GetId() );
111  }
112 
113  else
114  {
115  // all nested controls on a given row will have their ID encoded with
116  // encodeId(), and the corresponding decoding is getDecodedId()
117  int id = eventSource->GetId();
118  layer = getDecodedId( id );
119  row = findLayerRow( layer );
120  }
121 
122  if( OnLayerSelect( layer ) ) // if client allows this change.
123  SelectLayerRow( row );
124 
125  passOnFocus();
126 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:112
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:111
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 214 of file class_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().

215 {
216  int rowCount;
217  int menuId = event.GetId();
218  bool visible;
219  bool force_active_layer_visible;
220 
222  force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ||
224 
225  switch( menuId )
226  {
227 
228  case ID_SHOW_NO_LAYERS:
229  case ID_SHOW_ALL_LAYERS:
230  {
231  visible = ( menuId == ID_SHOW_ALL_LAYERS );
232  rowCount = GetLayerRowCount();
233 
234  for( int row=0; row<rowCount; ++row )
235  {
236  bool isLast;
237  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
238  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
239  cb->SetValue( visible );
240 
241  isLast = row == rowCount-1;
242 
243  OnLayerVisible( layer, visible, isLast );
244 
245  if( isLast )
246  break;
247  }
248  break;
249  }
250 
257  {
258 
259  // Search the last copper layer row index:
260  int lastCu = -1;
261  rowCount = GetLayerRowCount();
262  for( int row = rowCount-1; row>=0; --row )
263  {
264  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
265  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
266 
267  if( IsCopperLayer( layer ) )
268  {
269  lastCu = row;
270  break;
271  }
272  }
273 
274  // Enable/disable the copper layers visibility:
275  int startrow = 0;
276 
277  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
278  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
279  {
280  startrow = lastCu + 1;
281  }
282 
283  for( int row = startrow; row<rowCount; ++row )
284  {
285  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
286  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
287 
288  visible = ( ( menuId == ID_SHOW_ALL_COPPER_LAYERS ) || ( menuId == ID_SHOW_ALL_NON_COPPER ) );
289 
290  if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
291  visible = true;
292 
293  cb->SetValue( visible );
294 
295  bool isLastLayer = (row == lastCu);
296 
297  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
298  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
299  {
300  isLastLayer = false;
301  }
302  OnLayerVisible( layer, visible, isLastLayer );
303 
304  if( isLastLayer )
305  break;
306  }
307  break;
308  }
309 
310  case ID_SHOW_ALL_FRONT:
311  {
312  visible = false;
313  rowCount = GetLayerRowCount();
314 
315  for( int row=0; row<rowCount; ++row )
316  {
317  bool isLast;
318  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
319  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
320  isLast = ( row == rowCount-1 );
321 
322  if( layer == F_Paste || layer == F_SilkS ||
323  layer == F_Mask || layer == F_Cu ||
324  layer == F_Fab || layer == F_CrtYd || layer == Edge_Cuts )
325  {
326  visible = true;
327  }
328  else
329  {
330  visible = false;
331  }
332 
333  cb->SetValue( visible );
334  OnLayerVisible( layer, visible, isLast );
335 
336  if( isLast )
337  break;
338  }
339  break;
340  }
341  case ID_SHOW_ALL_BACK:
342  {
343  visible = false;
344  rowCount = GetLayerRowCount();
345 
346  for( int row=0; row<rowCount; ++row )
347  {
348  bool isLast;
349  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
350  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
351  isLast = ( row == rowCount-1 );
352 
353  if( layer == B_Paste || layer == B_SilkS ||
354  layer == B_Mask || layer == B_Cu ||
355  layer == B_Fab || layer == B_CrtYd || layer == Edge_Cuts )
356  {
357  visible = true;
358  }
359  else
360  {
361  visible = false;
362  }
363 
364  cb->SetValue( visible );
365  OnLayerVisible( layer, visible, isLast );
366 
367  if( isLast )
368  break;
369  }
370  break;
371  }
372  }
373 }
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.
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:52
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:767
void LAYER_WIDGET::OnRenderCheckBox ( wxCommandEvent &  event)
protectedinherited

Definition at line 172 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::insertRenderRow().

173 {
174  wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
175  LAYER_NUM id = getDecodedId( eventSource->GetId() );
176  OnRenderEnable( id, eventSource->IsChecked() );
177  passOnFocus();
178 }
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 627 of file class_pcb_layer_widget.cpp.

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

628 {
629  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
630 
631  myframe->Settings().Colors().SetItemColor( static_cast<GAL_LAYER_ID>( aId ), aColor );
632 
633  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
634 
635  if( galCanvas && myframe->IsGalCanvasActive() )
636  {
637  KIGFX::VIEW* view = galCanvas->GetView();
639  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
640  view->UpdateLayerColor( aId );
641  galCanvas->Refresh();
642  }
643 
644  myframe->GetCanvas()->Refresh();
645 }
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
Definition: draw_panel.cpp:326
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
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 MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:576
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:809
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
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:656
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:817
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 648 of file class_pcb_layer_widget.cpp.

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

649 {
650  BOARD* brd = myframe->GetBoard();
651  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
652 
653  // The layer visibility status is saved in the board file so set the board modified
654  // state so the user has the option to save the changes.
655  if( brd->IsElementVisible( static_cast<GAL_LAYER_ID>( aId ) ) != isEnabled )
656  myframe->OnModify();
657 
658  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
659 
660  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
661 
662  if( galCanvas && myframe->IsGalCanvasActive() )
663  {
664  if( aId == LAYER_GRID )
665  {
666  galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
668  }
669  else if ( aId == LAYER_RATSNEST )
670  {
671  // don't touch the layers. ratsnest is enabled on per-item basis.
673  galCanvas->GetView()->SetLayerVisible( aId, true );
674  }
675  else
676  galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
677 
678  galCanvas->Refresh();
679  }
680 
681  myframe->GetCanvas()->Refresh();
682 }
bool IsElementVisible(GAL_LAYER_ID LAYER_aPCB) const
Function IsElementVisible tests whether a given element category is visible.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
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:429
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 'dirty' flag.
Definition: view.h:576
void SetElementVisibility(GAL_LAYER_ID LAYER_aPCB, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:809
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
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
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:817
void LAYER_WIDGET::OnRenderSwatchChanged ( wxCommandEvent &  aEvent)
protectedinherited

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

Definition at line 157 of file layer_widget.cpp.

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

Referenced by LAYER_WIDGET::insertRenderRow().

158 {
159  auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
160 
161  COLOR4D newColor = eventSource->GetSwatchColor();
162 
163  LAYER_NUM id = getDecodedId( eventSource->GetId() );
164 
165  // tell the client code.
166  OnRenderColorChange( id, newColor );
167 
168  passOnFocus();
169 }
virtual void OnRenderColorChange(int aId, COLOR4D aColor)=0
Function OnRenderColorChange is called to notify client code whenever the user changes a rendering co...
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::onRightDownLayers ( wxMouseEvent &  event)
protected

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

Definition at line 165 of file class_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, KiBitmap(), and LAYER_WIDGET::passOnFocus().

Referenced by installRightLayerClickHandler(), and PCB_LAYER_WIDGET().

166 {
167  wxMenu menu;
168 
169  // menu text is capitalized:
170  // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
172  _( "Show All Copper Layers" ),
173  KiBitmap( select_layer_pair_xpm ) );
175  _( "Hide All Copper Layers But Active" ),
176  KiBitmap( select_w_layer_xpm ) );
178  _( "Always Hide All Copper Layers But Active" ),
179  KiBitmap( select_w_layer_xpm ) );
181  _( "Hide All Copper Layers" ),
182  KiBitmap( show_no_copper_layers_xpm ) );
183 
184  menu.AppendSeparator();
185 
187  _( "Show All Non Copper Layers" ),
188  KiBitmap( select_w_layer_xpm ) );
190  _( "Hide All Non Copper Layers" ),
191  KiBitmap( show_no_copper_layers_xpm ) );
192 
193  menu.AppendSeparator();
194 
195  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
196  KiBitmap( show_no_layers_xpm ) );
197  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
198  KiBitmap( show_all_layers_xpm ) );
199 
200  menu.AppendSeparator();
201 
202  AddMenuItem( &menu, ID_SHOW_ALL_FRONT, _( "Show All Front Layers" ),
203  KiBitmap( show_no_layers_xpm ) );
204 
205  AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
206  KiBitmap( show_all_layers_xpm ) );
207 
208  PopupMenu( &menu );
209 
210  passOnFocus();
211 }
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:55
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
void LAYER_WIDGET::OnTabChange ( wxNotebookEvent &  event)
protectedinherited

Definition at line 181 of file layer_widget.cpp.

References LAYER_WIDGET::passOnFocus().

Referenced by LAYER_WIDGET::LAYER_WIDGET().

182 {
183 // wxFocusEvent event( wxEVT_SET_FOCUS );
184 // m_FocusOwner->AddPendingEvent( event );
185 
186  passOnFocus(); // does not work in this context, probably because we have receive control here too early.
187 }
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
void LAYER_WIDGET::passOnFocus ( )
protectedinherited
void PCB_LAYER_WIDGET::ReFill ( )

Definition at line 452 of file class_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(), installRightLayerClickHandler(), isLayerAllowedInFpMode(), m_fp_editor_mode, Margin, myframe, and PCB_BASE_FRAME::Settings().

453 {
454  BOARD* brd = myframe->GetBoard();
455  LSET enabled = brd->GetEnabledLayers();
456 
457  ClearLayerRows();
458 
459  wxString dsc;
460 
461  // show all coppers first, with front on top, back on bottom, then technical layers
462  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
463  {
464  PCB_LAYER_ID layer = *cu_stack;
465 
466  switch( layer )
467  {
468  case F_Cu:
469  dsc = _( "Front copper layer" );
470  break;
471 
472  case B_Cu:
473  dsc = _( "Back copper layer" );
474  break;
475 
476  default:
477  dsc = _( "Inner copper layer" );
478  break;
479  }
480 
482  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
483  dsc, true ) );
484 
485  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
486  {
487  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
489  COLUMN_COLORBM )->SetToolTip( wxEmptyString );
490  }
491  }
492 
493 
494  // technical layers are shown in this order:
495  // Because they are static, wxGetTranslation must be explicitly
496  // called for tooltips.
497  static const struct {
498  PCB_LAYER_ID layerId;
499  wxString tooltip;
500  } non_cu_seq[] = {
501  { F_Adhes, _( "Adhesive on board's front" ) },
502  { B_Adhes, _( "Adhesive on board's back" ) },
503  { F_Paste, _( "Solder paste on board's front" ) },
504  { B_Paste, _( "Solder paste on board's back" ) },
505  { F_SilkS, _( "Silkscreen on board's front" ) },
506  { B_SilkS, _( "Silkscreen on board's back" ) },
507  { F_Mask, _( "Solder mask on board's front" ) },
508  { B_Mask, _( "Solder mask on board's back" ) },
509  { Dwgs_User, _( "Explanatory drawings" ) },
510  { Cmts_User, _( "Explanatory comments" ) },
511  { Eco1_User, _( "User defined meaning" ) },
512  { Eco2_User, _( "User defined meaning" ) },
513  { Edge_Cuts, _( "Board's perimeter definition" ) },
514  { Margin, _( "Board's edge setback outline" ) },
515  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
516  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
517  { F_Fab, _( "Footprint assembly on board's front" ) },
518  { B_Fab, _( "Footprint assembly on board's back" ) }
519  };
520 
521  for( unsigned i=0; i<DIM( non_cu_seq ); ++i )
522  {
523  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
524 
525  if( !enabled[layer] )
526  continue;
527 
529  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
530  wxGetTranslation( non_cu_seq[i].tooltip ), true ) );
531 
532  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
533  {
534  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
536  COLUMN_COLORBM )->SetToolTip( wxEmptyString );
537  }
538  }
539 
541 }
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:53
#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:84
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:51
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 installRightLayerClickHandler()
this is for the popup menu, the right click handler has to be installed on every child control within...
void PCB_LAYER_WIDGET::ReFillRender ( )

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

Definition at line 383 of file class_pcb_layer_widget.cpp.

References LAYER_WIDGET::AppendRenderRow(), LAYER_WIDGET::ClearRenderRows(), LAYER_WIDGET::ROW::color, PCB_GENERAL_SETTINGS::Colors(), DIM, PCB_BASE_FRAME::GetBoard(), COLORS_DESIGN_SETTINGS::GetItemColor(), LAYER_WIDGET::ROW::id, isAllowedInFpMode(), BOARD::IsElementVisible(), 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().

384 {
385  BOARD* board = myframe->GetBoard();
386  ClearRenderRows();
387 
388  // Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state.
389  // Because s_render_rows is created static, we must explicitly call
390  // wxGetTranslation for texts which are internationalized (tool tips
391  // and item names)
392  for( unsigned row=0; row<DIM(s_render_rows); ++row )
393  {
394  LAYER_WIDGET::ROW renderRow = s_render_rows[row];
395 
396  if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
397  continue;
398 
399  renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
400  renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
401 
402  if( renderRow.color != COLOR4D::UNSPECIFIED ) // does this row show a color?
403  {
404  // this window frame must have an established BOARD, i.e. after SetBoard()
405  renderRow.color = myframe->Settings().Colors().GetItemColor( static_cast<GAL_LAYER_ID>( renderRow.id ) );
406  }
407 
408  renderRow.state = board->IsElementVisible( static_cast<GAL_LAYER_ID>( renderRow.id ) );
409 
410  AppendRenderRow( renderRow );
411  }
412 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
bool IsElementVisible(GAL_LAYER_ID LAYER_aPCB) const
Function IsElementVisible tests whether a given element category is visible.
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:84
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:89
wxString tooltip
if not empty, use this tooltip on row
Definition: layer_widget.h:90
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:88
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
PCB_GENERAL_SETTINGS & Settings()
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.
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:86
int id
either a layer or "visible element" id
Definition: layer_widget.h:87
void LAYER_WIDGET::SelectLayer ( LAYER_NUM  aLayer)
inherited

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

Definition at line 555 of file layer_widget.cpp.

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

Referenced by GERBVIEW_FRAME::setActiveLayer(), and GERBVIEW_FRAME::syncLayerWidget().

556 {
557  int row = findLayerRow( aLayer );
558  SelectLayerRow( row );
559 }
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 526 of file layer_widget.cpp.

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

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

527 {
528  // enable the layer tab at index 0
529  m_notebook->SetSelection( 0 );
530 
531  INDICATOR_ICON* oldIndicator = (INDICATOR_ICON*) getLayerComp( m_CurrentRow, 0 );
532  if( oldIndicator )
534 
535  INDICATOR_ICON* newIndicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
536  if( newIndicator )
537  {
539 
540  // Make sure the desired layer row is visible.
541  // It seems that as of 2.8.2, setting the focus does this.
542  // I don't expect the scrolling to be needed at all because
543  // the minimum window size may end up being established so that the
544  // scroll bars will not be visible.
545  getLayerComp( aRow, 1 )->SetFocus();
546  }
547 
548  m_CurrentRow = aRow;
549 
550  // give the focus back to the app.
551  passOnFocus();
552 }
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
wxAuiNotebook * m_notebook
Definition: layer_widget.h:109
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:118
#define OFF
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 597 of file layer_widget.cpp.

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

598 {
599  int row = findLayerRow( aLayer );
600  if( row >= 0 )
601  {
602  int col = 1; // bitmap button is column 1
603  auto bmb = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
604  wxASSERT( bmb );
605 
606  bmb->SetSwatchColor( aColor, false );
607  }
608 }
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 376 of file class_pcb_layer_widget.cpp.

References LAYER_WIDGET::m_notebook.

Referenced by PCB_LAYER_WIDGET().

377 {
378  m_notebook->SetPageText( 0, _( "Layer" ) );
379  m_notebook->SetPageText( 1, _( "Render" ) );
380 }
wxAuiNotebook * m_notebook
Definition: layer_widget.h:109
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 572 of file layer_widget.cpp.

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

Referenced by SyncLayerVisibilities().

573 {
574  int row = findLayerRow( aLayer );
575  if( row >= 0 )
576  {
577  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
578  wxASSERT( cb );
579  cb->SetValue( isVisible ); // does not fire an event
580  }
581 }
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:52
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 628 of file layer_widget.cpp.

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

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

629 {
630  int row = findRenderRow( aId );
631 
632  if( row >= 0 )
633  {
634  int col = 1; // checkbox is column 1
635  wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
636  wxASSERT( cb );
637  cb->SetValue( isSet ); // does not fire an event
638  }
639 }
int findRenderRow(int aId) const
wxWindow * getRenderComp(int aRow, int aColumn) const
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 432 of file class_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().

433 {
434  BOARD* board = myframe->GetBoard();
435  int count = GetLayerRowCount();
436 
437  for( int row=0; row<count; ++row )
438  {
439  // this utilizes more implementation knowledge than ideal, eventually
440  // add member ROW getRow() or similar to base LAYER_WIDGET.
441 
442  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
443 
444  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
445 
446  // this does not fire a UI event
447  SetLayerVisible( layerId, board->IsLayerVisible( layerId ) );
448  }
449 }
PCB_BASE_FRAME * myframe
BOARD * GetBoard() const
PCB_LAYER_ID
A quick note on layer IDs:
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:50
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:767
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:443
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 415 of file class_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().

416 {
417  BOARD* board = myframe->GetBoard();
418 
419  for( unsigned row=0; row<DIM(s_render_rows); ++row )
420  {
421  int rowId = s_render_rows[row].id;
422 
423  if( m_fp_editor_mode && !isAllowedInFpMode( rowId ) )
424  continue;
425 
426  // this does not fire a UI event
427  SetRenderState( rowId, board->IsElementVisible( static_cast<GAL_LAYER_ID>( rowId ) ) );
428  }
429 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
bool IsElementVisible(GAL_LAYER_ID LAYER_aPCB) const
Function IsElementVisible tests whether a given element category is visible.
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.
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:87
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 668 of file layer_widget.cpp.

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

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

669 {
670  int rowCount = GetLayerRowCount();
671 
672  for( int row = 0; row < rowCount ; row++ )
673  {
675 
676  if( indicator )
677  {
678  auto state = ( row == m_CurrentRow ) ? ROW_ICON_PROVIDER::STATE::ON
680  indicator->SetIndicatorState( state );
681  }
682  }
683 }
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:118
#define OFF
Class representing a row indicator icon for use in places like the layer widget.
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:50
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.
#define ON
void LAYER_WIDGET::UpdateLayouts ( )
inherited

Definition at line 658 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(), and LAYER_WIDGET::AppendRenderRow().

659 {
660  m_LayersFlexGridSizer->Layout();
661  m_RenderFlexGridSizer->Layout();
662  m_LayerPanel->Layout();
663  m_RenderingPanel->Layout();
664  FitInside();
665 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:112
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:115
wxPanel * m_RenderingPanel
Definition: layer_widget.h:113
wxPanel * m_LayerPanel
Definition: layer_widget.h:110
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 129 of file layer_widget.h.

Referenced by LAYER_WIDGET::insertLayerRow().

129 { return false; }

Member Data Documentation

const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType()
staticinherited

Definition at line 105 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 117 of file layer_widget.h.

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

bool PCB_LAYER_WIDGET::m_fp_editor_mode
protected
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 114 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
Initial value:
= {
#define RR
RR( _( "Through Via" ), LAYER_VIA_THROUGH, WHITE, _( "Show through vias" ) ),
RR( _( "Bl/Buried Via" ), LAYER_VIA_BBLIND, WHITE, _( "Show blind or buried vias" ) ),
RR( _( "Micro Via" ), LAYER_VIA_MICROVIA, WHITE, _( "Show micro vias") ),
RR( _( "Non Plated Holes" ),LAYER_NON_PLATED, WHITE, _( "Show non plated holes in specific color") ),
RR( _( "Ratsnest" ), LAYER_RATSNEST, WHITE, _( "Show unconnected nets as a ratsnest") ),
RR( _( "Pads Front" ), LAYER_PAD_FR, WHITE, _( "Show footprint pads on board's front" ) ),
RR( _( "Pads Back" ), LAYER_PAD_BK, WHITE, _( "Show footprint pads on board's back" ) ),
RR( _( "Text Front" ), LAYER_MOD_TEXT_FR, COLOR4D::UNSPECIFIED, _( "Show footprint text on board's front" ) ),
RR( _( "Text Back" ), LAYER_MOD_TEXT_BK, COLOR4D::UNSPECIFIED, _( "Show footprint text on board's back" ) ),
RR( _( "Hidden Text" ), LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
RR( _( "Anchors" ), LAYER_ANCHOR, WHITE, _( "Show footprint and text origins as a cross" ) ),
RR( _( "Grid" ), LAYER_GRID, WHITE, _( "Show the (x,y) grid dots" ) ),
RR( _( "No-Connects" ), LAYER_NO_CONNECTS, COLOR4D::UNSPECIFIED, _( "Show a marker on pads which have no net connected" ) ),
RR( _( "Footprints Front" ),LAYER_MOD_FR, COLOR4D::UNSPECIFIED, _( "Show footprints that are on board's front") ),
RR( _( "Footprints Back" ), LAYER_MOD_BK, COLOR4D::UNSPECIFIED, _( "Show footprints that are on board's back") ),
RR( _( "Values" ), LAYER_MOD_VALUES, COLOR4D::UNSPECIFIED, _( "Show footprint's values") ),
RR( _( "References" ), LAYER_MOD_REFERENCES, COLOR4D::UNSPECIFIED, _( "Show footprint's references") ),
RR( _( "Worksheet" ), LAYER_WORKSHEET, DARKRED, _( "Show worksheet") ),
RR( _( "Cursor" ), LAYER_CURSOR, WHITE, _( "PCB Cursor" ), true, false ),
RR( _( "Aux items" ), LAYER_AUX_ITEMS, WHITE, _( "Auxillary items (rulers, assistants, axes, etc.)" ), true, false ),
RR( _( "Background" ), LAYER_PCB_BACKGROUND, BLACK, _( "PCB Background" ), true, false )
}

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

Definition at line 113 of file class_pcb_layer_widget.h.

Referenced by ReFillRender(), and SyncRenderStates().


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