KiCad PCB EDA Suite
dialog_layers_setup.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2009 Isaac Marino Bavaresco, isaacbavaresco@yahoo.com.br
5  * Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2009-2018 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 
27 #include <fctsys.h>
28 #include <macros.h>
29 
30 #include <confirm.h>
31 #include <pcbnew.h>
32 #include <invoke_pcb_dialog.h>
33 
34 #include <class_board.h>
35 #include <collectors.h>
36 
38 
39 
40 // some define to choose how copper layers widgets are shown
41 
42 // if defined, display only active copper layers
43 // if not displays always 1=the full set (32 copper layers)
44 #define HIDE_INACTIVE_LAYERS
45 
46 // if defined, use the layer manager copper layers order (from FRONT to BACK)
47 // to display inner layers.
48 // if not, use the default order (from BACK to FRONT)
49 #define USE_LAYER_MANAGER_COPPER_LAYERS_ORDER
50 
51 
55 struct CTLs
56 {
57  CTLs( wxControl* aName, wxCheckBox* aCheckBox, wxControl* aChoiceOrDesc,
58  wxPanel* aPanel = NULL )
59  {
60  name = aName;
61  checkbox = aCheckBox;
62  choice = aChoiceOrDesc;
63  panel = aPanel;
64  }
65 
66  wxControl* name;
67  wxCheckBox* checkbox;
68  wxControl* choice;
69  wxPanel * panel;
70 };
71 
72 
73 static LSEQ dlg_layers()
74 {
75  // layers that are put out into the dialog UI, coordinate with wxformbuilder and
76  // getCTLs( LAYER_NUM aLayerNumber )
77  static const PCB_LAYER_ID layers[] = {
78  F_CrtYd,
79  F_Fab,
80  F_Adhes,
81  F_Paste,
82  F_SilkS,
83  F_Mask,
84  F_Cu,
85 
86  In1_Cu,
87  In2_Cu,
88  In3_Cu,
89  In4_Cu,
90  In5_Cu,
91  In6_Cu,
92  In7_Cu,
93  In8_Cu,
94  In9_Cu,
95  In10_Cu,
96  In11_Cu,
97  In12_Cu,
98  In13_Cu,
99  In14_Cu,
100  In15_Cu,
101 
102  In16_Cu,
103  In17_Cu,
104  In18_Cu,
105  In19_Cu,
106  In20_Cu,
107  In21_Cu,
108  In22_Cu,
109  In23_Cu,
110  In24_Cu,
111  In25_Cu,
112  In26_Cu,
113  In27_Cu,
114  In28_Cu,
115  In29_Cu,
116  In30_Cu,
117 
118  B_Cu,
119  B_Mask,
120  B_SilkS,
121  B_Paste,
122  B_Adhes,
123  B_Fab,
124  B_CrtYd,
125 
126  Edge_Cuts,
127  Margin,
128  Eco2_User,
129  Eco1_User,
130  Cmts_User,
131  Dwgs_User,
132  };
133 
134  return LSEQ( layers, layers + DIM( layers ) );
135 }
136 
137 
139 {
140 public:
141  DIALOG_LAYERS_SETUP( wxTopLevelWindow* aCaller, BOARD* aBoard );
142 
143 private:
146 
148 
149  wxStaticText* m_nameStaticText;
150  wxStaticText* m_enabledStaticText;
151  wxStaticText* m_typeStaticText;
152 
153  void setLayerCheckBox( LAYER_NUM layer, bool isChecked );
154  void setCopperLayerCheckBoxes( int copperCount );
155 
156  void showCopperChoice( int copperCount );
157  void showBoardLayerNames();
158  void showSelectedLayerCheckBoxes( LSET enableLayerMask );
159  void showLayerTypes();
160  void showPresets( LSET enabledLayerMask );
161 
163  LSET getUILayerMask();
164  wxString getLayerName( LAYER_NUM layer );
165  int getLayerTypeIndex( LAYER_NUM layer );
166 
167  void OnInitDialog( wxInitDialogEvent& aEvent ) override;
168  void OnCheckBox( wxCommandEvent& event ) override;
169  void DenyChangeCheckBox( wxCommandEvent& event ) override;
170  void OnPresetsChoice( wxCommandEvent& event ) override;
171  void OnCopperLayersChoice( wxCommandEvent& event ) override;
172  bool TransferDataToWindow() override;
173  bool TransferDataFromWindow() override;
174 
175  bool testLayerNames();
176 
180  LSEQ getRemovedLayersWithItems();
181 
186  CTLs getCTLs( LAYER_NUM aLayerNumber );
187 
188  wxControl* getName( LAYER_NUM aLayer )
189  {
190  return getCTLs( aLayer ).name;
191  }
192 
193  wxCheckBox* getCheckBox( LAYER_NUM aLayer )
194  {
195  return getCTLs( aLayer ).checkbox;
196  }
197 
198  wxChoice* getChoice( LAYER_NUM aLayer )
199  {
200  return (wxChoice*) getCTLs( aLayer ).choice;
201  }
202 
203  void moveTitles()
204  {
205  wxArrayInt widths = m_LayerListFlexGridSizer->GetColWidths();
206 
207  int offset = 0;
208  wxSize txtz;
209 
210  wxSize panel_sz = m_TitlePanel->GetSize();
211  int voffset = panel_sz.y/2 - VertPixelsFromDU( 4 );
212 
213  txtz = m_nameStaticText->GetSize();
214  m_nameStaticText->Move( offset + (widths[0] - txtz.x)/2, voffset );
215  offset += widths[0];
216 
217  txtz = m_enabledStaticText->GetSize();
218  m_enabledStaticText->Move( offset + (widths[1] - txtz.x)/2, voffset );
219  offset += widths[1];
220 
221  txtz = m_typeStaticText->GetSize();
222  m_typeStaticText->Move( offset + (widths[2] - txtz.x)/2, voffset );
223  }
224 
225  void OnSize( wxSizeEvent& event ) override;
226 };
227 
228 
229 // Layer bit masks for each defined "Preset Layer Grouping"
230 static const LSET presets[] =
231 {
232  LSET(), // shift the array index up by one, matches with "Custom".
233 
234  // "Two layers, parts on Front only"
236 
237  // "Two layers, parts on Back only",
239 
240  // "Two layers, parts on Front and Back",
242 
243  // "Four layers, parts on Front only"
245 
246  // "Four layers, parts on Front and Back"
248  LSET::UserMask(),
249 
250  // "All layers on",
251  LSET().set(),
252 };
253 
254 
256 {
257 #define RETCOP(x) return CTLs( x##Name, x##CheckBox, x##Choice, x##Panel );
258 #define RETAUX(x) return CTLs( x##Name, x##CheckBox, x##StaticText, x##Panel );
259 
260  switch( aLayerNumber )
261  {
262  case F_CrtYd: RETAUX( m_CrtYdFront );
263  case F_Fab: RETAUX( m_FabFront );
264  case F_Adhes: RETAUX( m_AdhesFront );
265  case F_Paste: RETAUX( m_SoldPFront );
266  case F_SilkS: RETAUX( m_SilkSFront );
267  case F_Mask: RETAUX( m_MaskFront );
268  case F_Cu: RETCOP( m_Front );
269 
270  case In1_Cu: RETCOP( m_In1 );
271  case In2_Cu: RETCOP( m_In2 );
272  case In3_Cu: RETCOP( m_In3 );
273  case In4_Cu: RETCOP( m_In4 );
274  case In5_Cu: RETCOP( m_In5 );
275  case In6_Cu: RETCOP( m_In6 );
276  case In7_Cu: RETCOP( m_In7 );
277  case In8_Cu: RETCOP( m_In8 );
278  case In9_Cu: RETCOP( m_In9 );
279  case In10_Cu: RETCOP( m_In10 );
280  case In11_Cu: RETCOP( m_In11 );
281  case In12_Cu: RETCOP( m_In12 );
282  case In13_Cu: RETCOP( m_In13 );
283  case In14_Cu: RETCOP( m_In14 );
284  case In15_Cu: RETCOP( m_In15 );
285 
286  case In16_Cu: RETCOP( m_In16 );
287  case In17_Cu: RETCOP( m_In17 );
288  case In18_Cu: RETCOP( m_In18 );
289  case In19_Cu: RETCOP( m_In19 );
290  case In20_Cu: RETCOP( m_In20 );
291  case In21_Cu: RETCOP( m_In21 );
292  case In22_Cu: RETCOP( m_In22 );
293  case In23_Cu: RETCOP( m_In23 );
294  case In24_Cu: RETCOP( m_In24 );
295  case In25_Cu: RETCOP( m_In25 );
296  case In26_Cu: RETCOP( m_In26 );
297  case In27_Cu: RETCOP( m_In27 );
298  case In28_Cu: RETCOP( m_In28 );
299  case In29_Cu: RETCOP( m_In29 );
300  case In30_Cu: RETCOP( m_In30 );
301 
302  case B_Cu: RETCOP( m_Back );
303  case B_Mask: RETAUX( m_MaskBack );
304  case B_SilkS: RETAUX( m_SilkSBack );
305  case B_Paste: RETAUX( m_SoldPBack );
306  case B_Adhes: RETAUX( m_AdhesBack );
307  case B_Fab: RETAUX( m_FabBack );
308  case B_CrtYd: RETAUX( m_CrtYdBack );
309 
310  case Edge_Cuts: RETAUX( m_PCBEdges );
311  case Margin: RETAUX( m_Margin );
312  case Eco2_User: RETAUX( m_Eco2 );
313  case Eco1_User: RETAUX( m_Eco1 );
314  case Cmts_User: RETAUX( m_Comments );
315  case Dwgs_User: RETAUX( m_Drawings );
316  default:
317  wxASSERT_MSG( 0, wxT( "bad layer id" ) );
318  return CTLs( 0, 0, 0 );
319  }
320 
321 #undef RETCOP
322 #undef RETAUX
323 }
324 
325 
326 DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( wxTopLevelWindow* aParent, BOARD* aBoard ) :
327  DIALOG_LAYERS_SETUP_BASE( aParent )
328 {
329  m_pcb = aBoard;
330 
333 
334  SetAutoLayout( true );
335 
336  // these 3 controls are handled outside wxformbuilder so that we can add
337  // them without a sizer. Then we position them manually based on the column
338  // widths from m_LayerListFlexGridSizer->GetColWidths()
339  m_nameStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Name" ),
340  wxDefaultPosition, wxDefaultSize, 0 );
341 
342  m_enabledStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Enabled" ),
343  wxDefaultPosition, wxDefaultSize, 0 );
344 
345  m_typeStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Type" ),
346  wxDefaultPosition, wxDefaultSize, 0 );
347 }
348 
349 
350 void DIALOG_LAYERS_SETUP::OnInitDialog( wxInitDialogEvent& aEvent )
351 {
352  wxWindowBase::OnInitDialog( aEvent );
353 
354  m_TitlePanel->SetMinSize( wxSize( -1, VertPixelsFromDU( 10 ) ) );
355 
356  m_LayersListPanel->ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
357 
358  Layout();
359  SetSizeInDU( 240, 240 );
360  Center();
361 
362  m_sdbSizerOK->SetFocus();
363  m_sdbSizerOK->SetDefault();
364 
365  // OnSize() will fix the title spacing.
366  QueueEvent( new wxSizeEvent( GetSize() ) );
367 }
368 
369 
371 {
372  if( !wxDialog::TransferDataToWindow() )
373  return false;
374 
380 
384  showLayerTypes();
385 
386  // All widgets are now initialized. Fix the min sizes:
387  GetSizer()->SetSizeHints( this );
388 
389  return true;
390 }
391 
392 
393 void DIALOG_LAYERS_SETUP::OnSize( wxSizeEvent& event )
394 {
395  moveTitles();
396  event.Skip();
397 }
398 
399 
401 {
402  if( copperCount > MAX_CU_LAYERS )
403  copperCount = MAX_CU_LAYERS;
404 
405  if( copperCount < 2 )
406  copperCount = 2;
407 
408  for( int lyrCnt = 2; lyrCnt <= MAX_CU_LAYERS; lyrCnt += 2 )
409  {
410  // note this will change a one layer board to 2:
411  if( copperCount <= lyrCnt )
412  {
413  int idx = lyrCnt/2 - 1;
414  m_CopperLayersChoice->SetSelection(idx);
415  break;
416  }
417  }
418 }
419 
420 
422 {
423  // Establish all the board's layer names into the dialog presentation, by
424  // obtaining them from BOARD::GetLayerName() which calls
425  // BOARD::GetStandardLayerName() for non-coppers.
426 
427  for( LSEQ seq = dlg_layers(); seq; ++seq )
428  {
429  PCB_LAYER_ID layer = *seq;
430 
431  wxControl* ctl = getName( layer );
432 
433  wxASSERT( ctl );
434 
435  if( ctl )
436  {
437  wxString lname = m_pcb->GetLayerName( layer );
438 
439  if( ctl->IsKindOf( CLASSINFO( wxTextCtrl ) ) )
440  ((wxTextCtrl*)ctl)->SetValue( lname ); // wxTextCtrl
441  else
442  ctl->SetLabel( lname ); // wxStaticText
443  }
444  }
445 }
446 
447 
449 {
450  // the check boxes
451  for( LSEQ seq = dlg_layers(); seq; ++seq )
452  {
453  PCB_LAYER_ID layer = *seq;
454  setLayerCheckBox( layer, enabledLayers[layer] );
455  }
456 }
457 
458 
460 {
461  int presetsNdx = 0; // the "Custom" setting, matches nothing
462 
463  for( unsigned i=1; i<DIM( presets ); ++i )
464  {
465  if( enabledLayers == presets[i] )
466  {
467  presetsNdx = i;
468  break;
469  }
470  }
471 
472  m_PresetsChoice->SetSelection( presetsNdx );
473 }
474 
475 
477 {
478  for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
479  {
480  PCB_LAYER_ID cu_layer = *seq;
481 
482  wxChoice* ctl = getChoice( cu_layer );
483  ctl->SetSelection( m_pcb->GetLayerType( cu_layer ) );
484  }
485 }
486 
487 
489 {
490  LSET layerMaskResult;
491 
492  for( LSEQ seq = dlg_layers(); seq; ++seq )
493  {
494  PCB_LAYER_ID layer = *seq;
495  wxCheckBox* ctl = getCheckBox( layer );
496 
497  if( ctl->GetValue() )
498  {
499  layerMaskResult.set( layer );
500  }
501  }
502 
503  return layerMaskResult;
504 }
505 
506 
507 void DIALOG_LAYERS_SETUP::setLayerCheckBox( LAYER_NUM aLayer, bool isChecked )
508 {
509  wxCheckBox* ctl = getCheckBox( aLayer );
510  ctl->SetValue( isChecked );
511 }
512 
513 
515 {
516  if( copperCount > 0 )
517  {
518  setLayerCheckBox( F_Cu, true );
519  --copperCount;
520  }
521 
522  if( copperCount > 0 )
523  {
524  setLayerCheckBox( B_Cu, true );
525  --copperCount;
526  }
527 
528  for( LSEQ seq = LSET::InternalCuMask().Seq(); seq; ++seq, --copperCount )
529  {
530  PCB_LAYER_ID layer = *seq;
531  bool state = copperCount > 0;
532 
533 #ifdef HIDE_INACTIVE_LAYERS
534  // This code hides non-active copper layers, or redisplays hidden
535  // layers which are now needed.
536  CTLs ctl = getCTLs( layer );
537 
538  ctl.name->Show( state );
539  ctl.checkbox->Show( state );
540  ctl.choice->Show( state );
541 
542  if( ctl.panel )
543  ctl.panel->Show( state );
544 #endif
545 
546  setLayerCheckBox( layer, state );
547  }
548 
549 #ifdef HIDE_INACTIVE_LAYERS
550  // Send an size event to force sizers to be updated,
551  // because the number of copper layers can have changed.
552  wxSizeEvent evt_size( m_LayersListPanel->GetSize() );
553  m_LayersListPanel->GetEventHandler()->ProcessEvent( evt_size );
554 #endif
555 }
556 
557 
558 void DIALOG_LAYERS_SETUP::OnCheckBox( wxCommandEvent& event )
559 {
561 
563 }
564 
565 
566 void DIALOG_LAYERS_SETUP::DenyChangeCheckBox( wxCommandEvent& event )
567 {
568  // user may not change copper layer checkboxes from anything other than
569  // either presets choice or the copper layer choice controls.
570 
571  // I tried to simply disable the copper CheckBoxes but they look like crap,
572  // so leave them enabled and reverse the user's attempt to toggle them.
573 
575 }
576 
577 
578 void DIALOG_LAYERS_SETUP::OnPresetsChoice( wxCommandEvent& event )
579 {
580  unsigned presetNdx = m_PresetsChoice->GetCurrentSelection();
581 
582  if( presetNdx == 0 ) // the Custom setting controls nothing.
583  return;
584 
585  if( presetNdx < DIM(presets) )
586  {
587  m_enabledLayers = presets[ presetNdx ];
588 
589  LSET copperSet = m_enabledLayers & LSET::AllCuMask();
590 
591  int copperCount = copperSet.count();
592 
593  m_copperLayerCount = copperCount;
594 
596 
598 
600  }
601 }
602 
603 
604 void DIALOG_LAYERS_SETUP::OnCopperLayersChoice( wxCommandEvent& event )
605 {
606  m_copperLayerCount = m_CopperLayersChoice->GetCurrentSelection() * 2 + 2;
607 
609 
611 
613 }
614 
615 
617 {
618  if( !wxWindow::TransferDataFromWindow() || !testLayerNames() )
619  return false;
620 
621  wxString msg;
622 
623  // Make sure the board thickness is sane.
624  int thickness = ValueFromTextCtrl( *m_textCtrlBrdThickness );
625 
626  if( thickness < Millimeter2iu( 0.1 ) || thickness > Millimeter2iu( 10.0 ) )
627  {
628  msg.Printf( _( "Board thickness %s is out of range." ),
629  StringFromValue( g_UserUnit, thickness, true ) );
630  DisplayError( this, msg );
631  return false;
632  }
633 
634  // Check for removed layers with items which will get deleted from the board.
635  LSEQ removedLayers = getRemovedLayersWithItems();
636 
637  if( !removedLayers.empty()
638  && !IsOK( this, _( "Items have been found on removed layers. This operation will delete "
639  "all items from removed layers and cannot be undone. Do you wish to "
640  "continue?" ) ) )
641  return false;
642 
643  // Delete all objects on layers that have been removed. Leaving them in copper layers
644  // can (will?) result in DRC errors and it pollutes the board file with cruft.
645  if( !removedLayers.empty() )
646  {
647  PCB_LAYER_COLLECTOR collector;
648 
649  for( auto layer_id : removedLayers )
650  {
651  collector.SetLayerId( layer_id );
653 
654  // Bye-bye items on on removed layer.
655  if( collector.GetCount() != 0 )
656  {
657  for( int i = 0; i < collector.GetCount(); i++ )
658  m_pcb->Remove( collector[i] );
659  }
660  }
661  }
662 
663  wxString name;
664 
667 
668  /* Ensure enabled layers are also visible
669  * This is mainly to avoid mistakes if some enabled
670  * layers are not visible when exiting this dialog
671  */
673 
674  for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
675  {
676  PCB_LAYER_ID layer = *seq;
677 
678  if( m_enabledLayers[layer] )
679  {
680  name = getLayerName( layer );
681  m_pcb->SetLayerName( layer, name );
682  LAYER_T t = (LAYER_T) getLayerTypeIndex( layer );
683  m_pcb->SetLayerType( layer, t );
684  }
685  }
686 
687  m_pcb->GetDesignSettings().SetBoardThickness( thickness );
688 
689  return true;
690 }
691 
692 
694 {
695  wxChoice* ctl = getChoice( aLayer );
696 
697  int ret = ctl->GetCurrentSelection(); // indices must have same sequence as LAYER_T
698 
699  return ret;
700 }
701 
702 
704 {
705  wxString ret;
706 
707  wxASSERT( IsCopperLayer( aLayer ) );
708 
709  wxTextCtrl* ctl = (wxTextCtrl*) getName( aLayer );
710 
711  ret = ctl->GetValue().Trim();
712 
713  return ret;
714 }
715 
716 
717 static bool hasOneOf( const wxString& str, const wxString& chars )
718 {
719  for( unsigned i=0; i<chars.Len(); ++i )
720  {
721  if( str.Find( chars[i] ) != wxNOT_FOUND )
722  return true;
723  }
724 
725  return false;
726 }
727 
728 
730 {
731  std::vector<wxString> names;
732 
733  wxTextCtrl* ctl;
734 
735  for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
736  {
737  PCB_LAYER_ID layer = *seq;
738 
739  // we _can_ rely on m_enabledLayers being current here:
740  if( !m_enabledLayers[layer] )
741  continue;
742 
743  wxString name = getLayerName( layer );
744 
745  ctl = (wxTextCtrl*) getName( layer );
746 
747  // check name for legality.
748  // 1) cannot be blank.
749  // 2) cannot have blanks.
750  // 3) cannot have " chars
751  // 4) cannot be 'signal'
752  // 5) must be unique.
753  // 6) cannot have illegal chars in filenames ( some filenames are built from layer names )
754  // like : % $ \ " / :
755  wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
756  badchars.Append( '%' );
757 
758  if( !name )
759  {
760  DisplayError( this, _( "Layer name may not be empty." ) );
761  ctl->SetFocus(); // on the bad name
762  return false;
763  }
764 
765  if( hasOneOf( name, badchars ) )
766  {
767  DisplayError( this, _( "Layer name has an illegal character, one of: '" ) +
768  badchars + wxT( "'" ) );
769  ctl->SetFocus(); // on the bad name
770  return false;
771  }
772 
773  if( name == wxT( "signal" ) )
774  {
775  DisplayError( this, _( "Layer name 'signal' is reserved." ) );
776  ctl->SetFocus(); // on the bad name
777  return false;
778  }
779 
780  for( std::vector<wxString>::iterator it = names.begin(); it != names.end(); ++it )
781  {
782  if( name == *it )
783  {
784  DisplayError( this, _( "Duplicate layer names are not permitted." ) );
785  ctl->SetFocus(); // on the bad name
786  return false;
787  }
788  }
789 
790  names.push_back( name );
791  }
792 
793  return true;
794 }
795 
796 
798 {
799  LSEQ removedLayers;
800  LSET newLayers = getUILayerMask();
801  LSET curLayers = m_pcb->GetEnabledLayers();
802 
803  if( newLayers == curLayers )
804  return removedLayers;
805 
806  PCB_LAYER_COLLECTOR collector;
807  LSEQ newLayerSeq = newLayers.Seq();
808  std::vector< PCB_LAYER_ID >::iterator it;
809 
810  for( auto layer_id : curLayers.Seq() )
811  {
812  if( std::find( newLayerSeq.begin(), newLayerSeq.end(), layer_id ) == newLayerSeq.end() )
813  {
814  collector.SetLayerId( layer_id );
816 
817  if( collector.GetCount() != 0 )
818  removedLayers.push_back( layer_id );
819  }
820  }
821 
822  return removedLayers;
823 }
824 
825 
826 bool InvokeLayerSetup( wxTopLevelWindow* aCaller, BOARD* aBoard )
827 {
828  DIALOG_LAYERS_SETUP dlg( aCaller, aBoard );
829 
830  return dlg.ShowModal() == wxID_OK;
831 }
wxCheckBox * getCheckBox(LAYER_NUM aLayer)
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:107
#define DIM(x)
of elements in an array
Definition: macros.h:98
static LSEQ dlg_layers()
static const KICAD_T BoardLevelItems[]
A scan list for all primary board items, omitting items which are subordinate to a MODULE...
Definition: collectors.h:275
Holds the 3 UI control pointers for a single board layer.
wxControl * getName(LAYER_NUM aLayer)
This file is part of the common library.
static LSET BackTechMask()
Function BackTechMask returns a mask holding all technical layers (no CU layer) on back side...
Definition: lset.cpp:717
void setLayerCheckBox(LAYER_NUM layer, bool isChecked)
Class BOARD to handle a board.
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:204
int GetCopperLayerCount() const
Function GetCopperLayerCount.
wxStaticText * m_typeStaticText
CTLs(wxControl *aName, wxCheckBox *aCheckBox, wxControl *aChoiceOrDesc, wxPanel *aPanel=NULL)
void showPresets(LSET enabledLayerMask)
void Collect(BOARD_ITEM *aBoard, const KICAD_T aScanList[])
Tests a BOARD_ITEM using this class&#39;s Inspector method, which does the collection.
Definition: collectors.cpp:509
static LSET FrontTechMask()
Function FrontTechMask returns a mask holding all technical layers (no CU layer) on front side...
Definition: lset.cpp:729
wxStaticText * m_enabledStaticText
CTLs getCTLs(LAYER_NUM aLayerNumber)
Map aLayerNumber to the wx IDs for that layer which are the layer name control ID, checkbox control ID, and choice control ID.
Collect all BOARD_ITEM objects on a given layer.
Definition: collectors.h:614
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Function SetLayerType changes the type of the layer given by aLayer.
void OnSize(wxSizeEvent &event) override
void SetBoardThickness(int aThickness)
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
bool TransferDataToWindow() override
void SetLayerId(PCB_LAYER_ID aLayerId)
Definition: collectors.h:624
Class DIALOG_LAYERS_SETUP_BASE.
void OnCheckBox(wxCommandEvent &event) override
bool InvokeLayerSetup(wxTopLevelWindow *aCaller, BOARD *aBoard)
Function InvokeLayerSetup shows the layer setup dialog.
This file contains miscellaneous commonly used macros and functions.
wxStaticText * m_nameStaticText
wxControl * choice
static const LSET presets[]
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:364
wxPanel * panel
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
void OnInitDialog(wxInitDialogEvent &aEvent) override
void showCopperChoice(int copperCount)
#define RETCOP(x)
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void OnPresetsChoice(wxCommandEvent &event) override
LAYER_T
Enum LAYER_T gives the allowed types of layers, same as Specctra DSN spec.
Definition: class_board.h:71
bool TransferDataFromWindow() override
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit)
Definition: base_units.cpp:484
void setCopperLayerCheckBoxes(int copperCount)
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Function SetLayerName changes the name of the layer given by aLayer.
void SetSizeInDU(int x, int y)
Set the dialog to the given dimensions in "dialog units".
static LSET InternalCuMask()
Function InternalCuMask() returns a complete set of internal copper layers, which is all Cu layers ex...
Definition: lset.cpp:633
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
#define RETAUX(x)
int ValueFromTextCtrl(const wxTextCtrl &aTextCtr)
Convert the number Value in a string according to the internal units and the selected unit (g_UserUni...
Definition: base_units.cpp:385
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
void OnCopperLayersChoice(wxCommandEvent &event) override
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
wxChoice * getChoice(LAYER_NUM aLayer)
int VertPixelsFromDU(int y)
Convert an integer number of dialog units to pixels, vertically.
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
void showSelectedLayerCheckBoxes(LSET enableLayerMask)
LSET getUILayerMask()
Return the selected layer mask within the UI checkboxes.
void PutValueInLocalUnits(wxTextCtrl &aTextCtr, int aValue)
Function PutValueInLocalUnits converts aValue from internal units to user units and append the units ...
Definition: base_units.cpp:266
LSEQ getRemovedLayersWithItems()
Return a list of layers removed from the board that contain items.
const char * name
Definition: DXF_plotter.cpp:61
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
wxString getLayerName(LAYER_NUM layer)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
wxCheckBox * checkbox
static bool hasOneOf(const wxString &str, const wxString &chars)
int getLayerTypeIndex(LAYER_NUM layer)
void DenyChangeCheckBox(wxCommandEvent &event) override
static LSET UserMask()
Definition: lset.cpp:757
wxControl * name
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:241
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:289
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Function GetLayerType returns the type of the copper layer given by aLayer.
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void Remove(BOARD_ITEM *aBoardItem) override
Removes an item from the container.
DIALOG_LAYERS_SETUP(wxTopLevelWindow *aCaller, BOARD *aBoard)