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 (wxWindow *aParent, BOARD *aBrd, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask)
 
LAYER_NUM GetLayerSelection ()
 
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 OnLeftButtonReleased (wxMouseEvent &event)
 

Protected Attributes

BOARDm_brd
 
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
 
std::vector< PCB_LAYER_IDm_layersIdLeftColumn
 
std::vector< PCB_LAYER_IDm_layersIdRightColumn
 

Detailed Description

Definition at line 79 of file sel_layer.cpp.

Constructor & Destructor Documentation

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

Definition at line 104 of file sel_layer.cpp.

References buildList(), m_layerSelected, and m_notAllowedLayersMask.

106  : PCB_LAYER_SELECTOR( aBrd ), DIALOG_LAYER_SELECTION_BASE( aParent )
107 {
108  m_layerSelected = aDefaultLayer;
109  m_notAllowedLayersMask = aNotAllowedLayersMask;
110  buildList();
111  Layout();
112  GetSizer()->SetSizeHints( this );
113  SetFocus();
114 }
DIALOG_LAYER_SELECTION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Select Layer:"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(337, 183), long style=wxDEFAULT_DIALOG_STYLE)
PCB_LAYER_SELECTOR(BOARD *aBrd)
Definition: sel_layer.cpp:45
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:82

Member Function Documentation

void PCB_ONE_LAYER_SELECTOR::buildList ( )
private

Definition at line 123 of file sel_layer.cpp.

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

124 {
125  // Hide layerid column which is used only to know the layer id
126  // not to be shown in dialogs
127  m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
128  m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
129 
130  int left_row = 0;
131  int right_row = 0;
132  wxString layername;
133 
134  for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
135  {
136  PCB_LAYER_ID layerid = *ui_seq;
137 
138  if( m_notAllowedLayersMask[layerid] )
139  continue;
140 
141  COLOR4D color = GetLayerColor( layerid );
142  layername = GetLayerName( layerid );
143 
144  if( IsCopperLayer( layerid ) )
145  {
146  if( left_row )
147  m_leftGridLayers->AppendRows( 1 );
148 
149  m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM,
150  color.ToColour() );
151  m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM,
152  layername );
153 
154  if( m_layerSelected == layerid )
155  {
156  m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM,
157  wxT("X") );
158  m_leftGridLayers->SetCellBackgroundColour ( left_row, SELECT_COLNUM,
159  color.ToColour() );
160  m_leftGridLayers->SetGridCursor( left_row, LAYERNAME_COLNUM );
161  }
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,
172  color.ToColour() );
173  m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM,
174  layername );
175 
176  if( m_layerSelected == layerid )
177  {
178  m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM,
179  wxT("X") );
180  m_rightGridLayers->SetCellBackgroundColour ( right_row, SELECT_COLNUM,
181  color.ToColour() );
182  m_rightGridLayers->SetGridCursor( right_row, LAYERNAME_COLNUM );
183  }
184 
185  m_layersIdRightColumn.push_back( layerid );
186  right_row++;
187  }
188  }
189 
190  // Show only populated lists:
191  if( left_row <= 0 )
192  m_leftGridLayers->Show( false );
193 
194  if( right_row <= 0 )
195  m_rightGridLayers->Show( false );
196 
197  m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
198  m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
199  m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
200  m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
201 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:119
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:86
std::vector< PCB_LAYER_ID > m_layersIdLeftColumn
Definition: sel_layer.cpp:85
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
#define COLOR_COLNUM
Definition: sel_layer.cpp:120
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:82
wxString GetLayerName(LAYER_NUM aLayer) const override
Definition: sel_layer.cpp:68
COLOR4D GetLayerColor(LAYER_NUM aLayer) const override
Definition: sel_layer.cpp:62
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 buildList(), SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList(), and SELECT_COPPER_LAYERS_PAIR_DIALOG::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 buildList(), and SELECT_COPPER_LAYERS_PAIR_DIALOG::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
LAYER_NUM PCB_ONE_LAYER_SELECTOR::GetLayerSelection ( )
inline

Definition at line 93 of file sel_layer.cpp.

References m_layerSelected.

Referenced by PCB_BASE_FRAME::SelectLayer().

93 { return m_layerSelected; }
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:82
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:431
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 204 of file sel_layer.cpp.

References LAYERNAME_COLNUM, m_layerSelected, m_layersIdLeftColumn, and DIALOG_LAYER_SELECTION_BASE::m_leftGridLayers.

205 {
206  m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ];
207  m_leftGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
208  EndModal( 1 );
209 }
std::vector< PCB_LAYER_ID > m_layersIdLeftColumn
Definition: sel_layer.cpp:85
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:82
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:121
void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick ( wxGridEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_LAYER_SELECTION_BASE.

Definition at line 212 of file sel_layer.cpp.

References LAYERNAME_COLNUM, m_layerSelected, m_layersIdRightColumn, and DIALOG_LAYER_SELECTION_BASE::m_rightGridLayers.

213 {
214  m_layerSelected = m_layersIdRightColumn[ event.GetRow() ];
215  m_rightGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
216  EndModal( 2 );
217 }
std::vector< PCB_LAYER_ID > m_layersIdRightColumn
Definition: sel_layer.cpp:86
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:82
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:121
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
bool LAYER_SELECTOR::SetLayersOrdered ( bool  value)
inherited

Member Data Documentation

BOARD* PCB_LAYER_SELECTOR::m_brd
protectedinherited
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().

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 85 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 86 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 83 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: