41#include <wx/choicdlg.h>
50#define HIDE_INACTIVE_LAYERS
131 m_physicalStackup( nullptr ),
132 m_initialized( false )
140#define RETURN_COPPER( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##Choice )
141#define RETURN_AUX( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##StaticText )
142#define RETURN_MANDATORY( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, nullptr, x##StaticText )
143#define RETURN_USER( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##Type )
145 switch( aLayerNumber )
213 wxASSERT_MSG( 0, wxT(
"bad layer id" ) );
278#ifdef HIDE_INACTIVE_LAYERS
285 ctl.
name->Show( state );
287 ctl.
choice->Show( state );
293#ifdef HIDE_INACTIVE_LAYERS
309 wxControl* ctl =
getName( layer );
315 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( ctl ) )
316 textCtl->ChangeValue( lname );
318 ctl->SetLabel( lname );
347 default:
getChoice( ii )->SetSelection( 0 );
break;
355 LSET layerMaskResult;
361 if( !ctl || ctl->GetValue() )
362 layerMaskResult.
set( layer );
365 return layerMaskResult;
376 ctl.
checkbox->SetValue( isChecked );
382 if( copperCount > 0 )
388 if( copperCount > 0 )
396 bool state = copperCount > 0;
398#ifdef HIDE_INACTIVE_LAYERS
405 ctl.
name->Show( state );
407 ctl.
choice->Show( state );
414#ifdef HIDE_INACTIVE_LAYERS
431 wxObject* source =
event.GetEventObject();
437 if( source == copper )
440 _(
"Use the Physical Stackup page to change the number of "
441 "copper layers." ) );
443 copper->SetValue(
true );
460 bool modified =
false;
468 if( !notremovableLayers.empty() )
470 for(
unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
473 if( !
IsOK( wxGetTopLevelParent(
this ),
474 wxString::Format(
_(
"Footprints have some items on removed layers:\n"
476 "These items will be no longer accessible\n"
477 "Do you wish to continue?" ), msg ) ) )
483 if( !removedLayers.empty()
484 && !
IsOK( wxGetTopLevelParent(
this ),
485 _(
"Items have been found on removed layers. This operation will "
486 "delete all items from removed layers and cannot be undone.\n"
487 "Do you wish to continue?" ) ) )
494 bool hasRemovedBoardItems =
false;
496 if( !removedLayers.empty() )
508 for(
int i = 0; i < collector.
GetCount(); i++ )
522 layers.
reset( layer_id );
523 hasRemovedBoardItems =
true;
564 for(
PAD*
pad : fp->Pads() )
566 if(
pad->HasHole() &&
pad->IsOnCopperLayer() )
616 case 0: t =
LT_AUX;
break;
644 if( hasRemovedBoardItems )
656 wxControl* control =
getName( aLayer );
658 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( control ) )
659 return textCtl->GetValue().Trim();
661 return control->GetLabel();
665static bool hasOneOf(
const wxString& str,
const wxString& chars )
667 for(
unsigned i=0; i<chars.Len(); ++i )
669 if( str.Find( chars[i] ) != wxNOT_FOUND )
679 std::vector<wxString> names;
691 ctl = (wxTextCtrl*)
getName( layer );
701 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
702 badchars.Append(
'%' );
712 wxString msg = wxString::Format(
_(
"%s are forbidden in layer names." ), badchars );
717 if(
name == wxT(
"signal" ) )
724 for(
const wxString& existingName : names )
726 if(
name == existingName )
728 wxString msg = wxString::Format(
_(
"Layer name '%s' already in use." ),
name );
734 names.push_back(
name );
747 if( newLayers == curLayers )
748 return removedLayers;
751 LSEQ newLayerSeq = newLayers.
Seq();
764 for(
int i = 0; i < collector.
GetCount(); i++ )
771 removedLayers.push_back( layer_id );
778 return removedLayers;
789 if( newLayers == curLayers )
793 LSEQ newLayerSeq = newLayers.
Seq();
806 inUseLayers.push_back( layer_id );
833 bool okToDeleteCopperLayers =
true;
839 if( newNumLayers < currNumLayers )
841 wxString msg = wxString::Format(
_(
"Imported settings have fewer copper layers than "
842 "the current board (%i instead of %i).\n\n"
843 "Continue and delete the extra inner copper layers "
844 "from the current board?" ),
848 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
850 wxMessageDialog dlg( topLevelParent, msg,
_(
"Inner Layers To Be Deleted" ),
851 wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
853 if( wxID_NO == dlg.ShowModal() )
854 okToDeleteCopperLayers =
false;
857 return okToDeleteCopperLayers;
863 wxArrayString headers;
864 headers.Add(
_(
"Layers" ) );
867 std::vector<wxArrayString> list;
873 if( checkBox && checkBox->IsShown() )
876 wxArrayString available_user_layer;
877 available_user_layer.Add(
LayerName( layer ) );
879 list.emplace_back( available_user_layer );
885 _(
"All user-defined layers have already been added." ) );
910 LSET newLayer( layer );
920 wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( ctl.
name );
922 wxCHECK( textCtrl, );
925 wxChoice* userLayerType =
dynamic_cast<wxChoice*
>( ctl.
choice );
927 wxCHECK( userLayerType, );
928 userLayerType->SetSelection( 0 );
930 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 & set(size_t pos=std::numeric_limits< size_t >::max(), bool value=true)
BASE_SET & reset(size_t pos=std::numeric_limits< size_t >::max())
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.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
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.
static const wxChar * 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.
#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_FOOTPRINT_T
class FOOTPRINT, a footprint