Commit e4d1fa12 authored by Wayne Stambaugh's avatar Wayne Stambaugh

PCBNew trace search code refactoring and other minor fixes.

* Refactor trace search functions into the appropriate object.
* Translate French code names and comments.
* Lots of coding style policy fixes.
parent bd19d310
/**
* @file wxBasePcbStruct.h
* @file wxBasePcbFrame.h
* @brief Classes used in pcbnew, cvpcb and gerbview.
*/
......@@ -239,13 +239,19 @@ public:
MODULE* Create_1_Module( const wxString& aModuleName );
void Edit_Module( MODULE* module, wxDC* DC );
void Rotate_Module( wxDC* DC,
MODULE* module,
int angle,
bool incremental );
void Place_Module( MODULE* module,
wxDC* DC,
bool aDoNotRecreateRatsnest = false );
void Rotate_Module( wxDC* DC, MODULE* module, int angle, bool incremental );
/**
* Function PlaceModule
* places \a aModule at the current cursor position and updates module coordinates
* with the new position.
*
* @param aModule A MODULE object point of the module to be placed.
* @param aDC A wxDC object point of the device context to draw \a aModule on
* or NULL if no display screen need updated.
* @param aDoNotRecreateRatsnest A bool true redraws the module rats nest.
*/
void PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreateRatsnest = false );
// module texts
void RotateTextModule( TEXTE_MODULE* Text, wxDC* DC );
......@@ -297,7 +303,7 @@ public:
// loading footprints
/**
* Function Get_Librairie_Module
* Function GetModuleLibrary
*
* Read active libraries or one library to find and load a given module
* If found the module is linked to the tail of linked list of modules
......@@ -308,9 +314,9 @@ public:
* @return a pointer to the new module, or NULL
*
*/
MODULE* Get_Librairie_Module( const wxString& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError );
MODULE* GetModuleLibrary( const wxString& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError );
/**
* Function Select_1_Module_From_List
......@@ -345,12 +351,12 @@ public:
void Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus );
/**
* Function Test_1_Net_Ratsnest
* Function TestOneRatsNest
* Compute the ratsnest relative to the net "net_code"
* @param aDC - Device context to draw on.
* @param aNetcode = netcode used to compute the ratsnest.
* @param aNetCode = netcode used to compute the ratsnest.
*/
int Test_1_Net_Ratsnest( wxDC* aDC, int aNetcode );
int TestOneRatsNest( wxDC* aDC, int aNetCode );
/**
* Function build_ratsnest_module
......@@ -362,7 +368,13 @@ public:
*/
void build_ratsnest_module( MODULE* aModule );
void trace_ratsnest_module( wxDC* DC );
/**
* Function TraceModuleRatsNest
* display the rats nest of a moving footprint, computed by
* build_ratsnest_module()
*/
void TraceModuleRatsNest( wxDC* aDC );
void Build_Board_Ratsnest( wxDC* DC );
/**
......@@ -377,7 +389,14 @@ public:
void trace_ratsnest_pad( wxDC* DC );
void build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, bool init );
void Tst_Ratsnest( wxDC* DC, int ref_netcode );
/**
* Fucntion TestRatsNest
* computes the active rats nest
* The general rats nest list must exist.
* Compute the ACTIVE rats nest in the general rats nest list
* if aNetCode == 0, test all nets, else test only aNetCode
*/
void TestRatsNest( wxDC* aDC, int aNetCode );
/**
* Function TestConnections
......@@ -409,6 +428,7 @@ public:
* <p>
* This is a 2 pass computation. First we search a connection between a track segment
* and a pad. If the connection is found, the segment netcode is set to the pad netcode.
* </p>
*/
void RecalculateAllTracksNetcode();
......
......@@ -327,6 +327,14 @@ public:
*/
bool OnHotkeyDeleteItem( wxDC* aDC );
/**
* Function OnHotkeyPlaceItem
* Place the item (footprint, track, text .. ) found under the mouse cursor
* An item can be placed only if there is this item currently edited
* Only a footprint, a pad or a track can be placed
* @param aDC = current device context
* @return true if an item was placedd
*/
bool OnHotkeyPlaceItem( wxDC* aDC );
bool OnHotkeyEditItem( int aIdCommand );
......@@ -343,6 +351,8 @@ public:
/**
* Function OnHotkeyRotateItem
* Rotate the item (text or footprint) found under the mouse cursor
* @note This command can be used with an item currently in edit.
* Only some items can be rotated (footprints and texts).
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
......@@ -766,6 +776,15 @@ public:
*/
bool Delete_Module( MODULE* aModule, wxDC* aDC, bool aAskBeforeDeleting );
/**
* Function Change_Side_Module
* Flip a footprint (switch layer from component or component to copper)
* The mirroring is made from X axis
* if a footprint is not on copper or component layer it is not flipped
* (it could be on an adhesive layer, not supported at this time)
* @param Module the footprint to flip
* @param DC Current Device Context. if NULL, no redraw
*/
void Change_Side_Module( MODULE* Module, wxDC* DC );
void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule );
......
......@@ -271,7 +271,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
Ymax_size = MAX( Ymax_size, Module->m_BoundaryBox.GetHeight() );
Place_Module( Module, NULL, true );
PlaceModule( Module, NULL, true );
current.x += Module->m_BoundaryBox.GetWidth() + pas_grille;
}
......
......@@ -49,7 +49,7 @@ float MinCout;
static int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide );
static void TracePenaliteRectangle( BOARD* Pcb,
static void CreateKeepOutRectangle( BOARD* Pcb,
int ux0,
int uy0,
int ux1,
......@@ -115,11 +115,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
Board.m_GridRouting = (int) GetScreen()->GetGridSize().x;
// Ensure Board.m_GridRouting has a reasonnable value:
// Ensure Board.m_GridRouting has a reasonable value:
if( Board.m_GridRouting < 10 )
Board.m_GridRouting = 10; // Min value = 1/1000 inch
/* Compute module parmeters used in auto place */
/* Compute module parameters used in auto place */
Module = GetBoard()->m_Modules;
NbTotalModules = 0;
......@@ -143,6 +143,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
case PLACE_1_MODULE:
if( ThisModule == Module )
Module->m_ModuleStatus |= MODULE_to_PLACE;
break;
case PLACE_OUT_OF_BOARD:
......@@ -294,7 +295,7 @@ end_of_tst:
/* Place module. */
CurrPosition = GetScreen()->GetCrossHairPosition();
GetScreen()->SetCrossHairPosition( PosOK );
Place_Module( Module, DC );
PlaceModule( Module, DC );
GetScreen()->SetCrossHairPosition( CurrPosition );
Module->CalculateBoundingBox();
......@@ -567,7 +568,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
/* Trace clearance. */
marge = ( Board.m_GridRouting * Module->m_PadNum ) / GAIN;
Penalite = PENALITE;
TracePenaliteRectangle( GetBoard(), ox, oy, fx, fy, marge, Penalite, layerMask );
CreateKeepOutRectangle( GetBoard(), ox, oy, fx, fy, marge, Penalite, layerMask );
}
......@@ -582,8 +583,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
{
int cx, cy;
int ox, oy, fx, fy; /* occupying part of the module focuses on the
* cursor */
int ox, oy, fx, fy; /* occupying part of the module focuses on the cursor */
int error = 1;
int DisplayChevelu = 0;
wxPoint LastPosOK;
......@@ -604,6 +604,7 @@ int PCB_EDIT_FRAME::RecherchePlacementModule( MODULE* Module, wxDC* DC )
CurrPosition.x = GetBoard()->m_BoundaryBox.m_Pos.x - ox;
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy;
/* Module placement on grid. */
CurrPosition.x -= CurrPosition.x % Board.m_GridRouting;
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting;
......@@ -885,7 +886,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
/*
* Display the module's ratsnet during displacement, and
* Display the module's ratsnest during displacement, and
* assess the "cost" of the position.
* The cost is the longest ratsnest distance with penalty for connections
* approaching 45 degrees.
......@@ -909,16 +910,14 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
for( unsigned ii = 0; ii < GetBoard()->m_LocalRatsnest.size(); ii++ )
{
RATSNEST_ITEM* pt_local_chevelu = &GetBoard()->m_LocalRatsnest[ii];
RATSNEST_ITEM* pt_local_rats_nest = &GetBoard()->m_LocalRatsnest[ii];
if( !( pt_local_chevelu->m_Status & LOCAL_RATSNEST_ITEM ) )
if( !( pt_local_rats_nest->m_Status & LOCAL_RATSNEST_ITEM ) )
{
ox = pt_local_chevelu->m_PadStart->GetPosition().x -
g_Offset_Module.x;
oy = pt_local_chevelu->m_PadStart->GetPosition().y -
g_Offset_Module.y;
fx = pt_local_chevelu->m_PadEnd->GetPosition().x;
fy = pt_local_chevelu->m_PadEnd->GetPosition().y;
ox = pt_local_rats_nest->m_PadStart->GetPosition().x - g_Offset_Module.x;
oy = pt_local_rats_nest->m_PadStart->GetPosition().y - g_Offset_Module.y;
fx = pt_local_rats_nest->m_PadEnd->GetPosition().x;
fy = pt_local_rats_nest->m_PadEnd->GetPosition().y;
if( AutoPlaceShowAll )
{
......@@ -953,7 +952,7 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
/* Draw keep out area of a module. */
/***********************************/
/* Buid the cost map.
/* Build the cost map.
* Cells ( in Dist mao ) inside the rect x0,y0 a x1,y1 are
* incremented by value Penalite
* Cell outside this rectangle, but inside the rectangle
......@@ -961,7 +960,7 @@ float PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC )
* (Penalite ... 0). The decreasing value de pends on the distance to the first rectangle
* Therefore the cost is high in rect x0,y0 a x1,y1, and decrease outside this rectangle
*/
static void TracePenaliteRectangle( BOARD* Pcb,
static void CreateKeepOutRectangle( BOARD* Pcb,
int ux0,
int uy0,
int ux1,
......@@ -973,7 +972,7 @@ static void TracePenaliteRectangle( BOARD* Pcb,
int row, col;
int row_min, row_max, col_min, col_max, pmarge;
int trace = 0;
DIST_CELL data, LocalPenalite;
DIST_CELL data, LocalKeepOut;
int lgain, cgain;
if( aLayerMask & g_TabOneLayerMask[Route_Layer_BOTTOM] )
......@@ -993,7 +992,9 @@ static void TracePenaliteRectangle( BOARD* Pcb,
ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge;
pmarge = marge / Board.m_GridRouting; if( pmarge < 1 )
pmarge = marge / Board.m_GridRouting;
if( pmarge < 1 )
pmarge = 1;
/* Calculate the coordinate limits of the rectangle. */
......@@ -1033,7 +1034,7 @@ static void TracePenaliteRectangle( BOARD* Pcb,
for( col = col_min; col <= col_max; col++ )
{
cgain = 256;
LocalPenalite = Penalite;
LocalKeepOut = Penalite;
if( col < pmarge )
cgain = ( 256 * col ) / pmarge;
......@@ -1043,18 +1044,18 @@ static void TracePenaliteRectangle( BOARD* Pcb,
cgain = ( cgain * lgain ) / 256;
if( cgain != 256 )
LocalPenalite = ( LocalPenalite * cgain ) / 256;
LocalKeepOut = ( LocalKeepOut * cgain ) / 256;
if( trace & 1 )
{
data = GetDist( row, col, BOTTOM ) + LocalPenalite;
data = GetDist( row, col, BOTTOM ) + LocalKeepOut;
SetDist( row, col, BOTTOM, data );
}
if( trace & 2 )
{
data = GetDist( row, col, TOP );
data = MAX( data, LocalPenalite );
data = MAX( data, LocalKeepOut );
SetDist( row, col, TOP, data );
}
}
......@@ -1072,6 +1073,7 @@ static bool Tri_PlaceModules( MODULE* ref, MODULE* compare )
return ff2 < ff1;
}
static bool Tri_RatsModules( MODULE* ref, MODULE* compare )
{
double ff1, ff2;
......@@ -1084,7 +1086,7 @@ static bool Tri_RatsModules( MODULE* ref, MODULE* compare )
/* Find the "best" module place
* The criteria of choice are:
* - Maximum ratsnet with modules already placed
* - Maximum ratsnest with modules already placed
* - Max size, and number of pads max
*/
static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
......@@ -1115,7 +1117,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
Module->DisplayInfo( pcbframe );
pcbframe->build_ratsnest_module( Module );
/* Calculate external ratsnet. */
/* Calculate external ratsnest. */
for( unsigned ii = 0; ii < pcbframe->GetBoard()->m_LocalRatsnest.size(); ii++ )
{
if( ( pcbframe->GetBoard()->m_LocalRatsnest[ii].m_Status &
......@@ -1164,7 +1166,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
* Start from an initial point, to fill zone
* The zone must have no "copper island"
* Algorithm:
* If the current cell has a neightbour flagged as "cell in the zone", it
* If the current cell has a neighbor flagged as "cell in the zone", it
* become a cell in the zone
* The first point in the zone is the starting point
* 4 searches within the matrix are made:
......@@ -1172,10 +1174,10 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
* 2 - Right to left and top to bottom
* 3 - bottom to top and Right to left
* 4 - bottom to top and Left to right
* Given the current cell, for each search, we consider the 2 neightbour cells
* Given the current cell, for each search, we consider the 2 neighbor cells
* the previous cell on the same line and the previous cell on the same column.
*
* This funtion can request some iterations
* This function can request some iterations
* Iterations are made until no cell is added to the zone.
* @return: added cells count (i.e. which the attribute CELL_is_ZONE is set)
*/
......@@ -1192,7 +1194,7 @@ int Propagation( PCB_EDIT_FRAME* frame )
frame->MsgPanel->SetMessage( 57, wxT( "Detect" ), msg, CYAN );
frame->MsgPanel->SetMessage( -1, wxEmptyString, wxT( "1" ), CYAN );
// Alloc memory to handle 1 line or 1 colunmn on the routing matrix
// Alloc memory to handle 1 line or 1 column on the routing matrix
nn = MAX( Nrows, Ncols ) * sizeof(*pt_cell_V);
pt_cell_V = (long*) MyMalloc( nn );
......
......@@ -1634,6 +1634,37 @@ D_PAD* BOARD::GetPad( LISTE_PAD* aPad, const wxPoint& aPosition, int aLayerMask
}
TRACK* BOARD::GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask )
{
for( TRACK* track = aTrace; track; track = track->Next() )
{
int layer = track->GetLayer();
if( track->GetState( BUSY | IS_DELETED ) )
continue;
if( GetBoardDesignSettings()->IsLayerVisible( layer ) == false )
continue;
if( track->Type() == TYPE_VIA ) /* VIA encountered. */
{
if( track->HitTest( aPosition ) )
return track;
}
else
{
if( (g_TabOneLayerMask[layer] & aLayerMask) == 0 )
continue; /* Segments on different layers. */
if( track->HitTest( aPosition ) )
return track;
}
}
return NULL;
}
#if defined(DEBUG)
void BOARD::Show( int nestLevel, std::ostream& os )
......
......@@ -1134,13 +1134,26 @@ public:
* GetPadFast(). This list is a sorted pad list must be built before calling this
* function.
* </p>
* @note The normal pad list #m_Pads is sorted by increasing netcodes.
* @note The normal pad list is sorted by increasing netcodes.
* @param aPad A D_PAD object pointer the first pad in the list to begin searching.
* @param aPosition A wxPoint object containing the position to test.
* @param aLayerMast A layer or layers to mask the hit test.
* @param aLayerMask A layer or layers to mask the hit test.
* @return A D_PAD object pointer to the connected pad.
*/
D_PAD* GetPad( LISTE_PAD* aPad, const wxPoint& aPosition, int aLayerMask );
/**
* Function GetTrace
* find the segment of \a aTrace at \a aPosition on \a aLayer if \a Layer is visible.
* Traces that are flagged as deleted or busy are ignored.
*
* @param aTrace A pointer to the TRACK object to search.
* @param aPosition A wxPoint object containing the position to test.
* @param aLayerMask A layer or layers to mask the hit test. Use -1 to ignore
* layer mask.
* @return A TRACK object pointer if found otherwise NULL.
*/
TRACK* GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask );
};
#endif // #ifndef CLASS_BOARD_H
......@@ -30,6 +30,60 @@ static bool ShowClearance( const TRACK* aTrack )
}
/*
* return true if the dist between p1 and p2 < max_dist
* Currently in test (currently rasnest algos work only if p1 == p2)
*/
inline bool IsNear( wxPoint& p1, wxPoint& p2, int max_dist )
{
#if 0 // Do not change it: does not work
int dist;
dist = abs( p1.x - p2.x ) + abs( p1.y - p2.y );
dist *= 7;
dist /= 10;
if ( dist < max_dist )
return true;
#else
if ( p1 == p2 )
return true;
#endif
return false;
}
TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask )
{
TRACK* PtSegm;
if( aStartTrace == NULL )
return NULL;
for( PtSegm = aStartTrace; PtSegm != NULL; PtSegm = PtSegm->Next() )
{
if( PtSegm->GetState( IS_DELETED | BUSY ) == 0 )
{
if( aPosition == PtSegm->m_Start )
{
if( aLayerMask & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
if( aPosition == PtSegm->m_End )
{
if( aLayerMask & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
}
if( PtSegm == aEndTrace )
break;
}
return NULL;
}
TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_CONNECTED_ITEM( aParent, idtype )
{
......@@ -1165,6 +1219,265 @@ TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask
}
TRACK* TRACK::GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint )
{
const int NEIGHTBOUR_COUNT_MAX = 50;
TRACK* previousSegment;
TRACK* nextSegment;
int Reflayer;
wxPoint position;
int ii;
int max_dist;
if( aEndPoint == START )
position = m_Start;
else
position = m_End;
Reflayer = ReturnMaskLayer();
previousSegment = nextSegment = this;
for( ii = 0; ii < NEIGHTBOUR_COUNT_MAX; ii++ )
{
if( (nextSegment == NULL) && (previousSegment == NULL) )
break;
if( nextSegment )
{
if( nextSegment->GetState( BUSY | IS_DELETED ) )
goto suite;
if( nextSegment == this )
goto suite;
/* max_dist is the max distance between 2 track ends which
* ensure a copper continuity */
max_dist = ( nextSegment->m_Width + this->m_Width ) / 2;
if( IsNear( position, nextSegment->m_Start, max_dist ) )
{
if( Reflayer & nextSegment->ReturnMaskLayer() )
return nextSegment;
}
if( IsNear( position, nextSegment->m_End, max_dist ) )
{
if( Reflayer & nextSegment->ReturnMaskLayer() )
return nextSegment;
}
suite:
if( nextSegment == aEndTrace )
nextSegment = NULL;
else
nextSegment = nextSegment->Next();
}
if( previousSegment )
{
if( previousSegment->GetState( BUSY | IS_DELETED ) )
goto suite1;
if( previousSegment == this )
goto suite1;
max_dist = ( previousSegment->m_Width + m_Width ) / 2;
if( IsNear( position, previousSegment->m_Start, max_dist ) )
{
if( Reflayer & previousSegment->ReturnMaskLayer() )
return previousSegment;
}
if( IsNear( position, previousSegment->m_End, max_dist ) )
{
if( Reflayer & previousSegment->ReturnMaskLayer() )
return previousSegment;
}
suite1:
if( previousSegment == aStartTrace )
previousSegment = NULL;
else if( previousSegment->Type() != TYPE_PCB )
previousSegment = previousSegment->Back();
else
previousSegment = NULL;
}
}
/* General search. */
for( nextSegment = aStartTrace; nextSegment != NULL; nextSegment = nextSegment->Next() )
{
if( nextSegment->GetState( IS_DELETED | BUSY ) )
{
if( nextSegment == aEndTrace )
break;
continue;
}
if( nextSegment == this )
{
if( nextSegment == aEndTrace )
break;
continue;
}
max_dist = ( nextSegment->m_Width + m_Width ) / 2;
if( IsNear( position, nextSegment->m_Start, max_dist ) )
{
if( Reflayer & nextSegment->ReturnMaskLayer() )
return nextSegment;
}
if( IsNear( position, nextSegment->m_End, max_dist ) )
{
if( Reflayer & nextSegment->ReturnMaskLayer() )
return nextSegment;
}
if( nextSegment == aEndTrace )
break;
}
return NULL;
}
int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
{
TRACK* Track, * via, * segm, * TrackListEnd;
int NbEnds, layerMask, ii, ok = 0;
if( aCount <= 1 )
{
*aStartTrace = *aEndTrace = this;
return 1;
}
/* Calculation of the limit analysis. */
*aStartTrace = *aEndTrace = NULL;
TrackListEnd = Track = this;
ii = 0;
for( ; ( Track != NULL ) && ( ii < aCount ); ii++, Track = Track->Next() )
{
TrackListEnd = Track;
Track->m_Param = 0;
}
/* Calculate the extremes. */
NbEnds = 0;
Track = this;
ii = 0;
for( ; ( Track != NULL ) && ( ii < aCount ); ii++, Track = Track->Next() )
{
if( Track->Type() == TYPE_VIA )
continue;
layerMask = Track->ReturnMaskLayer();
via = GetVia( TrackListEnd, Track->m_Start, layerMask );
if( via )
{
layerMask |= via->ReturnMaskLayer();
via->SetState( BUSY, ON );
}
Track->SetState( BUSY, ON );
segm = ::GetTrace( this, TrackListEnd, Track->m_Start, layerMask );
Track->SetState( BUSY, OFF );
if( via )
via->SetState( BUSY, OFF );
if( segm == NULL )
{
switch( NbEnds )
{
case 0:
*aStartTrace = Track; NbEnds++;
break;
case 1:
int BeginPad, EndPad;
*aEndTrace = Track;
/* Swap ox, oy with fx, fy */
BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD );
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
if( BeginPad )
Track->SetState( END_ONPAD, ON );
if( EndPad )
Track->SetState( BEGIN_ONPAD, ON );
EXCHG( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end );
ok = 1;
return ok;
}
}
layerMask = Track->ReturnMaskLayer();
via = GetVia( TrackListEnd, Track->m_End, layerMask );
if( via )
{
layerMask |= via->ReturnMaskLayer();
via->SetState( BUSY, ON );
}
Track->SetState( BUSY, ON );
segm = ::GetTrace( this, TrackListEnd, Track->m_End, layerMask );
Track->SetState( BUSY, OFF );
if( via )
via->SetState( BUSY, OFF );
if( segm == NULL )
{
switch( NbEnds )
{
case 0:
int BeginPad, EndPad;
*aStartTrace = Track;
NbEnds++;
/* Swap ox, oy with fx, fy */
BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD );
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
if( BeginPad )
Track->SetState( END_ONPAD, ON );
if( EndPad )
Track->SetState( BEGIN_ONPAD, ON );
EXCHG( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end );
break;
case 1:
*aEndTrace = Track;
ok = 1;
return ok;
}
}
}
return ok;
}
wxString TRACK::GetSelectMenuText() const
{
wxString text;
......
......@@ -17,7 +17,26 @@
* to the near neighbor internal layer */
#define VIA_NOT_DEFINED 0 /* not yet used */
/***/
/**
* Function GetTrace
* is a helper function to locate a trace segment having an end point at \a aPosition
* on \a aLayerMask starting at \a aStartTrace and end at \a aEndTrace.
* <p>
* The segments of track that are flagged as deleted or busy are ignored. Layer
* visibility is also ignored.
* </p>
* @param aStartTrace A pointer to the TRACK object to begin searching.
* @param aEndTrace A pointer to the TRACK object to stop the search. A NULL value
* searches to the end of the list.
* @param aPosition A wxPoint object containing the position to test.
* @param aLayerMask A layer or layers to mask the hit test. Use -1 to ignore
* layer mask.
* @return A TRACK object pointer if found otherwise NULL.
*/
extern TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, const wxPoint& aPosition,
int aLayerMask );
class TRACK : public BOARD_CONNECTED_ITEM
{
......@@ -300,6 +319,31 @@ public:
*/
TRACK* GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask );
/**
* Function GetTrace
* return the trace segment connected to the segment at \a aEndPoint from \a
* aStartTrace to \a aEndTrace.
*
* @param aStartTrace A pointer to the TRACK object to begin searching.
* @param aEndTrace A pointer to the TRACK object to stop the search. A NULL value
* searches to the end of the list.
* @param aEndPoint The start or end point of the segment to test against.
* @return A TRACK object pointer if found otherwise NULL.
*/
TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint );
/**
* Function GetEndSegments
* get the segments connected to the end point of the track.
* return 1 if OK, 0 when a track is a closed loop
* and the beginning and the end of the track in *StartTrack and *EndTrack
* Modify *StartTrack en *EndTrack :
* (*StartTrack)->m_Start coordinate is the beginning of the track
* (*EndTrack)->m_End coordinate is the end of the track
* Segments connected must be consecutive in list
*/
int GetEndSegments( int NbSegm, TRACK** StartTrack, TRACK** EndTrack );
/**
* Function GetClass
* returns the class name.
......
......@@ -245,7 +245,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC )
if( (type_end & START_ON_PAD ) == 0 )
{
other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, START );
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, START );
if( other == NULL ) // Test a connection to zones
{
......@@ -278,7 +278,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC )
segment->SetState( BUSY, ON );
SEGVIA* via = (SEGVIA*) other;
other = GetConnectedTrace( via, frame->GetBoard()->m_Track, NULL, START );
other = via->GetTrace( frame->GetBoard()->m_Track, NULL, START );
if( other == NULL )
{
......@@ -299,7 +299,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC )
// if not connected to a pad, test if segment's END is connected to another track
if( (type_end & END_ON_PAD ) == 0 )
{
other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, END );
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, END );
if( other == NULL ) // Test a connection to zones
{
......@@ -333,7 +333,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* frame, wxDC* DC )
segment->SetState( BUSY, ON );
SEGVIA* via = (SEGVIA*) other;
other = GetConnectedTrace( via, frame->GetBoard()->m_Track, NULL, END );
other = via->GetTrace( frame->GetBoard()->m_Track, NULL, END );
if( other == NULL )
{
......@@ -458,7 +458,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
// search for a possible point that connects on the START point of the segment
for( segStart = segment->Next(); ; )
{
segStart = GetConnectedTrace( segment, segStart, NULL, START );
segStart = segment->GetTrace( segStart, NULL, START );
if( segStart )
{
......@@ -472,7 +472,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
/* We must have only one segment connected */
segStart->SetState( BUSY, ON );
other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, START );
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, START );
segStart->SetState( BUSY, OFF );
if( other == NULL )
......@@ -497,7 +497,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
/* search for a possible point that connects on the END point of the segment: */
for( segEnd = segment->Next(); ; )
{
segEnd = GetConnectedTrace( segment, segEnd, NULL, END );
segEnd = segment->GetTrace( segEnd, NULL, END );
if( segEnd )
{
......@@ -509,7 +509,7 @@ static void clean_segments( PCB_EDIT_FRAME* frame )
/* We must have only one segment connected */
segEnd->SetState( BUSY, ON );
other = GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, END );
other = segment->GetTrace( frame->GetBoard()->m_Track, NULL, END );
segEnd->SetState( BUSY, OFF );
if( other == NULL )
......@@ -662,7 +662,8 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC )
}
else
{
other = GetConnectedTrace( segment, GetBoard()->m_Track, NULL, START );
other = segment->GetTrace( GetBoard()->m_Track, NULL, START );
if( other )
net_code_s = other->GetNet();
}
......@@ -679,7 +680,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC )
}
else
{
other = GetConnectedTrace( segment, GetBoard()->m_Track, NULL, END );
other = segment->GetTrace( GetBoard()->m_Track, NULL, END );
if( other )
net_code_e = other->GetNet();
......@@ -825,7 +826,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC )
// test if the track is not precisely starting on the found pad
if( segment->m_Start != pad->m_Pos )
{
if( GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, START ) == NULL )
if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, START ) == NULL )
{
TRACK* newTrack = segment->Copy();
......@@ -849,7 +850,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame, wxDC* DC )
// test if the track is not precisely ending on the found pad
if( segment->m_End != pad->m_Pos )
{
if( GetConnectedTrace( segment, frame->GetBoard()->m_Track, NULL, END ) == NULL )
if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, END ) == NULL )
{
TRACK* newTrack = segment->Copy();
......
......@@ -378,7 +378,7 @@ void PCB_BASE_FRAME::TestNetConnection( wxDC* aDC, int aNetCode )
Merge_SubNets_Connected_By_CopperAreas( m_Pcb, aNetCode );
/* Test the ratsnest for this net */
int nb_net_noconnect = Test_1_Net_Ratsnest( aDC, aNetCode );
int nb_net_noconnect = TestOneRatsNest( aDC, aNetCode );
/* Display results */
msg.Printf( wxT( "links %d nc %d net:nc %d" ),
......@@ -450,12 +450,12 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK*
if( Track->start == NULL ) // end track not already connected, search a connection
{
Track->start = GetConnectedTrace( Track, Track, pt_end_conn, START );
Track->start = Track->GetTrace( Track, pt_end_conn, START );
}
if( Track->end == NULL ) // end track not already connected, search a connection
{
Track->end = GetConnectedTrace( Track, Track, pt_end_conn, END );
Track->end = Track->GetTrace( Track, pt_end_conn, END );
}
if( Track == pt_end_conn )
......@@ -578,12 +578,12 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode()
{
if( pt_trace->start == NULL )
{
pt_trace->start = GetConnectedTrace( pt_trace, m_Pcb->m_Track, NULL, START );
pt_trace->start = pt_trace->GetTrace( m_Pcb->m_Track, NULL, START );
}
if( pt_trace->end == NULL )
{
pt_trace->end = GetConnectedTrace( pt_trace, m_Pcb->m_Track, NULL, END );
pt_trace->end = pt_trace->GetTrace( m_Pcb->m_Track, NULL, END );
}
}
......@@ -608,7 +608,7 @@ void PCB_BASE_FRAME::RecalculateAllTracksNetcode()
// Lock for a connection to a track with a known netcode
pt_next = m_Pcb->m_Track;
while( ( pt_next = GetConnectedTrace( via, pt_next, NULL, START ) ) != NULL )
while( ( pt_next = via->GetTrace( pt_next, NULL, START ) ) != NULL )
{
if( pt_next->GetNet() )
{
......
......@@ -529,7 +529,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
TestConnections( NULL );
Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
TestRatsNest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
OnModify();
GetBoard()->DisplayInfo( this );
DrawPanel->Refresh();
......
......@@ -191,7 +191,7 @@ void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC )
int layerMask = (1 << getActiveLayer());
wxPoint pos = GetScreen()->RefPos( true );
pt_segm = GetTrace( GetBoard(), GetBoard()->m_Track, pos, layerMask );
pt_segm = GetBoard()->GetTrace( GetBoard()->m_Track, pos, layerMask );
if( pt_segm == NULL )
GetBoard()->DisplayInfo( this );
......
This diff is collapsed.
......@@ -122,7 +122,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
/* Display info : */
module->DisplayInfo( this );
Place_Module( module, NULL );
PlaceModule( module, NULL );
GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NetInfo->BuildListOfNets();
......@@ -411,6 +411,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
NewModulesOnly ? false : true,
false ) == 0 )
break;
DisplayActivity( (int) ( ii * step ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */
......@@ -458,7 +459,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
if( dlg.ShowModal() != wxID_OK )
return false; // cancelled by user
return false; // canceled by user
Name_Cmp = dlg.GetValue();
Name_Cmp.Trim( true );
......@@ -557,7 +558,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
if( strnicmp( Line, "$EndLIBRARY", 8 ) == 0 )
continue;
// Search fo the beginning of module section:
// Search for the beginning of module section:
if( skip_header )
{
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
......
......@@ -58,7 +58,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* Module )
GetBoard()->m_NetInfo->BuildListOfNets();
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
Place_Module( Module, NULL );
PlaceModule( Module, NULL );
if( Module->GetLayer() != LAYER_N_FRONT )
Module->Flip( Module->m_Pos );
......@@ -123,9 +123,9 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
}
}
module = Get_Librairie_Module( library, ModuleName, false );
module = GetModuleLibrary( library, ModuleName, false );
if( ( module == NULL ) && AllowWildSeach ) /* Search with wildcard */
if( ( module == NULL ) && AllowWildSeach ) /* Search with wild card */
{
AllowWildSeach = false;
wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' );
......@@ -139,7 +139,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
}
else
{
module = Get_Librairie_Module( library, ModuleName, true );
module = GetModuleLibrary( library, ModuleName, true );
}
}
......@@ -175,21 +175,9 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
}
/**
* Function Get_Librairie_Module
*
* Read active libraries or one library to find and load a given module
* If found the module is linked to the tail of linked list of modules
* @param aLibraryFullFilename: the full filename of the library to read. If empty,
* all active libraries are read
* @param aModuleName = module name to load
* @param aDisplayMessageError = true to display an error message if any.
* @return a MODULE * pointer to the new module, or NULL
*
*/
MODULE* PCB_BASE_FRAME::Get_Librairie_Module( const wxString& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError )
MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError )
{
wxFileName fn;
wxString Name;
......@@ -296,20 +284,6 @@ MODULE* PCB_BASE_FRAME::Get_Librairie_Module( const wxString& aLibraryFullFilena
}
/**
* Function Select_1_Module_From_List
* Display a list of modules found in active libraries or a given library
*
* @param aWindow - The active window.
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename ==
* void, list all modules)
* @param aMask = Display filter (wildcard)( Mask = wxEmptyString if not used )
* @param aKeyWord = keyword list, to display a filtered list of module having
* one (or more) of these keyworks in their keyword list
* ( aKeyWord = wxEmptyString if not used )
*
* @return wxEmptyString if abort or fails, or the selected module name if Ok
*/
wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
const wxString& aLibraryFullFilename,
const wxString& aMask,
......@@ -406,6 +380,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
wxArrayString listnames;
Module = aPcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
listnames.Add( Module->m_Reference->m_Text );
......
......@@ -107,253 +107,3 @@ MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActi
return NULL;
}
/*
* return true if the dist between p1 and p2 < max_dist
* Currently in test (currently rasnest algos work only if p1 == p2)
*/
inline bool IsPointsAreNear(wxPoint & p1, wxPoint & p2, int max_dist)
{
#if 0 // Do not change it: does not work
{
int dist;
dist = abs(p1.x - p2.x) + abs (p1.y - p2.y);
dist *= 7;
dist /= 10;
if ( dist < max_dist ) return true;
}
#else
if ( p1 == p2 ) return true;
#endif
return false;
}
/**
* Search for the track (or via) segment which is connected to the track
* segment PtRefSegm
* if extr == START, the starting track segment PtRefSegm is used to locate
* a connected segment
* if extr == END, the ending track segment PtRefSegm is used
* The test connection consider only end track segments
*
* Search is made from pt_base to pt_lim (in the track linked list)
* if pt_lim == NULL, the search is made from pt_base to the end of list
*
* In order to have a fast computation time:
* a first search is made considering only the +/- 50 next door neighbor
* of PtRefSegm.
* if no track is found : the entire list is tested
*
* @param PtRefSegm = reference segment
* @param pt_base = lower limit for search
* @param pt_lim = upper limit for search (can be NULL)
* @param extr = START or END = end of ref track segment to use in tests
*/
TRACK* GetConnectedTrace( TRACK* PtRefSegm, TRACK* pt_base, TRACK* pt_lim, int extr )
{
const int NEIGHTBOUR_COUNT_MAX = 50;
TRACK* PtSegmB, * PtSegmN;
int Reflayer;
wxPoint pos_ref;
int ii;
int max_dist;
if( extr == START )
pos_ref = PtRefSegm->m_Start;
else
pos_ref = PtRefSegm->m_End;
Reflayer = PtRefSegm->ReturnMaskLayer();
PtSegmB = PtSegmN = PtRefSegm;
for( ii = 0; ii < NEIGHTBOUR_COUNT_MAX; ii++ )
{
if( (PtSegmN == NULL) && (PtSegmB == NULL) )
break;
if( PtSegmN )
{
if( PtSegmN->GetState( BUSY | IS_DELETED ) )
goto suite;
if( PtSegmN == PtRefSegm )
goto suite;
/* max_dist is the max distance between 2 track ends which
* ensure a copper continuity */
max_dist = (PtSegmN->m_Width + PtRefSegm->m_Width)/2;
if( IsPointsAreNear(pos_ref, PtSegmN->m_Start, max_dist) )
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
if( IsPointsAreNear(pos_ref, PtSegmN->m_End, max_dist) )
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
suite:
if( PtSegmN == pt_lim )
PtSegmN = NULL;
else
PtSegmN = PtSegmN->Next();
}
if( PtSegmB )
{
if( PtSegmB->GetState( BUSY | IS_DELETED ) )
goto suite1;
if( PtSegmB == PtRefSegm )
goto suite1;
max_dist = (PtSegmB->m_Width + PtRefSegm->m_Width)/2;
if( IsPointsAreNear(pos_ref, PtSegmB->m_Start, max_dist) )
{
if( Reflayer & PtSegmB->ReturnMaskLayer() )
return PtSegmB;
}
if( IsPointsAreNear(pos_ref, PtSegmB->m_End, max_dist) )
{
if( Reflayer & PtSegmB->ReturnMaskLayer() )
return PtSegmB;
}
suite1:
if( PtSegmB == pt_base )
PtSegmB = NULL;
else if( PtSegmB->Type() != TYPE_PCB )
PtSegmB = PtSegmB->Back();
else
PtSegmB = NULL;
}
}
/* General search. */
for( PtSegmN = pt_base; PtSegmN != NULL; PtSegmN = PtSegmN->Next() )
{
if( PtSegmN->GetState( IS_DELETED | BUSY ) )
{
if( PtSegmN == pt_lim )
break;
continue;
}
if( PtSegmN == PtRefSegm )
{
if( PtSegmN == pt_lim )
break;
continue;
}
max_dist = ( PtSegmN->m_Width + PtRefSegm->m_Width ) / 2;
if( IsPointsAreNear( pos_ref, PtSegmN->m_Start, max_dist ) )
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
if( IsPointsAreNear( pos_ref, PtSegmN->m_End, max_dist ) )
{
if( Reflayer & PtSegmN->ReturnMaskLayer() )
return PtSegmN;
}
if( PtSegmN == pt_lim )
break;
}
return NULL;
}
/*
* 1 - Locate segment of track leading from the mouse.
* 2 - Locate segment of track point by point
* ref_pos.x, ref_pos.y.r
*
* The search begins to address start_adresse
*/
TRACK* GetTrace( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int LayerMask )
{
for( TRACK* track = start_adresse; track; track = track->Next() )
{
int layer = track->GetLayer();
if( track->GetState( BUSY | IS_DELETED ) )
{
// D( printf( "track %p is BUSY | IS_DELETED. BUSY=%d IS_DELETED=%d\n",
// track, track->GetState( BUSY ),
// track->GetState( IS_DELETED ) );)
continue;
}
if( aPcb->GetBoardDesignSettings()->IsLayerVisible( layer ) == false )
continue;
if( track->Type() == TYPE_VIA ) /* VIA encountered. */
{
if( track->HitTest( ref_pos ) )
return track;
}
else
{
if( (g_TabOneLayerMask[layer] & LayerMask) == 0 )
continue; /* Segments on different layers. */
if( track->HitTest( ref_pos ) )
return track;
}
}
return NULL;
}
/* Locate segment with one end that coincides with the point x, y
* Data on layers by masklayer
* Research is done to address start_adr has end_adr
* If end_adr = NULL, end search list
* The segments of track marks with the flag are not IS_DELETED or taken
* into account
*/
TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int MaskLayer )
{
TRACK* PtSegm;
if( start_adr == NULL )
return NULL;
for( PtSegm = start_adr; PtSegm != NULL; PtSegm = PtSegm->Next() )
{
if( PtSegm->GetState( IS_DELETED | BUSY ) == 0 )
{
if( ref_pos == PtSegm->m_Start )
{
if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
if( ref_pos == PtSegm->m_End )
{
if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
}
if( PtSegm == end_adr )
break;
}
return NULL;
}
......@@ -193,7 +193,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
{
int layer_mask = g_TabOneLayerMask[layer];
TRACK* track = GetTrace( m_Pcb, m_Pcb->m_Track, pos, layer_mask );
TRACK* track = m_Pcb->GetTrace( m_Pcb->m_Track, pos, layer_mask );
if( !track || track->Type() != TYPE_TRACK )
{
......
......@@ -330,7 +330,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxPoint cursor_pos = pcbframe->GetScreen()->GetCrossHairPosition();
pcbframe->GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
pcbframe->Place_Module( newmodule, NULL );
pcbframe->PlaceModule( newmodule, NULL );
pcbframe->GetScreen()->SetCrossHairPosition( cursor_pos );
newmodule->m_TimeStamp = GetTimeStamp();
pcbframe->SaveCopyInUndoList( newmodule, UR_NEW );
......@@ -568,7 +568,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
EDGE_MODULE* edge = NULL;
if( GetScreen()->GetCurItem()
&& ( GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE ) )
&& ( GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE ) )
{
edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
}
......
......@@ -69,6 +69,7 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC )
delete s_ModuleInitialCopy;
s_PickedList.ClearItemsList(); // Should be empty, but...
// Creates a copy of the current module, for abort and undo commands
s_ModuleInitialCopy = new MODULE( GetBoard() );
s_ModuleInitialCopy->Copy( module );
......@@ -256,14 +257,6 @@ void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
}
/**
* Function Delete Module
* Remove a footprint from m_Modules linked list and put it in undelete buffer
* The ratsnest and pad list are recalculated
* @param aModule = footprint to delete
* @param aDC = currentDevice Context. if NULL: do not redraw new ratsnest
* @param aAskBeforeDeleting : if true: ask for confirmation before deleting
*/
bool PCB_EDIT_FRAME::Delete_Module( MODULE* aModule, wxDC* aDC, bool aAskBeforeDeleting )
{
wxString msg;
......@@ -304,15 +297,6 @@ bool PCB_EDIT_FRAME::Delete_Module( MODULE* aModule, wxDC* aDC, bool aAskBeforeD
}
/**
* Function Change_Side_Module
* Flip a footprint (switch layer from component or component to copper)
* The mirroring is made from X axis
* if a footprint is not on copper or component layer it is not flipped
* (it could be on an adhesive layer, not supported at this time)
* @param Module the footprint to flip
* @param DC Current Device Context. if NULL, no redraw
*/
void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC )
{
if( Module == NULL )
......@@ -380,29 +364,24 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC )
}
/* Place module at cursor position.
*
* DC (if NULL: no display screen has the output.
* Update module coordinates with the new position.
*/
void PCB_BASE_FRAME::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest )
void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreateRatsnest )
{
TRACK* pt_segm;
wxPoint newpos;
if( module == 0 )
if( aModule == 0 )
return;
OnModify();
GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK);
if( module->IsNew() )
if( aModule->IsNew() )
{
SaveCopyInUndoList( module, UR_NEW );
SaveCopyInUndoList( aModule, UR_NEW );
}
else if( (module->m_Flags & IS_MOVED ) )
else if( (aModule->m_Flags & IS_MOVED ) )
{
ITEM_PICKER picker( module, UR_CHANGED );
ITEM_PICKER picker( aModule, UR_CHANGED );
picker.m_Link = s_ModuleInitialCopy;
s_PickedList.PushItem( picker );
s_ModuleInitialCopy = NULL; // the picker is now owner of s_ModuleInitialCopy.
......@@ -417,18 +396,18 @@ void PCB_BASE_FRAME::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreate
s_PickedList.ClearItemsList();
}
if( g_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK ) && DC )
trace_ratsnest_module( DC );
if( g_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK ) && aDC )
TraceModuleRatsNest( aDC );
newpos = GetScreen()->GetCrossHairPosition();
module->SetPosition( newpos );
module->m_Flags = 0;
aModule->SetPosition( newpos );
aModule->m_Flags = 0;
delete s_ModuleInitialCopy;
s_ModuleInitialCopy = NULL;
if( DC )
module->Draw( DrawPanel, DC, GR_OR );
if( aDC )
aModule->Draw( DrawPanel, aDC, GR_OR );
if( g_DragSegmentList.size() )
{
......@@ -438,8 +417,8 @@ void PCB_BASE_FRAME::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreate
pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->SetState( IN_EDIT, OFF );
if( DC )
pt_segm->Draw( DrawPanel, DC, GR_OR );
if( aDC )
pt_segm->Draw( DrawPanel, aDC, GR_OR );
}
// Delete drag list
......@@ -450,12 +429,12 @@ void PCB_BASE_FRAME::Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreate
DrawPanel->SetMouseCapture( NULL, NULL );
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) && !aDoNotRecreateRatsnest )
Compile_Ratsnest( DC, true );
Compile_Ratsnest( aDC, true );
if( DC )
if( aDC )
DrawPanel->Refresh();
module->DisplayInfo( this );
aModule->DisplayInfo( this );
}
......@@ -559,6 +538,6 @@ void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module )
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
frame->build_ratsnest_module( module );
frame->trace_ratsnest_module( DC );
frame->TraceModuleRatsNest( DC );
}
}
......@@ -770,7 +770,7 @@ void SortTrackEndPoints( TRACK* track )
bool PCB_EDIT_FRAME::MergeCollinearTracks( TRACK* track, wxDC* DC, int end )
{
testtrack = (TRACK*) GetConnectedTrace( track, GetBoard()->m_Track, NULL, end );
testtrack = track->GetTrace( GetBoard()->m_Track, NULL, end );
if( testtrack )
{
......@@ -844,7 +844,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
s_StartSegmentPresent = s_EndSegmentPresent = true;
if( ( track->start == NULL ) || ( track->start->Type() == TYPE_TRACK ) )
TrackToStartPoint = GetConnectedTrace( track, GetBoard()->m_Track, NULL, START );
TrackToStartPoint = track->GetTrace( GetBoard()->m_Track, NULL, START );
// Test if more than one segment is connected to this point
if( TrackToStartPoint )
......@@ -852,14 +852,14 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
TrackToStartPoint->SetState( BUSY, ON );
if( ( TrackToStartPoint->Type() == TYPE_VIA )
|| GetConnectedTrace( track, GetBoard()->m_Track, NULL, START ) )
|| track->GetTrace( GetBoard()->m_Track, NULL, START ) )
error = true;
TrackToStartPoint->SetState( BUSY, OFF );
}
if( ( track->end == NULL ) || ( track->end->Type() == TYPE_TRACK ) )
TrackToEndPoint = GetConnectedTrace( track, GetBoard()->m_Track, NULL, END );
TrackToEndPoint = track->GetTrace( GetBoard()->m_Track, NULL, END );
// Test if more than one segment is connected to this point
if( TrackToEndPoint )
......@@ -867,7 +867,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
TrackToEndPoint->SetState( BUSY, ON );
if( (TrackToEndPoint->Type() == TYPE_VIA)
|| GetConnectedTrace( track, GetBoard()->m_Track, NULL, END ) )
|| track->GetTrace( GetBoard()->m_Track, NULL, END ) )
error = true;
TrackToEndPoint->SetState( BUSY, OFF );
......@@ -1064,7 +1064,7 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
TRACK* ptsegm = GetTrace( Pcb->m_Track, NULL, pos, LayerMask );
if( ptsegm == NULL )
ptsegm = GetTrace( Pcb, Pcb->m_Track, pos, LayerMask );
ptsegm = Pcb->GetTrace( Pcb->m_Track, pos, LayerMask );
return ptsegm;
}
......
This diff is collapsed.
......@@ -68,7 +68,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case TYPE_MODULE:
Place_Module( (MODULE*) DrawStruct, aDC );
PlaceModule( (MODULE*) DrawStruct, aDC );
exit = true;
break;
......@@ -190,8 +190,10 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_PCB_ADD_LINE_BUTT:
{
int shape = S_SEGMENT;
if( GetToolId() == ID_PCB_CIRCLE_BUTT )
shape = S_CIRCLE;
if( GetToolId() == ID_PCB_ARC_BUTT )
shape = S_ARC;
......@@ -200,6 +202,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
DisplayError( this, _( "Graphic not authorized on Copper layers" ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_DrawSegment( NULL, shape, aDC );
......@@ -207,8 +210,8 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
DrawPanel->m_AutoPAN_Request = true;
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPE_DRAWSEGMENT)
&& DrawStruct->IsNew() )
&& (DrawStruct->Type() == TYPE_DRAWSEGMENT)
&& DrawStruct->IsNew() )
{
DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, aDC );
SetCurItem( DrawStruct );
......@@ -228,20 +231,23 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{
DrawStruct = Begin_Route( NULL, aDC );
SetCurItem( DrawStruct );
if( DrawStruct )
DrawPanel->m_AutoPAN_Request = true;
}
else if( DrawStruct && DrawStruct->IsNew() )
{
TRACK* track = Begin_Route( (TRACK*) DrawStruct, aDC );
// SetCurItem() must not write to the msg panel
// because a track info is displayed while moving the mouse cursor
if( track ) // A new segment was created
SetCurItem( DrawStruct = track, false );
DrawPanel->m_AutoPAN_Request = true;
}
break;
break;
case ID_PCB_ZONES_BUTT:
......@@ -254,23 +260,23 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
// there is no current item, try to find something under mouse
DrawStruct = PcbGeneralLocateAndDisplay();
bool hit_on_corner = false;
if( DrawStruct && (DrawStruct->Type() == TYPE_ZONE_CONTAINER) )
{
// We have a hit under mouse (a zone outline corner or segment)
// test for a corner only because want to move corners only.
ZONE_CONTAINER* edge_zone = (ZONE_CONTAINER*) DrawStruct;
if( edge_zone->HitTestForCorner( GetScreen()->RefPos( true ) ) ) // corner located!
hit_on_corner = true;
}
if( hit_on_corner )
{
DrawPanel->MoveCursorToCrossHair();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
DrawPanel->m_AutoPAN_Request = true;
Start_Move_Zone_Corner( aDC,
zone_cont,
zone_cont->m_CornerSelection,
false );
Start_Move_Zone_Corner( aDC, zone_cont, zone_cont->m_CornerSelection, false );
}
else if( Begin_Zone( aDC ) )
{
......@@ -279,9 +285,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
GetScreen()->SetCurItem( DrawStruct );
}
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPE_ZONE_CONTAINER)
&& DrawStruct->IsNew() )
else if( DrawStruct && (DrawStruct->Type() == TYPE_ZONE_CONTAINER) && DrawStruct->IsNew() )
{ // Add a new corner to the current outline beeing created:
DrawPanel->m_AutoPAN_Request = true;
Begin_Zone( aDC );
......@@ -326,7 +330,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else if( DrawStruct->Type() == TYPE_MODULE )
{
Place_Module( (MODULE*) DrawStruct, aDC );
PlaceModule( (MODULE*) DrawStruct, aDC );
DrawPanel->m_AutoPAN_Request = false;
}
else
......@@ -342,15 +346,14 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
DisplayError( this, _( "Dimension not authorized on Copper layers" ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_Dimension( NULL, aDC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = true;
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPE_DIMENSION)
&& DrawStruct->IsNew() )
else if( DrawStruct && (DrawStruct->Type() == TYPE_DIMENSION) && DrawStruct->IsNew() )
{
DrawStruct = Begin_Dimension( (DIMENSION*) DrawStruct, aDC );
SetCurItem( DrawStruct );
......@@ -478,6 +481,7 @@ void PCB_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL );
}
break;
case ID_PCB_ADD_LINE_BUTT:
......
......@@ -66,41 +66,10 @@ void DrawTraces( EDA_DRAW_PANEL* panel,
/* LOCATE.CPP : */
/****************/
/* Locates the center through the point x, y, on layer data
* by masquelayer.
* Search is done to address start_adr has end_adr (not included)
*/
TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int masquelayer );
/* Search for segment connected to the segment edge by
* Ptr_piste:
* If int = START, the point of beginning of the segment is used
* If int = END, the end point of the segment is used
* The search is done only on the ends of segments
* The search is limited to the area [... pt_base] pt_lim.
*/
TRACK* GetConnectedTrace( TRACK* aTrace, TRACK* pt_base, TRACK* pt_lim, int extr );
/*
* 1 - Locate segment of track leading from the mouse.
* 2 - Locate segment of track point by point.
* Ref_pX, ref_pY.
*
* If layer <0 the layer is not tested.
*
* The search begins to address start_adresse
*/
TRACK* GetTrace( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int layer );
/* Locate a footprint by its bounding rectangle. */
MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked = false );
/* Locate a trace segment at the current cursor position.
* The search begins to address start_adresse.
*/
TRACK* GetTrace( TRACK* start_adresse, int typeloc );
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc );
/*************/
......
......@@ -148,7 +148,7 @@ void PCB_BASE_FRAME::Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus )
* it is faster than Build_Board_Ratsnest()
* because many optimizations and computations are already made
*/
Tst_Ratsnest( aDC, 0 );
TestRatsNest( aDC, 0 );
// Redraw the active ratsnest ( if enabled )
if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) && aDC )
......@@ -551,7 +551,7 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode )
/**
* Function used by Tst_Ratsnest
* Function used by TestRatsNest
* Function like gen_rats_block_to_block(..)
* Function testing the ratsnest between 2 blocks ( same net )
* The search is made between pads in block 1 and the others blocks
......@@ -615,7 +615,7 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net,
/**
* Function used by Tst_Ratsnest_general
* Function used by TestRatsNest_general
* The general ratsnest list must exists
* Activates the ratsnest between 2 pads ( assumes the same net )
* The function links 1 pad not already connected an other pad and activate
......@@ -673,12 +673,7 @@ static int tst_rats_pad_to_pad( int current_num_block,
}
/* Compute the active ratsnest
* The general ratsnest list must exists
* Compute the ACTIVE ratsnest in the general ratsnest list
* if ref_netcode == 0, test all nets, else test only ref_netcode
*/
void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode )
void PCB_BASE_FRAME::TestRatsNest( wxDC* aDC, int aNetCode )
{
RATSNEST_ITEM* rats;
D_PAD* pad;
......@@ -688,19 +683,16 @@ void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode )
return;
if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
Build_Board_Ratsnest( DC );
Build_Board_Ratsnest( aDC );
for( int net_code = 1; net_code < (int) m_Pcb->m_NetInfo->GetCount(); net_code++ )
{
net = m_Pcb->FindNet( net_code );
if( net == NULL ) //Should not occur
{
DisplayError( this, wxT( "Tst_Ratsnest() error: net not found" ) );
return;
}
wxCHECK_RET( net != NULL,
wxString::Format( wxT( "Net code %d not found!" ), net_code ) );
if( ref_netcode && (net_code != ref_netcode) )
if( aNetCode && (net_code != aNetCode) )
continue;
int num_block = 0;
......@@ -741,38 +733,17 @@ void PCB_BASE_FRAME::Tst_Ratsnest( wxDC* DC, int ref_netcode )
}
/**
* Function Test_1_Net_Ratsnest
* Compute the ratsnest relative to the net "net_code"
* @param aDC - Device context to draw on.
* @param aNetcode = netcode used to compute the ratsnest.
*/
int PCB_BASE_FRAME::Test_1_Net_Ratsnest( wxDC* aDC, int aNetcode )
int PCB_BASE_FRAME::TestOneRatsNest( wxDC* aDC, int aNetCode )
{
DisplayRastnestInProgress = false;
DrawGeneralRatsnest( aDC, aNetcode );
Tst_Ratsnest( aDC, aNetcode );
DrawGeneralRatsnest( aDC, aNetcode );
DrawGeneralRatsnest( aDC, aNetCode );
TestRatsNest( aDC, aNetCode );
DrawGeneralRatsnest( aDC, aNetCode );
return m_Pcb->GetRatsnestsCount();
}
/*
* Function build_ratsnest_module
* Build a ratsnest relative to one footprint. This is a simplified computation
* used only in move footprint. It is not optimal, but it is fast and sufficient
* to help a footprint placement
* It shows the connections from a pad to the nearest connected pad
*
* The ratsnest has 2 sections:
* - An "internal" ratsnest relative to pads of this footprint which are
* in the same net.
* this ratsnest section is computed once.
* - An "external" ratsnest connecting a pad of this footprint to an other
* pad (in an other footprint)
* The ratsnest section must be computed for each new position
*/
void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
{
static unsigned pads_module_count; // node count (node = pad with a net
......@@ -989,11 +960,7 @@ CalculateExternalRatsnest:
}
/*
* Display the ratsnest of a moving footprint, computed by
* build_ratsnest_module()
*/
void PCB_BASE_FRAME::trace_ratsnest_module( wxDC* DC )
void PCB_BASE_FRAME::TraceModuleRatsNest( wxDC* DC )
{
if( DC == NULL )
return;
......@@ -1022,7 +989,7 @@ void PCB_BASE_FRAME::trace_ratsnest_module( wxDC* DC )
}
}
g_ColorsSettings.SetItemColor(RATSNEST_VISIBLE, tmpcolor);
g_ColorsSettings.SetItemColor( RATSNEST_VISIBLE, tmpcolor );
}
......
......@@ -10,8 +10,6 @@
#include "protos.h"
static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff );
extern int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
TRACK** StartTrack, TRACK** EndTrack );
int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
......@@ -64,7 +62,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
#endif
TRACK* bufStart = m_Pcb->m_Track->GetStartNetCode( netcode ); // Beginning of tracks of the net
TRACK* bufEnd = bufStart->GetEndNetCode( netcode ); // Enf of tracks of the net
TRACK* bufEnd = bufStart->GetEndNetCode( netcode ); // End of tracks of the net
/* Flags for cleaning the net. */
for( pt_del = bufStart; pt_del; pt_del = pt_del->Next() )
......@@ -77,7 +75,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
break;
}
if( ReturnEndsTrack( aNewTrack, aNewTrackSegmentsCount, &StartTrack, &EndTrack ) == 0 )
if( aNewTrack->GetEndSegments( aNewTrackSegmentsCount, &StartTrack, &EndTrack ) == 0 )
return 0;
if( ( StartTrack == NULL ) || ( EndTrack == NULL ) )
......@@ -118,8 +116,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
endmasklayer |= pt_pad->m_layerMask;
}
/* Mark as deleted a new track (which is not involved in the search for other connections)
*/
// Mark as deleted a new track (which is not involved in the search for other connections)
ListSetState( aNewTrack, aNewTrackSegmentsCount, IS_DELETED, ON );
/* A segment must be connected to the starting point, otherwise
......@@ -249,8 +246,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
}
}
/* Clear BUSY flag here because the track did not get marked.
*/
// Clear BUSY flag here because the track did not get marked.
ListSetState( pt_del, nb_segm, BUSY, OFF );
}
......
......@@ -393,142 +393,3 @@ static void ChainMarkedSegments( BOARD* aPcb,
}
}
}
/* Calculate the end points coordinates of a track (a list of connected
* segments)
* RefTrack is a segment of the track
* return 1 if OK, 0 when a track is a closed loop
* and the beginning and the end of the track in *StartTrack and *EndTrack
* Modify *StartTrack en *EndTrack :
* (*StartTrack)->m_Start coordinate is the beginning of the track
* (*EndTrack)->m_End coordinate is the end of the track
* Segments connected must be consecutive in list
*/
int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** EndTrack )
{
TRACK* Track, * via, * segm, * TrackListEnd;
int NbEnds, layerMask, ii, ok = 0;
if( NbSegm <= 1 )
{
*StartTrack = *EndTrack = RefTrack;
return 1;
}
/* Calculation of the limit analysis. */
*StartTrack = *EndTrack = NULL;
TrackListEnd = Track = RefTrack; ii = 0;
for( ; ( Track != NULL ) && ( ii < NbSegm ); ii++, Track = Track->Next() )
{
TrackListEnd = Track;
Track->m_Param = 0;
}
/* Calculate the extremes. */
NbEnds = 0; Track = RefTrack; ii = 0;
for( ; ( Track != NULL ) && ( ii < NbSegm ); ii++, Track = Track->Next() )
{
if( Track->Type() == TYPE_VIA )
continue;
layerMask = Track->ReturnMaskLayer();
via = RefTrack->GetVia( TrackListEnd, Track->m_Start, layerMask );
if( via )
{
layerMask |= via->ReturnMaskLayer();
via->SetState( BUSY, ON );
}
Track->SetState( BUSY, ON );
segm = GetTrace( RefTrack, TrackListEnd, Track->m_Start, layerMask );
Track->SetState( BUSY, OFF );
if( via )
via->SetState( BUSY, OFF );
if( segm == NULL )
{
switch( NbEnds )
{
case 0:
*StartTrack = Track; NbEnds++;
break;
case 1:
int BeginPad, EndPad;
*EndTrack = Track;
/* Swap ox, oy with fx, fy */
BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD );
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
if( BeginPad )
Track->SetState( END_ONPAD, ON );
if( EndPad )
Track->SetState( BEGIN_ONPAD, ON );
EXCHG( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end );
ok = 1;
return ok;
}
}
layerMask = Track->ReturnMaskLayer();
via = RefTrack->GetVia( TrackListEnd, Track->m_End, layerMask );
if( via )
{
layerMask |= via->ReturnMaskLayer();
via->SetState( BUSY, ON );
}
Track->SetState( BUSY, ON );
segm = GetTrace( RefTrack, TrackListEnd, Track->m_End, layerMask );
Track->SetState( BUSY, OFF );
if( via )
via->SetState( BUSY, OFF );
if( segm == NULL )
{
switch( NbEnds )
{
case 0:
int BeginPad, EndPad;
*StartTrack = Track;
NbEnds++;
/* Swap ox, oy with fx, fy */
BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD );
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
if( BeginPad )
Track->SetState( END_ONPAD, ON );
if( EndPad )
Track->SetState( BEGIN_ONPAD, ON );
EXCHG( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end );
break;
case 1:
*EndTrack = Track;
ok = 1;
return ok;
}
}
}
return ok;
}
......@@ -12,8 +12,7 @@
#include "dialog_exchange_modules_base.h"
int s_SelectionMode = 0; // Remember the last exchange option, when exit
// dialog.
int s_SelectionMode = 0; // Remember the last exchange option, when exit dialog.
class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE
......@@ -420,9 +419,8 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
namecmp.Trim( true );
namecmp.Trim( false );
NewModule = m_Parent->Get_Librairie_Module( wxEmptyString,
namecmp,
ShowError );
NewModule = m_Parent->GetModuleLibrary( wxEmptyString, namecmp, ShowError );
if( NewModule == NULL ) /* New module not found, redraw the old one. */
{
m_WinMessages->AppendText( wxT( "No\n" ) );
......@@ -431,6 +429,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
if( Module == m_CurrentModule )
m_CurrentModule = NewModule;
m_WinMessages->AppendText( wxT( "Ok\n" ) );
m_Parent->Exchange_Module( Module, NewModule, aUndoPickList );
......@@ -477,7 +476,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
/* place module without ratsnest refresh: this will be made later
* when all modules are on board
*/
Place_Module( aNewModule, NULL, true );
PlaceModule( aNewModule, NULL, true );
GetScreen()->SetCrossHairPosition( oldpos, false );
/* Flip footprint if needed */
......
......@@ -166,7 +166,7 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose )
TestConnections( NULL );
// Recalculate the active ratsnest, i.e. the unconnected links
Tst_Ratsnest( NULL, 0 );
TestRatsNest( NULL, 0 );
DrawPanel->Refresh( true );
return errorLevel;
......
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