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" ),
157  KiBitmap( select_layer_pair_xpm ) );
159  _( "Hide All Copper Layers But Active" ),
160  KiBitmap( select_w_layer_xpm ) );
162  _( "Always Hide All Copper Layers But Active" ),
163  KiBitmap( select_w_layer_xpm ) );
165  _( "Hide All Copper Layers" ),
166  KiBitmap( show_no_copper_layers_xpm ) );
167 
168  menu.AppendSeparator();
169 
171  _( "Show All Non Copper Layers" ),
172  KiBitmap( select_w_layer_xpm ) );
174  _( "Hide All Non Copper Layers" ),
175  KiBitmap( show_no_copper_layers_xpm ) );
176 
177  menu.AppendSeparator();
178 
179  AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
180  KiBitmap( show_no_layers_xpm ) );
181  AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
182  KiBitmap( show_all_layers_xpm ) );
183 
184  menu.AppendSeparator();
185 
186  AddMenuItem( &menu, ID_SHOW_ALL_FRONT, _( "Show All Front Layers" ),
187  KiBitmap( show_no_layers_xpm ) );
188 
189  AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ),
190  KiBitmap( show_all_layers_xpm ) );
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
414  renderRow.state = board->IsElementVisible(
415  static_cast<GAL_LAYER_ID>( renderRow.id ) );
416  }
417 
418  AppendRenderRow( renderRow );
419  }
420 
421  UpdateLayouts();
422 }
423 
424 
426 {
427  BOARD* board = myframe->GetBoard();
428  int count = GetLayerRowCount();
429 
430  for( int row=0; row<count; ++row )
431  {
432  // this utilizes more implementation knowledge than ideal, eventually
433  // add member ROW getRow() or similar to base LAYER_WIDGET.
434 
435  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
436 
437  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
438 
439  // this does not fire a UI event
440  setLayerCheckbox( layerId, board->IsLayerVisible( layerId ) );
441  }
442 }
443 
444 
445 #define ALPHA_EPSILON 0.04
446 
448 {
449  int count = GetLayerRowCount();
451  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() );
452  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
453 
454  for( int row = 0; row < count; ++row )
455  {
456  // this utilizes more implementation knowledge than ideal, eventually
457  // add member ROW getRow() or similar to base LAYER_WIDGET.
458 
459  wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
460  PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
461  KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId );
462 
463  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) );
464  KIGFX::COLOR4D layerColor = swatch->GetSwatchColor();
465 
466  INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) );
467 
468  if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON )
469  {
470  if( screenColor.a < layerColor.a )
471  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
472  else
473  indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
474  }
475  else
477  }
478 }
479 
480 
482 {
483  BOARD* brd = myframe->GetBoard();
484  LSET enabled = brd->GetEnabledLayers();
485 
486  ClearLayerRows();
487 
488  wxString dsc;
489 
490  // show all coppers first, with front on top, back on bottom, then technical layers
491  for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
492  {
493  PCB_LAYER_ID layer = *cu_stack;
494 
495  switch( layer )
496  {
497  case F_Cu:
498  dsc = _( "Front copper layer" );
499  break;
500 
501  case B_Cu:
502  dsc = _( "Back copper layer" );
503  break;
504 
505  default:
506  dsc = _( "Inner copper layer" );
507  break;
508  }
509 
510  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
511  myframe->Settings().Colors().GetLayerColor( layer ), dsc, true, true,
512  myframe->Settings().Colors().GetDefaultLayerColor( layer ) ) );
513 
514  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
515  {
516  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
517  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
518  }
519  }
520 
521  UpdateLayouts();
522 
523 
524  // technical layers are shown in this order:
525  // Because they are static, wxGetTranslation must be explicitly
526  // called for tooltips.
527  static const struct {
528  PCB_LAYER_ID layerId;
529  wxString tooltip;
530  } non_cu_seq[] = {
531  { F_Adhes, _( "Adhesive on board's front" ) },
532  { B_Adhes, _( "Adhesive on board's back" ) },
533  { F_Paste, _( "Solder paste on board's front" ) },
534  { B_Paste, _( "Solder paste on board's back" ) },
535  { F_SilkS, _( "Silkscreen on board's front" ) },
536  { B_SilkS, _( "Silkscreen on board's back" ) },
537  { F_Mask, _( "Solder mask on board's front" ) },
538  { B_Mask, _( "Solder mask on board's back" ) },
539  { Dwgs_User, _( "Explanatory drawings" ) },
540  { Cmts_User, _( "Explanatory comments" ) },
541  { Eco1_User, _( "User defined meaning" ) },
542  { Eco2_User, _( "User defined meaning" ) },
543  { Edge_Cuts, _( "Board's perimeter definition" ) },
544  { Margin, _( "Board's edge setback outline" ) },
545  { F_CrtYd, _( "Footprint courtyards on board's front" ) },
546  { B_CrtYd, _( "Footprint courtyards on board's back" ) },
547  { F_Fab, _( "Footprint assembly on board's front" ) },
548  { B_Fab, _( "Footprint assembly on board's back" ) }
549  };
550 
551  for( unsigned i=0; i<arrayDim( non_cu_seq ); ++i )
552  {
553  PCB_LAYER_ID layer = non_cu_seq[i].layerId;
554 
555  if( !enabled[layer] )
556  continue;
557 
558  AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
559  myframe->Settings().Colors().GetLayerColor( layer ),
560  wxGetTranslation( non_cu_seq[i].tooltip ), true, true,
561  myframe->Settings().Colors().GetDefaultLayerColor( layer ) ) );
562 
563  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
564  {
565  getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
566  getLayerComp( GetLayerRowCount()-1, COLUMN_COLORBM )->SetToolTip( wxEmptyString );
567  }
568  }
569 }
570 
571 
572 //-----<LAYER_WIDGET callbacks>-------------------------------------------
573 
575 {
576  myframe->Settings().Colors().SetLayerColor( aLayer, aColor );
577 
578  KIGFX::VIEW* view = myframe->GetCanvas()->GetView();
580  view->UpdateLayerColor( aLayer );
581  view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
582 
584 
585  myframe->GetCanvas()->Refresh();
586 
587  if( aLayer == LAYER_PCB_BACKGROUND )
588  myframe->SetDrawBgColor( aColor );
589 }
590 
591 
593 {
594  // the layer change from the PCB_LAYER_WIDGET can be denied by returning
595  // false from this function.
596  PCB_LAYER_ID layer = ToLAYER_ID( aLayer );
597 
598  if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
599  return false;
600 
601  myframe->SetActiveLayer( layer );
602 
604  OnLayerSelected();
606  myframe->GetCanvas()->Refresh();
607 
608  return true;
609 }
610 
611 
613 {
615  return false;
616 
617  // postprocess after an active layer selection
618  // ensure active layer visible
619  wxCommandEvent event;
621  onPopupSelection( event );
622 
623  return true;
624 }
625 
626 
627 void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
628 {
629  BOARD* brd = myframe->GetBoard();
630 
631  LSET visibleLayers = brd->GetVisibleLayers();
632 
633  if( visibleLayers.test( aLayer ) != isVisible )
634  {
635  visibleLayers.set( aLayer, isVisible );
636 
637  brd->SetVisibleLayers( visibleLayers );
638 
639  // Layer visibility is not stored in .kicad_mod files
640  if( !m_fp_editor_mode )
641  myframe->OnModify();
642 
643  if( myframe->GetCanvas() )
644  myframe->GetCanvas()->GetView()->SetLayerVisible( aLayer, isVisible );
645  }
646 
647  if( isFinal )
648  myframe->GetCanvas()->Refresh();
649 }
650 
651 
653 {
654  AddRightClickMenuItems( aMenu );
655 }
656 
657 
659 {
660  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
661 
662  myframe->Settings().Colors().SetItemColor( static_cast<GAL_LAYER_ID>( aId ), aColor );
663 
664  if( aId == LAYER_GRID )
665  myframe->GetCanvas()->GetGAL()->SetGridColor( aColor );
666 
667  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  myframe->GetCanvas()->Refresh();
679 }
680 
681 
682 void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
683 {
684  BOARD* brd = myframe->GetBoard();
685  wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
686 
688  {
689  // The layer visibility status is saved in the board file so set the board
690  // modified state so the user has the option to save the changes.
691  if( brd->IsElementVisible( static_cast<GAL_LAYER_ID>( aId ) ) != isEnabled )
692  myframe->OnModify();
693  }
694 
695  brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );
696 
697  if( aId == LAYER_GRID )
698  {
701  }
702  else if( aId == LAYER_RATSNEST )
703  {
704  // don't touch the layers. ratsnest is enabled on per-item basis.
706  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, true );
707 
709  {
711  opt.m_ShowGlobalRatsnest = isEnabled;
713  }
714  }
715  else
716  myframe->GetCanvas()->GetView()->SetLayerVisible( aId, isEnabled );
717 
718  myframe->GetCanvas()->Refresh();
719  myframe->GetCanvas()->Refresh();
720 }
721 
722 //-----</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:150
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
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:789
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)
virtual bool IsGridVisible() const
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
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:531
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:746
Class 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...
#define abs(a)
Definition: auxiliary.h:84
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.
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:61
Class 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.
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:304
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:52
bool isAllowedInFpMode(int aId)
Function isAllowedInFpMode.
Class 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 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: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.
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.
#define _(s)
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.
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
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...
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 IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:450
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
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
wxString rowName
the prompt or layername
Definition: layer_widget.h:89
size_t i
Definition: json11.cpp:649
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:38
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.
static COLOR4D GetDefaultItemColor(int aItemIdx)
Function GetDefaultItemColor.
Definition: colors.h:45
BOARD * GetBoard() const
Class 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:813
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.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39