taking in account filled zones areas in pcb cleanup and tracks creation
This commit is contained in:
parent
4f1c146957
commit
6691eca2fa
|
@ -216,17 +216,13 @@ wxPoint& BOARD::GetPosition()
|
||||||
|
|
||||||
void BOARD::UnLink()
|
void BOARD::UnLink()
|
||||||
{
|
{
|
||||||
/* Modification du chainage arriere */
|
/* Update back link */
|
||||||
if( Back() )
|
if( Back() )
|
||||||
{
|
{
|
||||||
if( Back()->Type() == TYPEPCB )
|
if( Back()->Type() == TYPEPCB )
|
||||||
{
|
{
|
||||||
Back()->SetNext( Next() );
|
Back()->SetNext( Next() );
|
||||||
}
|
}
|
||||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
|
||||||
{
|
|
||||||
// Pback-> = Pnext;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modification du chainage avant */
|
/* Modification du chainage avant */
|
||||||
|
@ -1082,6 +1078,39 @@ void BOARD::RedrawFilledAreas(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTestForAnyFilledArea
|
||||||
|
* tests if the given wxPoint is within the bounds of a filled area of this zone.
|
||||||
|
* the test is made on zones on layer from aStartLayer to aEndLayer
|
||||||
|
* Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
|
||||||
|
* @param refPos A wxPoint to test
|
||||||
|
* @param aStartLayer the first layer to test
|
||||||
|
* @param aEndLayer the last layer (-1 to ignore it) to test
|
||||||
|
* @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else NULL
|
||||||
|
*/
|
||||||
|
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos, int aStartLayer, int aEndLayer )
|
||||||
|
{
|
||||||
|
if( aEndLayer < 0 )
|
||||||
|
aEndLayer = aStartLayer;
|
||||||
|
if( aEndLayer < aStartLayer)
|
||||||
|
EXCHG (aEndLayer, aStartLayer);
|
||||||
|
|
||||||
|
for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
|
||||||
|
{
|
||||||
|
ZONE_CONTAINER* area = m_ZoneDescriptorList[ia];
|
||||||
|
int layer = area->GetLayer();
|
||||||
|
if ( (layer < aStartLayer) || (layer > aEndLayer) )
|
||||||
|
continue;
|
||||||
|
if ( area->GetState( BUSY ) ) // In locate functions we must skip tagged items with BUSY flag set.
|
||||||
|
continue;
|
||||||
|
if( area->HitTestFilledArea( aRefPos ) )
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
|
|
||||||
|
|
|
@ -355,6 +355,17 @@ public:
|
||||||
/*************************/
|
/*************************/
|
||||||
/* Copper Areas handling */
|
/* Copper Areas handling */
|
||||||
/*************************/
|
/*************************/
|
||||||
|
/**
|
||||||
|
* Function HitTestForAnyFilledArea
|
||||||
|
* tests if the given wxPoint is within the bounds of a filled area of this zone.
|
||||||
|
* the test is made on zones on layer from aStartLayer to aEndLayer
|
||||||
|
* Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
|
||||||
|
* @param refPos A wxPoint to test
|
||||||
|
* @param aStartLayer the first layer to test
|
||||||
|
* @param aEndLayer the last layer (-1 to ignore it) to test
|
||||||
|
* @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else NULL
|
||||||
|
*/
|
||||||
|
ZONE_CONTAINER* HitTestForAnyFilledArea( const wxPoint& aRefPos, int aStartLayer, int aEndLayer = -1 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function RedrawAreasOutlines
|
* Function RedrawAreasOutlines
|
||||||
|
|
|
@ -797,6 +797,31 @@ bool ZONE_CONTAINER::HitTest( EDA_Rect& refArea )
|
||||||
return is_out_of_box ? false : true;
|
return is_out_of_box ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTestFilledArea
|
||||||
|
* tests if the given wxPoint is within the bounds of a filled area of this zone.
|
||||||
|
* @param aRefPos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos )
|
||||||
|
{
|
||||||
|
unsigned indexstart = 0, indexend;
|
||||||
|
bool inside = false;
|
||||||
|
for( indexend = 0; indexend < m_FilledPolysList.size(); indexend++ )
|
||||||
|
{
|
||||||
|
if( m_FilledPolysList[indexend].end_contour ) // end of a filled sub-area found
|
||||||
|
{
|
||||||
|
if( TestPointInsidePolygon( m_FilledPolysList, indexstart, indexend, aRefPos.x, aRefPos.y ) )
|
||||||
|
{
|
||||||
|
inside = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return inside;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
|
void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
|
||||||
|
|
|
@ -166,11 +166,20 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function HitTest
|
* Function HitTest
|
||||||
* tests if the given wxPoint is within the bounds of this object.
|
* tests if the given wxPoint is within the bounds of this object.
|
||||||
|
* For zones, this means near an ouline segment
|
||||||
* @param refPos A wxPoint to test
|
* @param refPos A wxPoint to test
|
||||||
* @return bool - true if a hit, else false
|
* @return bool - true if a hit, else false
|
||||||
*/
|
*/
|
||||||
bool HitTest( const wxPoint& refPos );
|
bool HitTest( const wxPoint& refPos );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function HitTestFilledArea
|
||||||
|
* tests if the given wxPoint is within the bounds of a filled area of this zone.
|
||||||
|
* @param aRefPos A wxPoint to test
|
||||||
|
* @return bool - true if a hit, else false
|
||||||
|
*/
|
||||||
|
bool HitTestFilledArea( const wxPoint& aRefPos );
|
||||||
|
|
||||||
/** function BuildFilledPolysListData
|
/** function BuildFilledPolysListData
|
||||||
* Build m_FilledPolysList data from real outlines (m_Poly)
|
* Build m_FilledPolysList data from real outlines (m_Poly)
|
||||||
* in order to have drawable (and plottable) filled polygons
|
* in order to have drawable (and plottable) filled polygons
|
||||||
|
|
|
@ -169,6 +169,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
|
||||||
TRACK* other;
|
TRACK* other;
|
||||||
TRACK* startNetcode;
|
TRACK* startNetcode;
|
||||||
TRACK* next;
|
TRACK* next;
|
||||||
|
ZONE_CONTAINER* zone;
|
||||||
|
|
||||||
int nbpoints_supprimes = 0;
|
int nbpoints_supprimes = 0;
|
||||||
int masklayer, oldnetcode;
|
int masklayer, oldnetcode;
|
||||||
|
@ -234,7 +235,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
|
||||||
oldnetcode = segment->GetNet();
|
oldnetcode = segment->GetNet();
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_erase = 0;
|
flag_erase = 0; //Not connected indicator
|
||||||
type_end = 0;
|
type_end = 0;
|
||||||
|
|
||||||
/* Is a pad found on a track end ? */
|
/* Is a pad found on a track end ? */
|
||||||
|
@ -258,27 +259,51 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not connected to a pad, test if segment's START is connected to another track
|
// if not connected to a pad, test if segment's START is connected to another track
|
||||||
|
// For via tests, an enhancement could to test if connected to 2 items on different layers.
|
||||||
|
// Currently a via must be connected to 2 items, taht can be on the same layer
|
||||||
|
int top_layer, bottom_layer;
|
||||||
if( (type_end & START_ON_PAD ) == 0 )
|
if( (type_end & START_ON_PAD ) == 0 )
|
||||||
{
|
{
|
||||||
other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
|
other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track, NULL, START );
|
||||||
NULL, START );
|
|
||||||
if( other == NULL )
|
if( other == NULL ) // Test a connection to zones
|
||||||
|
{
|
||||||
|
if( segment->Type() != TYPEVIA )
|
||||||
|
{
|
||||||
|
zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_Start, segment->GetLayer() );
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer );
|
||||||
|
zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_Start, top_layer, bottom_layer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (other == NULL) && (zone == NULL) )
|
||||||
flag_erase |= 1;
|
flag_erase |= 1;
|
||||||
|
|
||||||
else // segment or via connected to this end
|
else // segment, via or zone connected to this end
|
||||||
{
|
{
|
||||||
segment->start = other;
|
segment->start = other;
|
||||||
|
// If a via is connected to this end, test if this via has a second item connected
|
||||||
if( other->Type() == TYPEVIA )
|
// if no, remove it with the current segment
|
||||||
|
if( other && other->Type() == TYPEVIA )
|
||||||
{
|
{
|
||||||
// search for another segment following the via
|
// search for another segment following the via
|
||||||
|
|
||||||
segment->SetState( BUSY, ON );
|
segment->SetState( BUSY, ON );
|
||||||
|
|
||||||
TRACK* via = other;
|
SEGVIA* via = (SEGVIA*) other;
|
||||||
other = Locate_Piste_Connectee( via, frame->m_Pcb->m_Track,
|
other = Locate_Piste_Connectee( via, frame->m_Pcb->m_Track,
|
||||||
NULL, START );
|
NULL, START );
|
||||||
if( other == NULL )
|
if( other == NULL )
|
||||||
|
{
|
||||||
|
via->ReturnLayerPair( &top_layer, &bottom_layer );
|
||||||
|
zone = frame->m_Pcb->HitTestForAnyFilledArea(via->m_Start, bottom_layer, top_layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (other == NULL) && (zone == NULL) )
|
||||||
flag_erase |= 2;
|
flag_erase |= 2;
|
||||||
|
|
||||||
segment->SetState( BUSY, OFF );
|
segment->SetState( BUSY, OFF );
|
||||||
|
@ -291,22 +316,42 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
|
||||||
{
|
{
|
||||||
other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
|
other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
|
||||||
NULL, END );
|
NULL, END );
|
||||||
if( other == NULL )
|
if( other == NULL ) // Test a connection to zones
|
||||||
|
{
|
||||||
|
if( segment->Type() != TYPEVIA )
|
||||||
|
zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_End, segment->GetLayer() );
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer );
|
||||||
|
zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_End,top_layer, bottom_layer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (other == NULL) && (zone == NULL) )
|
||||||
flag_erase |= 0x10;
|
flag_erase |= 0x10;
|
||||||
|
|
||||||
else // segment or via connected to this end
|
else // segment, via or zone connected to this end
|
||||||
{
|
{
|
||||||
segment->end = other;
|
segment->end = other;
|
||||||
if( other->Type() == TYPEVIA )
|
// If a via is connected to this end, test if this via has a second item connected
|
||||||
|
// if no, remove it with the current segment
|
||||||
|
if( other && other->Type() == TYPEVIA )
|
||||||
{
|
{
|
||||||
// search for another segment following the via
|
// search for another segment following the via
|
||||||
|
|
||||||
segment->SetState( BUSY, ON );
|
segment->SetState( BUSY, ON );
|
||||||
|
|
||||||
TRACK* via = other;
|
SEGVIA* via = (SEGVIA*) other;
|
||||||
other = Locate_Piste_Connectee( via, frame->m_Pcb->m_Track,
|
other = Locate_Piste_Connectee( via, frame->m_Pcb->m_Track,
|
||||||
NULL, END );
|
NULL, END );
|
||||||
if( other == NULL )
|
if( other == NULL )
|
||||||
|
{
|
||||||
|
via->ReturnLayerPair( &top_layer, &bottom_layer );
|
||||||
|
zone = frame->m_Pcb->HitTestForAnyFilledArea(via->m_End, bottom_layer, top_layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (other == NULL) && (zone == NULL) )
|
||||||
flag_erase |= 0x20;
|
flag_erase |= 0x20;
|
||||||
|
|
||||||
segment->SetState( BUSY, OFF );
|
segment->SetState( BUSY, OFF );
|
||||||
|
|
|
@ -99,7 +99,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
|
||||||
|
|
||||||
if( track == NULL ) /* Starting a new track */
|
if( track == NULL ) /* Starting a new track */
|
||||||
{
|
{
|
||||||
/* undrw old hightlight */
|
/* erase old highlight */
|
||||||
OldNetCodeSurbrillance = g_HightLigth_NetCode;
|
OldNetCodeSurbrillance = g_HightLigth_NetCode;
|
||||||
OldEtatSurbrillance = g_HightLigt_Status;
|
OldEtatSurbrillance = g_HightLigt_Status;
|
||||||
|
|
||||||
|
@ -133,6 +133,13 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else // no starting point, but a filled zone area can exist. This is also a good starting point.
|
||||||
|
{
|
||||||
|
ZONE_CONTAINER* zone = m_Pcb->HitTestForAnyFilledArea(pos, GetScreen()->m_Active_Layer );
|
||||||
|
if ( zone )
|
||||||
|
g_HightLigth_NetCode = zone->GetNet();
|
||||||
|
}
|
||||||
|
|
||||||
build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), TRUE );
|
build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), TRUE );
|
||||||
Hight_Light( DC );
|
Hight_Light( DC );
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ TARGET=pcbnew
|
||||||
|
|
||||||
include ../libs.win
|
include ../libs.win
|
||||||
|
|
||||||
EXTRACPPFLAGS += -I /f/kicad-sourceforge/trunk/kicad
|
EXTRACPPFLAGS += -I /f/kicad-sourceforge/trunk/kicad -I $(BOOST_PATH)
|
||||||
all: $(TARGET).exe
|
all: $(TARGET).exe
|
||||||
|
|
||||||
include makefile.include
|
include makefile.include
|
||||||
|
|
Loading…
Reference in New Issue