39#include <wx/choicdlg.h>
47#define HIDE_INACTIVE_LAYERS
128 m_physicalStackup( nullptr ),
129 m_initialized( false )
137#define RETURN_COPPER( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##Choice )
138#define RETURN_AUX( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##StaticText )
139#define RETURN_MANDATORY( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, nullptr, x##StaticText )
141 switch( aLayerNumber )
209 wxASSERT_MSG( 0, wxT(
"bad layer id" ) );
275#ifdef HIDE_INACTIVE_LAYERS
282 ctl.
name->Show( state );
284 ctl.
choice->Show( state );
290#ifdef HIDE_INACTIVE_LAYERS
307 wxControl* ctl =
getName( layer );
313 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( ctl ) )
314 textCtl->ChangeValue( lname );
316 ctl->SetLabel( lname );
347 LSET layerMaskResult;
354 if( !ctl || ctl->GetValue() )
355 layerMaskResult.set( layer );
358 return layerMaskResult;
369 ctl.
checkbox->SetValue( isChecked );
375 if( copperCount > 0 )
381 if( copperCount > 0 )
390 bool state = copperCount > 0;
392#ifdef HIDE_INACTIVE_LAYERS
399 ctl.
name->Show( state );
401 ctl.
choice->Show( state );
407#ifdef HIDE_INACTIVE_LAYERS
424 wxObject* source =
event.GetEventObject();
430 if( source == copper )
432 DisplayError(
this,
_(
"Use the Physical Stackup page to change the number of "
433 "copper layers." ) );
435 copper->SetValue(
true );
452 bool modified =
false;
460 if( !notremovableLayers.empty() )
462 for(
unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
465 if( !
IsOK(
this, wxString::Format(
_(
"Footprints have some items on removed layers:\n"
467 "These items will be no longer accessible\n"
468 "Do you wish to continue?" ), msg ) ) )
474 if( !removedLayers.empty()
475 && !
IsOK(
this,
_(
"Items have been found on removed layers. This operation will "
476 "delete all items from removed layers and cannot be undone.\n"
477 "Do you wish to continue?" ) ) )
484 bool hasRemovedBoardItems =
false;
486 if( !removedLayers.empty() )
496 for(
int i = 0; i < collector.
GetCount(); i++ )
501 layers.reset( layer_id );
502 hasRemovedBoardItems =
true;
540 for(
PAD*
pad : fp->Pads() )
542 if(
pad->HasHole() &&
pad->IsOnCopperLayer() )
598 if( hasRemovedBoardItems )
611 int ret = ctl->GetCurrentSelection();
618 wxControl* control =
getName( aLayer );
620 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( control ) )
621 return textCtl->GetValue().Trim();
623 return control->GetLabel();
627static bool hasOneOf(
const wxString& str,
const wxString& chars )
629 for(
unsigned i=0; i<chars.Len(); ++i )
631 if( str.Find( chars[i] ) != wxNOT_FOUND )
641 std::vector<wxString> names;
655 ctl = (wxTextCtrl*)
getName( layer );
665 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
666 badchars.Append(
'%' );
676 wxString msg = wxString::Format(
_(
"%s are forbidden in layer names." ), badchars );
681 if(
name == wxT(
"signal" ) )
688 for(
const wxString& existingName : names )
690 if(
name == existingName )
692 wxString msg = wxString::Format(
_(
"Layer name '%s' already in use." ),
name );
698 names.push_back(
name );
711 if( newLayers == curLayers )
712 return removedLayers;
715 LSEQ newLayerSeq = newLayers.
Seq();
725 removedLayers.push_back( layer_id );
729 return removedLayers;
740 if( newLayers == curLayers )
744 LSEQ newLayerSeq = newLayers.
Seq();
757 inUseLayers.push_back( layer_id );
784 bool okToDeleteCopperLayers =
true;
790 if( newNumLayers < currNumLayers )
792 wxString msg = wxString::Format(
_(
"Imported settings have fewer copper layers than "
793 "the current board (%i instead of %i).\n\n"
794 "Continue and delete the extra inner copper layers "
795 "from the current board?" ),
799 wxMessageDialog dlg(
this, msg,
_(
"Inner Layers To Be Deleted" ),
800 wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
802 if( wxID_NO == dlg.ShowModal() )
803 okToDeleteCopperLayers =
false;
806 return okToDeleteCopperLayers;
812 wxArrayString headers;
813 headers.Add(
_(
"Layers" ) );
816 std::vector<wxArrayString> list;
822 if( checkBox && checkBox->IsShown() )
825 wxArrayString available_user_layer;
826 available_user_layer.Add(
LayerName( *seq ) );
828 list.emplace_back( available_user_layer );
834 _(
"All user-defined layers have already been added." ) );
856 LSET newLayer( *seq );
865 wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( ctl.
name );
867 wxCHECK( textCtrl, );
869 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.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual void SetLayerSet(LSET aLayers)
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.
FOOTPRINTS & Footprints()
int GetCopperLayerCount() 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.
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
int getLayerTypeIndex(int layer)
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()
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:
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)
The 3 UI control pointers for a single board layer.