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 )
144 switch( aLayerNumber )
212 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
310 wxControl* ctl =
getName( layer );
316 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( ctl ) )
317 textCtl->ChangeValue( lname );
319 ctl->SetLabel( lname );
350 LSET layerMaskResult;
357 if( !ctl || ctl->GetValue() )
358 layerMaskResult.set( layer );
361 return layerMaskResult;
372 ctl.
checkbox->SetValue( isChecked );
378 if( copperCount > 0 )
384 if( copperCount > 0 )
393 bool state = copperCount > 0;
395#ifdef HIDE_INACTIVE_LAYERS
402 ctl.
name->Show( state );
404 ctl.
choice->Show( state );
410#ifdef HIDE_INACTIVE_LAYERS
427 wxObject* source =
event.GetEventObject();
433 if( source == copper )
436 _(
"Use the Physical Stackup page to change the number of "
437 "copper layers." ) );
439 copper->SetValue(
true );
456 bool modified =
false;
464 if( !notremovableLayers.empty() )
466 for(
unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
469 if( !
IsOK( wxGetTopLevelParent(
this ),
470 wxString::Format(
_(
"Footprints have some items on removed layers:\n"
472 "These items will be no longer accessible\n"
473 "Do you wish to continue?" ), msg ) ) )
479 if( !removedLayers.empty()
480 && !
IsOK( wxGetTopLevelParent(
this ),
481 _(
"Items have been found on removed layers. This operation will "
482 "delete all items from removed layers and cannot be undone.\n"
483 "Do you wish to continue?" ) ) )
490 bool hasRemovedBoardItems =
false;
492 if( !removedLayers.empty() )
504 for(
int i = 0; i < collector.
GetCount(); i++ )
518 layers.reset( layer_id );
519 hasRemovedBoardItems =
true;
557 for(
PAD*
pad : fp->Pads() )
559 if(
pad->HasHole() &&
pad->IsOnCopperLayer() )
614 if( hasRemovedBoardItems )
627 int ret = ctl->GetCurrentSelection();
634 wxControl* control =
getName( aLayer );
636 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( control ) )
637 return textCtl->GetValue().Trim();
639 return control->GetLabel();
643static bool hasOneOf(
const wxString& str,
const wxString& chars )
645 for(
unsigned i=0; i<chars.Len(); ++i )
647 if( str.Find( chars[i] ) != wxNOT_FOUND )
657 std::vector<wxString> names;
671 ctl = (wxTextCtrl*)
getName( layer );
681 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
682 badchars.Append(
'%' );
692 wxString msg = wxString::Format(
_(
"%s are forbidden in layer names." ), badchars );
697 if(
name == wxT(
"signal" ) )
704 for(
const wxString& existingName : names )
706 if(
name == existingName )
708 wxString msg = wxString::Format(
_(
"Layer name '%s' already in use." ),
name );
714 names.push_back(
name );
727 if( newLayers == curLayers )
728 return removedLayers;
731 LSEQ newLayerSeq = newLayers.
Seq();
744 for(
int i = 0; i < collector.
GetCount(); i++ )
752 removedLayers.push_back( layer_id );
759 return removedLayers;
770 if( newLayers == curLayers )
774 LSEQ newLayerSeq = newLayers.
Seq();
787 inUseLayers.push_back( layer_id );
814 bool okToDeleteCopperLayers =
true;
820 if( newNumLayers < currNumLayers )
822 wxString msg = wxString::Format(
_(
"Imported settings have fewer copper layers than "
823 "the current board (%i instead of %i).\n\n"
824 "Continue and delete the extra inner copper layers "
825 "from the current board?" ),
829 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
831 wxMessageDialog dlg( topLevelParent, msg,
_(
"Inner Layers To Be Deleted" ),
832 wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
834 if( wxID_NO == dlg.ShowModal() )
835 okToDeleteCopperLayers =
false;
838 return okToDeleteCopperLayers;
844 wxArrayString headers;
845 headers.Add(
_(
"Layers" ) );
848 std::vector<wxArrayString> list;
854 if( checkBox && checkBox->IsShown() )
857 wxArrayString available_user_layer;
858 available_user_layer.Add(
LayerName( *seq ) );
860 list.emplace_back( available_user_layer );
866 _(
"All user-defined layers have already been added." ) );
888 LSET newLayer( *seq );
897 wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( ctl.
name );
899 wxCHECK( textCtrl, );
901 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...
FOOTPRINT * GetParentFootprint() const
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.
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.
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()
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:
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.