42#include <wx/choicdlg.h>
57 aCheckBox.SetValue(
true );
58 aCheckBox.SetToolTip(
_(
"This layer is required and cannot be disabled" ) );
65 m_physicalStackup( nullptr ),
66 m_initialized( false )
75 wxDefaultPosition, wxDefaultSize, 0 );
77 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT
78 | wxRESERVE_SPACE_EVEN_IF_HIDDEN,
82 wxDefaultPosition, wxDefaultSize, 0 );
89 wxDefaultPosition, wxDefaultSize, 0 );
96 wxDefaultPosition, wxDefaultSize, 0 );
98 _(
"If you want a fabrication layer for the front side of the board" ) );
101 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
104 wxDefaultPosition, wxDefaultSize, 0 );
109 wxDefaultPosition, wxDefaultSize, 0 );
114 wxDefaultPosition, wxDefaultSize, 0 );
116 _(
"If you want an adhesive template for the front side of the board" ) );
119 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
122 wxDefaultPosition, wxDefaultSize, 0 );
127 wxDefaultPosition, wxDefaultSize, 0 );
132 wxDefaultPosition, wxDefaultSize, 0 );
134 _(
"If you want a solder paste layer for front side of the board" ) );
137 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
140 wxDefaultPosition, wxDefaultSize, 0 );
145 wxDefaultPosition, wxDefaultSize, 0 );
150 wxDefaultPosition, wxDefaultSize, 0 );
152 _(
"If you want a silk screen layer for the front side of the board" ) );
155 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
158 wxDefaultPosition, wxDefaultSize, 0 );
163 wxDefaultPosition, wxDefaultSize, 0 );
168 wxDefaultPosition, wxDefaultSize, 0 );
170 _(
"If you want a solder mask layer for the front of the board" ) );
173 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
176 wxDefaultPosition, wxDefaultSize, 0 );
181 wxDefaultPosition, wxDefaultSize, 0 );
192 wxDefaultPosition, wxDefaultSize, 0 );
194 _(
"If you want a solder mask layer for the back side of the board" ) );
197 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
200 wxDefaultPosition, wxDefaultSize, 0 );
205 wxDefaultPosition, wxDefaultSize, 0 );
210 wxDefaultPosition, wxDefaultSize, 0 );
212 _(
"If you want a silk screen layer for the back side of the board" ) );
215 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
218 wxDefaultPosition, wxDefaultSize, 0 );
223 wxDefaultPosition, wxDefaultSize, 0 );
228 wxDefaultPosition, wxDefaultSize, 0 );
230 _(
"If you want a solder paste layer for the back side of the board" ) );
233 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
236 wxDefaultPosition, wxDefaultSize, 0 );
241 wxDefaultPosition, wxDefaultSize, 0 );
246 wxDefaultPosition, wxDefaultSize, 0 );
248 _(
"If you want an adhesive layer for the back side of the board" ) );
251 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
254 wxDefaultPosition, wxDefaultSize, 0 );
259 wxDefaultPosition, wxDefaultSize, 0 );
264 wxDefaultPosition, wxDefaultSize, 0 );
266 _(
"If you want a fabrication layer for the back side of the board" ) );
269 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
272 wxDefaultPosition, wxDefaultSize, 0 );
277 wxDefaultPosition, wxDefaultSize, 0 );
283 wxDefaultPosition, wxDefaultSize, 0 );
285 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT
286 | wxRESERVE_SPACE_EVEN_IF_HIDDEN,
290 wxDefaultPosition, wxDefaultSize, 0 );
295 wxDefaultPosition, wxDefaultSize, 0 );
301 wxDefaultPosition, wxDefaultSize, 0 );
303 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT
304 | wxRESERVE_SPACE_EVEN_IF_HIDDEN,
308 wxDefaultPosition, wxDefaultSize, 0 );
313 wxDefaultPosition, wxDefaultSize, 0 );
318 wxDefaultPosition, wxDefaultSize, 0 );
320 wxLEFT | wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL
321 | wxRESERVE_SPACE_EVEN_IF_HIDDEN,
325 wxDefaultPosition, wxDefaultSize, 0 );
330 wxDefaultPosition, wxDefaultSize, 0 );
335 wxDefaultPosition, wxDefaultSize, 0 );
337 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
340 wxDefaultPosition, wxDefaultSize, 0 );
344 wxDefaultPosition, wxDefaultSize, 0 );
349 wxDefaultPosition, wxDefaultSize, 0 );
351 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
354 wxDefaultPosition, wxDefaultSize, 0 );
358 wxDefaultPosition, wxDefaultSize, 0 );
363 wxDefaultPosition, wxDefaultSize, 0 );
364 m_CommentsCheckBox->SetToolTip(
_(
"If you want a separate layer for comments or notes" ) );
367 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
370 wxDefaultPosition, wxDefaultSize, 0 );
374 wxDefaultPosition, wxDefaultSize, 0 );
379 wxDefaultPosition, wxDefaultSize, 0 );
383 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
386 wxDefaultPosition, wxDefaultSize, 0 );
390 wxDefaultPosition, wxDefaultSize, 0 );
393 wxALIGN_CENTER_VERTICAL | wxBOTTOM | wxLEFT | wxRIGHT, 5 );
419 wxCheckBox* cb =
new wxCheckBox(
m_LayersListPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
420 cb->SetToolTip(
_(
"Use the Physical Stackup page to change the number of copper layers." ) );
423 m_LayersSizer->Add( cb, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
426 txt->SetToolTip(
_(
"Layer Name") );
430 wxArrayString choices;
431 choices.Add(
_(
"signal" ) );
432 choices.Add(
_(
"power plane" ) );
433 choices.Add(
_(
"mixed" ) );
434 choices.Add(
_(
"jumper" ) );
435 wxChoice* choice =
new wxChoice(
m_LayersListPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices, 0 );
436 choice->SetSelection( 0 );
437 choice->SetToolTip(
_(
"Copper layer type for Freerouter and other external routers.\n"
438 "Power plane layers are removed from Freerouter's layer menus.") );
472 wxCheckBox* cb =
new wxCheckBox(
m_LayersListPanel, wxID_ANY, wxEmptyString, wxDefaultPosition,
474 m_LayersSizer->Add( cb, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
477 wxDefaultPosition, wxDefaultSize, 0 );
478 txt->SetToolTip(
_(
"Layer Name" ) );
481 wxArrayString choices;
482 choices.Add(
_(
"Auxiliary" ) );
483 choices.Add(
_(
"Off-board, front" ) );
484 choices.Add(
_(
"Off-board, back" ) );
487 wxDefaultSize, choices, 0 );
488 choice->SetSelection( 0 );
490 _(
"Auxiliary layers do not flip with board side, while back and front layers do." ) );
583 wxControl* ctl =
getName( layer );
589 if(
auto textCtl =
dynamic_cast<wxTextCtrl*
>( ctl ) )
590 textCtl->ChangeValue( lname );
592 ctl->SetLabel( lname );
615 case LT_SIGNAL: ctl->SetSelection( 0 );
break;
616 case LT_POWER: ctl->SetSelection( 1 );
break;
617 case LT_MIXED: ctl->SetSelection( 2 );
break;
618 case LT_JUMPER: ctl->SetSelection( 3 );
break;
619 default: ctl->SetSelection( 0 );
632 case LT_AUX: ctl->SetSelection( 0 );
break;
633 case LT_FRONT: ctl->SetSelection( 1 );
break;
634 case LT_BACK: ctl->SetSelection( 2 );
break;
635 default: ctl->SetSelection( 0 );
break;
643 LSET layerMaskResult;
649 if( ctl && ctl->IsChecked() )
650 layerMaskResult.
set( layer );
653 return layerMaskResult;
664 ctl.
checkbox->SetValue( isChecked );
670 if( copperCount > 0 )
676 if( copperCount > 0 )
697 bool modified =
false;
702 if( enabledLayers != previousEnabled )
706 LSET changedLayers = enabledLayers ^ previousEnabled;
720 for(
PAD*
pad : fp->Pads() )
722 if(
pad->HasHole() &&
pad->IsOnCopperLayer() )
737 wxString newLayerName =
getName( layer )->GetValue();
770 case 0: t =
LT_AUX;
break;
788 wxString newLayerName =
getName( layer )->GetValue();
811 bool modified =
false;
812 wxWindow* parent = wxGetTopLevelParent(
this );
820 if( !notremovableLayers.empty() )
825 if( !
IsOK( parent, wxString::Format(
_(
"Footprints have some items on removed layers:\n"
827 "These items will be no longer accessible\n"
828 "Do you wish to continue?" ),
835 if( !removedLayers.empty() )
837 if( !
IsOK( parent,
_(
"Items have been found on removed layers. This operation will "
838 "delete all items from removed layers and cannot be undone.\n"
839 "Do you wish to continue?" ) ) )
847 bool hasRemovedBoardItems =
false;
849 if( !removedLayers.empty() )
861 for(
int i = 0; i < collector.
GetCount(); i++ )
881 if(
via->GetViaType() == VIATYPE::THROUGH )
887 via->LayerPair( &top_layer, &bottom_layer );
889 if( top_layer != layer_id && bottom_layer != layer_id )
902 layers.
reset( layer_id );
903 hasRemovedBoardItems =
true;
927 if( hasRemovedBoardItems )
939 std::vector<wxString> names;
949 ctl = (wxTextCtrl*)
getName( layer );
950 wxString
name = ctl->GetValue();
960 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
961 badchars.Append(
'%' );
969 if(
name.find_first_of( badchars ) != wxString::npos )
971 wxString msg = wxString::Format(
_(
"%s are forbidden in layer names." ), badchars );
976 if(
name == wxT(
"signal" ) )
983 for(
const wxString& existingName : names )
985 if(
name == existingName )
987 wxString msg = wxString::Format(
_(
"Layer name '%s' already in use." ),
name );
993 names.push_back(
name );
1006 if( newLayers == curLayers )
1007 return removedLayers;
1010 LSEQ newLayerSeq = newLayers.
Seq();
1014 if( !newLayers[layer_id] )
1023 for(
int i = 0; i < collector.
GetCount(); i++ )
1037 if(
via->GetViaType() == VIATYPE::THROUGH )
1043 via->LayerPair( &top_layer, &bottom_layer );
1045 if( top_layer != layer_id && bottom_layer != layer_id )
1050 removedLayers.push_back( layer_id );
1057 return removedLayers;
1068 if( newLayers == curLayers )
1072 LSEQ newLayerSeq = newLayers.
Seq();
1085 inUseLayers.push_back( layer_id );
1112 bool okToDeleteCopperLayers =
true;
1118 if( newNumLayers < currNumLayers )
1120 wxString msg = wxString::Format(
_(
"Imported settings have fewer copper layers than "
1121 "the current board (%i instead of %i).\n\n"
1122 "Continue and delete the extra inner copper layers "
1123 "from the current board?" ),
1127 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
1129 wxMessageDialog dlg( topLevelParent, msg,
_(
"Inner Layers to Be Deleted" ),
1130 wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
1132 if( wxID_ANY == dlg.ShowModal() )
1133 okToDeleteCopperLayers =
false;
1136 return okToDeleteCopperLayers;
1142 wxArrayString headers;
1143 headers.Add(
_(
"Layers" ) );
1146 std::vector<wxArrayString> list;
1152 if( checkBox && checkBox->IsShown() )
1155 wxArrayString available_user_layer;
1156 available_user_layer.Add(
LayerName( layer ) );
1158 list.emplace_back( available_user_layer );
1164 _(
"All user-defined layers have already been added." ) );
1187 wxCHECK( layer >=
User_1, );
1198 wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( ctl.
name );
1200 wxCHECK( textCtrl, );
1201 textCtrl->ChangeValue(
LSET::Name( layer ) );
1203 wxChoice* userLayerType =
dynamic_cast<wxChoice*
>( ctl.
choice );
1205 wxCHECK( userLayerType, );
1206 userLayerType->SetSelection( 0 );
1208 ctl.
name->Show(
true );
1210 ctl.
choice->Show(
true );
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
BASE_SET & reset(size_t pos)
BASE_SET & set(size_t pos)
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 SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
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
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.
void SetEnabledLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
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.
copper_layers_iterator copper_layers_end() const
static LSET AllLayersMask()
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
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.
copper_layers_iterator copper_layers_begin() const
non_copper_layers_iterator non_copper_layers_begin() const
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
non_copper_layers_iterator non_copper_layers_end() const
static LSET UserDefinedLayersMask(int aUserDefinedLayerCount=MAX_USER_DEFINED_LAYERS)
Return a mask with the requested number of user defined layers.
static wxString 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
wxFlexGridSizer * m_LayersSizer
wxStaticText * m_CrtYdBackStaticText
wxStaticText * m_CrtYdFrontStaticText
wxCheckBox * m_SoldPBackCheckBox
wxStaticText * m_PCBEdgesStaticText
wxTextCtrl * m_FabBackName
wxStaticText * m_FabBackStaticText
wxTextCtrl * m_PCBEdgesName
wxTextCtrl * m_DrawingsName
wxStaticText * m_MarginStaticText
void append_user_layer(PCB_LAYER_ID aLayer)
wxCheckBox * m_AdhesBackCheckBox
wxTextCtrl * getName(PCB_LAYER_ID aLayer)
bool transferDataFromWindow()
wxStaticText * m_Eco2StaticText
void showSelectedLayerCheckBoxes(const LSET &enableLayerMask)
bool CheckCopperLayerCount(BOARD *aWorkingBoard, BOARD *aImportedBoard)
Check and warn if inner copper layers will be deleted.
wxTextCtrl * m_CrtYdBackName
wxStaticText * m_AdhesFrontStaticText
wxTextCtrl * m_MaskFrontName
wxCheckBox * m_Eco1CheckBox
wxCheckBox * m_CrtYdFrontCheckBox
wxCheckBox * m_FabFrontCheckBox
bool TransferDataToWindow() override
wxTextCtrl * m_AdhesFrontName
wxCheckBox * getCheckBox(PCB_LAYER_ID aLayer)
wxCheckBox * m_MaskFrontCheckBox
void setLayerCheckBox(PCB_LAYER_ID layer, bool isChecked)
virtual void addUserDefinedLayer(wxCommandEvent &aEvent) override
wxCheckBox * m_SilkSBackCheckBox
void SyncCopperLayers(int aNumCopperLayers)
Called when switching to this tab to make sure that any changes to the copper layer count made on the...
wxStaticText * m_AdhesBackStaticText
void initialize_back_tech_layers()
void initialize_front_tech_layers()
wxTextCtrl * m_CrtYdFrontName
std::map< PCB_LAYER_ID, PANEL_SETUP_LAYERS_CTLs > m_layersControls
wxTextCtrl * m_MaskBackName
wxStaticText * m_Eco1StaticText
PANEL_SETUP_BOARD_STACKUP * m_physicalStackup
wxTextCtrl * m_AdhesBackName
wxTextCtrl * m_MarginName
wxCheckBox * m_MaskBackCheckBox
wxCheckBox * m_SoldPFrontCheckBox
wxStaticText * m_CommentsStaticText
wxCheckBox * m_PCBEdgesCheckBox
wxStaticText * m_FabFrontStaticText
wxStaticText * m_MaskFrontStaticText
LSEQ getNonRemovableLayers()
Return a list of layers in use in footprints, and therefore not removable.
wxStaticText * m_SilkSFrontStaticText
void showBoardLayerNames()
wxCheckBox * m_MarginCheckBox
wxStaticText * m_SoldPBackStaticText
wxCheckBox * m_SilkSFrontCheckBox
wxStaticText * m_MaskBackStaticText
void setCopperLayerCheckBoxes(int copperCount)
wxCheckBox * m_CrtYdBackCheckBox
wxCheckBox * m_CommentsCheckBox
wxCheckBox * m_FabBackCheckBox
wxTextCtrl * m_SoldPFrontName
wxTextCtrl * m_SilkSBackName
wxTextCtrl * m_SoldPBackName
wxStaticText * m_SilkSBackStaticText
wxTextCtrl * m_SilkSFrontName
wxCheckBox * m_Eco2CheckBox
wxCheckBox * m_AdhesFrontCheckBox
wxChoice * getChoice(PCB_LAYER_ID aLayer)
void initialize_layers_controls()
wxStaticText * m_SoldPFrontStaticText
LSEQ getRemovedLayersWithItems()
Return a list of layers removed from the board that contain items.
wxCheckBox * m_DrawingsCheckBox
wxStaticText * m_DrawingsStaticText
bool TransferDataFromWindow() override
PANEL_SETUP_LAYERS(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
void ImportSettingsFrom(BOARD *aBoard)
wxTextCtrl * m_CommentsName
wxTextCtrl * m_FabFrontName
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 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)
Test 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.
static void mandatoryLayerCbSetup(wxCheckBox &aCheckBox)
Configure a layer checkbox to be mandatory and disabled.
std::deque< BOARD_ITEM * > GetCurrentSelection()
Get the list of selected objects.
The 3 UI control pointers for a single board layer.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint