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 
27 #include <fctsys.h>
28 #include <pgm_base.h>
29 #include <pcb_draw_panel_gal.h>
30 #include <view/view.h>
31 #include <painter.h>
32 #include <confirm.h>
33 #include <pcb_edit_frame.h>
34 #include <pcb_display_options.h>
35 #include <tool/tool_manager.h>
36 #include <layer_widget.h>
37 #include <class_text_mod.h>
38 #include <widgets/indicator_icon.h>
39 #include <macros.h>
40 #include <menus_helpers.h>
42 #include <pcb_painter.h>
43 #include <pcb_view.h>
44 #include <class_board.h>
45 #include <pcb_layer_widget.h>
46 #include <pcbnew.h>
47 #include <collectors.h>
48 #include <pcbnew_id.h>
50 
51 
54 
55 #define RR LAYER_WIDGET::ROW // Render Row abbreviation to reduce source width
56 #define NOCOLOR COLOR4D::UNSPECIFIED // specify rows that do not have a color selector icon
57 
58  // text id color tooltip
59  RR( _( "Footprints Front" ), LAYER_MOD_FR, NOCOLOR, _( "Show footprints that are on board's front") ),
60  RR( _( "Footprints Back" ), LAYER_MOD_BK, NOCOLOR, _( "Show footprints that are on board's back") ),
61  RR( _( "Values" ), LAYER_MOD_VALUES, NOCOLOR, _( "Show footprint values") ),
62  RR( _( "References" ), LAYER_MOD_REFERENCES, NOCOLOR, _( "Show footprint references") ),
63  RR( _( "Footprint Text Front" ), LAYER_MOD_TEXT_FR, NOCOLOR, _( "Show footprint text on board's front" ) ),
64  RR( _( "Footprint Text Back" ), LAYER_MOD_TEXT_BK, NOCOLOR, _( "Show footprint text on board's back" ) ),
65  RR( _( "Hidden Text" ), LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
66  RR( _( "Pads Front" ), LAYER_PAD_FR, WHITE, _( "Show footprint pads on board's front" ) ),
67  RR( _( "Pads Back" ), LAYER_PAD_BK, WHITE, _( "Show footprint pads on board's back" ) ),
68  RR( _( "Through Hole Pads" ), LAYER_PADS_TH, YELLOW, _( "Show through hole pads in specific color") ),
69  RR(),
70  RR( _( "Tracks" ), LAYER_TRACKS, NOCOLOR, _( "Show tracks" ) ),
71  RR( _( "Through Via" ), LAYER_VIA_THROUGH, WHITE, _( "Show through vias" ) ),
72  RR( _( "Bl/Buried Via" ), LAYER_VIA_BBLIND, WHITE, _( "Show blind or buried vias" ) ),
73  RR( _( "Micro Via" ), LAYER_VIA_MICROVIA, WHITE, _( "Show micro vias") ),
74  RR( _( "Non Plated Holes" ),LAYER_NON_PLATEDHOLES,WHITE, _( "Show non plated holes in specific color") ),
75  RR(),
76  RR( _( "Ratsnest" ), LAYER_RATSNEST, WHITE, _( "Show unconnected nets as a ratsnest") ),
77  RR( _( "No-Connects" ), LAYER_NO_CONNECTS, BLUE, _( "Show a marker on pads which have no net connected" ) ),
78  RR( _( "Anchors" ), LAYER_ANCHOR, WHITE, _( "Show footprint and text origins as a cross" ) ),
79  RR( _( "Worksheet" ), LAYER_WORKSHEET, DARKRED, _( "Show worksheet") ),
80  RR( _( "Cursor" ), LAYER_CURSOR, WHITE, _( "PCB Cursor" ), true, false ),
81  RR( _( "Aux items" ), LAYER_AUX_ITEMS, WHITE, _( "Auxiliary items (rulers, assistants, axes, etc.)" ), true, false ),
82  RR( _( "Grid" ), LAYER_GRID, WHITE, _( "Show the (x,y) grid dots" ) ),
83  RR( _( "Background" ), LAYER_PCB_BACKGROUND, BLACK, _( "PCB Background" ), true, false )
84 };
85 
86 static int s_allowed_in_FpEditor[] =
87 {
97  LAYER_GRID,
99 };
100 
101 
102 PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner,
103  bool aFpEditorMode ) :
104  LAYER_WIDGET( aParent, aFocusOwner ),
105  myframe( aParent )
106 {
108  m_fp_editor_mode = aFpEditorMode;
109 
110  // Update default tabs labels
112 
113  //-----<Popup menu>-------------------------------------------------
114  // handle the popup menu over the layer window.
115  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
116  wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
117 
118  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
119  // and not m_LayerScrolledWindow->Connect()
120 
122  wxEVT_COMMAND_MENU_SELECTED,
123  wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
124 }
125 
126 
128 {
130 }
131 
132 
134 {
135  for( unsigned ii = 0; ii < arrayDim( s_allowed_in_FpEditor ); ii++ )
136  if( s_allowed_in_FpEditor[ii] == aId )
137  return true;
138 
139  return false;
140 }
141 
142 
144 {
145  static LSET allowed = LSET::AllTechMask();
146  allowed.set( F_Cu ).set( B_Cu );
147  return allowed.test( aLayer );
148 }
149 
150 
152 {
153  // menu text is capitalized:
154  // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
156  _( "Show All Copper Layers" ),
159  _( "Hide All Copper Layers But Active" ),
162  _( "Always Hide All Copper Layers But Active" ),
165  _( "Hide All Copper Layers" ),
167 
168  menu.AppendSeparator();
169 
171  _( "Show All Non Copper Layers" ),
174  _( "Hide All Non Copper Layers" ),
176 
177  menu.AppendSeparator();
178 
179  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
181  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
183 
184  menu.AppendSeparator();
185 
186  AddMenuItem( &menu, ID_SHOW_ALL_FRONT, _( "Show All Front Layers" ),
188 
189  AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
191 }
192 
193 
194 void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
195 {
196  wxMenu menu;
197 
198  AddRightClickMenuItems( menu );
199  PopupMenu( &menu );
200 
201  passOnFocus();
202 }
203 
204 
205 void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
206 {
207  int rowCount;
208  int menuId = event.GetId();
209  bool visible;
210  bool force_active_layer_visible;
211 
213  force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ||
215 
216  switch( menuId )
217  {
218  case ID_SHOW_NO_LAYERS:
219  case ID_SHOW_ALL_LAYERS:
220  {
221  visible = ( menuId == ID_SHOW_ALL_LAYERS );
222  rowCount = GetLayerRowCount();
223 
224  for( int row=0; row<rowCount; ++row )
225  {
226  bool isLast;
227  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
228  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
229  cb->SetValue( visible );
230 
231  isLast = row == rowCount-1;
232 
233  OnLayerVisible( layer, visible, isLast );
234 
235  if( isLast )
236  break;
237  }
238  break;
239  }
240 
247  {
248 
249  // Search the last copper layer row index:
250  int lastCu = -1;
251  rowCount = GetLayerRowCount();
252  for( int row = rowCount-1; row>=0; --row )
253  {
254  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
255  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
256 
257  if( IsCopperLayer( layer ) )
258  {
259  lastCu = row;
260  break;
261  }
262  }
263 
264  // Enable/disable the copper layers visibility:
265  int startrow = 0;
266 
267  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
268  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
269  {
270  startrow = lastCu + 1;
271  }
272 
273  for( int row = startrow; row<rowCount; ++row )
274  {
275  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
276  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
277 
278  visible = ( ( menuId == ID_SHOW_ALL_COPPER_LAYERS ) || ( menuId == ID_SHOW_ALL_NON_COPPER ) );
279 
280  if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
281  visible = true;
282 
283  cb->SetValue( visible );
284 
285  bool isLastLayer = (row == lastCu);
286 
287  if( ( menuId == ID_SHOW_ALL_NON_COPPER ) ||
288  ( menuId == ID_HIDE_ALL_NON_COPPER ) )
289  {
290  isLastLayer = false;
291  }
292  OnLayerVisible( layer, visible, isLastLayer );
293 
294  if( isLastLayer )
295  break;
296  }
297  break;
298  }
299 
300  case ID_SHOW_ALL_FRONT:
301  {
302  visible = false;
303  rowCount = GetLayerRowCount();
304 
305  for( int row=0; row<rowCount; ++row )
306  {
307  bool isLast;
308  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
309  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
310  isLast = ( row == rowCount-1 );
311 
312  if( layer == F_Paste || layer == F_SilkS ||
313  layer == F_Mask || layer == F_Cu ||
314  layer == F_Fab || layer == F_CrtYd || layer == Edge_Cuts )
315  {
316  visible = true;
317  }
318  else
319  {
320  visible = false;
321  }
322 
323  cb->SetValue( visible );
324  OnLayerVisible( layer, visible, isLast );
325 
326  if( isLast )
327  break;
328  }
329  break;
330  }
331  case ID_SHOW_ALL_BACK:
332  {
333  visible = false;
334  rowCount = GetLayerRowCount();
335 
336  for( int row=0; row<rowCount; ++row )
337  {
338  bool isLast;
339  wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
340  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
341  isLast = ( row == rowCount-1 );
342 
343  if( layer == B_Paste || layer == B_SilkS ||
344  layer == B_Mask || layer == B_Cu ||
345  layer == B_Fab || layer == B_CrtYd || layer == Edge_Cuts )
346  {
347  visible = true;
348  }
349  else
350  {
351  visible = false;
352  }
353 
354  cb->SetValue( visible );
355  OnLayerVisible( layer, visible, isLast );
356 
357  if( isLast )
358  break;
359  }
360  break;
361  }
362  }
363 }
364 
365 
367 {
368  m_notebook->SetPageText( 0, _( "Layers" ) );
369  m_notebook->SetPageText( 1, _( "Items" ) );
370 }
371 
372 
374 {
375  BOARD* board = myframe->GetBoard();
376  auto settings = board->GetDesignSettings();
377 
378  ClearRenderRows();
379 
380  // Add "Items" tab rows to LAYER_WIDGET, after setting color and checkbox state.
381  // Because s_render_rows is created static, we must explicitly call
382  // wxGetTranslation for texts which are internationalized (tool tips
383  // and item names)
384  for( unsigned row=0; row<arrayDim(s_render_rows); ++row )
385  {
386  LAYER_WIDGET::ROW renderRow = s_render_rows[row];
387 
388  if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
389  continue;
390 
391  if( renderRow.id == LAYER_VIA_MICROVIA && !settings.m_MicroViasAllowed )
392  continue;
393 
394  if( renderRow.id == LAYER_VIA_BBLIND && !settings.m_BlindBuriedViaAllowed )
395  continue;
396 
397  if( !renderRow.spacer )
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(
406  static_cast<GAL_LAYER_ID>( renderRow.id ) );
408  static_cast<GAL_LAYER_ID>( renderRow.id ) );
409  }
410 
411  if( renderRow.id == LAYER_RATSNEST )
413  else if( renderRow.id == LAYER_GRID )
414  renderRow.state = myframe->IsGridVisible();
415  else
416  renderRow.state = board->IsElementVisible(
417  static_cast<GAL_LAYER_ID>( renderRow.id ) );
418  }
419 
420  AppendRenderRow( renderRow );
421  }
422 
423  UpdateLayouts();
424 }
425 
426 
428 {
429  BOARD* board = myframe->GetBoard();
430  int count = GetLayerRowCount();
431 
432  for( int row=0; row<count; ++row )
433  {
434  // this utilizes more implementation knowledge than ideal, eventually
435  // add member ROW getRow() or similar to base LAYER_WIDGET.
436 
437  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
438 
439  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
440 
441  // this does not fire a UI event
442  setLayerCheckbox( layerId, board->IsLayerVisible( layerId ) );
443  }
444 }
445 
446 
447 #define ALPHA_EPSILON 0.04
448 
450 {
451  int count = GetLayerRowCount();
453  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() );
454  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
455 
456  for( int row = 0; row < count; ++row )
457  {
458  // this utilizes more implementation knowledge than ideal, eventually
459  // add member ROW getRow() or similar to base LAYER_WIDGET.
460 
461  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
462  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
463  KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId );
464 
465  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) );
466  KIGFX::COLOR4D layerColor = swatch->GetSwatchColor();
467 
468  INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) );
469 
470  if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON )
471  {
472  if( screenColor.a < layerColor.a )
473  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
474  else
475  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
476  }
477  else
479  }
480 }
481 
482 
484 {
485  BOARD* brd = myframe->GetBoard();
486  LSET enabled = brd->GetEnabledLayers();
487 
488  ClearLayerRows();
489 
490  wxString dsc;
491 
492  // show all coppers first, with front on top, back on bottom, then technical layers
493  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
494  {
495  PCB_LAYER_ID layer = *cu_stack;
496 
497  switch( layer )
498  {
499  case F_Cu:
500  dsc = _( "Front copper layer" );
501  break;
502 
503  case B_Cu:
504  dsc = _( "Back copper layer" );
505  break;
506 
507  default:
508  dsc = _( "Inner copper layer" );
509  break;
510  }
511 
512  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
513  myframe->Settings().Colors().GetLayerColor( layer ), dsc, true, true,
514  myframe->Settings().Colors().GetDefaultLayerColor( layer ) ) );
515 
516  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
517  {
518  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
519  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
520  }
521  }
522 
523  UpdateLayouts();
524 
525 
526  // technical layers are shown in this order:
527  // Because they are static, wxGetTranslation must be explicitly
528  // called for tooltips.
529  static const struct {
530  PCB_LAYER_ID layerId;
531  wxString tooltip;
532  } non_cu_seq[] = {
533  { F_Adhes, _( "Adhesive on board's front" ) },
534  { B_Adhes, _( "Adhesive on board's back" ) },
535  { F_Paste, _( "Solder paste on board's front" ) },
536  { B_Paste, _( "Solder paste on board's back" ) },
537  { F_SilkS, _( "Silkscreen on board's front" ) },
538  { B_SilkS, _( "Silkscreen on board's back" ) },
539  { F_Mask, _( "Solder mask on board's front" ) },
540  { B_Mask, _( "Solder mask on board's back" ) },
541  { Dwgs_User, _( "Explanatory drawings" ) },
542  { Cmts_User, _( "Explanatory comments" ) },
543  { Eco1_User, _( "User defined meaning" ) },
544  { Eco2_User, _( "User defined meaning" ) },
545  { Edge_Cuts, _( "Board's perimeter definition" ) },
546  { Margin, _( "Board's edge setback outline" ) },
547  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
548  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
549  { F_Fab, _( "Footprint assembly on board's front" ) },
550  { B_Fab, _( "Footprint assembly on board's back" ) }
551  };
552 
553  for( unsigned i=0; i<arrayDim( non_cu_seq ); ++i )
554  {
555  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
556 
557  if( !enabled[layer] )
558  continue;
559 
560  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
561  myframe->Settings().Colors().GetLayerColor( layer ),
562  wxGetTranslation( non_cu_seq[i].tooltip ), true, true,
563  myframe->Settings().Colors().GetDefaultLayerColor( layer ) ) );
564 
565  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
566  {
567  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
568  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
569  }
570  }
571 }
572 
573 
574 //-----<LAYER_WIDGET callbacks>-------------------------------------------
575 
577 {
578  myframe->Settings().Colors().SetLayerColor( aLayer, aColor );
579 
580  KIGFX::VIEW* view = myframe->GetCanvas()->GetView();
582  view->UpdateLayerColor( aLayer );
583  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
584 
586 
587  myframe->GetCanvas()->Refresh();
588 
589  if( aLayer == LAYER_PCB_BACKGROUND )
590  myframe->SetDrawBgColor( aColor );
591 }
592 
593 
595 {
596  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
597  // false from this function.
598  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
599 
600  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
601  return false;
602 
603  myframe->SetActiveLayer( layer );
604 
606  OnLayerSelected();
608  myframe->GetCanvas()->Refresh();
609 
610  return true;
611 }
612 
613 
615 {
617  return false;
618 
619  // postprocess after an active layer selection
620  // ensure active layer visible
621  wxCommandEvent event;
623  onPopupSelection( event );
624 
625  return true;
626 }
627 
628 
629 void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
630 {
631  BOARD* brd = myframe->GetBoard();
632 
633  LSET visibleLayers = brd->GetVisibleLayers();
634 
635  if( visibleLayers.test( aLayer ) != isVisible )
636  {
637  visibleLayers.set( aLayer, isVisible );
638 
639  brd->SetVisibleLayers( visibleLayers );
640 
641  // Layer visibility is not stored in .kicad_mod files
642  if( !m_fp_editor_mode )
643  myframe->OnModify();
644 
645  if( myframe->GetCanvas() )
646  myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
647  }
648 
649  if( isFinal )
650  myframe->GetCanvas()->Refresh();
651 }
652 
653 
655 {
656  AddRightClickMenuItems( aMenu );
657 }
658 
659 
661 {
662  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
663 
664  myframe->Settings().Colors().SetItemColor( static_cast<GAL_LAYER_ID>( aId ), aColor );
665 
666  if( aId == LAYER_GRID )
667  myframe->GetCanvas()->GetGAL()->SetGridColor( aColor );
668 
669  KIGFX::VIEW* view = myframe->GetCanvas()->GetView();
671  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
672  view->UpdateLayerColor( aId );
673 
674  // plated-through-holes don't have their own color; they use the background color
675  if( aId == LAYER_PCB_BACKGROUND )
677 
680  myframe->GetCanvas()->Refresh();
681 }
682 
683 
684 void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
685 {
686  BOARD* brd = myframe->GetBoard();
687  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
688 
690  {
691  // The layer visibility status is saved in the board file so set the board
692  // modified state so the user has the option to save the changes.
693  if( brd->IsElementVisible( static_cast<GAL_LAYER_ID>( aId ) ) != isEnabled )
694  myframe->OnModify();
695  }
696 
697  // Grid is not set through the board visibility
698  if( aId == LAYER_GRID )
699  myframe->SetGridVisibility( isEnabled );
700  else
701  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
702 
703  if( aId == LAYER_RATSNEST )
704  {
705  // don't touch the layers. ratsnest is enabled on per-item basis.
707  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, true );
708 
710  {
712  opt.m_ShowGlobalRatsnest = isEnabled;
714  }
715  }
716  else if( aId != LAYER_GRID )
717  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, isEnabled );
718 
719  myframe->GetCanvas()->Refresh();
720  myframe->GetCanvas()->Refresh();
721 }
722 
723 //-----</LAYER_WIDGET callbacks>------------------------------------------
Definition: colors.h:57
COLOR4D defaultColor
The default color for the row.
Definition: layer_widget.h:96
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:55
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.
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:250
wxAuiNotebook * m_notebook
Definition: layer_widget.h:127
to draw blind/buried vias
#define ALPHA_EPSILON
LSEQ CuStack() const
Function CuStack returns a sequence of copper layers in starting from the front/top and extending to ...
Definition: lset.cpp:155
show a marker on pads with no nets
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
KIGFX::COLOR4D GetSwatchColor() const
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 GAL_L...
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
Struct ROW provides all the data needed to add a row to a LAYER_WIDGET.
Definition: layer_widget.h:87
virtual bool IsGridVisible() const override
Function IsGridVisible()
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:799
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:251
handle color for not plated holes (holes, not pads)
anchor of items having an anchor point (texts, footprints)
void UpdateLayouts()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool isLayerAllowedInFpMode(PCB_LAYER_ID aLayer)
Function isLayerAllowedInFpMode.
bool isLast(CPTREE &aTree, CITER it)
Definition: ptree.cpp:122
const BITMAP_OPAQUE show_no_copper_layers_xpm[1]
const BITMAP_OPAQUE select_layer_pair_xpm[1]
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
PCB_BASE_FRAME * myframe
show modules values (when texts are visibles)
virtual COLOR4D getBackgroundLayerColor() override
Subclasses can override this to provide accurate representation of transparent colour swatches.
#define OFF
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
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 item indices given in enum PCB_L...
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
void SetDrawBgColor(COLOR4D aColor) override
static COLOR4D GetDefaultLayerColor(LAYER_NUM aLayer)
Function GetDefaultLayerColor.
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:756
PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:226
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions returns the display options current in use Display options are relative to...
void ClearRenderRows()
Function ClearRenderRows empties out the render rows.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
Definition: colors.h:54
bool state
initial wxCheckBox state
Definition: layer_widget.h:92
void SetLayersManagerTabsText()
Function SetLayersManagerTabsText Update the layer manager tabs labels Useful when changing Language ...
void ClearLayerRows()
Function ClearLayerRows empties out the layer rows.
wxString tooltip
if not empty, use this tooltip on row
Definition: layer_widget.h:93
Auxiliary rendering target (noncached)
Definition: definitions.h:49
This file contains miscellaneous commonly used macros and functions.
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
show modules on front
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:61
TOOL_MANAGER.
Definition: tool_manager.h:50
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 GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
COLOR4D color
COLOR4D::UNSPECIFIED if none.
Definition: layer_widget.h:91
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
representing a row indicator icon for use in places like the layer widget
double a
Alpha component.
Definition: color4d.h:304
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
LSET is a set of PCB_LAYER_IDs.
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:113
Footprint text class description.
Auxiliary items (guides, rule, etc)
void setLayerCheckbox(LAYER_NUM aLayer, bool isVisible)
#define NULL
#define COLUMN_COLORBM
Definition: layer_widget.h:53
const BITMAP_OPAQUE select_w_layer_xpm[1]
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:238
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
virtual void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings)
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: painter.h:67
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
#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.
const BITMAP_OPAQUE show_all_layers_xpm[1]
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:129
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
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:399
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
static LAYER_NUM getDecodedId(int aControlId)
Function getDecodedId decodes aControlId to original un-encoded value.
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
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
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
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:777
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...
LAYER_WIDGET is abstract and is used to manage a list of layers, with the notion of a "current" layer...
Definition: layer_widget.h:79
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:449
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
bool IsType(FRAME_T aType) const
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:54
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
wxString rowName
the prompt or layername
Definition: layer_widget.h:89
#define _(s)
Definition: 3d_actions.cpp:31
virtual void SetGridVisibility(bool aVisible) override
Function SetGridVisibility() Turn the display of the canvas grid on/off.
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
Definition: colors.h:49
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
static COLOR4D GetDefaultItemColor(int aItemIdx)
Function GetDefaultItemColor.
Definition: colors.h:45
BOARD * GetBoard() const
VIEW.
Definition: view.h:61
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
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
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)
const BITMAP_OPAQUE show_no_layers_xpm[1]
#define RR
PCB_LAYER_WIDGET(PCB_BASE_FRAME *aParent, wxWindow *aFocusOwner, bool aFpEditorMode=false)
Constructor.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39