KiCad PCB EDA Suite
GERBER_LAYER_WIDGET Class Reference

Class GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied into the GERBVIEW_FRAME's data and so we can add a popup menu which is specific to Pcbnew's needs. More...

#include <class_gerbview_layer_widget.h>

Inheritance diagram for GERBER_LAYER_WIDGET:
LAYER_WIDGET

Public Member Functions

 GERBER_LAYER_WIDGET (GERBVIEW_FRAME *aParent, wxWindow *aFocusOwner, int aPointSize=10)
 Constructor. More...
 
void ReFill ()
 
void ReFillRender ()
 Function ReFillRender Rebuild Render for instance after the config is read. 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...
 
void SetLayersManagerTabsText ()
 Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language or to set labels to a non default value. 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 Member Functions

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

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
 

Private Member Functions

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) override
 Virtual Function useAlternateBitmap. More...
 
GERBER_FILE_IMAGE_LISTGetImagesList ()
 

Private Attributes

GERBVIEW_FRAMEmyframe
 
bool m_alwaysShowActiveLayer
 

Detailed Description

Class GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied into the GERBVIEW_FRAME's data and so we can add a popup menu which is specific to Pcbnew's needs.

Definition at line 54 of file class_gerbview_layer_widget.h.

Constructor & Destructor Documentation

GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET ( GERBVIEW_FRAME aParent,
wxWindow *  aFocusOwner,
int  aPointSize = 10 
)

Constructor.

Parameters
aParent: the parent frame
aFocusOwner: the window that has the keyboard focus.
aPointSizeis the font point size to use within the widget. This effectively sets the overal size of the widget via the row height and bitmap button sizes.

Definition at line 53 of file class_gerbview_layer_widget.cpp.

References ID_LAYER_MANAGER_END, ID_LAYER_MANAGER_START, m_alwaysShowActiveLayer, LAYER_WIDGET::m_LayerScrolledWindow, onPopupSelection(), onRightDownLayers(), ReFillRender(), and SetLayersManagerTabsText().

54  :
55  LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
56  myframe( aParent )
57 {
59 
60  ReFillRender();
61 
62  // Update default tabs labels for GerbView
64 
65  //-----<Popup menu>-------------------------------------------------
66  // handle the popup menu over the layer window.
67  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
68  wxMouseEventHandler( GERBER_LAYER_WIDGET::onRightDownLayers ), NULL, this );
69 
70  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
71  // and not m_LayerScrolledWindow->Connect()
73  wxEVT_COMMAND_MENU_SELECTED,
74  wxCommandEventHandler( GERBER_LAYER_WIDGET::onPopupSelection ), NULL, this );
75 
76  // install the right click handler into each control at end of ReFill()
77  // using installRightLayerClickHandler
78 }
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
void SetLayersManagerTabsText()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:109
void onPopupSelection(wxCommandEvent &event)
void ReFillRender()
Function ReFillRender Rebuild Render for instance after the config is read.
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 497 of file layer_widget.cpp.

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

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

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

References LAYER_WIDGET::AppendLayerRow().

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

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

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

512 {
513  int nextRow = GetRenderRowCount();
514  insertRenderRow( nextRow, aRow );
515  UpdateLayouts();
516 }
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 287 of file layer_widget.h.

References LAYER_WIDGET::AppendRenderRow().

Referenced by ReFillRender().

288  {
289  for( int row=0; row<aRowCount; ++row )
290  AppendRenderRow( aRowsArray[row] );
291  }
void AppendRenderRow(const ROW &aRow)
Function AppendRenderRow appends a new row in the render portion of the widget.
virtual bool LAYER_WIDGET::AreArbitraryColorsAllowed ( )
inlineprotectedvirtualinherited

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

Reimplemented in PCB_LAYER_WIDGET.

Definition at line 133 of file layer_widget.h.

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

133 { return false; }
void LAYER_WIDGET::ClearLayerRows ( )
inherited

Function ClearLayerRows empties out the layer rows.

Definition at line 505 of file layer_widget.cpp.

References LAYER_WIDGET::m_LayersFlexGridSizer.

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

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

Function ClearRenderRows empties out the render rows.

Definition at line 519 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer.

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

520 {
521  m_RenderFlexGridSizer->Clear( true );
522 }
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:113
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 428 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().

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

Definition at line 80 of file class_gerbview_layer_widget.cpp.

References GERBER_FILE_IMAGE_LIST::GetImagesList().

Referenced by onPopupSelection(), ReFill(), and useAlternateBitmap().

