KiCad PCB EDA Suite
pcb_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-2020 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>
27 #include <tools/selection_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 "pcb_inspection_tool.h"
39 
40 
41 void DIALOG_INSPECTION_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& event )
42 {
43  if( event.GetLinkInfo().GetHref() == "boardsetup" )
44  m_frame->ShowBoardSetupDialog( _( "Rules" ) );
45  else if( event.GetLinkInfo().GetHref() == "drc" )
47 }
48 
49 
51  PCB_TOOL_BASE( "pcbnew.InspectionTool" ),
52  m_frame( nullptr )
53 {
54  m_probingSchToPcb = false;
55  m_lastNetcode = -1;
56  m_dynamicData = nullptr;
57 }
58 
59 
61 {
62 public:
64  {
66  SetTitle( _( "Net Tools" ) );
67 
70  // Add( PCB_ACTIONS::highlightNet );
71  }
72 
73 private:
74  ACTION_MENU* create() const override
75  {
76  return new NET_CONTEXT_MENU();
77  }
78 };
79 
80 
82 {
83  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
84 
85  auto netSubMenu = std::make_shared<NET_CONTEXT_MENU>();
86  netSubMenu->SetTool( this );
87 
88  static KICAD_T connectedTypes[] = { PCB_TRACE_T, PCB_VIA_T, PCB_ARC_T, PCB_PAD_T,
89  PCB_ZONE_T, EOT };
90 
91  CONDITIONAL_MENU& menu = selectionTool->GetToolMenu().GetMenu();
92 
93  selectionTool->GetToolMenu().AddSubMenu( netSubMenu );
94 
95  menu.AddMenu( netSubMenu.get(), SELECTION_CONDITIONS::OnlyTypes( connectedTypes ), 200 );
97 
98  return true;
99 }
100 
101 
103 {
104  m_frame = getEditFrame<PCB_EDIT_FRAME>();
105 }
106 
107 
109 {
111  dialog.ShowModal();
112  return 0;
113 }
114 
115 
117 {
118  wxString s = aItem->GetSelectMenuText( m_frame->GetUserUnits() );
119 
120  if( aItem->IsConnected() )
121  {
122  BOARD_CONNECTED_ITEM* cItem = static_cast<BOARD_CONNECTED_ITEM*>( aItem );
123  s += wxS( " " ) + wxString::Format( _( "[netclass %s]" ),
124  cItem->GetNetClass()->GetName() );
125  }
126 
127  return s;
128 };
129 
130 
132 {
134  wxString source;
135  ZONE_CONNECTION connection = aZone->GetPadConnection( aPad, &source );
136 
137  r->Report( "" );
138 
139  r->Report( wxString::Format( _( "Zone connection type: %s." ),
140  connectionEnum.ToString( aZone->GetPadConnection() ) ) );
141 
142  if( source != _( "zone" ) )
143  {
144  r->Report( wxString::Format( _( "Overridden by %s; connection type: %s." ),
145  source,
146  connectionEnum.ToString( connection ) ) );
147  }
148 
149  // Resolve complex connection types into simple types
150  if( connection == ZONE_CONNECTION::THT_THERMAL )
151  {
152  if( aPad->GetAttribute() == PAD_ATTRIB_PTH )
153  {
154  connection = ZONE_CONNECTION::THERMAL;
155  }
156  else
157  {
158  connection = ZONE_CONNECTION::FULL;
159  r->Report( wxString::Format( _( "Pad is not a PTH pad; connection will be: %s." ),
160  connectionEnum.ToString( ZONE_CONNECTION::FULL ) ) );
161  }
162  }
163 
164  r->Report( "" );
165 
166  // Process simple connection types
167  if( connection == ZONE_CONNECTION::THERMAL )
168  {
169  int gap = aZone->GetThermalReliefGap();
170 
171  r->Report( wxString::Format( _( "Zone thermal relief: %s." ),
172  StringFromValue( r->GetUnits(), gap, true ) ) );
173 
174  gap = aZone->GetThermalReliefGap( aPad, &source );
175 
176  if( source != _( "zone" ) )
177  {
178  r->Report( wxString::Format( _( "Overridden by %s; thermal relief: %s." ),
179  source,
180  StringFromValue( r->GetUnits(), gap, true ) ) );
181  }
182  }
183  else if( connection == ZONE_CONNECTION::NONE )
184  {
185  int clearance = aZone->GetLocalClearance();
186 
187  r->Report( wxString::Format( _( "Zone clearance: %s." ),
188  StringFromValue( r->GetUnits(), clearance, true ) ) );
189 
190  if( aZone->GetThermalReliefGap( aPad ) > clearance )
191  {
192  clearance = aZone->GetThermalReliefGap( aPad, &source );
193 
194  if( source != _( "zone" ) )
195  {
196  r->Report( wxString::Format( _( "Overridden by larger thermal relief from %s;"
197  "clearance: %s." ),
198  source,
199  StringFromValue( r->GetUnits(), clearance, true ) ) );
200  }
201  }
202  }
203  else
204  {
205  r->Report( wxString::Format( _( "Clearance: %s." ),
206  StringFromValue( r->GetUnits(), 0, true ) ) );
207  }
208 }
209 
210 
212  PCB_LAYER_ID aLayer, BOARD_ITEM* aA, BOARD_ITEM* aB,
213  REPORTER* r )
214 {
215  r->Report( "" );
216 
218 
219  try
220  {
221  drcEngine.InitEngine( m_frame->GetDesignRulesPath() );
222  }
223  catch( PARSE_ERROR& pe )
224  {
225  r->Report( "" );
226  r->Report( _( "Report incomplete: could not compile design rules. " )
227  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
228  return;
229  }
230 
231  for( ZONE* zone : m_frame->GetBoard()->Zones() )
232  zone->CacheBoundingBox();
233 
235  {
236  for( ZONE* zone : footprint->Zones() )
237  zone->CacheBoundingBox();
238 
240  }
241 
242  int clearance = 0;
243 
244  if( aClearanceType == CLEARANCE_CONSTRAINT )
245  {
246  if( ( aA && ( aA->GetLayerSet() & LSET( 2, Edge_Cuts, Margin ) ).any() )
247  || ( aB && ( aB->GetLayerSet() & LSET( 2, Edge_Cuts, Margin ) ).any() ) )
248  {
249  auto edgeConstraint = drcEngine.EvalRulesForItems( EDGE_CLEARANCE_CONSTRAINT, aA, aB,
250  aLayer, r );
251 
252  clearance = edgeConstraint.m_Value.HasMin() ? edgeConstraint.m_Value.Min() : 0;
253  }
254  }
255 
256  auto constraint = drcEngine.EvalRulesForItems( aClearanceType, aA, aB, aLayer, r );
257 
258  if( constraint.m_Value.HasMin() && constraint.m_Value.Min() > clearance )
259  clearance = constraint.m_Value.Min();
260 
261  wxString clearanceStr = StringFromValue( r->GetUnits(), clearance, true );
262 
263  r->Report( "" );
264  r->Report( wxString::Format( _( "Resolved clearance: %s." ), clearanceStr ) );
265 }
266 
267 
269 {
271  const PCBNEW_SELECTION& selection = selTool->GetSelection();
273 
274  if( selection.Size() != 2 )
275  {
276  m_frame->ShowInfoBarError( _( "Select two items for a clearance resolution report." ) );
277  return 0;
278  }
279 
280  if( m_inspectClearanceDialog == nullptr )
281  {
282  m_inspectClearanceDialog = std::make_unique<DIALOG_INSPECTION_REPORTER>( m_frame );
283  m_inspectClearanceDialog->SetTitle( _( "Clearance Report" ) );
284 
285  m_inspectClearanceDialog->Connect( wxEVT_CLOSE_WINDOW,
287  nullptr, this );
288  }
289 
291  r->SetUnits( m_frame->GetUserUnits() );
292  r->Clear();
293 
294  BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
295  BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection.GetItem( 1 ) );
296 
297  if( a->Type() == PCB_GROUP_T )
298  {
299  PCB_GROUP* ag = static_cast<PCB_GROUP*>( a );
300 
301  if( ag->GetItems().empty() )
302  {
303  m_frame->ShowInfoBarError( _( "Cannot generate clearance report on empty group." ) );
304  return 0;
305  }
306 
307  a = *ag->GetItems().begin();
308  }
309 
310  if( b->Type() == PCB_GROUP_T )
311  {
312  PCB_GROUP* bg = static_cast<PCB_GROUP*>( a );
313 
314  if( bg->GetItems().empty() )
315  {
316  m_frame->ShowInfoBarError( _( "Cannot generate clearance report on empty group." ) );
317  return 0;
318  }
319 
320  a = *bg->GetItems().begin();
321  }
322 
323  if( a->Type() == PCB_TRACE_T || a->Type() == PCB_ARC_T )
324  {
325  layer = a->GetLayer();
326  }
327  else if( b->Type() == PCB_TRACE_T || b->Type() == PCB_ARC_T )
328  {
329  layer = b->GetLayer();
330  }
331  else if( a->Type() == PCB_PAD_T && static_cast<PAD*>( a )->GetAttribute() == PAD_ATTRIB_SMD )
332  {
333  PAD* pad = static_cast<PAD*>( a );
334 
335  if( pad->GetAttribute() == PAD_ATTRIB_SMD && pad->IsOnLayer( F_Cu ) )
336  layer = F_Cu;
337  else
338  layer = B_Cu;
339  }
340  else if( b->Type() == PCB_PAD_T )
341  {
342  PAD* pad = static_cast<PAD*>( b );
343 
344  if( pad->GetAttribute() == PAD_ATTRIB_SMD && pad->IsOnLayer( F_Cu ) )
345  layer = F_Cu;
346  else
347  layer = B_Cu;
348  }
349 
350  if( a->Type() != PCB_ZONE_T && b->Type() == PCB_ZONE_T )
351  std::swap( a, b );
352  else if( !a->IsConnected() && b->IsConnected() )
353  std::swap( a, b );
354 
355  if( layer == F_SilkS || layer == B_SilkS )
356  {
357  r->Report( "<h7>" + _( "Silkscreen clearance resolution for:" ) + "</h7>" );
358 
359  r->Report( wxString::Format( "<ul><li>%s %s</li><li>%s</li><li>%s</li></ul>",
360  _( "Layer" ),
361  EscapeHTML( m_frame->GetBoard()->GetLayerName( layer ) ),
363  EscapeHTML( getItemDescription( b ) ) ) );
364 
365  reportClearance( SILK_CLEARANCE_CONSTRAINT, layer, a, b, r );
366  }
367  else if( !( a->GetLayerSet() & LSET( 3, layer, Edge_Cuts, Margin ) ).any() )
368  {
369  r->Report( wxString::Format( _( "%s not present on layer %s. No clearance defined." ),
370  a->GetSelectMenuText( r->GetUnits() ),
371  m_frame->GetBoard()->GetLayerName( layer ) ) );
372  }
373  else if( !( b->GetLayerSet() & LSET( 3, layer, Edge_Cuts, Margin ) ).any() )
374  {
375  r->Report( wxString::Format( _( "%s not present on layer %s. No clearance defined." ),
376  b->GetSelectMenuText( r->GetUnits() ),
377  m_frame->GetBoard()->GetLayerName( layer ) ) );
378  }
379  else
380  {
381  r->Report( "<h7>" + _( "Clearance resolution for:" ) + "</h7>" );
382 
383  r->Report( wxString::Format( "<ul><li>%s %s</li><li>%s</li><li>%s</li></ul>",
384  _( "Layer" ),
385  EscapeHTML( m_frame->GetBoard()->GetLayerName( layer ) ),
387  EscapeHTML( getItemDescription( b ) ) ) );
388 
389  BOARD_CONNECTED_ITEM* ac = a && a->IsConnected() ?
390  static_cast<BOARD_CONNECTED_ITEM*>( a ) : nullptr;
391  BOARD_CONNECTED_ITEM* bc = b && b->IsConnected() ?
392  static_cast<BOARD_CONNECTED_ITEM*>( b ) : nullptr;
393 
394  if( ac && bc && ac->GetNetCode() > 0 && ac->GetNetCode() == bc->GetNetCode() )
395  {
396  // Same nets....
397 
398  if( ac->Type() == PCB_ZONE_T && bc->Type() == PCB_PAD_T )
399  {
400  reportZoneConnection( static_cast<ZONE*>( ac ), static_cast<PAD*>( bc ), r );
401  }
402  else
403  {
404  r->Report( "" );
405  r->Report( _( "Items belong to the same net. Clearance is 0." ) );
406  }
407  }
408  else
409  {
410  // Different nets (or one or both unconnected)....
411  reportClearance( CLEARANCE_CONSTRAINT, layer, a, b, r );
412  }
413  }
414 
415  r->Flush();
416 
417  m_inspectClearanceDialog->Raise();
418  m_inspectClearanceDialog->Show( true );
419  return 0;
420 }
421 
422 
424 {
426  const PCBNEW_SELECTION& selection = selTool->GetSelection();
427 
428  if( selection.Size() != 1 )
429  {
430  m_frame->ShowInfoBarError( _( "Select an item for a constraints resolution report." ) );
431  return 0;
432  }
433 
434  if( m_inspectConstraintsDialog == nullptr )
435  {
436  m_inspectConstraintsDialog = std::make_unique<DIALOG_CONSTRAINTS_REPORTER>( m_frame );
437  m_inspectConstraintsDialog->SetTitle( _( "Constraints Report" ) );
438 
439  m_inspectConstraintsDialog->Connect( wxEVT_CLOSE_WINDOW,
441  nullptr, this );
442  }
443 
444  m_inspectConstraintsDialog->DeleteAllPages();
445 
446  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
448  bool courtyardError = false;
449  bool compileError = false;
450 
451  try
452  {
453  drcEngine.InitEngine( m_frame->GetDesignRulesPath() );
454  }
455  catch( PARSE_ERROR& pe )
456  {
457  compileError = true;
458  }
459 
460  for( ZONE* zone : m_frame->GetBoard()->Zones() )
461  zone->CacheBoundingBox();
462 
464  {
465  for( ZONE* zone : footprint->Zones() )
466  zone->CacheBoundingBox();
467 
469 
470  if( ( footprint->GetFlags() & MALFORMED_COURTYARDS ) != 0 )
471  courtyardError = true;
472  }
473 
474  WX_HTML_REPORT_BOX* r = nullptr;
475 
476  if( item->Type() == PCB_TRACE_T )
477  {
478  r = m_inspectConstraintsDialog->AddPage( _( "Track Width" ) );
479 
480  r->Report( "<h7>" + _( "Track width resolution for:" ) + "</h7>" );
481  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
482  r->Report( "" );
483 
484  if( compileError )
485  {
486  r->Report( "" );
487  r->Report( _( "Report incomplete: could not compile design rules. " )
488  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
489  }
490  else
491  {
492  auto constraint = drcEngine.EvalRulesForItems( TRACK_WIDTH_CONSTRAINT, item, nullptr,
493  UNDEFINED_LAYER, r );
494 
495  wxString min = _( "undefined" );
496  wxString max = _( "undefined" );
497 
498  if( constraint.m_Value.HasMin() )
499  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
500 
501  if( constraint.m_Value.HasMax() )
502  max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true );
503 
504  r->Report( "" );
505  r->Report( wxString::Format( _( "Width constraints: min %s max %s." ),
506  min,
507  max ) );
508  }
509 
510  r->Flush();
511  }
512 
513  if( item->Type() == PCB_VIA_T )
514  {
515  r = m_inspectConstraintsDialog->AddPage( _( "Via Diameter" ) );
516 
517  r->Report( "<h7>" + _( "Via diameter resolution for:" ) + "</h7>" );
518  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
519  r->Report( "" );
520 
521  if( compileError )
522  {
523  r->Report( "" );
524  r->Report( _( "Report incomplete: could not compile design rules. " )
525  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
526  }
527  else
528  {
529  auto constraint = drcEngine.EvalRulesForItems( VIA_DIAMETER_CONSTRAINT, item, nullptr,
530  UNDEFINED_LAYER, r );
531 
532  wxString min = _( "undefined" );
533  wxString max = _( "undefined" );
534 
535  if( constraint.m_Value.HasMin() )
536  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
537 
538  if( constraint.m_Value.HasMax() )
539  max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true );
540 
541  r->Report( "" );
542  r->Report( wxString::Format( _( "Diameter constraints: min %s max %s." ),
543  min,
544  max ) );
545  }
546 
547  r->Flush();
548 
549  r = m_inspectConstraintsDialog->AddPage( _( "Via Annular Width" ) );
550 
551  r->Report( "<h7>" + _( "Via annular width resolution for:" ) + "</h7>" );
552  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
553  r->Report( "" );
554 
555  if( compileError )
556  {
557  r->Report( "" );
558  r->Report( _( "Report incomplete: could not compile design rules. " )
559  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
560  }
561  else
562  {
563  auto constraint = drcEngine.EvalRulesForItems( ANNULAR_WIDTH_CONSTRAINT, item, nullptr,
564  UNDEFINED_LAYER, r );
565 
566  wxString min = _( "undefined" );
567  wxString max = _( "undefined" );
568 
569  if( constraint.m_Value.HasMin() )
570  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
571 
572  if( constraint.m_Value.HasMax() )
573  max = StringFromValue( r->GetUnits(), constraint.m_Value.Max(), true );
574 
575  r->Report( "" );
576  r->Report( wxString::Format( _( "Annular width constraints: min %s max %s." ),
577  min,
578  max ) );
579  }
580 
581  r->Flush();
582  }
583 
584  if( ( item->Type() == PCB_PAD_T && static_cast<PAD*>( item )->GetDrillSize().x > 0 )
585  || item->Type() == PCB_VIA_T )
586  {
587  r = m_inspectConstraintsDialog->AddPage( _( "Hole Size" ) );
588 
589  r->Report( "<h7>" + _( "Hole diameter resolution for:" ) + "</h7>" );
590  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
591  r->Report( "" );
592 
593  if( compileError )
594  {
595  r->Report( "" );
596  r->Report( _( "Report incomplete: could not compile design rules. " )
597  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
598  }
599  else
600  {
601  auto constraint = drcEngine.EvalRulesForItems( HOLE_SIZE_CONSTRAINT, item, nullptr,
602  UNDEFINED_LAYER, r );
603 
604  wxString min = _( "undefined" );
605 
606  if( constraint.m_Value.HasMin() )
607  min = StringFromValue( r->GetUnits(), constraint.m_Value.Min(), true );
608 
609  r->Report( "" );
610  r->Report( wxString::Format( _( "Hole constraint: min %s." ), min ) );
611  }
612 
613  r->Flush();
614  }
615 
616  r = m_inspectConstraintsDialog->AddPage( _( "Keepouts" ) );
617 
618  r->Report( "<h7>" + _( "Keepout resolution for:" ) + "</h7>" );
619  r->Report( "<ul><li>" + EscapeHTML( getItemDescription( item ) ) + "</li></ul>" );
620  r->Report( "" );
621 
622  if( compileError )
623  {
624  r->Report( "" );
625  r->Report( _( "Report incomplete: could not compile design rules. " )
626  + "<a href='boardsetup'>" + _( "Show design rules." ) + "</a>" );
627  }
628  else
629  {
630  if( courtyardError )
631  {
632  r->Report( "" );
633  r->Report( _( "Report may be incomplete: some footprint courtyards are malformed." )
634  + " <a href='drc'>" + _( "Run DRC for a full analysis." ) + "</a>" );
635  }
636 
637  auto constraint = drcEngine.EvalRulesForItems( DISALLOW_CONSTRAINT, item, nullptr,
638  UNDEFINED_LAYER, r );
639 
640  r->Report( "" );
641 
642  if( constraint.m_DisallowFlags )
643  r->Report( _( "Item <b>disallowed</b> at current location." ) );
644  else
645  r->Report( _( "Item allowed at current location." ) );
646  }
647 
648  r->Flush();
649 
650  m_inspectConstraintsDialog->FinishInitialization();
652  m_inspectConstraintsDialog->Show( true );
653  return 0;
654 }
655 
656 
658 {
659  // Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
660  if( m_probingSchToPcb )
661  return 0;
662 
664  const PCBNEW_SELECTION& selection = selTool->GetSelection();
665 
666  if( selection.Size() == 1 )
667  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
668  else
669  m_frame->SendMessageToEESCHEMA( nullptr );
670 
671  m_frame->Update3DView( false );
672 
673  return 0;
674 }
675 
676 
678 {
679  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
680 
681  m_probingSchToPcb = true; // recursion guard
682  {
684 
685  if( item )
686  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, (void*) item );
687  }
688  m_probingSchToPcb = false;
689 
690  bool request3DviewRedraw = true;
691 
692  if( item && item->Type() != PCB_FOOTPRINT_T )
693  request3DviewRedraw = false;
694 
695  if( request3DviewRedraw )
696  m_frame->Update3DView( false );
697 
698  return 0;
699 }
700 
701 
709  bool PCB_INSPECTION_TOOL::highlightNet( const VECTOR2D& aPosition, bool aUseSelection )
710 {
711  BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
713  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
714 
715  int net = -1;
716  bool enableHighlight = false;
717 
718  if( aUseSelection )
719  {
720  const PCBNEW_SELECTION& selection = selectionTool->GetSelection();
721 
722  for( auto item : selection )
723  {
724  if( auto ci = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
725  {
726  int item_net = ci->GetNetCode();
727 
728  if( net < 0 )
729  net = item_net;
730  else if( net != item_net ) // more than one net selected: do nothing
731  return false;
732  }
733  }
734 
735  enableHighlight = ( net >= 0 && !settings->GetHighlightNetCodes().count( net ) );
736  }
737 
738  // If we didn't get a net to highlight from the selection, use the cursor
739  if( net < 0 )
740  {
742  GENERAL_COLLECTOR collector;
743 
744  PCB_LAYER_ID activeLayer = static_cast<PCB_LAYER_ID>( view()->GetTopLayer() );
745  guide.SetPreferredLayer( activeLayer );
746 
747  // Find a connected item for which we are going to highlight a net
748  collector.Collect( board, GENERAL_COLLECTOR::PadsOrTracks, (wxPoint) aPosition, guide );
749 
750  if( collector.GetCount() == 0 )
751  collector.Collect( board, GENERAL_COLLECTOR::Zones, (wxPoint) aPosition, guide );
752 
753  // Apply the active selection filter
754  selectionTool->FilterCollectedItems( collector );
755 
756  // Clear the previous highlight
757  m_frame->SendMessageToEESCHEMA( nullptr );
758 
759  bool highContrast = settings->GetHighContrast();
760  PCB_LAYER_ID contrastLayer = settings->GetPrimaryHighContrastLayer();
761 
762  for( int i = collector.GetCount() - 1; i >= 0; i-- )
763  {
764  LSET itemLayers = collector[i]->GetLayerSet();
765 
766  if( ( itemLayers & LSET::AllCuMask() ).none() ||
767  ( highContrast && !itemLayers.Contains( contrastLayer ) ) )
768  {
769  collector.Remove( i );
770  continue;
771  }
772  }
773 
774  enableHighlight = ( collector.GetCount() > 0 );
775 
776  // Obtain net code for the clicked item
777  if( enableHighlight )
778  {
779  BOARD_CONNECTED_ITEM* targetItem = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] );
780 
781  if( targetItem->Type() == PCB_PAD_T )
782  m_frame->SendMessageToEESCHEMA( targetItem );
783 
784  net = targetItem->GetNetCode();
785  }
786  }
787 
788  auto& netcodes = settings->GetHighlightNetCodes();
789 
790  // Toggle highlight when the same net was picked
791  if( net > 0 && netcodes.count( net ) )
792  enableHighlight = !settings->IsHighlightEnabled();
793 
794  if( enableHighlight != settings->IsHighlightEnabled()
795  || !netcodes.count( net ) )
796  {
797  if( !netcodes.empty() )
798  m_lastNetcode = *netcodes.begin();
799 
800  settings->SetHighlight( enableHighlight, net );
802  }
803 
804  // Store the highlighted netcode in the current board (for dialogs for instance)
805  if( enableHighlight && net >= 0 )
806  {
807  board->SetHighLightNet( net );
808  board->HighLightON();
809 
810  NETINFO_ITEM* netinfo = board->FindNet( net );
811 
812  if( netinfo )
813  {
814  MSG_PANEL_ITEMS items;
815  netinfo->GetMsgPanelInfo( m_frame, items );
816  m_frame->SetMsgPanel( items );
818  }
819  }
820  else
821  {
825  }
826 
827  return true;
828 }
829 
830 
832 {
833  int netcode = aEvent.Parameter<intptr_t>();
835  const std::set<int>& highlighted = settings->GetHighlightNetCodes();
836 
837  if( netcode > 0 )
838  {
839  m_lastNetcode = highlighted.empty() ? -1 : *highlighted.begin();
840  settings->SetHighlight( true, netcode );
842  }
843  else if( aEvent.IsAction( &PCB_ACTIONS::toggleLastNetHighlight ) )
844  {
845  int temp = highlighted.empty() ? -1 : *highlighted.begin();
846  settings->SetHighlight( true, m_lastNetcode );
848  m_lastNetcode = temp;
849  }
850  else // Highlight the net belonging to the item under the cursor
851  {
852  highlightNet( getViewControls()->GetMousePosition(), false );
853  }
854 
855  return 0;
856 }
857 
858 
860 {
861  BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
863 
865  settings->SetHighlight( false );
869  return 0;
870 }
871 
872 
874 {
875  std::string tool = aEvent.GetCommandStr().get();
877 
878  // Deactivate other tools; particularly important if another PICKER is currently running
879  Activate();
880 
881  // If the keyboard hotkey was triggered and we are already in the highlight tool, behave
882  // the same as a left-click. Otherwise highlight the net of the selected item(s), or if
883  // there is no selection, then behave like a ctrl-left-click.
885  {
886  bool use_selection = m_frame->IsCurrentTool( PCB_ACTIONS::highlightNetTool );
887  highlightNet( getViewControls()->GetMousePosition(), use_selection );
888  }
889 
890  picker->SetClickHandler(
891  [this] ( const VECTOR2D& pt ) -> bool
892  {
893  highlightNet( pt, false );
894  return true;
895  } );
896 
897  picker->SetLayerSet( LSET::AllCuMask() );
898 
899  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
900 
901  return 0;
902 }
903 
904 
906 {
907  std::string tool = aEvent.GetCommandStr().get();
909  BOARD* board = getModel<BOARD>();
910  auto& opt = displayOptions();
911 
912  // Deactivate other tools; particularly important if another PICKER is currently running
913  Activate();
914 
915  picker->SetClickHandler(
916  [this, board, opt]( const VECTOR2D& pt ) -> bool
917  {
918  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
919 
922  PCBNEW_SELECTION& selection = selectionTool->GetSelection();
923 
924  if( selection.Empty() )
925  {
928  selection = selectionTool->GetSelection();
929  }
930 
931  if( selection.Empty() )
932  {
933  // Clear the previous local ratsnest if we click off all items
934  for( FOOTPRINT* fp : board->Footprints() )
935  {
936  for( PAD* pad : fp->Pads() )
937  pad->SetLocalRatsnestVisible( opt.m_ShowGlobalRatsnest );
938  }
939  }
940  else
941  {
942  for( EDA_ITEM* item : selection )
943  {
944  if( PAD* pad = dyn_cast<PAD*>( item) )
945  {
946  pad->SetLocalRatsnestVisible( !pad->GetLocalRatsnestVisible() );
947  }
948  else if( FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( item) )
949  {
950  if( !fp->Pads().empty() )
951  {
952  bool enable = !fp->Pads()[0]->GetLocalRatsnestVisible();
953 
954  for( PAD* childPad : fp->Pads() )
955  childPad->SetLocalRatsnestVisible( enable );
956  }
957  }
958  }
959  }
960 
962 
963  return true;
964  } );
965 
966  picker->SetFinalizeHandler(
967  [board, opt] ( int aCondition )
968  {
969  if( aCondition != PCBNEW_PICKER_TOOL::END_ACTIVATE )
970  {
971  for( FOOTPRINT* fp : board->Footprints() )
972  {
973  for( PAD* pad : fp->Pads() )
974  pad->SetLocalRatsnestVisible( opt.m_ShowGlobalRatsnest );
975  }
976  }
977  } );
978 
979  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
980 
981  return 0;
982 }
983 
984 
986 {
987  VECTOR2I delta;
988 
989  // If we have passed the simple move vector, we can update without recalculation
990  if( aEvent.Parameter<VECTOR2I*>() )
991  {
992  delta = *aEvent.Parameter<VECTOR2I*>();
993  delete aEvent.Parameter<VECTOR2I*>();
994  }
995  else
996  {
997  // We can delete the existing map to force a recalculation
998  delete m_dynamicData;
999  m_dynamicData = nullptr;
1000  }
1001 
1002  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1003  auto& selection = selectionTool->GetSelection();
1004  auto connectivity = getModel<BOARD>()->GetConnectivity();
1005 
1006  if( selection.Empty() )
1007  {
1008  connectivity->ClearDynamicRatsnest();
1009  delete m_dynamicData;
1010  m_dynamicData = nullptr;
1011  }
1012  else
1013  {
1014  calculateSelectionRatsnest( delta );
1015  }
1016 
1017  return 0;
1018 }
1019 
1020 
1022 {
1023  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1024  delete m_dynamicData;
1025  m_dynamicData = nullptr;
1026 
1027  return 0;
1028 }
1029 
1030 
1032 {
1033  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1034  SELECTION& selection = selectionTool->GetSelection();
1035  std::shared_ptr<CONNECTIVITY_DATA> connectivity = board()->GetConnectivity();
1036  std::vector<BOARD_ITEM*> items;
1037  std::deque<EDA_ITEM*> queued_items( selection.begin(), selection.end() );
1038 
1039  for( std::size_t i = 0; i < queued_items.size(); ++i )
1040  {
1041  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( queued_items[i] );
1042 
1043  if( item->Type() == PCB_FOOTPRINT_T )
1044  {
1045  for( PAD* pad : static_cast<FOOTPRINT*>( item )->Pads() )
1046  {
1047  if( pad->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
1048  items.push_back( pad );
1049  }
1050  }
1051  else if( item->Type() == PCB_GROUP_T )
1052  {
1053  PCB_GROUP *group = static_cast<PCB_GROUP*>( item );
1054  group->RunOnDescendants( [ &queued_items ]( BOARD_ITEM *aItem )
1055  {
1056  queued_items.push_back( aItem );
1057  } );
1058  }
1059  else if( BOARD_CONNECTED_ITEM* boardItem = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
1060  {
1061  if( boardItem->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
1062  items.push_back( boardItem );
1063  }
1064  }
1065 
1066  if( items.empty() || std::none_of( items.begin(), items.end(),
1067  []( const BOARD_ITEM* aItem )
1068  {
1069  return( aItem->Type() == PCB_TRACE_T
1070  || aItem->Type() == PCB_PAD_T
1071  || aItem->Type() == PCB_ARC_T
1072  || aItem->Type() == PCB_ZONE_T
1073  || aItem->Type() == PCB_FOOTPRINT_T
1074  || aItem->Type() == PCB_VIA_T );
1075  } ) )
1076  {
1077  return;
1078  }
1079 
1080  if( !m_dynamicData )
1081  {
1082  m_dynamicData = new CONNECTIVITY_DATA( items, true );
1083  connectivity->BlockRatsnestItems( items );
1084  }
1085  else
1086  {
1087  m_dynamicData->Move( aDelta );
1088  }
1089 
1090  connectivity->ComputeDynamicRatsnest( items, m_dynamicData );
1091 }
1092 
1093 
1095 {
1096  if( m_listNetsDialog == nullptr )
1097  {
1099  std::make_unique<DIALOG_NET_INSPECTOR>( m_frame, m_listNetsDialogSettings );
1100 
1101  m_listNetsDialog->Connect( wxEVT_CLOSE_WINDOW,
1102  wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
1103  this );
1104 
1105  m_listNetsDialog->Connect( wxEVT_BUTTON,
1106  wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr,
1107  this );
1108  }
1109 
1110  m_listNetsDialog->Raise();
1111  m_listNetsDialog->Show( true );
1112  return 0;
1113 }
1114 
1115 
1116 void PCB_INSPECTION_TOOL::onListNetsDialogClosed( wxCommandEvent& event )
1117 {
1119 
1120  m_listNetsDialog->Disconnect( wxEVT_CLOSE_WINDOW,
1121  wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
1122 
1123  m_listNetsDialog->Disconnect( wxEVT_BUTTON,
1124  wxCommandEventHandler( PCB_INSPECTION_TOOL::onListNetsDialogClosed ), nullptr, this );
1125 
1126  m_listNetsDialog->Destroy();
1127  m_listNetsDialog.release();
1128 }
1129 
1130 
1132 {
1133  m_inspectClearanceDialog->Disconnect( wxEVT_CLOSE_WINDOW,
1134  wxCommandEventHandler( PCB_INSPECTION_TOOL::onInspectClearanceDialogClosed ), nullptr, this );
1135 
1136  m_inspectClearanceDialog->Destroy();
1137  m_inspectClearanceDialog.release();
1138 }
1139 
1140 
1142 {
1143  m_inspectConstraintsDialog->Disconnect( wxEVT_CLOSE_WINDOW,
1144  wxCommandEventHandler( PCB_INSPECTION_TOOL::onInspectConstraintsDialogClosed ), nullptr, this );
1145 
1146  m_inspectConstraintsDialog->Destroy();
1147  m_inspectConstraintsDialog.release();
1148 }
1149 
1150 
1152 {
1153  doHideNet( aEvent.Parameter<intptr_t>(), true );
1154  return 0;
1155 }
1156 
1157 
1159 {
1160  doHideNet( aEvent.Parameter<intptr_t>(), false );
1161  return 0;
1162 }
1163 
1164 
1165 void PCB_INSPECTION_TOOL::doHideNet( int aNetCode, bool aHide )
1166 {
1167  KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
1169 
1170  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1171  SELECTION& selection = selectionTool->GetSelection();
1172 
1173  if( aNetCode <= 0 && !selection.Empty() )
1174  {
1175  for( EDA_ITEM* item : selection )
1176  {
1177  if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1178  {
1179  if( bci->GetNetCode() > 0 )
1180  doHideNet( bci->GetNetCode(), aHide );
1181  }
1182  }
1183 
1184  return;
1185  }
1186 
1187  if( aHide )
1188  rs->GetHiddenNets().insert( aNetCode );
1189  else
1190  rs->GetHiddenNets().erase( aNetCode );
1191 
1193  m_frame->GetCanvas()->Refresh();
1194 }
1195 
1196 
1198 {
1202 
1206 
1211 
1219 
1222 }
void SetUnits(EDA_UNITS aUnits)
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
void BuildPolyCourtyards(OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Builds complex polygons of the courtyard areas from graphic items on the courtyard layers.
Definition: footprint.cpp:1776
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 AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Adds a submenu to the menu.
std::set< int > & GetHiddenNets()
Definition: pcb_painter.h:184
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1234
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
Design Rule Checker object that performs all the DRC tests.
Definition: drc_engine.h:78
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon)
Adds a wxWidgets-style entry to the menu.
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:290
bool IsCurrentTool(const TOOL_ACTION &aAction) const
static const TOOL_EVENT SelectedEvent
Definition: actions.h:213
void reportClearance(DRC_CONSTRAINT_TYPE_T aClearanceType, PCB_LAYER_ID aLayer, BOARD_ITEM *aA, BOARD_ITEM *aB, REPORTER *r)
int GetNetCode() const
Function GetNetCode.
void FilterCollectedItems(GENERAL_COLLECTOR &aCollector)
Applies the SELECTION_FILTER_OPTIONS to a collection of items
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to eeschema for highlighting.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:332
ZONES & Zones()
Definition: board.h:289
BOARD * board() const
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
std::unique_ptr< DIALOG_NET_INSPECTOR > m_listNetsDialog
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
wxString GetDesignRulesPath()
Returns the absolute path to the design rules file for the currently-loaded board.
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:214
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:1981
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:43
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:109
WX_HTML_REPORT_BOX.
static TOOL_ACTION hideNet
Definition: pcb_actions.h:447
int InspectClearance(const TOOL_EVENT &aEvent)
Show the clearance resolution for two selected items
virtual EDA_UNITS GetUnits() const
Definition: reporter.h:121
static TOOL_ACTION highlightItem
Definition: pcb_actions.h:446
const wxString & GetName() const
Definition: netclass.h:96
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
PCB_GROUP is 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:560
static TOOL_ACTION boardStatistics
Definition: pcb_actions.h:433
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Creates a functor that tests if the selected items are only of given types.
SELECTION_TOOL.
virtual void Update3DView(bool aReloadRequest, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
virtual NETCLASS * GetNetClass() const
Function GetNetClassPtr returns the NETCLASS for this item.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int InspectConstraints(const TOOL_EVENT &aEvent)
CONDITIONAL_MENU & GetMenu()
Function 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:219
ITER end()
Definition: selection.h:61
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
int HighlightNetTool(const TOOL_EVENT &aEvent)
Launches a tool to pick the item whose net is going to be highlighted.
static ENUM_MAP< T > & Instance()
Definition: property.h:519
TOOL_MENU & GetToolMenu()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
void onInspectConstraintsDialogClosed(wxCommandEvent &aEvent)
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: pad.h:544
wxString getItemDescription(BOARD_ITEM *aItem)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Notifies eeschema about the selected item.
class PAD, a pad in a footprint
Definition: typeinfo.h:90
static const KICAD_T PadsOrTracks[]
A scan list for PADs, TRACKs, or VIAs.
Definition: collectors.h:289
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 TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:451
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
static SELECTION_CONDITION Count(int aNumber)
Creates a functor that tests if the number of selected items is equal to the value given as parameter...
bool IsConnected() const override
const std::unordered_set< BOARD_ITEM * > & GetItems() const
Definition: pcb_group.h:68
static TOOL_ACTION toggleLastNetHighlight
Definition: pcb_actions.h:443
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
int HideNet(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net
EDA_ITEM * GetModel() const
Definition: tool_manager.h:297
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:133
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:201
void RedrawRatsnest()
Forces refresh of the ratsnest visual representation
void onListNetsDialogClosed(wxCommandEvent &aEvent)
int ShowStatisticsDialog(const TOOL_EVENT &aEvent)
Function ShowStatisticDialog()
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
static TOOL_ACTION inspectConstraints
Definition: pcb_actions.h:437
PAD_ATTR_T GetAttribute() const
Definition: pad.h:348
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
void doHideNet(int aNetCode, bool aHide)
static TOOL_ACTION pickerTool
Definition: actions.h:158
int GetThermalReliefGap() const
Definition: zone.h:190
virtual PCB_LAYER_ID GetActiveLayer() const
static TOOL_ACTION highlightNetTool
Definition: pcb_actions.h:444
PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:64
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:104
FP_ZONES & Zones()
Definition: footprint.h:188
ITER begin()
Definition: selection.h:60
PCB_EDIT_FRAME * m_frame
PCB_LAYER_ID
A quick note on layer IDs:
void SetPreferredLayer(PCB_LAYER_ID aLayer)
Definition: collectors.h:504
void reportZoneConnection(ZONE *aZone, PAD *aPad, REPORTER *r)
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
Generic tool for picking a point.
LSET is a set of PCB_LAYER_IDs.
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:1959
pads are covered by copper
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
Function ShowBoardSetupDialog.
const PCBNEW_SELECTION & selection() const
std::unique_ptr< DIALOG_INSPECTION_REPORTER > m_inspectClearanceDialog
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:571
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, SELECTION_TOOL *sTool)
Function FootprintFilter() A selection filter which prunes the selection to contain only items of typ...
Definition: edit_tool.cpp:1735
int GetLocalClearance(wxString *aSource) const override
Function GetLocalClearance returns any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.cpp:491
int HighlightItem(const TOOL_EVENT &aEvent)
Performs the appropriate action in response to an eeschema cross-probe.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
FOOTPRINTS & Footprints()
Definition: board.h:283
void SetIcon(const BITMAP_OPAQUE *aIcon)
Assigns an icon for the entry.
Definition: action_menu.cpp:71
TOOL_EVENT.
Definition: tool_event.h:171
FOOTPRINT * footprint() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:382
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
Function GetNetname.
Definition: netinfo.h:231
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
static const TOOL_EVENT ClearedEvent
Definition: actions.h:215
CONNECTIVITY_DATA * m_dynamicData
#define MALFORMED_COURTYARDS
Definition: eda_item.h:124
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:106
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
Recalculates dynamic ratsnest for the current selection
void RunOnDescendants(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invokes a function on all descendents of the group.
Definition: pcb_group.cpp:326
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:1968
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:104
static TOOL_ACTION hideDynamicRatsnest
Definition: pcb_actions.h:452
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
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:120
Thermal relief only for THT pads.
static TOOL_ACTION inspectClearance
Definition: pcb_actions.h:436
const PCB_DISPLAY_OPTIONS & displayOptions() const
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION clearHighlight
Definition: pcb_actions.h:441
int HideDynamicRatsnest(const TOOL_EVENT &aEvent)
Hides ratsnest for selected items. Called when there are no items selected.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
Use thermal relief for pads.
EDA_UNITS GetUnits() const override
void SendMessageToEESCHEMA(BOARD_ITEM *objectToSync)
Function SendMessageToEESCHEMA sends a message to the schematic editor so that it may move its cursor...
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter Returns pointer to current settings that are going to be used when drawing items.
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
static TOOL_ACTION showNet
Definition: pcb_actions.h:448
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
void SetTitle(const wxString &aTitle) override
Sets title for the menu.
Definition: action_menu.cpp:89
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:442
static TOOL_ACTION highlightNetSelection
Definition: pcb_actions.h:445
std::unique_ptr< DIALOG_CONSTRAINTS_REPORTER > m_inspectConstraintsDialog
DRC_CONSTRAINT_TYPE_T
Definition: drc_rule.h:41
void setTransitions() override
Bind handlers to corresponding TOOL_ACTIONs
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
void SetLayerSet(LSET aLayerSet)
Function SetLayerSet() Sets the tool's snap layer set.
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
Shows local ratsnest of a component
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION listNets
Definition: pcb_actions.h:337
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:241
DIALOG_BOARD_STATISTIC.
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: eda_item.cpp:123
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Function CreateSubMenu.
Definition: tool_menu.cpp:52
static void PadFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, SELECTION_TOOL *sTool)
Function PadFilter() A selection filter which prunes the selection to contain only items of type PCB_...
Definition: edit_tool.cpp:1723
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
Plated through hole pad.
Definition: pad_shapes.h:80
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
static TOOL_ACTION runDRC
Definition: pcb_actions.h:338
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
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 a Error icon on the left of...
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings
int ListNets(const TOOL_EVENT &aEvent)
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:220
void Activate()
Function Activate() Runs the tool.
virtual bool IsConnected() const
Function IsConnected() Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:146
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
void onInspectClearanceDialogClosed(wxCommandEvent &aEvent)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:76
const std::set< int > & GetHighlightNetCodes() const
Function GetHighlightNetCode Returns netcode of currently highlighted net.
static TOOL_ACTION updateLocalRatsnest
Definition: pcb_actions.h:453
BOARD * GetBoard() const
int ClearHighlight(const TOOL_EVENT &aEvent)
Clears all board highlights
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:376
ZONE_CONNECTION GetPadConnection(PAD *aPad, wxString *aSource=nullptr) const
Definition: zone.cpp:770
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo returns the information about the NETINFO_ITEM in aList to display in the me...
Definition: pad.h:59
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:776
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:341
STATUS_FLAGS GetFlags() const
Definition: eda_item.h:222
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
Definition: board_item.h:185
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:59
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
void InitEngine(const wxFileName &aRulePath)
Initializes the DRC engine.
Definition: drc_engine.cpp:595
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
int ShowNet(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net
virtual LSET GetLayerSet() const
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:191
EDA_ITEM * Front() const
Definition: selection.h:201
const wxString & ToString(T value) const
Definition: property.h:538
ACTION_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes.
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
const BITMAP_OPAQUE ratsnest_xpm[1]
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.