KiCad PCB EDA Suite
SELECT_COPPER_LAYERS_PAIR_DIALOG Class Reference

Class SELECT_COPPER_LAYERS_PAIR_DIALOG displays a double pcb copper layers list in a dialog, to select a layer pair from these lists. More...

Inheritance diagram for SELECT_COPPER_LAYERS_PAIR_DIALOG:
PCB_LAYER_SELECTOR DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE LAYER_SELECTOR

Public Member Functions

 SELECT_COPPER_LAYERS_PAIR_DIALOG (wxWindow *aParent, BOARD *aPcb, PCB_LAYER_ID aFrontLayer, PCB_LAYER_ID aBackLayer)
 
void GetLayerPair (PCB_LAYER_ID &aFrontLayer, PCB_LAYER_ID &aBackLayer)
 
bool SetLayersOrdered (bool value)
 
bool SetLayersHotkeys (bool value)
 

Public Attributes

struct EDA_HOTKEY_CONFIGm_hotkeys
 

Protected Member Functions

bool IsLayerEnabled (LAYER_NUM aLayer) const override
 
COLOR4D GetLayerColor (LAYER_NUM aLayer) const override
 
wxString GetLayerName (LAYER_NUM aLayer) const override
 
void SetBitmapLayer (wxBitmap &aLayerbmp, LAYER_NUM aLayer)
 
virtual void OnOKClick (wxCommandEvent &event)
 

Protected Attributes

BOARDm_brd
 
bool m_layerhotkeys
 
wxStaticText * m_staticTextTopLayer
 
wxGrid * m_leftGridLayers
 
wxStaticText * m_staticTextBottomLayer
 
wxGrid * m_rightGridLayers
 
wxStaticLine * m_staticline1
 
wxStdDialogButtonSizer * m_sdbSizer
 
wxButton * m_sdbSizerOK
 
wxButton * m_sdbSizerCancel
 

Private Member Functions

void OnLeftGridCellClick (wxGridEvent &event) override
 
void OnRightGridCellClick (wxGridEvent &event) override
 
void OnOkClick (wxCommandEvent &event)
 
void OnCancelClick (wxCommandEvent &event) override
 
void buildList ()
 
void SetGridCursor (wxGrid *aGrid, int aRow, bool aEnable)
 

Private Attributes

PCB_LAYER_ID m_frontLayer
 
PCB_LAYER_ID m_backLayer
 
int m_leftRowSelected
 
int m_rightRowSelected
 
std::vector< PCB_LAYER_IDm_layersId
 

Detailed Description

Class SELECT_COPPER_LAYERS_PAIR_DIALOG displays a double pcb copper layers list in a dialog, to select a layer pair from these lists.

Definition at line 245 of file sel_layer.cpp.

Constructor & Destructor Documentation

SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG ( wxWindow *  aParent,
BOARD aPcb,
PCB_LAYER_ID  aFrontLayer,
PCB_LAYER_ID  aBackLayer 
)

Definition at line 308 of file sel_layer.cpp.

References buildList(), PCAD2KICAD::Center, m_backLayer, m_frontLayer, m_leftRowSelected, and m_rightRowSelected.

309  :
310  PCB_LAYER_SELECTOR( aPcb ),
312 {
313  m_frontLayer = aFrontLayer;
314  m_backLayer = aBackLayer;
315  m_leftRowSelected = 0;
316  m_rightRowSelected = 0;
317  buildList();
318  SetFocus();
319  GetSizer()->SetSizeHints( this );
320  Center();
321 }
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Select Copper Layer Pair:"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 175), long style=wxDEFAULT_DIALOG_STYLE)
PCB_LAYER_SELECTOR(BOARD *aBrd)
Definition: sel_layer.cpp:45

Member Function Documentation

void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList ( )
private

Definition at line 324 of file sel_layer.cpp.

References color, COLOR_COLNUM, BOARD::GetEnabledLayers(), PCB_LAYER_SELECTOR::GetLayerColor(), PCB_LAYER_SELECTOR::GetLayerName(), IsCopperLayer(), LAYERNAME_COLNUM, m_backLayer, PCB_LAYER_SELECTOR::m_brd, m_frontLayer, m_layersId, DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_leftGridLayers, m_leftRowSelected, DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_rightGridLayers, m_rightRowSelected, SELECT_COLNUM, SetGridCursor(), and LSET::UIOrder().

Referenced by SELECT_COPPER_LAYERS_PAIR_DIALOG().

325 {
326  m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
327  m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
328 
329  // Select a not show cell, to avoid a wrong cell selection for user
330 
331  int row = 0;
332  wxString layername;
333 
334  for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
335  {
336  PCB_LAYER_ID layerid = *ui_seq;
337 
338  if( !IsCopperLayer( layerid ) )
339  break;
340 
341  COLOR4D color = GetLayerColor( layerid );
342 
343  layername = GetLayerName( layerid );
344 
345  if( row )
346  m_leftGridLayers->AppendRows( 1 );
347 
348  m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color.ToColour() );
349  m_leftGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername );
350  m_layersId.push_back( layerid );
351 
352  if( m_frontLayer == layerid )
353  {
354  SetGridCursor( m_leftGridLayers, row, true );
355  m_leftRowSelected = row;
356  }
357 
358  if( row )
359  m_rightGridLayers->AppendRows( 1 );
360  m_rightGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM,
361  color.ToColour() );
362  m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM,
363  layername );
364 
365  if( m_backLayer == layerid )
366  {
367  SetGridCursor( m_rightGridLayers, row, true );
368  m_rightRowSelected = row;
369  }
370 
371  row++;
372  }
373 
374  m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
375  m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
376  m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
377  m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
378 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:119
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:254
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
PCB_LAYER_ID
A quick note on layer IDs:
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
#define COLOR_COLNUM
Definition: sel_layer.cpp:120
wxString GetLayerName(LAYER_NUM aLayer) const override
Definition: sel_layer.cpp:68
COLOR4D GetLayerColor(LAYER_NUM aLayer) const override
Definition: sel_layer.cpp:62
void SetGridCursor(wxGrid *aGrid, int aRow, bool aEnable)
Definition: sel_layer.cpp:381
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:121
LSEQ UIOrder() const
Definition: lset.cpp:752
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
COLOR4D PCB_LAYER_SELECTOR::GetLayerColor ( LAYER_NUM  aLayer) const
inlineoverrideprotectedvirtualinherited

Implements LAYER_SELECTOR.

Definition at line 62 of file sel_layer.cpp.

References BOARD::GetLayerColor(), and ToLAYER_ID().

Referenced by PCB_ONE_LAYER_SELECTOR::buildList(), buildList(), and SetGridCursor().

63  {
64  return m_brd->GetLayerColor( ToLAYER_ID( aLayer ) );
65  }
COLOR4D GetLayerColor(PCB_LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
wxString PCB_LAYER_SELECTOR::GetLayerName ( LAYER_NUM  aLayer) const
inlineoverrideprotectedvirtualinherited

Implements LAYER_SELECTOR.

Definition at line 68 of file sel_layer.cpp.

References BOARD::GetLayerName(), and ToLAYER_ID().

Referenced by PCB_ONE_LAYER_SELECTOR::buildList(), and buildList().

69  {
70  return m_brd->GetLayerName( ToLAYER_ID( aLayer ) );
71  }
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
void SELECT_COPPER_LAYERS_PAIR_DIALOG::GetLayerPair ( PCB_LAYER_ID aFrontLayer,
PCB_LAYER_ID aBackLayer 
)
inline

Definition at line 260 of file sel_layer.cpp.

References m_backLayer, and m_frontLayer.

Referenced by PCB_BASE_FRAME::SelectCopperLayerPair().

261  {
262  aFrontLayer = m_frontLayer;
263  aBackLayer = m_backLayer;
264  }
bool PCB_LAYER_SELECTOR::IsLayerEnabled ( LAYER_NUM  aLayer) const
inlineoverrideprotectedvirtualinherited

Implements LAYER_SELECTOR.

Definition at line 55 of file sel_layer.cpp.

References BOARD::IsLayerEnabled().

56  {
57  return m_brd->IsLayerEnabled( PCB_LAYER_ID( aLayer ) );
58  }
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
Function IsLayerEnabled is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:428
PCB_LAYER_ID
A quick note on layer IDs:
void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnCancelClick ( wxCommandEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE.

Definition at line 275 of file sel_layer.cpp.

276  {
277  EndModal( wxID_CANCEL );
278  }
void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnLeftGridCellClick ( wxGridEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE.

Definition at line 402 of file sel_layer.cpp.

References m_frontLayer, m_layersId, DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_leftGridLayers, m_leftRowSelected, and SetGridCursor().

403 {
404  int row = event.GetRow();
405  PCB_LAYER_ID layer = m_layersId[row];
406 
407  if( m_frontLayer == layer )
408  return;
409 
411  m_frontLayer = layer;
412  m_leftRowSelected = row;
414 }
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:254
PCB_LAYER_ID
A quick note on layer IDs:
void SetGridCursor(wxGrid *aGrid, int aRow, bool aEnable)
Definition: sel_layer.cpp:381
virtual void DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnOKClick ( wxCommandEvent &  event)
inlineprotectedvirtualinherited
void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnOkClick ( wxCommandEvent &  event)
inlineprivate

Definition at line 270 of file sel_layer.cpp.

271  {
272  EndModal( wxID_OK );
273  }
void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnRightGridCellClick ( wxGridEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE.

Definition at line 417 of file sel_layer.cpp.

References m_backLayer, m_layersId, DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_rightGridLayers, m_rightRowSelected, and SetGridCursor().

418 {
419  int row = event.GetRow();
420  PCB_LAYER_ID layer = m_layersId[row];
421 
422  if( m_backLayer == layer )
423  return;
424 
426  m_backLayer = layer;
427  m_rightRowSelected = row;
429 }
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:254
PCB_LAYER_ID
A quick note on layer IDs:
void SetGridCursor(wxGrid *aGrid, int aRow, bool aEnable)
Definition: sel_layer.cpp:381
void LAYER_SELECTOR::SetBitmapLayer ( wxBitmap &  aLayerbmp,
LAYER_NUM  aLayer 
)
protectedinherited

Definition at line 51 of file class_layer_box_selector.cpp.

References LAYER_SELECTOR::GetLayerColor().

Referenced by GBR_LAYER_BOX_SELECTOR::Resync(), PCB_LAYER_BOX_SELECTOR::Resync(), and LAYER_BOX_SELECTOR::ResyncBitmapOnly().

52 {
53  wxMemoryDC bmpDC;
54  wxBrush brush;
55 
56  // Prepare Bitmap
57  bmpDC.SelectObject( aLayerbmp );
58  brush.SetColour( GetLayerColor( aLayer ).ToColour() );
59  brush.SetStyle( wxBRUSHSTYLE_SOLID );
60 
61  bmpDC.SetBrush( brush );
62  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
63  bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
64  bmpDC.SetPen( *wxBLACK_PEN );
65  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
66 }
virtual COLOR4D GetLayerColor(LAYER_NUM aLayer) const =0
void SELECT_COPPER_LAYERS_PAIR_DIALOG::SetGridCursor ( wxGrid *  aGrid,
int  aRow,
bool  aEnable 
)
private

Definition at line 381 of file sel_layer.cpp.

References color, PCB_LAYER_SELECTOR::GetLayerColor(), LAYERNAME_COLNUM, m_layersId, and SELECT_COLNUM.

Referenced by buildList(), OnLeftGridCellClick(), and OnRightGridCellClick().

383 {
384  if( aEnable )
385  {
386  PCB_LAYER_ID layerid = m_layersId[aRow];
387  COLOR4D color = GetLayerColor( layerid );
388  aGrid->SetCellValue( aRow, SELECT_COLNUM, wxT("X") );
389  aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color.ToColour() );
390  aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
391  }
392  else
393  {
394  aGrid->SetCellValue( aRow, SELECT_COLNUM, wxEmptyString );
395  aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM,
396  aGrid->GetDefaultCellBackgroundColour() );
397  aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
398  }
399 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:119
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:254
PCB_LAYER_ID
A quick note on layer IDs:
COLOR4D GetLayerColor(LAYER_NUM aLayer) const override
Definition: sel_layer.cpp:62
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:121
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
bool LAYER_SELECTOR::SetLayersOrdered ( bool  value)
inherited

Member Data Documentation

PCB_LAYER_ID SELECT_COPPER_LAYERS_PAIR_DIALOG::m_backLayer
private
BOARD* PCB_LAYER_SELECTOR::m_brd
protectedinherited
PCB_LAYER_ID SELECT_COPPER_LAYERS_PAIR_DIALOG::m_frontLayer
private
struct EDA_HOTKEY_CONFIG* LAYER_SELECTOR::m_hotkeys
inherited

Definition at line 46 of file class_layer_box_selector.h.

Referenced by LAYER_SELECTOR::LAYER_SELECTOR().

std::vector<PCB_LAYER_ID> SELECT_COPPER_LAYERS_PAIR_DIALOG::m_layersId
private

Definition at line 254 of file sel_layer.cpp.

Referenced by buildList(), OnLeftGridCellClick(), OnRightGridCellClick(), and SetGridCursor().

int SELECT_COPPER_LAYERS_PAIR_DIALOG::m_leftRowSelected
private

Definition at line 251 of file sel_layer.cpp.

Referenced by buildList(), OnLeftGridCellClick(), and SELECT_COPPER_LAYERS_PAIR_DIALOG().

int SELECT_COPPER_LAYERS_PAIR_DIALOG::m_rightRowSelected
private
wxStdDialogButtonSizer* DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_sdbSizer
protectedinherited
wxButton* DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_sdbSizerCancel
protectedinherited
wxButton* DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_sdbSizerOK
protectedinherited
wxStaticLine* DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_staticline1
protectedinherited
wxStaticText* DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_staticTextBottomLayer
protectedinherited
wxStaticText* DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::m_staticTextTopLayer
protectedinherited

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