TRACK::GetBoundingBox() revised for when track clearance is displayed

This commit is contained in:
dickelbeck 2008-03-11 01:19:08 +00:00
parent 1bb2da51cb
commit 6153dadc07
4 changed files with 29 additions and 11 deletions

View File

@ -26,6 +26,7 @@ email address.
PostDirtyRect(). PostDirtyRect().
* void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* Track ) now redraws * void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* Track ) now redraws
the screen after a net deletion. the screen after a net deletion.
* eeschema/dialog_find.cpp: set the initial keyboard focus to the text control
2008-Mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>

View File

@ -42,6 +42,20 @@ void DbgDisplayTrackInfos( TRACK* track )
#endif #endif
/**
* Function ShowClearance
* tests to see if the clearance border is drawn on the given track.
* @return bool - true if should draw clearance, else false.
*/
static bool ShowClearance( const TRACK* aTrack )
{
// maybe return true for (for tracks and vias, not for zone segments
return ( DisplayOpt.DisplayTrackIsol && ( aTrack->GetLayer() <= LAST_COPPER_LAYER )
&& ( aTrack->Type() == TYPETRACK || aTrack->Type() == TYPEVIA) );
}
/**********************************************************/ /**********************************************************/
TRACK::TRACK( BOARD_ITEM* StructFather, KICAD_T idtype ) : TRACK::TRACK( BOARD_ITEM* StructFather, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype ) BOARD_ITEM( StructFather, idtype )
@ -242,6 +256,12 @@ EDA_Rect TRACK::GetBoundingBox() const
xmin = MIN( m_Start.x, m_End.x ); xmin = MIN( m_Start.x, m_End.x );
} }
if( ShowClearance( this ) )
{
// + 1 is for the clearance line itself.
radius += g_DesignSettings.m_TrackClearence + 1;
}
ymax += radius; ymax += radius;
xmax += radius; xmax += radius;
@ -249,7 +269,9 @@ EDA_Rect TRACK::GetBoundingBox() const
xmin -= radius; xmin -= radius;
// return a rectangle which is [pos,dim) in nature. therefore the +1 // return a rectangle which is [pos,dim) in nature. therefore the +1
return EDA_Rect( wxPoint( xmin, ymin ), wxSize( xmax-xmin+1, ymax-ymin+1 ) ); EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( xmax-xmin+1, ymax-ymin+1 ) );
return ret;
} }
@ -783,8 +805,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode )
} }
/* Shows clearance (for tracks and vias, not for zone segments */ /* Shows clearance (for tracks and vias, not for zone segments */
if( DisplayOpt.DisplayTrackIsol && ( m_Layer <= LAST_COPPER_LAYER ) if( ShowClearance( this ) )
&& ( Type() == TYPETRACK || Type() == TYPEVIA) )
{ {
GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y, m_End.x, m_End.y,

View File

@ -168,14 +168,9 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* Track )
if( segm->GetNet() != net_code_delete ) if( segm->GetNet() != net_code_delete )
break; break;
// This works ok, but sometimes leaves stuff on screen. I think DrawPanel->PostDirtyRect( segm->GetBoundingBox() );
// the erase rectangle is not large enough always.
// DrawPanel->PostDirtyRect( segm->GetBoundingBox() );
} }
// Do this instead of PostDirtyRect() for now
DrawPanel->Refresh( TRUE );
SaveItemEfface( trackList, ii ); SaveItemEfface( trackList, ii );
GetScreen()->SetModify(); GetScreen()->SetModify();
test_1_net_connexion( DC, net_code_delete ); test_1_net_connexion( DC, net_code_delete );

View File

@ -274,8 +274,9 @@ void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect )
// Ensure the rectangle is large enough after truncations. // Ensure the rectangle is large enough after truncations.
// The pcb units have finer granularity than the pixels, so it can happen // The pcb units have finer granularity than the pixels, so it can happen
// that the rectangle is not large enough for the erase portion. // that the rectangle is not large enough for the erase portion.
aRect.m_Size.x += 1;
aRect.m_Size.y += 1; aRect.m_Size.x += 2; // += 1 is not enough!
aRect.m_Size.y += 2;
// pass wxRect() via EDA_Rect::operator wxRect() overload // pass wxRect() via EDA_Rect::operator wxRect() overload
RefreshRect( aRect, TRUE ); RefreshRect( aRect, TRUE );