diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index fd9b656271..ae30c05e26 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -7,7 +7,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2016 KiCad Developers, see change_log.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 @@ -43,6 +43,7 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* parent ) : { m_tester = aTester; m_Parent = parent; + m_currentBoard = m_Parent->GetBoard(); m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings(); InitValues(); @@ -55,6 +56,39 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* parent ) : } +void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event ) +{ + if( m_currentBoard != m_Parent->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->DestroyDialog( wxID_CANCEL ); + return; + } + + // updating data which can be modified outside the dialog (DRC parameters, units ...) + // because the dialog is not modal + m_BrdSettings = m_Parent->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 @@ -71,12 +105,10 @@ void DIALOG_DRC_CONTROL::InitValues() wxMouseEventHandler( DIALOG_DRC_CONTROL::OnRightUpUnconnected ), NULL, this ); - AddUnitSymbol( *m_TrackMinWidthTitle ); - AddUnitSymbol( *m_ViaMinTitle ); - AddUnitSymbol( *m_MicroViaMinTitle ); - m_DeleteCurrentMarkerButton->Enable( false ); + DisplayDRCValues(); + Layout(); // adding the units above expanded Clearance text, now resize. // Set the initial "enabled" status of the browse button and the text @@ -91,11 +123,11 @@ void DIALOG_DRC_CONTROL::InitValues() */ 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_BrdSettings.m_TrackMinWidth = ValueFromTextCtrl( *m_SetTrackMinWidthCtrl ); + m_BrdSettings.m_ViasMinSize = ValueFromTextCtrl( *m_SetViaMinSizeCtrl ); + m_BrdSettings.m_MicroViasMinSize = ValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl ); - m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings ); + m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings ); } @@ -117,7 +149,6 @@ void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event ) } SetDrcParmeters(); - m_tester->SetSettings( true, // Pad to pad DRC test enabled true, // unconnected pdas DRC test enabled true, // DRC test for zones enabled @@ -131,9 +162,8 @@ void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event ) // run all the tests, with no UI at this time. m_Messages->Clear(); wxSafeYield(); // Allows time slice to refresh the m_Messages window - m_tester->m_pcb->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations + m_Parent->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 ..." diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h index a75d457150..3efd0a96d9 100644 --- a/pcbnew/dialogs/dialog_drc.h +++ b/pcbnew/dialogs/dialog_drc.h @@ -71,6 +71,8 @@ private: void InitValues( ); + void DisplayDRCValues( ); + void SetDrcParmeters( ); /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX @@ -109,6 +111,10 @@ private: /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK void OnOkClick( wxCommandEvent& event ); + /// handler for activate event, updating data which can be modified outside the dialog + /// (DRC parameters) + void OnActivateDlg( wxActivateEvent& event ); + void OnMarkerSelectionEvent( wxCommandEvent& event ); void OnUnconnectedSelectionEvent( wxCommandEvent& event ); void OnChangingMarkerList( wxNotebookEvent& event ); @@ -118,6 +124,7 @@ private: void OnPopupMenu( wxCommandEvent& event ); + BOARD* m_currentBoard; // the board currently on test DRC* m_tester; PCB_EDIT_FRAME* m_Parent; }; diff --git a/pcbnew/dialogs/dialog_drc_base.cpp b/pcbnew/dialogs/dialog_drc_base.cpp index 5d073accc3..b9c21b978d 100644 --- a/pcbnew/dialogs/dialog_drc_base.cpp +++ b/pcbnew/dialogs/dialog_drc_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 9 2015) +// C++ code generated with wxFormBuilder (version Mar 28 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -28,70 +28,86 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i bSizer7 = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer* fgMinValuesSizer; - fgMinValuesSizer = new wxFlexGridSizer( 4, 2, 0, 0 ); + fgMinValuesSizer = new wxFlexGridSizer( 4, 3, 0, 0 ); fgMinValuesSizer->AddGrowableCol( 1 ); fgMinValuesSizer->SetFlexibleDirection( wxHORIZONTAL ); fgMinValuesSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_ClearanceTitle = new wxStaticText( this, wxID_ANY, _("Clearance"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ClearanceTitle = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Clearance"), wxDefaultPosition, wxDefaultSize, 0 ); m_ClearanceTitle->Wrap( -1 ); fgMinValuesSizer->Add( m_ClearanceTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - m_SetClearance = new wxTextCtrl( this, wxID_ANY, _("By Netclass"), wxDefaultPosition, wxDefaultSize, 0 ); - m_SetClearance->SetMaxLength( 0 ); + m_SetClearance = new wxTextCtrl( sbSizerOptions->GetStaticBox(), wxID_ANY, _("By Netclass"), wxDefaultPosition, wxDefaultSize, 0 ); m_SetClearance->Enable( false ); fgMinValuesSizer->Add( m_SetClearance, 0, wxALL|wxEXPAND, 5 ); - m_TrackMinWidthTitle = new wxStaticText( this, wxID_ANY, _("Min track width"), wxDefaultPosition, wxDefaultSize, 0 ); + + fgMinValuesSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_TrackMinWidthTitle = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Min track width"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackMinWidthTitle->Wrap( -1 ); m_TrackMinWidthTitle->SetToolTip( _("Enter the minimum acceptable value for a track width") ); fgMinValuesSizer->Add( m_TrackMinWidthTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - m_SetTrackMinWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_SetTrackMinWidthCtrl->SetMaxLength( 0 ); + m_SetTrackMinWidthCtrl = new wxTextCtrl( sbSizerOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgMinValuesSizer->Add( m_SetTrackMinWidthCtrl, 0, wxALL|wxEXPAND, 5 ); - m_ViaMinTitle = new wxStaticText( this, wxID_ANY, _("Min via size"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TrackMinWidthUnit = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TrackMinWidthUnit->Wrap( -1 ); + m_TrackMinWidthUnit->SetToolTip( _("Enter the minimum acceptable value for a track width") ); + + fgMinValuesSizer->Add( m_TrackMinWidthUnit, 0, wxALL, 5 ); + + m_ViaMinTitle = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Min via size"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaMinTitle->Wrap( -1 ); m_ViaMinTitle->SetHelpText( _("Enter the minimum acceptable diameter for a standard via") ); fgMinValuesSizer->Add( m_ViaMinTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - m_SetViaMinSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_SetViaMinSizeCtrl->SetMaxLength( 0 ); + m_SetViaMinSizeCtrl = new wxTextCtrl( sbSizerOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgMinValuesSizer->Add( m_SetViaMinSizeCtrl, 0, wxALL|wxEXPAND, 5 ); - m_MicroViaMinTitle = new wxStaticText( this, wxID_ANY, _("Min uVia size"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ViaMinUnit = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ViaMinUnit->Wrap( -1 ); + m_ViaMinUnit->SetHelpText( _("Enter the minimum acceptable diameter for a standard via") ); + + fgMinValuesSizer->Add( m_ViaMinUnit, 0, wxALL, 5 ); + + m_MicroViaMinTitle = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Min uVia size"), wxDefaultPosition, wxDefaultSize, 0 ); m_MicroViaMinTitle->Wrap( -1 ); m_MicroViaMinTitle->SetToolTip( _("Enter the minimum acceptable diameter for a micro via") ); fgMinValuesSizer->Add( m_MicroViaMinTitle, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - m_SetMicroViakMinSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_SetMicroViakMinSizeCtrl->SetMaxLength( 0 ); + m_SetMicroViakMinSizeCtrl = new wxTextCtrl( sbSizerOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgMinValuesSizer->Add( m_SetMicroViakMinSizeCtrl, 0, wxALL|wxEXPAND, 5 ); + m_MicroViaMinUnit = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_MicroViaMinUnit->Wrap( -1 ); + m_MicroViaMinUnit->SetToolTip( _("Enter the minimum acceptable diameter for a micro via") ); + + fgMinValuesSizer->Add( m_MicroViaMinUnit, 0, wxALL, 5 ); + bSizer7->Add( fgMinValuesSizer, 1, wxEXPAND, 5 ); wxStaticBoxSizer* ReportFileSizer; - ReportFileSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Create Report File") ), wxHORIZONTAL ); + ReportFileSizer = new wxStaticBoxSizer( new wxStaticBox( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Create Report File") ), wxHORIZONTAL ); - m_CreateRptCtrl = new wxCheckBox( this, ID_CHECKBOX_RPT_FILE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_CreateRptCtrl = new wxCheckBox( ReportFileSizer->GetStaticBox(), ID_CHECKBOX_RPT_FILE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_CreateRptCtrl->SetToolTip( _("Enable writing report to this file") ); ReportFileSizer->Add( m_CreateRptCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_RptFilenameCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_RptFilenameCtrl->SetMaxLength( 0 ); + m_RptFilenameCtrl = new wxTextCtrl( ReportFileSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_RptFilenameCtrl->SetToolTip( _("Enter the report filename") ); m_RptFilenameCtrl->SetMinSize( wxSize( 180,-1 ) ); ReportFileSizer->Add( m_RptFilenameCtrl, 1, wxALL|wxEXPAND, 5 ); - m_BrowseButton = new wxButton( this, ID_BUTTON_BROWSE_RPT_FILE, _("..."), wxDefaultPosition, wxSize( 50,-1 ), 0 ); + m_BrowseButton = new wxButton( ReportFileSizer->GetStaticBox(), ID_BUTTON_BROWSE_RPT_FILE, _("..."), wxDefaultPosition, wxSize( 50,-1 ), 0 ); ReportFileSizer->Add( m_BrowseButton, 0, wxALIGN_CENTER_VERTICAL, 5 ); @@ -197,9 +213,9 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i this->SetSizer( m_MainSizer ); this->Layout(); - m_MainSizer->Fit( this ); // Connect Events + this->Connect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_CONTROL_BASE::OnActivateDlg ) ); m_CreateRptCtrl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportCheckBoxClicked ), NULL, this ); m_BrowseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this ); m_buttonRunDRC->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnStartdrcClick ), NULL, this ); @@ -220,6 +236,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE() { // Disconnect Events + this->Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_CONTROL_BASE::OnActivateDlg ) ); m_CreateRptCtrl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnReportCheckBoxClicked ), NULL, this ); m_BrowseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this ); m_buttonRunDRC->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnStartdrcClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_drc_base.fbp b/pcbnew/dialogs/dialog_drc_base.fbp index 2e1b037bfd..6f7dc9f16f 100644 --- a/pcbnew/dialogs/dialog_drc_base.fbp +++ b/pcbnew/dialogs/dialog_drc_base.fbp @@ -44,7 +44,7 @@ DIALOG_DRC_CONTROL_BASE - -1,-1 + 733,438 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h DRC Control @@ -52,7 +52,7 @@ - + OnActivateDlg @@ -112,6 +112,7 @@ sbSizerOptions wxHORIZONTAL + 1 none @@ -128,7 +129,7 @@ wxEXPAND 1 - 2 + 3 wxHORIZONTAL 1 @@ -313,6 +314,16 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL @@ -487,6 +498,89 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + + 0 + + + 0 + + 1 + m_TrackMinWidthUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter the minimum acceptable value for a track width + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL @@ -661,6 +755,89 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + Enter the minimum acceptable diameter for a standard via + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + + 0 + + + 0 + + 1 + m_ViaMinUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL @@ -835,6 +1012,89 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + + 0 + + + 0 + + 1 + m_MicroViaMinUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter the minimum acceptable diameter for a micro via + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + @@ -847,6 +1107,7 @@ ReportFileSizer wxHORIZONTAL + 1 none @@ -1249,7 +1510,7 @@ 0 - + 0 0 220,-1 diff --git a/pcbnew/dialogs/dialog_drc_base.h b/pcbnew/dialogs/dialog_drc_base.h index f38e48ea42..9507c4644a 100644 --- a/pcbnew/dialogs/dialog_drc_base.h +++ b/pcbnew/dialogs/dialog_drc_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 9 2015) +// C++ code generated with wxFormBuilder (version Mar 28 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -55,8 +55,11 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM protected: wxStaticText* m_ClearanceTitle; wxStaticText* m_TrackMinWidthTitle; + wxStaticText* m_TrackMinWidthUnit; wxStaticText* m_ViaMinTitle; + wxStaticText* m_ViaMinUnit; wxStaticText* m_MicroViaMinTitle; + wxStaticText* m_MicroViaMinUnit; wxButton* m_BrowseButton; wxStaticText* m_staticText6; wxTextCtrl* m_Messages; @@ -73,6 +76,7 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM wxButton* m_sdbSizer1Cancel; // Virtual event handlers, overide them in your derived class + virtual void OnActivateDlg( wxActivateEvent& event ) { event.Skip(); } virtual void OnReportCheckBoxClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonBrowseRptFileClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnStartdrcClick( wxCommandEvent& event ) { event.Skip(); } @@ -100,7 +104,7 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM DRCLISTBOX* m_ClearanceListBox; DRCLISTBOX* m_UnconnectedListBox; - DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("DRC Control"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("DRC Control"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 733,438 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_DRC_CONTROL_BASE(); }; diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index ef61b5d90f..06a4950460 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -4,7 +4,7 @@ * * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2016 KiCad Developers, see change_log.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 @@ -55,44 +55,35 @@ void DRC::ShowDialog() { - if( !m_ui ) + if( !m_drcDialog ) { m_mainWindow->GetToolManager()->RunAction( COMMON_ACTIONS::selectionClear, true ); - m_ui = new DIALOG_DRC_CONTROL( this, m_mainWindow ); + m_drcDialog = new DIALOG_DRC_CONTROL( this, m_mainWindow ); updatePointers(); - // copy data retained in this DRC object into the m_ui DrcPanel: - - PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl, - m_pcb->GetDesignSettings().m_TrackMinWidth ); - PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl, - m_pcb->GetDesignSettings().m_ViasMinSize ); - PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl, - m_pcb->GetDesignSettings().m_MicroViasMinSize ); - - m_ui->m_CreateRptCtrl->SetValue( m_doCreateRptFile ); - m_ui->m_RptFilenameCtrl->SetValue( m_rptFilename ); + m_drcDialog->m_CreateRptCtrl->SetValue( m_doCreateRptFile ); + m_drcDialog->m_RptFilenameCtrl->SetValue( m_rptFilename ); } else updatePointers(); - m_ui->Show( true ); + m_drcDialog->Show( true ); } void DRC::DestroyDialog( int aReason ) { - if( m_ui ) + if( m_drcDialog ) { if( aReason == wxID_OK ) { // if user clicked OK, save his choices in this DRC object. - m_doCreateRptFile = m_ui->m_CreateRptCtrl->GetValue(); - m_rptFilename = m_ui->m_RptFilenameCtrl->GetValue(); + m_doCreateRptFile = m_drcDialog->m_CreateRptCtrl->GetValue(); + m_rptFilename = m_drcDialog->m_RptFilenameCtrl->GetValue(); } - m_ui->Destroy(); - m_ui = 0; + m_drcDialog->Destroy(); + m_drcDialog = NULL; } } @@ -101,7 +92,7 @@ DRC::DRC( PCB_EDIT_FRAME* aPcbWindow ) { m_mainWindow = aPcbWindow; m_pcb = aPcbWindow->GetBoard(); - m_ui = 0; + m_drcDialog = NULL; // establish initial values for everything: m_doPad2PadTest = true; // enable pad to pad clearance tests @@ -176,6 +167,10 @@ int DRC::Drc( ZONE_CONTAINER* aArea, int aCornerIndex ) void DRC::RunTests( wxTextCtrl* aMessages ) { + // be sure m_pcb is the current board, not a old one + // ( the board can be reloaded ) + m_pcb = m_mainWindow->GetBoard(); + // Ensure ratsnest is up to date: if( (m_pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) { @@ -199,7 +194,7 @@ void DRC::RunTests( wxTextCtrl* aMessages ) if( aMessages ) aMessages->AppendText( _( "Aborting\n" ) ); - // update the m_ui listboxes + // update the m_drcDialog listboxes updatePointers(); return; @@ -279,7 +274,7 @@ void DRC::RunTests( wxTextCtrl* aMessages ) testTexts(); - // update the m_ui listboxes + // update the m_drcDialog listboxes updatePointers(); if( aMessages ) @@ -295,7 +290,7 @@ void DRC::ListUnconnectedPads() { testUnconnected(); - // update the m_ui listboxes + // update the m_drcDialog listboxes updatePointers(); } @@ -305,10 +300,10 @@ void DRC::updatePointers() // update my pointers, m_mainWindow is the only unchangeable one m_pcb = m_mainWindow->GetBoard(); - if( m_ui ) // Use diag list boxes only in DRC dialog + if( m_drcDialog ) // Use diag list boxes only in DRC dialog { - m_ui->m_ClearanceListBox->SetList( new DRC_LIST_MARKERS( m_pcb ) ); - m_ui->m_UnconnectedListBox->SetList( new DRC_LIST_UNCONNECTED( &m_unconnected ) ); + m_drcDialog->m_ClearanceListBox->SetList( new DRC_LIST_MARKERS( m_pcb ) ); + m_drcDialog->m_UnconnectedListBox->SetList( new DRC_LIST_UNCONNECTED( &m_unconnected ) ); } } @@ -955,7 +950,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li if( pad->PadNameEqual( aRefPad ) ) continue; } - + // if either pad has no drill and is only on technical layers, not a clearance violation if( ( ( pad->GetLayerSet() & layerMask ) == 0 && !pad->GetDrillSize().x ) || ( ( aRefPad->GetLayerSet() & layerMask ) == 0 && !aRefPad->GetDrillSize().x ) ) diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h index 86a2cea217..b35c9b9977 100644 --- a/pcbnew/drc_stuff.h +++ b/pcbnew/drc_stuff.h @@ -195,7 +195,7 @@ private: PCB_EDIT_FRAME* m_mainWindow; BOARD* m_pcb; - DIALOG_DRC_CONTROL* m_ui; + DIALOG_DRC_CONTROL* m_drcDialog; DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs