KiCad PCB EDA Suite
PCB_LAYER_BOX_SELECTOR Class Reference

Class to display a pcb layer list in a wxBitmapComboBox. More...

#include <class_pcb_layer_box_selector.h>

Inheritance diagram for PCB_LAYER_BOX_SELECTOR:
LAYER_BOX_SELECTOR LAYER_SELECTOR

Public Member Functions

 PCB_LAYER_BOX_SELECTOR (wxWindow *parent, wxWindowID id, const wxString &value=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL, int style=0)
 
void SetBoardFrame (PCB_BASE_FRAME *aFrame)
 
void SetLayerSet (LSET aMask)
 
void Resync () override
 
void ShowNonActivatedLayers (bool aShow)
 
int GetChoice ()
 
LAYER_NUM GetLayerSelection () const
 
int SetLayerSelection (LAYER_NUM layer)
 
void ResyncBitmapOnly ()
 
bool SetLayersOrdered (bool value)
 
bool SetLayersHotkeys (bool value)
 

Public Attributes

EDA_HOTKEY_CONFIGm_hotkeys
 

Protected Member Functions

void SetBitmapLayer (wxBitmap &aLayerbmp, LAYER_NUM aLayer)
 

Protected Attributes

bool m_layerhotkeys
 

Private Member Functions

COLOR4D GetLayerColor (LAYER_NUM aLayer) const override
 
bool IsLayerEnabled (LAYER_NUM aLayer) const override
 
wxString GetLayerName (LAYER_NUM aLayer) const override
 
LSET getEnabledLayers () const
 

Private Attributes

PCB_BASE_FRAMEm_boardFrame
 
LSET m_layerMaskDisable
 
bool m_showNotEnabledBrdlayers
 

Detailed Description

Class to display a pcb layer list in a wxBitmapComboBox.

Definition at line 35 of file class_pcb_layer_box_selector.h.

Constructor & Destructor Documentation

PCB_LAYER_BOX_SELECTOR::PCB_LAYER_BOX_SELECTOR ( wxWindow *  parent,
wxWindowID  id,
const wxString &  value = wxEmptyString,
const wxPoint pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
int  n = 0,
const wxString  choices[] = NULL,
int  style = 0 
)
inline

Definition at line 54 of file class_pcb_layer_box_selector.h.

58  :
59  LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
60  {
61  m_boardFrame = NULL;
62  m_hotkeys = NULL;
64  }
LAYER_BOX_SELECTOR(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL)

Member Function Documentation

int LAYER_BOX_SELECTOR::GetChoice ( )
inherited

Definition at line 97 of file class_layer_box_selector.cpp.

98 {
99  return GetSelection();
100 }
LSET PCB_LAYER_BOX_SELECTOR::getEnabledLayers ( ) const
private

Definition at line 138 of file class_pcb_layer_box_selector.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetEnabledLayers(), and m_boardFrame.

Referenced by Resync().

139 {
140  wxASSERT( m_boardFrame != NULL );
141  BOARD* board = m_boardFrame->GetBoard();
142  wxASSERT( board != NULL );
143 
144  return board->GetEnabledLayers();
145 }
BOARD * GetBoard() const
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
COLOR4D PCB_LAYER_BOX_SELECTOR::GetLayerColor ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 149 of file class_pcb_layer_box_selector.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetLayerColor(), m_boardFrame, and ToLAYER_ID().

