KiCad PCB EDA Suite
board_inspection_tool.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) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <bitmaps.h>
25 #include <pcb_group.h>
26 #include <tool/tool_manager.h>
28 #include <tools/pcb_picker_tool.h>
29 #include <tools/edit_tool.h>
30 #include <pcb_painter.h>
32 #include <profile.h>
34 #include <drc/drc_engine.h>
37 #include <kicad_string.h>
38 #include "board_inspection_tool.h"
39 #include <pcbnew_settings.h>
41 
42 
43 void DIALOG_INSPECTION_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& event )
44 {
45  if( event.GetLinkInfo().GetHref() == "boardsetup" )
46  m_frame->ShowBoardSetupDialog( _( "Rules" ) );
47  else if( event.GetLinkInfo().GetHref() == "drc" )
49 }
50 
51 
53  PCB_TOOL_BASE( "pcbnew.InspectionTool" ),
54  m_frame( nullptr )
55 {
56  m_probingSchToPcb = false;
57  m_lastNetcode = -1;
58  m_dynamicData = nullptr;
59 }
60 
61 
63 {
64 public:
66  {
68  SetTitle( _( "Net Tools" ) );
69 
72  // Add( PCB_ACTIONS::highlightNet );
73  }
74 
75 private:
76  ACTION_MENU* create() const override
77  {
78  return new NET_CONTEXT_MENU();
79  }
80 };
81 
82 
84 {
86 
87  auto netSubMenu = std::make_shared<NET_CONTEXT_MENU>();
88  netSubMenu->SetTool( this );
89 
90  static KICAD_T connectedTypes[] = { PCB_TRACE_T, PCB_VIA_T, PCB_ARC_T, PCB_PAD_T,
91  PCB_ZONE_T, EOT };
92 
93  CONDITIONAL_MENU& menu = selectionTool->GetToolMenu().GetMenu();
94 
95  selectionTool->GetToolMenu().AddSubMenu( netSubMenu );
96 
97  menu.AddMenu( netSubMenu.get(), SELECTION_CONDITIONS::OnlyTypes( connectedTypes ), 200 );
99 
100  return true;
101 }
102 
103 
105 {
106  m_frame = getEditFrame<PCB_EDIT_FRAME>();
107 }
108 
109 
111 {
113  dialog.ShowModal();
114  return 0;
115 }
116 
117 
119 {
120  // Null items have no description
121  if( !aItem )
122  return wxString();
123 
124  wxString s = aItem->GetSelectMenuText( m_frame->GetUserUnits() );
125 
126  if( aItem->IsConnected() )
127  {
128  BOARD_CONNECTED_ITEM* cItem = static_cast<BOARD_CONNECTED_ITEM*>( aItem );
129  s += wxS( " " ) + wxString::Format( _( "[netclass %s]" ),
130  cItem->GetNetClass()->GetName() );
131  }
132 
133  return s;
134 };
135 
136 
138 {
140  wxString source;
141  ZONE_CONNECTION connection = aZone->GetPadConnection( aPad, &source );
142 
143  r->Report( "" );
144 
145  r->Report( wxString::Format( _( "Zone connection type: %s." ),
146  connectionEnum.ToString( aZone->GetPadConnection() ) ) );
147 
148  if( source != _( "zone" ) )
149  {
150  r->Report( wxString::Format( _( "Overridden by %s; connection type: %s." ),
151  source,
152  connectionEnum.ToString( connection ) ) );
153  }
154 
155  // Resolve complex connection types into simple types
156  if( connection == ZONE_CONNECTION::THT_THERMAL )
157  {
158  if( aPad->GetAttribute() == PAD_ATTRIB::PTH )
159  {
160  connection = ZONE_CONNECTION::THERMAL;
161  }
162  else
163  {
164  connection = ZONE_CONNECTION::FULL;
165  r->Report( wxString::Format( _( "Pad is not a PTH pad; connection will be: %s." ),
166  connectionEnum.ToString( ZONE_CONNECTION::FULL ) ) );
167  }
168  }
169 
170  r->Report( "" );
171 
172  // Process simple connection types
173  if( connection == ZONE_CONNECTION::THERMAL )
174  {
175  int gap = aZone->GetThermalReliefGap();
176 
177  r->Report( wxString::Format( _( "Zone thermal relief: %s." ),
178  StringFromValue( r->GetUnits(), gap, true ) ) );
179 
180  gap = aZone->GetThermalReliefGap( aPad, &source );
181 
182  if( source != _( "zone" ) )
183  {
184  r->Report( wxString::Format( _( "Overridden by %s; thermal relief: %s." ),
185  source,
186  StringFromValue( r->GetUnits(), gap, true ) ) );
187  }
188  }
189  else if( connection == ZONE_CONNECTION::NONE )
190  {
191  int clearance = aZone->GetLocalClearance();
192 
193  r->Report( wxString::Format( _( "Zone clearance: %s." ),
194  StringFromValue( r->GetUnits(), clearance, true ) ) );
195 
196  if( aZone->GetThermalReliefGap( aPad ) > clearance )
197  {
198  clearance = aZone->GetThermalReliefGap( aPad, &source );
199 
200  if( source != _( "zone" ) )
201  {
202  r->Report( wxString::Format( _( "Overridden by larger thermal relief from %s;"
203  "clearance: %s." ),
204  source,
205  StringFromValue( r->GetUnits(), clearance, true ) ) );
206  }
207  }
208  }
209  else
210  {
211  r->Report( wxString::Format( _( "Clearance: %s." ),
212  StringFromValue( r->GetUnits(), 0, true ) ) );
213  }
214 }
215 
216 
218  BOARD_ITEM* aA, BOARD_ITEM* aB, REPORTER* r )
219 {
220  r->Report( "" );
221 
223 
224  try
225  {
226  drcEngine.InitEngine( m_frame->GetDesignRulesPath() );
227  }
228  catch( PARSE_ERROR& )
229  {
230  r->Report( "" );
231  r->Report( _( "Report incomplete: could not compile custom design rules. " )
232  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
233  return;
234  }
235 
236  for( ZONE* zone : m_frame->GetBoard()->Zones() )
237  zone->CacheBoundingBox();
238 
240  {
241  for( ZONE* zone : footprint->Zones() )
242  zone->CacheBoundingBox();
243 
245  }
246 
247  auto constraint = drcEngine.EvalRules( aClearanceType, aA, aB, aLayer, r );
248  int clearance = constraint.m_Value.Min();
249 
250  wxString clearanceStr = StringFromValue( r->GetUnits(), clearance, true );
251 
252  r->Report( "" );
253  r->Report( wxString::Format( _( "Resolved clearance: %s." ), clearanceStr ) );
254 }
255 
256 
258 {
260  const PCB_SELECTION& selection = selTool->GetSelection();
262 
263  if( selection.Size() != 2 )
264  {
265  m_frame->ShowInfoBarError( _( "Select two items for a clearance resolution report." ) );
266  return 0;
267  }
268 
269  if( m_inspectClearanceDialog == nullptr )
270  {
271  m_inspectClearanceDialog = std::make_unique<DIALOG_INSPECTION_REPORTER>( m_frame );
272  m_inspectClearanceDialog->SetTitle( _( "Clearance Report" ) );
273 
274  m_inspectClearanceDialog->Connect( wxEVT_CLOSE_WINDOW,
276  nullptr, this );
277  }
278 
280  r->SetUnits( m_frame->GetUserUnits() );
281  r->Clear();
282 
283  BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
284  BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection.GetItem( 1 ) );
285 
286  auto hasHole =
287  []( BOARD_ITEM* aItem )
288  {
289  PAD* pad = dynamic_cast<PAD*>( aItem );
290  return pad && pad->GetDrillSizeX() > 0 && pad->GetDrillSizeY() > 0;
291  };
292 
293  wxCHECK( a && b, 0 );
294 
295  if( a->Type() == PCB_GROUP_T )
296  {
297  PCB_GROUP* ag = static_cast<PCB_GROUP*>( a );
298 
299  if( ag->GetItems().empty() )
300  {
301  m_frame->ShowInfoBarError( _( "Cannot generate clearance report on empty group." ) );
302  return 0;
303  }
304 
305  a = *ag->GetItems().begin();
306  }
307 
308  if( b->Type() == PCB_GROUP_T )
309  {
310  PCB_GROUP* bg = static_cast<PCB_GROUP*>( b );
311 
312  if( bg->GetItems().empty() )
313  {
314  m_frame->ShowInfoBarError( _( "Cannot generate clearance report on empty group." ) );
315  return 0;
316  }
317 
318  b = *bg->GetItems().begin();
319  }
320 
321  // a and b could be null after group tests above.
322  wxCHECK( a && b, 0 );
323 
324  if( a->Type() == PCB_TRACE_T || a->Type() == PCB_ARC_T )
325  {
326  layer = a->GetLayer();
327  }
328  else if( b->Type() == PCB_TRACE_T || b->Type() == PCB_ARC_T )
329  {
330  layer = b->GetLayer();
331  }
332  else if( a->Type() == PCB_PAD_T && static_cast<PAD*>( a )->GetAttribute() == PAD_ATTRIB::SMD )
333  {
334  PAD* pad = static_cast<PAD*>( a );
335 
336  if( pad->IsOnLayer( F_Cu ) )
337  layer = F_Cu;
338  else
339  layer = B_Cu;
340  }
341  else if( b->Type() == PCB_PAD_T && static_cast<PAD*>( a )->GetAttribute() == PAD_ATTRIB::SMD )
342  {
343  PAD* pad = static_cast<PAD*>( b );
344 
345  if( pad->IsOnLayer( F_Cu ) )
346  layer = F_Cu;
347  else
348  layer = B_Cu;
349  }
350 
351  if( a->Type() != PCB_ZONE_T && b->Type() == PCB_ZONE_T )
352  std::swap( a, b );
353  else if( !a->IsConnected() && b->IsConnected() )
354  std::swap( a, b );
355 
356  if( layer == F_SilkS || layer == B_SilkS )
357  {
358  r->Report( "<h7>" + _( "Silkscreen clearance resolution for:" ) + "</h7>" );
359 
360  r->Report( wxString::Format( "<ul><li>%s %s</li><li>%s</li><li>%s</li></ul>",
361  _( "Layer" ),
362  EscapeHTML( m_frame->GetBoard()->GetLayerName( layer ) ),
364  EscapeHTML( getItemDescription( b ) ) ) );
365 
366  reportClearance( SILK_CLEARANCE_CONSTRAINT, layer, a, b, r );
367  }
368  else if( !( a->GetLayerSet() & LSET( 3, layer, Edge_Cuts, Margin ) ).any() )
369  {
370  if( hasHole( a ) )
371  {
372  r->Report( "<h7>" + _( "Hole clearance resolution for:" ) + "</h7>" );
373 
374  r->Report( wxString::Format( "<ul><li>%s %s</li><li>%s</li><li>%s</li></ul>",
375  _( "Layer" ),
376  EscapeHTML( m_frame->GetBoard()->GetLayerName( layer ) ),
378  EscapeHTML( getItemDescription( b ) ) ) );
379 
380  reportClearance( HOLE_CLEARANCE_CONSTRAINT, layer, a, b, r );
381  }
382  else
383  {
384  r->Report( wxString::Format( _( "%s not present on layer %s. No clearance defined." ),
385  a->GetSelectMenuText( r->GetUnits() ),
386  m_frame->GetBoard()->GetLayerName( layer ) ) );
387  }
388  }
389  else if( !( b->GetLayerSet() & LSET( 3, layer, Edge_Cuts, Margin ) ).any() )
390  {
391  if( hasHole( b ) )
392  {
393  r->Report( "<h7>" + _( "Hole clearance resolution for:" ) + "</h7>" );
394 
395  r->Report( wxString::Format( "<ul><li>%s %s</li><li>%s</li><li>%s</li></ul>",
396  _( "Layer" ),
397  EscapeHTML( m_frame->GetBoard()->GetLayerName( layer ) ),
399  EscapeHTML( getItemDescription( a ) ) ) );
400 
401  reportClearance( HOLE_CLEARANCE_CONSTRAINT, layer, b, a, r );
402  }
403  else
404  {
405  r->Report( wxString::Format( _( "%s not present on layer %s. No clearance defined." ),
406  b->GetSelectMenuText( r->GetUnits() ),
407  m_frame->GetBoard()->GetLayerName( layer ) ) );
408  }
409  }
410  else if( a->GetLayer() == Edge_Cuts || a->GetLayer() == Margin
411  || b->GetLayer() == Edge_Cuts || b->GetLayer() == Margin )
412  {
413  r->Report( "<h7>" + _( "Edge clearance resolution for:" ) + "</h7>" );
414 
415  r->Report( wxString::Format( "<ul><li>%s</li><li>%s</li></ul>",
417  EscapeHTML( getItemDescription( b ) ) ) );
418 
419  reportClearance( EDGE_CLEARANCE_CONSTRAINT, layer, a, b, r );
420  }
421  else
422  {
423  r->Report( "<h7>" + _( "Clearance resolution for:" ) + "</h7>" );
424 
425  r->Report( wxString::Format( "<ul><li>%s %s</li><li>%s</li><li>%s</li></ul>",
426  _( "Layer" ),
427  EscapeHTML( m_frame->GetBoard()->GetLayerName( layer ) ),
429  EscapeHTML( getItemDescription( b ) ) ) );
430 
431  BOARD_CONNECTED_ITEM* ac = a && a->IsConnected() ?
432  static_cast<BOARD_CONNECTED_ITEM*>( a ) : nullptr;
433  BOARD_CONNECTED_ITEM* bc = b && b->IsConnected() ?
434  static_cast<BOARD_CONNECTED_ITEM*>( b ) : nullptr;
435 
436  if( ac && bc && ac->GetNetCode() > 0 && ac->GetNetCode() == bc->GetNetCode() )
437  {
438  // Same nets....
439 
440  if( ac->Type() == PCB_ZONE_T && bc->Type() == PCB_PAD_T )
441  {
442  reportZoneConnection( static_cast<ZONE*>( ac ), static_cast<PAD*>( bc ), r );
443  }
444  else
445  {
446  r->Report( "" );
447  r->Report( _( "Items belong to the same net. Clearance is 0." ) );
448  }
449  }
450  else
451  {
452  // Different nets (or one or both unconnected)....
453  reportClearance( CLEARANCE_CONSTRAINT, layer, a, b, r );
454  }
455  }
456 
457  r->Flush();
458 
459  m_inspectClearanceDialog->Raise();
460  m_inspectClearanceDialog->Show( true );
461  return 0;
462 }
463 
464 
466 {
468  const PCB_SELECTION& selection = selTool->GetSelection();
469 
470  if( selection.Size() != 1 )
471  {
472  m_frame->ShowInfoBarError( _( "Select an item for a constraints resolution report." ) );
473  return 0;
474  }
475 
476  if( m_inspectConstraintsDialog == nullptr )
477  {
478  m_inspectConstraintsDialog = std::make_unique<DIALOG_CONSTRAINTS_REPORTER>( m_frame );
479  m_inspectConstraintsDialog->SetTitle( _( "Constraints Report" ) );
480 
482  wxEVT_CLOSE_WINDOW,
484  nullptr, this );
485  }
486 
487  m_inspectConstraintsDialog->DeleteAllPages();
488 
489  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
491  bool courtyardError = false;
492  bool compileError = false;
493 
494  try
495  {
496  drcEngine.InitEngine( m_frame->GetDesignRulesPath() );
497  }
498  catch( PARSE_ERROR& )
499  {
500  compileError = true;
501  }
502 
503  for( ZONE* zone : m_frame->GetBoard()->Zones() )
504  zone->CacheBoundingBox();
505 
507  {
508  for( ZONE* zone : footprint->Zones() )
509  zone->CacheBoundingBox();
510 
512 
513  if( ( footprint->GetFlags() & MALFORMED_COURTYARDS ) != 0 )
514  courtyardError = true;
515  }
516 
517  WX_HTML_REPORT_BOX* r = nullptr;
518 
519  if( item->Type() == PCB_TRACE_T )
520  {
521  r = m_inspectConstraintsDialog->AddPage( _( "Track Width" ) );
522 
523  r->Report( "<h7>" + _( "Track width resolution for:" ) + "</h7>" );
524  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
525  r->Report( "" );
526 
527  if( compileError )
528  {
529  r->Report( "" );
530  r->Report( _( "Report incomplete: could not compile custom design rules. " )
531  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
532  }
533  else
534  {
535  auto constraint = drcEngine.EvalRules( TRACK_WIDTH_CONSTRAINT, item, nullptr,
536  item->GetLayer(), r );
537 
538  wxString min = _( "undefined" );
539  wxString max = _( "undefined" );
540 
541  if( constraint.m_Value.HasMin() )
542  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
543 
544  if( constraint.m_Value.HasMax() )
545  max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true );
546 
547  r->Report( "" );
548  r->Report( wxString::Format( _( "Width constraints: min %s max %s." ),
549  min,
550  max ) );
551  }
552 
553  r->Flush();
554  }
555 
556  if( item->Type() == PCB_VIA_T )
557  {
558  r = m_inspectConstraintsDialog->AddPage( _( "Via Diameter" ) );
559 
560  r->Report( "<h7>" + _( "Via diameter resolution for:" ) + "</h7>" );
561  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
562  r->Report( "" );
563 
564  if( compileError )
565  {
566  r->Report( "" );
567  r->Report( _( "Report incomplete: could not compile custom design rules. " )
568  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
569  }
570  else
571  {
572  // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
573  auto constraint = drcEngine.EvalRules( VIA_DIAMETER_CONSTRAINT, item, nullptr,
574  UNDEFINED_LAYER, r );
575 
576  wxString min = _( "undefined" );
577  wxString max = _( "undefined" );
578 
579  if( constraint.m_Value.HasMin() )
580  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
581 
582  if( constraint.m_Value.HasMax() )
583  max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true );
584 
585  r->Report( "" );
586  r->Report( wxString::Format( _( "Diameter constraints: min %s max %s." ),
587  min,
588  max ) );
589  }
590 
591  r->Flush();
592 
593  r = m_inspectConstraintsDialog->AddPage( _( "Via Annular Width" ) );
594 
595  r->Report( "<h7>" + _( "Via annular width resolution for:" ) + "</h7>" );
596  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
597  r->Report( "" );
598 
599  if( compileError )
600  {
601  r->Report( "" );
602  r->Report( _( "Report incomplete: could not compile custom design rules. " )
603  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
604  }
605  else
606  {
607  // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
608  auto constraint = drcEngine.EvalRules( ANNULAR_WIDTH_CONSTRAINT, item, nullptr,
609  UNDEFINED_LAYER, r );
610 
611  wxString min = _( "undefined" );
612  wxString max = _( "undefined" );
613 
614  if( constraint.m_Value.HasMin() )
615  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
616 
617  if( constraint.m_Value.HasMax() )
618  max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true );
619 
620  r->Report( "" );
621  r->Report( wxString::Format( _( "Annular width constraints: min %s max %s." ),
622  min,
623  max ) );
624  }
625 
626  r->Flush();
627  }
628 
629  if( ( item->Type() == PCB_PAD_T && static_cast<PAD*>( item )->GetDrillSize().x > 0 )
630  || item->Type() == PCB_VIA_T )
631  {
632  r = m_inspectConstraintsDialog->AddPage( _( "Hole Size" ) );
633 
634  r->Report( "<h7>" + _( "Hole diameter resolution for:" ) + "</h7>" );
635  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
636  r->Report( "" );
637 
638  if( compileError )
639  {
640  r->Report( "" );
641  r->Report( _( "Report incomplete: could not compile custom design rules. " )
642  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
643  }
644  else
645  {
646  // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
647  auto constraint = drcEngine.EvalRules( HOLE_SIZE_CONSTRAINT, item, nullptr,
648  UNDEFINED_LAYER, r );
649 
650  wxString min = _( "undefined" );
651 
652  if( constraint.m_Value.HasMin() )
653  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
654 
655  r->Report( "" );
656  r->Report( wxString::Format( _( "Hole constraint: min %s." ), min ) );
657  }
658 
659  r->Flush();
660  }
661 
662  r = m_inspectConstraintsDialog->AddPage( _( "Keepouts" ) );
663 
664  r->Report( "<h7>" + _( "Keepout resolution for:" ) + "</h7>" );
665  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
666  r->Report( "" );
667 
668  if( compileError )
669  {
670  r->Report( "" );
671  r->Report( _( "Report incomplete: could not compile custom design rules. " )
672  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
673  }
674  else
675  {
676  if( courtyardError )
677  {
678  r->Report( "" );
679  r->Report( _( "Report may be incomplete: some footprint courtyards are malformed." )
680  + " <a href='drc'>" + _( "Run DRC for a full analysis." ) + "</a>" );
681  }
682 
683  auto constraint = drcEngine.EvalRules( DISALLOW_CONSTRAINT, item, nullptr, item->GetLayer(),
684  r );
685 
686  r->Report( "" );
687 
688  if( constraint.m_DisallowFlags )
689  r->Report( _( "Item <b>disallowed</b> at current location." ) );
690  else
691  r->Report( _( "Item allowed at current location." ) );
692  }
693 
694  r->Flush();
695 
696  m_inspectConstraintsDialog->FinishInitialization();
698  m_inspectConstraintsDialog->Show( true );
699  return 0;
700 }
701 
702 
704 {
705  // Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
706  if( m_probingSchToPcb )
707  return 0;
708 
710  const PCB_SELECTION& selection = selTool->GetSelection();
711 
712  if( selection.Size() == 1 )
713  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
714  else
715  m_frame->SendMessageToEESCHEMA( nullptr );
716 
717  // Update 3D viewer highlighting
718  m_frame->Update3DView( false, frame()->GetDisplayOptions().m_Live3DRefresh );
719 
720  return 0;
721 }
722 
723 
725 {
726  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
727 
728  m_probingSchToPcb = true; // recursion guard
729  {
731 
732  if( item )
733  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, (void*) item );
734  }
735  m_probingSchToPcb = false;
736 
737  bool request3DviewRedraw = frame()->GetDisplayOptions().m_Live3DRefresh;
738 
739  if( item && item->Type() != PCB_FOOTPRINT_T )
740  request3DviewRedraw = false;
741 
742  // Update 3D viewer highlighting
743  if( request3DviewRedraw )
744  m_frame->Update3DView( false, true );
745 
746  return 0;
747 }
748 
749 
750  bool BOARD_INSPECTION_TOOL::highlightNet( const VECTOR2D& aPosition, bool aUseSelection )
751 {
752  BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
755 
756  int net = -1;
757  bool enableHighlight = false;
758 
759  if( aUseSelection )
760  {
761  const PCB_SELECTION& selection = selectionTool->GetSelection();
762 
763  for( auto item : selection )
764  {
765  if( auto ci = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
766  {
767  int item_net = ci->GetNetCode();
768 
769  if( net < 0 )
770  net = item_net;
771  else if( net != item_net ) // more than one net selected: do nothing
772  return false;
773  }
774  }
775 
776  enableHighlight = ( net >= 0 && !settings->GetHighlightNetCodes().count( net ) );
777  }
778 
779  // If we didn't get a net to highlight from the selection, use the cursor
780  if( net < 0 )
781  {
783  GENERAL_COLLECTOR collector;
784 
785  PCB_LAYER_ID activeLayer = static_cast<PCB_LAYER_ID>( view()->GetTopLayer() );
786  guide.SetPreferredLayer( activeLayer );
787 
788  // Find a connected item for which we are going to highlight a net
789  collector.Collect( board, GENERAL_COLLECTOR::PadsOrTracks, (wxPoint) aPosition, guide );
790 
791  if( collector.GetCount() == 0 )
792  collector.Collect( board, GENERAL_COLLECTOR::Zones, (wxPoint) aPosition, guide );
793 
794  // Apply the active selection filter, except we want to allow picking locked items for
795  // highlighting even if the user has disabled them for selection
796  SELECTION_FILTER_OPTIONS& filter = selectionTool->GetFilter();
797 
798  bool saved = filter.lockedItems;
799  filter.lockedItems = true;
800 
801  selectionTool->FilterCollectedItems( collector );
802 
803  filter.lockedItems = saved;
804 
805  // Clear the previous highlight
806  m_frame->SendMessageToEESCHEMA( nullptr );
807 
808  bool highContrast = settings->GetHighContrast();
809  PCB_LAYER_ID contrastLayer = settings->GetPrimaryHighContrastLayer();
810 
811  for( int i = collector.GetCount() - 1; i >= 0; i-- )
812  {
813  LSET itemLayers = collector[i]->GetLayerSet();
814 
815  if( ( itemLayers & LSET::AllCuMask() ).none() ||
816  ( highContrast && !itemLayers.Contains( contrastLayer ) ) )
817  {
818  collector.Remove( i );
819  continue;
820  }
821  }
822 
823  enableHighlight = ( collector.GetCount() > 0 );
824 
825  // Obtain net code for the clicked item
826  if( enableHighlight )
827  {
828  BOARD_CONNECTED_ITEM* targetItem = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] );
829 
830  if( targetItem->Type() == PCB_PAD_T )
831  m_frame->SendMessageToEESCHEMA( targetItem );
832 
833  net = targetItem->GetNetCode();
834  }
835  }
836 
837  auto& netcodes = settings->GetHighlightNetCodes();
838 
839  // Toggle highlight when the same net was picked
840  if( net > 0 && netcodes.count( net ) )
841  enableHighlight = !settings->IsHighlightEnabled();
842 
843  if( enableHighlight != settings->IsHighlightEnabled() || !netcodes.count( net ) )
844  {
845  if( !netcodes.empty() )
846  m_lastNetcode = *netcodes.begin();
847 
848  settings->SetHighlight( enableHighlight, net );
850  }
851 
852  // Store the highlighted netcode in the current board (for dialogs for instance)
853  if( enableHighlight && net >= 0 )
854  {
855  board->SetHighLightNet( net );
856  board->HighLightON();
857 
858  NETINFO_ITEM* netinfo = board->FindNet( net );
859 
860  if( netinfo )
861  {
862  MSG_PANEL_ITEMS items;
863  netinfo->GetMsgPanelInfo( m_frame, items );
864  m_frame->SetMsgPanel( items );
866  }
867  }
868  else
869  {
873  }
874 
875  return true;
876 }
877 
878 
880 {
881  int netcode = aEvent.Parameter<intptr_t>();
883  const std::set<int>& highlighted = settings->GetHighlightNetCodes();
884 
885  if( netcode > 0 )
886  {
887  m_lastNetcode = highlighted.empty() ? -1 : *highlighted.begin();
888  settings->SetHighlight( true, netcode );
890  }
891  else if( aEvent.IsAction( &PCB_ACTIONS::toggleLastNetHighlight ) )
892  {
893  int temp = highlighted.empty() ? -1 : *highlighted.begin();
894  settings->SetHighlight( true, m_lastNetcode );
896  m_lastNetcode = temp;
897  }
898  else // Highlight the net belonging to the item under the cursor
899  {
900  highlightNet( getViewControls()->GetMousePosition(), false );
901  }
902 
903  return 0;
904 }
905 
906 
908 {
909  BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
911 
913  settings->SetHighlight( false );
917  return 0;
918 }
919 
920 
922 {
923  std::string tool = aEvent.GetCommandStr().get();
925 
926  // Deactivate other tools; particularly important if another PICKER is currently running
927  Activate();
928 
929  // If the keyboard hotkey was triggered and we are already in the highlight tool, behave
930  // the same as a left-click. Otherwise highlight the net of the selected item(s), or if
931  // there is no selection, then behave like a ctrl-left-click.
933  {
934  bool use_selection = m_frame->IsCurrentTool( PCB_ACTIONS::highlightNetTool );
935  highlightNet( getViewControls()->GetMousePosition(), use_selection );
936  }
937 
938  picker->SetClickHandler(
939  [this] ( const VECTOR2D& pt ) -> bool
940  {
941  highlightNet( pt, false );
942  return true;
943  } );
944 
945  picker->SetLayerSet( LSET::AllCuMask() );
946  picker->SetSnapping( false );
947 
948  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
949 
950  return 0;
951 }
952 
953 
955 {
956  std::string tool = aEvent.GetCommandStr().get();
958  BOARD* board = getModel<BOARD>();
959 
960  // Deactivate other tools; particularly important if another PICKER is currently running
961  Activate();
962 
963  picker->SetClickHandler(
964  [this, board]( const VECTOR2D& pt ) -> bool
965  {
966  const PCB_DISPLAY_OPTIONS& opt = displayOptions();
968 
971  PCB_SELECTION& selection = selectionTool->GetSelection();
972 
973  if( selection.Empty() )
974  {
977  selection = selectionTool->GetSelection();
978  }
979 
980  if( selection.Empty() )
981  {
982  // Clear the previous local ratsnest if we click off all items
983  for( FOOTPRINT* fp : board->Footprints() )
984  {
985  for( PAD* pad : fp->Pads() )
986  pad->SetLocalRatsnestVisible( opt.m_ShowGlobalRatsnest );
987  }
988  }
989  else
990  {
991  for( EDA_ITEM* item : selection )
992  {
993  if( PAD* pad = dyn_cast<PAD*>( item) )
994  {
995  pad->SetLocalRatsnestVisible( !pad->GetLocalRatsnestVisible() );
996  }
997  else if( FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( item) )
998  {
999  if( !fp->Pads().empty() )
1000  {
1001  bool enable = !fp->Pads()[0]->GetLocalRatsnestVisible();
1002 
1003  for( PAD* childPad : fp->Pads() )
1004  childPad->SetLocalRatsnestVisible( enable );
1005  }
1006  }
1007  }
1008  }
1009 
1011 
1012  return true;
1013  } );
1014 
1015  picker->SetFinalizeHandler(
1016  [this, board]( int aCondition )
1017  {
1018  const PCB_DISPLAY_OPTIONS& opt = displayOptions();
1019 
1020  if( aCondition != PCB_PICKER_TOOL::END_ACTIVATE )
1021  {
1022  for( FOOTPRINT* fp : board->Footprints() )
1023  {
1024  for( PAD* pad : fp->Pads() )
1025  pad->SetLocalRatsnestVisible( opt.m_ShowGlobalRatsnest );
1026  }
1027  }
1028  } );
1029 
1030  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1031 
1032  return 0;
1033 }
1034 
1035 
1037 {
1038  VECTOR2I delta;
1039 
1040  // If we have passed the simple move vector, we can update without recalculation
1041  if( aEvent.Parameter<VECTOR2I*>() )
1042  {
1043  delta = *aEvent.Parameter<VECTOR2I*>();
1044  delete aEvent.Parameter<VECTOR2I*>();
1045  }
1046  else
1047  {
1048  // We can delete the existing map to force a recalculation
1049  delete m_dynamicData;
1050  m_dynamicData = nullptr;
1051  }
1052 
1053  auto selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1054  auto& selection = selectionTool->GetSelection();
1055  auto connectivity = getModel<BOARD>()->GetConnectivity();
1056 
1057  if( selection.Empty() )
1058  {
1059  connectivity->ClearDynamicRatsnest();
1060  delete m_dynamicData;
1061  m_dynamicData = nullptr;
1062  }
1063  else
1064  {
1065  calculateSelectionRatsnest( delta );
1066  }
1067 
1068  return 0;
1069 }
1070 
1071 
1073 {
1074  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1075  delete m_dynamicData;
1076  m_dynamicData = nullptr;
1077 
1078  return 0;
1079 }
1080 
1081 
1083 {
1085  SELECTION& selection = selectionTool->GetSelection();
1086  std::shared_ptr<CONNECTIVITY_DATA> connectivity = board()->GetConnectivity();
1087  std::vector<BOARD_ITEM*> items;
1088  std::deque<EDA_ITEM*> queued_items( selection.begin(), selection.end() );
1089 
1090  for( std::size_t i = 0; i < queued_items.size(); ++i )
1091  {
1092  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( queued_items[i] );
1093 
1094  if( item->Type() == PCB_FOOTPRINT_T )
1095  {
1096  for( PAD* pad : static_cast<FOOTPRINT*>( item )->Pads() )
1097  {
1098  if( pad->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
1099  items.push_back( pad );
1100  }
1101  }
1102  else if( item->Type() == PCB_GROUP_T )
1103  {
1104  PCB_GROUP *group = static_cast<PCB_GROUP*>( item );
1105  group->RunOnDescendants( [ &queued_items ]( BOARD_ITEM *aItem )
1106  {
1107  queued_items.push_back( aItem );
1108  } );
1109  }
1110  else if( BOARD_CONNECTED_ITEM* boardItem = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
1111  {
1112  if( boardItem->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
1113  items.push_back( boardItem );
1114  }
1115  }
1116 
1117  if( items.empty() || std::none_of( items.begin(), items.end(),
1118  []( const BOARD_ITEM* aItem )
1119  {
1120  return( aItem->Type() == PCB_TRACE_T
1121  || aItem->Type() == PCB_PAD_T
1122  || aItem->Type() == PCB_ARC_T
1123  || aItem->Type() == PCB_ZONE_T
1124  || aItem->Type() == PCB_FOOTPRINT_T
1125  || aItem->Type() == PCB_VIA_T );
1126  } ) )
1127  {
1128  return;
1129  }
1130 
1131  if( !m_dynamicData )
1132  {
1133  m_dynamicData = new CONNECTIVITY_DATA( items, true );
1134  connectivity->BlockRatsnestItems( items );
1135  }
1136  else
1137  {
1138  m_dynamicData->Move( aDelta );
1139  }
1140 
1141  connectivity->ComputeDynamicRatsnest( items, m_dynamicData );
1142 }
1143 
1144 
1146 {
1147  if( m_listNetsDialog == nullptr )
1148  {
1150  std::make_unique<DIALOG_NET_INSPECTOR>( m_frame, m_listNetsDialogSettings );
1151 
1152  m_listNetsDialog->Connect( wxEVT_CLOSE_WINDOW,
1153  wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
1154  this );
1155 
1156  m_listNetsDialog->Connect( wxEVT_BUTTON,
1157  wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
1158  this );
1159  }
1160 
1161  m_listNetsDialog->Raise();
1162  m_listNetsDialog->Show( true );
1163  return 0;
1164 }
1165 
1166 
1168 {
1170 
1171  m_listNetsDialog->Disconnect( wxEVT_CLOSE_WINDOW,
1172  wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
1173 
1174  m_listNetsDialog->Disconnect( wxEVT_BUTTON,
1175  wxCommandEventHandler( BOARD_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
1176 
1177  m_listNetsDialog->Destroy();
1178  m_listNetsDialog.release();
1179 }
1180 
1181 
1183 {
1184  m_inspectClearanceDialog->Disconnect( wxEVT_CLOSE_WINDOW,
1186  nullptr, this );
1187 
1188  m_inspectClearanceDialog->Destroy();
1189  m_inspectClearanceDialog.release();
1190 }
1191 
1192 
1194 {
1195  m_inspectConstraintsDialog->Disconnect( wxEVT_CLOSE_WINDOW,
1197  nullptr, this );
1198 
1199  m_inspectConstraintsDialog->Destroy();
1200  m_inspectConstraintsDialog.release();
1201 }
1202 
1203 
1205 {
1206  doHideNet( aEvent.Parameter<intptr_t>(), true );
1207  return 0;
1208 }
1209 
1210 
1212 {
1213  doHideNet( aEvent.Parameter<intptr_t>(), false );
1214  return 0;
1215 }
1216 
1217 
1218 void BOARD_INSPECTION_TOOL::doHideNet( int aNetCode, bool aHide )
1219 {
1220  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
1222 
1224  SELECTION& selection = selectionTool->GetSelection();
1225 
1226  if( aNetCode <= 0 && !selection.Empty() )
1227  {
1228  for( EDA_ITEM* item : selection )
1229  {
1230  if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1231  {
1232  if( bci->GetNetCode() > 0 )
1233  doHideNet( bci->GetNetCode(), aHide );
1234  }
1235  }
1236 
1237  return;
1238  }
1239 
1240  if( aHide )
1241  rs->GetHiddenNets().insert( aNetCode );
1242  else
1243  rs->GetHiddenNets().erase( aNetCode );
1244 
1246  m_frame->GetCanvas()->Refresh();
1247 
1248  m_frame->GetAppearancePanel()->OnNetVisibilityChanged( aNetCode, !aHide );
1249 }
1250 
1251 
1253 {
1257 
1259  PCB_ACTIONS::localRatsnestTool.MakeEvent() );
1261  PCB_ACTIONS::hideDynamicRatsnest.MakeEvent() );
1263  PCB_ACTIONS::updateLocalRatsnest.MakeEvent() );
1264 
1269  PCB_ACTIONS::inspectConstraints.MakeEvent() );
1270 
1273  PCB_ACTIONS::highlightNetSelection.MakeEvent() );
1280 
1283 }
void SetUnits(EDA_UNITS aUnits)
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
void BuildPolyCourtyards(OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Build complex polygons of the courtyard areas from graphic items on the courtyard layers.
Definition: footprint.cpp:1931
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
void reportClearance(DRC_CONSTRAINT_T aClearanceType, PCB_LAYER_ID aLayer, BOARD_ITEM *aA, BOARD_ITEM *aB, REPORTER *r)
int HideDynamicRatsnest(const TOOL_EVENT &aEvent)
Show local ratsnest of a component.
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
std::set< int > & GetHiddenNets()
Definition: pcb_painter.h:187
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1291
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
Design Rule Checker object that performs all the DRC tests.
Definition: drc_engine.h:80
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
bool IsCurrentTool(const TOOL_ACTION &aAction) const
static const TOOL_EVENT SelectedEvent
Definition: actions.h:201
wxString getItemDescription(BOARD_ITEM *aItem)
void SendCrossProbeNetName(const wxString &aNetName)
Send a net name to Eeschema for highlighting.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:342
ZONES & Zones()
Definition: board.h:311
BOARD * board() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:202
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:2069
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:47
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
A slimmed down version of WX_HTML_REPORT_PANEL.
static TOOL_ACTION hideNet
Definition: pcb_actions.h:455
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:72
virtual EDA_UNITS GetUnits() const
Definition: reporter.h:120
static TOOL_ACTION highlightItem
Definition: pcb_actions.h:454
const wxString & GetName() const
Definition: netclass.h:65
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
Definition: collectors.cpp:567
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
static TOOL_ACTION boardStatistics
Definition: pcb_actions.h:441
int InspectClearance(const TOOL_EVENT &aEvent)
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
int ClearHighlight(const TOOL_EVENT &aEvent)
Launch a tool to pick the item whose net is going to be highlighted.
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
ITER end()
Definition: selection.h:63
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Highlight net belonging to the item under the cursor.
Smd pad, appears on the solder paste layer (default)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static ENUM_MAP< T > & Instance()
Definition: property.h:510
TOOL_MENU & GetToolMenu()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:102
static const KICAD_T PadsOrTracks[]
A scan list for PADs, TRACKs, or VIAs.
Definition: collectors.h:289
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:459
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
static TOOL_ACTION toggleLastNetHighlight
Definition: pcb_actions.h:451
APPEARANCE_CONTROLS * GetAppearancePanel()
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
std::unordered_set< BOARD_ITEM * > & GetItems()
Definition: pcb_group.h:68
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
EDA_ITEM * GetModel() const
Definition: tool_manager.h:296
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
Plated through hole pad.
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:70
static TOOL_ACTION inspectConstraints
Definition: pcb_actions.h:445
void SetLayerSet(LSET aLayerSet)
Set the tool's snap layer set.
static TOOL_ACTION pickerTool
Definition: actions.h:158
PCB_BASE_EDIT_FRAME * frame() const
int GetThermalReliefGap() const
Definition: zone.h:190
virtual PCB_LAYER_ID GetActiveLayer() const
DRC_CONSTRAINT_T
Definition: drc_rule.h:41
static TOOL_ACTION highlightNetTool
Definition: pcb_actions.h:452
PCB specific render settings.
Definition: pcb_painter.h:64
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
int InspectConstraints(const TOOL_EVENT &aEvent)
FP_ZONES & Zones()
Definition: footprint.h:170
ITER begin()
Definition: selection.h:62
Container for display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
void SetPreferredLayer(PCB_LAYER_ID aLayer)
Definition: collectors.h:509
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
LSET is a set of PCB_LAYER_IDs.
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:2047
pads are covered by copper
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
int HighlightNet(const TOOL_EVENT &aEvent)
Clear all board highlights.
const PCB_SELECTION & selection() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
std::unique_ptr< DIALOG_CONSTRAINTS_REPORTER > m_inspectConstraintsDialog
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:574
void onInspectClearanceDialogClosed(wxCommandEvent &aEvent)
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.cpp:492
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:448
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
FOOTPRINTS & Footprints()
Definition: board.h:305
Generic, UI-independent tool event.
Definition: tool_event.h:173
FOOTPRINT * footprint() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:416
KIGFX::PCB_VIEW * view() const
static const KICAD_T Zones[]
A scan list for zones outlines only.
Definition: collectors.h:273
const wxString & GetNetname() const
Definition: netinfo.h:119
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
int HighlightItem(const TOOL_EVENT &aEvent)
Update ratsnest for selected items.
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:203
#define MALFORMED_COURTYARDS
Definition: eda_item.h:126
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:105
This file contains data structures that are saved in the project file or project local settings file ...
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:2056
int ShowNet(const TOOL_EVENT &aEvent)
Show the clearance resolution for two selected items.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:106
static TOOL_ACTION hideDynamicRatsnest
Definition: pcb_actions.h:460
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool highlightNet(const VECTOR2D &aPosition, bool aUseSelection)
Look for a BOARD_CONNECTED_ITEM in a given spot and if one is found - it enables highlight for its ne...
static void PadFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
A selection filter which prunes the selection to contain only items of type PCB_PAD_T.
Definition: edit_tool.cpp:2175
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...
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
Thermal relief only for THT pads.
static TOOL_ACTION inspectClearance
Definition: pcb_actions.h:444
const PCB_DISPLAY_OPTIONS & displayOptions() const
Generic tool for picking an item.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
std::unique_ptr< DIALOG_NET_INSPECTOR > m_listNetsDialog
static TOOL_ACTION clearHighlight
Definition: pcb_actions.h:449
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void reportZoneConnection(ZONE *aZone, PAD *aPad, REPORTER *r)
int ListNets(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net.
void OnNetVisibilityChanged(int aNetCode, bool aVisibility)
Notifies the panel when a net has been hidden or shown via the external tool.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:476
Use thermal relief for pads.
EDA_UNITS GetUnits() const override
int HighlightNetTool(const TOOL_EVENT &aEvent)
Perform the appropriate action in response to an Eeschema cross-probe.
void SendMessageToEESCHEMA(BOARD_ITEM *objectToSync)
Send a message to the schematic editor so that it may move its cursor to a symbol with the same refer...
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Handle the data for a net.
Definition: netinfo.h:64
static TOOL_ACTION showNet
Definition: pcb_actions.h:456
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:90
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:450
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings
static TOOL_ACTION highlightNetSelection
Definition: pcb_actions.h:453
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
#define _(s)
Definition: 3d_actions.cpp:33
PAD_ATTRIB GetAttribute() const
Definition: pad.h:371
static TOOL_ACTION listNets
Definition: pcb_actions.h:344
bool Init() override
Init() is called once upon a registration of the tool.
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:241
Dialog to show common board info.
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: eda_item.cpp:107
bool m_Live3DRefresh
If true, 3D viewer will redraw on every modification operation.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
void onListNetsDialogClosed(wxCommandEvent &aEvent)
void doHideNet(int aNetCode, bool aHide)
Bind handlers to corresponding TOOL_ACTIONs.
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:66
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
The selection tool: currently supports:
static TOOL_ACTION runDRC
Definition: pcb_actions.h:345
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
CONNECTIVITY_DATA * m_dynamicData
Pads are not covered.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
int HideNet(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net.
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:190
void Activate()
Run the tool.
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Hide ratsnest for selected items. Called when there are no items selected.
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:136
SELECTION_FILTER_OPTIONS & GetFilter()
Set up handlers for various events.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void SetSnapping(bool aSnap)
Definition: picker_tool.h:64
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:461
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
A selection filter which prunes the selection to contain only items of type #PCB_MODULE_T.
Definition: edit_tool.cpp:2188
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:381
ZONE_CONNECTION GetPadConnection(PAD *aPad, wxString *aSource=nullptr) const
Definition: zone.cpp:774
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Return the information about the NETINFO_ITEM in aList to display in the message panel.
Definition: pad.h:60
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:773
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:366
STATUS_FLAGS GetFlags() const
Definition: eda_item.h:205
void FilterCollectedItems(GENERAL_COLLECTOR &aCollector)
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
std::unique_ptr< DIALOG_INSPECTION_REPORTER > m_inspectClearanceDialog
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173
void Move(const VECTOR2I &aDelta)
Moves the connectivity list anchors.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:60
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
void onInspectConstraintsDialogClosed(wxCommandEvent &aEvent)
int ShowStatisticsDialog(const TOOL_EVENT &aEvent)
Show dialog with board statistics.
void InitEngine(const wxFileName &aRulePath)
Initializes the DRC engine.
Definition: drc_engine.cpp:621
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:178
EDA_ITEM * Front() const
Definition: selection.h:203
const wxString & ToString(T value) const
Definition: property.h:529
ACTION_MENU * create() const override
< Return an instance of this class. It has to be overridden in inheriting classes.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163