81 {
83 }
static GERBER_FILE_IMAGE_LIST & GetImagesList()
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 610 of file layer_widget.cpp.

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

611 {
612  int row = findLayerRow( aLayer );
613  if( row >= 0 )
614  {
615  int col = 1; // bitmap button is column 1
616  wxBitmapButton* bmb = (wxBitmapButton*) getLayerComp( row, col );
617  wxASSERT( bmb );
618 
619  wxString colorTxt = bmb->GetName();
620  return ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) );
621  }
622 
623  return COLOR4D::UNSPECIFIED; // it's caller fault, gave me a bad layer
624 }
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(), installRightLayerClickHandler(), PCB_LAYER_WIDGET::installRightLayerClickHandler(), LAYER_WIDGET::IsLayerVisible(), LAYER_WIDGET::OnLeftDownLayers(), onPopupSelection(), PCB_LAYER_WIDGET::onPopupSelection(), PCB_LAYER_WIDGET::ReFill(), LAYER_WIDGET::SelectLayerRow(), LAYER_WIDGET::SetLayerColor(), LAYER_WIDGET::SetLayerVisible(), PCB_LAYER_WIDGET::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:110
int LAYER_WIDGET::GetLayerRowCount ( ) const
inherited

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

Definition at line 483 of file layer_widget.cpp.

References LYR_COLUMN_COUNT, and LAYER_WIDGET::m_LayersFlexGridSizer.

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

484 {
485  int controlCount = m_LayersFlexGridSizer->GetChildren().GetCount();
486  return controlCount / LYR_COLUMN_COUNT;
487 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:110
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:113
int LAYER_WIDGET::GetRenderRowCount ( ) const
inherited

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

Definition at line 490 of file layer_widget.cpp.

References LAYER_WIDGET::m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

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

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

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

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

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

562 {
563  wxWindow* w = getLayerComp( m_CurrentRow, 0 );
564  if( w )
565  return getDecodedId( w->GetId() );
566 
567  return UNDEFINED_LAYER;
568 }
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:116
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:110
virtual bool useAlternateBitmap(int aRow)
Virtual Function useAlternateBitmap.
Definition: layer_widget.h:127
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:133
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:109
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::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->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
328  cb->SetToolTip( aSpec.tooltip );
329  m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
330 }
wxScrolledWindow * m_RenderScrolledWindow
Definition: layer_widget.h:112
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:113
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:133
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 GERBER_LAYER_WIDGET::installRightLayerClickHandler ( )
private

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 129 of file class_gerbview_layer_widget.cpp.

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

Referenced by ReFill().

