41#include <wx/choicdlg.h>
50#define HIDE_INACTIVE_LAYERS
139 m_physicalStackup( nullptr ),
140 m_initialized( false )
148#define RETURN_COPPER( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##Choice )
149#define RETURN_AUX( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##StaticText )
150#define RETURN_MANDATORY( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, nullptr, x##StaticText )
151#define RETURN_USER( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##Type )
153 switch( aLayerNumber )
221 wxASSERT_MSG( 0, wxT(
"bad layer id" ) );
288#ifdef HIDE_INACTIVE_LAYERS
295 ctl.
name->Show( state );
297 ctl.
choice->Show( state );
303#ifdef HIDE_INACTIVE_LAYERS
319 wxControl* ctl =
getName( layer );
325 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( ctl ) )
326 textCtl->ChangeValue( lname );
328 ctl->SetLabel( lname );
357 default:
getChoice( ii )->SetSelection( 0 );
break;
365 LSET layerMaskResult;
371 if( !ctl || ctl->GetValue() )
372 layerMaskResult.
set( layer );
375 return layerMaskResult;
386 ctl.
checkbox->SetValue( isChecked );
392 if( copperCount > 0 )
398 if( copperCount > 0 )
406 bool state = copperCount > 0;
408#ifdef HIDE_INACTIVE_LAYERS
415 ctl.
name->Show( state );
417 ctl.
choice->Show( state );
424#ifdef HIDE_INACTIVE_LAYERS
441 wxObject* source =
event.GetEventObject();
447 if( source == copper )
450 _(
"Use the Physical Stackup page to change the number of "
451 "copper layers." ) );
453 copper->SetValue(
true );
470 bool modified =
false;
478 if( !notremovableLayers.empty() )
480 for(
unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
483 if( !
IsOK( wxGetTopLevelParent(
this ),
484 wxString::Format(
_(
"Footprints have some items on removed layers:\n"
486 "These items will be no longer accessible\n"
487 "Do you wish to continue?" ), msg ) ) )
493 if( !removedLayers.empty()
494 && !
IsOK( wxGetTopLevelParent(
this ),
495 _(
"Items have been found on removed layers. This operation will "
496 "delete all items from removed layers and cannot be undone.\n"
497 "Do you wish to continue?" ) ) )
504 bool hasRemovedBoardItems =
false;
506 if( !removedLayers.empty() )
518 for(
int i = 0; i < collector.
GetCount(); i++ )
538 if(
via->GetViaType() == VIATYPE::THROUGH )
544 via->LayerPair( &top_layer, &bottom_layer );
546 if( top_layer != layer_id && bottom_layer != layer_id )
559 layers.
reset( layer_id );
560 hasRemovedBoardItems =
true;
602 for(
PAD*
pad : fp->Pads() )
604 if(
pad->HasHole() &&
pad->IsOnCopperLayer() )
654 case 0: t =
LT_AUX;
break;
682 if( hasRemovedBoardItems )
694 wxControl* control =
getName( aLayer );
696 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( control ) )
697 return textCtl->GetValue().Trim();
699 return control->GetLabel();
703static bool hasOneOf(
const wxString& str,
const wxString& chars )
705 for(
unsigned i=0; i<chars.Len(); ++i )
707 if( str.Find( chars[i] ) != wxNOT_FOUND )
717 std::vector<wxString> names;
729 ctl = (wxTextCtrl*)
getName( layer );
739 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
740 badchars.Append(
'%' );
750 wxString msg = wxString::Format(
_(
"%s are forbidden in layer names." ), badchars );
755 if(
name == wxT(
"signal" ) )
762 for(
const wxString& existingName : names )
764 if(
name == existingName )
766 wxString msg = wxString::Format(
_(
"Layer name '%s' already in use." ),
name );
772 names.push_back(
name );
785 if( newLayers == curLayers )
786 return removedLayers;
789 LSEQ newLayerSeq = newLayers.
Seq();
802 for(
int i = 0; i < collector.
GetCount(); i++ )
816 if(
via->GetViaType() == VIATYPE::THROUGH )
822 via->LayerPair( &top_layer, &bottom_layer );
824 if( top_layer != layer_id && bottom_layer != layer_id )
829 removedLayers.push_back( layer_id );
836 return removedLayers;
847 if( newLayers == curLayers )
851 LSEQ newLayerSeq = newLayers.
Seq();
864 inUseLayers.push_back( layer_id );
891 bool okToDeleteCopperLayers =
true;
897 if( newNumLayers < currNumLayers )
899 wxString msg = wxString::Format(
_(
"Imported settings have fewer copper layers than "
900 "the current board (%i instead of %i).\n\n"
901 "Continue and delete the extra inner copper layers "
902 "from the current board?" ),
906 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
908 wxMessageDialog dlg( topLevelParent, msg,
_(
"Inner Layers to Be Deleted" ),
909 wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
911 if( wxID_NO == dlg.ShowModal() )
912 okToDeleteCopperLayers =
false;
915 return okToDeleteCopperLayers;
921 wxArrayString headers;
922 headers.Add(
_(
"Layers" ) );
925 std::vector<wxArrayString> list;
931 if( checkBox && checkBox->IsShown() )
934 wxArrayString available_user_layer;
935 available_user_layer.Add(
LayerName( layer ) );
937 list.emplace_back( available_user_layer );
943 _(
"All user-defined layers have already been added." ) );
968 LSET newLayer( { layer } );
978 wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( ctl.
name );
980 wxCHECK( textCtrl, );
983 wxChoice* userLayerType =
dynamic_cast<wxChoice*
>( ctl.
choice );
985 wxCHECK( userLayerType, );
986 userLayerType->SetSelection( 0 );
988 ctl.
name->Show(
true );
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
BASE_SET & reset(size_t pos)
BASE_SET & set(size_t pos)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void SetLayerSet(const LSET &aLayers)
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Information pertinent to a Pcbnew printed circuit board.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
int GetCopperLayerCount() const
const FOOTPRINTS & Footprints() const
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
int GetCount() const
Return the number of objects in the list.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
KICAD_T Type() const
Returns the type of object.
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
static const std::vector< KICAD_T > BoardLevelItems
A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT,...
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
static LSET UserDefinedLayers()
Return a mask with all of the allowable user defined layers.
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
int GetCopperLayerCount() const
Class PANEL_SETUP_LAYERS_BASE.
wxScrolledWindow * m_LayersListPanel
wxString GetLayerName(int layer)
PANEL_SETUP_LAYERS_CTLs getCTLs(int aLayerNumber)
void showSelectedLayerCheckBoxes(LSET enableLayerMask)
bool CheckCopperLayerCount(BOARD *aWorkingBoard, BOARD *aImportedBoard)
Check and warn if inner copper layers will be deleted.
void DenyChangeCheckBox(wxCommandEvent &event) override
bool TransferDataToWindow() override
virtual void addUserDefinedLayer(wxCommandEvent &aEvent) override
void SyncCopperLayers(int aNumCopperLayers)
Called when switching to this tab to make sure that any changes to the copper layer count made on the...
void setLayerCheckBox(int layer, bool isChecked)
PANEL_SETUP_BOARD_STACKUP * m_physicalStackup
LSEQ getNonRemovableLayers()
Return a list of layers in use in footprints, and therefore not removable.
void showBoardLayerNames()
void setCopperLayerCheckBoxes(int copperCount)
wxControl * getName(int aLayer)
wxChoice * getChoice(int aLayer)
LSEQ getRemovedLayersWithItems()
Return a list of layers removed from the board that contain items.
bool TransferDataFromWindow() override
void OnCheckBox(wxCommandEvent &event) override
PANEL_SETUP_LAYERS(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
void ImportSettingsFrom(BOARD *aBoard)
void setMandatoryLayerCheckBoxes()
wxCheckBox * getCheckBox(int aLayer)
void setUserDefinedLayerCheckBoxes()
static TOOL_ACTION selectionClear
Clear the current selection.
The main frame for Pcbnew.
void OnModify() override
Must be called after a board change to set the modified flag.
Collect all BOARD_ITEM objects on a given layer.
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Test a BOARD_ITEM using this class's Inspector method, which does the collection.
void SetLayerId(PCB_LAYER_ID aLayerId)
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
static LSET AllExistingLayersInDlgMask()
#define RETURN_MANDATORY(x)
static bool hasOneOf(const wxString &str, const wxString &chars)
std::deque< BOARD_ITEM * > GetCurrentSelection()
Get the list of selected objects.
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
The 3 UI control pointers for a single board layer.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint