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-2017 KiCad Developers, see change_log.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 
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 
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  txtz = m_nameStaticText->GetSize();
211  m_nameStaticText->Move( offset + (widths[0] - txtz.x)/2, 5 );
212  offset += widths[0];
213 
214  txtz = m_enabledStaticText->GetSize();
215  m_enabledStaticText->Move( offset + (widths[1] - txtz.x)/2, 5 );
216  offset += widths[1];
217 
218  txtz = m_typeStaticText->GetSize();
219  m_typeStaticText->Move( offset + (widths[2] - txtz.x)/2, 5 );
220  }
221 
222  void OnSize( wxSizeEvent& event ) override;
223 };
224 
225 
226 // Layer bit masks for each defined "Preset Layer Grouping"
227 static const LSET presets[] =
228 {
229  LSET(), // shift the array index up by one, matches with "Custom".
230 
231  // "Two layers, parts on Front only"
233 
234  // "Two layers, parts on Back only",
236 
237  // "Two layers, parts on Front and Back",
239 
240  // "Four layers, parts on Front only"
242 
243  // "Four layers, parts on Front and Back"
245  LSET::UserMask(),
246 
247  // "All layers on",
248  LSET().set(),
249 };
250 
251 
253 {
254 #define RETCOP(x) return CTLs( x##Name, x##CheckBox, x##Choice, x##Panel );
255 #define RETAUX(x) return CTLs( x##Name, x##CheckBox, x##StaticText, x##Panel );
256 
257  switch( aLayerNumber )
258  {
259  case F_CrtYd: RETAUX( m_CrtYdFront );
260  case F_Fab: RETAUX( m_FabFront );
261  case F_Adhes: RETAUX( m_AdhesFront );
262  case F_Paste: RETAUX( m_SoldPFront );
263  case F_SilkS: RETAUX( m_SilkSFront );
264  case F_Mask: RETAUX( m_MaskFront );
265  case F_Cu: RETCOP( m_Front );
266 
267  case In1_Cu: RETCOP( m_In1 );
268  case In2_Cu: RETCOP( m_In2 );
269  case In3_Cu: RETCOP( m_In3 );
270  case In4_Cu: RETCOP( m_In4 );
271  case In5_Cu: RETCOP( m_In5 );
272  case In6_Cu: RETCOP( m_In6 );
273  case In7_Cu: RETCOP( m_In7 );
274  case In8_Cu: RETCOP( m_In8 );
275  case In9_Cu: RETCOP( m_In9 );
276  case In10_Cu: RETCOP( m_In10 );
277  case In11_Cu: RETCOP( m_In11 );
278  case In12_Cu: RETCOP( m_In12 );
279  case In13_Cu: RETCOP( m_In13 );
280  case In14_Cu: RETCOP( m_In14 );
281  case In15_Cu: RETCOP( m_In15 );
282 
283  case In16_Cu: RETCOP( m_In16 );
284  case In17_Cu: RETCOP( m_In17 );
285  case In18_Cu: RETCOP( m_In18 );
286  case In19_Cu: RETCOP( m_In19 );
287  case In20_Cu: RETCOP( m_In20 );
288  case In21_Cu: RETCOP( m_In21 );
289  case In22_Cu: RETCOP( m_In22 );
290  case In23_Cu: RETCOP( m_In23 );
291  case In24_Cu: RETCOP( m_In24 );
292  case In25_Cu: RETCOP( m_In25 );
293  case In26_Cu: RETCOP( m_In26 );
294  case In27_Cu: RETCOP( m_In27 );
295  case In28_Cu: RETCOP( m_In28 );
296  case In29_Cu: RETCOP( m_In29 );
297  case In30_Cu: RETCOP( m_In30 );
298 
299  case B_Cu: RETCOP( m_Back );
300  case B_Mask: RETAUX( m_MaskBack );
301  case B_SilkS: RETAUX( m_SilkSBack );
302  case B_Paste: RETAUX( m_SoldPBack );
303  case B_Adhes: RETAUX( m_AdhesBack );
304  case B_Fab: RETAUX( m_FabBack );
305  case B_CrtYd: RETAUX( m_CrtYdBack );
306 
307  case Edge_Cuts: RETAUX( m_PCBEdges );
308  case Margin: RETAUX( m_Margin );
309  case Eco2_User: RETAUX( m_Eco2 );
310  case Eco1_User: RETAUX( m_Eco1 );
311  case Cmts_User: RETAUX( m_Comments );
312  case Dwgs_User: RETAUX( m_Drawings );
313  default:
314  wxASSERT_MSG( 0, wxT( "bad layer id" ) );
315  return CTLs( 0, 0, 0 );
316  }
317 
318 #undef RETCOP
319 #undef RETAUX
320 }
321 
322 
323 DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( wxTopLevelWindow* aParent, BOARD* aBoard ) :
324  DIALOG_LAYERS_SETUP_BASE( aParent )
325 {
326  m_pcb = aBoard;
327 
330 
331  SetAutoLayout( true );
332 
333  // these 3 controls are handled outside wxformbuilder so that we can add
334  // them without a sizer. Then we position them manually based on the column
335  // widths from m_LayerListFlexGridSizer->GetColWidths()
336  m_nameStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Name" ),
337  wxDefaultPosition, wxDefaultSize, 0 );
338 
339  m_enabledStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Enabled" ),
340  wxDefaultPosition, wxDefaultSize, 0 );
341 
342  m_typeStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Type" ),
343  wxDefaultPosition, wxDefaultSize, 0 );
344 }
345 
346 
347 void DIALOG_LAYERS_SETUP::OnInitDialog( wxInitDialogEvent& aEvent )
348 {
349  wxWindowBase::OnInitDialog( aEvent );
350 
351  // set the height of the title panel to be the size of any wxStaticText object
352  // plus 10 so we can have a border of 5 on both top and bottom.
353  m_TitlePanel->SetMinSize( wxSize( -1, m_AdhesFrontName->GetSize().y+10 ) );
354 
355  m_LayersListPanel->ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
356 
357  Layout();
358  Fit();
359  Center();
360 
361  m_sdbSizerOK->SetFocus();
362  m_sdbSizerOK->SetDefault();
363 
364  // OnSize() will fix the title spacing.
365  QueueEvent( new wxSizeEvent( GetSize() ) );
366 }
367 
368 
370 {
371  if( !wxDialog::TransferDataToWindow() )
372  return false;
373 
379 
383  showLayerTypes();
384 
385  return true;
386 }
387 
388 
389 void DIALOG_LAYERS_SETUP::OnSize( wxSizeEvent& event )
390 {
391  moveTitles();
392  event.Skip();
393 }
394 
395 
397 {
398  if( copperCount > MAX_CU_LAYERS )
399  copperCount = MAX_CU_LAYERS;
400 
401  if( copperCount < 2 )
402  copperCount = 2;
403 
404  for( int lyrCnt = 2; lyrCnt <= MAX_CU_LAYERS; lyrCnt += 2 )
405  {
406  // note this will change a one layer board to 2:
407  if( copperCount <= lyrCnt )
408  {
409  int idx = lyrCnt/2 - 1;
410  m_CopperLayersChoice->SetSelection(idx);
411  break;
412  }
413  }
414 }
415 
416 
418 {
419  // Establish all the board's layer names into the dialog presentation, by
420  // obtaining them from BOARD::GetLayerName() which calls
421  // BOARD::GetStandardLayerName() for non-coppers.
422 
423  for( LSEQ seq = dlg_layers(); seq; ++seq )
424  {
425  PCB_LAYER_ID layer = *seq;
426 
427  wxControl* ctl = getName( layer );
428 
429  wxASSERT( ctl );
430 
431  if( ctl )
432  {
433  wxString lname = m_pcb->GetLayerName( layer );
434 
435  if( ctl->IsKindOf( CLASSINFO( wxTextCtrl ) ) )
436  ((wxTextCtrl*)ctl)->SetValue( lname ); // wxTextCtrl
437  else
438  ctl->SetLabel( lname ); // wxStaticText
439  }
440  }
441 }
442 
443 
445 {
446  // the check boxes
447  for( LSEQ seq = dlg_layers(); seq; ++seq )
448  {
449  PCB_LAYER_ID layer = *seq;
450  setLayerCheckBox( layer, enabledLayers[layer] );
451  }
452 }
453 
454 
456 {
457  int presetsNdx = 0; // the "Custom" setting, matches nothing
458 
459  for( unsigned i=1; i<DIM( presets ); ++i )
460  {
461  if( enabledLayers == presets[i] )
462  {
463  presetsNdx = i;
464  break;
465  }
466  }
467 
468  m_PresetsChoice->SetSelection( presetsNdx );
469 }
470 
471 
473 {
474  for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
475  {
476  PCB_LAYER_ID cu_layer = *seq;
477 
478  wxChoice* ctl = getChoice( cu_layer );
479  ctl->SetSelection( m_pcb->GetLayerType( cu_layer ) );
480  }
481 }
482 
483 
485 {
486  LSET layerMaskResult;
487 
488  for( LSEQ seq = dlg_layers(); seq; ++seq )
489  {
490  PCB_LAYER_ID layer = *seq;
491  wxCheckBox* ctl = getCheckBox( layer );
492 
493  if( ctl->GetValue() )
494  {
495  layerMaskResult.set( layer );
496  }
497  }
498 
499  return layerMaskResult;
500 }
501 
502 
503 void DIALOG_LAYERS_SETUP::setLayerCheckBox( LAYER_NUM aLayer, bool isChecked )
504 {
505  wxCheckBox* ctl = getCheckBox( aLayer );
506  ctl->SetValue( isChecked );
507 }
508 
509 
511 {
512  if( copperCount > 0 )
513  {
514  setLayerCheckBox( F_Cu, true );
515  --copperCount;
516  }
517 
518  if( copperCount > 0 )
519  {
520  setLayerCheckBox( B_Cu, true );
521  --copperCount;
522  }
523 
524  for( LSEQ seq = LSET::InternalCuMask().Seq(); seq; ++seq, --copperCount )
525  {
526  PCB_LAYER_ID layer = *seq;
527  bool state = copperCount > 0;
528 
529 #ifdef HIDE_INACTIVE_LAYERS
530  // This code hides non-active copper layers, or redisplays hidden
531  // layers which are now needed.
532  CTLs ctl = getCTLs( layer );
533 
534  ctl.name->Show( state );
535  ctl.checkbox->Show( state );
536  ctl.choice->Show( state );
537 
538  if( ctl.panel )
539  ctl.panel->Show( state );
540 #endif
541 
542  setLayerCheckBox( layer, state );
543  }
544 
545 #ifdef HIDE_INACTIVE_LAYERS
546  // Send an size event to force sizers to be updated,
547  // because the number of copper layers can have changed.
548  wxSizeEvent evt_size( m_LayersListPanel->GetSize() );
549  m_LayersListPanel->GetEventHandler()->ProcessEvent( evt_size );
550 #endif
551 }
552 
553 
554 void DIALOG_LAYERS_SETUP::OnCheckBox( wxCommandEvent& event )
555 {
557 
559 }
560 
561 
562 void DIALOG_LAYERS_SETUP::DenyChangeCheckBox( wxCommandEvent& event )
563 {
564  // user may not change copper layer checkboxes from anything other than
565  // either presets choice or the copper layer choice controls.
566 
567  // I tried to simply disable the copper CheckBoxes but they look like crap,
568  // so leave them enabled and reverse the user's attempt to toggle them.
569 
571 }
572 
573 
574 void DIALOG_LAYERS_SETUP::OnPresetsChoice( wxCommandEvent& event )
575 {
576  unsigned presetNdx = m_PresetsChoice->GetCurrentSelection();
577 
578  if( presetNdx == 0 ) // the Custom setting controls nothing.
579  return;
580 
581  if( presetNdx < DIM(presets) )
582  {
583  m_enabledLayers = presets[ presetNdx ];
584 
585  LSET copperSet = m_enabledLayers & LSET::AllCuMask();
586 
587  int copperCount = copperSet.count();
588 
589  m_copperLayerCount = copperCount;
590 
592 
594 
596  }
597 }
598 
599 
600 void DIALOG_LAYERS_SETUP::OnCopperLayersChoice( wxCommandEvent& event )
601 {
602  m_copperLayerCount = m_CopperLayersChoice->GetCurrentSelection() * 2 + 2;
603 
605 
607 
609 }
610 
611 
613 {
614  if( !wxWindow::TransferDataFromWindow() || !testLayerNames() )
615  return false;
616 
617  wxString msg;
618 
619  // Make sure the board thickness is sane.
620  int thickness = ValueFromTextCtrl( *m_textCtrlBrdThickness );
621 
622  if( thickness < Millimeter2iu( 0.1 ) || thickness > Millimeter2iu( 10.0 ) )
623  {
624  msg.Printf( _( "Board thickness %s is out of range." ),
625  StringFromValue( g_UserUnit, thickness, true ) );
626  DisplayError( this, msg );
627  return false;
628  }
629 
630  // Check for removed layers with items which will get deleted from the board.
631  LSEQ removedLayers = getRemovedLayersWithItems();
632 
633  if( !removedLayers.empty()
634  && !IsOK( this, _( "Items have been found on removed layers. This operation will delete "
635  "all items from removed layers and cannot be undone. Do you wish to "
636  "continue?" ) ) )
637  return false;
638 
639  // Delete all objects on layers that have been removed. Leaving them in copper layers
640  // can (will?) result in DRC errors and it pollutes the board file with cruft.
641  if( !removedLayers.empty() )
642  {
643  PCB_LAYER_COLLECTOR collector;
644 
645  for( auto layer_id : removedLayers )
646  {
647  collector.SetLayerId( layer_id );
649 
650  // Bye-bye items on on removed layer.
651  if( collector.GetCount() != 0 )
652  {
653  for( int i = 0; i < collector.GetCount(); i++ )
654  m_pcb->Remove( collector[i] );
655  }
656  }
657  }
658 
659  wxString name;
660 
663 
664  /* Ensure enabled layers are also visible
665  * This is mainly to avoid mistakes if some enabled
666  * layers are not visible when exiting this dialog
667  */
669 
670  for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
671  {
672  PCB_LAYER_ID layer = *seq;
673 
674  if( m_enabledLayers[layer] )
675  {
676  name = getLayerName( layer );
677  m_pcb->SetLayerName( layer, name );
678  LAYER_T t = (LAYER_T) getLayerTypeIndex( layer );
679  m_pcb->SetLayerType( layer, t );
680  }
681  }
682 
683  m_pcb->GetDesignSettings().SetBoardThickness( thickness );
684 
685  return true;
686 }
687 
688 
690 {
691  wxChoice* ctl = getChoice( aLayer );
692 
693  int ret = ctl->GetCurrentSelection(); // indices must have same sequence as LAYER_T
694 
695  return ret;
696 }
697 
698 
700 {
701  wxString ret;
702 
703  wxASSERT( IsCopperLayer( aLayer ) );
704 
705  wxTextCtrl* ctl = (wxTextCtrl*) getName( aLayer );
706 
707  ret = ctl->GetValue().Trim();
708 
709  return ret;
710 }
711 
712 
713 static bool hasOneOf( const wxString& str, const wxString& chars )
714 {
715  for( unsigned i=0; i<chars.Len(); ++i )
716  {
717  if( str.Find( chars[i] ) != wxNOT_FOUND )
718  return true;
719  }
720 
721  return false;
722 }
723 
724 
726 {
727  std::vector<wxString> names;
728 
729  wxTextCtrl* ctl;
730 
731  for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
732  {
733  PCB_LAYER_ID layer = *seq;
734 
735  // we _can_ rely on m_enabledLayers being current here:
736  if( !m_enabledLayers[layer] )
737  continue;
738 
739  wxString name = getLayerName( layer );
740 
741  ctl = (wxTextCtrl*) getName( layer );
742 
743  // check name for legality.
744  // 1) cannot be blank.
745  // 2) cannot have blanks.
746  // 3) cannot have " chars
747  // 4) cannot be 'signal'
748  // 5) must be unique.
749  // 6) cannot have illegal chars in filenames ( some filenames are built from layer names )
750  // like : % $ \ " / :
751  wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
752  badchars.Append( '%' );
753 
754  if( !name )
755  {
756  DisplayError( this, _( "Layer name may not be empty." ) );
757  ctl->SetFocus(); // on the bad name
758  return false;
759  }
760 
761  if( hasOneOf( name, badchars ) )
762  {
763  DisplayError( this, _( "Layer name has an illegal character, one of: '" ) +
764  badchars + wxT( "'" ) );
765  ctl->SetFocus(); // on the bad name
766  return false;
767  }
768 
769  if( name == wxT( "signal" ) )
770  {
771  DisplayError( this, _( "Layer name 'signal' is reserved." ) );
772  ctl->SetFocus(); // on the bad name
773  return false;
774  }
775 
776  for( std::vector<wxString>::iterator it = names.begin(); it != names.end(); ++it )
777  {
778  if( name == *it )
779  {
780  DisplayError( this, _( "Duplicate layer names are not permitted." ) );
781  ctl->SetFocus(); // on the bad name
782  return false;
783  }
784  }
785 
786  names.push_back( name );
787  }
788 
789  return true;
790 }
791 
792 
794 {
795  LSEQ removedLayers;
796  LSET newLayers = getUILayerMask();
797  LSET curLayers = m_pcb->GetEnabledLayers();
798 
799  if( newLayers == curLayers )
800  return removedLayers;
801 
802  PCB_LAYER_COLLECTOR collector;
803  LSEQ newLayerSeq = newLayers.Seq();
804  std::vector< PCB_LAYER_ID >::iterator it;
805 
806  for( auto layer_id : curLayers.Seq() )
807  {
808  if( std::find( newLayerSeq.begin(), newLayerSeq.end(), layer_id ) == newLayerSeq.end() )
809  {
810  collector.SetLayerId( layer_id );
812 
813  if( collector.GetCount() != 0 )
814  removedLayers.push_back( layer_id );
815  }
816  }
817 
818  return removedLayers;
819 }
820 
821 
822 bool InvokeLayerSetup( wxTopLevelWindow* aCaller, BOARD* aBoard )
823 {
824  DIALOG_LAYERS_SETUP dlg( aCaller, aBoard );
825 
826  return dlg.ShowModal() == wxID_OK;
827 }
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:646
int GetCount() const
Function GetCount returns the number of objects in the list.
#define DIM(x)
of elements in an array
Definition: macros.h:98
static LSEQ dlg_layers()
wxFlexGridSizer * m_LayerListFlexGridSizer
static const KICAD_T BoardLevelItems[]
A scan list for all primary board items, omitting items which are subordinate to a MODULE...
Definition: collectors.h:255
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:690
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:203
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's Inspector method, which does the collection.
Definition: collectors.cpp:494
static LSET FrontTechMask()
Function FrontTechMask returns a mask holding all technical layers (no CU layer) on front side...
Definition: lset.cpp:702
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:573
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:583
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:337
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:479
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.
static LSET InternalCuMask()
Function InternalCuMask() returns a complete set of internal copper layers, which is all Cu layers ex...
Definition: lset.cpp:606
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:384
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)
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:265
LSEQ getRemovedLayersWithItems()
Return a list of layers removed from the board that contain items.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
wxString getLayerName(LAYER_NUM layer)
const char * name
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:730
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:71
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:129
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)