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 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

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

References buildList(), m_brd, m_layerSelected, and m_notAllowedLayersMask.

106  : PCB_LAYER_SELECTOR( aParent ), DIALOG_LAYER_SELECTION_BASE( aParent )
107 {
108  m_layerSelected = aDefaultLayer;
109  m_notAllowedLayersMask = aNotAllowedLayersMask;
110  m_brd = aBrd;
111  buildList();
112  Layout();
113  GetSizer()->SetSizeHints( this );
114  SetFocus();
115 }
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_ID m_layerSelected
Definition: sel_layer.cpp:82
PCB_LAYER_SELECTOR(PCB_BASE_FRAME *aFrame)
Definition: sel_layer.cpp:45

Member Function Documentation

void PCB_ONE_LAYER_SELECTOR::buildList ( )
private

Definition at line 124 of file sel_layer.cpp.

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

125 {
126  // Hide layerid column which is used only to know the layer id
127  // not to be shown in dialogs
128  m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 );
129  m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 );
130 
131  int left_row = 0;
132  int right_row = 0;
133  wxString layername;
134 
135  for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq )
136  {
137  PCB_LAYER_ID layerid = *ui_seq;
138 
139  if( m_notAllowedLayersMask[layerid] )
140  continue;
141 
142  COLOR4D color = GetLayerColor( layerid );
143  layername = GetLayerName( layerid );
144 
145  if( IsCopperLayer( layerid ) )
146  {
147  if( left_row )
148  m_leftGridLayers->AppendRows( 1 );
149 
150  m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM,
151  color.ToColour() );
152  m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM,
153  layername );
154 
155  if( m_layerSelected == layerid )
156  {
157  m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM,
158  wxT("X") );
159  m_leftGridLayers->SetCellBackgroundColour ( left_row, SELECT_COLNUM,
160  color.ToColour() );
161  m_leftGridLayers->SetGridCursor( left_row, LAYERNAME_COLNUM );
162  }
163 
164  m_layersIdLeftColumn.push_back( layerid );
165  left_row++;
166  }
167  else
168  {
169  if( right_row )
170  m_rightGridLayers->AppendRows( 1 );
171 
172  m_rightGridLayers->SetCellBackgroundColour ( right_row, COLOR_COLNUM,
173  color.ToColour() );
174  m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM,
175  layername );
176 
177  if( m_layerSelected == layerid )
178  {
179  m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM,
180  wxT("X") );
181  m_rightGridLayers->SetCellBackgroundColour ( right_row, SELECT_COLNUM,
182  color.ToColour() );
183  m_rightGridLayers->SetGridCursor( right_row, LAYERNAME_COLNUM );
184  }
185 
186  m_layersIdRightColumn.push_back( layerid );
187  right_row++;
188  }
189  }
190 
191  // Show only populated lists:
192  if( left_row <= 0 )
193  m_leftGridLayers->Show( false );
194 
195  if( right_row <= 0 )
196  m_rightGridLayers->Show( false );
197 
198  m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
199  m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM);
200  m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM);
201  m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM);
202 }
#define SELECT_COLNUM
Definition: sel_layer.cpp:120
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:121
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:122
LSEQ UIOrder() const
Definition: lset.cpp:759
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 buildList(), SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList(), and SELECT_COPPER_LAYERS_PAIR_DIALOG::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:774
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 buildList(), and SELECT_COPPER_LAYERS_PAIR_DIALOG::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:774
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 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:
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 205 of file sel_layer.cpp.

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

206 {
207  m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ];
208  m_leftGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
209  EndModal( 1 );
210 }
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:122
void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick ( wxGridEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_LAYER_SELECTION_BASE.

Definition at line 213 of file sel_layer.cpp.

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

214 {
215  m_layerSelected = m_layersIdRightColumn[ event.GetRow() ];
216  m_rightGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM );
217  EndModal( 2 );
218 }
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:122
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
bool LAYER_SELECTOR::SetLayersOrdered ( bool  value)
inherited

Member Data Documentation

BOARD* PCB_ONE_LAYER_SELECTOR::m_brd
private

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