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,18 +14,18 @@ ...@@ -14,18 +14,18 @@
#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 */
...@@ -36,8 +36,8 @@ static float OrientPenality[11] = { ...@@ -36,8 +36,8 @@ static float OrientPenality[11] = {
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
...@@ -50,41 +50,42 @@ static bool AutoPlaceShowAll = TRUE; ...@@ -50,41 +50,42 @@ 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_AbortRequest = FALSE;
DrawPanel->m_AbortEnable = TRUE; DrawPanel->m_AbortEnable = TRUE;
...@@ -93,20 +94,21 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -93,20 +94,21 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
{ {
case PLACE_1_MODULE: case PLACE_1_MODULE:
ThisModule = Module; ThisModule = Module;
if(ThisModule == NULL) return; if( ThisModule == NULL )
ThisModule->m_ModuleStatus &= ~(MODULE_is_PLACED|MODULE_to_PLACE); return;
ThisModule->m_ModuleStatus &= ~(MODULE_is_PLACED | MODULE_to_PLACE);
break; break;
case PLACE_OUT_OF_BOARD: case PLACE_OUT_OF_BOARD:
break; break;
case PLACE_ALL: case PLACE_ALL:
if( ! IsOK(this, _("Footprints NOT LOCKED will be moved") )) if( !IsOK( this, _( "Footprints NOT LOCKED will be moved" ) ) )
return; return;
break; break;
case PLACE_INCREMENTAL: case PLACE_INCREMENTAL:
if( ! IsOK(this, _("Footprints NOT PLACED will be moved")) ) if( !IsOK( this, _( "Footprints NOT PLACED will be moved" ) ) )
return; return;
break; break;
} }
...@@ -117,27 +119,30 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -117,27 +119,30 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
OldPasRoute = g_GridRoutingSize; OldPasRoute = g_GridRoutingSize;
g_GridRoutingSize = m_CurrentScreen->GetGrid().x; g_GridRoutingSize = m_CurrentScreen->GetGrid().x;
// Ensure g_GridRoutingSize has a reasonnable value: // Ensure g_GridRoutingSize has a reasonnable value:
if ( g_GridRoutingSize < 10 ) g_GridRoutingSize = 10; // Min value = 1/1000 inch if( g_GridRoutingSize < 10 )
g_GridRoutingSize = 10; // Min value = 1/1000 inch
/* Compute module parmeters used in auto place */ /* Compute module parmeters used in auto place */
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext) // remise a jour du rect d'encadrement for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) // remise a jour du rect d'encadrement
{ {
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit(); Module->SetRectangleExinscrit();
} }
/* Generation du plan de placement */ /* Generation du plan de placement */
if( GenPlaceBoard() == 0) return; if( GenPlaceBoard() == 0 )
return;
/* Mise a jour des parametres modules utiles au placement */ /* Mise a jour des parametres modules utiles au placement */
BaseListeModules = GenListeModules(m_Pcb, &NbTotalModules ); BaseListeModules = GenListeModules( m_Pcb, &NbTotalModules );
MyFree(BaseListeModules); MyFree( BaseListeModules );
/* Placement des modules fixes sur le plan de placement */ /* Placement des modules fixes sur le plan de placement */
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
Module->m_ModuleStatus &= ~MODULE_to_PLACE; Module->m_ModuleStatus &= ~MODULE_to_PLACE;
...@@ -150,14 +155,16 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -150,14 +155,16 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
case PLACE_OUT_OF_BOARD: case PLACE_OUT_OF_BOARD:
Module->m_ModuleStatus &= ~MODULE_is_PLACED; Module->m_ModuleStatus &= ~MODULE_is_PLACED;
if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; if( Module->m_ModuleStatus & MODULE_is_LOCKED )
if( ! m_Pcb->m_BoundaryBox.Inside(Module->m_Pos) ) 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_ALL: case PLACE_ALL:
Module->m_ModuleStatus &= ~MODULE_is_PLACED; Module->m_ModuleStatus &= ~MODULE_is_PLACED;
if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; if( Module->m_ModuleStatus & MODULE_is_LOCKED )
break;
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
break; break;
...@@ -166,7 +173,7 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -166,7 +173,7 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
{ {
Module->m_ModuleStatus &= ~MODULE_is_PLACED; break; Module->m_ModuleStatus &= ~MODULE_is_PLACED; break;
} }
if( ! (Module->m_ModuleStatus & MODULE_is_PLACED) ) if( !(Module->m_ModuleStatus & MODULE_is_PLACED) )
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
break; break;
} }
...@@ -175,40 +182,41 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -175,40 +182,41 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
if( Module->m_ModuleStatus & MODULE_to_PLACE ) // Erase from screen if( Module->m_ModuleStatus & MODULE_to_PLACE ) // Erase from screen
{ {
NbModules++; NbModules++;
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
} }
else else
{ {
GenModuleOnBoard(Module); GenModuleOnBoard( Module );
} }
} }
/* Placement des modules */ /* Placement des modules */
activ = 0; Pas = 100.0; activ = 0; Pas = 100.0;
if( NbModules ) Pas = 100.0 / (float)NbModules; if( NbModules )
while( (Module = PickModule(this, DC) ) != NULL ) Pas = 100.0 / (float) NbModules;
while( ( Module = PickModule( this, DC ) ) != NULL )
{ {
float BestScore; float BestScore;
DisplayActivity((int)(activ * Pas) , wxEmptyString ); activ++; DisplayActivity( (int) (activ * Pas), wxEmptyString ); activ++;
/* Affichage du remplissage: surface de placement, obstacles, penalites */ /* Affichage du remplissage: surface de placement, obstacles, penalites */
DrawInfoPlace(DC); DrawInfoPlace( DC );
/* Recherche du placement: orientation 0 */ /* Recherche du placement: orientation 0 */
error = RecherchePlacementModule(Module, DC); error = RecherchePlacementModule( Module, DC );
BestScore = MinCout; BestScore = MinCout;
PosOK = CurrPosition; PosOK = CurrPosition;
if ( error == ESC ) goto end_of_tst; if( error == ESC )
goto end_of_tst;
/* Recherche du placement: orientation 180 */ /* Recherche du placement: orientation 180 */
ii = Module->m_CntRot180 & 0x0F; ii = Module->m_CntRot180 & 0x0F;
if( ii != 0 ) if( ii != 0 )
{ {
int Angle_Rot_Module = 1800; int Angle_Rot_Module = 1800;
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
Module->SetRectangleExinscrit(); Module->SetRectangleExinscrit();
error = RecherchePlacementModule(Module, DC ); error = RecherchePlacementModule( Module, DC );
MinCout *= OrientPenality[ii]; MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) /* Cette orientation est meilleure */ if( BestScore > MinCout ) /* Cette orientation est meilleure */
{ {
...@@ -218,9 +226,10 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -218,9 +226,10 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
else else
{ {
Angle_Rot_Module = -1800; Angle_Rot_Module = -1800;
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
} }
if ( error == ESC ) goto end_of_tst; if( error == ESC )
goto end_of_tst;
} }
/* Recherche du placement: orientation 90 */ /* Recherche du placement: orientation 90 */
...@@ -228,8 +237,8 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -228,8 +237,8 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
if( ii != 0 ) if( ii != 0 )
{ {
int Angle_Rot_Module = 900; int Angle_Rot_Module = 900;
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
error = RecherchePlacementModule(Module, DC ); error = RecherchePlacementModule( Module, DC );
MinCout *= OrientPenality[ii]; MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) /* Cette orientation est meilleure */ if( BestScore > MinCout ) /* Cette orientation est meilleure */
{ {
...@@ -239,9 +248,10 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -239,9 +248,10 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
else else
{ {
Angle_Rot_Module = -900; Angle_Rot_Module = -900;
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
} }
if ( error == ESC ) goto end_of_tst; if( error == ESC )
goto end_of_tst;
} }
/* Recherche du placement: orientation -90 (ou 270 degres) */ /* Recherche du placement: orientation -90 (ou 270 degres) */
...@@ -249,8 +259,8 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -249,8 +259,8 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
if( ii != 0 ) if( ii != 0 )
{ {
int Angle_Rot_Module = 2700; 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 ); error = RecherchePlacementModule( Module, DC );
MinCout *= OrientPenality[ii]; MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) /* Cette orientation est meilleure */ if( BestScore > MinCout ) /* Cette orientation est meilleure */
{ {
...@@ -260,25 +270,27 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute; ...@@ -260,25 +270,27 @@ int lay_tmp_TOP, lay_tmp_BOTTOM, OldPasRoute;
else else
{ {
Angle_Rot_Module = -2700; Angle_Rot_Module = -2700;
Rotate_Module(DC, Module, Angle_Rot_Module, FALSE); Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
} }
if ( error == ESC ) goto end_of_tst; if( error == ESC )
goto end_of_tst;
} }
end_of_tst: end_of_tst:
if ( error == ESC ) break; if( error == ESC )
break;
/* placement du module */ /* placement du module */
CurrPosition = m_CurrentScreen->m_Curseur; CurrPosition = m_CurrentScreen->m_Curseur;
m_CurrentScreen->m_Curseur = PosOK; m_CurrentScreen->m_Curseur = PosOK;
Place_Module(Module, DC); Place_Module( Module, DC );
m_CurrentScreen->m_Curseur = CurrPosition; m_CurrentScreen->m_Curseur = CurrPosition;
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit(); Module->SetRectangleExinscrit();
GenModuleOnBoard(Module); GenModuleOnBoard( Module );
Module->m_ModuleStatus |= MODULE_is_PLACED; Module->m_ModuleStatus |= MODULE_is_PLACED;
Module->m_ModuleStatus &= ~MODULE_to_PLACE; Module->m_ModuleStatus &= ~MODULE_to_PLACE;
} }
...@@ -293,7 +305,7 @@ end_of_tst: ...@@ -293,7 +305,7 @@ end_of_tst:
g_GridRoutingSize = OldPasRoute; g_GridRoutingSize = OldPasRoute;
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
} }
...@@ -301,89 +313,94 @@ end_of_tst: ...@@ -301,89 +313,94 @@ end_of_tst:
/* Recalcul de la liste des pads, detruite par les calculs precedents */ /* Recalcul de la liste des pads, detruite par les calculs precedents */
m_Pcb->m_Status_Pcb = 0; build_liste_pads(); m_Pcb->m_Status_Pcb = 0; build_liste_pads();
DrawPanel->ReDraw(DC, TRUE); DrawPanel->ReDraw( DC, TRUE );
DrawPanel->m_AbortEnable = FALSE; 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 */ /* obstacles */
if( (top_state & CELL_is_EDGE) || (bottom_state & CELL_is_EDGE)) color = WHITE; if( (top_state & CELL_is_EDGE) || (bottom_state & CELL_is_EDGE) )
color = WHITE;
else if( top_state & (HOLE|CELL_is_MODULE) ) color = LIGHTRED; else if( top_state & (HOLE | CELL_is_MODULE) )
else if( bottom_state & (HOLE|CELL_is_MODULE) ) color = LIGHTGREEN; color = LIGHTRED;
else if( bottom_state & (HOLE | CELL_is_MODULE) )
color = LIGHTGREEN;
else /* Affichage du remplissage: Penalites */ else /* Affichage du remplissage: Penalites */
{ {
if( GetDist(ii, jj , TOP ) || GetDist(ii, jj , BOTTOM ) ) if( GetDist( ii, jj, TOP ) || GetDist( ii, jj, BOTTOM ) )
color = DARKGRAY; color = DARKGRAY;
} }
GRPutPixel(&DrawPanel->m_ClipBox, DC, ox, oy, color); 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: */
...@@ -393,7 +410,7 @@ wxString msg; ...@@ -393,7 +410,7 @@ wxString msg;
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;
...@@ -402,160 +419,172 @@ wxString msg; ...@@ -402,160 +419,172 @@ wxString msg;
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 */ /* Creation du mapping du board */
Board.InitBoard(); Board.InitBoard();
/* Affichage de la memoire utilisee */ /* Affichage de la memoire utilisee */
msg.Printf( wxT("%d"), Board.m_MemSize / 1024 ); msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
Affiche_1_Parametre(this, 24, wxT("Mem(Ko)"),msg,CYAN); Affiche_1_Parametre( this, 24, wxT( "Mem(Ko)" ), msg, CYAN );
Route_Layer_BOTTOM = CMP_N; Route_Layer_BOTTOM = CMP_N;
if( Nb_Sides == TWO_SIDES ) Route_Layer_BOTTOM = CUIVRE_N; if( Nb_Sides == TWO_SIDES )
Route_Layer_BOTTOM = CUIVRE_N;
Route_Layer_TOP = CMP_N; Route_Layer_TOP = CMP_N;
/* Place the edge layer segments */ /* Place the edge layer segments */
PtStruct = m_Pcb->m_Drawings; PtStruct = m_Pcb->m_Drawings;
TRACK TmpSegm(NULL); TRACK TmpSegm( NULL );
TmpSegm.m_Layer = -1; TmpSegm.m_Layer = -1;
TmpSegm.m_NetCode = -1; TmpSegm.m_NetCode = -1;
TmpSegm.m_Width = g_GridRoutingSize/2; TmpSegm.m_Width = g_GridRoutingSize / 2;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
DRAWSEGMENT * DrawSegm; DRAWSEGMENT* DrawSegm;
switch( PtStruct->m_StructType)
switch( PtStruct->m_StructType )
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
DrawSegm = (DRAWSEGMENT *) PtStruct; DrawSegm = (DRAWSEGMENT*) PtStruct;
if(DrawSegm->m_Layer != EDGE_N) break; if( DrawSegm->m_Layer != EDGE_N )
break;
TmpSegm.m_Start = DrawSegm->m_Start; TmpSegm.m_Start = DrawSegm->m_Start;
TmpSegm.m_End = DrawSegm->m_End; TmpSegm.m_End = DrawSegm->m_End;
TmpSegm.m_Shape = DrawSegm->m_Shape; TmpSegm.m_Shape = DrawSegm->m_Shape;
TmpSegm.m_Param = DrawSegm->m_Angle; TmpSegm.m_Param = DrawSegm->m_Angle;
TraceSegmentPcb(m_Pcb, &TmpSegm, HOLE|CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL ); TraceSegmentPcb( m_Pcb, &TmpSegm, HOLE | CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL );
break; break;
case TYPETEXTE: case TYPETEXTE:
default: break; default:
break;
} }
} }
/* Init du point d'accrochage de la zone */ /* Init du point d'accrochage de la zone */
OrCell(Nrows/2, Ncols/2, BOTTOM, CELL_is_ZONE); OrCell( Nrows / 2, Ncols / 2, BOTTOM, CELL_is_ZONE );
/* Remplissage des cellules de la couche BOTTOM */ /* Remplissage des cellules de la couche BOTTOM */
ii = 1; jj = 1; ii = 1; jj = 1;
while( ii ) while( ii )
{ {
msg.Printf( wxT("%d"), jj++ ); msg.Printf( wxT( "%d" ), jj++ );
Affiche_1_Parametre(this, 50, _("Loop"),msg,CYAN); Affiche_1_Parametre( this, 50, _( "Loop" ), msg, CYAN );
ii = Propagation(this); ii = Propagation( this );
} }
/* Init de la couche TOP */ /* Init de la couche TOP */
if( Board.m_BoardSide[TOP] ) if( Board.m_BoardSide[TOP] )
memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM],NbCells * sizeof(BoardCell)); memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM], NbCells * sizeof(BoardCell) );
return(1); 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;
if( fx > m_Pcb->m_BoundaryBox.GetRight() )
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.m_Pos.y )
if( oy > m_Pcb->m_BoundaryBox.GetBottom()) oy = m_Pcb->m_BoundaryBox.m_Pos.y;
if( oy > m_Pcb->m_BoundaryBox.GetBottom() )
oy = m_Pcb->m_BoundaryBox.GetBottom(); oy = m_Pcb->m_BoundaryBox.GetBottom();
if( fy < m_Pcb->m_BoundaryBox.m_Pos.y) fy = m_Pcb->m_BoundaryBox.m_Pos.y; if( fy < m_Pcb->m_BoundaryBox.m_Pos.y )
if( fy > m_Pcb->m_BoundaryBox.GetBottom()) fy = m_Pcb->m_BoundaryBox.m_Pos.y;
if( fy > m_Pcb->m_BoundaryBox.GetBottom() )
fy = m_Pcb->m_BoundaryBox.GetBottom(); fy = m_Pcb->m_BoundaryBox.GetBottom();
masque_layer = 0; masque_layer = 0;
if( Module->m_Layer == CMP_N ) masque_layer = CMP_LAYER; if( Module->m_Layer == CMP_N )
if( Module->m_Layer == CUIVRE_N ) masque_layer = CUIVRE_LAYER; masque_layer = CMP_LAYER;
if( Module->m_Layer == CUIVRE_N )
masque_layer = CUIVRE_LAYER;
TraceFilledRectangle(m_Pcb, ox, oy, fx, fy, masque_layer, TraceFilledRectangle( m_Pcb, ox, oy, fx, fy, masque_layer,
CELL_is_MODULE, WRITE_OR_CELL); CELL_is_MODULE, WRITE_OR_CELL );
/* Trace des pads et leur surface de securite */ /* Trace des pads et leur surface de securite */
marge = g_DesignSettings.m_TrackClearence + g_DesignSettings.m_CurrentTrackWidth; marge = g_DesignSettings.m_TrackClearence + g_DesignSettings.m_CurrentTrackWidth;
for(Pad = Module->m_Pads ; Pad != NULL; Pad = (D_PAD *) Pad->Pnext ) for( Pad = Module->m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext )
{ {
Place_1_Pad_Board( m_Pcb, Pad, CELL_is_MODULE, marge, WRITE_OR_CELL); Place_1_Pad_Board( m_Pcb, Pad, CELL_is_MODULE, marge, WRITE_OR_CELL );
} }
/* Trace de la penalite */ /* Trace de la penalite */
marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN; marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN;
Penalite = PENALITE; Penalite = PENALITE;
TracePenaliteRectangle(m_Pcb, ox, oy, fx, fy, marge, Penalite, TracePenaliteRectangle( m_Pcb, ox, oy, fx, fy, marge, Penalite,
masque_layer); 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;
...@@ -577,72 +606,77 @@ bool TstOtherSide; ...@@ -577,72 +606,77 @@ bool TstOtherSide;
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; if( (Pad->m_Masque_Layer & masque_otherlayer) == 0 )
continue;
TstOtherSide = TRUE; TstOtherSide = TRUE;
break; break;
} }
} }
DrawModuleOutlines(DrawPanel, DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
mincout = -1.0; mincout = -1.0;
Affiche_Message(wxT("Score ??, pos ??") ); Affiche_Message( wxT( "Score ??, pos ??" ) );
for ( ; CurrPosition.x < m_Pcb->m_BoundaryBox.GetRight() - fx; for( ; CurrPosition.x < m_Pcb->m_BoundaryBox.GetRight() - fx;
CurrPosition.x += g_GridRoutingSize ) CurrPosition.x += g_GridRoutingSize )
{ {
wxYield(); wxYield();
if ( DrawPanel->m_AbortRequest ) if( DrawPanel->m_AbortRequest )
{ {
if ( IsOK(this, _("Ok to abort ?")) ) return ESC; if( IsOK( this, _( "Ok to abort ?" ) ) )
else DrawPanel->m_AbortRequest = FALSE; return ESC;
else
DrawPanel->m_AbortRequest = FALSE;
} }
cx = Module->m_Pos.x; cy = Module->m_Pos.y; cx = Module->m_Pos.x; cy = Module->m_Pos.y;
Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x; Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x;
Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y; Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y;
DrawModuleOutlines(DrawPanel, DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
g_Offset_Module.x = cx - CurrPosition.x; g_Offset_Module.x = cx - CurrPosition.x;
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.y -= CurrPosition.y % g_GridRoutingSize; CurrPosition.y -= CurrPosition.y % g_GridRoutingSize;
DrawModuleOutlines(DrawPanel, DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
for ( ; CurrPosition.y < m_Pcb->m_BoundaryBox.GetBottom() - fy; for( ; CurrPosition.y < m_Pcb->m_BoundaryBox.GetBottom() - fy;
CurrPosition.y += g_GridRoutingSize ) CurrPosition.y += g_GridRoutingSize )
{ {
/* effacement des traces */ /* effacement des traces */
DrawModuleOutlines(DrawPanel, DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
if (DisplayChevelu) Compute_Ratsnest_PlaceModule(DC); if( DisplayChevelu )
Compute_Ratsnest_PlaceModule( DC );
DisplayChevelu = 0; DisplayChevelu = 0;
Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x; Module->m_RealBoundaryBox.m_Pos.x = ox + CurrPosition.x;
Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y; Module->m_RealBoundaryBox.m_Pos.y = oy + CurrPosition.y;
g_Offset_Module.y = cy - CurrPosition.y; g_Offset_Module.y = cy - CurrPosition.y;
DrawModuleOutlines(DrawPanel, DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
Penalite = TstModuleOnBoard(m_Pcb, Module, TstOtherSide ); Penalite = TstModuleOnBoard( m_Pcb, Module, TstOtherSide );
if( Penalite >= 0 ) /* c a d si le module peut etre place */ if( Penalite >= 0 ) /* c a d si le module peut etre place */
{ {
error = 0; error = 0;
build_ratsnest_module(DC, Module); build_ratsnest_module( DC, Module );
cout = Compute_Ratsnest_PlaceModule(DC); cout = Compute_Ratsnest_PlaceModule( DC );
DisplayChevelu = 1; DisplayChevelu = 1;
Score = cout + (float) Penalite; Score = cout + (float) Penalite;
...@@ -651,19 +685,21 @@ bool TstOtherSide; ...@@ -651,19 +685,21 @@ bool TstOtherSide;
LastPosOK = CurrPosition; LastPosOK = CurrPosition;
mincout = Score; mincout = Score;
wxString msg; wxString msg;
msg.Printf( wxT("Score %d, pos %3.4f, %3.4f"), msg.Printf( wxT( "Score %d, pos %3.4f, %3.4f" ),
(int)mincout, (int) mincout,
(float)LastPosOK.x /10000, (float)LastPosOK.y /10000); (float) LastPosOK.x / 10000, (float) LastPosOK.y / 10000 );
Affiche_Message(msg); Affiche_Message( msg );
} }
} }
if( DisplayChevelu ) Compute_Ratsnest_PlaceModule(DC); if( DisplayChevelu )
Compute_Ratsnest_PlaceModule( DC );
DisplayChevelu = 0; DisplayChevelu = 0;
} }
} }
DrawModuleOutlines(DrawPanel, DC, Module); /* effacement du dernier trace */ DrawModuleOutlines( DrawPanel, DC, Module ); /* effacement du dernier trace */
if (DisplayChevelu) Compute_Ratsnest_PlaceModule(DC); if( DisplayChevelu )
Compute_Ratsnest_PlaceModule( DC );
/* Regeneration des variables modifiees */ /* Regeneration des variables modifiees */
Module->m_RealBoundaryBox.m_Pos.x = ox + cx; Module->m_RealBoundaryBox.m_Pos.x = ox + cx;
...@@ -673,24 +709,24 @@ bool TstOtherSide; ...@@ -673,24 +709,24 @@ bool TstOtherSide;
m_Pcb->m_Status_Pcb &= ~(CHEVELU_LOCAL_OK | LISTE_PAD_OK ); m_Pcb->m_Status_Pcb &= ~(CHEVELU_LOCAL_OK | LISTE_PAD_OK );
MinCout = mincout; MinCout = mincout;
return(error); 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;
...@@ -698,40 +734,48 @@ unsigned int data; ...@@ -698,40 +734,48 @@ unsigned int data;
/* 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 )
col_min = 0;
if( col_max >= (Ncols - 1) )
col_max = Ncols - 1;
for( row = row_min; row <= row_max; row++ )
{ {
for(col = col_min;col <= col_max; col++) for( col = col_min; col <= col_max; col++ )
{ {
data = GetCell(row,col,side); data = GetCell( row, col, side );
if( (data & CELL_is_ZONE) == 0 ) /* Cellule non autorisee */ if( (data & CELL_is_ZONE) == 0 ) /* Cellule non autorisee */
return(OUT_OF_BOARD); return OUT_OF_BOARD;
if( data & CELL_is_MODULE ) /* Deja utilisee */ if( data & CELL_is_MODULE ) /* Deja utilisee */
return(OCCUPED_By_MODULE); return OCCUPED_By_MODULE;
} }
} }
return( 0 );
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;
...@@ -739,38 +783,47 @@ unsigned int Penalite; ...@@ -739,38 +783,47 @@ unsigned int Penalite;
/* 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) )
row_max = Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= (Ncols - 1) )
col_max = Ncols - 1;
Penalite = 0; Penalite = 0;
for( row = row_min ;row <= row_max ; row++) for( row = row_min; row <= row_max; row++ )
{ {
for(col = col_min;col <= col_max; col++) for( col = col_min; col <= col_max; col++ )
{ {
Penalite += (int) GetDist(row, col, side ); Penalite += (int) GetDist( row, col, side );
} }
} }
return( Penalite );
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;
} }
...@@ -780,137 +833,145 @@ int error, Penalite, marge, side, otherside; ...@@ -780,137 +833,145 @@ int error, Penalite, marge, side, otherside;
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 ); error = TstRectangle( Pcb, ox, oy, fx, fy, otherside );
if( error < 0 ) return (error); if( error < 0 )
return error;
} }
marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN; marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN;
Penalite = CalculePenaliteRectangle(Pcb, ox - marge, oy - marge, Penalite = CalculePenaliteRectangle( Pcb, ox - marge, oy - marge,
fx + marge, fy + marge, side ); fx + marge, fy + marge, side );
return( Penalite ); 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
}
else
{ {
ox = pt_local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x; ox = pt_local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x;
oy = pt_local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y; oy = pt_local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y;
fx = pt_local_chevelu->pad_end->m_Pos.x; fx = pt_local_chevelu->pad_end->m_Pos.x;
fy = pt_local_chevelu->pad_end->m_Pos.y; fy = pt_local_chevelu->pad_end->m_Pos.y;
if ( AutoPlaceShowAll ) if( AutoPlaceShowAll )
{ {
GRLine(&DrawPanel->m_ClipBox, DC, ox, oy, fx, fy, GRLine( &DrawPanel->m_ClipBox, DC, ox, oy, fx, fy,
0, g_DesignSettings.m_RatsnestColor|GR_XOR) ; 0, g_DesignSettings.m_RatsnestColor | GR_XOR );
} }
/* Evaluation du cout du chevelu: */ /* Evaluation du cout du chevelu: */
dx = fx - ox; dy = fy - oy; dx = fx - ox; dy = fy - oy;
dx = abs(dx); dy = abs( dy ); dx = abs( dx ); dy = abs( dy );
if( dx < dy ) EXCHG(dx,dy); /* dx >= dy */ if( dx < dy )
EXCHG( dx, dy );/* dx >= dy */
/* cout de la distance: */ /* cout de la distance: */
icout = (float) dx * dx; icout = (float) dx * dx;
/* cout de l'inclinaison */ /* cout de l'inclinaison */
icout += 3 * (float) dy * dy; icout += 3 * (float) dy * dy;
icout = sqrt(icout); icout = sqrt( icout );
cout += icout; /* cout total = somme des couts de chaque chevelu */ 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; pt_liste_pad = Pcb->m_Pads = NULL;
Pcb->m_NbPads = Pcb->m_NbNodes = 0; Pcb->m_NbPads = Pcb->m_NbNodes = 0;
/* Calcul du nombre de pads utiles */ /* Calcul du nombre de pads utiles */
Module = Pcb->m_Modules; Module = Pcb->m_Modules;
for( ; Module != NULL ; Module = (MODULE*) Module->Pnext) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; if( Module->m_ModuleStatus & MODULE_to_PLACE )
continue;
PtPad = (D_PAD*) Module->m_Pads; PtPad = (D_PAD*) Module->m_Pads;
for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext )
{ {
Pcb->m_NbPads++; Pcb->m_NbPads++;
} }
} }
/* Allocation memoire du buffer */ /* Allocation memoire du buffer */
if ( Pcb->m_NbPads > 0) if( Pcb->m_NbPads > 0 )
{ {
pt_liste_pad = Pcb->m_Pads pt_liste_pad = Pcb->m_Pads
= (D_PAD**) MyMalloc(Pcb->m_NbPads * sizeof(D_PAD*) ); = (D_PAD**) MyMalloc( Pcb->m_NbPads * sizeof(D_PAD *) );
} }
/* Initialisation du buffer et des variables de travail */ /* Initialisation du buffer et des variables de travail */
Module = Pcb->m_Modules; Module = Pcb->m_Modules;
for( ;(Module != NULL) && (pt_liste_pad != NULL); Module = (MODULE*) Module->Pnext) for( ; (Module != NULL) && (pt_liste_pad != NULL); Module = (MODULE*) Module->Pnext )
{ {
if( Module->m_ModuleStatus & MODULE_to_PLACE ) continue; if( Module->m_ModuleStatus & MODULE_to_PLACE )
continue;
PtPad = (D_PAD*) Module->m_Pads; PtPad = (D_PAD*) Module->m_Pads;
for(; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext ) for( ; PtPad != NULL; PtPad = (D_PAD*) PtPad->Pnext )
{ {
*pt_liste_pad = PtPad; *pt_liste_pad = PtPad;
PtPad->m_physical_connexion = 0; PtPad->m_physical_connexion = 0;
PtPad->m_logical_connexion = 0; PtPad->m_logical_connexion = 0;
PtPad->m_Parent = Module; PtPad->m_Parent = Module;
if(PtPad->m_NetCode) Pcb->m_NbNodes++; if( PtPad->m_NetCode )
Pcb->m_NbNodes++;
pt_liste_pad++; pt_liste_pad++;
} }
} }
...@@ -926,27 +987,28 @@ D_PAD * PtPad; ...@@ -926,27 +987,28 @@ 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; 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;
...@@ -954,116 +1016,132 @@ int lgain, cgain; ...@@ -954,116 +1016,132 @@ int lgain, cgain;
ux0 -= marge; ux1 += marge; ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge; uy0 -= marge; uy1 += marge;
pmarge = marge / g_GridRoutingSize; if (pmarge < 1 ) pmarge = 1; pmarge = marge / g_GridRoutingSize; if( pmarge < 1 )
pmarge = 1;
/* 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 )
col_min = 0;
if( col_max >= (Ncols - 1) )
col_max = Ncols - 1;
for( row = row_min; row <= row_max; row++ )
{ {
lgain = 256; lgain = 256;
if ( row < pmarge ) if( row < pmarge )
lgain = (256 * row) / pmarge; lgain = (256 * row) / pmarge;
else if( row > row_max - pmarge ) else if( row > row_max - pmarge )
lgain = (256 * (row_max - row) ) / pmarge; lgain = ( 256 * (row_max - row) ) / pmarge;
for(col = col_min;col <= col_max; col++) for( col = col_min; col <= col_max; col++ )
{ {
cgain = 256; cgain = 256;
LocalPenalite = Penalite; LocalPenalite = Penalite;
if ( col < pmarge ) if( col < pmarge )
cgain = (256 * col) / pmarge; cgain = (256 * col) / pmarge;
else if( col > col_max - pmarge ) else if( col > col_max - pmarge )
cgain = (256 * (col_max - col) ) / pmarge; cgain = ( 256 * (col_max - col) ) / pmarge;
cgain = (cgain * lgain) / 256; cgain = (cgain * lgain) / 256;
if( cgain != 256 ) LocalPenalite = (LocalPenalite * cgain) / 256; if( cgain != 256 )
if(trace & 1) LocalPenalite = (LocalPenalite * cgain) / 256;
if( trace & 1 )
{ {
data = GetDist(row,col,BOTTOM) + LocalPenalite; data = GetDist( row, col, BOTTOM ) + LocalPenalite;
SetDist(row,col,BOTTOM, data); SetDist( row, col, BOTTOM, data );
} }
if(trace & 2) if( trace & 2 )
{ {
data = GetDist(row,col,TOP); data = GetDist( row, col, TOP );
data = max( data, LocalPenalite); data = max( data, LocalPenalite );
SetDist(row,col,TOP, data); 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 /* Tri par surface decroissante des modules
(on place les plus gros en 1er), surface ponderee par le nombre de pads */ * (on place les plus gros en 1er), surface ponderee par le nombre de pads */
qsort(BaseListeModules, NbModules, sizeof(MODULE**), qsort( BaseListeModules, NbModules, sizeof(MODULE * *),
(int(*)(const void *, const void * ))Tri_PlaceModules); ( 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; (*pt_Dmod)->flag = 0;
if( ! ((*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE) ) continue; if( !( (*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE ) )
continue;
pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
adr_lowmem = buf_work; adr_lowmem = buf_work;
(*pt_Dmod)->Display_Infos(pcbframe); (*pt_Dmod)->Display_Infos( pcbframe );
pcbframe->build_ratsnest_module(DC, *pt_Dmod); pcbframe->build_ratsnest_module( DC, *pt_Dmod );
/* calcul du nombre de chevelus externes */ /* calcul du nombre de chevelus externes */
pt_local_chevelu = local_liste_chevelu; pt_local_chevelu = local_liste_chevelu;
...@@ -1075,84 +1153,89 @@ int NbModules, ii; ...@@ -1075,84 +1153,89 @@ int NbModules, ii;
pt_local_chevelu++; pt_local_chevelu++;
} }
} }
pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; pcbframe->m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
qsort(BaseListeModules, NbModules, sizeof(MODULE**), qsort( BaseListeModules, NbModules, sizeof(MODULE * *),
(int(*)(const void *, const void * ))Tri_RatsModules); ( int (*)( const void*, const void* ) )Tri_RatsModules );
/* Recherche du "meilleur" module */ /* Recherche du "meilleur" module */
Module = NULL; Module = NULL;
for(pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++) for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
{ {
if( ! ((*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE) ) continue; if( !( (*pt_Dmod)->m_ModuleStatus & MODULE_to_PLACE ) )
continue;
AltModule = *pt_Dmod; AltModule = *pt_Dmod;
if( (*pt_Dmod)->flag == 0 ) continue; if( (*pt_Dmod)->flag == 0 )
continue;
Module = *pt_Dmod; break; Module = *pt_Dmod; break;
} }
MyFree(BaseListeModules); MyFree( BaseListeModules );
if ( Module ) return(Module); if( Module )
else return(AltModule); 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 ; m_Pcb->m_BoundaryBox.m_Pos.x = m_Pcb->m_BoundaryBox.m_Pos.y = 0x7FFFFFFFl;
xmax = ymax = -0x7FFFFFFFl ; xmax = ymax = -0x7FFFFFFFl;
/* Analyse des Contours PCB */ /* Analyse des Contours PCB */
PtStruct = m_Pcb->m_Drawings; PtStruct = m_Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; if( PtStruct->m_StructType != TYPEDRAWSEGMENT )
continue;
succes = TRUE; succes = TRUE;
ptr = (DRAWSEGMENT*) PtStruct; ptr = (DRAWSEGMENT*) PtStruct;
d = (ptr->m_Width /2) + 1; d = (ptr->m_Width / 2) + 1;
if(ptr->m_Shape == S_CIRCLE) if( ptr->m_Shape == S_CIRCLE )
{ {
cx = ptr->m_Start.x; cy = ptr->m_Start.y; cx = ptr->m_Start.x; cy = ptr->m_Start.y;
rayon = (int)hypot((double)(ptr->m_End.x-cx),(double)(ptr->m_End.y-cy) ); rayon = (int) hypot( (double) (ptr->m_End.x - cx), (double) (ptr->m_End.y - cy) );
rayon += d; rayon += d;
m_Pcb->m_BoundaryBox.m_Pos.x = min(m_Pcb->m_BoundaryBox.m_Pos.x,cx-rayon); m_Pcb->m_BoundaryBox.m_Pos.x = min( m_Pcb->m_BoundaryBox.m_Pos.x, cx - rayon );
m_Pcb->m_BoundaryBox.m_Pos.y = min(m_Pcb->m_BoundaryBox.m_Pos.y,cy-rayon); m_Pcb->m_BoundaryBox.m_Pos.y = min( m_Pcb->m_BoundaryBox.m_Pos.y, cy - rayon );
xmax = max(xmax,cx+rayon); xmax = max( xmax, cx + rayon );
ymax = max(ymax,cy+rayon); ymax = max( ymax, cy + rayon );
} }
else else
{ {
cx = min(ptr->m_Start.x, ptr->m_End.x ); cx = min( ptr->m_Start.x, ptr->m_End.x );
cy = min(ptr->m_Start.y, ptr->m_End.y); 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); m_Pcb->m_BoundaryBox.m_Pos.x = min( m_Pcb->m_BoundaryBox.m_Pos.x, cx - d );
m_Pcb->m_BoundaryBox.m_Pos.y = min(m_Pcb->m_BoundaryBox.m_Pos.y,cy - d); m_Pcb->m_BoundaryBox.m_Pos.y = min( m_Pcb->m_BoundaryBox.m_Pos.y, cy - d );
cx = max(ptr->m_Start.x, ptr->m_End.x ); cx = max( ptr->m_Start.x, ptr->m_End.x );
cy = max(ptr->m_Start.y, ptr->m_End.y); cy = max( ptr->m_Start.y, ptr->m_End.y );
xmax = max(xmax,cx + d); xmax = max( xmax, cx + d );
ymax = max(ymax,cy + d); ymax = max( ymax, cy + d );
} }
} }
m_Pcb->m_BoundaryBox.SetWidth(xmax - m_Pcb->m_BoundaryBox.m_Pos.x); 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); m_Pcb->m_BoundaryBox.SetHeight( ymax - m_Pcb->m_BoundaryBox.m_Pos.y );
return(succes); 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 ) )
{
if( layer_mask & pad->m_Masque_Layer )
{ {
found = testItem; found = testItem;
return SEARCH_QUIT; 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;
......
...@@ -31,7 +31,9 @@ D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD ) ...@@ -31,7 +31,9 @@ D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD )
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"
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
#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 */
...@@ -39,63 +39,71 @@ static bool s_ConnectToPads = false; ...@@ -39,63 +39,71 @@ 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 )
continue;
/* Search and delete others vias at same location */ /* Search and delete others vias at same location */
TRACK * alt_track = track->Next(); TRACK* alt_track = track->Next();
for( ; alt_track != NULL; alt_track = next_track ) for( ; alt_track != NULL; alt_track = next_track )
{ {
next_track = alt_track->Next(); next_track = alt_track->Next();
if( alt_track->m_Shape != VIA_NORMALE ) continue; if( alt_track->m_Shape != VIA_NORMALE )
if ( alt_track->m_Start != track->m_Start ) continue; continue;
if( alt_track->m_Start != track->m_Start )
continue;
/* delete via */ /* delete via */
alt_track->UnLink(); alt_track->UnLink();
delete alt_track; delete alt_track;
} }
} }
/* Delete Via on pads at same location */ /* Delete Via on pads at same location */
for( track = frame->m_Pcb->m_Track; track != NULL; track = next_track) for( track = frame->m_Pcb->m_Track; track != NULL; track = next_track )
{ {
next_track = track->Next(); next_track = track->Next();
if( track->m_Shape != VIA_NORMALE ) continue; if( track->m_Shape != VIA_NORMALE )
D_PAD * pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, track->m_Start, ALL_CU_LAYERS); continue;
if (pad && (pad->m_Masque_Layer&EXTERNAL_LAYERS) == EXTERNAL_LAYERS) // redundant Via
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 */ /* delete via */
track->UnLink(); track->UnLink();
...@@ -108,65 +116,69 @@ void Clean_Pcb_Items(WinEDA_PcbFrame * frame, wxDC * DC ) ...@@ -108,65 +116,69 @@ void Clean_Pcb_Items(WinEDA_PcbFrame * frame, wxDC * DC )
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.x = PtSegm->m_Start.x;
PtSegm->m_End.y = PtSegm->m_Start.y; PtSegm->m_End.y = PtSegm->m_Start.y;
ii++; ii++;
msg.Printf( wxT("%d "), ii); msg.Printf( wxT( "%d " ), ii );
Affiche_1_Parametre(frame, POS_AFF_PASSE,_("ViaDef"),msg,LIGHTRED); Affiche_1_Parametre( frame, POS_AFF_PASSE, _( "ViaDef" ), msg, LIGHTRED );
} }
continue; continue;
} }
...@@ -176,25 +188,26 @@ wxString msg; ...@@ -176,25 +188,26 @@ wxString msg;
PtSegm = frame->m_Pcb->m_Track; ii = 0; PtSegm = frame->m_Pcb->m_Track; ii = 0;
percent = 0; oldpercent = -1; percent = 0; oldpercent = -1;
oldnetcode = 0; PtStartNetCode = frame->m_Pcb->m_Track; oldnetcode = 0; PtStartNetCode = frame->m_Pcb->m_Track;
for( ; PtSegm != NULL; PtSegm = (TRACK*) NextS, ii++) for( ; PtSegm != NULL; PtSegm = (TRACK*) NextS, ii++ )
{ {
NextS = PtSegm->Pnext; NextS = PtSegm->Pnext;
/* Affiche activite */ /* Affiche activite */
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack;
if( percent != oldpercent) if( percent != oldpercent )
{ {
oldpercent = percent; oldpercent = percent;
frame->DisplayActivity(percent, wxT("No Conn: ") ); frame->DisplayActivity( percent, wxT( "No Conn: " ) );
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_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT("%d "),ii ); msg.Printf( wxT( "%d " ), ii );
Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
} }
if( frame->DrawPanel->m_AbortRequest ) break; if( frame->DrawPanel->m_AbortRequest )
break;
if( PtSegm->m_NetCode != oldnetcode) if( PtSegm->m_NetCode != oldnetcode )
{ {
PtStartNetCode = PtSegm; oldnetcode = PtSegm->m_NetCode; PtStartNetCode = PtSegm; oldnetcode = PtSegm->m_NetCode;
} }
...@@ -204,102 +217,107 @@ wxString msg; ...@@ -204,102 +217,107 @@ wxString msg;
masklayer = PtSegm->ReturnMaskLayer(); masklayer = PtSegm->ReturnMaskLayer();
ptr_pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, PtSegm->m_Start, masklayer); ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, PtSegm->m_Start, masklayer );
if( ptr_pad != NULL) if( ptr_pad != NULL )
{ {
PtSegm->start = ptr_pad; PtSegm->start = ptr_pad;
type_end |= START_SUR_PAD; type_end |= START_SUR_PAD;
} }
ptr_pad = Fast_Locate_Pad_Connecte(frame->m_Pcb, PtSegm->m_End, masklayer); ptr_pad = Fast_Locate_Pad_Connecte( frame->m_Pcb, PtSegm->m_End, masklayer );
if( ptr_pad != NULL) if( ptr_pad != NULL )
{ {
PtSegm->end = ptr_pad; PtSegm->end = ptr_pad;
type_end |= END_SUR_PAD; type_end |= END_SUR_PAD;
} }
/* Test si une extremite est connectee sur une piste */ /* Test si une extremite est connectee sur une piste */
if ( (type_end & START_SUR_PAD ) == 0 ) if( (type_end & START_SUR_PAD ) == 0 )
{ {
pt_other = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL, START); NULL, START );
if(pt_other == NULL) flag_erase |= 1; if( pt_other == NULL )
flag_erase |= 1;
else /* Segment ou via connectee a cette extremite */ else /* Segment ou via connectee a cette extremite */
{ {
PtSegm->start = pt_other; PtSegm->start = pt_other;
if(pt_other->m_StructType == TYPEVIA) /* recherche d'un autre segment */ if( pt_other->m_StructType == TYPEVIA ) /* recherche d'un autre segment */
{ {
PtSegm->SetState(BUSY,ON); PtSegm->SetState( BUSY, ON );
pt_via = pt_other; pt_via = pt_other;
pt_other = Locate_Piste_Connectee(pt_via,frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track,
NULL,START); NULL, START );
if(pt_other == NULL) flag_erase |= 2; if( pt_other == NULL )
PtSegm->SetState(BUSY,OFF); flag_erase |= 2;
PtSegm->SetState( BUSY, OFF );
} }
} }
} }
if ( (type_end & END_SUR_PAD ) == 0 ) if( (type_end & END_SUR_PAD ) == 0 )
{ {
pt_other = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL, END); NULL, END );
if(pt_other == NULL) flag_erase |= 0x10; if( pt_other == NULL )
flag_erase |= 0x10;
else /* Segment ou via connectee a cette extremite */ else /* Segment ou via connectee a cette extremite */
{ {
PtSegm->end = pt_other; PtSegm->end = pt_other;
if(pt_other->m_StructType == TYPEVIA) /* recherche d'un autre segment */ if( pt_other->m_StructType == TYPEVIA ) /* recherche d'un autre segment */
{ {
PtSegm->SetState(BUSY,ON); PtSegm->SetState( BUSY, ON );
pt_via = pt_other; pt_via = pt_other;
pt_other = Locate_Piste_Connectee(pt_via,frame->m_Pcb->m_Track, pt_other = Locate_Piste_Connectee( pt_via, frame->m_Pcb->m_Track,
NULL, END); NULL, END );
if(pt_other == NULL) flag_erase |= 0x20; if( pt_other == NULL )
PtSegm->SetState(BUSY,OFF); flag_erase |= 0x20;
PtSegm->SetState( BUSY, OFF );
} }
} }
} }
if(flag_erase) if( flag_erase )
{ {
oldpercent = -1; /* force affichage activite */ oldpercent = -1; /* force affichage activite */
nbpoints_supprimes++; ii--; nbpoints_supprimes++; ii--;
msg.Printf( wxT("%d "),nbpoints_supprimes); msg.Printf( wxT( "%d " ), nbpoints_supprimes );
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("NoConn."), msg,LIGHTRED); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "NoConn." ), msg, LIGHTRED );
/* rectification du pointeur PtSegm pour repartir en debut /* rectification du pointeur PtSegm pour repartir en debut
du block des segments de meme net_code */ * du block des segments de meme net_code */
if( PtSegm == PtStartNetCode ) if( PtSegm == PtStartNetCode )
{ {
NextS = PtSegm->Pnext; NextS = PtSegm->Pnext;
PtStartNetCode = (TRACK*)NextS; PtStartNetCode = (TRACK*) NextS;
} }
else NextS = PtStartNetCode; else
NextS = PtStartNetCode;
/* Suppression du segment */ /* Suppression du segment */
PtSegm->Draw(frame->DrawPanel, DC, GR_XOR); PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
DeleteStructure(PtSegm); DeleteStructure( PtSegm );
if ( NextS == NULL ) break; 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;
...@@ -311,57 +329,63 @@ wxString msg; ...@@ -311,57 +329,63 @@ wxString msg;
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 */ /* Lenght segment = 0; delete it */
PtSegm->Draw(frame->DrawPanel, DC, GR_XOR); PtSegm->Draw( frame->DrawPanel, DC, GR_XOR );
DeleteStructure(PtSegm); DeleteStructure( PtSegm );
nbpoints_supprimes++; nbpoints_supprimes++;
msg.Printf( wxT(" %d"),nbpoints_supprimes); msg.Printf( wxT( " %d" ), nbpoints_supprimes );
Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString, msg,a_color); 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); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "Ident" ), wxT( "0" ), a_color );
percent = 0; oldpercent = -1; percent = 0; oldpercent = -1;
PtSegm = frame->m_Pcb->m_Track; PtSegm = frame->m_Pcb->m_Track;
for( ii = 0; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext , ii++) for( ii = 0; PtSegm != NULL; PtSegm = (TRACK*) PtSegm->Pnext, ii++ )
{ {
/* affichage activite */ /* affichage activite */
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, wxT("Id segm: ") ); frame->DisplayActivity( percent, wxT( "Id segm: " ) );
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, wxT("Max"), msg,GREEN); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT("%d"), ii ); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); 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 ) for( pt_aux = (TRACK*) PtSegm->Pnext; pt_aux != NULL; pt_aux = (TRACK*) NextS )
{ {
int erase = 0; int erase = 0;
NextS = pt_aux->Pnext; NextS = pt_aux->Pnext;
if( PtSegm->m_StructType != pt_aux->m_StructType ) continue; if( PtSegm->m_StructType != pt_aux->m_StructType )
if( PtSegm->m_Layer != pt_aux->m_Layer ) continue; continue;
if( PtSegm->m_NetCode != pt_aux->m_NetCode ) break; if( PtSegm->m_Layer != pt_aux->m_Layer )
continue;
if( PtSegm->m_NetCode != pt_aux->m_NetCode )
break;
if( (PtSegm->m_Start.x == pt_aux->m_Start.x ) && (PtSegm->m_Start.y == pt_aux->m_Start.y) ) if( (PtSegm->m_Start.x == pt_aux->m_Start.x )
&& (PtSegm->m_Start.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) ) if( (PtSegm->m_End.x == pt_aux->m_End.x ) && (PtSegm->m_End.y==pt_aux->m_End.y) )
erase = 1; erase = 1;
...@@ -377,12 +401,12 @@ wxString msg; ...@@ -377,12 +401,12 @@ wxString msg;
if( erase ) if( erase )
{ {
ii--; ii--;
pt_aux->Draw(frame->DrawPanel, DC, GR_OR); pt_aux->Draw( frame->DrawPanel, DC, GR_OR );
DeleteStructure(pt_aux); DeleteStructure( pt_aux );
nbpoints_supprimes++; nbpoints_supprimes++;
msg.Printf( wxT(" %d"),nbpoints_supprimes); msg.Printf( wxT( " %d" ), nbpoints_supprimes );
Affiche_1_Parametre(frame,50, wxEmptyString, msg,a_color); Affiche_1_Parametre( frame, 50, wxEmptyString, msg, a_color );
} }
} }
} }
...@@ -393,486 +417,534 @@ wxString msg; ...@@ -393,486 +417,534 @@ wxString msg;
PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0; PtSegm = frame->m_Pcb->m_Track; nbpoints_supprimes = 0;
percent = 0; oldpercent = -1; percent = 0; oldpercent = -1;
frame->Affiche_Message( _("Merging Segments:") ); frame->Affiche_Message( _( "Merging Segments:" ) );
Affiche_1_Parametre(frame,POS_AFF_VAR, _("Merge"), _("0"),a_color); Affiche_1_Parametre( frame, POS_AFF_VAR, _( "Merge" ), _( "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 )
{ {
TRACK * pt_segm_s, * pt_segm_e, *pt_segm_delete; TRACK* pt_segm_s, * pt_segm_e, * pt_segm_delete;
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, _("Merge: ") ); frame->DisplayActivity( percent, _( "Merge: " ) );
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, wxT("Max"), msg,GREEN); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT("%d"), ii ); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(frame, POS_AFF_NUMSEGM, wxT("Segm"), msg,CYAN); 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;
} }
if(PtSegm->m_StructType != TYPETRACK) continue; if( PtSegm->m_StructType != TYPETRACK )
continue;
flag = no_inc = 0; flag = no_inc = 0;
/* Recherche d'un point possible raccorde sur DEBUT de segment: */ /* Recherche d'un point possible raccorde sur DEBUT de segment: */
for( pt_segm_s = (TRACK*)PtSegm->Pnext; ; ) for( pt_segm_s = (TRACK*) PtSegm->Pnext; ; )
{ {
pt_segm_s = Locate_Piste_Connectee(PtSegm, pt_segm_s, pt_segm_s = Locate_Piste_Connectee( PtSegm, pt_segm_s,
NULL, START); NULL, START );
if(pt_segm_s) if( pt_segm_s )
{ {
/* les 2 segments doivent avoir meme largeur */ /* les 2 segments doivent avoir meme largeur */
if(PtSegm->m_Width != pt_segm_s->m_Width ) break; if( PtSegm->m_Width != pt_segm_s->m_Width )
break;
/* Ce ne peut etre une via */ /* Ce ne peut etre une via */
if(pt_segm_s->m_StructType != TYPETRACK) break; if( pt_segm_s->m_StructType != TYPETRACK )
break;
/* On ne peut avoir que 1 seul segment connecte */ /* On ne peut avoir que 1 seul segment connecte */
pt_segm_s->SetState(BUSY,ON); pt_segm_s->SetState( BUSY, ON );
pt_aux = Locate_Piste_Connectee(PtSegm, frame->m_Pcb->m_Track, pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL,START); NULL, START );
pt_segm_s->SetState(BUSY,OFF); pt_segm_s->SetState( BUSY, OFF );
if(pt_aux == NULL) flag = 1; /* OK */ if( pt_aux == NULL )
flag = 1;/* OK */
break; break;
} }
break; break;
} }
if(flag) /* debut de segment raccorde a un autre segment */ if( flag ) /* debut de segment raccorde a un autre segment */
{ {
pt_segm_delete = AlignSegment(frame->m_Pcb, PtSegm,pt_segm_s,START); pt_segm_delete = AlignSegment( frame->m_Pcb, PtSegm, pt_segm_s, START );
if ( pt_segm_delete ) if( pt_segm_delete )
{ {
nbpoints_supprimes++; no_inc = 1; nbpoints_supprimes++; no_inc = 1;
DeleteStructure(pt_segm_delete); DeleteStructure( pt_segm_delete );
} }
} }
/* Recherche d'un point possible raccorde sur FIN de segment: */ /* Recherche d'un point possible raccorde sur FIN de segment: */
for( pt_segm_e = (TRACK*)PtSegm->Pnext; ; ) for( pt_segm_e = (TRACK*) PtSegm->Pnext; ; )
{ {
pt_segm_e = Locate_Piste_Connectee(PtSegm, pt_segm_e, pt_segm_e = Locate_Piste_Connectee( PtSegm, pt_segm_e,
NULL, END); NULL, END );
if(pt_segm_e) if( pt_segm_e )
{ {
/* les 2 segments doivent avoir meme largeur */ /* les 2 segments doivent avoir meme largeur */
if(PtSegm->m_Width != pt_segm_e->m_Width ) break; if( PtSegm->m_Width != pt_segm_e->m_Width )
break;
/* Ce ne peut etre une via */ /* Ce ne peut etre une via */
if(pt_segm_e->m_StructType != TYPETRACK) break; if( pt_segm_e->m_StructType != TYPETRACK )
break;
/* On ne peut avoir que 1 seul segment connecte */ /* On ne peut avoir que 1 seul segment connecte */
pt_segm_e->SetState(BUSY,ON); pt_segm_e->SetState( BUSY, ON );
pt_aux = Locate_Piste_Connectee(PtSegm, frame->m_Pcb->m_Track, pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL,END) ; NULL, END );
pt_segm_e->SetState(BUSY,OFF); pt_segm_e->SetState( BUSY, OFF );
if (pt_aux == NULL) flag |= 2;/* Ok */ if( pt_aux == NULL )
flag |= 2;/* Ok */
break; break;
} }
else break; else
break;
} }
if(flag & 2) /* FIN de segment raccorde a un autre segment */ if( flag & 2 ) /* FIN de segment raccorde a un autre segment */
{ {
pt_segm_delete = AlignSegment(frame->m_Pcb, PtSegm,pt_segm_e,END); pt_segm_delete = AlignSegment( frame->m_Pcb, PtSegm, pt_segm_e, END );
if ( pt_segm_delete ) if( pt_segm_delete )
{ {
nbpoints_supprimes++; no_inc = 1; nbpoints_supprimes++; no_inc = 1;
DeleteStructure(pt_segm_delete); DeleteStructure( pt_segm_delete );
} }
} }
if(no_inc) /* Le segment en cours a ete modifie, il faut le reexaminer */ if( no_inc ) /* Le segment en cours a ete modifie, il faut le reexaminer */
{ {
msg.Printf( wxT("%d "),nbpoints_supprimes); msg.Printf( wxT( "%d " ), nbpoints_supprimes );
Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString, msg,a_color); Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
NextS = PtSegm->Pnext; NextS = PtSegm->Pnext;
} }
} }
return (0) ;
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
flag = 1;
} }
/* Tst alignement horizontal possible: */ /* Tst alignement horizontal possible: */
if(refdy == 0) if( refdy == 0 )
{ {
if (segmdy != 0) return(NULL); if( segmdy != 0 )
else flag = 2; return NULL;
else
flag = 2;
} }
/* tst si il y a alignement d'angle qcq /* tst si il y a alignement d'angle qcq
il faut que refdy/refdx == (+/-)segmdy/segmdx, c.a.d meme direction */ * il faut que refdy/refdx == (+/-)segmdy/segmdx, c.a.d meme direction */
if (flag == 0) if( flag == 0 )
{ {
if( (refdy * segmdx != refdx * segmdy) && if( (refdy * segmdx != refdx * segmdy)
(refdy * segmdx != -refdx * segmdy) ) return(NULL); && (refdy * segmdx != -refdx * segmdy) )
return NULL;
flag = 4; flag = 4;
} }
/* Ici il y a alignement: il faut determiner les positions relatives /* Ici il y a alignement: il faut determiner les positions relatives
pour supprimer le point commun et le remplacer */ * pour supprimer le point commun et le remplacer */
if (extremite == START) if( extremite == START )
{ {
/* Ce ne doit pas etre sur un pad */ /* Ce ne doit pas etre sur un pad */
if(Fast_Locate_Pad_Connecte(Pcb, pt_ref->m_Start, if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_Start,
g_TabOneLayerMask[pt_ref->m_Layer])) g_TabOneLayerMask[pt_ref->m_Layer] ) )
return(NULL); return NULL;
if( (pt_ref->m_Start.x == pt_segm->m_Start.x) && (pt_ref->m_Start.y == pt_segm->m_Start.y) ) 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_End.x; pt_ref->m_Start.y = pt_segm->m_End.y; pt_ref->m_Start.x = pt_segm->m_End.x; pt_ref->m_Start.y = pt_segm->m_End.y;
return(pt_segm); return pt_segm;
} }
else /* connexion par la fin de pt_segm */ else /* connexion par la fin de pt_segm */
{ {
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); return pt_segm;
} }
} }
else /* extremite == END */ else /* extremite == END */
{ {
/* Ce ne doit pas etre sur un pad */ /* Ce ne doit pas etre sur un pad */
if(Fast_Locate_Pad_Connecte(Pcb, pt_ref->m_End, g_TabOneLayerMask[pt_ref->m_Layer])) if( Fast_Locate_Pad_Connecte( Pcb, pt_ref->m_End, g_TabOneLayerMask[pt_ref->m_Layer] ) )
return(NULL); return NULL;
if( pt_ref->m_End == pt_segm->m_Start ) if( pt_ref->m_End == pt_segm->m_Start )
{ {
pt_ref->m_End = pt_segm->m_End; pt_ref->m_End = pt_segm->m_End;
return(pt_segm); return pt_segm;
} }
else /* connexion par la fin de pt_segm */ else /* connexion par la fin de pt_segm */
{ {
pt_ref->m_End = pt_segm->m_Start; pt_ref->m_End = pt_segm->m_Start;
return(pt_segm); return pt_segm;
} }
} }
return(NULL); 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; ii = 0;
for(PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*)PtSegm->Pnext) for( PtSegm = frame->m_Pcb->m_Track; PtSegm != NULL; PtSegm = (TRACK*) 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, wxT("Drc: ") ); frame->DisplayActivity( percent, wxT( "Drc: " ) );
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, wxT("Max"),msg,GREEN); 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_NUMSEGM, wxT("Segm"),msg,CYAN); 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); PtSegm->SetState( FLAG0, OFF );
/* Calcul du net_code des elements raccordes sur le point de debut */ /* Calcul du net_code des elements raccordes sur le point de debut */
net_code_s = -1; net_code_s = -1;
if( (PtSegm->start != NULL) && if( (PtSegm->start != NULL)
( ((EDA_BaseStruct*)(PtSegm->start))->m_StructType == TYPEPAD) ) && ( ( (EDA_BaseStruct*) (PtSegm->start) )->m_StructType == TYPEPAD ) )
net_code_s = ((D_PAD*)(PtSegm->start))->m_NetCode; net_code_s = ( (D_PAD*) (PtSegm->start) )->m_NetCode;
else else
{ {
pt_aux = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL, START); NULL, START );
if(pt_aux) net_code_s = pt_aux->m_NetCode; if( pt_aux )
net_code_s = pt_aux->m_NetCode;
} }
if(net_code_s < 0 ) continue ; /* Extremite en l'air */ if( net_code_s < 0 )
continue;/* Extremite en l'air */
/* Calcul du net_code des elements raccordes sur le point de fin */ /* Calcul du net_code des elements raccordes sur le point de fin */
net_code_e = -1; net_code_e = -1;
if( (PtSegm->end != NULL) && if( (PtSegm->end != NULL)
( ((EDA_BaseStruct*)(PtSegm->end))->m_StructType == TYPEPAD) ) && ( ( (EDA_BaseStruct*) (PtSegm->end) )->m_StructType == TYPEPAD ) )
net_code_e = ((D_PAD*)(PtSegm->end))->m_NetCode; net_code_e = ( (D_PAD*) (PtSegm->end) )->m_NetCode;
else else
{ {
pt_aux = Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, pt_aux = Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL,END); NULL, END );
if(pt_aux) net_code_e = pt_aux->m_NetCode; if( pt_aux )
net_code_e = pt_aux->m_NetCode;
} }
if(net_code_e < 0 ) continue ; /* Extremite en l'air */ if( net_code_e < 0 )
continue;/* Extremite en l'air */
/* Marquage des segments a supprimer */ /* Marquage des segments a supprimer */
if(net_code_s != net_code_e) if( net_code_s != net_code_e )
{ {
PtSegm->SetState(FLAG0,ON); PtSegm->SetState( FLAG0, ON );
} }
} }
/* Suppression effective des segments */ /* Suppression effective des segments */
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->GetState(FLAG0) ) /* Connexion erronee : a supprimer */ if( PtSegm->GetState( FLAG0 ) ) /* Connexion erronee : a supprimer */
{ {
PtSegm->SetState(FLAG0,OFF); PtSegm->SetState( FLAG0, OFF );
flag = 1; oldpercent = -1; flag = 1; oldpercent = -1;
frame->m_Pcb->m_Status_Pcb = 0; frame->m_Pcb->m_Status_Pcb = 0;
frame->Supprime_Une_Piste( DC, PtSegm); frame->Supprime_Une_Piste( DC, PtSegm );
NextS = frame->m_Pcb->m_Track; /* NextS a peut etre ete efface */ NextS = frame->m_Pcb->m_Track; /* NextS a peut etre ete efface */
if(affiche) if( affiche )
{ {
nbpoints_modifies++; nbpoints_modifies++;
msg.Printf( wxT("%d "),nbpoints_modifies); msg.Printf( wxT( "%d " ), nbpoints_modifies );
Affiche_1_Parametre(frame,POS_AFF_VAR,wxEmptyString,msg,a_color); Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
} }
} }
} }
return(flag);
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; oldpercent = -1; 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, wxT("Tracks: ") ); frame->DisplayActivity( percent, wxT( "Tracks: " ) );
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, wxT("Max"),msg,GREEN); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT("%d"), ii); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(frame,POS_AFF_NUMSEGM, wxT("Segm"),msg,CYAN); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
} }
if( frame->DrawPanel->m_AbortRequest ) return; if( frame->DrawPanel->m_AbortRequest )
return;
masquelayer = PtSegm->ReturnMaskLayer(); masquelayer = PtSegm->ReturnMaskLayer();
/* examen du point de depart du segment de reference */ /* examen du point de depart du segment de reference */
for(pt_aux = frame->m_Pcb->m_Track; ; pt_aux = (TRACK*) pt_aux->Pnext) for( pt_aux = frame->m_Pcb->m_Track; ; pt_aux = (TRACK*) pt_aux->Pnext )
{ {
if (pt_aux == NULL) break; if( pt_aux == NULL )
pt_aux = Locate_Pistes(pt_aux, PtSegm->m_Start, masquelayer); break;
if (pt_aux == NULL) break; pt_aux = Locate_Pistes( pt_aux, PtSegm->m_Start, masquelayer );
if(pt_aux == PtSegm) continue; if( pt_aux == NULL )
if(pt_aux->m_StructType == TYPEVIA) continue; break;
if( PtSegm->m_Start == pt_aux->m_Start ) continue; if( pt_aux == PtSegm )
if( PtSegm->m_Start == pt_aux->m_End ) continue; continue;
if( pt_aux->m_StructType == TYPEVIA )
continue;
if( PtSegm->m_Start == pt_aux->m_Start )
continue;
if( PtSegm->m_Start == pt_aux->m_End )
continue;
// Test si autre extremite du segment ne serait pas deja connectee // Test si autre extremite du segment ne serait pas deja connectee
if( PtSegm->m_End == pt_aux->m_Start ) continue; if( PtSegm->m_End == pt_aux->m_Start )
if( PtSegm->m_End == pt_aux->m_End ) continue; continue;
if( PtSegm->m_End == pt_aux->m_End )
continue;
pt_aux->Draw(frame->DrawPanel, DC, GR_XOR); pt_aux->Draw( frame->DrawPanel, DC, GR_XOR );
NewTrack = pt_aux->Copy(); NewTrack = pt_aux->Copy();
NewTrack->Insert(frame->m_Pcb, pt_aux); NewTrack->Insert( frame->m_Pcb, pt_aux );
nn++; nn++;
frame->m_Pcb->m_NbSegmTrack++; frame->m_Pcb->m_NbSegmTrack++;
msg.Printf( wxT("%d"),nn); msg.Printf( wxT( "%d" ), nn );
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("New <"),msg,YELLOW); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New <" ), msg, YELLOW );
pt_aux->m_End = PtSegm->m_Start; pt_aux->m_End = PtSegm->m_Start;
NewTrack->m_Start = PtSegm->m_Start; NewTrack->m_Start = PtSegm->m_Start;
Trace_Une_Piste(frame->DrawPanel, DC, pt_aux, 2, GR_OR); Trace_Une_Piste( frame->DrawPanel, DC, pt_aux, 2, GR_OR );
pt_aux = NewTrack; pt_aux = NewTrack;
} }
/* examen du point de fin du segment de reference */ /* examen du point de fin du segment de reference */
for(pt_aux = frame->m_Pcb->m_Track; pt_aux != NULL; pt_aux = (TRACK*) pt_aux->Pnext) for( pt_aux = frame->m_Pcb->m_Track; pt_aux != NULL; pt_aux = (TRACK*) pt_aux->Pnext )
{ {
pt_aux = Locate_Pistes(pt_aux, PtSegm->m_End, masquelayer); pt_aux = Locate_Pistes( pt_aux, PtSegm->m_End, masquelayer );
if(pt_aux == NULL) break; if( pt_aux == NULL )
if(pt_aux == PtSegm) continue; break;
if(pt_aux->m_StructType == TYPEVIA) continue; if( pt_aux == PtSegm )
continue;
if( pt_aux->m_StructType == TYPEVIA )
continue;
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_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)) continue; continue;
if( (PtSegm->m_End.x == pt_aux->m_End.x) && (PtSegm->m_End.y == pt_aux->m_End.y) )
continue;
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_Start.x)
if( (PtSegm->m_Start.x == pt_aux->m_End.x) && (PtSegm->m_Start.y == pt_aux->m_End.y)) continue; && (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); pt_aux->Draw( frame->DrawPanel, DC, GR_XOR );
NewTrack = pt_aux->Copy(); NewTrack = pt_aux->Copy();
NewTrack->Insert(frame->m_Pcb, pt_aux); NewTrack->Insert( frame->m_Pcb, pt_aux );
frame->m_Pcb->m_NbSegmTrack++; frame->m_Pcb->m_NbSegmTrack++;
nn++; msg.Printf( wxT("%d"),nn); nn++; msg.Printf( wxT( "%d" ), nn );
Affiche_1_Parametre(frame,POS_AFF_VAR, wxT("New >"),msg,YELLOW); 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; 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; 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); Trace_Une_Piste( frame->DrawPanel, DC, pt_aux, 2, GR_OR );
pt_aux = NewTrack; 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); ptr_pad = Locate_Pad_Connecte( frame->m_Pcb, PtSegm, START );
if( ptr_pad != NULL ) if( ptr_pad != NULL )
{ /* Test si point piste non deja connecte a un autre segment */ { /* Test si point piste non deja connecte a un autre segment */
if( PtSegm->m_Start != ptr_pad->m_Pos ) if( PtSegm->m_Start != ptr_pad->m_Pos )
{ {
if(Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, if( Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL, START) == NULL) NULL, START ) == NULL )
{ {
TRACK * NewTrack = PtSegm->Copy(); TRACK* NewTrack = PtSegm->Copy();
NewTrack->Insert(frame->m_Pcb, PtSegm); NewTrack->Insert( frame->m_Pcb, PtSegm );
NewTrack->m_End = ptr_pad->m_Pos; NewTrack->m_End = ptr_pad->m_Pos;
NewTrack->start = PtSegm; NewTrack->start = PtSegm;
NewTrack->end = ptr_pad; NewTrack->end = ptr_pad;
nb_new_piste++; nb_new_piste++;
NewTrack->Draw(frame->DrawPanel, DC, GR_OR); 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); ptr_pad = Locate_Pad_Connecte( frame->m_Pcb, PtSegm, END );
if( ptr_pad != NULL ) if( ptr_pad != NULL )
{ /* Test si point piste "en l'air" */ { /* Test si point piste "en l'air" */
if( (PtSegm->m_End.x != ptr_pad->m_Pos.x) || if( (PtSegm->m_End.x != ptr_pad->m_Pos.x)
(PtSegm->m_End.y != ptr_pad->m_Pos.y) ) || (PtSegm->m_End.y != ptr_pad->m_Pos.y) )
{ {
if(Locate_Piste_Connectee(PtSegm,frame->m_Pcb->m_Track, if( Locate_Piste_Connectee( PtSegm, frame->m_Pcb->m_Track,
NULL,END) == NULL) NULL, END ) == NULL )
{ {
TRACK * NewTrack = PtSegm->Copy(); TRACK* NewTrack = PtSegm->Copy();
NewTrack->Insert(frame->m_Pcb, PtSegm); NewTrack->Insert( frame->m_Pcb, PtSegm );
NewTrack->m_Start.x = ptr_pad->m_Pos.x; NewTrack->m_Start.x = ptr_pad->m_Pos.x;
NewTrack->m_Start.y = ptr_pad->m_Pos.y; NewTrack->m_Start.y = ptr_pad->m_Pos.y;
NewTrack->start = ptr_pad; NewTrack->start = ptr_pad;
NewTrack->end = PtSegm; NewTrack->end = PtSegm;
nb_new_piste++; nb_new_piste++;
msg.Printf( wxT("e %d"),nb_new_piste); msg.Printf( wxT( "e %d" ), nb_new_piste );
Affiche_1_Parametre(frame, POS_AFF_VAR,wxEmptyString,msg,a_color); Affiche_1_Parametre( frame, POS_AFF_VAR, wxEmptyString, msg, a_color );
} }
} }
} }
......
...@@ -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 */
...@@ -23,7 +23,7 @@ public: ...@@ -23,7 +23,7 @@ public:
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
...@@ -35,34 +35,35 @@ public: ...@@ -35,34 +35,35 @@ public:
/* 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_X0 = Mself.m_Start.x;
Bl_Y0 = Mself.m_Start.y - deltaX; Bl_Y0 = Mself.m_Start.y - deltaX;
...@@ -76,19 +77,19 @@ int deltaX, deltaY; ...@@ -76,19 +77,19 @@ int deltaX, deltaY;
Bl_Xf = Mself.m_Start.x + deltaY; Bl_Xf = Mself.m_Start.x + deltaY;
Bl_Yf = panel->GetScreen()->m_Curseur.y; 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;
} }
...@@ -96,16 +97,16 @@ void Exit_Self(WinEDA_DrawPanel * Panel, wxDC *DC) ...@@ -96,16 +97,16 @@ void Exit_Self(WinEDA_DrawPanel * Panel, wxDC *DC)
/*******************************************/ /*******************************************/
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 )
if ( Self_On )
{ {
Genere_Self(DC); Genere_Self( DC );
return; return;
} }
...@@ -122,64 +123,66 @@ Routine d'initialisation d'un trace de self ...@@ -122,64 +123,66 @@ Routine d'initialisation d'un trace de self
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;
...@@ -189,41 +192,43 @@ wxString msg; ...@@ -189,41 +192,43 @@ wxString msg;
/* 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 )
EXCHG( Mself.m_Start.x, Mself.m_End.x );
Mself.m_Size.y = Mself.m_End.x - Mself.m_Start.x; Mself.m_Size.y = Mself.m_End.x - Mself.m_Start.x;
Mself.lng = Mself.m_Size.y; 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 )
EXCHG( Mself.m_Start.y, Mself.m_End.y );
Mself.m_Size.y = Mself.m_End.y - Mself.m_Start.y; Mself.m_Size.y = Mself.m_End.y - Mself.m_Start.y;
Mself.lng = Mself.m_Size.y; Mself.lng = Mself.m_Size.y;
} }
/* Entree de la vraie longueur desiree */ /* Entree de la vraie longueur desiree */
if( ! g_UnitMetric ) if( !g_UnitMetric )
{ {
fcoeff = 10000.0 ; fcoeff = 10000.0;
msg.Printf( wxT("%1.4f"), Mself.lng /fcoeff); msg.Printf( wxT( "%1.4f" ), Mself.lng / fcoeff );
abort = Get_Message(_("Length(inch):"),msg, this); abort = Get_Message( _( "Length(inch):" ), msg, this );
} }
else else
{ {
fcoeff = 10000.0/25.4 ; fcoeff = 10000.0 / 25.4;
msg.Printf( wxT("%2.3f"), Mself.lng /fcoeff); msg.Printf( wxT( "%2.3f" ), Mself.lng / fcoeff );
abort = Get_Message( _("Length(mm):"),msg, this); abort = Get_Message( _( "Length(mm):" ), msg, this );
} }
if ( abort ) return NULL; if( abort )
return NULL;
double fval; double fval;
if ( ! msg.ToDouble(&fval) ) if( !msg.ToDouble( &fval ) )
{ {
DisplayError(this, _("Incorrect number, abort")); DisplayError( this, _( "Incorrect number, abort" ) );
return NULL; return NULL;
} }
Mself.lng = (int) round( fval * fcoeff ); Mself.lng = (int) round( fval * fcoeff );
...@@ -231,60 +236,65 @@ wxString msg; ...@@ -231,60 +236,65 @@ wxString msg;
/* Controle des valeurs ( ii = valeur minimale de la longueur */ /* Controle des valeurs ( ii = valeur minimale de la longueur */
if( Mself.lng < Mself.m_Size.y ) if( Mself.lng < Mself.m_Size.y )
{ {
DisplayError(this, _("Requested length < minimum length")); DisplayError( this, _( "Requested length < minimum length" ) );
return NULL; return NULL;
} }
/* Generation du composant: calcul des elements de la self */ /* Generation du composant: calcul des elements de la self */
Mself.m_Width = g_DesignSettings.m_CurrentTrackWidth; Mself.m_Width = g_DesignSettings.m_CurrentTrackWidth;
Mself.m_Size.x = Mself.m_Size.y / 2 ; Mself.m_Size.x = Mself.m_Size.y / 2;
// Choix d'une Valeur de depart raisonnable pour le rayon des arcs de cercle // Choix d'une Valeur de depart raisonnable pour le rayon des arcs de cercle
Mself.rayon = min(Mself.m_Width * 5, Mself.m_Size.x/4); Mself.rayon = min( Mself.m_Width * 5, Mself.m_Size.x / 4 );
/* Calcul des parametres */ /* Calcul des parametres */
for ( Mself.nbrin = 2 ; ; Mself.nbrin++) for( Mself.nbrin = 2; ; Mself.nbrin++ )
{ {
Mself.delta = (Mself.m_Size.y - ( Mself.rayon * 2 * Mself.nbrin ) ) / 2 ; 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 if( Mself.delta < Mself.m_Size.y / 10 ) // C.a.d. si m_Size.yeur self > m_Size.yeur specifiee
{ // Reduction du rayon des arrondis { // Reduction du rayon des arrondis
Mself.delta = Mself.m_Size.y / 10; Mself.delta = Mself.m_Size.y / 10;
Mself.rayon = (Mself.m_Size.y - 2*Mself.delta) / ( 2 * Mself.nbrin) ; Mself.rayon = (Mself.m_Size.y - 2 * Mself.delta) / ( 2 * Mself.nbrin);
if(Mself.rayon < Mself.m_Width) if( Mself.rayon < Mself.m_Width )
{ // Rayon vraiment trop petit... { // Rayon vraiment trop petit...
Affiche_Message(_("Unable to create line: Requested length is too big")); Affiche_Message( _( "Unable to create line: Requested length is too big" ) );
return NULL; return NULL;
} }
} }
Mself.lbrin = Mself.m_Size.x - (Mself.rayon * 2); Mself.lbrin = Mself.m_Size.x - (Mself.rayon * 2);
lextbrin = (Mself.lbrin/2) - Mself.rayon; lextbrin = (Mself.lbrin / 2) - Mself.rayon;
ll = 2 * lextbrin ; // Longueur du 1er et dernier brin ll = 2 * lextbrin; // Longueur du 1er et dernier brin
ll += 2 * Mself.delta ; // Longueur des raccord au serpentin ll += 2 * Mself.delta; // Longueur des raccord au serpentin
ll += Mself.nbrin * (Mself.lbrin - 2); // longueur des autres brins ll += Mself.nbrin * (Mself.lbrin - 2); // longueur des autres brins
ll += ((Mself.nbrin+1) * 314 * Mself.rayon) /100 ; ll += ( (Mself.nbrin + 1) * 314 * Mself.rayon ) / 100;
msg.Printf( _("Segm count = %d, Lenght = "), Mself.nbrin); msg.Printf( _( "Segm count = %d, Lenght = " ), Mself.nbrin );
wxString stlen; wxString stlen;
valeur_param(ll, stlen); msg += stlen; valeur_param( ll, stlen ); msg += stlen;
Affiche_Message(msg); Affiche_Message( msg );
if ( ll >= Mself.lng) break; if( ll >= Mself.lng )
break;
} }
/* Generation du composant : le calcul est fait self Verticale */ /* Generation du composant : le calcul est fait self Verticale */
if( Create_1_Module(DC, wxEmptyString) == NULL ) return NULL; if( Create_1_Module( DC, wxEmptyString ) == NULL )
return NULL;
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
Module->m_LibRef = wxT("MuSelf"); Module->m_LibRef = wxT( "MuSelf" );
Module->m_Attributs = MOD_VIRTUAL | MOD_CMS; Module->m_Attributs = MOD_VIRTUAL | MOD_CMS;
Module->m_Flags = 0; Module->m_Flags = 0;
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Generation des elements speciaux: drawsegments */ /* Generation des elements speciaux: drawsegments */
LastSegm = (EDGE_MODULE*) Module->m_Drawings; LastSegm = (EDGE_MODULE*) Module->m_Drawings;
if( LastSegm ) while( LastSegm->Pnext) LastSegm = (EDGE_MODULE*)LastSegm->Pnext; if( LastSegm )
while( LastSegm->Pnext )
LastSegm = (EDGE_MODULE*) LastSegm->Pnext;
FirstSegm = PtSegm = new EDGE_MODULE(Module); FirstSegm = PtSegm = new EDGE_MODULE( Module );
if (LastSegm ) if( LastSegm )
{ {
LastSegm->Pnext = PtSegm; LastSegm->Pnext = PtSegm;
PtSegm->Pback = LastSegm; PtSegm->Pback = LastSegm;
...@@ -300,94 +310,97 @@ wxString msg; ...@@ -300,94 +310,97 @@ wxString msg;
PtSegm->m_Layer = Module->m_Layer; PtSegm->m_Layer = Module->m_Layer;
PtSegm->m_Shape = S_SEGMENT; PtSegm->m_Shape = S_SEGMENT;
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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm = gen_arc(PtSegm,PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900); PtSegm = gen_arc( PtSegm, PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900 );
if(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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End.x -= lextbrin; PtSegm->m_End.x -= lextbrin;
} }
/* Trace du serpentin */ /* Trace du serpentin */
for (ii = 1 ; ii < Mself.nbrin; ii++) for( ii = 1; ii < Mself.nbrin; ii++ )
{ {
int arc_angle; int arc_angle;
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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
if( ii & 1) /* brin d'ordre impair : cercles de sens > 0 */ if( ii & 1 ) /* brin d'ordre impair : cercles de sens > 0 */
arc_angle = 1800; arc_angle = 1800;
else arc_angle = -1800; else
arc_angle = -1800;
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm = gen_arc( PtSegm, PtSegm->m_End.x,
PtSegm->m_End.y + Mself.rayon, arc_angle); PtSegm->m_End.y + Mself.rayon, arc_angle );
if( ii < Mself.nbrin-1) if( ii < Mself.nbrin - 1 )
{ {
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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
if( ii & 1) PtSegm->m_End.x += Mself.lbrin; if( ii & 1 )
else PtSegm->m_End.x -= Mself.lbrin; PtSegm->m_End.x += Mself.lbrin;
else
PtSegm->m_End.x -= Mself.lbrin;
} }
} }
/* Trace du point final */ /* Trace du point final */
if( ii & 1) /* brin final de sens > 0 */ if( ii & 1 ) /* brin final de sens > 0 */
{ {
if(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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End.x -= lextbrin; PtSegm->m_End.x -= 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.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900); PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900 );
} }
else else
{ {
if(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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End.x += lextbrin; PtSegm->m_End.x += 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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900); PtSegm = gen_arc( PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900 );
} }
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 = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End = Mself.m_End; PtSegm->m_End = Mself.m_End;
...@@ -395,14 +408,14 @@ wxString msg; ...@@ -395,14 +408,14 @@ wxString msg;
/* Rotation de la self si le trace doit etre horizontal : */ /* Rotation de la self si le trace doit etre horizontal : */
LastSegm = PtSegm; LastSegm = PtSegm;
if ( Mself.orient == 0) if( Mself.orient == 0 )
{ {
for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext ) for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext )
{ {
RotatePoint(&PtSegm->m_Start.x, &PtSegm->m_Start.y, RotatePoint( &PtSegm->m_Start.x, &PtSegm->m_Start.y,
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 ); FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
if( PtSegm != LastSegm ) if( PtSegm != LastSegm )
RotatePoint(&PtSegm->m_End.x, &PtSegm->m_End.y, RotatePoint( &PtSegm->m_End.x, &PtSegm->m_End.y,
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 ); FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
} }
} }
...@@ -411,10 +424,10 @@ wxString msg; ...@@ -411,10 +424,10 @@ wxString msg;
Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos.y = LastSegm->m_End.y; Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos.y = LastSegm->m_End.y;
/* Placement des 2 pads sur extremite */ /* Placement des 2 pads sur extremite */
PtPad = new D_PAD(Module); PtPad = new D_PAD( Module );
Module->m_Pads = PtPad; PtPad->Pback = Module; Module->m_Pads = PtPad; PtPad->Pback = Module;
PtPad->SetPadName( wxT("1") ); PtPad->SetPadName( wxT( "1" ) );
PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y; 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.x = PtPad->m_Pos.x - Module->m_Pos.x;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y; PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
...@@ -424,19 +437,21 @@ wxString msg; ...@@ -424,19 +437,21 @@ wxString msg;
PtPad->m_PadShape = CIRCLE; PtPad->m_PadShape = CIRCLE;
PtPad->m_Rayon = PtPad->m_Size.x / 2; PtPad->m_Rayon = PtPad->m_Size.x / 2;
D_PAD * newpad = new D_PAD(Module); D_PAD* newpad = new D_PAD( Module );
newpad->Copy(PtPad); newpad->Copy( PtPad );
newpad->AddToChain(PtPad); newpad->AddToChain( PtPad );
PtPad = newpad; PtPad = newpad;
PtPad->SetPadName( wxT("2") ); PtPad->SetPadName( wxT( "2" ) );
PtPad->m_Pos.x = FirstSegm->m_Start.x; PtPad->m_Pos.y = FirstSegm->m_Start.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; PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y; PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
/* Modif des positions textes */ /* Modif des positions textes */
Module->Display_Infos(this); Module->Display_Infos( this );
Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x = ( FirstSegm->m_Start.x + LastSegm->m_End.x ) /2 ; Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x = ( FirstSegm->m_Start.x +
Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y = ( FirstSegm->m_Start.y + LastSegm->m_End.y ) /2 ; LastSegm->m_End.x ) / 2;
Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y = ( FirstSegm->m_Start.y +
LastSegm->m_End.y ) / 2;
Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y; Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y;
Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y; Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y;
...@@ -457,54 +472,55 @@ wxString msg; ...@@ -457,54 +472,55 @@ wxString msg;
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
return Module; 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 = new EDGE_MODULE( (MODULE*) NULL );
newedge->Copy(PtSegm); newedge->Copy( PtSegm );
newedge->m_Parent = PtSegm->m_Parent; newedge->m_Parent = PtSegm->m_Parent;
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.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
} }
beta = (alpha * ii); beta = (alpha * ii);
fcos = cos(beta); fsin = sin(beta); fcos = cos( beta ); fsin = sin( beta );
xr0 = (int)(x0 * fcos + y0 * fsin); xr0 = (int) (x0 * fcos + y0 * fsin);
yr0 = (int)(y0 * fcos - x0 * fsin); yr0 = (int) (y0 * fcos - x0 * fsin);
PtSegm->m_End.x = cX + yr0; PtSegm->m_End.y = cY + xr0 ; 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,8 +19,8 @@ ...@@ -19,8 +19,8 @@
/* 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)
...@@ -28,69 +28,77 @@ static int ModuleInitLayer; // Lors des moves, val init de la couche (pour annu ...@@ -28,69 +28,77 @@ static int ModuleInitLayer; // Lors des moves, val init de la couche (pour annu
/*************************************************************************/ /*************************************************************************/
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; pad_fill_tmp = DisplayOpt.DisplayPadFill;
DisplayOpt.DisplayPadFill = FALSE; /* Trace en SKETCH */ DisplayOpt.DisplayPadFill = FALSE; /* Trace en SKETCH */
pt_pad = module->m_Pads; pt_pad = module->m_Pads;
for( ;pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) 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 )
break;
module = module->Next(); 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;
...@@ -99,16 +107,17 @@ void WinEDA_PcbFrame::StartMove_Module(MODULE * module, wxDC * DC) ...@@ -99,16 +107,17 @@ void WinEDA_PcbFrame::StartMove_Module(MODULE * module, wxDC * DC)
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; m_Pcb->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
...@@ -117,72 +126,75 @@ void WinEDA_PcbFrame::StartMove_Module(MODULE * module, wxDC * DC) ...@@ -117,72 +126,75 @@ void WinEDA_PcbFrame::StartMove_Module(MODULE * module, wxDC * DC)
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
// effacement module a l'ecran: // effacement module a l'ecran:
module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
// Reaffichage // Reaffichage
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); 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(); EraseDragListe();
module->m_Flags = 0; module->m_Flags = 0;
} }
if (module->m_Flags & IS_NEW ) if( module->m_Flags & IS_NEW )
{ {
DeleteStructure(module); DeleteStructure( module );
module = NULL; module = NULL;
pcbframe->m_Pcb->m_Status_Pcb = 0 ; pcbframe->m_Pcb->m_Status_Pcb = 0;
pcbframe->build_liste_pads() ; pcbframe->build_liste_pads();
} }
} }
/* Reaffichage du module a l'ecran */ /* Reaffichage du module a l'ecran */
if ( module ) if( module )
{ {
if ( ModuleInitOrient != module->m_Orient ) if( ModuleInitOrient != module->m_Orient )
pcbframe->Rotate_Module(NULL,module, ModuleInitOrient, FALSE); pcbframe->Rotate_Module( NULL, module, ModuleInitOrient, FALSE );
if( ModuleInitLayer != module->m_Layer ) if( ModuleInitLayer != module->m_Layer )
pcbframe->Change_Side_Module(module, NULL); pcbframe->Change_Side_Module( module, NULL );
module->Draw(Panel, DC, wxPoint(0,0), GR_OR); module->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR );
} }
g_Drag_Pistes_On = FALSE; g_Drag_Pistes_On = FALSE;
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
...@@ -192,77 +204,84 @@ WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*)Panel->m_Parent; ...@@ -192,77 +204,84 @@ WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*)Panel->m_Parent;
/**********************************************************/ /**********************************************************/
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 ! */ /* Si l'empreinte est selectee , on ne peut pas l'effacer ! */
if ( module == NULL ) return FALSE; if( module == NULL )
return FALSE;
/* Confirmation de l'effacement */ /* Confirmation de l'effacement */
module->Display_Infos(this); module->Display_Infos( this );
msg << _("Delete Module") << wxT(" ") << module->m_Reference->m_Text msg << _( "Delete Module" ) << wxT( " " ) << module->m_Reference->m_Text
<< wxT(" (") << _("Value ") << module->m_Value->m_Text << wxT( " (" ) << _( "Value " ) << module->m_Value->m_Text
<< wxT(") ?"); << wxT( ") ?" );
if( !IsOK(this, msg ) ) if( !IsOK( this, msg ) )
{ {
return FALSE; return FALSE;
} }
...@@ -270,95 +289,104 @@ wxString msg; ...@@ -270,95 +289,104 @@ wxString msg;
m_CurrentScreen->SetModify(); m_CurrentScreen->SetModify();
/* Erase rastnest if needed */ /* Erase rastnest if needed */
if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); if( g_Show_Ratsnest )
DrawGeneralRatsnest( DC );
/* Effacement du module a l'ecran */ /* Effacement du module a l'ecran */
if ( DC ) module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); if( DC )
module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Suppression du chainage */ /* Suppression du chainage */
PtBack = module->Pback; PtBack = module->Pback;
PtNext = module->Pnext; PtNext = module->Pnext;
if( PtBack == (EDA_BaseStruct*) m_Pcb ) if( PtBack == (EDA_BaseStruct*) m_Pcb )
{ {
m_Pcb->m_Modules = (MODULE*)PtNext; m_Pcb->m_Modules = (MODULE*) PtNext;
} }
else else
{ {
PtBack->Pnext = PtNext; PtBack->Pnext = PtNext;
} }
if(PtNext) PtNext->Pback = PtBack; if( PtNext )
PtNext->Pback = PtBack;
/* Sauvegarde en buffer des undelete */ /* Sauvegarde en buffer des undelete */
SaveItemEfface( module, 1); SaveItemEfface( module, 1 );
m_Pcb->m_Status_Pcb = 0 ; m_Pcb->m_Status_Pcb = 0;
build_liste_pads() ; build_liste_pads();
ReCompile_Ratsnest_After_Changes( DC ); ReCompile_Ratsnest_After_Changes( DC );
return TRUE; 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) )
return;
m_CurrentScreen->SetModify(); m_CurrentScreen->SetModify();
if ( ! (Module->m_Flags & IS_MOVED) ) if( !(Module->m_Flags & IS_MOVED) )
{ {
m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); if( DC )
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Effacement chevelu general si necessaire */ /* Effacement chevelu general si necessaire */
if ( DC && g_Show_Ratsnest) DrawGeneralRatsnest(DC); if( DC && g_Show_Ratsnest )
DrawGeneralRatsnest( DC );
/* Init des variables utilisees dans la routine Dessine_Drag_segment() */ /* Init des variables utilisees dans la routine Dessine_Drag_segment() */
g_Offset_Module.x = 0; g_Offset_Module.x = 0;
g_Offset_Module.y = 0; g_Offset_Module.y = 0;
} }
else // Module en deplacement else // Module en deplacement
{ {
/* efface empreinte ( vue en contours) si elle a ete deja dessinee */ /* efface empreinte ( vue en contours) si elle a ete deja dessinee */
if ( DC ) if( DC )
{ {
DrawModuleOutlines(DrawPanel, DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
Dessine_Segments_Dragges(DrawPanel, DC); Dessine_Segments_Dragges( DrawPanel, DC );
} }
} }
/* mise a jour du Flag de l'empreinte et des couches des contours et textes */ /* mise a jour du Flag de l'empreinte et des couches des contours et textes */
Module->m_Layer = ChangeSideNumLayer(Module->m_Layer); Module->m_Layer = ChangeSideNumLayer( Module->m_Layer );
/* Inversion miroir de l'orientation */ /* Inversion miroir de l'orientation */
Module->m_Orient = - Module->m_Orient; Module->m_Orient = -Module->m_Orient;
NORMALIZE_ANGLE_POS(Module->m_Orient); NORMALIZE_ANGLE_POS( Module->m_Orient );
/* Inversion miroir + layers des pastilles */ /* Inversion miroir + layers des pastilles */
pt_pad = Module->m_Pads; pt_pad = Module->m_Pads;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
pt_pad->m_Pos.y -= Module->m_Pos.y ; pt_pad->m_Pos.y -= Module->m_Pos.y;
pt_pad->m_Pos.y = -pt_pad->m_Pos.y; pt_pad->m_Pos.y = -pt_pad->m_Pos.y;
pt_pad->m_Pos.y += Module->m_Pos.y; pt_pad->m_Pos.y += Module->m_Pos.y;
pt_pad->m_Pos0.y = - pt_pad->m_Pos0.y; pt_pad->m_Pos0.y = -pt_pad->m_Pos0.y;
pt_pad->m_Offset.y = -pt_pad->m_Offset.y; pt_pad->m_Offset.y = -pt_pad->m_Offset.y;
pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y; pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y;
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_pad->m_Orient); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient );
/* change cote pour pastilles surfaciques */ /* change cote pour pastilles surfaciques */
pt_pad->m_Masque_Layer = ChangeSideMaskLayer(pt_pad->m_Masque_Layer); pt_pad->m_Masque_Layer = ChangeSideMaskLayer( pt_pad->m_Masque_Layer );
} }
/* Inversion miroir de la Reference et mise en miroir : */ /* Inversion miroir de la Reference et mise en miroir : */
...@@ -367,15 +395,20 @@ EDA_BaseStruct * PtStruct; ...@@ -367,15 +395,20 @@ EDA_BaseStruct * PtStruct;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += Module->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Pos0.y = pt_texte->m_Pos0.y;
pt_texte->m_Miroir = 1 ; pt_texte->m_Miroir = 1;
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = Module->m_Layer;
pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer );
if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU;
if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; if( Module->m_Layer == CUIVRE_N )
if( (Module->m_Layer == SILKSCREEN_N_CU) || pt_texte->m_Layer = SILKSCREEN_N_CU;
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
pt_texte->m_Miroir = 0 ; if( Module->m_Layer == CMP_N )
pt_texte->m_Layer = SILKSCREEN_N_CMP;
if( (Module->m_Layer == SILKSCREEN_N_CU)
|| (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
pt_texte->m_Miroir = 0;
/* Inversion miroir de la Valeur et mise en miroir : */ /* Inversion miroir de la Valeur et mise en miroir : */
pt_texte = Module->m_Value; pt_texte = Module->m_Value;
...@@ -383,103 +416,112 @@ EDA_BaseStruct * PtStruct; ...@@ -383,103 +416,112 @@ EDA_BaseStruct * PtStruct;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += Module->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Pos0.y = pt_texte->m_Pos0.y;
pt_texte->m_Miroir = 1 ; pt_texte->m_Miroir = 1;
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = Module->m_Layer;
pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer );
if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU;
if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; if( Module->m_Layer == CUIVRE_N )
if( (Module->m_Layer == SILKSCREEN_N_CU) || pt_texte->m_Layer = SILKSCREEN_N_CU;
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
pt_texte->m_Miroir = 0 ; if( Module->m_Layer == CMP_N )
pt_texte->m_Layer = SILKSCREEN_N_CMP;
if( (Module->m_Layer == SILKSCREEN_N_CU)
|| (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
pt_texte->m_Miroir = 0;
/* Inversion miroir des dessins de l'empreinte : */ /* Inversion miroir des dessins de l'empreinte : */
PtStruct = Module->m_Drawings; PtStruct = Module->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
{ {
switch( PtStruct->m_StructType) switch( PtStruct->m_StructType )
{ {
case TYPEEDGEMODULE: case TYPEEDGEMODULE:
pt_edgmod = (EDGE_MODULE *) PtStruct; pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->m_Start.y -= Module->m_Pos.y; pt_edgmod->m_Start.y -= Module->m_Pos.y;
pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y ; pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y;
pt_edgmod->m_Start.y += Module->m_Pos.y; pt_edgmod->m_Start.y += Module->m_Pos.y;
pt_edgmod->m_End.y -= Module->m_Pos.y; pt_edgmod->m_End.y -= Module->m_Pos.y;
pt_edgmod->m_End.y = -pt_edgmod->m_End.y ; pt_edgmod->m_End.y = -pt_edgmod->m_End.y;
pt_edgmod->m_End.y += Module->m_Pos.y; pt_edgmod->m_End.y += Module->m_Pos.y;
/* inversion des coords locales */ /* inversion des coords locales */
pt_edgmod->m_Start0.y = -pt_edgmod->m_Start0.y; pt_edgmod->m_Start0.y = -pt_edgmod->m_Start0.y;
pt_edgmod->m_End0.y = -pt_edgmod->m_End0.y; pt_edgmod->m_End0.y = -pt_edgmod->m_End0.y;
if ( pt_edgmod->m_Shape == S_ARC ) if( pt_edgmod->m_Shape == S_ARC )
{ {
pt_edgmod->m_Angle = - pt_edgmod->m_Angle; pt_edgmod->m_Angle = -pt_edgmod->m_Angle;
} }
pt_edgmod->m_Layer = ChangeSideNumLayer(pt_edgmod->m_Layer); pt_edgmod->m_Layer = ChangeSideNumLayer( pt_edgmod->m_Layer );
break; break;
case TYPETEXTEMODULE: case TYPETEXTEMODULE:
/* Inversion miroir de la position et mise en miroir : */ /* Inversion miroir de la position et mise en miroir : */
pt_texte = (TEXTE_MODULE*)PtStruct; pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.y -= Module->m_Pos.y; pt_texte->m_Pos.y -= Module->m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += Module->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y;
pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Pos0.y = pt_texte->m_Pos0.y;
pt_texte->m_Miroir = 1 ; pt_texte->m_Miroir = 1;
NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = Module->m_Layer;
pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); pt_texte->m_Layer = ChangeSideNumLayer( pt_texte->m_Layer );
if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU;
if(Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP;
if((Module->m_Layer == SILKSCREEN_N_CU) ||
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N))
pt_texte->m_Miroir = 0 ;
break; if( Module->m_Layer == CUIVRE_N )
pt_texte->m_Layer = SILKSCREEN_N_CU;
default: DisplayError(this, wxT("Unknown Draw Type")); break; if( Module->m_Layer == CMP_N )
pt_texte->m_Layer = SILKSCREEN_N_CMP;
if( (Module->m_Layer == SILKSCREEN_N_CU)
|| (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
pt_texte->m_Miroir = 0;
break;
default:
DisplayError( this, wxT( "Unknown Draw Type" ) ); break;
} }
} }
/* calcul du rectangle d'encadrement */ /* calcul du rectangle d'encadrement */
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->Display_Infos(this); Module->Display_Infos( this );
if( !(Module->m_Flags & IS_MOVED) ) /* Inversion simple */ if( !(Module->m_Flags & IS_MOVED) ) /* Inversion simple */
{ {
if ( DC ) if( DC )
{ {
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
/* affichage chevelu general si necessaire */ /* affichage chevelu general si necessaire */
ReCompile_Ratsnest_After_Changes( DC ); ReCompile_Ratsnest_After_Changes( DC );
} }
} }
else else
{ {
if ( DC ) if( DC )
{ {
DrawModuleOutlines(DrawPanel, DC, Module); DrawModuleOutlines( DrawPanel, DC, Module );
Dessine_Segments_Dragges(DrawPanel, DC); Dessine_Segments_Dragges( DrawPanel, DC );
} }
m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; 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 |
...@@ -488,106 +530,142 @@ int newmasque; ...@@ -488,106 +530,142 @@ int newmasque;
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 & CUIVRE_LAYER )
if( masque & CMP_LAYER) newmasque |= CUIVRE_LAYER; newmasque |= CMP_LAYER;
if( masque & CMP_LAYER )
if( masque & SILKSCREEN_LAYER_CU) newmasque |= SILKSCREEN_LAYER_CMP; newmasque |= CUIVRE_LAYER;
if( masque & SILKSCREEN_LAYER_CMP) newmasque |= SILKSCREEN_LAYER_CU;
if( masque & SILKSCREEN_LAYER_CU )
if( masque & ADHESIVE_LAYER_CU) newmasque |= ADHESIVE_LAYER_CMP; newmasque |= SILKSCREEN_LAYER_CMP;
if( masque & ADHESIVE_LAYER_CMP) newmasque |= ADHESIVE_LAYER_CU; if( masque & SILKSCREEN_LAYER_CMP )
newmasque |= SILKSCREEN_LAYER_CU;
if( masque & SOLDERMASK_LAYER_CU) newmasque |= SOLDERMASK_LAYER_CMP;
if( masque & SOLDERMASK_LAYER_CMP) newmasque |= SOLDERMASK_LAYER_CU; if( masque & ADHESIVE_LAYER_CU )
newmasque |= ADHESIVE_LAYER_CMP;
if( masque & SOLDERPASTE_LAYER_CU) newmasque |= SOLDERPASTE_LAYER_CMP; if( masque & ADHESIVE_LAYER_CMP )
if( masque & SOLDERPASTE_LAYER_CMP) newmasque |= SOLDERPASTE_LAYER_CU; newmasque |= ADHESIVE_LAYER_CU;
if( masque & ADHESIVE_LAYER_CU) newmasque |= ADHESIVE_LAYER_CMP; if( masque & SOLDERMASK_LAYER_CU )
if( masque & ADHESIVE_LAYER_CMP) newmasque |= ADHESIVE_LAYER_CU; newmasque |= SOLDERMASK_LAYER_CMP;
if( masque & SOLDERMASK_LAYER_CMP )
return(newmasque); 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;
} }
/*************************************/ /*************************************/
int ChangeSideNumLayer(int oldlayer) int ChangeSideNumLayer( int oldlayer )
/*************************************/ /*************************************/
/* Routine de recalcul du numero de couche lors des /* Routine de recalcul du numero de couche 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 newlayer; int newlayer;
switch ( oldlayer ) switch( oldlayer )
{ {
case CUIVRE_N: newlayer = CMP_N; break; case CUIVRE_N:
case CMP_N: newlayer = CUIVRE_N; break; newlayer = CMP_N; break;
case CMP_N:
newlayer = CUIVRE_N; break;
case SILKSCREEN_N_CU:
newlayer = SILKSCREEN_N_CMP; break;
case SILKSCREEN_N_CMP:
newlayer = SILKSCREEN_N_CU; break;
case SILKSCREEN_N_CU: newlayer = SILKSCREEN_N_CMP; break; case ADHESIVE_N_CU:
case SILKSCREEN_N_CMP: newlayer = SILKSCREEN_N_CU; break; newlayer = ADHESIVE_N_CMP; break;
case ADHESIVE_N_CU: newlayer = ADHESIVE_N_CMP; break; case ADHESIVE_N_CMP:
case ADHESIVE_N_CMP: newlayer = ADHESIVE_N_CU; break; newlayer = ADHESIVE_N_CU; break;
case SOLDERMASK_N_CU: newlayer = SOLDERMASK_N_CMP; break; case SOLDERMASK_N_CU:
case SOLDERMASK_N_CMP: newlayer = SOLDERMASK_N_CU; break; newlayer = SOLDERMASK_N_CMP; break;
case SOLDERPASTE_N_CU: newlayer = SOLDERPASTE_N_CMP; break; case SOLDERMASK_N_CMP:
case SOLDERPASTE_N_CMP: newlayer = SOLDERPASTE_N_CU; break; newlayer = SOLDERMASK_N_CU; break;
default: newlayer = oldlayer; case SOLDERPASTE_N_CU:
newlayer = SOLDERPASTE_N_CMP; break;
case SOLDERPASTE_N_CMP:
newlayer = SOLDERPASTE_N_CU; break;
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_CurrentScreen->SetModify();
m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
if(g_Show_Module_Ratsnest && (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) && DC) if( g_Show_Module_Ratsnest && (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) && DC )
trace_ratsnest_module(DC); trace_ratsnest_module( DC );
newpos = m_CurrentScreen->m_Curseur; newpos = m_CurrentScreen->m_Curseur;
module->SetPosition(newpos); module->SetPosition( newpos );
if ( DC ) module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); if( DC )
module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
/* Tracage des segments dragges et liberation memoire */ /* Tracage des segments dragges et liberation memoire */
if( g_DragSegmentList ) if( g_DragSegmentList )
{ {
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->SetState(EDIT,OFF); pt_segm->SetState( EDIT, OFF );
if ( DC ) pt_segm->Draw(DrawPanel, DC, GR_OR); if( DC )
pt_segm->Draw( DrawPanel, DC, GR_OR );
} }
EraseDragListe(); EraseDragListe();
} }
/* affichage chevelu general si necessaire */ /* affichage chevelu general si necessaire */
ReCompile_Ratsnest_After_Changes( DC ); ReCompile_Ratsnest_After_Changes( DC );
module->Display_Infos(this); module->Display_Infos( this );
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
...@@ -597,63 +675,66 @@ wxPoint newpos; ...@@ -597,63 +675,66 @@ wxPoint newpos;
/***********************************************************************/ /***********************************************************************/
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 */ /* efface ancienne position */
if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */ if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */
{ {
if ( DC ) if( DC )
{ {
module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
/* Reaffichage chevelu general si necessaire */ /* Reaffichage chevelu general si necessaire */
if(g_Show_Ratsnest) DrawGeneralRatsnest(DC); if( g_Show_Ratsnest )
DrawGeneralRatsnest( DC );
} }
} }
else else
{ {
/* reaffiche module en mouvement */ /* reaffiche module en mouvement */
if ( DC ) if( DC )
{ {
DrawModuleOutlines(DrawPanel, DC, module); DrawModuleOutlines( DrawPanel, DC, module );
Dessine_Segments_Dragges(DrawPanel, DC); Dessine_Segments_Dragges( DrawPanel, DC );
} }
} }
m_Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CONNEXION_OK); m_Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CONNEXION_OK);
if ( incremental ) if( incremental )
module->SetOrientation(module->m_Orient + angle); module->SetOrientation( module->m_Orient + angle );
else else
module->SetOrientation(angle); module->SetOrientation( angle );
module->Display_Infos(this); module->Display_Infos( this );
if ( DC ) if( DC )
{ {
if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */ if( !(module->m_Flags & IS_MOVED) ) /* Rotation simple */
{ {
module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
/* Reaffichage chevelu general si necessaire */ /* Reaffichage chevelu general si necessaire */
ReCompile_Ratsnest_After_Changes( DC ); ReCompile_Ratsnest_After_Changes( DC );
} }
else else
{ {
/* reaffiche module en mouvement */ /* reaffiche module en mouvement */
DrawModuleOutlines(DrawPanel, DC, module); DrawModuleOutlines( DrawPanel, DC, module );
Dessine_Segments_Dragges(DrawPanel, DC); 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; pad_fill_tmp = DisplayOpt.DisplayPadFill;
DisplayOpt.DisplayPadFill = SKETCH; /* Trace en SKETCH en deplacement */ DisplayOpt.DisplayPadFill = SKETCH; /* Trace en SKETCH en deplacement */
pt_pad = module->m_Pads; pt_pad = module->m_Pads;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext) 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) if( g_Show_Module_Ratsnest && panel )
{ {
WinEDA_BasePcbFrame * frame = (WinEDA_BasePcbFrame * ) panel->m_Parent; WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
frame->build_ratsnest_module(DC, module); frame->build_ratsnest_module( DC, module );
frame->trace_ratsnest_module(DC); 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,70 +17,75 @@ ...@@ -17,70 +17,75 @@
/* 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->GetScreen()->m_Curseur = PosInit;
Panel->ManageCurseur(Panel, DC, TRUE); Panel->ManageCurseur( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = oldpos; Panel->GetScreen()->m_Curseur = oldpos;
g_HightLigt_Status = FALSE; g_HightLigt_Status = FALSE;
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; ( (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; if( NewTrack == NULL )
break;
NextS = (TRACK*) NewTrack->Pnext; NextS = (TRACK*) NewTrack->Pnext;
delete NewTrack; delete NewTrack;
} }
} }
else /* Move : remise en ancienne position */ else /* Move : remise en ancienne position */
{ {
TRACK * Track = NewTrack; TRACK* Track = NewTrack;
int dx = LastPos.x - PosInit.x; int dx = LastPos.x - PosInit.x;
int dy = LastPos.y - PosInit.y; int dy = LastPos.y - PosInit.y;
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
{ {
if( Track == NULL ) break; if( Track == NULL )
break;
Track->m_Start.x -= dx; Track->m_Start.x -= dx;
Track->m_Start.y -= dy; Track->m_Start.y -= dy;
Track->m_End.x -= dx; Track->m_End.x -= dx;
Track->m_End.y -= dy; Track->m_End.y -= dy;
Track->m_Flags = 0; Track->m_Flags = 0;
} }
Trace_Une_Piste(Panel, DC, NewTrack,NbPtNewTrack,GR_OR);
Trace_Une_Piste( Panel, DC, NewTrack, NbPtNewTrack, GR_OR );
} }
NewTrack = NULL; NewTrack = NULL;
...@@ -92,44 +97,44 @@ int ii; ...@@ -92,44 +97,44 @@ int ii;
Panel->m_Parent->EraseMsgBox(); Panel->m_Parent->EraseMsgBox();
/* Annulation deplacement et Redessin des segments dragges */ /* Annulation deplacement et Redessin des segments dragges */
DRAG_SEGM * pt_drag = g_DragSegmentList; DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
TRACK * Track = pt_drag->m_Segm; TRACK* Track = pt_drag->m_Segm;
pt_drag->SetInitialValues(); pt_drag->SetInitialValues();
Track->SetState(EDIT,OFF); Track->SetState( EDIT, OFF );
Track->m_Flags = 0; Track->m_Flags = 0;
Track->Draw(Panel, DC, GR_OR); Track->Draw( Panel, DC, GR_OR );
} }
g_HightLigth_NetCode = Old_HightLigth_NetCode; g_HightLigth_NetCode = Old_HightLigth_NetCode;
g_HightLigt_Status = Old_HightLigt_Status; g_HightLigt_Status = Old_HightLigt_Status;
if(g_HightLigt_Status) if( g_HightLigt_Status )
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; ( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
EraseDragListe(); 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 */ /* mise a jour des coordonnees des segments de la piste */
...@@ -140,65 +145,66 @@ erase = TRUE; ...@@ -140,65 +145,66 @@ erase = TRUE;
ii = NbPtNewTrack, Track = NewTrack; ii = NbPtNewTrack, Track = NewTrack;
for( ; ii > 0; ii--, Track = Track->Next() ) 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 */ /* dessin de la nouvelle piste */
Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,GR_XOR) ; Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
/* Tracage des segments dragges */ /* Tracage des segments dragges */
DRAG_SEGM * pt_drag = g_DragSegmentList; DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
Track = pt_drag->m_Segm; Track = pt_drag->m_Segm;
if ( erase ) Track->Draw(panel, DC, GR_XOR); if( erase )
if( Track->m_Flags & STARTPOINT) Track->Draw( panel, DC, GR_XOR );
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;
} }
Track->Draw(panel, DC, GR_XOR); Track->Draw( panel, DC, GR_XOR );
} }
DisplayOpt.DisplayPcbTrackFill = track_fill_copy ;
}
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; track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT;
Collect_TrackSegmentsToDrag(DrawPanel, DC, track->m_Start, Collect_TrackSegmentsToDrag( DrawPanel, DC, track->m_Start,
track->ReturnMaskLayer(), track->m_NetCode); track->ReturnMaskLayer(), track->m_NetCode );
NewTrack = track; NewTrack = track;
NbPtNewTrack = 1; NbPtNewTrack = 1;
PosInit = track->m_Start; 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;
...@@ -210,49 +216,52 @@ void WinEDA_PcbFrame::Start_MoveOneTrackSegment(TRACK * track, wxDC * DC, bool D ...@@ -210,49 +216,52 @@ void WinEDA_PcbFrame::Start_MoveOneTrackSegment(TRACK * track, wxDC * DC, bool D
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: // DRC control:
if(Drc_On) if( Drc_On )
{ {
errdrc = Drc(this, DC, Track, m_Pcb->m_Track,1); errdrc = Drc( this, DC, Track, m_Pcb->m_Track, 1 );
if(errdrc == BAD_DRC) return FALSE; if( errdrc == BAD_DRC )
return FALSE;
/* Tracage des segments dragges */ /* Tracage des segments dragges */
pt_drag = g_DragSegmentList; pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext) for( ; pt_drag; pt_drag = pt_drag->Pnext )
{ {
errdrc = Drc(this, DC, pt_drag->m_Segm, m_Pcb->m_Track,1); errdrc = Drc( this, DC, pt_drag->m_Segm, m_Pcb->m_Track, 1 );
if(errdrc == BAD_DRC) return FALSE; if( errdrc == BAD_DRC )
return FALSE;
} }
} }
// DRC Ok: place track segments // DRC Ok: place track segments
Track->m_Flags = 0; Track->m_Flags = 0;
Track->Draw(DrawPanel, DC, GR_OR); Track->Draw( DrawPanel, DC, GR_OR );
/* Tracage des segments dragges */ /* Tracage des segments dragges */
pt_drag = g_DragSegmentList; pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext) for( ; pt_drag; pt_drag = pt_drag->Pnext )
{ {
Track = pt_drag->m_Segm; Track = pt_drag->m_Segm;
Track->SetState(EDIT,OFF); Track->SetState( EDIT, OFF );
Track->m_Flags = 0; Track->m_Flags = 0;
Track->Draw(DrawPanel, DC, GR_OR); Track->Draw( DrawPanel, DC, GR_OR );
} }
EraseDragListe(); EraseDragListe();
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -266,83 +275,89 @@ DRAG_SEGM * pt_drag; ...@@ -266,83 +275,89 @@ DRAG_SEGM * pt_drag;
#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 /* Placement du flag BUSY de la piste originelle, qui ne doit
pas etre vue dans les recherches de raccordement suivantes */ * pas etre vue dans les recherches de raccordement suivantes */
ii = NbPtNewTrack; pt_track = NewTrack; ii = NbPtNewTrack; pt_track = NewTrack;
for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) 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 */ /* Detection du nouveau net_code */
ii = NbPtNewTrack; pt_track = NewTrack; ii = NbPtNewTrack; pt_track = NewTrack;
for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
{ {
pt_track->net_code = 0; pt_track->net_code = 0;
} }
new_net_code = 0; new_net_code = 0;
ii = 0; pt_track = NewTrack; ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack ; ii++, pt_track = (TRACK*)pt_track->Pnext) for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*) pt_track->Pnext )
{ {
/* Localisation de la pastille ou segment en debut de segment: */ /* Localisation de la pastille ou segment en debut de segment: */
masquelayer = tab_layer[pt_track->Layer]; masquelayer = tab_layer[pt_track->Layer];
LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer); LockPoint = LocateLockPoint( pt_track->m_Start.x, pt_track->m_Start.y, masquelayer );
if( LockPoint ) if( LockPoint )
{ {
if ( LockPoint->m_StructType == TYPEPAD ) if( LockPoint->m_StructType == TYPEPAD )
{ {
pt_pad = (D_PAD*) LockPoint; pt_pad = (D_PAD*) LockPoint;
new_net_code = pt_pad->net_code; new_net_code = pt_pad->net_code;
if ( new_net_code > 0 ) break; if( new_net_code > 0 )
break;
} }
else /* debut de piste sur un segment de piste */ else /* debut de piste sur un segment de piste */
{ {
Track = (TRACK *) LockPoint; Track = (TRACK*) LockPoint;
new_net_code = Track->net_code; new_net_code = Track->net_code;
if ( new_net_code > 0 ) break; if( new_net_code > 0 )
break;
} }
} }
LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); LockPoint = LocateLockPoint( pt_track->m_End.x, pt_track->m_End.y, masquelayer );
if( LockPoint ) if( LockPoint )
{ {
if ( LockPoint->m_StructType == TYPEPAD ) if( LockPoint->m_StructType == TYPEPAD )
{ {
pt_pad = (D_PAD*) LockPoint; pt_pad = (D_PAD*) LockPoint;
new_net_code = pt_pad->net_code; new_net_code = pt_pad->net_code;
if ( new_net_code > 0 ) break; if( new_net_code > 0 )
break;
} }
else /* debut de piste sur un segment de piste */ else /* debut de piste sur un segment de piste */
{ {
Track = (TRACK *) LockPoint; Track = (TRACK*) LockPoint;
new_net_code = Track->net_code; new_net_code = Track->net_code;
if ( new_net_code > 0 ) break; if( new_net_code > 0 )
break;
} }
} }
} }
/* Mise a jour du nouveau net code de la piste */ /* Mise a jour du nouveau net code de la piste */
ii = 0; pt_track = NewTrack; ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*)pt_track->Pnext) for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*) pt_track->Pnext )
{ {
pt_track->net_code = new_net_code; pt_track->net_code = new_net_code;
} }
...@@ -352,175 +367,189 @@ wxDC * DC = Cmd->DC; ...@@ -352,175 +367,189 @@ wxDC * DC = Cmd->DC;
for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() ) for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() )
{ {
if( Drc_On == RUN ) if( Drc_On == RUN )
if( drc(DC, pt_track, pt_pcb->Track, 1) == BAD_DRC ) if( drc( DC, pt_track, pt_pcb->Track, 1 ) == BAD_DRC )
{ {
if( confirmation(" Erreur DRC, Place piste:") == YES ) continue; if( confirmation( " Erreur DRC, Place piste:" ) == YES )
else { DRC_error = 1; break; } continue;
else
{
DRC_error = 1; break;
}
} }
} }
if( DRC_error == 0) if( DRC_error == 0 )
{ {
if(FlagState == MOVE_ROUTE) if( FlagState == MOVE_ROUTE )
{ {
/* copie nouvelle piste */ /* copie nouvelle piste */
pt_track = NewTrack; pt_track = NewTrack;
NewTrack = pt_track->Copy(NbPtNewTrack); NewTrack = pt_track->Copy( NbPtNewTrack );
/* effacement ancienne ( chainage et liens mauvais */ /* effacement ancienne ( chainage et liens mauvais */
ii = NbPtNewTrack; ii = NbPtNewTrack;
for ( ; ii > 0; ii --, pt_track = NextS) for( ; ii > 0; ii--, pt_track = NextS )
{ {
NextS = (TRACK*) pt_track->Pnext; NextS = (TRACK*) pt_track->Pnext;
DeleteStructure(pt_track); DeleteStructure( pt_track );
} }
test_1_net_connexion(DC, old_net_code );
test_1_net_connexion( DC, old_net_code );
} }
pt_classe = NewTrack->GetBestInsertPoint(); pt_classe = NewTrack->GetBestInsertPoint();
NewTrack->Insert(pt_classe); NewTrack->Insert( pt_classe );
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR) ; Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_OR );
/* Mise a jour des connexions sur pads et sur pistes */ /* Mise a jour des connexions sur pads et sur pistes */
ii = 0; pt_track = NewTrack; ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack; ii++, pt_track = NextS) for( ; ii < NbPtNewTrack; ii++, pt_track = NextS )
{ {
NextS = (TRACK*)pt_track->Pnext; NextS = (TRACK*) pt_track->Pnext;
pt_track->SetState(BEGIN_ONPAD|END_ONPAD, OFF); pt_track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
masquelayer = tab_layer[pt_track->Layer]; masquelayer = tab_layer[pt_track->Layer];
/* Localisation de la pastille ou segment sur debut segment: */ /* Localisation de la pastille ou segment sur debut segment: */
LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer); LockPoint = LocateLockPoint( pt_track->m_Start.x, pt_track->m_Start.y, masquelayer );
if( LockPoint ) if( LockPoint )
{ {
pt_track->start = LockPoint; pt_track->start = LockPoint;
if ( LockPoint->m_StructType == TYPEPAD ) if( LockPoint->m_StructType == TYPEPAD )
{ /* fin de piste sur un pad */ { /* fin de piste sur un pad */
pt_pad = (D_PAD*) LockPoint; pt_pad = (D_PAD*) LockPoint;
pt_track->SetState(BEGIN_ONPAD, ON); pt_track->SetState( BEGIN_ONPAD, ON );
} }
else /* debut de piste sur un segment de piste */ else /* debut de piste sur un segment de piste */
{ {
Track = (TRACK *) LockPoint; Track = (TRACK*) LockPoint;
CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); CreateLockPoint( &pt_track->m_Start.x, &pt_track->m_Start.y, Track, pt_track );
} }
} }
/* Localisation de la pastille ou segment sur fin de segment: */ /* Localisation de la pastille ou segment sur fin de segment: */
LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer); LockPoint = LocateLockPoint( pt_track->m_End.x, pt_track->m_End.y, masquelayer );
if( LockPoint ) if( LockPoint )
{ {
pt_track->end = LockPoint; pt_track->end = LockPoint;
if ( LockPoint->m_StructType == TYPEPAD ) if( LockPoint->m_StructType == TYPEPAD )
{ /* fin de piste sur un pad */ { /* fin de piste sur un pad */
pt_pad = (D_PAD*) LockPoint; pt_pad = (D_PAD*) LockPoint;
pt_track->SetState(END_ONPAD, ON); pt_track->SetState( END_ONPAD, ON );
} }
else /* debut de piste sur un segment de piste */ else /* debut de piste sur un segment de piste */
{ {
Track = (TRACK *) LockPoint; Track = (TRACK*) LockPoint;
CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track); CreateLockPoint( &pt_track->m_Start.x, &pt_track->m_Start.y, Track, pt_track );
} }
} }
} }
/* Suppression du flag BUSY */ /* Suppression du flag BUSY */
ii = NbPtNewTrack; pt_track = NewTrack; ii = NbPtNewTrack; pt_track = NewTrack;
for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext) for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
{ {
pt_track->SetState(BUSY, OFF); pt_track->SetState( BUSY, OFF );
} }
test_1_net_connexion(DC, new_net_code ); test_1_net_connexion( DC, new_net_code );
ActiveScreen->SetModify(); ActiveScreen->SetModify();
} }
else /* Erreur DRC: Annulation commande */ else /* Erreur DRC: Annulation commande */
{ {
DisplayOpt.DisplayPcbTrackFill = SKETCH ; DisplayOpt.DisplayPcbTrackFill = SKETCH;
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR); Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_XOR );
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
if(FlagState == MOVE_ROUTE) if( FlagState == MOVE_ROUTE )
{ /* Remise en position de la piste deplacee */ { /* Remise en position de la piste deplacee */
Track = NewTrack; Track = NewTrack;
PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y; PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y;
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
{ {
if( Track == NULL ) break; if( Track == NULL )
break;
Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY; Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY;
Track->m_End.x += PosInitX; Track->m_End.y += PosInitY; Track->m_End.x += PosInitX; Track->m_End.y += PosInitY;
Track->SetState(BUSY,OFF); Track->SetState( BUSY, OFF );
} }
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR);
Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_OR );
} }
if (FlagState == COPY_ROUTE ) if( FlagState == COPY_ROUTE )
{ /* Suppression copie */ { /* Suppression copie */
for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS) for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS )
{ {
if(NewTrack == NULL) break; if( NewTrack == NULL )
break;
NextS = (TRACK*) NewTrack->Pnext; NextS = (TRACK*) NewTrack->Pnext;
delete NewTrack; delete NewTrack;
} }
} }
} }
NewTrack = NULL; NewTrack = NULL;
Affiche_Infos_Status_Pcb(Cmd); Affiche_Infos_Status_Pcb( Cmd );
if(Etat_Surbrillance) Hight_Light(DC); 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) */ /* 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) 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); pt_segm = Locate_Pistes( pt_segm, masquelayer, CURSEUR_OFF_GRILLE );
if( pt_segm == NULL ) break ; if( pt_segm == NULL )
break ; break;
break;
} }
if( pt_segm != NULL ) if( pt_segm != NULL )
{ {
if (FlagState == COPY_ROUTE ) if( FlagState == COPY_ROUTE )
pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, 0); pt_track = Marque_Une_Piste( DC, pt_segm, &NbPtNewTrack, 0 );
else pt_track = Marque_Une_Piste(DC, pt_segm, &NbPtNewTrack, GR_XOR); else
pt_track = Marque_Une_Piste( DC, pt_segm, &NbPtNewTrack, GR_XOR );
if(NbPtNewTrack) /* Il y a NbPtNewTrack segments de piste a traiter */ if( NbPtNewTrack ) /* Il y a NbPtNewTrack segments de piste a traiter */
{ {
/* effacement du flag BUSY de la piste originelle */ /* effacement du flag BUSY de la piste originelle */
ii = NbPtNewTrack; pt_segm = pt_track; ii = NbPtNewTrack; pt_segm = pt_track;
for ( ; ii > 0; ii --, pt_segm = (TRACK*) pt_segm->Pnext) for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Pnext )
{ {
pt_segm->SetState(BUSY, OFF); pt_segm->SetState( BUSY, OFF );
} }
if (FlagState == COPY_ROUTE ) if( FlagState == COPY_ROUTE )
NewTrack = pt_track->Copy(NbPtNewTrack); NewTrack = pt_track->Copy( NbPtNewTrack );
else NewTrack = pt_track; else
NewTrack = pt_track;
Affiche_Infos_Piste(Cmd, pt_track) ; Affiche_Infos_Piste( Cmd, pt_track );
startX = ActiveScreen->Curseur_X; startX = ActiveScreen->Curseur_X;
startY = ActiveScreen->Curseur_Y; startY = ActiveScreen->Curseur_Y;
Place_Dupl_Route_Item.State = WAIT; Place_Dupl_Route_Item.State = WAIT;
ActiveDrawPanel->ManageCurseur = Show_Move_Piste; ActiveDrawPanel->ManageCurseur = Show_Move_Piste;
DisplayOpt.DisplayPcbTrackFill = SKETCH ; DisplayOpt.DisplayPcbTrackFill = SKETCH;
Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR) ; Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_XOR );
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ; DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
PosInitX = NewTrack->m_Start.x; PosInitY = NewTrack->m_Start.y; PosInitX = NewTrack->m_Start.x; PosInitY = NewTrack->m_Start.y;
} }
} }
...@@ -530,83 +559,89 @@ wxDC * DC = Cmd->DC; ...@@ -530,83 +559,89 @@ wxDC * DC = Cmd->DC;
#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); ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
if( ptsegm == NULL ) if( ptsegm == NULL )
ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask); ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask );
return(ptsegm); 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) )
return NULL;
/* le point n'est pas sur une extremite de piste */ /* le point n'est pas sur une extremite de piste */
if(ptsegm->m_StructType == TYPEVIA ) if( ptsegm->m_StructType == TYPEVIA )
{ {
*pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y; *pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y;
return(ptsegm); return ptsegm;
} }
/* calcul des coord vraies du point intermediaire dans le repere d'origine /* calcul des coord vraies du point intermediaire dans le repere d'origine
= origine de ptsegm */ * = origine de ptsegm */
cX = *pX - ptsegm->m_Start.x; 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;
...@@ -615,31 +650,30 @@ TRACK * NewTrack; ...@@ -615,31 +650,30 @@ TRACK * NewTrack;
} }
/* 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;
} }
/****************************************************/ /****************************************************/
/* 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,71 +18,76 @@ ...@@ -18,71 +18,76 @@
/* 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; Panel->GetScreen()->m_Curseur = PosInit;
if ( Panel->ManageCurseur ) Panel->ManageCurseur(Panel, DC, TRUE); if( Panel->ManageCurseur )
Panel->ManageCurseur( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = oldpos; Panel->GetScreen()->m_Curseur = oldpos;
g_HightLigt_Status = FALSE; g_HightLigt_Status = FALSE;
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; ( (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; if( NewTrack == NULL )
break;
NextS = (TRACK*) NewTrack->Pnext; NextS = (TRACK*) NewTrack->Pnext;
delete NewTrack; delete NewTrack;
} }
} }
else /* Move : remise en ancienne position */ else /* Move : remise en ancienne position */
{ {
TRACK * Track = NewTrack; TRACK* Track = NewTrack;
int dx = s_LastPos.x - PosInit.x; int dx = s_LastPos.x - PosInit.x;
int dy = s_LastPos.y - PosInit.y; int dy = s_LastPos.y - PosInit.y;
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext) for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
{ {
if( Track == NULL ) break; if( Track == NULL )
break;
Track->m_Start.x -= dx; Track->m_Start.x -= dx;
Track->m_Start.y -= dy; Track->m_Start.y -= dy;
Track->m_End.x -= dx; Track->m_End.x -= dx;
Track->m_End.y -= dy; Track->m_End.y -= dy;
Track->m_Flags = 0; Track->m_Flags = 0;
} }
Trace_Une_Piste(Panel, DC, NewTrack,NbPtNewTrack,GR_OR);
Trace_Une_Piste( Panel, DC, NewTrack, NbPtNewTrack, GR_OR );
} }
NewTrack = NULL; NewTrack = NULL;
...@@ -94,43 +99,45 @@ int ii; ...@@ -94,43 +99,45 @@ int ii;
Panel->m_Parent->EraseMsgBox(); Panel->m_Parent->EraseMsgBox();
/* Annulation deplacement et Redessin des segments dragges */ /* Annulation deplacement et Redessin des segments dragges */
DRAG_SEGM * pt_drag = g_DragSegmentList; DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
TRACK * Track = pt_drag->m_Segm; TRACK* Track = pt_drag->m_Segm;
pt_drag->SetInitialValues(); pt_drag->SetInitialValues();
Track->SetState(EDIT,OFF); Track->SetState( EDIT, OFF );
Track->m_Flags = 0; Track->m_Flags = 0;
Track->Draw(Panel, DC, GR_OR); Track->Draw( Panel, DC, GR_OR );
} }
g_HightLigth_NetCode = Old_HightLigth_NetCode; g_HightLigth_NetCode = Old_HightLigth_NetCode;
g_HightLigt_Status = Old_HightLigt_Status; g_HightLigt_Status = Old_HightLigt_Status;
if(g_HightLigt_Status) if( g_HightLigt_Status )
( (WinEDA_PcbFrame *)Panel->m_Parent)->DrawHightLight( DC, g_HightLigth_NetCode) ; ( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
EraseDragListe(); 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 */ /* set the new track coordinates */
...@@ -141,114 +148,121 @@ erase = TRUE; ...@@ -141,114 +148,121 @@ erase = TRUE;
ii = NbPtNewTrack, Track = NewTrack; ii = NbPtNewTrack, Track = NewTrack;
for( ; (ii > 0) && (Track != NULL); ii--, Track = Track->Next() ) 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 */ /* Redraw the current moved track segments */
Trace_Une_Piste(panel, DC, NewTrack,NbPtNewTrack,GR_XOR) ; Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
DRAG_SEGM * pt_drag = g_DragSegmentList; DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext) for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
Track = pt_drag->m_Segm; Track = pt_drag->m_Segm;
if ( erase ) Track->Draw(panel, DC, draw_mode); if( erase )
if( Track->m_Flags & STARTPOINT) Track->Draw( panel, DC, draw_mode );
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;
} }
Track->Draw(panel, DC, draw_mode); Track->Draw( panel, DC, draw_mode );
} }
DisplayOpt.DisplayPcbTrackFill = track_fill_copy ;
}
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 )
return;
TrackSegWrapper = TrackSegWrapper->Pnext; TrackSegWrapper = TrackSegWrapper->Pnext;
if ( TrackSegWrapper ) if( TrackSegWrapper )
{ {
if ( s_EndSegmentPresent ) if( s_EndSegmentPresent )
{ {
tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point
TrackSegWrapper = TrackSegWrapper->Pnext; TrackSegWrapper = TrackSegWrapper->Pnext;
} }
if ( s_StartSegmentPresent ) if( s_StartSegmentPresent )
{ {
if ( TrackSegWrapper ) if( TrackSegWrapper )
tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point
} }
} }
int draw_mode = GR_XOR | GR_SURBRILL; int draw_mode = GR_XOR | GR_SURBRILL;
/* Undraw the current moved track segments before modification*/ /* 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 */ /* Compute the new track segment position */
...@@ -256,285 +270,337 @@ TRACK * tSegmentToStart = NULL, * tSegmentToEnd = NULL; ...@@ -256,285 +270,337 @@ TRACK * tSegmentToStart = NULL, * tSegmentToEnd = NULL;
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 //move the line by dx and dy
tx1 = (double)(Track->m_Start.x + dx); tx1 = (double) (Track->m_Start.x + dx);
ty1 = (double)(Track->m_Start.y + dy); ty1 = (double) (Track->m_Start.y + dy);
tx2 = (double)(Track->m_End.x + dx); tx2 = (double) (Track->m_End.x + dx);
ty2 = (double)(Track->m_End.y + dy); ty2 = (double) (Track->m_End.y + dy);
// recalculate the segments new parameters and intersection points // recalculate the segments new parameters and intersection points
// only the intercept will change, segment slopes does not change // only the intercept will change, segment slopes does not change
// because we are moving parallel with is initial state // because we are moving parallel with is initial state
if (!s_MovingSegmentVertical) { if( !s_MovingSegmentVertical )
{
s_MovingSegment_Yorg = ty1 - (s_MovingSegmentSlope * tx1); s_MovingSegment_Yorg = ty1 - (s_MovingSegmentSlope * tx1);
} }
if ((!s_EndPointVertical) && (!s_MovingSegmentVertical)) { if( (!s_EndPointVertical) && (!s_MovingSegmentVertical) )
xi2 = (s_MovingSegment_Yorg - s_EndSegment_Yorg) / (s_EndSegmentSlope - s_MovingSegmentSlope); {
} else { xi2 = (s_MovingSegment_Yorg -
if (!s_EndPointVertical) { s_EndSegment_Yorg) / (s_EndSegmentSlope - s_MovingSegmentSlope);
}
else
{
if( !s_EndPointVertical )
{
xi2 = tx2; xi2 = tx2;
} else { }
else
{
//P1=P2 //P1=P2
if (!s_EndPointHorizontal) { if( !s_EndPointHorizontal )
xi2 = tx2-dx; {
} else { xi2 = tx2 - dx;
update=false; }
else
{
update = false;
} }
} }
} }
if (!s_MovingSegmentVertical) if( !s_MovingSegmentVertical )
{ {
yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg; yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg;
} }
else else
{ {
if (!s_EndPointVertical) { if( !s_EndPointVertical )
{
yi2 = s_EndSegmentSlope * (xi2) + s_EndSegment_Yorg; yi2 = s_EndSegmentSlope * (xi2) + s_EndSegment_Yorg;
} }
else else
{ {
if (!s_EndPointHorizontal) { if( !s_EndPointHorizontal )
update=false; {
update = false;
} }
else { else
{
yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg; yi2 = s_MovingSegmentSlope * (xi2) + s_MovingSegment_Yorg;
} }
} }
} }
if ((!s_StartPointVertical) && (!s_MovingSegmentVertical)) if( (!s_StartPointVertical) && (!s_MovingSegmentVertical) )
{ {
xi1 = (s_MovingSegment_Yorg - s_StartSegment_Yorg) / (s_StartSegmentSlope - s_MovingSegmentSlope); xi1 = (s_MovingSegment_Yorg -
s_StartSegment_Yorg) / (s_StartSegmentSlope - s_MovingSegmentSlope);
} }
else else
{ {
if (!s_StartPointVertical) { if( !s_StartPointVertical )
{
xi1 = tx1; xi1 = tx1;
} }
else else
{ {
//P1=P2 //P1=P2
if (!s_StartPointHorizontal) { if( !s_StartPointHorizontal )
xi1 = tx1-dx; {
xi1 = tx1 - dx;
} }
else else
{ {
if (!s_StartPointHorizontal) { if( !s_StartPointHorizontal )
update=false; {
update = false;
} }
} }
} }
} }
if (!s_MovingSegmentVertical) { if( !s_MovingSegmentVertical )
{
yi1 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg; yi1 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg;
} }
else { else
if (!s_StartPointVertical) { {
if( !s_StartPointVertical )
{
yi1 = s_StartSegmentSlope * (xi1) + s_StartSegment_Yorg; yi1 = s_StartSegmentSlope * (xi1) + s_StartSegment_Yorg;
} else { }
if (!s_StartPointHorizontal) { else
update=false; {
} else { if( !s_StartPointHorizontal )
{
update = false;
}
else
{
yi2 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg; yi2 = s_MovingSegmentSlope * (xi1) + s_MovingSegment_Yorg;
} }
} }
} }
// update the segment coordinates (if possible) // update the segment coordinates (if possible)
if ( tSegmentToStart == NULL ) if( tSegmentToStart == NULL )
{ {
xi1 = tx1; yi1 = ty1; xi1 = tx1; yi1 = ty1;
} }
if ( tSegmentToEnd == NULL ) if( tSegmentToEnd == NULL )
{ {
xi2 = tx2; yi2 = ty2; xi2 = tx2; yi2 = ty2;
} }
if (update) if( update )
{ {
s_LastPos=Pos; s_LastPos = Pos;
Track->m_Start.x = (int) round(xi1); Track->m_Start.x = (int) round( xi1 );
Track->m_Start.y = (int) round(yi1); Track->m_Start.y = (int) round( yi1 );
Track->m_End.x = (int) round(xi2); Track->m_End.x = (int) round( xi2 );
Track->m_End.y = (int) round(yi2); Track->m_End.y = (int) round( yi2 );
if ( tSegmentToEnd ) if( tSegmentToEnd )
{ {
if ( tSegmentToEnd->m_Flags & STARTPOINT ) if( tSegmentToEnd->m_Flags & STARTPOINT )
tSegmentToEnd->m_Start = Track->m_End; tSegmentToEnd->m_Start = Track->m_End;
else tSegmentToEnd->m_End = Track->m_End; else
tSegmentToEnd->m_End = Track->m_End;
} }
if ( tSegmentToStart ) if( tSegmentToStart )
{ {
if ( tSegmentToStart->m_Flags & STARTPOINT ) if( tSegmentToStart->m_Flags & STARTPOINT )
tSegmentToStart->m_Start = Track->m_Start; tSegmentToStart->m_Start = Track->m_Start;
else tSegmentToStart->m_End = Track->m_Start; else
tSegmentToStart->m_End = Track->m_Start;
} }
} }
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 );
} }
/**********************************/ /**********************************/
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 )
return FALSE;
Track = TrackSegWrapper->m_Segm; Track = TrackSegWrapper->m_Segm;
if (Track == NULL ) return FALSE; if( Track == NULL )
return FALSE;
TrackSegWrapper = TrackSegWrapper->Pnext; TrackSegWrapper = TrackSegWrapper->Pnext;
if ( TrackSegWrapper ) if( TrackSegWrapper )
{ {
if ( s_EndSegmentPresent ) if( s_EndSegmentPresent )
{ {
tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment connected to the end point
TrackSegWrapper = TrackSegWrapper->Pnext; TrackSegWrapper = TrackSegWrapper->Pnext;
} }
if ( s_StartSegmentPresent ) if( s_StartSegmentPresent )
{ {
if ( TrackSegWrapper ) if( TrackSegWrapper )
tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point
} }
} }
s_StartPointVertical=false; s_StartPointVertical = false;
s_EndPointVertical=false; s_EndPointVertical = false;
s_MovingSegmentVertical=false; s_MovingSegmentVertical = false;
s_StartPointHorizontal=false; s_StartPointHorizontal = false;
s_EndPointHorizontal=false; s_EndPointHorizontal = false;
s_MovingSegmentHorizontal=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_StartSegmentSlope = (ty2 - ty1) / (tx2 - tx1);
s_StartSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1); s_StartSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1);
} else {
s_StartPointVertical=true; //signal first segment vertical
} }
if (ty1==ty2) { else
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_EndSegmentSlope = (ty2 - ty1) / (tx2 - tx1);
s_EndSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1); s_EndSegment_Yorg = ty1 - (ty2 - ty1) * tx1 / (tx2 - tx1);
} else { }
else
{
s_EndPointVertical = true; //signal second segment vertical s_EndPointVertical = true; //signal second segment vertical
} }
if (ty1==ty2) { if( ty1==ty2 )
{
s_EndPointHorizontal = true; 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); s_MovingSegmentSlope = (ty2 - ty1) / (tx2 - tx1);
} else { }
else
{
s_MovingSegmentVertical = true; //signal vertical line s_MovingSegmentVertical = true; //signal vertical line
} }
if (ty1==ty2) { if( ty1==ty2 )
s_MovingSegmentHorizontal=true; {
s_MovingSegmentHorizontal = true;
} }
// Test if drag is possible: // Test if drag is possible:
if( s_MovingSegmentVertical ) if( s_MovingSegmentVertical )
{ {
if ( s_EndPointVertical || s_StartPointVertical ) return false; if( s_EndPointVertical || s_StartPointVertical )
return false;
} }
else else
{ if ( ! s_EndPointVertical && (s_MovingSegmentSlope == s_EndSegmentSlope) ) return false; {
if ( ! s_StartPointVertical && (s_MovingSegmentSlope == s_StartSegmentSlope) ) return false; if( !s_EndPointVertical && (s_MovingSegmentSlope == s_EndSegmentSlope) )
return false;
if( !s_StartPointVertical && (s_MovingSegmentSlope == s_StartSegmentSlope) )
return false;
} }
return TRUE; 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; NewTrack = NULL;
NbPtNewTrack = 0; NbPtNewTrack = 0;
...@@ -543,51 +609,52 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment(TRACK * track, wxDC * DC, int c ...@@ -543,51 +609,52 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment(TRACK * track, wxDC * DC, int c
/* 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 );
PosInit = GetScreen()->m_Curseur; PosInit = GetScreen()->m_Curseur;
if ( track->m_StructType == TYPEVIA) if( track->m_StructType == TYPEVIA )
{ {
track->m_Flags = IS_DRAGGED|STARTPOINT|ENDPOINT; track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT;
if ( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT ) if( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT )
{ {
Collect_TrackSegmentsToDrag(DrawPanel, DC, track->m_Start, Collect_TrackSegmentsToDrag( DrawPanel, DC, track->m_Start,
track->ReturnMaskLayer(), track->m_NetCode); track->ReturnMaskLayer(), track->m_NetCode );
} }
NewTrack = track; NewTrack = track;
NbPtNewTrack = 1; NbPtNewTrack = 1;
PosInit = track->m_Start; PosInit = track->m_Start;
} }
else else
{ {
int diag = track->IsPointOnEnds(GetScreen()->m_Curseur, -1); int diag = track->IsPointOnEnds( GetScreen()->m_Curseur, -1 );
wxPoint pos; wxPoint pos;
switch ( command )
switch( command )
{ {
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT: case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
track->m_Flags |= IS_DRAGGED|ENDPOINT|STARTPOINT; track->m_Flags |= IS_DRAGGED | ENDPOINT | STARTPOINT;
AddSegmentToDragList(DrawPanel, DC, track->m_Flags, track); AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track );
break; break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
pos = track->m_Start; pos = track->m_Start;
Collect_TrackSegmentsToDrag(DrawPanel, DC, pos, Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->ReturnMaskLayer(), track->m_NetCode); track->ReturnMaskLayer(), track->m_NetCode );
pos = track->m_End; pos = track->m_End;
track->m_Flags |= IS_DRAGGED|ENDPOINT|STARTPOINT; track->m_Flags |= IS_DRAGGED | ENDPOINT | STARTPOINT;
Collect_TrackSegmentsToDrag(DrawPanel, DC, pos, Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->ReturnMaskLayer(), track->m_NetCode); track->ReturnMaskLayer(), track->m_NetCode );
break; break;
case ID_POPUP_PCB_MOVE_TRACK_NODE: case ID_POPUP_PCB_MOVE_TRACK_NODE:
pos = (diag & STARTPOINT) ? track->m_Start : track->m_End; 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 );
PosInit = pos; PosInit = pos;
break; break;
} }
track->m_Flags |= IS_DRAGGED; track->m_Flags |= IS_DRAGGED;
} }
s_LastPos = PosInit; s_LastPos = PosInit;
...@@ -596,61 +663,65 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment(TRACK * track, wxDC * DC, int c ...@@ -596,61 +663,65 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment(TRACK * track, wxDC * DC, int c
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 );
} }
/***********************************************************************************/ /***********************************************************************************/
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) ) if( (track->start == NULL) || (track->start->m_StructType == TYPETRACK) )
TrackToStartPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START); TrackToStartPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START );
// Test if more than one segment is connected to this point // Test if more than one segment is connected to this point
if ( TrackToStartPoint ) if( TrackToStartPoint )
{ {
TrackToStartPoint->SetState(BUSY,ON); TrackToStartPoint->SetState( BUSY, ON );
if ( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START) ) error = TRUE; if( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START ) )
TrackToStartPoint->SetState(BUSY,OFF); error = TRUE;
TrackToStartPoint->SetState( BUSY, OFF );
} }
if ( (track->end == NULL) || (track->end->m_StructType == TYPETRACK) ) if( (track->end == NULL) || (track->end->m_StructType == TYPETRACK) )
TrackToEndPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END); TrackToEndPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END );
// Test if more than one segment is connected to this point // Test if more than one segment is connected to this point
if ( TrackToEndPoint ) if( TrackToEndPoint )
{ {
TrackToEndPoint->SetState(BUSY,ON); TrackToEndPoint->SetState( BUSY, ON );
if ( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END) ) error = TRUE; if( Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END ) )
TrackToEndPoint->SetState(BUSY,OFF); error = TRUE;
TrackToEndPoint->SetState( BUSY, OFF );
} }
if ( error ) if( error )
{ {
DisplayError( this, _("Unable to drag this segment: too many segments connected") ); DisplayError( this, _( "Unable to drag this segment: too many segments connected" ) );
return; return;
} }
if ( !TrackToStartPoint || (TrackToStartPoint->m_StructType != TYPETRACK) ) if( !TrackToStartPoint || (TrackToStartPoint->m_StructType != TYPETRACK) )
s_StartSegmentPresent = FALSE; s_StartSegmentPresent = FALSE;
if ( !TrackToEndPoint || (TrackToEndPoint->m_StructType != TYPETRACK) ) if( !TrackToEndPoint || (TrackToEndPoint->m_StructType != TYPETRACK) )
s_EndSegmentPresent = FALSE; s_EndSegmentPresent = FALSE;
/* 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 );
EraseDragListe(); EraseDragListe();
...@@ -661,62 +732,68 @@ bool error = FALSE; ...@@ -661,62 +732,68 @@ bool error = FALSE;
if( TrackToStartPoint ) if( TrackToStartPoint )
{ {
int flag = STARTPOINT; int flag = STARTPOINT;
if ( track->m_Start != TrackToStartPoint->m_Start ) flag = ENDPOINT; if( track->m_Start != TrackToStartPoint->m_Start )
AddSegmentToDragList(DrawPanel, DC, flag, TrackToStartPoint); flag = ENDPOINT;
AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint );
track->m_Flags |= STARTPOINT; track->m_Flags |= STARTPOINT;
} }
if( TrackToEndPoint ) if( TrackToEndPoint )
{ {
int flag = STARTPOINT; int flag = STARTPOINT;
if ( track->m_End != TrackToEndPoint->m_Start ) flag = ENDPOINT; if( track->m_End != TrackToEndPoint->m_Start )
AddSegmentToDragList(DrawPanel, DC, flag, TrackToEndPoint); flag = ENDPOINT;
AddSegmentToDragList( DrawPanel, DC, flag, TrackToEndPoint );
track->m_Flags |= ENDPOINT; track->m_Flags |= ENDPOINT;
} }
AddSegmentToDragList(DrawPanel, DC, track->m_Flags, track); AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track );
PosInit=GetScreen()->m_Curseur; PosInit = GetScreen()->m_Curseur;
s_LastPos = GetScreen()->m_Curseur; s_LastPos = GetScreen()->m_Curseur;
DrawPanel->ManageCurseur = Show_Drag_Track_Segment_With_Cte_Slope; DrawPanel->ManageCurseur = Show_Drag_Track_Segment_With_Cte_Slope;
DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack; DrawPanel->ForceCloseManageCurseur = Abort_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 );
if ( ! InitialiseDragParameters() ) if( !InitialiseDragParameters() )
{ {
DisplayError( this, _("Unable to drag this segment: two collinear segments") ); DisplayError( this, _( "Unable to drag this segment: two collinear segments" ) );
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
Abort_MoveTrack(DrawPanel, DC); Abort_MoveTrack( DrawPanel, DC );
return; 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 )
return FALSE;
int current_net_code = Track->m_NetCode; int current_net_code = Track->m_NetCode;
// DRC control: // DRC control:
if(Drc_On) if( Drc_On )
{ {
errdrc = Drc(this, DC, Track, m_Pcb->m_Track,1); errdrc = Drc( this, DC, Track, m_Pcb->m_Track, 1 );
if(errdrc == BAD_DRC) return FALSE; if( errdrc == BAD_DRC )
return FALSE;
/* Redraw the dragged segments */ /* Redraw the dragged segments */
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 )
{ {
errdrc = Drc(this, DC, pt_drag->m_Segm, m_Pcb->m_Track,1); errdrc = Drc( this, DC, pt_drag->m_Segm, m_Pcb->m_Track, 1 );
if(errdrc == BAD_DRC) return FALSE; if( errdrc == BAD_DRC )
return FALSE;
} }
} }
...@@ -724,22 +801,23 @@ int current_net_code = Track->m_NetCode; ...@@ -724,22 +801,23 @@ int current_net_code = Track->m_NetCode;
// DRC Ok: place track segments // DRC Ok: place track segments
Track->m_Flags = 0; Track->m_Flags = 0;
Track->SetState(EDIT,OFF); Track->SetState( EDIT, OFF );
Track->Draw(DrawPanel, DC, draw_mode); Track->Draw( DrawPanel, DC, draw_mode );
/* Tracage des segments dragges */ /* Tracage des segments dragges */
pt_drag = g_DragSegmentList; pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext) for( ; pt_drag; pt_drag = pt_drag->Pnext )
{ {
Track = pt_drag->m_Segm; Track = pt_drag->m_Segm;
Track->SetState(EDIT,OFF); Track->SetState( EDIT, OFF );
Track->m_Flags = 0; Track->m_Flags = 0;
Track->Draw(DrawPanel, DC, draw_mode); Track->Draw( DrawPanel, DC, draw_mode );
/* Test the connections modified by the move /* Test the connections modified by the move
(only pad connection must be tested, track connection will be tested by test_1_net_connexion() ) */ * (only pad connection must be tested, track connection will be tested by test_1_net_connexion() ) */
int masque_layer = g_TabOneLayerMask[Track->m_Layer]; int masque_layer = g_TabOneLayerMask[Track->m_Layer];
Track->start = Fast_Locate_Pad_Connecte(m_Pcb, Track->m_Start, masque_layer); Track->start = Fast_Locate_Pad_Connecte( m_Pcb, Track->m_Start, masque_layer );
Track->end = Fast_Locate_Pad_Connecte(m_Pcb, Track->m_End, masque_layer); Track->end = Fast_Locate_Pad_Connecte( m_Pcb, Track->m_End, masque_layer );
} }
EraseDragListe(); EraseDragListe();
...@@ -748,90 +826,97 @@ int current_net_code = Track->m_NetCode; ...@@ -748,90 +826,97 @@ int current_net_code = Track->m_NetCode;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
if ( current_net_code > 0 ) test_1_net_connexion(DC, current_net_code); if( current_net_code > 0 )
test_1_net_connexion( DC, current_net_code );
return TRUE; 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); ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
if( ptsegm == NULL ) if( ptsegm == NULL )
ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask); ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask );
return(ptsegm); 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) )
return NULL;
/* le point n'est pas sur une extremite de piste */ /* le point n'est pas sur une extremite de piste */
if(ptsegm->m_StructType == TYPEVIA ) if( ptsegm->m_StructType == TYPEVIA )
{ {
*pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y; *pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y;
return(ptsegm); return ptsegm;
} }
/* calcul des coord vraies du point intermediaire dans le repere d'origine /* calcul des coord vraies du point intermediaire dans le repere d'origine
= origine de ptsegm */ * = origine de ptsegm */
cX = *pX - ptsegm->m_Start.x; 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;
...@@ -840,31 +925,30 @@ TRACK * NewTrack; ...@@ -840,31 +925,30 @@ TRACK * NewTrack;
} }
/* 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"
...@@ -19,6 +19,7 @@ enum layer_sel_id { ...@@ -19,6 +19,7 @@ enum layer_sel_id {
ID_LAYER_SELECT_TOP, ID_LAYER_SELECT_TOP,
ID_LAYER_SELECT_BOTTOM, ID_LAYER_SELECT_BOTTOM,
ID_LAYER_SELECT ID_LAYER_SELECT
}; };
...@@ -26,79 +27,90 @@ enum layer_sel_id { ...@@ -26,79 +27,90 @@ 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 // Constructor and destructor
WinEDA_SelLayerFrame(WinEDA_BasePcbFrame *parent, int default_layer, WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, int default_layer,
int min_layer, int max_layer); int min_layer, int max_layer );
~WinEDA_SelLayerFrame(void) {}; ~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(); layer = frame->ShowModal(); frame->Destroy();
return layer; 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) )
break;
LayerList[LayerCount] = ReturnPcbLayerName( ii );
if( ii == default_layer )
LayerSelect = LayerCount;
m_LayerId[LayerCount] = ii; m_LayerId[LayerCount] = ii;
LayerCount++; LayerCount++;
} }
...@@ -106,42 +118,45 @@ int LayerCount, LayerSelect = -1; ...@@ -106,42 +118,45 @@ int LayerCount, LayerSelect = -1;
pos.x = 5; pos.y = 5; pos.x = 5; pos.y = 5;
m_LayerList = new wxRadioBox(this, ID_LAYER_SELECT, _("Layer"), m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _( "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 );
if ( LayerSelect >= 0 ) m_LayerList->SetSelection(LayerSelect); if( LayerSelect >= 0 )
m_LayerList->SetSelection( LayerSelect );
m_LayerList->GetSize(&xx, &yy); m_LayerList->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, Button = new wxButton( this, ID_LAYER_CANCEL,
_("Cancel"), pos); _( "Cancel" ), pos );
Button->SetForegroundColour(*wxRED); 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,42 +164,46 @@ void WinEDA_SelLayerFrame::Cancel(wxCommandEvent& event) ...@@ -149,42 +164,46 @@ 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(); frame->ShowModal(); frame->Destroy();
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
SetToolbars(); SetToolbars();
...@@ -192,34 +211,34 @@ void WinEDA_BasePcbFrame::SelectLayerPair(void) ...@@ -192,34 +211,34 @@ void WinEDA_BasePcbFrame::SelectLayerPair(void)
/*******************************************************************************/ /*******************************************************************************/
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++;
...@@ -227,51 +246,48 @@ PCB_SCREEN * screen = (PCB_SCREEN *) m_Parent->m_CurrentScreen; ...@@ -227,51 +246,48 @@ PCB_SCREEN * screen = (PCB_SCREEN *) m_Parent->m_CurrentScreen;
} }
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, Button = new wxButton( this, ID_LAYER_CANCEL, _( "Cancel" ), pos );
_("Cancel"), pos); Button->SetForegroundColour( *wxRED );
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,51 +12,57 @@ ...@@ -12,51 +12,57 @@
#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; Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
for ( ; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) for( ; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
{ {
wxString Line; wxString Line;
/* calcul adr relative du nom de la pastille reference de la piste */ /* calcul adr relative du nom de la pastille reference de la piste */
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE ) ) continue ; if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
continue;
Line.Printf( wxT("net_code = %3.3d [%.16s] "),Equipot->m_NetCode, Line.Printf( wxT( "net_code = %3.3d [%.16s] " ), Equipot->m_NetCode,
Equipot->m_Netname.GetData()); Equipot->m_Netname.GetData() );
List->Append(Line); List->Append( Line );
} }
ii = List->ShowModal(); List->Destroy(); ii = List->ShowModal(); List->Destroy();
if (ii < 0) return; if( ii < 0 )
return;
/* Recherche du numero de net rellement selectionn */ /* Recherche du numero de net rellement selectionn�*/
Equipot = (EQUIPOT*) m_Pcb->m_Equipots; Equipot = (EQUIPOT*) m_Pcb->m_Equipots;
for ( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*)Equipot->Pnext ) for( jj = 0; Equipot != NULL; Equipot = (EQUIPOT*) Equipot->Pnext )
{ {
/* calcul adr relative du nom de la pastille reference de la piste */ /* calcul adr relative du nom de la pastille reference de la piste */
if( ! WildCompareString(msg, Equipot->m_Netname, FALSE) ) continue ; if( !WildCompareString( msg, Equipot->m_Netname, FALSE ) )
if ( ii == jj ) continue;
if( ii == jj )
{ {
ii = Equipot->m_NetCode; ii = Equipot->m_NetCode;
break; break;
...@@ -64,41 +70,44 @@ int ii, jj; ...@@ -64,41 +70,44 @@ int ii, jj;
jj++; jj++;
} }
wxClientDC dc( DrawPanel );
wxClientDC dc(DrawPanel); DrawPanel->PrepareGraphicContext( &dc );
DrawPanel->PrepareGraphicContext(&dc);
if(g_HightLigt_Status) Hight_Light(&dc); if( g_HightLigt_Status )
Hight_Light( &dc );
g_HightLigth_NetCode = ii; g_HightLigth_NetCode = ii;
Hight_Light(&dc); 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; code = g_HightLigth_NetCode = pt_piste->m_NetCode;
Hight_Light(DC); Hight_Light( DC );
} }
else else
{ {
pt_pad = Locate_Any_Pad(m_Pcb, CURSEUR_OFF_GRILLE); pt_pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE );
if( pt_pad != NULL ) if( pt_pad != NULL )
{ {
code = g_HightLigth_NetCode = pt_pad->m_NetCode ; code = g_HightLigth_NetCode = pt_pad->m_NetCode;
Hight_Light(DC) ; Hight_Light( DC );
} }
} }
...@@ -107,65 +116,67 @@ int code = -1; ...@@ -107,65 +116,67 @@ int code = -1;
/*******************************************/ /*******************************************/
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
draw_mode = GR_AND | GR_SURBRILL;
Module = m_Pcb->m_Modules; Module = m_Pcb->m_Modules;
/* Redraw pads */ /* Redraw pads */
for( ; Module != NULL; Module = (MODULE*) Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
Pad_Surbrillance(DrawPanel, DC, Module, NetCode) ; Pad_Surbrillance( DrawPanel, DC, Module, NetCode );
} }
/* Redraw track and vias: */ /* Redraw track and vias: */
for ( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext) for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext )
{ {
if( pts->m_NetCode == NetCode ) if( pts->m_NetCode == NetCode )
{ {
pts->Draw(DrawPanel, DC, draw_mode); 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,11 +36,11 @@ ...@@ -35,11 +36,11 @@
////@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;
...@@ -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,21 +77,33 @@ END_EVENT_TABLE() ...@@ -76,21 +77,33 @@ 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;
...@@ -98,126 +111,163 @@ bool WinEDA_ZoneFrame::Create( wxWindow* parent, wxWindowID id, const wxString& ...@@ -98,126 +111,163 @@ bool WinEDA_ZoneFrame::Create( wxWindow* parent, wxWindowID id, const wxString&
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_ClearanceValueTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Zone clearance value (mm):"), wxDefaultPosition, wxDefaultSize, 0 ); m_GridCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _(
itemBoxSizer3->Add(m_ClearanceValueTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); "Grid size:" ), wxDefaultPosition, wxDefaultSize, 4,
m_GridCtrlStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer3->Add( m_GridCtrl, 0, wxALIGN_LEFT | wxALL, 5 );
m_ClearanceValueTitle = new wxStaticText( itemDialog1, wxID_STATIC,
_("Zone clearance value (mm):"),
wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer3->Add( m_ClearanceValueTitle,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_ZoneClearanceCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); m_ZoneClearanceCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(
itemBoxSizer3->Add(m_ZoneClearanceCtrl, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); "" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer3->Add( m_ZoneClearanceCtrl, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); itemBoxSizer2->Add( 5, 5, 0, wxGROW | wxALL, 5 );
wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer8 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer2->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5); itemBoxSizer2->Add( itemBoxSizer8, 0, wxGROW | wxALL, 5 );
wxString m_FillOptStrings[] = { static const wxString m_FillOptStrings[] = {
_("Include Pads"), _( "Include Pads" ),
_("Thermal"), _( "Thermal" ),
_("Exclude Pads") _( "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);
wxString m_OrientEdgesOptStrings[] = { m_FillOpt = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _(
_("Any"), "Pad options:" ), wxDefaultPosition, wxDefaultSize, 3,
_("H , V and 45 deg") m_FillOptStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer8->Add( m_FillOpt, 0, wxALIGN_LEFT | wxALL, 5 );
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);
itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); 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 );
itemBoxSizer2->Add( 5, 5, 0, wxGROW | wxALL, 5 );
wxBoxSizer* itemBoxSizer12 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer2->Add( itemBoxSizer12, 0, wxALIGN_TOP | wxALL, 5 );
wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL); wxButton* itemButton13 = new wxButton( itemDialog1, ID_FILL_ZONE,
itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_TOP|wxALL, 5); _("Fill"), wxDefaultPosition, wxDefaultSize, 0 );
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);
wxButton* itemButton15 = new wxButton( itemDialog1, ID_SET_OPTIONS_ZONE, _("Update Options"), wxDefaultPosition, wxDefaultSize, 0 ); itemButton14->SetForegroundColour( wxColour( 0, 0, 255 ) );
itemButton15->SetForegroundColour(wxColour(0, 100, 0)); itemBoxSizer12->Add( itemButton14, 0, wxGROW | wxALL, 5 );
itemBoxSizer12->Add(itemButton15, 0, wxGROW|wxALL, 5);
itemBoxSizer2->Add(5, 5, 0, wxGROW|wxALL, 5); wxButton* itemButton15 = new wxButton( itemDialog1, ID_SET_OPTIONS_ZONE,
_("Update Options" ), wxDefaultPosition, wxDefaultSize, 0 );
itemButton15->SetForegroundColour( wxColour( 0, 100, 0 ) );
itemBoxSizer12->Add( itemButton15, 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,
g_DesignSettings.m_ZoneClearence,
m_Parent->m_InternalUnits );
m_ZoneClearanceCtrl->SetValue( title ); m_ZoneClearanceCtrl->SetValue( title );
if ( Zone_45_Only ) m_OrientEdgesOpt->SetSelection(1); if( Zone_45_Only )
m_OrientEdgesOpt->SetSelection( 1 );
static const int GridList[4] = { 50, 100, 250, 500 };
int selection = 0;
int GridList[4] = { 50,100,250,500}, selection = 0; for( unsigned ii = 0; ii < m_GridCtrl->GetCount(); ii++ )
for ( unsigned ii = 0; ii < m_GridCtrl->GetCount(); ii++ )
{ {
wxString msg = ReturnStringFromValue(g_UnitMetric, GridList[ii], m_Parent->m_InternalUnits); wxString msg = ReturnStringFromValue( g_UnitMetric,
m_GridCtrl->SetString(ii,msg); GridList[ii],
if ( g_GridRoutingSize == GridList[ii] ) selection = ii; m_Parent->m_InternalUnits );
m_GridCtrl->SetString( ii, msg );
if( g_GridRoutingSize == GridList[ii] )
selection = ii;
} }
m_GridCtrl->SetSelection(selection);
if ( Zone_Exclude_Pads) m_GridCtrl->SetSelection( selection );
if( Zone_Exclude_Pads )
{ {
if ( Zone_Genere_Freins_Thermiques ) m_FillOpt->SetSelection(1); if( Zone_Genere_Freins_Thermiques )
else m_FillOpt->SetSelection(2); 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,10 +326,10 @@ void WinEDA_ZoneFrame::OnCancelClick( wxCommandEvent& event ) ...@@ -270,10 +326,10 @@ 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;
...@@ -291,7 +347,7 @@ void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent & event) ...@@ -291,7 +347,7 @@ void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent & event)
break; break;
} }
switch ( m_GridCtrl->GetSelection() ) switch( m_GridCtrl->GetSelection() )
{ {
case 0: case 0:
g_GridRoutingSize = 50; g_GridRoutingSize = 50;
...@@ -312,54 +368,66 @@ void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent & event) ...@@ -312,54 +368,66 @@ void WinEDA_ZoneFrame::ExecFillZone( wxCommandEvent & event)
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
Zone_45_Only = TRUE;
if ( event.GetId() == ID_SET_OPTIONS_ZONE ) EndModal(1); if( event.GetId() == ID_SET_OPTIONS_ZONE )
else EndModal(0); 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() );
f_new_width = To_User_Unit(g_UnitMetric, Zone->m_Width, GetScreen()->GetInternalUnits()); Line.Printf( wxT( "%.4f" ), f_new_width );
Line.Printf(wxT("%.4f"), f_new_width);
Msg += g_UnitMetric ? wxT("(mm)") : wxT("(\")"); Msg += g_UnitMetric ? wxT( "(mm)" ) : wxT( "(\")" );
if ( Get_Message(Msg, Line, this) != 0 ) return; if( Get_Message( Msg, Line, this ) != 0 )
return;
w_tmp = g_DesignSettings.m_CurrentTrackWidth; w_tmp = g_DesignSettings.m_CurrentTrackWidth;
Line.ToDouble( &f_new_width); Line.ToDouble( &f_new_width );
g_DesignSettings.m_CurrentTrackWidth = From_User_Unit(g_UnitMetric, f_new_width, GetScreen()->GetInternalUnits());
g_DesignSettings.m_CurrentTrackWidth = From_User_Unit( g_UnitMetric,
f_new_width, GetScreen()->GetInternalUnits() );
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;
Edit_TrackSegm_Width(DC, pt_segm); Edit_TrackSegm_Width( DC, pt_segm );
} }
} }
g_DesignSettings.m_CurrentTrackWidth = w_tmp; g_DesignSettings.m_CurrentTrackWidth = w_tmp;
if ( modify ) if( modify )
{ {
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->Refresh(); DrawPanel->Refresh();
...@@ -367,34 +435,34 @@ wxString Msg( _("New zone segment width: ") ); ...@@ -367,34 +435,34 @@ wxString Msg( _("New zone segment width: ") );
} }
/**********************************************************/ /**********************************************************/
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();
...@@ -403,20 +471,23 @@ bool modify = FALSE; ...@@ -403,20 +471,23 @@ bool modify = FALSE;
/*****************************************************************************/ /*****************************************************************************/
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
Segm = edge_zone;
if( Segm == NULL) return NULL; if( Segm == NULL )
return NULL;
Trace_DrawSegmentPcb(DrawPanel, DC, Segm, GR_XOR); Trace_DrawSegmentPcb( DrawPanel, DC, Segm, GR_XOR );
previous_segm = (EDGE_ZONE *)Segm->Pback; previous_segm = (EDGE_ZONE*) Segm->Pback;
delete Segm; delete Segm;
Segm = previous_segm; Segm = previous_segm;
...@@ -426,8 +497,8 @@ EDGE_ZONE * Segm, * previous_segm; ...@@ -426,8 +497,8 @@ EDGE_ZONE * Segm, * previous_segm;
if( Segm ) if( Segm )
{ {
Segm->Pnext = NULL; Segm->Pnext = NULL;
if( DrawPanel->ManageCurseur) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE); DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
} }
else else
{ {
...@@ -440,132 +511,145 @@ EDGE_ZONE * Segm, * previous_segm; ...@@ -440,132 +511,145 @@ EDGE_ZONE * Segm, * previous_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 */ /* Affichage du net selectionne pour la zone a tracer */
Display_Zone_Netname(this); 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 ) if( pt_equipot )
{ {
line.Printf( wxT("Zone: Net[%d] <%s>"),g_HightLigth_NetCode, line.Printf( wxT( "Zone: Net[%d] <%s>" ), g_HightLigth_NetCode,
pt_equipot->m_Netname.GetData()); pt_equipot->m_Netname.GetData() );
} }
else line.Printf( wxT("Zone: NetCode[%d], Equipot not found"), else
g_HightLigth_NetCode); line.Printf( wxT( "Zone: NetCode[%d], Equipot not found" ),
g_HightLigth_NetCode );
} }
line = _("Zone: No net selected"); line = _( "Zone: No net selected" );
frame->Affiche_Message(line); 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;
if ( ! IsOK(this, _("Delete Current Zone Edges")) ) return;
/* efface ancienne limite de zone */ /* efface ancienne limite de zone */
segment = m_Pcb->m_CurrentLimitZone; segment = m_Pcb->m_CurrentLimitZone;
for( ; segment != NULL; segment = Next) for( ; segment != NULL; segment = Next )
{ {
Next = (EDGE_ZONE*) segment->Pback; Next = (EDGE_ZONE*) segment->Pback;
if ( Redraw ) Trace_DrawSegmentPcb(DrawPanel, DC, segment,GR_XOR); if( Redraw )
Trace_DrawSegmentPcb( DrawPanel, DC, segment, GR_XOR );
segment->Pnext = NULL; delete segment; segment->Pnext = NULL; delete segment;
} }
...@@ -573,42 +657,44 @@ EDGE_ZONE * segment, * Next; ...@@ -573,42 +657,44 @@ EDGE_ZONE * segment, * Next;
m_Pcb->m_CurrentLimitZone = 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 )
oldedge->Pnext = newedge;
newedge->m_Layer = GetScreen()->m_Active_Layer; newedge->m_Layer = GetScreen()->m_Active_Layer;
newedge->m_Width = 2 ; /* Largeur minimum tracable */ newedge->m_Width = 2; /* Largeur minimum tracable */
newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur; newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur;
m_Pcb->m_CurrentLimitZone = newedge; m_Pcb->m_CurrentLimitZone = newedge;
DrawPanel->ManageCurseur = Show_Zone_Edge_While_MoveMouse; DrawPanel->ManageCurseur = Show_Zone_Edge_While_MoveMouse;
DrawPanel->ForceCloseManageCurseur = Exit_Zones; 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;
...@@ -621,14 +707,16 @@ EDGE_ZONE * oldedge, * newedge = NULL; ...@@ -621,14 +707,16 @@ EDGE_ZONE * oldedge, * newedge = NULL;
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 )
{ {
...@@ -637,20 +725,21 @@ EDGE_ZONE * PtLim; ...@@ -637,20 +725,21 @@ EDGE_ZONE * PtLim;
/* 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); PtLim->m_Flags &= ~(IS_NEW | IS_MOVED);
m_Pcb->m_CurrentLimitZone->m_End = PtLim->m_Start; 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->ManageCurseur = NULL;
...@@ -659,40 +748,42 @@ EDGE_ZONE * PtLim; ...@@ -659,40 +748,42 @@ EDGE_ZONE * PtLim;
/******************************************************************************************/ /******************************************************************************************/
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 */ /* efface ancienne position si elle a ete deja dessinee */
if( erase ) if( erase )
{ {
PtLim = pcbframe->m_Pcb->m_CurrentLimitZone; PtLim = pcbframe->m_Pcb->m_CurrentLimitZone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) 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 */ /* mise a jour de la couche */
edgezone = PtLim = pcbframe->m_Pcb->m_CurrentLimitZone; edgezone = PtLim = pcbframe->m_Pcb->m_CurrentLimitZone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) 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 */ /* dessin de la nouvelle piste : mise a jour du point d'arrivee */
if (Zone_45_Only) if( Zone_45_Only )
{/* Calcul de l'extremite de la piste pour orientations permises: {/* Calcul de l'extremite de la piste pour orientations permises:
horiz,vertical ou 45 degre */ * horiz,vertical ou 45 degre */
edgezone->m_End = pcbframe->GetScreen()->m_Curseur; edgezone->m_End = pcbframe->GetScreen()->m_Curseur;
Calcule_Coord_Extremite_45(edgezone->m_Start.x, edgezone->m_Start.y, Calcule_Coord_Extremite_45( edgezone->m_Start.x, edgezone->m_Start.y,
&edgezone->m_End.x, &edgezone->m_End.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 */
{ {
...@@ -700,218 +791,237 @@ WinEDA_PcbFrame * pcbframe = (WinEDA_PcbFrame *) panel->m_Parent; ...@@ -700,218 +791,237 @@ WinEDA_PcbFrame * pcbframe = (WinEDA_PcbFrame *) panel->m_Parent;
} }
PtLim = edgezone; PtLim = edgezone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) 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
On place la zone sur la couche (layer) active.
"Hight Light" la zone fera partie de ce net /*
*/ * 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
*
*
* 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 */ /* mise a jour de la couche */
PtLim = m_Pcb->m_CurrentLimitZone; PtLim = m_Pcb->m_CurrentLimitZone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback) for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
{ {
Trace_DrawSegmentPcb(DrawPanel, DC, PtLim, GR_XOR); Trace_DrawSegmentPcb( DrawPanel, DC, PtLim, GR_XOR );
PtLim->m_Layer = GetScreen()->m_Active_Layer; PtLim->m_Layer = GetScreen()->m_Active_Layer;
Trace_DrawSegmentPcb(DrawPanel, DC, PtLim, GR_XOR); 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 */ /* Calcul du pas de routage fixe a 5 mils et plus */
E_scale = g_GridRoutingSize / 50 ; if (g_GridRoutingSize < 1 ) g_GridRoutingSize = 1 ; E_scale = g_GridRoutingSize / 50; if( g_GridRoutingSize < 1 )
g_GridRoutingSize = 1;
/* calcule de Ncols et Nrow, taille de la matrice de routage */ /* calcule de Ncols et Nrow, taille de la matrice de routage */
ComputeMatriceSize(this, g_GridRoutingSize); ComputeMatriceSize( this, g_GridRoutingSize );
/* Determination de la cellule pointee par la souris */ /* Determination de la cellule pointee par la souris */
ZoneStartFill.x = (GetScreen()->m_Curseur.x - m_Pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize/2) ) / g_GridRoutingSize; ZoneStartFill.x = ( GetScreen()->m_Curseur.x - m_Pcb->m_BoundaryBox.m_Pos.x +
ZoneStartFill.y = (GetScreen()->m_Curseur.y - m_Pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize/2) ) / g_GridRoutingSize; (g_GridRoutingSize / 2) ) / g_GridRoutingSize;
if(ZoneStartFill.x < 0) ZoneStartFill.x = 0; ZoneStartFill.y = ( GetScreen()->m_Curseur.y - m_Pcb->m_BoundaryBox.m_Pos.y +
if(ZoneStartFill.x >= Ncols) ZoneStartFill.x = Ncols-1; (g_GridRoutingSize / 2) ) / g_GridRoutingSize;
if(ZoneStartFill.y < 0) ZoneStartFill.y = 0; if( ZoneStartFill.x < 0 )
if(ZoneStartFill.y >= Nrows) ZoneStartFill.y = Nrows-1; ZoneStartFill.x = 0;
if( ZoneStartFill.x >= Ncols )
ZoneStartFill.x = Ncols - 1;
if( ZoneStartFill.y < 0 )
ZoneStartFill.y = 0;
if( ZoneStartFill.y >= Nrows )
ZoneStartFill.y = Nrows - 1;
/* Creation du mapping de la matrice de routage */ /* Creation du mapping de la matrice de routage */
Nb_Sides = ONE_SIDE; Nb_Sides = ONE_SIDE;
if( Board.InitBoard() < 0) if( Board.InitBoard() < 0 )
{ {
DisplayError(this, wxT("Mo memory for creating zones")); DisplayError( this, wxT( "Mo memory for creating zones" ) );
return; return;
} }
msg.Printf( wxT("%d"),Ncols); msg.Printf( wxT( "%d" ), Ncols );
Affiche_1_Parametre(this, 1, wxT("Cols"),msg,GREEN); Affiche_1_Parametre( this, 1, wxT( "Cols" ), msg, GREEN );
msg.Printf( wxT("%d"),Nrows); msg.Printf( wxT( "%d" ), Nrows );
Affiche_1_Parametre(this, 7, wxT("Lines"),msg,GREEN); Affiche_1_Parametre( this, 7, wxT( "Lines" ), msg, GREEN );
msg.Printf( wxT("%d"), Board.m_MemSize / 1024 ); msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
Affiche_1_Parametre(this, 14, wxT("Mem(Ko)"),msg,CYAN); Affiche_1_Parametre( this, 14, wxT( "Mem(Ko)" ), msg, CYAN );
lay_tmp_BOTTOM = Route_Layer_BOTTOM; lay_tmp_BOTTOM = Route_Layer_BOTTOM;
lay_tmp_TOP = Route_Layer_TOP; lay_tmp_TOP = Route_Layer_TOP;
Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer; Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer;
lp_tmp = g_DesignSettings.m_CurrentTrackWidth; g_DesignSettings.m_CurrentTrackWidth = g_GridRoutingSize; lp_tmp = g_DesignSettings.m_CurrentTrackWidth;
g_DesignSettings.m_CurrentTrackWidth = g_GridRoutingSize;
/* Affichage du NetName */ /* Affichage du NetName */
if(g_HightLigth_NetCode > 0) if( g_HightLigth_NetCode > 0 )
{ {
pt_equipot = GetEquipot(m_Pcb, g_HightLigth_NetCode); pt_equipot = GetEquipot( m_Pcb, g_HightLigth_NetCode );
if( pt_equipot == NULL) if( pt_equipot == NULL )
{ {
if(g_HightLigth_NetCode > 0 ) DisplayError(this, wxT("Equipot Error")); if( g_HightLigth_NetCode > 0 )
DisplayError( this, wxT( "Equipot Error" ) );
} }
else msg = pt_equipot->m_Netname; else
msg = pt_equipot->m_Netname;
} }
else msg = _("No Net"); else
msg = _( "No Net" );
Affiche_1_Parametre(this, 22,_("NetName"),msg,RED) ; Affiche_1_Parametre( this, 22, _( "NetName" ), msg, RED );
/* Init des points d'accrochage possibles de la zone: /* Init des points d'accrochage possibles de la zone:
les pistes du net sont des points d'accrochage convenables*/ * les pistes du net sont des points d'accrochage convenables*/
TRACK * pt_segm = m_Pcb->m_Track; TRACK* pt_segm = m_Pcb->m_Track;
for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext) for( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext )
{ {
if(g_HightLigth_NetCode != pt_segm->m_NetCode) continue; if( g_HightLigth_NetCode != pt_segm->m_NetCode )
if ( pt_segm->m_Layer != GetScreen()->m_Active_Layer ) continue; continue;
if (pt_segm->m_StructType != TYPETRACK ) continue; if( pt_segm->m_Layer != GetScreen()->m_Active_Layer )
TraceSegmentPcb(m_Pcb, pt_segm, CELL_is_FRIEND, 0, WRITE_CELL ); continue;
if( pt_segm->m_StructType != TYPETRACK )
continue;
TraceSegmentPcb( m_Pcb, pt_segm, CELL_is_FRIEND, 0, WRITE_CELL );
} }
/* Trace des contours du PCB sur la matrice de routage: */ /* Trace des contours du PCB sur la matrice de routage: */
Route_Layer_BOTTOM = Route_Layer_TOP = EDGE_N; Route_Layer_BOTTOM = Route_Layer_TOP = EDGE_N;
PlaceCells(m_Pcb, -1, 0); PlaceCells( m_Pcb, -1, 0 );
Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer; Route_Layer_BOTTOM = Route_Layer_TOP = GetScreen()->m_Active_Layer;
/* Trace des limites de la zone sur la matrice de routage: */ /* Trace des limites de la zone sur la matrice de routage: */
PtLim = m_Pcb->m_CurrentLimitZone; PtLim = m_Pcb->m_CurrentLimitZone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*)PtLim->Pback) for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
{ {
int ux0, uy0, ux1, uy1; int ux0, uy0, ux1, uy1;
ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x; ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x;
uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y; uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y;
ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x; ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x;
uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y; uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y;
TraceLignePcb(ux0,uy0,ux1,uy1,-1,HOLE|CELL_is_EDGE,WRITE_CELL); TraceLignePcb( ux0, uy0, ux1, uy1, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
} }
OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
OrCell(ZoneStartFill.y,ZoneStartFill.x, BOTTOM, CELL_is_ZONE);
/* Marquage des cellules faisant partie de la zone*/ /* Marquage des cellules faisant partie de la zone*/
ii = 1; jj = 1; ii = 1; jj = 1;
while( ii ) while( ii )
{ {
msg.Printf( wxT("%d"), jj++ ); msg.Printf( wxT( "%d" ), jj++ );
Affiche_1_Parametre(this, 50, wxT("Iter."),msg,CYAN); Affiche_1_Parametre( this, 50, wxT( "Iter." ), msg, CYAN );
ii = Propagation(this); ii = Propagation( this );
} }
/* Selection des cellules convenables pour les points d'ancrage de la zone */ /* Selection des cellules convenables pour les points d'ancrage de la zone */
for( ii = 0; ii < Nrows ; ii++) for( ii = 0; ii < Nrows; ii++ )
{ {
for( jj = 0; jj < Ncols ; jj++) for( jj = 0; jj < Ncols; jj++ )
{ {
long cell = GetCell(ii,jj,BOTTOM); long cell = GetCell( ii, jj, BOTTOM );
if( (cell & CELL_is_ZONE) ) if( (cell & CELL_is_ZONE) )
{ {
if ( (cell & CELL_is_FRIEND) == 0) if( (cell & CELL_is_FRIEND) == 0 )
AndCell(ii,jj,BOTTOM, (BoardCell) ~(CELL_is_FRIEND|CELL_is_ZONE) ); 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) /* Placement des cellules (pads, tracks, vias, edges pcb ou segments)
faisant des obsctacles sur la matrice de routage */ * faisant des obsctacles sur la matrice de routage */
ii = 0; ii = 0;
if( Zone_Exclude_Pads ) ii = FORCE_PADS; if( Zone_Exclude_Pads )
Affiche_1_Parametre(this, 42, wxT("GenZone"),wxEmptyString,RED); ii = FORCE_PADS;
PlaceCells(m_Pcb, g_HightLigth_NetCode, ii);
Affiche_1_Parametre(this, -1, wxEmptyString, _("Ok"),RED); Affiche_1_Parametre( this, 42, wxT( "GenZone" ), wxEmptyString, RED );
PlaceCells( m_Pcb, g_HightLigth_NetCode, ii );
Affiche_1_Parametre( this, -1, wxEmptyString, _( "Ok" ), RED );
/* Trace des limites de la zone sur la matrice de routage /* Trace des limites de la zone sur la matrice de routage
(a pu etre detruit par PlaceCells()) : */ * (a pu etre detruit par PlaceCells()) : */
PtLim = m_Pcb->m_CurrentLimitZone; PtLim = m_Pcb->m_CurrentLimitZone;
for( ; PtLim != NULL; PtLim = (EDGE_ZONE*)PtLim->Pback) for( ; PtLim != NULL; PtLim = (EDGE_ZONE*) PtLim->Pback )
{ {
int ux0, uy0, ux1, uy1; int ux0, uy0, ux1, uy1;
ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x; ux0 = PtLim->m_Start.x - m_Pcb->m_BoundaryBox.m_Pos.x;
uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y; uy0 = PtLim->m_Start.y - m_Pcb->m_BoundaryBox.m_Pos.y;
ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x; ux1 = PtLim->m_End.x - m_Pcb->m_BoundaryBox.m_Pos.x;
uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y; uy1 = PtLim->m_End.y - m_Pcb->m_BoundaryBox.m_Pos.y;
TraceLignePcb(ux0,uy0,ux1,uy1,-1,HOLE|CELL_is_EDGE,WRITE_CELL); 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 /* Init du point d'accrochage de la zone donné par la position souris
(a pu etre detruit par PlaceCells()) : */ * (a pu etre detruit par PlaceCells()) : */
OrCell(ZoneStartFill.y,ZoneStartFill.x, BOTTOM, CELL_is_ZONE); OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
if(Zone_Debug) DisplayBoard(DrawPanel, DC); if( Zone_Debug )
DisplayBoard( DrawPanel, DC );
/* Remplissage des cellules (creation effective de la zone)*/ /* Remplissage des cellules (creation effective de la zone)*/
ii = 1; jj = 1; ii = 1; jj = 1;
while( ii ) while( ii )
{ {
msg.Printf( wxT("%d"), jj++ ); msg.Printf( wxT( "%d" ), jj++ );
Affiche_1_Parametre(this, 50, wxT("Iter."),msg,CYAN); Affiche_1_Parametre( this, 50, wxT( "Iter." ), msg, CYAN );
ii = Propagation(this); ii = Propagation( this );
} }
if(Zone_Debug) DisplayBoard(DrawPanel, DC); if( Zone_Debug )
DisplayBoard( DrawPanel, DC );
/* Generation des segments de piste type Zone correspondants*/ /* Generation des segments de piste type Zone correspondants*/
if(g_HightLigth_NetCode < 0 ) if( g_HightLigth_NetCode < 0 )
Genere_Segments_Zone(this, DC, 0); Genere_Segments_Zone( this, DC, 0 );
else Genere_Segments_Zone(this, DC, g_HightLigth_NetCode); else
Genere_Segments_Zone( this, DC, g_HightLigth_NetCode );
/* Trace des connexions type frein thermique */ /* Trace des connexions type frein thermique */
g_DesignSettings.m_CurrentTrackWidth = lp_tmp; g_DesignSettings.m_CurrentTrackWidth = lp_tmp;
if ( Zone_Exclude_Pads && Zone_Genere_Freins_Thermiques) if( Zone_Exclude_Pads && Zone_Genere_Freins_Thermiques )
Genere_Pad_Connexion(this, DC, GetScreen()->m_Active_Layer); Genere_Pad_Connexion( this, DC, GetScreen()->m_Active_Layer );
g_DesignSettings.m_TrackClearence = save_isol; g_DesignSettings.m_TrackClearence = save_isol;
...@@ -927,153 +1037,163 @@ wxString msg; ...@@ -927,153 +1037,163 @@ wxString msg;
/*******************************************************************************/ /*******************************************************************************/
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) ) if( (old_cell) && (ux0 != ux1) )
{ /* un segment avait debute de longueur > 0 */ {
pt_track = new SEGZONE(frame->m_Pcb); /* un segment avait debute de longueur > 0 */
pt_track = new SEGZONE( frame->m_Pcb );
pt_track->m_Layer = layer; pt_track->m_Layer = layer;
pt_track->m_NetCode = net_code; pt_track->m_NetCode = net_code;
pt_track->m_Width = g_GridRoutingSize; pt_track->m_Width = g_GridRoutingSize;
pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; 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_End.x = ux1; pt_track->m_End.y = uy1;
pt_track->m_TimeStamp = s_TimeStamp; pt_track->m_TimeStamp = s_TimeStamp;
pt_track->Insert(frame->m_Pcb, NULL); pt_track->Insert( frame->m_Pcb, NULL );
pt_track->Draw(frame->DrawPanel, DC, GR_OR); pt_track->Draw( frame->DrawPanel, DC, GR_OR );
nbsegm++; nbsegm++;
} }
} }
old_cell = current_cell; old_cell = current_cell;
} }
msg.Printf( wxT("%d"),nbsegm);
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,BROWN); msg.Printf( wxT( "%d" ), nbsegm );
Affiche_1_Parametre( frame, -1, wxEmptyString, msg, BROWN );
} }
Affiche_1_Parametre(frame, 72, wxT("Segm V"), wxT("0"),BROWN); Affiche_1_Parametre( frame, 72, wxT( "Segm V" ), wxT( "0" ), BROWN );
for( col = 0; col < Ncols ; col++) for( col = 0; col < Ncols; col++ )
{ {
old_cell = 0; old_cell = 0;
ux0 = ux1 = (col * g_GridRoutingSize) + Xmin; ux0 = ux1 = (col * g_GridRoutingSize) + Xmin;
for( row = 0; row < Nrows ; row++) for( row = 0; row < Nrows; row++ )
{ {
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 */
{ {
uy1 = (row * g_GridRoutingSize) + Ymin; uy1 = (row * g_GridRoutingSize) + Ymin;
if( old_cell == 0 ) uy0 = uy1; if( old_cell == 0 )
uy0 = uy1;
} }
if( ! current_cell || (row == Nrows-1) ) /* peut etre fin d'un segment */ if( !current_cell || (row == Nrows - 1) ) /* peut etre fin d'un segment */
{ {
if( (old_cell) && (uy0 != uy1) ) if( (old_cell) && (uy0 != uy1) )
{ /* un segment avait debute de longueur > 0 */ {
pt_track = new SEGZONE(frame->m_Pcb); /* un segment avait debute de longueur > 0 */
pt_track = new SEGZONE( frame->m_Pcb );
pt_track->m_Layer = layer; pt_track->m_Layer = layer;
pt_track->m_Width = g_GridRoutingSize; pt_track->m_Width = g_GridRoutingSize;
pt_track->m_NetCode = net_code; pt_track->m_NetCode = net_code;
pt_track->m_Start.x = ux0; pt_track->m_Start.y = uy0; 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_End.x = ux1; pt_track->m_End.y = uy1;
pt_track->m_TimeStamp = s_TimeStamp; pt_track->m_TimeStamp = s_TimeStamp;
pt_track->Insert(frame->m_Pcb, NULL); pt_track->Insert( frame->m_Pcb, NULL );
pt_track->Draw(frame->DrawPanel, DC, GR_OR); pt_track->Draw( frame->DrawPanel, DC, GR_OR );
nbsegm++; nbsegm++;
} }
} }
old_cell = current_cell; old_cell = current_cell;
} }
msg.Printf( wxT("%d"),nbsegm);
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,BROWN); 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; old_cell_H = 0;
for( col = 0; col < Ncols ; col++) for( col = 0; col < Ncols; col++ )
{ {
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE; current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
{ {
if( (old_cell_H & CELL_is_ZONE) if( (old_cell_H & CELL_is_ZONE)
|| (pt_cell_V[col] & CELL_is_ZONE) ) || (pt_cell_V[col] & CELL_is_ZONE) )
{ {
OrCell(row,col,BOTTOM,CELL_is_ZONE); OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE; current_cell = CELL_is_ZONE;
nbpoints++; nbpoints++;
} }
...@@ -1083,20 +1203,20 @@ wxString msg; ...@@ -1083,20 +1203,20 @@ wxString msg;
} }
/* balayage Droite-> gauche de Haut->bas */ /* balayage Droite-> gauche de Haut->bas */
Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("2"),CYAN); Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "2" ), CYAN );
memset(pt_cell_V, 0, nn); memset( pt_cell_V, 0, nn );
for( row = 0; row < Nrows ; row++) for( row = 0; row < Nrows; row++ )
{ {
old_cell_H = 0; old_cell_H = 0;
for( col = Ncols -1 ; col >= 0 ; col--) for( col = Ncols - 1; col >= 0; col-- )
{ {
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
{ {
if( (old_cell_H & CELL_is_ZONE) if( (old_cell_H & CELL_is_ZONE)
|| (pt_cell_V[col] & CELL_is_ZONE) ) || (pt_cell_V[col] & CELL_is_ZONE) )
{ {
OrCell(row,col,BOTTOM,CELL_is_ZONE); OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE; current_cell = CELL_is_ZONE;
nbpoints++; nbpoints++;
} }
...@@ -1106,20 +1226,20 @@ wxString msg; ...@@ -1106,20 +1226,20 @@ wxString msg;
} }
/* balayage Bas->Haut de Droite->gauche */ /* balayage Bas->Haut de Droite->gauche */
Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("3"),CYAN); Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "3" ), CYAN );
memset(pt_cell_V, 0, nn); memset( pt_cell_V, 0, nn );
for( col = Ncols -1 ; col >= 0 ; col--) for( col = Ncols - 1; col >= 0; col-- )
{ {
old_cell_H = 0; old_cell_H = 0;
for( row = Nrows-1; row >= 0 ; row--) for( row = Nrows - 1; row >= 0; row-- )
{ {
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
{ {
if( (old_cell_H & CELL_is_ZONE) if( (old_cell_H & CELL_is_ZONE)
|| (pt_cell_V[row] & CELL_is_ZONE) ) || (pt_cell_V[row] & CELL_is_ZONE) )
{ {
OrCell(row,col,BOTTOM,CELL_is_ZONE); OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE; current_cell = CELL_is_ZONE;
nbpoints++; nbpoints++;
} }
...@@ -1129,20 +1249,20 @@ wxString msg; ...@@ -1129,20 +1249,20 @@ wxString msg;
} }
/* balayage Bas->Haut de Gauche->Droite*/ /* balayage Bas->Haut de Gauche->Droite*/
Affiche_1_Parametre(frame, -1, wxEmptyString, wxT("4"),CYAN); Affiche_1_Parametre( frame, -1, wxEmptyString, wxT( "4" ), CYAN );
memset(pt_cell_V, 0, nn); memset( pt_cell_V, 0, nn );
for( col = 0 ; col < Ncols ; col++) for( col = 0; col < Ncols; col++ )
{ {
old_cell_H = 0; old_cell_H = 0;
for( row = Nrows-1; row >= 0 ; row--) for( row = Nrows - 1; row >= 0; row-- )
{ {
current_cell = GetCell(row,col,BOTTOM) & NO_CELL_ZONE ; current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if(current_cell == 0 ) /* une cellule libre a ete trouvee */ if( current_cell == 0 ) /* une cellule libre a ete trouvee */
{ {
if( (old_cell_H & CELL_is_ZONE) if( (old_cell_H & CELL_is_ZONE)
|| (pt_cell_V[row] & CELL_is_ZONE) ) || (pt_cell_V[row] & CELL_is_ZONE) )
{ {
OrCell(row,col,BOTTOM,CELL_is_ZONE) ; OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE; current_cell = CELL_is_ZONE;
nbpoints++; nbpoints++;
} }
...@@ -1151,72 +1271,80 @@ wxString msg; ...@@ -1151,72 +1271,80 @@ wxString msg;
} }
} }
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 )
return FALSE; /* pas de zone */
if( frame->m_Pcb->m_Zone->m_TimeStamp != s_TimeStamp ) /* c'est une autre zone */ if( frame->m_Pcb->m_Zone->m_TimeStamp != s_TimeStamp ) /* c'est une autre zone */
return FALSE; return FALSE;
/* Calcul du nombre de pads a traiter et affichage */ /* Calcul du nombre de pads a traiter et affichage */
Affiche_1_Parametre(frame, 50, wxT("NPads"),wxT(" "),CYAN); Affiche_1_Parametre( frame, 50, wxT( "NPads" ), wxT( " " ), CYAN );
pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads; 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++) for( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++ )
{ {
pt_pad = *pt_liste_pad; pt_pad = *pt_liste_pad;
/* la pastille doit etre du meme net */ /* la pastille doit etre du meme net */
if(pt_pad->m_NetCode != g_HightLigth_NetCode) continue; if( pt_pad->m_NetCode != g_HightLigth_NetCode )
continue;
/* la pastille doit exister sur la couche */ /* la pastille doit exister sur la couche */
if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 ) continue; if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 )
continue;
Npads++; Npads++;
} }
msg.Printf( wxT("%d"), Npads );
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,CYAN);
Affiche_1_Parametre(frame, 57, wxT("Pads"), wxT(" "),CYAN); msg.Printf( wxT( "%d" ), Npads );
Affiche_1_Parametre( frame, -1, wxEmptyString, msg, CYAN );
Affiche_1_Parametre( frame, 57, wxT( "Pads" ), wxT( " " ), CYAN );
pt_liste_pad = (LISTE_PAD*) frame->m_Pcb->m_Pads; 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++) for( ii = 0, Npads = 0; ii < frame->m_Pcb->m_NbPads; ii++, pt_liste_pad++ )
{ {
pt_pad = *pt_liste_pad; pt_pad = *pt_liste_pad;
/* la pastille doit etre du meme net */ /* la pastille doit etre du meme net */
if(pt_pad->m_NetCode != g_HightLigth_NetCode) continue; if( pt_pad->m_NetCode != g_HightLigth_NetCode )
continue;
/* la pastille doit exister sur la couche */ /* la pastille doit exister sur la couche */
if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 ) continue; if( (pt_pad->m_Masque_Layer & g_TabOneLayerMask[layer]) == 0 )
continue;
/* traitement du pad en cours */ /* traitement du pad en cours */
Npads++; msg.Printf( wxT("%d"), Npads ); Npads++; msg.Printf( wxT( "%d" ), Npads );
Affiche_1_Parametre(frame, -1, wxEmptyString,msg,CYAN); Affiche_1_Parametre( frame, -1, wxEmptyString, msg, CYAN );
cX = pt_pad->m_Pos.x; cY = pt_pad->m_Pos.y; cX = pt_pad->m_Pos.x; cY = pt_pad->m_Pos.y;
dx = pt_pad->m_Size.x / 2; dx = pt_pad->m_Size.x / 2;
dy = pt_pad->m_Size.y / 2; dy = pt_pad->m_Size.y / 2;
dx += g_DesignSettings.m_TrackClearence + g_GridRoutingSize; dx += g_DesignSettings.m_TrackClearence + g_GridRoutingSize;
dy += g_DesignSettings.m_TrackClearence + g_GridRoutingSize; dy += g_DesignSettings.m_TrackClearence + g_GridRoutingSize;
if(pt_pad->m_PadShape == TRAPEZE) if( pt_pad->m_PadShape == TRAPEZE )
{ {
dx += abs(pt_pad->m_DeltaSize.y) / 2; dx += abs( pt_pad->m_DeltaSize.y ) / 2;
dy += abs(pt_pad->m_DeltaSize.x) / 2; dy += abs( pt_pad->m_DeltaSize.x ) / 2;
} }
/* calcul des coord des 4 segments a rajouter a partir du centre cX,cY */ /* calcul des coord des 4 segments a rajouter a partir du centre cX,cY */
...@@ -1226,11 +1354,11 @@ wxString msg; ...@@ -1226,11 +1354,11 @@ wxString msg;
sommet[3][0] = dx; sommet[3][1] = 0; sommet[3][0] = dx; sommet[3][1] = 0;
angle = pt_pad->m_Orient; angle = pt_pad->m_Orient;
for(jj = 0; jj < 4; jj++) for( jj = 0; jj < 4; jj++ )
{ {
RotatePoint(&sommet[jj][0], &sommet[jj][1], angle); RotatePoint( &sommet[jj][0], &sommet[jj][1], angle );
pt_track = new SEGZONE(frame->m_Pcb); pt_track = new SEGZONE( frame->m_Pcb );
pt_track->m_Layer = layer; pt_track->m_Layer = layer;
pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth; pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth;
...@@ -1242,23 +1370,22 @@ wxString msg; ...@@ -1242,23 +1370,22 @@ wxString msg;
pt_track->m_TimeStamp = s_TimeStamp; pt_track->m_TimeStamp = s_TimeStamp;
/* tst si trace possible */ /* tst si trace possible */
if( Drc(frame, DC, pt_track,frame->m_Pcb->m_Track,0) == BAD_DRC ) if( Drc( frame, DC, pt_track, frame->m_Pcb->m_Track, 0 ) == BAD_DRC )
{ {
delete pt_track; continue; delete pt_track; continue;
} }
/* on doit pouvoir se connecter sur la zone */ /* on doit pouvoir se connecter sur la zone */
loctrack = Locate_Zone(frame->m_Pcb->m_Zone,pt_track->m_End, layer); loctrack = Locate_Zone( frame->m_Pcb->m_Zone, pt_track->m_End, layer );
if( (loctrack == NULL) || (loctrack->m_TimeStamp != s_TimeStamp) ) if( (loctrack == NULL) || (loctrack->m_TimeStamp != s_TimeStamp) )
{ {
delete pt_track; continue; delete pt_track; continue;
} }
pt_track->Insert(frame->m_Pcb, NULL); pt_track->Insert( frame->m_Pcb, NULL );
pt_track->Draw(frame->DrawPanel, DC, GR_OR); pt_track->Draw( frame->DrawPanel, DC, GR_OR );
} }
} }
return TRUE; 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