37 #include <wx/choicdlg.h> 38 #include <wx/treebook.h> 46 #define HIDE_INACTIVE_LAYERS 126 m_parentDialog( aParent ),
128 m_physicalStackup( nullptr )
136 #define RETURN_COPPER( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##Choice ) 137 #define RETURN_AUX( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, x##CheckBox, x##StaticText ) 138 #define RETURN_MANDATORY( x ) return PANEL_SETUP_LAYERS_CTLs( x##Name, nullptr, x##StaticText ) 140 switch( aLayerNumber )
208 wxASSERT_MSG( 0, wxT(
"bad layer id" ) );
272 #ifdef HIDE_INACTIVE_LAYERS 279 ctl.
name->Show( state );
281 ctl.
choice->Show( state );
287 #ifdef HIDE_INACTIVE_LAYERS 304 wxControl* ctl =
getName( layer );
310 if(
auto textCtl = dynamic_cast<wxTextCtrl*>( ctl ) )
311 textCtl->ChangeValue( lname );
313 ctl->SetLabel( lname );
344 LSET layerMaskResult;
351 if( !ctl || ctl->GetValue() )
352 layerMaskResult.set( layer );
355 return layerMaskResult;
366 ctl.
checkbox->SetValue( isChecked );
372 if( copperCount > 0 )
378 if( copperCount > 0 )
387 bool state = copperCount > 0;
389 #ifdef HIDE_INACTIVE_LAYERS 396 ctl.
name->Show( state );
398 ctl.
choice->Show( state );
404 #ifdef HIDE_INACTIVE_LAYERS 421 wxObject* source =
event.GetEventObject();
428 if( source == copper )
431 _(
"Use the Physical Stackup page to change the number of copper layers." ) );
433 copper->SetValue(
true );
451 bool modified =
false;
459 if( !notremovableLayers.empty() )
461 for(
unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
466 "These items will be no longer accessible\n" 467 "Do you wish to continue?" ), msg ) ) )
473 if( !removedLayers.empty()
474 && !
IsOK(
this,
_(
"Items have been found on removed layers. This operation will " 475 "delete all items from removed layers and cannot be undone.\n" 476 "Do you wish to continue?" ) ) )
483 bool hasRemovedBoardItems =
false;
485 if( !removedLayers.empty() )
495 for(
int i = 0; i < collector.
GetCount(); i++ )
500 layers.reset( layer_id );
501 hasRemovedBoardItems =
true;
578 if( hasRemovedBoardItems )
595 int ret = ctl->GetCurrentSelection();
602 wxControl* control =
getName( aLayer );
604 if(
auto textCtl = dynamic_cast<wxTextCtrl*>( control ) )
605 return textCtl->GetValue().Trim();
607 return control->GetLabel();
611 static bool hasOneOf(
const wxString& str,
const wxString& chars )
613 for(
unsigned i=0; i<chars.Len(); ++i )
615 if( str.Find( chars[i] ) != wxNOT_FOUND )
625 std::vector<wxString> names;
639 ctl = (wxTextCtrl*)
getName( layer );
649 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
650 badchars.Append(
'%' );
660 wxString msg =
wxString::Format(
_(
"%s are forbidden in layer names." ), badchars );
665 if(
name == wxT(
"signal" ) )
671 for(
const wxString& existingName : names )
673 if(
name == existingName )
681 names.push_back(
name );
694 if( newLayers == curLayers )
695 return removedLayers;
698 LSEQ newLayerSeq = newLayers.
Seq();
708 removedLayers.push_back( layer_id );
712 return removedLayers;
723 if( newLayers == curLayers )
727 LSEQ newLayerSeq = newLayers.
Seq();
729 for(
auto layer_id : curLayers.
Seq() )
740 inUseLayers.push_back( layer_id );
767 bool okToDeleteCopperLayers =
true;
773 if( newNumLayers < currNumLayers )
775 wxString msg =
wxString::Format(
_(
"Imported settings have fewer copper layers than " 776 "the current board (%i instead of %i).\n\n" 777 "Continue and delete the extra inner copper layers " 778 "from the current board?" ),
782 wxMessageDialog dlg(
this, msg,
_(
"Inner Layers To Be Deleted" ),
783 wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
785 if( wxID_NO == dlg.ShowModal() )
786 okToDeleteCopperLayers =
false;
789 return okToDeleteCopperLayers;
795 wxArrayString headers;
796 headers.Add(
_(
"Layers" ) );
799 std::vector<wxArrayString> list;
805 if( checkBox && checkBox->IsShown() )
808 wxArrayString available_user_layer;
809 available_user_layer.Add(
LayerName( *seq ) );
811 list.emplace_back( available_user_layer );
817 _(
"All user-defined layers have already been added." ) );
838 LSET newLayer( *seq );
847 wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( ctl.
name );
849 wxCHECK( textCtrl, );
851 ctl.
name->Show(
true );
static LSET UserDefinedLayers()
Return a mask with all of the allowable user defined layers.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
LSEQ getNonRemovableLayers()
Return a list of layers in use in footprints, and therefore not removable.
void OnModify() override
Must be called after a board change to set the modified flag.
static const KICAD_T FootprintItems[]
A scan list for primary footprint items.
static const KICAD_T BoardLevelItems[]
A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT,...
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
static bool hasOneOf(const wxString &str, const wxString &chars)
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
void OnCheckBox(wxCommandEvent &event) override
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
PANEL_SETUP_LAYERS(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
void setMandatoryLayerCheckBoxes()
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
This file is part of the common library.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
bool TransferDataFromWindow() override
wxScrolledWindow * m_LayersListPanel
void SyncCopperLayers(int aNumCopperLayers)
Called when switching to this tab to make sure that any changes to the copper layer count made on the...
bool TransferDataToWindow() override
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Class PANEL_SETUP_LAYERS_BASE.
int LAYER_NUM
This can be replaced with int and removed.
void Collect(BOARD_ITEM *aBoard, const KICAD_T aScanList[])
Test a BOARD_ITEM using this class's Inspector method, which does the collection.
wxChoice * getChoice(LAYER_NUM aLayer)
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
Collect all BOARD_ITEM objects on a given layer.
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
virtual void SetLayerSet(LSET aLayers)
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
PAGED_DIALOG * m_parentDialog
void SetLayerId(PCB_LAYER_ID aLayerId)
wxCheckBox * getCheckBox(LAYER_NUM aLayer)
void setCopperLayerCheckBoxes(int copperCount)
int GetCount() const
Return the number of objects in the list.
bool CheckCopperLayerCount(BOARD *aWorkingBoard, BOARD *aImportedBoard)
Check and warn if inner copper layers will be deleted.
LSET is a set of PCB_LAYER_IDs.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
virtual void addUserDefinedLayer(wxCommandEvent &aEvent) override
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
static LSET AllLayersMask()
void setUserDefinedLayerCheckBoxes()
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
void ImportSettingsFrom(BOARD *aBoard)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
PANEL_SETUP_LAYERS_CTLs getCTLs(LAYER_NUM aLayerNumber)
#define RETURN_MANDATORY(x)
Information pertinent to a Pcbnew printed circuit board.
PCB_LAYER_ID
A quick note on layer IDs:
int GetCopperLayerCount() const
The main frame for Pcbnew.
void showSelectedLayerCheckBoxes(LSET enableLayerMask)
wxControl * getName(LAYER_NUM aLayer)
wxString GetLayerName(LAYER_NUM layer)
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
void setLayerCheckBox(LAYER_NUM layer, bool isChecked)
void showBoardLayerNames()
int getLayerTypeIndex(LAYER_NUM layer)
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
The 3 UI control pointers for a single board layer.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
int GetCopperLayerCount() const
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void DenyChangeCheckBox(wxCommandEvent &event) override
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
LSEQ getRemovedLayersWithItems()
Return a list of layers removed from the board that contain items.
PANEL_SETUP_BOARD_STACKUP * m_physicalStackup
void SetListLabel(const wxString &aLabel)