Commit 4b04d6c2 authored by dickelbeck's avatar dickelbeck

fix for magnetic tracks for parallel case, cleanup of original patches

parent 5cb57e3b
...@@ -5,23 +5,28 @@ Started 2007-June-11 ...@@ -5,23 +5,28 @@ 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.
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> 2008-Feb-29 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+eeschema +eeschema
Renaming the sheet filename now works in simple and complex hierarchies. Renaming the sheet filename now works in simple and complex hierarchies.
Use carefully because this can change the whole schematic structure. Use carefully because this can change the whole schematic structure.
Gen Bom List now works in unicode build version Gen Bom List now works in unicode build version
(label list generation crashed eeschema in unicode build version) (label list generation crashed eeschema in unicode build version)
+all +all
Display filename and full sheet name ("sheet path") in sheet reference Display filename and full sheet name ("sheet path") in sheet reference
the full sheet name has no meanning in pcbnew. the full sheet name has no meanning in pcbnew.
2008-Feb-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Feb-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+eeschema +eeschema
Fixed: problem which could crash eeschema when a sub schematic file in a hierarchy was not found. Fixed: problem which could crash eeschema when a sub schematic file in a hierarchy was not found.
2008-Feb-27 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net> 2008-Feb-27 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net>
...@@ -40,18 +45,16 @@ email address. ...@@ -40,18 +45,16 @@ email address.
2008-Feb-26 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Feb-26 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+eeschema +eeschema
changed in class DrawSheetStruct m_s member name to m_AssociatedScreen changed in class DrawSheetStruct m_s member name to m_AssociatedScreen
some others minor problems solved. some others minor problems solved.
some files "uncrustified" some files "uncrustified"
Major problem in undo/redo when a sheet is deleted not yet solved Major problem in undo/redo when a sheet is deleted not yet solved
Only for a complex hierarchy, could lost data. Only for a complex hierarchy, could lost data.
When a sheet is deleted by block delete. it is put in undo list. When a sheet is deleted by block delete. it is put in undo list.
It is really deleted after 10 changes (when the undo list is full). It is really deleted after 10 changes (when the undo list is full).
At this time, the associated data is also deleted. At this time, the associated data is also deleted.
If an other (not deleted) sheet shares the same data, this data is lost. If an other (not deleted) sheet shares the same data, this data is lost.
Need work to solve this problem and keep the undo/redo feature. Need work to solve this problem and keep the undo/redo feature.
2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net> 2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net>
......
...@@ -55,22 +55,22 @@ SchematicGeneralLocateAndDisplay( bool IncludePin ) ...@@ -55,22 +55,22 @@ SchematicGeneralLocateAndDisplay( bool IncludePin )
/* Cross probing to pcbnew if a pin or a component is found */ /* Cross probing to pcbnew if a pin or a component is found */
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case DRAW_PART_TEXT_STRUCT_TYPE: case DRAW_PART_TEXT_STRUCT_TYPE:
case COMPONENT_FIELD_DRAW_TYPE: case COMPONENT_FIELD_DRAW_TYPE:
LibItem = (EDA_SchComponentStruct*) DrawStruct->m_Parent; LibItem = (EDA_SchComponentStruct*) DrawStruct->m_Parent;
SendMessageToPCBNEW( DrawStruct,LibItem ); SendMessageToPCBNEW( DrawStruct,LibItem );
break; break;
case DRAW_LIB_ITEM_STRUCT_TYPE: case DRAW_LIB_ITEM_STRUCT_TYPE:
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem ); Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
if( Pin ) if( Pin )
break; // Priority is probing a pin first break; // Priority is probing a pin first
LibItem = (EDA_SchComponentStruct*) DrawStruct; LibItem = (EDA_SchComponentStruct*) DrawStruct;
SendMessageToPCBNEW( DrawStruct, LibItem ); SendMessageToPCBNEW( DrawStruct, LibItem );
break; break;
default: default:
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem ); Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
break; break;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
...@@ -89,7 +89,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin ) ...@@ -89,7 +89,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin )
CYAN ); CYAN );
// Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net) // Cross probing:2 - pin found, and send a locate pin command to pcbnew (hightlight net)
SendMessageToPCBNEW( Pin, LibItem ); SendMessageToPCBNEW( Pin, LibItem );
} }
return DrawStruct; return DrawStruct;
} }
...@@ -156,7 +156,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) ...@@ -156,7 +156,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
WIREITEM | BUSITEM | RACCORDITEM ); WIREITEM | BUSITEM | RACCORDITEM );
if( DrawStruct ) // Search for a pin if( DrawStruct ) // Search for a pin
{ {
Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem ); Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
if( Pin ) if( Pin )
{ {
Pin->Display_Infos( this ); Pin->Display_Infos( this );
...@@ -182,7 +182,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin ) ...@@ -182,7 +182,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
} }
/* search for a pin */ /* search for a pin */
Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem ); Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
if( Pin ) if( Pin )
{ {
Pin->Display_Infos( this ); Pin->Display_Infos( this );
...@@ -230,16 +230,16 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ...@@ -230,16 +230,16 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
/***********************************************************************/ /***********************************************************************/
{ {
wxSize delta; wxSize delta;
SCH_SCREEN* screen = (SCH_SCREEN*)GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*)GetScreen();
int zoom = screen->GetZoom(); int zoom = screen->GetZoom();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
int hotkey = 0; int hotkey = 0;
curpos = screen->m_MousePosition; curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
delta.x = screen->GetGrid().x / zoom; delta.x = screen->GetGrid().x / zoom;
delta.y = screen->GetGrid().y / zoom; delta.y = screen->GetGrid().y / zoom;
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
...@@ -253,37 +253,37 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ...@@ -253,37 +253,37 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
case EDA_PANNING_UP_KEY: case EDA_PANNING_UP_KEY:
OnZoom( ID_ZOOM_PANNING_UP ); OnZoom( ID_ZOOM_PANNING_UP );
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
break; break;
case EDA_PANNING_DOWN_KEY: case EDA_PANNING_DOWN_KEY:
OnZoom( ID_ZOOM_PANNING_DOWN ); OnZoom( ID_ZOOM_PANNING_DOWN );
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
break; break;
case EDA_PANNING_LEFT_KEY: case EDA_PANNING_LEFT_KEY:
OnZoom( ID_ZOOM_PANNING_LEFT ); OnZoom( ID_ZOOM_PANNING_LEFT );
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
break; break;
case EDA_PANNING_RIGHT_KEY: case EDA_PANNING_RIGHT_KEY:
OnZoom( ID_ZOOM_PANNING_RIGHT ); OnZoom( ID_ZOOM_PANNING_RIGHT );
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
break; break;
case EDA_ZOOM_IN_FROM_MOUSE: case EDA_ZOOM_IN_FROM_MOUSE:
OnZoom( ID_ZOOM_IN_KEY ); OnZoom( ID_ZOOM_IN_KEY );
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
break; break;
case EDA_ZOOM_OUT_FROM_MOUSE: case EDA_ZOOM_OUT_FROM_MOUSE:
OnZoom( ID_ZOOM_OUT_KEY ); OnZoom( ID_ZOOM_OUT_KEY );
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
break; break;
case EDA_ZOOM_CENTER_FROM_MOUSE: case EDA_ZOOM_CENTER_FROM_MOUSE:
OnZoom( ID_ZOOM_CENTER_KEY ); OnZoom( ID_ZOOM_CENTER_KEY );
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
break; break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
...@@ -294,6 +294,7 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ...@@ -294,6 +294,7 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_DOWN: case WXK_DOWN:
D(printf("DOWN\n");)
MousePositionInPixels.y += delta.y; MousePositionInPixels.y += delta.y;
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
...@@ -316,22 +317,22 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ...@@ -316,22 +317,22 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
} }
/* Recalcul de la position du curseur schema */ /* Recalcul de la position du curseur schema */
screen->m_Curseur = curpos; screen->m_Curseur = curpos;
/* Placement sur la grille generale */ /* Placement sur la grille generale */
PutOnGrid( &(screen->m_Curseur) ); PutOnGrid( &(screen->m_Curseur) );
if( screen->IsRefreshReq() ) if( screen->IsRefreshReq() )
{ {
RedrawActiveWindow( DC, TRUE ); RedrawActiveWindow( DC, TRUE );
} }
if( oldpos != screen->m_Curseur ) if( oldpos != screen->m_Curseur )
{ {
curpos = screen->m_Curseur; curpos = screen->m_Curseur;
screen->m_Curseur = oldpos; screen->m_Curseur = oldpos;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = curpos; GetScreen()->m_Curseur = curpos;
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
...@@ -342,9 +343,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ...@@ -342,9 +343,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
if( hotkey ) if( hotkey )
{ {
if( screen->GetCurItem() if( screen->GetCurItem()
&& screen->GetCurItem()->m_Flags ) && screen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, screen->GetCurItem() ); OnHotKey( DC, hotkey, screen->GetCurItem() );
else else
OnHotKey( DC, hotkey, NULL ); OnHotKey( DC, hotkey, NULL );
} }
......
...@@ -219,14 +219,20 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) ...@@ -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. * 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, * Join returns the point in "res" and "true" if a suitable point was found,
* "false" if both lines are parallel. * "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; int64_t denom;
double t; double t;
...@@ -234,16 +240,18 @@ static bool Join( wxPoint& res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 ) ...@@ -234,16 +240,18 @@ static bool Join( wxPoint& res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
b1 -= b0; b1 -= b0;
b0 -= a0; b0 -= a0;
denom = (int64_t) b1.y*a1.x - (int64_t) b1.x*a1.y; denom = (int64_t) b1.y * a1.x - (int64_t) b1.x * a1.y;
if (!denom) if( !denom )
return false; // parallel {
return false; // parallel
}
t = ((int64_t) b1.y*b0.x - (int64_t) b1.x*b0.y)/(double) denom; t = ((int64_t) b1.y * b0.x - (int64_t) b1.x * b0.y ) / (double) denom;
t = min( max( t, 0.0 ), 1.0 ); t = min( max( t, 0.0 ), 1.0 );
res.x = (int) round(a0.x+t*a1.x); res->x = (int) round( a0.x + t * a1.x );
res.y = (int) round(a0.y+t*a1.y); res->y = (int) round( a0.y + t * a1.y );
return true; return true;
} }
...@@ -253,7 +261,7 @@ static bool Join( wxPoint& res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 ) ...@@ -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 * "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. * 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; wxPoint vec;
double t; double t;
...@@ -269,31 +277,40 @@ bool Project( wxPoint& res, wxPoint on_grid, const TRACK* track ) ...@@ -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 /= (int64_t) vec.x*vec.x + (int64_t) vec.y*vec.y;
t = min( max( t, 0.0 ), 1.0 ); t = min( max( t, 0.0 ), 1.0 );
res.x = (int) round( track->m_Start.x + t*vec.x ); res->x = (int) round( track->m_Start.x + t*vec.x );
res.y = (int) round( track->m_Start.y + t*vec.y ); res->y = (int) round( track->m_Start.y + t*vec.y );
return true; 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, 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; D_PAD* pad;
const TRACK* curr = NULL; TRACK* curr = g_CurrentTrackSegment;
const TRACK* via, * track; TRACK* via;
int layer, layer_mask; 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 ) if( frame->GetCurItem() != curr )
{
curr = NULL; curr = NULL;
}
switch( g_MagneticPadOption ) switch( g_MagneticPadOption )
{ {
case capture_cursor_in_track_tool: case capture_cursor_in_track_tool:
if( m_ID_current_state != ID_TRACK_BUTT ) if( aCurrentTool != ID_TRACK_BUTT )
return false; return false;
break; break;
...@@ -308,20 +325,22 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -308,20 +325,22 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE ); pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE );
if( pad ) if( pad )
{ {
if( curr && curr->GetNet() != pad->GetNet() && sometimes ) if( doCheckNet && curr && curr->GetNet() != pad->GetNet() )
return false; return false;
curpos = pad->m_Pos;
*curpos = pad->m_Pos;
return true; return true;
} }
layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer; 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( via )
{ {
if( curr && curr->GetNet() != via->GetNet() && sometimes ) if( doCheckNet && curr && curr->GetNet() != via->GetNet() )
return false; return false;
curpos = via->m_Start;
*curpos = via->m_Start;
return true; return true;
} }
...@@ -340,25 +359,57 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -340,25 +359,57 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
* In two segment mode, ignore the final segment if it's inside a grid * In two segment mode, ignore the final segment if it's inside a grid
* square. * 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.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->m_Start.y + grid.y > curr->m_End.y ) && curr->m_Start.y + grid.y > curr->m_End.y )
{
curr = curr->Back(); curr = curr->Back();
}
track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE ); for( track = m_Pcb->m_Track; track; track = track->Next() )
for( ; track; track = track->Next() )
{ {
if( track->Type() != TYPETRACK ) if( track->Type() != TYPETRACK )
continue; continue;
if( curr->GetNet() != track->GetNet() && sometimes ) if( doCheckNet && curr->GetNet() != track->GetNet() )
continue; continue;
if( Join( curpos, track->m_Start, track->m_End, if( (g_DesignSettings.m_LayerColor[track->GetLayer()] & ITEM_NOT_SHOW) )
curr->m_Start, curr->m_End ) ) 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; 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; return false;
...@@ -505,20 +556,21 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -505,20 +556,21 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
PutOnGrid( &on_grid ); PutOnGrid( &on_grid );
if( Magnetize(m_Pcb, (WinEDA_PcbFrame *) this, m_ID_current_state, 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; GetScreen()->m_Curseur = curpos;
}
else else
{ {
/* // If there's no intrusion and DRC is active, we pass the cursor
* If there's an intrusion and DRC is active, we pass the cursor // "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
* "as is", and let ShowNewTrackWhenMovingCursor figure our what to
* do.
*/
if( !Drc_On || !g_CurrentTrackSegment if( !Drc_On || !g_CurrentTrackSegment
|| g_CurrentTrackSegment != this->GetCurItem() || g_CurrentTrackSegment != this->GetCurItem()
|| !LocateIntrusion(m_Pcb->m_Track, g_CurrentTrackSegment->GetNet(), || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment->GetNet(),
g_CurrentTrackSegment->m_Width ) ) g_CurrentTrackSegment->m_Width ) )
{
GetScreen()->m_Curseur = on_grid; GetScreen()->m_Curseur = on_grid;
}
} }
} }
......
...@@ -500,44 +500,41 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) ...@@ -500,44 +500,41 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
TRACK* LocateIntrusion( TRACK* start, int net, int width ) TRACK* LocateIntrusion( TRACK* start, int net, int width )
{ {
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer; 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 );
{
int dist;
wxPoint pos, vec;
int64_t tmp;
/* Locate_Pistes */ TRACK* found = NULL;
if( track->GetState( BUSY | DELETED ) )
continue;
if( !(g_TabOneLayerMask[track->GetLayer()] & layer_mask) ) for( TRACK* track = start; track; track = track->Next() )
continue; {
if( track->Type() == TYPETRACK ) // skip vias
{
if( track->GetState( BUSY | DELETED ) )
continue;
if( track->GetNet() == net ) if( layer != track->GetLayer() )
continue; continue;
if( track->Type() == TYPEVIA ) if( track->GetNet() == net )
continue; continue;
/* TRACK::HitTest */ /* TRACK::HitTest */
dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence; int dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence;
pos = ref - track->m_Start;
vec = track->m_End - track->m_Start;
if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) ) wxPoint pos = ref - track->m_Start;
continue; wxPoint vec = track->m_End - track->m_Start;
found = track; if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) )
continue;
/* prefer intrusions from the side, not the end */ found = track;
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 ) /* prefer intrusions from the side, not the end */
break; 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; return found;
...@@ -612,7 +609,7 @@ static void PushTrack( WinEDA_DrawPanel* panel ) ...@@ -612,7 +609,7 @@ static void PushTrack( WinEDA_DrawPanel* panel )
n.x = (int) round( f * n.x ); n.x = (int) round( f * n.x );
n.y = (int) round( f * n.y ); n.y = (int) round( f * n.y );
Project( track->m_End, cursor, other ); Project( &track->m_End, cursor, other );
track->m_End += n; track->m_End += n;
} }
......
...@@ -387,7 +387,7 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm ...@@ -387,7 +387,7 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm
/* CONTROLE.CPP */ /* CONTROLE.CPP */
/****************/ /****************/
void RemoteCommand( const char* cmdline ); 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 );
/***************/ /***************/
......
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