130 {
131  int rowCount = GetLayerRowCount();
132 
133  for( int row=0; row<rowCount; ++row )
134  {
135  for( int col=0; col<LYR_COLUMN_COUNT; ++col )
136  {
137  wxWindow* w = getLayerComp( row, col );
138 
139  w->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler(
141  }
142  }
143 }
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
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.
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 583 of file layer_widget.cpp.

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

Referenced by GERBVIEW_FRAME::IsLayerVisible().

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

References EDA_DRAW_FRAME::GetCanvas(), GERBVIEW_FRAME::m_SelLayerBox, myframe, EDA_DRAW_PANEL::Refresh(), LAYER_BOX_SELECTOR::ResyncBitmapOnly(), and GERBVIEW_FRAME::SetLayerColor().

256 {
257  myframe->SetLayerColor( aLayer, aColor );
259  myframe->GetCanvas()->Refresh();
260 }
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
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void SetLayerColor(int aLayer, COLOR4D aColor)
Function SetLayerColor changes a layer color for any valid layer.
bool GERBER_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 262 of file class_gerbview_layer_widget.cpp.

References GERBVIEW_FRAME::getActiveLayer(), EDA_DRAW_FRAME::GetCanvas(), myframe, OnLayerSelected(), EDA_DRAW_PANEL::Refresh(), GERBVIEW_FRAME::setActiveLayer(), and GERBVIEW_FRAME::syncLayerBox().

263 {
264  // the layer change from the GERBER_LAYER_WIDGET can be denied by returning
265  // false from this function.
266  int layer = myframe->getActiveLayer( );
267  myframe->setActiveLayer( aLayer, false );
269 
270  if( layer != myframe->getActiveLayer( ) )
271  {
272  if( ! OnLayerSelected() )
273  myframe->GetCanvas()->Refresh();
274  }
275 
276  return true;
277 }
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
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
void setActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function setActiveLayer will change the currently active layer to aLayer and also update the GERBER_L...
int getActiveLayer()
Function getActiveLayer returns the active layer.
bool OnLayerSelected()
Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwa...
bool GERBER_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 220 of file class_gerbview_layer_widget.cpp.

References ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE, m_alwaysShowActiveLayer, and onPopupSelection().

Referenced by GERBVIEW_FRAME::OnHotKey(), OnLayerSelect(), and GERBVIEW_FRAME::OnSelectActiveLayer().

221 {
223  return false;
224 
225  // postprocess after active layer selection
226  // ensure active layer visible
227  wxCommandEvent event;
229  onPopupSelection( event );
230  return true;
231 }
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:103
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 GERBER_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 279 of file class_gerbview_layer_widget.cpp.

References EDA_DRAW_FRAME::GetCanvas(), GERBVIEW_FRAME::GetVisibleLayers(), myframe, EDA_DRAW_PANEL::Refresh(), and GERBVIEW_FRAME::SetVisibleLayers().

280 {
281  long visibleLayers = myframe->GetVisibleLayers();
282 
283  if( isVisible )
284  visibleLayers |= 1 << aLayer;
285  else
286  visibleLayers &= ~( 1 << aLayer );
287 
288  myframe->SetVisibleLayers( visibleLayers );
289 
290  if( isFinal )
291  myframe->GetCanvas()->Refresh();
292 }
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
void SetVisibleLayers(long aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
long GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
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:110
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:109
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 GERBER_LAYER_WIDGET::onPopupSelection ( wxCommandEvent &  event)
private

Definition at line 171 of file class_gerbview_layer_widget.cpp.

References COLUMN_COLOR_LYR_CB, GERBVIEW_FRAME::getActiveLayer(), EDA_DRAW_FRAME::GetCanvas(), LAYER_WIDGET::getDecodedId(), GetImagesList(), LAYER_WIDGET::getLayerComp(), LAYER_WIDGET::GetLayerRowCount(), ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE, ID_SHOW_ALL_LAYERS, ID_SHOW_NO_LAYERS, ID_SHOW_NO_LAYERS_BUT_ACTIVE, ID_SORT_GBR_LAYERS, m_alwaysShowActiveLayer, myframe, GERBVIEW_FRAME::ReFillLayerWidget(), EDA_DRAW_PANEL::Refresh(), GERBVIEW_FRAME::SetVisibleLayers(), GERBER_FILE_IMAGE_LIST::SortImagesByZOrder(), and GERBVIEW_FRAME::syncLayerBox().

Referenced by GERBER_LAYER_WIDGET(), and OnLayerSelected().

172 {
173  int rowCount;
174  int menuId = event.GetId();
175  bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;
176  long visibleLayers = 0;
177  bool force_active_layer_visible;
178 
180  force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE ||
182 
183  switch( menuId )
184  {
185  case ID_SHOW_ALL_LAYERS:
186  case ID_SHOW_NO_LAYERS:
189  rowCount = GetLayerRowCount();
190  for( int row=0; row < rowCount; ++row )
191  {
192  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
193  int layer = getDecodedId( cb->GetId() );
194  bool loc_visible = visible;
195 
196  if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) )
197  loc_visible = true;
198 
199  cb->SetValue( loc_visible );
200 
201  if( loc_visible )
202  visibleLayers |= 1 << row;
203  else
204  visibleLayers &= ~( 1 << row );
205  }
206 
207  myframe->SetVisibleLayers( visibleLayers );
208  myframe->GetCanvas()->Refresh();
209  break;
210 
211  case ID_SORT_GBR_LAYERS:
214  myframe->syncLayerBox( true );
215  myframe->GetCanvas()->Refresh();
216  break;
217  }
218 }
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
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
void SortImagesByZOrder()
Sort loaded images by Z order priority, if they have the X2 FileFormat info (SortImagesByZOrder updat...
GERBER_FILE_IMAGE_LIST * GetImagesList()
void SetVisibleLayers(long aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
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.
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:52
int getActiveLayer()
Function getActiveLayer returns the active layer.
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading new ...
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 GERBER_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 294 of file class_gerbview_layer_widget.cpp.

References EDA_DRAW_FRAME::GetCanvas(), myframe, EDA_DRAW_PANEL::Refresh(), and GERBVIEW_FRAME::SetVisibleElementColor().

295 {
297  myframe->GetCanvas()->Refresh();
298 }
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
void SetVisibleElementColor(GERBVIEW_LAYER_ID aItemIdVisible, COLOR4D aColor)
GERBVIEW_LAYER_ID
GerbView draw layers.
void GERBER_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 300 of file class_gerbview_layer_widget.cpp.

References EDA_DRAW_FRAME::GetCanvas(), myframe, EDA_DRAW_PANEL::Refresh(), and GERBVIEW_FRAME::SetElementVisibility().

301 {
302  myframe->SetElementVisibility( (GERBVIEW_LAYER_ID) aId, isEnabled );
303  myframe->GetCanvas()->Refresh();
304 }
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
GERBVIEW_LAYER_ID
GerbView draw layers.
void SetElementVisibility(GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
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 GERBER_LAYER_WIDGET::onRightDownLayers ( wxMouseEvent &  event)
private

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

Definition at line 146 of file class_gerbview_layer_widget.cpp.

References ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE, ID_SHOW_ALL_LAYERS, ID_SHOW_NO_LAYERS, ID_SHOW_NO_LAYERS_BUT_ACTIVE, ID_SORT_GBR_LAYERS, and LAYER_WIDGET::passOnFocus().

Referenced by GERBER_LAYER_WIDGET(), and installRightLayerClickHandler().

147 {
148  wxMenu menu;
149 
150  // Remember: menu text is capitalized (see our rules_for_capitalization_in_Kicad_UI.txt)
151  menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_LAYERS,
152  _("Show All Layers") ) );
153 
154  menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS_BUT_ACTIVE,
155  _( "Hide All Layers But Active" ) ) );
156 
157  menu.Append( new wxMenuItem( &menu, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
158  _( "Always Hide All Layers But Active" ) ) );
159 
160  menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS,
161  _( "Hide All Layers" ) ) );
162 
163  menu.AppendSeparator();
164  menu.Append( new wxMenuItem( &menu, ID_SORT_GBR_LAYERS,
165  _( "Sort Layers if X2 Mode" ) ) );
166  PopupMenu( &menu );
167 
168  passOnFocus();
169 }
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 GERBER_LAYER_WIDGET::ReFill ( )

