KiCad PCB EDA Suite
class_pcb_layer_widget.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) 2004-2016 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
5  * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2010-2016 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 /******************************************************/
28 /* class_pcb_layer_widget.cpp - Pcbnew layers manager */
29 /******************************************************/
30 
31 #include <fctsys.h>
32 #include <pgm_base.h>
33 #include <class_drawpanel.h>
34 #include <class_draw_panel_gal.h>
35 #include <view/view.h>
36 #include <painter.h>
37 
38 #include <confirm.h>
39 #include <wxPcbStruct.h>
40 #include <pcbstruct.h>
41 #include <layer_widget.h>
42 #include <macros.h>
43 #include <menus_helpers.h>
44 
45 #include <class_board.h>
46 #include <class_pcb_layer_widget.h>
47 
48 #include <pcbnew.h>
49 #include <collectors.h>
50 #include <pcbnew_id.h>
51 
53 
54 
57 
58 #define RR LAYER_WIDGET::ROW // Render Row abbreviation to reduce source width
59 
60  // text id color tooltip
61  RR( _( "Through Via" ), LAYER_VIA_THROUGH, WHITE, _( "Show through vias" ) ),
62  RR( _( "Bl/Buried Via" ), LAYER_VIA_BBLIND, WHITE, _( "Show blind or buried vias" ) ),
63  RR( _( "Micro Via" ), LAYER_VIA_MICROVIA, WHITE, _( "Show micro vias") ),
64  RR( _( "Non Plated Holes" ),LAYER_NON_PLATED, WHITE, _( "Show non plated holes in specific color") ),
65  RR( _( "Ratsnest" ), LAYER_RATSNEST, WHITE, _( "Show unconnected nets as a ratsnest") ),
66 
67  RR( _( "Pads Front" ), LAYER_PAD_FR, WHITE, _( "Show footprint pads on board's front" ) ),
68  RR( _( "Pads Back" ), LAYER_PAD_BK, WHITE, _( "Show footprint pads on board's back" ) ),
69 
70  RR( _( "Text Front" ), LAYER_MOD_TEXT_FR, COLOR4D::UNSPECIFIED, _( "Show footprint text on board's front" ) ),
71  RR( _( "Text Back" ), LAYER_MOD_TEXT_BK, COLOR4D::UNSPECIFIED, _( "Show footprint text on board's back" ) ),
72  RR( _( "Hidden Text" ), LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
73 
74  RR( _( "Anchors" ), LAYER_ANCHOR, WHITE, _( "Show footprint and text origins as a cross" ) ),
75  RR( _( "Grid" ), LAYER_GRID, WHITE, _( "Show the (x,y) grid dots" ) ),
76  RR( _( "No-Connects" ), LAYER_NO_CONNECTS, COLOR4D::UNSPECIFIED, _( "Show a marker on pads which have no net connected" ) ),
77  RR( _( "Footprints Front" ),LAYER_MOD_FR, COLOR4D::UNSPECIFIED, _( "Show footprints that are on board's front") ),
78  RR( _( "Footprints Back" ), LAYER_MOD_BK, COLOR4D::UNSPECIFIED, _( "Show footprints that are on board's back") ),
79  RR( _( "Values" ), LAYER_MOD_VALUES, COLOR4D::UNSPECIFIED, _( "Show footprint's values") ),
80  RR( _( "References" ), LAYER_MOD_REFERENCES, COLOR4D::UNSPECIFIED, _( "Show footprint's references") ),
81  RR( _( "Worksheet" ), LAYER_WORKSHEET, DARKRED, _( "Show worksheet") ),
82  RR( _( "Cursor" ), LAYER_CURSOR, WHITE, _( "PCB Cursor" ), true, false ),
83  RR( _( "Aux items" ), LAYER_AUX_ITEMS, WHITE, _( "Auxillary items (rulers, assistants, axes, etc.)" ), true, false ),
84  RR( _( "Background" ), LAYER_PCB_BACKGROUND, BLACK, _( "PCB Background" ), true, false )
85 };
86 
87 static int s_allowed_in_FpEditor[] =
88 {
91 };
92 
93 
94 PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner,
95  int aPointSize, bool aFpEditorMode ) :
96  LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
97  myframe( aParent )
98 {
100  m_fp_editor_mode = aFpEditorMode;
101  ReFillRender();
102 
103  // Update default tabs labels
105 
106  //-----<Popup menu>-------------------------------------------------
107  // handle the popup menu over the layer window.
108  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
109  wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
110 
111  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
112  // and not m_LayerScrolledWindow->Connect()
113 
115  wxEVT_COMMAND_MENU_SELECTED,
116  wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
117  // install the right click handler into each control at end of ReFill()
118  // using installRightLayerClickHandler
119 }
120 
121 
123 {
124  return myframe->IsGalCanvasActive();
125 }
126 
127 
129 {
130  for( unsigned ii = 0; ii < DIM( s_allowed_in_FpEditor ); ii++ )
131  if( s_allowed_in_FpEditor[ii] == aId )
132  return true;
133 
134  return false;
135 }
136 
137 
139 {
140  static LSET allowed = LSET::AllTechMask();
141  // Currently not in use because putting a graphic item on a copper layer
142  // is not currently supported by DRC.
143  // allowed.set( F_Cu ).set( B_Cu );
144  return allowed.test( aLayer );
145 }
146 
147 
149 {
150  int rowCount = GetLayerRowCount();
151 
152  for( int row=0; row < rowCount; ++row )
153  {
154  for( int col=0; col<LYR_COLUMN_COUNT; ++col )
155  {
156  wxWindow* w = getLayerComp( row, col );
157 
158  w->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler(
159  PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
160  }
161  }
162 }
163 
164 
165 void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
166 {
167  wxMenu menu;
168 
169  // menu text is capitalized:
170  // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
172  _( "Show All Copper Layers" ),
173  KiBitmap( select_layer_pair_xpm ) );
175  _( "Hide All Copper Layers But Active" ),
176  KiBitmap( select_w_layer_xpm ) );
178  _( "Always Hide All Copper Layers But Active" ),
179  KiBitmap( select_w_layer_xpm ) );
181  _( "Hide All Copper Layers" ),
182  KiBitmap( show_no_copper_layers_xpm ) );
183 
184  menu.AppendSeparator();
185 
187  _( "Show All Non Copper Layers" ),
188  KiBitmap( select_w_layer_xpm ) );
190  _( "Hide All Non Copper Layers" ),
191  KiBitmap( show_no_copper_layers_xpm ) );
192 
193  menu.AppendSeparator();
194 
195  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
196  KiBitmap( show_no_layers_xpm ) );
197  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
198  KiBitmap( show_all_layers_xpm ) );
199 
200  menu.AppendSeparator();
201 
202  AddMenuItem( &menu, ID_SHOW_ALL_FRONT, _( "Show All Front Layers" ),
203  KiBitmap( show_no_layers_xpm ) );
204 
205  AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
206  KiBitmap( show_all_layers_xpm ) );
207 
208  PopupMenu( &menu );
209 
210  passOnFocus();
211 }
212 
213 
214 void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
215 {
216  int rowCount;
217  int menuId = event.GetId();
218  bool visible;
219  bool force_active_layer_visible;
220 
222  force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ||
224 
225  switch( menuId )
226  {
227 
228  case ID_SHOW_NO_LAYERS:
229  case ID_SHOW_ALL_LAYERS:
230  {
231  visible = ( menuId == ID_SHOW_ALL_LAYERS );
232  rowCount = GetLayerRowCount();
233 
234  for( int row=0; row<rowCount; ++row )
235  {
236  bool isLast;
237  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
238  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
239  cb->SetValue( visible );
240 
241  isLast = row == rowCount-1;
242 
243  OnLayerVisible( layer, visible, isLast );
244 
245  if( isLast )
246  break;
247  }
248  break;
249  }
250 
257  {
258 
259  // Search the last copper layer row index:
260  int lastCu = -1;
261  rowCount = GetLayerRowCount();
262  for( int row = rowCount-1; row>=0; --row )
263  {
264  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
265  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
266 
267  if( IsCopperLayer( layer ) )
268  {
269  lastCu = row;
270  break;
271  }
272  }
273 
274  // Enable/disable the copper layers visibility:
275  int startrow = 0;
276 
277  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
278  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
279  {
280  startrow = lastCu + 1;
281  }
282 
283  for( int row = startrow; row<rowCount; ++row )
284  {
285  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
286  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
287 
288  visible = ( ( menuId == ID_SHOW_ALL_COPPER_LAYERS ) || ( menuId == ID_SHOW_ALL_NON_COPPER ) );
289 
290  if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
291  visible = true;
292 
293  cb->SetValue( visible );
294 
295  bool isLastLayer = (row == lastCu);
296 
297  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
298  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
299  {
300  isLastLayer = false;
301  }
302  OnLayerVisible( layer, visible, isLastLayer );
303 
304  if( isLastLayer )
305  break;
306  }
307  break;
308  }
309 
310  case ID_SHOW_ALL_FRONT:
311  {
312  visible = false;
313  rowCount = GetLayerRowCount();
314 
315  for( int row=0; row<rowCount; ++row )
316  {
317  bool isLast;
318  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
319  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
320  isLast = ( row == rowCount-1 );
321 
322  if( layer == F_Paste || layer == F_SilkS ||
323  layer == F_Mask || layer == F_Cu ||
324  layer == F_Fab || layer == F_CrtYd || layer == Edge_Cuts )
325  {
326  visible = true;
327  }
328  else
329  {
330  visible = false;
331  }
332 
333  cb->SetValue( visible );
334  OnLayerVisible( layer, visible, isLast );
335 
336  if( isLast )
337  break;
338  }
339  break;
340  }
341  case ID_SHOW_ALL_BACK:
342  {
343  visible = false;
344  rowCount = GetLayerRowCount();
345 
346  for( int row=0; row<rowCount; ++row )
347  {
348  bool isLast;
349  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
350  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
351  isLast = ( row == rowCount-1 );
352 
353  if( layer == B_Paste || layer == B_SilkS ||
354  layer == B_Mask || layer == B_Cu ||
355  layer == B_Fab || layer == B_CrtYd || layer == Edge_Cuts )
356  {
357  visible = true;
358  }
359  else
360  {
361  visible = false;
362  }
363 
364  cb->SetValue( visible );
365  OnLayerVisible( layer, visible, isLast );
366 
367  if( isLast )
368  break;
369  }
370  break;
371  }
372  }
373 }
374 
375 
377 {
378  m_notebook->SetPageText( 0, _( "Layer" ) );
379  m_notebook->SetPageText( 1, _( "Render" ) );
380 }
381 
382 
384 {
385  BOARD* board = myframe->GetBoard();
386  ClearRenderRows();
387 
388  // Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state.
389  // Because s_render_rows is created static, we must explicitly call
390  // wxGetTranslation for texts which are internationalized (tool tips
391  // and item names)
392  for( unsigned row=0; row<DIM(s_render_rows); ++row )
393  {
394  LAYER_WIDGET::ROW renderRow = s_render_rows[row];
395 
396  if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
397  continue;
398 
399  renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
400  renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
401 
402  if( renderRow.color != COLOR4D::UNSPECIFIED ) // does this row show a color?
403  {
404  // this window frame must have an established BOARD, i.e. after SetBoard()
405  renderRow.color = myframe->Settings().Colors().GetItemColor( static_cast<GAL_LAYER_ID>( renderRow.id ) );
406  }
407 
408  renderRow.state = board->IsElementVisible( static_cast<GAL_LAYER_ID>( renderRow.id ) );
409 
410  AppendRenderRow( renderRow );
411  }
412 }
413 
414 
416 {
417  BOARD* board = myframe->GetBoard();
418 
419  for( unsigned row=0; row<DIM(s_render_rows); ++row )
420  {
421  int rowId = s_render_rows[row].id;
422 
423  if( m_fp_editor_mode && !isAllowedInFpMode( rowId ) )
424  continue;
425 
426  // this does not fire a UI event
427  SetRenderState( rowId, board->IsElementVisible( static_cast<GAL_LAYER_ID>( rowId ) ) );
428  }
429 }
430 
431 
433 {
434  BOARD* board = myframe->GetBoard();
435  int count = GetLayerRowCount();
436 
437  for( int row=0; row<count; ++row )
438  {
439  // this utilizes more implementation knowledge than ideal, eventually
440  // add member ROW getRow() or similar to base LAYER_WIDGET.
441 
442  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
443 
444  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
445 
446  // this does not fire a UI event
447  SetLayerVisible( layerId, board->IsLayerVisible( layerId ) );
448  }
449 }
450 
451 
453 {
454  BOARD* brd = myframe->GetBoard();
455  LSET enabled = brd->GetEnabledLayers();
456 
457  ClearLayerRows();
458 
459  wxString dsc;
460 
461  // show all coppers first, with front on top, back on bottom, then technical layers
462  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
463  {
464  PCB_LAYER_ID layer = *cu_stack;
465 
466  switch( layer )
467  {
468  case F_Cu:
469  dsc = _( "Front copper layer" );
470  break;
471 
472  case B_Cu:
473  dsc = _( "Back copper layer" );
474  break;
475 
476  default:
477  dsc = _( "Inner copper layer" );
478  break;
479  }
480 
482  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
483  dsc, true ) );
484 
485  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
486  {
487  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
489  COLUMN_COLORBM )->SetToolTip( wxEmptyString );
490  }
491  }
492 
493 
494  // technical layers are shown in this order:
495  // Because they are static, wxGetTranslation must be explicitly
496  // called for tooltips.
497  static const struct {
498  PCB_LAYER_ID layerId;
499  wxString tooltip;
500  } non_cu_seq[] = {
501  { F_Adhes, _( "Adhesive on board's front" ) },
502  { B_Adhes, _( "Adhesive on board's back" ) },
503  { F_Paste, _( "Solder paste on board's front" ) },
504  { B_Paste, _( "Solder paste on board's back" ) },
505  { F_SilkS, _( "Silkscreen on board's front" ) },
506  { B_SilkS, _( "Silkscreen on board's back" ) },
507  { F_Mask, _( "Solder mask on board's front" ) },
508  { B_Mask, _( "Solder mask on board's back" ) },
509  { Dwgs_User, _( "Explanatory drawings" ) },
510  { Cmts_User, _( "Explanatory comments" ) },
511  { Eco1_User, _( "User defined meaning" ) },
512  { Eco2_User, _( "User defined meaning" ) },
513  { Edge_Cuts, _( "Board's perimeter definition" ) },
514  { Margin, _( "Board's edge setback outline" ) },
515  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
516  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
517  { F_Fab, _( "Footprint assembly on board's front" ) },
518  { B_Fab, _( "Footprint assembly on board's back" ) }
519  };
520 
521  for( unsigned i=0; i<DIM( non_cu_seq ); ++i )
522  {
523  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
524 
525  if( !enabled[layer] )
526  continue;
527 
529  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
530  wxGetTranslation( non_cu_seq[i].tooltip ), true ) );
531 
532  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
533  {
534  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
536  COLUMN_COLORBM )->SetToolTip( wxEmptyString );
537  }
538  }
539 
541 }
542 
543 
544 //-----<LAYER_WIDGET callbacks>-------------------------------------------
545 
547 {
548  // Avoid setting the alpha channel, when we are in legacy mode,
549  // because in legacy mode the alpha channel is not used, but changing it
550  // destroys the GAL color setup
551  if( !myframe->IsGalCanvasActive() )
552  {
553  COLOR4D oldColor = myframe->Settings().Colors().GetLayerColor( ToLAYER_ID( aLayer ) );
554  aColor.a = oldColor.a;
555  }
556 
557  myframe->Settings().Colors().SetLayerColor( ToLAYER_ID( aLayer ), aColor );
558 
559  if( myframe->IsGalCanvasActive() )
560  {
561  KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
563  view->UpdateLayerColor( aLayer );
564  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
565  }
566 
567  myframe->GetCanvas()->Refresh();
568 }
569 
570 
572 {
573  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
574  // false from this function.
575  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
576 
577  if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
578  return false;
579 
580  myframe->SetActiveLayer( layer );
582 
584  OnLayerSelected();
585  else if( displ_opts->m_ContrastModeDisplay )
586  myframe->GetCanvas()->Refresh();
587 
588  return true;
589 }
590 
591 
593 {
595  return false;
596 
597  // postprocess after an active layer selection
598  // ensure active layer visible
599  wxCommandEvent event;
601  onPopupSelection( event );
602 
603  return true;
604 }
605 
606 
607 void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
608 {
609  BOARD* brd = myframe->GetBoard();
610 
611  LSET visibleLayers = brd->GetVisibleLayers();
612 
613  visibleLayers.set( aLayer, isVisible );
614 
615  brd->SetVisibleLayers( visibleLayers );
616 
617  myframe->OnModify();
618 
619  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
620 
621  if( galCanvas )
622  galCanvas->GetView()->SetLayerVisible( aLayer, isVisible );
623 
624  if( isFinal )
625  myframe->GetCanvas()->Refresh();
626 }
627 
628 
630 {
631  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
632 
633  myframe->Settings().Colors().SetItemColor( static_cast<GAL_LAYER_ID>( aId ), aColor );
634 
635  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
636 
637  if( galCanvas && myframe->IsGalCanvasActive() )
638  {
639  if( aId == LAYER_GRID )
640  galCanvas->GetGAL()->SetGridColor( aColor );
641 
642  KIGFX::VIEW* view = galCanvas->GetView();
644  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
645  view->UpdateLayerColor( aId );
646  galCanvas->Refresh();
647  }
648 
649  myframe->GetCanvas()->Refresh();
650 }
651 
652 
653 void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
654 {
655  BOARD* brd = myframe->GetBoard();
656  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
657 
658  // The layer visibility status is saved in the board file so set the board modified
659  // state so the user has the option to save the changes.
660  if( brd->IsElementVisible( static_cast<GAL_LAYER_ID>( aId ) ) != isEnabled )
661  myframe->OnModify();
662 
663  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
664 
665  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
666 
667  if( galCanvas && myframe->IsGalCanvasActive() )
668  {
669  if( aId == LAYER_GRID )
670  {
671  galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
673  }
674  else if ( aId == LAYER_RATSNEST )
675  {
676  // don't touch the layers. ratsnest is enabled on per-item basis.
678  galCanvas->GetView()->SetLayerVisible( aId, true );
679  }
680  else
681  galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
682 
683  galCanvas->Refresh();
684  }
685 
686  myframe->GetCanvas()->Refresh();
687 }
688 
689 //-----</LAYER_WIDGET callbacks>------------------------------------------
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:53
#define DIM(x)
of elements in an array
Definition: macros.h:98
wxAuiNotebook * m_notebook
Definition: layer_widget.h:109
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:47
to draw blind/buried vias
show a marker on pads with no nets
bool IsElementVisible(GAL_LAYER_ID LAYER_aPCB) const
Function IsElementVisible tests whether a given element category is visible.
void SetItemColor(int aItemIdx, COLOR4D aColor)
Function SetItemColor sets the color for an item which is one of the item indices given in enum PCB_L...
#define RR
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:84
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
bool OnLayerSelect(int aLayer) override
Function OnLayerSelect is called to notify client code whenever the user selects a different layer...
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
This file is part of the common library.
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:304
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:55
anchor of items having an anchor point (texts, footprints)
LSEQ CuStack() const
Function CuStack returns a sequence of copper layers in starting from the front/top and extending to ...
Definition: lset.cpp:147
Class BOARD to handle a board.
bool isLayerAllowedInFpMode(PCB_LAYER_ID aLayer)
Function isLayerAllowedInFpMode.
bool isLast(CPTREE &aTree, CITER it)
Definition: ptree.cpp:122
show modules on back
PCB_BASE_FRAME * myframe
show modules values (when texts are visibles)
BOARD * GetBoard() const
bool OnLayerSelected()
Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwa...
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer which is one of the layer indices given in pcbstruct...
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Add new GAL layers here.
static LSET AllTechMask()
Function AllTechMask returns a mask holding all technical layers (no CU layer) on both side...
Definition: lset.cpp:709
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
void ClearRenderRows()
Function ClearRenderRows empties out the render rows.
smd pads, back layer
Definition: colors.h:54
bool state
initial wxCheckBox state
Definition: layer_widget.h:89
virtual bool IsGridVisible() const
Function IsGridVisible() , virtual.
Definition: draw_frame.h:448
void SetLayersManagerTabsText()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
void ClearLayerRows()
Function ClearLayerRows empties out the layer rows.
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
wxString tooltip
if not empty, use this tooltip on row
Definition: layer_widget.h:90
Auxiliary rendering target (noncached)
Definition: definitions.h:42
This file contains miscellaneous commonly used macros and functions.
show modules on front
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
void AppendRenderRow(const ROW &aRow)
Function AppendRenderRow appends a new row in the render portion of the widget.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
COLOR4D color
COLOR4D::UNSPECIFIED if none.
Definition: layer_widget.h:88
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:289
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:50
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
Class LSET is a set of PCB_LAYER_IDs.
Auxillary items (guides, rule, etc)
static int s_allowed_in_FpEditor[]
#define COLUMN_COLORBM
Definition: layer_widget.h:51
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:568
void OnLayerColorChange(int aLayer, COLOR4D aColor) override
Function OnLayerColorChange is called to notify client code about a layer color change.
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
PCB_GENERAL_SETTINGS & Settings()
to draw usual through hole vias
Classes and definitions used in Pcbnew.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
PCB_LAYER_WIDGET(PCB_BASE_FRAME *aParent, wxWindow *aFocusOwner, int aPointSize=10, bool aFpEditorMode=false)
Constructor.
void AppendLayerRow(const ROW &aRow)
Function AppendLayerRow appends a new row in the layer portion of the widget.
void SetElementVisibility(GAL_LAYER_ID LAYER_aPCB, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void ReFillRender()
Function ReFillRender rebuilds Render for instance after the config is read.
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:111
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:828
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:387
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
COLORS_DESIGN_SETTINGS & Colors()
static const LAYER_WIDGET::ROW s_render_rows[]
This is a read only template that is copied and modified before adding to LAYER_WIDGET.
void OnRenderColorChange(int aId, COLOR4D aColor) override
Function OnRenderColorChange is called to notify client code whenever the user changes a rendering co...
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
virtual void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings)=0
Function ImportLegacyColors Loads a list of color settings for layers.
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:656
void OnLayerVisible(int aLayer, bool isVisible, bool isFinal) override
Function OnLayerVisible is called to notify client code about a layer visibility change.
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
Class LAYER_WIDGET is abstract and is used to manage a list of layers, with the notion of a "current"...
Definition: layer_widget.h:76
void SyncLayerVisibilities()
Function SyncLayerVisibilities updates each "Layer" checkbox in this layer widget according to each l...
smd pads, front layer
see class PGM_BASE
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:52
handle color for not plated holes
virtual bool AreArbitraryColorsAllowed() override
Subclasses can override this to provide logic for allowing arbitrary color selection via wxColourPick...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
wxString rowName
the prompt or layername
Definition: layer_widget.h:86
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
Definition: colors.h:49
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:836
void installRightLayerClickHandler()
this is for the popup menu, the right click handler has to be installed on every child control within...
Definition: colors.h:45
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
Function SetLayerVisible sets aLayer visible or not.
Class VIEW.
Definition: view.h:58
void OnRenderEnable(int aId, bool isEnabled) override
Function OnRenderEnable is called to notify client code whenever the user changes an rendering enable...
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
void SyncRenderStates()
Function SyncRenderStates updates the checkboxes (checked or not) to be consistent with the current s...
int id
either a layer or "visible element" id
Definition: layer_widget.h:87
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
show modules references (when texts are visibles)
void onPopupSelection(wxCommandEvent &event)
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:451
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39