40#include <wx/choicdlg.h>
41#include <wx/treebook.h>
49#define HIDE_INACTIVE_LAYERS
129 m_parentDialog( aParent ),
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 )
435 DisplayError(
this,
_(
"Use the Physical Stackup page to change the number of "
436 "copper layers." ) );
438 copper->SetValue(
true );
456 bool modified =
false;
464 if( !notremovableLayers.empty() )
466 for(
unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
471 "These items will be no longer accessible\n"
472 "Do you wish to continue?" ), msg ) ) )
478 if( !removedLayers.empty()
479 && !
IsOK(
this,
_(
"Items have been found on removed layers. This operation will "
480 "delete all items from removed layers and cannot be undone.\n"
481 "Do you wish to continue?" ) ) )
488 bool hasRemovedBoardItems =
false;
490 if( !removedLayers.empty() )
500 for(
int i = 0; i < collector.
GetCount(); i++ )
505 layers.reset( layer_id );
506 hasRemovedBoardItems =
true;
544 for(
PAD*
pad : fp->Pads() )
546 if(
pad->HasHole() &&
pad->IsOnCopperLayer() )
602 if( hasRemovedBoardItems )
615 int ret = ctl->GetCurrentSelection();
624 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>(
control ) )
625 return textCtl->GetValue().Trim();
631static bool hasOneOf(
const wxString& str,
const wxString& chars )
633 for(
unsigned i=0; i<chars.Len(); ++i )
635 if( str.Find( chars[i] ) != wxNOT_FOUND )
645 std::vector<wxString> names;
659 ctl = (wxTextCtrl*)
getName( layer );
669 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
670 badchars.Append(
'%' );
680 wxString msg =
wxString::Format(
_(
"%s are forbidden in layer names." ), badchars );
685 if(
name == wxT(
"signal" ) )
691 for(
const wxString& existingName : names )
693 if(
name == existingName )
701 names.push_back(
name );
714 if( newLayers == curLayers )
715 return removedLayers;
718 LSEQ newLayerSeq = newLayers.
Seq();
728 removedLayers.push_back( layer_id );
732 return removedLayers;
743 if( newLayers == curLayers )
747 LSEQ newLayerSeq = newLayers.
Seq();
760 inUseLayers.push_back( layer_id );
787 bool okToDeleteCopperLayers =
true;
793 if( newNumLayers < currNumLayers )
795 wxString msg =
wxString::Format(
_(
"Imported settings have fewer copper layers than "
796 "the current board (%i instead of %i).\n\n"
797 "Continue and delete the extra inner copper layers "
798 "from the current board?" ),
802 wxMessageDialog dlg(
this, msg,
_(
"Inner Layers To Be Deleted" ),
803 wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
805 if( wxID_NO == dlg.ShowModal() )
806 okToDeleteCopperLayers =
false;
809 return okToDeleteCopperLayers;
815 wxArrayString headers;
816 headers.Add(
_(
"Layers" ) );
819 std::vector<wxArrayString> list;
825 if( checkBox && checkBox->IsShown() )
828 wxArrayString available_user_layer;
829 available_user_layer.Add(
LayerName( *seq ) );
831 list.emplace_back( available_user_layer );
837 _(
"All user-defined layers have already been added." ) );
858 LSET newLayer( *seq );
867 wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( ctl.
name );
869 wxCHECK( textCtrl, );
871 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.
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)
PANEL_SETUP_LAYERS(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
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
void ImportSettingsFrom(BOARD *aBoard)
void setMandatoryLayerCheckBoxes()
wxCheckBox * getCheckBox(int aLayer)
PAGED_DIALOG * m_parentDialog
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:
must_if< error >::control< Rule > control
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)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
The 3 UI control pointers for a single board layer.