Definition at line 234 of file class_gerbview_layer_widget.cpp.

References LAYER_WIDGET::AppendLayerRow(), LAYER_WIDGET::ClearLayerRows(), GERBER_DRAWLAYERS_COUNT, GERBER_FILE_IMAGE_LIST::GetDisplayName(), GetImagesList(), GERBVIEW_FRAME::GetLayerColor(), installRightLayerClickHandler(), and myframe.

Referenced by GERBVIEW_FRAME::ReFillLayerWidget().

235 {
236  Freeze();
237 
238  ClearLayerRows();
239 
240  for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
241  {
242  wxString msg = GetImagesList()->GetDisplayName( layer );
243 
244  AppendLayerRow( LAYER_WIDGET::ROW( msg, layer,
245  myframe->GetLayerColor( layer ), wxEmptyString, true ) );
246  }
247 
248  Thaw();
249 
251 }
void installRightLayerClickHandler()
this is for the popup menu, the right click handler has to be installed on every child control within...
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:84
const wxString GetDisplayName(int aIdx, bool aNameOnly=false)
GERBER_FILE_IMAGE_LIST * GetImagesList()
void ClearLayerRows()
Function ClearLayerRows empties out the layer rows.
#define GERBER_DRAWLAYERS_COUNT
void AppendLayerRow(const ROW &aRow)
Function AppendLayerRow appends a new row in the layer portion of the widget.
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
void GERBER_LAYER_WIDGET::ReFillRender ( )

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

Definition at line 96 of file class_gerbview_layer_widget.cpp.

References LAYER_WIDGET::AppendRenderRows(), LAYER_WIDGET::ClearRenderRows(), color, LAYER_WIDGET::ROW::color, DARKGRAY, DIM, GERBVIEW_FRAME::GetVisibleElementColor(), GERBVIEW_FRAME::IsElementVisible(), LAYER_DCODES, LAYER_GERBVIEW_GRID, LAYER_NEGATIVE_OBJECTS, myframe, RR, LAYER_WIDGET::ROW::state, and WHITE.

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

