fix for magnetic tracks for parallel case, cleanup of original patches
This commit is contained in:
parent
5cb57e3b3b
commit
4b04d6c287
|
@ -5,6 +5,12 @@ Started 2007-June-11
|
|||
Please add newer entries at the top, list the date and your name with
|
||||
email address.
|
||||
|
||||
2008-Feb-29 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||
================================================================================
|
||||
+pcbnew
|
||||
controle.cpp: fixed the magnetic track if tracks are parallel.
|
||||
|
||||
|
||||
2008-Feb-29 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||
================================================================================
|
||||
+eeschema
|
||||
|
@ -12,7 +18,6 @@ email address.
|
|||
Use carefully because this can change the whole schematic structure.
|
||||
Gen Bom List now works in unicode build version
|
||||
(label list generation crashed eeschema in unicode build version)
|
||||
|
||||
+all
|
||||
Display filename and full sheet name ("sheet path") in sheet reference
|
||||
the full sheet name has no meanning in pcbnew.
|
||||
|
@ -52,8 +57,6 @@ email address.
|
|||
Need work to solve this problem and keep the undo/redo feature.
|
||||
|
||||
|
||||
|
||||
|
||||
2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net>
|
||||
================================================================================
|
||||
+eeschema
|
||||
|
|
|
@ -294,6 +294,7 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
|
|||
|
||||
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
|
||||
case WXK_DOWN:
|
||||
D(printf("DOWN\n");)
|
||||
MousePositionInPixels.y += delta.y;
|
||||
DrawPanel->MouseTo( MousePositionInPixels );
|
||||
break;
|
||||
|
|
|
@ -219,14 +219,20 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* "Join" finds the point where b0+x*(b1-b0) intersects with a0+y*(a1-a0).
|
||||
/**
|
||||
* Function Join
|
||||
* finds the point where b0+x*(b1-b0) intersects with a0+y*(a1-a0).
|
||||
* If that point would be outside of a0-a1, the respective endpoint is used.
|
||||
* Join returns the point in "res" and "true" if a suitable point was found,
|
||||
* "false" if both lines are parallel.
|
||||
*/
|
||||
static bool Join( wxPoint& res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
|
||||
static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
|
||||
{
|
||||
/* References:
|
||||
http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
|
||||
http://www.gekkou.co.uk/blogs/monologues/2007/12/13/1197586800000.html
|
||||
*/
|
||||
|
||||
int64_t denom;
|
||||
double t;
|
||||
|
||||
|
@ -236,14 +242,16 @@ static bool Join( wxPoint& res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
|
|||
|
||||
denom = (int64_t) b1.y * a1.x - (int64_t) 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 = min( max( t, 0.0 ), 1.0 );
|
||||
|
||||
res.x = (int) round(a0.x+t*a1.x);
|
||||
res.y = (int) round(a0.y+t*a1.y);
|
||||
res->x = (int) round( a0.x + t * a1.x );
|
||||
res->y = (int) round( a0.y + t * a1.y );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -253,7 +261,7 @@ static bool Join( wxPoint& res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
|
|||
* "Project" finds the projection of a grid point on a track. This is the point
|
||||
* from where we want to draw new orthogonal tracks when starting on a track.
|
||||
*/
|
||||
bool Project( wxPoint& res, wxPoint on_grid, const TRACK* track )
|
||||
bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track )
|
||||
{
|
||||
wxPoint vec;
|
||||
double t;
|
||||
|
@ -269,31 +277,40 @@ bool Project( wxPoint& res, wxPoint on_grid, const TRACK* track )
|
|||
t /= (int64_t) vec.x*vec.x + (int64_t) 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function Magnetize
|
||||
* tests to see if there are any magnetic items within near reach of the given
|
||||
* "curpos". If yes, then curpos is adjusted appropriately according to that
|
||||
* near magnetic item and true is returned.
|
||||
* @param curpos The initial position, and what to adjust if a change is needed.
|
||||
*/
|
||||
static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
|
||||
int m_ID_current_state, wxSize grid, wxPoint on_grid, wxPoint& curpos )
|
||||
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos )
|
||||
{
|
||||
const D_PAD* pad;
|
||||
const TRACK* curr = NULL;
|
||||
const TRACK* via, * track;
|
||||
D_PAD* pad;
|
||||
TRACK* curr = g_CurrentTrackSegment;
|
||||
TRACK* via;
|
||||
TRACK* track;
|
||||
int layer, layer_mask;
|
||||
|
||||
bool sometimes = g_MagneticPadOption != capture_always && Drc_On;
|
||||
bool doCheckNet = g_MagneticPadOption != capture_always && Drc_On;
|
||||
|
||||
curr = g_CurrentTrackSegment;
|
||||
if( frame->GetCurItem() != curr )
|
||||
{
|
||||
curr = NULL;
|
||||
}
|
||||
|
||||
switch( g_MagneticPadOption )
|
||||
{
|
||||
case capture_cursor_in_track_tool:
|
||||
if( m_ID_current_state != ID_TRACK_BUTT )
|
||||
if( aCurrentTool != ID_TRACK_BUTT )
|
||||
return false;
|
||||
break;
|
||||
|
||||
|
@ -308,20 +325,22 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
|
|||
pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE );
|
||||
if( pad )
|
||||
{
|
||||
if( curr && curr->GetNet() != pad->GetNet() && sometimes )
|
||||
if( doCheckNet && curr && curr->GetNet() != pad->GetNet() )
|
||||
return false;
|
||||
curpos = pad->m_Pos;
|
||||
|
||||
*curpos = pad->m_Pos;
|
||||
return true;
|
||||
}
|
||||
|
||||
layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
|
||||
|
||||
via = Locate_Via_Area( m_Pcb, curpos, layer );
|
||||
via = Locate_Via_Area( m_Pcb, *curpos, layer );
|
||||
if( via )
|
||||
{
|
||||
if( curr && curr->GetNet() != via->GetNet() && sometimes )
|
||||
if( doCheckNet && curr && curr->GetNet() != via->GetNet() )
|
||||
return false;
|
||||
curpos = via->m_Start;
|
||||
|
||||
*curpos = via->m_Start;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -340,27 +359,59 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
|
|||
* In two segment mode, ignore the final segment if it's inside a grid
|
||||
* square.
|
||||
*/
|
||||
if( g_TwoSegmentTrackBuild && curr->Pback
|
||||
if( g_TwoSegmentTrackBuild && curr->Back()
|
||||
&& curr->m_Start.x - grid.x < curr->m_End.x
|
||||
&& curr->m_Start.x + grid.x > curr->m_End.x
|
||||
&& curr->m_Start.y - grid.y < curr->m_End.y
|
||||
&& curr->m_Start.y + grid.y > curr->m_End.y )
|
||||
{
|
||||
curr = curr->Back();
|
||||
}
|
||||
|
||||
track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE );
|
||||
for( ; track; track = track->Next() )
|
||||
for( track = m_Pcb->m_Track; track; track = track->Next() )
|
||||
{
|
||||
if( track->Type() != TYPETRACK )
|
||||
continue;
|
||||
|
||||
if( curr->GetNet() != track->GetNet() && sometimes )
|
||||
if( doCheckNet && curr->GetNet() != track->GetNet() )
|
||||
continue;
|
||||
|
||||
if( Join( curpos, track->m_Start, track->m_End,
|
||||
curr->m_Start, curr->m_End ) )
|
||||
if( (g_DesignSettings.m_LayerColor[track->GetLayer()] & ITEM_NOT_SHOW) )
|
||||
continue;
|
||||
|
||||
if( !track->IsOnLayer( layer ) )
|
||||
continue;
|
||||
|
||||
// @todo, this should be a track overlap test, not a mouse on track test.
|
||||
// The former would consider the new track's width.
|
||||
if( !track->HitTest( *curpos ) )
|
||||
continue;
|
||||
|
||||
if( Join( curpos, track->m_Start, track->m_End, curr->m_Start, curr->m_End ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( aCurrentTool == ID_TRACK_BUTT )
|
||||
{
|
||||
// At this point we have a drawing mouse on a track, we are drawing
|
||||
// a new track and that new track is parallel to the track the
|
||||
// mouse is on. Find the nearest end point of the track under mouse
|
||||
// to the mouse and return that.
|
||||
double distStart = hypot( double( curpos->x - track->m_Start.x ),
|
||||
double( curpos->y - track->m_Start.y ));
|
||||
|
||||
double distEnd = hypot( double( curpos->x - track->m_End.x ),
|
||||
double( curpos->y - track->m_End.y ));
|
||||
|
||||
if( distStart < distEnd )
|
||||
*curpos = track->m_Start;
|
||||
else
|
||||
*curpos = track->m_End;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -505,22 +556,23 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
|
|||
|
||||
PutOnGrid( &on_grid );
|
||||
if( Magnetize(m_Pcb, (WinEDA_PcbFrame *) this, m_ID_current_state,
|
||||
GetScreen()->GetGrid(), on_grid, curpos) )
|
||||
GetScreen()->GetGrid(), on_grid, &curpos) )
|
||||
{
|
||||
GetScreen()->m_Curseur = curpos;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* If there's an intrusion and DRC is active, we pass the cursor
|
||||
* "as is", and let ShowNewTrackWhenMovingCursor figure our what to
|
||||
* do.
|
||||
*/
|
||||
// If there's no intrusion and DRC is active, we pass the cursor
|
||||
// "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
|
||||
if( !Drc_On || !g_CurrentTrackSegment
|
||||
|| g_CurrentTrackSegment != this->GetCurItem()
|
||||
|| !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment->GetNet(),
|
||||
g_CurrentTrackSegment->m_Width ) )
|
||||
{
|
||||
GetScreen()->m_Curseur = on_grid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( oldpos != GetScreen()->m_Curseur )
|
||||
{
|
||||
|
|
|
@ -501,33 +501,29 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
|
|||
TRACK* LocateIntrusion( TRACK* start, int net, int width )
|
||||
{
|
||||
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
|
||||
int layer_mask = g_TabOneLayerMask[layer];
|
||||
wxPoint ref = ActiveScreen->RefPos( 1 );
|
||||
TRACK* track, * found = NULL;
|
||||
|
||||
for( track = start; track; track = track->Next() )
|
||||
wxPoint ref = ActiveScreen->RefPos( true );
|
||||
|
||||
TRACK* found = NULL;
|
||||
|
||||
for( TRACK* track = start; track; track = track->Next() )
|
||||
{
|
||||
if( track->Type() == TYPETRACK ) // skip vias
|
||||
{
|
||||
int dist;
|
||||
wxPoint pos, vec;
|
||||
int64_t tmp;
|
||||
|
||||
/* Locate_Pistes */
|
||||
if( track->GetState( BUSY | DELETED ) )
|
||||
continue;
|
||||
|
||||
if( !(g_TabOneLayerMask[track->GetLayer()] & layer_mask) )
|
||||
if( layer != track->GetLayer() )
|
||||
continue;
|
||||
|
||||
if( track->GetNet() == net )
|
||||
continue;
|
||||
|
||||
if( track->Type() == TYPEVIA )
|
||||
continue;
|
||||
|
||||
/* TRACK::HitTest */
|
||||
dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence;
|
||||
pos = ref - track->m_Start;
|
||||
vec = track->m_End - track->m_Start;
|
||||
int dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence;
|
||||
|
||||
wxPoint pos = ref - track->m_Start;
|
||||
wxPoint vec = track->m_End - track->m_Start;
|
||||
|
||||
if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) )
|
||||
continue;
|
||||
|
@ -535,10 +531,11 @@ TRACK* LocateIntrusion( TRACK* start, int net, int width )
|
|||
found = track;
|
||||
|
||||
/* prefer intrusions from the side, not the end */
|
||||
tmp = (int64_t) pos.x * vec.x + (int64_t) pos.y * vec.y;
|
||||
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 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
@ -612,7 +609,7 @@ static void PushTrack( WinEDA_DrawPanel* panel )
|
|||
n.x = (int) round( f * n.x );
|
||||
n.y = (int) round( f * n.y );
|
||||
|
||||
Project( track->m_End, cursor, other );
|
||||
Project( &track->m_End, cursor, other );
|
||||
track->m_End += n;
|
||||
}
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm
|
|||
/* CONTROLE.CPP */
|
||||
/****************/
|
||||
void RemoteCommand( const char* cmdline );
|
||||
bool Project( wxPoint& res, wxPoint on_grid, const TRACK* track );
|
||||
bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track );
|
||||
|
||||
|
||||
/***************/
|
||||
|
|
Loading…
Reference in New Issue