KiCad PCB EDA Suite
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-2017 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-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 
32 #include <fctsys.h>
33 #include <pgm_base.h>
34 #include <class_drawpanel.h>
35 #include <class_draw_panel_gal.h>
36 #include <view/view.h>
37 #include <painter.h>
38 
39 #include <confirm.h>
40 #include <pcb_edit_frame.h>
41 #include <pcb_display_options.h>
42 #include <tool/tool_manager.h>
43 #include <layer_widget.h>
44 #include <class_text_mod.h>
45 #include <widgets/indicator_icon.h>
46 #include <macros.h>
47 #include <menus_helpers.h>
49 #include <pcb_painter.h>
50 
51 #include <class_board.h>
52 #include <pcb_layer_widget.h>
53 
54 #include <pcbnew.h>
55 #include <collectors.h>
56 #include <pcbnew_id.h>
57 
59 
60 
63 
64 #define RR LAYER_WIDGET::ROW // Render Row abbreviation to reduce source width
65 #define NOCOLOR COLOR4D::UNSPECIFIED // specify rows that do not have a color selector icon
66 
67  // text id color tooltip
68  RR( _( "Footprints Front" ), LAYER_MOD_FR, NOCOLOR, _( "Show footprints that are on board's front") ),
69  RR( _( "Footprints Back" ), LAYER_MOD_BK, NOCOLOR, _( "Show footprints that are on board's back") ),
70  RR( _( "Values" ), LAYER_MOD_VALUES, NOCOLOR, _( "Show footprint values") ),
71  RR( _( "References" ), LAYER_MOD_REFERENCES, NOCOLOR, _( "Show footprint references") ),
72  RR( _( "Footprint Text Front" ), LAYER_MOD_TEXT_FR, NOCOLOR, _( "Show footprint text on board's front" ) ),
73  RR( _( "Footprint Text Back" ), LAYER_MOD_TEXT_BK, NOCOLOR, _( "Show footprint text on board's back" ) ),
74  RR( _( "Hidden Text" ), LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
75  RR( _( "Pads Front" ), LAYER_PAD_FR, WHITE, _( "Show footprint pads on board's front" ) ),
76  RR( _( "Pads Back" ), LAYER_PAD_BK, WHITE, _( "Show footprint pads on board's back" ) ),
77  RR( _( "Through Hole Pads" ), LAYER_PADS_TH, YELLOW, _( "Show through hole pads in specific color") ),
78  RR(),
79  RR( _( "Tracks" ), LAYER_TRACKS, NOCOLOR, _( "Show tracks" ) ),
80  RR( _( "Through Via" ), LAYER_VIA_THROUGH, WHITE, _( "Show through vias" ) ),
81  RR( _( "Bl/Buried Via" ), LAYER_VIA_BBLIND, WHITE, _( "Show blind or buried vias" ) ),
82  RR( _( "Micro Via" ), LAYER_VIA_MICROVIA, WHITE, _( "Show micro vias") ),
83  RR( _( "Non Plated Holes" ),LAYER_NON_PLATEDHOLES,WHITE, _( "Show non plated holes in specific color") ),
84  RR(),
85  RR( _( "Ratsnest" ), LAYER_RATSNEST, WHITE, _( "Show unconnected nets as a ratsnest") ),
86  RR( _( "No-Connects" ), LAYER_NO_CONNECTS, BLUE, _( "Show a marker on pads which have no net connected" ) ),
87  RR( _( "Anchors" ), LAYER_ANCHOR, WHITE, _( "Show footprint and text origins as a cross" ) ),
88  RR( _( "Worksheet" ), LAYER_WORKSHEET, DARKRED, _( "Show worksheet") ),
89  RR( _( "Cursor" ), LAYER_CURSOR, WHITE, _( "PCB Cursor" ), true, false ),
90  RR( _( "Aux items" ), LAYER_AUX_ITEMS, WHITE, _( "Auxiliary items (rulers, assistants, axes, etc.)" ), true, false ),
91  RR( _( "Grid" ), LAYER_GRID, WHITE, _( "Show the (x,y) grid dots" ) ),
92  RR( _( "Background" ), LAYER_PCB_BACKGROUND, BLACK, _( "PCB Background" ), true, false )
93 };
94 
95 static int s_allowed_in_FpEditor[] =
96 {
100  LAYER_PAD_FR,
101  LAYER_PAD_BK,
102  LAYER_GRID,
106 };
107 
108 
109 PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner,
110  bool aFpEditorMode ) :
111  LAYER_WIDGET( aParent, aFocusOwner ),
112  myframe( aParent )
113 {
115  m_fp_editor_mode = aFpEditorMode;
116 
117  // Update default tabs labels
119 
120  //-----<Popup menu>-------------------------------------------------
121  // handle the popup menu over the layer window.
122  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
123  wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
124 
125  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
126  // and not m_LayerScrolledWindow->Connect()
127 
129  wxEVT_COMMAND_MENU_SELECTED,
130  wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
131 }
132 
133 
135 {
136  return myframe->IsGalCanvasActive();
137 }
138 
139 
141 {
142  return myframe->Settings().Colors().GetLayerColor( LAYER_PCB_BACKGROUND );
143 }
144 
145 
147 {
148  for( unsigned ii = 0; ii < DIM( s_allowed_in_FpEditor ); ii++ )
149  if( s_allowed_in_FpEditor[ii] == aId )
150  return true;
151 
152  return false;
153 }
154 
155 
157 {
158  static LSET allowed = LSET::AllTechMask();
159  allowed.set( F_Cu ).set( B_Cu );
160  return allowed.test( aLayer );
161 }
162 
163 
165 {
166  // menu text is capitalized:
167  // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
169  _( "Show All Copper Layers" ),
170  KiBitmap( select_layer_pair_xpm ) );
172  _( "Hide All Copper Layers But Active" ),
173  KiBitmap( select_w_layer_xpm ) );
175  _( "Always Hide All Copper Layers But Active" ),
176  KiBitmap( select_w_layer_xpm ) );
178  _( "Hide All Copper Layers" ),
179  KiBitmap( show_no_copper_layers_xpm ) );
180 
181  menu.AppendSeparator();
182 
184  _( "Show All Non Copper Layers" ),
185  KiBitmap( select_w_layer_xpm ) );
187  _( "Hide All Non Copper Layers" ),
188  KiBitmap( show_no_copper_layers_xpm ) );
189 
190  menu.AppendSeparator();
191 
192  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
193  KiBitmap( show_no_layers_xpm ) );
194  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
195  KiBitmap( show_all_layers_xpm ) );
196 
197  menu.AppendSeparator();
198 
199  AddMenuItem( &menu, ID_SHOW_ALL_FRONT, _( "Show All Front Layers" ),
200  KiBitmap( show_no_layers_xpm ) );
201 
202  AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
203  KiBitmap( show_all_layers_xpm ) );
204 }
205 
206 
207 void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
208 {
209  wxMenu menu;
210 
211  AddRightClickMenuItems( menu );
212  PopupMenu( &menu );
213 
214  passOnFocus();
215 }
216 
217 
218 void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
219 {
220  int rowCount;
221  int menuId = event.GetId();
222  bool visible;
223  bool force_active_layer_visible;
224 
226  force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ||
228 
229  switch( menuId )
230  {
231  case ID_SHOW_NO_LAYERS:
232  case ID_SHOW_ALL_LAYERS:
233  {
234  visible = ( menuId == ID_SHOW_ALL_LAYERS );
235  rowCount = GetLayerRowCount();
236 
237  for( int row=0; row<rowCount; ++row )
238  {
239  bool isLast;
240  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
241  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
242  cb->SetValue( visible );
243 
244  isLast = row == rowCount-1;
245 
246  OnLayerVisible( layer, visible, isLast );
247 
248  if( isLast )
249  break;
250  }
251  break;
252  }
253 
260  {
261 
262  // Search the last copper layer row index:
263  int lastCu = -1;
264  rowCount = GetLayerRowCount();
265  for( int row = rowCount-1; row>=0; --row )
266  {
267  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
268  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
269 
270  if( IsCopperLayer( layer ) )
271  {
272  lastCu = row;
273  break;
274  }
275  }
276 
277  // Enable/disable the copper layers visibility:
278  int startrow = 0;
279 
280  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
281  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
282  {
283  startrow = lastCu + 1;
284  }
285 
286  for( int row = startrow; row<rowCount; ++row )
287  {
288  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
289  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
290 
291  visible = ( ( menuId == ID_SHOW_ALL_COPPER_LAYERS ) || ( menuId == ID_SHOW_ALL_NON_COPPER ) );
292 
293  if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
294  visible = true;
295 
296  cb->SetValue( visible );
297 
298  bool isLastLayer = (row == lastCu);
299 
300  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
301  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
302  {
303  isLastLayer = false;
304  }
305  OnLayerVisible( layer, visible, isLastLayer );
306 
307  if( isLastLayer )
308  break;
309  }
310  break;
311  }
312 
313  case ID_SHOW_ALL_FRONT:
314  {
315  visible = false;
316  rowCount = GetLayerRowCount();
317 
318  for( int row=0; row<rowCount; ++row )
319  {
320  bool isLast;
321  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
322  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
323  isLast = ( row == rowCount-1 );
324 
325  if( layer == F_Paste || layer == F_SilkS ||
326  layer == F_Mask || layer == F_Cu ||
327  layer == F_Fab || layer == F_CrtYd || layer == Edge_Cuts )
328  {
329  visible = true;
330  }
331  else
332  {
333  visible = false;
334  }
335 
336  cb->SetValue( visible );
337  OnLayerVisible( layer, visible, isLast );
338 
339  if( isLast )
340  break;
341  }
342  break;
343  }
344  case ID_SHOW_ALL_BACK:
345  {
346  visible = false;
347  rowCount = GetLayerRowCount();
348 
349  for( int row=0; row<rowCount; ++row )
350  {
351  bool isLast;
352  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
353  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
354  isLast = ( row == rowCount-1 );
355 
356  if( layer == B_Paste || layer == B_SilkS ||
357  layer == B_Mask || layer == B_Cu ||
358  layer == B_Fab || layer == B_CrtYd || layer == Edge_Cuts )
359  {
360  visible = true;
361  }
362  else
363  {
364  visible = false;
365  }
366 
367  cb->SetValue( visible );
368  OnLayerVisible( layer, visible, isLast );
369 
370  if( isLast )
371  break;
372  }
373  break;
374  }
375  }
376 }
377 
378 
380 {
381  m_notebook->SetPageText( 0, _( "Layers" ) );
382  m_notebook->SetPageText( 1, _( "Items" ) );
383 }
384 
385 
387 {
388  BOARD* board = myframe->GetBoard();
389  auto settings = board->GetDesignSettings();
390 
391  ClearRenderRows();
392 
393  // Add "Items" tab rows to LAYER_WIDGET, after setting color and checkbox state.
394  // Because s_render_rows is created static, we must explicitly call
395  // wxGetTranslation for texts which are internationalized (tool tips
396  // and item names)
397  for( unsigned row=0; row<DIM(s_render_rows); ++row )
398  {
399  LAYER_WIDGET::ROW renderRow = s_render_rows[row];
400 
401  if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
402  continue;
403 
404  if( renderRow.id == LAYER_VIA_MICROVIA && !settings.m_MicroViasAllowed )
405  continue;
406 
407  if( renderRow.id == LAYER_VIA_BBLIND && !settings.m_BlindBuriedViaAllowed )
408  continue;
409 
410  if( !renderRow.spacer )
411  {
412  renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
413  renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
414 
415  if( renderRow.color != COLOR4D::UNSPECIFIED ) // does this row show a color?
416  {
417  // this window frame must have an established BOARD, i.e. after SetBoard()
418  renderRow.color = myframe->Settings().Colors().GetItemColor( static_cast<GAL_LAYER_ID>( renderRow.id ) );
419  }
420 
421  renderRow.state = board->IsElementVisible( static_cast<GAL_LAYER_ID>( renderRow.id ) );
422  }
423 
424  AppendRenderRow( renderRow );
425  }
426 
427  UpdateLayouts();
428 }
429 
430 
432 {
433  BOARD* board = myframe->GetBoard();
434  int count = GetLayerRowCount();
435 
436  for( int row=0; row<count; ++row )
437  {
438  // this utilizes more implementation knowledge than ideal, eventually
439  // add member ROW getRow() or similar to base LAYER_WIDGET.
440 
441  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
442 
443  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
444 
445  // this does not fire a UI event
446  setLayerCheckbox( layerId, board->IsLayerVisible( layerId ) );
447  }
448 }
449 
450 
451 #define ALPHA_EPSILON 0.04
452 
454 {
455  int count = GetLayerRowCount();
457  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() );
458  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
459 
460  for( int row = 0; row < count; ++row )
461  {
462  // this utilizes more implementation knowledge than ideal, eventually
463  // add member ROW getRow() or similar to base LAYER_WIDGET.
464 
465  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
466  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
467  KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId );
468 
469  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) );
470  KIGFX::COLOR4D layerColor = swatch->GetSwatchColor();
471 
472  INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) );
473 
474  if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON )
475  {
476  if( screenColor.a < layerColor.a )
477  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
478  else
479  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
480  }
481  else
483  }
484 }
485 
486 
488 {
489  BOARD* brd = myframe->GetBoard();
490  LSET enabled = brd->GetEnabledLayers();
491 
492  ClearLayerRows();
493 
494  wxString dsc;
495 
496  // show all coppers first, with front on top, back on bottom, then technical layers
497  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
498  {
499  PCB_LAYER_ID layer = *cu_stack;
500 
501  switch( layer )
502  {
503  case F_Cu:
504  dsc = _( "Front copper layer" );
505  break;
506 
507  case B_Cu:
508  dsc = _( "Back copper layer" );
509  break;
510 
511  default:
512  dsc = _( "Inner copper layer" );
513  break;
514  }
515 
517  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
518  dsc, true ) );
519 
520  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
521  {
522  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
523  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
524  }
525  }
526 
527  UpdateLayouts();
528 
529 
530  // technical layers are shown in this order:
531  // Because they are static, wxGetTranslation must be explicitly
532  // called for tooltips.
533  static const struct {
534  PCB_LAYER_ID layerId;
535  wxString tooltip;
536  } non_cu_seq[] = {
537  { F_Adhes, _( "Adhesive on board's front" ) },
538  { B_Adhes, _( "Adhesive on board's back" ) },
539  { F_Paste, _( "Solder paste on board's front" ) },
540  { B_Paste, _( "Solder paste on board's back" ) },
541  { F_SilkS, _( "Silkscreen on board's front" ) },
542  { B_SilkS, _( "Silkscreen on board's back" ) },
543  { F_Mask, _( "Solder mask on board's front" ) },
544  { B_Mask, _( "Solder mask on board's back" ) },
545  { Dwgs_User, _( "Explanatory drawings" ) },
546  { Cmts_User, _( "Explanatory comments" ) },
547  { Eco1_User, _( "User defined meaning" ) },
548  { Eco2_User, _( "User defined meaning" ) },
549  { Edge_Cuts, _( "Board's perimeter definition" ) },
550  { Margin, _( "Board's edge setback outline" ) },
551  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
552  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
553  { F_Fab, _( "Footprint assembly on board's front" ) },
554  { B_Fab, _( "Footprint assembly on board's back" ) }
555  };
556 
557  for( unsigned i=0; i<DIM( non_cu_seq ); ++i )
558  {
559  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
560 
561  if( !enabled[layer] )
562  continue;
563 
565  brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
566  wxGetTranslation( non_cu_seq[i].tooltip ), true ) );
567 
568  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
569  {
570  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
571  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
572  }
573  }
574 }
575 
576 
577 //-----<LAYER_WIDGET callbacks>-------------------------------------------
578 
580 {
581  // Avoid setting the alpha channel, when we are in legacy mode,
582  // because in legacy mode the alpha channel is not used, but changing it
583  // destroys the GAL color setup
584  if( !myframe->IsGalCanvasActive() )
585  {
586  COLOR4D oldColor = myframe->Settings().Colors().GetLayerColor( aLayer );
587  aColor.a = oldColor.a;
588  }
589 
590  myframe->Settings().Colors().SetLayerColor( aLayer, aColor );
591 
592  if( myframe->IsGalCanvasActive() )
593  {
594  KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
596  view->UpdateLayerColor( aLayer );
597  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
598  }
599 
601 
602  myframe->GetCanvas()->Refresh();
603 
604  if( aLayer == LAYER_PCB_BACKGROUND )
605  myframe->SetDrawBgColor( aColor );
606 }
607 
608 
610 {
611  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
612  // false from this function.
613  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
614 
615  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
616  return false;
617 
618  myframe->SetActiveLayer( layer );
620 
622  OnLayerSelected();
623  else if( displ_opts->m_ContrastModeDisplay )
624  myframe->GetCanvas()->Refresh();
625 
626  return true;
627 }
628 
629 
631 {
633  return false;
634 
635  // postprocess after an active layer selection
636  // ensure active layer visible
637  wxCommandEvent event;
639  onPopupSelection( event );
640 
641  return true;
642 }
643 
644 
645 void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
646 {
647  BOARD* brd = myframe->GetBoard();
648 
649  LSET visibleLayers = brd->GetVisibleLayers();
650 
651  if( visibleLayers.test( aLayer ) != isVisible )
652  {
653  visibleLayers.set( aLayer, isVisible );
654 
655  brd->SetVisibleLayers( visibleLayers );
656 
657  myframe->OnModify();
658 
659  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
660 
661  if( galCanvas )
662  galCanvas->GetView()->SetLayerVisible( aLayer, isVisible );
663  }
664 
665  if( isFinal )
666  myframe->GetCanvas()->Refresh();
667 }
668 
669 
671 {
672  AddRightClickMenuItems( aMenu );
673 }
674 
675 
677 {
678  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
679 
680  myframe->Settings().Colors().SetItemColor( static_cast<GAL_LAYER_ID>( aId ), aColor );
681 
682  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
683 
684  if( galCanvas && myframe->IsGalCanvasActive() )
685  {
686  if( aId == LAYER_GRID )
687  galCanvas->GetGAL()->SetGridColor( aColor );
688 
689  KIGFX::VIEW* view = galCanvas->GetView();
691  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
692  view->UpdateLayerColor( aId );
693 
694  // plated-through-holes don't have their own color; they use the background color
695  if( aId == LAYER_PCB_BACKGROUND )
697 
698  galCanvas->ForceRefresh();
699  }
700 
702 
703  myframe->GetCanvas()->Refresh();
704 }
705 
706 
707 void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
708 {
709  BOARD* brd = myframe->GetBoard();
710  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
711 
712  if( myframe->IsType( FRAME_PCB ) )
713  {
714  // The layer visibility status is saved in the board file so set the board
715  // modified state so the user has the option to save the changes.
716  if( brd->IsElementVisible( static_cast<GAL_LAYER_ID>( aId ) ) != isEnabled )
717  myframe->OnModify();
718  }
719 
720  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
721 
722  EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
723 
724  if( galCanvas && myframe->IsGalCanvasActive() )
725  {
726  if( aId == LAYER_GRID )
727  {
728  galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
730  }
731  else if( aId == LAYER_RATSNEST )
732  {
733  // don't touch the layers. ratsnest is enabled on per-item basis.
735  galCanvas->GetView()->SetLayerVisible( aId, true );
736  }
737  else
738  galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
739 
740  galCanvas->Refresh();
741  }
742 
743  myframe->GetCanvas()->Refresh();
744 }
745 
746 //-----</LAYER_WIDGET callbacks>------------------------------------------
Definition: colors.h:57
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:55
#define DIM(x)
of elements in an array
Definition: macros.h:98
void AddRightClickMenuItems(wxMenu &menu)
Function addRightClickMenuItems add menu items to a menu that should be shown when right-clicking the...
void SetIndicatorState(ICON_ID aIconId)
Sets the row indiciator to the given state.
wxAuiNotebook * m_notebook
Definition: layer_widget.h:123
to draw blind/buried vias
#define ALPHA_EPSILON
show a marker on pads with no nets
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
static int s_allowed_in_FpEditor[]
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
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...
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:388
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:87
multilayer pads, usually with holes
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.
#define COLUMN_ALPHA_INDICATOR
Definition: layer_widget.h:56
This file is part of the common library.
static LSET ForbiddenFootprintLayers()
Function ForbiddenFootprintLayers Layers which are not allowed within footprint definitions.
Definition: lset.cpp:786
bool spacer
if true, this row is a spacer
Definition: layer_widget.h:95
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:223
handle color for not plated holes (holes, not pads)
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.
void UpdateLayouts()
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
virtual COLOR4D getBackgroundLayerColor() override
Subclasses can override this to provide accurate representation of transparent colour swatches...
#define OFF
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.
void SetDrawBgColor(COLOR4D aColor) override
KIGFX::COLOR4D GetSwatchColor() const
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Add new GAL layers here.
void OnLayerRightClick(wxMenu &aMenu) override
Function OnLayerRightClick is called to notify client code about a layer being right-clicked.
static LSET AllTechMask()
Function AllTechMask returns a mask holding all technical layers (no CU layer) on both side...
Definition: lset.cpp:743
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:211
#define abs(a)
Definition: auxiliary.h:84
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
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
Definition: colors.h:54
bool state
initial wxCheckBox state
Definition: layer_widget.h:92
virtual bool IsGridVisible() const
Definition: draw_frame.h:528
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:93
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.
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
Class TOOL_MANAGER.
Definition: tool_manager.h:49
void AppendRenderRow(const ROW &aRow)
Function AppendRenderRow appends a new row in the render portion of the widget.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
COLOR4D color
COLOR4D::UNSPECIFIED if none.
Definition: layer_widget.h:91
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.
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
Class representing a row indicator icon for use in places like the layer widget.
double a
Alpha component.
Definition: color4d.h:290
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
Class LSET is a set of PCB_LAYER_IDs.
Footprint text class description.
Auxiliary items (guides, rule, etc)
void setLayerCheckbox(LAYER_NUM aLayer, bool isVisible)
#define COLUMN_COLORBM
Definition: layer_widget.h:53
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:223
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:596
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
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
#define NOCOLOR
void AppendLayerRow(const ROW &aRow)
Function AppendLayerRow appends a new row in the layer portion of the widget.
void ReFillRender()
Function ReFillRender rebuilds Render for instance after the config is read.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:125
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:921
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:410
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:199
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SyncLayerAlphaIndicators()
Function SyncLayerAlphaIndicators updates each "Layer"s alpha indicator to show if the board is curre...
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...
bool m_alwaysShowActiveCopperLayer
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:774
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...
TOOL_MANAGER * GetToolManager() const
Return the tool manager instance, if any.
Definition: draw_frame.h:934
Class LAYER_WIDGET is abstract and is used to manage a list of layers, with the notion of a "current"...
Definition: layer_widget.h:79
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
void SyncLayerVisibilities()
Function SyncLayerVisibilities updates each "Layer" checkbox in this layer widget according to each l...
virtual void ReCreateHToolbar()=0
smd pads, front layer
see class PGM_BASE
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:54
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:170
wxString rowName
the prompt or layername
Definition: layer_widget.h:89
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
size_t i
Definition: json11.cpp:597
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
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
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:928
bool IsType(FRAME_T aType) const
Definition: colors.h:45
Class VIEW.
Definition: view.h:61
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
void OnRenderEnable(int aId, bool isEnabled) override
Function OnRenderEnable is called to notify client code whenever the user changes an rendering enable...
Definition: colors.h:68
Definition of PCB_DISPLAY_OPTIONS class.
int id
either a layer or "visible element" id
Definition: layer_widget.h:90
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
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)
#define RR
PCB_LAYER_WIDGET(PCB_BASE_FRAME *aParent, wxWindow *aFocusOwner, bool aFpEditorMode=false)
Constructor.
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:457
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39