KiCad PCB EDA Suite
PCB_ONE_LAYER_SELECTOR Class Reference
Inheritance diagram for PCB_ONE_LAYER_SELECTOR:
PCB_LAYER_SELECTOR DIALOG_LAYER_SELECTION_BASE LAYER_SELECTOR

Public Member Functions

 PCB_ONE_LAYER_SELECTOR (PCB_BASE_FRAME *aParent, BOARD *aBrd, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask)
 
LAYER_NUM GetLayerSelection ()
 
bool SetLayersHotkeys (bool value)
 

Static Public Member Functions

static void DrawColorSwatch (wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
 

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
 
virtual void OnLeftButtonReleased (wxMouseEvent &event)
 

Protected Attributes

PCB_BASE_FRAMEm_frame
 
bool m_layerhotkeys
 
wxGrid * m_leftGridLayers
 
wxGrid * m_rightGridLayers
 

Private Member Functions

void OnLeftGridCellClick (wxGridEvent &event) override
 
void OnRightGridCellClick (wxGridEvent &event) override
 
void buildList ()
 

Private Attributes

PCB_LAYER_ID m_layerSelected
 
LSET m_notAllowedLayersMask
 
BOARDm_brd
 
std::vector< PCB_LAYER_IDm_layersIdLeftColumn
 
std::vector< PCB_LAYER_IDm_layersIdRightColumn
 

Detailed Description

Definition at line 85 of file sel_layer.cpp.

Constructor & Destructor Documentation

PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR ( PCB_BASE_FRAME aParent,
BOARD aBrd,
PCB_LAYER_ID  aDefaultLayer,
LSET  aNotAllowedLayersMask 
)

Definition at line 109 of file sel_layer.cpp.

References buildList(), m_brd, m_layerSelected, DIALOG_LAYER_SELECTION_BASE::m_leftGridLayers, m_notAllowedLayersMask, DIALOG_LAYER_SELECTION_BASE::m_rightGridLayers, and SELECT_COLNUM.

111  :
112  PCB_LAYER_SELECTOR( aParent ),
113  DIALOG_LAYER_SELECTION_BASE( aParent )
114 {
115  m_layerSelected = aDefaultLayer;
116  m_notAllowedLayersMask = aNotAllowedLayersMask;
117  m_brd = aBrd;
118 
119  m_leftGridLayers->SetCellHighlightPenWidth( 0 );
120  m_rightGridLayers->SetCellHighlightPenWidth( 0 );
121  m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
122  m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
123  buildList();
124 
125  Layout();
126  GetSizer()->SetSizeHints( this );
127  SetFocus();
128 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:41
DIALOG_LAYER_SELECTION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Select Layer"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:88
PCB_LAYER_SELECTOR(PCB_BASE_FRAME *aFrame)
Definition: sel_layer.cpp:51

Member Function Documentation

void PCB_ONE_LAYER_SELECTOR::buildList ( )
private

Definition at line 131 of file sel_layer.cpp.

References color, COLOR_COLNUM, BOARD::GetEnabledLayers(), PCB_LAYER_SELECTOR::GetLayerColor(), PCB_LAYER_SELECTOR::GetLayerName(), IsCopperLayer(), LAYER_PCB_BACKGROUND, LAYERNAME_COLNUM, m_brd, m_layerSelected, m_layersIdLeftColumn, m_layersIdRightColumn, DIALOG_LAYER_SELECTION_BASE::m_leftGridLayers, m_notAllowedLayersMask, DIALOG_LAYER_SELECTION_BASE::m_rightGridLayers, SELECT_COLNUM, and LSET::UIOrder().

Referenced by SELECT_COPPER_LAYERS_PAIR_DIALOG::GetLayerPair(), and PCB_ONE_LAYER_SELECTOR().

132 {
133  wxColour bg = GetLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
134  int left_row = 0;
135  int right_row = 0;
136  wxString layername;
137 
138  for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
139  {
140  PCB_LAYER_ID layerid = *ui_seq;
141 
142  if( m_notAllowedLayersMask[layerid] )
143  continue;
144 
145  wxColour fg = GetLayerColor( layerid ).ToColour();
146  wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
147  wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
148  wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
149 
150  layername = wxT( " " ) + GetLayerName( layerid );
151 
152  if( IsCopperLayer( layerid ) )
153  {
154  if( left_row )
155  m_leftGridLayers->AppendRows( 1 );
156 
157  m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM, color );
158  m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
159 
160  if( m_layerSelected == layerid )
161  m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, "1" );
162 
163  m_layersIdLeftColumn.push_back( layerid );
164  left_row++;
165  }
166  else
167  {
168  if( right_row )
169  m_rightGridLayers->AppendRows( 1 );
170 
171  m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
172  m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
173 
174  if( m_layerSelected == layerid )
175  m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, "1" );
176 
177  m_layersIdRightColumn.push_back( layerid );
178  right_row++;
179  }
180  }
181 
182  // Show only populated lists:
183  if( left_row <= 0 )
184  m_leftGridLayers->Show( false );
185 
186  if( right_row <= 0 )
187  m_rightGridLayers->Show( false );
188 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:41
int color
Definition: DXF_plotter.cpp:62
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:
std::vector< PCB_LAYER_ID > m_layersIdRightColumn
Definition: sel_layer.cpp:92
std::vector< PCB_LAYER_ID > m_layersIdLeftColumn
Definition: sel_layer.cpp:91
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
#define COLOR_COLNUM
Definition: sel_layer.cpp:42
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:88
wxString GetLayerName(LAYER_NUM aLayer) const override
Definition: sel_layer.cpp:74
COLOR4D GetLayerColor(LAYER_NUM aLayer) const override
Definition: sel_layer.cpp:68
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:43
LSEQ UIOrder() const
Definition: lset.cpp:800
void LAYER_SELECTOR::DrawColorSwatch ( wxBitmap &  aLayerbmp,
COLOR4D  aBackground,
COLOR4D  aColor 
)
staticinherited

Definition at line 48 of file layer_box_selector.cpp.

References KIGFX::COLOR4D::WithAlpha().

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

49 {
50  wxMemoryDC bmpDC;
51  wxBrush brush;
52 
53  // Prepare Bitmap
54  bmpDC.SelectObject( aLayerbmp );
55 
56  brush.SetStyle( wxBRUSHSTYLE_SOLID );
57  if( aBackground != COLOR4D::UNSPECIFIED )
58  {
59  brush.SetColour( aBackground.WithAlpha(1.0).ToColour() );
60  bmpDC.SetBrush( brush );
61  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
62  }
63 
64  brush.SetColour( aColor.ToColour() );
65  bmpDC.SetBrush( brush );
66  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
67 
68  bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
69  bmpDC.SetPen( *wxBLACK_PEN );
70  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
71 }
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:233
COLOR4D PCB_LAYER_SELECTOR::GetLayerColor ( LAYER_NUM  aLayer) const
inlineoverrideprotectedvirtualinherited

Implements LAYER_SELECTOR.

Definition at line 68 of file sel_layer.cpp.

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

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

69  {
70  return m_frame->Settings().Colors().GetLayerColor( aLayer );
71  }
PCB_BASE_FRAME * m_frame
Definition: sel_layer.cpp:58
PCB_GENERAL_SETTINGS & Settings()
COLORS_DESIGN_SETTINGS & Colors()
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
wxString PCB_LAYER_SELECTOR::GetLayerName ( LAYER_NUM  aLayer) const
inlineoverrideprotectedvirtualinherited

Implements LAYER_SELECTOR.

Definition at line 74 of file sel_layer.cpp.

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

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