150 {
151  wxASSERT( m_boardFrame );
152  BOARD* board = m_boardFrame->GetBoard();
153  wxASSERT( board );
154 
155  return board->GetLayerColor( ToLAYER_ID( aLayer ) );
156 }
COLOR4D GetLayerColor(PCB_LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
BOARD * GetBoard() const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
wxString PCB_LAYER_BOX_SELECTOR::GetLayerName ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 160 of file class_pcb_layer_box_selector.cpp.

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

Referenced by Resync().

161 {
162  wxASSERT( m_boardFrame );
163  BOARD* board = m_boardFrame->GetBoard();
164  wxASSERT( board );
165 
166  return board->GetLayerName( ToLAYER_ID( aLayer ) );
167 }
BOARD * GetBoard() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 128 of file class_pcb_layer_box_selector.cpp.

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

129 {
130  wxASSERT( m_boardFrame != NULL );
131  BOARD* board = m_boardFrame->GetBoard();
132  wxASSERT( board != NULL );
133 
134  return board->IsLayerEnabled( ToLAYER_ID( aLayer ) );
135 }
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
BOARD * GetBoard() const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
void PCB_LAYER_BOX_SELECTOR::Resync ( )
overridevirtual

Implements LAYER_BOX_SELECTOR.

Definition at line 76 of file class_pcb_layer_box_selector.cpp.

References AddHotkeyName(), LSET::AllLayersMask(), BM_SIZE, getEnabledLayers(), GetLayerName(), IS_COMMENT, layer2hotkey_id(), m_hotkeys, LAYER_SELECTOR::m_layerhotkeys, m_layerMaskDisable, m_showNotEnabledBrdlayers, max, LAYER_SELECTOR::SetBitmapLayer(), and LSET::UIOrder().

Referenced by DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PCB_EDIT_FRAME::ReCreateLayerBox(), DialogEditModuleText::TransferDataToWindow(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow().

77 {
78  Clear();
79 
80  // Tray to fix a minimum width fot the BitmapComboBox
81  int minwidth = 80;
82 
83  wxClientDC dc( GetParent() ); // The DC for "this" is not always initialized
84 
85  const int BM_SIZE = 14;
86 
88  LSET activated = getEnabledLayers() & ~m_layerMaskDisable;
89  wxString layerstatus;
90 
91  for( LSEQ seq = show.UIOrder(); seq; ++seq )
92  {
93  PCB_LAYER_ID layerid = *seq;
94 
95  if( !m_showNotEnabledBrdlayers && !activated[layerid] )
96  continue;
97  else if( !activated[layerid] )
98  layerstatus = wxT( " " ) + _( "(not activated)" );
99  else
100  layerstatus.Empty();
101 
102  wxBitmap layerbmp( BM_SIZE, BM_SIZE );
103  SetBitmapLayer( layerbmp, layerid );
104 
105  wxString layername = GetLayerName( layerid ) + layerstatus;
106 
107  if( m_layerhotkeys && m_hotkeys )
108  {
109  int id = layer2hotkey_id( layerid );
110 
111  if( id != -1 )
112  layername = AddHotkeyName( layername, m_hotkeys, id, IS_COMMENT );
113  }
114 
115  Append( layername, layerbmp, (void*)(intptr_t) layerid );
116 
117  int w, h;
118  dc.GetTextExtent ( layername, &w, &h );
119  minwidth = std::max( minwidth, w );
120  }
121 
122  minwidth += BM_SIZE + 35; // Take in account the bitmap size and margins
123  SetMinSize( wxSize( minwidth, -1 ) );
124 }
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
static int layer2hotkey_id(PCB_LAYER_ID aLayer)
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
Definition: lset.cpp:676
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
#define BM_SIZE
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
#define max(a, b)
Definition: auxiliary.h:86
wxString GetLayerName(LAYER_NUM aLayer) const override
LSEQ UIOrder() const
Definition: lset.cpp:752
void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )
inherited

Definition at line 138 of file class_layer_box_selector.cpp.

References LAYER_SELECTOR::SetBitmapLayer().

Referenced by LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR(), and GERBER_LAYER_WIDGET::OnLayerColorChange().

139 {
140  int elements = GetCount();
141 
142  for( LAYER_NUM i = 0; i < elements; ++i )
143  {
144  wxBitmap layerbmp( 14, 14 );
145  SetBitmapLayer( layerbmp, i );
146  }
147 }
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
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(), 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
int LAYER_BOX_SELECTOR::SetLayerSelection ( LAYER_NUM  layer)
inherited

Definition at line 114 of file class_layer_box_selector.cpp.

Referenced by DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PCB_EDIT_FRAME::OnUpdateLayerSelectBox(), DialogEditModuleText::TransferDataToWindow(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow().

115 {
116  int elements = GetCount();
117 
118  for( int i = 0; i < elements; i++ )
119  {
120  if( GetClientData( i ) == (void*)(intptr_t) layer )
121  {
122  if( GetSelection() != i ) // Element (i) is not selected
123  {
124  SetSelection( i );
125  return i;
126  }
127  else
128  return i; //If element already selected; do nothing
129  }
130  }
131 
132  // Not Found
133  SetSelection( -1 );
134  return -1;
135 }
bool LAYER_SELECTOR::SetLayersOrdered ( bool  value)
inherited
void PCB_LAYER_BOX_SELECTOR::ShowNonActivatedLayers ( bool  aShow)
inline

Member Data Documentation

PCB_BASE_FRAME* PCB_LAYER_BOX_SELECTOR::m_boardFrame
private
EDA_HOTKEY_CONFIG* PCB_LAYER_BOX_SELECTOR::m_hotkeys

Definition at line 46 of file class_pcb_layer_box_selector.h.

Referenced by PCB_EDIT_FRAME::ReCreateLayerBox(), and Resync().

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited
LSET PCB_LAYER_BOX_SELECTOR::m_layerMaskDisable
private

Definition at line 39 of file class_pcb_layer_box_selector.h.

Referenced by Resync().

bool PCB_LAYER_BOX_SELECTOR::m_showNotEnabledBrdlayers
private

Definition at line 41 of file class_pcb_layer_box_selector.h.

Referenced by Resync().


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