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-2020 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 <class_board.h>
28 #include <fctsys.h>
30 #include <layer_widget.h>
31 #include <macros.h>
32 #include <menus_helpers.h>
33 #include <pcb_display_options.h>
34 #include <pcb_edit_frame.h>
35 #include <pcb_layer_widget.h>
36 #include <pcb_painter.h>
37 #include <pcbnew_id.h>
38 #include <pcbnew_settings.h>
39 #include <pgm_base.h>
41 #include <tool/tool_manager.h>
42 #include <view/view.h>
43 #include <widgets/indicator_icon.h>
44 
45 
48 
49 #define RR LAYER_WIDGET::ROW // Render Row abbreviation to reduce source width
50 #define NOCOLOR COLOR4D::UNSPECIFIED // specify rows that do not have a color selector icon
51 
52  // text id color tooltip
53  RR( _( "Footprints Front" ), LAYER_MOD_FR, NOCOLOR, _( "Show footprints that are on board's front") ),
54  RR( _( "Footprints Back" ), LAYER_MOD_BK, NOCOLOR, _( "Show footprints that are on board's back") ),
55  RR( _( "Values" ), LAYER_MOD_VALUES, NOCOLOR, _( "Show footprint values") ),
56  RR( _( "Reference Designators" ),LAYER_MOD_REFERENCES, NOCOLOR, _( "Show footprint reference designators") ),
57  RR( _( "Footprint Text Front" ), LAYER_MOD_TEXT_FR, NOCOLOR, _( "Show footprint text on board's front" ) ),
58  RR( _( "Footprint Text Back" ), LAYER_MOD_TEXT_BK, NOCOLOR, _( "Show footprint text on board's back" ) ),
59  RR( _( "Hidden Text" ), LAYER_MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
60  RR( _( "Pads Front" ), LAYER_PAD_FR, WHITE, _( "Show footprint pads on board's front" ) ),
61  RR( _( "Pads Back" ), LAYER_PAD_BK, WHITE, _( "Show footprint pads on board's back" ) ),
62  RR( _( "Through Hole Pads" ), LAYER_PADS_TH, YELLOW, _( "Show through hole pads in specific color") ),
63  RR(),
64  RR( _( "Tracks" ), LAYER_TRACKS, NOCOLOR, _( "Show tracks" ) ),
65  RR( _( "Through Via" ), LAYER_VIA_THROUGH, WHITE, _( "Show through vias" ) ),
66  RR( _( "Bl/Buried Via" ), LAYER_VIA_BBLIND, WHITE, _( "Show blind or buried vias" ) ),
67  RR( _( "Micro Via" ), LAYER_VIA_MICROVIA, WHITE, _( "Show micro vias") ),
68  RR( _( "Non Plated Holes" ), LAYER_NON_PLATEDHOLES, WHITE, _( "Show non plated holes in specific color") ),
69  RR(),
70  RR( _( "Ratsnest" ), LAYER_RATSNEST, WHITE, _( "Show unconnected nets as a ratsnest") ),
71  RR( _( "No-Connects" ), LAYER_NO_CONNECTS, BLUE, _( "Show a marker on pads which have no net connected" ) ),
72  RR( _( "DRC Warnings" ), LAYER_DRC_WARNING, YELLOW, _( "DRC violations with a Warning severity" ) ),
73  RR( _( "DRC Errors" ), LAYER_DRC_ERROR, PURERED, _( "DRC violations with an Error severity" ) ),
74  RR( _( "DRC Exclusions" ), LAYER_DRC_EXCLUSION, WHITE, _( "DRC violations which have been individually excluded" ) ),
75  RR( _( "Anchors" ), LAYER_ANCHOR, WHITE, _( "Show footprint and text origins as a cross" ) ),
76  RR( _( "Worksheet" ), LAYER_WORKSHEET, DARKRED, _( "Show worksheet") ),
77  RR( _( "Cursor" ), LAYER_CURSOR, WHITE, _( "PCB Cursor" ), true, false ),
78  RR( _( "Aux Items" ), LAYER_AUX_ITEMS, WHITE, _( "Auxiliary items (rulers, assistants, axes, etc.)" ), true, false ),
79  RR( _( "Grid" ), LAYER_GRID, WHITE, _( "Show the (x,y) grid dots" ) ),
80  RR( _( "Background" ), LAYER_PCB_BACKGROUND, BLACK, _( "PCB Background" ), true, false )
81 };
82 
83 static int s_allowed_in_FpEditor[] =
84 {
94  LAYER_GRID,
96 };
97 
98 
99 PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner,
100  bool aFpEditorMode ) :
101  LAYER_WIDGET( aParent, aFocusOwner ),
102  myframe( aParent )
103 {
105  m_fp_editor_mode = aFpEditorMode;
106 
107  // Update default tabs labels
109 
110  //-----<Popup menu>-------------------------------------------------
111  // handle the popup menu over the layer window.
112  m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
113  wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
114 
115  // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
116  // and not m_LayerScrolledWindow->Connect()
117 
119  wxEVT_COMMAND_MENU_SELECTED,
120  wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
121 }
122 
123 
125 {
127 }
128 
129 
131 {
132  for( unsigned ii = 0; ii < arrayDim( s_allowed_in_FpEditor ); ii++ )
133  if( s_allowed_in_FpEditor[ii] == aId )
134  return true;
135 
136  return false;
137 }
138 
139 
141 {
142  static LSET allowed = LSET::AllTechMask();
143  allowed.set( F_Cu ).set( B_Cu );
144  return allowed.test( aLayer );
145 }
146 
147 
149 {
151  _( "Show All Copper Layers" ),
154  _( "Hide All Copper Layers" ),
156 
157  menu.AppendSeparator();
158 
160  _( "Hide All Copper Layers But Active" ),
163  _( "Always Hide All Copper Layers But Active" ),
165 
166  menu.AppendSeparator();
167 
169  _( "Show All Non Copper Layers" ),
172  _( "Hide All Non Copper Layers" ),
174 
175  menu.AppendSeparator();
176 
177  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
179  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
181 
182  menu.AppendSeparator();
183 
184  AddMenuItem( &menu, ID_SHOW_ONLY_FRONT_ASSEMBLY, _( "Show Only Front Assembly Layers" ),
185  KiBitmap( shape_3d_xpm ) );
186 
187  AddMenuItem( &menu, ID_SHOW_ONLY_FRONT, _( "Show Only Front Layers" ),
189 
190  // Only show the internal layer option if internal layers are enabled
191  if( myframe->GetBoard()->GetCopperLayerCount() > 2 )
192  {
193  AddMenuItem( &menu, ID_SHOW_ONLY_INNER, _( "Show Only Inner Layers" ),
195  }
196 
197  AddMenuItem( &menu, ID_SHOW_ONLY_BACK, _( "Show Only Back Layers" ),
199 
200  AddMenuItem( &menu, ID_SHOW_ONLY_BACK_ASSEMBLY, _( "Show Only Back Assembly Layers" ),
202 }
203 
204 
205 void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
206 {
207  wxMenu menu;
208 
209  AddRightClickMenuItems( menu );
210  PopupMenu( &menu );
211 
212  passOnFocus();
213 }
214 
215 
216 void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
217 {
218  // Force the active layer to be visible
219  bool forceActiveLayer = false;
220 
221  // Reset the always show property
223 
224  // Make a distinction between the layers we want to enable and those we
225  // want to disable explictly. That way we can either or the current layerset
226  // or operate on all layers.
227  LSET layersToShow;
228  LSET layersToHide;
229 
230  switch( event.GetId() )
231  {
232  case ID_SHOW_NO_LAYERS:
233  layersToHide = LSET::AllLayersMask();
234  break;
235 
236  case ID_SHOW_ALL_LAYERS:
237  layersToShow = LSET::AllLayersMask();
238  break;
239 
241  layersToShow = LSET::AllCuMask();
242  break;
243 
247 
249  forceActiveLayer = true;
251 
253  layersToHide = LSET::AllCuMask();
254  break;
255 
257  layersToHide = LSET::AllNonCuMask();
258  break;
259 
261  layersToShow = LSET::AllNonCuMask();
262  break;
263 
265  // Include the edgecuts layer as well as the front assembly layers and hide the other layers
266  layersToShow = LSET::FrontAssembly().set( Edge_Cuts );
267  layersToHide = ~layersToShow;
269  break;
270 
271  case ID_SHOW_ONLY_FRONT:
272  // Include the edgecuts layer as well as the front layers and hide the other layers
273  layersToShow = LSET::FrontMask().set( Edge_Cuts );
274  layersToHide = ~layersToShow;
275  break;
276 
277  case ID_SHOW_ONLY_INNER:
278  // Include the edgecuts layer as well as the internal layers and hide the other layers
279  layersToShow = LSET::InternalCuMask().set( Edge_Cuts );
280  layersToHide = ~layersToShow;
281  break;
282 
283  case ID_SHOW_ONLY_BACK:
284  // Include the edgecuts layer as well as the back layers and hide the other layers
285  layersToShow = LSET::BackMask().set( Edge_Cuts );
286  layersToHide = ~layersToShow;
287  break;
288 
290  // Include the edgecuts layer as well as the back assembly layers and hide the other layers
291  layersToShow = LSET::BackAssembly().set( Edge_Cuts );
292  layersToHide = ~layersToShow;
294  break;
295  }
296 
297  int rowCount = GetLayerRowCount();
298 
299  for( int row = 0; row < rowCount; ++row )
300  {
301  wxCheckBox* cb = static_cast<wxCheckBox*>( getLayerComp( row, COLUMN_COLOR_LYR_CB ) );
302  PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
303 
304  bool visible = cb->GetValue();
305 
306  if( layersToShow.Contains( layer ) )
307  visible = true;
308 
309  if( layersToHide.Contains( layer ) )
310  visible = false;
311 
312  // Force the active layer in the editor to be visible
313  if( forceActiveLayer && ( layer == myframe->GetActiveLayer() ) )
314  visible = true;
315 
316  cb->SetValue( visible );
317  OnLayerVisible( layer, visible, false );
318  }
319 
320  // Refresh the drawing canvas
321  myframe->GetCanvas()->Refresh();
322 }
323 
324 
326 {
327  m_notebook->SetPageText( 0, _( "Layers" ) );
328  m_notebook->SetPageText( 1, _( "Items" ) );
329 }
330 
331 
333 {
334  BOARD* board = myframe->GetBoard();
335 
336  ClearRenderRows();
337 
338  // Add "Items" tab rows to LAYER_WIDGET, after setting color and checkbox state.
339  // Because s_render_rows is created static, we must explicitly call
340  // wxGetTranslation for texts which are internationalized (tool tips
341  // and item names)
342  for( unsigned row=0; row<arrayDim(s_render_rows); ++row )
343  {
344  LAYER_WIDGET::ROW renderRow = s_render_rows[row];
345 
346  if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
347  continue;
348 
349  if( !renderRow.spacer )
350  {
351  renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
352  renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
353 
354  if( renderRow.color != COLOR4D::UNSPECIFIED ) // does this row show a color?
355  {
356  // this window frame must have an established BOARD, i.e. after SetBoard()
357  renderRow.color = myframe->GetColorSettings()->GetColor(
358  static_cast<GAL_LAYER_ID>( renderRow.id ) );
360  static_cast<GAL_LAYER_ID>( renderRow.id ) );
361  }
362 
363  if( renderRow.id == LAYER_RATSNEST )
365  else if( renderRow.id == LAYER_GRID )
366  renderRow.state = myframe->IsGridVisible();
367  else
368  renderRow.state = board->IsElementVisible(
369  static_cast<GAL_LAYER_ID>( renderRow.id ) );
370  }
371 
372  AppendRenderRow( renderRow );
373  }
374 
375  UpdateLayouts();
376 }
377 
378 
380 {
381  BOARD* board = myframe->GetBoard();
382  int count = GetLayerRowCount();
383 
384  for( int row=0; row<count; ++row )
385  {
386  // this utilizes more implementation knowledge than ideal, eventually
387  // add member ROW getRow() or similar to base LAYER_WIDGET.
388 
389  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
390 
391  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
392 
393  // this does not fire a UI event
394  setLayerCheckbox( layerId, board->IsLayerVisible( layerId ) );
395  }
396 }
397 
398 
399 #define ALPHA_EPSILON 0.04
400 
402 {
403  int count = GetLayerRowCount();
405  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() );
406  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
407 
408  for( int row = 0; row < count; ++row )
409  {
410  // this utilizes more implementation knowledge than ideal, eventually
411  // add member ROW getRow() or similar to base LAYER_WIDGET.
412 
413  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
414  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
415  KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId );
416 
417  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) );
418  KIGFX::COLOR4D layerColor = swatch->GetSwatchColor();
419 
420  INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) );
421 
422  if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON )
423  {
424  if( screenColor.a < layerColor.a )
425  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
426  else
427  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
428  }
429  else
430  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );
431  }
432 }
433 
434 
436 {
438 
440 
441  int count = GetLayerRowCount();
442  int row;
443  int col = 1; // bitmap button is column 1 in layers tab
444 
445  for( row = 0; row < count; ++row )
446  {
447  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
448 
449  if( swatch )
450  {
451  swatch->SetSwatchBackground( bg );
452  swatch->SetSwatchColor( cs->GetColor( getDecodedId( swatch->GetId() ) ), false );
453  }
454  }
455 
456  count = GetRenderRowCount();
457  col = 0; // bitmap button is column 0 in render tab
458 
459  for( row = 0; row < count; ++row )
460  {
461  COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getRenderComp( row, col ) );
462 
463  if( swatch )
464  {
465  swatch->SetSwatchBackground( bg );
466  swatch->SetSwatchColor( cs->GetColor( getDecodedId( swatch->GetId() ) ), false );
467  }
468  }
469 }
470 
471 
473 {
474  BOARD* brd = myframe->GetBoard();
475  LSET enabled = brd->GetEnabledLayers();
476 
477  ClearLayerRows();
478 
479  wxString dsc;
480 
481  // show all coppers first, with front on top, back on bottom, then technical layers
482  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
483  {
484  PCB_LAYER_ID layer = *cu_stack;
485 
486  switch( layer )
487  {
488  case F_Cu:
489  dsc = _( "Front copper layer" );
490  break;
491 
492  case B_Cu:
493  dsc = _( "Back copper layer" );
494  break;
495 
496  default:
497  dsc = _( "Inner copper layer" );
498  break;
499  }
500 
501  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
502  myframe->GetColorSettings()->GetColor( layer ), dsc, true, true,
503  myframe->GetColorSettings()->GetDefaultColor( layer ) ) );
504 
506  {
507  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
508  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
509  }
510  }
511 
512  // technical layers are shown in this order:
513  // Because they are static, wxGetTranslation must be explicitly
514  // called for tooltips.
515  static const struct {
516  PCB_LAYER_ID layerId;
517  wxString tooltip;
518  } non_cu_seq[] = {
519  { F_Adhes, _( "Adhesive on board's front" ) },
520  { B_Adhes, _( "Adhesive on board's back" ) },
521  { F_Paste, _( "Solder paste on board's front" ) },
522  { B_Paste, _( "Solder paste on board's back" ) },
523  { F_SilkS, _( "Silkscreen on board's front" ) },
524  { B_SilkS, _( "Silkscreen on board's back" ) },
525  { F_Mask, _( "Solder mask on board's front" ) },
526  { B_Mask, _( "Solder mask on board's back" ) },
527  { Dwgs_User, _( "Explanatory drawings" ) },
528  { Cmts_User, _( "Explanatory comments" ) },
529  { Eco1_User, _( "User defined meaning" ) },
530  { Eco2_User, _( "User defined meaning" ) },
531  { Edge_Cuts, _( "Board's perimeter definition" ) },
532  { Margin, _( "Board's edge setback outline" ) },
533  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
534  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
535  { F_Fab, _( "Footprint assembly on board's front" ) },
536  { B_Fab, _( "Footprint assembly on board's back" ) },
537  };
538 
539  for( unsigned i=0; i<arrayDim( non_cu_seq ); ++i )
540  {
541  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
542 
543  if( !enabled[layer] )
544  {
545  wxLogDebug( "Layer widget: layer %s not enabled.", LSET::Name( layer ) );
546  continue;
547  }
548 
549  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
550  myframe->GetColorSettings()->GetColor( layer ),
551  wxGetTranslation( non_cu_seq[i].tooltip ), true, true,
552  myframe->GetColorSettings()->GetDefaultColor( layer ) ) );
553 
555  {
556  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
557  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
558  }
559  }
560 
561  UpdateLayouts();
562 }
563 
564 
565 //-----<LAYER_WIDGET callbacks>-------------------------------------------
566 
568 {
570  cs->SetColor( aLayer, aColor );
571 
573 
574  KIGFX::VIEW* view = myframe->GetCanvas()->GetView();
575  view->UpdateLayerColor( aLayer );
576  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
577 
579 
580  myframe->GetCanvas()->Refresh();
581 
582  if( aLayer == LAYER_PCB_BACKGROUND )
583  myframe->SetDrawBgColor( aColor );
584 }
585 
586 
588 {
589  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
590  // false from this function.
591  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
592 
594  return false;
595 
596  myframe->SetActiveLayer( layer );
597 
600 
602  OnLayerSelected();
603  else if( hcm )
604  myframe->GetCanvas()->Refresh();
605 
606  return true;
607 }
608 
609 
611 {
613  return false;
614 
615  // postprocess after an active layer selection
616  // ensure active layer visible
617  wxCommandEvent event;
619  onPopupSelection( event );
620 
621  return true;
622 }
623 
624 
625 void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
626 {
627  // In other frames than board editor, the board is a dummy board.
628  // so changing board settings makes sense (and works) only for the board editor frame
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  brd->SetVisibleLayers( visibleLayers );
639 
640  if( myframe->GetCanvas() )
641  myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
642  }
643  }
644  else
645  {
646  if( myframe->GetCanvas() )
647  myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
648  }
649 
650  if( isFinal )
651  myframe->GetCanvas()->Refresh();
652 }
653 
654 
656 {
657  AddRightClickMenuItems( aMenu );
658 }
659 
660 
662 {
663  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
664 
665  myframe->GetColorSettings()->SetColor( aId, aColor );
667 
668  KIGFX::VIEW* view = myframe->GetCanvas()->GetView();
669  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
670  view->UpdateLayerColor( aId );
671 
672  // plated-through-holes don't have their own color; they use the background color
673  if( aId == LAYER_PCB_BACKGROUND )
675 
678 }
679 
680 
681 void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
682 {
683  BOARD* brd = myframe->GetBoard();
684  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
685 
686  // Grid is not set through the board visibility
687  if( aId == LAYER_GRID )
688  myframe->SetGridVisibility( isEnabled );
689  else
690  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
691 
692  if( aId == LAYER_RATSNEST )
693  {
694  // don't touch the layers. ratsnest is enabled on per-item basis.
696  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, true );
697 
699  {
701  opt.m_ShowGlobalRatsnest = isEnabled;
702  myframe->SetDisplayOptions( opt );
703  }
704  }
705  else if( aId != LAYER_GRID )
706  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, isEnabled );
707 
708  myframe->GetCanvas()->Refresh();
709 }
710 
711 //-----</LAYER_WIDGET callbacks>------------------------------------------
COLOR4D defaultColor
The default color for the row.
Definition: layer_widget.h:96
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:749
#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:289
wxAuiNotebook * m_notebook
Definition: layer_widget.h:127
to draw blind/buried vias
#define ALPHA_EPSILON
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:169
show a marker on pads with no nets
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)
Change the visibility of an element category.
void SetSwatchColor(KIGFX::COLOR4D aColor, bool sendEvent)
Set the current swatch color directly.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
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
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
Definition: lset.cpp:880
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:232
handle color for not plated holes (holes, not pads)
anchor of items having an anchor point (texts, footprints)
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
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 Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:772
const BITMAP_OPAQUE show_no_copper_layers_xpm[1]
const BITMAP_OPAQUE select_layer_pair_xpm[1]
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings Returns a bit-mask of all t...
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.
bool OnLayerSelected()
Function OnLayerSelected ensure the active layer is visible, and other layers not visible when m_alwa...
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:88
wxWindow * getLayerComp(int aRow, int aColumn) const
Function getLayerComp returns the component within the m_LayersFlexGridSizer at aRow and aCol or NULL...
void SetSwatchBackground(KIGFX::COLOR4D aBackground)
Set the swatch background color.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
void SetDrawBgColor(COLOR4D aColor) override
Definition: color4d.h:44
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()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:819
PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:260
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
void ClearRenderRows()
Function ClearRenderRows empties out the render rows.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:866
const BITMAP_OPAQUE show_all_copper_layers_xpm[1]
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
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.
show modules on front
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:64
Definition: color4d.h:67
TOOL_MANAGER.
Definition: tool_manager.h:51
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:80
COLOR4D color
COLOR4D::UNSPECIFIED if none.
Definition: layer_widget.h:91
static LSET BackAssembly()
Return a complete set of all bottom assembly layers which is all B_SilkS and B_Mask.
Definition: lset.cpp:695
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:369
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
LSET is a set of PCB_LAYER_IDs.
const BITMAP_OPAQUE show_all_back_layers_xpm[1]
Auxiliary items (guides, rule, etc)
void setLayerCheckbox(LAYER_NUM aLayer, bool isVisible)
#define NULL
#define COLUMN_COLORBM
Definition: layer_widget.h:53
wxWindow * getRenderComp(int aRow, int aColumn) const
const BITMAP_OPAQUE select_w_layer_xpm[1]
virtual PCB_RENDER_SETTINGS * GetSettings() override
Definition: pcb_painter.h:272
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:81
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:569
bool IsGridVisible() const
void OnLayerColorChange(int aLayer, COLOR4D aColor) override
Function OnLayerColorChange is called to notify client code about a layer color change.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
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 shape_3d_back_xpm[1]
COLOR4D GetDefaultColor(int aLayer)
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition: lset.cpp:709
const BITMAP_OPAQUE show_all_layers_xpm[1]
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:129
static LSET FrontAssembly()
Return a complete set of all top assembly layers which is all F_SilkS and F_Mask.
Definition: lset.cpp:681
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
void onRightDownLayers(wxMouseEvent &event)
Function OnRightDownLayers puts up a popup menu for the layer panel.
static LSET AllLayersMask()
Definition: lset.cpp:786
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:383
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void SyncLayerColors()
Updates the color for each layer and item from the active color theme.
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.
const BITMAP_OPAQUE shape_3d_xpm[1]
Definition: shape_3d.cpp:35
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...
void UpdateColors()
Updates the color settings in the painter and GAL.
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:160
layer for drc markers which have been individually excluded
int GetLayerRowCount() const
Function GetLayerRowCount returns the number of rows in the layer tab.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
void passOnFocus()
Function passOnFocus gives away the keyboard focus up to the main parent window.
Definition: color4d.h:48
layer for drc markers with SEVERITY_WARNING
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:773
void OnLayerVisible(int aLayer, bool isVisible, bool isFinal) override
Function OnLayerVisible is called to notify client code about a layer visibility change.
COLOR4D GetColor(int aLayer) const
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
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: color4d.h:56
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
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
wxString rowName
the prompt or layername
Definition: layer_widget.h:89
#define _(s)
Definition: 3d_actions.cpp:33
int GetCopperLayerCount() const
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:53
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:873
Color settings are a bit different than most of the settings objects in that there can be more than o...
int GetRenderRowCount() const
Function GetRenderRowCount returns the number of rows in the render tab.
const BITMAP_OPAQUE show_all_front_layers_xpm[1]
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:78
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 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:904
virtual void SetGridVisibility(bool aVisible)
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
show modules references (when texts are visibles)
layer for drc markers with SEVERITY_ERROR
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.
void SetColor(int aLayer, COLOR4D aColor)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99