75  {
76  return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
77  }
PCB_BASE_FRAME * m_frame
Definition: sel_layer.cpp:58
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:810
LAYER_NUM PCB_ONE_LAYER_SELECTOR::GetLayerSelection ( )
inline

Definition at line 98 of file sel_layer.cpp.

Referenced by PCB_BASE_FRAME::SelectLayer().

98 { return m_layerSelected; }
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:88
bool PCB_LAYER_SELECTOR::IsLayerEnabled ( LAYER_NUM  aLayer) const
inlineoverrideprotectedvirtualinherited

Implements LAYER_SELECTOR.

Definition at line 61 of file sel_layer.cpp.

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

62  {
63  return m_frame->GetBoard()->IsLayerEnabled( PCB_LAYER_ID( aLayer ) );
64  }
PCB_BASE_FRAME * m_frame
Definition: sel_layer.cpp: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:445
BOARD * GetBoard() const
PCB_LAYER_ID
A quick note on layer IDs:
virtual void DIALOG_LAYER_SELECTION_BASE::OnLeftButtonReleased ( wxMouseEvent &  event)
inlineprotectedvirtualinherited
void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick ( wxGridEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_LAYER_SELECTION_BASE.

Definition at line 191 of file sel_layer.cpp.

References m_layerSelected, and m_layersIdLeftColumn.

Referenced by SELECT_COPPER_LAYERS_PAIR_DIALOG::GetLayerPair().

192 {
193  m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ];
194  EndModal( 1 );
195 }
std::vector< PCB_LAYER_ID > m_layersIdLeftColumn
Definition: sel_layer.cpp:91
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:88
void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick ( wxGridEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_LAYER_SELECTION_BASE.

Definition at line 198 of file sel_layer.cpp.

References m_layerSelected, and m_layersIdRightColumn.

Referenced by SELECT_COPPER_LAYERS_PAIR_DIALOG::GetLayerPair().

199 {
200  m_layerSelected = m_layersIdRightColumn[ event.GetRow() ];
201  EndModal( 2 );
202 }
std::vector< PCB_LAYER_ID > m_layersIdRightColumn
Definition: sel_layer.cpp:92
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:88

Member Data Documentation

BOARD* PCB_ONE_LAYER_SELECTOR::m_brd
private

Definition at line 90 of file sel_layer.cpp.

Referenced by buildList(), and PCB_ONE_LAYER_SELECTOR().

PCB_BASE_FRAME* PCB_LAYER_SELECTOR::m_frame
protectedinherited

Definition at line 58 of file sel_layer.cpp.

Referenced by PCB_LAYER_SELECTOR::PCB_LAYER_SELECTOR().

struct EDA_HOTKEY_CONFIG* LAYER_SELECTOR::m_hotkeys
inherited

Definition at line 46 of file layer_box_selector.h.

Referenced by LAYER_SELECTOR::LAYER_SELECTOR().

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited
PCB_LAYER_ID PCB_ONE_LAYER_SELECTOR::m_layerSelected
private
std::vector<PCB_LAYER_ID> PCB_ONE_LAYER_SELECTOR::m_layersIdLeftColumn
private

Definition at line 91 of file sel_layer.cpp.

Referenced by buildList(), and OnLeftGridCellClick().

std::vector<PCB_LAYER_ID> PCB_ONE_LAYER_SELECTOR::m_layersIdRightColumn
private

Definition at line 92 of file sel_layer.cpp.

Referenced by buildList(), and OnRightGridCellClick().

wxGrid* DIALOG_LAYER_SELECTION_BASE::m_leftGridLayers
protectedinherited
LSET PCB_ONE_LAYER_SELECTOR::m_notAllowedLayersMask
private

Definition at line 89 of file sel_layer.cpp.

Referenced by buildList(), and PCB_ONE_LAYER_SELECTOR().

wxGrid* DIALOG_LAYER_SELECTION_BASE::m_rightGridLayers
protectedinherited

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