From fcc86fb007d3f337c45169a7358c6a50ce459dc7 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Fri, 29 Feb 2008 23:01:30 +0000 Subject: [PATCH] fix for magnetic tracks for parallel case, cleanup of original patches --- pcbnew/class_track.cpp | 4 ++-- pcbnew/controle.cpp | 16 ++++++++-------- pcbnew/editrack.cpp | 10 +++++----- pcbnew/specctra_import.cpp | 9 +++++++++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index caab31f715..dcc5d528cd 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -890,8 +890,8 @@ bool TRACK::HitTest( const wxPoint& ref_pos ) if( Type() == TYPEVIA ) /* VIA rencontree */ { - return (int64_t) spot_cX*spot_cX + (int64_t) spot_cY*spot_cY <= - (int64_t) l_piste*l_piste; + return (double) spot_cX * spot_cX + (double) spot_cY * spot_cY <= + (double) l_piste * l_piste; } else { diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 710ae07c31..fda09cf0a1 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -233,20 +233,20 @@ static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 ) http://www.gekkou.co.uk/blogs/monologues/2007/12/13/1197586800000.html */ - int64_t denom; + double denom; double t; a1 -= a0; b1 -= b0; b0 -= a0; - denom = (int64_t) b1.y * a1.x - (int64_t) b1.x * a1.y; + denom = (double) b1.y * a1.x - (double) b1.x * a1.y; if( !denom ) { return false; // parallel } - t = ((int64_t) b1.y * b0.x - (int64_t) b1.x * b0.y ) / (double) denom; + t = ((double) b1.y * b0.x - (double) b1.x * b0.y ) / denom; t = min( max( t, 0.0 ), 1.0 ); @@ -271,14 +271,14 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ) vec = track->m_End-track->m_Start; - t = (int64_t) (on_grid.x-track->m_Start.x)*vec.x + - (int64_t) (on_grid.y-track->m_Start.y)*vec.y; + t = double( on_grid.x - track->m_Start.x ) * vec.x + + double( on_grid.y - track->m_Start.y ) * vec.y; - t /= (int64_t) vec.x*vec.x + (int64_t) vec.y*vec.y; + t /= (double) vec.x * vec.x + (double) vec.y * vec.y; t = min( max( t, 0.0 ), 1.0 ); - res->x = (int) round( track->m_Start.x + t*vec.x ); - res->y = (int) round( track->m_Start.y + t*vec.y ); + res->x = (int) round( track->m_Start.x + t * vec.x ); + res->y = (int) round( track->m_Start.y + t * vec.y ); return true; } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 11ef54904e..df0e37bab3 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -531,8 +531,8 @@ TRACK* LocateIntrusion( TRACK* start, int net, int width ) found = track; /* prefer intrusions from the side, not the end */ - int64_t tmp = (int64_t) pos.x * vec.x + (int64_t) pos.y * vec.y; - if( tmp >= 0 && tmp <= (int64_t) vec.x * vec.x + (int64_t) vec.y * vec.y ) + double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y; + if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y * vec.y ) break; } } @@ -564,7 +564,7 @@ static void PushTrack( WinEDA_DrawPanel* panel ) wxPoint cv, vec, n; TRACK* track = g_CurrentTrackSegment; TRACK* other; - int64_t det; + double det; int dist; double f; @@ -580,7 +580,7 @@ static void PushTrack( WinEDA_DrawPanel* panel ) cv = cursor - other->m_Start; vec = other->m_End - other->m_Start; - det = (int64_t) cv.x * vec.y - (int64_t) cv.y * vec.x; + det = (double) cv.x * vec.y - (double) cv.y * vec.x; /* cursor is right at the center of the old track */ if( !det ) @@ -605,7 +605,7 @@ static void PushTrack( WinEDA_DrawPanel* panel ) n.x = -vec.y; n.y = vec.x; } - f = dist / hypot( n.x, n.y ); + f = dist / hypot( double(n.x), double(n.y) ); n.x = (int) round( f * n.x ); n.y = (int) round( f * n.y ); diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 92c0b43928..36a637886c 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -506,6 +506,15 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError ) PADSTACK* padstack = library.FindPADSTACK( wire_via->GetPadstackId() ); if( !padstack ) { + // Dick Feb 29, 2008: + // Freerouter has a bug where it will not round trip all vias. + // Vias which have a (use_via) element will be round tripped. + // Vias which do not, don't come back in in the session library, + // even though they may be actually used in the pre-routed, + // protected wire_vias. So until that is fixed, create the + // padstack from its name as a work around. + + // Could use a STRINGFORMATTER here and convert the entire // wire_via to text and put that text into the exception. wxString psid( CONV_FROM_UTF8( wire_via->GetPadstackId().c_str() ) );