Commit 8a8377ff authored by dickelbeck's avatar dickelbeck

beautification, hit test improvements

parent ea6aba82
/*************************************************/ /*************************************************/
/* Routines de placement automatique des MODULES */ /* Routines de placement automatique des MODULES */
/*************************************************/ /*************************************************/
/* Fichier autoplac.cpp */ /* Fichier autoplac.cpp */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -14,910 +14,971 @@ ...@@ -14,910 +14,971 @@
#include "protos.h" #include "protos.h"
/************************************************************/ /************************************************************/
/* Menu et Routines de placement automatique des composants */ /* Menu et Routines de placement automatique des composants */
/************************************************************/ /************************************************************/
#define GAIN 16 #define GAIN 16
#define PENALITE 500 #define PENALITE 500
/* Penalite pour orientation donnee par CntRot90 et CntRot180: /* Penalite pour orientation donnee par CntRot90 et CntRot180:
gradue de 0 ( rotation interdite ) a 10 ( rotation a cout null ) * gradue de 0 ( rotation interdite ) a 10 ( rotation a cout null )
Le cout est ici donne en majoration * Le cout est ici donne en majoration
*/ */
static float OrientPenality[11] = { static const float OrientPenality[11] = {
2.0, /* CntRot = 0 en fait rotation interdite */ 2.0, /* CntRot = 0 en fait rotation interdite */
1.9, /* CntRot = 1 */ 1.9, /* CntRot = 1 */
1.8, /* CntRot = 2 */ 1.8, /* CntRot = 2 */
1.7, /* CntRot = 3 */ 1.7, /* CntRot = 3 */
1.6, /* CntRot = 4 */ 1.6, /* CntRot = 4 */
1.5, /* CntRot = 5 */ 1.5, /* CntRot = 5 */
1.4, /* CntRot = 5 */ 1.4, /* CntRot = 5 */
1.3, /* CntRot = 7 */ 1.3, /* CntRot = 7 */
1.2, /* CntRot = 8 */ 1.2, /* CntRot = 8 */
1.1, /* CntRot = 9 */ 1.1, /* CntRot = 9 */
1.0}; /* CntRot = 10 rotation autorisee, penalite nulle */ 1.0 /* CntRot = 10 rotation autorisee, penalite nulle */
};
/* Etat d'une cellule */ /* Etat d'une cellule */
#define OUT_OF_BOARD -2 #define OUT_OF_BOARD -2
#define OCCUPED_By_MODULE -1 #define OCCUPED_By_MODULE -1
/* variables locales */ /* variables locales */
static wxPoint CurrPosition; // position courante du module en cours de placement static wxPoint CurrPosition; // position courante du module en cours de placement
static bool AutoPlaceShowAll = TRUE; static bool AutoPlaceShowAll = TRUE;
float MinCout; float MinCout;
/* Fonctions locales */ /* Fonctions locales */
static int TstModuleOnBoard(BOARD * Pcb, MODULE * Module, bool TstOtherSide); static int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide );
static void Build_PlacedPads_List(BOARD * Pcb); static void Build_PlacedPads_List( BOARD* Pcb );
static int Tri_PlaceModules(MODULE ** pt_ref, MODULE ** pt_compare); static int Tri_PlaceModules( MODULE** pt_ref, MODULE** pt_compare );
static void TracePenaliteRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int marge, int Penalite, int masque_layer); int marge, int Penalite, int masque_layer );
static MODULE * PickModule( WinEDA_PcbFrame * pcbframe, wxDC * DC ); static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC );
/* variables importees */ /* variables importees */
extern CHEVELU * local_liste_chevelu; // adresse de base du buffer des chevelus locaux extern CHEVELU* local_liste_chevelu; // adresse de base du buffer des chevelus locaux
extern int nb_local_chevelu; // nbr de links du module en deplacement extern int nb_local_chevelu; // nbr de links du module en deplacement
/********************************************************************************/ /********************************************************************************/
void WinEDA_PcbFrame::AutoPlaceModule(MODULE * Module, int place_mode, wxDC * DC) void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
/********************************************************************************/ /********************************************************************************/
/* Routine de Placement Automatique des composants dans le contour du PCB /* Routine de Placement Automatique des composants dans le contour du PCB
Les composants ayant le status FIXE ne sont pas bouges * Les composants ayant le status FIXE ne sont pas bouges
Si le menu appelant est le placement de 1 module, il sera replace * Si le menu appelant est le placement de 1 module, il sera replace
*/ */
{ {
int ii, activ; int ii, activ;
MODULE * ThisModule = NULL; MODULE* ThisModule = NULL;
MODULE ** BaseListeModules; MODULE** BaseListeModules;
wxPoint PosOK; wxPoint PosOK;
wxPoint memopos; wxPoint memopos;
int error; int error;
int NbModules = 0; int NbModules = 0;
int NbTotalModules = 0; int NbTotalModules = 0;
float Pas; float Pas;
int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
if( m_Pcb->m_Modules == NULL ) return; if( m_Pcb->m_Modules == NULL )
return;
DrawPanel->m_AbortRequest = FALSE;
DrawPanel->m_AbortEnable = TRUE; DrawPanel->m_AbortRequest = FALSE;
DrawPanel->m_AbortEnable = TRUE;
switch( place_mode )
{ switch( place_mode )
case PLACE_1_MODULE: {
ThisModule = Module; case PLACE_1_MODULE:
if(ThisModule == NULL) return; ThisModule = Module;
ThisModule->m_ModuleStatus &= ~(MODULE_is_PLACED|MODULE_to_PLACE); if( ThisModule == NULL )
break; return;
ThisModule->m_ModuleStatus &= ~(MODULE_is_PLACED | MODULE_to_PLACE);
case PLACE_OUT_OF_BOARD: break;
break;
case PLACE_OUT_OF_BOARD:
case PLACE_ALL: break;
if( ! IsOK(this, _("Footprints NOT LOCKED will be moved") ))
return; case PLACE_ALL:
break; if( !IsOK( this, _( "Footprints NOT LOCKED will be moved" ) ) )
return;
case PLACE_INCREMENTAL: break;
if( ! IsOK(this, _("Footprints NOT PLACED will be moved")) )
return; case PLACE_INCREMENTAL:
break; if( !IsOK( this, _( "Footprints NOT PLACED will be moved" ) ) )
} return;
break;
memopos = CurrPosition; }
lay_tmp_BOTTOM = Route_Layer_BOTTOM;
lay_tmp_TOP = Route_Layer_TOP; memopos = CurrPosition;
OldPasRoute = g_GridRoutingSize; lay_tmp_BOTTOM = Route_Layer_BOTTOM;
lay_tmp_TOP = Route_Layer_TOP;
g_GridRoutingSize = m_CurrentScreen->GetGrid().x; OldPasRoute = g_GridRoutingSize;
// Ensure g_GridRoutingSize has a reasonnable value:
if ( g_GridRoutingSize < 10 ) g_GridRoutingSize = 10; // Min value = 1/1000 inch g_GridRoutingSize = m_CurrentScreen->GetGrid().x;
/* Compute module parmeters used in auto place */ // Ensure g_GridRoutingSize has a reasonnable value:
Module = m_Pcb->m_Modules; if( g_GridRoutingSize < 10 )
for( ; Module != NULL; Module = (MODULE*)Module->Pnext) // remise a jour du rect d'encadrement g_GridRoutingSize = 10; // Min value = 1/1000 inch
{
Module->Set_Rectangle_Encadrement(); /* Compute module parmeters used in auto place */
Module->SetRectangleExinscrit(); Module = m_Pcb->m_Modules;
} for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) // remise a jour du rect d'encadrement
{
/* Generation du plan de placement */ Module->Set_Rectangle_Encadrement();
if( GenPlaceBoard() == 0) return; Module->SetRectangleExinscrit();
}
/* Mise a jour des parametres modules utiles au placement */
BaseListeModules = GenListeModules(m_Pcb, &NbTotalModules ); /* Generation du plan de placement */
MyFree(BaseListeModules); if( GenPlaceBoard() == 0 )
return;
/* Placement des modules fixes sur le plan de placement */
Module = m_Pcb->m_Modules; /* Mise a jour des parametres modules utiles au placement */
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) BaseListeModules = GenListeModules( m_Pcb, &NbTotalModules );
{ MyFree( BaseListeModules );
Module->m_ModuleStatus &= ~MODULE_to_PLACE;
/* Placement des modules fixes sur le plan de placement */
switch( place_mode ) Module = m_Pcb->m_Modules;
{ for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
case PLACE_1_MODULE: {
if( ThisModule == Module ) Module->m_ModuleStatus &= ~MODULE_to_PLACE;
Module->m_ModuleStatus |= MODULE_to_PLACE;
break; switch( place_mode )
{
case PLACE_OUT_OF_BOARD: case PLACE_1_MODULE:
Module->m_ModuleStatus &= ~MODULE_is_PLACED; if( ThisModule == Module )
if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; Module->m_ModuleStatus |= MODULE_to_PLACE;
if( ! m_Pcb->m_BoundaryBox.Inside(Module->m_Pos) ) break;
Module->m_ModuleStatus |= MODULE_to_PLACE;
break; case PLACE_OUT_OF_BOARD:
Module->m_ModuleStatus &= ~MODULE_is_PLACED;
case PLACE_ALL: if( Module->m_ModuleStatus & MODULE_is_LOCKED )
Module->m_ModuleStatus &= ~MODULE_is_PLACED; break;
if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; if( !m_Pcb->m_BoundaryBox.Inside( Module->m_Pos ) )
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
break; break;
case PLACE_INCREMENTAL: case PLACE_ALL:
if( Module->m_ModuleStatus & MODULE_is_LOCKED ) Module->m_ModuleStatus &= ~MODULE_is_PLACED;
{ if( Module->m_ModuleStatus & MODULE_is_LOCKED )
Module->m_ModuleStatus &= ~MODULE_is_PLACED; break; break;
} Module->m_ModuleStatus |= MODULE_to_PLACE;
if( ! (Module->m_ModuleStatus & MODULE_is_PLACED) ) break;
Module->m_ModuleStatus |= MODULE_to_PLACE;
break; case PLACE_INCREMENTAL:
} if( Module->m_ModuleStatus & MODULE_is_LOCKED )
{
Module->m_ModuleStatus &= ~MODULE_is_PLACED; break;
if( Module->m_ModuleStatus & MODULE_to_PLACE ) // Erase from screen }
{ if( !(Module->m_ModuleStatus & MODULE_is_PLACED) )
NbModules++; Module->m_ModuleStatus |= MODULE_to_PLACE;
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); break;
} }
else
{ if( Module->m_ModuleStatus & MODULE_to_PLACE ) // Erase from screen
GenModuleOnBoard(Module); {
} NbModules++;
} Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
}
/* Placement des modules */ else
activ = 0; Pas = 100.0; {
if( NbModules ) Pas = 100.0 / (float)NbModules; GenModuleOnBoard( Module );
while( (Module = PickModule(this, DC) ) != NULL ) }
{ }
float BestScore;
DisplayActivity((int)(activ * Pas) , wxEmptyString ); activ++; /* Placement des modules */
activ = 0; Pas = 100.0;
/* Affichage du remplissage: surface de placement, obstacles, penalites */ if( NbModules )
DrawInfoPlace(DC); Pas = 100.0 / (float) NbModules;
while( ( Module = PickModule( this, DC ) ) != NULL )
/* Recherche du placement: orientation 0 */ {
error = RecherchePlacementModule(Module, DC); float BestScore;
BestScore = MinCout; DisplayActivity( (int) (activ * Pas), wxEmptyString ); activ++;
PosOK = CurrPosition;
if ( error == ESC ) goto end_of_tst; /* Affichage du remplissage: surface de placement, obstacles, penalites */
DrawInfoPlace( DC );
/* Recherche du placement: orientation 180 */
ii = Module->m_CntRot180 & 0x0F; /* Recherche du placement: orientation 0 */
if( ii != 0 ) error = RecherchePlacementModule( Module, DC );
{ BestScore = MinCout;
int Angle_Rot_Module = 1800; PosOK = CurrPosition;
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); if( error == ESC )
Module->SetRectangleExinscrit(); goto end_of_tst;
error = RecherchePlacementModule(Module, DC );
MinCout *= OrientPenality[ii]; /* Recherche du placement: orientation 180 */
if( BestScore > MinCout ) /* Cette orientation est meilleure */ ii = Module->m_CntRot180 & 0x0F;
{ if( ii != 0 )
PosOK = CurrPosition; {
BestScore = MinCout; int Angle_Rot_Module = 1800;
} Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
else Module->SetRectangleExinscrit();
{ error = RecherchePlacementModule( Module, DC );
Angle_Rot_Module = -1800; MinCout *= OrientPenality[ii];
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); if( BestScore > MinCout ) /* Cette orientation est meilleure */
} {
if ( error == ESC ) goto end_of_tst; PosOK = CurrPosition;
} BestScore = MinCout;
}
/* Recherche du placement: orientation 90 */ else
ii = Module->m_CntRot90 & 0x0F; {
if( ii != 0 ) Angle_Rot_Module = -1800;
{ Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
int Angle_Rot_Module = 900; }
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); if( error == ESC )
error = RecherchePlacementModule(Module, DC ); goto end_of_tst;
MinCout *= OrientPenality[ii]; }
if( BestScore > MinCout ) /* Cette orientation est meilleure */
{ /* Recherche du placement: orientation 90 */
PosOK = CurrPosition; ii = Module->m_CntRot90 & 0x0F;
BestScore = MinCout; if( ii != 0 )
} {
else int Angle_Rot_Module = 900;
{ Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
Angle_Rot_Module = -900; error = RecherchePlacementModule( Module, DC );
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); MinCout *= OrientPenality[ii];
} if( BestScore > MinCout ) /* Cette orientation est meilleure */
if ( error == ESC ) goto end_of_tst; {
} PosOK = CurrPosition;
BestScore = MinCout;
/* Recherche du placement: orientation -90 (ou 270 degres) */ }
ii = (Module->m_CntRot90 >> 4 ) & 0x0F; else
if( ii != 0 ) {
{ Angle_Rot_Module = -900;
int Angle_Rot_Module = 2700; Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); }
error = RecherchePlacementModule(Module, DC ); if( error == ESC )
MinCout *= OrientPenality[ii]; goto end_of_tst;
if( BestScore > MinCout ) /* Cette orientation est meilleure */ }
{
PosOK = CurrPosition; /* Recherche du placement: orientation -90 (ou 270 degres) */
BestScore = MinCout; ii = (Module->m_CntRot90 >> 4 ) & 0x0F;
} if( ii != 0 )
else {
{ int Angle_Rot_Module = 2700;
Angle_Rot_Module = -2700; Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); error = RecherchePlacementModule( Module, DC );
} MinCout *= OrientPenality[ii];
if ( error == ESC ) goto end_of_tst; if( BestScore > MinCout ) /* Cette orientation est meilleure */
} {
PosOK = CurrPosition;
BestScore = MinCout;
}
else
{
Angle_Rot_Module = -2700;
Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
}
if( error == ESC )
goto end_of_tst;
}
end_of_tst: end_of_tst:
if ( error == ESC ) break; if( error == ESC )
break;
/* placement du module */
CurrPosition = m_CurrentScreen->m_Curseur;
m_CurrentScreen->m_Curseur = PosOK;
Place_Module(Module, DC);
m_CurrentScreen->m_Curseur = CurrPosition;
Module->Set_Rectangle_Encadrement(); /* placement du module */
Module->SetRectangleExinscrit(); CurrPosition = m_CurrentScreen->m_Curseur;
m_CurrentScreen->m_Curseur = PosOK;
Place_Module( Module, DC );
m_CurrentScreen->m_Curseur = CurrPosition;
GenModuleOnBoard(Module); Module->Set_Rectangle_Encadrement();
Module->m_ModuleStatus |= MODULE_is_PLACED; Module->SetRectangleExinscrit();
Module->m_ModuleStatus &= ~MODULE_to_PLACE;
}
CurrPosition = memopos; GenModuleOnBoard( Module );
Module->m_ModuleStatus |= MODULE_is_PLACED;
Module->m_ModuleStatus &= ~MODULE_to_PLACE;
}
/* Liberation de la memoire */ CurrPosition = memopos;
Board.UnInitBoard();
Route_Layer_TOP = lay_tmp_TOP; /* Liberation de la memoire */
Route_Layer_BOTTOM = lay_tmp_BOTTOM; Board.UnInitBoard();
g_GridRoutingSize = OldPasRoute;
Module = m_Pcb->m_Modules; Route_Layer_TOP = lay_tmp_TOP;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) Route_Layer_BOTTOM = lay_tmp_BOTTOM;
{ g_GridRoutingSize = OldPasRoute;
Module->Set_Rectangle_Encadrement();
}
/* Recalcul de la liste des pads, detruite par les calculs precedents */ Module = m_Pcb->m_Modules;
m_Pcb->m_Status_Pcb = 0; build_liste_pads(); for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
Module->Set_Rectangle_Encadrement();
}
DrawPanel->ReDraw(DC, TRUE); /* Recalcul de la liste des pads, detruite par les calculs precedents */
m_Pcb->m_Status_Pcb = 0; build_liste_pads();
DrawPanel->m_AbortEnable = FALSE; DrawPanel->ReDraw( DC, TRUE );
DrawPanel->m_AbortEnable = FALSE;
} }
/**********************************************/ /**********************************************/
void WinEDA_PcbFrame::DrawInfoPlace(wxDC * DC) void WinEDA_PcbFrame::DrawInfoPlace( wxDC* DC )
/**********************************************/ /**********************************************/
/* Affiche a l'ecran les infos de placement /* Affiche a l'ecran les infos de placement
*/ */
{ {
int color, ii, jj; int color, ii, jj;
int ox, oy, top_state, bottom_state; int ox, oy, top_state, bottom_state;
GRSetDrawMode(DC, GR_COPY); GRSetDrawMode( DC, GR_COPY );
for ( ii = 0; ii < Nrows; ii ++ ) for( ii = 0; ii < Nrows; ii++ )
{ {
oy = m_Pcb->m_BoundaryBox.m_Pos.y + (ii * g_GridRoutingSize); oy = m_Pcb->m_BoundaryBox.m_Pos.y + (ii * g_GridRoutingSize);
for (jj = 0; jj < Ncols ; jj ++ ) for( jj = 0; jj < Ncols; jj++ )
{ {
ox = m_Pcb->m_BoundaryBox.m_Pos.x + (jj * g_GridRoutingSize); ox = m_Pcb->m_BoundaryBox.m_Pos.x + (jj * g_GridRoutingSize);
/* surface de placement : */ /* surface de placement : */
color = BLACK; color = BLACK;
top_state = GetCell(ii, jj , TOP); top_state = GetCell( ii, jj, TOP );
bottom_state = GetCell(ii, jj , BOTTOM); bottom_state = GetCell( ii, jj, BOTTOM );
if( (top_state & CELL_is_ZONE) ) color = BLUE; if( (top_state & CELL_is_ZONE) )
color = BLUE;
/* obstacles */
if( (top_state & CELL_is_EDGE) || (bottom_state & CELL_is_EDGE)) color = WHITE; /* obstacles */
if( (top_state & CELL_is_EDGE) || (bottom_state & CELL_is_EDGE) )
else if( top_state & (HOLE|CELL_is_MODULE) ) color = LIGHTRED; color = WHITE;
else if( bottom_state & (HOLE|CELL_is_MODULE) ) color = LIGHTGREEN;
else if( top_state & (HOLE | CELL_is_MODULE) )
else /* Affichage du remplissage: Penalites */ color = LIGHTRED;
{ else if( bottom_state & (HOLE | CELL_is_MODULE) )
if( GetDist(ii, jj , TOP ) || GetDist(ii, jj , BOTTOM ) ) color = LIGHTGREEN;
color = DARKGRAY;
} else /* Affichage du remplissage: Penalites */
{
GRPutPixel(&DrawPanel->m_ClipBox, DC, ox, oy, color); if( GetDist( ii, jj, TOP ) || GetDist( ii, jj, BOTTOM ) )
} color = DARKGRAY;
} }
GRPutPixel( &DrawPanel->m_ClipBox, DC, ox, oy, color );
}
}
} }
/***************************************/ /***************************************/
int WinEDA_PcbFrame::GenPlaceBoard(void) int WinEDA_PcbFrame::GenPlaceBoard( void )
/***************************************/ /***************************************/
/* Routine de generation du board ( cote composant + cote cuivre ) : /* Routine de generation du board ( cote composant + cote cuivre ) :
Alloue la memoire necessaire pour representer en "bitmap" sur la grille * Alloue la memoire necessaire pour representer en "bitmap" sur la grille
courante: * courante:
- la surface de placement des composant ( le board ) * - la surface de placement des composant ( le board )
- le bitmap des penalites * - le bitmap des penalites
et initialise les cellules du board a * et initialise les cellules du board a
- HOLE pour les cellules occupees par un segment EDGE * - HOLE pour les cellules occupees par un segment EDGE
- CELL_is_ZONE pour les cellules internes au contour EDGE (s'il est ferme) * - CELL_is_ZONE pour les cellules internes au contour EDGE (s'il est ferme)
*
la surface de placement (board) donne les cellules internes au contour * la surface de placement (board) donne les cellules internes au contour
du pcb, et parmi celle-ci les cellules libres et les cellules deja occupees * du pcb, et parmi celle-ci les cellules libres et les cellules deja occupees
*
le bitmap des penalites donnent les cellules occupes par les modules, * le bitmap des penalites donnent les cellules occupes par les modules,
augmentes d'une surface de penalite liee au nombre de pads du module * augmentes d'une surface de penalite liee au nombre de pads du module
*
le bitmap des penalites est mis a 0 * le bitmap des penalites est mis a 0
l'occupation des cellules est laisse a 0 * l'occupation des cellules est laisse a 0
*/ */
{ {
int jj, ii; int jj, ii;
int NbCells; int NbCells;
EDA_BaseStruct * PtStruct; EDA_BaseStruct* PtStruct;
wxString msg; wxString msg;
Board.UnInitBoard(); Board.UnInitBoard();
if( ! SetBoardBoundaryBoxFromEdgesOnly() ) if( !SetBoardBoundaryBoxFromEdgesOnly() )
{ {
DisplayError(this, _("No edge PCB, Unknown board size!"), 30); DisplayError( this, _( "No edge PCB, Unknown board size!" ), 30 );
return(0); return 0;
} }
/* The boundary box must have its start point on placing grid: */ /* The boundary box must have its start point on placing grid: */
m_Pcb->m_BoundaryBox.m_Pos.x -= m_Pcb->m_BoundaryBox.m_Pos.x % g_GridRoutingSize; m_Pcb->m_BoundaryBox.m_Pos.x -= m_Pcb->m_BoundaryBox.m_Pos.x % g_GridRoutingSize;
m_Pcb->m_BoundaryBox.m_Pos.y -= m_Pcb->m_BoundaryBox.m_Pos.y % g_GridRoutingSize; m_Pcb->m_BoundaryBox.m_Pos.y -= m_Pcb->m_BoundaryBox.m_Pos.y % g_GridRoutingSize;
/* The boundary box must have its end point on placing grid: */ /* The boundary box must have its end point on placing grid: */
wxPoint end = m_Pcb->m_BoundaryBox.GetEnd(); wxPoint end = m_Pcb->m_BoundaryBox.GetEnd();
end.x -= end.x % g_GridRoutingSize; end.x += g_GridRoutingSize; end.x -= end.x % g_GridRoutingSize; end.x += g_GridRoutingSize;
end.y -= end.y % g_GridRoutingSize; end.y += g_GridRoutingSize; end.y -= end.y % g_GridRoutingSize; end.y += g_GridRoutingSize;
m_Pcb->m_BoundaryBox.SetEnd(end); m_Pcb->m_BoundaryBox.SetEnd( end );
Nrows = m_Pcb->m_BoundaryBox.GetHeight() / g_GridRoutingSize; Nrows = m_Pcb->m_BoundaryBox.GetHeight() / g_GridRoutingSize;
Ncols = m_Pcb->m_BoundaryBox.GetWidth() / g_GridRoutingSize; Ncols = m_Pcb->m_BoundaryBox.GetWidth() / g_GridRoutingSize;
/* get a small margin for memory allocation: */ /* get a small margin for memory allocation: */
Ncols += 2; Nrows += 2; Ncols += 2; Nrows += 2;
NbCells = Ncols * Nrows; NbCells = Ncols * Nrows;
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
msg.Printf( wxT("%d"),Ncols); msg.Printf( wxT( "%d" ), Ncols );
Affiche_1_Parametre(this, 1, _("Cols"),msg,GREEN); Affiche_1_Parametre( this, 1, _( "Cols" ), msg, GREEN );
msg.Printf( wxT("%d"),Nrows); msg.Printf( wxT( "%d" ), Nrows );
Affiche_1_Parametre(this, 7, _("Lines"),msg,GREEN); Affiche_1_Parametre( this, 7, _( "Lines" ), msg, GREEN );
msg.Printf( wxT("%d"),NbCells); msg.Printf( wxT( "%d" ), NbCells );
Affiche_1_Parametre(this, 14, _("Cells."),msg,YELLOW); Affiche_1_Parametre( this, 14, _( "Cells." ), msg, YELLOW );
/* Choix du nombre de faces de placement */ /* Choix du nombre de faces de placement */
Nb_Sides = TWO_SIDES; Nb_Sides = TWO_SIDES;
Affiche_1_Parametre(this, 22, wxT("S"), ( Nb_Sides == TWO_SIDES ) ? wxT("2") : wxT("1"), WHITE); Affiche_1_Parametre( this, 22, wxT( "S" ), ( Nb_Sides == TWO_SIDES ) ? wxT( "2" ) : wxT(
"1" ), WHITE );
/* Creation du mapping du board */
Board.InitBoard(); /* Creation du mapping du board */
Board.InitBoard();
/* Affichage de la memoire utilisee */
msg.Printf( wxT("%d"), Board.m_MemSize / 1024 ); /* Affichage de la memoire utilisee */
Affiche_1_Parametre(this, 24, wxT("Mem(Ko)"),msg,CYAN); msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
Affiche_1_Parametre( this, 24, wxT( "Mem(Ko)" ), msg, CYAN );
Route_Layer_BOTTOM = CMP_N;
if( Nb_Sides == TWO_SIDES ) Route_Layer_BOTTOM = CUIVRE_N; Route_Layer_BOTTOM = CMP_N;
Route_Layer_TOP = CMP_N; if( Nb_Sides == TWO_SIDES )
Route_Layer_BOTTOM = CUIVRE_N;
/* Place the edge layer segments */ Route_Layer_TOP = CMP_N;
PtStruct = m_Pcb->m_Drawings;
TRACK TmpSegm(NULL); /* Place the edge layer segments */
TmpSegm.m_Layer = -1; PtStruct = m_Pcb->m_Drawings;
TmpSegm.m_NetCode = -1; TRACK TmpSegm( NULL );
TmpSegm.m_Width = g_GridRoutingSize/2;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) TmpSegm.m_Layer = -1;
{ TmpSegm.m_NetCode = -1;
DRAWSEGMENT * DrawSegm; TmpSegm.m_Width = g_GridRoutingSize / 2;
switch( PtStruct->m_StructType) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
case TYPEDRAWSEGMENT: DRAWSEGMENT* DrawSegm;
DrawSegm = (DRAWSEGMENT *) PtStruct;
if(DrawSegm->m_Layer != EDGE_N) break; switch( PtStruct->m_StructType )
{
TmpSegm.m_Start = DrawSegm->m_Start; case TYPEDRAWSEGMENT:
TmpSegm.m_End = DrawSegm->m_End; DrawSegm = (DRAWSEGMENT*) PtStruct;
TmpSegm.m_Shape = DrawSegm->m_Shape; if( DrawSegm->m_Layer != EDGE_N )
TmpSegm.m_Param = DrawSegm->m_Angle; break;
TraceSegmentPcb(m_Pcb, &TmpSegm, HOLE|CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL ); TmpSegm.m_Start = DrawSegm->m_Start;
break; TmpSegm.m_End = DrawSegm->m_End;
TmpSegm.m_Shape = DrawSegm->m_Shape;
case TYPETEXTE: TmpSegm.m_Param = DrawSegm->m_Angle;
default: break;
} TraceSegmentPcb( m_Pcb, &TmpSegm, HOLE | CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL );
} break;
case TYPETEXTE:
/* Init du point d'accrochage de la zone */ default:
OrCell(Nrows/2, Ncols/2, BOTTOM, CELL_is_ZONE); break;
}
/* Remplissage des cellules de la couche BOTTOM */ }
ii = 1; jj = 1;
/* Init du point d'accrochage de la zone */
while( ii ) OrCell( Nrows / 2, Ncols / 2, BOTTOM, CELL_is_ZONE );
{
msg.Printf( wxT("%d"), jj++ ); /* Remplissage des cellules de la couche BOTTOM */
Affiche_1_Parametre(this, 50, _("Loop"),msg,CYAN); ii = 1; jj = 1;
ii = Propagation(this);
} while( ii )
{
/* Init de la couche TOP */ msg.Printf( wxT( "%d" ), jj++ );
if( Board.m_BoardSide[TOP] ) Affiche_1_Parametre( this, 50, _( "Loop" ), msg, CYAN );
memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM],NbCells * sizeof(BoardCell)); ii = Propagation( this );
}
return(1);
/* Init de la couche TOP */
if( Board.m_BoardSide[TOP] )
memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM], NbCells * sizeof(BoardCell) );
return 1;
} }
/******************************************************/ /******************************************************/
void WinEDA_PcbFrame::GenModuleOnBoard(MODULE * Module) void WinEDA_PcbFrame::GenModuleOnBoard( MODULE* Module )
/******************************************************/ /******************************************************/
/* initialise sur le board de placement les cellules correspondantes au /* initialise sur le board de placement les cellules correspondantes au
module Module * module Module
*/ */
{ {
int ox, oy, fx, fy, Penalite; int ox, oy, fx, fy, Penalite;
int marge = g_GridRoutingSize / 2; int marge = g_GridRoutingSize / 2;
int masque_layer; int masque_layer;
D_PAD * Pad; D_PAD* Pad;
ox = Module->m_RealBoundaryBox.m_Pos.x - marge; ox = Module->m_RealBoundaryBox.m_Pos.x - marge;
fx = Module->m_RealBoundaryBox.GetRight() + marge; fx = Module->m_RealBoundaryBox.GetRight() + marge;
oy = Module->m_RealBoundaryBox.m_Pos.y - marge; oy = Module->m_RealBoundaryBox.m_Pos.y - marge;
fy = Module->m_RealBoundaryBox.GetBottom() + marge; fy = Module->m_RealBoundaryBox.GetBottom() + marge;
if( ox < m_Pcb->m_BoundaryBox.m_Pos.x) if( ox < m_Pcb->m_BoundaryBox.m_Pos.x )
ox = m_Pcb->m_BoundaryBox.m_Pos.x; ox = m_Pcb->m_BoundaryBox.m_Pos.x;
if( ox > m_Pcb->m_BoundaryBox.GetRight()) if( ox > m_Pcb->m_BoundaryBox.GetRight() )
ox = m_Pcb->m_BoundaryBox.GetRight(); ox = m_Pcb->m_BoundaryBox.GetRight();
if( fx < m_Pcb->m_BoundaryBox.m_Pos.x) fx = m_Pcb->m_BoundaryBox.m_Pos.x; if( fx < m_Pcb->m_BoundaryBox.m_Pos.x )
if( fx > m_Pcb->m_BoundaryBox.GetRight()) fx = m_Pcb->m_BoundaryBox.m_Pos.x;
fx = m_Pcb->m_BoundaryBox.GetRight(); if( fx > m_Pcb->m_BoundaryBox.GetRight() )
fx = m_Pcb->m_BoundaryBox.GetRight();
if( oy < m_Pcb->m_BoundaryBox.m_Pos.y) oy = m_Pcb->m_BoundaryBox.m_Pos.y;
if( oy > m_Pcb->m_BoundaryBox.GetBottom()) if( oy < m_Pcb->m_BoundaryBox.m_Pos.y )
oy = m_Pcb->m_BoundaryBox.GetBottom(); oy = m_Pcb->m_BoundaryBox.m_Pos.y;
if( oy > m_Pcb->m_BoundaryBox.GetBottom() )
if( fy < m_Pcb->m_BoundaryBox.m_Pos.y) fy = m_Pcb->m_BoundaryBox.m_Pos.y; oy = m_Pcb->m_BoundaryBox.GetBottom();
if( fy > m_Pcb->m_BoundaryBox.GetBottom())
fy = m_Pcb->m_BoundaryBox.GetBottom(); if( fy < m_Pcb->m_BoundaryBox.m_Pos.y )
fy = m_Pcb->m_BoundaryBox.m_Pos.y;
masque_layer = 0; if( fy > m_Pcb->m_BoundaryBox.GetBottom() )
if( Module->m_Layer == CMP_N ) masque_layer = CMP_LAYER; fy = m_Pcb->m_BoundaryBox.GetBottom();
if( Module->m_Layer == CUIVRE_N ) masque_layer = CUIVRE_LAYER;
masque_layer = 0;
TraceFilledRectangle(m_Pcb, ox, oy, fx, fy, masque_layer, if( Module->m_Layer == CMP_N )
CELL_is_MODULE, WRITE_OR_CELL); masque_layer = CMP_LAYER;
if( Module->m_Layer == CUIVRE_N )
/* Trace des pads et leur surface de securite */ masque_layer = CUIVRE_LAYER;
marge = g_DesignSettings.m_TrackClearence + g_DesignSettings.m_CurrentTrackWidth;
TraceFilledRectangle( m_Pcb, ox, oy, fx, fy, masque_layer,
for(Pad = Module->m_Pads ; Pad != NULL; Pad = (D_PAD *) Pad->Pnext ) CELL_is_MODULE, WRITE_OR_CELL );
{
Place_1_Pad_Board( m_Pcb, Pad, CELL_is_MODULE, marge, WRITE_OR_CELL); /* Trace des pads et leur surface de securite */
} marge = g_DesignSettings.m_TrackClearence + g_DesignSettings.m_CurrentTrackWidth;
/* Trace de la penalite */ for( Pad = Module->m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext )
marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN; {
Penalite = PENALITE; Place_1_Pad_Board( m_Pcb, Pad, CELL_is_MODULE, marge, WRITE_OR_CELL );
TracePenaliteRectangle(m_Pcb, ox, oy, fx, fy, marge, Penalite, }
masque_layer);
/* Trace de la penalite */
marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN;
Penalite = PENALITE;
TracePenaliteRectangle( m_Pcb, ox, oy, fx, fy, marge, Penalite,
masque_layer );
} }
/************************************************************************/ /************************************************************************/
int WinEDA_PcbFrame::RecherchePlacementModule(MODULE * Module, wxDC * DC) int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
/************************************************************************/ /************************************************************************/
/* /*
Routine Principale de recherche de la position optimale du module * Routine Principale de recherche de la position optimale du module
Entree: * Entree:
Module pointe la struct MODULE du module a placer. * Module pointe la struct MODULE du module a placer.
Retourne: * Retourne:
1 si placement impossible, 0 si OK * 1 si placement impossible, 0 si OK
et MinCout = variable externe = cout du meilleur placement * et MinCout = variable externe = cout du meilleur placement
*/ */
{ {
int cx, cy; int cx, cy;
int ox, oy, fx, fy; /* cadre d'occupation du module centre sur le curseur */ int ox, oy, fx, fy;/* cadre d'occupation du module centre sur le curseur */
int error = 1; int error = 1;
int DisplayChevelu = 0; int DisplayChevelu = 0;
wxPoint LastPosOK; wxPoint LastPosOK;
float mincout, cout, Score; float mincout, cout, Score;
int Penalite; int Penalite;
bool TstOtherSide; bool TstOtherSide;
Module->Display_Infos(this); Module->Display_Infos( this );
Build_PlacedPads_List(m_Pcb); Build_PlacedPads_List( m_Pcb );
LastPosOK.x = m_Pcb->m_BoundaryBox.m_Pos.x; LastPosOK.x = m_Pcb->m_BoundaryBox.m_Pos.x;
LastPosOK.y = m_Pcb->m_BoundaryBox.m_Pos.y; LastPosOK.y = m_Pcb->m_BoundaryBox.m_Pos.y;
cx = Module->m_Pos.x; cy = Module->m_Pos.y; cx = Module->m_Pos.x; cy = Module->m_Pos.y;
ox = Module->m_RealBoundaryBox.m_Pos.x - cx; ox = Module->m_RealBoundaryBox.m_Pos.x - cx;
fx = Module->m_RealBoundaryBox.m_Size.x + ox; fx = Module->m_RealBoundaryBox.m_Size.x + ox;
oy = Module->m_RealBoundaryBox.m_Pos.y - cy; oy = Module->m_RealBoundaryBox.m_Pos.y - cy;
fy = Module->m_RealBoundaryBox.m_Size.y + oy; fy = Module->m_RealBoundaryBox.m_Size.y + oy;
CurrPosition.x = m_Pcb->m_BoundaryBox.m_Pos.x - ox; CurrPosition.x = m_Pcb->m_BoundaryBox.m_Pos.x - ox;
CurrPosition.y = m_Pcb->m_BoundaryBox.m_Pos.y - oy; CurrPosition.y = m_Pcb->m_BoundaryBox.m_Pos.y - oy;
/* remise sur la grille de placement: */ /* remise sur la grille de placement: */
CurrPosition.x -= CurrPosition.x % g_GridRoutingSize; CurrPosition.x -= CurrPosition.x % g_GridRoutingSize;
CurrPosition.y -= CurrPosition.y % g_GridRoutingSize; CurrPosition.y -= CurrPosition.y % g_GridRoutingSize;
g_Offset_Module.x = cx - CurrPosition.x; g_Offset_Module.x = cx - CurrPosition.x;
g_Offset_Module.y = cy - CurrPosition.y; g_Offset_Module.y = cy - CurrPosition.y;
m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
/* tst des pastilles traversantes, qui pour un circuit imprime ayant des /* tst des pastilles traversantes, qui pour un circuit imprime ayant des
composants des 2 cotes, peuvent tomber sur un composant de cote oppose: * composants des 2 cotes, peuvent tomber sur un composant de cote oppose:
s'il y a au moins 1 pastille apparaissant sur l'autre cote, ce cote * s'il y a au moins 1 pastille apparaissant sur l'autre cote, ce cote
est teste */ * est teste */
TstOtherSide = FALSE; TstOtherSide = FALSE;
if( Nb_Sides == TWO_SIDES ) if( Nb_Sides == TWO_SIDES )
{ {
D_PAD * Pad; int masque_otherlayer; D_PAD* Pad; int masque_otherlayer;
masque_otherlayer = CUIVRE_LAYER; masque_otherlayer = CUIVRE_LAYER;
if ( Module->m_Layer == CUIVRE_N ) masque_otherlayer = CMP_LAYER; if( Module->m_Layer == CUIVRE_N )
masque_otherlayer = CMP_LAYER;
for(Pad = Module->m_Pads ; Pad != NULL; Pad = (D_PAD *) Pad->Pnext )
{ for( Pad = Module->m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext )
if( (Pad->m_Masque_Layer & masque_otherlayer) == 0 ) continue; {
TstOtherSide = TRUE; if( (Pad->m_Masque_Layer & masque_otherlayer) == 0 )
break; continue;
} TstOtherSide = TRUE;
} break;
}
}
DrawModuleOutlines(DrawPanel, DC, Module);
mincout = -1.0; DrawModuleOutlines( DrawPanel, DC, Module );
Affiche_Message(wxT("Score ??, pos ??") );
mincout = -1.0;
for ( ; CurrPosition.x < m_Pcb->m_BoundaryBox.GetRight() - fx; Affiche_Message( wxT( "Score ??, pos ??" ) );
CurrPosition.x += g_GridRoutingSize )
{ for( ; CurrPosition.x < m_Pcb->m_BoundaryBox.GetRight() - fx;
wxYield(); CurrPosition.x += g_GridRoutingSize )
if ( DrawPanel->m_AbortRequest ) {
{ wxYield();
if ( IsOK(this, _("Ok to abort ?")) ) return ESC; if( DrawPanel->m_AbortRequest )
else DrawPanel->m_AbortRequest = FALSE; {
} if( IsOK( this, _( "Ok to abort ?" ) ) )
return ESC;
cx = Module->m_Pos.x; cy = Module->m_Pos.y; else
Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x; DrawPanel->m_AbortRequest = FALSE;
Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y; }
DrawModuleOutlines(DrawPanel, DC, Module); cx = Module->m_Pos.x; cy = Module->m_Pos.y;
Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x;
g_Offset_Module.x = cx - CurrPosition.x; Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y;
CurrPosition.y = m_Pcb->m_BoundaryBox.m_Pos.y - oy;
/* remise sur la grille de placement: */ DrawModuleOutlines( DrawPanel, DC, Module );
CurrPosition.y -= CurrPosition.y % g_GridRoutingSize;
g_Offset_Module.x = cx - CurrPosition.x;
DrawModuleOutlines(DrawPanel, DC, Module); CurrPosition.y = m_Pcb->m_BoundaryBox.m_Pos.y - oy;
/* remise sur la grille de placement: */
for ( ; CurrPosition.y < m_Pcb->m_BoundaryBox.GetBottom() - fy; CurrPosition.y -= CurrPosition.y % g_GridRoutingSize;
CurrPosition.y += g_GridRoutingSize )
{ DrawModuleOutlines( DrawPanel, DC, Module );
/* effacement des traces */
DrawModuleOutlines(DrawPanel, DC, Module); for( ; CurrPosition.y < m_Pcb->m_BoundaryBox.GetBottom() - fy;
if (DisplayChevelu) Compute_Ratsnest_PlaceModule(DC); CurrPosition.y += g_GridRoutingSize )
DisplayChevelu = 0; {
Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x; /* effacement des traces */
Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y; DrawModuleOutlines( DrawPanel, DC, Module );
if( DisplayChevelu )
g_Offset_Module.y = cy - CurrPosition.y; Compute_Ratsnest_PlaceModule( DC );
DrawModuleOutlines(DrawPanel, DC, Module); DisplayChevelu = 0;
Penalite = TstModuleOnBoard(m_Pcb, Module, TstOtherSide ); Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x;
if( Penalite >= 0 ) /* c a d si le module peut etre place */ Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y;
{
error = 0; g_Offset_Module.y = cy - CurrPosition.y;
build_ratsnest_module(DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
cout = Compute_Ratsnest_PlaceModule(DC); Penalite = TstModuleOnBoard( m_Pcb, Module, TstOtherSide );
DisplayChevelu = 1; if( Penalite >= 0 ) /* c a d si le module peut etre place */
Score = cout + (float) Penalite; {
error = 0;
if( (mincout >= Score ) || (mincout < 0 ) ) build_ratsnest_module( DC, Module );
{ cout = Compute_Ratsnest_PlaceModule( DC );
LastPosOK = CurrPosition; DisplayChevelu = 1;
mincout = Score; Score = cout + (float) Penalite;
wxString msg;
msg.Printf( wxT("Score %d, pos %3.4f, %3.4f"), if( (mincout >= Score ) || (mincout < 0 ) )
(int)mincout, {
(float)LastPosOK.x /10000, (float)LastPosOK.y /10000); LastPosOK = CurrPosition;
Affiche_Message(msg); mincout = Score;
} wxString msg;
} msg.Printf( wxT( "Score %d, pos %3.4f, %3.4f" ),
if( DisplayChevelu ) Compute_Ratsnest_PlaceModule(DC); (int) mincout,
DisplayChevelu = 0; (float) LastPosOK.x / 10000, (float) LastPosOK.y / 10000 );
} Affiche_Message( msg );
} }
}
DrawModuleOutlines(DrawPanel, DC, Module); /* effacement du dernier trace */ if( DisplayChevelu )
if (DisplayChevelu) Compute_Ratsnest_PlaceModule(DC); Compute_Ratsnest_PlaceModule( DC );
DisplayChevelu = 0;
/* Regeneration des variables modifiees */ }
Module->m_RealBoundaryBox.m_Pos.x = ox + cx; }
Module->m_RealBoundaryBox.m_Pos.y = oy + cy;
CurrPosition = LastPosOK; DrawModuleOutlines( DrawPanel, DC, Module ); /* effacement du dernier trace */
if( DisplayChevelu )
m_Pcb->m_Status_Pcb &= ~(CHEVELU_LOCAL_OK | LISTE_PAD_OK ); Compute_Ratsnest_PlaceModule( DC );
MinCout = mincout; /* Regeneration des variables modifiees */
return(error); Module->m_RealBoundaryBox.m_Pos.x = ox + cx;
Module->m_RealBoundaryBox.m_Pos.y = oy + cy;
CurrPosition = LastPosOK;
m_Pcb->m_Status_Pcb &= ~(CHEVELU_LOCAL_OK | LISTE_PAD_OK );
MinCout = mincout;
return error;
} }
/**************************************************************************/ /**************************************************************************/
int TstRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, int side) int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
/**************************************************************************/ /**************************************************************************/
/* tst si la surface rectangulaire (ux,y0 .. ux,y1):
- est sur une zone libre ( retourne OCCUPED_By_MODULE sinon)
- est sur la surface utile du board ( retourne OUT_OF_BOARD sinon)
retourne 0 si OK /* tst si la surface rectangulaire (ux,y0 .. ux,y1):
*/ * - est sur une zone libre ( retourne OCCUPED_By_MODULE sinon)
* - est sur la surface utile du board ( retourne OUT_OF_BOARD sinon)
*
* retourne 0 si OK
*/
{ {
int row, col; int row, col;
int row_min, row_max, col_min, col_max; int row_min, row_max, col_min, col_max;
unsigned int data; unsigned int data;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
/* Calcul des coord limites des cellules appartenant au rectangle */ /* Calcul des coord limites des cellules appartenant au rectangle */
row_max = uy1 / g_GridRoutingSize; row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize; col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize )
col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; row_min++;
col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize )
if( row_min < 0 ) row_min = 0; col_min++;
if( row_max >= (Nrows-1)) row_max = Nrows-1;
if( col_min < 0 ) col_min = 0; if( row_min < 0 )
if( col_max >= (Ncols-1)) col_max = Ncols-1; row_min = 0;
if( row_max >= (Nrows - 1) )
for( row = row_min ;row <= row_max ; row++) row_max = Nrows - 1;
{ if( col_min < 0 )
for(col = col_min;col <= col_max; col++) col_min = 0;
{ if( col_max >= (Ncols - 1) )
data = GetCell(row,col,side); col_max = Ncols - 1;
if( (data & CELL_is_ZONE) == 0 ) /* Cellule non autorisee */
return(OUT_OF_BOARD); for( row = row_min; row <= row_max; row++ )
if( data & CELL_is_MODULE ) /* Deja utilisee */ {
return(OCCUPED_By_MODULE); for( col = col_min; col <= col_max; col++ )
} {
} data = GetCell( row, col, side );
return( 0 ); if( (data & CELL_is_ZONE) == 0 ) /* Cellule non autorisee */
return OUT_OF_BOARD;
if( data & CELL_is_MODULE ) /* Deja utilisee */
return OCCUPED_By_MODULE;
}
}
return 0;
} }
/******************************************************************************/ /******************************************************************************/
unsigned int CalculePenaliteRectangle(BOARD * Pcb, int ux0, int uy0, unsigned int CalculePenaliteRectangle( BOARD* Pcb, int ux0, int uy0,
int ux1, int uy1, int side) int ux1, int uy1, int side )
/******************************************************************************/ /******************************************************************************/
/* calcule et retourne la penalite de la surface rectangulaire (ux,y0 .. ux,y1): /* calcule et retourne la penalite de la surface rectangulaire (ux,y0 .. ux,y1):
( somme des valeurs des cellules du plan des Distances ) * ( somme des valeurs des cellules du plan des Distances )
*/ */
{ {
int row, col; int row, col;
int row_min, row_max, col_min, col_max; int row_min, row_max, col_min, col_max;
unsigned int Penalite; unsigned int Penalite;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y; ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
/* Calcul des coord limites des cellules appartenant au rectangle */ /* Calcul des coord limites des cellules appartenant au rectangle */
row_max = uy1 / g_GridRoutingSize; row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize; col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize )
col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; row_min++;
col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize )
if( row_min < 0 ) row_min = 0; col_min++;
if( row_max >= (Nrows-1)) row_max = Nrows-1;
if( col_min < 0 ) col_min = 0; if( row_min < 0 )
if( col_max >= (Ncols-1)) col_max = Ncols-1; row_min = 0;
if( row_max >= (Nrows - 1) )
Penalite = 0; row_max = Nrows - 1;
for( row = row_min ;row <= row_max ; row++) if( col_min < 0 )
{ col_min = 0;
for(col = col_min;col <= col_max; col++) if( col_max >= (Ncols - 1) )
{ col_max = Ncols - 1;
Penalite += (int) GetDist(row, col, side );
} Penalite = 0;
} for( row = row_min; row <= row_max; row++ )
return( Penalite ); {
for( col = col_min; col <= col_max; col++ )
{
Penalite += (int) GetDist( row, col, side );
}
}
return Penalite;
} }
/**********************************************************************/ /**********************************************************************/
int TstModuleOnBoard(BOARD * Pcb, MODULE * Module, bool TstOtherSide) int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
/**********************************************************************/ /**********************************************************************/
/* Teste si le module peut etre place sur le board. /* Teste si le module peut etre place sur le board.
retourne de diagnostic de TstRectangle(). * retourne de diagnostic de TstRectangle().
le module est connu par son rectangle d'encadrement * le module est connu par son rectangle d'encadrement
*/ */
{ {
int ox, oy, fx, fy; int ox, oy, fx, fy;
int error, Penalite, marge, side, otherside; int error, Penalite, marge, side, otherside;
side = TOP; otherside = BOTTOM; side = TOP; otherside = BOTTOM;
if ( Module->m_Layer == CUIVRE_N ) if( Module->m_Layer == CUIVRE_N )
{ {
side = BOTTOM; otherside = TOP; side = BOTTOM; otherside = TOP;
} }
ox = Module->m_RealBoundaryBox.m_Pos.x; ox = Module->m_RealBoundaryBox.m_Pos.x;
fx = Module->m_RealBoundaryBox.GetRight(); fx = Module->m_RealBoundaryBox.GetRight();
oy = Module->m_RealBoundaryBox.m_Pos.y; oy = Module->m_RealBoundaryBox.m_Pos.y;
fy = Module->m_RealBoundaryBox.GetBottom(); fy = Module->m_RealBoundaryBox.GetBottom();
error = TstRectangle(Pcb, ox, oy, fx, fy, side ); error = TstRectangle( Pcb, ox, oy, fx, fy, side );
if( error < 0 ) return (error); if( error < 0 )
return error;
if( TstOtherSide )
{ if( TstOtherSide )
error = TstRectangle(Pcb, ox, oy, fx, fy, otherside ); {
if( error < 0 ) return (error); error = TstRectangle( Pcb, ox, oy, fx, fy, otherside );
} if( error < 0 )
return error;
marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN; }
Penalite = CalculePenaliteRectangle(Pcb, ox - marge, oy - marge, marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN;
fx + marge, fy + marge, side );
return( Penalite ); Penalite = CalculePenaliteRectangle( Pcb, ox - marge, oy - marge,
fx + marge, fy + marge, side );
return Penalite;
} }
/************************************************************/ /************************************************************/
float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule(wxDC * DC) float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
/************************************************************/ /************************************************************/
/* Routine affichant le chevelu du module en cours de deplacement, et /* Routine affichant le chevelu du module en cours de deplacement, et
evaluant le "cout" de la position. * evaluant le "cout" de la position.
Le cout est la longueur des chevelus en distance de manhattan, avec * Le cout est la longueur des chevelus en distance de manhattan, avec
penalite pour les inclinaisons se rapprochant de 45 degre * penalite pour les inclinaisons se rapprochant de 45 degre
*/ */
{ {
CHEVELU* pt_local_chevelu ; CHEVELU* pt_local_chevelu;
int ii; int ii;
float cout, icout; float cout, icout;
int ox, oy, fx, fy, dx , dy; int ox, oy, fx, fy, dx, dy;
if((m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) == 0) if( (m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) == 0 )
return(-1); return -1;
pt_local_chevelu = local_liste_chevelu; pt_local_chevelu = local_liste_chevelu;
ii = nb_local_chevelu; cout = 0; ii = nb_local_chevelu; cout = 0;
while( ii-- > 0 ) while( ii-- > 0 )
{ {
if(pt_local_chevelu->status & LOCAL_CHEVELU) if( !(pt_local_chevelu->status & LOCAL_CHEVELU) )
{ // Non Affich {
} ox = pt_local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x;
else oy = pt_local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y;
{ fx = pt_local_chevelu->pad_end->m_Pos.x;
ox = pt_local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x; fy = pt_local_chevelu->pad_end->m_Pos.y;
oy = pt_local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y;
fx = pt_local_chevelu->pad_end->m_Pos.x; if( AutoPlaceShowAll )
fy = pt_local_chevelu->pad_end->m_Pos.y; {
GRLine( &DrawPanel->m_ClipBox, DC, ox, oy, fx, fy,
if ( AutoPlaceShowAll ) 0, g_DesignSettings.m_RatsnestColor | GR_XOR );
{ }
GRLine(&DrawPanel->m_ClipBox, DC, ox, oy, fx, fy,
0, g_DesignSettings.m_RatsnestColor|GR_XOR) ; /* Evaluation du cout du chevelu: */
} dx = fx - ox; dy = fy - oy;
dx = abs( dx ); dy = abs( dy );
/* Evaluation du cout du chevelu: */ if( dx < dy )
dx = fx - ox; dy = fy - oy; EXCHG( dx, dy );/* dx >= dy */
dx = abs(dx); dy = abs( dy ); /* cout de la distance: */
if( dx < dy ) EXCHG(dx,dy); /* dx >= dy */ icout = (float) dx * dx;
/* cout de la distance: */ /* cout de l'inclinaison */
icout = (float) dx * dx; icout += 3 * (float) dy * dy;
/* cout de l'inclinaison */ icout = sqrt( icout );
icout += 3 * (float) dy * dy; cout += icout; /* cout total = somme des couts de chaque chevelu */
icout = sqrt(icout); }
cout += icout; /* cout total = somme des couts de chaque chevelu */
} pt_local_chevelu++;
pt_local_chevelu++; }
}
return (cout); return cout;
} }
/********************************************/ /********************************************/
void Build_PlacedPads_List(BOARD * Pcb) void Build_PlacedPads_List( BOARD* Pcb )
/********************************************/ /********************************************/
/* /*
construction de la liste ( sous forme d'une liste de stucture ) * construction de la liste ( sous forme d'une liste de stucture )
des caract utiles des pads du PCB pour Placement Automatique ) * des caract utiles des pads du PCB pour Placement Automatique )
Cette liste est restreinte a la liste des pads des modules deja places sur * Cette liste est restreinte a la liste des pads des modules deja places sur
la carte. * la carte.
*
parametres: * parametres:
adresse du buffer de classement = Pcb->ptr_pads; * adresse du buffer de classement = Pcb->ptr_pads;
*
Variables globales mise a jour: * Variables globales mise a jour:
pointeur ptr_pads (adr de classement de la liste des pads) * pointeur ptr_pads (adr de classement de la liste des pads)
nb_pads = nombre utile de pastilles classes * nb_pads = nombre utile de pastilles classes
m_Status_Pcb |= LISTE_PAD_OK * m_Status_Pcb |= LISTE_PAD_OK
*/ */
{ {
LISTE_PAD* pt_liste_pad; LISTE_PAD* pt_liste_pad;
MODULE * Module; MODULE* Module;
D_PAD * PtPad; D_PAD* PtPad;
if( Pcb->m_Pads ) MyFree( Pcb->m_Pads ); if( Pcb->m_Pads )
MyFree( Pcb->m_Pads );
pt_liste_pad = Pcb->m_Pads = NULL;
Pcb->m_NbPads = Pcb->m_NbNodes = 0; pt_liste_pad = Pcb->m_Pads = NULL;
Pcb->m_NbPads = Pcb->m_NbNodes = 0;
/* Calcul du nombre de pads utiles */
Module = Pcb->m_Modules; /* Calcul du nombre de pads utiles */
for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) Module = Pcb->m_Modules;
{ for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; {
PtPad = (D_PAD*) Module->m_Pads; if( Module->m_ModuleStatus & MODULE_to_PLACE )
for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) continue;
{ PtPad = (D_PAD*) Module->m_Pads;
Pcb->m_NbPads++; for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext )
} {
} Pcb->m_NbPads++;
}
/* Allocation memoire du buffer */ }
if ( Pcb->m_NbPads > 0)
{ /* Allocation memoire du buffer */
pt_liste_pad = Pcb->m_Pads if( Pcb->m_NbPads > 0 )
= (D_PAD**) MyMalloc(Pcb->m_NbPads * sizeof(D_PAD*) ); {
} pt_liste_pad = Pcb->m_Pads
= (D_PAD**) MyMalloc( Pcb->m_NbPads * sizeof(D_PAD *) );
/* Initialisation du buffer et des variables de travail */ }
Module = Pcb->m_Modules;
for( ;(Module != NULL) && (pt_liste_pad != NULL); Module = (MODULE*) Module->Pnext) /* Initialisation du buffer et des variables de travail */
{ Module = Pcb->m_Modules;
if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; for( ; (Module != NULL) && (pt_liste_pad != NULL); Module = (MODULE*) Module->Pnext )
PtPad = (D_PAD*) Module->m_Pads; {
for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) if( Module->m_ModuleStatus & MODULE_to_PLACE )
{ continue;
*pt_liste_pad = PtPad; PtPad = (D_PAD*) Module->m_Pads;
PtPad->m_physical_connexion = 0; for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext )
PtPad->m_logical_connexion = 0; {
PtPad->m_Parent = Module; *pt_liste_pad = PtPad;
if(PtPad->m_NetCode) Pcb->m_NbNodes++; PtPad->m_physical_connexion = 0;
pt_liste_pad++; PtPad->m_logical_connexion = 0;
} PtPad->m_Parent = Module;
} if( PtPad->m_NetCode )
Pcb->m_NbNodes++;
Pcb->m_Status_Pcb |= LISTE_PAD_OK; pt_liste_pad++;
Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CHEVELU_LOCAL_OK); }
adr_lowmem = buf_work; }
Pcb->m_Status_Pcb |= LISTE_PAD_OK;
Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CHEVELU_LOCAL_OK);
adr_lowmem = buf_work;
} }
...@@ -926,233 +987,255 @@ D_PAD * PtPad; ...@@ -926,233 +987,255 @@ D_PAD * PtPad;
/*****************************************************************/ /*****************************************************************/
/* les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont /* les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont
incrementees de la valeur Penalite * incrementees de la valeur Penalite
celles qui sont externes au rectangle, mais internes au rectangle * celles qui sont externes au rectangle, mais internes au rectangle
x0,y0 -marge a x1,y1 + marge sont incrementees d'une valeur * x0,y0 -marge a x1,y1 + marge sont incrementees d'une valeur
(Penalite ... 0) decroissante en fonction de leur eloignement * (Penalite ... 0) decroissante en fonction de leur eloignement
*/ */
static void TracePenaliteRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1 , static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int marge, int Penalite, int masque_layer) int marge, int Penalite, int masque_layer )
{ {
int row, col; int row, col;
int row_min, row_max, col_min, col_max, pmarge; int row_min, row_max, col_min, col_max, pmarge;
int trace = 0; int trace = 0;
DistCell data, LocalPenalite; DistCell data, LocalPenalite;
int lgain, cgain; int lgain, cgain;
if(masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM]) if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] )
trace = 1; /* Trace sur BOTTOM */ trace = 1; /* Trace sur BOTTOM */
if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides) if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides )
trace |= 2; /* Trace sur TOP */ trace |= 2; /* Trace sur TOP */
if(trace == 0) return; if( trace == 0 )
return;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y; ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge; ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge;
pmarge = marge / g_GridRoutingSize; if (pmarge < 1 ) pmarge = 1;
pmarge = marge / g_GridRoutingSize; if( pmarge < 1 )
/* Calcul des coord limites des cellules appartenant au rectangle */ pmarge = 1;
row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize; /* Calcul des coord limites des cellules appartenant au rectangle */
row_min = uy0 / g_GridRoutingSize; if (uy0 > row_min*g_GridRoutingSize ) row_min++; row_max = uy1 / g_GridRoutingSize;
col_min = ux0 / g_GridRoutingSize; if (ux0 > col_min*g_GridRoutingSize ) col_min++; col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize )
if( row_min < 0 ) row_min = 0; row_min++;
if( row_max >= (Nrows-1)) row_max = Nrows-1; col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize )
if( col_min < 0 ) col_min = 0; col_min++;
if( col_max >= (Ncols-1)) col_max = Ncols-1;
if( row_min < 0 )
for( row = row_min ;row <= row_max ; row++) row_min = 0;
{ if( row_max >= (Nrows - 1) )
lgain = 256; row_max = Nrows - 1;
if ( row < pmarge ) if( col_min < 0 )
lgain = (256 * row) / pmarge; col_min = 0;
else if( row > row_max - pmarge ) if( col_max >= (Ncols - 1) )
lgain = (256 * (row_max - row) ) / pmarge; col_max = Ncols - 1;
for(col = col_min;col <= col_max; col++) for( row = row_min; row <= row_max; row++ )
{ {
cgain = 256; lgain = 256;
LocalPenalite = Penalite; if( row < pmarge )
if ( col < pmarge ) lgain = (256 * row) / pmarge;
cgain = (256 * col) / pmarge; else if( row > row_max - pmarge )
else if( col > col_max - pmarge ) lgain = ( 256 * (row_max - row) ) / pmarge;
cgain = (256 * (col_max - col) ) / pmarge;
for( col = col_min; col <= col_max; col++ )
cgain = (cgain * lgain) / 256; {
if( cgain != 256 ) LocalPenalite = (LocalPenalite * cgain) / 256; cgain = 256;
if(trace & 1) LocalPenalite = Penalite;
{ if( col < pmarge )
data = GetDist(row,col,BOTTOM) + LocalPenalite; cgain = (256 * col) / pmarge;
SetDist(row,col,BOTTOM, data); else if( col > col_max - pmarge )
} cgain = ( 256 * (col_max - col) ) / pmarge;
if(trace & 2)
{ cgain = (cgain * lgain) / 256;
data = GetDist(row,col,TOP); if( cgain != 256 )
data = max( data, LocalPenalite); LocalPenalite = (LocalPenalite * cgain) / 256;
SetDist(row,col,TOP, data); if( trace & 1 )
} {
} data = GetDist( row, col, BOTTOM ) + LocalPenalite;
} SetDist( row, col, BOTTOM, data );
}
if( trace & 2 )
{
data = GetDist( row, col, TOP );
data = max( data, LocalPenalite );
SetDist( row, col, TOP, data );
}
}
}
} }
/***************************************************/
/* Routines de tri de modules, utilisee par qsort: */
/***************************************************/
static int Tri_PlaceModules(MODULE ** pt_ref, MODULE ** pt_compare) /***************************************************/
/* Routines de tri de modules, utilisee par qsort: */
/***************************************************/
static int Tri_PlaceModules( MODULE** pt_ref, MODULE** pt_compare )
{ {
float ff, ff1, ff2 ; float ff, ff1, ff2;
ff1 = (*pt_ref)->m_Surface * (*pt_ref)->m_PadNum ; ff1 = (*pt_ref)->m_Surface * (*pt_ref)->m_PadNum;
ff2 = (*pt_compare)->m_Surface * (*pt_compare)->m_PadNum ; ff2 = (*pt_compare)->m_Surface * (*pt_compare)->m_PadNum;
ff = ff1 - ff2 ; ff = ff1 - ff2;
if( ff < 0 ) return(1) ; if( ff < 0 )
if( ff > 0 ) return(-1) ; return 1;
return( 0 ); if( ff > 0 )
return -1;
return 0;
} }
static int Tri_RatsModules(MODULE ** pt_ref, MODULE ** pt_compare)
static int Tri_RatsModules( MODULE** pt_ref, MODULE** pt_compare )
{ {
float ff, ff1, ff2 ; float ff, ff1, ff2;
ff1 = (*pt_ref)->m_Surface * (*pt_ref)->flag; ff1 = (*pt_ref)->m_Surface * (*pt_ref)->flag;
ff2 = (*pt_compare)->m_Surface * (*pt_compare)->flag; ff2 = (*pt_compare)->m_Surface * (*pt_compare)->flag;
ff = ff1 - ff2 ; ff = ff1 - ff2;
if( ff < 0 ) return(1) ; if( ff < 0 )
if( ff > 0 ) return(-1) ; return 1;
return( 0 ); if( ff > 0 )
return -1;
return 0;
} }
/***************************************************************/ /***************************************************************/
static MODULE * PickModule(WinEDA_PcbFrame * pcbframe, wxDC * DC) static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
/***************************************************************/ /***************************************************************/
/* Recherche le "meilleur" module a placer /* Recherche le "meilleur" module a placer
les criteres de choix sont: * les criteres de choix sont:
- maximum de chevelus avec les modules deja places * - maximum de chevelus avec les modules deja places
- taille max, et nombre de pads max * - taille max, et nombre de pads max
*/ */
{ {
MODULE ** BaseListeModules, ** pt_Dmod; MODULE** BaseListeModules, ** pt_Dmod;
MODULE * Module = NULL, * AltModule = NULL; MODULE* Module = NULL, * AltModule = NULL;
CHEVELU* pt_local_chevelu; CHEVELU* pt_local_chevelu;
int NbModules, ii; int NbModules, ii;
BaseListeModules = GenListeModules(pcbframe->m_Pcb, &NbModules ); BaseListeModules = GenListeModules( pcbframe->m_Pcb, &NbModules );
if( BaseListeModules == NULL ) return(NULL); if( BaseListeModules == NULL )
return NULL;
Build_PlacedPads_List(pcbframe->m_Pcb);
Build_PlacedPads_List( pcbframe->m_Pcb );
/* Tri par surface decroissante des modules
(on place les plus gros en 1er), surface ponderee par le nombre de pads */ /* Tri par surface decroissante des modules
* (on place les plus gros en 1er), surface ponderee par le nombre de pads */
qsort(BaseListeModules, NbModules, sizeof(MODULE**),
(int(*)(const void *, const void * ))Tri_PlaceModules); qsort( BaseListeModules, NbModules, sizeof(MODULE * *),
( int (*)( const void*, const void* ) )Tri_PlaceModules );
for(pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++)
{ for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
(*pt_Dmod)->flag = 0; {
if( ! ((*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE) ) continue; (*pt_Dmod)->flag = 0;
pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; if( !( (*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE ) )
adr_lowmem = buf_work; continue;
(*pt_Dmod)->Display_Infos(pcbframe); pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
pcbframe->build_ratsnest_module(DC, *pt_Dmod); adr_lowmem = buf_work;
(*pt_Dmod)->Display_Infos( pcbframe );
/* calcul du nombre de chevelus externes */ pcbframe->build_ratsnest_module( DC, *pt_Dmod );
pt_local_chevelu = local_liste_chevelu;
ii = nb_local_chevelu; /* calcul du nombre de chevelus externes */
while( ii-- > 0 ) pt_local_chevelu = local_liste_chevelu;
{ ii = nb_local_chevelu;
if( (pt_local_chevelu->status & LOCAL_CHEVELU) == 0 ) while( ii-- > 0 )
(*pt_Dmod)->flag++; {
pt_local_chevelu++; if( (pt_local_chevelu->status & LOCAL_CHEVELU) == 0 )
} (*pt_Dmod)->flag++;
} pt_local_chevelu++;
pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; }
}
qsort(BaseListeModules, NbModules, sizeof(MODULE**),
(int(*)(const void *, const void * ))Tri_RatsModules); pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
qsort( BaseListeModules, NbModules, sizeof(MODULE * *),
/* Recherche du "meilleur" module */ ( int (*)( const void*, const void* ) )Tri_RatsModules );
Module = NULL;
for(pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++)
{ /* Recherche du "meilleur" module */
if( ! ((*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE) ) continue; Module = NULL;
AltModule = *pt_Dmod; for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
if( (*pt_Dmod)->flag == 0 ) continue; {
Module = *pt_Dmod; break; if( !( (*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE ) )
} continue;
AltModule = *pt_Dmod;
MyFree(BaseListeModules); if( (*pt_Dmod)->flag == 0 )
if ( Module ) return(Module); continue;
else return(AltModule); Module = *pt_Dmod; break;
}
MyFree( BaseListeModules );
if( Module )
return Module;
else
return AltModule;
} }
/*******************************************************/ /*******************************************************/
bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly(void) bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly( void )
/*******************************************************/ /*******************************************************/
/* Determine le rectangle d'encadrement du pcb, selon les contours /* Determine le rectangle d'encadrement du pcb, selon les contours
(couche EDGE) uniquement * (couche EDGE) uniquement
Sortie: * Sortie:
m_Pcb->m_BoundaryBox mis a jour * m_Pcb->m_BoundaryBox mis a jour
Retourne FALSE si pas de contour * Retourne FALSE si pas de contour
*/ */
{ {
int rayon, cx, cy, d; int rayon, cx, cy, d;
int xmax, ymax; int xmax, ymax;
EDA_BaseStruct * PtStruct; EDA_BaseStruct* PtStruct;
DRAWSEGMENT* ptr; DRAWSEGMENT* ptr;
bool succes = FALSE; bool succes = FALSE;
if (m_Pcb == NULL) return FALSE; if( m_Pcb == NULL )
return FALSE;
m_Pcb->m_BoundaryBox.m_Pos.x = m_Pcb->m_BoundaryBox.m_Pos.y = 0x7FFFFFFFl ;
xmax = ymax = -0x7FFFFFFFl ; m_Pcb->m_BoundaryBox.m_Pos.x = m_Pcb->m_BoundaryBox.m_Pos.y = 0x7FFFFFFFl;
xmax = ymax = -0x7FFFFFFFl;
/* Analyse des Contours PCB */
PtStruct = m_Pcb->m_Drawings; /* Analyse des Contours PCB */
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) PtStruct = m_Pcb->m_Drawings;
{ for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; {
succes = TRUE; if( PtStruct->m_StructType != TYPEDRAWSEGMENT )
ptr = (DRAWSEGMENT*) PtStruct; continue;
d = (ptr->m_Width /2) + 1; succes = TRUE;
if(ptr->m_Shape == S_CIRCLE) ptr = (DRAWSEGMENT*) PtStruct;
{ d = (ptr->m_Width / 2) + 1;
cx = ptr->m_Start.x; cy = ptr->m_Start.y; if( ptr->m_Shape == S_CIRCLE )
rayon = (int)hypot((double)(ptr->m_End.x-cx),(double)(ptr->m_End.y-cy) ); {
rayon += d; cx = ptr->m_Start.x; cy = ptr->m_Start.y;
m_Pcb->m_BoundaryBox.m_Pos.x = min(m_Pcb->m_BoundaryBox.m_Pos.x,cx-rayon); rayon = (int) hypot( (double) (ptr->m_End.x - cx), (double) (ptr->m_End.y - cy) );
m_Pcb->m_BoundaryBox.m_Pos.y = min(m_Pcb->m_BoundaryBox.m_Pos.y,cy-rayon); rayon += d;
xmax = max(xmax,cx+rayon); m_Pcb->m_BoundaryBox.m_Pos.x = min( m_Pcb->m_BoundaryBox.m_Pos.x, cx - rayon );
ymax = max(ymax,cy+rayon); m_Pcb->m_BoundaryBox.m_Pos.y = min( m_Pcb->m_BoundaryBox.m_Pos.y, cy - rayon );
} xmax = max( xmax, cx + rayon );
else ymax = max( ymax, cy + rayon );
{ }
cx = min(ptr->m_Start.x, ptr->m_End.x ); else
cy = min(ptr->m_Start.y, ptr->m_End.y); {
m_Pcb->m_BoundaryBox.m_Pos.x = min(m_Pcb->m_BoundaryBox.m_Pos.x,cx - d); cx = min( ptr->m_Start.x, ptr->m_End.x );
m_Pcb->m_BoundaryBox.m_Pos.y = min(m_Pcb->m_BoundaryBox.m_Pos.y,cy - d); cy = min( ptr->m_Start.y, ptr->m_End.y );
cx = max(ptr->m_Start.x, ptr->m_End.x ); m_Pcb->m_BoundaryBox.m_Pos.x = min( m_Pcb->m_BoundaryBox.m_Pos.x, cx - d );
cy = max(ptr->m_Start.y, ptr->m_End.y); m_Pcb->m_BoundaryBox.m_Pos.y = min( m_Pcb->m_BoundaryBox.m_Pos.y, cy - d );
xmax = max(xmax,cx + d); cx = max( ptr->m_Start.x, ptr->m_End.x );
ymax = max(ymax,cy + d); cy = max( ptr->m_Start.y, ptr->m_End.y );
} xmax = max( xmax, cx + d );
} ymax = max( ymax, cy + d );
}
m_Pcb->m_BoundaryBox.SetWidth(xmax - m_Pcb->m_BoundaryBox.m_Pos.x); }
m_Pcb->m_BoundaryBox.SetHeight(ymax - m_Pcb->m_BoundaryBox.m_Pos.y);
return(succes); m_Pcb->m_BoundaryBox.SetWidth( xmax - m_Pcb->m_BoundaryBox.m_Pos.x );
m_Pcb->m_BoundaryBox.SetHeight( ymax - m_Pcb->m_BoundaryBox.m_Pos.y );
return succes;
} }
...@@ -332,9 +332,10 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -332,9 +332,10 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
public: public:
EDA_BaseStruct* found; EDA_BaseStruct* found;
int layer; int layer;
int layer_mask;
PadOrModule( int alayer ) : PadOrModule( int alayer ) :
found(0), layer(alayer) found(0), layer(alayer), layer_mask( g_TabOneLayerMask[alayer] )
{} {}
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData ) SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
...@@ -343,23 +344,33 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) ...@@ -343,23 +344,33 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
if( testItem->m_StructType == TYPEPAD ) if( testItem->m_StructType == TYPEPAD )
{ {
if( testItem->HitTest( refPos ) ) D_PAD* pad = (D_PAD*) testItem;
if( pad->HitTest( refPos ) )
{ {
found = testItem; if( layer_mask & pad->m_Masque_Layer )
return SEARCH_QUIT; {
found = testItem;
return SEARCH_QUIT;
}
else if( !found )
{
MODULE* parent = (MODULE*) pad->m_Parent;
if( IsModuleLayerVisible( parent->m_Layer ) )
found = testItem;
}
} }
} }
else if( testItem->m_StructType == TYPEMODULE ) else if( testItem->m_StructType == TYPEMODULE )
{ {
int mlayer = ((MODULE*)testItem)->m_Layer; MODULE* module = (MODULE*) testItem;
// consider only visible modules // consider only visible modules
if( IsModuleLayerVisible( mlayer ) ) if( IsModuleLayerVisible( module->m_Layer ) )
{ {
if( testItem->HitTest( refPos ) ) if( module->HitTest( refPos ) )
{ {
if( layer == mlayer ) if( layer == module->m_Layer )
{ {
found = testItem; found = testItem;
return SEARCH_QUIT; return SEARCH_QUIT;
......
...@@ -27,11 +27,13 @@ ...@@ -27,11 +27,13 @@
D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD ) D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD )
{ {
m_NumPadName = 0; m_NumPadName = 0;
m_Masque_Layer = CUIVRE_LAYER; m_Masque_Layer = CUIVRE_LAYER;
m_NetCode = 0; /* Numero de net pour comparaisons rapides */ m_NetCode = 0; /* Numero de net pour comparaisons rapides */
m_DrillShape = CIRCLE; // Drill shape = circle m_DrillShape = CIRCLE; // Drill shape = circle
m_Size.x = m_Size.y = 500; m_Size.x = m_Size.y = 500;
if( m_Parent && (m_Parent->m_StructType == TYPEMODULE) ) if( m_Parent && (m_Parent->m_StructType == TYPEMODULE) )
{ {
m_Pos = ( (MODULE*) m_Parent )->m_Pos; m_Pos = ( (MODULE*) m_Parent )->m_Pos;
...@@ -91,7 +93,8 @@ const wxPoint D_PAD::ReturnShapePos( void ) ...@@ -91,7 +93,8 @@ const wxPoint D_PAD::ReturnShapePos( void )
wxPoint shape_pos; wxPoint shape_pos;
int dX, dY; int dX, dY;
dX = m_Offset.x; dY = m_Offset.y; dX = m_Offset.x;
dY = m_Offset.y;
RotatePoint( &dX, &dY, m_Orient ); RotatePoint( &dX, &dY, m_Orient );
...@@ -458,12 +461,13 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int ...@@ -458,12 +461,13 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, 0, color, color ); GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, 0, color, color );
} }
}
break; break;
default: default:
break; break;
} }
}
/* Draw the pad hole */ /* Draw the pad hole */
int cx0 = m_Pos.x - offset.x; int cx0 = m_Pos.x - offset.x;
......
/******************************************************/ /******************************************************/
/* editeur de PCB PCBNEW */ /* editeur de PCB PCBNEW */
/* Fonctions de Nettoyage et reorganisation de Pistes */ /* Fonctions de Nettoyage et reorganisation de Pistes */
/******************************************************/ /******************************************************/
/* Fichier CLEAN.CPP */ /* Fichier CLEAN.CPP */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -15,21 +15,21 @@ ...@@ -15,21 +15,21 @@
#include "protos.h" #include "protos.h"
/* Constantes de controle de l'affichage des messages */ /* Constantes de controle de l'affichage des messages */
#define AFFICHE 1 #define AFFICHE 1
#define POS_AFF_PASSE 40 #define POS_AFF_PASSE 40
#define POS_AFF_VAR 50 #define POS_AFF_VAR 50
#define POS_AFF_MAX 60 #define POS_AFF_MAX 60
#define POS_AFF_NUMSEGM 70 #define POS_AFF_NUMSEGM 70
/* Routines locales : */ /* Routines locales : */
static int clean_segments(WinEDA_PcbFrame * frame, wxDC * DC); static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC );
static void suppression_piste_non_connectee(WinEDA_PcbFrame * frame, wxDC * DC); static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC );
static TRACK * AlignSegment(BOARD * Pcb, TRACK * pt_ref, TRACK * pt_segm, int extremite); static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extremite );
static void Clean_Pcb_Items(WinEDA_PcbFrame * frame, wxDC * DC ); static void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC );
/* Variables locales : */ /* Variables locales : */
static bool a_color; /* couleur du message */ static bool a_color; /* couleur du message */
static bool s_CleanVias = true; static bool s_CleanVias = true;
static bool s_MergeSegments = true; static bool s_MergeSegments = true;
static bool s_DeleteUnconnectedSegm = true; static bool s_DeleteUnconnectedSegm = true;
static bool s_ConnectToPads = false; static bool s_ConnectToPads = false;
...@@ -39,844 +39,916 @@ static bool s_ConnectToPads = false; ...@@ -39,844 +39,916 @@ static bool s_ConnectToPads = false;
#define CONN2PAD_ENBL #define CONN2PAD_ENBL
#ifdef CONN2PAD_ENBL #ifdef CONN2PAD_ENBL
static void ConnectDanglingEndToPad(WinEDA_PcbFrame * frame, wxDC * DC); static void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC );
static void Gen_Raccord_Track(WinEDA_PcbFrame * frame, wxDC * DC); static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC );
#endif #endif
/*****************************************/ /*****************************************/
void WinEDA_PcbFrame::Clean_Pcb(wxDC * DC) void WinEDA_PcbFrame::Clean_Pcb( wxDC* DC )
/*****************************************/ /*****************************************/
/* Regroupement des segments de meme piste. /* Regroupement des segments de meme piste.
Suppression des points inutiles * Suppression des points inutiles
- via sur pad * - via sur pad
- points de couche et coord identiques * - points de couche et coord identiques
- points alignes (supp du pt milieu) * - points alignes (supp du pt milieu)
*/ */
{ {
s_ConnectToPads = false; s_ConnectToPads = false;
WinEDA_CleaningOptionsFrame * frame = new WinEDA_CleaningOptionsFrame( this, DC ); WinEDA_CleaningOptionsFrame* frame = new WinEDA_CleaningOptionsFrame( this, DC );
frame->ShowModal(); frame->Destroy(); frame->ShowModal(); frame->Destroy();
DrawPanel->Refresh(true); DrawPanel->Refresh( true );
} }
/************************************************************/ /************************************************************/
void Clean_Pcb_Items(WinEDA_PcbFrame * frame, wxDC * DC ) void Clean_Pcb_Items( WinEDA_PcbFrame* frame, wxDC* DC )
/************************************************************/ /************************************************************/
{ {
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
frame->m_Pcb->GetNumSegmTrack(); /* Met a jour le compte */ frame->m_Pcb->GetNumSegmTrack(); /* Met a jour le compte */
/* construction de la liste des coordonnes des pastilles */ /* construction de la liste des coordonn�s des pastilles */
frame->m_Pcb->m_Status_Pcb = 0; frame->m_Pcb->m_Status_Pcb = 0;
frame->build_liste_pads(); frame->build_liste_pads();
frame->recalcule_pad_net_code(); frame->recalcule_pad_net_code();
if ( s_CleanVias ) /* delete redundant vias */ if( s_CleanVias ) /* delete redundant vias */
{ {
TRACK *track, *next_track; TRACK* track, * next_track;
for( track = frame->m_Pcb->m_Track; track != NULL; track = track->Next()) for( track = frame->m_Pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( track->m_Shape != VIA_NORMALE ) continue; if( track->m_Shape != VIA_NORMALE )
/* Search and delete others vias at same location */ continue;
TRACK * alt_track = track->Next(); /* Search and delete others vias at same location */
for( ; alt_track != NULL; alt_track = next_track ) TRACK* alt_track = track->Next();
{ for( ; alt_track != NULL; alt_track = next_track )
next_track = alt_track->Next(); {
if( alt_track->m_Shape != VIA_NORMALE ) continue; next_track = alt_track->Next();
if ( alt_track->m_Start != track->m_Start ) continue; if( alt_track->m_Shape != VIA_NORMALE )
/* delete via */ continue;
alt_track->UnLink(); if( alt_track->m_Start != track->m_Start )
delete alt_track; continue;
} /* delete via */
} alt_track->UnLink();
/* Delete Via on pads at same location */ delete alt_track;
for( track = frame->m_Pcb->m_Track; track != NULL; track = next_track) }
{ }
next_track = track->Next();
if( track->m_Shape != VIA_NORMALE ) continue; /* Delete Via on pads at same location */
D_PAD * pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, track->m_Start, ALL_CU_LAYERS); for( track = frame->m_Pcb->m_Track; track != NULL; track = next_track )
if (pad && (pad->m_Masque_Layer&EXTERNAL_LAYERS) == EXTERNAL_LAYERS) // redundant Via {
{ next_track = track->Next();
/* delete via */ if( track->m_Shape != VIA_NORMALE )
track->UnLink(); continue;
delete track;
} D_PAD* pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, track->m_Start, ALL_CU_LAYERS );
} if( pad && (pad->m_Masque_Layer & EXTERNAL_LAYERS) == EXTERNAL_LAYERS ) // redundant Via
} {
/* delete via */
track->UnLink();
delete track;
}
}
}
#ifdef CONN2PAD_ENBL #ifdef CONN2PAD_ENBL
if( s_ConnectToPads ) /* Creation de points de connexion */ if( s_ConnectToPads ) /* Creation de points de connexion */
{ {
/* Raccordement des extremites de piste au centre des pastilles : */ /* Raccordement des extremites de piste au centre des pastilles : */
ConnectDanglingEndToPad(frame, DC); ConnectDanglingEndToPad( frame, DC );
/* Creation de points de raccordements aux intersections de pistes */
/* Creation de points de raccordements aux intersections de pistes */
// Gen_Raccord_Track(frame, DC); // Gen_Raccord_Track(frame, DC);
} }
#endif #endif
/* suppression des segments de longueur nulle et des points intermediaires /* suppression des segments de longueur nulle et des points intermediaires
alignes */ * alignes */
if ( s_MergeSegments ) clean_segments(frame, DC); if( s_MergeSegments )
clean_segments( frame, DC );
/* suppression des pistes non connectees ( c.a.d dont 1 extremite est en l'air) */ /* suppression des pistes non connectees ( c.a.d dont 1 extremite est en l'air) */
if ( s_DeleteUnconnectedSegm ) suppression_piste_non_connectee(frame, DC); if( s_DeleteUnconnectedSegm )
suppression_piste_non_connectee( frame, DC );
frame->Compile_Ratsnest(DC, AFFICHE); frame->Compile_Ratsnest( DC, AFFICHE );
frame->m_CurrentScreen->SetModify(); frame->m_CurrentScreen->SetModify();
} }
/*****************************************************************************/ /*****************************************************************************/
static void suppression_piste_non_connectee(WinEDA_PcbFrame * frame, wxDC * DC) static void suppression_piste_non_connectee( WinEDA_PcbFrame* frame, wxDC* DC )
/*****************************************************************************/ /*****************************************************************************/
/* /*
Supprime les segments de piste ayant 1 ou 2 extremites non connectees * Supprime les segments de piste ayant 1 ou 2 extremites non connectees
Cas des vias: * Cas des vias:
si une extremite de segment est connectee uniquement a une via, la via * si une extremite de segment est connectee uniquement a une via, la via
et le segment seront supprimes * et le segment seront supprimes
*/ */
{ {
TRACK * PtSegm, * pt_other, * pt_via; TRACK* PtSegm, * pt_other, * pt_via;
TRACK * PtStartNetCode; TRACK* PtStartNetCode;
EDA_BaseStruct * NextS; EDA_BaseStruct* NextS;
D_PAD * ptr_pad; D_PAD* ptr_pad;
int nbpoints_supprimes = 0; int nbpoints_supprimes = 0;
int masklayer, oldnetcode; int masklayer, oldnetcode;
int type_end,flag_erase; int type_end, flag_erase;
int ii, percent, oldpercent; int ii, percent, oldpercent;
wxString msg; wxString msg;
frame->Affiche_Message( _("Delete unconnected tracks:") ); frame->Affiche_Message( _( "Delete unconnected tracks:" ) );
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
/* Correction des defauts des vias et recalcul du nombre de segm */ /* Correction des defauts des vias et recalcul du nombre de segm */
frame->m_Pcb->m_NbSegmTrack = 0; ii = 0; frame->m_Pcb->m_NbSegmTrack = 0; ii = 0;
for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)NextS) for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS )
{ {
frame->m_Pcb->m_NbSegmTrack++; frame->m_Pcb->m_NbSegmTrack++;
NextS = PtSegm->Pnext; NextS = PtSegm->Pnext;
if(PtSegm->m_StructType == TYPEVIA) if( PtSegm->m_StructType == TYPEVIA )
{ {
if( (PtSegm->m_Start.x != PtSegm->m_End.x ) || (PtSegm->m_Start.y != PtSegm->m_End.y ) ) if( (PtSegm->m_Start.x != PtSegm->m_End.x )
{ || (PtSegm->m_Start.y != PtSegm->m_End.y ) )
PtSegm->m_End.x = PtSegm->m_Start.x; {
PtSegm->m_End.y = PtSegm->m_Start.y; PtSegm->m_End.x = PtSegm->m_Start.x;
ii++; PtSegm->m_End.y = PtSegm->m_Start.y;
msg.Printf( wxT("%d "), ii); ii++;
Affiche_1_Parametre(frame, POS_AFF_PASSE,_("ViaDef"),msg,LIGHTRED); msg.Printf( wxT( "%d " ), ii );
} Affiche_1_Parametre( frame, POS_AFF_PASSE, _( "ViaDef" ), msg, LIGHTRED );
continue; }
} continue;
} }
}
/* Suppression des pistes en l'air */
PtSegm = frame->m_Pcb->m_Track; ii = 0; /* Suppression des pistes en l'air */
percent = 0; oldpercent = -1; PtSegm = frame->m_Pcb->m_Track; ii = 0;
oldnetcode = 0; PtStartNetCode = frame->m_Pcb->m_Track; percent = 0; oldpercent = -1;
for( ; PtSegm != NULL; PtSegm = (TRACK*) NextS, ii++) oldnetcode = 0; PtStartNetCode = frame->m_Pcb->m_Track;
{ for( ; PtSegm != NULL; PtSegm = (TRACK*) NextS, ii++ )
NextS = PtSegm->Pnext; {
/* Affiche activite */ NextS = PtSegm->Pnext;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; /* Affiche activite */
if( percent != oldpercent) percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
{ if( percent != oldpercent )
oldpercent = percent; {
frame->DisplayActivity(percent, wxT("No Conn: ") ); oldpercent = percent;
frame->DisplayActivity( percent, wxT( "No Conn: " ) );
msg.Printf( wxT("%d "), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre(frame,POS_AFF_MAX, wxT("Max"), msg,GREEN); msg.Printf( wxT( "%d " ), frame->m_Pcb->m_NbSegmTrack );
msg.Printf( wxT("%d "),ii ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); msg.Printf( wxT( "%d " ), ii );
} Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
}
if( frame->DrawPanel->m_AbortRequest ) break;
if( frame->DrawPanel->m_AbortRequest )
if( PtSegm->m_NetCode != oldnetcode) break;
{
PtStartNetCode = PtSegm; oldnetcode = PtSegm->m_NetCode; if( PtSegm->m_NetCode != oldnetcode )
} {
PtStartNetCode = PtSegm; oldnetcode = PtSegm->m_NetCode;
flag_erase = 0; type_end = 0; }
/* y a t-il une pastille sur chaque extremite */
flag_erase = 0; type_end = 0;
masklayer = PtSegm->ReturnMaskLayer(); /* y a t-il une pastille sur chaque extremite */
ptr_pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, PtSegm->m_Start, masklayer); masklayer = PtSegm->ReturnMaskLayer();
if( ptr_pad != NULL) ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, PtSegm->m_Start, masklayer );
{
PtSegm->start = ptr_pad; if( ptr_pad != NULL )
type_end |= START_SUR_PAD; {
} PtSegm->start = ptr_pad;
type_end |= START_SUR_PAD;
ptr_pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, PtSegm->m_End, masklayer); }
if( ptr_pad != NULL) ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, PtSegm->m_End, masklayer );
{
PtSegm->end = ptr_pad; if( ptr_pad != NULL )
type_end |= END_SUR_PAD; {
} PtSegm->end = ptr_pad;
type_end |= END_SUR_PAD;
/* Test si une extremite est connectee sur une piste */ }
if ( (type_end & START_SUR_PAD ) == 0 )
{ /* Test si une extremite est connectee sur une piste */
pt_other = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, if( (type_end & START_SUR_PAD ) == 0 )
NULL, START); {
pt_other = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
if(pt_other == NULL) flag_erase |= 1; NULL, START );
else /* Segment ou via connectee a cette extremite */ if( pt_other == NULL )
{ flag_erase |= 1;
PtSegm->start = pt_other;
if(pt_other->m_StructType == TYPEVIA) /* recherche d'un autre segment */ else /* Segment ou via connectee a cette extremite */
{ {
PtSegm->SetState(BUSY,ON); PtSegm->start = pt_other;
pt_via = pt_other; if( pt_other->m_StructType == TYPEVIA ) /* recherche d'un autre segment */
pt_other = Locate_Piste_Connectee(pt_via,frame->m_Pcb->m_Track, {
NULL,START); PtSegm->SetState( BUSY, ON );
if(pt_other == NULL) flag_erase |= 2; pt_via = pt_other;
PtSegm->SetState(BUSY,OFF); pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track,
} NULL, START );
} if( pt_other == NULL )
} flag_erase |= 2;
PtSegm->SetState( BUSY, OFF );
if ( (type_end & END_SUR_PAD ) == 0 ) }
{ }
pt_other = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, }
NULL, END);
if(pt_other == NULL) flag_erase |= 0x10; if( (type_end & END_SUR_PAD ) == 0 )
else /* Segment ou via connectee a cette extremite */ {
{ pt_other = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
PtSegm->end = pt_other; NULL, END );
if(pt_other->m_StructType == TYPEVIA) /* recherche d'un autre segment */ if( pt_other == NULL )
{ flag_erase |= 0x10;
PtSegm->SetState(BUSY,ON); else /* Segment ou via connectee a cette extremite */
pt_via = pt_other; {
PtSegm->end = pt_other;
pt_other = Locate_Piste_Connectee(pt_via,frame->m_Pcb->m_Track, if( pt_other->m_StructType == TYPEVIA ) /* recherche d'un autre segment */
NULL, END); {
if(pt_other == NULL) flag_erase |= 0x20; PtSegm->SetState( BUSY, ON );
PtSegm->SetState(BUSY,OFF); pt_via = pt_other;
}
} pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track,
} NULL, END );
if( pt_other == NULL )
if(flag_erase) flag_erase |= 0x20;
{ PtSegm->SetState( BUSY, OFF );
oldpercent = -1; /* force affichage activite */ }
nbpoints_supprimes++; ii--; }
msg.Printf( wxT("%d "),nbpoints_supprimes); }
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("NoConn."), msg,LIGHTRED);
if( flag_erase )
/* rectification du pointeur PtSegm pour repartir en debut {
du block des segments de meme net_code */ oldpercent = -1; /* force affichage activite */
if( PtSegm == PtStartNetCode ) nbpoints_supprimes++; ii--;
{ msg.Printf( wxT( "%d " ), nbpoints_supprimes );
NextS = PtSegm->Pnext; Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "NoConn." ), msg, LIGHTRED );
PtStartNetCode = (TRACK*)NextS;
} /* rectification du pointeur PtSegm pour repartir en debut
else NextS = PtStartNetCode; * du block des segments de meme net_code */
if( PtSegm == PtStartNetCode )
/* Suppression du segment */ {
PtSegm->Draw(frame->DrawPanel, DC, GR_XOR); NextS = PtSegm->Pnext;
DeleteStructure(PtSegm); PtStartNetCode = (TRACK*) NextS;
if ( NextS == NULL ) break; }
} else
} NextS = PtStartNetCode;
/* Suppression du segment */
PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
DeleteStructure( PtSegm );
if( NextS == NULL )
break;
}
}
} }
/************************************************************/ /************************************************************/
static int clean_segments(WinEDA_PcbFrame * frame, wxDC * DC) static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
/************************************************************/ /************************************************************/
/* Supprime segments nulls, points inutiles .. */ /* Supprime segments nulls, points inutiles .. */
{ {
TRACK * PtSegm, * pt_aux; TRACK* PtSegm, * pt_aux;
EDA_BaseStruct * NextS; EDA_BaseStruct* NextS;
int ii, nbpoints_supprimes = 0; int ii, nbpoints_supprimes = 0;
int flag, no_inc, percent, oldpercent; int flag, no_inc, percent, oldpercent;
wxString msg; wxString msg;
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
/**********************************************/ /**********************************************/
/* suppression des segments de longueur nulle */ /* suppression des segments de longueur nulle */
/**********************************************/ /**********************************************/
a_color = GREEN; a_color = GREEN;
nbpoints_supprimes = 0; PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0; PtSegm = frame->m_Pcb->m_Track;
percent = 0; oldpercent = -1; percent = 0; oldpercent = -1;
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
frame->Affiche_Message( _("Clean Null Segments") ); frame->Affiche_Message( _( "Clean Null Segments" ) );
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("NullSeg"), wxT("0"),a_color); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "NullSeg" ), wxT( "0" ), a_color );
for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)NextS ) for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS )
{ {
NextS = PtSegm->Pnext; NextS = PtSegm->Pnext;
if( ! PtSegm->IsNull() ) continue; if( !PtSegm->IsNull() )
continue;
/* Lenght segment = 0; delete it */
PtSegm->Draw(frame->DrawPanel, DC, GR_XOR); /* Lenght segment = 0; delete it */
DeleteStructure(PtSegm); PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
nbpoints_supprimes++; DeleteStructure( PtSegm );
nbpoints_supprimes++;
msg.Printf( wxT(" %d"),nbpoints_supprimes);
Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString, msg,a_color); msg.Printf( wxT( " %d" ), nbpoints_supprimes );
} Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
}
/**************************************/
/* suppression des segments confondus */ /**************************************/
/**************************************/ /* suppression des segments confondus */
/**************************************/
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("Ident"), wxT("0"),a_color);
percent = 0; oldpercent = -1; Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "Ident" ), wxT( "0" ), a_color );
PtSegm = frame->m_Pcb->m_Track; percent = 0; oldpercent = -1;
for( ii = 0; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext , ii++) PtSegm = frame->m_Pcb->m_Track;
{ for( ii = 0; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext, ii++ )
/* affichage activite */ {
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; /* affichage activite */
if( percent != oldpercent) percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
{ if( percent != oldpercent )
frame->DisplayActivity(percent, wxT("Id segm: ") ); {
oldpercent = percent; frame->DisplayActivity( percent, wxT( "Id segm: " ) );
oldpercent = percent;
msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack);
Affiche_1_Parametre(frame,POS_AFF_MAX, wxT("Max"), msg,GREEN); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
msg.Printf( wxT("%d"), ii ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
if( frame->DrawPanel->m_AbortRequest ) return(-1);
} if( frame->DrawPanel->m_AbortRequest )
return -1;
for( pt_aux = (TRACK*)PtSegm->Pnext; pt_aux != NULL; pt_aux = (TRACK*)NextS ) }
{
int erase = 0; for( pt_aux = (TRACK*) PtSegm->Pnext; pt_aux != NULL; pt_aux = (TRACK*) NextS )
NextS = pt_aux->Pnext; {
int erase = 0;
if( PtSegm->m_StructType != pt_aux->m_StructType ) continue; NextS = pt_aux->Pnext;
if( PtSegm->m_Layer != pt_aux->m_Layer ) continue;
if( PtSegm->m_NetCode != pt_aux->m_NetCode ) break; if( PtSegm->m_StructType != pt_aux->m_StructType )
continue;
if( (PtSegm->m_Start.x == pt_aux->m_Start.x ) && (PtSegm->m_Start.y == pt_aux->m_Start.y) ) if( PtSegm->m_Layer != pt_aux->m_Layer )
{ continue;
if( (PtSegm->m_End.x == pt_aux->m_End.x ) && (PtSegm->m_End.y==pt_aux->m_End.y) ) if( PtSegm->m_NetCode != pt_aux->m_NetCode )
erase = 1; break;
}
if( (PtSegm->m_Start.x == pt_aux->m_Start.x )
if( (PtSegm->m_Start.x==pt_aux->m_End.x ) && (PtSegm->m_Start.y == pt_aux->m_End.y) ) && (PtSegm->m_Start.y == pt_aux->m_Start.y) )
{ {
if( (PtSegm->m_End.x==pt_aux->m_Start.x ) && (PtSegm->m_End.y==pt_aux->m_Start.y) ) if( (PtSegm->m_End.x == pt_aux->m_End.x ) && (PtSegm->m_End.y==pt_aux->m_End.y) )
erase = 1; erase = 1;
} }
/* suppression du point en trop */ if( (PtSegm->m_Start.x==pt_aux->m_End.x ) && (PtSegm->m_Start.y == pt_aux->m_End.y) )
if( erase ) {
{ if( (PtSegm->m_End.x==pt_aux->m_Start.x ) && (PtSegm->m_End.y==pt_aux->m_Start.y) )
ii--; erase = 1;
pt_aux->Draw(frame->DrawPanel, DC, GR_OR); }
DeleteStructure(pt_aux);
nbpoints_supprimes++; /* suppression du point en trop */
if( erase )
msg.Printf( wxT(" %d"),nbpoints_supprimes); {
Affiche_1_Parametre(frame,50, wxEmptyString, msg,a_color); ii--;
} pt_aux->Draw( frame->DrawPanel, DC, GR_OR );
} DeleteStructure( pt_aux );
} nbpoints_supprimes++;
/**************************************************************/ msg.Printf( wxT( " %d" ), nbpoints_supprimes );
/* suppression des points intermediaires ( segments alignes ) */ Affiche_1_Parametre( frame, 50, wxEmptyString, msg, a_color );
/**************************************************************/ }
}
PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0; }
percent = 0; oldpercent = -1;
frame->Affiche_Message( _("Merging Segments:") ); /**************************************************************/
/* suppression des points intermediaires ( segments alignes ) */
Affiche_1_Parametre(frame,POS_AFF_VAR, _("Merge"), _("0"),a_color); /**************************************************************/
ii = 0; PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0;
for( PtSegm = frame->m_Pcb->m_Track; PtSegm!= NULL; PtSegm = (TRACK*) NextS) percent = 0; oldpercent = -1;
{ frame->Affiche_Message( _( "Merging Segments:" ) );
TRACK * pt_segm_s, * pt_segm_e, *pt_segm_delete;
Affiche_1_Parametre( frame, POS_AFF_VAR, _( "Merge" ), _( "0" ), a_color );
NextS = PtSegm->Pnext;
/* affichage activite */ ii = 0;
ii++; for( PtSegm = frame->m_Pcb->m_Track; PtSegm!= NULL; PtSegm = (TRACK*) NextS )
percent = (100 * ii)/ frame->m_Pcb->m_NbSegmTrack; {
if( percent != oldpercent) TRACK* pt_segm_s, * pt_segm_e, * pt_segm_delete;
{
frame->DisplayActivity(percent, _("Merge: ") ); NextS = PtSegm->Pnext;
oldpercent = percent; /* affichage activite */
msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack); ii++;
Affiche_1_Parametre(frame, POS_AFF_MAX, wxT("Max"), msg,GREEN); percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
msg.Printf( wxT("%d"), ii ); if( percent != oldpercent )
Affiche_1_Parametre(frame, POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); {
frame->DisplayActivity( percent, _( "Merge: " ) );
if( frame->DrawPanel->m_AbortRequest ) return(-1); oldpercent = percent;
} msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
if(PtSegm->m_StructType != TYPETRACK) continue; msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
flag = no_inc = 0;
if( frame->DrawPanel->m_AbortRequest )
/* Recherche d'un point possible raccorde sur DEBUT de segment: */ return -1;
for( pt_segm_s = (TRACK*)PtSegm->Pnext; ; ) }
{
pt_segm_s = Locate_Piste_Connectee(PtSegm, pt_segm_s, if( PtSegm->m_StructType != TYPETRACK )
NULL, START); continue;
if(pt_segm_s)
{ flag = no_inc = 0;
/* les 2 segments doivent avoir meme largeur */
if(PtSegm->m_Width != pt_segm_s->m_Width ) break; /* Recherche d'un point possible raccorde sur DEBUT de segment: */
/* Ce ne peut etre une via */ for( pt_segm_s = (TRACK*) PtSegm->Pnext; ; )
if(pt_segm_s->m_StructType != TYPETRACK) break; {
pt_segm_s = Locate_Piste_Connectee( PtSegm, pt_segm_s,
/* On ne peut avoir que 1 seul segment connecte */ NULL, START );
pt_segm_s->SetState(BUSY,ON); if( pt_segm_s )
pt_aux = Locate_Piste_Connectee(PtSegm, frame->m_Pcb->m_Track, {
NULL,START); /* les 2 segments doivent avoir meme largeur */
pt_segm_s->SetState(BUSY,OFF); if( PtSegm->m_Width != pt_segm_s->m_Width )
break;
if(pt_aux == NULL) flag = 1; /* OK */
break; /* Ce ne peut etre une via */
} if( pt_segm_s->m_StructType != TYPETRACK )
break; break;
}
/* On ne peut avoir que 1 seul segment connecte */
if(flag) /* debut de segment raccorde a un autre segment */ pt_segm_s->SetState( BUSY, ON );
{ pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
pt_segm_delete = AlignSegment(frame->m_Pcb, PtSegm,pt_segm_s,START); NULL, START );
if ( pt_segm_delete ) pt_segm_s->SetState( BUSY, OFF );
{
nbpoints_supprimes++; no_inc = 1; if( pt_aux == NULL )
DeleteStructure(pt_segm_delete); flag = 1;/* OK */
} break;
} }
break;
/* Recherche d'un point possible raccorde sur FIN de segment: */ }
for( pt_segm_e = (TRACK*)PtSegm->Pnext; ; )
{ if( flag ) /* debut de segment raccorde a un autre segment */
pt_segm_e = Locate_Piste_Connectee(PtSegm, pt_segm_e, {
NULL, END); pt_segm_delete = AlignSegment( frame->m_Pcb, PtSegm, pt_segm_s, START );
if(pt_segm_e) if( pt_segm_delete )
{ {
/* les 2 segments doivent avoir meme largeur */ nbpoints_supprimes++; no_inc = 1;
if(PtSegm->m_Width != pt_segm_e->m_Width ) break; DeleteStructure( pt_segm_delete );
/* Ce ne peut etre une via */ }
if(pt_segm_e->m_StructType != TYPETRACK) break; }
/* On ne peut avoir que 1 seul segment connecte */ /* Recherche d'un point possible raccorde sur FIN de segment: */
pt_segm_e->SetState(BUSY,ON); for( pt_segm_e = (TRACK*) PtSegm->Pnext; ; )
pt_aux = Locate_Piste_Connectee(PtSegm, frame->m_Pcb->m_Track, {
NULL,END) ; pt_segm_e = Locate_Piste_Connectee( PtSegm, pt_segm_e,
pt_segm_e->SetState(BUSY,OFF); NULL, END );
if (pt_aux == NULL) flag |= 2;/* Ok */ if( pt_segm_e )
break; {
} /* les 2 segments doivent avoir meme largeur */
else break; if( PtSegm->m_Width != pt_segm_e->m_Width )
} break;
/* Ce ne peut etre une via */
if(flag & 2) /* FIN de segment raccorde a un autre segment */ if( pt_segm_e->m_StructType != TYPETRACK )
{ break;
pt_segm_delete = AlignSegment(frame->m_Pcb, PtSegm,pt_segm_e,END);
if ( pt_segm_delete ) /* On ne peut avoir que 1 seul segment connecte */
{ pt_segm_e->SetState( BUSY, ON );
nbpoints_supprimes++; no_inc = 1; pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
DeleteStructure(pt_segm_delete); NULL, END );
} pt_segm_e->SetState( BUSY, OFF );
} if( pt_aux == NULL )
flag |= 2;/* Ok */
if(no_inc) /* Le segment en cours a ete modifie, il faut le reexaminer */ break;
{ }
msg.Printf( wxT("%d "),nbpoints_supprimes); else
Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString, msg,a_color); break;
NextS = PtSegm->Pnext; }
}
} if( flag & 2 ) /* FIN de segment raccorde a un autre segment */
return (0) ; {
pt_segm_delete = AlignSegment( frame->m_Pcb, PtSegm, pt_segm_e, END );
if( pt_segm_delete )
{
nbpoints_supprimes++; no_inc = 1;
DeleteStructure( pt_segm_delete );
}
}
if( no_inc ) /* Le segment en cours a ete modifie, il faut le reexaminer */
{
msg.Printf( wxT( "%d " ), nbpoints_supprimes );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
NextS = PtSegm->Pnext;
}
}
return 0;
} }
/****************************************************************************/ /****************************************************************************/
static TRACK * AlignSegment(BOARD * Pcb, TRACK * pt_ref, TRACK * pt_segm, int extremite) static TRACK* AlignSegment( BOARD* Pcb, TRACK* pt_ref, TRACK* pt_segm, int extremite )
/****************************************************************************/ /****************************************************************************/
/* Routine utilisee par clean_segments. /* Routine utilisee par clean_segments.
Verifie l'alignement de pt_segm / pt_ref. et verifie que le point commun * Verifie l'alignement de pt_segm / pt_ref. et verifie que le point commun
a faire disparaitre n'est pas sur un pad. * a faire disparaitre n'est pas sur un pad.
l'extremite testee est debut (extremite == START) ou fin (extremite == FIN) * l'extremite testee est debut (extremite == START) ou fin (extremite == FIN)
si il y a alignement, modifie les coord d'extremite de pt_ref et retourne * si il y a alignement, modifie les coord d'extremite de pt_ref et retourne
pt_segm. * pt_segm.
sinon retourne NULL * sinon retourne NULL
*/ */
{ {
int refdx,refdy, segmdx, segmdy; /* projections des segments */ int refdx, refdy, segmdx, segmdy;/* projections des segments */
int flag = 0; int flag = 0;
refdx = pt_ref->m_End.x - pt_ref->m_Start.x; refdy = pt_ref->m_End.y - pt_ref->m_Start.y; refdx = pt_ref->m_End.x - pt_ref->m_Start.x; refdy = pt_ref->m_End.y - pt_ref->m_Start.y;
segmdx = pt_segm->m_End.x - pt_segm->m_Start.x; segmdy = pt_segm->m_End.y - pt_segm->m_Start.y; segmdx = pt_segm->m_End.x - pt_segm->m_Start.x; segmdy = pt_segm->m_End.y - pt_segm->m_Start.y;
/* Tst alignement vertical possible: */ /* Tst alignement vertical possible: */
if(refdx == 0) if( refdx == 0 )
{ {
if (segmdx != 0) return(NULL); if( segmdx != 0 )
else flag = 1; return NULL;
} else
/* Tst alignement horizontal possible: */ flag = 1;
if(refdy == 0) }
{ /* Tst alignement horizontal possible: */
if (segmdy != 0) return(NULL); if( refdy == 0 )
else flag = 2; {
} if( segmdy != 0 )
return NULL;
/* tst si il y a alignement d'angle qcq else
il faut que refdy/refdx == (+/-)segmdy/segmdx, c.a.d meme direction */ flag = 2;
if (flag == 0) }
{
if( (refdy * segmdx != refdx * segmdy) && /* tst si il y a alignement d'angle qcq
(refdy * segmdx != -refdx * segmdy) ) return(NULL); * il faut que refdy/refdx == (+/-)segmdy/segmdx, c.a.d meme direction */
flag = 4; if( flag == 0 )
} {
if( (refdy * segmdx != refdx * segmdy)
/* Ici il y a alignement: il faut determiner les positions relatives && (refdy * segmdx != -refdx * segmdy) )
pour supprimer le point commun et le remplacer */ return NULL;
if (extremite == START) flag = 4;
{ }
/* Ce ne doit pas etre sur un pad */
if(Fast_Locate_Pad_Connecte(Pcb, pt_ref->m_Start, /* Ici il y a alignement: il faut determiner les positions relatives
g_TabOneLayerMask[pt_ref->m_Layer])) * pour supprimer le point commun et le remplacer */
return(NULL); if( extremite == START )
{
if( (pt_ref->m_Start.x == pt_segm->m_Start.x) && (pt_ref->m_Start.y == pt_segm->m_Start.y) ) /* Ce ne doit pas etre sur un pad */
{ if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_Start,
pt_ref->m_Start.x = pt_segm->m_End.x; pt_ref->m_Start.y = pt_segm->m_End.y; g_TabOneLayerMask[pt_ref->m_Layer] ) )
return(pt_segm); return NULL;
}
else /* connexion par la fin de pt_segm */ if( (pt_ref->m_Start.x == pt_segm->m_Start.x)
{ && (pt_ref->m_Start.y == pt_segm->m_Start.y) )
pt_ref->m_Start.x = pt_segm->m_Start.x; pt_ref->m_Start.y = pt_segm->m_Start.y; {
return(pt_segm); pt_ref->m_Start.x = pt_segm->m_End.x; pt_ref->m_Start.y = pt_segm->m_End.y;
} return pt_segm;
} }
else /* extremite == END */ else /* connexion par la fin de pt_segm */
{ {
/* Ce ne doit pas etre sur un pad */ pt_ref->m_Start.x = pt_segm->m_Start.x; pt_ref->m_Start.y = pt_segm->m_Start.y;
if(Fast_Locate_Pad_Connecte(Pcb, pt_ref->m_End, g_TabOneLayerMask[pt_ref->m_Layer])) return pt_segm;
return(NULL); }
}
if( pt_ref->m_End == pt_segm->m_Start ) else /* extremite == END */
{ {
pt_ref->m_End = pt_segm->m_End; /* Ce ne doit pas etre sur un pad */
return(pt_segm); if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_End, g_TabOneLayerMask[pt_ref->m_Layer] ) )
} return NULL;
else /* connexion par la fin de pt_segm */
{ if( pt_ref->m_End == pt_segm->m_Start )
pt_ref->m_End = pt_segm->m_Start; {
return(pt_segm); pt_ref->m_End = pt_segm->m_End;
} return pt_segm;
} }
return(NULL); else /* connexion par la fin de pt_segm */
{
pt_ref->m_End = pt_segm->m_Start;
return pt_segm;
}
}
return NULL;
} }
/***************************************************************************/ /***************************************************************************/
int Netliste_Controle_piste(WinEDA_PcbFrame * frame, wxDC * DC, int affiche) int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
/***************************************************************************/ /***************************************************************************/
/* /*
verification des connexions. * verification des connexions.
Supprime les segments mal connectes, c.a.d. interconnectant des segments * Supprime les segments mal connectes, c.a.d. interconnectant des segments
de net_code differents * de net_code differents
*/ */
{ {
TRACK * PtSegm, * pt_aux; TRACK* PtSegm, * pt_aux;
EDA_BaseStruct * NextS; EDA_BaseStruct* NextS;
int net_code_s, net_code_e; int net_code_s, net_code_e;
int nbpoints_modifies = 0; int nbpoints_modifies = 0;
int flag = 0; int flag = 0;
int ii, percent, oldpercent; int ii, percent, oldpercent;
wxString msg; wxString msg;
a_color = RED; a_color = RED;
percent = 0; oldpercent = -1; percent = 0; oldpercent = -1;
frame->Affiche_Message( _("DRC Control:") ); frame->Affiche_Message( _( "DRC Control:" ) );
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
if(affiche) Affiche_1_Parametre(frame,POS_AFF_VAR, _("NetCtr"), wxT("0 "),a_color); if( affiche )
Affiche_1_Parametre( frame, POS_AFF_VAR, _( "NetCtr" ), wxT( "0 " ), a_color );
ii = 0;
for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)PtSegm->Pnext) ii = 0;
{ for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext )
/* affichage activite */ {
ii++; /* affichage activite */
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; ii++;
if( percent != oldpercent) percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
{ if( percent != oldpercent )
frame->DisplayActivity(percent, wxT("Drc: ") ); {
oldpercent = percent; frame->DisplayActivity( percent, wxT( "Drc: " ) );
msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack); oldpercent = percent;
Affiche_1_Parametre(frame, POS_AFF_MAX, wxT("Max"),msg,GREEN); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
Affiche_1_Parametre(frame, POS_AFF_NUMSEGM, wxT("Segm"),msg,CYAN); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
if( frame->DrawPanel->m_AbortRequest ) return(flag);
} if( frame->DrawPanel->m_AbortRequest )
return flag;
PtSegm->SetState(FLAG0,OFF); }
/* Calcul du net_code des elements raccordes sur le point de debut */ PtSegm->SetState( FLAG0, OFF );
net_code_s = -1;
if( (PtSegm->start != NULL) && /* Calcul du net_code des elements raccordes sur le point de debut */
( ((EDA_BaseStruct*)(PtSegm->start))->m_StructType == TYPEPAD) ) net_code_s = -1;
net_code_s = ((D_PAD*)(PtSegm->start))->m_NetCode; if( (PtSegm->start != NULL)
&& ( ( (EDA_BaseStruct*) (PtSegm->start) )->m_StructType == TYPEPAD ) )
else net_code_s = ( (D_PAD*) (PtSegm->start) )->m_NetCode;
{
pt_aux = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, else
NULL, START); {
if(pt_aux) net_code_s = pt_aux->m_NetCode; pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
} NULL, START );
if(net_code_s < 0 ) continue ; /* Extremite en l'air */ if( pt_aux )
net_code_s = pt_aux->m_NetCode;
/* Calcul du net_code des elements raccordes sur le point de fin */ }
net_code_e = -1; if( net_code_s < 0 )
if( (PtSegm->end != NULL) && continue;/* Extremite en l'air */
( ((EDA_BaseStruct*)(PtSegm->end))->m_StructType == TYPEPAD) )
net_code_e = ((D_PAD*)(PtSegm->end))->m_NetCode; /* Calcul du net_code des elements raccordes sur le point de fin */
net_code_e = -1;
else if( (PtSegm->end != NULL)
{ && ( ( (EDA_BaseStruct*) (PtSegm->end) )->m_StructType == TYPEPAD ) )
pt_aux = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, net_code_e = ( (D_PAD*) (PtSegm->end) )->m_NetCode;
NULL,END);
if(pt_aux) net_code_e = pt_aux->m_NetCode; else
} {
pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
if(net_code_e < 0 ) continue ; /* Extremite en l'air */ NULL, END );
if( pt_aux )
/* Marquage des segments a supprimer */ net_code_e = pt_aux->m_NetCode;
if(net_code_s != net_code_e) }
{
PtSegm->SetState(FLAG0,ON); if( net_code_e < 0 )
} continue;/* Extremite en l'air */
}
/* Marquage des segments a supprimer */
/* Suppression effective des segments */ if( net_code_s != net_code_e )
{
for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS) PtSegm->SetState( FLAG0, ON );
{ }
NextS = PtSegm->Pnext; }
if( PtSegm->GetState(FLAG0) ) /* Connexion erronee : a supprimer */
{ /* Suppression effective des segments */
PtSegm->SetState(FLAG0,OFF);
flag = 1; oldpercent = -1; for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS )
frame->m_Pcb->m_Status_Pcb = 0; {
frame->Supprime_Une_Piste( DC, PtSegm); NextS = PtSegm->Pnext;
NextS = frame->m_Pcb->m_Track; /* NextS a peut etre ete efface */ if( PtSegm->GetState( FLAG0 ) ) /* Connexion erronee : a supprimer */
if(affiche) {
{ PtSegm->SetState( FLAG0, OFF );
nbpoints_modifies++; flag = 1; oldpercent = -1;
msg.Printf( wxT("%d "),nbpoints_modifies); frame->m_Pcb->m_Status_Pcb = 0;
Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString,msg,a_color); frame->Supprime_Une_Piste( DC, PtSegm );
} NextS = frame->m_Pcb->m_Track; /* NextS a peut etre ete efface */
} if( affiche )
} {
return(flag); nbpoints_modifies++;
msg.Printf( wxT( "%d " ), nbpoints_modifies );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
}
}
}
return flag;
} }
#ifdef CONN2PAD_ENBL #ifdef CONN2PAD_ENBL
/***************************************************************/ /***************************************************************/
static void Gen_Raccord_Track(WinEDA_PcbFrame * frame, wxDC * DC) static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
/***************************************************************/ /***************************************************************/
/* Teste les extremites de segments : /* Teste les extremites de segments :
si une extremite est sur un segment de piste, mais pas sur une extremite, * si une extremite est sur un segment de piste, mais pas sur une extremite,
le segment est coupe en 2, le point de coupure etant l'extremite du segment * le segment est coupe en 2, le point de coupure etant l'extremite du segment
Ceci est fait pour que les tests de connexion qui ne testent que les extremites * Ceci est fait pour que les tests de connexion qui ne testent que les extremites
de segments voient la connexion * de segments voient la connexion
*/ */
{ {
TRACK * PtSegm, *pt_aux, * NewTrack; TRACK* PtSegm, * pt_aux, * NewTrack;
EDA_BaseStruct * NextS; EDA_BaseStruct* NextS;
int nn = 0; int nn = 0;
int masquelayer; int masquelayer;
int ii, percent, oldpercent; int ii, percent, oldpercent;
wxString msg; wxString msg;
frame->Affiche_Message( wxT("Gen Raccords sur Pistes:") ); frame->Affiche_Message( wxT( "Gen Raccords sur Pistes:" ) );
if( frame->m_Pcb->GetNumSegmTrack() == 0 ) return; if( frame->m_Pcb->GetNumSegmTrack() == 0 )
return;
frame->DrawPanel->m_AbortRequest = FALSE;
frame->DrawPanel->m_AbortRequest = FALSE;
oldpercent = -1; ii = 0;
for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS) oldpercent = -1; ii = 0;
{ for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS )
NextS = PtSegm->Pnext; {
/* affichage activite */ NextS = PtSegm->Pnext;
ii++; /* affichage activite */
percent = (100 * ii)/ frame->m_Pcb->m_NbSegmTrack; ii++;
if( percent != oldpercent) percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
{ if( percent != oldpercent )
frame->DisplayActivity(percent, wxT("Tracks: ") ); {
oldpercent = percent; frame->DisplayActivity( percent, wxT( "Tracks: " ) );
msg.Printf( wxT("%d"),frame->m_Pcb->m_NbSegmTrack ); oldpercent = percent;
Affiche_1_Parametre(frame,POS_AFF_MAX, wxT("Max"),msg,GREEN); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
msg.Printf( wxT("%d"), ii); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"),msg,CYAN); msg.Printf( wxT( "%d" ), ii );
} Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
}
if( frame->DrawPanel->m_AbortRequest ) return;
if( frame->DrawPanel->m_AbortRequest )
masquelayer = PtSegm->ReturnMaskLayer(); return;
/* examen du point de depart du segment de reference */ masquelayer = PtSegm->ReturnMaskLayer();
for(pt_aux = frame->m_Pcb->m_Track; ; pt_aux = (TRACK*) pt_aux->Pnext)
{ /* examen du point de depart du segment de reference */
if (pt_aux == NULL) break; for( pt_aux = frame->m_Pcb->m_Track; ; pt_aux = (TRACK*) pt_aux->Pnext )
pt_aux = Locate_Pistes(pt_aux, PtSegm->m_Start, masquelayer); {
if (pt_aux == NULL) break; if( pt_aux == NULL )
if(pt_aux == PtSegm) continue; break;
if(pt_aux->m_StructType == TYPEVIA) continue; pt_aux = Locate_Pistes( pt_aux, PtSegm->m_Start, masquelayer );
if( PtSegm->m_Start == pt_aux->m_Start ) continue; if( pt_aux == NULL )
if( PtSegm->m_Start == pt_aux->m_End ) continue; break;
if( pt_aux == PtSegm )
// Test si autre extremite du segment ne serait pas deja connectee continue;
if( PtSegm->m_End == pt_aux->m_Start ) continue; if( pt_aux->m_StructType == TYPEVIA )
if( PtSegm->m_End == pt_aux->m_End ) continue; continue;
if( PtSegm->m_Start == pt_aux->m_Start )
pt_aux->Draw(frame->DrawPanel, DC, GR_XOR); continue;
NewTrack = pt_aux->Copy(); if( PtSegm->m_Start == pt_aux->m_End )
NewTrack->Insert(frame->m_Pcb, pt_aux); continue;
nn++;
frame->m_Pcb->m_NbSegmTrack++; // Test si autre extremite du segment ne serait pas deja connectee
msg.Printf( wxT("%d"),nn); if( PtSegm->m_End == pt_aux->m_Start )
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("New <"),msg,YELLOW); continue;
pt_aux->m_End = PtSegm->m_Start; if( PtSegm->m_End == pt_aux->m_End )
NewTrack->m_Start = PtSegm->m_Start; continue;
Trace_Une_Piste(frame->DrawPanel, DC, pt_aux, 2, GR_OR);
pt_aux = NewTrack; pt_aux->Draw( frame->DrawPanel, DC, GR_XOR );
} NewTrack = pt_aux->Copy();
NewTrack->Insert( frame->m_Pcb, pt_aux );
/* examen du point de fin du segment de reference */ nn++;
for(pt_aux = frame->m_Pcb->m_Track; pt_aux != NULL; pt_aux = (TRACK*) pt_aux->Pnext) frame->m_Pcb->m_NbSegmTrack++;
{ msg.Printf( wxT( "%d" ), nn );
pt_aux = Locate_Pistes(pt_aux, PtSegm->m_End, masquelayer); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New <" ), msg, YELLOW );
if(pt_aux == NULL) break; pt_aux->m_End = PtSegm->m_Start;
if(pt_aux == PtSegm) continue; NewTrack->m_Start = PtSegm->m_Start;
if(pt_aux->m_StructType == TYPEVIA) continue; Trace_Une_Piste( frame->DrawPanel, DC, pt_aux, 2, GR_OR );
pt_aux = NewTrack;
if( (PtSegm->m_End.x == pt_aux->m_Start.x) && (PtSegm->m_End.y == pt_aux->m_Start.y)) continue; }
if( (PtSegm->m_End.x == pt_aux->m_End.x) && (PtSegm->m_End.y == pt_aux->m_End.y)) continue;
/* examen du point de fin du segment de reference */
if( (PtSegm->m_Start.x == pt_aux->m_Start.x) && (PtSegm->m_Start.y == pt_aux->m_Start.y)) continue; for( pt_aux = frame->m_Pcb->m_Track; pt_aux != NULL; pt_aux = (TRACK*) pt_aux->Pnext )
if( (PtSegm->m_Start.x == pt_aux->m_End.x) && (PtSegm->m_Start.y == pt_aux->m_End.y)) continue; {
pt_aux = Locate_Pistes( pt_aux, PtSegm->m_End, masquelayer );
pt_aux->Draw(frame->DrawPanel, DC, GR_XOR); if( pt_aux == NULL )
break;
NewTrack = pt_aux->Copy(); if( pt_aux == PtSegm )
NewTrack->Insert(frame->m_Pcb, pt_aux); continue;
if( pt_aux->m_StructType == TYPEVIA )
frame->m_Pcb->m_NbSegmTrack++; continue;
nn++; msg.Printf( wxT("%d"),nn);
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("New >"),msg,YELLOW); if( (PtSegm->m_End.x == pt_aux->m_Start.x) && (PtSegm->m_End.y == pt_aux->m_Start.y) )
pt_aux->m_End.x = PtSegm->m_End.x; pt_aux->m_End.y = PtSegm->m_End.y; continue;
NewTrack->m_Start.x = PtSegm->m_End.x; NewTrack->m_Start.y = PtSegm->m_End.y; if( (PtSegm->m_End.x == pt_aux->m_End.x) && (PtSegm->m_End.y == pt_aux->m_End.y) )
Trace_Une_Piste(frame->DrawPanel, DC, pt_aux,2,GR_OR); continue;
pt_aux = NewTrack;
} if( (PtSegm->m_Start.x == pt_aux->m_Start.x)
} && (PtSegm->m_Start.y == pt_aux->m_Start.y) )
continue;
if( (PtSegm->m_Start.x == pt_aux->m_End.x) && (PtSegm->m_Start.y == pt_aux->m_End.y) )
continue;
pt_aux->Draw( frame->DrawPanel, DC, GR_XOR );
NewTrack = pt_aux->Copy();
NewTrack->Insert( frame->m_Pcb, pt_aux );
frame->m_Pcb->m_NbSegmTrack++;
nn++; msg.Printf( wxT( "%d" ), nn );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New >" ), msg, YELLOW );
pt_aux->m_End.x = PtSegm->m_End.x; pt_aux->m_End.y = PtSegm->m_End.y;
NewTrack->m_Start.x = PtSegm->m_End.x; NewTrack->m_Start.y = PtSegm->m_End.y;
Trace_Une_Piste( frame->DrawPanel, DC, pt_aux, 2, GR_OR );
pt_aux = NewTrack;
}
}
} }
/***************************************************************/ /***************************************************************/
void ConnectDanglingEndToPad(WinEDA_PcbFrame * frame, wxDC * DC) void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC )
/**************************************************************/ /**************************************************************/
/* /*
rajoute eventuellement un segment a une extremite de piste connectee * rajoute eventuellement un segment a une extremite de piste connectee
a un pad si cette extremite n'est pas exactement connectee au centre * a un pad si cette extremite n'est pas exactement connectee au centre
du pad. * du pad.
Ceci permet un controle plus rapide des connexions * Ceci permet un controle plus rapide des connexions
*/ */
{ {
TRACK * PtSegm; TRACK* PtSegm;
EDA_BaseStruct * NextS; EDA_BaseStruct* NextS;
D_PAD * ptr_pad; D_PAD* ptr_pad;
int nb_new_piste = 0 , ii; int nb_new_piste = 0, ii;
int percent, oldpercent; int percent, oldpercent;
wxString msg; wxString msg;
a_color = GREEN; a_color = GREEN;
percent = 0; oldpercent = -1; percent = 0; oldpercent = -1;
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
Affiche_1_Parametre(frame, POS_AFF_VAR, _("Centre"), _("0 "),a_color); Affiche_1_Parametre( frame, POS_AFF_VAR, _( "Centre" ), _( "0 " ), a_color );
ii = 0; ii = 0;
for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)NextS) for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) NextS )
{ {
NextS = PtSegm->Pnext; NextS = PtSegm->Pnext;
/* affichage activite */ /* affichage activite */
ii++; ii++;
percent = (100 * ii)/ frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
if( percent != oldpercent) if( percent != oldpercent )
{ {
frame->DisplayActivity(percent, _("Pads: ")); frame->DisplayActivity( percent, _( "Pads: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT("%d"), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack );
Affiche_1_Parametre(frame, POS_AFF_MAX, _("Max"),msg,GREEN); Affiche_1_Parametre( frame, POS_AFF_MAX, _( "Max" ), msg, GREEN );
msg.Printf( wxT("%d"), ii); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(frame, POS_AFF_NUMSEGM, _("Segm"),msg,CYAN); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, _( "Segm" ), msg, CYAN );
if( frame->DrawPanel->m_AbortRequest ) return; if( frame->DrawPanel->m_AbortRequest )
} return;
}
ptr_pad = Locate_Pad_Connecte(frame->m_Pcb, PtSegm,START);
if( ptr_pad != NULL ) ptr_pad = Locate_Pad_Connecte( frame->m_Pcb, PtSegm, START );
{ /* Test si point piste non deja connecte a un autre segment */ if( ptr_pad != NULL )
if( PtSegm->m_Start != ptr_pad->m_Pos ) { /* Test si point piste non deja connecte a un autre segment */
{ if( PtSegm->m_Start != ptr_pad->m_Pos )
if(Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, {
NULL, START) == NULL) if( Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
{ NULL, START ) == NULL )
TRACK * NewTrack = PtSegm->Copy(); {
NewTrack->Insert(frame->m_Pcb, PtSegm); TRACK* NewTrack = PtSegm->Copy();
NewTrack->m_End = ptr_pad->m_Pos; NewTrack->Insert( frame->m_Pcb, PtSegm );
NewTrack->start = PtSegm; NewTrack->m_End = ptr_pad->m_Pos;
NewTrack->end = ptr_pad; NewTrack->start = PtSegm;
nb_new_piste++; NewTrack->end = ptr_pad;
NewTrack->Draw(frame->DrawPanel, DC, GR_OR); nb_new_piste++;
NewTrack->Draw( frame->DrawPanel, DC, GR_OR );
Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString,msg,a_color);
} Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
} }
} }
}
ptr_pad = Locate_Pad_Connecte(frame->m_Pcb, PtSegm,END);
if( ptr_pad != NULL ) ptr_pad = Locate_Pad_Connecte( frame->m_Pcb, PtSegm, END );
{ /* Test si point piste "en l'air" */ if( ptr_pad != NULL )
if( (PtSegm->m_End.x != ptr_pad->m_Pos.x) || { /* Test si point piste "en l'air" */
(PtSegm->m_End.y != ptr_pad->m_Pos.y) ) if( (PtSegm->m_End.x != ptr_pad->m_Pos.x)
{ || (PtSegm->m_End.y != ptr_pad->m_Pos.y) )
if(Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, {
NULL,END) == NULL) if( Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
{ NULL, END ) == NULL )
TRACK * NewTrack = PtSegm->Copy(); {
NewTrack->Insert(frame->m_Pcb, PtSegm); TRACK* NewTrack = PtSegm->Copy();
NewTrack->m_Start.x = ptr_pad->m_Pos.x; NewTrack->Insert( frame->m_Pcb, PtSegm );
NewTrack->m_Start.y = ptr_pad->m_Pos.y; NewTrack->m_Start.x = ptr_pad->m_Pos.x;
NewTrack->start = ptr_pad; NewTrack->m_Start.y = ptr_pad->m_Pos.y;
NewTrack->end = PtSegm; NewTrack->start = ptr_pad;
nb_new_piste++; NewTrack->end = PtSegm;
nb_new_piste++;
msg.Printf( wxT("e %d"),nb_new_piste);
Affiche_1_Parametre(frame, POS_AFF_VAR,wxEmptyString,msg,a_color); msg.Printf( wxT( "e %d" ), nb_new_piste );
} Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
} }
} }
} }
}
} }
#endif #endif
...@@ -336,9 +336,11 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -336,9 +336,11 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
bool keep_on_grid = TRUE; bool keep_on_grid = TRUE;
if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT ) if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT )
keep_on_grid = FALSE; keep_on_grid = FALSE;
/* Cursor is left off grid if no block in progress and no moving object */ /* Cursor is left off grid if no block in progress and no moving object */
if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK ) if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK )
keep_on_grid = TRUE; keep_on_grid = TRUE;
EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem; EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem;
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
keep_on_grid = TRUE; keep_on_grid = TRUE;
......
...@@ -35,7 +35,8 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC ) ...@@ -35,7 +35,8 @@ void WinEDA_PcbFrame::InstallFindFrame( const wxPoint& pos, wxDC* DC )
{ {
WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos ); WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos );
frame->ShowModal(); frame->Destroy(); frame->ShowModal();
frame->Destroy();
} }
......
/****************************************************/ /****************************************************/
/* Gestion des composants specifiques aux microndes */ /* Gestion des composants specifiques aux microndes */
/* Generation d'une self */ /* Generation d'une self */
/****************************************************/ /****************************************************/
/* Fichier GEN_SELF.H */ /* Fichier GEN_SELF.H */
/* Fonctions locales */ /* Fonctions locales */
static void Exit_Self(WinEDA_DrawPanel * Panel, wxDC *DC); static void Exit_Self( WinEDA_DrawPanel* Panel, wxDC* DC );
static EDGE_MODULE * gen_arc(EDGE_MODULE * PtSegm, int cX, int cY, int angle); static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle );
static void ShowCadreSelf(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); static void ShowCadreSelf( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* structures locales */ /* structures locales */
class SELFPCB // Definition d'une self constituee par une piste class SELFPCB // Definition d'une self constituee par une piste
{ {
public: public:
int forme; // Serpentin, spirale .. int forme; // Serpentin, spirale ..
int orient; // 0..3600 int orient; // 0..3600
int valeur; // Valeur de la self int valeur; // Valeur de la self
wxPoint m_Start; wxPoint m_Start;
wxPoint m_End; // Coord du point de depart et d'arrivee wxPoint m_End; // Coord du point de depart et d'arrivee
wxSize m_Size; wxSize m_Size;
D_PAD * pt_pad_start, *pt_pad_end; // Pointeurs sur les pads d'extremite D_PAD* pt_pad_start, * pt_pad_end; // Pointeurs sur les pads d'extremite
int lng; // Longueur de la piste constituant la self int lng; // Longueur de la piste constituant la self
int m_Width; // m_Size.xur de la piste int m_Width; // m_Size.xur de la piste
int nbrin; // Parametres de calcul: nombre de brins int nbrin; // Parametres de calcul: nombre de brins
int lbrin; // longueur du brin int lbrin; // longueur du brin
int rayon; // Rayon des raccords entre brins int rayon; // Rayon des raccords entre brins
int delta; // distance aux pads int delta; // distance aux pads
}; };
/* Variables locales */ /* Variables locales */
static SELFPCB Mself; static SELFPCB Mself;
static int Self_On; static int Self_On;
static int Bl_X0, Bl_Y0 , Bl_Xf, Bl_Yf; // Coord du cadre insrcivant la self static int Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf; // Coord du cadre insrcivant la self
/*************************************************************************/ /*************************************************************************/
static void ShowCadreSelf(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) static void ShowCadreSelf( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************************/ /*************************************************************************/
/* Routine d'affichage a l'ecran du cadre de la self */ /* Routine d'affichage a l'ecran du cadre de la self */
{ {
int deltaX, deltaY; int deltaX, deltaY;
/* Calcul de l'orientation et de la taille de la fenetre: /* Calcul de l'orientation et de la taille de la fenetre:
- orient = vert ou Horiz ( dimension max) * - orient = vert ou Horiz ( dimension max)
- Size.x = Size.y / 2 * - Size.x = Size.y / 2
*/ */
GRSetDrawMode(DC, GR_XOR); GRSetDrawMode( DC, GR_XOR );
if( erase)/* effacement du cadre */ if( erase )/* effacement du cadre */
{ {
GRRect( & panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf, YELLOW); GRRect( &panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf, YELLOW );
} }
deltaX = (panel->GetScreen()->m_Curseur.x - Mself.m_Start.x) / 4; deltaX = (panel->GetScreen()->m_Curseur.x - Mself.m_Start.x) / 4;
deltaY = (panel->GetScreen()->m_Curseur.y - Mself.m_Start.y) / 4; deltaY = (panel->GetScreen()->m_Curseur.y - Mself.m_Start.y) / 4;
Mself.orient = 900; Mself.orient = 900;
if( abs(deltaX) > abs(deltaY) ) Mself.orient = 0; if( abs( deltaX ) > abs( deltaY ) )
Mself.orient = 0;
if(Mself.orient == 0)
{ if( Mself.orient == 0 )
Bl_X0 = Mself.m_Start.x; {
Bl_Y0 = Mself.m_Start.y - deltaX; Bl_X0 = Mself.m_Start.x;
Bl_Xf = panel->GetScreen()->m_Curseur.x; Bl_Y0 = Mself.m_Start.y - deltaX;
Bl_Yf = Mself.m_Start.y + deltaX; Bl_Xf = panel->GetScreen()->m_Curseur.x;
} Bl_Yf = Mself.m_Start.y + deltaX;
else }
{ else
Bl_X0 = Mself.m_Start.x - deltaY; {
Bl_Y0 = Mself.m_Start.y; Bl_X0 = Mself.m_Start.x - deltaY;
Bl_Xf = Mself.m_Start.x + deltaY; Bl_Y0 = Mself.m_Start.y;
Bl_Yf = panel->GetScreen()->m_Curseur.y; Bl_Xf = Mself.m_Start.x + deltaY;
} Bl_Yf = panel->GetScreen()->m_Curseur.y;
GRRect( & panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf,YELLOW); }
GRRect( &panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf, YELLOW );
} }
/*************************************************/ /*************************************************/
void Exit_Self(WinEDA_DrawPanel * Panel, wxDC *DC) void Exit_Self( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************/ /*************************************************/
/* Routine de fermeture de l'application : ferme les commandes en cours */ /* Routine de fermeture de l'application : ferme les commandes en cours */
{ {
if(Self_On) if( Self_On )
{ {
Self_On = 0; Self_On = 0;
Panel->ManageCurseur(Panel, DC, 0); /* efface cadre */ Panel->ManageCurseur( Panel, DC, 0 ); /* efface cadre */
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
} }
} }
/*******************************************/ /*******************************************/
void WinEDA_PcbFrame::Begin_Self( wxDC *DC) void WinEDA_PcbFrame::Begin_Self( wxDC* DC )
/*******************************************/ /*******************************************/
/* /*
Routine d'initialisation d'un trace de self * Routine d'initialisation d'un trace de self
*/ */
{ {
if( Self_On )
{
Genere_Self( DC );
return;
}
if ( Self_On ) Mself.m_Start = GetScreen()->m_Curseur;
{
Genere_Self(DC);
return;
}
Mself.m_Start = GetScreen()->m_Curseur;
Self_On = 1; Self_On = 1;
/* Mise a jour de l'origine des coord relatives */ /* Mise a jour de l'origine des coord relatives */
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur; GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
Affiche_Status_Box(); Affiche_Status_Box();
Bl_X0 = Mself.m_Start.x; Bl_Y0 = Mself.m_Start.y; Bl_X0 = Mself.m_Start.x; Bl_Y0 = Mself.m_Start.y;
Bl_Xf = Bl_X0; Bl_Yf = Bl_Y0; Bl_Xf = Bl_X0; Bl_Yf = Bl_Y0;
DrawPanel->ManageCurseur = ShowCadreSelf; DrawPanel->ManageCurseur = ShowCadreSelf;
DrawPanel->ForceCloseManageCurseur = Exit_Self; DrawPanel->ForceCloseManageCurseur = Exit_Self;
DrawPanel->ManageCurseur(DrawPanel, DC, 0); /* Affiche cadre */ DrawPanel->ManageCurseur( DrawPanel, DC, 0 ); /* Affiche cadre */
} }
/**********************************************/ /**********************************************/
MODULE * WinEDA_PcbFrame::Genere_Self( wxDC *DC) MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
/**********************************************/ /**********************************************/
/* Genere une self en forme de serpentin /* Genere une self en forme de serpentin
- longueur Mself.lng * - longueur Mself.lng
- Extremites Mself.m_Start et Mself.m_End * - Extremites Mself.m_Start et Mself.m_End
- Contrainte: m_Start.x = m_End.x ( self verticale ) * - Contrainte: m_Start.x = m_End.x ( self verticale )
ou m_Start.y = m_End.y ( self horizontale ) * ou m_Start.y = m_End.y ( self horizontale )
*
On doit determiner: * On doit determiner:
Mself.nbrin = nombre de segments perpendiculaires a la direction * Mself.nbrin = nombre de segments perpendiculaires a la direction
( le serpention aura nbrin + 1 demicercles + 2 1/4 de cercle) * ( le serpention aura nbrin + 1 demicercles + 2 1/4 de cercle)
Mself.lbrin = longueur d'un brin * Mself.lbrin = longueur d'un brin
Mself.rayon = rayon des parties arrondies du serpentin * Mself.rayon = rayon des parties arrondies du serpentin
Mself.delta = segments raccord entre extremites et le serpention lui meme * Mself.delta = segments raccord entre extremites et le serpention lui meme
*
Les equations sont * Les equations sont
Mself.m_Size.x = 2*Mself.rayon + Mself.lbrin * Mself.m_Size.x = 2*Mself.rayon + Mself.lbrin
Mself.m_Size.y = 2*Mself.delta + 2*Mself.nbrin*Mself.rayon * Mself.m_Size.y = 2*Mself.delta + 2*Mself.nbrin*Mself.rayon
Mself.lng = 2*Mself.delta // Raccords au serpentin * Mself.lng = 2*Mself.delta // Raccords au serpentin
+ (Mself.nbrin-2) * Mself.lbrin //longueur des brins sauf 1er et dernier + (Mself.nbrin-2) * Mself.lbrin //longueur des brins sauf 1er et dernier
+ (Mself.nbrin+1) * ( PI * Mself.rayon) // longueur des arrondis + (Mself.nbrin+1) * ( PI * Mself.rayon) // longueur des arrondis
+ Mself.lbrin/2 - Melf.rayon*2) // longueur du 1er et dernier brin + Mself.lbrin/2 - Melf.rayon*2) // longueur du 1er et dernier brin
*
Les contraintes sont: * Les contraintes sont:
nbrin >= 2 * nbrin >= 2
Mself.rayon < Mself.m_Size.x * Mself.rayon < Mself.m_Size.x
Mself.m_Size.y = Mself.rayon*4 + 2*Mself.raccord * Mself.m_Size.y = Mself.rayon*4 + 2*Mself.raccord
Mself.lbrin > Mself.rayon *2 * Mself.lbrin > Mself.rayon *2
*
Le calcul est conduit de la facon suivante: * Le calcul est conduit de la facon suivante:
Initialement: * Initialement:
nbrin = 2 * nbrin = 2
rayon = 4 * m_Size.x (valeur fixe arbitraire) * rayon = 4 * m_Size.x (valeur fixe arbitraire)
puis: * puis:
on augmente le nombre de brins jusqu'a la longueur desiree * on augmente le nombre de brins jusqu'a la longueur desiree
( le rayon est diminue si necessaire ) * ( le rayon est diminue si necessaire )
*
*/ */
{ {
EDGE_MODULE * PtSegm, * LastSegm, *FirstSegm, * newedge; EDGE_MODULE* PtSegm, * LastSegm, * FirstSegm, * newedge;
MODULE * Module; MODULE* Module;
D_PAD * PtPad; D_PAD* PtPad;
int ii, ll, lextbrin; int ii, ll, lextbrin;
float fcoeff; float fcoeff;
bool abort = FALSE; bool abort = FALSE;
wxString msg; wxString msg;
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); /* efface cadre */ DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); /* efface cadre */
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
if(Self_On == 0) if( Self_On == 0 )
{ {
DisplayError(this, wxT("Starting point not init..")); return NULL; DisplayError( this, wxT( "Starting point not init.." ) ); return NULL;
} }
Self_On = 0; Self_On = 0;
Mself.m_End = m_CurrentScreen->m_Curseur; Mself.m_End = m_CurrentScreen->m_Curseur;
/* Agencement des parametres pour simplifier le calcul : */ /* Agencement des parametres pour simplifier le calcul : */
/* le point de depart doit avoir la coord depart < celle du point de fin */ /* le point de depart doit avoir la coord depart < celle du point de fin */
if(Mself.orient == 0) // Self horizontale if( Mself.orient == 0 ) // Self horizontale
{ {
Mself.m_End.y = Mself.m_Start.y; Mself.m_End.y = Mself.m_Start.y;
if(Mself.m_Start.x > Mself.m_End.x) EXCHG(Mself.m_Start.x,Mself.m_End.x); if( Mself.m_Start.x > Mself.m_End.x )
Mself.m_Size.y = Mself.m_End.x - Mself.m_Start.x; EXCHG( Mself.m_Start.x, Mself.m_End.x );
Mself.lng = Mself.m_Size.y; Mself.m_Size.y = Mself.m_End.x - Mself.m_Start.x;
} Mself.lng = Mself.m_Size.y;
}
else // Self verticale else // Self verticale
{ {
Mself.m_End.x = Mself.m_Start.x; Mself.m_End.x = Mself.m_Start.x;
if(Mself.m_Start.y > Mself.m_End.y) EXCHG(Mself.m_Start.y,Mself.m_End.y); if( Mself.m_Start.y > Mself.m_End.y )
Mself.m_Size.y = Mself.m_End.y - Mself.m_Start.y; EXCHG( Mself.m_Start.y, Mself.m_End.y );
Mself.lng = Mself.m_Size.y; Mself.m_Size.y = Mself.m_End.y - Mself.m_Start.y;
} Mself.lng = Mself.m_Size.y;
}
/* Entree de la vraie longueur desiree */
if( ! g_UnitMetric ) /* Entree de la vraie longueur desiree */
{ if( !g_UnitMetric )
fcoeff = 10000.0 ; {
msg.Printf( wxT("%1.4f"), Mself.lng /fcoeff); fcoeff = 10000.0;
abort = Get_Message(_("Length(inch):"),msg, this); msg.Printf( wxT( "%1.4f" ), Mself.lng / fcoeff );
} abort = Get_Message( _( "Length(inch):" ), msg, this );
else }
{ else
fcoeff = 10000.0/25.4 ; {
msg.Printf( wxT("%2.3f"), Mself.lng /fcoeff); fcoeff = 10000.0 / 25.4;
abort = Get_Message( _("Length(mm):"),msg, this); msg.Printf( wxT( "%2.3f" ), Mself.lng / fcoeff );
} abort = Get_Message( _( "Length(mm):" ), msg, this );
if ( abort ) return NULL; }
if( abort )
double fval; return NULL;
if ( ! msg.ToDouble(&fval) )
{ double fval;
DisplayError(this, _("Incorrect number, abort")); if( !msg.ToDouble( &fval ) )
return NULL; {
} DisplayError( this, _( "Incorrect number, abort" ) );
Mself.lng = (int) round( fval * fcoeff ); return NULL;
}
/* Controle des valeurs ( ii = valeur minimale de la longueur */ Mself.lng = (int) round( fval * fcoeff );
if( Mself.lng < Mself.m_Size.y )
{ /* Controle des valeurs ( ii = valeur minimale de la longueur */
DisplayError(this, _("Requested length < minimum length")); if( Mself.lng < Mself.m_Size.y )
return NULL; {
} DisplayError( this, _( "Requested length < minimum length" ) );
return NULL;
/* Generation du composant: calcul des elements de la self */ }
Mself.m_Width = g_DesignSettings.m_CurrentTrackWidth;
Mself.m_Size.x = Mself.m_Size.y / 2 ; /* Generation du composant: calcul des elements de la self */
// Choix d'une Valeur de depart raisonnable pour le rayon des arcs de cercle Mself.m_Width = g_DesignSettings.m_CurrentTrackWidth;
Mself.rayon = min(Mself.m_Width * 5, Mself.m_Size.x/4); Mself.m_Size.x = Mself.m_Size.y / 2;
/* Calcul des parametres */
// Choix d'une Valeur de depart raisonnable pour le rayon des arcs de cercle
for ( Mself.nbrin = 2 ; ; Mself.nbrin++) Mself.rayon = min( Mself.m_Width * 5, Mself.m_Size.x / 4 );
{ /* Calcul des parametres */
Mself.delta = (Mself.m_Size.y - ( Mself.rayon * 2 * Mself.nbrin ) ) / 2 ;
if(Mself.delta < Mself.m_Size.y / 10) // C.a.d. si m_Size.yeur self > m_Size.yeur specifiee for( Mself.nbrin = 2; ; Mself.nbrin++ )
{ // Reduction du rayon des arrondis {
Mself.delta = Mself.m_Size.y / 10; Mself.delta = ( Mself.m_Size.y - ( Mself.rayon * 2 * Mself.nbrin ) ) / 2;
Mself.rayon = (Mself.m_Size.y - 2*Mself.delta) / ( 2 * Mself.nbrin) ; if( Mself.delta < Mself.m_Size.y / 10 ) // C.a.d. si m_Size.yeur self > m_Size.yeur specifiee
if(Mself.rayon < Mself.m_Width) { // Reduction du rayon des arrondis
{ // Rayon vraiment trop petit... Mself.delta = Mself.m_Size.y / 10;
Affiche_Message(_("Unable to create line: Requested length is too big")); Mself.rayon = (Mself.m_Size.y - 2 * Mself.delta) / ( 2 * Mself.nbrin);
return NULL; if( Mself.rayon < Mself.m_Width )
} { // Rayon vraiment trop petit...
} Affiche_Message( _( "Unable to create line: Requested length is too big" ) );
Mself.lbrin = Mself.m_Size.x - (Mself.rayon * 2); return NULL;
lextbrin = (Mself.lbrin/2) - Mself.rayon; }
ll = 2 * lextbrin ; // Longueur du 1er et dernier brin }
ll += 2 * Mself.delta ; // Longueur des raccord au serpentin Mself.lbrin = Mself.m_Size.x - (Mself.rayon * 2);
ll += Mself.nbrin * (Mself.lbrin - 2); // longueur des autres brins lextbrin = (Mself.lbrin / 2) - Mself.rayon;
ll += ((Mself.nbrin+1) * 314 * Mself.rayon) /100 ; ll = 2 * lextbrin; // Longueur du 1er et dernier brin
ll += 2 * Mself.delta; // Longueur des raccord au serpentin
msg.Printf( _("Segm count = %d, Lenght = "), Mself.nbrin); ll += Mself.nbrin * (Mself.lbrin - 2); // longueur des autres brins
wxString stlen; ll += ( (Mself.nbrin + 1) * 314 * Mself.rayon ) / 100;
valeur_param(ll, stlen); msg += stlen;
Affiche_Message(msg); msg.Printf( _( "Segm count = %d, Lenght = " ), Mself.nbrin );
if ( ll >= Mself.lng) break; wxString stlen;
} valeur_param( ll, stlen ); msg += stlen;
Affiche_Message( msg );
/* Generation du composant : le calcul est fait self Verticale */ if( ll >= Mself.lng )
if( Create_1_Module(DC, wxEmptyString) == NULL ) return NULL; break;
}
Module = m_Pcb->m_Modules;
Module->m_LibRef = wxT("MuSelf"); /* Generation du composant : le calcul est fait self Verticale */
Module->m_Attributs = MOD_VIRTUAL | MOD_CMS; if( Create_1_Module( DC, wxEmptyString ) == NULL )
Module->m_Flags = 0; return NULL;
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); Module = m_Pcb->m_Modules;
Module->m_LibRef = wxT( "MuSelf" );
/* Generation des elements speciaux: drawsegments */ Module->m_Attributs = MOD_VIRTUAL | MOD_CMS;
LastSegm = (EDGE_MODULE*) Module->m_Drawings; Module->m_Flags = 0;
if( LastSegm ) while( LastSegm->Pnext) LastSegm = (EDGE_MODULE*)LastSegm->Pnext;
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
FirstSegm = PtSegm = new EDGE_MODULE(Module);
if (LastSegm ) /* Generation des elements speciaux: drawsegments */
{ LastSegm = (EDGE_MODULE*) Module->m_Drawings;
LastSegm->Pnext = PtSegm; if( LastSegm )
PtSegm->Pback = LastSegm; while( LastSegm->Pnext )
} LastSegm = (EDGE_MODULE*) LastSegm->Pnext;
else
{ FirstSegm = PtSegm = new EDGE_MODULE( Module );
Module->m_Drawings = PtSegm; PtSegm->Pback = Module; if( LastSegm )
} {
PtSegm->m_Start = Mself.m_Start; LastSegm->Pnext = PtSegm;
PtSegm->m_End.x = Mself.m_Start.x; PtSegm->Pback = LastSegm;
PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta; }
PtSegm->m_Width = Mself.m_Width; else
PtSegm->m_Layer = Module->m_Layer; {
PtSegm->m_Shape = S_SEGMENT; Module->m_Drawings = PtSegm; PtSegm->Pback = Module;
}
newedge = new EDGE_MODULE(Module); PtSegm->m_Start = Mself.m_Start;
newedge->Copy(PtSegm); PtSegm->m_End.x = Mself.m_Start.x;
newedge->AddToChain(PtSegm); PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta;
PtSegm = newedge; PtSegm->m_Width = Mself.m_Width;
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_Layer = Module->m_Layer;
PtSegm = gen_arc(PtSegm,PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900); PtSegm->m_Shape = S_SEGMENT;
if(lextbrin) newedge = new EDGE_MODULE( Module );
{ newedge->Copy( PtSegm );
newedge = new EDGE_MODULE(Module); newedge->AddToChain( PtSegm );
newedge->Copy(PtSegm); PtSegm = newedge;
newedge->AddToChain(PtSegm); PtSegm->m_Start = PtSegm->m_End;
PtSegm = newedge; PtSegm = gen_arc( PtSegm, PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900 );
PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End.x -= lextbrin; if( lextbrin )
} {
newedge = new EDGE_MODULE( Module );
/* Trace du serpentin */ newedge->Copy( PtSegm );
for (ii = 1 ; ii < Mself.nbrin; ii++) newedge->AddToChain( PtSegm );
{ PtSegm = newedge;
int arc_angle; PtSegm->m_Start = PtSegm->m_End;
newedge = new EDGE_MODULE(Module); PtSegm->m_End.x -= lextbrin;
newedge->Copy(PtSegm); }
newedge->AddToChain(PtSegm);
PtSegm = newedge; /* Trace du serpentin */
PtSegm->m_Start = PtSegm->m_End; for( ii = 1; ii < Mself.nbrin; ii++ )
if( ii & 1) /* brin d'ordre impair : cercles de sens > 0 */ {
arc_angle = 1800; int arc_angle;
else arc_angle = -1800; newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm );
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, newedge->AddToChain( PtSegm );
PtSegm->m_End.y + Mself.rayon, arc_angle); PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
if( ii < Mself.nbrin-1) if( ii & 1 ) /* brin d'ordre impair : cercles de sens > 0 */
{ arc_angle = 1800;
newedge = new EDGE_MODULE(Module); else
newedge->Copy(PtSegm); arc_angle = -1800;
newedge->AddToChain(PtSegm);
PtSegm = newedge; PtSegm = gen_arc( PtSegm, PtSegm->m_End.x,
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_End.y + Mself.rayon, arc_angle );
if( ii & 1) PtSegm->m_End.x += Mself.lbrin;
else PtSegm->m_End.x -= Mself.lbrin; if( ii < Mself.nbrin - 1 )
} {
} newedge = new EDGE_MODULE( Module );
newedge->Copy( PtSegm );
/* Trace du point final */ newedge->AddToChain( PtSegm );
PtSegm = newedge;
if( ii & 1) /* brin final de sens > 0 */ PtSegm->m_Start = PtSegm->m_End;
{ if( ii & 1 )
if(lextbrin) PtSegm->m_End.x += Mself.lbrin;
{ else
newedge = new EDGE_MODULE(Module); PtSegm->m_End.x -= Mself.lbrin;
newedge->Copy(PtSegm); }
newedge->AddToChain(PtSegm); }
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End; /* Trace du point final */
PtSegm->m_End.x -= lextbrin;
} if( ii & 1 ) /* brin final de sens > 0 */
{
newedge = new EDGE_MODULE(Module); if( lextbrin )
newedge->Copy(PtSegm); {
newedge->AddToChain(PtSegm); newedge = new EDGE_MODULE( Module );
PtSegm = newedge; newedge->Copy( PtSegm );
PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y; newedge->AddToChain( PtSegm );
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900); PtSegm = newedge;
} PtSegm->m_Start = PtSegm->m_End;
else PtSegm->m_End.x -= lextbrin;
{ }
if(lextbrin)
{ newedge = new EDGE_MODULE( Module );
newedge = new EDGE_MODULE(Module); newedge->Copy( PtSegm );
newedge->Copy(PtSegm); newedge->AddToChain( PtSegm );
newedge->AddToChain(PtSegm); PtSegm = newedge;
PtSegm = newedge; PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
PtSegm->m_Start = PtSegm->m_End; PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900 );
PtSegm->m_End.x += lextbrin; }
} else
newedge = new EDGE_MODULE(Module); {
newedge->Copy(PtSegm); if( lextbrin )
newedge->AddToChain(PtSegm); {
PtSegm = newedge; newedge = new EDGE_MODULE( Module );
PtSegm->m_Start = PtSegm->m_End; newedge->Copy( PtSegm );
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900); newedge->AddToChain( PtSegm );
} PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
newedge = new EDGE_MODULE(Module); PtSegm->m_End.x += lextbrin;
newedge->Copy(PtSegm); }
newedge->AddToChain(PtSegm); newedge = new EDGE_MODULE( Module );
PtSegm = newedge; newedge->Copy( PtSegm );
PtSegm->m_Start = PtSegm->m_End; newedge->AddToChain( PtSegm );
PtSegm->m_End = Mself.m_End; PtSegm = newedge;
PtSegm->Pnext = NULL; PtSegm->m_Start = PtSegm->m_End;
PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900 );
/* Rotation de la self si le trace doit etre horizontal : */ }
LastSegm = PtSegm;
if ( Mself.orient == 0) newedge = new EDGE_MODULE( Module );
{ newedge->Copy( PtSegm );
for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext ) newedge->AddToChain( PtSegm );
{ PtSegm = newedge;
RotatePoint(&PtSegm->m_Start.x, &PtSegm->m_Start.y, PtSegm->m_Start = PtSegm->m_End;
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 ); PtSegm->m_End = Mself.m_End;
if( PtSegm != LastSegm ) PtSegm->Pnext = NULL;
RotatePoint(&PtSegm->m_End.x, &PtSegm->m_End.y,
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 ); /* Rotation de la self si le trace doit etre horizontal : */
} LastSegm = PtSegm;
} if( Mself.orient == 0 )
{
/* Modif position ancre */ for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext )
Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos.y = LastSegm->m_End.y; {
RotatePoint( &PtSegm->m_Start.x, &PtSegm->m_Start.y,
/* Placement des 2 pads sur extremite */ FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
PtPad = new D_PAD(Module); if( PtSegm != LastSegm )
RotatePoint( &PtSegm->m_End.x, &PtSegm->m_End.y,
Module->m_Pads = PtPad; PtPad->Pback = Module; FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
PtPad->SetPadName( wxT("1") ); }
PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y; }
PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y; /* Modif position ancre */
PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width; Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos.y = LastSegm->m_End.y;
PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->m_Layer];
PtPad->m_Attribut = SMD; /* Placement des 2 pads sur extremite */
PtPad->m_PadShape = CIRCLE; PtPad = new D_PAD( Module );
PtPad->m_Rayon = PtPad->m_Size.x / 2;
Module->m_Pads = PtPad; PtPad->Pback = Module;
D_PAD * newpad = new D_PAD(Module); PtPad->SetPadName( wxT( "1" ) );
newpad->Copy(PtPad); PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y;
newpad->AddToChain(PtPad); PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x;
PtPad = newpad; PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
PtPad->SetPadName( wxT("2") ); PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width;
PtPad->m_Pos.x = FirstSegm->m_Start.x; PtPad->m_Pos.y = FirstSegm->m_Start.y; PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->m_Layer];
PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x; PtPad->m_Attribut = SMD;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y; PtPad->m_PadShape = CIRCLE;
PtPad->m_Rayon = PtPad->m_Size.x / 2;
/* Modif des positions textes */
Module->Display_Infos(this); D_PAD* newpad = new D_PAD( Module );
Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x = ( FirstSegm->m_Start.x + LastSegm->m_End.x ) /2 ; newpad->Copy( PtPad );
Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y = ( FirstSegm->m_Start.y + LastSegm->m_End.y ) /2 ; newpad->AddToChain( PtPad );
PtPad = newpad;
Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y; PtPad->SetPadName( wxT( "2" ) );
Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y; PtPad->m_Pos.x = FirstSegm->m_Start.x; PtPad->m_Pos.y = FirstSegm->m_Start.y;
PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x;
Module->m_Reference->m_Pos0.x = Module->m_Reference->m_Pos.x - Module->m_Pos.x; PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
Module->m_Reference->m_Pos0.y = Module->m_Reference->m_Pos.y - Module->m_Pos.y;
Module->m_Value->m_Pos0.x = Module->m_Value->m_Pos.x - Module->m_Pos.x; /* Modif des positions textes */
Module->m_Value->m_Pos0.y = Module->m_Value->m_Pos.y - Module->m_Pos.y; Module->Display_Infos( this );
Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x = ( FirstSegm->m_Start.x +
/* Init des Coord locales des segments */ LastSegm->m_End.x ) / 2;
for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext ) Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y = ( FirstSegm->m_Start.y +
{ LastSegm->m_End.y ) / 2;
PtSegm->m_Start0.x = PtSegm->m_Start.x - Module->m_Pos.x;
PtSegm->m_Start0.y = PtSegm->m_Start.y - Module->m_Pos.y; Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y;
PtSegm->m_End0.x = PtSegm->m_End.x - Module->m_Pos.x; Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y;
PtSegm->m_End0.y = PtSegm->m_End.y - Module->m_Pos.y;
} Module->m_Reference->m_Pos0.x = Module->m_Reference->m_Pos.x - Module->m_Pos.x;
Module->m_Reference->m_Pos0.y = Module->m_Reference->m_Pos.y - Module->m_Pos.y;
Module->Set_Rectangle_Encadrement(); Module->m_Value->m_Pos0.x = Module->m_Value->m_Pos.x - Module->m_Pos.x;
Module->m_Value->m_Pos0.y = Module->m_Value->m_Pos.y - Module->m_Pos.y;
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
/* Init des Coord locales des segments */
return Module; for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext )
{
PtSegm->m_Start0.x = PtSegm->m_Start.x - Module->m_Pos.x;
PtSegm->m_Start0.y = PtSegm->m_Start.y - Module->m_Pos.y;
PtSegm->m_End0.x = PtSegm->m_End.x - Module->m_Pos.x;
PtSegm->m_End0.y = PtSegm->m_End.y - Module->m_Pos.y;
}
Module->Set_Rectangle_Encadrement();
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
return Module;
} }
/**************************************************************************/ /**************************************************************************/
static EDGE_MODULE * gen_arc(EDGE_MODULE * PtSegm, int cX, int cY, int angle) static EDGE_MODULE* gen_arc( EDGE_MODULE* PtSegm, int cX, int cY, int angle )
/**************************************************************************/ /**************************************************************************/
/* Genere un arc de EDGE_MODULE : /* Genere un arc de EDGE_MODULE :
de centre cX,cY * de centre cX,cY
d'angle "angle" * d'angle "angle"
de point de depart donne dans la structure pointee par PtSegm, qui doit * de point de depart donne dans la structure pointee par PtSegm, qui doit
entre a jour (type,net..) * entre a jour (type,net..)
Retourne un pointeur sur la derniere structure EDGE_MODULE generee * Retourne un pointeur sur la derniere structure EDGE_MODULE generee
*/ */
{ {
int ii, nb_seg; int ii, nb_seg;
float alpha, beta, fsin, fcos; float alpha, beta, fsin, fcos;
int x0, xr0, y0, yr0; int x0, xr0, y0, yr0;
EDGE_MODULE * newedge; EDGE_MODULE* newedge;
angle = -angle; angle = -angle;
y0 = PtSegm->m_Start.x - cX; x0 = PtSegm->m_Start.y - cY; y0 = PtSegm->m_Start.x - cX; x0 = PtSegm->m_Start.y - cY;
nb_seg = (abs(angle)) / 225 ; if(nb_seg == 0) nb_seg = 1 ; nb_seg = ( abs( angle ) ) / 225; if( nb_seg == 0 )
alpha = ( (float)angle * 3.14159 / 1800 ) / nb_seg; nb_seg = 1;
alpha = ( (float) angle * 3.14159 / 1800 ) / nb_seg;
for ( ii = 1 ; ii <= nb_seg ; ii++ )
{ for( ii = 1; ii <= nb_seg; ii++ )
if( ii > 1) {
{ if( ii > 1 )
newedge = new EDGE_MODULE( (MODULE*) NULL); {
newedge->Copy(PtSegm); newedge = new EDGE_MODULE( (MODULE*) NULL );
newedge->m_Parent = PtSegm->m_Parent; newedge->Copy( PtSegm );
newedge->AddToChain(PtSegm); newedge->m_Parent = PtSegm->m_Parent;
PtSegm = newedge; newedge->AddToChain( PtSegm );
PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y; PtSegm = newedge;
} PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
}
beta = (alpha * ii);
fcos = cos(beta); fsin = sin(beta); beta = (alpha * ii);
fcos = cos( beta ); fsin = sin( beta );
xr0 = (int)(x0 * fcos + y0 * fsin);
yr0 = (int)(y0 * fcos - x0 * fsin); xr0 = (int) (x0 * fcos + y0 * fsin);
PtSegm->m_End.x = cX + yr0; PtSegm->m_End.y = cY + xr0 ; yr0 = (int) (y0 * fcos - x0 * fsin);
} PtSegm->m_End.x = cX + yr0; PtSegm->m_End.y = cY + xr0;
return( PtSegm ); }
return PtSegm;
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
/* fonctions locales */ /* fonctions locales */
EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int typeloc ); EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int typeloc );
D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer );
/** /**
...@@ -390,10 +391,10 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc ) ...@@ -390,10 +391,10 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc )
} }
/*************************************************/ /*************************************************
/* D_PAD * Locate_Any_Pad(int typeloc, bool OnlyCurrentLayer) */ * D_PAD * Locate_Any_Pad(int typeloc, bool OnlyCurrentLayer)
/* D_PAD* Locate_Any_Pad(int ref_pos, bool OnlyCurrentLayer) */ * D_PAD* Locate_Any_Pad(int ref_pos, bool OnlyCurrentLayer)
/*************************************************/ *************************************************/
/* /*
* localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou * localisation de la pastille pointee par la coordonnee ref_pos.x,,ref_pos.y, ou
......
/********************************************************/ /********************************************************/
/* Modification de la place, orient, nombre des MODULES */ /* Modification de la place, orient, nombre des MODULES */
/********************************************************/ /********************************************************/
/* Fichier MODULES.Cpp */ /* Fichier MODULES.Cpp */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -19,643 +19,724 @@ ...@@ -19,643 +19,724 @@
/* fonctions externes */ /* fonctions externes */
/* Fonctions locales */ /* Fonctions locales */
static int ChangeSideMaskLayer(int masque); static int ChangeSideMaskLayer( int masque );
static void Exit_Module(WinEDA_DrawPanel * Panel, wxDC *DC) ; static void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC );
/* Variables locales : */ /* Variables locales : */
static int ModuleInitOrient; // Lors des moves, val init de l'orient (pour annulation) static int ModuleInitOrient; // Lors des moves, val init de l'orient (pour annulation)
static int ModuleInitLayer; // Lors des moves, val init de la couche (pour annulation) static int ModuleInitLayer; // Lors des moves, val init de la couche (pour annulation)
/*************************************************************************/ /*************************************************************************/
void Show_Pads_On_Off(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * module) void Show_Pads_On_Off( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module )
/**************************************************************************/ /**************************************************************************/
/* Fonction appelee lors de l'activation/desactivation de la visualisation /* Fonction appelee lors de l'activation/desactivation de la visualisation
des Pads du module en deplacement * des Pads du module en deplacement
Effacement ou visu des Pads selon conditions initiales * Effacement ou visu des Pads selon conditions initiales
*/ */
{ {
D_PAD* pt_pad; D_PAD* pt_pad;
bool pad_fill_tmp; bool pad_fill_tmp;
if(module == 0 ) return ; if( module == 0 )
return;
pad_fill_tmp = DisplayOpt.DisplayPadFill;
DisplayOpt.DisplayPadFill = FALSE; /* Trace en SKETCH */ pad_fill_tmp = DisplayOpt.DisplayPadFill;
pt_pad = module->m_Pads; DisplayOpt.DisplayPadFill = FALSE; /* Trace en SKETCH */
for( ;pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) pt_pad = module->m_Pads;
{ for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
pt_pad->Draw(panel, DC, g_Offset_Module, GR_XOR) ; {
} pt_pad->Draw( panel, DC, g_Offset_Module, GR_XOR );
DisplayOpt.DisplayPadFill = pad_fill_tmp; }
DisplayOpt.DisplayPadFill = pad_fill_tmp;
} }
/***************************************************************************/ /***************************************************************************/
/* Fonction appelee lors de l'activation/desactivation de la visualisation */ /* Fonction appelee lors de l'activation/desactivation de la visualisation */
/* du rastnest du module en deplacement */ /* du rastnest du module en deplacement */
/* Effacement ou visu du rastnest selon conditions initiales */ /* Effacement ou visu du rastnest selon conditions initiales */
/***************************************************************************/ /***************************************************************************/
void Rastnest_On_Off(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * module) void Rastnest_On_Off( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module )
{ {
WinEDA_BasePcbFrame * frame = (WinEDA_BasePcbFrame *)panel->m_Parent; WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
frame->build_ratsnest_module(DC, module) ;
frame->trace_ratsnest_module(DC); frame->build_ratsnest_module( DC, module );
frame->trace_ratsnest_module( DC );
} }
/***************************************************/ /***************************************************/
MODULE * WinEDA_BasePcbFrame::GetModuleByName(void) MODULE* WinEDA_BasePcbFrame::GetModuleByName( void )
/***************************************************/ /***************************************************/
/* Get a module name from user and return a pointer to the corresponding module /* Get a module name from user and return a pointer to the corresponding module
*/ */
{ {
wxString modulename; wxString modulename;
MODULE * module = NULL; MODULE* module = NULL;
Get_Message(_("Footprint name:"), modulename, this); Get_Message( _( "Footprint name:" ), modulename, this );
if ( ! modulename.IsEmpty() ) if( !modulename.IsEmpty() )
{ {
module = m_Pcb->m_Modules; module = m_Pcb->m_Modules;
while (module ) while( module )
{ {
if ( module->m_Reference->m_Text.CmpNoCase(modulename) == 0 ) break; if( module->m_Reference->m_Text.CmpNoCase( modulename ) == 0 )
module = module->Next(); break;
} module = module->Next();
} }
return module; }
return module;
} }
/**********************************************************************/ /**********************************************************************/
void WinEDA_PcbFrame::StartMove_Module(MODULE * module, wxDC * DC) void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
/**********************************************************************/ /**********************************************************************/
{ {
if( module == NULL )
if (module == NULL ) return; return;
m_CurrentScreen->m_CurrentItem = module; m_CurrentScreen->m_CurrentItem = module;
m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
module->m_Flags |= IS_MOVED; module->m_Flags |= IS_MOVED;
ModuleInitOrient = module->m_Orient; ModuleInitOrient = module->m_Orient;
ModuleInitLayer = module->m_Layer; ModuleInitLayer = module->m_Layer;
/* Effacement chevelu general si necessaire */ /* Effacement chevelu general si necessaire */
if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); if( g_Show_Ratsnest )
DrawGeneralRatsnest( DC );
if( g_DragSegmentList ) /* Anormal ! */
{ if( g_DragSegmentList ) /* Anormal ! */
EraseDragListe(); {
} EraseDragListe();
}
if( g_Drag_Pistes_On)
{ if( g_Drag_Pistes_On )
Build_Drag_Liste(DrawPanel, DC, module); {
} Build_Drag_Liste( DrawPanel, DC, module );
}
m_Pcb->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
DrawPanel->ManageCurseur = Montre_Position_Empreinte; m_Pcb->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
DrawPanel->ForceCloseManageCurseur = Exit_Module; DrawPanel->ManageCurseur = Montre_Position_Empreinte;
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->ForceCloseManageCurseur = Exit_Module;
DrawPanel->m_AutoPAN_Request = TRUE;
// effacement module a l'ecran:
module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); // effacement module a l'ecran:
// Reaffichage module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE);
// Reaffichage
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
} }
/**************************************************/ /**************************************************/
void Exit_Module(WinEDA_DrawPanel * Panel, wxDC *DC) void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
/***************************************************/ /***************************************************/
/* fonction de sortie de l'application */ /* fonction de sortie de l'application */
{ {
DRAG_SEGM * pt_drag; DRAG_SEGM* pt_drag;
TRACK * pt_segm; TRACK* pt_segm;
MODULE * module; MODULE* module;
WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*)Panel->m_Parent; WinEDA_BasePcbFrame* pcbframe = (WinEDA_BasePcbFrame*) Panel->m_Parent;
module = (MODULE *) pcbframe->m_CurrentScreen->m_CurrentItem; module = (MODULE*) pcbframe->m_CurrentScreen->m_CurrentItem;
pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
if (module) if( module )
{ {
// effacement module a l'ecran: // effacement module a l'ecran:
DrawModuleOutlines(Panel, DC, module); DrawModuleOutlines( Panel, DC, module );
/* restitution de l'empreinte si move ou effacement copie*/ /* restitution de l'empreinte si move ou effacement copie*/
if (module->m_Flags & IS_MOVED ) if( module->m_Flags & IS_MOVED )
{ {
/* Move en cours : remise a l'etat d'origine */ /* Move en cours : remise a l'etat d'origine */
if( g_Drag_Pistes_On) if( g_Drag_Pistes_On )
{ {
/* Effacement des segments dragges */ /* Effacement des segments dragges */
pt_drag = g_DragSegmentList; pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
pt_segm = pt_drag->m_Segm; pt_segm = pt_drag->m_Segm;
pt_segm->Draw(Panel, DC, GR_XOR); pt_segm->Draw( Panel, DC, GR_XOR );
} }
} }
/* Remise en etat d'origine des segments dragges */ /* Remise en etat d'origine des segments dragges */
pt_drag = g_DragSegmentList; pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
pt_segm = pt_drag->m_Segm; pt_segm->SetState(EDIT,OFF); pt_segm = pt_drag->m_Segm; pt_segm->SetState( EDIT, OFF );
pt_drag->SetInitialValues(); pt_drag->SetInitialValues();
pt_segm->Draw(Panel, DC, GR_OR); pt_segm->Draw( Panel, DC, GR_OR );
} }
EraseDragListe();
module->m_Flags = 0; EraseDragListe();
} module->m_Flags = 0;
}
if (module->m_Flags & IS_NEW )
{ if( module->m_Flags & IS_NEW )
DeleteStructure(module); {
module = NULL; DeleteStructure( module );
pcbframe->m_Pcb->m_Status_Pcb = 0 ; module = NULL;
pcbframe->build_liste_pads() ; pcbframe->m_Pcb->m_Status_Pcb = 0;
} pcbframe->build_liste_pads();
} }
}
/* Reaffichage du module a l'ecran */
if ( module ) /* Reaffichage du module a l'ecran */
{ if( module )
if ( ModuleInitOrient != module->m_Orient ) {
pcbframe->Rotate_Module(NULL,module, ModuleInitOrient, FALSE); if( ModuleInitOrient != module->m_Orient )
if( ModuleInitLayer != module->m_Layer ) pcbframe->Rotate_Module( NULL, module, ModuleInitOrient, FALSE );
pcbframe->Change_Side_Module(module, NULL); if( ModuleInitLayer != module->m_Layer )
module->Draw(Panel, DC, wxPoint(0,0), GR_OR); pcbframe->Change_Side_Module( module, NULL );
} module->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR );
g_Drag_Pistes_On = FALSE; }
Panel->ManageCurseur = NULL; g_Drag_Pistes_On = FALSE;
Panel->ForceCloseManageCurseur = NULL; Panel->ManageCurseur = NULL;
pcbframe->m_CurrentScreen->m_CurrentItem = NULL; Panel->ForceCloseManageCurseur = NULL;
pcbframe->m_CurrentScreen->m_CurrentItem = NULL;
} }
/**********************************************************/ /**********************************************************/
MODULE * WinEDA_BasePcbFrame::Copie_Module(MODULE * module) MODULE* WinEDA_BasePcbFrame::Copie_Module( MODULE* module )
/**********************************************************/ /**********************************************************/
/* copie le module "module" en position courante */ /* copie le module "module" en position courante */
{ {
MODULE * newmodule; MODULE* newmodule;
if (module == NULL ) return NULL; if( module == NULL )
return NULL;
m_CurrentScreen->SetModify(); m_CurrentScreen->SetModify();
/* Duplication du module */ /* Duplication du module */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
newmodule = new MODULE(m_Pcb); newmodule = new MODULE( m_Pcb );
newmodule->Copy(module); newmodule->Copy( module );
newmodule->m_Parent = m_Pcb; newmodule->m_Parent = m_Pcb;
newmodule->AddToChain(module); newmodule->AddToChain( module );
newmodule->m_Flags = IS_NEW; newmodule->m_Flags = IS_NEW;
build_liste_pads(); build_liste_pads();
newmodule->Display_Infos(this); newmodule->Display_Infos( this );
m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
return newmodule; return newmodule;
} }
/**********************************************************************************/ /**********************************************************************************/
void Montre_Position_Empreinte(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) void Montre_Position_Empreinte( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/**********************************************************************************/ /**********************************************************************************/
/* redessin du contour de l'empreinte lors des deplacements de la souris /* redessin du contour de l'empreinte lors des deplacements de la souris
*/ */
{ {
MODULE * module = (MODULE *) panel->m_Parent->m_CurrentScreen->m_CurrentItem; MODULE* module = (MODULE*) panel->m_Parent->m_CurrentScreen->m_CurrentItem;
if ( module == NULL ) return; if( module == NULL )
return;
/* efface ancienne position */ /* efface ancienne position */
if( erase ) if( erase )
{ {
DrawModuleOutlines(panel, DC, module); DrawModuleOutlines( panel, DC, module );
} }
/* Redessine le module a la nouvelle place */ /* Redessine le module a la nouvelle place */
g_Offset_Module.x = module->m_Pos.x - panel->m_Parent->m_CurrentScreen->m_Curseur.x; g_Offset_Module.x = module->m_Pos.x - panel->m_Parent->m_CurrentScreen->m_Curseur.x;
g_Offset_Module.y = module->m_Pos.y - panel->m_Parent->m_CurrentScreen->m_Curseur.y; g_Offset_Module.y = module->m_Pos.y - panel->m_Parent->m_CurrentScreen->m_Curseur.y;
DrawModuleOutlines(panel, DC, module); DrawModuleOutlines( panel, DC, module );
Dessine_Segments_Dragges(panel, DC); Dessine_Segments_Dragges( panel, DC );
} }
/**************************************************************/ /**************************************************************/
bool WinEDA_PcbFrame::Delete_Module(MODULE * module, wxDC * DC) bool WinEDA_PcbFrame::Delete_Module( MODULE* module, wxDC* DC )
/**************************************************************/ /**************************************************************/
/* /*
Commande Delete Module : * Commande Delete Module :
Suppression d'une empreinte * Suppression d'une empreinte
les pointeurs divers sont mis a jour * les pointeurs divers sont mis a jour
*/ */
{ {
EDA_BaseStruct * PtBack, *PtNext; EDA_BaseStruct* PtBack, * PtNext;
wxString msg; wxString msg;
/* Si l'empreinte est selectee , on ne peut pas l'effacer ! */
if ( module == NULL ) return FALSE; /* Si l'empreinte est selectee , on ne peut pas l'effacer ! */
if( module == NULL )
/* Confirmation de l'effacement */ return FALSE;
module->Display_Infos(this);
/* Confirmation de l'effacement */
msg << _("Delete Module") << wxT(" ") << module->m_Reference->m_Text module->Display_Infos( this );
<< wxT(" (") << _("Value ") << module->m_Value->m_Text
<< wxT(") ?"); msg << _( "Delete Module" ) << wxT( " " ) << module->m_Reference->m_Text
if( !IsOK(this, msg ) ) << wxT( " (" ) << _( "Value " ) << module->m_Value->m_Text
{ << wxT( ") ?" );
return FALSE; if( !IsOK( this, msg ) )
} {
return FALSE;
m_CurrentScreen->SetModify(); }
/* Erase rastnest if needed */ m_CurrentScreen->SetModify();
if(g_Show_Ratsnest) DrawGeneralRatsnest(DC);
/* Erase rastnest if needed */
/* Effacement du module a l'ecran */ if( g_Show_Ratsnest )
if ( DC ) module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); DrawGeneralRatsnest( DC );
/* Suppression du chainage */ /* Effacement du module a l'ecran */
PtBack = module->Pback; if( DC )
PtNext = module->Pnext; module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
if( PtBack == (EDA_BaseStruct*) m_Pcb )
{ /* Suppression du chainage */
m_Pcb->m_Modules = (MODULE*)PtNext; PtBack = module->Pback;
} PtNext = module->Pnext;
else if( PtBack == (EDA_BaseStruct*) m_Pcb )
{ {
PtBack->Pnext = PtNext; m_Pcb->m_Modules = (MODULE*) PtNext;
} }
if(PtNext) PtNext->Pback = PtBack; else
{
/* Sauvegarde en buffer des undelete */ PtBack->Pnext = PtNext;
SaveItemEfface( module, 1); }
if( PtNext )
m_Pcb->m_Status_Pcb = 0 ; PtNext->Pback = PtBack;
build_liste_pads() ;
ReCompile_Ratsnest_After_Changes( DC ); /* Sauvegarde en buffer des undelete */
return TRUE; SaveItemEfface( module, 1 );
m_Pcb->m_Status_Pcb = 0;
build_liste_pads();
ReCompile_Ratsnest_After_Changes( DC );
return TRUE;
} }
/**********************************************************************/ /**********************************************************************/
void WinEDA_BasePcbFrame::Change_Side_Module(MODULE * Module, wxDC * DC) void WinEDA_BasePcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC )
/**********************************************************************/ /**********************************************************************/
/* Change de cote un composant : il y a inversion MIROIR autour de l'axe X /* Change de cote un composant : il y a inversion MIROIR autour de l'axe X
Le changement n'est fait que si la couche est * Le changement n'est fait que si la couche est
- CUIVRE ou CMP * - CUIVRE ou CMP
Si DC == NULL, il n'y a pas de redessin du composant et du chevelu * Si DC == NULL, il n'y a pas de redessin du composant et du chevelu
*/ */
{ {
D_PAD* pt_pad ; D_PAD* pt_pad;
TEXTE_MODULE* pt_texte; TEXTE_MODULE* pt_texte;
EDGE_MODULE * pt_edgmod ; EDGE_MODULE* pt_edgmod;
EDA_BaseStruct * PtStruct; EDA_BaseStruct* PtStruct;
if ( Module == NULL ) return; if( Module == NULL )
if( (Module->m_Layer != CMP_N) && (Module->m_Layer != CUIVRE_N) ) return; return;
if( (Module->m_Layer != CMP_N) && (Module->m_Layer != CUIVRE_N) )
m_CurrentScreen->SetModify(); return;
if ( ! (Module->m_Flags & IS_MOVED) ) m_CurrentScreen->SetModify();
{
m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); if( !(Module->m_Flags & IS_MOVED) )
if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); {
m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
/* Effacement chevelu general si necessaire */ if( DC )
if ( DC && g_Show_Ratsnest) DrawGeneralRatsnest(DC); Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Init des variables utilisees dans la routine Dessine_Drag_segment() */
g_Offset_Module.x = 0; /* Effacement chevelu general si necessaire */
g_Offset_Module.y = 0; if( DC && g_Show_Ratsnest )
} DrawGeneralRatsnest( DC );
else // Module en deplacement /* Init des variables utilisees dans la routine Dessine_Drag_segment() */
{ g_Offset_Module.x = 0;
/* efface empreinte ( vue en contours) si elle a ete deja dessinee */ g_Offset_Module.y = 0;
if ( DC ) }
{ else // Module en deplacement
DrawModuleOutlines(DrawPanel, DC, Module); {
Dessine_Segments_Dragges(DrawPanel, DC); /* efface empreinte ( vue en contours) si elle a ete deja dessinee */
} if( DC )
} {
DrawModuleOutlines( DrawPanel, DC, Module );
/* mise a jour du Flag de l'empreinte et des couches des contours et textes */ Dessine_Segments_Dragges( DrawPanel, DC );
Module->m_Layer = ChangeSideNumLayer(Module->m_Layer); }
}
/* Inversion miroir de l'orientation */
Module->m_Orient = - Module->m_Orient; /* mise a jour du Flag de l'empreinte et des couches des contours et textes */
NORMALIZE_ANGLE_POS(Module->m_Orient); Module->m_Layer = ChangeSideNumLayer( Module->m_Layer );
/* Inversion miroir + layers des pastilles */ /* Inversion miroir de l'orientation */
pt_pad = Module->m_Pads; Module->m_Orient = -Module->m_Orient;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) NORMALIZE_ANGLE_POS( Module->m_Orient );
{
pt_pad->m_Pos.y -= Module->m_Pos.y ; /* Inversion miroir + layers des pastilles */
pt_pad->m_Pos.y = -pt_pad->m_Pos.y; pt_pad = Module->m_Pads;
pt_pad->m_Pos.y += Module->m_Pos.y; for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
pt_pad->m_Pos0.y = - pt_pad->m_Pos0.y; {
pt_pad->m_Offset.y = -pt_pad->m_Offset.y; pt_pad->m_Pos.y -= Module->m_Pos.y;
pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y; pt_pad->m_Pos.y = -pt_pad->m_Pos.y;
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_pad->m_Orient); pt_pad->m_Pos.y += Module->m_Pos.y;
/* change cote pour pastilles surfaciques */ pt_pad->m_Pos0.y = -pt_pad->m_Pos0.y;
pt_pad->m_Masque_Layer = ChangeSideMaskLayer(pt_pad->m_Masque_Layer); pt_pad->m_Offset.y = -pt_pad->m_Offset.y;
} pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient );
/* Inversion miroir de la Reference et mise en miroir : */
pt_texte = Module->m_Reference; /* change cote pour pastilles surfaciques */
pt_texte->m_Pos.y -= Module->m_Pos.y; pt_pad->m_Masque_Layer = ChangeSideMaskLayer( pt_pad->m_Masque_Layer );
pt_texte->m_Pos.y = -pt_texte->m_Pos.y; }
pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; /* Inversion miroir de la Reference et mise en miroir : */
pt_texte->m_Miroir = 1 ; pt_texte = Module->m_Reference;
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); pt_texte->m_Pos.y -= Module->m_Pos.y;
pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); pt_texte->m_Pos.y += Module->m_Pos.y;
if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; pt_texte->m_Pos0.y = pt_texte->m_Pos0.y;
if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; pt_texte->m_Miroir = 1;
if( (Module->m_Layer == SILKSCREEN_N_CU) || NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) pt_texte->m_Layer = Module->m_Layer;
pt_texte->m_Miroir = 0 ; pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer );
/* Inversion miroir de la Valeur et mise en miroir : */ if( Module->m_Layer == CUIVRE_N )
pt_texte = Module->m_Value; pt_texte->m_Layer = SILKSCREEN_N_CU;
pt_texte->m_Pos.y -= Module->m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y; if( Module->m_Layer == CMP_N )
pt_texte->m_Pos.y += Module->m_Pos.y; pt_texte->m_Layer = SILKSCREEN_N_CMP;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y;
pt_texte->m_Miroir = 1 ; if( (Module->m_Layer == SILKSCREEN_N_CU)
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Miroir = 0;
pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer);
if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; /* Inversion miroir de la Valeur et mise en miroir : */
if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; pt_texte = Module->m_Value;
if( (Module->m_Layer == SILKSCREEN_N_CU) || pt_texte->m_Pos.y -= Module->m_Pos.y;
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Miroir = 0 ; pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y;
/* Inversion miroir des dessins de l'empreinte : */ pt_texte->m_Miroir = 1;
PtStruct = Module->m_Drawings; NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) pt_texte->m_Layer = Module->m_Layer;
{ pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer );
switch( PtStruct->m_StructType)
{ if( Module->m_Layer == CUIVRE_N )
case TYPEEDGEMODULE: pt_texte->m_Layer = SILKSCREEN_N_CU;
pt_edgmod = (EDGE_MODULE *) PtStruct;
pt_edgmod->m_Start.y -= Module->m_Pos.y; if( Module->m_Layer == CMP_N )
pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y ; pt_texte->m_Layer = SILKSCREEN_N_CMP;
pt_edgmod->m_Start.y += Module->m_Pos.y;
pt_edgmod->m_End.y -= Module->m_Pos.y; if( (Module->m_Layer == SILKSCREEN_N_CU)
pt_edgmod->m_End.y = -pt_edgmod->m_End.y ; || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
pt_edgmod->m_End.y += Module->m_Pos.y; pt_texte->m_Miroir = 0;
/* inversion des coords locales */
pt_edgmod->m_Start0.y = -pt_edgmod->m_Start0.y; /* Inversion miroir des dessins de l'empreinte : */
pt_edgmod->m_End0.y = -pt_edgmod->m_End0.y; PtStruct = Module->m_Drawings;
if ( pt_edgmod->m_Shape == S_ARC ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
pt_edgmod->m_Angle = - pt_edgmod->m_Angle; switch( PtStruct->m_StructType )
} {
case TYPEEDGEMODULE:
pt_edgmod->m_Layer = ChangeSideNumLayer(pt_edgmod->m_Layer); pt_edgmod = (EDGE_MODULE*) PtStruct;
break; pt_edgmod->m_Start.y -= Module->m_Pos.y;
pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y;
case TYPETEXTEMODULE: pt_edgmod->m_Start.y += Module->m_Pos.y;
/* Inversion miroir de la position et mise en miroir : */ pt_edgmod->m_End.y -= Module->m_Pos.y;
pt_texte = (TEXTE_MODULE*)PtStruct; pt_edgmod->m_End.y = -pt_edgmod->m_End.y;
pt_texte->m_Pos.y -= Module->m_Pos.y; pt_edgmod->m_End.y += Module->m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y; /* inversion des coords locales */
pt_texte->m_Pos.y += Module->m_Pos.y; pt_edgmod->m_Start0.y = -pt_edgmod->m_Start0.y;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_edgmod->m_End0.y = -pt_edgmod->m_End0.y;
pt_texte->m_Miroir = 1 ; if( pt_edgmod->m_Shape == S_ARC )
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); {
pt_edgmod->m_Angle = -pt_edgmod->m_Angle;
pt_texte->m_Layer = Module->m_Layer; }
pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer);
if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; pt_edgmod->m_Layer = ChangeSideNumLayer( pt_edgmod->m_Layer );
if(Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; break;
if((Module->m_Layer == SILKSCREEN_N_CU) ||
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N)) case TYPETEXTEMODULE:
pt_texte->m_Miroir = 0 ; /* Inversion miroir de la position et mise en miroir : */
pt_texte = (TEXTE_MODULE*) PtStruct;
break; pt_texte->m_Pos.y -= Module->m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
default: DisplayError(this, wxT("Unknown Draw Type")); break; pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y;
} pt_texte->m_Miroir = 1;
} NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
/* calcul du rectangle d'encadrement */ pt_texte->m_Layer = Module->m_Layer;
Module->Set_Rectangle_Encadrement(); pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer );
Module->Display_Infos(this); if( Module->m_Layer == CUIVRE_N )
pt_texte->m_Layer = SILKSCREEN_N_CU;
if( !(Module->m_Flags & IS_MOVED) ) /* Inversion simple */
{ if( Module->m_Layer == CMP_N )
if ( DC ) pt_texte->m_Layer = SILKSCREEN_N_CMP;
{
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); if( (Module->m_Layer == SILKSCREEN_N_CU)
/* affichage chevelu general si necessaire */ || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
ReCompile_Ratsnest_After_Changes( DC ); pt_texte->m_Miroir = 0;
}
} break;
else default:
{ DisplayError( this, wxT( "Unknown Draw Type" ) ); break;
if ( DC ) }
{ }
DrawModuleOutlines(DrawPanel, DC, Module);
Dessine_Segments_Dragges(DrawPanel, DC); /* calcul du rectangle d'encadrement */
} Module->Set_Rectangle_Encadrement();
m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
} Module->Display_Infos( this );
if( !(Module->m_Flags & IS_MOVED) ) /* Inversion simple */
{
if( DC )
{
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
/* affichage chevelu general si necessaire */
ReCompile_Ratsnest_After_Changes( DC );
}
}
else
{
if( DC )
{
DrawModuleOutlines( DrawPanel, DC, Module );
Dessine_Segments_Dragges( DrawPanel, DC );
}
m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
}
} }
/*********************************************/ /*********************************************/
static int ChangeSideMaskLayer(int masque) static int ChangeSideMaskLayer( int masque )
/*********************************************/ /*********************************************/
/* Routine de recalcul du masque-layer lors des /* Routine de recalcul du masque-layer lors des
echanges cote cu/cmp pour les couches CU/CMP specialisees * echanges cote cu/cmp pour les couches CU/CMP specialisees
(cuivre, serigr., pate , soudure) * (cuivre, serigr., pate , soudure)
*/ */
{ {
int newmasque; int newmasque;
newmasque = masque & ~(CUIVRE_LAYER | CMP_LAYER | newmasque = masque & ~(CUIVRE_LAYER | CMP_LAYER |
SILKSCREEN_LAYER_CU | SILKSCREEN_LAYER_CMP | SILKSCREEN_LAYER_CU | SILKSCREEN_LAYER_CMP |
ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP | ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP |
SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP | SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP |
SOLDERPASTE_LAYER_CU | SOLDERPASTE_LAYER_CMP | SOLDERPASTE_LAYER_CU | SOLDERPASTE_LAYER_CMP |
ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP); ADHESIVE_LAYER_CU | ADHESIVE_LAYER_CMP);
if( masque & CUIVRE_LAYER )
newmasque |= CMP_LAYER;
if( masque & CMP_LAYER )
newmasque |= CUIVRE_LAYER;
if( masque & SILKSCREEN_LAYER_CU )
newmasque |= SILKSCREEN_LAYER_CMP;
if( masque & SILKSCREEN_LAYER_CMP )
newmasque |= SILKSCREEN_LAYER_CU;
if( masque & ADHESIVE_LAYER_CU )
newmasque |= ADHESIVE_LAYER_CMP;
if( masque & ADHESIVE_LAYER_CMP )
newmasque |= ADHESIVE_LAYER_CU;
if( masque & SOLDERMASK_LAYER_CU )
newmasque |= SOLDERMASK_LAYER_CMP;
if( masque & SOLDERMASK_LAYER_CMP )
newmasque |= SOLDERMASK_LAYER_CU;
if( masque & SOLDERPASTE_LAYER_CU )
newmasque |= SOLDERPASTE_LAYER_CMP;
if( masque & SOLDERPASTE_LAYER_CMP )
newmasque |= SOLDERPASTE_LAYER_CU;
if( masque & ADHESIVE_LAYER_CU )
newmasque |= ADHESIVE_LAYER_CMP;
if( masque & ADHESIVE_LAYER_CMP )
newmasque |= ADHESIVE_LAYER_CU;
return newmasque;
}
if( masque & CUIVRE_LAYER) newmasque |= CMP_LAYER;
if( masque & CMP_LAYER) newmasque |= CUIVRE_LAYER;
if( masque & SILKSCREEN_LAYER_CU) newmasque |= SILKSCREEN_LAYER_CMP; /*************************************/
if( masque & SILKSCREEN_LAYER_CMP) newmasque |= SILKSCREEN_LAYER_CU; int ChangeSideNumLayer( int oldlayer )
/*************************************/
if( masque & ADHESIVE_LAYER_CU) newmasque |= ADHESIVE_LAYER_CMP; /* Routine de recalcul du numero de couche lors des
if( masque & ADHESIVE_LAYER_CMP) newmasque |= ADHESIVE_LAYER_CU; * echanges cote cu/cmp pour les couches CU/CMP specialisees
* (cuivre, serigr., pate , soudure)
*/
{
int newlayer;
if( masque & SOLDERMASK_LAYER_CU) newmasque |= SOLDERMASK_LAYER_CMP; switch( oldlayer )
if( masque & SOLDERMASK_LAYER_CMP) newmasque |= SOLDERMASK_LAYER_CU; {
case CUIVRE_N:
newlayer = CMP_N; break;
if( masque & SOLDERPASTE_LAYER_CU) newmasque |= SOLDERPASTE_LAYER_CMP; case CMP_N:
if( masque & SOLDERPASTE_LAYER_CMP) newmasque |= SOLDERPASTE_LAYER_CU; newlayer = CUIVRE_N; break;
if( masque & ADHESIVE_LAYER_CU) newmasque |= ADHESIVE_LAYER_CMP; case SILKSCREEN_N_CU:
if( masque & ADHESIVE_LAYER_CMP) newmasque |= ADHESIVE_LAYER_CU; newlayer = SILKSCREEN_N_CMP; break;
return(newmasque); case SILKSCREEN_N_CMP:
} newlayer = SILKSCREEN_N_CU; break;
case ADHESIVE_N_CU:
newlayer = ADHESIVE_N_CMP; break;
/*************************************/ case ADHESIVE_N_CMP:
int ChangeSideNumLayer(int oldlayer) newlayer = ADHESIVE_N_CU; break;
/*************************************/
/* Routine de recalcul du numero de couche lors des
echanges cote cu/cmp pour les couches CU/CMP specialisees
(cuivre, serigr., pate , soudure)
*/
{
int newlayer;
switch ( oldlayer ) case SOLDERMASK_N_CU:
{ newlayer = SOLDERMASK_N_CMP; break;
case CUIVRE_N: newlayer = CMP_N; break;
case CMP_N: newlayer = CUIVRE_N; break;
case SILKSCREEN_N_CU: newlayer = SILKSCREEN_N_CMP; break; case SOLDERMASK_N_CMP:
case SILKSCREEN_N_CMP: newlayer = SILKSCREEN_N_CU; break; newlayer = SOLDERMASK_N_CU; break;
case ADHESIVE_N_CU: newlayer = ADHESIVE_N_CMP; break; case SOLDERPASTE_N_CU:
case ADHESIVE_N_CMP: newlayer = ADHESIVE_N_CU; break; newlayer = SOLDERPASTE_N_CMP; break;
case SOLDERMASK_N_CU: newlayer = SOLDERMASK_N_CMP; break; case SOLDERPASTE_N_CMP:
case SOLDERMASK_N_CMP: newlayer = SOLDERMASK_N_CU; break; newlayer = SOLDERPASTE_N_CU; break;
case SOLDERPASTE_N_CU: newlayer = SOLDERPASTE_N_CMP; break; default:
case SOLDERPASTE_N_CMP: newlayer = SOLDERPASTE_N_CU; break; newlayer = oldlayer;
}
default: newlayer = oldlayer; return newlayer;
}
return(newlayer);
} }
/*****************************************************************/ /*****************************************************************/
void WinEDA_BasePcbFrame::Place_Module(MODULE * module, wxDC * DC) void WinEDA_BasePcbFrame::Place_Module( MODULE* module, wxDC* DC )
/*****************************************************************/ /*****************************************************************/
/* Place a l'endroit pointe par la souris le module deja existant selectionne /* Place a l'endroit pointe par la souris le module deja existant selectionne
auparavant. * auparavant.
Entree: module = num du module a replacer * Entree: module = num du module a replacer
DC ( si NULL: pas d'affichage a l'cran * DC ( si NULL: pas d'affichage a l'�ran
Sortie : * Sortie :
mise a jour des nouvelles coord des differents elements du module * mise a jour des nouvelles coord des differents elements du module
affichage a l'ecran du module * affichage a l'ecran du module
*/ */
{ {
TRACK * pt_segm; TRACK* pt_segm;
DRAG_SEGM * pt_drag; DRAG_SEGM* pt_drag;
wxPoint newpos; wxPoint newpos;
if ( module == 0 ) return ; if( module == 0 )
return;
m_CurrentScreen->SetModify();
m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); m_CurrentScreen->SetModify();
m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
if(g_Show_Module_Ratsnest && (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) && DC)
trace_ratsnest_module(DC); if( g_Show_Module_Ratsnest && (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) && DC )
trace_ratsnest_module( DC );
newpos = m_CurrentScreen->m_Curseur;
newpos = m_CurrentScreen->m_Curseur;
module->SetPosition(newpos);
if ( DC ) module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); module->SetPosition( newpos );
if( DC )
/* Tracage des segments dragges et liberation memoire */ module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
if( g_DragSegmentList )
{ /* Tracage des segments dragges et liberation memoire */
pt_drag = g_DragSegmentList; if( g_DragSegmentList )
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) {
{ pt_drag = g_DragSegmentList;
pt_segm = pt_drag->m_Segm; for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
pt_segm->SetState(EDIT,OFF); {
if ( DC ) pt_segm->Draw(DrawPanel, DC, GR_OR); pt_segm = pt_drag->m_Segm;
} pt_segm->SetState( EDIT, OFF );
EraseDragListe(); if( DC )
} pt_segm->Draw( DrawPanel, DC, GR_OR );
}
/* affichage chevelu general si necessaire */
ReCompile_Ratsnest_After_Changes( DC ); EraseDragListe();
}
module->Display_Infos(this);
/* affichage chevelu general si necessaire */
DrawPanel->ManageCurseur = NULL; ReCompile_Ratsnest_After_Changes( DC );
DrawPanel->ForceCloseManageCurseur = NULL;
module->m_Flags = 0; module->Display_Infos( this );
g_Drag_Pistes_On = FALSE;
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
module->m_Flags = 0;
g_Drag_Pistes_On = FALSE;
} }
/***********************************************************************/ /***********************************************************************/
void WinEDA_BasePcbFrame::Rotate_Module(wxDC * DC, MODULE * module, void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
int angle, bool incremental) int angle, bool incremental )
/***********************************************************************/ /***********************************************************************/
/* /*
Fait tourner l'empreinte de angle degres, dans le sens < 0. * Fait tourner l'empreinte de angle degres, dans le sens < 0.
Si incremental == TRUE, la rotation est faite a partir de la derniere orientation, * Si incremental == TRUE, la rotation est faite a partir de la derniere orientation,
sinon le module est mis dans l'orientation absolue angle. * sinon le module est mis dans l'orientation absolue angle.
Si DC == NULL, le composant n'est pas redessine. * Si DC == NULL, le composant n'est pas redessine.
Sinon, il est efface, tourne et redessine * Sinon, il est efface, tourne et redessine
*/ */
{ {
if ( module == NULL ) return; if( module == NULL )
return;
m_CurrentScreen->SetModify();
m_CurrentScreen->SetModify();
/* efface ancienne position */
if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */ /* efface ancienne position */
{ if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */
if ( DC ) {
{ if( DC )
module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); {
/* Reaffichage chevelu general si necessaire */ module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); /* Reaffichage chevelu general si necessaire */
} if( g_Show_Ratsnest )
} DrawGeneralRatsnest( DC );
else }
{ }
/* reaffiche module en mouvement */ else
if ( DC ) {
{ /* reaffiche module en mouvement */
DrawModuleOutlines(DrawPanel, DC, module); if( DC )
Dessine_Segments_Dragges(DrawPanel, DC); {
} DrawModuleOutlines( DrawPanel, DC, module );
} Dessine_Segments_Dragges( DrawPanel, DC );
}
m_Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CONNEXION_OK); }
if ( incremental ) m_Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CONNEXION_OK);
module->SetOrientation(module->m_Orient + angle);
else if( incremental )
module->SetOrientation(angle); module->SetOrientation( module->m_Orient + angle );
else
module->Display_Infos(this); module->SetOrientation( angle );
if ( DC ) module->Display_Infos( this );
{
if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */ if( DC )
{ {
module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */
/* Reaffichage chevelu general si necessaire */ {
ReCompile_Ratsnest_After_Changes( DC ); module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
} /* Reaffichage chevelu general si necessaire */
else ReCompile_Ratsnest_After_Changes( DC );
{ }
/* reaffiche module en mouvement */ else
DrawModuleOutlines(DrawPanel, DC, module); {
Dessine_Segments_Dragges(DrawPanel, DC); /* reaffiche module en mouvement */
} DrawModuleOutlines( DrawPanel, DC, module );
} Dessine_Segments_Dragges( DrawPanel, DC );
}
}
} }
...@@ -663,33 +744,33 @@ void WinEDA_BasePcbFrame::Rotate_Module(wxDC * DC, MODULE * module, ...@@ -663,33 +744,33 @@ void WinEDA_BasePcbFrame::Rotate_Module(wxDC * DC, MODULE * module,
/* Redessine en mode XOR la silouhette du module */ /* Redessine en mode XOR la silouhette du module */
/*************************************************/ /*************************************************/
void DrawModuleOutlines(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * module) void DrawModuleOutlines( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module )
{ {
int pad_fill_tmp; int pad_fill_tmp;
D_PAD* pt_pad; D_PAD* pt_pad;
if(module == NULL) return ; if( module == NULL )
module->DrawEdgesOnly(panel, DC, g_Offset_Module, GR_XOR); return;
module->DrawEdgesOnly( panel, DC, g_Offset_Module, GR_XOR );
if(g_Show_Pads_Module_in_Move)
{ if( g_Show_Pads_Module_in_Move )
pad_fill_tmp = DisplayOpt.DisplayPadFill; {
DisplayOpt.DisplayPadFill = SKETCH; /* Trace en SKETCH en deplacement */ pad_fill_tmp = DisplayOpt.DisplayPadFill;
DisplayOpt.DisplayPadFill = SKETCH; /* Trace en SKETCH en deplacement */
pt_pad = module->m_Pads;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext) pt_pad = module->m_Pads;
{ for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
pt_pad->Draw(panel, DC, g_Offset_Module, GR_XOR); {
} pt_pad->Draw( panel, DC, g_Offset_Module, GR_XOR );
DisplayOpt.DisplayPadFill = pad_fill_tmp; }
}
DisplayOpt.DisplayPadFill = pad_fill_tmp;
if(g_Show_Module_Ratsnest && panel) }
{
WinEDA_BasePcbFrame * frame = (WinEDA_BasePcbFrame * ) panel->m_Parent; if( g_Show_Module_Ratsnest && panel )
frame->build_ratsnest_module(DC, module); {
frame->trace_ratsnest_module(DC); WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
} frame->build_ratsnest_module( DC, module );
frame->trace_ratsnest_module( DC );
}
} }
/****************************************************/ /****************************************************/
/* Edition des pistes */ /* Edition des pistes */
/* Routines de duplication et deplacement de pistes */ /* Routines de duplication et deplacement de pistes */
/****************************************************/ /****************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -17,629 +17,663 @@ ...@@ -17,629 +17,663 @@
/* Routines externes */ /* Routines externes */
static void Show_MoveTrack(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); static void Show_MoveTrack( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Exit_MoveTrack(WinEDA_DrawPanel * Panel, wxDC *DC); static void Exit_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC );
#if 0 #if 0
/* Routines Locales */ /* Routines Locales */
static void Duplic_Track(COMMAND * Cmd); static void Duplic_Track( COMMAND* Cmd );
static void Place_Dupl_Route(COMMAND * Cmd); static void Place_Dupl_Route( COMMAND* Cmd );
#endif #endif
/* variables locales */ /* variables locales */
static wxPoint PosInit, LastPos; static wxPoint PosInit, LastPos;
static TRACK * NewTrack; /* Nouvelle piste creee ou piste deplacee */ static TRACK* NewTrack; /* Nouvelle piste creee ou piste deplacee */
static int NbPtNewTrack; static int NbPtNewTrack;
static int Old_HightLigth_NetCode; static int Old_HightLigth_NetCode;
static bool Old_HightLigt_Status; static bool Old_HightLigt_Status;
/**************************************************************/ /**************************************************************/
static void Exit_MoveTrack(WinEDA_DrawPanel * Panel, wxDC *DC) static void Exit_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
/***************************************************************/ /***************************************************************/
/* routine d'annulation de la commande drag, copy ou move track si une piste est en cours /* routine d'annulation de la commande drag, copy ou move track si une piste est en cours
de tracage, ou de sortie de l'application EDITRACK. * de tracage, ou de sortie de l'application EDITRACK.
Appel par la touche ESC * Appel par la touche ESC
*/ */
{ {
TRACK * NextS; TRACK* NextS;
int ii; int ii;
/* Effacement du trace en cours */ /* Effacement du trace en cours */
wxPoint oldpos = Panel->GetScreen()->m_Curseur; wxPoint oldpos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = PosInit;
Panel->ManageCurseur(Panel, DC, TRUE); Panel->GetScreen()->m_Curseur = PosInit;
Panel->GetScreen()->m_Curseur = oldpos; Panel->ManageCurseur( Panel, DC, TRUE );
g_HightLigt_Status = FALSE; Panel->GetScreen()->m_Curseur = oldpos;
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; g_HightLigt_Status = FALSE;
( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
if( NewTrack )
{ if( NewTrack )
if (NewTrack->m_Flags & IS_NEW ) {
{ if( NewTrack->m_Flags & IS_NEW )
for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS) {
{ for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS )
if(NewTrack == NULL) break; {
NextS = (TRACK*) NewTrack->Pnext; if( NewTrack == NULL )
delete NewTrack; break;
} NextS = (TRACK*) NewTrack->Pnext;
} delete NewTrack;
else /* Move : remise en ancienne position */ }
{ }
TRACK * Track = NewTrack; else /* Move : remise en ancienne position */
int dx = LastPos.x - PosInit.x; {
int dy = LastPos.y - PosInit.y; TRACK* Track = NewTrack;
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) int dx = LastPos.x - PosInit.x;
{ int dy = LastPos.y - PosInit.y;
if( Track == NULL ) break; for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
Track->m_Start.x -= dx; {
Track->m_Start.y -= dy; if( Track == NULL )
Track->m_End.x -= dx; break;
Track->m_End.y -= dy; Track->m_Start.x -= dx;
Track->m_Flags = 0; Track->m_Start.y -= dy;
Track->m_End.x -= dx;
} Track->m_End.y -= dy;
Trace_Une_Piste(Panel, DC, NewTrack,NbPtNewTrack,GR_OR); Track->m_Flags = 0;
} }
NewTrack = NULL; Trace_Une_Piste( Panel, DC, NewTrack, NbPtNewTrack, GR_OR );
} }
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->m_CurrentItem = NULL;
Panel->m_Parent->EraseMsgBox();
/* Annulation deplacement et Redessin des segments dragges */
DRAG_SEGM * pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext)
{
TRACK * Track = pt_drag->m_Segm;
pt_drag->SetInitialValues();
Track->SetState(EDIT,OFF);
Track->m_Flags = 0;
Track->Draw(Panel, DC, GR_OR);
}
g_HightLigth_NetCode = Old_HightLigth_NetCode;
g_HightLigt_Status = Old_HightLigt_Status;
if(g_HightLigt_Status)
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ;
EraseDragListe();
}
NewTrack = NULL;
}
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->m_CurrentItem = NULL;
Panel->m_Parent->EraseMsgBox();
/* Annulation deplacement et Redessin des segments dragges */
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{
TRACK* Track = pt_drag->m_Segm;
pt_drag->SetInitialValues();
Track->SetState( EDIT, OFF );
Track->m_Flags = 0;
Track->Draw( Panel, DC, GR_OR );
}
g_HightLigth_NetCode = Old_HightLigth_NetCode;
g_HightLigt_Status = Old_HightLigt_Status;
if( g_HightLigt_Status )
( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
EraseDragListe();
}
/*************************************************************************/ /*************************************************************************/
static void Show_MoveTrack(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) static void Show_MoveTrack( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************************/ /*************************************************************************/
/* redessin du contour de la piste lors des deplacements de la souris */ /* redessin du contour de la piste lors des deplacements de la souris */
{ {
int ii, dx, dy; int ii, dx, dy;
TRACK * Track; TRACK* Track;
BASE_SCREEN * screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
int track_fill_copy = DisplayOpt.DisplayPcbTrackFill; int track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
DisplayOpt.DisplayPcbTrackFill = SKETCH ; DisplayOpt.DisplayPcbTrackFill = SKETCH;
erase = TRUE; erase = TRUE;
/* efface ancienne position si elle a ete deja dessinee */ /* efface ancienne position si elle a ete deja dessinee */
if( erase ) if( erase )
{ {
if ( NewTrack ) Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,GR_XOR) ; if( NewTrack )
} Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
}
/* mise a jour des coordonnees des segments de la piste */
wxPoint Pos = screen->m_Curseur; /* mise a jour des coordonnees des segments de la piste */
dx = Pos.x - LastPos.x; wxPoint Pos = screen->m_Curseur;
dy = Pos.y - LastPos.y; dx = Pos.x - LastPos.x;
LastPos = Pos; dy = Pos.y - LastPos.y;
ii = NbPtNewTrack, Track = NewTrack; LastPos = Pos;
for( ; ii > 0; ii--, Track = Track->Next() ) ii = NbPtNewTrack, Track = NewTrack;
{ for( ; ii > 0; ii--, Track = Track->Next() )
if( Track->m_Flags & STARTPOINT) {
{ if( Track->m_Flags & STARTPOINT )
Track->m_Start.x += dx; Track->m_Start.y += dy; {
} Track->m_Start.x += dx; Track->m_Start.y += dy;
if( Track->m_Flags & ENDPOINT) }
{ if( Track->m_Flags & ENDPOINT )
Track->m_End.x += dx; Track->m_End.y += dy; {
} Track->m_End.x += dx; Track->m_End.y += dy;
} }
}
/* dessin de la nouvelle piste */
Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,GR_XOR) ; /* dessin de la nouvelle piste */
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
/* Tracage des segments dragges */
DRAG_SEGM * pt_drag = g_DragSegmentList; /* Tracage des segments dragges */
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) DRAG_SEGM* pt_drag = g_DragSegmentList;
{ for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
Track = pt_drag->m_Segm; {
if ( erase ) Track->Draw(panel, DC, GR_XOR); Track = pt_drag->m_Segm;
if( Track->m_Flags & STARTPOINT) if( erase )
{ Track->Draw( panel, DC, GR_XOR );
Track->m_Start.x += dx; Track->m_Start.y += dy; if( Track->m_Flags & STARTPOINT )
} {
if( Track->m_Flags & ENDPOINT) Track->m_Start.x += dx; Track->m_Start.y += dy;
{ }
Track->m_End.x += dx; Track->m_End.y += dy; if( Track->m_Flags & ENDPOINT )
} {
Track->Draw(panel, DC, GR_XOR); Track->m_End.x += dx; Track->m_End.y += dy;
} }
DisplayOpt.DisplayPcbTrackFill = track_fill_copy ; Track->Draw( panel, DC, GR_XOR );
} }
DisplayOpt.DisplayPcbTrackFill = track_fill_copy;
}
/***********************************************************************************/ /***********************************************************************************/
void WinEDA_PcbFrame::Start_MoveOneTrackSegment(TRACK * track, wxDC * DC, bool Drag) void WinEDA_PcbFrame::Start_MoveOneTrackSegment( TRACK* track, wxDC* DC, bool Drag )
/***********************************************************************************/ /***********************************************************************************/
{ {
/* Change hight light net: the new one will be hightlighted */ /* Change hight light net: the new one will be hightlighted */
Old_HightLigt_Status = g_HightLigt_Status; Old_HightLigt_Status = g_HightLigt_Status;
Old_HightLigth_NetCode = g_HightLigth_NetCode; Old_HightLigth_NetCode = g_HightLigth_NetCode;
if(g_HightLigt_Status) Hight_Light(DC); if( g_HightLigt_Status )
Hight_Light( DC );
if ( Drag && track->m_StructType == TYPEVIA)
{ if( Drag && track->m_StructType == TYPEVIA )
track->m_Flags = IS_DRAGGED|STARTPOINT|ENDPOINT; {
Collect_TrackSegmentsToDrag(DrawPanel, DC, track->m_Start, track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT;
track->ReturnMaskLayer(), track->m_NetCode); Collect_TrackSegmentsToDrag( DrawPanel, DC, track->m_Start,
NewTrack = track; track->ReturnMaskLayer(), track->m_NetCode );
NbPtNewTrack = 1; NewTrack = track;
PosInit = track->m_Start; NbPtNewTrack = 1;
} PosInit = track->m_Start;
}
else else
{ {
int diag = track->IsPointOnEnds(GetScreen()->m_Curseur, -1); int diag = track->IsPointOnEnds( GetScreen()->m_Curseur, -1 );
wxPoint pos = (diag & STARTPOINT) ? track->m_Start : track->m_End; wxPoint pos = (diag & STARTPOINT) ? track->m_Start : track->m_End;
Collect_TrackSegmentsToDrag(DrawPanel, DC, pos, Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->ReturnMaskLayer(), track->m_NetCode); track->ReturnMaskLayer(), track->m_NetCode );
track->m_Flags |= IS_DRAGGED; track->m_Flags |= IS_DRAGGED;
NewTrack = NULL; NewTrack = NULL;
NbPtNewTrack = 0; NbPtNewTrack = 0;
PosInit = pos; PosInit = pos;
} }
LastPos = PosInit; LastPos = PosInit;
DrawPanel->ManageCurseur = Show_MoveTrack; DrawPanel->ManageCurseur = Show_MoveTrack;
DrawPanel->ForceCloseManageCurseur = Exit_MoveTrack; DrawPanel->ForceCloseManageCurseur = Exit_MoveTrack;
g_HightLigth_NetCode = track->m_NetCode; g_HightLigth_NetCode = track->m_NetCode;
g_HightLigt_Status = TRUE; g_HightLigt_Status = TRUE;
DrawHightLight( DC, g_HightLigth_NetCode) ; DrawHightLight( DC, g_HightLigth_NetCode );
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
} }
/**********************************************************************/ /**********************************************************************/
bool WinEDA_PcbFrame::PlaceDraggedTrackSegment(TRACK * Track, wxDC * DC) bool WinEDA_PcbFrame::PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC )
/**********************************************************************/ /**********************************************************************/
/* Place a dragged track segment or via */ /* Place a dragged track segment or via */
{ {
int errdrc; int errdrc;
DRAG_SEGM * pt_drag; DRAG_SEGM* pt_drag;
if(Track == NULL ) return FALSE; if( Track == NULL )
return FALSE;
// DRC control:
if(Drc_On) // DRC control:
{ if( Drc_On )
errdrc = Drc(this, DC, Track, m_Pcb->m_Track,1); {
if(errdrc == BAD_DRC) return FALSE; errdrc = Drc( this, DC, Track, m_Pcb->m_Track, 1 );
/* Tracage des segments dragges */ if( errdrc == BAD_DRC )
pt_drag = g_DragSegmentList; return FALSE;
for( ; pt_drag; pt_drag = pt_drag->Pnext) /* Tracage des segments dragges */
{ pt_drag = g_DragSegmentList;
errdrc = Drc(this, DC, pt_drag->m_Segm, m_Pcb->m_Track,1); for( ; pt_drag; pt_drag = pt_drag->Pnext )
if(errdrc == BAD_DRC) return FALSE; {
} errdrc = Drc( this, DC, pt_drag->m_Segm, m_Pcb->m_Track, 1 );
} if( errdrc == BAD_DRC )
return FALSE;
// DRC Ok: place track segments }
Track->m_Flags = 0; }
Track->Draw(DrawPanel, DC, GR_OR);
// DRC Ok: place track segments
/* Tracage des segments dragges */ Track->m_Flags = 0;
pt_drag = g_DragSegmentList; Track->Draw( DrawPanel, DC, GR_OR );
for( ; pt_drag; pt_drag = pt_drag->Pnext)
{ /* Tracage des segments dragges */
Track = pt_drag->m_Segm; pt_drag = g_DragSegmentList;
Track->SetState(EDIT,OFF); for( ; pt_drag; pt_drag = pt_drag->Pnext )
Track->m_Flags = 0; {
Track->Draw(DrawPanel, DC, GR_OR); Track = pt_drag->m_Segm;
} Track->SetState( EDIT, OFF );
EraseDragListe(); Track->m_Flags = 0;
Track->Draw( DrawPanel, DC, GR_OR );
GetScreen()->SetModify(); }
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; EraseDragListe();
return TRUE; GetScreen()->SetModify();
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
return TRUE;
} }
#if 0 #if 0
/***********************************************/ /***********************************************/
void WinEDA_PcbFrame::Place_Dupl_Route(Track * Track, wxDC * DC) void WinEDA_PcbFrame::Place_Dupl_Route( Track* Track, wxDC* DC )
/******************************************/ /******************************************/
/* /*
Routine de placement d'une piste (succession de segments) * Routine de placement d'une piste (succession de segments)
*/ */
{ {
D_PAD * pt_pad; D_PAD* pt_pad;
TRACK * pt_track, *Track, * pt_classe, *NextS; TRACK* pt_track, * Track, * pt_classe, * NextS;
int masquelayer; int masquelayer;
EDA_BaseStruct * LockPoint; EDA_BaseStruct* LockPoint;
int ii, old_net_code, new_net_code, DRC_error = 0; int ii, old_net_code, new_net_code, DRC_error = 0;
wxDC * DC = Cmd->DC; wxDC* DC = Cmd->DC;
ActiveDrawPanel->ManageCurseur = NULL; ActiveDrawPanel->ManageCurseur = NULL;
if( NewTrack == NULL ) return ; if( NewTrack == NULL )
return;
old_net_code = NewTrack->net_code;
old_net_code = NewTrack->net_code;
/* Placement du flag BUSY de la piste originelle, qui ne doit
pas etre vue dans les recherches de raccordement suivantes */ /* Placement du flag BUSY de la piste originelle, qui ne doit
ii = NbPtNewTrack; pt_track = NewTrack; * pas etre vue dans les recherches de raccordement suivantes */
for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) ii = NbPtNewTrack; pt_track = NewTrack;
{ for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
pt_track->SetState(BUSY, ON); {
} pt_track->SetState( BUSY, ON );
}
/* Detection du nouveau net_code */
ii = NbPtNewTrack; pt_track = NewTrack; /* Detection du nouveau net_code */
for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) ii = NbPtNewTrack; pt_track = NewTrack;
{ for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
pt_track->net_code = 0; {
} pt_track->net_code = 0;
}
new_net_code = 0;
ii = 0; pt_track = NewTrack; new_net_code = 0;
for( ; ii < NbPtNewTrack ; ii++, pt_track = (TRACK*)pt_track->Pnext) ii = 0; pt_track = NewTrack;
{ for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*) pt_track->Pnext )
/* Localisation de la pastille ou segment en debut de segment: */ {
masquelayer = tab_layer[pt_track->Layer]; /* Localisation de la pastille ou segment en debut de segment: */
LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer); masquelayer = tab_layer[pt_track->Layer];
if( LockPoint ) LockPoint = LocateLockPoint( pt_track->m_Start.x, pt_track->m_Start.y, masquelayer );
{ if( LockPoint )
if ( LockPoint->m_StructType == TYPEPAD ) {
{ if( LockPoint->m_StructType == TYPEPAD )
pt_pad = (D_PAD*) LockPoint; {
new_net_code = pt_pad->net_code; pt_pad = (D_PAD*) LockPoint;
if ( new_net_code > 0 ) break; new_net_code = pt_pad->net_code;
} if( new_net_code > 0 )
else /* debut de piste sur un segment de piste */ break;
{ }
Track = (TRACK *) LockPoint; else /* debut de piste sur un segment de piste */
new_net_code = Track->net_code; {
if ( new_net_code > 0 ) break; Track = (TRACK*) LockPoint;
} new_net_code = Track->net_code;
} if( new_net_code > 0 )
LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); break;
if( LockPoint ) }
{ }
if ( LockPoint->m_StructType == TYPEPAD ) LockPoint = LocateLockPoint( pt_track->m_End.x, pt_track->m_End.y, masquelayer );
{ if( LockPoint )
pt_pad = (D_PAD*) LockPoint; {
new_net_code = pt_pad->net_code; if( LockPoint->m_StructType == TYPEPAD )
if ( new_net_code > 0 ) break; {
} pt_pad = (D_PAD*) LockPoint;
else /* debut de piste sur un segment de piste */ new_net_code = pt_pad->net_code;
{ if( new_net_code > 0 )
Track = (TRACK *) LockPoint; break;
new_net_code = Track->net_code; }
if ( new_net_code > 0 ) break; else /* debut de piste sur un segment de piste */
} {
} Track = (TRACK*) LockPoint;
} new_net_code = Track->net_code;
if( new_net_code > 0 )
/* Mise a jour du nouveau net code de la piste */ break;
ii = 0; pt_track = NewTrack; }
for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*)pt_track->Pnext) }
{ }
pt_track->net_code = new_net_code;
} /* Mise a jour du nouveau net code de la piste */
ii = 0; pt_track = NewTrack;
/* Controle DRC de la nouvelle piste */ for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*) pt_track->Pnext )
ii = 0; pt_track = NewTrack; {
for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() ) pt_track->net_code = new_net_code;
{ }
if( Drc_On == RUN )
if( drc(DC, pt_track, pt_pcb->Track, 1) == BAD_DRC ) /* Controle DRC de la nouvelle piste */
{ ii = 0; pt_track = NewTrack;
if( confirmation(" Erreur DRC, Place piste:") == YES ) continue; for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() )
else { DRC_error = 1; break; } {
} if( Drc_On == RUN )
} if( drc( DC, pt_track, pt_pcb->Track, 1 ) == BAD_DRC )
{
if( DRC_error == 0) if( confirmation( " Erreur DRC, Place piste:" ) == YES )
{ continue;
if(FlagState == MOVE_ROUTE) else
{ {
/* copie nouvelle piste */ DRC_error = 1; break;
pt_track = NewTrack; }
NewTrack = pt_track->Copy(NbPtNewTrack); }
/* effacement ancienne ( chainage et liens mauvais */ }
ii = NbPtNewTrack;
for ( ; ii > 0; ii --, pt_track = NextS) if( DRC_error == 0 )
{ {
NextS = (TRACK*) pt_track->Pnext; if( FlagState == MOVE_ROUTE )
DeleteStructure(pt_track); {
} /* copie nouvelle piste */
test_1_net_connexion(DC, old_net_code ); pt_track = NewTrack;
} NewTrack = pt_track->Copy( NbPtNewTrack );
/* effacement ancienne ( chainage et liens mauvais */
pt_classe = NewTrack->GetBestInsertPoint(); ii = NbPtNewTrack;
NewTrack->Insert(pt_classe); for( ; ii > 0; ii--, pt_track = NextS )
{
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR) ; NextS = (TRACK*) pt_track->Pnext;
DeleteStructure( pt_track );
/* Mise a jour des connexions sur pads et sur pistes */ }
ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack; ii++, pt_track = NextS) test_1_net_connexion( DC, old_net_code );
{ }
NextS = (TRACK*)pt_track->Pnext;
pt_track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); pt_classe = NewTrack->GetBestInsertPoint();
masquelayer = tab_layer[pt_track->Layer]; NewTrack->Insert( pt_classe );
/* Localisation de la pastille ou segment sur debut segment: */ Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_OR );
LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer);
if( LockPoint ) /* Mise a jour des connexions sur pads et sur pistes */
{ ii = 0; pt_track = NewTrack;
pt_track->start = LockPoint; for( ; ii < NbPtNewTrack; ii++, pt_track = NextS )
if ( LockPoint->m_StructType == TYPEPAD ) {
{ /* fin de piste sur un pad */ NextS = (TRACK*) pt_track->Pnext;
pt_pad = (D_PAD*) LockPoint; pt_track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
pt_track->SetState(BEGIN_ONPAD, ON); masquelayer = tab_layer[pt_track->Layer];
}
else /* debut de piste sur un segment de piste */ /* Localisation de la pastille ou segment sur debut segment: */
{ LockPoint = LocateLockPoint( pt_track->m_Start.x, pt_track->m_Start.y, masquelayer );
Track = (TRACK *) LockPoint; if( LockPoint )
CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); {
} pt_track->start = LockPoint;
} if( LockPoint->m_StructType == TYPEPAD )
{ /* fin de piste sur un pad */
/* Localisation de la pastille ou segment sur fin de segment: */ pt_pad = (D_PAD*) LockPoint;
LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); pt_track->SetState( BEGIN_ONPAD, ON );
if( LockPoint ) }
{ else /* debut de piste sur un segment de piste */
pt_track->end = LockPoint; {
if ( LockPoint->m_StructType == TYPEPAD ) Track = (TRACK*) LockPoint;
{ /* fin de piste sur un pad */ CreateLockPoint( &pt_track->m_Start.x, &pt_track->m_Start.y, Track, pt_track );
pt_pad = (D_PAD*) LockPoint; }
pt_track->SetState(END_ONPAD, ON); }
}
else /* debut de piste sur un segment de piste */ /* Localisation de la pastille ou segment sur fin de segment: */
{ LockPoint = LocateLockPoint( pt_track->m_End.x, pt_track->m_End.y, masquelayer );
Track = (TRACK *) LockPoint; if( LockPoint )
CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); {
} pt_track->end = LockPoint;
} if( LockPoint->m_StructType == TYPEPAD )
} { /* fin de piste sur un pad */
pt_pad = (D_PAD*) LockPoint;
/* Suppression du flag BUSY */ pt_track->SetState( END_ONPAD, ON );
ii = NbPtNewTrack; pt_track = NewTrack; }
for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) else /* debut de piste sur un segment de piste */
{ {
pt_track->SetState(BUSY, OFF); Track = (TRACK*) LockPoint;
} CreateLockPoint( &pt_track->m_Start.x, &pt_track->m_Start.y, Track, pt_track );
}
test_1_net_connexion(DC, new_net_code ); }
ActiveScreen->SetModify(); }
}
/* Suppression du flag BUSY */
else /* Erreur DRC: Annulation commande */ ii = NbPtNewTrack; pt_track = NewTrack;
{ for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
DisplayOpt.DisplayPcbTrackFill = SKETCH ; {
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR); pt_track->SetState( BUSY, OFF );
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; }
if(FlagState == MOVE_ROUTE) test_1_net_connexion( DC, new_net_code );
{ /* Remise en position de la piste deplacee */ ActiveScreen->SetModify();
Track = NewTrack; }
PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y; else /* Erreur DRC: Annulation commande */
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) {
{ DisplayOpt.DisplayPcbTrackFill = SKETCH;
if( Track == NULL ) break; Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_XOR );
Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY; DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
Track->m_End.x += PosInitX; Track->m_End.y += PosInitY;
Track->SetState(BUSY,OFF); if( FlagState == MOVE_ROUTE )
} { /* Remise en position de la piste deplacee */
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR); Track = NewTrack;
} PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y;
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
if (FlagState == COPY_ROUTE ) {
{ /* Suppression copie */ if( Track == NULL )
for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS) break;
{ Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY;
if(NewTrack == NULL) break; Track->m_End.x += PosInitX; Track->m_End.y += PosInitY;
NextS = (TRACK*) NewTrack->Pnext; Track->SetState( BUSY, OFF );
delete NewTrack; }
}
} Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_OR );
} }
NewTrack = NULL;
Affiche_Infos_Status_Pcb(Cmd); if( FlagState == COPY_ROUTE )
if(Etat_Surbrillance) Hight_Light(DC); { /* Suppression copie */
for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS )
{
if( NewTrack == NULL )
break;
NextS = (TRACK*) NewTrack->Pnext;
delete NewTrack;
}
}
}
NewTrack = NULL;
Affiche_Infos_Status_Pcb( Cmd );
if( Etat_Surbrillance )
Hight_Light( DC );
} }
/************************************************/ /************************************************/
void WinEDA_PcbFrame::Start_CopieMove_Route(TRACK * track, wxDC * DC, bool Drag) void WinEDA_PcbFrame::Start_CopieMove_Route( TRACK* track, wxDC* DC, bool Drag )
/************************************************/ /************************************************/
/* Routine permettant la recopie d'une piste (suite de segments) deja tracee /* Routine permettant la recopie d'une piste (suite de segments) deja tracee
*/ */
{ {
int ii; int ii;
TRACK *pt_segm, *pt_track; TRACK* pt_segm, * pt_track;
int masquelayer = tab_layer[ActiveScreen->Active_Layer]; int masquelayer = tab_layer[ActiveScreen->Active_Layer];
wxDC * DC = Cmd->DC; wxDC* DC = Cmd->DC;
if( NewTrack ) return; if( NewTrack )
return;
FlagState = (int)Cmd->Menu->param_inf;
FlagState = (int) Cmd->Menu->param_inf;
/* Recherche de la piste sur la couche active (non zone) */
for(pt_segm = pt_pcb->Track; pt_segm != NULL; pt_segm = (TRACK*)pt_segm->Pnext) /* Recherche de la piste sur la couche active (non zone) */
{ for( pt_segm = pt_pcb->Track; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext )
pt_segm = Locate_Pistes(pt_segm,masquelayer, CURSEUR_OFF_GRILLE); {
if( pt_segm == NULL ) break ; pt_segm = Locate_Pistes( pt_segm, masquelayer, CURSEUR_OFF_GRILLE );
break ; if( pt_segm == NULL )
} break;
break;
if( pt_segm != NULL ) }
{
if (FlagState == COPY_ROUTE ) if( pt_segm != NULL )
pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, 0); {
else pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, GR_XOR); if( FlagState == COPY_ROUTE )
pt_track = Marque_Une_Piste( DC, pt_segm, &NbPtNewTrack, 0 );
if(NbPtNewTrack) /* Il y a NbPtNewTrack segments de piste a traiter */ else
{ pt_track = Marque_Une_Piste( DC, pt_segm, &NbPtNewTrack, GR_XOR );
/* effacement du flag BUSY de la piste originelle */
ii = NbPtNewTrack; pt_segm = pt_track; if( NbPtNewTrack ) /* Il y a NbPtNewTrack segments de piste a traiter */
for ( ; ii > 0; ii --, pt_segm = (TRACK*) pt_segm->Pnext) {
{ /* effacement du flag BUSY de la piste originelle */
pt_segm->SetState(BUSY, OFF); ii = NbPtNewTrack; pt_segm = pt_track;
} for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Pnext )
{
if (FlagState == COPY_ROUTE ) pt_segm->SetState( BUSY, OFF );
NewTrack = pt_track->Copy(NbPtNewTrack); }
else NewTrack = pt_track;
if( FlagState == COPY_ROUTE )
Affiche_Infos_Piste(Cmd, pt_track) ; NewTrack = pt_track->Copy( NbPtNewTrack );
else
startX = ActiveScreen->Curseur_X; NewTrack = pt_track;
startY = ActiveScreen->Curseur_Y;
Place_Dupl_Route_Item.State = WAIT; Affiche_Infos_Piste( Cmd, pt_track );
ActiveDrawPanel->ManageCurseur = Show_Move_Piste;
DisplayOpt.DisplayPcbTrackFill = SKETCH ; startX = ActiveScreen->Curseur_X;
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR) ; startY = ActiveScreen->Curseur_Y;
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; Place_Dupl_Route_Item.State = WAIT;
PosInitX = NewTrack->m_Start.x; PosInitY = NewTrack->m_Start.y; ActiveDrawPanel->ManageCurseur = Show_Move_Piste;
} DisplayOpt.DisplayPcbTrackFill = SKETCH;
} Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_XOR );
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
PosInitX = NewTrack->m_Start.x; PosInitY = NewTrack->m_Start.y;
}
}
} }
#endif #endif
/************************************************************************/ /************************************************************************/
EDA_BaseStruct * LocateLockPoint(BOARD * Pcb, wxPoint pos, int LayerMask) EDA_BaseStruct* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
/************************************************************************/ /************************************************************************/
/* Routine trouvant le point " d'accrochage " d'une extremite de piste. /* Routine trouvant le point " d'accrochage " d'une extremite de piste.
Ce point peut etre un PAD ou un autre segment de piste * Ce point peut etre un PAD ou un autre segment de piste
Retourne: * Retourne:
- pointeur sur ce PAD ou: * - pointeur sur ce PAD ou:
- pointeur sur le segment ou: * - pointeur sur le segment ou:
- NULL * - NULL
Parametres d'appel: * Parametres d'appel:
coord pX, pY du point tst * coord pX, pY du point tst
masque des couches a tester * masque des couches a tester
*/ */
{ {
D_PAD * pt_pad; D_PAD* pt_pad;
TRACK * ptsegm; TRACK* ptsegm;
MODULE * Module; MODULE* Module;
/* detection du point type PAD */ /* detection du point type PAD */
pt_pad = NULL; pt_pad = NULL;
Module = Pcb->m_Modules; Module = Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
pt_pad = Locate_Pads(Module, pos, LayerMask); pt_pad = Locate_Pads( Module, pos, LayerMask );
if (pt_pad) return(pt_pad); if( pt_pad )
} return pt_pad;
}
/* ici aucun pad n'a ete localise: detection d'un segment de piste */
/* ici aucun pad n'a ete localise: detection d'un segment de piste */
ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask);
if( ptsegm == NULL ) ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask); if( ptsegm == NULL )
return(ptsegm); ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask );
return ptsegm;
} }
/******************************************************************************/ /******************************************************************************/
TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm) TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm )
/******************************************************************************/ /******************************************************************************/
/* Routine de creation d'un point intermediaire sur un segment /* Routine de creation d'un point intermediaire sur un segment
le segment ptsegm est casse en 2 segments se raccordant au point pX, pY * le segment ptsegm est casse en 2 segments se raccordant au point pX, pY
retourne: * retourne:
NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja * NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja
a une extremite ou: * a une extremite ou:
pointeur sur le segment cree * pointeur sur le segment cree
si refsegm != NULL refsegm est pointeur sur le segment incident, * si refsegm != NULL refsegm est pointeur sur le segment incident,
et le point cree est l'intersection des 2 axes des segments ptsegm et * et le point cree est l'intersection des 2 axes des segments ptsegm et
refsegm * refsegm
retourne la valeur exacte de pX et pY * retourne la valeur exacte de pX et pY
Si ptsegm pointe sur une via: * Si ptsegm pointe sur une via:
retourne la valeur exacte de pX et pY et ptsegm, * retourne la valeur exacte de pX et pY et ptsegm,
mais ne cree pas de point supplementaire * mais ne cree pas de point supplementaire
*
*/ */
{ {
int cX, cY; int cX, cY;
int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */ int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */
int ox, oy, fx , fy; /* coord de refsegm / origine de prsegm */ int ox, oy, fx, fy; /* coord de refsegm / origine de prsegm */
TRACK * NewTrack; TRACK* NewTrack;
if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) ) return(NULL); if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) )
if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) ) return(NULL); return NULL;
if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) )
/* le point n'est pas sur une extremite de piste */ return NULL;
if(ptsegm->m_StructType == TYPEVIA )
{ /* le point n'est pas sur une extremite de piste */
*pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y; if( ptsegm->m_StructType == TYPEVIA )
return(ptsegm); {
} *pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y;
/* calcul des coord vraies du point intermediaire dans le repere d'origine return ptsegm;
= origine de ptsegm */ }
cX = *pX - ptsegm->m_Start.x;
/* calcul des coord vraies du point intermediaire dans le repere d'origine
* = origine de ptsegm */
cX = *pX - ptsegm->m_Start.x;
cY = *pY - ptsegm->m_Start.y; cY = *pY - ptsegm->m_Start.y;
dx = ptsegm->m_End.x - ptsegm->m_Start.x; dx = ptsegm->m_End.x - ptsegm->m_Start.x;
dy = ptsegm->m_End.y - ptsegm->m_Start.y; dy = ptsegm->m_End.y - ptsegm->m_Start.y;
// ***** A COMPLETER : non utilise // ***** A COMPLETER : non utilise
if ( refsegm ) if( refsegm )
{ {
ox = refsegm->m_Start.x - ptsegm->m_Start.x; ox = refsegm->m_Start.x - ptsegm->m_Start.x;
oy = refsegm->m_Start.y - ptsegm->m_Start.y; oy = refsegm->m_Start.y - ptsegm->m_Start.y;
fx = refsegm->m_End.x - ptsegm->m_Start.x; fx = refsegm->m_End.x - ptsegm->m_Start.x;
fy = refsegm->m_End.y - ptsegm->m_Start.y; fy = refsegm->m_End.y - ptsegm->m_Start.y;
} }
/* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */
if ( dx == 0 ) cX = 0; /* segm horizontal */
else cY = (cX * dy) / dx;
/* creation du point intermediaire ( c'est a dire creation d'un nouveau /* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */
segment, debutant au point intermediaire */ if( dx == 0 )
cX = 0; /* segm horizontal */
else
cY = (cX * dy) / dx;
cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y; /* creation du point intermediaire ( c'est a dire creation d'un nouveau
NewTrack = ptsegm->Copy(); * segment, debutant au point intermediaire */
NewTrack->Insert(NULL, ptsegm); cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y;
/* correction du pointeur de fin du nouveau segment */ NewTrack = ptsegm->Copy();
NewTrack->end = ptsegm->end;
/* le segment primitif finit au nouveau point : */ NewTrack->Insert( NULL, ptsegm );
ptsegm->m_End.x = cX; ptsegm->m_End.y = cY; /* correction du pointeur de fin du nouveau segment */
ptsegm->SetState(END_ONPAD, OFF); NewTrack->end = ptsegm->end;
/* le nouveau segment debute au nouveau point : */ /* le segment primitif finit au nouveau point : */
ptsegm = NewTrack;; ptsegm->m_End.x = cX; ptsegm->m_End.y = cY;
ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY; ptsegm->SetState( END_ONPAD, OFF );
ptsegm->SetState(BEGIN_ONPAD, OFF);
*pX = cX; *pY = cY;
return(ptsegm); /* le nouveau segment debute au nouveau point : */
ptsegm = NewTrack;;
ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY;
ptsegm->SetState( BEGIN_ONPAD, OFF );
*pX = cX; *pY = cY;
return ptsegm;
} }
/****************************************************/ /****************************************************/
/* Track editing */ /* Track editing */
/* routines to move and drag track segments or node */ /* routines to move and drag track segments or node */
/****************************************************/ /****************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -18,853 +18,937 @@ ...@@ -18,853 +18,937 @@
/* local functions */ /* local functions */
static void Show_MoveNode(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Show_Drag_Track_Segment_With_Cte_Slope(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Abort_MoveTrack(WinEDA_DrawPanel * Panel, wxDC *DC); static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC );
static bool InitialiseDragParameters(void); static bool InitialiseDragParameters( void );
/* variables locales */ /* variables locales */
static wxPoint PosInit, s_LastPos; static wxPoint PosInit, s_LastPos;
static TRACK * NewTrack; /* Nouvelle piste creee ou piste deplacee */ static TRACK* NewTrack; /* Nouvelle piste creee ou piste deplacee */
static int NbPtNewTrack; static int NbPtNewTrack;
static int Old_HightLigth_NetCode; static int Old_HightLigth_NetCode;
static bool Old_HightLigt_Status; static bool Old_HightLigt_Status;
static double s_StartSegmentSlope, s_EndSegmentSlope, s_MovingSegmentSlope, static double s_StartSegmentSlope, s_EndSegmentSlope, s_MovingSegmentSlope,
s_StartSegment_Yorg, s_EndSegment_Yorg, s_StartSegment_Yorg, s_EndSegment_Yorg,
s_MovingSegment_Yorg; //slope and intercept parameters of lines s_MovingSegment_Yorg; //slope and intercept parameters of lines
bool s_StartPointVertical,s_EndPointVertical, bool s_StartPointVertical, s_EndPointVertical,
s_MovingSegmentVertical,s_MovingSegmentHorizontal, s_MovingSegmentVertical, s_MovingSegmentHorizontal,
s_StartPointHorizontal,s_EndPointHorizontal; // vertical or horizontal line indicators s_StartPointHorizontal, s_EndPointHorizontal; // vertical or horizontal line indicators
bool s_StartSegmentPresent, s_EndSegmentPresent; bool s_StartSegmentPresent, s_EndSegmentPresent;
/**************************************************************/ /**************************************************************/
static void Abort_MoveTrack(WinEDA_DrawPanel * Panel, wxDC *DC) static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
/***************************************************************/ /***************************************************************/
/* routine d'annulation de la commande drag, copy ou move track si une piste est en cours /* routine d'annulation de la commande drag, copy ou move track si une piste est en cours
de tracage, ou de sortie de l'application EDITRACK. * de tracage, ou de sortie de l'application EDITRACK.
*/ */
{ {
TRACK * NextS; TRACK* NextS;
int ii; int ii;
/* Erase the current drawings */ /* Erase the current drawings */
wxPoint oldpos = Panel->GetScreen()->m_Curseur; wxPoint oldpos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = PosInit;
if ( Panel->ManageCurseur ) Panel->ManageCurseur(Panel, DC, TRUE); Panel->GetScreen()->m_Curseur = PosInit;
Panel->GetScreen()->m_Curseur = oldpos; if( Panel->ManageCurseur )
g_HightLigt_Status = FALSE; Panel->ManageCurseur( Panel, DC, TRUE );
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; Panel->GetScreen()->m_Curseur = oldpos;
g_HightLigt_Status = FALSE;
if( NewTrack ) ( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
{
if (NewTrack->m_Flags & IS_NEW ) if( NewTrack )
{ {
for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS) if( NewTrack->m_Flags & IS_NEW )
{ {
if(NewTrack == NULL) break; for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS )
NextS = (TRACK*) NewTrack->Pnext; {
delete NewTrack; if( NewTrack == NULL )
} break;
} NextS = (TRACK*) NewTrack->Pnext;
else /* Move : remise en ancienne position */ delete NewTrack;
{ }
TRACK * Track = NewTrack; }
int dx = s_LastPos.x - PosInit.x; else /* Move : remise en ancienne position */
int dy = s_LastPos.y - PosInit.y; {
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) TRACK* Track = NewTrack;
{ int dx = s_LastPos.x - PosInit.x;
if( Track == NULL ) break; int dy = s_LastPos.y - PosInit.y;
Track->m_Start.x -= dx; for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
Track->m_Start.y -= dy; {
Track->m_End.x -= dx; if( Track == NULL )
Track->m_End.y -= dy; break;
Track->m_Flags = 0; Track->m_Start.x -= dx;
Track->m_Start.y -= dy;
} Track->m_End.x -= dx;
Trace_Une_Piste(Panel, DC, NewTrack,NbPtNewTrack,GR_OR); Track->m_End.y -= dy;
} Track->m_Flags = 0;
}
NewTrack = NULL;
} Trace_Une_Piste( Panel, DC, NewTrack, NbPtNewTrack, GR_OR );
}
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; NewTrack = NULL;
Panel->GetScreen()->m_CurrentItem = NULL; }
Panel->m_Parent->EraseMsgBox();
Panel->ManageCurseur = NULL;
/* Annulation deplacement et Redessin des segments dragges */ Panel->ForceCloseManageCurseur = NULL;
DRAG_SEGM * pt_drag = g_DragSegmentList; Panel->GetScreen()->m_CurrentItem = NULL;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) Panel->m_Parent->EraseMsgBox();
{
TRACK * Track = pt_drag->m_Segm; /* Annulation deplacement et Redessin des segments dragges */
pt_drag->SetInitialValues(); DRAG_SEGM* pt_drag = g_DragSegmentList;
Track->SetState(EDIT,OFF); for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
Track->m_Flags = 0; {
Track->Draw(Panel, DC, GR_OR); TRACK* Track = pt_drag->m_Segm;
} pt_drag->SetInitialValues();
Track->SetState( EDIT, OFF );
g_HightLigth_NetCode = Old_HightLigth_NetCode; Track->m_Flags = 0;
g_HightLigt_Status = Old_HightLigt_Status; Track->Draw( Panel, DC, GR_OR );
if(g_HightLigt_Status) }
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ;
g_HightLigth_NetCode = Old_HightLigth_NetCode;
EraseDragListe(); g_HightLigt_Status = Old_HightLigt_Status;
if( g_HightLigt_Status )
( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
EraseDragListe();
} }
/*************************************************************************/ /*************************************************************************/
static void Show_MoveNode(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************************/ /*************************************************************************/
/* Redraw the moved node according to the mouse cursor position */ /* Redraw the moved node according to the mouse cursor position */
{ {
int ii, dx, dy; int ii, dx, dy;
TRACK * Track; TRACK* Track;
BASE_SCREEN * screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
int track_fill_copy = DisplayOpt.DisplayPcbTrackFill; int track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
int draw_mode = GR_XOR | GR_SURBRILL; int draw_mode = GR_XOR | GR_SURBRILL;
DisplayOpt.DisplayPcbTrackFill = FALSE ; DisplayOpt.DisplayPcbTrackFill = FALSE;
erase = TRUE; erase = TRUE;
/* erase the current moved track segments from screen */ /* erase the current moved track segments from screen */
if( erase ) if( erase )
{ {
if ( NewTrack ) Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,draw_mode) ; if( NewTrack )
} Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, draw_mode );
}
/* set the new track coordinates */
wxPoint Pos = screen->m_Curseur; /* set the new track coordinates */
dx = Pos.x - s_LastPos.x; wxPoint Pos = screen->m_Curseur;
dy = Pos.y - s_LastPos.y; dx = Pos.x - s_LastPos.x;
s_LastPos = Pos; dy = Pos.y - s_LastPos.y;
ii = NbPtNewTrack, Track = NewTrack; s_LastPos = Pos;
for( ; (ii > 0) && (Track != NULL); ii--, Track = Track->Next() ) ii = NbPtNewTrack, Track = NewTrack;
{ for( ; (ii > 0) && (Track != NULL); ii--, Track = Track->Next() )
if( Track->m_Flags & STARTPOINT) {
{ if( Track->m_Flags & STARTPOINT )
Track->m_Start.x += dx; Track->m_Start.y += dy; {
} Track->m_Start.x += dx; Track->m_Start.y += dy;
if( Track->m_Flags & ENDPOINT) }
{ if( Track->m_Flags & ENDPOINT )
Track->m_End.x += dx; Track->m_End.y += dy; {
} Track->m_End.x += dx; Track->m_End.y += dy;
} }
}
/* Redraw the current moved track segments */
Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,GR_XOR) ; /* Redraw the current moved track segments */
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
DRAG_SEGM * pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) DRAG_SEGM* pt_drag = g_DragSegmentList;
{ for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
Track = pt_drag->m_Segm; {
if ( erase ) Track->Draw(panel, DC, draw_mode); Track = pt_drag->m_Segm;
if( Track->m_Flags & STARTPOINT) if( erase )
{ Track->Draw( panel, DC, draw_mode );
Track->m_Start.x += dx; Track->m_Start.y += dy; if( Track->m_Flags & STARTPOINT )
} {
if( Track->m_Flags & ENDPOINT) Track->m_Start.x += dx; Track->m_Start.y += dy;
{ }
Track->m_End.x += dx; Track->m_End.y += dy; if( Track->m_Flags & ENDPOINT )
} {
Track->Draw(panel, DC, draw_mode); Track->m_End.x += dx; Track->m_End.y += dy;
} }
DisplayOpt.DisplayPcbTrackFill = track_fill_copy ; Track->Draw( panel, DC, draw_mode );
} }
DisplayOpt.DisplayPcbTrackFill = track_fill_copy;
}
/*************************************************************************/ /*************************************************************************/
static void Show_Drag_Track_Segment_With_Cte_Slope(WinEDA_DrawPanel * panel, static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
wxDC * DC, bool erase) wxDC* DC, bool erase )
/*************************************************************************/ /*************************************************************************/
/* drawing the track segment movement /* drawing the track segment movement
> s_MovingSegmentSlope slope = moving track segment slope * > s_MovingSegmentSlope slope = moving track segment slope
> s_StartSegmentSlope slope = slope of the segment connected to the start point of the moving segment * > s_StartSegmentSlope slope = slope of the segment connected to the start point of the moving segment
> s_EndSegmentSlope slope = slope of the segment connected to the end point of the moving segment * > s_EndSegmentSlope slope = slope of the segment connected to the end point of the moving segment
*
moved segment function : * moved segment function :
yt=s_MovingSegmentSlope * x + s_MovingSegment_Yorg * yt=s_MovingSegmentSlope * x + s_MovingSegment_Yorg
*
segment connected to moved segment's start: * segment connected to moved segment's start:
y1 = s_StartSegmentSlope * x + s_StartSegment_Yorg * y1 = s_StartSegmentSlope * x + s_StartSegment_Yorg
*
segment connected to moved segment's end: * segment connected to moved segment's end:
y2=s_EndSegmentSlope * x + s_EndSegment_Yorg * y2=s_EndSegmentSlope * x + s_EndSegment_Yorg
*
first intersection point will be located at * first intersection point will be located at
y1=yt -> * y1=yt ->
xi1=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_StartSegmentSlope-s_MovingSegmentSlope) * xi1=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_StartSegmentSlope-s_MovingSegmentSlope)
yi1=s_MovingSegmentSlope*xi1+s_MovingSegment_Yorg * yi1=s_MovingSegmentSlope*xi1+s_MovingSegment_Yorg
or yi1=s_StartSegmentSlope*xi1+s_MovingSegment_Yorg * or yi1=s_StartSegmentSlope*xi1+s_MovingSegment_Yorg
*
second intersection point * second intersection point
y2=yt -> * y2=yt ->
xi2=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_MovingSegmentSlope-s_MovingSegmentSlope) * xi2=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_MovingSegmentSlope-s_MovingSegmentSlope)
yi2=s_MovingSegmentSlope*xi2+s_MovingSegment_Yorg * yi2=s_MovingSegmentSlope*xi2+s_MovingSegment_Yorg
or yi1=s_EndSegmentSlope*xi2+s_MovingSegment_Yorg * or yi1=s_EndSegmentSlope*xi2+s_MovingSegment_Yorg
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!! special attention to vertical segments because * !!!!! special attention to vertical segments because
!!!!! their slope=infinite * !!!!! their slope=infinite
!!!!! intersection point will be calculated using the * !!!!! intersection point will be calculated using the
!!!!! segment intersecting it * !!!!! segment intersecting it
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
Slope parametres are computed once, because they can become undetermined when moving segments * Slope parametres are computed once, because they can become undetermined when moving segments
(i.e. when a segment lenght is 0) and we want keep them constant * (i.e. when a segment lenght is 0) and we want keep them constant
*/ */
{ {
double xi1=0,yi1=0,xi2=0,yi2=0; // calculated intersection points double xi1 = 0, yi1 = 0, xi2 = 0, yi2 = 0; // calculated intersection points
double tx1,tx2,ty1,ty2; // temporary storage of points double tx1, tx2, ty1, ty2; // temporary storage of points
int dx, dy; int dx, dy;
BASE_SCREEN * screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
bool update=true; bool update = true;
TRACK * Track; TRACK* Track;
DRAG_SEGM * TrackSegWrapper = g_DragSegmentList; DRAG_SEGM* TrackSegWrapper = g_DragSegmentList;
TRACK * tSegmentToStart = NULL, * tSegmentToEnd = NULL; TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
if ( TrackSegWrapper == NULL ) return; if( TrackSegWrapper == NULL )
Track = TrackSegWrapper->m_Segm; if (Track == NULL ) return; return;
Track = TrackSegWrapper->m_Segm; if( Track == NULL )
TrackSegWrapper = TrackSegWrapper->Pnext; return;
if ( TrackSegWrapper )
{ TrackSegWrapper = TrackSegWrapper->Pnext;
if ( s_EndSegmentPresent ) if( TrackSegWrapper )
{ {
tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point if( s_EndSegmentPresent )
TrackSegWrapper = TrackSegWrapper->Pnext; {
} tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point
if ( s_StartSegmentPresent ) TrackSegWrapper = TrackSegWrapper->Pnext;
{ }
if ( TrackSegWrapper ) if( s_StartSegmentPresent )
tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point {
} if( TrackSegWrapper )
} tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point
}
int draw_mode = GR_XOR | GR_SURBRILL; }
/* Undraw the current moved track segments before modification*/
int draw_mode = GR_XOR | GR_SURBRILL;
/* Undraw the current moved track segments before modification*/
// if( erase ) // if( erase )
{ {
Track->Draw(panel, DC, draw_mode); Track->Draw( panel, DC, draw_mode );
if ( tSegmentToStart ) tSegmentToStart->Draw(panel, DC, draw_mode); if( tSegmentToStart )
if ( tSegmentToEnd ) tSegmentToEnd->Draw(panel, DC, draw_mode); tSegmentToStart->Draw( panel, DC, draw_mode );
} if( tSegmentToEnd )
tSegmentToEnd->Draw( panel, DC, draw_mode );
/* Compute the new track segment position */ }
wxPoint Pos = screen->m_Curseur;
/* Compute the new track segment position */
wxPoint Pos = screen->m_Curseur;
dx = Pos.x - s_LastPos.x; dx = Pos.x - s_LastPos.x;
dy = Pos.y - s_LastPos.y; dy = Pos.y - s_LastPos.y;
//move the line by dx and dy
tx1 = (double)(Track->m_Start.x + dx); //move the line by dx and dy
ty1 = (double)(Track->m_Start.y + dy); tx1 = (double) (Track->m_Start.x + dx);
tx2 = (double)(Track->m_End.x + dx); ty1 = (double) (Track->m_Start.y + dy);
ty2 = (double)(Track->m_End.y + dy); tx2 = (double) (Track->m_End.x + dx);
ty2 = (double) (Track->m_End.y + dy);
// recalculate the segments new parameters and intersection points
// only the intercept will change, segment slopes does not change // recalculate the segments new parameters and intersection points
// because we are moving parallel with is initial state // only the intercept will change, segment slopes does not change
if (!s_MovingSegmentVertical) { // because we are moving parallel with is initial state
s_MovingSegment_Yorg = ty1 - (s_MovingSegmentSlope * tx1); if( !s_MovingSegmentVertical )
} {
s_MovingSegment_Yorg = ty1 - (s_MovingSegmentSlope * tx1);
if ((!s_EndPointVertical) && (!s_MovingSegmentVertical)) { }
xi2 = (s_MovingSegment_Yorg - s_EndSegment_Yorg) / (s_EndSegmentSlope - s_MovingSegmentSlope);
} else { if( (!s_EndPointVertical) && (!s_MovingSegmentVertical) )
if (!s_EndPointVertical) { {
xi2 = tx2; xi2 = (s_MovingSegment_Yorg -
} else { s_EndSegment_Yorg) / (s_EndSegmentSlope - s_MovingSegmentSlope);
//P1=P2 }
if (!s_EndPointHorizontal) { else
xi2 = tx2-dx; {
} else { if( !s_EndPointVertical )
update=false; {
} xi2 = tx2;
} }
} else
{
if (!s_MovingSegmentVertical) //P1=P2
{ if( !s_EndPointHorizontal )
yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg; {
} xi2 = tx2 - dx;
else }
{ else
if (!s_EndPointVertical) { {
yi2 = s_EndSegmentSlope * (xi2) + s_EndSegment_Yorg; update = false;
} }
else }
{ }
if (!s_EndPointHorizontal) {
update=false; if( !s_MovingSegmentVertical )
} {
else { yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg;
yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg; }
} else
} {
} if( !s_EndPointVertical )
{
if ((!s_StartPointVertical) && (!s_MovingSegmentVertical)) yi2 = s_EndSegmentSlope * (xi2) + s_EndSegment_Yorg;
{ }
xi1 = (s_MovingSegment_Yorg - s_StartSegment_Yorg) / (s_StartSegmentSlope - s_MovingSegmentSlope); else
} {
else if( !s_EndPointHorizontal )
{ {
if (!s_StartPointVertical) { update = false;
xi1 = tx1; }
} else
else {
{ yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg;
//P1=P2 }
if (!s_StartPointHorizontal) { }
xi1 = tx1-dx; }
}
else if( (!s_StartPointVertical) && (!s_MovingSegmentVertical) )
{ {
if (!s_StartPointHorizontal) { xi1 = (s_MovingSegment_Yorg -
update=false; s_StartSegment_Yorg) / (s_StartSegmentSlope - s_MovingSegmentSlope);
} }
} else
} {
} if( !s_StartPointVertical )
{
if (!s_MovingSegmentVertical) { xi1 = tx1;
yi1 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg; }
} else
else { {
if (!s_StartPointVertical) { //P1=P2
yi1 = s_StartSegmentSlope * (xi1) + s_StartSegment_Yorg; if( !s_StartPointHorizontal )
} else { {
if (!s_StartPointHorizontal) { xi1 = tx1 - dx;
update=false; }
} else { else
yi2 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg; {
} if( !s_StartPointHorizontal )
} {
} update = false;
}
// update the segment coordinates (if possible) }
if ( tSegmentToStart == NULL ) }
{ }
xi1 = tx1; yi1 = ty1;
} if( !s_MovingSegmentVertical )
if ( tSegmentToEnd == NULL ) {
{ yi1 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg;
xi2 = tx2; yi2 = ty2; }
} else
{
if( !s_StartPointVertical )
if (update) {
{ yi1 = s_StartSegmentSlope * (xi1) + s_StartSegment_Yorg;
s_LastPos=Pos; }
Track->m_Start.x = (int) round(xi1); else
Track->m_Start.y = (int) round(yi1); {
Track->m_End.x = (int) round(xi2); if( !s_StartPointHorizontal )
Track->m_End.y = (int) round(yi2); {
if ( tSegmentToEnd ) update = false;
{ }
if ( tSegmentToEnd->m_Flags & STARTPOINT ) else
tSegmentToEnd->m_Start = Track->m_End; {
else tSegmentToEnd->m_End = Track->m_End; yi2 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg;
} }
if ( tSegmentToStart ) }
{ }
if ( tSegmentToStart->m_Flags & STARTPOINT )
tSegmentToStart->m_Start = Track->m_Start; // update the segment coordinates (if possible)
else tSegmentToStart->m_End = Track->m_Start; if( tSegmentToStart == NULL )
} {
} xi1 = tx1; yi1 = ty1;
}
Track->Draw(panel, DC, draw_mode); if( tSegmentToEnd == NULL )
if ( tSegmentToStart ) tSegmentToStart->Draw(panel, DC, draw_mode); {
if ( tSegmentToEnd ) tSegmentToEnd->Draw(panel, DC, draw_mode); xi2 = tx2; yi2 = ty2;
}
if( update )
{
s_LastPos = Pos;
Track->m_Start.x = (int) round( xi1 );
Track->m_Start.y = (int) round( yi1 );
Track->m_End.x = (int) round( xi2 );
Track->m_End.y = (int) round( yi2 );
if( tSegmentToEnd )
{
if( tSegmentToEnd->m_Flags & STARTPOINT )
tSegmentToEnd->m_Start = Track->m_End;
else
tSegmentToEnd->m_End = Track->m_End;
}
if( tSegmentToStart )
{
if( tSegmentToStart->m_Flags & STARTPOINT )
tSegmentToStart->m_Start = Track->m_Start;
else
tSegmentToStart->m_End = Track->m_Start;
}
}
Track->Draw( panel, DC, draw_mode );
if( tSegmentToStart )
tSegmentToStart->Draw( panel, DC, draw_mode );
if( tSegmentToEnd )
tSegmentToEnd->Draw( panel, DC, draw_mode );
} }
/**********************************/ /**********************************/
bool InitialiseDragParameters(void) bool InitialiseDragParameters( void )
/**********************************/ /**********************************/
/* Init variables (slope, Y intersect point, flags) for Show_Drag_Track_Segment_With_Cte_Slope() /* Init variables (slope, Y intersect point, flags) for Show_Drag_Track_Segment_With_Cte_Slope()
return TRUE if Ok, FALSE if dragging is not possible * return TRUE if Ok, FALSE if dragging is not possible
(2 colinear segments) * (2 colinear segments)
*/ */
{ {
double tx1,tx2,ty1,ty2; // temporary storage of points double tx1, tx2, ty1, ty2; // temporary storage of points
TRACK * Track; TRACK* Track;
DRAG_SEGM * TrackSegWrapper = g_DragSegmentList; DRAG_SEGM* TrackSegWrapper = g_DragSegmentList;
TRACK * tSegmentToStart = NULL, * tSegmentToEnd = NULL; TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
if ( TrackSegWrapper == NULL ) return FALSE; if( TrackSegWrapper == NULL )
Track = TrackSegWrapper->m_Segm; return FALSE;
if (Track == NULL ) return FALSE; Track = TrackSegWrapper->m_Segm;
if( Track == NULL )
TrackSegWrapper = TrackSegWrapper->Pnext; return FALSE;
if ( TrackSegWrapper )
{ TrackSegWrapper = TrackSegWrapper->Pnext;
if ( s_EndSegmentPresent ) if( TrackSegWrapper )
{ {
tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point if( s_EndSegmentPresent )
TrackSegWrapper = TrackSegWrapper->Pnext; {
} tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point
if ( s_StartSegmentPresent ) TrackSegWrapper = TrackSegWrapper->Pnext;
{ }
if ( TrackSegWrapper ) if( s_StartSegmentPresent )
tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point {
} if( TrackSegWrapper )
} tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point
}
s_StartPointVertical=false; }
s_EndPointVertical=false;
s_MovingSegmentVertical=false; s_StartPointVertical = false;
s_StartPointHorizontal=false; s_EndPointVertical = false;
s_EndPointHorizontal=false; s_MovingSegmentVertical = false;
s_MovingSegmentHorizontal=false; s_StartPointHorizontal = false;
s_EndPointHorizontal = false;
s_MovingSegmentHorizontal = false;
// Init parameters for the starting point of the moved segment // Init parameters for the starting point of the moved segment
if ( tSegmentToStart ) if( tSegmentToStart )
{ {
if ( tSegmentToStart->m_Flags & ENDPOINT ) if( tSegmentToStart->m_Flags & ENDPOINT )
{ {
tx1=(double)tSegmentToStart->m_Start.x; tx1 = (double) tSegmentToStart->m_Start.x;
ty1=(double)tSegmentToStart->m_Start.y; ty1 = (double) tSegmentToStart->m_Start.y;
tx2=(double)tSegmentToStart->m_End.x; tx2 = (double) tSegmentToStart->m_End.x;
ty2=(double)tSegmentToStart->m_End.y; ty2 = (double) tSegmentToStart->m_End.y;
} }
else else
{ {
tx1=(double)tSegmentToStart->m_End.x; tx1 = (double) tSegmentToStart->m_End.x;
ty1=(double)tSegmentToStart->m_End.y; ty1 = (double) tSegmentToStart->m_End.y;
tx2=(double)tSegmentToStart->m_Start.x; tx2 = (double) tSegmentToStart->m_Start.x;
ty2=(double)tSegmentToStart->m_Start.y; ty2 = (double) tSegmentToStart->m_Start.y;
} }
} }
else // move the start point on a line starting at Track->m_Start, and perpendicular to Track else // move the start point on a line starting at Track->m_Start, and perpendicular to Track
{ {
tx1 = (double)Track->m_Start.x; tx1 = (double) Track->m_Start.x;
ty1 = (double)Track->m_Start.y; ty1 = (double) Track->m_Start.y;
tx2 = (double)Track->m_End.x; tx2 = (double) Track->m_End.x;
ty2 = (double)Track->m_End.y; ty2 = (double) Track->m_End.y;
RotatePoint(&tx2, &ty2, tx1, ty1, 900); RotatePoint( &tx2, &ty2, tx1, ty1, 900 );
} }
if (tx1!=tx2) { if( tx1!=tx2 )
s_StartSegmentSlope = (ty2 - ty1) / (tx2 - tx1); {
s_StartSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1); s_StartSegmentSlope = (ty2 - ty1) / (tx2 - tx1);
} else { s_StartSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1);
s_StartPointVertical=true; //signal first segment vertical }
} else
if (ty1==ty2) { {
s_StartPointHorizontal=true; s_StartPointVertical = true; //signal first segment vertical
} }
if( ty1==ty2 )
{
s_StartPointHorizontal = true;
}
// Init parameters for the ending point of the moved segment // Init parameters for the ending point of the moved segment
if ( tSegmentToEnd ) if( tSegmentToEnd )
{ {
//check if second line is vertical //check if second line is vertical
if ( tSegmentToEnd->m_Flags & STARTPOINT ) if( tSegmentToEnd->m_Flags & STARTPOINT )
{ {
tx1=(double)tSegmentToEnd->m_Start.x; tx1 = (double) tSegmentToEnd->m_Start.x;
ty1=(double)tSegmentToEnd->m_Start.y; ty1 = (double) tSegmentToEnd->m_Start.y;
tx2=(double)tSegmentToEnd->m_End.x; tx2 = (double) tSegmentToEnd->m_End.x;
ty2=(double)tSegmentToEnd->m_End.y; ty2 = (double) tSegmentToEnd->m_End.y;
} }
else else
{ {
tx1=(double)tSegmentToEnd->m_End.x; tx1 = (double) tSegmentToEnd->m_End.x;
ty1=(double)tSegmentToEnd->m_End.y; ty1 = (double) tSegmentToEnd->m_End.y;
tx2=(double)tSegmentToEnd->m_Start.x; tx2 = (double) tSegmentToEnd->m_Start.x;
ty2=(double)tSegmentToEnd->m_Start.y; ty2 = (double) tSegmentToEnd->m_Start.y;
} }
} }
else // move the start point on a line starting at Track->m_End, and perpendicular to Track else // move the start point on a line starting at Track->m_End, and perpendicular to Track
{ {
tx1 = (double)Track->m_End.x; tx1 = (double) Track->m_End.x;
ty1 = (double)Track->m_End.y; ty1 = (double) Track->m_End.y;
tx2 = (double)Track->m_Start.x; tx2 = (double) Track->m_Start.x;
ty2 = (double)Track->m_Start.y; ty2 = (double) Track->m_Start.y;
RotatePoint(&tx2, &ty2, tx1, ty1, -900); RotatePoint( &tx2, &ty2, tx1, ty1, -900 );
} }
if (tx2!=tx1) { if( tx2!=tx1 )
s_EndSegmentSlope = (ty2 - ty1) / (tx2 - tx1); {
s_EndSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1); s_EndSegmentSlope = (ty2 - ty1) / (tx2 - tx1);
} else { s_EndSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1);
s_EndPointVertical = true; //signal second segment vertical }
} else
if (ty1==ty2) { {
s_EndPointHorizontal = true; s_EndPointVertical = true; //signal second segment vertical
} }
if( ty1==ty2 )
{
s_EndPointHorizontal = true;
}
// Init parameters for the moved segment // Init parameters for the moved segment
tx1 = (double)Track->m_Start.x; tx1 = (double) Track->m_Start.x;
ty1 = (double)Track->m_Start.y; ty1 = (double) Track->m_Start.y;
tx2 = (double)Track->m_End.x; tx2 = (double) Track->m_End.x;
ty2 = (double)Track->m_End.y; ty2 = (double) Track->m_End.y;
if (tx2 != tx1) { if( tx2 != tx1 )
s_MovingSegmentSlope = (ty2 - ty1) / (tx2 - tx1); {
} else { s_MovingSegmentSlope = (ty2 - ty1) / (tx2 - tx1);
s_MovingSegmentVertical = true; //signal vertical line }
} else
if (ty1==ty2) { {
s_MovingSegmentHorizontal=true; s_MovingSegmentVertical = true; //signal vertical line
} }
if( ty1==ty2 )
// Test if drag is possible: {
if( s_MovingSegmentVertical ) s_MovingSegmentHorizontal = true;
{ }
if ( s_EndPointVertical || s_StartPointVertical ) return false;
} // Test if drag is possible:
else if( s_MovingSegmentVertical )
{ if ( ! s_EndPointVertical && (s_MovingSegmentSlope == s_EndSegmentSlope) ) return false; {
if ( ! s_StartPointVertical && (s_MovingSegmentSlope == s_StartSegmentSlope) ) return false; if( s_EndPointVertical || s_StartPointVertical )
} return false;
}
return TRUE; else
{
if( !s_EndPointVertical && (s_MovingSegmentSlope == s_EndSegmentSlope) )
return false;
if( !s_StartPointVertical && (s_MovingSegmentSlope == s_StartSegmentSlope) )
return false;
}
return TRUE;
} }
/*************************************************************************************/ /*************************************************************************************/
void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment(TRACK * track, wxDC * DC, int command) void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command )
/*************************************************************************************/ /*************************************************************************************/
/* Init parametres to move one node: /* Init parametres to move one node:
a via or/and a terminal point of a track segment * a via or/and a terminal point of a track segment
The terminal point of other connected segments (if any) are moved too. * The terminal point of other connected segments (if any) are moved too.
*/ */
{ {
if ( ! track ) return; if( !track )
return;
NewTrack = NULL;
NbPtNewTrack = 0; NewTrack = NULL;
EraseDragListe(); NbPtNewTrack = 0;
EraseDragListe();
/* Change hight light net: the new one will be hightlighted */
Old_HightLigt_Status = g_HightLigt_Status; /* Change hight light net: the new one will be hightlighted */
Old_HightLigth_NetCode = g_HightLigth_NetCode; Old_HightLigt_Status = g_HightLigt_Status;
if(g_HightLigt_Status) Hight_Light(DC); Old_HightLigth_NetCode = g_HightLigth_NetCode;
PosInit = GetScreen()->m_Curseur; if( g_HightLigt_Status )
Hight_Light( DC );
if ( track->m_StructType == TYPEVIA) PosInit = GetScreen()->m_Curseur;
{
track->m_Flags = IS_DRAGGED|STARTPOINT|ENDPOINT; if( track->m_StructType == TYPEVIA )
if ( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT ) {
{ track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT;
Collect_TrackSegmentsToDrag(DrawPanel, DC, track->m_Start, if( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT )
track->ReturnMaskLayer(), track->m_NetCode); {
} Collect_TrackSegmentsToDrag( DrawPanel, DC, track->m_Start,
NewTrack = track; track->ReturnMaskLayer(), track->m_NetCode );
NbPtNewTrack = 1; }
PosInit = track->m_Start; NewTrack = track;
} NbPtNewTrack = 1;
PosInit = track->m_Start;
else }
{ else
int diag = track->IsPointOnEnds(GetScreen()->m_Curseur, -1); {
wxPoint pos; int diag = track->IsPointOnEnds( GetScreen()->m_Curseur, -1 );
switch ( command ) wxPoint pos;
{
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT: switch( command )
track->m_Flags |= IS_DRAGGED|ENDPOINT|STARTPOINT; {
AddSegmentToDragList(DrawPanel, DC, track->m_Flags, track); case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
break; track->m_Flags |= IS_DRAGGED | ENDPOINT | STARTPOINT;
AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track );
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: break;
pos = track->m_Start;
Collect_TrackSegmentsToDrag(DrawPanel, DC, pos, case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
track->ReturnMaskLayer(), track->m_NetCode); pos = track->m_Start;
pos = track->m_End; Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->m_Flags |= IS_DRAGGED|ENDPOINT|STARTPOINT; track->ReturnMaskLayer(), track->m_NetCode );
Collect_TrackSegmentsToDrag(DrawPanel, DC, pos, pos = track->m_End;
track->ReturnMaskLayer(), track->m_NetCode); track->m_Flags |= IS_DRAGGED | ENDPOINT | STARTPOINT;
break; Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->ReturnMaskLayer(), track->m_NetCode );
case ID_POPUP_PCB_MOVE_TRACK_NODE: break;
pos = (diag & STARTPOINT) ? track->m_Start : track->m_End;
Collect_TrackSegmentsToDrag(DrawPanel, DC, pos, case ID_POPUP_PCB_MOVE_TRACK_NODE:
track->ReturnMaskLayer(), track->m_NetCode); pos = (diag & STARTPOINT) ? track->m_Start : track->m_End;
PosInit = pos; Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
break; track->ReturnMaskLayer(), track->m_NetCode );
PosInit = pos;
} break;
track->m_Flags |= IS_DRAGGED; }
}
s_LastPos = PosInit;
DrawPanel->ManageCurseur = Show_MoveNode;
DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack;
g_HightLigth_NetCode = track->m_NetCode;
g_HightLigt_Status = TRUE;
DrawHightLight( DC, g_HightLigth_NetCode) ;
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE);
}
track->m_Flags |= IS_DRAGGED;
}
s_LastPos = PosInit;
DrawPanel->ManageCurseur = Show_MoveNode;
DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack;
g_HightLigth_NetCode = track->m_NetCode;
g_HightLigt_Status = TRUE;
DrawHightLight( DC, g_HightLigth_NetCode );
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
}
/***********************************************************************************/ /***********************************************************************************/
void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope(TRACK * track, wxDC * DC) void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC )
/***********************************************************************************/ /***********************************************************************************/
{ {
TRACK * TrackToStartPoint = NULL; TRACK* TrackToStartPoint = NULL;
TRACK * TrackToEndPoint = NULL; TRACK* TrackToEndPoint = NULL;
bool error = FALSE; bool error = FALSE;
if ( ! track ) return; if( !track )
return;
s_StartSegmentPresent = s_EndSegmentPresent = TRUE;
s_StartSegmentPresent = s_EndSegmentPresent = TRUE;
if ( (track->start == NULL) || (track->start->m_StructType == TYPETRACK) )
TrackToStartPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START); if( (track->start == NULL) || (track->start->m_StructType == TYPETRACK) )
// Test if more than one segment is connected to this point TrackToStartPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START );
if ( TrackToStartPoint )
{ // Test if more than one segment is connected to this point
TrackToStartPoint->SetState(BUSY,ON); if( TrackToStartPoint )
if ( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START) ) error = TRUE; {
TrackToStartPoint->SetState(BUSY,OFF); TrackToStartPoint->SetState( BUSY, ON );
} if( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START ) )
error = TRUE;
if ( (track->end == NULL) || (track->end->m_StructType == TYPETRACK) ) TrackToStartPoint->SetState( BUSY, OFF );
TrackToEndPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END); }
// Test if more than one segment is connected to this point
if ( TrackToEndPoint ) if( (track->end == NULL) || (track->end->m_StructType == TYPETRACK) )
{ TrackToEndPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END );
TrackToEndPoint->SetState(BUSY,ON);
if ( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END) ) error = TRUE; // Test if more than one segment is connected to this point
TrackToEndPoint->SetState(BUSY,OFF); if( TrackToEndPoint )
} {
TrackToEndPoint->SetState( BUSY, ON );
if ( error ) if( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END ) )
{ error = TRUE;
DisplayError( this, _("Unable to drag this segment: too many segments connected") ); TrackToEndPoint->SetState( BUSY, OFF );
return; }
}
if( error )
if ( !TrackToStartPoint || (TrackToStartPoint->m_StructType != TYPETRACK) ) {
s_StartSegmentPresent = FALSE; DisplayError( this, _( "Unable to drag this segment: too many segments connected" ) );
return;
if ( !TrackToEndPoint || (TrackToEndPoint->m_StructType != TYPETRACK) ) }
s_EndSegmentPresent = FALSE;
if( !TrackToStartPoint || (TrackToStartPoint->m_StructType != TYPETRACK) )
/* Change hight light net: the new one will be hightlighted */ s_StartSegmentPresent = FALSE;
Old_HightLigt_Status = g_HightLigt_Status;
Old_HightLigth_NetCode = g_HightLigth_NetCode; if( !TrackToEndPoint || (TrackToEndPoint->m_StructType != TYPETRACK) )
if(g_HightLigt_Status) Hight_Light(DC); s_EndSegmentPresent = FALSE;
EraseDragListe(); /* Change hight light net: the new one will be hightlighted */
Old_HightLigt_Status = g_HightLigt_Status;
NewTrack = NULL; Old_HightLigth_NetCode = g_HightLigth_NetCode;
NbPtNewTrack = 0; if( g_HightLigt_Status )
track->m_Flags = IS_DRAGGED; Hight_Light( DC );
if( TrackToStartPoint ) EraseDragListe();
{
int flag = STARTPOINT; NewTrack = NULL;
if ( track->m_Start != TrackToStartPoint->m_Start ) flag = ENDPOINT; NbPtNewTrack = 0;
AddSegmentToDragList(DrawPanel, DC, flag, TrackToStartPoint); track->m_Flags = IS_DRAGGED;
track->m_Flags |= STARTPOINT;
} if( TrackToStartPoint )
if( TrackToEndPoint ) {
{ int flag = STARTPOINT;
int flag = STARTPOINT; if( track->m_Start != TrackToStartPoint->m_Start )
if ( track->m_End != TrackToEndPoint->m_Start ) flag = ENDPOINT; flag = ENDPOINT;
AddSegmentToDragList(DrawPanel, DC, flag, TrackToEndPoint); AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint );
track->m_Flags |= ENDPOINT; track->m_Flags |= STARTPOINT;
} }
if( TrackToEndPoint )
AddSegmentToDragList(DrawPanel, DC, track->m_Flags, track); {
int flag = STARTPOINT;
if( track->m_End != TrackToEndPoint->m_Start )
PosInit=GetScreen()->m_Curseur; flag = ENDPOINT;
s_LastPos = GetScreen()->m_Curseur; AddSegmentToDragList( DrawPanel, DC, flag, TrackToEndPoint );
DrawPanel->ManageCurseur = Show_Drag_Track_Segment_With_Cte_Slope; track->m_Flags |= ENDPOINT;
DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack; }
g_HightLigth_NetCode = track->m_NetCode; AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track );
g_HightLigt_Status = TRUE;
DrawHightLight( DC, g_HightLigth_NetCode) ;
PosInit = GetScreen()->m_Curseur;
if ( ! InitialiseDragParameters() ) s_LastPos = GetScreen()->m_Curseur;
{ DrawPanel->ManageCurseur = Show_Drag_Track_Segment_With_Cte_Slope;
DisplayError( this, _("Unable to drag this segment: two collinear segments") ); DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack;
DrawPanel->ManageCurseur = NULL;
Abort_MoveTrack(DrawPanel, DC); g_HightLigth_NetCode = track->m_NetCode;
return; g_HightLigt_Status = TRUE;
} DrawHightLight( DC, g_HightLigth_NetCode );
if( !InitialiseDragParameters() )
{
DisplayError( this, _( "Unable to drag this segment: two collinear segments" ) );
DrawPanel->ManageCurseur = NULL;
Abort_MoveTrack( DrawPanel, DC );
return;
}
} }
/**********************************************************************/ /**********************************************************************/
bool WinEDA_PcbFrame::PlaceDraggedTrackSegment(TRACK * Track, wxDC * DC) bool WinEDA_PcbFrame::PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC )
/**********************************************************************/ /**********************************************************************/
/* Place a dragged (or moved) track segment or via */ /* Place a dragged (or moved) track segment or via */
{ {
int errdrc; int errdrc;
DRAG_SEGM * pt_drag; DRAG_SEGM* pt_drag;
if(Track == NULL ) return FALSE;
if( Track == NULL )
int current_net_code = Track->m_NetCode; return FALSE;
// DRC control: int current_net_code = Track->m_NetCode;
if(Drc_On)
{ // DRC control:
errdrc = Drc(this, DC, Track, m_Pcb->m_Track,1); if( Drc_On )
if(errdrc == BAD_DRC) return FALSE; {
/* Redraw the dragged segments */ errdrc = Drc( this, DC, Track, m_Pcb->m_Track, 1 );
pt_drag = g_DragSegmentList; if( errdrc == BAD_DRC )
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) return FALSE;
{ /* Redraw the dragged segments */
errdrc = Drc(this, DC, pt_drag->m_Segm, m_Pcb->m_Track,1); pt_drag = g_DragSegmentList;
if(errdrc == BAD_DRC) return FALSE; for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
} {
} errdrc = Drc( this, DC, pt_drag->m_Segm, m_Pcb->m_Track, 1 );
if( errdrc == BAD_DRC )
int draw_mode = GR_OR | GR_SURBRILL; return FALSE;
}
// DRC Ok: place track segments }
Track->m_Flags = 0;
Track->SetState(EDIT,OFF); int draw_mode = GR_OR | GR_SURBRILL;
Track->Draw(DrawPanel, DC, draw_mode);
// DRC Ok: place track segments
/* Tracage des segments dragges */ Track->m_Flags = 0;
pt_drag = g_DragSegmentList; Track->SetState( EDIT, OFF );
for( ; pt_drag; pt_drag = pt_drag->Pnext) Track->Draw( DrawPanel, DC, draw_mode );
{
Track = pt_drag->m_Segm; /* Tracage des segments dragges */
Track->SetState(EDIT,OFF); pt_drag = g_DragSegmentList;
Track->m_Flags = 0; for( ; pt_drag; pt_drag = pt_drag->Pnext )
Track->Draw(DrawPanel, DC, draw_mode); {
/* Test the connections modified by the move Track = pt_drag->m_Segm;
(only pad connection must be tested, track connection will be tested by test_1_net_connexion() ) */ Track->SetState( EDIT, OFF );
int masque_layer = g_TabOneLayerMask[Track->m_Layer]; Track->m_Flags = 0;
Track->start = Fast_Locate_Pad_Connecte(m_Pcb, Track->m_Start, masque_layer); Track->Draw( DrawPanel, DC, draw_mode );
Track->end = Fast_Locate_Pad_Connecte(m_Pcb, Track->m_End, masque_layer);
} /* Test the connections modified by the move
* (only pad connection must be tested, track connection will be tested by test_1_net_connexion() ) */
EraseDragListe(); int masque_layer = g_TabOneLayerMask[Track->m_Layer];
Track->start = Fast_Locate_Pad_Connecte( m_Pcb, Track->m_Start, masque_layer );
GetScreen()->SetModify(); Track->end = Fast_Locate_Pad_Connecte( m_Pcb, Track->m_End, masque_layer );
DrawPanel->ManageCurseur = NULL; }
DrawPanel->ForceCloseManageCurseur = NULL;
EraseDragListe();
if ( current_net_code > 0 ) test_1_net_connexion(DC, current_net_code);
GetScreen()->SetModify();
return TRUE; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
if( current_net_code > 0 )
test_1_net_connexion( DC, current_net_code );
return TRUE;
} }
/************************************************************************/ /************************************************************************/
EDA_BaseStruct * LocateLockPoint(BOARD * Pcb, wxPoint pos, int LayerMask) EDA_BaseStruct* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
/************************************************************************/ /************************************************************************/
/* Routine trouvant le point " d'accrochage " d'une extremite de piste. /* Routine trouvant le point " d'accrochage " d'une extremite de piste.
Ce point peut etre un PAD ou un autre segment de piste * Ce point peut etre un PAD ou un autre segment de piste
Retourne: * Retourne:
- pointeur sur ce PAD ou: * - pointeur sur ce PAD ou:
- pointeur sur le segment ou: * - pointeur sur le segment ou:
- NULL * - NULL
Parametres d'appel: * Parametres d'appel:
coord pX, pY du point tst * coord pX, pY du point tst
masque des couches a tester * masque des couches a tester
*/ */
{ {
D_PAD * pt_pad; D_PAD* pt_pad;
TRACK * ptsegm; TRACK* ptsegm;
MODULE * Module; MODULE* Module;
/* detection du point type PAD */ /* detection du point type PAD */
pt_pad = NULL; pt_pad = NULL;
Module = Pcb->m_Modules; Module = Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
pt_pad = Locate_Pads(Module, pos, LayerMask); pt_pad = Locate_Pads( Module, pos, LayerMask );
if (pt_pad) return(pt_pad); if( pt_pad )
} return pt_pad;
}
/* ici aucun pad n'a ete localise: detection d'un segment de piste */
/* ici aucun pad n'a ete localise: detection d'un segment de piste */
ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask);
if( ptsegm == NULL ) ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask); if( ptsegm == NULL )
return(ptsegm); ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask );
return ptsegm;
} }
/******************************************************************************/ /******************************************************************************/
TRACK * CreateLockPoint(int *pX, int *pY, TRACK * ptsegm, TRACK * refsegm) TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm )
/******************************************************************************/ /******************************************************************************/
/* Routine de creation d'un point intermediaire sur un segment /* Routine de creation d'un point intermediaire sur un segment
le segment ptsegm est casse en 2 segments se raccordant au point pX, pY * le segment ptsegm est casse en 2 segments se raccordant au point pX, pY
retourne: * retourne:
NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja * NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja
a une extremite ou: * a une extremite ou:
pointeur sur le segment cree * pointeur sur le segment cree
si refsegm != NULL refsegm est pointeur sur le segment incident, * si refsegm != NULL refsegm est pointeur sur le segment incident,
et le point cree est l'intersection des 2 axes des segments ptsegm et * et le point cree est l'intersection des 2 axes des segments ptsegm et
refsegm * refsegm
retourne la valeur exacte de pX et pY * retourne la valeur exacte de pX et pY
Si ptsegm pointe sur une via: * Si ptsegm pointe sur une via:
retourne la valeur exacte de pX et pY et ptsegm, * retourne la valeur exacte de pX et pY et ptsegm,
mais ne cree pas de point supplementaire * mais ne cree pas de point supplementaire
*
*/ */
{ {
int cX, cY; int cX, cY;
int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */ int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */
int ox, oy, fx , fy; /* coord de refsegm / origine de prsegm */ int ox, oy, fx, fy; /* coord de refsegm / origine de prsegm */
TRACK * NewTrack; TRACK* NewTrack;
if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) ) return(NULL); if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) )
if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) ) return(NULL); return NULL;
if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) )
/* le point n'est pas sur une extremite de piste */ return NULL;
if(ptsegm->m_StructType == TYPEVIA )
{ /* le point n'est pas sur une extremite de piste */
*pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y; if( ptsegm->m_StructType == TYPEVIA )
return(ptsegm); {
} *pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y;
/* calcul des coord vraies du point intermediaire dans le repere d'origine return ptsegm;
= origine de ptsegm */ }
cX = *pX - ptsegm->m_Start.x;
/* calcul des coord vraies du point intermediaire dans le repere d'origine
* = origine de ptsegm */
cX = *pX - ptsegm->m_Start.x;
cY = *pY - ptsegm->m_Start.y; cY = *pY - ptsegm->m_Start.y;
dx = ptsegm->m_End.x - ptsegm->m_Start.x; dx = ptsegm->m_End.x - ptsegm->m_Start.x;
dy = ptsegm->m_End.y - ptsegm->m_Start.y; dy = ptsegm->m_End.y - ptsegm->m_Start.y;
// ***** A COMPLETER : non utilise // ***** A COMPLETER : non utilise
if ( refsegm ) if( refsegm )
{ {
ox = refsegm->m_Start.x - ptsegm->m_Start.x; ox = refsegm->m_Start.x - ptsegm->m_Start.x;
oy = refsegm->m_Start.y - ptsegm->m_Start.y; oy = refsegm->m_Start.y - ptsegm->m_Start.y;
fx = refsegm->m_End.x - ptsegm->m_Start.x; fx = refsegm->m_End.x - ptsegm->m_Start.x;
fy = refsegm->m_End.y - ptsegm->m_Start.y; fy = refsegm->m_End.y - ptsegm->m_Start.y;
} }
/* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */ /* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */
if ( dx == 0 ) cX = 0; /* segm horizontal */ if( dx == 0 )
else cY = (cX * dy) / dx; cX = 0; /* segm horizontal */
else
cY = (cX * dy) / dx;
/* creation du point intermediaire ( c'est a dire creation d'un nouveau /* creation du point intermediaire ( c'est a dire creation d'un nouveau
segment, debutant au point intermediaire */ * segment, debutant au point intermediaire */
cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y; cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y;
NewTrack = ptsegm->Copy(); NewTrack = ptsegm->Copy();
NewTrack->Insert(NULL, ptsegm); NewTrack->Insert( NULL, ptsegm );
/* correction du pointeur de fin du nouveau segment */ /* correction du pointeur de fin du nouveau segment */
NewTrack->end = ptsegm->end; NewTrack->end = ptsegm->end;
/* le segment primitif finit au nouveau point : */ /* le segment primitif finit au nouveau point : */
ptsegm->m_End.x = cX; ptsegm->m_End.y = cY; ptsegm->m_End.x = cX; ptsegm->m_End.y = cY;
ptsegm->SetState(END_ONPAD, OFF); ptsegm->SetState( END_ONPAD, OFF );
/* le nouveau segment debute au nouveau point : */ /* le nouveau segment debute au nouveau point : */
ptsegm = NewTrack;; ptsegm = NewTrack;;
ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY; ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY;
ptsegm->SetState(BEGIN_ONPAD, OFF); ptsegm->SetState( BEGIN_ONPAD, OFF );
*pX = cX; *pY = cY; *pX = cX; *pY = cY;
return(ptsegm);
return ptsegm;
} }
/* Set up the basic primitives for Layer control */ /* Set up the basic primitives for Layer control */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
/* Fonctions locales: */ /* Fonctions locales: */
enum layer_sel_id { enum layer_sel_id {
ID_LAYER_OK = 1800, ID_LAYER_OK = 1800,
ID_LAYER_CANCEL, ID_LAYER_CANCEL,
ID_LAYER_SELECT_TOP, ID_LAYER_SELECT_TOP,
ID_LAYER_SELECT_BOTTOM, ID_LAYER_SELECT_BOTTOM,
ID_LAYER_SELECT ID_LAYER_SELECT
}; };
...@@ -26,122 +27,136 @@ enum layer_sel_id { ...@@ -26,122 +27,136 @@ enum layer_sel_id {
/* classe pour la frame de selection de layers */ /* classe pour la frame de selection de layers */
/***********************************************/ /***********************************************/
class WinEDA_SelLayerFrame: public wxDialog class WinEDA_SelLayerFrame : public wxDialog
{ {
private: private:
WinEDA_BasePcbFrame *m_Parent; WinEDA_BasePcbFrame* m_Parent;
wxRadioBox * m_LayerList; wxRadioBox* m_LayerList;
int m_LayerId[NB_LAYERS]; int m_LayerId[NB_LAYERS];
public: public:
// Constructor and destructor
WinEDA_SelLayerFrame(WinEDA_BasePcbFrame *parent, int default_layer, // Constructor and destructor
int min_layer, int max_layer); WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, int default_layer,
~WinEDA_SelLayerFrame(void) {}; int min_layer, int max_layer );
~WinEDA_SelLayerFrame( void ) { };
private: private:
void Sel_Layer(wxCommandEvent& event); void Sel_Layer( wxCommandEvent& event );
void Cancel(wxCommandEvent& event); void Cancel( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
DECLARE_EVENT_TABLE()
}; };
/* Table des evenements pour WinEDA_SelLayerFrame */ /* Table des evenements pour WinEDA_SelLayerFrame */
BEGIN_EVENT_TABLE(WinEDA_SelLayerFrame, wxDialog) BEGIN_EVENT_TABLE( WinEDA_SelLayerFrame, wxDialog )
EVT_BUTTON(ID_LAYER_OK, WinEDA_SelLayerFrame::Sel_Layer) EVT_BUTTON( ID_LAYER_OK, WinEDA_SelLayerFrame::Sel_Layer )
EVT_BUTTON(ID_LAYER_CANCEL, WinEDA_SelLayerFrame::Cancel) EVT_BUTTON( ID_LAYER_CANCEL, WinEDA_SelLayerFrame::Cancel )
EVT_RADIOBOX(ID_LAYER_SELECT, WinEDA_SelLayerFrame::Sel_Layer) EVT_RADIOBOX( ID_LAYER_SELECT, WinEDA_SelLayerFrame::Sel_Layer )
END_EVENT_TABLE() END_EVENT_TABLE()
/***********************************************************************************/ /***********************************************************************************/
int WinEDA_BasePcbFrame::SelectLayer(int default_layer, int min_layer, int max_layer) int WinEDA_BasePcbFrame::SelectLayer( int default_layer, int min_layer, int max_layer )
/***********************************************************************************/ /***********************************************************************************/
/* Install the dialog box for layer selection /* Install the dialog box for layer selection
default_layer = Preselection * default_layer = Preselection
min_layer = val min de layer selectionnable (-1 si pas de val mini) * min_layer = val min de layer selectionnable (-1 si pas de val mini)
max_layer = val max de layer selectionnable (-1 si pas de val maxi) * max_layer = val max de layer selectionnable (-1 si pas de val maxi)
*/ */
{ {
int layer; int layer;
WinEDA_SelLayerFrame * frame = WinEDA_SelLayerFrame* frame =
new WinEDA_SelLayerFrame(this, default_layer,min_layer, max_layer); new WinEDA_SelLayerFrame( this, default_layer, min_layer, max_layer );
layer = frame->ShowModal(); frame->Destroy();
return layer; layer = frame->ShowModal(); frame->Destroy();
return layer;
} }
/***********************************************************************/ /***********************************************************************/
WinEDA_SelLayerFrame::WinEDA_SelLayerFrame(WinEDA_BasePcbFrame *parent, WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent,
int default_layer, int min_layer, int max_layer): int default_layer, int min_layer, int max_layer ) :
wxDialog(parent, -1, _("Select Layer:"),wxPoint(-1,-1), wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ),
wxSize(470, 250), wxSize( 470, 250 ),
DIALOG_STYLE ) DIALOG_STYLE )
/***********************************************************************/ /***********************************************************************/
{ {
wxButton * Button; wxButton* Button;
int ii, yy, xx; int ii, yy, xx;
wxPoint pos; wxPoint pos;
wxString LayerList[NB_LAYERS]; wxString LayerList[NB_LAYERS];
int LayerCount, LayerSelect = -1; int LayerCount, LayerSelect = -1;
m_Parent = parent; m_Parent = parent;
SetFont(*g_DialogFont); SetFont( *g_DialogFont );
/* Construction de la liste des couches autorises */ /* Construction de la liste des couches autoris�s */
LayerCount = 0; LayerCount = 0;
int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]; int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount - 1];
Masque_Layer += ALL_NO_CU_LAYERS; Masque_Layer += ALL_NO_CU_LAYERS;
for ( ii = 0; ii < NB_LAYERS ; ii ++ ) for( ii = 0; ii < NB_LAYERS; ii++ )
{ {
m_LayerId[ii] = 0; m_LayerId[ii] = 0;
if ( (g_TabOneLayerMask[ii] & Masque_Layer) ) if( (g_TabOneLayerMask[ii] & Masque_Layer) )
{ {
if ( min_layer > ii ) continue; if( min_layer > ii )
if ( (max_layer >= 0) && (max_layer < ii) ) break; continue;
LayerList[LayerCount] = ReturnPcbLayerName(ii);
if ( ii == default_layer ) LayerSelect = LayerCount; if( (max_layer >= 0) && (max_layer < ii) )
m_LayerId[LayerCount] = ii; break;
LayerCount++;
} LayerList[LayerCount] = ReturnPcbLayerName( ii );
} if( ii == default_layer )
LayerSelect = LayerCount;
pos.x = 5; pos.y = 5;
m_LayerId[LayerCount] = ii;
m_LayerList = new wxRadioBox(this, ID_LAYER_SELECT, _("Layer"), LayerCount++;
pos, wxSize(-1,-1), LayerCount, LayerList, }
(LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS); }
if ( LayerSelect >= 0 ) m_LayerList->SetSelection(LayerSelect); pos.x = 5; pos.y = 5;
m_LayerList->GetSize(&xx, &yy); m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _( "Layer" ),
pos.x += xx + 12; pos, wxSize( -1, -1 ), LayerCount, LayerList,
Button = new wxButton(this,ID_LAYER_OK, (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS );
_("OK"), pos);
Button->SetForegroundColour(*wxBLUE); if( LayerSelect >= 0 )
m_LayerList->SetSelection( LayerSelect );
pos.y += Button->GetSize().y + 5;
Button = new wxButton(this,ID_LAYER_CANCEL, m_LayerList->GetSize( &xx, &yy );
_("Cancel"), pos); pos.x += xx + 12;
Button->SetForegroundColour(*wxRED); Button = new wxButton( this, ID_LAYER_OK,
_( "OK" ), pos );
Button->SetForegroundColour( *wxBLUE );
pos.y += Button->GetSize().y + 5;
Button = new wxButton( this, ID_LAYER_CANCEL,
_( "Cancel" ), pos );
Button->SetForegroundColour( *wxRED );
/* Redimensionnement de la boite de dialogue: */ /* Redimensionnement de la boite de dialogue: */
pos.x += Button->GetSize().x + 10; pos.x += Button->GetSize().x + 10;
SetSize(-1, -1, pos.x , yy + 35); SetSize( -1, -1, pos.x, yy + 35 );
} }
/***************************************************************/ /***************************************************************/
void WinEDA_SelLayerFrame::Sel_Layer(wxCommandEvent& event) void WinEDA_SelLayerFrame::Sel_Layer( wxCommandEvent& event )
/***************************************************************/ /***************************************************************/
{ {
int ii = m_LayerId[m_LayerList->GetSelection()]; int ii = m_LayerId[m_LayerList->GetSelection()];
EndModal(ii);
EndModal( ii );
} }
/***************************************************************/ /***************************************************************/
void WinEDA_SelLayerFrame::Cancel(wxCommandEvent& event) void WinEDA_SelLayerFrame::Cancel( wxCommandEvent& event )
/***************************************************************/ /***************************************************************/
{ {
EndModal(-1); EndModal( -1 );
} }
...@@ -149,129 +164,130 @@ void WinEDA_SelLayerFrame::Cancel(wxCommandEvent& event) ...@@ -149,129 +164,130 @@ void WinEDA_SelLayerFrame::Cancel(wxCommandEvent& event)
/* classe pour la frame de selection de paires de layers */ /* classe pour la frame de selection de paires de layers */
/*********************************************************/ /*********************************************************/
class WinEDA_SelLayerPairFrame: public wxDialog class WinEDA_SelLayerPairFrame : public wxDialog
{ {
private: private:
WinEDA_BasePcbFrame *m_Parent; WinEDA_BasePcbFrame* m_Parent;
wxRadioBox * m_LayerListTOP; wxRadioBox* m_LayerListTOP;
wxRadioBox * m_LayerListBOTTOM; wxRadioBox* m_LayerListBOTTOM;
int m_LayerId[NB_COPPER_LAYERS]; int m_LayerId[NB_COPPER_LAYERS];
public: public:
// Constructor and destructor // Constructor and destructor
WinEDA_SelLayerPairFrame(WinEDA_BasePcbFrame *parent); WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent );
~WinEDA_SelLayerPairFrame(void) {}; ~WinEDA_SelLayerPairFrame( void ) { };
private: private:
void Sel_Layer(wxCommandEvent& event); void Sel_Layer( wxCommandEvent& event );
void Cancel(wxCommandEvent& event); void Cancel( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
DECLARE_EVENT_TABLE()
}; };
/* Table des evenements pour WinEDA_SelLayerPairFrame */ /* Table des evenements pour WinEDA_SelLayerPairFrame */
BEGIN_EVENT_TABLE(WinEDA_SelLayerPairFrame, wxDialog) BEGIN_EVENT_TABLE( WinEDA_SelLayerPairFrame, wxDialog )
EVT_BUTTON(ID_LAYER_OK, WinEDA_SelLayerPairFrame::Sel_Layer) EVT_BUTTON( ID_LAYER_OK, WinEDA_SelLayerPairFrame::Sel_Layer )
EVT_BUTTON(ID_LAYER_CANCEL, WinEDA_SelLayerPairFrame::Cancel) EVT_BUTTON( ID_LAYER_CANCEL, WinEDA_SelLayerPairFrame::Cancel )
EVT_RADIOBOX(ID_LAYER_SELECT, WinEDA_SelLayerPairFrame::Sel_Layer) EVT_RADIOBOX( ID_LAYER_SELECT, WinEDA_SelLayerPairFrame::Sel_Layer )
END_EVENT_TABLE() END_EVENT_TABLE()
/***********************************************/ /***********************************************/
void WinEDA_BasePcbFrame::SelectLayerPair(void) void WinEDA_BasePcbFrame::SelectLayerPair( void )
/***********************************************/ /***********************************************/
/* Affiche une double liste de layers cuivre pour selection d'une paire de layers /* Affiche une double liste de layers cuivre pour selection d'une paire de layers
pour autorutage, vias... * pour autorutage, vias...
*/ */
{ {
WinEDA_SelLayerPairFrame * frame = WinEDA_SelLayerPairFrame* frame =
new WinEDA_SelLayerPairFrame(this); new WinEDA_SelLayerPairFrame( this );
frame->ShowModal(); frame->Destroy();
DrawPanel->MouseToCursorSchema(); frame->ShowModal(); frame->Destroy();
SetToolbars(); DrawPanel->MouseToCursorSchema();
SetToolbars();
} }
/*******************************************************************************/ /*******************************************************************************/
WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame(WinEDA_BasePcbFrame *parent): WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent ) :
wxDialog(parent, -1, _("Select Layer Pair:"),wxPoint(-1,-1), wxDialog( parent, -1, _( "Select Layer Pair:" ), wxPoint( -1, -1 ),
wxSize(470, 250), DIALOG_STYLE ) wxSize( 470, 250 ), DIALOG_STYLE )
/*******************************************************************************/ /*******************************************************************************/
{ {
wxButton * Button; wxButton* Button;
int ii, LayerCount; int ii, LayerCount;
int yy, xx; int yy, xx;
wxPoint pos; wxPoint pos;
wxString LayerList[NB_COPPER_LAYERS]; wxString LayerList[NB_COPPER_LAYERS];
int LayerTopSelect = 0, LayerBottomSelect = 0 ; int LayerTopSelect = 0, LayerBottomSelect = 0;
m_Parent = parent; m_Parent = parent;
SetFont(*g_DialogFont); SetFont( *g_DialogFont );
PCB_SCREEN * screen = (PCB_SCREEN *) m_Parent->m_CurrentScreen; PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->m_CurrentScreen;
/* Construction de la liste des couches autorises */ /* Construction de la liste des couches autoris�s */
int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount-1]; int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.m_CopperLayerCount - 1];
Masque_Layer += ALL_NO_CU_LAYERS; Masque_Layer += ALL_NO_CU_LAYERS;
for ( ii = 0, LayerCount = 0; ii < NB_COPPER_LAYERS ; ii ++ ) for( ii = 0, LayerCount = 0; ii < NB_COPPER_LAYERS; ii++ )
{ {
m_LayerId[ii] = 0; m_LayerId[ii] = 0;
if ( (g_TabOneLayerMask[ii] & Masque_Layer) ) if( (g_TabOneLayerMask[ii] & Masque_Layer) )
{ {
LayerList[LayerCount] = ReturnPcbLayerName(ii); LayerList[LayerCount] = ReturnPcbLayerName( ii );
if ( ii == screen->m_Route_Layer_TOP ) if( ii == screen->m_Route_Layer_TOP )
LayerTopSelect = LayerCount; LayerTopSelect = LayerCount;
if ( ii == screen->m_Route_Layer_BOTTOM ) if( ii == screen->m_Route_Layer_BOTTOM )
LayerBottomSelect = LayerCount; LayerBottomSelect = LayerCount;
m_LayerId[LayerCount] = ii; m_LayerId[LayerCount] = ii;
LayerCount++; LayerCount++;
} }
} }
pos.x = 5; pos.y = 5; pos.x = 5; pos.y = 5;
m_LayerListTOP = new wxRadioBox(this, ID_LAYER_SELECT_TOP, _("Top Layer"), m_LayerListTOP = new wxRadioBox( this, ID_LAYER_SELECT_TOP, _( "Top Layer" ),
pos, wxSize(-1,-1), LayerCount, LayerList, pos, wxSize( -1, -1 ), LayerCount, LayerList,
(LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS); (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS );
m_LayerListTOP->SetSelection(LayerTopSelect); m_LayerListTOP->SetSelection( LayerTopSelect );
m_LayerListTOP->GetSize(&xx, &yy); m_LayerListTOP->GetSize( &xx, &yy );
pos.x += xx + 12; pos.x += xx + 12;
m_LayerListBOTTOM = new wxRadioBox(this, ID_LAYER_SELECT_BOTTOM, _("Bottom Layer"), m_LayerListBOTTOM = new wxRadioBox( this, ID_LAYER_SELECT_BOTTOM, _( "Bottom Layer" ),
pos, wxSize(-1,-1), LayerCount, LayerList, pos, wxSize( -1, -1 ), LayerCount, LayerList,
(LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS); (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS );
m_LayerListBOTTOM->SetSelection(LayerBottomSelect); m_LayerListBOTTOM->SetSelection( LayerBottomSelect );
m_LayerListBOTTOM->GetSize(&xx, &yy); m_LayerListBOTTOM->GetSize( &xx, &yy );
pos.x += xx + 12; pos.x += xx + 12;
Button = new wxButton(this,ID_LAYER_OK, Button = new wxButton( this, ID_LAYER_OK, _( "OK" ), pos );
_("OK"), pos); Button->SetForegroundColour( *wxBLUE );
Button->SetForegroundColour(*wxBLUE);
pos.y += Button->GetSize().y + 5;
pos.y += Button->GetSize().y + 5; Button = new wxButton( this, ID_LAYER_CANCEL, _( "Cancel" ), pos );
Button = new wxButton(this,ID_LAYER_CANCEL, Button->SetForegroundColour( *wxRED );
_("Cancel"), pos);
Button->SetForegroundColour(*wxRED);
/* Redimensionnement de la boite de dialogue: */ /* Redimensionnement de la boite de dialogue: */
pos.x += Button->GetSize().x + 10; pos.x += Button->GetSize().x + 10;
SetSize(-1, -1, pos.x , yy + 35); SetSize( -1, -1, pos.x, yy + 35 );
} }
/***************************************************************/ /***************************************************************/
void WinEDA_SelLayerPairFrame::Sel_Layer(wxCommandEvent& event) void WinEDA_SelLayerPairFrame::Sel_Layer( wxCommandEvent& event )
/***************************************************************/ /***************************************************************/
{ {
PCB_SCREEN * screen = (PCB_SCREEN *) m_Parent->m_CurrentScreen; PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->m_CurrentScreen;
screen->m_Route_Layer_TOP = m_LayerId[m_LayerListTOP->GetSelection()]; screen->m_Route_Layer_TOP = m_LayerId[m_LayerListTOP->GetSelection()];
screen->m_Route_Layer_BOTTOM = m_LayerId[m_LayerListBOTTOM->GetSelection()]; screen->m_Route_Layer_BOTTOM = m_LayerId[m_LayerListBOTTOM->GetSelection()];
EndModal(0); EndModal( 0 );
} }
/***************************************************************/ /***************************************************************/
void WinEDA_SelLayerPairFrame::Cancel(wxCommandEvent& event) void WinEDA_SelLayerPairFrame::Cancel( wxCommandEvent& event )
/***************************************************************/ /***************************************************************/
{ {
EndModal(-1); EndModal( -1 );
} }
/****************************/ /****************************/
/* affichage des empreintes */ /* affichage des empreintes */
/****************************/ /****************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -12,160 +12,171 @@ ...@@ -12,160 +12,171 @@
#define Pad_fill (Pad_Fill_Item.State == RUN) #define Pad_fill (Pad_Fill_Item.State == RUN)
static void Pad_Surbrillance(WinEDA_DrawPanel * panel, wxDC * DC, MODULE * Module, int NetCode); static void Pad_Surbrillance( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, int NetCode );
/* variables locales : */ /* variables locales : */
static int draw_mode ; static int draw_mode;
/*********************************************************/ /*********************************************************/
void WinEDA_PcbFrame::Liste_Equipot(wxCommandEvent & event) void WinEDA_PcbFrame::Liste_Equipot( wxCommandEvent& event )
/*********************************************************/ /*********************************************************/
/* Display a filtered list of equipot names /* Display a filtered list of equipot names
if an equipot is selected the corresponding tracks and pads are highlighted * if an equipot is selected the corresponding tracks and pads are highlighted
*/ */
{ {
EQUIPOT * Equipot ; EQUIPOT* Equipot;
wxString msg; wxString msg;
WinEDA_TextFrame * List; WinEDA_TextFrame* List;
int ii, jj; int ii, jj;
msg = wxT("*"); msg = wxT( "*" );
Get_Message(_("Filter for net names:"),msg, this); Get_Message( _( "Filter for net names:" ), msg, this );
if ( msg.IsEmpty() ) return; if( msg.IsEmpty() )
return;
List = new WinEDA_TextFrame(this, _("List Nets") );
List = new WinEDA_TextFrame( this, _( "List Nets" ) );
Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
for ( ; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
{ for( ; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
wxString Line; {
/* calcul adr relative du nom de la pastille reference de la piste */ wxString Line;
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE ) ) continue ; /* calcul adr relative du nom de la pastille reference de la piste */
if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
Line.Printf( wxT("net_code = %3.3d [%.16s] "),Equipot->m_NetCode, continue;
Equipot->m_Netname.GetData());
List->Append(Line); Line.Printf( wxT( "net_code = %3.3d [%.16s] " ), Equipot->m_NetCode,
} Equipot->m_Netname.GetData() );
ii = List->ShowModal(); List->Destroy(); List->Append( Line );
if (ii < 0) return; }
/* Recherche du numero de net rellement selectionn */ ii = List->ShowModal(); List->Destroy();
Equipot = (EQUIPOT*) m_Pcb->m_Equipots; if( ii < 0 )
for ( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) return;
{
/* calcul adr relative du nom de la pastille reference de la piste */ /* Recherche du numero de net rellement selectionn�*/
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE) ) continue ; Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
if ( ii == jj ) for( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
{ {
ii = Equipot->m_NetCode; /* calcul adr relative du nom de la pastille reference de la piste */
break; if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
} continue;
jj++; if( ii == jj )
} {
ii = Equipot->m_NetCode;
break;
wxClientDC dc(DrawPanel); }
DrawPanel->PrepareGraphicContext(&dc); jj++;
}
if(g_HightLigt_Status) Hight_Light(&dc);
g_HightLigth_NetCode = ii; wxClientDC dc( DrawPanel );
Hight_Light(&dc);
DrawPanel->PrepareGraphicContext( &dc );
if( g_HightLigt_Status )
Hight_Light( &dc );
g_HightLigth_NetCode = ii;
Hight_Light( &dc );
} }
/**************************************************/ /**************************************************/
int WinEDA_PcbFrame::Select_High_Light(wxDC * DC) int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
/**************************************************/ /**************************************************/
/* Localise track ou pad et met en surbrillance le net correspondant /* Localise track ou pad et met en surbrillance le net correspondant
Retourne le netcode, ou -1 si pas de net localis */ * Retourne le netcode, ou -1 si pas de net localis�*/
{ {
TRACK * pt_piste; TRACK* pt_piste;
D_PAD* pt_pad ; D_PAD* pt_pad;
int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];
int code = -1; int code = -1;
if ( g_HightLigt_Status ) Hight_Light(DC); if( g_HightLigt_Status )
pt_piste = Locate_Pistes(m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE); Hight_Light( DC );
if ( pt_piste) pt_piste = Locate_Pistes( m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE );
{ if( pt_piste )
code = g_HightLigth_NetCode = pt_piste->m_NetCode; {
Hight_Light(DC); code = g_HightLigth_NetCode = pt_piste->m_NetCode;
} Hight_Light( DC );
else }
{ else
pt_pad = Locate_Any_Pad(m_Pcb, CURSEUR_OFF_GRILLE); {
if( pt_pad != NULL ) pt_pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE );
{ if( pt_pad != NULL )
code = g_HightLigth_NetCode = pt_pad->m_NetCode ; {
Hight_Light(DC) ; code = g_HightLigth_NetCode = pt_pad->m_NetCode;
} Hight_Light( DC );
} }
}
return code;
return code;
} }
/*******************************************/ /*******************************************/
void WinEDA_PcbFrame::Hight_Light(wxDC * DC) void WinEDA_PcbFrame::Hight_Light( wxDC* DC )
/*******************************************/ /*******************************************/
/* /*
fonction d'appel de Surbrillance a partir du menu * fonction d'appel de Surbrillance a partir du menu
Met ou supprime la surbrillance d'un net pointe par la souris * Met ou supprime la surbrillance d'un net pointe par la souris
*/ */
{ {
g_HightLigt_Status = !g_HightLigt_Status; g_HightLigt_Status = !g_HightLigt_Status;
DrawHightLight( DC, g_HightLigth_NetCode) ; DrawHightLight( DC, g_HightLigth_NetCode );
} }
/****************************************************************/ /****************************************************************/
void WinEDA_PcbFrame::DrawHightLight(wxDC * DC, int NetCode) void WinEDA_PcbFrame::DrawHightLight( wxDC* DC, int NetCode )
/****************************************************************/ /****************************************************************/
/* Turn On or OFF the HightLight for trcak and pads with the netcode "NetCode' /* Turn On or OFF the HightLight for trcak and pads with the netcode "NetCode'
*/ */
{ {
TRACK * pts ; TRACK* pts;
MODULE * Module; MODULE* Module;
if(g_HightLigt_Status ) draw_mode = GR_SURBRILL | GR_OR; if( g_HightLigt_Status )
else draw_mode = GR_AND | GR_SURBRILL; draw_mode = GR_SURBRILL | GR_OR;
else
Module = m_Pcb->m_Modules; draw_mode = GR_AND | GR_SURBRILL;
/* Redraw pads */ Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ /* Redraw pads */
Pad_Surbrillance(DrawPanel, DC, Module, NetCode) ; for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
} {
Pad_Surbrillance( DrawPanel, DC, Module, NetCode );
/* Redraw track and vias: */ }
for ( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext)
{ /* Redraw track and vias: */
if( pts->m_NetCode == NetCode ) for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext )
{ {
pts->Draw(DrawPanel, DC, draw_mode); if( pts->m_NetCode == NetCode )
} {
} pts->Draw( DrawPanel, DC, draw_mode );
}
}
} }
/*******************************************************/ /*******************************************************/
static void Pad_Surbrillance(WinEDA_DrawPanel * panel, static void Pad_Surbrillance( WinEDA_DrawPanel* panel,
wxDC * DC, MODULE * Module, int NetCode) wxDC* DC, MODULE* Module, int NetCode )
/*******************************************************/ /*******************************************************/
/* Mise en Surbrillance des Pads */ /* Mise en Surbrillance des Pads */
{ {
D_PAD * pt_pad ; D_PAD* pt_pad;
/* trace des pastilles */ /* trace des pastilles */
for(pt_pad = Module->m_Pads; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext) for( pt_pad = Module->m_Pads; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
if ( pt_pad->m_NetCode == NetCode ) if( pt_pad->m_NetCode == NetCode )
{ {
pt_pad->Draw(panel, DC, wxPoint(0,0),draw_mode); pt_pad->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode );
} }
} }
} }
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
/* Data to build the layer pair indicator button */ /* Data to build the layer pair indicator button */
static wxBitmap* LayerPairBitmap = NULL; static wxBitmap* LayerPairBitmap = NULL;
static char s_BitmapLayerIcon[16][16] = { static const char s_BitmapLayerIcon[16][16] = {
// 0 = draw pixel with active layer color // 0 = draw pixel with active layer color
// 1 = draw pixel with top layer color (top/bottom layer used in autoroute and place via) // 1 = draw pixel with top layer color (top/bottom layer used in autoroute and place via)
// 2 = draw pixel with bottom layer color // 2 = draw pixel with bottom layer color
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: zones.cpp // Name: zones.cpp
// Purpose: // Purpose:
// Author: jean-pierre Charras // Author: jean-pierre Charras
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
// Generated by DialogBlocks (unregistered), 25/01/2006 11:35:19 // Generated by DialogBlocks (unregistered), 25/01/2006 11:35:19
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #if defined (__GNUG__) && !defined (NO_GCC_PRAGMA)
#pragma implementation "zones.h" #pragma implementation "zones.h"
#endif #endif
...@@ -35,19 +36,19 @@ ...@@ -35,19 +36,19 @@
////@end XPM images ////@end XPM images
/* Routines Locales */ /* Routines Locales */
static void Display_Zone_Netname(WinEDA_PcbFrame *frame); static void Display_Zone_Netname( WinEDA_PcbFrame* frame );
static void Exit_Zones(WinEDA_DrawPanel * Panel, wxDC *DC); static void Exit_Zones( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Show_Zone_Edge_While_MoveMouse(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); static void Show_Zone_Edge_While_MoveMouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Genere_Segments_Zone(WinEDA_PcbFrame *frame, wxDC * DC, int net_code); static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code );
static bool Genere_Pad_Connexion(WinEDA_PcbFrame *frame, wxDC * DC, int layer); static bool Genere_Pad_Connexion( WinEDA_PcbFrame* frame, wxDC* DC, int layer );
/* Variables locales */ /* Variables locales */
static bool Zone_Debug = FALSE; static bool Zone_Debug = FALSE;
static bool Zone_45_Only = FALSE; static bool Zone_45_Only = FALSE;
static bool Zone_Exclude_Pads = TRUE; static bool Zone_Exclude_Pads = TRUE;
static bool Zone_Genere_Freins_Thermiques = TRUE; static bool Zone_Genere_Freins_Thermiques = TRUE;
static unsigned long s_TimeStamp; /* signature temporelle pour la zone generee */ static unsigned long s_TimeStamp; /* signature temporelle pour la zone generee */
/*! /*!
* WinEDA_ZoneFrame type definition * WinEDA_ZoneFrame type definition
...@@ -62,11 +63,11 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_ZoneFrame, wxDialog ) ...@@ -62,11 +63,11 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_ZoneFrame, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_ZoneFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_ZoneFrame, wxDialog )
////@begin WinEDA_ZoneFrame event table entries ////@begin WinEDA_ZoneFrame event table entries
EVT_BUTTON( ID_FILL_ZONE, WinEDA_ZoneFrame::ExecFillZone ) EVT_BUTTON( ID_FILL_ZONE, WinEDA_ZoneFrame::ExecFillZone )
EVT_BUTTON( wxID_CANCEL, WinEDA_ZoneFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_ZoneFrame::OnCancelClick )
EVT_BUTTON( ID_SET_OPTIONS_ZONE, WinEDA_ZoneFrame::ExecFillZone ) EVT_BUTTON( ID_SET_OPTIONS_ZONE, WinEDA_ZoneFrame::ExecFillZone )
////@end WinEDA_ZoneFrame event table entries ////@end WinEDA_ZoneFrame event table entries
...@@ -76,148 +77,197 @@ END_EVENT_TABLE() ...@@ -76,148 +77,197 @@ END_EVENT_TABLE()
* WinEDA_ZoneFrame constructors * WinEDA_ZoneFrame constructors
*/ */
WinEDA_ZoneFrame::WinEDA_ZoneFrame( ) WinEDA_ZoneFrame::WinEDA_ZoneFrame()
{ {
} }
WinEDA_ZoneFrame::WinEDA_ZoneFrame( WinEDA_PcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
WinEDA_ZoneFrame::WinEDA_ZoneFrame( WinEDA_PcbFrame* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{ {
m_Parent = parent; m_Parent = parent;
Create(parent, id, caption, pos, size, style); Create( parent, id, caption, pos, size, style );
} }
/*! /*!
* WinEDA_ZoneFrame creator * WinEDA_ZoneFrame creator
*/ */
bool WinEDA_ZoneFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) bool WinEDA_ZoneFrame::Create( wxWindow* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{ {
////@begin WinEDA_ZoneFrame member initialisation ////@begin WinEDA_ZoneFrame member initialisation
m_GridCtrl = NULL; m_GridCtrl = NULL;
m_ClearanceValueTitle = NULL; m_ClearanceValueTitle = NULL;
m_ZoneClearanceCtrl = NULL; m_ZoneClearanceCtrl = NULL;
m_FillOpt = NULL; m_FillOpt = NULL;
m_OrientEdgesOpt = NULL; m_OrientEdgesOpt = NULL;
////@end WinEDA_ZoneFrame member initialisation ////@end WinEDA_ZoneFrame member initialisation
////@begin WinEDA_ZoneFrame creation ////@begin WinEDA_ZoneFrame creation
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
GetSizer()->Fit(this); GetSizer()->Fit( this );
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
Centre(); Centre();
////@end WinEDA_ZoneFrame creation ////@end WinEDA_ZoneFrame creation
return true; return true;
} }
/*! /*!
* Control creation for WinEDA_ZoneFrame * Control creation for WinEDA_ZoneFrame
*/ */
void WinEDA_ZoneFrame::CreateControls() void WinEDA_ZoneFrame::CreateControls()
{ {
SetFont(*g_DialogFont); SetFont( *g_DialogFont );
////@begin WinEDA_ZoneFrame content construction ////@begin WinEDA_ZoneFrame content construction
// Generated by DialogBlocks, 03/03/2006 13:36:21 (unregistered) // Generated by DialogBlocks, 03/03/2006 13:36:21 (unregistered)
WinEDA_ZoneFrame* itemDialog1 = this; WinEDA_ZoneFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxHORIZONTAL );
itemDialog1->SetSizer(itemBoxSizer2); itemDialog1->SetSizer( itemBoxSizer2 );
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 );
wxString m_GridCtrlStrings[] = { static const wxString m_GridCtrlStrings[] = {
_("0.00000"), _( "0.00000" ),
_("0.00000"), _( "0.00000" ),
_("0.00000"), _( "0.00000" ),
_("0.00000") _( "0.00000" )
}; };
m_GridCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid size:"), wxDefaultPosition, wxDefaultSize, 4, m_GridCtrlStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer3->Add(m_GridCtrl, 0, wxALIGN_LEFT|wxALL, 5); m_GridCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _(
"Grid size:" ), wxDefaultPosition, wxDefaultSize, 4,
m_ClearanceValueTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Zone clearance value (mm):"), wxDefaultPosition, wxDefaultSize, 0 ); m_GridCtrlStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer3->Add(m_ClearanceValueTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); itemBoxSizer3->Add( m_GridCtrl, 0, wxALIGN_LEFT | wxALL, 5 );
m_ZoneClearanceCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); m_ClearanceValueTitle = new wxStaticText( itemDialog1, wxID_STATIC,
itemBoxSizer3->Add(m_ZoneClearanceCtrl, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); _("Zone clearance value (mm):"),
wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); itemBoxSizer3->Add( m_ClearanceValueTitle,
0,
wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
itemBoxSizer2->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5); 5 );
wxString m_FillOptStrings[] = { m_ZoneClearanceCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(
_("Include Pads"), "" ), wxDefaultPosition, wxDefaultSize, 0 );
_("Thermal"), itemBoxSizer3->Add( m_ZoneClearanceCtrl, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
_("Exclude Pads")
itemBoxSizer2->Add( 5, 5, 0, wxGROW | wxALL, 5 );
wxBoxSizer* itemBoxSizer8 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer2->Add( itemBoxSizer8, 0, wxGROW | wxALL, 5 );
static const wxString m_FillOptStrings[] = {
_( "Include Pads" ),
_( "Thermal" ),
_( "Exclude Pads" )
}; };
m_FillOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Pad options:"), wxDefaultPosition, wxDefaultSize, 3, m_FillOptStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer8->Add(m_FillOpt, 0, wxALIGN_LEFT|wxALL, 5); m_FillOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _(
"Pad options:" ), wxDefaultPosition, wxDefaultSize, 3,
wxString m_OrientEdgesOptStrings[] = { m_FillOptStrings, 1, wxRA_SPECIFY_COLS );
_("Any"), itemBoxSizer8->Add( m_FillOpt, 0, wxALIGN_LEFT | wxALL, 5 );
_("H , V and 45 deg")
static const wxString m_OrientEdgesOptStrings[] = {
_( "Any" ),
_( "H , V and 45 deg" )
}; };
m_OrientEdgesOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Zone edges orient:"), wxDefaultPosition, wxDefaultSize, 2, m_OrientEdgesOptStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer8->Add(m_OrientEdgesOpt, 0, wxALIGN_RIGHT|wxALL, 5); m_OrientEdgesOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX2,
_("Zone edges orient:" ), wxDefaultPosition,
itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); wxDefaultSize, 2, m_OrientEdgesOptStrings, 1,
wxRA_SPECIFY_COLS );
wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_TOP|wxALL, 5); itemBoxSizer8->Add( m_OrientEdgesOpt, 0, wxALIGN_RIGHT | wxALL, 5 );
wxButton* itemButton13 = new wxButton( itemDialog1, ID_FILL_ZONE, _("Fill"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer2->Add( 5, 5, 0, wxGROW | wxALL, 5 );
wxBoxSizer* itemBoxSizer12 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer2->Add( itemBoxSizer12, 0, wxALIGN_TOP | wxALL, 5 );
wxButton* itemButton13 = new wxButton( itemDialog1, ID_FILL_ZONE,
_("Fill"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton13->SetDefault(); itemButton13->SetDefault();
itemButton13->SetForegroundColour(wxColour(204, 0, 0)); itemButton13->SetForegroundColour( wxColour( 204, 0, 0 ) );
itemBoxSizer12->Add(itemButton13, 0, wxGROW|wxALL, 5); itemBoxSizer12->Add( itemButton13, 0, wxGROW | wxALL, 5 );
wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL,
itemButton14->SetForegroundColour(wxColour(0, 0, 255)); _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer12->Add(itemButton14, 0, wxGROW|wxALL, 5);
itemButton14->SetForegroundColour( wxColour( 0, 0, 255 ) );
itemBoxSizer12->Add( itemButton14, 0, wxGROW | wxALL, 5 );
wxButton* itemButton15 = new wxButton( itemDialog1, ID_SET_OPTIONS_ZONE, _("Update Options"), wxDefaultPosition, wxDefaultSize, 0 ); wxButton* itemButton15 = new wxButton( itemDialog1, ID_SET_OPTIONS_ZONE,
itemButton15->SetForegroundColour(wxColour(0, 100, 0)); _("Update Options" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer12->Add(itemButton15, 0, wxGROW|wxALL, 5);
itemButton15->SetForegroundColour( wxColour( 0, 100, 0 ) );
itemBoxSizer12->Add( itemButton15, 0, wxGROW | wxALL, 5 );
itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); itemBoxSizer2->Add( 5, 5, 0, wxGROW | wxALL, 5 );
////@end WinEDA_ZoneFrame content construction ////@end WinEDA_ZoneFrame content construction
wxString title = _("Zone clearance value:") + ReturnUnitSymbol(g_UnitMetric); wxString title = _( "Zone clearance value:" ) + ReturnUnitSymbol( g_UnitMetric );
m_ClearanceValueTitle->SetLabel( title ); m_ClearanceValueTitle->SetLabel( title );
title = _("Grid :") + ReturnUnitSymbol(g_UnitMetric);; title = _( "Grid :" ) + ReturnUnitSymbol( g_UnitMetric );;
m_GridCtrl->SetLabel(title); m_GridCtrl->SetLabel( title );
if ( g_DesignSettings.m_ZoneClearence == 0 ) if( g_DesignSettings.m_ZoneClearence == 0 )
g_DesignSettings.m_ZoneClearence = g_DesignSettings.m_TrackClearence; g_DesignSettings.m_ZoneClearence = g_DesignSettings.m_TrackClearence;
title = ReturnStringFromValue( g_UnitMetric, g_DesignSettings.m_ZoneClearence, m_Parent->m_InternalUnits); title = ReturnStringFromValue( g_UnitMetric,
m_ZoneClearanceCtrl->SetValue( title ); g_DesignSettings.m_ZoneClearence,
m_Parent->m_InternalUnits );
if ( Zone_45_Only ) m_OrientEdgesOpt->SetSelection(1); m_ZoneClearanceCtrl->SetValue( title );
int GridList[4] = { 50,100,250,500}, selection = 0; if( Zone_45_Only )
for ( unsigned ii = 0; ii < m_GridCtrl->GetCount(); ii++ ) m_OrientEdgesOpt->SetSelection( 1 );
{
wxString msg = ReturnStringFromValue(g_UnitMetric, GridList[ii], m_Parent->m_InternalUnits); static const int GridList[4] = { 50, 100, 250, 500 };
m_GridCtrl->SetString(ii,msg); int selection = 0;
if ( g_GridRoutingSize == GridList[ii] ) selection = ii;
} for( unsigned ii = 0; ii < m_GridCtrl->GetCount(); ii++ )
m_GridCtrl->SetSelection(selection); {
wxString msg = ReturnStringFromValue( g_UnitMetric,
if ( Zone_Exclude_Pads) GridList[ii],
{ m_Parent->m_InternalUnits );
if ( Zone_Genere_Freins_Thermiques ) m_FillOpt->SetSelection(1); m_GridCtrl->SetString( ii, msg );
else m_FillOpt->SetSelection(2); if( g_GridRoutingSize == GridList[ii] )
} selection = ii;
}
m_GridCtrl->SetSelection( selection );
if( Zone_Exclude_Pads )
{
if( Zone_Genere_Freins_Thermiques )
m_FillOpt->SetSelection( 1 );
else
m_FillOpt->SetSelection( 2 );
}
} }
/*! /*!
* Should we show tooltips? * Should we show tooltips?
*/ */
...@@ -227,6 +277,7 @@ bool WinEDA_ZoneFrame::ShowToolTips() ...@@ -227,6 +277,7 @@ bool WinEDA_ZoneFrame::ShowToolTips()
return true; return true;
} }
/*! /*!
* Get bitmap resources * Get bitmap resources
*/ */
...@@ -235,11 +286,13 @@ wxBitmap WinEDA_ZoneFrame::GetBitmapResource( const wxString& name ) ...@@ -235,11 +286,13 @@ wxBitmap WinEDA_ZoneFrame::GetBitmapResource( const wxString& name )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin WinEDA_ZoneFrame bitmap retrieval ////@begin WinEDA_ZoneFrame bitmap retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullBitmap; return wxNullBitmap;
////@end WinEDA_ZoneFrame bitmap retrieval ////@end WinEDA_ZoneFrame bitmap retrieval
} }
/*! /*!
* Get icon resources * Get icon resources
*/ */
...@@ -248,11 +301,13 @@ wxIcon WinEDA_ZoneFrame::GetIconResource( const wxString& name ) ...@@ -248,11 +301,13 @@ wxIcon WinEDA_ZoneFrame::GetIconResource( const wxString& name )
{ {
// Icon retrieval // Icon retrieval
////@begin WinEDA_ZoneFrame icon retrieval ////@begin WinEDA_ZoneFrame icon retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullIcon; return wxNullIcon;
////@end WinEDA_ZoneFrame icon retrieval ////@end WinEDA_ZoneFrame icon retrieval
} }
/*! /*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/ */
...@@ -262,6 +317,7 @@ void WinEDA_ZoneFrame::OnCancelClick( wxCommandEvent& event ) ...@@ -262,6 +317,7 @@ void WinEDA_ZoneFrame::OnCancelClick( wxCommandEvent& event )
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_ZoneFrame. ////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_ZoneFrame.
// Before editing this code, remove the block markers. // Before editing this code, remove the block markers.
event.Skip(); event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_ZoneFrame. ////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_ZoneFrame.
} }
...@@ -270,995 +326,1066 @@ void WinEDA_ZoneFrame::OnCancelClick( wxCommandEvent& event ) ...@@ -270,995 +326,1066 @@ void WinEDA_ZoneFrame::OnCancelClick( wxCommandEvent& event )
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2
*/ */
/***********************************************************/ /***********************************************************/
void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent & event) void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent& event )
/***********************************************************/ /***********************************************************/
{ {
switch ( m_FillOpt->GetSelection() ) switch( m_FillOpt->GetSelection() )
{ {
case 0: case 0:
Zone_Exclude_Pads = FALSE; Zone_Exclude_Pads = FALSE;
Zone_Genere_Freins_Thermiques = FALSE; Zone_Genere_Freins_Thermiques = FALSE;
break; break;
case 1: case 1:
Zone_Exclude_Pads = TRUE; Zone_Exclude_Pads = TRUE;
Zone_Genere_Freins_Thermiques = TRUE; Zone_Genere_Freins_Thermiques = TRUE;
break; break;
case 2: case 2:
Zone_Exclude_Pads = TRUE; Zone_Exclude_Pads = TRUE;
Zone_Genere_Freins_Thermiques = FALSE; Zone_Genere_Freins_Thermiques = FALSE;
break; break;
} }
switch ( m_GridCtrl->GetSelection() ) switch( m_GridCtrl->GetSelection() )
{ {
case 0: case 0:
g_GridRoutingSize = 50; g_GridRoutingSize = 50;
break; break;
case 1: case 1:
g_GridRoutingSize = 100; g_GridRoutingSize = 100;
break; break;
case 2: case 2:
g_GridRoutingSize = 250; g_GridRoutingSize = 250;
break; break;
case 3: case 3:
g_GridRoutingSize = 500; g_GridRoutingSize = 500;
break; break;
} }
wxString txtvalue = m_ZoneClearanceCtrl->GetValue(); wxString txtvalue = m_ZoneClearanceCtrl->GetValue();
g_DesignSettings.m_ZoneClearence = g_DesignSettings.m_ZoneClearence =
ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits); ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits );
if ( m_OrientEdgesOpt->GetSelection() == 0) Zone_45_Only = FALSE; if( m_OrientEdgesOpt->GetSelection() == 0 )
else Zone_45_Only = TRUE; Zone_45_Only = FALSE;
else
if ( event.GetId() == ID_SET_OPTIONS_ZONE ) EndModal(1); Zone_45_Only = TRUE;
else EndModal(0);
if( event.GetId() == ID_SET_OPTIONS_ZONE )
EndModal( 1 );
else
EndModal( 0 );
} }
/**************************************************************/ /**************************************************************/
void WinEDA_PcbFrame::Edit_Zone_Width(wxDC * DC, SEGZONE * Zone) void WinEDA_PcbFrame::Edit_Zone_Width( wxDC* DC, SEGZONE* Zone )
/**************************************************************/ /**************************************************************/
/* Edite (change la largeur des segments) la zone Zone. /* Edite (change la largeur des segments) la zone Zone.
La zone est constituee des segments zones de meme TimeStamp * La zone est constituee des segments zones de meme TimeStamp
*/ */
{ {
SEGZONE * pt_segm, * NextS ; SEGZONE* pt_segm, * NextS;
unsigned long TimeStamp; unsigned long TimeStamp;
bool modify = FALSE; bool modify = FALSE;
double f_new_width; double f_new_width;
int w_tmp; int w_tmp;
wxString Line; wxString Line;
wxString Msg( _("New zone segment width: ") ); wxString Msg( _( "New zone segment width: " ) );
if ( Zone == NULL ) return; if( Zone == NULL )
return;
f_new_width = To_User_Unit(g_UnitMetric, Zone->m_Width, GetScreen()->GetInternalUnits());
Line.Printf(wxT("%.4f"), f_new_width); f_new_width = To_User_Unit( g_UnitMetric, Zone->m_Width, GetScreen()->GetInternalUnits() );
Msg += g_UnitMetric ? wxT("(mm)") : wxT("(\")");
if ( Get_Message(Msg, Line, this) != 0 ) return; Line.Printf( wxT( "%.4f" ), f_new_width );
w_tmp = g_DesignSettings.m_CurrentTrackWidth; Msg += g_UnitMetric ? wxT( "(mm)" ) : wxT( "(\")" );
Line.ToDouble( &f_new_width); if( Get_Message( Msg, Line, this ) != 0 )
g_DesignSettings.m_CurrentTrackWidth = From_User_Unit(g_UnitMetric, f_new_width, GetScreen()->GetInternalUnits()); return;
TimeStamp = Zone->m_TimeStamp; w_tmp = g_DesignSettings.m_CurrentTrackWidth;
Line.ToDouble( &f_new_width );
for( pt_segm = (SEGZONE*)m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS)
{ g_DesignSettings.m_CurrentTrackWidth = From_User_Unit( g_UnitMetric,
NextS = (SEGZONE*) pt_segm->Pnext; f_new_width, GetScreen()->GetInternalUnits() );
if(pt_segm->m_TimeStamp == TimeStamp)
{ TimeStamp = Zone->m_TimeStamp;
modify = TRUE;
Edit_TrackSegm_Width(DC, pt_segm); for( pt_segm = (SEGZONE*) m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
} {
} NextS = (SEGZONE*) pt_segm->Pnext;
if( pt_segm->m_TimeStamp == TimeStamp )
g_DesignSettings.m_CurrentTrackWidth = w_tmp; {
if ( modify ) modify = TRUE;
{ Edit_TrackSegm_Width( DC, pt_segm );
GetScreen()->SetModify(); }
DrawPanel->Refresh(); }
}
g_DesignSettings.m_CurrentTrackWidth = w_tmp;
if( modify )
{
GetScreen()->SetModify();
DrawPanel->Refresh();
}
} }
/**********************************************************/ /**********************************************************/
void WinEDA_PcbFrame::Delete_Zone(wxDC * DC, SEGZONE * Zone) void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* Zone )
/**********************************************************/ /**********************************************************/
/* Efface la zone Zone. /* Efface la zone Zone.
La zone est constituee des segments zones de meme TimeStamp * La zone est constituee des segments zones de meme TimeStamp
*/ */
{ {
SEGZONE * pt_segm, * NextS ; SEGZONE* pt_segm, * NextS;
unsigned long TimeStamp; unsigned long TimeStamp;
int nb_segm = 0; int nb_segm = 0;
bool modify = FALSE; bool modify = FALSE;
TimeStamp = Zone->m_TimeStamp; TimeStamp = Zone->m_TimeStamp;
for( pt_segm = (SEGZONE*)m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS) for( pt_segm = (SEGZONE*) m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
{ {
NextS = (SEGZONE*) pt_segm->Pnext; NextS = (SEGZONE*) pt_segm->Pnext;
if(pt_segm->m_TimeStamp == TimeStamp) if( pt_segm->m_TimeStamp == TimeStamp )
{ {
modify = TRUE; modify = TRUE;
/* effacement des segments a l'ecran */ /* effacement des segments a l'ecran */
Trace_Une_Piste(DrawPanel, DC, pt_segm, nb_segm, GR_XOR); Trace_Une_Piste( DrawPanel, DC, pt_segm, nb_segm, GR_XOR );
DeleteStructure(pt_segm); DeleteStructure( pt_segm );
} }
} }
if ( modify ) if( modify )
{ {
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->SetRefreshReq(); GetScreen()->SetRefreshReq();
} }
} }
/*****************************************************************************/ /*****************************************************************************/
EDGE_ZONE * WinEDA_PcbFrame::Del_SegmEdgeZone(wxDC * DC, EDGE_ZONE * edge_zone) EDGE_ZONE* WinEDA_PcbFrame::Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone )
/*****************************************************************************/ /*****************************************************************************/
/* Routine d'effacement du segment de limite zone en cours de trace */ /* Routine d'effacement du segment de limite zone en cours de trace */
{ {
EDGE_ZONE * Segm, * previous_segm; EDGE_ZONE* Segm, * previous_segm;
if (m_Pcb->m_CurrentLimitZone) Segm = m_Pcb->m_CurrentLimitZone; if( m_Pcb->m_CurrentLimitZone )
else Segm = edge_zone; Segm = m_Pcb->m_CurrentLimitZone;
else
if( Segm == NULL) return NULL; Segm = edge_zone;
Trace_DrawSegmentPcb(DrawPanel, DC, Segm, GR_XOR); if( Segm == NULL )
return NULL;
previous_segm = (EDGE_ZONE *)Segm->Pback;
delete Segm; Trace_DrawSegmentPcb( DrawPanel, DC, Segm, GR_XOR );
Segm = previous_segm; previous_segm = (EDGE_ZONE*) Segm->Pback;
m_Pcb->m_CurrentLimitZone = Segm; delete Segm;
GetScreen()->m_CurrentItem = Segm;
Segm = previous_segm;
if( Segm ) m_Pcb->m_CurrentLimitZone = Segm;
{ GetScreen()->m_CurrentItem = Segm;
Segm->Pnext = NULL;
if( DrawPanel->ManageCurseur) if( Segm )
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); {
} Segm->Pnext = NULL;
else if( DrawPanel->ManageCurseur )
{ DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->ManageCurseur = NULL; }
DrawPanel->ForceCloseManageCurseur = NULL; else
GetScreen()->m_CurrentItem = NULL; {
} DrawPanel->ManageCurseur = NULL;
return Segm; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->m_CurrentItem = NULL;
}
return Segm;
} }
/*********************************************/ /*********************************************/
void WinEDA_PcbFrame::CaptureNetName(wxDC * DC) void WinEDA_PcbFrame::CaptureNetName( wxDC* DC )
/*********************************************/ /*********************************************/
/* routine permettant de capturer le nom net net (netcode) d'un pad /* routine permettant de capturer le nom net net (netcode) d'un pad
ou d'une piste pour l'utiliser comme netcode de zone * ou d'une piste pour l'utiliser comme netcode de zone
*/ */
{ {
D_PAD* pt_pad = 0; D_PAD* pt_pad = 0;
TRACK * adrpiste ; TRACK* adrpiste;
MODULE * Module; MODULE* Module;
int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer]; int masquelayer = g_TabOneLayerMask[GetScreen()->m_Active_Layer];
int netcode; int netcode;
netcode = -1; netcode = -1;
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
adrpiste = Locate_Pistes(m_Pcb->m_Track, masquelayer,CURSEUR_OFF_GRILLE); adrpiste = Locate_Pistes( m_Pcb->m_Track, masquelayer, CURSEUR_OFF_GRILLE );
if ( adrpiste == NULL ) if( adrpiste == NULL )
{ {
pt_pad = Locate_Any_Pad(m_Pcb, CURSEUR_OFF_GRILLE); pt_pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE );
if(pt_pad) /* Verif qu'il est bien sur la couche active */ if( pt_pad ) /* Verif qu'il est bien sur la couche active */
{ {
Module = (MODULE*) pt_pad->m_Parent; Module = (MODULE*) pt_pad->m_Parent;
pt_pad = Locate_Pads(Module,g_TabOneLayerMask[GetScreen()->m_Active_Layer], pt_pad = Locate_Pads( Module, g_TabOneLayerMask[GetScreen()->m_Active_Layer],
CURSEUR_OFF_GRILLE); CURSEUR_OFF_GRILLE );
} }
if( pt_pad ) if( pt_pad )
{ {
pt_pad->Display_Infos(this); pt_pad->Display_Infos( this );
netcode = pt_pad->m_NetCode; netcode = pt_pad->m_NetCode;
} }
} }
else else
{ {
Affiche_Infos_Piste(this, adrpiste) ; Affiche_Infos_Piste( this, adrpiste );
netcode = adrpiste->m_NetCode; netcode = adrpiste->m_NetCode;
} }
// Mise en surbrillance du net // Mise en surbrillance du net
if(g_HightLigt_Status) Hight_Light(DC); if( g_HightLigt_Status )
g_HightLigth_NetCode = netcode; Hight_Light( DC );
if ( g_HightLigth_NetCode >= 0 ) g_HightLigth_NetCode = netcode;
{ if( g_HightLigth_NetCode >= 0 )
Hight_Light(DC); {
} Hight_Light( DC );
}
/* Affichage du net selectionne pour la zone a tracer */
Display_Zone_Netname(this); /* Affichage du net selectionne pour la zone a tracer */
Display_Zone_Netname( this );
} }
/*******************************************************/ /*******************************************************/
static void Display_Zone_Netname(WinEDA_PcbFrame *frame) static void Display_Zone_Netname( WinEDA_PcbFrame* frame )
/*******************************************************/ /*******************************************************/
/* /*
Affiche le net_code et le nom de net couramment selectionne * Affiche le net_code et le nom de net couramment selectionne
*/ */
{ {
EQUIPOT * pt_equipot; EQUIPOT* pt_equipot;
wxString line; wxString line;
pt_equipot = frame->m_Pcb->m_Equipots; pt_equipot = frame->m_Pcb->m_Equipots;
if( g_HightLigth_NetCode > 0 ) if( g_HightLigth_NetCode > 0 )
{ {
for( ; pt_equipot != NULL; pt_equipot = (EQUIPOT*)pt_equipot->Pnext) for( ; pt_equipot != NULL; pt_equipot = (EQUIPOT*) pt_equipot->Pnext )
{ {
if( pt_equipot->m_NetCode == g_HightLigth_NetCode) break; if( pt_equipot->m_NetCode == g_HightLigth_NetCode )
} break;
if( pt_equipot ) }
{
line.Printf( wxT("Zone: Net[%d] <%s>"),g_HightLigth_NetCode, if( pt_equipot )
pt_equipot->m_Netname.GetData()); {
} line.Printf( wxT( "Zone: Net[%d] <%s>" ), g_HightLigth_NetCode,
else line.Printf( wxT("Zone: NetCode[%d], Equipot not found"), pt_equipot->m_Netname.GetData() );
g_HightLigth_NetCode); }
} else
line.Printf( wxT( "Zone: NetCode[%d], Equipot not found" ),
line = _("Zone: No net selected"); g_HightLigth_NetCode );
}
frame->Affiche_Message(line);
line = _( "Zone: No net selected" );
frame->Affiche_Message( line );
} }
/********************************************************/ /********************************************************/
static void Exit_Zones(WinEDA_DrawPanel * Panel, wxDC *DC) static void Exit_Zones( WinEDA_DrawPanel* Panel, wxDC* DC )
/********************************************************/ /********************************************************/
/* routine d'annulation de la Commande Begin_Zone si une piste est en cours /* routine d'annulation de la Commande Begin_Zone si une piste est en cours
de tracage, ou de sortie de l'application SEGZONES. * de tracage, ou de sortie de l'application SEGZONES.
Appel par la touche ESC * Appel par la touche ESC
*/ */
{ {
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*)Panel->m_Parent; WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
if( pcbframe->m_Pcb->m_CurrentLimitZone ) if( pcbframe->m_Pcb->m_CurrentLimitZone )
{ {
if( Panel->ManageCurseur ) /* trace en cours */ if( Panel->ManageCurseur ) /* trace en cours */
{ {
Panel->ManageCurseur(Panel, DC, 0); Panel->ManageCurseur( Panel, DC, 0 );
} }
pcbframe->DelLimitesZone(DC, FALSE); pcbframe->DelLimitesZone( DC, FALSE );
} }
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
pcbframe->GetScreen()->m_CurrentItem = NULL; pcbframe->GetScreen()->m_CurrentItem = NULL;
} }
/**************************************************************/ /**************************************************************/
void WinEDA_BasePcbFrame::DelLimitesZone(wxDC *DC, bool Redraw) void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
/**************************************************************/ /**************************************************************/
/* Supprime la liste des segments constituant la frontiere courante /* Supprime la liste des segments constituant la frontiere courante
Libere la memoire correspondante * Libere la memoire correspondante
*/ */
{ {
EDGE_ZONE * segment, * Next; EDGE_ZONE* segment, * Next;
if( m_Pcb->m_CurrentLimitZone == NULL ) return; if( m_Pcb->m_CurrentLimitZone == NULL )
return;
if ( ! IsOK(this, _("Delete Current Zone Edges")) ) return;
/* efface ancienne limite de zone */ if( !IsOK( this, _( "Delete Current Zone Edges" ) ) )
segment = m_Pcb->m_CurrentLimitZone; return;
for( ; segment != NULL; segment = Next)
{ /* efface ancienne limite de zone */
Next = (EDGE_ZONE*) segment->Pback; segment = m_Pcb->m_CurrentLimitZone;
if ( Redraw ) Trace_DrawSegmentPcb(DrawPanel, DC, segment,GR_XOR); for( ; segment != NULL; segment = Next )
segment->Pnext = NULL; delete segment; {
} Next = (EDGE_ZONE*) segment->Pback;
if( Redraw )
GetScreen()->m_CurrentItem = NULL; Trace_DrawSegmentPcb( DrawPanel, DC, segment, GR_XOR );
m_Pcb->m_CurrentLimitZone = NULL; segment->Pnext = NULL; delete segment;
}
GetScreen()->m_CurrentItem = NULL;
m_Pcb->m_CurrentLimitZone = NULL;
} }
/********************************************/ /********************************************/
EDGE_ZONE * WinEDA_PcbFrame::Begin_Zone(void) EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( void )
/********************************************/ /********************************************/
/* /*
Routine d'initialisation d'un trace de Limite de Zone ou * Routine d'initialisation d'un trace de Limite de Zone ou
de placement d'un point intermediaire * de placement d'un point intermediaire
*/ */
{ {
EDGE_ZONE * oldedge, * newedge = NULL; EDGE_ZONE* oldedge, * newedge = NULL;
oldedge = m_Pcb->m_CurrentLimitZone; oldedge = m_Pcb->m_CurrentLimitZone;
if( (m_Pcb->m_CurrentLimitZone == NULL ) || /* debut reel du trace */ if( (m_Pcb->m_CurrentLimitZone == NULL ) /* debut reel du trace */
(DrawPanel->ManageCurseur == NULL) ) /* reprise d'un trace complementaire */ || (DrawPanel->ManageCurseur == NULL) ) /* reprise d'un trace complementaire */
{ {
m_Pcb->m_CurrentLimitZone = newedge = new EDGE_ZONE( m_Pcb ); m_Pcb->m_CurrentLimitZone = newedge = new EDGE_ZONE( m_Pcb );
newedge->m_Flags = IS_NEW | STARTPOINT | IS_MOVED; newedge->m_Flags = IS_NEW | STARTPOINT | IS_MOVED;
newedge->Pback = oldedge; newedge->Pback = oldedge;
if(oldedge) oldedge->Pnext = newedge; if( oldedge )
newedge->m_Layer = GetScreen()->m_Active_Layer; oldedge->Pnext = newedge;
newedge->m_Width = 2 ; /* Largeur minimum tracable */ newedge->m_Layer = GetScreen()->m_Active_Layer;
newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur; newedge->m_Width = 2; /* Largeur minimum tracable */
newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur;
m_Pcb->m_CurrentLimitZone = newedge;
DrawPanel->ManageCurseur = Show_Zone_Edge_While_MoveMouse; m_Pcb->m_CurrentLimitZone = newedge;
DrawPanel->ForceCloseManageCurseur = Exit_Zones; DrawPanel->ManageCurseur = Show_Zone_Edge_While_MoveMouse;
} DrawPanel->ForceCloseManageCurseur = Exit_Zones;
}
else /* piste en cours : les coord du point d'arrivee ont ete mises else /* piste en cours : les coord du point d'arrivee ont ete mises
a jour par la routine Show_Zone_Edge_While_MoveMouse*/ * a jour par la routine Show_Zone_Edge_While_MoveMouse*/
{ {
if( (oldedge->m_Start.x != oldedge->m_End.x) || if( (oldedge->m_Start.x != oldedge->m_End.x)
(oldedge->m_Start.y != oldedge->m_End.y) ) || (oldedge->m_Start.y != oldedge->m_End.y) )
{ {
newedge = new EDGE_ZONE( oldedge); newedge = new EDGE_ZONE( oldedge );
newedge->Pback = oldedge; newedge->Pback = oldedge;
oldedge->Pnext = newedge; oldedge->Pnext = newedge;
newedge->m_Flags = IS_NEW | IS_MOVED; newedge->m_Flags = IS_NEW | IS_MOVED;
newedge->m_Start = newedge->m_End = oldedge->m_End; newedge->m_Start = newedge->m_End = oldedge->m_End;
newedge->m_Layer = GetScreen()->m_Active_Layer; newedge->m_Layer = GetScreen()->m_Active_Layer;
m_Pcb->m_CurrentLimitZone = newedge; m_Pcb->m_CurrentLimitZone = newedge;
} }
} }
return newedge; return newedge;
} }
/*********************************************/ /*********************************************/
void WinEDA_PcbFrame::End_Zone(wxDC * DC) void WinEDA_PcbFrame::End_Zone( wxDC* DC )
/*********************************************/ /*********************************************/
/* /*
Routine de fin de trace d'une zone (succession de segments) * Routine de fin de trace d'une zone (succession de segments)
*/ */
{ {
EDGE_ZONE * PtLim; EDGE_ZONE* PtLim;
if( m_Pcb->m_CurrentLimitZone ) if( m_Pcb->m_CurrentLimitZone )
{ {
Begin_Zone(); Begin_Zone();
/* le dernier point genere est de longueur tj nulle donc inutile. */ /* le dernier point genere est de longueur tj nulle donc inutile. */
/* il sera raccorde au point de depart */ /* il sera raccorde au point de depart */
PtLim = m_Pcb->m_CurrentLimitZone; PtLim = m_Pcb->m_CurrentLimitZone;
PtLim->m_Flags &= ~(IS_NEW|IS_MOVED); PtLim->m_Flags &= ~(IS_NEW | IS_MOVED);
while( PtLim && PtLim->Pback) while( PtLim && PtLim->Pback )
{ {
PtLim = (EDGE_ZONE*) PtLim->Pback; PtLim = (EDGE_ZONE*) PtLim->Pback;
if ( PtLim->m_Flags & STARTPOINT) break; if( PtLim->m_Flags & STARTPOINT )
PtLim->m_Flags &= ~(IS_NEW|IS_MOVED); break;
} PtLim->m_Flags &= ~(IS_NEW | IS_MOVED);
}
if( PtLim )
{ if( PtLim )
PtLim->m_Flags &= ~(IS_NEW|IS_MOVED); {
m_Pcb->m_CurrentLimitZone->m_End = PtLim->m_Start; PtLim->m_Flags &= ~(IS_NEW | IS_MOVED);
} m_Pcb->m_CurrentLimitZone->m_End = PtLim->m_Start;
Trace_DrawSegmentPcb(DrawPanel, DC, m_Pcb->m_CurrentLimitZone,GR_XOR); }
} Trace_DrawSegmentPcb( DrawPanel, DC, m_Pcb->m_CurrentLimitZone, GR_XOR );
}
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
} }
/******************************************************************************************/ /******************************************************************************************/
static void Show_Zone_Edge_While_MoveMouse(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) static void Show_Zone_Edge_While_MoveMouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/******************************************************************************************/ /******************************************************************************************/
/* redessin du contour de la piste lors des deplacements de la souris /* redessin du contour de la piste lors des deplacements de la souris
*/ */
{ {
EDGE_ZONE * PtLim, * edgezone; EDGE_ZONE* PtLim, * edgezone;
WinEDA_PcbFrame * pcbframe = (WinEDA_PcbFrame *) panel->m_Parent; WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) panel->m_Parent;
if( pcbframe->m_Pcb->m_CurrentLimitZone == NULL ) return ; if( pcbframe->m_Pcb->m_CurrentLimitZone == NULL )
return;
/* efface ancienne position si elle a ete deja dessinee */
if( erase ) /* efface ancienne position si elle a ete deja dessinee */
{ if( erase )
PtLim = pcbframe->m_Pcb->m_CurrentLimitZone; {
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) PtLim = pcbframe->m_Pcb->m_CurrentLimitZone;
{ for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
Trace_DrawSegmentPcb(panel, DC, PtLim,GR_XOR); {
} Trace_DrawSegmentPcb( panel, DC, PtLim, GR_XOR );
} }
}
/* mise a jour de la couche */
edgezone = PtLim = pcbframe->m_Pcb->m_CurrentLimitZone; /* mise a jour de la couche */
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) edgezone = PtLim = pcbframe->m_Pcb->m_CurrentLimitZone;
{ for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
PtLim->m_Layer = pcbframe->GetScreen()->m_Active_Layer; {
} PtLim->m_Layer = pcbframe->GetScreen()->m_Active_Layer;
}
/* dessin de la nouvelle piste : mise a jour du point d'arrivee */
if (Zone_45_Only) /* dessin de la nouvelle piste : mise a jour du point d'arrivee */
{/* Calcul de l'extremite de la piste pour orientations permises: if( Zone_45_Only )
horiz,vertical ou 45 degre */ {/* Calcul de l'extremite de la piste pour orientations permises:
edgezone->m_End = pcbframe->GetScreen()->m_Curseur; * horiz,vertical ou 45 degre */
Calcule_Coord_Extremite_45(edgezone->m_Start.x, edgezone->m_Start.y, edgezone->m_End = pcbframe->GetScreen()->m_Curseur;
&edgezone->m_End.x, &edgezone->m_End.y); Calcule_Coord_Extremite_45( edgezone->m_Start.x, edgezone->m_Start.y,
} &edgezone->m_End.x, &edgezone->m_End.y );
else /* ici l'angle d'inclinaison est quelconque */ }
{ else /* ici l'angle d'inclinaison est quelconque */
edgezone->m_End = pcbframe->GetScreen()->m_Curseur; {
} edgezone->m_End = pcbframe->GetScreen()->m_Curseur;
}
PtLim = edgezone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) PtLim = edgezone;
{ for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
Trace_DrawSegmentPcb(panel, DC, PtLim,GR_XOR); {
} Trace_DrawSegmentPcb( panel, DC, PtLim, GR_XOR );
}
} }
/**********************************************/ /**********************************************/
void WinEDA_PcbFrame::Fill_Zone(wxDC * DC) void WinEDA_PcbFrame::Fill_Zone( wxDC* DC )
/**********************************************/ /**********************************************/
/*
Fonction generale de creation de zone
Un contour de zone doit exister, sinon l'ensemble du PCB est utilise
ce qui permet de creer des obstacles et donc des parties non remplies.
Le remplissage s'effectue a partir du point d'ancrage, jusque ves les limites /*
* Fonction generale de creation de zone
* Un contour de zone doit exister, sinon l'ensemble du PCB est utilise
On place la zone sur la couche (layer) active. *
* ce qui permet de creer des obstacles et donc des parties non remplies.
*
"Hight Light" la zone fera partie de ce net * Le remplissage s'effectue a partir du point d'ancrage, jusque ves les limites
*/ *
*
* On place la zone sur la couche (layer) active.
*
*
* "Hight Light" la zone fera partie de ce net
*/
{ {
int ii, jj; int ii, jj;
EDGE_ZONE* PtLim; EDGE_ZONE* PtLim;
int lp_tmp, lay_tmp_TOP, lay_tmp_BOTTOM; int lp_tmp, lay_tmp_TOP, lay_tmp_BOTTOM;
EQUIPOT* pt_equipot; EQUIPOT* pt_equipot;
int save_isol = g_DesignSettings.m_TrackClearence; int save_isol = g_DesignSettings.m_TrackClearence;
wxPoint ZoneStartFill; wxPoint ZoneStartFill;
wxString msg; wxString msg;
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
if ( m_Pcb->ComputeBoundaryBox() == FALSE ) if( m_Pcb->ComputeBoundaryBox() == FALSE )
{ {
DisplayError(this, wxT("Board is empty!"), 10); DisplayError( this, wxT( "Board is empty!" ), 10 );
return; return;
} }
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
WinEDA_ZoneFrame * frame = new WinEDA_ZoneFrame(this); WinEDA_ZoneFrame* frame = new WinEDA_ZoneFrame( this );
ii = frame->ShowModal(); frame->Destroy(); ii = frame->ShowModal(); frame->Destroy();
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE;
if ( ii ) return; if( ii )
return;
g_DesignSettings.m_TrackClearence = g_DesignSettings.m_ZoneClearence;
g_DesignSettings.m_TrackClearence = g_DesignSettings.m_ZoneClearence;
/* mise a jour de la couche */
PtLim = m_Pcb->m_CurrentLimitZone; /* mise a jour de la couche */
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) PtLim = m_Pcb->m_CurrentLimitZone;
{ for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
Trace_DrawSegmentPcb(DrawPanel, DC, PtLim, GR_XOR); {
PtLim->m_Layer = GetScreen()->m_Active_Layer; Trace_DrawSegmentPcb( DrawPanel, DC, PtLim, GR_XOR );
Trace_DrawSegmentPcb(DrawPanel, DC, PtLim, GR_XOR); PtLim->m_Layer = GetScreen()->m_Active_Layer;
} Trace_DrawSegmentPcb( DrawPanel, DC, PtLim, GR_XOR );
}
s_TimeStamp = time( NULL );
s_TimeStamp = time( NULL );
/* Calcul du pas de routage fixe a 5 mils et plus */
E_scale = g_GridRoutingSize / 50 ; if (g_GridRoutingSize < 1 ) g_GridRoutingSize = 1 ; /* Calcul du pas de routage fixe a 5 mils et plus */
E_scale = g_GridRoutingSize / 50; if( g_GridRoutingSize < 1 )
/* calcule de Ncols et Nrow, taille de la matrice de routage */ g_GridRoutingSize = 1;
ComputeMatriceSize(this, g_GridRoutingSize);
/* calcule de Ncols et Nrow, taille de la matrice de routage */
/* Determination de la cellule pointee par la souris */ ComputeMatriceSize( this, g_GridRoutingSize );
ZoneStartFill.x = (GetScreen()->m_Curseur.x - m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize/2) ) / g_GridRoutingSize;
ZoneStartFill.y = (GetScreen()->m_Curseur.y - m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize/2) ) / g_GridRoutingSize; /* Determination de la cellule pointee par la souris */
if(ZoneStartFill.x < 0) ZoneStartFill.x = 0; ZoneStartFill.x = ( GetScreen()->m_Curseur.x - m_Pcb->m_BoundaryBox.m_Pos.x +
if(ZoneStartFill.x >= Ncols) ZoneStartFill.x = Ncols-1; (g_GridRoutingSize / 2) ) / g_GridRoutingSize;
if(ZoneStartFill.y < 0) ZoneStartFill.y = 0; ZoneStartFill.y = ( GetScreen()->m_Curseur.y - m_Pcb->m_BoundaryBox.m_Pos.y +
if(ZoneStartFill.y >= Nrows) ZoneStartFill.y = Nrows-1; (g_GridRoutingSize / 2) ) / g_GridRoutingSize;
if( ZoneStartFill.x < 0 )
/* Creation du mapping de la matrice de routage */ ZoneStartFill.x = 0;
Nb_Sides = ONE_SIDE; if( ZoneStartFill.x >= Ncols )
if( Board.InitBoard() < 0) ZoneStartFill.x = Ncols - 1;
{ if( ZoneStartFill.y < 0 )
DisplayError(this, wxT("Mo memory for creating zones")); ZoneStartFill.y = 0;
return; if( ZoneStartFill.y >= Nrows )
} ZoneStartFill.y = Nrows - 1;
msg.Printf( wxT("%d"),Ncols); /* Creation du mapping de la matrice de routage */
Affiche_1_Parametre(this, 1, wxT("Cols"),msg,GREEN); Nb_Sides = ONE_SIDE;
msg.Printf( wxT("%d"),Nrows); if( Board.InitBoard() < 0 )
Affiche_1_Parametre(this, 7, wxT("Lines"),msg,GREEN); {
msg.Printf( wxT("%d"), Board.m_MemSize / 1024 ); DisplayError( this, wxT( "Mo memory for creating zones" ) );
Affiche_1_Parametre(this, 14, wxT("Mem(Ko)"),msg,CYAN); return;
}
lay_tmp_BOTTOM = Route_Layer_BOTTOM;
lay_tmp_TOP = Route_Layer_TOP; msg.Printf( wxT( "%d" ), Ncols );
Affiche_1_Parametre( this, 1, wxT( "Cols" ), msg, GREEN );
Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer; msg.Printf( wxT( "%d" ), Nrows );
lp_tmp = g_DesignSettings.m_CurrentTrackWidth; g_DesignSettings.m_CurrentTrackWidth = g_GridRoutingSize; Affiche_1_Parametre( this, 7, wxT( "Lines" ), msg, GREEN );
msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
/* Affichage du NetName */ Affiche_1_Parametre( this, 14, wxT( "Mem(Ko)" ), msg, CYAN );
if(g_HightLigth_NetCode > 0)
{ lay_tmp_BOTTOM = Route_Layer_BOTTOM;
pt_equipot = GetEquipot(m_Pcb, g_HightLigth_NetCode); lay_tmp_TOP = Route_Layer_TOP;
if( pt_equipot == NULL)
{ Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer;
if(g_HightLigth_NetCode > 0 ) DisplayError(this, wxT("Equipot Error")); lp_tmp = g_DesignSettings.m_CurrentTrackWidth;
} g_DesignSettings.m_CurrentTrackWidth = g_GridRoutingSize;
else msg = pt_equipot->m_Netname;
} /* Affichage du NetName */
else msg = _("No Net"); if( g_HightLigth_NetCode > 0 )
{
Affiche_1_Parametre(this, 22,_("NetName"),msg,RED) ; pt_equipot = GetEquipot( m_Pcb, g_HightLigth_NetCode );
if( pt_equipot == NULL )
/* Init des points d'accrochage possibles de la zone: {
les pistes du net sont des points d'accrochage convenables*/ if( g_HightLigth_NetCode > 0 )
TRACK * pt_segm = m_Pcb->m_Track; DisplayError( this, wxT( "Equipot Error" ) );
for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext) }
{ else
if(g_HightLigth_NetCode != pt_segm->m_NetCode) continue; msg = pt_equipot->m_Netname;
if ( pt_segm->m_Layer != GetScreen()->m_Active_Layer ) continue; }
if (pt_segm->m_StructType != TYPETRACK ) continue; else
TraceSegmentPcb(m_Pcb, pt_segm, CELL_is_FRIEND, 0, WRITE_CELL ); msg = _( "No Net" );
}
Affiche_1_Parametre( this, 22, _( "NetName" ), msg, RED );
/* Trace des contours du PCB sur la matrice de routage: */
Route_Layer_BOTTOM = Route_Layer_TOP = EDGE_N; /* Init des points d'accrochage possibles de la zone:
PlaceCells(m_Pcb, -1, 0); * les pistes du net sont des points d'accrochage convenables*/
Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer; TRACK* pt_segm = m_Pcb->m_Track;
for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext )
/* Trace des limites de la zone sur la matrice de routage: */ {
PtLim = m_Pcb->m_CurrentLimitZone; if( g_HightLigth_NetCode != pt_segm->m_NetCode )
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*)PtLim->Pback) continue;
{ if( pt_segm->m_Layer != GetScreen()->m_Active_Layer )
int ux0, uy0, ux1, uy1; continue;
ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x; if( pt_segm->m_StructType != TYPETRACK )
uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y; continue;
ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x; TraceSegmentPcb( m_Pcb, pt_segm, CELL_is_FRIEND, 0, WRITE_CELL );
uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y; }
TraceLignePcb(ux0,uy0,ux1,uy1,-1,HOLE|CELL_is_EDGE,WRITE_CELL);
} /* Trace des contours du PCB sur la matrice de routage: */
Route_Layer_BOTTOM = Route_Layer_TOP = EDGE_N;
PlaceCells( m_Pcb, -1, 0 );
OrCell(ZoneStartFill.y,ZoneStartFill.x, BOTTOM, CELL_is_ZONE); Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer;
/* Marquage des cellules faisant partie de la zone*/ /* Trace des limites de la zone sur la matrice de routage: */
ii = 1; jj = 1; PtLim = m_Pcb->m_CurrentLimitZone;
while( ii ) for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
{ {
msg.Printf( wxT("%d"), jj++ ); int ux0, uy0, ux1, uy1;
Affiche_1_Parametre(this, 50, wxT("Iter."),msg,CYAN); ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x;
ii = Propagation(this); uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y;
} ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x;
uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y;
/* Selection des cellules convenables pour les points d'ancrage de la zone */ TraceLignePcb( ux0, uy0, ux1, uy1, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
for( ii = 0; ii < Nrows ; ii++) }
{
for( jj = 0; jj < Ncols ; jj++) OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
{
long cell = GetCell(ii,jj,BOTTOM); /* Marquage des cellules faisant partie de la zone*/
if( (cell & CELL_is_ZONE) ) ii = 1; jj = 1;
{ while( ii )
if ( (cell & CELL_is_FRIEND) == 0) {
AndCell(ii,jj,BOTTOM, (BoardCell) ~(CELL_is_FRIEND|CELL_is_ZONE) ); msg.Printf( wxT( "%d" ), jj++ );
} Affiche_1_Parametre( this, 50, wxT( "Iter." ), msg, CYAN );
} ii = Propagation( this );
} }
/* Selection des cellules convenables pour les points d'ancrage de la zone */
for( ii = 0; ii < Nrows; ii++ )
{
for( jj = 0; jj < Ncols; jj++ )
{
long cell = GetCell( ii, jj, BOTTOM );
if( (cell & CELL_is_ZONE) )
{
if( (cell & CELL_is_FRIEND) == 0 )
AndCell( ii, jj, BOTTOM, (BoardCell) ~(CELL_is_FRIEND | CELL_is_ZONE) );
}
}
}
/* Maintenant, toutes les cellules candidates sont marquees */ /* Maintenant, toutes les cellules candidates sont marquees */
/* Placement des cellules (pads, tracks, vias, edges pcb ou segments)
faisant des obsctacles sur la matrice de routage */ /* Placement des cellules (pads, tracks, vias, edges pcb ou segments)
ii = 0; * faisant des obsctacles sur la matrice de routage */
if( Zone_Exclude_Pads ) ii = FORCE_PADS; ii = 0;
Affiche_1_Parametre(this, 42, wxT("GenZone"),wxEmptyString,RED); if( Zone_Exclude_Pads )
PlaceCells(m_Pcb, g_HightLigth_NetCode, ii); ii = FORCE_PADS;
Affiche_1_Parametre(this, -1, wxEmptyString, _("Ok"),RED);
Affiche_1_Parametre( this, 42, wxT( "GenZone" ), wxEmptyString, RED );
/* Trace des limites de la zone sur la matrice de routage PlaceCells( m_Pcb, g_HightLigth_NetCode, ii );
(a pu etre detruit par PlaceCells()) : */ Affiche_1_Parametre( this, -1, wxEmptyString, _( "Ok" ), RED );
PtLim = m_Pcb->m_CurrentLimitZone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*)PtLim->Pback) /* Trace des limites de la zone sur la matrice de routage
{ * (a pu etre detruit par PlaceCells()) : */
int ux0, uy0, ux1, uy1; PtLim = m_Pcb->m_CurrentLimitZone;
ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x; for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y; {
ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x; int ux0, uy0, ux1, uy1;
uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y; ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x;
TraceLignePcb(ux0,uy0,ux1,uy1,-1,HOLE|CELL_is_EDGE,WRITE_CELL); uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y;
} ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x;
uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y;
TraceLignePcb( ux0, uy0, ux1, uy1, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
/* Init du point d'accrochage de la zone donné par la position souris }
(a pu etre detruit par PlaceCells()) : */
OrCell(ZoneStartFill.y,ZoneStartFill.x, BOTTOM, CELL_is_ZONE); /* Init du point d'accrochage de la zone donné par la position souris
* (a pu etre detruit par PlaceCells()) : */
if(Zone_Debug) DisplayBoard(DrawPanel, DC); OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
/* Remplissage des cellules (creation effective de la zone)*/ if( Zone_Debug )
ii = 1; jj = 1; DisplayBoard( DrawPanel, DC );
while( ii )
{ /* Remplissage des cellules (creation effective de la zone)*/
msg.Printf( wxT("%d"), jj++ ); ii = 1; jj = 1;
Affiche_1_Parametre(this, 50, wxT("Iter."),msg,CYAN); while( ii )
ii = Propagation(this); {
} msg.Printf( wxT( "%d" ), jj++ );
Affiche_1_Parametre( this, 50, wxT( "Iter." ), msg, CYAN );
if(Zone_Debug) DisplayBoard(DrawPanel, DC); ii = Propagation( this );
}
/* Generation des segments de piste type Zone correspondants*/
if(g_HightLigth_NetCode < 0 ) if( Zone_Debug )
Genere_Segments_Zone(this, DC, 0); DisplayBoard( DrawPanel, DC );
else Genere_Segments_Zone(this, DC, g_HightLigth_NetCode);
/* Generation des segments de piste type Zone correspondants*/
/* Trace des connexions type frein thermique */ if( g_HightLigth_NetCode < 0 )
g_DesignSettings.m_CurrentTrackWidth = lp_tmp; Genere_Segments_Zone( this, DC, 0 );
if ( Zone_Exclude_Pads && Zone_Genere_Freins_Thermiques) else
Genere_Pad_Connexion(this, DC, GetScreen()->m_Active_Layer); Genere_Segments_Zone( this, DC, g_HightLigth_NetCode );
g_DesignSettings.m_TrackClearence = save_isol; /* Trace des connexions type frein thermique */
g_DesignSettings.m_CurrentTrackWidth = lp_tmp;
GetScreen()->SetModify(); if( Zone_Exclude_Pads && Zone_Genere_Freins_Thermiques )
Genere_Pad_Connexion( this, DC, GetScreen()->m_Active_Layer );
/* Liberation de la memoire */
Board.UnInitBoard(); g_DesignSettings.m_TrackClearence = save_isol;
/* Reprise des conditions initiales */ GetScreen()->SetModify();
Route_Layer_TOP = lay_tmp_TOP;
Route_Layer_BOTTOM = lay_tmp_BOTTOM; /* Liberation de la memoire */
Board.UnInitBoard();
/* Reprise des conditions initiales */
Route_Layer_TOP = lay_tmp_TOP;
Route_Layer_BOTTOM = lay_tmp_BOTTOM;
} }
/*******************************************************************************/ /*******************************************************************************/
static void Genere_Segments_Zone(WinEDA_PcbFrame *frame, wxDC * DC, int net_code) static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code )
/*******************************************************************************/ /*******************************************************************************/
/* Genere les segments de piste dans les limites de la zone a remplir /* Genere les segments de piste dans les limites de la zone a remplir
Algorithme: * Algorithme:
procede en 2 balayages * procede en 2 balayages
- Gauche->droite * - Gauche->droite
- Haut->Bas * - Haut->Bas
Parametres: * Parametres:
net_code = net_code a attribuer au segment de zone * net_code = net_code a attribuer au segment de zone
TimeStamp(global): signature temporelle d'identification * TimeStamp(global): signature temporelle d'identification
(mis en .start) * (mis en .start)
*/ */
{ {
int row, col; int row, col;
long current_cell, old_cell; long current_cell, old_cell;
int ux0 = 0, uy0 = 0, ux1 = 0, uy1 = 0; int ux0 = 0, uy0 = 0, ux1 = 0, uy1 = 0;
int Xmin = frame->m_Pcb->m_BoundaryBox.m_Pos.x; int Xmin = frame->m_Pcb->m_BoundaryBox.m_Pos.x;
int Ymin = frame->m_Pcb->m_BoundaryBox.m_Pos.y; int Ymin = frame->m_Pcb->m_BoundaryBox.m_Pos.y;
SEGZONE * pt_track; SEGZONE* pt_track;
int layer = frame->GetScreen()->m_Active_Layer; int layer = frame->GetScreen()->m_Active_Layer;
int nbsegm = 0; int nbsegm = 0;
wxString msg; wxString msg;
/* balayage Gauche-> droite */ /* balayage Gauche-> droite */
Affiche_1_Parametre(frame, 64, wxT("Segm H"), wxT("0"),BROWN); Affiche_1_Parametre( frame, 64, wxT( "Segm H" ), wxT( "0" ), BROWN );
for( row = 0; row < Nrows ; row++) for( row = 0; row < Nrows; row++ )
{ {
old_cell = 0; old_cell = 0;
uy0 = uy1 = (row * g_GridRoutingSize) + Ymin; uy0 = uy1 = (row * g_GridRoutingSize) + Ymin;
for( col = 0; col < Ncols ; col++) for( col = 0; col < Ncols; col++ )
{ {
current_cell = GetCell(row,col,BOTTOM) & CELL_is_ZONE; current_cell = GetCell( row, col, BOTTOM ) & CELL_is_ZONE;
if(current_cell) /* ce point doit faire partie d'un segment */ if( current_cell ) /* ce point doit faire partie d'un segment */
{ {
ux1 = (col * g_GridRoutingSize) + Xmin; ux1 = (col * g_GridRoutingSize) + Xmin;
if( old_cell == 0 ) ux0 = ux1; if( old_cell == 0 )
} ux0 = ux1;
}
if( ! current_cell || (col == Ncols-1) ) /* peut etre fin d'un segment */
{ if( !current_cell || (col == Ncols - 1) ) /* peut etre fin d'un segment */
if( (old_cell) && (ux0 != ux1) ) {
{ /* un segment avait debute de longueur > 0 */ if( (old_cell) && (ux0 != ux1) )
pt_track = new SEGZONE(frame->m_Pcb); {
pt_track->m_Layer = layer; /* un segment avait debute de longueur > 0 */
pt_track->m_NetCode = net_code; pt_track = new SEGZONE( frame->m_Pcb );
pt_track->m_Width = g_GridRoutingSize; pt_track->m_Layer = layer;
pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; pt_track->m_NetCode = net_code;
pt_track->m_End.x = ux1; pt_track->m_End.y = uy1; pt_track->m_Width = g_GridRoutingSize;
pt_track->m_TimeStamp = s_TimeStamp; pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0;
pt_track->Insert(frame->m_Pcb, NULL); pt_track->m_End.x = ux1; pt_track->m_End.y = uy1;
pt_track->Draw(frame->DrawPanel, DC, GR_OR); pt_track->m_TimeStamp = s_TimeStamp;
nbsegm++; pt_track->Insert( frame->m_Pcb, NULL );
} pt_track->Draw( frame->DrawPanel, DC, GR_OR );
} nbsegm++;
old_cell = current_cell; }
} }
msg.Printf( wxT("%d"),nbsegm); old_cell = current_cell;
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,BROWN); }
}
msg.Printf( wxT( "%d" ), nbsegm );
Affiche_1_Parametre(frame, 72, wxT("Segm V"), wxT("0"),BROWN); Affiche_1_Parametre( frame, -1, wxEmptyString, msg, BROWN );
for( col = 0; col < Ncols ; col++) }
{
old_cell = 0; Affiche_1_Parametre( frame, 72, wxT( "Segm V" ), wxT( "0" ), BROWN );
ux0 = ux1 = (col * g_GridRoutingSize) + Xmin; for( col = 0; col < Ncols; col++ )
for( row = 0; row < Nrows ; row++) {
{ old_cell = 0;
current_cell = GetCell(row,col,BOTTOM) & CELL_is_ZONE; ux0 = ux1 = (col * g_GridRoutingSize) + Xmin;
if(current_cell) /* ce point doit faire partie d'un segment */ for( row = 0; row < Nrows; row++ )
{ {
uy1 = (row * g_GridRoutingSize) + Ymin; current_cell = GetCell( row, col, BOTTOM ) & CELL_is_ZONE;
if( old_cell == 0 ) uy0 = uy1; if( current_cell ) /* ce point doit faire partie d'un segment */
} {
if( ! current_cell || (row == Nrows-1) ) /* peut etre fin d'un segment */ uy1 = (row * g_GridRoutingSize) + Ymin;
{ if( old_cell == 0 )
if( (old_cell) && (uy0 != uy1) ) uy0 = uy1;
{ /* un segment avait debute de longueur > 0 */ }
pt_track = new SEGZONE(frame->m_Pcb); if( !current_cell || (row == Nrows - 1) ) /* peut etre fin d'un segment */
pt_track->m_Layer = layer; {
pt_track->m_Width = g_GridRoutingSize; if( (old_cell) && (uy0 != uy1) )
pt_track->m_NetCode = net_code; {
pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; /* un segment avait debute de longueur > 0 */
pt_track->m_End.x = ux1; pt_track->m_End.y = uy1; pt_track = new SEGZONE( frame->m_Pcb );
pt_track->m_TimeStamp = s_TimeStamp; pt_track->m_Layer = layer;
pt_track->Insert(frame->m_Pcb, NULL); pt_track->m_Width = g_GridRoutingSize;
pt_track->Draw(frame->DrawPanel, DC, GR_OR); pt_track->m_NetCode = net_code;
nbsegm++; pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0;
} pt_track->m_End.x = ux1; pt_track->m_End.y = uy1;
} pt_track->m_TimeStamp = s_TimeStamp;
old_cell = current_cell; pt_track->Insert( frame->m_Pcb, NULL );
} pt_track->Draw( frame->DrawPanel, DC, GR_OR );
msg.Printf( wxT("%d"),nbsegm); nbsegm++;
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,BROWN); }
} }
old_cell = current_cell;
}
msg.Printf( wxT( "%d" ), nbsegm );
Affiche_1_Parametre( frame, -1, wxEmptyString, msg, BROWN );
}
} }
/********************************************/ /********************************************/
int Propagation(WinEDA_PcbFrame * frame) int Propagation( WinEDA_PcbFrame* frame )
/********************************************/ /********************************************/
/* Determine les cellules inscrites dans les limites de la zone a remplir /* Determine les cellules inscrites dans les limites de la zone a remplir
Algorithme: * Algorithme:
Si une cellule disponible a un voisin faisant partie de la zone, elle * Si une cellule disponible a un voisin faisant partie de la zone, elle
devient elle meme partie de la zone * devient elle meme partie de la zone
On procede en 4 balayages de la matrice des cellules * On procede en 4 balayages de la matrice des cellules
- Gauche->droite de Haut->bas * - Gauche->droite de Haut->bas
- Droite->gauche de Haut->bas * - Droite->gauche de Haut->bas
- Bas->Haut de Droite->gauche * - Bas->Haut de Droite->gauche
- Bas->Haut de Gauche->Droite * - Bas->Haut de Gauche->Droite
et pour chaque balayage, on considere des 2 cellules voisines de * et pour chaque balayage, on considere des 2 cellules voisines de
la cellule courants: cellule precedente sur la ligne et cellule precedente * la cellule courants: cellule precedente sur la ligne et cellule precedente
sur la colonne. * sur la colonne.
*
La routine peut demander plusieurs iterations * La routine peut demander plusieurs iterations
les iterations doivent continuer juqu'a ce que la routine ne trouve plus * les iterations doivent continuer juqu'a ce que la routine ne trouve plus
de cellules a modifier. * de cellules a modifier.
Retourne: * Retourne:
Nombre de cellules modifiees (c.a.d mises a la valeur CELL_is_ZONE. * Nombre de cellules modifiees (c.a.d mises a la valeur CELL_is_ZONE.
*/ */
{ {
int row, col, nn; int row, col, nn;
long current_cell, old_cell_H; long current_cell, old_cell_H;
int long * pt_cell_V; int long* pt_cell_V;
int nbpoints = 0; int nbpoints = 0;
#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE) #define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE)
wxString msg; wxString msg;
Affiche_1_Parametre(frame, 57, wxT("Detect"),msg,CYAN); Affiche_1_Parametre( frame, 57, wxT( "Detect" ), msg, CYAN );
/* balayage Gauche-> droite de Haut->bas */ /* balayage Gauche-> droite de Haut->bas */
Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("1"),CYAN); Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "1" ), CYAN );
// Reservation memoire pour stockahe de 1 ligne ou une colonne de cellules // Reservation memoire pour stockahe de 1 ligne ou une colonne de cellules
nn = MAX(Nrows, Ncols) * sizeof(*pt_cell_V); nn = MAX( Nrows, Ncols ) * sizeof(*pt_cell_V);
pt_cell_V = (long *) MyMalloc(nn); pt_cell_V = (long*) MyMalloc( nn );
memset(pt_cell_V, 0, nn);
for( row = 0; row < Nrows ; row++) memset( pt_cell_V, 0, nn );
{ for( row = 0; row < Nrows; row++ )
old_cell_H = 0; {
for( col = 0; col < Ncols ; col++) old_cell_H = 0;
{ for( col = 0; col < Ncols; col++ )
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE; {
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
{ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
if( (old_cell_H & CELL_is_ZONE) {
|| (pt_cell_V[col] & CELL_is_ZONE) ) if( (old_cell_H & CELL_is_ZONE)
{ || (pt_cell_V[col] & CELL_is_ZONE) )
OrCell(row,col,BOTTOM,CELL_is_ZONE); {
current_cell = CELL_is_ZONE; OrCell( row, col, BOTTOM, CELL_is_ZONE );
nbpoints++; current_cell = CELL_is_ZONE;
} nbpoints++;
} }
pt_cell_V[col] = old_cell_H = current_cell; }
} pt_cell_V[col] = old_cell_H = current_cell;
} }
}
/* balayage Droite-> gauche de Haut->bas */
Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("2"),CYAN); /* balayage Droite-> gauche de Haut->bas */
memset(pt_cell_V, 0, nn); Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "2" ), CYAN );
for( row = 0; row < Nrows ; row++) memset( pt_cell_V, 0, nn );
{ for( row = 0; row < Nrows; row++ )
old_cell_H = 0; {
for( col = Ncols -1 ; col >= 0 ; col--) old_cell_H = 0;
{ for( col = Ncols - 1; col >= 0; col-- )
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; {
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
{ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
if( (old_cell_H & CELL_is_ZONE) {
|| (pt_cell_V[col] & CELL_is_ZONE) ) if( (old_cell_H & CELL_is_ZONE)
{ || (pt_cell_V[col] & CELL_is_ZONE) )
OrCell(row,col,BOTTOM,CELL_is_ZONE); {
current_cell = CELL_is_ZONE; OrCell( row, col, BOTTOM, CELL_is_ZONE );
nbpoints++; current_cell = CELL_is_ZONE;
} nbpoints++;
} }
pt_cell_V[col] = old_cell_H = current_cell; }
} pt_cell_V[col] = old_cell_H = current_cell;
} }
}
/* balayage Bas->Haut de Droite->gauche */
Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("3"),CYAN); /* balayage Bas->Haut de Droite->gauche */
memset(pt_cell_V, 0, nn); Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "3" ), CYAN );
for( col = Ncols -1 ; col >= 0 ; col--) memset( pt_cell_V, 0, nn );
{ for( col = Ncols - 1; col >= 0; col-- )
old_cell_H = 0; {
for( row = Nrows-1; row >= 0 ; row--) old_cell_H = 0;
{ for( row = Nrows - 1; row >= 0; row-- )
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; {
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
{ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
if( (old_cell_H & CELL_is_ZONE) {
|| (pt_cell_V[row] & CELL_is_ZONE) ) if( (old_cell_H & CELL_is_ZONE)
{ || (pt_cell_V[row] & CELL_is_ZONE) )
OrCell(row,col,BOTTOM,CELL_is_ZONE); {
current_cell = CELL_is_ZONE; OrCell( row, col, BOTTOM, CELL_is_ZONE );
nbpoints++; current_cell = CELL_is_ZONE;
} nbpoints++;
} }
pt_cell_V[row] = old_cell_H = current_cell; }
} pt_cell_V[row] = old_cell_H = current_cell;
} }
}
/* balayage Bas->Haut de Gauche->Droite*/
Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("4"),CYAN); /* balayage Bas->Haut de Gauche->Droite*/
memset(pt_cell_V, 0, nn); Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "4" ), CYAN );
for( col = 0 ; col < Ncols ; col++) memset( pt_cell_V, 0, nn );
{ for( col = 0; col < Ncols; col++ )
old_cell_H = 0; {
for( row = Nrows-1; row >= 0 ; row--) old_cell_H = 0;
{ for( row = Nrows - 1; row >= 0; row-- )
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; {
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
{ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
if( (old_cell_H & CELL_is_ZONE) {
|| (pt_cell_V[row] & CELL_is_ZONE) ) if( (old_cell_H & CELL_is_ZONE)
{ || (pt_cell_V[row] & CELL_is_ZONE) )
OrCell(row,col,BOTTOM,CELL_is_ZONE) ; {
current_cell = CELL_is_ZONE; OrCell( row, col, BOTTOM, CELL_is_ZONE );
nbpoints++; current_cell = CELL_is_ZONE;
} nbpoints++;
} }
pt_cell_V[row] = old_cell_H = current_cell; }
} pt_cell_V[row] = old_cell_H = current_cell;
} }
}
MyFree(pt_cell_V);
MyFree( pt_cell_V );
return(nbpoints);
return nbpoints;
} }
/*****************************************************************************/ /*****************************************************************************/
static bool Genere_Pad_Connexion(WinEDA_PcbFrame *frame, wxDC * DC, int layer) static bool Genere_Pad_Connexion( WinEDA_PcbFrame* frame, wxDC* DC, int layer )
/*****************************************************************************/ /*****************************************************************************/
/* Generation des segments de zone de connexion zone / pad pour constitution /* Generation des segments de zone de connexion zone / pad pour constitution
de freins thermiques * de freins thermiques
*/ */
{ {
int ii, jj, Npads; int ii, jj, Npads;
D_PAD * pt_pad; D_PAD* pt_pad;
LISTE_PAD * pt_liste_pad; LISTE_PAD* pt_liste_pad;
TRACK * pt_track, * loctrack; TRACK* pt_track, * loctrack;
int angle; int angle;
int cX, cY, dx, dy; int cX, cY, dx, dy;
int sommet[4][2]; int sommet[4][2];
wxString msg; wxString msg;
if( frame->m_Pcb->m_Zone == NULL ) return FALSE; /* pas de zone */ if( frame->m_Pcb->m_Zone == NULL )
if( frame->m_Pcb->m_Zone->m_TimeStamp != s_TimeStamp ) /* c'est une autre zone */ return FALSE; /* pas de zone */
return FALSE; if( frame->m_Pcb->m_Zone->m_TimeStamp != s_TimeStamp ) /* c'est une autre zone */
return FALSE;
/* Calcul du nombre de pads a traiter et affichage */
Affiche_1_Parametre(frame, 50, wxT("NPads"),wxT(" "),CYAN); /* Calcul du nombre de pads a traiter et affichage */
pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads; Affiche_1_Parametre( frame, 50, wxT( "NPads" ), wxT( " " ), CYAN );
for ( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++) pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads;
{ for( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++ )
pt_pad = *pt_liste_pad; {
/* la pastille doit etre du meme net */ pt_pad = *pt_liste_pad;
if(pt_pad->m_NetCode != g_HightLigth_NetCode) continue;
/* la pastille doit exister sur la couche */ /* la pastille doit etre du meme net */
if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 ) continue; if( pt_pad->m_NetCode != g_HightLigth_NetCode )
Npads++; continue;
}
msg.Printf( wxT("%d"), Npads ); /* la pastille doit exister sur la couche */
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,CYAN); if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 )
continue;
Affiche_1_Parametre(frame, 57, wxT("Pads"), wxT(" "),CYAN); Npads++;
pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads; }
for ( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++)
{ msg.Printf( wxT( "%d" ), Npads );
pt_pad = *pt_liste_pad; Affiche_1_Parametre( frame, -1, wxEmptyString, msg, CYAN );
/* la pastille doit etre du meme net */ Affiche_1_Parametre( frame, 57, wxT( "Pads" ), wxT( " " ), CYAN );
if(pt_pad->m_NetCode != g_HightLigth_NetCode) continue; pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads;
/* la pastille doit exister sur la couche */ for( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++ )
if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 ) continue; {
pt_pad = *pt_liste_pad;
/* traitement du pad en cours */
Npads++; msg.Printf( wxT("%d"), Npads ); /* la pastille doit etre du meme net */
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,CYAN); if( pt_pad->m_NetCode != g_HightLigth_NetCode )
cX = pt_pad->m_Pos.x; cY = pt_pad->m_Pos.y; continue;
dx = pt_pad->m_Size.x / 2; /* la pastille doit exister sur la couche */
dy = pt_pad->m_Size.y / 2; if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 )
dx += g_DesignSettings.m_TrackClearence + g_GridRoutingSize; continue;
dy += g_DesignSettings.m_TrackClearence + g_GridRoutingSize;
/* traitement du pad en cours */
if(pt_pad->m_PadShape == TRAPEZE) Npads++; msg.Printf( wxT( "%d" ), Npads );
{ Affiche_1_Parametre( frame, -1, wxEmptyString, msg, CYAN );
dx += abs(pt_pad->m_DeltaSize.y) / 2; cX = pt_pad->m_Pos.x; cY = pt_pad->m_Pos.y;
dy += abs(pt_pad->m_DeltaSize.x) / 2; dx = pt_pad->m_Size.x / 2;
} dy = pt_pad->m_Size.y / 2;
dx += g_DesignSettings.m_TrackClearence + g_GridRoutingSize;
/* calcul des coord des 4 segments a rajouter a partir du centre cX,cY */ dy += g_DesignSettings.m_TrackClearence + g_GridRoutingSize;
sommet[0][0] = 0; sommet[0][1] = -dy;
sommet[1][0] = -dx; sommet[1][1] = 0; if( pt_pad->m_PadShape == TRAPEZE )
sommet[2][0] = 0; sommet[2][1] = dy; {
sommet[3][0] = dx; sommet[3][1] = 0; dx += abs( pt_pad->m_DeltaSize.y ) / 2;
dy += abs( pt_pad->m_DeltaSize.x ) / 2;
angle = pt_pad->m_Orient; }
for(jj = 0; jj < 4; jj++)
{ /* calcul des coord des 4 segments a rajouter a partir du centre cX,cY */
RotatePoint(&sommet[jj][0], &sommet[jj][1], angle); sommet[0][0] = 0; sommet[0][1] = -dy;
sommet[1][0] = -dx; sommet[1][1] = 0;
pt_track = new SEGZONE(frame->m_Pcb); sommet[2][0] = 0; sommet[2][1] = dy;
sommet[3][0] = dx; sommet[3][1] = 0;
pt_track->m_Layer = layer;
pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; angle = pt_pad->m_Orient;
pt_track->m_NetCode = g_HightLigth_NetCode; for( jj = 0; jj < 4; jj++ )
pt_track->start = pt_pad; {
pt_track->m_Start.x = cX; pt_track->m_Start.y = cY; RotatePoint( &sommet[jj][0], &sommet[jj][1], angle );
pt_track->m_End.x = cX + sommet[jj][0];
pt_track->m_End.y = cY + sommet[jj][1]; pt_track = new SEGZONE( frame->m_Pcb );
pt_track->m_TimeStamp = s_TimeStamp;
pt_track->m_Layer = layer;
/* tst si trace possible */ pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth;
if( Drc(frame, DC, pt_track,frame->m_Pcb->m_Track,0) == BAD_DRC ) pt_track->m_NetCode = g_HightLigth_NetCode;
{ pt_track->start = pt_pad;
delete pt_track; continue; pt_track->m_Start.x = cX; pt_track->m_Start.y = cY;
} pt_track->m_End.x = cX + sommet[jj][0];
pt_track->m_End.y = cY + sommet[jj][1];
/* on doit pouvoir se connecter sur la zone */ pt_track->m_TimeStamp = s_TimeStamp;
loctrack = Locate_Zone(frame->m_Pcb->m_Zone,pt_track->m_End, layer);
if( (loctrack == NULL) || (loctrack->m_TimeStamp != s_TimeStamp) ) /* tst si trace possible */
{ if( Drc( frame, DC, pt_track, frame->m_Pcb->m_Track, 0 ) == BAD_DRC )
delete pt_track; continue; {
} delete pt_track; continue;
}
pt_track->Insert(frame->m_Pcb, NULL);
pt_track->Draw(frame->DrawPanel, DC, GR_OR); /* on doit pouvoir se connecter sur la zone */
} loctrack = Locate_Zone( frame->m_Pcb->m_Zone, pt_track->m_End, layer );
} if( (loctrack == NULL) || (loctrack->m_TimeStamp != s_TimeStamp) )
return TRUE; {
delete pt_track; continue;
}
pt_track->Insert( frame->m_Pcb, NULL );
pt_track->Draw( frame->DrawPanel, DC, GR_OR );
}
}
return TRUE;
} }
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