97 {
99 
100  // Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color
101  // is changed before appending to the LAYER_WIDGET. This is an automatic variable
102  // not a static variable, change the color & state after copying from code to renderRows
103  // on the stack.
104  LAYER_WIDGET::ROW renderRows[3] = {
105 
106 #define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width
107 
108  // text id color tooltip checked
109  RR( _( "Grid" ), LAYER_GERBVIEW_GRID, WHITE, _( "Show the (x,y) grid dots" ) ),
110  RR( _( "DCodes" ), LAYER_DCODES, WHITE, _( "Show DCodes identification" ) ),
111  RR( _( "Neg. Obj." ), LAYER_NEGATIVE_OBJECTS, DARKGRAY,
112  _( "Show negative objects in this color" ) ),
113  };
114 
115  for( unsigned row=0; row<DIM(renderRows); ++row )
116  {
117  if( renderRows[row].color != COLOR4D::UNSPECIFIED ) // does this row show a color?
118  {
119  renderRows[row].color = myframe->GetVisibleElementColor(
120  ( GERBVIEW_LAYER_ID )renderRows[row].id );
121  }
122  renderRows[row].state = myframe->IsElementVisible(
123  ( GERBVIEW_LAYER_ID )renderRows[row].id );
124  }
125 
126  AppendRenderRows( renderRows, DIM(renderRows) );
127 }
#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
void ClearRenderRows()
Function ClearRenderRows empties out the render rows.
GERBVIEW_LAYER_ID
GerbView draw layers.
bool state
initial wxCheckBox state
Definition: layer_widget.h:89
COLOR4D color
COLOR4D::UNSPECIFIED if none.
Definition: layer_widget.h:88
#define RR
void AppendRenderRows(const ROW *aRowsArray, int aRowCount)
Function AppendRenderRows appends new rows in the render portion of the widget.
Definition: layer_widget.h:287
COLOR4D GetVisibleElementColor(GERBVIEW_LAYER_ID aItemIdVisible) const
Function GetVisibleElementColor returns the color of a gerber visible element.
bool IsElementVisible(GERBVIEW_LAYER_ID aItemIdVisible) const
Function IsElementVisible tests whether a given element category is visible.
Definition: colors.h:49
void LAYER_WIDGET::SelectLayer ( LAYER_NUM  aLayer)
inherited

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

Definition at line 554 of file layer_widget.cpp.

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

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

555 {
556  int row = findLayerRow( aLayer );
557  SelectLayerRow( row );
558 }
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 525 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().

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

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

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

References LAYER_WIDGET::m_notebook.

Referenced by GERBER_LAYER_WIDGET(), and GERBVIEW_FRAME::ShowChangedLanguage().

87 {
88  m_notebook->SetPageText(0, _("Layer") );
89  m_notebook->SetPageText(1, _("Render") );
90 }
wxAuiNotebook * m_notebook
Definition: layer_widget.h:107
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 571 of file layer_widget.cpp.

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

Referenced by PCB_LAYER_WIDGET::SyncLayerVisibilities().

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

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

668 {
669  int rowCount = GetLayerRowCount();
670 
671  for( int row = 0; row < rowCount ; row++ )
672  {
674 
675  if( indicator )
676  {
677  auto state = ( row == m_CurrentRow ) ? ROW_ICON_PROVIDER::STATE::ON
679  indicator->SetIndicatorState( state );
680  }
681  }
682 }
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:116
#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 657 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().

658 {
659  m_LayersFlexGridSizer->Layout();
660  m_RenderFlexGridSizer->Layout();
661  m_LayerPanel->Layout();
662  m_RenderingPanel->Layout();
663  FitInside();
664 }
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:110
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:113
wxPanel * m_RenderingPanel
Definition: layer_widget.h:111
wxPanel * m_LayerPanel
Definition: layer_widget.h:108
bool GERBER_LAYER_WIDGET::useAlternateBitmap ( int  aRow)
overrideprivatevirtual

Virtual Function useAlternateBitmap.

Returns
true if bitmaps shown in Render layer list are alternate bitmaps, or false if they are "normal" bitmaps

Reimplemented from LAYER_WIDGET.

Definition at line 313 of file class_gerbview_layer_widget.cpp.

References GERBER_FILE_IMAGE_LIST::GetGbrImage(), and GetImagesList().

314 {
315  return GetImagesList()->GetGbrImage( aRow ) != NULL;
316 }
GERBER_FILE_IMAGE_LIST * GetImagesList()
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)

Member Data Documentation

const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType()
staticinherited

Definition at line 103 of file layer_widget.h.

Referenced by LAYER_WIDGET::OnLayerSwatchChanged().

bool GERBER_LAYER_WIDGET::m_alwaysShowActiveLayer
private
int LAYER_WIDGET::m_CurrentRow
protectedinherited
wxWindow* LAYER_WIDGET::m_FocusOwner
protectedinherited

Definition at line 115 of file layer_widget.h.

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

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 112 of file layer_widget.h.

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


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