Commit f50ec6e0 authored by dickelbeck's avatar dickelbeck

D_PAD::Compare()

parent 1969a511
......@@ -4,6 +4,16 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Jan-24 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew:
* Export a specctra *.dsn file includes some padstacks, not ovals yet.
* Many many refinements to specctra.cpp and specctra.h.
* added COLLECTOR::BasePtr(), which is used in qsort. Could have used
* std::sort() instead.
* Wrote D_PAD::Compare()
* updated todo.txt
2008-Jan-24 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
......@@ -11,7 +21,6 @@ email address.
Bugs about fill zones removed (not all, of course).
Fixed an old bug in block delete (could crashes pcbnew after deleting footprints).
2008-Jan-23 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew:
......
......@@ -249,8 +249,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
{
frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
}
else // Use board frame setting
if( DisplayOpt.DisplayPadFill == FILLED )
else if( DisplayOpt.DisplayPadFill == FILLED ) // Use board frame setting
fillpad = 1;
if( frame->m_DisplayPadFill == FILLED )
......@@ -331,7 +330,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
}
//-----<test this>-----
// if PAD_SMD pad and high contrast mode
if( m_Attribut==PAD_SMD && DisplayOpt.ContrastModeDisplay )
{
......@@ -376,8 +374,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
}
}
}
//-----</test this>----
if( draw_mode & GR_SURBRILL )
{
......@@ -463,6 +459,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
if( DisplayIsol )
{
rotdx = rotdx + g_DesignSettings.m_TrackClearence + g_DesignSettings.m_TrackClearence;
GRCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy,
ux0 - delta_cx, uy0 - delta_cy,
rotdx, color );
......@@ -499,7 +496,9 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
if( DisplayIsol )
{
dx += g_DesignSettings.m_TrackClearence; dy += g_DesignSettings.m_TrackClearence;
dx += g_DesignSettings.m_TrackClearence;
dy += g_DesignSettings.m_TrackClearence;
coord[0].x = -dx - ddy;
coord[0].y = dy + ddx;
......@@ -763,97 +762,6 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
}
#if 0
/***********************************/
int D_PAD::WriteDescr( FILE* File )
/***********************************/
/* Sauvegarde de la description d'un PAD
*/
{
int cshape, NbLigne = 0;;
const char* texttype;
if( GetState( DELETED ) )
return NbLigne;
/* Generation du fichier pad: */
fprintf( File, "$PAD\n" ); NbLigne++;
switch( m_PadShape )
{
case PAD_CIRCLE:
cshape = 'C'; break;
case PAD_RECT:
cshape = 'R'; break;
case PAD_OVAL:
cshape = 'O'; break;
case PAD_TRAPEZOID:
cshape = 'T'; break;
default:
cshape = 'C';
DisplayError( NULL, _( "Unknown Pad shape" ) );
break;
}
fprintf( File, "Sh \"%.4s\" %c %d %d %d %d %d\n",
m_Padname, cshape, m_Size.x, m_Size.y,
m_DeltaSize.x, m_DeltaSize.y, m_Orient );
NbLigne++;
fprintf( File, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y );
if( m_DrillShape == PAD_OVAL )
{
fprintf( File, " %c %d %d", 'O', m_Drill.x, m_Drill.y );
}
fprintf( File, "\n" );
NbLigne++;
switch( m_Attribut )
{
case PAD_STANDARD:
texttype = "STD"; break;
case PAD_SMD:
texttype = "SMD"; break;
case PAD_CONN:
texttype = "CONN"; break;
case PAD_P_HOLE:
texttype = "HOLE"; break;
case MECA:
texttype = "MECA"; break;
default:
texttype = "STD";
DisplayError( NULL, wxT( "attribut Pad inconnu" ) );
break;
}
fprintf( File, "At %s N %8.8X\n", texttype, m_Masque_Layer );
NbLigne++;
fprintf( File, "Ne %d \"%s\"\n", GetNet(), CONV_TO_UTF8( m_Netname ) );
NbLigne++;
fprintf( File, "Po %d %d\n", m_Pos0.x, m_Pos0.y );
NbLigne++;
fprintf( File, "$EndPAD\n" );
NbLigne++;
return NbLigne;
}
#endif
bool D_PAD::Save( FILE* aFile ) const
{
int cshape;
......@@ -1167,8 +1075,66 @@ bool D_PAD::HitTest( const wxPoint& ref_pos )
}
/************************************************************/
int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
/************************************************************/
{
int diff;
if( (diff = padref->m_PadShape - padcmp->m_PadShape) )
return diff;
if( (diff = padref->m_Size.x - padcmp->m_Size.x) )
return diff;
if( (diff = padref->m_Size.y - padcmp->m_Size.y) )
return diff;
if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) )
return diff;
if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) )
return diff;
if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) )
return diff;
if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) )
return diff;
// @todo check if export_gencad still works:
// specctra_export needs this, but maybe export_gencad does not. added on Jan 24 2008 by Dick.
if( (diff = padref->m_Masque_Layer - padcmp->m_Masque_Layer) )
return diff;
return 0;
}
#if defined (DEBUG)
// @todo: could this be useable elsewhere also?
static const char* ShowPadType( int aPadType )
{
switch( aPadType )
{
case PAD_CIRCLE: return "circle";
case PAD_OVAL: return "oval";
case PAD_RECT: return "rect";
case PAD_TRAPEZOID: return "trap";
default: return "??unknown??";
}
}
static const char* ShowPadAttr( int aPadAttr )
{
switch( aPadAttr )
{
case PAD_STANDARD: return "STD";
case PAD_SMD: return "SMD";
case PAD_CONN: return "CONN";
case PAD_P_HOLE: return "HOLE";
case PAD_MECA: return "MECA";
default: return "??unkown??";
}
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
......@@ -1186,6 +1152,8 @@ void D_PAD::Show( int nestLevel, std::ostream& os )
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" shape=\"" << ShowPadType( m_PadShape ) << '"' <<
" attr=\"" << ShowPadAttr( m_Attribut ) << '"' <<
" num=\"" << padname << '"' <<
" net=\"" << m_Netname.mb_str() << '"' <<
" netcode=\"" << GetNet() << '"' <<
......@@ -1196,5 +1164,4 @@ void D_PAD::Show( int nestLevel, std::ostream& os )
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
......@@ -31,8 +31,8 @@ public:
// 2..14 = internal layers
// 16 .. 31 = technical layers
int m_PadShape; // Shape: PAD_CIRCLE, PAD_RECT, OVAL, TRAPEZOID
int m_DrillShape; // Shape PAD_CIRCLE, OVAL
int m_PadShape; // Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID
int m_DrillShape; // Shape PAD_CIRCLE, PAD_OVAL
wxSize m_Drill; // Drill diam (drill shape = PAD_CIRCLE) or drill size(shape = OVAL)
// for drill shape = PAD_CIRCLE, drill diam = m_Drill.x
......@@ -153,6 +153,15 @@ public:
return wxT( "PAD" );
}
/**
* Function Compare
* compares two pads and return 0 if they are equal.
* @return int - <0 if left less than right, 0 if equal, >0 if left greater than right.
*/
static int Compare( const D_PAD* padref, const D_PAD* padcmp );
#if defined (DEBUG)
/**
* Function Show
......
......@@ -145,32 +145,11 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
/**************************************************************************/
static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr )
/**************************************************************************/
/*
* Routine de tri de la liste des pads par type, puis pa taille
*/
{
const D_PAD* padref, * padcmp;
int diff;
const D_PAD* padref = *(D_PAD**)refptr;
const D_PAD* padcmp = *(D_PAD**)objptr;
padref = *( (D_PAD**) refptr );
padcmp = *( (D_PAD**) objptr );
if( (diff = padref->m_PadShape - padcmp->m_PadShape) )
return diff;
if( (diff = padref->m_Size.x - padcmp->m_Size.x) )
return diff;
if( (diff = padref->m_Size.y - padcmp->m_Size.y) )
return diff;
if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) )
return diff;
if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) )
return diff;
if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) )
return diff;
if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) )
return diff;
return 0;
return D_PAD::Compare( padref, padcmp );
}
......@@ -209,15 +188,7 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
pad = *padlist;
pad->m_logical_connexion = pad_name_number;
if( old_pad
&& (old_pad->m_PadShape == pad->m_PadShape)
&& (old_pad->m_Size.x == pad->m_Size.x)
&& (old_pad->m_Size.y == pad->m_Size.y)
&& (old_pad->m_Offset.x == pad->m_Offset.x)
&& (old_pad->m_Offset.y == pad->m_Offset.y)
&& (old_pad->m_DeltaSize.x == pad->m_DeltaSize.x)
&& (old_pad->m_DeltaSize.y == pad->m_DeltaSize.y)
)
if( old_pad && 0==D_PAD::Compare( old_pad, pad ) )
continue; // Forme deja generee
old_pad = pad;
......
......@@ -70,3 +70,15 @@ asked by: jp Charras
================================================================================
Use the collector classes in eeschema.
2008-Jan-24 Assigned To: nobody
asked by: Dick Hollenbeck
================================================================================
See specctra.h's such comment
* @todo
* I would have liked to put the flipping logic into the ExportToSPECCTRA()
* function directly, but for some strange reason,
* void Change_Side_Module( MODULE* Module, wxDC* DC ) is a member of
* of class WinEDA_BasePcbFrame rather than class BOARD.
*
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