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 (PCB_BASE_FRAME *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

PCB_BASE_FRAMEm_frame
 
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

BOARDm_brd
 
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 246 of file sel_layer.cpp.

Constructor & Destructor Documentation

SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG ( PCB_BASE_FRAME aParent,
BOARD aPcb,
PCB_LAYER_ID  aFrontLayer,
PCB_LAYER_ID  aBackLayer 
)

Definition at line 310 of file sel_layer.cpp.

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

311  :
312  PCB_LAYER_SELECTOR( aParent ),
314 {
315  m_frontLayer = aFrontLayer;
316  m_backLayer = aBackLayer;
317  m_leftRowSelected = 0;
318  m_rightRowSelected = 0;
319  m_brd = aPcb;
320  buildList();
321  SetFocus();
322  GetSizer()->SetSizeHints( this );
323  Center();
324 }
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(PCB_BASE_FRAME *aFrame)
Definition: sel_layer.cpp:45

Member Function Documentation

void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList ( )
private

Definition at line 327 of file sel_layer.cpp.

References color, COLOR_COLNUM, BOARD::GetEnabledLayers(), PCB_LAYER_SELECTOR::GetLayerColor(), PCB_LAYER_SELECTOR::GetLayerName(), IsCopperLayer(), LAYERNAME_COLNUM, m_backLayer, 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().

328 {
329  m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
330  m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
331 
332  // Select a not show cell, to avoid a wrong cell selection for user
333 
334  int row = 0;
335  wxString layername;
336 
337  for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
338  {
339  PCB_LAYER_ID layerid = *ui_seq;
340 
341  if( !IsCopperLayer( layerid ) )
342  break;
343 
344  COLOR4D color = GetLayerColor( layerid );
345 
346  layername = GetLayerName( layerid );
347 
348  if( row )
349  m_leftGridLayers->AppendRows( 1 );
350 
351  m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color.ToColour() );
352  m_leftGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername );
353  m_layersId.push_back( layerid );
354 
355  if( m_frontLayer == layerid )
356  {
357  SetGridCursor( m_leftGridLayers, row, true );
358  m_leftRowSelected = row;
359  }
360 
361  if( row )
362  m_rightGridLayers->AppendRows( 1 );
363  m_rightGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM,
364  color.ToColour() );
365  m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM,
366  layername );
367 
368  if( m_backLayer == layerid )
369  {
370  SetGridCursor( m_rightGridLayers, row, true );
371  m_rightRowSelected = row;
372  }
373 
374  row++;
375  }
376 
377  m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
378  m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
379  m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
380  m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
381 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:120
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:256
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:121
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:384
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:122
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 PCB_GENERAL_SETTINGS::Colors(), COLORS_DESIGN_SETTINGS::GetLayerColor(), PCB_BASE_FRAME::Settings(), and ToLAYER_ID().

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

63  {
64  return m_frame->Settings().Colors().GetLayerColor( ToLAYER_ID( aLayer ) );
65  }
PCB_BASE_FRAME * m_frame
Definition: sel_layer.cpp:52
PCB_GENERAL_SETTINGS & Settings()
COLORS_DESIGN_SETTINGS & Colors()
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
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 PCB_BASE_FRAME::GetBoard(), BOARD::GetLayerName(), and ToLAYER_ID().

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

69  {
70  return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
71  }
PCB_BASE_FRAME * m_frame
Definition: sel_layer.cpp:52
BOARD * GetBoard() const
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 262 of file sel_layer.cpp.

References m_backLayer, and m_frontLayer.

Referenced by PCB_BASE_FRAME::SelectCopperLayerPair().

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

Implements LAYER_SELECTOR.

Definition at line 55 of file sel_layer.cpp.

References PCB_BASE_FRAME::GetBoard(), and BOARD::IsLayerEnabled().

56  {
57  return m_frame->GetBoard()->IsLayerEnabled( PCB_LAYER_ID( aLayer ) );
58  }
PCB_BASE_FRAME * m_frame
Definition: sel_layer.cpp:52
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:439
BOARD * GetBoard() const
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 277 of file sel_layer.cpp.

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

Reimplemented from DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE.

Definition at line 405 of file sel_layer.cpp.

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

406 {
407  int row = event.GetRow();
408  PCB_LAYER_ID layer = m_layersId[row];
409 
410  if( m_frontLayer == layer )
411  return;
412 
414  m_frontLayer = layer;
415  m_leftRowSelected = row;
417 }
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:256
PCB_LAYER_ID
A quick note on layer IDs:
void SetGridCursor(wxGrid *aGrid, int aRow, bool aEnable)
Definition: sel_layer.cpp:384
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 272 of file sel_layer.cpp.

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

Reimplemented from DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE.

Definition at line 420 of file sel_layer.cpp.

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

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

Definition at line 50 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().

51 {
52  wxMemoryDC bmpDC;
53  wxBrush brush;
54 
55  // Prepare Bitmap
56  bmpDC.SelectObject( aLayerbmp );
57  brush.SetColour( GetLayerColor( aLayer ).ToColour() );
58  brush.SetStyle( wxBRUSHSTYLE_SOLID );
59 
60  bmpDC.SetBrush( brush );
61  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
62  bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
63  bmpDC.SetPen( *wxBLACK_PEN );
64  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
65 }
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 384 of file sel_layer.cpp.

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

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

386 {
387  if( aEnable )
388  {
389  PCB_LAYER_ID layerid = m_layersId[aRow];
390  COLOR4D color = GetLayerColor( layerid );
391  aGrid->SetCellValue( aRow, SELECT_COLNUM, wxT("X") );
392  aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color.ToColour() );
393  aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
394  }
395  else
396  {
397  aGrid->SetCellValue( aRow, SELECT_COLNUM, wxEmptyString );
398  aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM,
399  aGrid->GetDefaultCellBackgroundColour() );
400  aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
401  }
402 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:120
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:256
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:122
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* SELECT_COPPER_LAYERS_PAIR_DIALOG::m_brd
private

Definition at line 250 of file sel_layer.cpp.

Referenced by buildList(), and SELECT_COPPER_LAYERS_PAIR_DIALOG().

PCB_BASE_FRAME* PCB_LAYER_SELECTOR::m_frame
protectedinherited

Definition at line 52 of file sel_layer.cpp.

Referenced by PCB_LAYER_SELECTOR::PCB_LAYER_SELECTOR().

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 256 of file sel_layer.cpp.

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

int SELECT_COPPER_LAYERS_PAIR_DIALOG::m_leftRowSelected
private

Definition at line 253 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: