1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768
|
/**
* @file dialog_drc.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <kiface_i.h>
#include <confirm.h>
#include <wildcards_and_files_ext.h>
#include <pgm_base.h>
#include <dialog_drc.h>
#include <pcb_edit_frame.h>
#include <base_units.h>
#include <board_design_settings.h>
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
/* class DIALOG_DRC_CONTROL: a dialog to set DRC parameters (clearance, min cooper size)
* and run DRC tests
*/
// Keywords for read and write config
#define TestMissingCourtyardKey wxT( "TestMissingCourtyard" )
#define TestFootprintCourtyardKey wxT( "TestFootprintCourtyard" )
#define RefillZonesBeforeDrc wxT( "RefillZonesBeforeDrc" )
DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFrame,
wxWindow* aParent ) :
DIALOG_DRC_CONTROL_BASE( aParent )
{
m_config = Kiface().KifaceSettings();
m_tester = aTester;
m_brdEditor = aEditorFrame;
m_currentBoard = m_brdEditor->GetBoard();
m_BrdSettings = m_brdEditor->GetBoard()->GetDesignSettings();
InitValues();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
DIALOG_DRC_CONTROL::~DIALOG_DRC_CONTROL()
{
m_config->Write( TestMissingCourtyardKey, m_cbCourtyardMissing->GetValue() );
m_config->Write( TestFootprintCourtyardKey, m_cbCourtyardOverlap->GetValue() );
m_config->Write( RefillZonesBeforeDrc, m_cbRefillZones->GetValue() );
// Disonnect events
m_ClearanceListBox->Disconnect( ID_CLEARANCE_LIST, wxEVT_LEFT_DCLICK,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnLeftDClickClearance ), NULL, this );
m_ClearanceListBox->Disconnect( ID_CLEARANCE_LIST, wxEVT_RIGHT_UP,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnRightUpClearance ), NULL, this );
m_UnconnectedListBox->Disconnect( ID_UNCONNECTED_LIST, wxEVT_LEFT_DCLICK,
wxMouseEventHandler( DIALOG_DRC_CONTROL::
OnLeftDClickUnconnected ), NULL, this );
m_UnconnectedListBox->Disconnect( ID_UNCONNECTED_LIST, wxEVT_RIGHT_UP,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnRightUpUnconnected ), NULL, this );
this->Disconnect( wxEVT_MENU, wxCommandEventHandler( DIALOG_DRC_CONTROL::OnPopupMenu ), NULL, this );
}
void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event )
{
if( m_currentBoard != m_brdEditor->GetBoard() )
{
// If m_currentBoard is not the current parent board,
// (for instance because a new board was loaded),
// close the dialog, because many pointers are now invalid
// in lists
SetReturnCode( wxID_CANCEL );
Close();
m_tester->DestroyDRCDialog( wxID_CANCEL );
return;
}
// updating data which can be modified outside the dialog (DRC parameters, units ...)
// because the dialog is not modal
m_BrdSettings = m_brdEditor->GetBoard()->GetDesignSettings();
DisplayDRCValues();
}
void DIALOG_DRC_CONTROL::DisplayDRCValues()
{
m_TrackMinWidthUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_ViaMinUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_MicroViaMinUnit->SetLabel(GetAbbreviatedUnitsLabel( g_UserUnit ) );
PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings.m_TrackMinWidth );
PutValueInLocalUnits( *m_SetViaMinSizeCtrl, m_BrdSettings.m_ViasMinSize );
PutValueInLocalUnits( *m_SetMicroViakMinSizeCtrl, m_BrdSettings.m_MicroViasMinSize );
}
void DIALOG_DRC_CONTROL::InitValues()
{
// Connect events and objects
m_ClearanceListBox->Connect( ID_CLEARANCE_LIST, wxEVT_LEFT_DCLICK,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnLeftDClickClearance ), NULL, this );
m_ClearanceListBox->Connect( ID_CLEARANCE_LIST, wxEVT_RIGHT_UP,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnRightUpClearance ), NULL, this );
m_UnconnectedListBox->Connect( ID_UNCONNECTED_LIST, wxEVT_LEFT_DCLICK,
wxMouseEventHandler( DIALOG_DRC_CONTROL::
OnLeftDClickUnconnected ), NULL, this );
m_UnconnectedListBox->Connect( ID_UNCONNECTED_LIST, wxEVT_RIGHT_UP,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnRightUpUnconnected ), NULL, this );
this->Connect( wxEVT_MENU, wxCommandEventHandler( DIALOG_DRC_CONTROL::OnPopupMenu ), NULL,
this );
m_DeleteCurrentMarkerButton->Enable( false );
DisplayDRCValues();
// read options
bool value;
m_config->Read( TestMissingCourtyardKey, &value, false );
m_cbCourtyardMissing->SetValue( value );
m_config->Read( TestFootprintCourtyardKey, &value, false );
m_cbCourtyardOverlap->SetValue( value );
m_config->Read( RefillZonesBeforeDrc, &value, false );
m_cbRefillZones->SetValue( value );
// Set the initial "enabled" status of the browse button and the text
// field for report name
wxCommandEvent junk;
OnReportCheckBoxClicked( junk );
Layout(); // adding the units above expanded Clearance text, now resize.
SetFocus();
}
/* accept DRC parameters (min clearance value and min sizes
*/
void DIALOG_DRC_CONTROL::SetDrcParmeters( )
{
m_BrdSettings.m_TrackMinWidth = ValueFromTextCtrl( *m_SetTrackMinWidthCtrl );
m_BrdSettings.m_ViasMinSize = ValueFromTextCtrl( *m_SetViaMinSizeCtrl );
m_BrdSettings.m_MicroViasMinSize = ValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl );
m_brdEditor->GetBoard()->SetDesignSettings( m_BrdSettings );
}
void DIALOG_DRC_CONTROL::SetRptSettings( bool aEnable, const wxString& aFileName )
{
m_RptFilenameCtrl->Enable( aEnable );
m_BrowseButton->Enable( aEnable );
m_CreateRptCtrl->SetValue( aEnable );
m_RptFilenameCtrl->SetValue( aFileName );
}
void DIALOG_DRC_CONTROL::GetRptSettings( bool* aEnable, wxString& aFileName )
{
*aEnable = m_CreateRptCtrl->GetValue();
aFileName = m_RptFilenameCtrl->GetValue();
}
void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event )
{
wxString reportName;
bool make_report = m_CreateRptCtrl->IsChecked();
if( make_report ) // Create a rpt file
{
reportName = m_RptFilenameCtrl->GetValue();
if( reportName.IsEmpty() )
{
wxCommandEvent dummy;
OnButtonBrowseRptFileClick( dummy );
}
if( !reportName.IsEmpty() )
reportName = makeValidFileNameReport();
}
SetDrcParmeters();
m_tester->SetSettings( true, // Pad to pad DRC test enabled
true, // unconnected pads DRC test enabled
true, // DRC test for zones enabled
true, // DRC test for keepout areas enabled
m_cbRefillZones->GetValue(),
m_cbCourtyardOverlap->GetValue(),
m_cbCourtyardMissing->GetValue(),
m_cbReportAllTrackErrors->GetValue(),
reportName, make_report );
DelDRCMarkers();
wxBeginBusyCursor();
wxWindowDisabler disabler;
// run all the tests, with no UI at this time.
m_Messages->Clear();
wxSafeYield(); // Allows time slice to refresh the m_Messages window
m_brdEditor->GetBoard()->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations
m_tester->RunTests(m_Messages);
m_Notebook->ChangeSelection( 0 ); // display the 1at tab "...Markers ..."
// Generate the report
if( !reportName.IsEmpty() )
{
if( writeReport( reportName ) )
{
wxString msg;
msg.Printf( _( "Report file \"%s\" created" ), GetChars( reportName ) );
wxString caption( _( "Disk File Report Completed" ) );
wxMessageDialog popupWindow( this, msg, caption );
popupWindow.ShowModal();
}
else
DisplayError( this, wxString::Format( _( "Unable to create report file \"%s\""),
GetChars( reportName ) ) );
}
wxEndBusyCursor();
RedrawDrawPanel();
}
void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& event )
{
DelDRCMarkers();
RedrawDrawPanel();
UpdateDisplayedCounts();
}
void DIALOG_DRC_CONTROL::OnListUnconnectedClick( wxCommandEvent& event )
{
wxString reportName;
bool make_report = m_CreateRptCtrl->IsChecked();
if( make_report ) // Create a file rpt
{
reportName = m_RptFilenameCtrl->GetValue();
if( reportName.IsEmpty() )
{
wxCommandEvent junk;
OnButtonBrowseRptFileClick( junk );
}
if( !reportName.IsEmpty() )
reportName = makeValidFileNameReport();
}
SetDrcParmeters();
m_tester->SetSettings( true, // Pad to pad DRC test enabled
true, // unconnected pads DRC test enabled
true, // DRC test for zones enabled
true, // DRC test for keepout areas enabled
m_cbRefillZones->GetValue(),
m_cbCourtyardOverlap->GetValue(),
m_cbCourtyardMissing->GetValue(),
m_cbReportAllTrackErrors->GetValue(),
reportName, make_report );
DelDRCMarkers();
wxBeginBusyCursor();
m_Messages->Clear();
m_tester->ListUnconnectedPads();
m_Notebook->ChangeSelection( 1 ); // display the 2nd tab "Unconnected..."
// Generate the report
if( !reportName.IsEmpty() )
{
if( writeReport( reportName ) )
{
wxString msg;
msg.Printf( _( "Report file \"%s\" created" ), GetChars( reportName ) );
wxString caption( _( "Disk File Report Completed" ) );
wxMessageDialog popupWindow( this, msg, caption );
popupWindow.ShowModal();
}
else
DisplayError( this, wxString::Format( _( "Unable to create report file \"%s\""),
GetChars( reportName ) ) );
}
UpdateDisplayedCounts();
wxEndBusyCursor();
/* there is currently nothing visible on the DrawPanel for unconnected pads
* RedrawDrawPanel();
*/
}
void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
{
wxFileName fn = m_brdEditor->GetBoard()->GetFileName();
fn.SetExt( ReportFileExtension );
wxString prj_path = Prj().GetProjectPath();
wxFileDialog dlg( this, _( "Save DRC Report File" ), prj_path,
fn.GetFullName(), ReportFileWildcard(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return;
m_RptFilenameCtrl->SetValue( dlg.GetPath() );
}
void DIALOG_DRC_CONTROL::OnOkClick( wxCommandEvent& event )
{
SetReturnCode( wxID_OK );
SetDrcParmeters();
// The dialog can be modal or not modal.
// Leave the DRC caller destroy (or not) the dialog
m_tester->DestroyDRCDialog( wxID_OK );
}
void DIALOG_DRC_CONTROL::OnCancelClick( wxCommandEvent& event )
{
SetReturnCode( wxID_CANCEL );
// The dialog can be modal or not modal.
// Leave the DRC caller destroy (or not) the dialog
m_tester->DestroyDRCDialog( wxID_CANCEL );
}
void DIALOG_DRC_CONTROL::OnReportCheckBoxClicked( wxCommandEvent& event )
{
m_RptFilenameCtrl->Enable( m_CreateRptCtrl->IsChecked() );
m_BrowseButton->Enable( m_CreateRptCtrl->IsChecked() );
}
void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event )
{
event.Skip();
// I am assuming that the double click actually changed the selected item.
// please verify this.
int selection = m_ClearanceListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
// Find the selected MARKER in the PCB, position cursor there.
// Then close the dialog.
const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection );
if( item )
{
auto pos = item->GetPointA();
if( auto marker = item->GetParent() )
pos = marker->GetPos();
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( pos, true, center );
if( !IsModal() )
{
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
// no destruction so we can preserve listbox cursor
Show( false );
// We do not want the clarification popup window.
// when releasing the left button in the main window
m_brdEditor->SkipNextLeftButtonReleaseEvent();
}
}
}
}
void DIALOG_DRC_CONTROL::OnPopupMenu( wxCommandEvent& event )
{
int source = event.GetId();
const DRC_ITEM* item = nullptr;
wxPoint pos;
int selection;
switch( source )
{
case ID_POPUP_UNCONNECTED_A:
selection = m_UnconnectedListBox->GetSelection();
item = m_UnconnectedListBox->GetItem( selection );
pos = item->GetPointA();
break;
case ID_POPUP_UNCONNECTED_B:
selection = m_UnconnectedListBox->GetSelection();
item = m_UnconnectedListBox->GetItem( selection );
pos = item->GetPointB();
break;
case ID_POPUP_MARKERS_A:
selection = m_ClearanceListBox->GetSelection();
item = m_ClearanceListBox->GetItem( selection );
pos = item->GetPointA();
break;
case ID_POPUP_MARKERS_B:
selection = m_ClearanceListBox->GetSelection();
item = m_ClearanceListBox->GetItem( selection );
pos = item->GetPointB();
break;
}
if( item )
{
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( pos, true, center );
if( !IsModal() )
Show( false );
}
}
void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
int selection = m_UnconnectedListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
wxMenu menu;
wxMenuItem* mItem;
const DRC_ITEM* dItem = m_UnconnectedListBox->GetItem( selection );
mItem = new wxMenuItem( &menu, ID_POPUP_UNCONNECTED_A, dItem->GetTextA() );
menu.Append( mItem );
if( dItem->HasSecondItem() )
{
mItem = new wxMenuItem( &menu, ID_POPUP_UNCONNECTED_B, dItem->GetTextB() );
menu.Append( mItem );
}
PopupMenu( &menu );
}
}
void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
int selection = m_ClearanceListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
wxMenu menu;
wxMenuItem* mItem;
const DRC_ITEM* dItem = m_ClearanceListBox->GetItem( selection );
mItem = new wxMenuItem( &menu, ID_POPUP_MARKERS_A, dItem->GetTextA() );
menu.Append( mItem );
if( dItem->HasSecondItem() )
{
mItem = new wxMenuItem( &menu, ID_POPUP_MARKERS_B, dItem->GetTextB() );
menu.Append( mItem );
}
PopupMenu( &menu );
}
}
void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
{
event.Skip();
// I am assuming that the double click actually changed the selected item.
// please verify this.
int selection = m_UnconnectedListBox->GetSelection();
if( selection != wxNOT_FOUND )
{
// Find the selected DRC_ITEM in the listbox, position cursor there,
// at the first of the two pads.
// Then hide the dialog.
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
if( item )
{
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), true, center );
if( !IsModal() )
{
Show( false );
// We do not want the clarification popup window.
// when releasing the left button in the main window
m_brdEditor->SkipNextLeftButtonReleaseEvent();
}
}
}
}
/* called when switching from Error list to Unconnected list
* To avoid mistakes, the current marker is selection is cleared
*/
void DIALOG_DRC_CONTROL::OnChangingMarkerList( wxNotebookEvent& event )
{
// Shouldn't be necessary, but is on at least OSX
m_Notebook->ChangeSelection( event.GetSelection() );
m_DeleteCurrentMarkerButton->Enable( false );
m_ClearanceListBox->SetSelection( -1 );
m_UnconnectedListBox->SetSelection( -1 );
}
void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event )
{
int selection = event.GetSelection();
if( selection != wxNOT_FOUND )
{
// until a MARKER is selected, this button is not enabled.
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there,
// at the first of the two pads.
const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection );
if( item )
{
auto pos = item->GetPointA();
if( auto marker = item->GetParent() )
pos = marker->GetPos();
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( pos, false, center );
RedrawDrawPanel();
}
}
event.Skip();
}
void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event )
{
int selection = event.GetSelection();
if( selection != wxNOT_FOUND )
{
// until a MARKER is selected, this button is not enabled.
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there,
// at the first of the two pads.
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
if( item )
{
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), false, center );
RedrawDrawPanel();
}
}
event.Skip();
}
void DIALOG_DRC_CONTROL::RedrawDrawPanel()
{
int freezeCount = 0;
while( m_brdEditor->IsFrozen() )
{
m_brdEditor->Thaw();
freezeCount++;
}
m_brdEditor->GetCanvas()->Refresh();
while( freezeCount > 0 )
{
m_brdEditor->Freeze();
freezeCount--;
}
}
void DIALOG_DRC_CONTROL::DelDRCMarkers()
{
m_brdEditor->SetCurItem( NULL ); // clear curr item, because it could be a DRC marker
// Clear current selection list to avoid selection of deleted items
m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
m_ClearanceListBox->DeleteAllItems();
m_UnconnectedListBox->DeleteAllItems();
m_DeleteCurrentMarkerButton->Enable( false );
}
const wxString DIALOG_DRC_CONTROL::makeValidFileNameReport()
{
wxFileName fn = m_RptFilenameCtrl->GetValue();
if( !fn.HasExt() )
{
fn.SetExt( ReportFileExtension );
m_RptFilenameCtrl->SetValue( fn.GetFullPath() );
}
// Ensure it is an absolute filename. if it is given relative
// it will be made relative to the project
if( !fn.IsAbsolute() )
{
wxString prj_path = Prj().GetProjectPath();
fn.MakeAbsolute( prj_path );
}
return fn.GetFullPath();
}
bool DIALOG_DRC_CONTROL::writeReport( const wxString& aFullFileName )
{
FILE* fp = wxFopen( aFullFileName, wxT( "w" ) );
if( fp == NULL )
return false;
int count;
fprintf( fp, "** Drc report for %s **\n",
TO_UTF8( m_brdEditor->GetBoard()->GetFileName() ) );
wxDateTime now = wxDateTime::Now();
fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) );
count = m_ClearanceListBox->GetItemCount();
fprintf( fp, "\n** Found %d DRC errors **\n", count );
for( int i = 0; i<count; ++i )
fprintf( fp, "%s", TO_UTF8( m_ClearanceListBox->GetItem( i )->ShowReport()) );
count = m_UnconnectedListBox->GetItemCount();
fprintf( fp, "\n** Found %d unconnected pads **\n", count );
for( int i = 0; i<count; ++i )
fprintf( fp, "%s", TO_UTF8( m_UnconnectedListBox->GetItem( i )->ShowReport() ) );
fprintf( fp, "\n** End of Report **\n" );
fclose( fp );
return true;
}
void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& event )
{
int selectedIndex;
int curTab = m_Notebook->GetSelection();
if( curTab == 0 )
{
selectedIndex = m_ClearanceListBox->GetSelection();
if( selectedIndex != wxNOT_FOUND )
{
m_ClearanceListBox->DeleteItem( selectedIndex );
// redraw the pcb
RedrawDrawPanel();
}
}
else if( curTab == 1 )
{
selectedIndex = m_UnconnectedListBox->GetSelection();
if( selectedIndex != wxNOT_FOUND )
{
m_UnconnectedListBox->DeleteItem( selectedIndex );
/* these unconnected DRC_ITEMs are not currently visible on the pcb
* RedrawDrawPanel();
*/
}
}
UpdateDisplayedCounts();
}
void DIALOG_DRC_CONTROL::UpdateDisplayedCounts()
{
int marker_count = m_ClearanceListBox->GetItemCount();
int unconnected_count = m_UnconnectedListBox->GetItemCount();
m_MarkerCount->SetLabelText( wxString::Format( "%d", marker_count ) );
m_UnconnectedCount->SetLabelText( wxString::Format( "%d", unconnected_count ) );
}
|