2007-05-06 16:03:28 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
// Name: dialog_drc.cpp
|
|
|
|
// Author: jean-pierre Charras
|
2009-06-18 13:30:52 +00:00
|
|
|
// Licence: GPL
|
2007-05-06 16:03:28 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
#include "fctsys.h"
|
2008-02-12 21:12:46 +00:00
|
|
|
#include "wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "dialog_drc.h"
|
2009-06-18 13:30:52 +00:00
|
|
|
#include "common.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-05 19:51:50 +00:00
|
|
|
|
|
|
|
// dialog should remember its previous screen position and size
|
|
|
|
wxPoint DIALOG_DRC_CONTROL::s_LastPos( -1, -1 );
|
|
|
|
wxSize DIALOG_DRC_CONTROL::s_LastSize;
|
|
|
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
/* class DIALOG_DRC_CONTROL: a dialog to set DRC parameters (clearance, min cooper size)
|
|
|
|
* and run DRC tests
|
2008-02-23 04:53:44 +00:00
|
|
|
*/
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, WinEDA_PcbFrame* parent ) :
|
2009-06-27 06:26:41 +00:00
|
|
|
DIALOG_DRC_CONTROL_BASE( parent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-01 03:42:52 +00:00
|
|
|
m_tester = aTester;
|
2007-11-13 09:35:39 +00:00
|
|
|
m_Parent = parent;
|
2010-01-31 20:01:46 +00:00
|
|
|
m_BrdSettings = m_Parent->GetBoard()->GetBoardDesignSettings();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
InitValues();
|
2009-06-27 06:26:41 +00:00
|
|
|
if( GetSizer() )
|
2007-07-30 11:15:54 +00:00
|
|
|
{
|
2009-06-27 06:26:41 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-07-30 11:15:54 +00:00
|
|
|
}
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2009-12-04 09:21:53 +00:00
|
|
|
Centre();
|
2009-11-05 22:02:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_DRC_CONTROL::Show( bool show )
|
|
|
|
{
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
D(printf("%s %d\n", __func__, show );)
|
2009-11-05 19:51:50 +00:00
|
|
|
|
2009-11-05 22:02:24 +00:00
|
|
|
if( show )
|
2009-11-05 19:51:50 +00:00
|
|
|
{
|
2009-11-05 22:02:24 +00:00
|
|
|
ret = DIALOG_DRC_CONTROL_BASE::Show( show );
|
|
|
|
|
|
|
|
if( s_LastPos.x != -1 )
|
|
|
|
{
|
|
|
|
D(printf("setting window pos to (%d,%d)\n", s_LastPos.x, s_LastPos.y );)
|
|
|
|
//SetPosition( s_LastPos );
|
|
|
|
SetSize( s_LastPos.x, s_LastPos.y, s_LastSize.x, s_LastSize.y, 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
D(printf("not setting window pos (%d,%d)\n", s_LastPos.x, s_LastPos.y );)
|
|
|
|
}
|
2009-11-05 19:51:50 +00:00
|
|
|
}
|
2009-11-05 22:02:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Save the dialog's position before hiding
|
|
|
|
s_LastPos = GetPosition();
|
|
|
|
s_LastSize = GetSize();
|
|
|
|
|
|
|
|
D(printf("saving window pos as (%d,%d)\n", s_LastPos.x, s_LastPos.y );)
|
|
|
|
|
|
|
|
ret = DIALOG_DRC_CONTROL_BASE::Show( show );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-05 22:02:24 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
void DIALOG_DRC_CONTROL::InitValues()
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
|
|
|
// Connect events and objects
|
2009-06-27 06:26:41 +00:00
|
|
|
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 );
|
|
|
|
|
|
|
|
AddUnitSymbol( *m_TrackMinWidthTitle );
|
|
|
|
AddUnitSymbol( *m_ViaMinTitle );
|
|
|
|
AddUnitSymbol( *m_MicroViaMinTitle );
|
2009-11-05 19:51:50 +00:00
|
|
|
|
|
|
|
/* this looks terrible! does not fit into text field, do it in wxformbuilder instead
|
2009-10-21 19:42:57 +00:00
|
|
|
m_SetClearance->SetValue( _("Netclasses values"));
|
2009-11-05 19:51:50 +00:00
|
|
|
*/
|
2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
Layout(); // adding the units above expanded Clearance text, now resize.
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
// Set the initial "enabled" status of the browse button and the text
|
|
|
|
// field for report name
|
|
|
|
wxCommandEvent junk;
|
|
|
|
OnReportCheckBoxClicked( junk );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
SetFocus();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
// deselect the existing text, seems SetFocus() wants to emulate
|
|
|
|
// Microsoft and select all text, which is not desireable here.
|
|
|
|
// m_SetClearance->SetSelection(0,0);
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2009-10-06 18:58:51 +00:00
|
|
|
/* accept DRC parameters (min clearance value and min sizes
|
|
|
|
*/
|
|
|
|
void DIALOG_DRC_CONTROL::SetDrcParmeters( )
|
|
|
|
{
|
2010-01-31 20:01:46 +00:00
|
|
|
m_BrdSettings->m_TrackMinWidth =
|
2009-10-06 18:58:51 +00:00
|
|
|
ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits );
|
2010-01-31 20:01:46 +00:00
|
|
|
m_BrdSettings->m_ViasMinSize =
|
2009-10-06 18:58:51 +00:00
|
|
|
ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->m_InternalUnits );
|
2010-01-31 20:01:46 +00:00
|
|
|
m_BrdSettings->m_MicroViasMinSize =
|
2009-10-06 18:58:51 +00:00
|
|
|
ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->m_InternalUnits );
|
|
|
|
}
|
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DRC_RUN
|
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-03 05:14:51 +00:00
|
|
|
wxString reportName;
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
if( m_CreateRptCtrl->IsChecked() ) // Create a file rpt
|
|
|
|
{
|
|
|
|
reportName = m_RptFilenameCtrl->GetValue();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
if( reportName.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxCommandEvent junk;
|
|
|
|
OnButtonBrowseRptFileClick( junk );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
reportName = m_RptFilenameCtrl->GetValue();
|
|
|
|
}
|
|
|
|
|
2009-10-06 18:58:51 +00:00
|
|
|
SetDrcParmeters( );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
m_tester->SetSettings( true, // Pad to pad DRC test enabled
|
|
|
|
true, // unconnected pdas DRC test enabled
|
|
|
|
true, // DRC test for zones enabled
|
|
|
|
reportName, m_CreateRptCtrl->IsChecked() );
|
|
|
|
|
2007-12-03 21:28:56 +00:00
|
|
|
DelDRCMarkers();
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-12-05 14:17:10 +00:00
|
|
|
wxBeginBusyCursor();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
// run all the tests, with no UI at this time.
|
2009-06-27 06:26:41 +00:00
|
|
|
m_Messages->Clear();
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield(); // Allows time slice to refresh the m_Messages window
|
|
|
|
m_tester->m_pcb->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations
|
2009-06-27 06:26:41 +00:00
|
|
|
m_tester->RunTests(m_Messages);
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
#if wxCHECK_VERSION( 2, 8, 0 )
|
2009-06-27 06:26:41 +00:00
|
|
|
m_Notebook->ChangeSelection( 0 ); // display the 1at tab "...Markers ..."
|
2007-12-05 20:54:11 +00:00
|
|
|
#else
|
2009-06-27 06:26:41 +00:00
|
|
|
m_Notebook->SetSelection( 0 ); // display the 1at tab "... Markers..."
|
2007-12-05 20:54:11 +00:00
|
|
|
#endif
|
2008-02-23 04:53:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Generate the report
|
2007-12-03 05:14:51 +00:00
|
|
|
if( !reportName.IsEmpty() )
|
|
|
|
{
|
|
|
|
FILE* fp = wxFopen( reportName, wxT( "w" ) );
|
2007-12-04 18:23:38 +00:00
|
|
|
writeReport( fp );
|
2009-06-27 06:26:41 +00:00
|
|
|
fclose( fp );
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
wxString msg;
|
2009-09-10 15:22:26 +00:00
|
|
|
msg.Printf( _( "Report file \"%s\" created" ), GetChars( reportName ) );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
wxString caption( _( "Disk File Report Completed" ) );
|
2007-12-04 18:23:38 +00:00
|
|
|
wxMessageDialog popupWindow( this, msg, caption );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
popupWindow.ShowModal();
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-05 14:17:10 +00:00
|
|
|
wxEndBusyCursor();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-03 21:28:56 +00:00
|
|
|
RedrawDrawPanel();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-12-03 21:28:56 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS
|
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnDeleteAllClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-03 21:28:56 +00:00
|
|
|
DelDRCMarkers();
|
|
|
|
RedrawDrawPanel();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_LIST_UNCONNECTED_PADS
|
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnListUnconnectedClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-03 05:14:51 +00:00
|
|
|
wxString reportName;
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
if( m_CreateRptCtrl->IsChecked() ) // Create a file rpt
|
|
|
|
{
|
|
|
|
reportName = m_RptFilenameCtrl->GetValue();
|
|
|
|
|
|
|
|
if( reportName.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxCommandEvent junk;
|
|
|
|
OnButtonBrowseRptFileClick( junk );
|
|
|
|
}
|
|
|
|
|
|
|
|
reportName = m_RptFilenameCtrl->GetValue();
|
|
|
|
}
|
|
|
|
|
2009-10-06 18:58:51 +00:00
|
|
|
SetDrcParmeters( );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
m_tester->SetSettings( true, // Pad to pad DRC test enabled
|
|
|
|
true, // unconnected pdas DRC test enabled
|
|
|
|
true, // DRC test for zones enabled
|
|
|
|
reportName, m_CreateRptCtrl->IsChecked() );
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
DelDRCMarkers();
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-12-05 14:17:10 +00:00
|
|
|
wxBeginBusyCursor();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
m_Messages->Clear();
|
2007-12-03 05:14:51 +00:00
|
|
|
m_tester->ListUnconnectedPads();
|
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
#if wxCHECK_VERSION( 2, 8, 0 )
|
2009-06-27 06:26:41 +00:00
|
|
|
m_Notebook->ChangeSelection( 1 ); // display the 2nd tab "Unconnected..."
|
2007-12-05 20:54:11 +00:00
|
|
|
#else
|
2009-06-27 06:26:41 +00:00
|
|
|
m_Notebook->SetSelection( 1 ); // display the 2nd tab "Unconnected..."
|
2007-12-05 20:54:11 +00:00
|
|
|
#endif
|
2008-02-23 04:53:44 +00:00
|
|
|
|
|
|
|
// Generate the report
|
2007-12-03 05:14:51 +00:00
|
|
|
if( !reportName.IsEmpty() )
|
|
|
|
{
|
|
|
|
FILE* fp = wxFopen( reportName, wxT( "w" ) );
|
2007-12-04 18:23:38 +00:00
|
|
|
writeReport( fp );
|
2009-06-27 06:26:41 +00:00
|
|
|
fclose( fp );
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
wxString msg;
|
2009-09-10 15:22:26 +00:00
|
|
|
msg.Printf( _( "Report file \"%s\" created" ), GetChars( reportName ) );
|
2009-06-27 06:26:41 +00:00
|
|
|
wxString caption( _( "Disk File Report Completed" ) );
|
2007-12-04 18:23:38 +00:00
|
|
|
wxMessageDialog popupWindow( this, msg, caption );
|
|
|
|
popupWindow.ShowModal();
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-05 14:17:10 +00:00
|
|
|
wxEndBusyCursor();
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2008-02-23 04:53:44 +00:00
|
|
|
/* there is currently nothing visible on the DrawPanel for unconnected pads
|
2009-06-27 06:26:41 +00:00
|
|
|
* RedrawDrawPanel();
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2007-08-02 07:42:58 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_BROWSE_RPT_FILE
|
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
|
2007-08-02 07:42:58 +00:00
|
|
|
{
|
2009-06-27 06:26:41 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
|
|
|
|
wxString Ext( wxT( "rpt" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
fn = m_Parent->GetScreen()->m_FileName + wxT( "-drc" );
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( Ext );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
|
|
|
|
fn.GetFullName(), wildcard,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-11-13 09:35:39 +00:00
|
|
|
return;
|
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
m_RptFilenameCtrl->SetValue( dlg.GetPath() );
|
2007-08-02 07:42:58 +00:00
|
|
|
}
|
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
|
|
|
|
/*!
|
2007-11-27 01:34:35 +00:00
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
2007-10-03 15:21:13 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnOkClick( wxCommandEvent& event )
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
2007-12-03 05:14:51 +00:00
|
|
|
SetReturnCode( wxID_OK );
|
2009-10-06 18:58:51 +00:00
|
|
|
SetDrcParmeters( );
|
2009-11-05 19:51:50 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
m_tester->DestroyDialog( wxID_OK );
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2007-10-03 15:21:13 +00:00
|
|
|
|
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
|
|
|
*/
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnCancelClick( wxCommandEvent& event )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2007-12-03 05:14:51 +00:00
|
|
|
SetReturnCode( wxID_CANCEL );
|
2009-11-05 19:51:50 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
m_tester->DestroyDialog( wxID_CANCEL );
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX1
|
|
|
|
*/
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnReportCheckBoxClicked( wxCommandEvent& event )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
|
|
|
if( m_CreateRptCtrl->IsChecked() )
|
|
|
|
{
|
2009-06-27 06:26:41 +00:00
|
|
|
m_RptFilenameCtrl->Enable( true );
|
|
|
|
m_BrowseButton->Enable( true );
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2007-10-03 15:21:13 +00:00
|
|
|
else
|
|
|
|
{
|
2009-06-27 06:26:41 +00:00
|
|
|
m_RptFilenameCtrl->Enable( false );
|
|
|
|
m_BrowseButton->Enable( false );
|
2007-10-03 15:21:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-13 09:35:39 +00:00
|
|
|
|
|
|
|
/*!
|
2007-11-27 01:34:35 +00:00
|
|
|
* wxEVT_LEFT_DCLICK event handler for ID_CLEARANCE_LIST
|
2007-11-13 09:35:39 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event )
|
2007-11-13 09:35:39 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
// I am assuming that the double click actually changed the selected item.
|
2008-02-23 04:53:44 +00:00
|
|
|
// please verify this.
|
2007-11-27 01:34:35 +00:00
|
|
|
int selection = m_ClearanceListBox->GetSelection();
|
|
|
|
|
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
2007-12-03 05:14:51 +00:00
|
|
|
// Find the selected MARKER in the PCB, position cursor there.
|
2007-12-04 07:04:53 +00:00
|
|
|
// Then close the dialog.
|
|
|
|
const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection );
|
|
|
|
if( item )
|
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
/*
|
2009-06-27 06:26:41 +00:00
|
|
|
* // after the goto, process a button OK command later.
|
|
|
|
* wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK );
|
|
|
|
* ::wxPostEvent( GetEventHandler(), cmd );
|
|
|
|
*/
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
m_Parent->CursorGoto( item->GetPointA() );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
// turn control over to m_Parent, hide this DIALOG_DRC_CONTROL window,
|
2007-12-04 18:23:38 +00:00
|
|
|
// no destruction so we can preserve listbox cursor
|
2009-11-05 22:02:24 +00:00
|
|
|
Show( false );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
event.StopPropagation(); // still get the popup window.
|
2007-12-04 07:04:53 +00:00
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnPopupMenu( wxCommandEvent& event )
|
2007-12-04 20:44:41 +00:00
|
|
|
{
|
2009-06-27 06:26:41 +00:00
|
|
|
int source = event.GetId();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
const DRC_ITEM* item = 0;
|
|
|
|
wxPoint pos;
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
int selection;
|
2007-12-04 20:44:41 +00:00
|
|
|
|
|
|
|
switch( source )
|
|
|
|
{
|
|
|
|
case ID_POPUP_UNCONNECTED_A:
|
|
|
|
selection = m_UnconnectedListBox->GetSelection();
|
|
|
|
item = m_UnconnectedListBox->GetItem( selection );
|
|
|
|
pos = item->GetPointA();
|
|
|
|
break;
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
case ID_POPUP_UNCONNECTED_B:
|
|
|
|
selection = m_UnconnectedListBox->GetSelection();
|
|
|
|
item = m_UnconnectedListBox->GetItem( selection );
|
|
|
|
pos = item->GetPointB();
|
|
|
|
break;
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
case ID_POPUP_MARKERS_A:
|
|
|
|
selection = m_ClearanceListBox->GetSelection();
|
|
|
|
item = m_ClearanceListBox->GetItem( selection );
|
|
|
|
pos = item->GetPointA();
|
|
|
|
break;
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
case ID_POPUP_MARKERS_B:
|
|
|
|
selection = m_ClearanceListBox->GetSelection();
|
|
|
|
item = m_ClearanceListBox->GetItem( selection );
|
|
|
|
pos = item->GetPointB();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
m_Parent->CursorGoto( pos );
|
2009-11-05 22:02:24 +00:00
|
|
|
Show( false );
|
2007-12-04 20:44:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_RIGHT_UP event handler for ID_CLEARANCE_LIST
|
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
|
|
|
event.Skip();
|
2007-12-04 20:44:41 +00:00
|
|
|
|
|
|
|
// popup menu to go to either of the items listed in the DRC_ITEM.
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
int selection = m_UnconnectedListBox->GetSelection();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
|
|
|
wxMenuItem* mItem;
|
|
|
|
const DRC_ITEM* dItem = m_UnconnectedListBox->GetItem( selection );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
mItem = new wxMenuItem( &menu, ID_POPUP_UNCONNECTED_A, dItem->GetTextA() );
|
2007-12-04 20:44:41 +00:00
|
|
|
menu.Append( mItem );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
|
|
|
if( dItem->HasSecondItem() )
|
|
|
|
{
|
2009-06-27 06:26:41 +00:00
|
|
|
mItem = new wxMenuItem( &menu, ID_POPUP_UNCONNECTED_B, dItem->GetTextB() );
|
2008-02-23 04:53:44 +00:00
|
|
|
menu.Append( mItem );
|
|
|
|
}
|
2007-12-04 20:44:41 +00:00
|
|
|
|
|
|
|
PopupMenu( &menu );
|
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_RIGHT_UP event handler for ID_CLEARANCE_LIST
|
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2007-11-13 09:35:39 +00:00
|
|
|
event.Skip();
|
2007-12-04 20:44:41 +00:00
|
|
|
|
|
|
|
// popup menu to go to either of the items listed in the DRC_ITEM.
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
int selection = m_ClearanceListBox->GetSelection();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 20:44:41 +00:00
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
|
|
|
wxMenuItem* mItem;
|
|
|
|
const DRC_ITEM* dItem = m_ClearanceListBox->GetItem( selection );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
mItem = new wxMenuItem( &menu, ID_POPUP_MARKERS_A, dItem->GetTextA() );
|
2007-12-04 20:44:41 +00:00
|
|
|
menu.Append( mItem );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
|
|
|
if( dItem->HasSecondItem() )
|
|
|
|
{
|
2009-06-27 06:26:41 +00:00
|
|
|
mItem = new wxMenuItem( &menu, ID_POPUP_MARKERS_B, dItem->GetTextB() );
|
2008-02-23 04:53:44 +00:00
|
|
|
menu.Append( mItem );
|
|
|
|
}
|
2007-12-04 20:44:41 +00:00
|
|
|
|
|
|
|
PopupMenu( &menu );
|
|
|
|
}
|
2007-11-13 09:35:39 +00:00
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_LEFT_DCLICK event handler for ID_UNCONNECTED_LIST
|
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
// I am assuming that the double click actually changed the selected item.
|
2008-02-23 04:53:44 +00:00
|
|
|
// please verify this.
|
2007-11-27 01:34:35 +00:00
|
|
|
int selection = m_UnconnectedListBox->GetSelection();
|
|
|
|
|
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
2008-02-23 04:53:44 +00:00
|
|
|
// Find the selected DRC_ITEM in the listbox, position cursor there,
|
2007-12-04 18:23:38 +00:00
|
|
|
// at the first of the two pads.
|
|
|
|
// Then hide the dialog.
|
2007-12-04 07:04:53 +00:00
|
|
|
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
|
|
|
|
if( item )
|
|
|
|
{
|
2009-07-06 18:02:26 +00:00
|
|
|
m_Parent->CursorGoto( item->GetPointA() );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-11-05 22:02:24 +00:00
|
|
|
Show( false );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// intermittently, still get the popup window, even with this.
|
2008-02-23 04:53:44 +00:00
|
|
|
event.StopPropagation();
|
2007-12-04 07:04:53 +00:00
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
|
|
|
int selection = event.GetSelection();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
// until a MARKER is selected, this button is not enabled.
|
2009-06-27 06:26:41 +00:00
|
|
|
m_DeleteCurrentMarkerButton->Enable( true );
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
|
|
|
int selection = event.GetSelection();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
2007-12-04 07:04:53 +00:00
|
|
|
// until a MARKER is selected, this button is not enabled.
|
2009-06-27 06:26:41 +00:00
|
|
|
m_DeleteCurrentMarkerButton->Enable( true );
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::RedrawDrawPanel()
|
2007-12-03 21:28:56 +00:00
|
|
|
{
|
|
|
|
m_Parent->DrawPanel->Refresh();
|
|
|
|
}
|
2007-12-03 05:14:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::DelDRCMarkers()
|
2007-12-03 05:14:51 +00:00
|
|
|
/*********************************************************/
|
|
|
|
{
|
2010-04-08 11:33:43 +00:00
|
|
|
m_Parent->SetCurItem( NULL ); // clear curr item, because it could be a DRC marker
|
2007-12-03 21:28:56 +00:00
|
|
|
m_ClearanceListBox->DeleteAllItems();
|
|
|
|
m_UnconnectedListBox->DeleteAllItems();
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::writeReport( FILE* fp )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
fprintf( fp, "** Drc report for %s **\n",
|
|
|
|
CONV_TO_UTF8( m_Parent->GetScreen()->m_FileName ) );
|
2007-12-05 13:50:42 +00:00
|
|
|
|
|
|
|
wxDateTime now = wxDateTime::Now();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
fprintf( fp, "** Created on %s **\n", CONV_TO_UTF8( now.Format( wxT( "%F %T" ) ) ) );
|
2007-12-04 18:23:38 +00:00
|
|
|
|
|
|
|
count = m_ClearanceListBox->GetItemCount();
|
|
|
|
|
|
|
|
fprintf( fp, "\n** Found %d DRC errors **\n", count );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
for( int i = 0; i<count; ++i )
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( fp, "%s", CONV_TO_UTF8( m_ClearanceListBox->GetItem( i )->ShowReport()) );
|
2007-12-04 18:23:38 +00:00
|
|
|
|
|
|
|
count = m_UnconnectedListBox->GetItemCount();
|
|
|
|
|
|
|
|
fprintf( fp, "\n** Found %d unconnected pads **\n", count );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2009-06-27 06:26:41 +00:00
|
|
|
for( int i = 0; i<count; ++i )
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( fp, "%s", CONV_TO_UTF8( m_UnconnectedListBox->GetItem( i )->ShowReport() ) );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
fprintf( fp, "\n** End of Report **\n" );
|
|
|
|
}
|
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/*!
|
2007-12-03 05:14:51 +00:00
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ONE
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
void DIALOG_DRC_CONTROL::OnDeleteOneClick( wxCommandEvent& event )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2007-12-03 05:14:51 +00:00
|
|
|
int selectedIndex;
|
2009-06-27 06:26:41 +00:00
|
|
|
int curTab = m_Notebook->GetSelection();
|
2007-12-03 05:14:51 +00:00
|
|
|
|
|
|
|
if( curTab == 0 )
|
|
|
|
{
|
|
|
|
selectedIndex = m_ClearanceListBox->GetSelection();
|
|
|
|
if( selectedIndex != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
m_ClearanceListBox->DeleteItem( selectedIndex );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// redraw the pcb
|
2007-12-04 07:04:53 +00:00
|
|
|
RedrawDrawPanel();
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( curTab == 1 )
|
|
|
|
{
|
|
|
|
selectedIndex = m_UnconnectedListBox->GetSelection();
|
|
|
|
if( selectedIndex != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
m_UnconnectedListBox->DeleteItem( selectedIndex );
|
2008-02-23 04:53:44 +00:00
|
|
|
|
|
|
|
/* these unconnected DRC_ITEMs are not currently visible on the pcb
|
2009-06-27 06:26:41 +00:00
|
|
|
* RedrawDrawPanel();
|
|
|
|
*/
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|