Loading pcbnew/controle.cpp +20 −20 Original line number Original line Diff line number Diff line Loading @@ -499,24 +499,24 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags ) keep_on_grid = TRUE; keep_on_grid = TRUE; if (keep_on_grid) { if( keep_on_grid ) { wxPoint on_grid = curpos; wxPoint on_grid = curpos; 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 extern TRACK *LocateIntrusion(TRACK *start, int net, int width); { /* /* * If there's an 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 our what to * "as is", and let ShowNewTrackWhenMovingCursor figure our what to * do. * 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; } } Loading pcbnew/editrack.cpp +97 −88 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,8 @@ #include "protos.h" #include "protos.h" #include "drc_stuff.h" #include "drc_stuff.h" #include "trigo.h" /* Routines Locales */ /* Routines Locales */ Loading Loading @@ -281,6 +283,7 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ) pas_45 = GetScreen()->GetGrid().x / 2; pas_45 = GetScreen()->GetGrid().x / 2; if( pas_45 < pt_segm->m_Width ) if( pas_45 < pt_segm->m_Width ) pas_45 = GetScreen()->GetGrid().x; pas_45 = GetScreen()->GetGrid().x; while( pas_45 < pt_segm->m_Width ) while( pas_45 < pt_segm->m_Width ) pas_45 *= 2; pas_45 *= 2; Loading Loading @@ -436,6 +439,7 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) { { adr_buf = (TRACK*) LockPoint; adr_buf = (TRACK*) LockPoint; g_HightLigth_NetCode = adr_buf->GetNet(); g_HightLigth_NetCode = adr_buf->GetNet(); /* creation eventuelle d'un point d'accrochage */ /* creation eventuelle d'un point d'accrochage */ LockPoint = CreateLockPoint( &g_CurrentTrackSegment->m_End.x, LockPoint = CreateLockPoint( &g_CurrentTrackSegment->m_End.x, &g_CurrentTrackSegment->m_End.y, &g_CurrentTrackSegment->m_End.y, Loading Loading @@ -493,28 +497,6 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) SetCurItem( NULL ); SetCurItem( NULL ); } } /* * PushTrack detecs if the mouse is pointing into a conflicting track. * In this case, it tries to push the new track out of the conflicting track's * clearance zone. This gives us a cheap mechanism for drawing tracks that * tightly follow others, independent of grid settings. * * KNOWN BUGS: * - we do the same sort of search and calculation up to three times: * 1) we search for magnetic hits (in controle.cpp) * 2) we check if there's a DRC violation in the making (also controle.cpp) * 3) we try to fix the DRC violation (here) * - if we have a magnetic hit and a DRC violation at the same time, we choose * the magnetic hit instead of solving the violation * - should locate conflicting tracks also when we're crossing over them * - we obviously shouldn't access functions through "extern" or have #includes * in the middle of the file */ #include "trigo.h" extern bool Project(wxPoint &res, wxPoint on_grid, const TRACK *track); TRACK* LocateIntrusion( TRACK* start, int net, int width ) TRACK* LocateIntrusion( TRACK* start, int net, int width ) { { Loading @@ -523,7 +505,8 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) wxPoint ref = ActiveScreen->RefPos( 1 ); wxPoint ref = ActiveScreen->RefPos( 1 ); TRACK* track, * found = NULL; TRACK* track, * found = NULL; for (track = start; track; track = track->Next()) { for( track = start; track; track = track->Next() ) { int dist; int dist; wxPoint pos, vec; wxPoint pos, vec; int64_t tmp; int64_t tmp; Loading @@ -531,10 +514,13 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) /* Locate_Pistes */ /* Locate_Pistes */ if( track->GetState( BUSY | DELETED ) ) if( track->GetState( BUSY | DELETED ) ) continue; continue; if( !(g_TabOneLayerMask[track->GetLayer()] & layer_mask) ) if( !(g_TabOneLayerMask[track->GetLayer()] & layer_mask) ) continue; continue; if( track->GetNet() == net ) if( track->GetNet() == net ) continue; continue; if( track->Type() == TYPEVIA ) if( track->Type() == TYPEVIA ) continue; continue; Loading @@ -542,8 +528,10 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence; dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence; pos = ref - track->m_Start; pos = ref - track->m_Start; vec = track->m_End - track->m_Start; vec = track->m_End - track->m_Start; if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) ) if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) ) continue; continue; found = track; found = track; /* prefer intrusions from the side, not the end */ /* prefer intrusions from the side, not the end */ Loading @@ -551,11 +539,27 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) if( tmp >= 0 && tmp <= (int64_t) vec.x * vec.x + (int64_t) vec.y * vec.y ) if( tmp >= 0 && tmp <= (int64_t) vec.x * vec.x + (int64_t) vec.y * vec.y ) break; break; } } return found; return found; } } /** * Function PushTrack * detects if the mouse is pointing into a conflicting track. * In this case, it tries to push the new track out of the conflicting track's * clearance zone. This gives us a cheap mechanism for drawing tracks that * tightly follow others, independent of grid settings. * * KNOWN BUGS: * - we do the same sort of search and calculation up to three times: * 1) we search for magnetic hits (in controle.cpp) * 2) we check if there's a DRC violation in the making (also controle.cpp) * 3) we try to fix the DRC violation (here) * - if we have a magnetic hit and a DRC violation at the same time, we choose * the magnetic hit instead of solving the violation * - should locate conflicting tracks also when we're crossing over them */ static void PushTrack( WinEDA_DrawPanel* panel ) static void PushTrack( WinEDA_DrawPanel* panel ) { { BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->m_Pcb; BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->m_Pcb; Loading @@ -572,6 +576,7 @@ static void PushTrack(WinEDA_DrawPanel *panel) /* are we currently pointing into a conflicting trace ? */ /* are we currently pointing into a conflicting trace ? */ if( !other ) if( !other ) return; return; if( other->GetNet() == track->GetNet() ) if( other->GetNet() == track->GetNet() ) return; return; Loading @@ -586,17 +591,20 @@ static void PushTrack(WinEDA_DrawPanel *panel) dist = (track->m_Width + 1) / 2 + (other->m_Width + 1) / 2 + dist = (track->m_Width + 1) / 2 + (other->m_Width + 1) / 2 + g_DesignSettings.m_TrackClearence + 2; g_DesignSettings.m_TrackClearence + 2; /* /* * DRC wants >, so +1. * DRC wants >, so +1. * We may have a quantization error of 1/sqrt(2), so +1 again. * We may have a quantization error of 1/sqrt(2), so +1 again. */ */ /* Vector "n" is perpendicular to "other", pointing towards the cursor. */ /* Vector "n" is perpendicular to "other", pointing towards the cursor. */ if (det > 0) { if( det > 0 ) { n.x = vec.y; n.x = vec.y; n.y = -vec.x; n.y = -vec.x; } } else { else { n.x = -vec.y; n.x = -vec.y; n.y = vec.x; n.y = vec.x; } } Loading @@ -608,6 +616,7 @@ static void PushTrack(WinEDA_DrawPanel *panel) track->m_End += n; track->m_End += n; } } /****************************************************************************/ /****************************************************************************/ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /****************************************************************************/ /****************************************************************************/ Loading pcbnew/protos.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -224,6 +224,8 @@ MODULE* Load_Module_From_Library( WinEDA_DrawFrame* frame, wxDC* DC ); /* EDITRACK.C : */ /* EDITRACK.C : */ /****************/ /****************/ TRACK* LocateIntrusion( TRACK* start, int net, int width ); void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); wxDC* DC, bool erase ); Loading Loading @@ -385,6 +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 ); /***************/ /***************/ Loading Loading
pcbnew/controle.cpp +20 −20 Original line number Original line Diff line number Diff line Loading @@ -499,24 +499,24 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags ) keep_on_grid = TRUE; keep_on_grid = TRUE; if (keep_on_grid) { if( keep_on_grid ) { wxPoint on_grid = curpos; wxPoint on_grid = curpos; 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 extern TRACK *LocateIntrusion(TRACK *start, int net, int width); { /* /* * If there's an 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 our what to * "as is", and let ShowNewTrackWhenMovingCursor figure our what to * do. * 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; } } Loading
pcbnew/editrack.cpp +97 −88 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,8 @@ #include "protos.h" #include "protos.h" #include "drc_stuff.h" #include "drc_stuff.h" #include "trigo.h" /* Routines Locales */ /* Routines Locales */ Loading Loading @@ -281,6 +283,7 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ) pas_45 = GetScreen()->GetGrid().x / 2; pas_45 = GetScreen()->GetGrid().x / 2; if( pas_45 < pt_segm->m_Width ) if( pas_45 < pt_segm->m_Width ) pas_45 = GetScreen()->GetGrid().x; pas_45 = GetScreen()->GetGrid().x; while( pas_45 < pt_segm->m_Width ) while( pas_45 < pt_segm->m_Width ) pas_45 *= 2; pas_45 *= 2; Loading Loading @@ -436,6 +439,7 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) { { adr_buf = (TRACK*) LockPoint; adr_buf = (TRACK*) LockPoint; g_HightLigth_NetCode = adr_buf->GetNet(); g_HightLigth_NetCode = adr_buf->GetNet(); /* creation eventuelle d'un point d'accrochage */ /* creation eventuelle d'un point d'accrochage */ LockPoint = CreateLockPoint( &g_CurrentTrackSegment->m_End.x, LockPoint = CreateLockPoint( &g_CurrentTrackSegment->m_End.x, &g_CurrentTrackSegment->m_End.y, &g_CurrentTrackSegment->m_End.y, Loading Loading @@ -493,28 +497,6 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) SetCurItem( NULL ); SetCurItem( NULL ); } } /* * PushTrack detecs if the mouse is pointing into a conflicting track. * In this case, it tries to push the new track out of the conflicting track's * clearance zone. This gives us a cheap mechanism for drawing tracks that * tightly follow others, independent of grid settings. * * KNOWN BUGS: * - we do the same sort of search and calculation up to three times: * 1) we search for magnetic hits (in controle.cpp) * 2) we check if there's a DRC violation in the making (also controle.cpp) * 3) we try to fix the DRC violation (here) * - if we have a magnetic hit and a DRC violation at the same time, we choose * the magnetic hit instead of solving the violation * - should locate conflicting tracks also when we're crossing over them * - we obviously shouldn't access functions through "extern" or have #includes * in the middle of the file */ #include "trigo.h" extern bool Project(wxPoint &res, wxPoint on_grid, const TRACK *track); TRACK* LocateIntrusion( TRACK* start, int net, int width ) TRACK* LocateIntrusion( TRACK* start, int net, int width ) { { Loading @@ -523,7 +505,8 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) wxPoint ref = ActiveScreen->RefPos( 1 ); wxPoint ref = ActiveScreen->RefPos( 1 ); TRACK* track, * found = NULL; TRACK* track, * found = NULL; for (track = start; track; track = track->Next()) { for( track = start; track; track = track->Next() ) { int dist; int dist; wxPoint pos, vec; wxPoint pos, vec; int64_t tmp; int64_t tmp; Loading @@ -531,10 +514,13 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) /* Locate_Pistes */ /* Locate_Pistes */ if( track->GetState( BUSY | DELETED ) ) if( track->GetState( BUSY | DELETED ) ) continue; continue; if( !(g_TabOneLayerMask[track->GetLayer()] & layer_mask) ) if( !(g_TabOneLayerMask[track->GetLayer()] & layer_mask) ) continue; continue; if( track->GetNet() == net ) if( track->GetNet() == net ) continue; continue; if( track->Type() == TYPEVIA ) if( track->Type() == TYPEVIA ) continue; continue; Loading @@ -542,8 +528,10 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence; dist = width / 2 + track->m_Width / 2 + g_DesignSettings.m_TrackClearence; pos = ref - track->m_Start; pos = ref - track->m_Start; vec = track->m_End - track->m_Start; vec = track->m_End - track->m_Start; if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) ) if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) ) continue; continue; found = track; found = track; /* prefer intrusions from the side, not the end */ /* prefer intrusions from the side, not the end */ Loading @@ -551,11 +539,27 @@ TRACK *LocateIntrusion(TRACK *start, int net, int width) if( tmp >= 0 && tmp <= (int64_t) vec.x * vec.x + (int64_t) vec.y * vec.y ) if( tmp >= 0 && tmp <= (int64_t) vec.x * vec.x + (int64_t) vec.y * vec.y ) break; break; } } return found; return found; } } /** * Function PushTrack * detects if the mouse is pointing into a conflicting track. * In this case, it tries to push the new track out of the conflicting track's * clearance zone. This gives us a cheap mechanism for drawing tracks that * tightly follow others, independent of grid settings. * * KNOWN BUGS: * - we do the same sort of search and calculation up to three times: * 1) we search for magnetic hits (in controle.cpp) * 2) we check if there's a DRC violation in the making (also controle.cpp) * 3) we try to fix the DRC violation (here) * - if we have a magnetic hit and a DRC violation at the same time, we choose * the magnetic hit instead of solving the violation * - should locate conflicting tracks also when we're crossing over them */ static void PushTrack( WinEDA_DrawPanel* panel ) static void PushTrack( WinEDA_DrawPanel* panel ) { { BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->m_Pcb; BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->m_Pcb; Loading @@ -572,6 +576,7 @@ static void PushTrack(WinEDA_DrawPanel *panel) /* are we currently pointing into a conflicting trace ? */ /* are we currently pointing into a conflicting trace ? */ if( !other ) if( !other ) return; return; if( other->GetNet() == track->GetNet() ) if( other->GetNet() == track->GetNet() ) return; return; Loading @@ -586,17 +591,20 @@ static void PushTrack(WinEDA_DrawPanel *panel) dist = (track->m_Width + 1) / 2 + (other->m_Width + 1) / 2 + dist = (track->m_Width + 1) / 2 + (other->m_Width + 1) / 2 + g_DesignSettings.m_TrackClearence + 2; g_DesignSettings.m_TrackClearence + 2; /* /* * DRC wants >, so +1. * DRC wants >, so +1. * We may have a quantization error of 1/sqrt(2), so +1 again. * We may have a quantization error of 1/sqrt(2), so +1 again. */ */ /* Vector "n" is perpendicular to "other", pointing towards the cursor. */ /* Vector "n" is perpendicular to "other", pointing towards the cursor. */ if (det > 0) { if( det > 0 ) { n.x = vec.y; n.x = vec.y; n.y = -vec.x; n.y = -vec.x; } } else { else { n.x = -vec.y; n.x = -vec.y; n.y = vec.x; n.y = vec.x; } } Loading @@ -608,6 +616,7 @@ static void PushTrack(WinEDA_DrawPanel *panel) track->m_End += n; track->m_End += n; } } /****************************************************************************/ /****************************************************************************/ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /****************************************************************************/ /****************************************************************************/ Loading
pcbnew/protos.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -224,6 +224,8 @@ MODULE* Load_Module_From_Library( WinEDA_DrawFrame* frame, wxDC* DC ); /* EDITRACK.C : */ /* EDITRACK.C : */ /****************/ /****************/ TRACK* LocateIntrusion( TRACK* start, int net, int width ); void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); wxDC* DC, bool erase ); Loading Loading @@ -385,6 +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 ); /***************/ /***************/ Loading