KiCad PCB EDA Suite
dialog_drc.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com
6  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <bitmaps.h>
27 #include <confirm.h>
28 #include <dialog_drc.h>
29 #include <fctsys.h>
30 #include <kiface_i.h>
31 #include <pcb_edit_frame.h>
32 #include <pcbnew_settings.h>
33 #include <pgm_base.h>
34 #include <tool/tool_manager.h>
35 #include <tools/pcb_actions.h>
37 #include <class_marker_pcb.h>
38 #include <wx/wupdlock.h>
40 #include <widgets/ui_common.h>
42 #include <drc/drc_engine.h>
44 #include <tools/drc_tool.h>
45 #include <kiplatform/ui.h>
46 
47 DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
48  DIALOG_DRC_BASE( aParent ),
49  PROGRESS_REPORTER( 1 ),
50  m_running( false ),
51  m_cancelled( false ),
52  m_drcRun( false ),
53  m_footprintTestsRun( false ),
54  m_markersProvider( nullptr ),
55  m_markerTreeModel( nullptr ),
56  m_unconnectedItemsProvider( nullptr ),
57  m_unconnectedTreeModel( nullptr ),
58  m_footprintWarningsProvider( nullptr ),
59  m_footprintWarningsTreeModel( nullptr ),
61 {
62  SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it
63 
64  m_brdEditor = aEditorFrame;
66 
68  m_markerDataView->AssociateModel( m_markerTreeModel );
69 
72 
75 
76  if( Kiface().IsSingle() )
77  m_cbTestFootprints->Hide();
78 
79  // We use a sdbSizer here to get the order right, which is platform-dependent
80  m_sdbSizerOK->SetLabel( _( "Run DRC" ) );
81  m_sdbSizerCancel->SetLabel( _( "Close" ) );
82  m_sizerButtons->Layout();
83 
84  m_sdbSizerOK->SetDefault();
85 
86  initValues();
88 
90 }
91 
92 
94 {
95  m_brdEditor->FocusOnItem( nullptr );
96 
98  settings->m_DrcDialog.refill_zones = m_cbRefillZones->GetValue();
101 
102  if( !Kiface().IsSingle() )
103  settings->m_DrcDialog.test_footprints = m_cbTestFootprints->GetValue();
104 
105  settings->m_DrcDialog.severities = m_severities;
106 
107  m_markerTreeModel->DecRef();
108 }
109 
110 
111 void DIALOG_DRC::OnActivateDlg( wxActivateEvent& aEvent )
112 {
114  {
115  // If m_currentBoard is not the current board, (for instance because a new board
116  // was loaded), close the dialog, because many pointers are now invalid in lists
117  SetReturnCode( wxID_CANCEL );
118  Close();
119 
121  drcTool->DestroyDRCDialog();
122 
123  return;
124  }
125 
130 }
131 
132 
134 {
135  m_markersTitleTemplate = m_Notebook->GetPageText( 0 );
136  m_unconnectedTitleTemplate = m_Notebook->GetPageText( 1 );
137  m_footprintsTitleTemplate = m_Notebook->GetPageText( 2 );
138 
139  auto cfg = m_brdEditor->GetPcbNewSettings();
140 
141  m_cbRefillZones->SetValue( cfg->m_DrcDialog.refill_zones );
142  m_cbReportTracksToZonesErrors->SetValue( cfg->m_DrcDialog.test_track_to_zone );
143  m_cbReportAllTrackErrors->SetValue( cfg->m_DrcDialog.test_all_track_errors );
144 
145  if( Kiface().IsSingle() )
146  m_cbTestFootprints->SetValue( cfg->m_DrcDialog.test_footprints );
147 
148  m_severities = cfg->m_DrcDialog.severities;
152 
153  Layout(); // adding the units above expanded Clearance text, now resize.
154 
155  SetFocus();
156 }
157 
158 
159 // PROGRESS_REPORTER calls
160 
162 {
163  double cur = (double) m_progress.load() / m_maxProgress;
164  cur = std::max( 0.0, std::min( cur, 1.0 ) );
165 
166  m_gauge->SetValue( KiROUND( cur * 1000.0 ) );
167  wxSafeYield( this );
168 
169  return !m_cancelled;
170 }
171 
172 
173 void DIALOG_DRC::AdvancePhase( const wxString& aMessage )
174 {
176  SetCurrentProgress( 0.0 );
177 
178  m_Messages->AppendText( aMessage + "\n" );
179 }
180 
181 
182 void DIALOG_DRC::SetCurrentProgress( double aProgress )
183 {
185 }
186 
187 
188 // Don't globally define this; different facilities use different definitions of "ALL"
190 
191 
193 {
194  m_showAll->SetValue( m_severities == RPT_SEVERITY_ALL );
198 }
199 
200 
201 void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
202 {
204  bool testTracksAgainstZones = m_cbReportTracksToZonesErrors->GetValue();
205  bool refillZones = m_cbRefillZones->GetValue();
206  bool reportAllTrackErrors = m_cbReportAllTrackErrors->GetValue();
207  bool testFootprints = m_cbTestFootprints->GetValue();
208 
209  // This is not the time to have stale or buggy rules. Ensure they're up-to-date
210  // and that they at least parse.
211  try
212  {
213  drcTool->GetDRCEngine()->InitEngine( m_brdEditor->GetDesignRulesPath() );
214  }
215  catch( PARSE_ERROR& pe )
216  {
217  // Shouldn't be necessary, but we get into all kinds of wxWidgets window ordering
218  // issues (on at least OSX) if we don't.
219  drcTool->DestroyDRCDialog();
220 
222  pe.lineNumber, pe.byteIndex );
223 
224  return;
225  }
226 
227  m_drcRun = false;
228  m_footprintTestsRun = false;
229  m_cancelled = false;
230 
232  deleteAllMarkers( true );
233  m_unconnectedTreeModel->DeleteItems( false, true, true );
234  m_footprintWarningsTreeModel->DeleteItems( false, true, true );
235 
236  Raise();
237 
238  m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
239  m_Messages->Clear();
240  wxYield(); // Allow time slice to refresh Messages
241 
242  m_running = true;
243  m_sdbSizerCancel->SetLabel( _( "Cancel" ) );
244  m_sdbSizerOK->Enable( false );
245  m_DeleteCurrentMarkerButton->Enable( false );
246  m_DeleteAllMarkersButton->Enable( false );
247  m_saveReport->Enable( false );
248 
249  drcTool->RunTests( this, testTracksAgainstZones, refillZones, reportAllTrackErrors,
250  testFootprints );
251 
252  if( m_cancelled )
253  m_Messages->AppendText( _( "-------- DRC cancelled by user.\n\n" ) );
254  else
255  m_Messages->AppendText( _( "Done.\n\n" ) );
256 
257  Raise();
258  wxYield(); // Allow time slice to refresh Messages
259 
260  m_running = false;
261  m_sdbSizerCancel->SetLabel( _( "Close" ) );
262  m_sdbSizerOK->Enable( true );
263  m_DeleteCurrentMarkerButton->Enable( true );
264  m_DeleteAllMarkersButton->Enable( true );
265  m_saveReport->Enable( true );
266 
267  if( !m_cancelled )
268  {
269  wxMilliSleep( 500 );
270  m_runningResultsBook->ChangeSelection( 1 );
272  }
273 
275 }
276 
277 
279 {
280  m_markersProvider = aProvider;
283 }
284 
285 
287 {
288  m_unconnectedItemsProvider = aProvider;
291 }
292 
293 
295 {
296  m_footprintWarningsProvider = aProvider;
299 }
300 
301 
302 void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent )
303 {
304  BOARD* board = m_brdEditor->GetBoard();
305  RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
306  const KIID& itemID = node ? RC_TREE_MODEL::ToUUID( aEvent.GetItem() ) : niluuid;
307  BOARD_ITEM* item = board->GetItem( itemID );
308 
309  if( item )
310  {
311  PCB_LAYER_ID principalLayer = item->GetLayer();
312  std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
313  BOARD_ITEM* a = board->GetItem( rc_item->GetMainItemID() );
314  BOARD_ITEM* b = board->GetItem( rc_item->GetAuxItemID() );
315  BOARD_ITEM* c = board->GetItem( rc_item->GetAuxItem2ID() );
316  BOARD_ITEM* d = board->GetItem( rc_item->GetAuxItem3ID() );
317 
318  LSET violationLayers;
319 
320  if( a )
321  violationLayers &= a->GetLayerSet();
322 
323  if( b )
324  violationLayers &= b->GetLayerSet();
325 
326  if( c )
327  violationLayers &= c->GetLayerSet();
328 
329  if( d )
330  violationLayers &= d->GetLayerSet();
331 
332  if( violationLayers.count() )
333  principalLayer = violationLayers.Seq().front();
334  else
335  violationLayers.set( principalLayer );
336 
337  WINDOW_THAWER thawer( m_brdEditor );
338 
339  m_brdEditor->FocusOnItem( item );
341 
342  if( ( violationLayers & board->GetVisibleLayers() ) == 0 )
343  {
344  m_brdEditor->GetAppearancePanel()->SetLayerVisible( item->GetLayer(), true );
346  }
347 
348  if( board->GetVisibleLayers().test( principalLayer ) )
349  m_brdEditor->SetActiveLayer( principalLayer );
350  }
351 
352  aEvent.Skip();
353 }
354 
355 
356 void DIALOG_DRC::OnDRCItemDClick( wxDataViewEvent& aEvent )
357 {
358  if( aEvent.GetItem().IsOk() )
359  {
360  // turn control over to m_brdEditor, hide this DIALOG_DRC window,
361  // no destruction so we can preserve listbox cursor
362  if( !IsModal() )
363  Show( false );
364  }
365 
366  aEvent.Skip();
367 }
368 
369 
370 void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
371 {
372  RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
373 
374  if( !node )
375  return;
376 
377  std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
378  wxString listName;
379  wxMenu menu;
380  wxString msg;
381 
382  switch( bds().m_DRCSeverities[ rcItem->GetErrorCode() ] )
383  {
384  case RPT_SEVERITY_ERROR: listName = _( "errors" ); break;
385  case RPT_SEVERITY_WARNING: listName = _( "warnings" ); break;
386  default: listName = _( "appropriate" ); break;
387  }
388 
389  if( rcItem->GetParent()->IsExcluded() )
390  {
391  menu.Append( 1, _( "Remove exclusion for this violation" ),
392  wxString::Format( _( "It will be placed back in the %s list" ), listName ) );
393  }
394  else
395  {
396  menu.Append( 2, _( "Exclude this violation" ),
397  wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
398  }
399 
400  menu.AppendSeparator();
401 
402  if( bds().m_DRCSeverities[ rcItem->GetErrorCode() ] == RPT_SEVERITY_WARNING )
403  {
404  msg.Printf( _( "Change severity to Error for all '%s' violations" ),
405  rcItem->GetErrorText(),
406  _( "Violation severities can also be edited in the Board Setup... dialog" ) );
407  menu.Append( 3, msg );
408  }
409  else
410  {
411  msg.Printf( _( "Change severity to Warning for all '%s' violations" ),
412  rcItem->GetErrorText(),
413  _( "Violation severities can also be edited in the Board Setup... dialog" ) );
414  menu.Append( 4, msg );
415  }
416 
417  msg.Printf( _( "Ignore all '%s' violations" ),
418  rcItem->GetErrorText(),
419  _( "Violations will not be checked or reported" ) );
420  menu.Append( 5, msg );
421 
422  menu.AppendSeparator();
423 
424  menu.Append( 6, _( "Edit violation severities..." ), _( "Open the Board Setup... dialog" ) );
425 
426  bool modified = false;
427 
428  switch( GetPopupMenuSelectionFromUser( menu ) )
429  {
430  case 1:
431  {
432  MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() );
433 
434  if( marker )
435  {
436  marker->SetExcluded( false );
437  m_brdEditor->GetCanvas()->GetView()->Update( marker );
438 
439  // Update view
440  static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
441  modified = true;
442  }
443  }
444  break;
445 
446  case 2:
447  {
448  MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() );
449 
450  if( marker )
451  {
452  marker->SetExcluded( true );
453  m_brdEditor->GetCanvas()->GetView()->Update( marker );
454 
455  // Update view
457  static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
458  else
459  static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false );
460 
461  modified = true;
462  }
463  }
464  break;
465 
466  case 3:
467  bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_ERROR;
468 
469  for( MARKER_PCB* marker : m_brdEditor->GetBoard()->Markers() )
470  {
471  if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
472  m_brdEditor->GetCanvas()->GetView()->Update( marker );
473  }
474 
475  // Rebuild model and view
476  static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider );
477  modified = true;
478  break;
479 
480  case 4:
481  bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_WARNING;
482 
483  for( MARKER_PCB* marker : m_brdEditor->GetBoard()->Markers() )
484  {
485  if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
486  m_brdEditor->GetCanvas()->GetView()->Update( marker );
487  }
488 
489  // Rebuild model and view
490  static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider );
491  modified = true;
492  break;
493 
494  case 5:
495  {
496  bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_IGNORE;
497 
498  std::vector<MARKER_PCB*>& markers = m_brdEditor->GetBoard()->Markers();
499 
500  for( unsigned i = 0; i < markers.size(); )
501  {
502  if( markers[i]->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
503  {
504  m_brdEditor->GetCanvas()->GetView()->Remove( markers.at( i ) );
505  markers.erase( markers.begin() + i );
506  }
507  else
508  ++i;
509  }
510 
511  // Rebuild model and view
512  static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider );
513  modified = true;
514  }
515  break;
516 
517  case 6:
518  m_brdEditor->ShowBoardSetupDialog( _( "Violation Severity" ) );
519  break;
520  }
521 
522  if( modified )
523  {
527  }
528 }
529 
530 
531 void DIALOG_DRC::OnSeverity( wxCommandEvent& aEvent )
532 {
533  int flag = 0;
534 
535  if( aEvent.GetEventObject() == m_showAll )
536  flag = RPT_SEVERITY_ALL;
537  else if( aEvent.GetEventObject() == m_showErrors )
538  flag = RPT_SEVERITY_ERROR;
539  else if( aEvent.GetEventObject() == m_showWarnings )
540  flag = RPT_SEVERITY_WARNING;
541  else if( aEvent.GetEventObject() == m_showExclusions )
542  flag = RPT_SEVERITY_EXCLUSION;
543 
544  if( aEvent.IsChecked() )
545  m_severities |= flag;
546  else if( aEvent.GetEventObject() == m_showAll )
548  else
549  m_severities &= ~flag;
550 
551  syncCheckboxes();
552 
553  // Set the provider's severity levels through the TreeModel so that the old tree
554  // can be torn down before the severity changes.
555  //
556  // It's not clear this is required, but we've had a lot of issues with wxDataView
557  // being cranky on various platforms.
558 
562 
564 }
565 
566 
567 void DIALOG_DRC::OnSaveReport( wxCommandEvent& aEvent )
568 {
569  wxFileName fn( "./DRC." + ReportFileExtension );
570 
571  wxFileDialog dlg( this, _( "Save Report to File" ), fn.GetPath(), fn.GetFullName(),
572  ReportFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
573 
574  if( dlg.ShowModal() != wxID_OK )
575  return;
576 
577  fn = dlg.GetPath();
578 
579  if( fn.GetExt().IsEmpty() )
580  fn.SetExt( ReportFileExtension );
581 
582  if( !fn.IsAbsolute() )
583  {
584  wxString prj_path = Prj().GetProjectPath();
585  fn.MakeAbsolute( prj_path );
586  }
587 
588  if( writeReport( fn.GetFullPath() ) )
589  {
590  m_Messages->AppendText( wxString::Format( _( "Report file '%s' created\n" ),
591  fn.GetFullPath() ) );
592  }
593  else
594  {
595  DisplayError( this, wxString::Format( _( "Unable to create report file '%s'" ),
596  fn.GetFullPath() ) );
597  }
598 }
599 
600 
601 void DIALOG_DRC::OnClose( wxCloseEvent& aEvent )
602 {
603  if( m_running )
604  aEvent.Veto();
605 
606  wxCommandEvent dummy;
607 
608  OnCancelClick( dummy );
609 }
610 
611 
612 void DIALOG_DRC::OnCancelClick( wxCommandEvent& aEvent )
613 {
614  if( m_running )
615  {
616  m_cancelled = true;
617  return;
618  }
619 
620  m_brdEditor->FocusOnItem( nullptr );
621 
622  SetReturnCode( wxID_CANCEL );
623 
624  // The dialog can be modal or not modal.
625  // Leave the DRC caller destroy (or not) the dialog
627  drcTool->DestroyDRCDialog();
628 }
629 
630 
631 void DIALOG_DRC::OnChangingNotebookPage( wxNotebookEvent& aEvent )
632 {
633  // Shouldn't be necessary, but is on at least OSX
634  if( aEvent.GetSelection() >= 0 )
635  m_Notebook->ChangeSelection( (unsigned) aEvent.GetSelection() );
636 
637  m_markerDataView->UnselectAll();
638  m_unconnectedDataView->UnselectAll();
639  m_footprintsDataView->UnselectAll();
640 }
641 
642 
644 {
645  WINDOW_THAWER thawer( m_brdEditor );
646 
648 }
649 
650 
651 void DIALOG_DRC::deleteAllMarkers( bool aIncludeExclusions )
652 {
653  // Clear current selection list to avoid selection of deleted items
655 
656  m_markerTreeModel->DeleteItems( false, aIncludeExclusions, true );
657 }
658 
659 
660 bool DIALOG_DRC::writeReport( const wxString& aFullFileName )
661 {
662  FILE* fp = wxFopen( aFullFileName, wxT( "w" ) );
663 
664  if( fp == NULL )
665  return false;
666 
667  std::map<KIID, EDA_ITEM*> itemMap;
668  m_brdEditor->GetBoard()->FillItemMap( itemMap );
669 
670  EDA_UNITS units = GetUserUnits();
672  int count;
673 
674  fprintf( fp, "** Drc report for %s **\n", TO_UTF8( m_brdEditor->GetBoard()->GetFileName() ) );
675 
676  wxDateTime now = wxDateTime::Now();
677 
678  fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) );
679 
680  count = m_markersProvider->GetCount();
681 
682  fprintf( fp, "\n** Found %d DRC violations **\n", count );
683 
684  for( int i = 0; i < count; ++i )
685  {
686  const std::shared_ptr<RC_ITEM>& item = m_markersProvider->GetItem( i );
687  SEVERITY severity = (SEVERITY) bds.GetSeverity( item->GetErrorCode() );
688 
689  fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
690  }
691 
693 
694  fprintf( fp, "\n** Found %d unconnected pads **\n", count );
695 
696  for( int i = 0; i < count; ++i )
697  {
698  const std::shared_ptr<RC_ITEM>& item = m_unconnectedItemsProvider->GetItem( i );
699  SEVERITY severity = (SEVERITY) bds.GetSeverity( item->GetErrorCode() );
700 
701  fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
702  }
703 
705 
706  fprintf( fp, "\n** Found %d Footprint errors **\n", count );
707 
708  for( int i = 0; i < count; ++i )
709  {
710  const std::shared_ptr<RC_ITEM>& item = m_footprintWarningsProvider->GetItem( i );
711  SEVERITY severity = (SEVERITY) bds.GetSeverity( item->GetErrorCode() );
712 
713  fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) );
714  }
715 
716 
717  fprintf( fp, "\n** End of Report **\n" );
718 
719  fclose( fp );
720 
721  return true;
722 }
723 
724 
725 void DIALOG_DRC::OnDeleteOneClick( wxCommandEvent& aEvent )
726 {
727  if( m_Notebook->GetSelection() == 0 )
728  {
729  // Clear the selection. It may be the selected DRC marker.
731 
733 
734  // redraw the pcb
736  }
737  else if( m_Notebook->GetSelection() == 1 )
738  {
740  }
741  else if( m_Notebook->GetSelection() == 2 )
742  {
744  }
745 
747 }
748 
749 
750 void DIALOG_DRC::OnDeleteAllClick( wxCommandEvent& aEvent )
751 {
752  static bool s_includeExclusions = false;
753 
754  int numExcluded = 0;
755 
756  if( m_markersProvider )
758 
761 
764 
765  if( numExcluded > 0 )
766  {
767  wxRichMessageDialog dlg( this, _( "Do you wish to delete excluded markers as well?" ),
768  _( "Delete All Markers" ),
769  wxOK | wxCANCEL | wxCENTER | wxICON_QUESTION );
770  dlg.ShowCheckBox( _( "Delete exclusions" ), s_includeExclusions );
771 
772  int ret = dlg.ShowModal();
773 
774  if( ret == wxID_CANCEL )
775  return;
776  else
777  s_includeExclusions = dlg.IsCheckBoxChecked();
778  }
779 
780  deleteAllMarkers( s_includeExclusions );
781 
782  m_drcRun = false;
785 }
786 
787 
789 {
790  wxString msg;
791 
792  // First the tab headers:
793  //
794 
795  if( m_drcRun )
796  {
798  m_Notebook->SetPageText( 0, msg );
799 
801  m_Notebook->SetPageText( 1, msg );
802 
803  if( m_footprintTestsRun )
805  else
806  {
808  msg.Replace( wxT( "%d" ), _( "not run" ) );
809  }
810  m_Notebook->SetPageText( 2, msg );
811  }
812  else
813  {
815  msg.Replace( wxT( "(%d)" ), wxEmptyString );
816  m_Notebook->SetPageText( 0, msg );
817 
819  msg.Replace( wxT( "(%d)" ), wxEmptyString );
820  m_Notebook->SetPageText( 1, msg );
821 
823  msg.Replace( wxT( "(%d)" ), wxEmptyString );
824  m_Notebook->SetPageText( 2, msg );
825  }
826 
827  // And now the badges:
828  //
829 
830  int numErrors = 0;
831  int numWarnings = 0;
832  int numExcluded = 0;
833 
834  if( m_markersProvider )
835  {
839  }
840 
842  {
846  }
847 
849  {
853  }
854 
855  if( !m_drcRun )
856  {
857  numErrors = -1;
858  numWarnings = -1;
859  }
860 
861  m_errorsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_ERROR, numErrors, m_errorsBadge ) );
862  m_warningsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_WARNING, numWarnings, m_warningsBadge ) );
864 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
wxCheckBox * m_showWarnings
void initValues()
Definition: dialog_drc.cpp:133
virtual void AdvancePhase()
Uses the next vailable virtual zone of the dialog progress bar.
EDA_UNITS
Definition: common.h:198
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
void DeleteItems(bool aCurrentOnly, bool aIncludeExclusions, bool aDeep)
Deletes the current item or all items.
Definition: rc_item.cpp:424
void syncCheckboxes()
Definition: dialog_drc.cpp:192
wxCheckBox * m_cbTestFootprints
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
wxNotebook * m_Notebook
void updateDisplayedCounts()
Definition: dialog_drc.cpp:788
BOARD_DESIGN_SETTINGS & bds()
Definition: dialog_drc.h:102
static int RPT_SEVERITY_ALL
Definition: dialog_drc.cpp:189
void OnDRCItemRClick(wxDataViewEvent &aEvent) override
Definition: dialog_drc.cpp:370
void SetProvider(RC_ITEMS_PROVIDER *aProvider)
Definition: rc_item.cpp:257
wxCheckBox * m_cbReportAllTrackErrors
void deleteAllMarkers(bool aIncludeExclusions)
Definition: dialog_drc.cpp:651
wxButton * m_DeleteCurrentMarkerButton
wxString GetDesignRulesPath()
Returns the absolute path to the design rules file for the currently-loaded board.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
This file is part of the common library.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
RC_TREE_MODEL * m_markerTreeModel
Definition: dialog_drc.h:116
Class DIALOG_DRC_BASE.
SEVERITY
Definition: ui_common.h:45
A progress reporter for use in multi-threaded environments.
std::atomic_int m_progress
PCB_EDIT_FRAME * m_brdEditor
Definition: dialog_drc.h:105
wxSimplebook * m_runningResultsBook
MARKERS & Markers()
Definition: class_board.h:255
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool writeReport(const wxString &aFullFileName)
Function writeReport outputs the MARKER items and unconnecte DRC_ITEMs with commentary to an open tex...
Definition: dialog_drc.cpp:660
void refreshBoardEditor()
Definition: dialog_drc.cpp:643
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void OnDeleteOneClick(wxCommandEvent &aEvent) override
Definition: dialog_drc.cpp:725
bool m_footprintTestsRun
Definition: dialog_drc.h:109
wxString m_footprintsTitleTemplate
Definition: dialog_drc.h:113
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings Returns a bit-mask of all t...
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:514
virtual int GetCount(int aSeverity=-1)=0
wxButton * m_sdbSizerCancel
static KIID ToUUID(wxDataViewItem aItem)
Definition: rc_item.cpp:118
wxStaticBitmap * m_errorsBadge
RC_ITEMS_PROVIDER * m_markersProvider
Definition: dialog_drc.h:115
PCBNEW_SETTINGS * GetPcbNewSettings()
void OnDRCItemDClick(wxDataViewEvent &aEvent) override
Definition: dialog_drc.cpp:356
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:410
const wxString & GetFileName() const
Definition: class_board.h:242
BOARD_ITEM * GetItem(const KIID &aID)
BOARD * m_currentBoard
Definition: dialog_drc.h:104
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:124
virtual std::shared_ptr< RC_ITEM > GetItem(int aIndex)=0
Function GetItem retrieves a RC_ITEM by index.
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:76
void DeleteCurrentItem(bool aDeep)
Definition: rc_item.cpp:418
void SetSeverities(int aSeverities)
Definition: rc_item.cpp:263
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:43
void OnChangingNotebookPage(wxNotebookEvent &aEvent) override
Definition: dialog_drc.cpp:631
EDA_UNITS GetUserUnits() const
Definition: dialog_shim.h:131
RC_ITEMS_PROVIDER * m_unconnectedItemsProvider
Definition: dialog_drc.h:118
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:100
wxCheckBox * m_showExclusions
Definition: common.h:68
wxString m_markersTitleTemplate
Definition: dialog_drc.h:111
Markers used to show a drc problem on boards.
virtual void SetCurrentProgress(double aProgress)
Set the progress value to aProgress (0..1)
int GetDRCItemCount() const
Definition: rc_item.h:233
PCB_LAYER_ID
A quick note on layer IDs:
wxCheckBox * m_cbRefillZones
LSET is a set of PCB_LAYER_IDs.
wxStaticBitmap * m_warningsBadge
void SetExcluded(bool aExcluded)
Definition: marker_base.h:110
std::shared_ptr< RC_ITEM > m_RcItem
Definition: rc_item.h:202
wxDataViewCtrl * m_footprintsDataView
#define NULL
RC_ITEMS_PROVIDER * m_footprintWarningsProvider
Definition: dialog_drc.h:121
wxBoxSizer * m_sizerButtons
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
wxButton * m_DeleteAllMarkersButton
wxButton * m_sdbSizerOK
void OnDeleteAllClick(wxCommandEvent &aEvent) override
Definition: dialog_drc.cpp:750
static RC_TREE_NODE * ToNode(wxDataViewItem aItem)
Definition: rc_item.h:217
int lineNumber
at which line number, 1 based index.
Definition: ki_exception.h:125
wxString ReportFileWildcard()
void OnDRCItemSelected(wxDataViewEvent &aEvent) override
Definition: dialog_drc.cpp:302
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
DIALOG_DRC(PCB_EDIT_FRAME *aEditorFrame, wxWindow *aParent)
Constructors.
Definition: dialog_drc.cpp:47
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
RC_TREE_MODEL * m_footprintWarningsTreeModel
Definition: dialog_drc.h:122
KIID niluuid(0)
void SetFootprintsProvider(RC_ITEMS_PROVIDER *aProvider)
Definition: dialog_drc.cpp:294
std::atomic< bool > m_cancelled
Definition: dialog_drc.h:107
Definition of file extensions used in Kicad.
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:43
Functions to provide common constants and other functions to assist in making a consistent UI.
void OnClose(wxCloseEvent &event) override
Definition: dialog_drc.cpp:601
std::shared_ptr< DRC_ENGINE > GetDRCEngine()
Definition: drc_tool.h:113
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void OnRunDRCClick(wxCommandEvent &aEvent) override
Definition: dialog_drc.cpp:201
std::map< int, int > m_DRCSeverities
bool Show(bool show) override
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...
RC_TREE_MODEL * m_unconnectedTreeModel
Definition: dialog_drc.h:119
wxDataViewCtrl * m_unconnectedDataView
void OnCancelClick(wxCommandEvent &aEvent) override
Definition: dialog_drc.cpp:612
wxButton * m_saveReport
void SetMarkersProvider(RC_ITEMS_PROVIDER *aProvider)
Definition: dialog_drc.cpp:278
wxDataViewCtrl * m_markerDataView
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
#define ID_RULES_EDITOR
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
const std::string ReportFileExtension
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition: gtk/ui.cpp:34
wxBitmap MakeBadge(SEVERITY aStyle, int aCount, wxWindow *aWindow, int aDepth)
Definition: ui_common.cpp:36
#define _(s)
Definition: 3d_actions.cpp:33
wxStaticBitmap * m_exclusionsBadge
wxCheckBox * m_showErrors
wxCheckBox * m_cbReportTracksToZonesErrors
wxCheckBox * m_showAll
PCB_EDIT_FRAME is the main frame for Pcbnew.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
int byteIndex
at which byte offset within the line, 1 based index
Definition: ki_exception.h:126
void OnActivateDlg(wxActivateEvent &aEvent) override
Definition: dialog_drc.cpp:111
bool m_drcRun
Definition: dialog_drc.h:108
void RunTests(PROGRESS_REPORTER *aProgressReporter, bool aTestTracksAgainstZones, bool aRefillZones, bool aReportAllTrackErrors, bool aTestFootprints)
Run the DRC tests.
Definition: drc_tool.cpp:130
int m_severities
Definition: dialog_drc.h:124
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
Manually update visibility for a given layer
std::atomic_int m_maxProgress
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:78
APPEARANCE_CONTROLS * GetAppearancePanel()
void SetCurrentProgress(double aProgress) override
Set the progress value to aProgress (0..1)
Definition: dialog_drc.cpp:182
DIALOG_DRC m_DrcDialog
BOARD * GetBoard() const
void DestroyDRCDialog()
Closes and frees the DRC dialog.
Definition: drc_tool.cpp:120
int GetSeverity(int aDRCErrorCode)
void OnSaveReport(wxCommandEvent &aEvent) override
Definition: dialog_drc.cpp:567
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool m_running
Definition: dialog_drc.h:106
bool updateUI() override
Definition: dialog_drc.cpp:161
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
void FocusOnItem(BOARD_ITEM *aItem)
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString, const wxString &aErrorMsg=wxEmptyString, int aErrorCtrlId=-1, int aErrorLine=-1, int aErrorCol=-1)
Function ShowBoardSetupDialog.
void SetUnconnectedProvider(RC_ITEMS_PROVIDER *aProvider)
Definition: dialog_drc.cpp:286
wxTextCtrl * m_Messages
wxString m_unconnectedTitleTemplate
Definition: dialog_drc.h:112
virtual LSET GetLayerSet() const
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
void OnSeverity(wxCommandEvent &aEvent) override
Definition: dialog_drc.cpp:531
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.