Changes to pcbnew/gendrill.cpp which primarily enhance Drill Report files, but which also result in Drill Map files listing the diameters of each drill in the selected drill unit first (and then in the other drill unit).

This commit is contained in:
g_harland 2007-07-31 06:29:45 +00:00
parent b0d1057cfd
commit 8035f1a520
2 changed files with 151 additions and 66 deletions

View File

@ -4,6 +4,16 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Jul-31 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ pcbnew
Drill Map and Drill Report files now list the diameters of each drill in
the selected drill unit first, and then in the other drill unit.
Drill report files also now list the tool assigned to each drill, and
the correct hole count and oval count for each drill size; the
file creation date and the selected drill unit are also listed.
2007-Jul-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2007-Jul-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+ pcbnew + pcbnew

View File

@ -123,7 +123,7 @@ private:
void UpdatePrecisionOptions(wxCommandEvent& event); void UpdatePrecisionOptions(wxCommandEvent& event);
void UpdateConfig(void); void UpdateConfig(void);
int Plot_Drill_PcbMap( FORET * buffer, int format); int Plot_Drill_PcbMap( FORET * buffer, int format);
void GenDrillReport(const wxString & FullFileName); void GenDrillReport(void);
int Gen_Liste_Forets( FORET * buffer,bool print_header); int Gen_Liste_Forets( FORET * buffer,bool print_header);
int Gen_Drill_File_EXCELLON( FORET * buffer); int Gen_Drill_File_EXCELLON( FORET * buffer);
void Gen_Line_EXCELLON(char *line, float x, float y); void Gen_Line_EXCELLON(char *line, float x, float y);
@ -293,7 +293,7 @@ void WinEDA_DrillFrame::SetParams(void)
/*****************************************************************/ /*****************************************************************/
void WinEDA_PcbFrame::InstallDrillFrame(wxCommandEvent& event) void WinEDA_PcbFrame::InstallDrillFrame(wxCommandEvent& event)
/*****************************************************************/ /*****************************************************************/
/* Thi function display and delete the dialog frame for drill tools /* This function displays and deletes the dialog frame for drill tools
*/ */
{ {
wxConfig * Config = m_Parent->m_EDA_Config; wxConfig * Config = m_Parent->m_EDA_Config;
@ -348,8 +348,8 @@ void WinEDA_DrillFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
void WinEDA_DrillFrame::GenDrillFiles(wxCommandEvent& event) void WinEDA_DrillFrame::GenDrillFiles(wxCommandEvent& event)
/*************************************************************/ /*************************************************************/
{ {
wxString FullFileName, Mask(wxT("*")), Ext(wxT(".drl"));
int ii; int ii;
wxString FullFileName;
wxString msg; wxString msg;
UpdateConfig(); /* set params and Save drill options */ UpdateConfig(); /* set params and Save drill options */
@ -362,13 +362,14 @@ wxString msg;
/* Init nom fichier */ /* Init nom fichier */
FullFileName = m_Parent->m_CurrentScreen->m_FileName; FullFileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FullFileName, wxT(".drl") ); ChangeFileNameExt(FullFileName, Ext);
Mask += Ext;
FullFileName = EDA_FileSelector(_("Drill file"), FullFileName = EDA_FileSelector(_("Drill file"),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */ FullFileName, /* nom fichier par defaut */
wxT(".drl"), /* extension par defaut */ Ext, /* extension par defaut */
wxT("*.drl"), /* Masque d'affichage */ Mask, /* Masque d'affichage */
this, this,
wxFD_SAVE, wxFD_SAVE,
TRUE TRUE
@ -412,10 +413,7 @@ wxString msg;
} }
if ( m_Choice_Drill_Report->GetSelection() > 0 ) if ( m_Choice_Drill_Report->GetSelection() > 0 )
{ GenDrillReport();
FullFileName << wxT(".rpt");
GenDrillReport(FullFileName);
}
EndModal(0); EndModal(0);
} }
@ -869,11 +867,11 @@ wxString msg;
/* Init file name */ /* Init file name */
FullFileName = m_Parent->m_CurrentScreen->m_FileName; FullFileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FullFileName,Ext) ; ChangeFileNameExt(FullFileName, Ext);
Mask += Ext; Mask += Ext;
FullFileName = EDA_FileSelector(_("Drill Map file"), FullFileName = EDA_FileSelector(_("Drill Map file"),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */ FullFileName, /* nom fichier par defaut */
Ext, /* extension par defaut */ Ext, /* extension par defaut */
Mask, /* Masque d'affichage */ Mask, /* Masque d'affichage */
@ -1104,32 +1102,68 @@ wxString msg;
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
sprintf(line,"PU %d, %d; LB%2.2fmm / %2.3f\" (%d holes)", // List the diameter of each drill in the selected Drill Unit,
x + (int)(intervalle * CharScale * fTextScale), // and then its diameter in the other Drill Unit.
y - (int)(CharSize / 2 * CharScale * fTextScale), if ( Unit_Drill_is_Inch )
float(foret->m_Diameter) * 0.00254, sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ",
float(foret->m_Diameter) * 0.0001, x + (int)(intervalle * CharScale * fTextScale),
foret->m_TotalCount ); y - (int)(CharSize / 2 * CharScale * fTextScale),
fputs(line,dest); float(foret->m_Diameter) * 0.0001,
if ( foret->m_OvalCount ) float(foret->m_Diameter) * 0.00254 );
{ else
sprintf(line," (with %d oblongs)", foret->m_OvalCount ); sprintf( line, "PU %d, %d; LB%2.2fmm / %2.3f\" ",
fputs(line,dest); x + (int)(intervalle * CharScale * fTextScale),
} y - (int)(CharSize / 2 * CharScale * fTextScale),
float(foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 );
fputs( line, dest );
// Now list how many holes and ovals are associated with each drill.
if ( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) )
sprintf( line, "(1 hole)\n" );
else if ( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)\n" );
else if ( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)\n",
foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n",
foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)\n",
foret->m_TotalCount,
foret->m_OvalCount );
fputs( line, dest );
fputs("\03;\n",dest); fputs("\03;\n",dest);
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
sprintf(line,"%2.2fmm / %2.3f\" (%d holes)", // List the diameter of each drill in the selected Drill Unit,
float(foret->m_Diameter) * 0.00254, // and then its diameter in the other Drill Unit.
float(foret->m_Diameter) * 0.0001, if ( Unit_Drill_is_Inch )
foret->m_TotalCount ); sprintf( line, "%2.3f\" / %2.2fmm ",
float(foret->m_Diameter) * 0.0001,
float(foret->m_Diameter) * 0.00254 );
else
sprintf( line, "%2.2fmm / %2.3f\" ",
float(foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 );
msg = CONV_FROM_UTF8(line); msg = CONV_FROM_UTF8(line);
if ( foret->m_OvalCount ) // Now list how many holes and ovals are associated with each drill.
{ if ( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) )
sprintf(line," (with %d oblongs)", foret->m_OvalCount ); sprintf( line, "(1 hole)" );
msg += CONV_FROM_UTF8(line); else if ( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 )
} sprintf( line, "(1 hole) (with 1 oblong)" );
else if ( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)",
foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)",
foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)",
foret->m_TotalCount,
foret->m_OvalCount );
msg += CONV_FROM_UTF8(line);
Plot_1_texte(format, msg, 0, TextWidth, Plot_1_texte(format, msg, 0, TextWidth,
x, y, x, y,
(int) (CharSize * CharScale), (int) (CharSize * CharScale),
@ -1382,29 +1416,34 @@ void PlotOvalDrillSymbol(const wxPoint & position,const wxSize & size,int orient
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_pastille_OVALE_HPGL(position, size, orient, FILAIRE); trace_1_pastille_OVALE_HPGL(position, size, orient, FILAIRE);
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
trace_1_pastille_OVALE_POST(position, size, orient, FILAIRE); trace_1_pastille_OVALE_POST(position, size, orient, FILAIRE);
break; break;
} }
} }
/********************************************************************/ /*******************************************/
void WinEDA_DrillFrame::GenDrillReport(const wxString & FullFileName) void WinEDA_DrillFrame::GenDrillReport(void)
/********************************************************************/ /*******************************************/
/* /*
Create a list of drill values and drill count Create a list of drill values and drill count
*/ */
{ {
wxString FileName, Mask(wxT("*")), Ext(wxT(".*")); wxString FileName, Mask(wxT("*")), Ext(wxT(".rpt"));
int ii; int ii, TotalHoleCount;
char line[1024]; char line[1024];
FORET * foret; FORET * foret;
wxString msg;
FileName = FullFileName; FileName = m_Parent->m_CurrentScreen->m_FileName;
FileName = EDA_FileSelector(_("Drill Map file"), ChangeFileNameExt(FileName, wxT("-drl") + Ext);
wxEmptyString, /* Chemin par defaut */ Mask += Ext;
FullFileName, /* nom fichier par defaut */
FileName = EDA_FileSelector(_("Drill Report file"),
wxEmptyString, /* Chemin par defaut */
FileName, /* nom fichier par defaut */
Ext, /* extension par defaut */ Ext, /* extension par defaut */
Mask, /* Masque d'affichage */ Mask, /* Masque d'affichage */
this, this,
@ -1416,34 +1455,70 @@ FORET * foret;
dest = wxFopen(FileName, wxT("w") ); dest = wxFopen(FileName, wxT("w") );
if (dest == 0) if (dest == 0)
{ {
wxString msg = _("Unable to create file ") + FileName; msg = _("Unable to create file ") + FileName;
DisplayError(this, msg); DisplayError(this, msg);
return ; return ;
} }
sprintf(line,"Drill report\n\n" ); m_Parent->MsgPanel->EraseMsgBox();
fputs(line, dest); Affiche_1_Parametre( m_Parent, 0, _("File"), FileName, BLUE );
for(ii = 0, foret = (FORET*)adr_lowmem ; ii < DrillToolsCount; ii++, foret++) /* Determine the list of the different drill diameters. */
ii = Gen_Liste_Forets( (FORET *) adr_lowmem, FALSE );
msg.Printf( wxT("%d"), ii );
Affiche_1_Parametre( m_Parent, 30, _("Tools"), msg, BROWN );
fprintf(dest, "Drill report for %s\n", CONV_TO_UTF8(m_Parent->m_CurrentScreen->m_FileName) );
fprintf(dest, "Created on %s\n", DateAndTime(line));
// List which Drill Unit option had been selected for the associated drill file.
if ( Unit_Drill_is_Inch )
fputs("Selected Drill Unit: Imperial (\")\n\n", dest);
else
fputs("Selected Drill Unit: Metric (mm)\n\n", dest);
TotalHoleCount = 0;
for ( ii = 0, foret = (FORET*)adr_lowmem ; ii < DrillToolsCount; ii++, foret++ )
{ {
int ncount; // List the tool number assigned to each drill,
ncount = foret->m_TotalCount - foret->m_OvalCount; // then its diameter in the selected Drill Unit,
if ( ncount ) // and then its diameter in the other Drill Unit.
sprintf(line,"%2.2fmm %2.3f\" (%d holes)\n", if ( Unit_Drill_is_Inch )
float(foret->m_Diameter) * 0.00254, sprintf( line, "T%d %2.3f\" %2.2fmm ",
ii + 1,
float(foret->m_Diameter) * 0.0001, float(foret->m_Diameter) * 0.0001,
ncount ); float(foret->m_Diameter) * 0.00254 );
if ( foret->m_OvalCount ) else
{ sprintf( line, "T%d %2.2fmm %2.3f\" ",
sprintf(line,"%2.2fmm %2.3f\" (%d oblongs)\n", ii + 1,
float(foret->m_Diameter) * 0.00254, float(foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001, float(foret->m_Diameter) * 0.0001 );
foret->m_OvalCount ); fputs( line, dest );
}
fputs(line, dest); // Now list how many holes and ovals are associated with each drill.
if ( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) )
sprintf( line, "(1 hole)\n" );
else if ( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)\n" );
else if ( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)\n",
foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n",
foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)\n",
foret->m_TotalCount,
foret->m_OvalCount );
fputs( line, dest );
TotalHoleCount += foret->m_TotalCount;
} }
fclose(dest); msg.Printf( wxT("%d"), TotalHoleCount );
Affiche_1_Parametre( m_Parent, 45, _("Drill"), msg, GREEN );
fclose(dest);
} }