KiCad PCB EDA Suite
PCB_LAYER_BOX_SELECTOR Class Reference

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

#include <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 SetNotAllowedLayerSet (LSET aMask)
 
void Resync () override
 
void ShowNonActivatedLayers (bool aShow)
 
int GetChoice ()
 
LAYER_NUM GetLayerSelection () const
 
int SetLayerSelection (LAYER_NUM layer)
 
void ResyncBitmapOnly ()
 
bool SetLayersHotkeys (bool value)
 

Static Public Member Functions

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

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 pcb_layer_box_selector.h.

Constructor & Destructor Documentation

◆ PCB_LAYER_BOX_SELECTOR()

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 50 of file pcb_layer_box_selector.h.

54  :
55  LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
56  {
59  }
LAYER_BOX_SELECTOR(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL)
#define NULL

References m_boardFrame, m_showNotEnabledBrdlayers, and NULL.

Member Function Documentation

◆ DrawColorSwatch()

void LAYER_SELECTOR::DrawColorSwatch ( wxBitmap &  aLayerbmp,
COLOR4D  aBackground,
COLOR4D  aColor 
)
staticinherited

Definition at line 47 of file layer_box_selector.cpp.

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

References KIGFX::COLOR4D::WithAlpha().

Referenced by PANEL_SETUP_BOARD_STACKUP::createBmComboBox(), GRID_CELL_LAYER_RENDERER::Draw(), PANEL_SETUP_BOARD_STACKUP::onColorSelected(), GBR_LAYER_BOX_SELECTOR::Resync(), Resync(), LAYER_BOX_SELECTOR::ResyncBitmapOnly(), and PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard().

◆ GetChoice()

int LAYER_BOX_SELECTOR::GetChoice ( )
inherited

Definition at line 109 of file layer_box_selector.cpp.

110 {
111  return GetSelection();
112 }

◆ getEnabledLayers()

LSET PCB_LAYER_BOX_SELECTOR::getEnabledLayers ( ) const
private

Definition at line 129 of file pcb_layer_box_selector.cpp.

130 {
131  wxASSERT( m_boardFrame != NULL );
132  BOARD* board = m_boardFrame->GetBoard();
133  wxASSERT( board != NULL );
134 
135  return board->GetEnabledLayers();
136 }
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
#define NULL
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
BOARD * GetBoard() const

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

Referenced by Resync().

◆ GetLayerColor()

COLOR4D PCB_LAYER_BOX_SELECTOR::GetLayerColor ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 140 of file pcb_layer_box_selector.cpp.

141 {
142  wxASSERT( m_boardFrame );
143 
144  return m_boardFrame->Settings().Colors().GetLayerColor( aLayer );
145 }
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
PCB_GENERAL_SETTINGS & Settings()
COLORS_DESIGN_SETTINGS & Colors()

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

Referenced by Resync().

◆ GetLayerName()

wxString PCB_LAYER_BOX_SELECTOR::GetLayerName ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 149 of file pcb_layer_box_selector.cpp.

150 {
151  wxASSERT( m_boardFrame );
152  BOARD* board = m_boardFrame->GetBoard();
153  wxASSERT( board );
154 
155  return board->GetLayerName( ToLAYER_ID( aLayer ) );
156 }
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
BOARD * GetBoard() const
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823

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

Referenced by Resync().

◆ GetLayerSelection()

◆ IsLayerEnabled()

bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 119 of file pcb_layer_box_selector.cpp.

120 {
121  wxASSERT( m_boardFrame != NULL );
122  BOARD* board = m_boardFrame->GetBoard();
123  wxASSERT( board != NULL );
124 
125  return board->IsLayerEnabled( ToLAYER_ID( aLayer ) );
126 }
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:437
#define NULL
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
BOARD * GetBoard() const
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823

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

◆ Resync()

void PCB_LAYER_BOX_SELECTOR::Resync ( )
overridevirtual

Implements LAYER_BOX_SELECTOR.

Definition at line 66 of file pcb_layer_box_selector.cpp.

67 {
68  Clear();
69 
70  // Tray to fix a minimum width fot the BitmapComboBox
71  int minwidth = 80;
72 
73  wxClientDC dc( GetParent() ); // The DC for "this" is not always initialized
74 
75  const int BM_SIZE = 14;
76 
78  LSET activated = getEnabledLayers() & ~m_layerMaskDisable;
79  wxString layerstatus;
80 
81  for( LSEQ seq = show.UIOrder(); seq; ++seq )
82  {
83  PCB_LAYER_ID layerid = *seq;
84 
85  if( !m_showNotEnabledBrdlayers && !activated[layerid] )
86  continue;
87  else if( !activated[layerid] )
88  layerstatus = wxT( " " ) + _( "(not activated)" );
89  else
90  layerstatus.Empty();
91 
92  wxBitmap bmp( BM_SIZE, BM_SIZE );
94 
95  wxString layername = GetLayerName( layerid ) + layerstatus;
96 
97  if( m_layerhotkeys )
98  {
99  TOOL_ACTION* action = layer2action( layerid );
100 
101  if( action )
102  layername = AddHotkeyName( layername, action->GetHotKey(), IS_COMMENT );
103  }
104 
105  Append( layername, bmp, (void*)(intptr_t) layerid );
106 
107  int w, h;
108  dc.GetTextExtent ( layername, &w, &h );
109  minwidth = std::max( minwidth, w );
110  }
111 
112  // Approximate bitmap size and margins
113  minwidth += BM_SIZE + 32 + ConvertDialogToPixels( wxSize( 8, 0 ) ).x;
114  SetMinSize( wxSize( minwidth, -1 ) );
115 }
static TOOL_ACTION * layer2action(PCB_LAYER_ID aLayer)
wxString AddHotkeyName(const wxString &aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle)
AddHotkeyName.
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
Definition: lset.cpp:723
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
#define BM_SIZE
#define _(s)
Definition: 3d_actions.cpp:31
TOOL_ACTION.
Definition: tool_action.h:46
COLOR4D GetLayerColor(LAYER_NUM aLayer) const override
LSEQ UIOrder() const
Definition: lset.cpp:813
int GetHotKey() const
Function GetHotKey() Returns the hotkey keycode which initiates the action.
Definition: tool_action.h:90
wxString GetLayerName(LAYER_NUM aLayer) const override

References _, AddHotkeyName(), LSET::AllLayersMask(), BM_SIZE, LAYER_SELECTOR::DrawColorSwatch(), getEnabledLayers(), TOOL_ACTION::GetHotKey(), GetLayerColor(), GetLayerName(), IS_COMMENT, layer2action(), LAYER_PCB_BACKGROUND, LAYER_SELECTOR::m_layerhotkeys, m_layerMaskDisable, m_showNotEnabledBrdlayers, and LSET::UIOrder().

Referenced by GRID_CELL_LAYER_SELECTOR::BeginEdit(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), FOOTPRINT_EDIT_FRAME::ReCreateHToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateLayerBox(), and PCB_EDIT_FRAME::ReCreateLayerBox().

◆ ResyncBitmapOnly()

void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )
inherited

Definition at line 150 of file layer_box_selector.cpp.

151 {
152  int elements = GetCount();
153 
154  for( LAYER_NUM i = 0; i < elements; ++i )
155  {
156  wxBitmap layerbmp( 14, 14 );
158  }
159 }
virtual COLOR4D GetLayerColor(LAYER_NUM aLayer) const =0
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)

References LAYER_SELECTOR::DrawColorSwatch(), LAYER_SELECTOR::GetLayerColor(), and LAYER_PCB_BACKGROUND.

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

◆ SetBoardFrame()

◆ SetLayerSelection()

int LAYER_BOX_SELECTOR::SetLayerSelection ( LAYER_NUM  layer)
inherited

Definition at line 126 of file layer_box_selector.cpp.

127 {
128  int elements = GetCount();
129 
130  for( int i = 0; i < elements; i++ )
131  {
132  if( GetClientData( (unsigned) i ) == (void*)(intptr_t) layer )
133  {
134  if( GetSelection() != i ) // Element (i) is not selected
135  {
136  SetSelection( i );
137  return i;
138  }
139  else
140  return i; //If element already selected; do nothing
141  }
142  }
143 
144  // Not Found
145  SetSelection( -1 );
146  return -1;
147 }

Referenced by GRID_CELL_LAYER_SELECTOR::BeginEdit(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox(), PCB_EDIT_FRAME::OnUpdateLayerSelectBox(), DIALOG_TRACK_VIA_PROPERTIES::onViaEdit(), GRID_CELL_LAYER_SELECTOR::Reset(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), and DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow().

◆ SetLayersHotkeys()

◆ SetNotAllowedLayerSet()

◆ ShowNonActivatedLayers()

void PCB_LAYER_BOX_SELECTOR::ShowNonActivatedLayers ( bool  aShow)
inline

Member Data Documentation

◆ m_boardFrame

PCB_BASE_FRAME* PCB_LAYER_BOX_SELECTOR::m_boardFrame
private

◆ m_layerhotkeys

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited

◆ m_layerMaskDisable

LSET PCB_LAYER_BOX_SELECTOR::m_layerMaskDisable
private

Definition at line 39 of file pcb_layer_box_selector.h.

Referenced by Resync(), and SetNotAllowedLayerSet().

◆ m_showNotEnabledBrdlayers

bool PCB_LAYER_BOX_SELECTOR::m_showNotEnabledBrdlayers
private

Definition at line 41 of file pcb_layer_box_selector.h.

Referenced by PCB_LAYER_BOX_SELECTOR(), Resync(), and ShowNonActivatedLayers().


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