Commit 3e2662ae authored by dickelbeck's avatar dickelbeck

mord DRC changes

parent 36c316e7
This diff is collapsed.
......@@ -97,6 +97,81 @@ public:
};
/**
* Class DRC_LIST_UNCONNECTED
* is an implementation of the interface named DRC_ITEM_LIST which uses
* a vector of pointers to DRC_ITEMs to fulfill the interface. No ownership is taken of the
* vector, which will reside in class DRC
*/
class DRC_LIST_UNCONNECTED : public DRC_ITEM_LIST
{
DRC_LIST* m_vector;
public:
DRC_LIST_UNCONNECTED( DRC_LIST* aList ) :
m_vector(aList)
{
}
/* no destructor since we do not own anything to delete, not even the BOARD.
~DRC_LIST_UNCONNECTED() {}
*/
//-----<Interface DRC_ITEM_LIST>---------------------------------------
void DeleteAllItems()
{
if( m_vector )
{
for( unsigned i=0; i<m_vector->size(); ++i )
delete (*m_vector)[i];
m_vector->clear();
}
}
const DRC_ITEM* GetItem( int aIndex )
{
if( m_vector && (unsigned)aIndex < m_vector->size() )
{
const DRC_ITEM* item = (*m_vector)[aIndex];
return item;
}
return NULL;
}
void DeleteItem( int aIndex )
{
if( m_vector && (unsigned)aIndex < m_vector->size() )
{
delete (*m_vector)[aIndex];
m_vector->erase( m_vector->begin()+aIndex );
}
}
/**
* Function GetCount
* returns the number of items in the list.
*/
int GetCount()
{
if( m_vector )
{
return m_vector->size();
}
return 0;
}
//-----</Interface DRC_ITEM_LIST>--------------------------------------
};
/**
* Class DRCLISTBOX
* is used to display a DRC_ITEM_LIST.
......@@ -192,14 +267,15 @@ public:
{
if( m_list )
{
int selection = GetSelection();
m_list->DeleteItem( aIndex );
int count = m_list->GetCount();
SetItemCount( count );
if( aIndex < count )
SetSelection( aIndex );
else
SetSelection( aIndex-1 ); // -1 is no selection
// if old selection >= new count
if( selection >= count )
SetSelection( count-1 ); // -1 is "no selection"
Refresh();
}
}
......@@ -283,9 +359,6 @@ DrcDialog::DrcDialog( DRC* aTester, WinEDA_PcbFrame* parent,
m_Parent = parent;
Create(parent, id, caption, pos, size, style);
PutValueInLocalUnits( *m_SetClearance, g_DesignSettings.m_TrackClearence,
m_Parent->m_InternalUnits );
}
/*!
......@@ -556,7 +629,7 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event )
SetCursor( wxCursor( wxCURSOR_WAIT ) );
wxYield(); // process the cursor change event and the redraw.
wxYield(); // attempt to process the cursor change
// run all the tests, with no UI at this time.
m_tester->RunTests();
......@@ -566,12 +639,19 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event )
{
FILE* fp = wxFopen( reportName, wxT( "w" ) );
m_tester->WriteReport( fp );
writeReport( fp );
fclose(fp);
// @todo put up message box saying we created the report
//msg.Printf( _( "Report file <%s> created\n" ), s_RptFilename.GetData() );
wxString msg;
msg.Printf( _( "Report file \"%s\" created" ), reportName.GetData() );
wxString caption( _("Disk File Report Completed") );
wxMessageDialog popupWindow( this, msg, caption );
popupWindow.ShowModal();
}
SetCursor( wxCursor( wxCURSOR_ARROW ) );
......@@ -624,9 +704,8 @@ void DrcDialog::OnListUnconnectedClick( wxCommandEvent& event )
SetCursor( wxCursor( wxCURSOR_WAIT ) );
wxYield();
wxYield(); // attempt to process the cursor change
// run all the tests, with no UI at this time.
m_tester->ListUnconnectedPads();
// Generate the report
......@@ -634,19 +713,26 @@ void DrcDialog::OnListUnconnectedClick( wxCommandEvent& event )
{
FILE* fp = wxFopen( reportName, wxT( "w" ) );
m_tester->WriteReport( fp );
writeReport( fp );
fclose(fp);
// @todo put up message box saying we created the report
//msg.Printf( _( "Report file <%s> created\n" ), s_RptFilename.GetData() );
wxString msg;
msg.Printf( _( "Report file \"%s\" created" ), reportName.GetData() );
wxString caption( _("Disk File Report Completed") );
wxMessageDialog popupWindow( this, msg, caption );
popupWindow.ShowModal();
}
SetCursor( wxCursor( wxCURSOR_ARROW ) );
// @todo set the list counts in the DRCLISTITEMS here.
/* there is currently nothing visible on the DrawPanel for unconnected pads
RedrawDrawPanel();
*/
}
/*!
......@@ -690,8 +776,7 @@ void DrcDialog::OnOkClick( wxCommandEvent& event )
#endif
SetReturnCode( wxID_OK );
m_tester->DestroyDialog();
// event.Skip();
m_tester->DestroyDialog( wxID_OK );
}
......@@ -706,8 +791,7 @@ void DrcDialog::OnCancelClick( wxCommandEvent& event )
#endif
SetReturnCode( wxID_CANCEL );
m_tester->DestroyDialog();
// event.Skip();
m_tester->DestroyDialog( wxID_CANCEL );
}
......@@ -759,6 +843,10 @@ void DrcDialog::OnInitDialog( wxInitDialogEvent& event )
void DrcDialog::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 )
......@@ -769,18 +857,20 @@ void DrcDialog::OnLeftDClickClearance( wxMouseEvent& event )
if( item )
{
// after the goto, process a button OK command later.
/*
wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK );
::wxPostEvent( GetEventHandler(), cmd );
*/
m_Parent->CursorGoto( item->GetPosition() );
}
}
// On linux, the double click is being propagated to the parent. The
// call to StopPropagation was an attempt to prevent this.
// turn control over to m_Parent, hide this DrcDialog window,
// no destruction so we can preserve listbox cursor
Hide();
event.StopPropagation(); // we handled the double click event here.
// well that didn't work, we still get a popup menu
event.StopPropagation(); // still get the popup window.
}
}
}
......@@ -812,28 +902,28 @@ void DrcDialog::OnRightUpClearance( wxMouseEvent& event )
void DrcDialog::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 DRC, position cursor there.
// Then close the dialog.
// 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 )
{
// after the goto, process a button OK command later.
wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK );
::wxPostEvent( GetEventHandler(), cmd );
m_Parent->CursorGoto( item->GetPosition() );
}
}
// On linux, the double click is being propagated to the parent. The
// call to StopPropagation was an attempt to prevent this.
Hide();
event.StopPropagation(); // we handled the double click event here.
// well that didn't work, we still get a popup menu
// intermittently, still get the popup window, even with this.
event.StopPropagation();
}
}
}
......@@ -879,6 +969,33 @@ void DrcDialog::DelDRCMarkers()
}
void DrcDialog::writeReport( FILE* fp )
{
int count;
fprintf( fp, "** Drc report for %s **\n",
CONV_TO_UTF8( m_Parent->GetScreen()->m_FileName ) );
char line[256];
fprintf( fp, "** Created on %s **\n", DateAndTime( line ) ); //@todo make DateAndTime use localtime, not gmtime
count = m_ClearanceListBox->GetItemCount();
fprintf( fp, "\n** Found %d DRC errors **\n", count );
for( int i=0; i<count; ++i )
fprintf( fp, m_ClearanceListBox->GetItem(i)->ShowReport().mb_str() );
count = m_UnconnectedListBox->GetItemCount();
fprintf( fp, "\n** Found %d unconnected pads **\n", count );
for( int i=0; i<count; ++i )
fprintf( fp, m_UnconnectedListBox->GetItem(i)->ShowReport().mb_str() );
fprintf( fp, "\n** End of Report **\n" );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ONE
......@@ -895,6 +1012,8 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event )
if( selectedIndex != wxNOT_FOUND )
{
m_ClearanceListBox->DeleteItem( selectedIndex );
// redraw the pcb
RedrawDrawPanel();
}
}
......@@ -905,7 +1024,10 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event )
if( selectedIndex != wxNOT_FOUND )
{
m_UnconnectedListBox->DeleteItem( selectedIndex );
/* these unconnected DRC_ITEMs are not currently visible on the pcb
RedrawDrawPanel();
*/
}
}
......
......@@ -85,6 +85,16 @@ class DrcDialog: public wxDialog
DECLARE_DYNAMIC_CLASS( DrcDialog )
DECLARE_EVENT_TABLE()
/**
* Function writeReport
* outputs the MARKER items and unconnecte DRC_ITEMs with commentary to an
* open text file.
* @param fpOut The text file to write the report to.
*/
void writeReport( FILE* fpOut );
public:
/// Constructors
DrcDialog( );
......
This diff is collapsed.
......@@ -114,7 +114,9 @@ public:
{
wxString ret;
ret.Printf( _("<b>ErrType(%d): %s</b><ul><li> %s: %s </li><li> %s: %s </li></ul>"),
// an html fragment for the entire message in the listbox. feel free
// to add color if you want:
ret.Printf( _("ErrType(%d): <b>%s</b><ul><li> %s: %s </li><li> %s: %s </li></ul>"),
m_ErrorCode,
GetErrorText().GetData(),
ShowCoord( m_APos ).GetData(), m_AText.GetData(),
......@@ -249,6 +251,8 @@ public:
};
typedef std::vector<DRC_ITEM*> DRC_LIST;
/**
* Class DRC
......@@ -292,14 +296,12 @@ private:
int m_xcliphi;
int m_ycliphi; // coord de la surface de securite du segment a comparer
int m_unconnectedCount;
WinEDA_PcbFrame* m_mainWindow;
WinEDA_DrawPanel* m_drawPanel;
BOARD* m_pcb;
DrcDialog* m_ui;
std::vector<DRC_ITEM> m_unconnected;
DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs
/**
......@@ -425,6 +427,7 @@ private:
public:
DRC( WinEDA_PcbFrame* aPcbWindow );
~DRC();
/**
* Function Drc
......@@ -466,8 +469,9 @@ public:
* Function DestroyDialog
* deletes this ui dialog box and zeros out its pointer to remember
* the state of the dialog's existence.
* @param aReason Indication of which button was clicked to cause the destruction.
*/
void DestroyDialog();
void DestroyDialog( int aReason );
/**
......@@ -505,13 +509,6 @@ public:
*/
void ListUnconnectedPads();
/**
* Function WriteReport
* outputs the MARKER items with commentary to an open text file.
* @param fpOut The text file to write the report to.
*/
void WriteReport( FILE* fpOut );
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment