Commit de442033 authored by stambaughw's avatar stambaughw

Comment translation and capitalization fixes.

* Complete comment translation of PCBNew source.
* Some tooltip capitalization fixes in PCBNew toolbars.
parent de62fa09
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
#define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" ) #define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
#define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" ) #define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
/* Constantes de conversion d'unites */ /* Conversion unit constants. */
/* coeff de conversion dim en 0.1 mil -> dim en unite PS: (unite PS = pouce) */ /* Convert pcb dimension of 0.1 mil to PS units of inches. */
#define SCALE_PS .0001 #define SCALE_PS .0001
/* coeff de conversion dim en 0,1 mil -> dim en unite HPGL: */ /* Convert dimension 0.1 mil -> HPGL units: */
#define SCALE_HPGL 0.102041 #define SCALE_HPGL 0.102041
/* Plot Options : */ /* Plot Options : */
...@@ -29,7 +29,8 @@ public: ...@@ -29,7 +29,8 @@ public:
bool Exclude_Edges_Pcb; bool Exclude_Edges_Pcb;
int PlotLine_Width; int PlotLine_Width;
bool Plot_Frame_Ref; // True to plot/print frame references bool Plot_Frame_Ref; // True to plot/print frame references
bool DrawViaOnMaskLayer; // True if vias are drawn on Mask layer (ie protected by mask) bool DrawViaOnMaskLayer; // True if vias are drawn on Mask layer
// (ie protected by mask)
GRTraceMode Trace_Mode; GRTraceMode Trace_Mode;
bool Plot_Set_MIROIR; bool Plot_Set_MIROIR;
int HPGL_Pen_Num; int HPGL_Pen_Num;
...@@ -39,14 +40,14 @@ public: ...@@ -39,14 +40,14 @@ public:
int PlotPSColorOpt; // True for color Postscript output int PlotPSColorOpt; // True for color Postscript output
bool Plot_PS_Negative; // True to create a negative board ps plot bool Plot_PS_Negative; // True to create a negative board ps plot
/* Autorisation de trace des divers items en serigraphie */ /* Flags to enable or disable ploting of various PCB elements. */
bool Sel_Texte_Reference; bool Sel_Texte_Reference;
bool Sel_Texte_Valeur; bool Sel_Texte_Valeur;
bool Sel_Texte_Divers; bool Sel_Texte_Divers;
bool Sel_Texte_Invisible; bool Sel_Texte_Invisible;
bool PlotPadsOnSilkLayer; bool PlotPadsOnSilkLayer;
bool Plot_Pads_All_Layers; /* Plot pads meme n'appartenant pas a la bool Plot_Pads_All_Layers; /* Plot pads even outside the
* couche ( utile pour serigraphie) */ * Layer (useful for silkscreen) */
/* id for plot format (see enum PlotFormat in plot_common.h) */ /* id for plot format (see enum PlotFormat in plot_common.h) */
int PlotFormat; int PlotFormat;
...@@ -68,17 +69,12 @@ public: ...@@ -68,17 +69,12 @@ public:
extern PCB_Plot_Options g_pcb_plot_options; extern PCB_Plot_Options g_pcb_plot_options;
/*************************************/
/* Constantes utiles en trace GERBER */
/*************************************/
/* PLOT_RTN.CC */
void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer,
GRTraceMode trace_mode ); GRTraceMode trace_mode );
/* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, /* Plat PCB text type, ie other than text on modules
* prepare les parametres de trace de texte */ * prepare the plot settings of text */
void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* PtSegm, int masque_layer, void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* PtSegm, int masque_layer,
GRTraceMode trace_mode ); GRTraceMode trace_mode );
......
/*********************************************************/ /*************************/
/* Routines de trace: fonction communes aux diff formats */ /* Common plot routines. */
/*********************************************************/ /*************************/
/* Fichier PLOT_RTN.CPP*/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -16,19 +14,17 @@ ...@@ -16,19 +14,17 @@
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
/* Local functions */
static void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer, static void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer,
GRTraceMode trace_mode ); GRTraceMode trace_mode );
static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte,
GRTraceMode trace_mode ); GRTraceMode trace_mode );
/**********************************************************/
void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
int masque_layer, GRTraceMode trace_mode )
/***********************************************************/
/* Creates the plot for silkscreen layers /* Creates the plot for silkscreen layers
*/ */
void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
int masque_layer,
GRTraceMode trace_mode )
{ {
wxPoint pos, shape_pos; wxPoint pos, shape_pos;
wxSize size; wxSize size;
...@@ -39,31 +35,46 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -39,31 +35,46 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
/* Plot edge layer and graphic items */ /* Plot edge layer and graphic items */
for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( PtStruct = m_Pcb->m_Drawings;
PtStruct != NULL;
PtStruct = PtStruct->Next() )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
PlotDrawSegment( plotter, (DRAWSEGMENT*) PtStruct, masque_layer, trace_mode ); PlotDrawSegment( plotter,
(DRAWSEGMENT*) PtStruct,
masque_layer,
trace_mode );
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
PlotTextePcb( plotter, (TEXTE_PCB*) PtStruct, masque_layer, trace_mode ); PlotTextePcb( plotter,
(TEXTE_PCB*) PtStruct,
masque_layer,
trace_mode );
break; break;
case TYPE_COTATION: case TYPE_COTATION:
PlotCotation( plotter, (COTATION*) PtStruct, masque_layer, trace_mode ); PlotCotation( plotter,
(COTATION*) PtStruct,
masque_layer,
trace_mode );
break; break;
case TYPE_MIRE: case TYPE_MIRE:
PlotMirePcb( plotter, (MIREPCB*) PtStruct, masque_layer, trace_mode ); PlotMirePcb( plotter,
(MIREPCB*) PtStruct,
masque_layer,
trace_mode );
break; break;
case TYPE_MARKER_PCB: case TYPE_MARKER_PCB:
break; break;
default: default:
DisplayError( this, wxT( "Plot_Serigraphie() error: unexpected Type()" ) ); DisplayError( this,
wxT( "Plot_Serigraphie() error: unexpected Type()" ) );
break; break;
} }
} }
...@@ -79,11 +90,12 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -79,11 +90,12 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
Module; Module;
Module = Module->Next() ) Module = Module->Next() )
{ {
for( pt_pad = (D_PAD*) Module->m_Pads; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( pt_pad = (D_PAD*) Module->m_Pads;
pt_pad != NULL;
pt_pad = pt_pad->Next() )
{ {
/* Seen if the pad is on this layer */ /* Seen if the pad is on this layer */
if( (pt_pad->m_Masque_Layer & masque_layer) == 0 if( (pt_pad->m_Masque_Layer & masque_layer) == 0
/* Copper pads go on copper silk, component /* Copper pads go on copper silk, component
* pads go on component silk */ * pads go on component silk */
&& ( ( (pt_pad->m_Masque_Layer & CUIVRE_LAYER) == 0 ) && ( ( (pt_pad->m_Masque_Layer & CUIVRE_LAYER) == 0 )
...@@ -122,7 +134,10 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -122,7 +134,10 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
case PAD_RECT: case PAD_RECT:
default: default:
plotter->flash_pad_rect( pos, size, pt_pad->m_Orient, FILAIRE ); plotter->flash_pad_rect( pos,
size,
pt_pad->m_Orient,
FILAIRE );
break; break;
} }
} }
...@@ -143,14 +158,14 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -143,14 +158,14 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
{ {
wxString errMsg; wxString errMsg;
errMsg.Printf( errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \
_( "Your BOARD has a bad layer number of %u for module\n %s's \"reference\" text." ), module\n %s's \"reference\" text." ),
textLayer, GetChars( Module->GetReference() ) ); textLayer, GetChars( Module->GetReference() ) );
DisplayError( this, errMsg ); DisplayError( this, errMsg );
return; return;
} }
if( ( (1 << textLayer) & masque_layer ) == 0 ) if( ( ( 1 << textLayer ) & masque_layer ) == 0 )
trace_ref = FALSE; trace_ref = FALSE;
if( text->m_NoShow && !g_pcb_plot_options.Sel_Texte_Invisible ) if( text->m_NoShow && !g_pcb_plot_options.Sel_Texte_Invisible )
...@@ -163,8 +178,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -163,8 +178,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
{ {
wxString errMsg; wxString errMsg;
errMsg.Printf( errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \
_( "Your BOARD has a bad layer number of %u for module\n %s's \"value\" text." ), module\n %s's \"value\" text." ),
textLayer, GetChars( Module->GetReference() ) ); textLayer, GetChars( Module->GetReference() ) );
DisplayError( this, errMsg ); DisplayError( this, errMsg );
return; return;
...@@ -192,7 +207,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -192,7 +207,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
if( !g_pcb_plot_options.Sel_Texte_Divers ) if( !g_pcb_plot_options.Sel_Texte_Divers )
continue; continue;
if( (pt_texte->m_NoShow) && !g_pcb_plot_options.Sel_Texte_Invisible ) if( (pt_texte->m_NoShow)
&& !g_pcb_plot_options.Sel_Texte_Invisible )
continue; continue;
textLayer = pt_texte->GetLayer(); textLayer = pt_texte->GetLayer();
...@@ -200,23 +216,22 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -200,23 +216,22 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
{ {
wxString errMsg; wxString errMsg;
errMsg.Printf( errMsg.Printf( _( "Your BOARD has a bad layer number of %u \
_( for module\n %s's \"module text\" text of %s." ),
"Your BOARD has a bad layer number of %u for module\n %s's \"module text\" text of %s." ),
textLayer, GetChars( Module->GetReference() ), textLayer, GetChars( Module->GetReference() ),
GetChars( pt_texte->m_Text ) ); GetChars( pt_texte->m_Text ) );
DisplayError( this, errMsg ); DisplayError( this, errMsg );
return; return;
} }
if( !( (1 << textLayer) & masque_layer ) ) if( !( ( 1 << textLayer ) & masque_layer ) )
continue; continue;
PlotTextModule( plotter, pt_texte, trace_mode ); PlotTextModule( plotter, pt_texte, trace_mode );
} }
} }
/* Plot filled ares */ /* Plot filled areas */
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii ); ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii );
...@@ -225,7 +240,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -225,7 +240,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
PlotFilledAreas( plotter, edge_zone, trace_mode ); PlotFilledAreas( plotter, edge_zone, trace_mode );
} }
// Plot segments used to fill zone areas (outdated, but here for old boards compatibility): // Plot segments used to fill zone areas (outdated, but here for old boards
// compatibility):
for( SEGZONE* seg = m_Pcb->m_Zone; seg != NULL; seg = seg->Next() ) for( SEGZONE* seg = m_Pcb->m_Zone; seg != NULL; seg = seg->Next() )
{ {
if( ( ( 1 << seg->GetLayer() ) & masque_layer ) == 0 ) if( ( ( 1 << seg->GetLayer() ) & masque_layer ) == 0 )
...@@ -236,10 +252,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -236,10 +252,8 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
} }
/********************************************************************/
static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/********************************************************************/
{ {
wxSize size; wxSize size;
wxPoint pos; wxPoint pos;
...@@ -266,10 +280,8 @@ static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte, ...@@ -266,10 +280,8 @@ static void PlotTextModule( PLOTTER* plotter, TEXTE_MODULE* pt_texte,
} }
/*******************************************************************************/
void PlotCotation( PLOTTER* plotter, COTATION* Cotation, int masque_layer, void PlotCotation( PLOTTER* plotter, COTATION* Cotation, int masque_layer,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/*******************************************************************************/
{ {
DRAWSEGMENT* DrawTmp; DRAWSEGMENT* DrawTmp;
...@@ -283,42 +295,54 @@ void PlotCotation( PLOTTER* plotter, COTATION* Cotation, int masque_layer, ...@@ -283,42 +295,54 @@ void PlotCotation( PLOTTER* plotter, COTATION* Cotation, int masque_layer,
PlotTextePcb( plotter, Cotation->m_Text, masque_layer, trace_mode ); PlotTextePcb( plotter, Cotation->m_Text, masque_layer, trace_mode );
DrawTmp->m_Start.x = Cotation->Barre_ox; DrawTmp->m_Start.y = Cotation->Barre_oy; DrawTmp->m_Start.x = Cotation->Barre_ox;
DrawTmp->m_End.x = Cotation->Barre_fx; DrawTmp->m_End.y = Cotation->Barre_fy; DrawTmp->m_Start.y = Cotation->Barre_oy;
DrawTmp->m_End.x = Cotation->Barre_fx;
DrawTmp->m_End.y = Cotation->Barre_fy;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
DrawTmp->m_Start.x = Cotation->TraitG_ox; DrawTmp->m_Start.y = Cotation->TraitG_oy; DrawTmp->m_Start.x = Cotation->TraitG_ox;
DrawTmp->m_End.x = Cotation->TraitG_fx; DrawTmp->m_End.y = Cotation->TraitG_fy; DrawTmp->m_Start.y = Cotation->TraitG_oy;
DrawTmp->m_End.x = Cotation->TraitG_fx;
DrawTmp->m_End.y = Cotation->TraitG_fy;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
DrawTmp->m_Start.x = Cotation->TraitD_ox; DrawTmp->m_Start.y = Cotation->TraitD_oy; DrawTmp->m_Start.x = Cotation->TraitD_ox;
DrawTmp->m_End.x = Cotation->TraitD_fx; DrawTmp->m_End.y = Cotation->TraitD_fy; DrawTmp->m_Start.y = Cotation->TraitD_oy;
DrawTmp->m_End.x = Cotation->TraitD_fx;
DrawTmp->m_End.y = Cotation->TraitD_fy;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
DrawTmp->m_Start.x = Cotation->FlecheD1_ox; DrawTmp->m_Start.y = Cotation->FlecheD1_oy; DrawTmp->m_Start.x = Cotation->FlecheD1_ox;
DrawTmp->m_End.x = Cotation->FlecheD1_fx; DrawTmp->m_End.y = Cotation->FlecheD1_fy; DrawTmp->m_Start.y = Cotation->FlecheD1_oy;
DrawTmp->m_End.x = Cotation->FlecheD1_fx;
DrawTmp->m_End.y = Cotation->FlecheD1_fy;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
DrawTmp->m_Start.x = Cotation->FlecheD2_ox; DrawTmp->m_Start.y = Cotation->FlecheD2_oy; DrawTmp->m_Start.x = Cotation->FlecheD2_ox;
DrawTmp->m_End.x = Cotation->FlecheD2_fx; DrawTmp->m_End.y = Cotation->FlecheD2_fy; DrawTmp->m_Start.y = Cotation->FlecheD2_oy;
DrawTmp->m_End.x = Cotation->FlecheD2_fx;
DrawTmp->m_End.y = Cotation->FlecheD2_fy;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
DrawTmp->m_Start.x = Cotation->FlecheG1_ox; DrawTmp->m_Start.y = Cotation->FlecheG1_oy; DrawTmp->m_Start.x = Cotation->FlecheG1_ox;
DrawTmp->m_End.x = Cotation->FlecheG1_fx; DrawTmp->m_End.y = Cotation->FlecheG1_fy; DrawTmp->m_Start.y = Cotation->FlecheG1_oy;
DrawTmp->m_End.x = Cotation->FlecheG1_fx;
DrawTmp->m_End.y = Cotation->FlecheG1_fy;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
DrawTmp->m_Start.x = Cotation->FlecheG2_ox; DrawTmp->m_Start.y = Cotation->FlecheG2_oy; DrawTmp->m_Start.x = Cotation->FlecheG2_ox;
DrawTmp->m_End.x = Cotation->FlecheG2_fx; DrawTmp->m_End.y = Cotation->FlecheG2_fy; DrawTmp->m_Start.y = Cotation->FlecheG2_oy;
DrawTmp->m_End.x = Cotation->FlecheG2_fx;
DrawTmp->m_End.y = Cotation->FlecheG2_fy;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
delete DrawTmp; delete DrawTmp;
} }
/*****************************************************************/
void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer, void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/*****************************************************************/
{ {
DRAWSEGMENT* DrawTmp; DRAWSEGMENT* DrawTmp;
int dx1, dx2, dy1, dy2, radius; int dx1, dx2, dy1, dy2, radius;
...@@ -328,11 +352,11 @@ void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer, ...@@ -328,11 +352,11 @@ void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer,
DrawTmp = new DRAWSEGMENT( NULL ); DrawTmp = new DRAWSEGMENT( NULL );
DrawTmp->m_Width = (trace_mode==FILAIRE) ? -1 : Mire->m_Width; DrawTmp->m_Width = ( trace_mode == FILAIRE ) ? -1 : Mire->m_Width;
DrawTmp->SetLayer( Mire->GetLayer() ); DrawTmp->SetLayer( Mire->GetLayer() );
DrawTmp->m_Start.x = Mire->m_Pos.x; DrawTmp->m_Start.y = Mire->m_Pos.y; DrawTmp->m_Start.x = Mire->m_Pos.x; DrawTmp->m_Start.y = Mire->m_Pos.y;
DrawTmp->m_End.x = DrawTmp->m_Start.x + (Mire->m_Size / 4); DrawTmp->m_End.x = DrawTmp->m_Start.x + ( Mire->m_Size / 4 );
DrawTmp->m_End.y = DrawTmp->m_Start.y; DrawTmp->m_End.y = DrawTmp->m_Start.y;
DrawTmp->m_Shape = S_CIRCLE; DrawTmp->m_Shape = S_CIRCLE;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
...@@ -340,32 +364,37 @@ void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer, ...@@ -340,32 +364,37 @@ void PlotMirePcb( PLOTTER* plotter, MIREPCB* Mire, int masque_layer,
DrawTmp->m_Shape = S_SEGMENT; DrawTmp->m_Shape = S_SEGMENT;
radius = Mire->m_Size / 2; radius = Mire->m_Size / 2;
dx1 = radius, dy1 = 0; dx2 = 0, dy2 = radius; dx1 = radius;
dy1 = 0;
dx2 = 0;
dy2 = radius;
if( Mire->m_Shape ) /* Shape X */ if( Mire->m_Shape ) /* Shape X */
{ {
dx1 = dy1 = (radius * 7) / 5; dx1 = dy1 = ( radius * 7 ) / 5;
dx2 = dx1; dx2 = dx1;
dy2 = -dy1; dy2 = -dy1;
} }
DrawTmp->m_Start.x = Mire->m_Pos.x - dx1; DrawTmp->m_Start.y = Mire->m_Pos.y - dy1; DrawTmp->m_Start.x = Mire->m_Pos.x - dx1;
DrawTmp->m_End.x = Mire->m_Pos.x + dx1; DrawTmp->m_End.y = Mire->m_Pos.y + dy1; DrawTmp->m_Start.y = Mire->m_Pos.y - dy1;
DrawTmp->m_End.x = Mire->m_Pos.x + dx1;
DrawTmp->m_End.y = Mire->m_Pos.y + dy1;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
DrawTmp->m_Start.x = Mire->m_Pos.x - dx2; DrawTmp->m_Start.y = Mire->m_Pos.y - dy2; DrawTmp->m_Start.x = Mire->m_Pos.x - dx2;
DrawTmp->m_End.x = Mire->m_Pos.x + dx2; DrawTmp->m_End.y = Mire->m_Pos.y + dy2; DrawTmp->m_Start.y = Mire->m_Pos.y - dy2;
DrawTmp->m_End.x = Mire->m_Pos.x + dx2;
DrawTmp->m_End.y = Mire->m_Pos.y + dy2;
PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode ); PlotDrawSegment( plotter, DrawTmp, masque_layer, trace_mode );
delete DrawTmp; delete DrawTmp;
} }
/**********************************************************************/ /* Plot footprints graphic items (outlines) */
void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer, void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/**********************************************************************/
/* Plot footprints graphic items (outlines) */
{ {
for( MODULE* module = pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{ {
...@@ -376,7 +405,7 @@ void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer, ...@@ -376,7 +405,7 @@ void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer,
if( edge->Type() != TYPE_EDGE_MODULE ) if( edge->Type() != TYPE_EDGE_MODULE )
continue; continue;
if( (g_TabOneLayerMask[edge->GetLayer()] & masque_layer) == 0 ) if( ( g_TabOneLayerMask[edge->GetLayer()] & masque_layer ) == 0 )
continue; continue;
Plot_1_EdgeModule( plotter, edge, trace_mode ); Plot_1_EdgeModule( plotter, edge, trace_mode );
...@@ -385,17 +414,15 @@ void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer, ...@@ -385,17 +414,15 @@ void Plot_Edges_Modules( PLOTTER* plotter, BOARD* pcb, int masque_layer,
} }
/**************************************************************/ /* Plot a graphic item (outline) relative to a footprint */
void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/**************************************************************/
/* Plot a graphic item (outline) relative to a footprint */
{ {
int type_trace; /* forme a tracer (segment, cercle) */ int type_trace; /* Type of item to plot. */
int thickness; /* thickness des segments */ int thickness; /* Segment thickness. */
int radius; /* radius des cercles a tracer */ int radius; /* Circle radius. */
int StAngle, EndAngle; int StAngle, EndAngle;
wxPoint pos, end; /* Coord des segments a tracer */ wxPoint pos, end;
if( PtEdge->Type() != TYPE_EDGE_MODULE ) if( PtEdge->Type() != TYPE_EDGE_MODULE )
return; return;
...@@ -413,15 +440,22 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, ...@@ -413,15 +440,22 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge,
break; break;
case S_CIRCLE: case S_CIRCLE:
radius = (int) hypot( (double) ( end.x - pos.x ), (double) ( end.y - pos.y ) ); radius = (int) hypot( (double) ( end.x - pos.x ),
(double) ( end.y - pos.y ) );
plotter->thick_circle( pos, radius * 2, thickness, trace_mode ); plotter->thick_circle( pos, radius * 2, thickness, trace_mode );
break; break;
case S_ARC: case S_ARC:
radius = (int) hypot( (double) ( end.x - pos.x ), (double) ( end.y - pos.y ) ); radius = (int) hypot( (double) ( end.x - pos.x ),
(double) ( end.y - pos.y ) );
StAngle = ArcTangente( end.y - pos.y, end.x - pos.x ); StAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
EndAngle = StAngle + PtEdge->m_Angle; EndAngle = StAngle + PtEdge->m_Angle;
plotter->thick_arc( pos, -EndAngle, -StAngle, radius, thickness, trace_mode ); plotter->thick_arc( pos,
-EndAngle,
-StAngle,
radius,
thickness,
trace_mode );
break; break;
case S_POLYGON: case S_POLYGON:
...@@ -432,7 +466,8 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, ...@@ -432,7 +466,8 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge,
if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) ) if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) )
Module = (MODULE*) PtEdge->GetParent(); Module = (MODULE*) PtEdge->GetParent();
int* ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyPoints.size() * sizeof(int) ); int* ptr_base =
(int*) MyMalloc( 2 * PtEdge->m_PolyPoints.size() * sizeof(int) );
int* ptr = ptr_base; int* ptr = ptr_base;
int* source = (int*) &PtEdge->m_PolyPoints[0]; int* source = (int*) &PtEdge->m_PolyPoints[0];
...@@ -456,7 +491,8 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, ...@@ -456,7 +491,8 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge,
*ptr++ = y; *ptr++ = y;
} }
plotter->poly( PtEdge->m_PolyPoints.size(), ptr_base, NO_FILL, thickness ); plotter->poly( PtEdge->m_PolyPoints.size(), ptr_base, NO_FILL,
thickness );
free( ptr_base ); free( ptr_base );
} }
break; break;
...@@ -464,11 +500,9 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge, ...@@ -464,11 +500,9 @@ void Plot_1_EdgeModule( PLOTTER* plotter, EDGE_MODULE* PtEdge,
} }
/****************************************************************************/ /* Plot a PCB Text, i;e. a text found on a copper or technical layer */
void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/****************************************************************************/
/* Plot a PCB Text, i;e. a text found on a copper or technical layer */
{ {
int orient, thickness; int orient, thickness;
wxPoint pos; wxPoint pos;
...@@ -476,13 +510,13 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, ...@@ -476,13 +510,13 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer,
if( pt_texte->m_Text.IsEmpty() ) if( pt_texte->m_Text.IsEmpty() )
return; return;
if( (g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer) == 0 ) if( ( g_TabOneLayerMask[pt_texte->GetLayer()] & masque_layer ) == 0 )
return; return;
size = pt_texte->m_Size; size = pt_texte->m_Size;
pos = pt_texte->m_Pos; pos = pt_texte->m_Pos;
orient = pt_texte->m_Orient; orient = pt_texte->m_Orient;
thickness = (trace_mode==FILAIRE) ? -1 : pt_texte->m_Width; thickness = ( trace_mode==FILAIRE ) ? -1 : pt_texte->m_Width;
if( pt_texte->m_Mirror ) if( pt_texte->m_Mirror )
size.x = -size.x; size.x = -size.x;
...@@ -495,7 +529,7 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, ...@@ -495,7 +529,7 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer,
offset.y = pt_texte->GetInterline(); offset.y = pt_texte->GetInterline();
RotatePoint( &offset, orient ); RotatePoint( &offset, orient );
for( unsigned i = 0; i<list->Count(); i++ ) for( unsigned i = 0; i < list->Count(); i++ )
{ {
wxString txt = list->Item( i ); wxString txt = list->Item( i );
plotter->text( pos, BLACK, plotter->text( pos, BLACK,
...@@ -517,12 +551,10 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer, ...@@ -517,12 +551,10 @@ void PlotTextePcb( PLOTTER* plotter, TEXTE_PCB* pt_texte, int masque_layer,
} }
/*********************************************************/
void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
GRTraceMode trace_mode )
/*********************************************************/
/* Plot areas (given by .m_FilledPolysList member) in a zone /* Plot areas (given by .m_FilledPolysList member) in a zone
*/ */
void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
GRTraceMode trace_mode )
{ {
static int* CornersBuffer = NULL; static int* CornersBuffer = NULL;
static unsigned CornersBufferSize = 0; static unsigned CornersBufferSize = 0;
...@@ -533,7 +565,7 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, ...@@ -533,7 +565,7 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
// We need a buffer to store corners coordinates: // We need a buffer to store corners coordinates:
imax++; // provide room to sore an extra coordinte to close the ploygon imax++; // provide room to sore an extra coordinate to close the polygon
if( CornersBuffer == NULL ) if( CornersBuffer == NULL )
{ {
CornersBufferSize = imax * 2; CornersBufferSize = imax * 2;
...@@ -543,14 +575,15 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, ...@@ -543,14 +575,15 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
if( (imax * 4) > CornersBufferSize ) if( (imax * 4) > CornersBufferSize )
{ {
CornersBufferSize = imax * 2; CornersBufferSize = imax * 2;
CornersBuffer = (int*) realloc( CornersBuffer, CornersBufferSize * sizeof(int) ); CornersBuffer = (int*) realloc( CornersBuffer,
CornersBufferSize * sizeof(int) );
} }
imax--; imax--;
/* Plot all filled areas: filled areas have a filled area and a thick outline /* Plot all filled areas: filled areas have a filled area and a thick
* we must plot the filled area itself ( as a filled polygon OR a set of segments ) * outline we must plot the filled area itself ( as a filled polygon
* and plot the thick outline itself * OR a set of segments ) and plot the thick outline itself
* *
* in non filled mode the outline is plotted, but not the filling items * in non filled mode the outline is plotted, but not the filling items
*/ */
...@@ -576,15 +609,22 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, ...@@ -576,15 +609,22 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
if( trace_mode == FILLED ) if( trace_mode == FILLED )
{ {
// Plot the current filled area polygon // Plot the current filled area polygon
if( aZone->m_FillMode == 0 ) // We are using solid polygons (if != 0: using segments ) if( aZone->m_FillMode == 0 ) // We are using solid polygons
// (if != 0: using segments )
plotter->poly( corners_count, CornersBuffer, FILLED_SHAPE ); plotter->poly( corners_count, CornersBuffer, FILLED_SHAPE );
else // We are using areas filled by segments: plot hem ) else // We are using areas filled by
// segments: plot hem )
{ {
for( unsigned iseg = 0; iseg < aZone->m_FillSegmList.size(); iseg++ ) for( unsigned iseg = 0;
iseg < aZone->m_FillSegmList.size();
iseg++ )
{ {
wxPoint start = aZone->m_FillSegmList[iseg].m_Start; wxPoint start = aZone->m_FillSegmList[iseg].m_Start;
wxPoint end = aZone->m_FillSegmList[iseg].m_End; wxPoint end = aZone->m_FillSegmList[iseg].m_End;
plotter->thick_segment( start, end, aZone->m_ZoneMinThickness, trace_mode ); plotter->thick_segment( start,
end,
aZone->m_ZoneMinThickness,
trace_mode );
} }
} }
...@@ -603,7 +643,7 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, ...@@ -603,7 +643,7 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
CornersBuffer[ii * 2 - 1] ), CornersBuffer[ii * 2 - 1] ),
wxPoint( CornersBuffer[ii * 2], wxPoint( CornersBuffer[ii * 2],
CornersBuffer[ii * 2 + 1] ), CornersBuffer[ii * 2 + 1] ),
(trace_mode == FILAIRE) ? -1 : aZone->m_ZoneMinThickness, ( trace_mode == FILAIRE ) ? -1 : aZone->m_ZoneMinThickness,
trace_mode ); trace_mode );
} }
plotter->set_current_line_width( -1 ); plotter->set_current_line_width( -1 );
...@@ -615,13 +655,10 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone, ...@@ -615,13 +655,10 @@ void PlotFilledAreas( PLOTTER* plotter, ZONE_CONTAINER* aZone,
} }
/******************************************************************************/
void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer,
GRTraceMode trace_mode )
/******************************************************************************/
/* Plot items type DRAWSEGMENT on layers allowed by masque_layer /* Plot items type DRAWSEGMENT on layers allowed by masque_layer
*/ */
void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer,
GRTraceMode trace_mode )
{ {
wxPoint start, end; wxPoint start, end;
int thickness; int thickness;
...@@ -642,21 +679,32 @@ void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer, ...@@ -642,21 +679,32 @@ void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer,
switch( pt_segm->m_Shape ) switch( pt_segm->m_Shape )
{ {
case S_CIRCLE: case S_CIRCLE:
radius = (int) hypot( (double) ( end.x - start.x ), (double) ( end.y - start.y ) ); radius =
(int) hypot( (double) ( end.x - start.x ),
(double) ( end.y - start.y ) );
plotter->thick_circle( start, radius * 2, thickness, trace_mode ); plotter->thick_circle( start, radius * 2, thickness, trace_mode );
break; break;
case S_ARC: case S_ARC:
radius = (int) hypot( (double) ( end.x - start.x ), (double) ( end.y - start.y ) ); radius =
(int) hypot( (double) ( end.x - start.x ),
(double) ( end.y - start.y ) );
StAngle = ArcTangente( end.y - start.y, end.x - start.x ); StAngle = ArcTangente( end.y - start.y, end.x - start.x );
EndAngle = StAngle + pt_segm->m_Angle; EndAngle = StAngle + pt_segm->m_Angle;
plotter->thick_arc( start, -EndAngle, -StAngle, radius, thickness, trace_mode ); plotter->thick_arc( start,
-EndAngle,
-StAngle,
radius,
thickness,
trace_mode );
break; break;
case S_CURVE: case S_CURVE:
for( unsigned i = 1; i < pt_segm->m_BezierPoints.size(); i++ ) for( unsigned i = 1; i < pt_segm->m_BezierPoints.size(); i++ )
plotter->thick_segment( pt_segm->m_BezierPoints[i - 1], plotter->thick_segment( pt_segm->m_BezierPoints[i - 1],
pt_segm->m_BezierPoints[i], thickness, trace_mode ); pt_segm->m_BezierPoints[i],
thickness,
trace_mode );
break; break;
...@@ -666,10 +714,8 @@ void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer, ...@@ -666,10 +714,8 @@ void PlotDrawSegment( PLOTTER* plotter, DRAWSEGMENT* pt_segm, int masque_layer,
} }
/*********************************************************************/
void WinEDA_BasePcbFrame::Plot_Layer( PLOTTER* plotter, int Layer, void WinEDA_BasePcbFrame::Plot_Layer( PLOTTER* plotter, int Layer,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/*********************************************************************/
{ {
// Specify that the contents of the "Edges Pcb" layer are to be plotted // Specify that the contents of the "Edges Pcb" layer are to be plotted
// in addition to the contents of the currently specified layer. // in addition to the contents of the currently specified layer.
...@@ -698,12 +744,13 @@ void WinEDA_BasePcbFrame::Plot_Layer( PLOTTER* plotter, int Layer, ...@@ -698,12 +744,13 @@ void WinEDA_BasePcbFrame::Plot_Layer( PLOTTER* plotter, int Layer,
case LAST_COPPER_LAYER: case LAST_COPPER_LAYER:
Plot_Standard_Layer( plotter, layer_mask, true, trace_mode ); Plot_Standard_Layer( plotter, layer_mask, true, trace_mode );
// Adding drill marks, if required and if the plotter is able to plot them: // Adding drill marks, if required and if the plotter is able to plot
if( g_pcb_plot_options.DrillShapeOpt != PCB_Plot_Options::NO_DRILL_SHAPE ) // them:
if( g_pcb_plot_options.DrillShapeOpt !=
PCB_Plot_Options::NO_DRILL_SHAPE )
{ {
if( plotter->GetPlotterType() == PLOT_FORMAT_POST ) if( plotter->GetPlotterType() == PLOT_FORMAT_POST )
PlotDrillMark( PlotDrillMark( plotter,
plotter,
trace_mode, trace_mode,
g_pcb_plot_options.DrillShapeOpt == g_pcb_plot_options.DrillShapeOpt ==
PCB_Plot_Options::SMALL_DRILL_SHAPE ); PCB_Plot_Options::SMALL_DRILL_SHAPE );
...@@ -728,27 +775,28 @@ void WinEDA_BasePcbFrame::Plot_Layer( PLOTTER* plotter, int Layer, ...@@ -728,27 +775,28 @@ void WinEDA_BasePcbFrame::Plot_Layer( PLOTTER* plotter, int Layer,
} }
/******************************************************************************/ /* Plot a copper layer or mask in HPGL format.
void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask, * HPGL unit = 0.98 mils (1 mil = 1.02041 unit HPGL).
bool aPlotVia, GRTraceMode aPlotMode )
/*******************************************************************************/
/* Trace en format HPGL. d'une couche cuivre ou masque
* 1 unite HPGL = 0.98 mils ( 1 mil = 1.02041 unite HPGL ) .
*/ */
void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter,
int aLayerMask,
bool aPlotVia,
GRTraceMode aPlotMode )
{ {
wxPoint pos; wxPoint pos;
wxSize size; wxSize size;
wxString msg; wxString msg;
// trace des elements type Drawings Pcb : // Plot pcb draw items.
for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
PlotDrawSegment( aPlotter, (DRAWSEGMENT*) item, aLayerMask, aPlotMode ); PlotDrawSegment( aPlotter,
(DRAWSEGMENT*) item,
aLayerMask,
aPlotMode );
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
...@@ -782,7 +830,9 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask ...@@ -782,7 +830,9 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask
{ {
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
if( aLayerMask & g_TabOneLayerMask[ item->GetLayer() ] ) if( aLayerMask & g_TabOneLayerMask[ item->GetLayer() ] )
Plot_1_EdgeModule( aPlotter, (EDGE_MODULE*) item, aPlotMode ); Plot_1_EdgeModule( aPlotter,
(EDGE_MODULE*) item,
aPlotMode );
break; break;
default: default:
...@@ -803,7 +853,9 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask ...@@ -803,7 +853,9 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask
shape_pos = pad->ReturnShapePos(); shape_pos = pad->ReturnShapePos();
pos = shape_pos; pos = shape_pos;
wxSize margin; wxSize margin;
switch( aLayerMask & (SOLDERMASK_LAYER_CU|SOLDERMASK_LAYER_CMP|SOLDERPASTE_LAYER_CU|SOLDERPASTE_LAYER_CMP) ) switch( aLayerMask &
( SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP |
SOLDERPASTE_LAYER_CU | SOLDERPASTE_LAYER_CMP ) )
{ {
case SOLDERMASK_LAYER_CMP: case SOLDERMASK_LAYER_CMP:
case SOLDERMASK_LAYER_CU: case SOLDERMASK_LAYER_CU:
...@@ -819,8 +871,8 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask ...@@ -819,8 +871,8 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask
break; break;
} }
size.x = pad->m_Size.x + (2 * margin.x); size.x = pad->m_Size.x + ( 2 * margin.x );
size.y = pad->m_Size.y + (2 * margin.y); size.y = pad->m_Size.y + ( 2 * margin.y );
/* Don't draw a null size item : */ /* Don't draw a null size item : */
if( size.x <= 0 || size.y <= 0 ) if( size.x <= 0 || size.y <= 0 )
...@@ -839,7 +891,11 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask ...@@ -839,7 +891,11 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
{ {
wxSize delta = pad->m_DeltaSize; wxSize delta = pad->m_DeltaSize;
aPlotter->flash_pad_trapez( pos, size, delta, pad->m_Orient, aPlotMode ); aPlotter->flash_pad_trapez( pos,
size,
delta,
pad->m_Orient,
aPlotMode );
} }
break; break;
...@@ -869,12 +925,14 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask ...@@ -869,12 +925,14 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask
via_mask_layer |= SOLDERMASK_LAYER_CU; via_mask_layer |= SOLDERMASK_LAYER_CU;
if( via_mask_layer & CMP_LAYER ) if( via_mask_layer & CMP_LAYER )
via_mask_layer |= SOLDERMASK_LAYER_CMP; via_mask_layer |= SOLDERMASK_LAYER_CMP;
if( ( via_mask_layer & aLayerMask) == 0 ) if( ( via_mask_layer & aLayerMask ) == 0 )
continue; continue;
int via_margin = 0; int via_margin = 0;
// If the current layer is a solder mask, use the global mask clearance for vias
if( (aLayerMask & (SOLDERMASK_LAYER_CU|SOLDERMASK_LAYER_CMP) ) ) // If the current layer is a solder mask, use the global mask
// clearance for vias
if( ( aLayerMask & ( SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP ) ) )
via_margin = g_DesignSettings.m_SolderMaskMargin; via_margin = g_DesignSettings.m_SolderMaskMargin;
pos = Via->m_Start; pos = Via->m_Start;
size.x = size.y = Via->m_Width + 2 * via_margin; size.x = size.y = Via->m_Width + 2 * via_margin;
...@@ -934,12 +992,15 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask ...@@ -934,12 +992,15 @@ void WinEDA_BasePcbFrame::Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask
/** function PlotDrillMark /** function PlotDrillMark
* Draw a drill mark for pads and vias. * Draw a drill mark for pads and vias.
* Must be called after all drawings, because it * Must be called after all drawings, because it
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape in FILLED plot mode * redraw the drill mark on a pad or via, as a negative (i.e. white) shape in
* FILLED plot mode
* @param aPlotter = the PLOTTER * @param aPlotter = the PLOTTER
* @param aTraceMode = the mode of plot (FILLED, SKETCH) * @param aTraceMode = the mode of plot (FILLED, SKETCH)
* @param aSmallDrillShape = true to plot a small drill shape, false to plot the actual drill shape * @param aSmallDrillShape = true to plot a small drill shape, false to plot
* the actual drill shape
*/ */
void WinEDA_BasePcbFrame::PlotDrillMark( PLOTTER* aPlotter, GRTraceMode aTraceMode, void WinEDA_BasePcbFrame::PlotDrillMark( PLOTTER* aPlotter,
GRTraceMode aTraceMode,
bool aSmallDrillShape ) bool aSmallDrillShape )
{ {
const int SMALL_DRILL = 150; const int SMALL_DRILL = 150;
...@@ -959,7 +1020,8 @@ void WinEDA_BasePcbFrame::PlotDrillMark( PLOTTER* aPlotter, GRTraceMode aTraceMo ...@@ -959,7 +1020,8 @@ void WinEDA_BasePcbFrame::PlotDrillMark( PLOTTER* aPlotter, GRTraceMode aTraceMo
if( pts->Type() != TYPE_VIA ) if( pts->Type() != TYPE_VIA )
continue; continue;
pos = pts->m_Start; pos = pts->m_Start;
if( g_pcb_plot_options.DrillShapeOpt == PCB_Plot_Options::SMALL_DRILL_SHAPE ) if( g_pcb_plot_options.DrillShapeOpt ==
PCB_Plot_Options::SMALL_DRILL_SHAPE )
diam.x = diam.y = SMALL_DRILL; diam.x = diam.y = SMALL_DRILL;
else else
diam.x = diam.y = pts->GetDrillValue(); diam.x = diam.y = pts->GetDrillValue();
...@@ -983,7 +1045,10 @@ void WinEDA_BasePcbFrame::PlotDrillMark( PLOTTER* aPlotter, GRTraceMode aTraceMo ...@@ -983,7 +1045,10 @@ void WinEDA_BasePcbFrame::PlotDrillMark( PLOTTER* aPlotter, GRTraceMode aTraceMo
if( PtPad->m_DrillShape == PAD_OVAL ) if( PtPad->m_DrillShape == PAD_OVAL )
{ {
diam = PtPad->m_Drill; diam = PtPad->m_Drill;
aPlotter->flash_pad_oval( pos, diam, PtPad->m_Orient, aTraceMode ); aPlotter->flash_pad_oval( pos,
diam,
PtPad->m_Orient,
aTraceMode );
} }
else else
{ {
......
/*******************************/ /******************/
/**** Routine de trace HPGL ****/ /**** Plot DXF ****/
/*******************************/ /******************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
#include "protos.h" #include "protos.h"
/*****************************************************************************/
void WinEDA_BasePcbFrame::Genere_DXF( const wxString& FullFileName, int Layer, void WinEDA_BasePcbFrame::Genere_DXF( const wxString& FullFileName, int Layer,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/*****************************************************************************/
{ {
Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc; Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc;
...@@ -34,7 +32,7 @@ void WinEDA_BasePcbFrame::Genere_DXF( const wxString& FullFileName, int Layer, ...@@ -34,7 +32,7 @@ void WinEDA_BasePcbFrame::Genere_DXF( const wxString& FullFileName, int Layer,
DXF_PLOTTER* plotter = new DXF_PLOTTER(); DXF_PLOTTER* plotter = new DXF_PLOTTER();
plotter->set_paper_size( currentsheet ); plotter->set_paper_size( currentsheet );
plotter->set_viewport( wxPoint(0,0), 1, 0 ); plotter->set_viewport( wxPoint( 0, 0 ), 1, 0 );
plotter->set_creator( wxT( "PCBNEW-DXF" ) ); plotter->set_creator( wxT( "PCBNEW-DXF" ) );
plotter->set_filename( FullFileName ); plotter->set_filename( FullFileName );
plotter->start_plot( output_file ); plotter->start_plot( output_file );
......
/*******************************/ /*******************/
/**** Routine de trace HPGL ****/ /**** Plot HPGL ****/
/*******************************/ /*******************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -12,10 +12,9 @@ ...@@ -12,10 +12,9 @@
#include "protos.h" #include "protos.h"
/*****************************************************************************/
void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer, void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/*****************************************************************************/
{ {
wxSize SheetSize; wxSize SheetSize;
wxSize BoardSize; wxSize BoardSize;
...@@ -28,7 +27,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer, ...@@ -28,7 +27,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
ClearMsgPanel(); ClearMsgPanel();
// Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units, // Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units,
// with plot scale (if Scale is 2, pen diametre is always g_HPGL_Pen_Diam // with plot scale (if Scale is 2, pen diameter is always g_HPGL_Pen_Diam
// so apparent pen diam is real pen diam / Scale // so apparent pen diam is real pen diam / Scale
int pen_diam = wxRound( (g_pcb_plot_options.HPGL_Pen_Diam * U_PCB) / g_pcb_plot_options.Scale ); int pen_diam = wxRound( (g_pcb_plot_options.HPGL_Pen_Diam * U_PCB) / g_pcb_plot_options.Scale );
...@@ -53,14 +52,14 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer, ...@@ -53,14 +52,14 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
AppendMsgPanel( _( "File" ), FullFileName, CYAN ); AppendMsgPanel( _( "File" ), FullFileName, CYAN );
if( g_pcb_plot_options.PlotScaleOpt != 1 ) if( g_pcb_plot_options.PlotScaleOpt != 1 )
Center = TRUE; // Echelle != 1 donc trace centree du PCB Center = TRUE; // Scale != 1 so center PCB plot.
// calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce ) // Scale units from 0.0001" to HPGL plot units.
SheetSize.x = currentsheet->m_Size.x * U_PCB; SheetSize.x = currentsheet->m_Size.x * U_PCB;
SheetSize.y = currentsheet->m_Size.y * U_PCB; SheetSize.y = currentsheet->m_Size.y * U_PCB;
/* calcul des dimensions et centre du PCB */ /* Calculate the center of the PCB. */
m_Pcb->ComputeBoundaryBox(); m_Pcb->ComputeBoundaryBox();
BoardSize = m_Pcb->m_BoundaryBox.GetSize(); BoardSize = m_Pcb->m_BoundaryBox.GetSize();
BoardCenter = m_Pcb->m_BoundaryBox.Centre(); BoardCenter = m_Pcb->m_BoundaryBox.Centre();
...@@ -70,18 +69,18 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer, ...@@ -70,18 +69,18 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
double Xscale, Yscale; double Xscale, Yscale;
// Fit to 80% of the page // Fit to 80% of the page
Xscale = ( (SheetSize.x * 0.8) / BoardSize.x ); Xscale = ( ( SheetSize.x * 0.8 ) / BoardSize.x );
Yscale = ( (SheetSize.y * 0.8) / BoardSize.y ); Yscale = ( ( SheetSize.y * 0.8 ) / BoardSize.y );
scale = MIN( Xscale, Yscale ); scale = MIN( Xscale, Yscale );
} }
else else
scale = g_pcb_plot_options.Scale; scale = g_pcb_plot_options.Scale;
// Calcul du cadrage (echelle != 1 donc recadrage du trace) // Calculate the page size offset.
if( Center ) if( Center )
{ {
offset.x = BoardCenter.x - (SheetSize.x / 2) / scale; offset.x = BoardCenter.x - ( SheetSize.x / 2 ) / scale;
offset.y = BoardCenter.y - (SheetSize.y / 2) / scale; offset.y = BoardCenter.y - ( SheetSize.y / 2 ) / scale;
} }
else else
{ {
......
/*************************************/ /*************************/
/**** Pcbnew: Routine de trace PS ****/ /**** Plot Postscript ****/
/*************************************/ /*************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -12,14 +12,12 @@ ...@@ -12,14 +12,12 @@
#include "protos.h" #include "protos.h"
/****************************************************************************/
void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
bool useA4, GRTraceMode trace_mode )
/****************************************************************************/
/* Genere un fichier POSTSCRIPT (*.ps) de trace du circuit, couche layer /* Generate a PostScript file (*. ps) of the circuit layer.
* if layer < 0: all layers * If layer < 0: all layers are plotted.
*/ */
void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
bool useA4, GRTraceMode trace_mode )
{ {
wxSize SheetSize; wxSize SheetSize;
wxSize PaperSize; wxSize PaperSize;
...@@ -45,13 +43,12 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer, ...@@ -45,13 +43,12 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
AppendMsgPanel( _( "File" ), FullFileName, CYAN ); AppendMsgPanel( _( "File" ), FullFileName, CYAN );
if( g_pcb_plot_options.PlotScaleOpt != 1 ) if( g_pcb_plot_options.PlotScaleOpt != 1 )
Center = TRUE; // Echelle != 1 donc trace centree du PCB Center = TRUE; // Scale != 1 so center plot.
// Set default line width // Set default line width
if( g_pcb_plot_options.PlotLine_Width < 1 ) if( g_pcb_plot_options.PlotLine_Width < 1 )
g_pcb_plot_options.PlotLine_Width = 1; g_pcb_plot_options.PlotLine_Width = 1;
// calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce )
SheetSize.x = currentsheet->m_Size.x * U_PCB; SheetSize.x = currentsheet->m_Size.x * U_PCB;
SheetSize.y = currentsheet->m_Size.y * U_PCB; SheetSize.y = currentsheet->m_Size.y * U_PCB;
...@@ -69,7 +66,6 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer, ...@@ -69,7 +66,6 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
paperscale = 1; paperscale = 1;
} }
/* calcul des dimensions et centre du PCB */
m_Pcb->ComputeBoundaryBox(); m_Pcb->ComputeBoundaryBox();
BoardSize = m_Pcb->m_BoundaryBox.GetSize(); BoardSize = m_Pcb->m_BoundaryBox.GetSize();
BoardCenter = m_Pcb->m_BoundaryBox.Centre(); BoardCenter = m_Pcb->m_BoundaryBox.Centre();
...@@ -86,11 +82,10 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer, ...@@ -86,11 +82,10 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
else else
scale = g_pcb_plot_options.Scale * paperscale; scale = g_pcb_plot_options.Scale * paperscale;
// Calcul du cadrage (echelle != 1 donc recadrage du trace)
if( Center ) if( Center )
{ {
offset.x = BoardCenter.x - (PaperSize.x / 2) / scale; offset.x = BoardCenter.x - ( PaperSize.x / 2 ) / scale;
offset.y = BoardCenter.y - (PaperSize.y / 2) / scale; offset.y = BoardCenter.y - ( PaperSize.y / 2 ) / scale;
} }
else else
{ {
......
...@@ -12,20 +12,20 @@ ...@@ -12,20 +12,20 @@
#include "pcbplot.h" #include "pcbplot.h"
#include "protos.h" #include "protos.h"
/* Local functions */
static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module,
int draw_mode, int masklayer ); int draw_mode, int masklayer );
/************************************************************************************************************/
void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMaskLayer, bool aPrintMirrorMode )
/************************************************************************************************************/
/** Function PrintPage /** Function PrintPage
* Used to print the board (on printer, or when creating SVF files). * Used to print the board (on printer, or when creating SVF files).
* Print the board, but only layers allowed by aPrintMaskLayer * Print the board, but only layers allowed by aPrintMaskLayer
* ( printmasklayer is a 32 bits mask: bit n = 1 -> layer n is printed) * ( printmasklayer is a 32 bits mask: bit n = 1 -> layer n is printed)
*/ */
void WinEDA_DrawPanel::PrintPage( wxDC* aDC,
bool aPrint_Sheet_Ref,
int aPrintMaskLayer,
bool aPrintMirrorMode )
{ {
MODULE* Module; MODULE* Module;
int drawmode = GR_COPY; int drawmode = GR_COPY;
...@@ -61,14 +61,13 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa ...@@ -61,14 +61,13 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa
m_PrintIsMirrored = aPrintMirrorMode; m_PrintIsMirrored = aPrintMirrorMode;
// The OR mode is used in color mode, but be aware the backgroud *must be BLACK. // The OR mode is used in color mode, but be aware the backgroud *must be
// In print page dialog, we first plrint in BLACK, and after reprint in color, // BLACK. In the print page dialog, we first plrint in BLACK, and after
// on the black "local" backgroud, in OR mode // reprint in color, on the black "local" backgroud, in OR mode the black
// the black print is not made before, only a white page is printed // print is not made before, only a white page is printed
if( GetGRForceBlackPenState( ) == false ) if( GetGRForceBlackPenState() == false )
drawmode = GR_OR; drawmode = GR_OR;
/* Print the pcb graphic items (texts, ...) */ /* Print the pcb graphic items (texts, ...) */
GRSetDrawMode( aDC, drawmode ); GRSetDrawMode( aDC, drawmode );
for( BOARD_ITEM* item = Pcb->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = Pcb->m_Drawings; item; item = item->Next() )
...@@ -79,13 +78,13 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa ...@@ -79,13 +78,13 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa
case TYPE_COTATION: case TYPE_COTATION:
case TYPE_TEXTE: case TYPE_TEXTE:
case TYPE_MIRE: case TYPE_MIRE:
if( ((1<<item->GetLayer()) & aPrintMaskLayer) == 0 ) if( ( ( 1 << item->GetLayer() ) & aPrintMaskLayer ) == 0 )
break; break;
item->Draw( this, aDC, drawmode ); item->Draw( this, aDC, drawmode );
break; break;
case TYPE_MARKER_PCB: /* Trace des marqueurs */ case TYPE_MARKER_PCB:
default: default:
break; break;
} }
...@@ -97,13 +96,19 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa ...@@ -97,13 +96,19 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa
{ {
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 ) if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue; continue;
if( pt_piste->Type() == TYPE_VIA ) /* VIA rencontree */ if( pt_piste->Type() == TYPE_VIA ) /* VIA encountered. */
{ {
int rayon = pt_piste->m_Width >> 1; int rayon = pt_piste->m_Width >> 1;
int color = g_DesignSettings.m_ViaColor[pt_piste->m_Shape]; int color = g_DesignSettings.m_ViaColor[pt_piste->m_Shape];
GRSetDrawMode( aDC, drawmode ); GRSetDrawMode( aDC, drawmode );
GRFilledCircle( &m_ClipBox, aDC, pt_piste->m_Start.x, pt_piste->m_Start.y, GRFilledCircle( &m_ClipBox,
rayon, 0, color, color ); aDC,
pt_piste->m_Start.x,
pt_piste->m_Start.y,
rayon,
0,
color,
color );
} }
else else
pt_piste->Draw( this, aDC, drawmode ); pt_piste->Draw( this, aDC, drawmode );
...@@ -121,38 +126,46 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa ...@@ -121,38 +126,46 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa
/* Draw filled areas (i.e. zones) */ /* Draw filled areas (i.e. zones) */
for( int ii = 0; ii < Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < Pcb->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* zone = Pcb->GetArea(ii); ZONE_CONTAINER* zone = Pcb->GetArea( ii );
if( ( aPrintMaskLayer & (1 << zone->GetLayer()) ) == 0 ) if( ( aPrintMaskLayer & ( 1 << zone->GetLayer() ) ) == 0 )
continue; continue;
zone->DrawFilledArea( this, aDC, drawmode ); zone->DrawFilledArea( this, aDC, drawmode );
} }
// Draw footprints, this is done at last in order to print the pad holes in white (or g_DrawBgColor) // Draw footprints, this is done at last in order to print the pad holes in
// after the tracks and zones // white (or g_DrawBgColor) after the tracks and zones
Module = (MODULE*) Pcb->m_Modules; Module = (MODULE*) Pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
{ {
Print_Module( this, aDC, Module, drawmode, aPrintMaskLayer ); Print_Module( this, aDC, Module, drawmode, aPrintMaskLayer );
} }
/* Print via holes in bg color: Not sure it is good for buried or blind vias */ /* Print via holes in bg color: Not sure it is good for buried or blind
* vias */
pt_piste = Pcb->m_Track; pt_piste = Pcb->m_Track;
int color = g_DrawBgColor; int color = g_DrawBgColor;
bool blackpenstate = GetGRForceBlackPenState( ); bool blackpenstate = GetGRForceBlackPenState();
GRForceBlackPen( false ); GRForceBlackPen( false );
GRSetDrawMode( aDC, GR_COPY ); GRSetDrawMode( aDC, GR_COPY );
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() ) for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
{ {
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 ) if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue; continue;
if( pt_piste->Type() == TYPE_VIA ) /* VIA rencontree */ if( pt_piste->Type() == TYPE_VIA ) /* VIA encountered. */
{ {
int rayon = pt_piste->GetDrillValue() / 2; int rayon = pt_piste->GetDrillValue() / 2;
GRFilledCircle( &m_ClipBox, aDC, pt_piste->m_Start.x, pt_piste->m_Start.y, GRFilledCircle( &m_ClipBox,
rayon, 0, color, color ); aDC,
pt_piste->m_Start.x,
pt_piste->m_Start.y,
rayon,
0,
color,
color );
} }
} }
GRForceBlackPen( blackpenstate ); GRForceBlackPen( blackpenstate );
if( aPrint_Sheet_Ref ) if( aPrint_Sheet_Ref )
...@@ -168,10 +181,8 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa ...@@ -168,10 +181,8 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMa
} }
/***********************************************************/
static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC, static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC,
MODULE* Module, int draw_mode, int masklayer ) MODULE* Module, int draw_mode, int masklayer )
/***********************************************************/
{ {
D_PAD* pt_pad; D_PAD* pt_pad;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
...@@ -184,14 +195,18 @@ static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -184,14 +195,18 @@ static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
if( (pt_pad->m_Masque_Layer & masklayer ) == 0 ) if( (pt_pad->m_Masque_Layer & masklayer ) == 0 )
continue; continue;
// Usually we draw pads in sketch mode on non copper layers: // Usually we draw pads in sketch mode on non copper layers:
if ( (masklayer & ALL_CU_LAYERS) == 0 ) if( (masklayer & ALL_CU_LAYERS) == 0 )
{ {
int tmp_fill = ((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill; int tmp_fill =
( (WinEDA_BasePcbFrame*) panel->m_Parent )->m_DisplayPadFill;
// Switch in sketch mode // Switch in sketch mode
((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = 0; ( (WinEDA_BasePcbFrame*) panel->m_Parent )->m_DisplayPadFill = 0;
pt_pad->Draw( panel, DC, draw_mode ); pt_pad->Draw( panel, DC, draw_mode );
((WinEDA_BasePcbFrame*)panel->m_Parent)->m_DisplayPadFill = tmp_fill; ( (WinEDA_BasePcbFrame*) panel->m_Parent )->m_DisplayPadFill =
tmp_fill;
} }
else // on copper layer, draw pads according to current options else // on copper layer, draw pads according to current options
pt_pad->Draw( panel, DC, draw_mode ); pt_pad->Draw( panel, DC, draw_mode );
...@@ -207,9 +222,9 @@ static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -207,9 +222,9 @@ static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC,
if( mlayer & masklayer ) if( mlayer & masklayer )
{ {
if( ! Module->m_Reference->m_NoShow ) if( !Module->m_Reference->m_NoShow )
Module->m_Reference->Draw( panel, DC, draw_mode ); Module->m_Reference->Draw( panel, DC, draw_mode );
if( ! Module->m_Value->m_NoShow ) if( !Module->m_Value->m_NoShow )
Module->m_Value->Draw( panel, DC, draw_mode ); Module->m_Value->Draw( panel, DC, draw_mode );
} }
...@@ -228,7 +243,7 @@ static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -228,7 +243,7 @@ static void Print_Module( WinEDA_DrawPanel* panel, wxDC* DC,
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
{ {
EDGE_MODULE* edge = (EDGE_MODULE*) PtStruct; EDGE_MODULE* edge = (EDGE_MODULE*) PtStruct;
if( (g_TabOneLayerMask[edge->GetLayer()] & masklayer ) == 0 ) if( ( g_TabOneLayerMask[edge->GetLayer()] & masklayer ) == 0 )
break; break;
edge->Draw( panel, DC, draw_mode ); edge->Draw( panel, DC, draw_mode );
break; break;
......
/***************************************/ /***********/
/* prototypage des fonctions de PCBNEW */ /* protos.h */
/***************************************/ /***********/
#ifndef PROTO_H #ifndef PROTO_H
#define PROTO_H #define PROTO_H
...@@ -22,11 +22,12 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ); ...@@ -22,11 +22,12 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage );
/* install function for DialogNonCopperZonesEditor dialog frame :*/ /* install function for DialogNonCopperZonesEditor dialog frame :*/
bool InstallDialogNonCopperZonesEditor(WinEDA_PcbFrame* aParent, ZONE_CONTAINER* aZone); bool InstallDialogNonCopperZonesEditor( WinEDA_PcbFrame* aParent,
ZONE_CONTAINER* aZone );
/***************/ /*******************/
/* PAD_CONNECT.CPP */ /* PAD_CONNECT.CPP */
/***************/ /*******************/
class D_PAD; class D_PAD;
...@@ -43,7 +44,7 @@ void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector ); ...@@ -43,7 +44,7 @@ void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector );
/* Create a sorted list of pointers to pads. /* Create a sorted list of pointers to pads.
* This list is sorted by X ccordinate value. * This list is sorted by X coordinate value.
* The list must be freed bu user * The list must be freed bu user
*/ */
...@@ -57,45 +58,46 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ); ...@@ -57,45 +58,46 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/* TRPISTE.CPP */ /* TRPISTE.CPP */
/***************/ /***************/
/* Routine trace of n consecutive segments in memory.
* Useful for mounting a track record for being the segments that
* Tracks are contiguous in memory
* Parameters:
* Pt_start_piste = starting address of the list of segments
* Nbsegment = number of segments was traced
* Mode_color = mode (GrXOR, Gror ..)
* CAUTION:
* The starting point of a track following MUST exist: may be
* Then put a 0 before calling a routine if the track is the last draw
*/
void Trace_Une_Piste( WinEDA_DrawPanel* panel, void Trace_Une_Piste( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
TRACK* pt_start_piste, TRACK* pt_start_piste,
int nbsegment, int nbsegment,
int mode_color ); int mode_color );
/* routine de trace de n segments consecutifs en memoire.
* Utile pour monter une piste en cours de trace car les segments de cette
* piste sont alors contigus en memoire
* Parametres :
* pt_start_piste = adresse de depart de la liste des segments
* nbsegment = nombre de segments a tracer
* mode_color = mode ( GrXOR, GrOR..)
* ATTENTION:
* le point de depart d'une piste suivante DOIT exister: peut etre
* donc mis a 0 avant appel a la routine si la piste a tracer est la derniere
*/
/****************/ /****************/
/* TRACEMOD.C : */ /* TRACEMOD.C : */
/****************/ /****************/
void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, int ox, int oy,
int MasqueLayer, int mode_color );
/* Trace les pads d'un module en mode SKETCH. /* Trace the pads of a module in sketch mode.
* Utilisee pour afficher les pastilles d'un module lorsque celui ci n'est * Used to display a module pads when it is not displayed by the display
* pas affiche par les options d'affichage des Modules * options Module.
* Les pads affiches doivent apparaitre sur les couches donnees par * The pads must appear on the data layers by MasqueLayer
* MasqueLayer */ */
void Trace_Pads_Only( WinEDA_DrawPanel* panel,
wxDC* DC,
MODULE* Module,
int ox,
int oy,
int MasqueLayer,
int mode_color );
/****************/ /****************/
/* LOCATE.CPP : */ /* LOCATE.CPP : */
/****************/ /****************/
/* Recherche d'une empreinte par son nom */ /* Find a pad by it's name om the module. */
/* Recherche d'un pad par son nom, pour le module Module */
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 ); TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 );
/** /**
...@@ -106,130 +108,126 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 ); ...@@ -106,130 +108,126 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 );
* @param aLayer The layer to match, pass -1 for a don't care. * @param aLayer The layer to match, pass -1 for a don't care.
* @return TRACK* - actually a SEGVIA* if found, else NULL. * @return TRACK* - actually a SEGVIA* if found, else NULL.
*/ */
TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& aPos, int aLayer = -1 ); TRACK* Locate_Via_Area( TRACK* aStart,
const wxPoint& aPos,
int aLayer = -1 );
/* Locates the center through the point x, y, on layer data
* by masquelayer.
* Search is done to address start_adr has end_adr (not included)
*/
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
const wxPoint& pos, int masquelayer ); const wxPoint& pos, int masquelayer );
/* Localise la via de centre le point x,y , sur les couches donnees /* Locates the center through the point x, y, on layer data
* par masquelayer. * by masquelayer.
* la recherche se fait de l'adresse start_adr a end_adr(non comprise) * Search is done to address start_adr has end_adr (not included)
*/ */
TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
const wxPoint& ref_pos, int masquelayer ); const wxPoint& ref_pos, int masquelayer );
/* Localiste le segment dont une extremite coincide avec le point x,y /* Search for segment connected to the segment edge by
* sur les couches donnees par masquelayer * Ptr_piste:
* la recherche se fait de l'adresse start_adr a end_adr(non comprise) * If int = START, the point of beginning of the segment is used
* If int = END, the end point of the segment is used
* The search is done only on the ends of segments
* The search is limited to the area [... pt_base] pt_lim.
*/ */
TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base, TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base,
TRACK* pt_lim, int extr ); TRACK* pt_lim, int extr );
/* recherche le segment connecte au segment pointe par /*
* ptr_piste: * 1 - Locate segment of track leading from the mouse.
* si int = START, le point de debut du segment est utilise * 2 - Locate segment of track point by point.
* si int = END, le point de fin du segment est utilise * Ref_pX, ref_pY.
* La recherche ne se fait que sur les EXTREMITES des segments *
* La recherche est limitee a la zone [pt_base...]pt_lim. * If layer <0 the layer is not tested.
*
* The search begins to address start_adresse
*/ */
TRACK* Locate_Pistes( TRACK* start_adresse, int layer, int typeloc ); TRACK* Locate_Pistes( TRACK* start_adresse, int layer, int typeloc );
TRACK* Locate_Pistes( TRACK* start_adresse, TRACK* Locate_Pistes( TRACK* start_adresse,
const wxPoint& ref_pos, int layer ); const wxPoint& ref_pos, int layer );
/* /* Locate pad connected to the beginning or end of a segment
* 1 - routine de localisation du segment de piste pointe par la souris. * Input: pointer to the segment, and flag = START or END
* 2 - routine de localisation du segment de piste pointe par le point * Returns:
* ref_pX , ref_pY. * A pointer to the description of the patch if pad was found.
* * NULL pointer if pad was not found.
* Si layer < 0 la couche n'est pas testee.
*
* La recherche commence a l'adresse start_adresse
*/ */
D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_segment, int extr ); D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_segment, int extr );
/* localisation de la pastille connectee au debut ou fin du segment
* entree : pointeur sur le segment, et flag = START ou END
* retourne:
* un pointeur sur la description de la pastille si localisation
* pointeur NULL si pastille non trouvee */
D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer = FALSE );
D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, bool OnlyCurrentLayer = FALSE );
/* /*
* localisation de la pastille pointee par la coordonnee ref_pX,,ref_pY, ou * Locate pad pointed to by the coordinate ref_pX,, ref_pY or the current
* par la souris, recherche faite sur toutes les empreintes. * cursor position, search done on all tracks.
* entree : (OVERHAEAD) * Entry:
* - coord souris (Curseur_X et Curseur_Y) * - Mouse coord (Curseur_X and Curseur_Y)
* ou ref_pX, ref_pY * Or ref_pX, ref_pY
* retourne: * Returns:
* pointeur sur la description de la pastille si localisation * Pointer to the pad if found
* pointeur NULL si pastille non trouvee * NULL pointer if pad not found
*/
D_PAD* Locate_Any_Pad( BOARD* Pcb,
int typeloc,
bool OnlyCurrentLayer = FALSE );
D_PAD* Locate_Any_Pad( BOARD* Pcb,
const wxPoint& ref_pos,
bool OnlyCurrentLayer = FALSE );
/* Locate pad pointed to by the coordinate ref_pX,, ref_pY or the cursor
* position of the current footprint.
* Input:
* - The module to search.
* - Layer to search or -1 to search all layers.
* Returns:
* A pointer to the pad if found otherwise NULL.
*/ */
D_PAD* Locate_Pads( MODULE* Module, int layer, int typeloc ); D_PAD* Locate_Pads( MODULE* Module, int layer, int typeloc );
D_PAD* Locate_Pads( MODULE* Module, const wxPoint& ref_pos, int layer ); D_PAD* Locate_Pads( MODULE* Module, const wxPoint& ref_pos, int layer );
/* localisation de la pastille pointee par la coordonnee ref_pX,,ref_pY, ou /* Locate a footprint by its bounding rectangle. */
* par la souris, concernant l'empreinte en cours.
* entree :
* - parametres generaux de l'empreinte mise a jous par caract()
* - layer = couche ou doit se trouver la pastille
* (si layer < 0 ) la couche est ignoree)
* retourne:
* un pointeur sur la description de la pastille si localisation
* pointeur NULL si pastille non trouvee
*/
MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ); MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc );
/* localisation d'une empreinte par son rectangle d'encadrement */ /* Locate a pad pointed to by the cursor on the footprint.
D_PAD* Locate_Pads( MODULE* Module, int typeloc );
/* localisation de la pastille pointee par la souris, concernant l'empreinte
* Module. * Module.
* entree : * Input:
* - parametres generaux de l'empreinte mise a jous par caract() * - Module to search.
* retourne: * Returns:
* un pointeur sur la description de la pastille si localisation * A pointer to the pad if found otherwise NULL.
* pointeur NULL si pastille non trouvee
*/ */
D_PAD* Locate_Pads( MODULE* Module, int typeloc );
/* Locate a trace segment at the current cursor position.
* The search begins to address start_adresse.
*/
TRACK* Locate_Pistes( TRACK* start_adresse, int typeloc ); TRACK* Locate_Pistes( TRACK* start_adresse, int typeloc );
/* routine de localisation du segment de piste pointe par la souris
* La recherche commence a l'adresse start_adresse */
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc ); DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc );
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int layer ); /* Locate pad containing the point px, py, layer on layer.
/* Routine cherchant le pad contenant le point px,py, sur la couche layer
* ( extremite de piste )
* La liste des pads doit deja exister.
* *
* retourne : * The list of pads must already exist.
* NULL si pas de pad localise. *
* pointeur sur le pad correspondante si pad trouve * Returns:
* (bonne position ET bonne couche). */ * Pointer to the pad if found, otherwise NULL.
*/
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb,
TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc ); const wxPoint& ref_pos,
TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer ); int layer );
/* /*
* 1 - routine de localisation du segment de zone pointe par la souris. * 1 - Locate trace segment at the current cursor position.
* 2 - routine de localisation du segment de zone pointe par le point * 2 - Locate trace segment at the given coordinates ref_pos.
* ref_pX , ref_pY.r
* *
* Si layer == -1 , le tst de la couche n'est pas fait * If layer == -1, check all layers.
* *
* La recherche commence a l'adresse start_adresse * The search begins to address start_adresse
*/ */
TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc );
TRACK* Locate_Zone( TRACK* start_adresse,
const wxPoint& ref_pos,
int layer );
/*************/ /*************/
...@@ -237,12 +235,15 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int l ...@@ -237,12 +235,15 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int l
/*************/ /*************/
int ChangeSideNumLayer( int oldlayer ); int ChangeSideNumLayer( int oldlayer );
void DrawModuleOutlines( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module ); void DrawModuleOutlines( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* module );
void Montre_Position_Empreinte( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); void Montre_Position_Empreinte( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
/* LOADCMP.C : */ /* LOADCMP.C : */
MODULE* Load_Module_From_Library( WinEDA_DrawFrame* frame, wxDC* DC ); MODULE* Load_Module_From_Library( WinEDA_DrawFrame* frame, wxDC* DC );
/****************/ /****************/
/* EDITRACK.C : */ /* EDITRACK.C : */
/****************/ /****************/
...@@ -252,108 +253,119 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ); ...@@ -252,108 +253,119 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack );
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC, bool erase ); wxDC* DC, bool erase );
/* Determine coordinate for a segment direction of 0, 90 or 45 degrees,
* depending on it's position from the origin (ox, oy) and the current
* cursor position.
*/
void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ); void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy );
/* determine les coord fx et fy d'un segment
* pour avoir un segment oriente a 0, 90 ou 45 degres, selon position
* du point d'origine (ox,oy) et de la souris */
/*****************/ /*****************/
/* TRACK.CPP : */ /* TRACK.CPP : */
/*****************/ /*****************/
/** /**
* Function Marque_Une_Piste * Function Marque_Une_Piste
* marks a chain of track segments, connected to aTrackList. * marks a chain of track segments, connected to aTrackList.
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical continuity * Each segment is marked by setting the BUSY bit into m_Flags. Electrical
* is detected by walking each segment, and finally the segments are rearranged * continuity is detected by walking each segment, and finally the segments
* into a contiguous chain within the given list. * are rearranged into a contiguous chain within the given list.
* @param aPcb = the board to analyse *
* @param aStartSegm The first interesting segment within a list of track segment of aPcb * @param aPcb = the board to analyze
* @param aSegmCount = a pointer to an integer where to return the number of interesting segments * @param aStartSegm - The first interesting segment within a list of track
* @param aTrackLen = a pointer to an integer where to return the lenght of the track * segment of aPcb
* @param aReorder = * @param aSegmCount = a pointer to an integer where to return the number of
* true for reorder the interesting segments (useful for track edition/deletion) * interesting segments
* in this case the flag BUSY is set (the user is responsible of flag clearing) * @param aTrackLen = a pointer to an integer where to return the lenght of the
* false for no reorder : useful when we want just calculate the track lenght * track
* in this case, flags are reset * @param aReorder = true for reorder the interesting segments (useful for
* track edition/deletion) in this case the flag BUSY is
* set (the user is responsible of flag clearing). False
* for no reorder : useful when we want just calculate the
* track length in this case, flags are reset
* @return TRACK* the first in the chain of interesting segments. * @return TRACK* the first in the chain of interesting segments.
*/ */
TRACK* Marque_Une_Piste( BOARD * aPcb, TRACK* aStartSegm, int* aSegmCount, int * aTrackLen, bool aReorder ); TRACK* Marque_Une_Piste( BOARD* aPcb,
TRACK* aStartSegm,
int* aSegmCount,
int* aTrackLen,
bool aReorder );
/* Calculate end coordinate of a trace.
* Returns 1 if OK, 0 if trace looped back on itself.
* The coord are returned StartTrack-> ox, oy
* And EndTrack-> fx, fy if OK
* The segments are drawn consecutively.
*/
int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
TRACK** StartTrack, TRACK** EndTrack ); TRACK** StartTrack, TRACK** EndTrack );
/* Calcule les coordonnes des extremites d'une piste /* Update the state of a list of structures. */
* retourne 1 si OK, 0 si piste bouclee
* Les coord sont retournees en StartTrack->ox, oy
* et EndTrack->fx, fy si OK
* Les segments sont supposes chaines de facon consecutive */
void ListSetState( EDA_BaseStruct* Start, int Nbitem, int State, int onoff ); void ListSetState( EDA_BaseStruct* Start, int Nbitem, int State, int onoff );
/* Met a jour le membre .state d'une chaine de structures */
/**************/ /**************/
/* CLEAN.CPP : */ /* CLEAN.CPP : */
/**************/ /**************/
/* Remove segments connected incorrectly.
*/
int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche ); int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche );
/* Supprime les segments mal connectes, cad interconnectant des segments
* de net_code differents */
/************/ /************/
/* ZONES.CPP */ /* ZONES.CPP */
/************/ /************/
int Propagation( WinEDA_PcbFrame* frame ); int Propagation( WinEDA_PcbFrame* frame );
/***************/ /****************/
/* ATTRIBUT.CPP */ /* ATTRIBUT.CPP */
/***************/ /****************/
void MasqueAttributs( int* masque_set, int* masque_clr );
/* Calcule les attributs a remettre a 0 (masque_clr) et a mettre a 1 /* Compute the attributes that are 0 (masque_clr) and put a 1
* (masque_set), en fonction des options d'attributs * (Masque_set), depending on the options attribute.
* *
* ces attributs sont normalement le membre .flags de la structure TRACK * These attributes are normally the member flags of the structure TRACK
* les pointeurs NULLs sont acceptes * Pointers NULLs are accepted.
*/ */
void MasqueAttributs( int* masque_set, int* masque_clr );
/***************/ /***************/
/* DUPLTRAC.CPP */ /* DUPLTRAC.CPP */
/***************/ /***************/
/* Routine trouvant le point " d'accrochage " d'une extremite de piste. /* Routine to find the point "attachment" at the end of a trace.
* Ce point peut etre un PAD ou un autre segment de piste * This may be a PAD or another trace segment.
* Retourne: * Returns:
* - pointeur sur ce PAD ou: * - Pointer to the PAD or:
* - pointeur sur le segment ou: * - Pointer to the segment or:
* - NULL * - NULL
* Parametres d'appel: * Parameters:
* coord aPos du point tst * - aPos - coordinate point test
* aLayerMask masque des couches a tester * ALayerMask of mask layers to be tested
*/ */
BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask ); BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask );
/* Create an intermediate point on a segment
/* Routine de creation d'un point intermediaire sur un segment * ASegm segment is broken into 2 segments connecting point pX, pY
* le segment aSegm est casse en 2 segments se raccordant au point pX, pY * Returns:
* retourne: * NULL if no new point (ie if aRefPoint already corresponded
* NULL si pas de nouveau point ( c.a.d si aRefPoint correspondait deja * At one end where:
* a une extremite ou: * Pointer to the segment created
* pointeur sur le segment cree * If aRefSegm! Refsegm = NULL pointer is on the segment
* si aRefSegm != NULL refsegm est pointeur sur le segment incident, * Created and the point is the intersection of 2 lines segments ptsegm
* et le point cree est l'intersection des 2 axes des segments ptsegm et aRefSegm * and aRefSegm
* retourne la valeur exacte de aRefPoint * Returns the exact value of aRefPoint
* Si aSegm pointe sur une via: * If aSegm points to a via:
* retourne la valeur exacte de aRefPoint et aSegm, * Returns the exact value of aRefPoint and aSegm, but does not create
* mais ne cree pas de point supplementaire * extra point
*/ */
TRACK* CreateLockPoint( wxPoint & aRefPoint, TRACK* aSegm, TRACK* aRefSegm, PICKED_ITEMS_LIST* aItemsListPicker ); TRACK* CreateLockPoint( wxPoint& aRefPoint,
TRACK* aSegm,
TRACK* aRefSegm,
PICKED_ITEMS_LIST* aItemsListPicker );
/****************/ /****************/
/* CONTROLE.CPP */ /* CONTROLE.CPP */
...@@ -365,17 +377,18 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ); ...@@ -365,17 +377,18 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track );
/***************/ /***************/
/* AUTOROUT.CPP */ /* AUTOROUT.CPP */
/***************/ /***************/
void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC ); /* routine de Debug */ void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC ); /* for Debugging */
/**************/ /**************/
/* NETLIST.CPP */ /* NETLIST.CPP */
/**************/ /**************/
/* List the names of the modules of PCB
* Returns a pointer to the module selected or NULL if no selection.
*/
MODULE* ListAndSelectModuleName( COMMAND* Cmd ); MODULE* ListAndSelectModuleName( COMMAND* Cmd );
/* liste les noms des modules du PCB
* Retourne un pointeur sur le module selectionne
* ( ou NULL si pas de selection ) */
/*****************/ /*****************/
/* SET_COLOR.CPP */ /* SET_COLOR.CPP */
......
/*******************************************/ /*************/
/* EDITEUR de PCB: routines d'AUTOROUTAGE: */ /* queue.cpp */
/*******************************************/ /*************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
struct PcbQueue /* search queue structure */ struct PcbQueue /* search queue structure */
{ {
struct PcbQueue *Next; struct PcbQueue* Next;
int Row; /* current row */ int Row; /* current row */
int Col; /* current column */ int Col; /* current column */
int Side; /* 0=top, 1=bottom */ int Side; /* 0=top, 1=bottom */
...@@ -24,70 +24,63 @@ struct PcbQueue /* search queue structure */ ...@@ -24,70 +24,63 @@ struct PcbQueue /* search queue structure */
}; };
static long qlen = 0; /* current queue length */ static long qlen = 0; /* current queue length */
static struct PcbQueue *Head = NULL; static struct PcbQueue* Head = NULL;
static struct PcbQueue *Tail = NULL; static struct PcbQueue* Tail = NULL;
static struct PcbQueue *Save = NULL; /* hold empty queue structs */ static struct PcbQueue* Save = NULL; /* hold empty queue structs */
/* Routines definies ici : */
void InitQueue(); void InitQueue();
void GetQueue( int *, int *, int *, int *, int * ); void GetQueue( int*, int*, int*, int*, int* );
int SetQueue( int, int, int, int, int, int, int ); int SetQueue( int, int, int, int, int, int, int );
void ReSetQueue( int, int, int, int, int, int, int ); void ReSetQueue( int, int, int, int, int, int, int );
/************************/
void FreeQueue()
/************************/
/* Free the memory used for storing all the queue */ /* Free the memory used for storing all the queue */
void FreeQueue()
{ {
struct PcbQueue *p; struct PcbQueue* p;
InitQueue(); InitQueue();
while( (p = Save) != NULL ) while( (p = Save) != NULL )
{ {
Save = p->Next; MyFree(p); Save = p->Next; MyFree( p );
} }
} }
/************************/
/* void InitQueue() */
/************************/
/* initialize the search queue */ /* initialize the search queue */
void InitQueue() void InitQueue()
{ {
struct PcbQueue *p; struct PcbQueue* p;
while( (p = Head) != NULL ) while( (p = Head) != NULL )
{ {
Head = p->Next; Head = p->Next;
p->Next = Save; Save = p; p->Next = Save; Save = p;
} }
Tail = NULL; Tail = NULL;
OpenNodes = ClosNodes = MoveNodes = MaxNodes = qlen = 0; OpenNodes = ClosNodes = MoveNodes = MaxNodes = qlen = 0;
} }
/*********************************************************/
/* void GetQueue(int *r, int *c, int *s, int *d, int *a) */
/*********************************************************/
/* get search queue item from list */ /* get search queue item from list */
void GetQueue(int *r, int *c, int *s, int *d, int *a) void GetQueue( int* r, int* c, int* s, int* d, int* a )
{ {
struct PcbQueue *p; struct PcbQueue* p;
if( (p = Head) != NULL ) /* return first item in list */ if( (p = Head) != NULL ) /* return first item in list */
{ {
*r = p->Row; *c = p->Col; *r = p->Row; *c = p->Col;
*s = p->Side; *s = p->Side;
*d = p->Dist; *a = p->ApxDist; *d = p->Dist; *a = p->ApxDist;
if ((Head = p->Next) == NULL) Tail = NULL; if( (Head = p->Next) == NULL )
Tail = NULL;
/* put node on free list */ /* put node on free list */
p->Next = Save; Save = p; p->Next = Save; Save = p;
ClosNodes++; qlen--; ClosNodes++; qlen--;
} }
else /* empty list */ else /* empty list */
{ {
*r = *c = *s = *d = *a = ILLEGAL; *r = *c = *s = *d = *a = ILLEGAL;
...@@ -95,51 +88,53 @@ struct PcbQueue *p; ...@@ -95,51 +88,53 @@ struct PcbQueue *p;
} }
/****************************************************************/
int SetQueue (int r,int c,int side,int d,int a,int r2,int c2 )
/****************************************************************/
/* add a search node to the list /* add a search node to the list
Return: * Return:
1 si OK * 1 - OK
0 si defaut allocation Memoire * 0 - Failed to allocate memory.
*/ */
int SetQueue( int r, int c, int side, int d, int a, int r2, int c2 )
{ {
struct PcbQueue *p, *q, *t; struct PcbQueue* p, * q, * t;
int i, j; int i, j;
j = 0; // gcc warning fix j = 0; // gcc warning fix
if( (p = Save) != NULL ) /* try free list first */ if( (p = Save) != NULL ) /* try free list first */
{ {
Save = p->Next; Save = p->Next;
} }
else if ((p = (struct PcbQueue *) MyMalloc(sizeof(PcbQueue))) == NULL) else if( ( p = (struct PcbQueue*) MyMalloc( sizeof(PcbQueue) ) ) == NULL )
return(0); return 0;
p->Row = r; p->Row = r;
p->Col = c; p->Col = c;
p->Side = side; p->Side = side;
i = (p->Dist = d) + (p->ApxDist = a); i = (p->Dist = d) + (p->ApxDist = a);
p->Next = NULL; p->Next = NULL;
if( (q = Head) != NULL) if( (q = Head) != NULL ) /* insert in proper position in list */
{ /* insert in proper position in list */ {
if (q->Dist + q->ApxDist > i) if( q->Dist + q->ApxDist > i ) /* insert at head */
{ /* insert at head */ {
p->Next = q; Head = p; p->Next = q; Head = p;
} }
else { /* search for proper position */ else /* search for proper position */
for (t = q, q = q->Next; q && i > (j = q->Dist + q->ApxDist); {
t = q, q = q->Next) for( t = q, q = q->Next; q && i > ( j = q->Dist + q->ApxDist );
t = q, q = q->Next )
; ;
if (q && i == j && q->Row == r2 && q->Col == c2)
if( q && i == j && q->Row == r2 && q->Col == c2 )
{ {
/* insert after q, which is a goal node */ /* insert after q, which is a goal node */
if ( (p->Next = q->Next) == NULL) Tail = p; if( ( p->Next = q->Next ) == NULL )
Tail = p;
q->Next = p; q->Next = p;
} }
else else /* insert in front of q */
{ /* insert in front of q */ {
if ((p->Next = q) == NULL) Tail = p; if( ( p->Next = q ) == NULL )
Tail = p;
t->Next = p; t->Next = p;
} }
} }
...@@ -147,34 +142,40 @@ int SetQueue (int r,int c,int side,int d,int a,int r2,int c2 ) ...@@ -147,34 +142,40 @@ int SetQueue (int r,int c,int side,int d,int a,int r2,int c2 )
else /* empty search list */ else /* empty search list */
Head = Tail = p; Head = Tail = p;
OpenNodes++; OpenNodes++;
if (++qlen > MaxNodes) MaxNodes = qlen; if( ++qlen > MaxNodes )
return(1); MaxNodes = qlen;
return 1;
} }
/******************************************************************/
void ReSetQueue (int r,int c,int s,int d,int a,int r2,int c2 )
/******************************************************************/
/* reposition node in list */ /* reposition node in list */
void ReSetQueue( int r, int c, int s, int d, int a, int r2, int c2 )
{ {
struct PcbQueue *p, *q; struct PcbQueue* p, * q;
/* first, see if it is already in the list */ /* first, see if it is already in the list */
for (q = NULL, p = Head; p; q = p, p = p->Next) { for( q = NULL, p = Head; p; q = p, p = p->Next )
if (p->Row == r && p->Col == c && p->Side == s) { {
if( p->Row == r && p->Col == c && p->Side == s )
{
/* old one to remove */ /* old one to remove */
if (q) if( q )
{ {
if ( (q->Next = p->Next) == NULL) Tail = q; if( ( q->Next = p->Next ) == NULL )
Tail = q;
} }
else if ((Head = p->Next) == NULL) Tail = NULL; else if( ( Head = p->Next ) == NULL )
p->Next = Save; Save = p; Tail = NULL;
OpenNodes--; MoveNodes++; p->Next = Save;
Save = p;
OpenNodes--;
MoveNodes++;
qlen--; qlen--;
break; break;
} }
} }
if (!p) /* not found, it has already been closed once */
if( !p ) /* not found, it has already been closed once */
ClosNodes--; /* we will close it again, but just count once */ ClosNodes--; /* we will close it again, but just count once */
/* if it was there, it's gone now; insert it at the proper position */ /* if it was there, it's gone now; insert it at the proper position */
SetQueue( r, c, s, d, a, r2, c2 ); SetQueue( r, c, s, d, a, r2, c2 );
......
...@@ -15,21 +15,27 @@ ...@@ -15,21 +15,27 @@
#include "protos.h" #include "protos.h"
/* local variables */ static std::vector <D_PAD*> s_localPadBuffer; // for local ratsnest
static std::vector <D_PAD*> s_localPadBuffer; // for local ratsnest calculations when moving a footprint: buffer of pads to consider // calculations when moving a
// footprint: buffer of pads to
// consider
static bool DisplayRastnestInProgress; // Enable the display of the ratsnest during the ratsnest computations static bool DisplayRastnestInProgress; // Enable the display of the
// ratsnest during the ratsnest
// computations
/* Note about the ratsnest computation: /* Note about the ratsnest computation:
* Building the general ratsnest: * Building the general ratsnest:
* I used the "lee algoritm". * I used the "lee algorithm".
* This is a 2 steps algoritm. * This is a 2 steps algorithm.
* the m_SubRatsnest member of pads handle a "block number" or a "cluster number" or a "subnet number" * the m_SubRatsnest member of pads handle a "block number" or a "cluster
* number" or a "subnet number"
* initially, m_SubRatsnest = 0 (pad not connected). * initially, m_SubRatsnest = 0 (pad not connected).
* Build_Board_Ratsnest( wxDC* DC ) Create this rastnest * Build_Board_Ratsnest( wxDC* DC ) Create this ratsnest
* for each net: * for each net:
* First: * First:
* we create a link (and therefore a logical block) between 2 pad. This is achieved by: * we create a link (and therefore a logical block) between 2 pad. This is
* achieved by:
* search for a pad without link. * search for a pad without link.
* search its nearest pad * search its nearest pad
* link these 2 pads (i.e. create a ratsnest item) * link these 2 pads (i.e. create a ratsnest item)
...@@ -38,75 +44,82 @@ static bool DisplayRastnestInProgress; // Enable the display of ...@@ -38,75 +44,82 @@ static bool DisplayRastnestInProgress; // Enable the display of
* Each logical block has a number called block number or "subnet number", * Each logical block has a number called block number or "subnet number",
* stored in m_SubRatsnest member for each pad of the block. * stored in m_SubRatsnest member for each pad of the block.
* The first block has its block number = 1, the second is 2 ... * The first block has its block number = 1, the second is 2 ...
* the function to do thas is gen_rats_pad_to_pad() * the function to do that is gen_rats_pad_to_pad()
* *
* Secondly: * Secondly:
* The first pass created many logical blocks * The first pass created many logical blocks
* A block contains 2 or more pads. * A block contains 2 or more pads.
* we create links between 2 block. This is achieved by: * we create links between 2 block. This is achieved by:
* Test all pads in the first block, and search (for each pad) * Test all pads in the first block, and search (for each pad)
* a neighboor in other blocks and compute the distance between pads, * a neighbor in other blocks and compute the distance between pads,
* We select the pad pair which have the smallest distance. * We select the pad pair which have the smallest distance.
* These 2 pads are linked (i.e. a new ratsnest item is created between thes 2 pads) * These 2 pads are linked (i.e. a new ratsnest item is created between the 2
* pads)
* and the 2 block are merged. * and the 2 block are merged.
* Therefore the logical block 1 contains the initial block 1 "eats" the pads of the other block * Therefore the logical block 1 contains the initial block 1 "eats" the pads
* of the other block
* The computation is made until only one block is found. * The computation is made until only one block is found.
* the function used is gen_rats_block_to_block() * the function used is gen_rats_block_to_block()
* *
* *
* How existing and new tracks are handled: * How existing and new tracks are handled:
* The complete rastnest (using the pad analysis) is computed. * The complete ratsnest (using the pad analysis) is computed.
* it is independant of the tracks and handle the "logical connections". * it is independent of the tracks and handle the "logical connections".
* It depends only on the footprints geometry (and the netlist), * It depends only on the footprints geometry (and the netlist),
* and must be computed only after a netlist read or a footprints geometry change. * and must be computed only after a netlist read or a footprints geometry
* Each link (ratsnest) can only be INACTIVE (because pads are connected by a track) or ACTIVE (no tracks) * change.
* Each link (ratsnest) can only be INACTIVE (because pads are connected by a
* track) or ACTIVE (no tracks)
* *
* After the complete rastnest is built, or when a track is added or deleted, * After the complete ratsnest is built, or when a track is added or deleted,
* we run an algorithm derived from the complete rastnest computation. * we run an algorithm derived from the complete ratsnest computation.
* it is much faster because it analyses only the existing rastnest and not all the pads list * it is much faster because it analysis only the existing ratsnest and not all
* and determine only if an existing rastnest must be activated * the pads list
* and determine only if an existing ratsnest must be activated
* (no physical track exists) or not (a physical track exists) * (no physical track exists) or not (a physical track exists)
* if a track is added or deleted only the corresponding net is tested. * if a track is added or deleted only the corresponding net is tested.
* *
* the m_SubRatsnest member of pads is set to 0 (no blocks), and alls links are set to INACTIVE (ratsnest not show). * the m_SubRatsnest member of pads is set to 0 (no blocks), and all links are
* Before running this fast lee algorithm, we create blocks (and their corresponding block number) * set to INACTIVE (ratsnest not show).
* Before running this fast lee algorithm, we create blocks (and their
* corresponding block number)
* by grouping pads connected by tracks. * by grouping pads connected by tracks.
* So, when tracks exists, the fast lee algorithm is started with some blocks already created. * So, when tracks exists, the fast lee algorithm is started with some blocks
* because the fast lee algorithm test only the ratsnest and does not search for * already created.
* nearest pads (this search was previously made) the online ratsnest can be done * because the fast lee algorithm test only the ratsnest and does not search
* when a track is created without noticeable computing time * for nearest pads (this search was previously made) the online ratsnest
* can be done when a track is created without noticeable computing time
* First: * First:
* for all links (in this step, all are inactive): * for all links (in this step, all are inactive):
* search for a link which have 1 (or 2) pad having the m_SubRatsnest member = 0. * search for a link which have 1 (or 2) pad having the m_SubRatsnest member =
* if found the link is set to ACTIVE (i.e. the ratsnest will be showed) and the pad is meged with the block * 0.
* if found the link is set to ACTIVE (i.e. the ratsnest will be showed) and
* the pad is merged with the block
* or a new block is created ( see tst_rats_pad_to_pad() ). * or a new block is created ( see tst_rats_pad_to_pad() ).
* Secondly: * Secondly:
* blocks are tested: * blocks are tested:
* for all links we search if the 2 pads linkeds are in 2 different block. * for all links we search if the 2 pads linked are in 2 different block.
* if yes, the link status is set to ACTIVE, and the 2 block are merged * if yes, the link status is set to ACTIVE, and the 2 block are merged
* until only one block is found * until only one block is found
* ( see tst_rats_block_to_block() ) * ( see tst_rats_block_to_block() )
*
*
*/ */
/******************************************************************************/
void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb )
/******************************************************************************/
/** Function Compile_Ratsnest /** Function Compile_Ratsnest
* Create the entire board ratsnesr. * Create the entire board ratsnest.
* Must be called after a board change (changes for * Must be called after a board change (changes for
* pads, footprints or a read netlist ). * pads, footprints or a read netlist ).
* *
* @param display_status_pcb : if true, display the computation results * @param display_status_pcb : if true, display the computation results
*/ */
void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb )
{ {
wxString msg; wxString msg;
DisplayRastnestInProgress = TRUE; DisplayRastnestInProgress = TRUE;
GetBoard()->m_Status_Pcb = 0; /* we want a full ratnest computation, from the scratch */ GetBoard()->m_Status_Pcb = 0; /* we want a full ratsnest computation,
* from the scratch */
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
// Rebuild the full pads and net info list // Rebuild the full pads and net info list
...@@ -126,18 +139,20 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb ) ...@@ -126,18 +139,20 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb )
/* Compute the full ratsnest /* Compute the full ratsnest
* which can be see like all the possible links or logical connections. * which can be see like all the possible links or logical connections.
* some of thems are active (no track connected) and others are inactive (when track connect pads) * some of them are active (no track connected) and others are inactive
* (when track connect pads)
* This full ratsnest is not modified by track editing. * This full ratsnest is not modified by track editing.
* It changes only when a netlist is read, or footprints are modified * It changes only when a netlist is read, or footprints are modified
*/ */
Build_Board_Ratsnest( DC ); Build_Board_Ratsnest( DC );
/* Compute the pad connections due to the existing tracks (physical connections)*/ /* Compute the pad connections due to the existing tracks (physical
* connections) */
test_connexions( DC ); test_connexions( DC );
/* Compute the active ratsnest, i.e. the unconnected links /* Compute the active ratsnest, i.e. the unconnected links
* it is faster than Build_Board_Ratsnest() * it is faster than Build_Board_Ratsnest()
* because many optimisations and computations are already made * because many optimizations and computations are already made
*/ */
Tst_Ratsnest( DC, 0 ); Tst_Ratsnest( DC, 0 );
...@@ -150,13 +165,10 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb ) ...@@ -150,13 +165,10 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb )
} }
/*****************************************************************/
static int sortByNetcode( const void* o1, const void* o2 )
/****************************************************************/
/* Sort function used by QSORT /* Sort function used by QSORT
* Sort pads by net code * Sort pads by net code
*/ */
static int sortByNetcode( const void* o1, const void* o2 )
{ {
D_PAD** pt_ref = (D_PAD**) o1; D_PAD** pt_ref = (D_PAD**) o1;
D_PAD** pt_compare = (D_PAD**) o2; D_PAD** pt_compare = (D_PAD**) o2;
...@@ -165,13 +177,10 @@ static int sortByNetcode( const void* o1, const void* o2 ) ...@@ -165,13 +177,10 @@ static int sortByNetcode( const void* o1, const void* o2 )
} }
/********************************************************/
static int sort_by_length( const void* o1, const void* o2 )
/********************************************************/
/* Sort function used by QSORT /* Sort function used by QSORT
* Sort ratsnest by lenght * Sort ratsnest by length
*/ */
static int sort_by_length( const void* o1, const void* o2 )
{ {
RATSNEST_ITEM* ref = (RATSNEST_ITEM*) o1; RATSNEST_ITEM* ref = (RATSNEST_ITEM*) o1;
RATSNEST_ITEM* compare = (RATSNEST_ITEM*) o2; RATSNEST_ITEM* compare = (RATSNEST_ITEM*) o2;
...@@ -180,32 +189,37 @@ static int sort_by_length( const void* o1, const void* o2 ) ...@@ -180,32 +189,37 @@ static int sort_by_length( const void* o1, const void* o2 )
} }
/*****************************************************************************/
static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer,
std::vector<D_PAD*>& aPadBuffer,
unsigned aPadIdxStart,
unsigned aPadIdxMax )
/*****************************************************************************/
/** /**
* Function used by Build_Board_Ratsnest() * Function used by Build_Board_Ratsnest()
* This function creates a rastsnet between two blocks ( which fit the same net ) * This function creates a ratsnest between two blocks ( which fit the same
* A block is a group of pads already linked (by a previous ratsnest computation, or tracks) * net )
* The search is made between the pads in block 1 (the reference block) and other blocks * A block is a group of pads already linked (by a previous ratsnest
* computation, or tracks)
* The search is made between the pads in block 1 (the reference block) and
* other blocks
* the block n ( n > 1 ) it connected to block 1 by their 2 nearest pads. * the block n ( n > 1 ) it connected to block 1 by their 2 nearest pads.
* When the block is found, it is merged with the block 1 * When the block is found, it is merged with the block 1
* the D_PAD member m_SubRatsnest handles the block number * the D_PAD member m_SubRatsnest handles the block number
* @param aRatsnestBuffer = a std::vector<RATSNEST_ITEM> buffer to fill with new ratsnest items * @param aRatsnestBuffer = a std::vector<RATSNEST_ITEM> buffer to fill with
* @param aPadBuffer = a std::vector<D_PAD*> that is the list of pads to consider * new ratsnest items
* @param aPadBuffer = a std::vector<D_PAD*> that is the list of pads to
* consider
* @param aPadIdxStart = starting index (within the pad list) for search * @param aPadIdxStart = starting index (within the pad list) for search
* @param aPadIdxMax = ending index (within the pad list) for search * @param aPadIdxMax = ending index (within the pad list) for search
* @return blocks not connected count * @return blocks not connected count
*/ */
static int gen_rats_block_to_block(
std::vector<RATSNEST_ITEM>& aRatsnestBuffer,
std::vector<D_PAD*>& aPadBuffer,
unsigned aPadIdxStart,
unsigned aPadIdxMax )
{ {
int dist_min, current_dist; int dist_min, current_dist;
int current_num_block = 1; int current_num_block = 1;
int padBlock1Idx = -1; // Index in aPadBuffer for the "better" pad found in block 1 int padBlock1Idx = -1; // Index in aPadBuffer for the "better" pad
int padBlockToMergeIdx = -1; // Index in aPadBuffer for the "better" pad found in block to merge // found in block 1
int padBlockToMergeIdx = -1; // Index in aPadBuffer for the "better" pad
// found in block to merge
dist_min = 0x7FFFFFFF; dist_min = 0x7FFFFFFF;
...@@ -218,7 +232,7 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -218,7 +232,7 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer,
if( ref_pad->GetSubRatsnest() != 1 ) if( ref_pad->GetSubRatsnest() != 1 )
continue; continue;
/* pad is found, search its nearest neighbour in other blocks */ /* pad is found, search its nearest neighbor in other blocks */
for( unsigned jj = aPadIdxStart; jj < aPadIdxMax; jj++ ) for( unsigned jj = aPadIdxStart; jj < aPadIdxMax; jj++ )
{ {
D_PAD* curr_pad = aPadBuffer[jj]; D_PAD* curr_pad = aPadBuffer[jj];
...@@ -233,7 +247,7 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -233,7 +247,7 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer,
if( dist_min > current_dist ) // we have found a better pad pair if( dist_min > current_dist ) // we have found a better pad pair
{ {
// The tested block can be a good candidate for merging // The tested block can be a good candidate for merging
// we memorise the "best" current values for merging // we memorize the "best" current values for merging
current_num_block = curr_pad->GetSubRatsnest(); current_num_block = curr_pad->GetSubRatsnest();
dist_min = current_dist; dist_min = current_dist;
...@@ -243,15 +257,16 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -243,15 +257,16 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer,
} }
} }
/* The reference block is labelled block 1. /* The reference block is labeled block 1.
* if current_num_block != 1 we have found an other block, and we must merge it * if current_num_block != 1 we have found an other block, and we must
* with the reference block * merge it with the reference block
* The link is made by the 2 nearest pads * The link is made by the 2 nearest pads
*/ */
if( current_num_block > 1 ) if( current_num_block > 1 )
{ {
/* The block n (n=current_num_block) is merged with the bloc 1 : /* The block n (n=current_num_block) is merged with the bloc 1 :
* to do that, we set the m_SubRatsnest member to 1 for all pads in block n * to do that, we set the m_SubRatsnest member to 1 for all pads in
* block n
*/ */
for( unsigned ii = aPadIdxStart; ii < aPadIdxMax; ii++ ) for( unsigned ii = aPadIdxStart; ii < aPadIdxMax; ii++ )
{ {
...@@ -261,10 +276,11 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -261,10 +276,11 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer,
} }
if( padBlock1Idx < 0 ) if( padBlock1Idx < 0 )
DisplayError( NULL, wxT( "gen_rats_block_to_block() internal error" ) ); DisplayError( NULL,
wxT( "gen_rats_block_to_block() internal error" ) );
else else
{ {
/* Create the new ratsnet */ /* Create the new ratsnest */
RATSNEST_ITEM net; RATSNEST_ITEM net;
net.SetNet( aPadBuffer[padBlock1Idx]->GetNet() ); net.SetNet( aPadBuffer[padBlock1Idx]->GetNet() );
net.m_Status = CH_ACTIF | CH_VISIBLE; net.m_Status = CH_ACTIF | CH_VISIBLE;
...@@ -278,32 +294,33 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -278,32 +294,33 @@ static int gen_rats_block_to_block( std::vector<RATSNEST_ITEM>& aRatsnestBuffer,
} }
/*****************************************************************************/
static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer,
std::vector<D_PAD*>& aPadBuffer,
unsigned aPadIdxStart,
unsigned aPadIdxMax,
int current_num_block )
/*****************************************************************************/
/** /**
* Function used by Build_Board_Ratsnest() * Function used by Build_Board_Ratsnest()
* this is the first pass of the lee algorithm * this is the first pass of the lee algorithm
* This function creates the link (ratsnest) between 2 pads ( fitting the same net ) * This function creates the link (ratsnest) between 2 pads ( fitting the same
* the function search for a first not connected pad * net )
* and search its nearest neighboor * the function search for a first not connected pad and search its nearest
* Its creates a block if the 2 pads are not connected, or merge the unconnected pad to the existing block. * neighbor
* Its creates a block if the 2 pads are not connected, or merge the
* unconnected pad to the existing block.
* These blocks include 2 pads and the 2 pads are linked by a ratsnest. * These blocks include 2 pads and the 2 pads are linked by a ratsnest.
* *
* @param aRatsnestBuffer = a std::vector<RATSNEST_ITEM> buffer to fill with new ratsnest items * @param aRatsnestBuffer = a std::vector<RATSNEST_ITEM> buffer to fill with
* @param aPadBuffer = a std::vector<D_PAD*> that is the list of pads to consider * new ratsnest items
* @param aPadBuffer = a std::vector<D_PAD*> that is the list of pads to
* consider
* @param aPadIdxStart = starting index (within the pad list) for search * @param aPadIdxStart = starting index (within the pad list) for search
* @param aPadIdxMax = ending index (within the pad list) for search * @param aPadIdxMax = ending index (within the pad list) for search
* @param current_num_block = Last existing block number de pads * @param current_num_block = Last existing block number of pads
* These block are created by the existing tracks analysis * These block are created by the existing tracks analysis
* *
* @return the last block number used * @return the last block number used
*/ */
static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer,
std::vector<D_PAD*>& aPadBuffer,
unsigned aPadIdxStart,
unsigned aPadIdxMax,
int current_num_block )
{ {
int dist_min, current_dist; int dist_min, current_dist;
D_PAD* ref_pad, * pad; D_PAD* ref_pad, * pad;
...@@ -316,7 +333,8 @@ static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -316,7 +333,8 @@ static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer,
continue; // Pad already connected continue; // Pad already connected
dist_min = 0x7FFFFFFF; dist_min = 0x7FFFFFFF;
int padBlockToMergeIdx = -1; // Index in aPadBuffer for the "better" pad found in block to merge int padBlockToMergeIdx = -1; // Index in aPadBuffer for the "better"
// pad found in block to merge
for( unsigned jj = aPadIdxStart; jj < aPadIdxMax; jj++ ) for( unsigned jj = aPadIdxStart; jj < aPadIdxMax; jj++ )
{ {
if( ii == jj ) if( ii == jj )
...@@ -342,19 +360,22 @@ static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -342,19 +360,22 @@ static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer,
/* Update the block number /* Update the block number
* if the 2 pads are not already created : a new block is created * if the 2 pads are not already created : a new block is created
*/ */
if( (pad->GetSubRatsnest() == 0) && (ref_pad->GetSubRatsnest() == 0) ) if( (pad->GetSubRatsnest() == 0)
&& (ref_pad->GetSubRatsnest() == 0) )
{ {
current_num_block++; // Creates a new block number (or subratsnest) current_num_block++; // Creates a new block number (or
// subratsnest)
pad->SetSubRatsnest( current_num_block ); pad->SetSubRatsnest( current_num_block );
ref_pad->SetSubRatsnest( current_num_block ); ref_pad->SetSubRatsnest( current_num_block );
} }
/* If a pad is already connected connected : merge the other pad in the block */ /* If a pad is already connected connected : merge the other pad in
* the block */
else else
{ {
ref_pad->SetSubRatsnest( pad->GetSubRatsnest() ); ref_pad->SetSubRatsnest( pad->GetSubRatsnest() );
} }
/* Create the new ratsnet item */ /* Create the new ratsnest item */
RATSNEST_ITEM rast; RATSNEST_ITEM rast;
rast.SetNet( ref_pad->GetNet() ); rast.SetNet( ref_pad->GetNet() );
rast.m_Status = CH_ACTIF | CH_VISIBLE; rast.m_Status = CH_ACTIF | CH_VISIBLE;
...@@ -369,10 +390,6 @@ static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer, ...@@ -369,10 +390,6 @@ static int gen_rats_pad_to_pad( vector<RATSNEST_ITEM>& aRatsnestBuffer,
} }
/***********************************************************/
void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
/***********************************************************/
/** Function to compute the full ratsnest (using the LEE algorithm ) /** Function to compute the full ratsnest (using the LEE algorithm )
* In the functions tracks are not considered * In the functions tracks are not considered
* This is only the "basic" ratsnest depending only on pads. * This is only the "basic" ratsnest depending only on pads.
...@@ -383,14 +400,14 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) ...@@ -383,14 +400,14 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
* *
* - Compute the ratsnest (LEE algorithm ): * - Compute the ratsnest (LEE algorithm ):
* a - Create the ratsnest between a not connected pad and its nearest * a - Create the ratsnest between a not connected pad and its nearest
* neighbour. Blocks of pads are created * neighbor. Blocks of pads are created
* b - Create the ratsnest between blocks: * b - Create the ratsnest between blocks:
* Test the pads of the 1st block and create a link (ratsnest) * Test the pads of the 1st block and create a link (ratsnest)
* with the nearest pad found in an other block. * with the nearest pad found in an other block.
* The other block is merged with the first block. * The other block is merged with the first block.
* until only one block is left. * until only one block is left.
* *
* A ratnest can be seen as a logical connection. * A ratsnest can be seen as a logical connection.
* *
* Update : * Update :
* nb_nodes = Active pads count for the board * nb_nodes = Active pads count for the board
...@@ -398,6 +415,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) ...@@ -398,6 +415,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
* (there are n-1 links for an equipotent which have n active pads) . * (there are n-1 links for an equipotent which have n active pads) .
* *
*/ */
void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
{ {
D_PAD* pad; D_PAD* pad;
int noconn; int noconn;
...@@ -420,12 +438,13 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) ...@@ -420,12 +438,13 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
} }
if( m_Pcb->GetNodesCount() == 0 ) if( m_Pcb->GetNodesCount() == 0 )
return; /* pas de connexions utiles */ return; /* No useful connections. */
/* Ratsnest computation */ /* Ratsnest computation */
DisplayRastnestInProgress = TRUE; DisplayRastnestInProgress = TRUE;
unsigned current_net_code = 1; // 1er net_code a analyser (net_code = 0 -> no connect) unsigned current_net_code = 1; // First net code is analyzed.
// (net_code = 0 -> no connect)
noconn = 0; noconn = 0;
for( ; current_net_code < m_Pcb->m_NetInfo->GetCount(); current_net_code++ ) for( ; current_net_code < m_Pcb->m_NetInfo->GetCount(); current_net_code++ )
...@@ -433,7 +452,8 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) ...@@ -433,7 +452,8 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code ); NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code );
if( net == NULL ) //Should not occur if( net == NULL ) //Should not occur
{ {
DisplayError( this, wxT( "Build_Board_Ratsnest() error: net not found" ) ); DisplayError( this,
wxT( "Build_Board_Ratsnest() error: net not found" ) );
return; return;
} }
net->m_RatsnestStartIdx = m_Pcb->GetRatsnestsCount(); net->m_RatsnestStartIdx = m_Pcb->GetRatsnestsCount();
...@@ -459,16 +479,18 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) ...@@ -459,16 +479,18 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
/* b - blocks connection (Iteration) */ /* b - blocks connection (Iteration) */
while( icnt > 1 ) while( icnt > 1 )
{ {
icnt = gen_rats_block_to_block( m_Pcb->m_FullRatsnest, net->m_ListPad, 0, icnt = gen_rats_block_to_block( m_Pcb->m_FullRatsnest,
net->m_ListPad,
0,
net->m_ListPad.size() ); net->m_ListPad.size() );
net = m_Pcb->FindNet( current_net_code ); net = m_Pcb->FindNet( current_net_code );
} }
net->m_RatsnestEndIdx = m_Pcb->GetRatsnestsCount(); net->m_RatsnestEndIdx = m_Pcb->GetRatsnestsCount();
/* sort by lenght */ /* sort by length */
net = m_Pcb->FindNet( current_net_code ); net = m_Pcb->FindNet( current_net_code );
if( (net->m_RatsnestEndIdx - net->m_RatsnestStartIdx) > 1 ) if( ( net->m_RatsnestEndIdx - net->m_RatsnestStartIdx ) > 1 )
{ {
RATSNEST_ITEM* rats = &m_Pcb->m_FullRatsnest[0]; RATSNEST_ITEM* rats = &m_Pcb->m_FullRatsnest[0];
qsort( rats + net->m_RatsnestStartIdx, qsort( rats + net->m_RatsnestStartIdx,
...@@ -480,51 +502,49 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) ...@@ -480,51 +502,49 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC )
m_Pcb->m_NbNoconnect = noconn; m_Pcb->m_NbNoconnect = noconn;
m_Pcb->m_Status_Pcb |= LISTE_RATSNEST_ITEM_OK; m_Pcb->m_Status_Pcb |= LISTE_RATSNEST_ITEM_OK;
// erase the ratsnest displayed on screen if needed // erase the ratsnest displayed on screen if needed
for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ )
{ {
if( !g_Show_Ratsnest && DC ) // Clear VISIBLE flag if( !g_Show_Ratsnest && DC ) // Clear VISIBLE flag
m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE; m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
if( DC ) if( DC )
m_Pcb->m_FullRatsnest[ii].Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) ); m_Pcb->m_FullRatsnest[ii].Draw( DrawPanel, DC, GR_XOR,
wxPoint( 0, 0 ) );
} }
} }
/*********************************************************************/
void WinEDA_BasePcbFrame::DrawGeneralRatsnest( wxDC* DC, int net_code )
/*********************************************************************/
/** /**
* Displays the general ratsnest * Displays the general ratsnest
* Only ratsnets with the status bit CH_VISIBLE is set are displayed * Only ratsnest with the status bit CH_VISIBLE is set are displayed
* @param netcode if > 0, Display only the ratsnest relative to the correponding net_code * @param netcode if > 0, Display only the ratsnest relative to the
* corresponding net_code
*/ */
void WinEDA_BasePcbFrame::DrawGeneralRatsnest( wxDC* DC, int net_code )
{ {
if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( ( m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
return; return;
if( (m_Pcb->m_Status_Pcb & DO_NOT_SHOW_GENERAL_RASTNEST) ) if( ( m_Pcb->m_Status_Pcb & DO_NOT_SHOW_GENERAL_RASTNEST ) )
return; return;
if( DC == NULL ) if( DC == NULL )
return; return;
for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ )
{ {
if( ( m_Pcb->m_FullRatsnest[ii].m_Status & (CH_VISIBLE | CH_ACTIF) ) != if( ( m_Pcb->m_FullRatsnest[ii].m_Status &
(CH_VISIBLE | CH_ACTIF) ) ( CH_VISIBLE | CH_ACTIF ) ) !=
( CH_VISIBLE | CH_ACTIF ) )
continue; continue;
if( (net_code <= 0) || ( net_code == m_Pcb->m_FullRatsnest[ii].GetNet() ) ) if( ( net_code <= 0 )
m_Pcb->m_FullRatsnest[ii].Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) ); || ( net_code == m_Pcb->m_FullRatsnest[ii].GetNet() ) )
m_Pcb->m_FullRatsnest[ii].Draw( DrawPanel, DC, GR_XOR,
wxPoint( 0, 0 ) );
} }
} }
/**********************************************************************************************/
static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aRatsnestBuffer )
/**********************************************************************************************/
/** /**
* Function used by Tst_Ratsnest() * Function used by Tst_Ratsnest()
* Function like gen_rats_block_to_block(..) * Function like gen_rats_block_to_block(..)
...@@ -538,19 +558,24 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aR ...@@ -538,19 +558,24 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aR
* *
* @param net = the current NETINFO_ITEM for the current net * @param net = the current NETINFO_ITEM for the current net
* output: * output:
* .state member of the ratsnests * .state member of the ratsnest
* @return blocks not connected count * @return blocks not connected count
*/ */
static int tst_rats_block_to_block( NETINFO_ITEM* net,
vector<RATSNEST_ITEM>& aRatsnestBuffer )
{ {
int current_num_block, min_block; int current_num_block, min_block;
RATSNEST_ITEM* rats, * min_rats; RATSNEST_ITEM* rats, * min_rats;
/* Search a link from a block to an other block */ /* Search a link from a block to an other block */
min_rats = NULL; min_rats = NULL;
for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ ) for( unsigned ii = net->m_RatsnestStartIdx;
ii < net->m_RatsnestEndIdx;
ii++ )
{ {
rats = &aRatsnestBuffer[ii]; rats = &aRatsnestBuffer[ii];
if( rats->m_PadStart->GetSubRatsnest() == rats->m_PadEnd->GetSubRatsnest() ) // Same block if( rats->m_PadStart->GetSubRatsnest() ==
rats->m_PadEnd->GetSubRatsnest() ) // Same block
continue; continue;
if( min_rats == NULL ) if( min_rats == NULL )
...@@ -562,7 +587,7 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aR ...@@ -562,7 +587,7 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aR
if( min_rats == NULL ) if( min_rats == NULL )
return 1; return 1;
/* At this point we have found a link between 2 differents blocks (clusters) : /* At this point we have found a link between 2 different blocks (clusters)
* we must set its status to ACTIVE and merge the 2 blocks * we must set its status to ACTIVE and merge the 2 blocks
*/ */
min_rats->m_Status |= CH_ACTIF; min_rats->m_Status |= CH_ACTIF;
...@@ -585,22 +610,19 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aR ...@@ -585,22 +610,19 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, vector<RATSNEST_ITEM>& aR
} }
/*********************************************************************/
static int tst_rats_pad_to_pad( int current_num_block,
RATSNEST_ITEM* start_rat_list, RATSNEST_ITEM* end_rat_list )
/**********************************************************************/
/** /**
* Function used by Tst_Ratsnest_general() * Function used by Tst_Ratsnest_general()
* The general ratsnest list must exists * The general ratsnest list must exists
* Activates the ratsnest between 2 pads ( supposes du meme net ) * Activates the ratsnest between 2 pads ( supposes du meme net )
* The function links 1 pad not already connected an other pad and activate * The function links 1 pad not already connected an other pad and activate
* some blocks linked by a ratsnest * some blocks linked by a ratsnest
* Its test only the existing ratsnest and activate some ratsnest (status bit CH_ACTIF set) * Its test only the existing ratsnest and activate some ratsnest (status bit
* CH_ACTIF set)
* *
* @param start_rat_list = starting address for the ratnest list * @param start_rat_list = starting address for the ratsnest list
* @param end_rat_list = ending address for the ratnest list * @param end_rat_list = ending address for the ratsnest list
* @param current_num_block = last block number (computed from the track analysis) * @param current_num_block = last block number (computed from the track
* analysis)
* *
* output: * output:
* ratsnest list (status member set) * ratsnest list (status member set)
...@@ -608,6 +630,9 @@ static int tst_rats_pad_to_pad( int current_num_block, ...@@ -608,6 +630,9 @@ static int tst_rats_pad_to_pad( int current_num_block,
* *
* @return new block number * @return new block number
*/ */
static int tst_rats_pad_to_pad( int current_num_block,
RATSNEST_ITEM* start_rat_list,
RATSNEST_ITEM* end_rat_list )
{ {
D_PAD* pad_start, * pad_end; D_PAD* pad_start, * pad_end;
RATSNEST_ITEM* chevelu; RATSNEST_ITEM* chevelu;
...@@ -617,16 +642,19 @@ static int tst_rats_pad_to_pad( int current_num_block, ...@@ -617,16 +642,19 @@ static int tst_rats_pad_to_pad( int current_num_block,
pad_start = chevelu->m_PadStart; pad_start = chevelu->m_PadStart;
pad_end = chevelu->m_PadEnd; pad_end = chevelu->m_PadEnd;
/* Update the block if the 2 pads are not connected : a new block is created /* Update the block if the 2 pads are not connected : a new block is
* created
*/ */
if( (pad_start->GetSubRatsnest() == 0) && (pad_end->GetSubRatsnest() == 0) ) if( (pad_start->GetSubRatsnest() == 0)
&& (pad_end->GetSubRatsnest() == 0) )
{ {
current_num_block++; current_num_block++;
pad_start->SetSubRatsnest( current_num_block ); pad_start->SetSubRatsnest( current_num_block );
pad_end->SetSubRatsnest( current_num_block ); pad_end->SetSubRatsnest( current_num_block );
chevelu->m_Status |= CH_ACTIF; chevelu->m_Status |= CH_ACTIF;
} }
/* If a pad is already connected : the other is merged in the current block */ /* If a pad is already connected : the other is merged in the current
* block */
else if( pad_start->GetSubRatsnest() == 0 ) else if( pad_start->GetSubRatsnest() == 0 )
{ {
pad_start->SetSubRatsnest( pad_end->GetSubRatsnest() ); pad_start->SetSubRatsnest( pad_end->GetSubRatsnest() );
...@@ -643,15 +671,12 @@ static int tst_rats_pad_to_pad( int current_num_block, ...@@ -643,15 +671,12 @@ static int tst_rats_pad_to_pad( int current_num_block,
} }
/******************************************************************/
void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode )
/*******************************************************************/
/* Compute the active ratsnest /* Compute the active ratsnest
* The general ratsnest list must exists * The general ratsnest list must exists
* Compute the ACTIVE ratsnests in the general ratsnest list * Compute the ACTIVE ratsnest in the general ratsnest list
* if ref_netcode == 0, test all nets, else test only ref_netcode * if ref_netcode == 0, test all nets, else test only ref_netcode
*/ */
void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode )
{ {
RATSNEST_ITEM* rats; RATSNEST_ITEM* rats;
D_PAD* pad; D_PAD* pad;
...@@ -662,7 +687,9 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode ) ...@@ -662,7 +687,9 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode )
if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
Build_Board_Ratsnest( DC ); Build_Board_Ratsnest( DC );
for( int net_code = 1; net_code < (int) m_Pcb->m_NetInfo->GetCount(); net_code++ ) for( int net_code = 1;
net_code < (int) m_Pcb->m_NetInfo->GetCount();
net_code++ )
{ {
net = m_Pcb->FindNet( net_code ); net = m_Pcb->FindNet( net_code );
if( net == NULL ) //Should not occur if( net == NULL ) //Should not occur
...@@ -683,18 +710,20 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode ) ...@@ -683,18 +710,20 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode )
num_block = MAX( num_block, subnet ); num_block = MAX( num_block, subnet );
} }
for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ ) for( unsigned ii = net->m_RatsnestStartIdx;
ii < net->m_RatsnestEndIdx;
ii++ )
{ {
m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_ACTIF; m_Pcb->m_FullRatsnest[ii].m_Status &= ~CH_ACTIF;
} }
/* a - tst connection between pads */ /* a - test connection between pads */
rats = &m_Pcb->m_FullRatsnest[0]; rats = &m_Pcb->m_FullRatsnest[0];
int icnt = tst_rats_pad_to_pad( num_block, int icnt = tst_rats_pad_to_pad( num_block,
rats + net->m_RatsnestStartIdx, rats + net->m_RatsnestStartIdx,
rats + net->m_RatsnestEndIdx ); rats + net->m_RatsnestEndIdx );
/* b - test connexion between blocks (Iteration) */ /* b - test connection between blocks (Iteration) */
while( icnt > 1 ) while( icnt > 1 )
{ {
icnt = tst_rats_block_to_block( net, m_Pcb->m_FullRatsnest ); icnt = tst_rats_block_to_block( net, m_Pcb->m_FullRatsnest );
...@@ -710,14 +739,11 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode ) ...@@ -710,14 +739,11 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode )
} }
/**************************************************************************/
int WinEDA_BasePcbFrame::Test_1_Net_Ratsnest( wxDC* DC, int ref_netcode )
/**************************************************************************/
/** function Test_1_Net_Ratsnest /** function Test_1_Net_Ratsnest
* Compute the rastnest relative to the net "net_code" * Compute the ratsnest relative to the net "net_code"
* @param ref_netcode = netcode used to compute the rastnest. * @param ref_netcode = netcode used to compute the ratsnest.
*/ */
int WinEDA_BasePcbFrame::Test_1_Net_Ratsnest( wxDC* DC, int ref_netcode )
{ {
DisplayRastnestInProgress = FALSE; DisplayRastnestInProgress = FALSE;
DrawGeneralRatsnest( DC, ref_netcode ); DrawGeneralRatsnest( DC, ref_netcode );
...@@ -728,33 +754,36 @@ int WinEDA_BasePcbFrame::Test_1_Net_Ratsnest( wxDC* DC, int ref_netcode ) ...@@ -728,33 +754,36 @@ int WinEDA_BasePcbFrame::Test_1_Net_Ratsnest( wxDC* DC, int ref_netcode )
} }
/*****************************************************************************/
void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
/*****************************************************************************/
/** /**
* Build a rastenest relative to one footprint. This is a simplified computation * Build a ratsnest relative to one footprint. This is a simplified
* used only in move footprint. It is not optimal, but it is fast and sufficient * computation
* used only in move footprint. It is not optimal, but it is fast and
* sufficient
* to guide a footprint placement * to guide a footprint placement
* It shows the connections from a pad to the nearest conected pad * It shows the connections from a pad to the nearest connected pad
* @param Module = module to consider. * @param Module = module to consider.
* *
* The ratsnest has 2 sections: * The ratsnest has 2 sections:
* - An "internal" ratsnet relative to pads of this footprint which are in the same net. * - An "internal" ratsnest relative to pads of this footprint which are
* in the same net.
* this ratsnest section is computed once. * this ratsnest section is computed once.
* - An "external" rastnest connecting a pad of this footprint to an other pad (in an other footprint) * - An "external" ratsnest connecting a pad of this footprint to an other
* pad (in an other footprint)
* The ratsnest section must be computed for each new position * The ratsnest section must be computed for each new position
*/ */
void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
{ {
static unsigned pads_module_count; // node count (node = pad with a net code) for the footprint beeing moved static unsigned pads_module_count; // node count (node = pad with a net
static unsigned internalRatsCount; // number of internal links (links between pads of the module) // code) for the footprint being moved
static unsigned internalRatsCount; // number of internal links (links
// between pads of the module)
D_PAD** baseListePad; D_PAD** baseListePad;
D_PAD* pad_ref; D_PAD* pad_ref;
D_PAD* pad_externe; D_PAD* pad_externe;
int current_net_code; int current_net_code;
int distance; // variables de calcul de ratsnest int distance;
wxPoint pad_pos; // True pad position according to the current footprint position wxPoint pad_pos; // True pad position according to the
// current footprint position
if( (GetBoard()->m_Status_Pcb & LISTE_PAD_OK) == 0 ) if( (GetBoard()->m_Status_Pcb & LISTE_PAD_OK) == 0 )
{ {
...@@ -763,13 +792,15 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) ...@@ -763,13 +792,15 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
} }
/* Compute the "local" ratsnest if needed (when this footprint starts move) /* Compute the "local" ratsnest if needed (when this footprint starts move)
* and the list of external pads to consider, i.e pads in others footprints which are "connected" to * and the list of external pads to consider, i.e pads in others
* footprints which are "connected" to
* a pad in the current footprint * a pad in the current footprint
*/ */
if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) != 0 ) if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) != 0 )
goto CalculateExternalRatsnest; goto CalculateExternalRatsnest;
/* Compute the "internal" ratsnest, i.e the links between the curent footprint pads */ /* Compute the "internal" ratsnest, i.e the links between the current
*footprint pads */
s_localPadBuffer.clear(); s_localPadBuffer.clear();
m_Pcb->m_LocalRatsnest.clear(); m_Pcb->m_LocalRatsnest.clear();
...@@ -787,7 +818,10 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) ...@@ -787,7 +818,10 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
if( pads_module_count == 0 ) if( pads_module_count == 0 )
return; /* no connection! */ return; /* no connection! */
qsort( &s_localPadBuffer[0], pads_module_count, sizeof(D_PAD*), sortByNetcode ); qsort( &s_localPadBuffer[0],
pads_module_count,
sizeof(D_PAD*),
sortByNetcode );
/* Build the list of pads linked to the current footprint pads */ /* Build the list of pads linked to the current footprint pads */
DisplayRastnestInProgress = FALSE; DisplayRastnestInProgress = FALSE;
...@@ -799,11 +833,13 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) ...@@ -799,11 +833,13 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
if( pad_ref->GetNet() == current_net_code ) if( pad_ref->GetNet() == current_net_code )
continue; continue;
// A new net was found, load all pads of others modules members of this net: // A new net was found, load all pads of others modules members of this
// net:
NETINFO_ITEM* net = m_Pcb->FindNet( pad_ref->GetNet() ); NETINFO_ITEM* net = m_Pcb->FindNet( pad_ref->GetNet() );
if( net == NULL ) //Should not occur if( net == NULL ) //Should not occur
{ {
DisplayError( this, wxT( "build_ratsnest_module() error: net not found" ) ); DisplayError( this,
wxT( "build_ratsnest_module() error: net not found" ) );
return; return;
} }
...@@ -827,8 +863,9 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) ...@@ -827,8 +863,9 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
sizeof(D_PAD*), sortByNetcode ); sizeof(D_PAD*), sortByNetcode );
/* Compute the internal rats nest: /* Compute the internal rats nest:
* this is the same as general ratsnest, but considers only the current footprint pads * this is the same as general ratsnest, but considers only the current
* it is therefore not time consuming, and it is made only once * footprint pads it is therefore not time consuming, and it is made only
* once
*/ */
current_net_code = s_localPadBuffer[0]->GetNet(); current_net_code = s_localPadBuffer[0]->GetNet();
...@@ -847,12 +884,20 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) ...@@ -847,12 +884,20 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
/* End of list found: */ /* End of list found: */
/* a - first step of lee algorithm : build the pad to pad link list */ /* a - first step of lee algorithm : build the pad to pad link list */
int icnt = gen_rats_pad_to_pad( m_Pcb->m_LocalRatsnest, s_localPadBuffer, ii, jj, 0 ); int icnt = gen_rats_pad_to_pad( m_Pcb->m_LocalRatsnest,
s_localPadBuffer,
/* b - second step of lee algorithm : build the block to block link list (Iteration) */ ii,
jj,
0 );
/* b - second step of lee algorithm : build the block to block link
*list (Iteration) */
while( icnt > 1 ) while( icnt > 1 )
{ {
icnt = gen_rats_block_to_block( m_Pcb->m_LocalRatsnest, s_localPadBuffer, ii, jj ); icnt = gen_rats_block_to_block( m_Pcb->m_LocalRatsnest,
s_localPadBuffer,
ii,
jj );
} }
ii = jj; ii = jj;
...@@ -862,7 +907,7 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) ...@@ -862,7 +907,7 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
internalRatsCount = m_Pcb->m_LocalRatsnest.size(); internalRatsCount = m_Pcb->m_LocalRatsnest.size();
/* set the ratsnets status, flag LOCAL_RATSNEST_ITEM */ /* set the ratsnest status, flag LOCAL_RATSNEST_ITEM */
for( unsigned ii = 0; ii < m_Pcb->m_LocalRatsnest.size(); ii++ ) for( unsigned ii = 0; ii < m_Pcb->m_LocalRatsnest.size(); ii++ )
{ {
m_Pcb->m_LocalRatsnest[ii].m_Status = LOCAL_RATSNEST_ITEM; m_Pcb->m_LocalRatsnest[ii].m_Status = LOCAL_RATSNEST_ITEM;
...@@ -870,14 +915,16 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) ...@@ -870,14 +915,16 @@ void WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module )
m_Pcb->m_Status_Pcb |= RATSNEST_ITEM_LOCAL_OK; m_Pcb->m_Status_Pcb |= RATSNEST_ITEM_LOCAL_OK;
/* /* This section computes the "external" ratsnest: must be done when the
* This section computes the "external" ratsnest: must be done when the footprint position changes * footprint position changes
*/ */
CalculateExternalRatsnest: CalculateExternalRatsnest:
/* This section search: /* This section search:
* for each current module pad the nearest neighbour external pad (of course for the same net code). * for each current module pad the nearest neighbor external pad (of
* For each current footprint cluster of pad (pads having the same net code), * course for the same net code).
* For each current footprint cluster of pad (pads having the same net
* code),
* we search the smaller rats nest. * we search the smaller rats nest.
* so, for each net, only one rats nest item is created * so, for each net, only one rats nest item is created
*/ */
...@@ -886,7 +933,8 @@ CalculateExternalRatsnest: ...@@ -886,7 +933,8 @@ CalculateExternalRatsnest:
local_rats.m_Status = 0; local_rats.m_Status = 0;
bool addRats = false; bool addRats = false;
if( internalRatsCount < m_Pcb->m_LocalRatsnest.size() ) if( internalRatsCount < m_Pcb->m_LocalRatsnest.size() )
m_Pcb->m_LocalRatsnest.erase( m_Pcb->m_LocalRatsnest.begin() + internalRatsCount, m_Pcb->m_LocalRatsnest.erase(
m_Pcb->m_LocalRatsnest.begin() + internalRatsCount,
m_Pcb->m_LocalRatsnest.end() ); m_Pcb->m_LocalRatsnest.end() );
current_net_code = s_localPadBuffer[0]->GetNet(); current_net_code = s_localPadBuffer[0]->GetNet();
...@@ -908,7 +956,9 @@ CalculateExternalRatsnest: ...@@ -908,7 +956,9 @@ CalculateExternalRatsnest:
pad_pos = pad_ref->m_Pos - g_Offset_Module; pad_pos = pad_ref->m_Pos - g_Offset_Module;
// Search the nearest external pad of this current pad // Search the nearest external pad of this current pad
for( unsigned jj = pads_module_count; jj < s_localPadBuffer.size(); jj++ ) for( unsigned jj = pads_module_count;
jj < s_localPadBuffer.size();
jj++ )
{ {
pad_externe = s_localPadBuffer[jj]; pad_externe = s_localPadBuffer[jj];
...@@ -916,7 +966,9 @@ CalculateExternalRatsnest: ...@@ -916,7 +966,9 @@ CalculateExternalRatsnest:
if( pad_externe->GetNet() < pad_ref->GetNet() ) if( pad_externe->GetNet() < pad_ref->GetNet() )
continue; continue;
if( pad_externe->GetNet() > pad_ref->GetNet() ) // remember pads are sorted by net code if( pad_externe->GetNet() > pad_ref->GetNet() ) // remember pads
// are sorted by
// net code
break; break;
distance = abs( pad_externe->m_Pos.x - pad_pos.x ) + distance = abs( pad_externe->m_Pos.x - pad_pos.x ) +
...@@ -940,17 +992,15 @@ CalculateExternalRatsnest: ...@@ -940,17 +992,15 @@ CalculateExternalRatsnest:
} }
/***********************************************************/
void WinEDA_BasePcbFrame::trace_ratsnest_module( wxDC* DC )
/**********************************************************/
/* /*
* Display the rastnest of a moving footprint, computed by build_ratsnest_module() * Display the ratsnest of a moving footprint, computed by
* build_ratsnest_module()
*/ */
void WinEDA_BasePcbFrame::trace_ratsnest_module( wxDC* DC )
{ {
if( DC == NULL ) if( DC == NULL )
return; return;
if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 ) if( ( m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 )
return; return;
int tmpcolor = g_DesignSettings.m_RatsnestColor; int tmpcolor = g_DesignSettings.m_RatsnestColor;
...@@ -977,26 +1027,30 @@ void WinEDA_BasePcbFrame::trace_ratsnest_module( wxDC* DC ) ...@@ -977,26 +1027,30 @@ void WinEDA_BasePcbFrame::trace_ratsnest_module( wxDC* DC )
/* /*
* construction de la liste en mode de calcul rapide pour affichage * Construction of the list mode display for quick calculation
* en temps reel du chevelu d'un pad lors des tracés d'une piste démarrant * in real time the net of a pad in the paths of a track starting
* sur ce pad. * on the pad.
* *
* parametres d'appel: * Parameters:
* pad_ref ( si null : mise a 0 du nombre de chevelus ) * Pad_ref (if null: 0 has put the number of ratsnest)
* ox, oy = coord de l'extremite de la piste en trace * Ox, oy = coord of extremity of the track record
* init (flag) * Init (flag)
* = 0 : mise a jour des chevelu * = 0: update of the ratsnest.
* <> 0: creation de la liste * <> 0: Creating a list
*/ */
/* Buffer to store pads coordinates when creating a track. /* Buffer to store pads coordinates when creating a track.
* these pads are members of the net * these pads are members of the net
* and when the mouse is moved, the g_MaxLinksShowed links to neightbors are drawn * and when the mouse is moved, the g_MaxLinksShowed links to neighbors are
* drawn
*/ */
static std::vector <wxPoint> s_RatsnestMouseToPads; static std::vector <wxPoint> s_RatsnestMouseToPads;
static wxPoint s_CursorPos; // Coordinate of the moving point (mouse cursor and end of current track segment) static wxPoint s_CursorPos; // Coordinate of the moving point (mouse cursor and
// end of current track segment)
/* Used by build_ratsnest_pad(): sort function by link lenght (manhattan distance)*/ /* Used by build_ratsnest_pad(): sort function by link length (manhattan
* distance)
*/
static bool sort_by_localnetlength( const wxPoint& ref, const wxPoint& compare ) static bool sort_by_localnetlength( const wxPoint& ref, const wxPoint& compare )
{ {
wxPoint deltaref = ref - s_CursorPos; wxPoint deltaref = ref - s_CursorPos;
...@@ -1012,23 +1066,20 @@ static bool sort_by_localnetlength( const wxPoint& ref, const wxPoint& compare ) ...@@ -1012,23 +1066,20 @@ static bool sort_by_localnetlength( const wxPoint& ref, const wxPoint& compare )
} }
/****************************************************************************************/
void WinEDA_BasePcbFrame::build_ratsnest_pad( BOARD_ITEM* ref, void WinEDA_BasePcbFrame::build_ratsnest_pad( BOARD_ITEM* ref,
const wxPoint& refpos, bool init ) const wxPoint& refpos, bool init )
/****************************************************************************************/
{ {
int current_net_code = 0, conn_number = 0; int current_net_code = 0, conn_number = 0;
D_PAD* pad_ref = NULL; D_PAD* pad_ref = NULL;
if( ( (m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( ( ( m_Pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
|| ( (m_Pcb->m_Status_Pcb & LISTE_PAD_OK) == 0 ) || ( ( m_Pcb->m_Status_Pcb & LISTE_PAD_OK ) == 0 )
|| ( (m_Pcb->m_Status_Pcb & NET_CODES_OK) == 0 ) ) || ( ( m_Pcb->m_Status_Pcb & NET_CODES_OK ) == 0 ) )
{ {
s_RatsnestMouseToPads.clear(); s_RatsnestMouseToPads.clear();
return; return;
} }
s_CursorPos = refpos; s_CursorPos = refpos;
if( init ) if( init )
{ {
...@@ -1061,13 +1112,16 @@ void WinEDA_BasePcbFrame::build_ratsnest_pad( BOARD_ITEM* ref, ...@@ -1061,13 +1112,16 @@ void WinEDA_BasePcbFrame::build_ratsnest_pad( BOARD_ITEM* ref,
return; return;
NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code ); NETINFO_ITEM* net = m_Pcb->FindNet( current_net_code );
if( net == NULL ) //Should not occur
if( net == NULL ) // Should not occur
{ {
DisplayError( this, wxT( "build_ratsnest_pad() error: net not found" ) ); DisplayError( this,
wxT( "build_ratsnest_pad() error: net not found" ) );
return; return;
} }
// Create a list of pads candidates ( pads not already connected to the current track: // Create a list of pads candidates ( pads not already connected to the
// current track:
for( unsigned ii = 0; ii < net->m_ListPad.size(); ii++ ) for( unsigned ii = 0; ii < net->m_ListPad.size(); ii++ )
{ {
D_PAD* pad = net->m_ListPad[ii]; D_PAD* pad = net->m_ListPad[ii];
...@@ -1080,17 +1134,15 @@ void WinEDA_BasePcbFrame::build_ratsnest_pad( BOARD_ITEM* ref, ...@@ -1080,17 +1134,15 @@ void WinEDA_BasePcbFrame::build_ratsnest_pad( BOARD_ITEM* ref,
} /* end if Init */ } /* end if Init */
if( s_RatsnestMouseToPads.size() > 1 ) if( s_RatsnestMouseToPads.size() > 1 )
sort( s_RatsnestMouseToPads.begin(), s_RatsnestMouseToPads.end(), sort_by_localnetlength ); sort( s_RatsnestMouseToPads.begin(),
s_RatsnestMouseToPads.end(), sort_by_localnetlength );
} }
/*******************************************************/
void WinEDA_BasePcbFrame::trace_ratsnest_pad( wxDC* DC )
/*******************************************************/
/* /*
* Displays a "ratsnest" during track creation * Displays a "ratsnest" during track creation
*/ */
void WinEDA_BasePcbFrame::trace_ratsnest_pad( wxDC* DC )
{ {
if( DC == NULL ) if( DC == NULL )
return; return;
...@@ -1105,6 +1157,7 @@ void WinEDA_BasePcbFrame::trace_ratsnest_pad( wxDC* DC ) ...@@ -1105,6 +1157,7 @@ void WinEDA_BasePcbFrame::trace_ratsnest_pad( wxDC* DC )
if( ii >= g_MaxLinksShowed ) if( ii >= g_MaxLinksShowed )
break; break;
GRLine( &DrawPanel->m_ClipBox, DC, s_CursorPos, s_RatsnestMouseToPads[ii], 0, YELLOW ); GRLine( &DrawPanel->m_ClipBox, DC, s_CursorPos,
s_RatsnestMouseToPads[ii], 0, YELLOW );
} }
} }
...@@ -18,19 +18,15 @@ enum layer_sel_id { ...@@ -18,19 +18,15 @@ enum layer_sel_id {
}; };
/***********************************************/
/* 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 + 1]; // One extra element for "(Deselect)" radiobutton int m_LayerId[NB_LAYERS + 1]; // One extra element for "(Deselect)"
// radiobutton
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, bool null_layer ); int min_layer, int max_layer, bool null_layer );
...@@ -43,7 +39,7 @@ private: ...@@ -43,7 +39,7 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* Table des evenements pour WinEDA_SelLayerFrame */
BEGIN_EVENT_TABLE( WinEDA_SelLayerFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_SelLayerFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_SelLayerFrame::Sel_Layer ) EVT_BUTTON( wxID_OK, WinEDA_SelLayerFrame::Sel_Layer )
EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerFrame::OnCancelClick )
...@@ -51,31 +47,34 @@ BEGIN_EVENT_TABLE( WinEDA_SelLayerFrame, wxDialog ) ...@@ -51,31 +47,34 @@ BEGIN_EVENT_TABLE( WinEDA_SelLayerFrame, wxDialog )
END_EVENT_TABLE() END_EVENT_TABLE()
/****************************************************************************************/
int WinEDA_BasePcbFrame::SelectLayer( int default_layer, int min_layer, int max_layer,
bool null_layer )
/****************************************************************************************/
/** Install the dialog box for layer selection /** Install the dialog box for layer selection
* @param default_layer = Preselection (NB_LAYERS for "(Deselect)" layer) * @param default_layer = Preselection (NB_LAYERS for "(Deselect)" layer)
* @param min_layer = min layer value (-1 if no min value) * @param min_layer = min layer value (-1 if no min value)
* @param max_layer = max layer value (-1 if no max value) * @param max_layer = max layer value (-1 if no max value)
* @param null_layer = display a "(Deselect)" radiobutton (when set to true) * @param null_layer = display a "(Deselect)" radiobutton (when set to true)
* @return new layer value (NB_LAYERS when "(Deselect)" radiobutton selected), * @return new layer value (NB_LAYERS when "(Deselect)" radiobutton selected),
* or -1 if cancelled * or -1 if canceled
* *
* Providing the option to also display a "(Deselect)" radiobutton makes the * Providing the option to also display a "(Deselect)" radiobutton makes the
* "Swap Layers" command (and GerbView's "Export to Pcbnew" command) more "user * "Swap Layers" command (and GerbView's "Export to Pcbnew" command) more "user
* friendly", by permitting any layer to be "deselected" immediately after its * friendly", by permitting any layer to be "deselected" immediately after its
* corresponding radiobutton has been clicked on. (It would otherwise be * corresponding radiobutton has been clicked on. (It would otherwise be
* necessary to first cancel the "Select Layer:" dialog box (invoked after a * necessary to first cancel the "Select Layer:" dialog box (invoked after a
* different radiobutton is clicked on) prior to then clicking on the "Deselect" * different radiobutton is clicked on) prior to then clicking on the
* "Deselect"
* button provided within the "Swap Layers:" or "Layer selection:" dialog box). * button provided within the "Swap Layers:" or "Layer selection:" dialog box).
*/ */
int WinEDA_BasePcbFrame::SelectLayer( int default_layer,
int min_layer,
int max_layer,
bool null_layer )
{ {
int layer; int layer;
WinEDA_SelLayerFrame* frame = WinEDA_SelLayerFrame* frame = new WinEDA_SelLayerFrame( this,
new WinEDA_SelLayerFrame( this, default_layer, min_layer, max_layer, null_layer ); default_layer,
min_layer,
max_layer,
null_layer );
layer = frame->ShowModal(); layer = frame->ShowModal();
frame->Destroy(); frame->Destroy();
...@@ -83,42 +82,43 @@ int WinEDA_BasePcbFrame::SelectLayer( int default_layer, int min_layer, int max_ ...@@ -83,42 +82,43 @@ int WinEDA_BasePcbFrame::SelectLayer( int default_layer, int min_layer, int max_
} }
/***********************************************************************/
WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent,
int default_layer, int min_layer,
int max_layer, bool null_layer ) :
wxDialog( parent, -1, _("Select Layer:"), wxPoint( -1, -1 ),
wxSize( 470, 250 ),
DIALOG_STYLE )
/***********************************************************************/
/* /*
* The "OK" and "Cancel" buttons are positioned (in a horizontal line) * The "OK" and "Cancel" buttons are positioned (in a horizontal line)
* beneath the "Layer" radiobox, unless that contains only one column of * beneath the "Layer" radiobox, unless that contains only one column of
* radiobuttons, in which case they are positioned (in a vertical line) * radiobuttons, in which case they are positioned (in a vertical line)
* to the right of that radiobox. * to the right of that radiobox.
*/ */
WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent,
int default_layer, int min_layer,
int max_layer, bool null_layer ) :
wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ),
wxSize( 470, 250 ),
DIALOG_STYLE )
{ {
BOARD* board = parent->GetBoard(); BOARD* board = parent->GetBoard();
wxButton* Button; wxButton* Button;
int ii; int ii;
wxString LayerList[NB_LAYERS + 1]; // One extra element for "(Deselect)" radiobutton wxString LayerList[NB_LAYERS + 1]; // One extra element for "(Deselect)"
// radiobutton
int LayerCount, LayerSelect = -1; int LayerCount, LayerSelect = -1;
m_Parent = parent; m_Parent = parent;
/* Build the layer list */ /* Build the layer list */
LayerCount = 0; LayerCount = 0;
int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount( ) - 1]; int Masque_Layer =
g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount() - 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 ) if( min_layer > ii )
continue; continue;
if( (max_layer >= 0) && (max_layer < ii) ) if( ( max_layer >= 0 ) && ( max_layer < ii ) )
break; break;
LayerList[LayerCount] = board->GetLayerName( ii ); LayerList[LayerCount] = board->GetLayerName( ii );
...@@ -129,6 +129,7 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, ...@@ -129,6 +129,7 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent,
LayerCount++; LayerCount++;
} }
} }
// When appropriate, also provide a "(Deselect)" radiobutton // When appropriate, also provide a "(Deselect)" radiobutton
if( null_layer ) if( null_layer )
{ {
...@@ -140,35 +141,35 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, ...@@ -140,35 +141,35 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent,
LayerCount++; LayerCount++;
} }
m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _("Layer"), m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _( "Layer" ),
wxPoint( -1, -1 ), wxSize( -1, -1 ), LayerCount, LayerList, wxPoint( -1, -1 ), wxSize( -1, -1 ),
(LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS ); LayerCount, LayerList,
(LayerCount < 8) ? LayerCount : 8,
wxRA_SPECIFY_ROWS );
if( LayerSelect >= 0 ) if( LayerSelect >= 0 )
m_LayerList->SetSelection( LayerSelect ); m_LayerList->SetSelection( LayerSelect );
wxBoxSizer* FrameBoxSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* FrameBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer(FrameBoxSizer); SetSizer( FrameBoxSizer );
FrameBoxSizer->Add(m_LayerList, 0, wxALIGN_TOP|wxALL, 5); FrameBoxSizer->Add( m_LayerList, 0, wxALIGN_TOP | wxALL, 5 );
wxBoxSizer* ButtonBoxSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* ButtonBoxSizer = new wxBoxSizer( wxVERTICAL );
FrameBoxSizer->Add(ButtonBoxSizer, 0, wxALIGN_BOTTOM|wxALL, 0); FrameBoxSizer->Add( ButtonBoxSizer, 0, wxALIGN_BOTTOM | wxALL, 0 );
Button = new wxButton( this, wxID_OK, _("OK") ); Button = new wxButton( this, wxID_OK, _( "OK" ) );
ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, wxID_CANCEL, _("Cancel") ); Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
if( GetSizer() ) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
} }
/***************************************************************/
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()];
...@@ -176,17 +177,15 @@ void WinEDA_SelLayerFrame::Sel_Layer( wxCommandEvent& event ) ...@@ -176,17 +177,15 @@ void WinEDA_SelLayerFrame::Sel_Layer( wxCommandEvent& event )
} }
/***************************************************************/
void WinEDA_SelLayerFrame::OnCancelClick( wxCommandEvent& event ) void WinEDA_SelLayerFrame::OnCancelClick( wxCommandEvent& event )
/***************************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/*********************************************************/ /*********************************************/
/* classe pour la frame de selection de paires de layers */ /* Dialog for the selecting pairs of layers. */
/*********************************************************/ /*********************************************/
class WinEDA_SelLayerPairFrame : public wxDialog class WinEDA_SelLayerPairFrame : public wxDialog
{ {
...@@ -196,10 +195,7 @@ private: ...@@ -196,10 +195,7 @@ private:
wxRadioBox* m_LayerListBOTTOM; wxRadioBox* m_LayerListBOTTOM;
int m_LayerId[NB_COPPER_LAYERS]; int m_LayerId[NB_COPPER_LAYERS];
public: public: WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent );
// Constructor and destructor
WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent );
~WinEDA_SelLayerPairFrame() { }; ~WinEDA_SelLayerPairFrame() { };
private: private:
...@@ -210,29 +206,25 @@ private: ...@@ -210,29 +206,25 @@ private:
}; };
/* Table des evenements pour WinEDA_SelLayerPairFrame */
BEGIN_EVENT_TABLE( WinEDA_SelLayerPairFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_SelLayerPairFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_SelLayerPairFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_SelLayerPairFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerPairFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerPairFrame::OnCancelClick )
END_EVENT_TABLE() END_EVENT_TABLE()
/***********************************************/ /* Display a list of two copper layers for selection of a pair of layers
void WinEDA_BasePcbFrame::SelectLayerPair() * for auto-routing, vias ...
/***********************************************/
/* Affiche une double liste de layers cuivre pour selection d'une paire de layers
* pour autorutage, vias...
*/ */
void WinEDA_BasePcbFrame::SelectLayerPair()
{ {
// Check whether more than one copper layer has been enabled for the // Check whether more than one copper layer has been enabled for the
// current PCB file, as Layer Pairs can only meaningfully be defined // current PCB file, as Layer Pairs can only meaningfully be defined
// within PCB files which contain at least two copper layers. // within PCB files which contain at least two copper layers.
if( GetBoard()->m_BoardSettings->GetCopperLayerCount( ) < 2 ) if( GetBoard()->m_BoardSettings->GetCopperLayerCount() < 2 )
{ {
wxString InfoMsg; wxString InfoMsg;
InfoMsg = _( "Less than two copper layers are being used." ); InfoMsg = _( "Less than two copper layers are being used." );
InfoMsg << wxT( "\n" ) << _( "Hence Layer Pairs cannot be specified." ); InfoMsg << wxT( "\n" ) << _( "Hence layer pairs cannot be specified." );
DisplayInfoMessage( this, InfoMsg ); DisplayInfoMessage( this, InfoMsg );
return; return;
} }
...@@ -254,11 +246,9 @@ void WinEDA_BasePcbFrame::SelectLayerPair() ...@@ -254,11 +246,9 @@ void WinEDA_BasePcbFrame::SelectLayerPair()
} }
/*******************************************************************************/
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 )
/*******************************************************************************/
{ {
BOARD* board = parent->GetBoard(); BOARD* board = parent->GetBoard();
wxButton* Button; wxButton* Button;
...@@ -269,9 +259,10 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent ...@@ -269,9 +259,10 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent
m_Parent = parent; m_Parent = parent;
PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->GetScreen();
/* Construction de la liste des couches autoris�s */ int Masque_Layer =
int Masque_Layer = g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount( ) - 1]; g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount() - 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;
...@@ -287,63 +278,68 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent ...@@ -287,63 +278,68 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent
} }
} }
m_LayerListTOP = new wxRadioBox( this, ID_LAYER_SELECT_TOP, _("Top Layer"), m_LayerListTOP = new wxRadioBox( this, ID_LAYER_SELECT_TOP,
wxPoint( -1, -1 ), wxSize( -1, -1 ), LayerCount, LayerList, _( "Top Layer" ),
(LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS ); wxPoint( -1, -1 ), wxSize( -1, -1 ),
LayerCount, LayerList,
(LayerCount < 8) ? LayerCount : 8,
wxRA_SPECIFY_ROWS );
m_LayerListTOP->SetSelection( LayerTopSelect ); m_LayerListTOP->SetSelection( LayerTopSelect );
m_LayerListBOTTOM = new wxRadioBox( this, ID_LAYER_SELECT_BOTTOM, _("Bottom Layer"), m_LayerListBOTTOM = new wxRadioBox( this, ID_LAYER_SELECT_BOTTOM,
wxPoint( -1, -1 ), wxSize( -1, -1 ), LayerCount, LayerList, _( "Bottom Layer" ),
(LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS ); wxPoint( -1, -1 ), wxSize( -1, -1 ),
LayerCount, LayerList,
(LayerCount < 8) ? LayerCount : 8,
wxRA_SPECIFY_ROWS );
m_LayerListBOTTOM->SetSelection( LayerBottomSelect ); m_LayerListBOTTOM->SetSelection( LayerBottomSelect );
wxBoxSizer* FrameBoxSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* FrameBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer(FrameBoxSizer); SetSizer( FrameBoxSizer );
wxBoxSizer* RadioBoxSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* RadioBoxSizer = new wxBoxSizer( wxHORIZONTAL );
FrameBoxSizer->Add(RadioBoxSizer, 0, wxALIGN_LEFT|wxALL, 0); FrameBoxSizer->Add( RadioBoxSizer, 0, wxALIGN_LEFT | wxALL, 0 );
wxBoxSizer* ButtonBoxSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* ButtonBoxSizer = new wxBoxSizer( wxHORIZONTAL );
FrameBoxSizer->Add(ButtonBoxSizer, 0, wxALIGN_RIGHT|wxALL, 0); FrameBoxSizer->Add( ButtonBoxSizer, 0, wxALIGN_RIGHT | wxALL, 0 );
RadioBoxSizer->Add(m_LayerListTOP, 0, wxALIGN_TOP|wxALL, 5); RadioBoxSizer->Add( m_LayerListTOP, 0, wxALIGN_TOP | wxALL, 5 );
RadioBoxSizer->Add(m_LayerListBOTTOM, 0, wxALIGN_TOP|wxALL, 5); RadioBoxSizer->Add( m_LayerListBOTTOM, 0, wxALIGN_TOP | wxALL, 5 );
Button = new wxButton( this, wxID_OK, _("OK") ); Button = new wxButton( this, wxID_OK, _( "OK" ) );
ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, wxID_CANCEL, _("Cancel") ); Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
if( GetSizer() ) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
} }
/***************************************************************/
void WinEDA_SelLayerPairFrame::OnOkClick( wxCommandEvent& event ) void WinEDA_SelLayerPairFrame::OnOkClick( wxCommandEvent& event )
/***************************************************************/
{ {
// select the same layer for top and bottom is allowed (normal in some boards) // select the same layer for top and bottom is allowed (normal in some
// boards)
// but could be a mistake. So display an info message // but could be a mistake. So display an info message
if( m_LayerId[m_LayerListTOP->GetSelection()] if( m_LayerId[m_LayerListTOP->GetSelection()]
== m_LayerId[m_LayerListBOTTOM->GetSelection()] ) == m_LayerId[m_LayerListBOTTOM->GetSelection()] )
DisplayInfoMessage( this, _( "Warning: The Top Layer and Bottom Layer are same." ) ); DisplayInfoMessage( this,
_( "Warning: The Top Layer and Bottom Layer are same." ) );
PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->GetScreen();
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::OnCancelClick( wxCommandEvent& event ) void WinEDA_SelLayerPairFrame::OnCancelClick( wxCommandEvent& event )
/***************************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/***************************************************/ /************************************/
/* set_grid.cpp - Gestion de la grille utilisateur */ /* set_grid.cpp - manage user grid. */
/***************************************************/ /************************************/
/*
Affichage et modifications des parametres de travail de PcbNew
Parametres = dimensions de la grille utilisateur
*/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -20,8 +16,7 @@ ...@@ -20,8 +16,7 @@
#include "set_grid.h" #include "set_grid.h"
/************************************************************/ void WinEDA_BasePcbFrame::InstallGridFrame( const wxPoint& pos )
void WinEDA_BasePcbFrame::InstallGridFrame(const wxPoint & pos)
{ {
WinEDA_PcbGridFrame dlg( this, pos ); WinEDA_PcbGridFrame dlg( this, pos );
...@@ -55,49 +50,58 @@ BEGIN_EVENT_TABLE( WinEDA_PcbGridFrame, wxDialog ) ...@@ -55,49 +50,58 @@ BEGIN_EVENT_TABLE( WinEDA_PcbGridFrame, wxDialog )
////@end WinEDA_PcbGridFrame event table entries ////@end WinEDA_PcbGridFrame event table entries
END_EVENT_TABLE() END_EVENT_TABLE()
/*! /*!
* WinEDA_PcbGridFrame constructors * WinEDA_PcbGridFrame constructors
*/ */
WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( ) WinEDA_PcbGridFrame::WinEDA_PcbGridFrame()
{ {
} }
WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent, WinEDA_PcbGridFrame::WinEDA_PcbGridFrame( WinEDA_BasePcbFrame* parent,
const wxPoint& pos, const wxPoint& pos,
wxWindowID id, wxWindowID id,
const wxString& caption, const wxString& caption,
const wxSize& size, long style ) const wxSize& size, long style )
{ {
Create(parent, id, caption, pos, size, style); Create( parent, id, caption, pos, size, style );
} }
/*! /*!
* WinEDA_PcbGridFrame creator * WinEDA_PcbGridFrame creator
*/ */
bool WinEDA_PcbGridFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) bool WinEDA_PcbGridFrame::Create( wxWindow* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{ {
////@begin WinEDA_PcbGridFrame member initialisation ////@begin WinEDA_PcbGridFrame member initialisation
m_UnitGrid = NULL; m_UnitGrid = NULL;
m_OptGridSizeX = NULL; m_OptGridSizeX = NULL;
m_OptGridSizeY = NULL; m_OptGridSizeY = NULL;
////@end WinEDA_PcbGridFrame member initialisation ////@end WinEDA_PcbGridFrame member initialisation
////@begin WinEDA_PcbGridFrame creation ////@begin WinEDA_PcbGridFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS); SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
if (GetSizer()) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
////@end WinEDA_PcbGridFrame creation ////@end WinEDA_PcbGridFrame creation
return true; return true;
} }
/*! /*!
* Control creation for WinEDA_PcbGridFrame * Control creation for WinEDA_PcbGridFrame
*/ */
...@@ -109,46 +113,79 @@ void WinEDA_PcbGridFrame::CreateControls() ...@@ -109,46 +113,79 @@ void WinEDA_PcbGridFrame::CreateControls()
WinEDA_PcbGridFrame* itemDialog1 = this; WinEDA_PcbGridFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxHORIZONTAL );
itemDialog1->SetSizer(itemBoxSizer2);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);
wxArrayString m_UnitGridStrings;
m_UnitGridStrings.Add(_("Inches"));
m_UnitGridStrings.Add(_("mm"));
m_UnitGrid = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid Size Units"), wxDefaultPosition, wxDefaultSize, m_UnitGridStrings, 1, wxRA_SPECIFY_COLS );
m_UnitGrid->SetSelection(0);
itemBoxSizer3->Add(m_UnitGrid, 0, wxGROW|wxALL, 5);
itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Grid Size X"), wxDefaultPosition, wxDefaultSize, 0 ); itemDialog1->SetSizer( itemBoxSizer2 );
itemBoxSizer3->Add(itemStaticText6, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_OptGridSizeX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer3->Add(m_OptGridSizeX, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 );
wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("User Grid Size Y"), wxDefaultPosition, wxDefaultSize, 0 ); wxArrayString m_UnitGridStrings;
itemBoxSizer3->Add(itemStaticText8, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); m_UnitGridStrings.Add( _( "Inches" ) );
m_UnitGridStrings.Add( _( "mm" ) );
m_OptGridSizeY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); m_UnitGrid = new wxRadioBox( itemDialog1, ID_RADIOBOX,
itemBoxSizer3->Add(m_OptGridSizeY, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); _( "Grid Size Units" ), wxDefaultPosition,
wxDefaultSize, m_UnitGridStrings, 1,
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); wxRA_SPECIFY_COLS );
itemBoxSizer2->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_UnitGrid->SetSelection( 0 );
itemBoxSizer3->Add( m_UnitGrid, 0, wxGROW | wxALL, 5 );
wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer3->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1,
wxID_STATIC,
_( "User Grid Size X" ),
wxDefaultPosition,
wxDefaultSize,
0 );
itemBoxSizer3->Add( itemStaticText6,
0,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_OptGridSizeX = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer3->Add( m_OptGridSizeX,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1,
wxID_STATIC,
_( "User Grid Size Y" ),
wxDefaultPosition,
wxDefaultSize,
0 );
itemBoxSizer3->Add( itemStaticText8,
0,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_OptGridSizeY = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ),
wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer3->Add( m_OptGridSizeY,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer2->Add( itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _( "&OK" ),
wxDefaultPosition,
wxDefaultSize, 0 );
itemButton11->SetDefault(); itemButton11->SetDefault();
itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); itemBoxSizer10->Add( itemButton11, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CANCEL,
itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); _( "&Cancel" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer10->Add( itemButton12, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
////@end WinEDA_PcbGridFrame content construction ////@end WinEDA_PcbGridFrame content construction
} }
/*! /*!
* Should we show tooltips? * Should we show tooltips?
*/ */
...@@ -158,6 +195,7 @@ bool WinEDA_PcbGridFrame::ShowToolTips() ...@@ -158,6 +195,7 @@ bool WinEDA_PcbGridFrame::ShowToolTips()
return true; return true;
} }
/*! /*!
* Get bitmap resources * Get bitmap resources
*/ */
...@@ -166,11 +204,13 @@ wxBitmap WinEDA_PcbGridFrame::GetBitmapResource( const wxString& name ) ...@@ -166,11 +204,13 @@ wxBitmap WinEDA_PcbGridFrame::GetBitmapResource( const wxString& name )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin WinEDA_PcbGridFrame bitmap retrieval ////@begin WinEDA_PcbGridFrame bitmap retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullBitmap; return wxNullBitmap;
////@end WinEDA_PcbGridFrame bitmap retrieval ////@end WinEDA_PcbGridFrame bitmap retrieval
} }
/*! /*!
* Get icon resources * Get icon resources
*/ */
...@@ -179,8 +219,9 @@ wxIcon WinEDA_PcbGridFrame::GetIconResource( const wxString& name ) ...@@ -179,8 +219,9 @@ wxIcon WinEDA_PcbGridFrame::GetIconResource( const wxString& name )
{ {
// Icon retrieval // Icon retrieval
////@begin WinEDA_PcbGridFrame icon retrieval ////@begin WinEDA_PcbGridFrame icon retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullIcon; return wxNullIcon;
////@end WinEDA_PcbGridFrame icon retrieval ////@end WinEDA_PcbGridFrame icon retrieval
} }
...@@ -195,6 +236,7 @@ void WinEDA_PcbGridFrame::SetGridSize( const wxRealPoint& grid ) ...@@ -195,6 +236,7 @@ void WinEDA_PcbGridFrame::SetGridSize( const wxRealPoint& grid )
m_OptGridSizeY->SetValue( msg ); m_OptGridSizeY->SetValue( msg );
} }
wxRealPoint WinEDA_PcbGridFrame::GetGridSize() wxRealPoint WinEDA_PcbGridFrame::GetGridSize()
{ {
wxRealPoint grid; wxRealPoint grid;
...@@ -207,12 +249,14 @@ wxRealPoint WinEDA_PcbGridFrame::GetGridSize() ...@@ -207,12 +249,14 @@ wxRealPoint WinEDA_PcbGridFrame::GetGridSize()
return grid; return grid;
} }
void WinEDA_PcbGridFrame::SetGridUnits( int units ) void WinEDA_PcbGridFrame::SetGridUnits( int units )
{ {
if ( units != INCHES ) if( units != INCHES )
m_UnitGrid->SetSelection( 1 ); m_UnitGrid->SetSelection( 1 );
} }
int WinEDA_PcbGridFrame::GetGridUnits() int WinEDA_PcbGridFrame::GetGridUnits()
{ {
return m_UnitGrid->GetSelection(); return m_UnitGrid->GetSelection();
......
/***************************************/ /*************/
/* AUTOROUTAGE PCB : routine de calcul */ /* solve.cpp */
/***************************************/ /*************/
/* fichier SOLVE.Cpp */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -19,20 +17,38 @@ ...@@ -19,20 +17,38 @@
#include "cell.h" #include "cell.h"
/* Routines definies ici : */
static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, int two_sides, int row_source, static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe,
wxDC* DC,
int two_sides,
int row_source,
int col_source, int col_source,
int row_target, int col_target, RATSNEST_ITEM* pt_chevelu ); int row_target,
static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, int, int, int, int, int, int net_code ); int col_target,
static void OrCell_Trace( BOARD* pcb, int col, int row, int side, int orient, int current_net_code ); RATSNEST_ITEM* pt_chevelu );
static int Retrace( WinEDA_PcbFrame* pcbframe,
wxDC* DC,
int,
int,
int,
int,
int,
int net_code );
static void OrCell_Trace( BOARD* pcb,
int col,
int row,
int side,
int orient,
int current_net_code );
static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ); static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC );
/* Variables locales : */
static int segm_oX, segm_oY; static int segm_oX, segm_oY;
static int segm_fX, segm_fY; /* Origine et fin de la piste en cours de trace */ static int segm_fX, segm_fY; /* Origin and position of the current
* trace segment. */
static RATSNEST_ITEM* pt_cur_ch; static RATSNEST_ITEM* pt_cur_ch;
static int Ncurrent; /* measures of progress */ static int Ncurrent; /* measures of progress */
static int s_Clearance; // Clerance value used in autorouter static int s_Clearance; // Clearance value used in autorouter
#define NOSUCCESS 0 #define NOSUCCESS 0
...@@ -53,10 +69,12 @@ static int s_Clearance; // Clerance value used in autorouter ...@@ -53,10 +69,12 @@ static int s_Clearance; // Clerance value used in autorouter
** +---+---+---+ ** +---+---+---+
*/ */
/* for visiting neighbors on the same side: increments/decrements des coord /* for visiting neighbors on the same side: increments/decrements coord of
* [][0] = row, []{1] = col a ajouter aux coord du point central pour * [] [0] = row [] (1] = col was added to the coord of the midpoint for
* obtenir les coord des 8 points voisins */ * Get the coord of the 8 neighboring points.
static int delta[8][2] = { */
static int delta[8][2] =
{
{ 1, -1 }, /* northwest */ { 1, -1 }, /* northwest */
{ 1, 0 }, /* north */ { 1, 0 }, /* north */
{ 1, 1 }, /* northeast */ { 1, 1 }, /* northeast */
...@@ -67,7 +85,9 @@ static int delta[8][2] = { ...@@ -67,7 +85,9 @@ static int delta[8][2] = {
{ -1, 1 } /* southeast */ { -1, 1 } /* southeast */
}; };
static int ndir[8] = { /* for building paths back to source */ static int ndir[8] =
{
/* for building paths back to source */
FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST, FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST,
FROM_EAST, FROM_WEST, FROM_EAST, FROM_WEST,
FROM_NORTHEAST, FROM_NORTH, FROM_NORTHWEST FROM_NORTHEAST, FROM_NORTH, FROM_NORTHWEST
...@@ -175,7 +195,8 @@ static struct ...@@ -175,7 +195,8 @@ static struct
{ {
long trace; long trace;
int present; int present;
} selfok2[8] = { } selfok2[8] =
{
{ HOLE_NORTHWEST, 0 }, { HOLE_NORTHWEST, 0 },
{ HOLE_NORTH, 0 }, { HOLE_NORTH, 0 },
{ HOLE_NORTHEAST, 0 }, { HOLE_NORTHEAST, 0 },
...@@ -186,30 +207,27 @@ static struct ...@@ -186,30 +207,27 @@ static struct
{ HOLE_SOUTHEAST, 0 } { HOLE_SOUTHEAST, 0 }
}; };
static long newmask[8] = { /* patterns to mask out in neighbor cells */ static long newmask[8] =
0, CORNER_NORTHWEST | CORNER_NORTHEAST, {
/* patterns to mask out in neighbor cells */
0,
CORNER_NORTHWEST | CORNER_NORTHEAST,
0, 0,
CORNER_NORTHWEST | CORNER_SOUTHWEST, CORNER_NORTHEAST | CORNER_SOUTHEAST, CORNER_NORTHWEST | CORNER_SOUTHWEST,
0, CORNER_SOUTHWEST | CORNER_SOUTHEAST, CORNER_NORTHEAST | CORNER_SOUTHEAST,
0,
CORNER_SOUTHWEST | CORNER_SOUTHEAST,
0 0
}; };
/* Macro d'affichage de l'activite du routeur; */ /* Route all traces
#define AFFICHE_ACTIVITE_ROUTE \ * Return:
msg.Printf( wxT("Activity: Open %d Closed %d Moved %d"), OpenNodes, ClosNodes, MoveNodes); \ * 1 if OK
pcbframe->Affiche_Message(msg); * -1 if escape (stop being routed) request
* -2 if default memory allocation
/********************************************************/
int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
/********************************************************/
/* route all traces
* Return: 1 si OK
* -1 si Escape (arret en cours de routage) demande
* -2 si defaut alloc memoire
*/ */
int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
{ {
int current_net_code; int current_net_code;
int row_source, col_source, row_target, col_target; int row_source, col_source, row_target, col_target;
...@@ -231,13 +249,14 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides ) ...@@ -231,13 +249,14 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
/* go until no more work to do */ /* go until no more work to do */
GetWork( &row_source, &col_source, &current_net_code, GetWork( &row_source, &col_source, &current_net_code,
&row_target, &col_target, &pt_cur_ch ); // 1er chevelu a router &row_target, &col_target, &pt_cur_ch ); // First net to route.
for( ; row_source != ILLEGAL; GetWork( &row_source, &col_source, for( ; row_source != ILLEGAL; GetWork( &row_source, &col_source,
&current_net_code, &row_target, &col_target, &current_net_code, &row_target,
&col_target,
&pt_cur_ch ) ) &pt_cur_ch ) )
{ {
/* Tst demande d'arret de routage ( key ESCAPE actionnee ) */ /* Test to stop routing ( escape key pressed ) */
wxYield(); wxYield();
if( DrawPanel->m_AbortRequest ) if( DrawPanel->m_AbortRequest )
{ {
...@@ -262,18 +281,35 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides ) ...@@ -262,18 +281,35 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
} }
pt_cur_ch = pt_cur_ch; pt_cur_ch = pt_cur_ch;
segm_oX = GetBoard()->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_source); segm_oX = GetBoard()->m_BoundaryBox.m_Pos.x +
segm_oY = GetBoard()->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_source); (g_GridRoutingSize * col_source);
segm_fX = GetBoard()->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * col_target); segm_oY = GetBoard()->m_BoundaryBox.m_Pos.y +
segm_fY = GetBoard()->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * row_target); (g_GridRoutingSize * row_source);
segm_fX = GetBoard()->m_BoundaryBox.m_Pos.x +
/* Affiche Liaison */ (g_GridRoutingSize * col_target);
GRLine( &DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, 0, WHITE | GR_XOR ); segm_fY = GetBoard()->m_BoundaryBox.m_Pos.y +
(g_GridRoutingSize * row_target);
/* Draw segment. */
GRLine( &DrawPanel->m_ClipBox,
DC,
segm_oX,
segm_oY,
segm_fX,
segm_fY,
0,
WHITE | GR_XOR );
pt_cur_ch->m_PadStart->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL ); pt_cur_ch->m_PadStart->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
pt_cur_ch->m_PadEnd->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL ); pt_cur_ch->m_PadEnd->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
success = Autoroute_One_Track( this, DC, two_sides, row_source, col_source, success = Autoroute_One_Track( this,
row_target, col_target, pt_cur_ch ); DC,
two_sides,
row_source,
col_source,
row_target,
col_target,
pt_cur_ch );
switch( success ) switch( success )
{ {
...@@ -302,7 +338,7 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides ) ...@@ -302,7 +338,7 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
msg.Printf( wxT( "%d " ), GetBoard()->m_NbNoconnect ); msg.Printf( wxT( "%d " ), GetBoard()->m_NbNoconnect );
Affiche_1_Parametre( this, 38, wxT( "NoConn" ), msg, CYAN ); Affiche_1_Parametre( this, 38, wxT( "NoConn" ), msg, CYAN );
/* Effacement des affichages de routage sur l'ecran */ /* Delete routing from display. */
pt_cur_ch->m_PadStart->Draw( DrawPanel, DC, GR_AND ); pt_cur_ch->m_PadStart->Draw( DrawPanel, DC, GR_AND );
pt_cur_ch->m_PadEnd->Draw( DrawPanel, DC, GR_AND ); pt_cur_ch->m_PadEnd->Draw( DrawPanel, DC, GR_AND );
...@@ -316,27 +352,29 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides ) ...@@ -316,27 +352,29 @@ int WinEDA_PcbFrame::Solve( wxDC* DC, int two_sides )
} }
/**********************************************************************************/ /* Route a trace on the BOARD.
static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, * Parameters:
int two_sides, int row_source, int col_source, * 1 side / 2 sides (0 / 1)
int row_target, int col_target, RATSNEST_ITEM* pt_chevelu ) * Coord source (row, col)
/**********************************************************************************/ * Coord destination (row, col)
* Net_code
/* Route une piste du BOARD. * Pointer to the ratsnest reference
* Parametres:
* 1 face / 2 faces ( 0 / 1)
* coord source (row,col)
* coord destination (row,col)
* net_code
* pointeur sur le chevelu de reference
* *
* Retourne : * Returns:
* SUCCESS si route trouvee * SUCCESS if routed
* TRIVIAL_SUCCESS si pads connectes par superposition ( pas de piste a tirer) * TRIVIAL_SUCCESS if pads connected by overlay (no track has learned)
* NOSUCCESS si echec * If failure NOSUCCESS
* STOP_FROM_ESC si Escape demande * Escape STOP_FROM_ESC if demand
* ERR_MEMORY defaut alloc RAM * ERR_MEMORY if memory allocation failed.
*/ */
static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe,
wxDC* DC,
int two_sides,
int row_source,
int col_source,
int row_target,
int col_target,
RATSNEST_ITEM* pt_chevelu )
{ {
int r, c, side, d, apx_dist, nr, nc; int r, c, side, d, apx_dist, nr, nc;
int result, skip; int result, skip;
...@@ -345,22 +383,27 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -345,22 +383,27 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
int newdist, olddir, _self; int newdist, olddir, _self;
int current_net_code; int current_net_code;
int marge, via_marge; int marge, via_marge;
int pad_masque_layer_s; /* Masque des couches appartenant au pad de depart */ int pad_masque_layer_s; /* Mask layers belonging to the
int pad_masque_layer_e; /* Masque des couches appartenant au pad d'arrivee */ *starting pad. */
int pad_masque_layer_e; /* Mask layers belonging to the ending
*pad. */
int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP]; int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP];
int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM]; int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM];
int masque_layers; /* Masque des 2 couches de routage */ int masque_layers; /* Mask two layers for routing. */
int tab_mask[2]; /* permet le calcul du Masque de la couche en cours int tab_mask[2]; /* Enables the calculation of the mask
* de tst (side = TOP ou BOTTOM)*/ * layer being
* tested. (side = TOP or BOTTOM) */
int start_mask_layer = 0; int start_mask_layer = 0;
wxString msg; wxString msg;
wxBusyCursor dummy_cursor; // Set an hourglass cursor while routing a track wxBusyCursor dummy_cursor; // Set an hourglass cursor while routing a
// track
result = NOSUCCESS; result = NOSUCCESS;
marge = s_Clearance + (pcbframe->GetBoard()->GetCurrentTrackWidth() / 2); marge = s_Clearance +
via_marge = s_Clearance + (pcbframe->GetBoard()->GetCurrentViaSize() / 2); ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
via_marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentViaSize() / 2 );
/* clear direction flags */ /* clear direction flags */
i = Nrows * Ncols * sizeof(char); i = Nrows * Ncols * sizeof(char);
...@@ -369,10 +412,10 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -369,10 +412,10 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
lastopen = lastclos = lastmove = 0; lastopen = lastclos = lastmove = 0;
/* Init tab_masque[side] pour tests de fin de routage */ /* Set tab_masque[side] for final test of routing. */
tab_mask[TOP] = masque_layer_TOP; tab_mask[TOP] = masque_layer_TOP;
tab_mask[BOTTOM] = masque_layer_BOTTOM; tab_mask[BOTTOM] = masque_layer_BOTTOM;
/* Init masque des couches actives */ /* Set active layers mask. */
masque_layers = masque_layer_TOP | masque_layer_BOTTOM; masque_layers = masque_layer_TOP | masque_layer_BOTTOM;
pt_cur_ch = pt_chevelu; pt_cur_ch = pt_chevelu;
...@@ -380,31 +423,37 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -380,31 +423,37 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
pad_masque_layer_s = pt_cur_ch->m_PadStart->m_Masque_Layer; pad_masque_layer_s = pt_cur_ch->m_PadStart->m_Masque_Layer;
pad_masque_layer_e = pt_cur_ch->m_PadEnd->m_Masque_Layer; pad_masque_layer_e = pt_cur_ch->m_PadEnd->m_Masque_Layer;
/* Test 1 Si routage possible c.a.d si les pads sont accessibles
* sur les couches de routage */
if( (masque_layers & pad_masque_layer_s) == 0 ) /* First Test if routing possible ie if the pads are accessible
* on the routing layers.
*/
if( ( masque_layers & pad_masque_layer_s ) == 0 )
goto end_of_route; goto end_of_route;
if( (masque_layers & pad_masque_layer_e) == 0 ) if( ( masque_layers & pad_masque_layer_e ) == 0 )
goto end_of_route; goto end_of_route;
/* Test 2 Si routage possible c.a.d si les pads sont accessibles /* Then test if routing possible ie if the pads are accessible
* sur la grille de routage ( 1 point de grille doit etre dans le pad)*/ * On the routing grid (1 grid point must be in the pad)
*/
{ {
int cX = (g_GridRoutingSize * col_source) + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; int cX = ( g_GridRoutingSize * col_source )
int cY = (g_GridRoutingSize * row_source) + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
int cY = ( g_GridRoutingSize * row_source )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
int dx = pt_cur_ch->m_PadStart->m_Size.x / 2; int dx = pt_cur_ch->m_PadStart->m_Size.x / 2;
int dy = pt_cur_ch->m_PadStart->m_Size.y / 2; int dy = pt_cur_ch->m_PadStart->m_Size.y / 2;
int px = pt_cur_ch->m_PadStart->GetPosition().x; int px = pt_cur_ch->m_PadStart->GetPosition().x;
int py = pt_cur_ch->m_PadStart->GetPosition().y; int py = pt_cur_ch->m_PadStart->GetPosition().y;
if( ( (pt_cur_ch->m_PadStart->m_Orient / 900) & 1 ) != 0 ) if( ( ( pt_cur_ch->m_PadStart->m_Orient / 900 ) & 1 ) != 0 )
EXCHG( dx, dy ); EXCHG( dx, dy );
if( (abs( cX - px ) > dx ) || (abs( cY - py ) > dy) ) if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route; goto end_of_route;
cX = (g_GridRoutingSize * col_target) + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; cX = ( g_GridRoutingSize * col_target )
cY = (g_GridRoutingSize * row_target) + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
cY = ( g_GridRoutingSize * row_target )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
dx = pt_cur_ch->m_PadEnd->m_Size.x / 2; dx = pt_cur_ch->m_PadEnd->m_Size.x / 2;
dy = pt_cur_ch->m_PadEnd->m_Size.y / 2; dy = pt_cur_ch->m_PadEnd->m_Size.y / 2;
px = pt_cur_ch->m_PadEnd->GetPosition().x; px = pt_cur_ch->m_PadEnd->GetPosition().x;
...@@ -412,44 +461,46 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -412,44 +461,46 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
if( ( (pt_cur_ch->m_PadEnd->m_Orient / 900) & 1 ) != 0 ) if( ( (pt_cur_ch->m_PadEnd->m_Orient / 900) & 1 ) != 0 )
EXCHG( dx, dy ); EXCHG( dx, dy );
if( (abs( cX - px ) > dx ) || (abs( cY - py ) > dy) ) if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
goto end_of_route; goto end_of_route;
} }
/* Test du cas trivial: connection directe par superposition des pads */ /* Test the trivial case: direct connection overlay pads. */
if( (row_source == row_target) && (col_source == col_target) if( ( row_source == row_target ) && ( col_source == col_target )
&& ( pad_masque_layer_e & pad_masque_layer_s & && ( pad_masque_layer_e & pad_masque_layer_s &
g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount() - 1]) ) g_TabAllCopperLayerMask[g_DesignSettings.GetCopperLayerCount() - 1] ) )
{ {
result = TRIVIAL_SUCCESS; result = TRIVIAL_SUCCESS;
goto end_of_route; goto end_of_route;
} }
/* Placing the bit to remove obstacles on 2 pads to a link. */
/* Placement du bit de suppression d'obstacle relative aux 2 pads a relier */
pcbframe->Affiche_Message( wxT( "Gen Cells" ) ); pcbframe->Affiche_Message( wxT( "Gen Cells" ) );
Place_1_Pad_Board( Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart,
pcbframe->GetBoard(), pt_cur_ch->m_PadStart, CURRENT_PAD, marge, WRITE_OR_CELL ); CURRENT_PAD, marge, WRITE_OR_CELL );
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd, CURRENT_PAD, marge, WRITE_OR_CELL ); Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
CURRENT_PAD, marge, WRITE_OR_CELL );
/* Regenere les barrieres restantes (qui peuvent empieter sur le placement /* Regenerates the remaining barriers (which may encroach on the placement
* des bits precedents) */ * bits precedent)
*/
i = pcbframe->GetBoard()->GetPadsCount(); i = pcbframe->GetBoard()->GetPadsCount();
for( unsigned ii = 0; ii < pcbframe->GetBoard()->GetPadsCount(); ii++ ) for( unsigned ii = 0; ii < pcbframe->GetBoard()->GetPadsCount(); ii++ )
{ {
D_PAD * ptr = pcbframe->GetBoard()->m_NetInfo->GetPad(ii); D_PAD* ptr = pcbframe->GetBoard()->m_NetInfo->GetPad( ii );
if( (pt_cur_ch->m_PadStart != ptr) && (pt_cur_ch->m_PadEnd != ptr) ) if( ( pt_cur_ch->m_PadStart != ptr ) && ( pt_cur_ch->m_PadEnd != ptr ) )
{ {
Place_1_Pad_Board( pcbframe->GetBoard(), ptr, ~CURRENT_PAD, marge, WRITE_AND_CELL ); Place_1_Pad_Board( pcbframe->GetBoard(), ptr, ~CURRENT_PAD,
marge, WRITE_AND_CELL );
} }
} }
InitQueue(); /* initialize the search queue */ InitQueue(); /* initialize the search queue */
apx_dist = GetApxDist( row_source, col_source, row_target, col_target ); apx_dist = GetApxDist( row_source, col_source, row_target, col_target );
/* Init 1ere recherche */ /* Initialize first search. */
if( two_sides ) /* orientation preferentielle */ if( two_sides ) /* Preferred orientation. */
{ {
if( abs( row_target - row_source ) > abs( col_target - col_source ) ) if( abs( row_target - row_source ) > abs( col_target - col_source ) )
{ {
...@@ -514,10 +565,10 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -514,10 +565,10 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
curcell = GetCell( r, c, side ); curcell = GetCell( r, c, side );
if( curcell & CURRENT_PAD ) if( curcell & CURRENT_PAD )
curcell &= ~HOLE; curcell &= ~HOLE;
if( (r == row_target) && (c == col_target) /* success si layer OK */ if( (r == row_target) && (c == col_target) /* success if layer OK */
&& ( tab_mask[side] & pad_masque_layer_e) ) && ( tab_mask[side] & pad_masque_layer_e) )
{ {
/* Efface Liaison */ /* Remove link. */
GRSetDrawMode( DC, GR_XOR ); GRSetDrawMode( DC, GR_XOR );
GRLine( &pcbframe->DrawPanel->m_ClipBox, GRLine( &pcbframe->DrawPanel->m_ClipBox,
DC, DC,
...@@ -528,28 +579,33 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -528,28 +579,33 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
0, 0,
WHITE ); WHITE );
/* Generation de la trace */ /* Generate trace. */
if( Retrace( pcbframe, DC, row_source, col_source, if( Retrace( pcbframe, DC, row_source, col_source,
row_target, col_target, side, current_net_code ) ) row_target, col_target, side, current_net_code ) )
{ {
result = SUCCESS; /* Success : Route OK */ result = SUCCESS; /* Success : Route OK */
} }
break; /* Fin du routage */ break; /* Routing complete. */
} }
if( pcbframe->DrawPanel->m_AbortRequest ) if( pcbframe->DrawPanel->m_AbortRequest )
{ {
result = STOP_FROM_ESC; break; result = STOP_FROM_ESC;
break;
} }
/* report every COUNT new nodes or so */ /* report every COUNT new nodes or so */
#define COUNT 20000 #define COUNT 20000
if( (OpenNodes-lastopen > COUNT) || (ClosNodes-lastclos > COUNT) || (MoveNodes - lastmove > COUNT)) if( ( OpenNodes - lastopen > COUNT )
|| ( ClosNodes - lastclos > COUNT )
|| ( MoveNodes - lastmove > COUNT ) )
{ {
lastopen = OpenNodes; lastopen = OpenNodes;
lastclos = ClosNodes; lastclos = ClosNodes;
lastmove = MoveNodes; lastmove = MoveNodes;
AFFICHE_ACTIVITE_ROUTE; msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d" ),
OpenNodes, ClosNodes, MoveNodes );
pcbframe->Affiche_Message( msg );
} }
_self = 0; _self = 0;
...@@ -560,7 +616,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -560,7 +616,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
for( i = 0; i < 8; i++ ) for( i = 0; i < 8; i++ )
{ {
selfok2[i].present = 0; selfok2[i].present = 0;
if( (curcell & selfok2[i].trace) ) if( curcell & selfok2[i].trace )
selfok2[i].present = 1; selfok2[i].present = 1;
} }
} }
...@@ -612,9 +668,8 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -612,9 +668,8 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
olddir = GetDir( r, c, side ); olddir = GetDir( r, c, side );
newdist = d + CalcDist( ndir[i], olddir, newdist = d + CalcDist( ndir[i], olddir,
(olddir == FROM_OTHERSIDE) ? GetDir( r, ( olddir == FROM_OTHERSIDE ) ?
c, GetDir( r, c, 1 - side ) : 0, side );
1 - side ) : 0, side );
/* if (a) not visited yet, or (b) we have */ /* if (a) not visited yet, or (b) we have */
/* found a better path, add it to queue */ /* found a better path, add it to queue */
...@@ -639,7 +694,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -639,7 +694,7 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
} }
} }
/** etude de l'autre couche **/ /** Test the other layer. **/
if( (two_sides) && !g_No_Via_Route ) if( (two_sides) && !g_No_Via_Route )
{ {
olddir = GetDir( r, c, side ); olddir = GetDir( r, c, side );
...@@ -693,81 +748,156 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -693,81 +748,156 @@ static int Autoroute_One_Track( WinEDA_PcbFrame* pcbframe, wxDC* DC,
{ {
SetDir( r, c, 1 - side, FROM_OTHERSIDE ); SetDir( r, c, 1 - side, FROM_OTHERSIDE );
SetDist( r, c, 1 - side, newdist ); SetDist( r, c, 1 - side, newdist );
ReSetQueue( r, c, 1 - side, newdist, apx_dist, row_target, col_target ); ReSetQueue( r,
c,
1 - side,
newdist,
apx_dist,
row_target,
col_target );
} }
} /* Fin de l'exploration de l'autre couche */ } /* Finished attempt to route on other layer. */
} }
end_of_route: end_of_route:
Place_1_Pad_Board( Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart,
pcbframe->GetBoard(), pt_cur_ch->m_PadStart, ~CURRENT_PAD, marge, WRITE_AND_CELL ); ~CURRENT_PAD, marge, WRITE_AND_CELL );
Place_1_Pad_Board( Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
pcbframe->GetBoard(), pt_cur_ch->m_PadEnd, ~CURRENT_PAD, marge, WRITE_AND_CELL ); ~CURRENT_PAD, marge, WRITE_AND_CELL );
AFFICHE_ACTIVITE_ROUTE; msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d"),
OpenNodes, ClosNodes, MoveNodes );
pcbframe->Affiche_Message( msg );
return result; return result;
} }
static long bit[8][9] = { /* OT=Otherside */ static long bit[8][9] =
{
/* OT=Otherside */
/* N, NE, E, SE, S, SW, W, NW, OT */ /* N, NE, E, SE, S, SW, W, NW, OT */
/* N */ /* N */
{ LINE_VERTICAL, BENT_StoNE, CORNER_SOUTHEAST, { LINE_VERTICAL,
BENT_StoNE,
CORNER_SOUTHEAST,
SHARP_StoSE, SHARP_StoSE,
0, 0,
SHARP_StoSW, CORNER_SOUTHWEST, BENT_StoNW, (HOLE | HOLE_SOUTH) },
/* NE */ { BENT_NtoSW, DIAG_NEtoSW, BENT_EtoSW, ANGLE_SEtoSW,
SHARP_StoSW, SHARP_StoSW,
0, SHARP_WtoSW, ANGLE_SWtoNW, (HOLE | HOLE_SOUTHWEST) }, CORNER_SOUTHWEST,
/* E */ { CORNER_NORTHWEST, BENT_WtoNE, LINE_HORIZONTAL, BENT_WtoSE, BENT_StoNW,
CORNER_SOUTHWEST, SHARP_WtoSW, 0, SHARP_WtoNW, (HOLE | HOLE_WEST) }, ( HOLE | HOLE_SOUTH )
/* SE */ { SHARP_NtoNW, ANGLE_NWtoNE, BENT_EtoNW, DIAG_SEtoNW, },
/* NE */
{
BENT_NtoSW,
DIAG_NEtoSW,
BENT_EtoSW,
ANGLE_SEtoSW,
SHARP_StoSW,
0,
SHARP_WtoSW,
ANGLE_SWtoNW,
( HOLE | HOLE_SOUTHWEST )
},
/* E */
{
CORNER_NORTHWEST,
BENT_WtoNE,
LINE_HORIZONTAL,
BENT_WtoSE,
CORNER_SOUTHWEST,
SHARP_WtoSW,
0,
SHARP_WtoNW,
( HOLE | HOLE_WEST )
},
/* SE */
{
SHARP_NtoNW,
ANGLE_NWtoNE,
BENT_EtoNW,
DIAG_SEtoNW,
BENT_StoNW, BENT_StoNW,
ANGLE_SWtoNW, SHARP_WtoNW, 0, (HOLE | HOLE_NORTHWEST) }, ANGLE_SWtoNW,
/* S */ { 0, SHARP_NtoNE, CORNER_NORTHEAST, BENT_NtoSE, SHARP_WtoNW,
0,
( HOLE | HOLE_NORTHWEST )
},
/* S */
{
0,
SHARP_NtoNE,
CORNER_NORTHEAST,
BENT_NtoSE,
LINE_VERTICAL, LINE_VERTICAL,
BENT_NtoSW, CORNER_NORTHWEST, SHARP_NtoNW, (HOLE | HOLE_NORTH) }, BENT_NtoSW,
/* SW */ { SHARP_NtoNE, 0, SHARP_EtoNE, ANGLE_NEtoSE, CORNER_NORTHWEST,
SHARP_NtoNW,
( HOLE | HOLE_NORTH )
},
/* SW */
{
SHARP_NtoNE,
0,
SHARP_EtoNE,
ANGLE_NEtoSE,
BENT_StoNE, BENT_StoNE,
DIAG_NEtoSW, DIAG_NEtoSW,
BENT_WtoNE, ANGLE_NWtoNE, (HOLE | HOLE_NORTHEAST) }, BENT_WtoNE,
/* W */ { CORNER_NORTHEAST, SHARP_EtoNE, 0, SHARP_EtoSE, ANGLE_NWtoNE,
( HOLE | HOLE_NORTHEAST )
},
/* W */
{
CORNER_NORTHEAST,
SHARP_EtoNE,
0,
SHARP_EtoSE,
CORNER_SOUTHEAST, CORNER_SOUTHEAST,
BENT_EtoSW, LINE_HORIZONTAL, BENT_EtoNW, (HOLE | HOLE_EAST) }, BENT_EtoSW,
/* NW */ { BENT_NtoSE, ANGLE_NEtoSE, SHARP_EtoSE, 0, LINE_HORIZONTAL,
BENT_EtoNW,
( HOLE | HOLE_EAST )
},
/* NW */
{
BENT_NtoSE,
ANGLE_NEtoSE,
SHARP_EtoSE,
0,
SHARP_StoSE, SHARP_StoSE,
ANGLE_SEtoSW, BENT_WtoSE, DIAG_SEtoNW, (HOLE | HOLE_SOUTHEAST) } ANGLE_SEtoSW,
BENT_WtoSE,
DIAG_SEtoNW,
( HOLE | HOLE_SOUTHEAST )
}
}; };
/*******************************************************************/
static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC,
int row_source, int col_source,
int row_target, int col_target, int target_side,
int current_net_code )
/*******************************************************************/
/* work from target back to source, actually laying the traces /* work from target back to source, actually laying the traces
* Parametres: * Parameters:
* start on side target_side, aux coordonnees row_target, col_target. * start on side target_side, of coordinates row_target, col_target.
* arrivee sur side masque_layer_start, coord row_source, col_source * arrive on side masque_layer_start, coordinate row_source, col_source
* La recherche se fait en sens inverse du routage, * The search is done in reverse routing, the point of arrival (target) to
* c.a.d du point d'arrivee (target) vers le point de depart (source) * the starting point (source)
* du routeur. * The router.
* *
* target_side = cote (TOP / BOTTOM) de depart * Target_side = symbol (TOP / BOTTOM) of departure
* mask_layer_source = masque des couches d'arrivee * = Mask_layer_source mask layers Arrival
* *
* Retourne: * Returns:
* 0 si erreur * 0 if error
* > 0 si Ok * > 0 if Ok
*/ */
static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC,
int row_source, int col_source,
int row_target, int col_target, int target_side,
int current_net_code )
{ {
int r0, c0, s0; int r0, c0, s0;
int r1, c1, s1; /* row, col, side d'ou on vient */ int r1, c1, s1; /* row, col, starting side. */
int r2, c2, s2; /* row, col, side ou on va */ int r2, c2, s2; /* row, col, ending side. */
int x, y = -1; int x, y = -1;
long b; long b;
...@@ -786,34 +916,48 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -786,34 +916,48 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC,
switch( x ) switch( x )
{ {
case FROM_NORTH: case FROM_NORTH:
r2++; break; r2++;
break;
case FROM_EAST: case FROM_EAST:
c2++; break; c2++;
break;
case FROM_SOUTH: case FROM_SOUTH:
r2--; break; r2--;
break;
case FROM_WEST: case FROM_WEST:
c2--; break; c2--;
break;
case FROM_NORTHEAST: case FROM_NORTHEAST:
r2++; c2++; break; r2++;
c2++;
break;
case FROM_SOUTHEAST: case FROM_SOUTHEAST:
r2--; c2++; break; r2--;
c2++;
break;
case FROM_SOUTHWEST: case FROM_SOUTHWEST:
r2--; c2--; break; r2--;
c2--;
break;
case FROM_NORTHWEST: case FROM_NORTHWEST:
r2++; c2--; break; r2++;
c2--;
break;
case FROM_OTHERSIDE: case FROM_OTHERSIDE:
s2 = 1 - s2; break; s2 = 1 - s2;
break;
default: default:
DisplayError( pcbframe, wxT( "Retrace: internal error: no way back" ) ); DisplayError( pcbframe,
wxT( "Retrace: internal error: no way back" ) );
return 0; return 0;
} }
...@@ -821,36 +965,44 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -821,36 +965,44 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC,
y = GetDir( r0, c0, s0 ); y = GetDir( r0, c0, s0 );
/* see if target or hole */ /* see if target or hole */
if( ( (r1 == row_target) && (c1 == col_target) ) if( ( ( r1 == row_target ) && ( c1 == col_target ) )
|| (s1 != s0) ) || ( s1 != s0 ) )
{ {
int p_dir; int p_dir;
switch( x ) switch( x )
{ {
case FROM_NORTH: case FROM_NORTH:
p_dir = HOLE_NORTH; break; p_dir = HOLE_NORTH;
break;
case FROM_EAST: case FROM_EAST:
p_dir = HOLE_EAST; break; p_dir = HOLE_EAST;
break;
case FROM_SOUTH: case FROM_SOUTH:
p_dir = HOLE_SOUTH; break; p_dir = HOLE_SOUTH;
break;
case FROM_WEST: case FROM_WEST:
p_dir = HOLE_WEST; break; p_dir = HOLE_WEST;
break;
case FROM_NORTHEAST: case FROM_NORTHEAST:
p_dir = HOLE_NORTHEAST; break; p_dir = HOLE_NORTHEAST;
break;
case FROM_SOUTHEAST: case FROM_SOUTHEAST:
p_dir = HOLE_SOUTHEAST; break; p_dir = HOLE_SOUTHEAST;
break;
case FROM_SOUTHWEST: case FROM_SOUTHWEST:
p_dir = HOLE_SOUTHWEST; break; p_dir = HOLE_SOUTHWEST;
break;
case FROM_NORTHWEST: case FROM_NORTHWEST:
p_dir = HOLE_NORTHWEST; break; p_dir = HOLE_NORTHWEST;
break;
case FROM_OTHERSIDE: case FROM_OTHERSIDE:
default: default:
...@@ -858,24 +1010,27 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -858,24 +1010,27 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC,
return 0; return 0;
} }
OrCell_Trace( pcbframe->GetBoard(), r1, c1, s1, p_dir, current_net_code ); OrCell_Trace(
pcbframe->GetBoard(), r1, c1, s1, p_dir, current_net_code );
} }
else else
{ {
if( (y == FROM_NORTH || y == FROM_NORTHEAST if( ( y == FROM_NORTH || y == FROM_NORTHEAST
|| y == FROM_EAST || y == FROM_SOUTHEAST || y == FROM_EAST || y == FROM_SOUTHEAST
|| y == FROM_SOUTH || y == FROM_SOUTHWEST || y == FROM_SOUTH || y == FROM_SOUTHWEST
|| y == FROM_WEST || y == FROM_NORTHWEST) || y == FROM_WEST || y == FROM_NORTHWEST )
&& (x == FROM_NORTH || x == FROM_NORTHEAST && ( x == FROM_NORTH || x == FROM_NORTHEAST
|| x == FROM_EAST || x == FROM_SOUTHEAST || x == FROM_EAST || x == FROM_SOUTHEAST
|| x == FROM_SOUTH || x == FROM_SOUTHWEST || x == FROM_SOUTH || x == FROM_SOUTHWEST
|| x == FROM_WEST || x == FROM_NORTHWEST || x == FROM_WEST || x == FROM_NORTHWEST
|| x == FROM_OTHERSIDE) || x == FROM_OTHERSIDE )
&& ( (b = bit[y - 1][x - 1]) != 0 ) ) && ( ( b = bit[y - 1][x - 1] ) != 0 ) )
{ {
OrCell_Trace( pcbframe->GetBoard(), r1, c1, s1, b, current_net_code ); OrCell_Trace( pcbframe->GetBoard(), r1, c1, s1, b,
current_net_code );
if( b & HOLE ) if( b & HOLE )
OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, HOLE, current_net_code ); OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, HOLE,
current_net_code );
} }
else else
{ {
...@@ -884,35 +1039,43 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -884,35 +1039,43 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC,
} }
} }
if( (r2 == row_source) && (c2 == col_source) ) if( ( r2 == row_source ) && ( c2 == col_source ) ) /* see if source */
{ /* see if source */ {
int p_dir; int p_dir;
switch( x ) switch( x )
{ {
case FROM_NORTH: case FROM_NORTH:
p_dir = HOLE_SOUTH; break; p_dir = HOLE_SOUTH;
break;
case FROM_EAST: case FROM_EAST:
p_dir = HOLE_WEST; break; p_dir = HOLE_WEST;
break;
case FROM_SOUTH: case FROM_SOUTH:
p_dir = HOLE_NORTH; break; p_dir = HOLE_NORTH;
break;
case FROM_WEST: case FROM_WEST:
p_dir = HOLE_EAST; break; p_dir = HOLE_EAST;
break;
case FROM_NORTHEAST: case FROM_NORTHEAST:
p_dir = HOLE_SOUTHWEST; break; p_dir = HOLE_SOUTHWEST;
break;
case FROM_SOUTHEAST: case FROM_SOUTHEAST:
p_dir = HOLE_NORTHWEST; break; p_dir = HOLE_NORTHWEST;
break;
case FROM_SOUTHWEST: case FROM_SOUTHWEST:
p_dir = HOLE_NORTHEAST; break; p_dir = HOLE_NORTHEAST;
break;
case FROM_NORTHWEST: case FROM_NORTHWEST:
p_dir = HOLE_SOUTHEAST; break; p_dir = HOLE_SOUTHEAST;
break;
case FROM_OTHERSIDE: case FROM_OTHERSIDE:
default: default:
...@@ -920,23 +1083,26 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, ...@@ -920,23 +1083,26 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC,
return 0; return 0;
} }
OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, p_dir, current_net_code ); OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, p_dir,
current_net_code );
} }
/* move to next cell */ /* move to next cell */
r0 = r1; c0 = c1; s0 = s1; r0 = r1;
r1 = r2; c1 = c2; s1 = s2; c0 = c1;
} while( !( (r2 == row_source) && (c2 == col_source) ) ); s0 = s1;
r1 = r2;
c1 = c2;
s1 = s2;
} while( !( ( r2 == row_source ) && ( c2 == col_source ) ) );
Place_Piste_en_Buffer( pcbframe, DC ); Place_Piste_en_Buffer( pcbframe, DC );
return 1; return 1;
} }
/*****************************************************************************/ /* ??? appelle la routine OrCell et place la piste reelle sur le pcb */
static void OrCell_Trace( BOARD* pcb, int col, int row, static void OrCell_Trace( BOARD* pcb, int col, int row,
int side, int orient, int current_net_code ) int side, int orient, int current_net_code )
/*****************************************************************************/
/* appelle la routine OrCell et place la piste reelle sur le pcb */
{ {
int dx0, dy0, dx1, dy1; int dx0, dy0, dx1, dy1;
TRACK* newTrack; TRACK* newTrack;
...@@ -951,10 +1117,12 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, ...@@ -951,10 +1117,12 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->SetLayer( 0x0F ); g_CurrentTrackSegment->SetLayer( 0x0F );
g_CurrentTrackSegment->m_Start.x = g_CurrentTrackSegment->m_Start.x =
g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x +
( g_GridRoutingSize * row );
g_CurrentTrackSegment->m_Start.y = g_CurrentTrackSegment->m_Start.y =
g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y +
( g_GridRoutingSize * col );
g_CurrentTrackSegment->m_Width = pcb->GetCurrentViaSize(); g_CurrentTrackSegment->m_Width = pcb->GetCurrentViaSize();
g_CurrentTrackSegment->m_Shape = g_DesignSettings.m_CurrentViaType; g_CurrentTrackSegment->m_Shape = g_DesignSettings.m_CurrentViaType;
...@@ -972,30 +1140,38 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, ...@@ -972,30 +1140,38 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->SetLayer( Route_Layer_TOP ); g_CurrentTrackSegment->SetLayer( Route_Layer_TOP );
g_CurrentTrackSegment->SetState( SEGM_AR, ON ); g_CurrentTrackSegment->SetState( SEGM_AR, ON );
g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x +
g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); ( g_GridRoutingSize * row );
g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y +
( g_GridRoutingSize * col );
g_CurrentTrackSegment->SetNet( current_net_code ); g_CurrentTrackSegment->SetNet( current_net_code );
if( g_CurrentTrackSegment->Back() == NULL ) /* Start Piste */ if( g_CurrentTrackSegment->Back() == NULL ) /* Start trace. */
{ {
g_CurrentTrackSegment->m_Start.x = segm_fX; g_CurrentTrackSegment->m_Start.x = segm_fX;
g_CurrentTrackSegment->m_Start.y = segm_fY; g_CurrentTrackSegment->m_Start.y = segm_fY;
/* Replacement sur le centre du pad si hors grille */ /* Placement on the center of the pad if outside grid. */
dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; dx1 = g_CurrentTrackSegment->m_End.x -
dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; g_CurrentTrackSegment->m_Start.x;
dy1 = g_CurrentTrackSegment->m_End.y -
g_CurrentTrackSegment->m_Start.y;
dx0 = pt_cur_ch->m_PadEnd->GetPosition().x - g_CurrentTrackSegment->m_Start.x; dx0 = pt_cur_ch->m_PadEnd->GetPosition().x -
dy0 = pt_cur_ch->m_PadEnd->GetPosition().y - g_CurrentTrackSegment->m_Start.y; g_CurrentTrackSegment->m_Start.x;
dy0 = pt_cur_ch->m_PadEnd->GetPosition().y -
g_CurrentTrackSegment->m_Start.y;
/* si aligne: modif du point origine */ /* If aligned, change the origin point. */
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) /* Alignes ! */ if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
{ {
g_CurrentTrackSegment->m_Start = pt_cur_ch->m_PadEnd->GetPosition(); g_CurrentTrackSegment->m_Start =
pt_cur_ch->m_PadEnd->GetPosition();
} }
else // Creation of a supplemental segment else // Creation of a supplemental segment
{ {
g_CurrentTrackSegment->m_Start = pt_cur_ch->m_PadEnd->GetPosition(); g_CurrentTrackSegment->m_Start =
pt_cur_ch->m_PadEnd->GetPosition();
newTrack = g_CurrentTrackSegment->Copy(); newTrack = g_CurrentTrackSegment->Copy();
newTrack->m_Start = g_CurrentTrackSegment->m_End; newTrack->m_Start = g_CurrentTrackSegment->m_End;
...@@ -1007,24 +1183,27 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, ...@@ -1007,24 +1183,27 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
{ {
if( g_CurrentTrackSegment->Back() ) if( g_CurrentTrackSegment->Back() )
{ {
g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->Back()->m_End; g_CurrentTrackSegment->m_Start =
g_CurrentTrackSegment->Back()->m_End;
} }
} }
g_CurrentTrackSegment->m_Width = pcb->GetCurrentTrackWidth(); g_CurrentTrackSegment->m_Width = pcb->GetCurrentTrackWidth();
if( g_CurrentTrackSegment->m_Start != g_CurrentTrackSegment->m_End ) if( g_CurrentTrackSegment->m_Start != g_CurrentTrackSegment->m_End )
{ {
/* Reduction des segments alignes a 1 seul */ /* Reduce aligned segments by one. */
TRACK* oldTrack = g_CurrentTrackSegment->Back(); TRACK* oldTrack = g_CurrentTrackSegment->Back();
if( oldTrack && oldTrack->Type() != TYPE_VIA ) if( oldTrack && oldTrack->Type() != TYPE_VIA )
{ {
dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; dx1 = g_CurrentTrackSegment->m_End.x -
dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; g_CurrentTrackSegment->m_Start.x;
dy1 = g_CurrentTrackSegment->m_End.y -
g_CurrentTrackSegment->m_Start.y;
dx0 = oldTrack->m_End.x - oldTrack->m_Start.x; dx0 = oldTrack->m_End.x - oldTrack->m_Start.x;
dy0 = oldTrack->m_End.y - oldTrack->m_Start.y; dy0 = oldTrack->m_End.y - oldTrack->m_Start.y;
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) /* le dernier segment est en ligne*/ if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
{ {
oldTrack->m_End = g_CurrentTrackSegment->m_End; oldTrack->m_End = g_CurrentTrackSegment->m_End;
...@@ -1036,14 +1215,12 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, ...@@ -1036,14 +1215,12 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
} }
/***********************************************************************/ /* Insert the new track created in the list of tracks.
static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) * amend the points of beginning and end of the track so that they are
/***********************************************************************/ * connected
* Center on pads even if they are off grid.
/* Insere la nouvelle piste creee dans la liste standard des pistes.
* Modifie les points de debut et fin de piste pour qu'ils soient relies
* au centre des pads corresponadants, meme hors grille
*/ */
static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
{ {
if( g_FirstTrackSegment == NULL ) if( g_FirstTrackSegment == NULL )
return; return;
...@@ -1052,24 +1229,25 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1052,24 +1229,25 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
int marge, via_marge; int marge, via_marge;
WinEDA_DrawPanel* panel = pcbframe->DrawPanel; WinEDA_DrawPanel* panel = pcbframe->DrawPanel;
marge = s_Clearance + (pcbframe->GetBoard()->GetCurrentTrackWidth() / 2); marge = s_Clearance +
via_marge = s_Clearance + (pcbframe->GetBoard()->GetCurrentViaSize() / 2); ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
via_marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentViaSize() / 2 );
/* tst point d'arrivee : doit etre sur pad start */
dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x;
dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y;
/* Replacement sur le centre du pad si hors grille */
dx0 = pt_cur_ch->m_PadStart->GetPosition().x - g_CurrentTrackSegment->m_Start.x; /* Place on center of pad if off grid. */
dy0 = pt_cur_ch->m_PadStart->GetPosition().y - g_CurrentTrackSegment->m_Start.y; dx0 = pt_cur_ch->m_PadStart->GetPosition().x -
g_CurrentTrackSegment->m_Start.x;
dy0 = pt_cur_ch->m_PadStart->GetPosition().y -
g_CurrentTrackSegment->m_Start.y;
/* si aligne: modif du point origine */ /* If aligned, change the origin point. */
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) /* Alignes ! */ if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
{ {
g_CurrentTrackSegment->m_End = pt_cur_ch->m_PadStart->GetPosition(); g_CurrentTrackSegment->m_End = pt_cur_ch->m_PadStart->GetPosition();
} }
else /* Creation d'un segment suppl raccord */ else
{ {
TRACK* newTrack = g_CurrentTrackSegment->Copy(); TRACK* newTrack = g_CurrentTrackSegment->Copy();
...@@ -1093,7 +1271,8 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1093,7 +1271,8 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() ) for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
{ {
TraceSegmentPcb( pcbframe->GetBoard(), track, HOLE, marge, WRITE_CELL ); TraceSegmentPcb( pcbframe->GetBoard(), track, HOLE, marge, WRITE_CELL );
TraceSegmentPcb( pcbframe->GetBoard(), track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); TraceSegmentPcb( pcbframe->GetBoard(), track, VIA_IMPOSSIBLE,
via_marge, WRITE_OR_CELL );
} }
// Insert new segments in real board // Insert new segments in real board
...@@ -1103,7 +1282,9 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1103,7 +1282,9 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
// Put entire new current segment list in BOARD // Put entire new current segment list in BOARD
TRACK* track; TRACK* track;
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() ); TRACK* insertBeforeMe =
g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() );
while( ( track = g_CurrentTrackList.PopFront() ) != NULL ) while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
{ {
pcbframe->GetBoard()->m_Track.Insert( track, insertBeforeMe ); pcbframe->GetBoard()->m_Track.Insert( track, insertBeforeMe );
......
/****************************/ /*******************/
/* affichage des empreintes */ /* Highlight nets. */
/****************************/ /*******************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -16,22 +16,20 @@ ...@@ -16,22 +16,20 @@
#define Pad_fill (Pad_Fill_Item.State == RUN) #define Pad_fill (Pad_Fill_Item.State == RUN)
/*********************************************************/
void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
/*********************************************************/
/** Function ListNetsAndSelect /** Function ListNetsAndSelect
* called by a command event * called by a command event
* displays the sorted list of nets in a dialog frame * displays the sorted list of nets in a dialog frame
* If a net is selected, it is hightlighted * If a net is selected, it is highlighted
*/ */
void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
{ {
NETINFO_ITEM* net; NETINFO_ITEM* net;
wxString netFilter; wxString netFilter;
int selection; int selection;
netFilter = wxT( "*" ); netFilter = wxT( "*" );
Get_Message( _( "Filter for net names:" ), _( "Net Filter" ), netFilter, this ); Get_Message( _( "Filter for net names:" ), _( "Net Filter" ),
netFilter, this );
if( netFilter.IsEmpty() ) if( netFilter.IsEmpty() )
return; return;
...@@ -87,12 +85,10 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event ) ...@@ -87,12 +85,10 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
} }
/**************************************************/ /* Locate track or pad and highlight the corresponding net
* Returns the Netcode, or -1 if no net located.
*/
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
* Retourne le netcode, ou -1 si pas de net localis�*/
{ {
if( g_HightLigt_Status ) if( g_HightLigt_Status )
Hight_Light( DC ); Hight_Light( DC );
...@@ -145,14 +141,12 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC ) ...@@ -145,14 +141,12 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
} }
/*******************************************/
void WinEDA_PcbFrame::Hight_Light( wxDC* DC )
/*******************************************/
/* /*
* fonction d'appel de Surbrillance a partir du menu * Highlight command.
* Met ou supprime la surbrillance d'un net pointe par la souris *
* Show or removes the net at the current cursor position.
*/ */
void WinEDA_PcbFrame::Hight_Light( wxDC* DC )
{ {
g_HightLigt_Status = !g_HightLigt_Status; g_HightLigt_Status = !g_HightLigt_Status;
......
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
#include "wx/statline.h" #include "wx/statline.h"
/* Variables locales */
#define LAYER_NO_CHANGE NB_LAYERS #define LAYER_NO_CHANGE NB_LAYERS
static int New_Layer[NB_LAYERS]; static int New_Layer[NB_LAYERS];
wxStaticText* layer_list[NB_LAYERS]; wxStaticText* layer_list[NB_LAYERS];
enum swap_layer_id { enum swap_layer_id {
ID_WINEDA_SWAPLAYERFRAME = 1800, ID_WINEDA_SWAPLAYERFRAME = 1800,
ID_BUTTON_0, ID_BUTTON_0,
...@@ -27,10 +28,6 @@ enum swap_layer_id { ...@@ -27,10 +28,6 @@ enum swap_layer_id {
}; };
/***********************************************/
/* classe pour la frame de selection de layers */
/***********************************************/
class WinEDA_SwapLayerFrame : public wxDialog class WinEDA_SwapLayerFrame : public wxDialog
{ {
private: private:
...@@ -46,7 +43,6 @@ private: ...@@ -46,7 +43,6 @@ private:
public: public:
// Constructor and destructor
WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ); WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent );
~WinEDA_SwapLayerFrame() { }; ~WinEDA_SwapLayerFrame() { };
...@@ -58,7 +54,7 @@ private: ...@@ -58,7 +54,7 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/* Table des evenements pour WinEDA_SwapLayerFrame */
BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_LAYERS - 1, EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_LAYERS - 1,
wxEVT_COMMAND_BUTTON_CLICKED, wxEVT_COMMAND_BUTTON_CLICKED,
...@@ -72,7 +68,6 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) : ...@@ -72,7 +68,6 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) :
wxDialog( parent, -1, _( "Swap Layers:" ), wxPoint( -1, -1 ), wxDialog( parent, -1, _( "Swap Layers:" ), wxPoint( -1, -1 ),
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER ) wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
{ {
/*************************************************************************/
BOARD* board = parent->GetBoard(); BOARD* board = parent->GetBoard();
OuterBoxSizer = NULL; OuterBoxSizer = NULL;
...@@ -357,7 +352,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) ...@@ -357,7 +352,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event )
if( ii != 1 ) if( ii != 1 )
return; // (Canceled dialog box returns -1 instead) return; // (Canceled dialog box returns -1 instead)
/* Modifications des pistes */ /* Change traces. */
pt_segm = GetBoard()->m_Track; pt_segm = GetBoard()->m_Track;
for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) for( ; pt_segm != NULL; pt_segm = pt_segm->Next() )
{ {
...@@ -385,7 +380,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) ...@@ -385,7 +380,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event )
} }
} }
/* Modifications des zones */ /* Change zones. */
for( pt_segm = GetBoard()->m_Zone; pt_segm; pt_segm = pt_segm->Next() ) for( pt_segm = GetBoard()->m_Zone; pt_segm; pt_segm = pt_segm->Next() )
{ {
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -394,7 +389,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) ...@@ -394,7 +389,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event )
pt_segm->SetLayer( New_Layer[jj] ); pt_segm->SetLayer( New_Layer[jj] );
} }
/* Modifications des autres segments */ /* Change other segments. */
PtStruct = GetBoard()->m_Drawings; PtStruct = GetBoard()->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
......
/*****************************************************************/ /***********************************************/
/* tool_modeit.cpp: construction du menu de l'editeur de modules */ /* tool_modeit.cpp: footprint editor toolbars. */
/*****************************************************************/ /***********************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -22,10 +22,9 @@ ...@@ -22,10 +22,9 @@
#define LISTBOX_WIDTH 120 #define LISTBOX_WIDTH 120
#endif #endif
/***************************************************/
void WinEDA_ModuleEditFrame::ReCreateHToolbar()
/***************************************************/
/* Create the main horizontal toolbar for the footprint editor */ /* Create the main horizontal toolbar for the footprint editor */
void WinEDA_ModuleEditFrame::ReCreateHToolbar()
{ {
if( m_HToolBar != NULL ) if( m_HToolBar != NULL )
return; return;
...@@ -140,9 +139,7 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar() ...@@ -140,9 +139,7 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar()
} }
/********************************************************/
void WinEDA_ModuleEditFrame::ReCreateVToolbar() void WinEDA_ModuleEditFrame::ReCreateVToolbar()
/********************************************************/
{ {
if( m_VToolBar ) if( m_VToolBar )
return; return;
...@@ -192,14 +189,12 @@ void WinEDA_ModuleEditFrame::ReCreateVToolbar() ...@@ -192,14 +189,12 @@ void WinEDA_ModuleEditFrame::ReCreateVToolbar()
} }
/*********************************************************/
void WinEDA_ModuleEditFrame::ReCreateOptToolbar() void WinEDA_ModuleEditFrame::ReCreateOptToolbar()
/*********************************************************/
{ {
if( m_OptionsToolBar ) if( m_OptionsToolBar )
return; return;
// creation du tool bar options // Create options tool bar.
m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this,
ID_OPT_TOOLBAR, FALSE ); ID_OPT_TOOLBAR, FALSE );
...@@ -245,9 +240,7 @@ void WinEDA_ModuleEditFrame::ReCreateOptToolbar() ...@@ -245,9 +240,7 @@ void WinEDA_ModuleEditFrame::ReCreateOptToolbar()
} }
/*********************************************************/
void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar() void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
/*********************************************************/
{ {
size_t i; size_t i;
wxString msg; wxString msg;
...@@ -260,14 +253,14 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar() ...@@ -260,14 +253,14 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
// Set up toolbar // Set up toolbar
m_AuxiliaryToolBar->AddSeparator(); m_AuxiliaryToolBar->AddSeparator();
// Boite de selection du pas de grille // Grid selection choice box.
m_SelGridBox = new WinEDAChoiceBox( m_AuxiliaryToolBar, m_SelGridBox = new WinEDAChoiceBox( m_AuxiliaryToolBar,
ID_ON_GRID_SELECT, ID_ON_GRID_SELECT,
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( LISTBOX_WIDTH, -1 ) ); wxSize( LISTBOX_WIDTH, -1 ) );
m_AuxiliaryToolBar->AddControl( m_SelGridBox ); m_AuxiliaryToolBar->AddControl( m_SelGridBox );
// Boite de selection du Zoom // Zoom selection choice box.
m_AuxiliaryToolBar->AddSeparator(); m_AuxiliaryToolBar->AddSeparator();
m_SelZoomBox = new WinEDAChoiceBox( m_AuxiliaryToolBar, m_SelZoomBox = new WinEDAChoiceBox( m_AuxiliaryToolBar,
ID_ON_ZOOM_SELECT, ID_ON_ZOOM_SELECT,
...@@ -298,7 +291,7 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar() ...@@ -298,7 +291,7 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
m_AuxiliaryToolBar->Realize(); m_AuxiliaryToolBar->Realize();
} }
// mise a jour des affichages // Update tool bar to reflect setting.
m_SelGridBox->Clear(); m_SelGridBox->Clear();
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ ) for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{ {
......
/********************************************************************************/ /*************************/
/* tool_onrightclick.cpp: fonctions appel�s par le bouton droit sur un TOOL */ /* tool_onrightclick.cpp */
/********************************************************************************/ /*************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
/*****************************************************************/
void WinEDA_PcbFrame::ToolOnRightClick( wxCommandEvent& event ) void WinEDA_PcbFrame::ToolOnRightClick( wxCommandEvent& event )
/*****************************************************************/
{ {
wxPoint pos; wxPoint pos;
int id = event.GetSelection(); int id = event.GetSelection();
...@@ -49,9 +47,7 @@ void WinEDA_PcbFrame::ToolOnRightClick( wxCommandEvent& event ) ...@@ -49,9 +47,7 @@ void WinEDA_PcbFrame::ToolOnRightClick( wxCommandEvent& event )
} }
/************************************************************************/
void WinEDA_ModuleEditFrame::ToolOnRightClick( wxCommandEvent& event ) void WinEDA_ModuleEditFrame::ToolOnRightClick( wxCommandEvent& event )
/************************************************************************/
{ {
wxPoint pos; wxPoint pos;
int id = event.GetSelection(); int id = event.GetSelection();
......
/*********************************************/ /***************************************/
/* tool_pcb.cpp: construction des tool bars */ /* tool_pcb.cpp: PCB editor tool bars */
/*********************************************/ /***************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -34,7 +34,8 @@ static wxBitmap* LayerPairBitmap = NULL; ...@@ -34,7 +34,8 @@ static wxBitmap* LayerPairBitmap = NULL;
static const 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
// 3 = draw pixel with via color // 3 = draw pixel with via color
{ 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 0, 0 },
...@@ -56,12 +57,9 @@ static const char s_BitmapLayerIcon[16][16] = { ...@@ -56,12 +57,9 @@ static const char s_BitmapLayerIcon[16][16] = {
}; };
/************************************************************/
void WinEDA_PcbFrame::PrepareLayerIndicator()
/************************************************************/
/* Draw the icon for the "Select layer pair" bitmap tool /* Draw the icon for the "Select layer pair" bitmap tool
*/ */
void WinEDA_PcbFrame::PrepareLayerIndicator()
{ {
int ii, jj; int ii, jj;
int active_layer_color, Route_Layer_TOP_color, int active_layer_color, Route_Layer_TOP_color,
...@@ -106,8 +104,8 @@ void WinEDA_PcbFrame::PrepareLayerIndicator() ...@@ -106,8 +104,8 @@ void WinEDA_PcbFrame::PrepareLayerIndicator()
LayerPairBitmap = new wxBitmap( 16, 16 ); LayerPairBitmap = new wxBitmap( 16, 16 );
} }
/* Draw the icon, with colors according to the active layer and layer pairs for /* Draw the icon, with colors according to the active layer and layer
* via command (change layer) * pairs for via command (change layer)
*/ */
wxMemoryDC iconDC; wxMemoryDC iconDC;
iconDC.SelectObject( *LayerPairBitmap ); iconDC.SelectObject( *LayerPairBitmap );
...@@ -178,12 +176,9 @@ void WinEDA_PcbFrame::PrepareLayerIndicator() ...@@ -178,12 +176,9 @@ void WinEDA_PcbFrame::PrepareLayerIndicator()
} }
/******************************************/
void WinEDA_PcbFrame::ReCreateHToolbar()
/******************************************/
/* Creates or updates the main horizontal toolbar for the board editor /* Creates or updates the main horizontal toolbar for the board editor
*/ */
void WinEDA_PcbFrame::ReCreateHToolbar()
{ {
wxString msg; wxString msg;
...@@ -272,19 +267,20 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -272,19 +267,20 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
m_HToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, wxBitmap( netlist_xpm ), m_HToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, wxBitmap( netlist_xpm ),
_( "Read netlist" ) ); _( "Read netlist" ) );
m_HToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, wxBitmap( erc_xpm ), m_HToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, wxBitmap( erc_xpm ),
_( "Pcb Design Rules Check" ) ); _( "Perform design rules check" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
ReCreateLayerBox( m_HToolBar ); ReCreateLayerBox( m_HToolBar );
PrepareLayerIndicator(); // Initialize the bitmap with current active layer colors for the next tool PrepareLayerIndicator(); // Initialize the bitmap with current
// active layer colors for the next tool
m_HToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString, m_HToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
*LayerPairBitmap, SEL_LAYER_HELP ); *LayerPairBitmap, SEL_LAYER_HELP );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_TOOLBARH_PCB_AUTOPLACE, wxEmptyString, m_HToolBar->AddTool( ID_TOOLBARH_PCB_AUTOPLACE, wxEmptyString,
wxBitmap( mode_module_xpm ), wxBitmap( mode_module_xpm ),
_( "Mode Module: Manual and Automatic Move or Place for modules" ), _( "Manual and automatic move or place of modules" ),
wxITEM_CHECK ); wxITEM_CHECK );
m_HToolBar->AddTool( ID_TOOLBARH_PCB_AUTOROUTE, wxEmptyString, m_HToolBar->AddTool( ID_TOOLBARH_PCB_AUTOROUTE, wxEmptyString,
wxBitmap( mode_track_xpm ), wxBitmap( mode_track_xpm ),
...@@ -306,28 +302,24 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -306,28 +302,24 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
} }
/*********************************************/
void WinEDA_PcbFrame::ReCreateOptToolbar() void WinEDA_PcbFrame::ReCreateOptToolbar()
/*********************************************/
// Create the left vertical toolbar (option selections)
{ {
if( m_OptionsToolBar ) if( m_OptionsToolBar )
return; return;
// creation du tool bar options
m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this,
ID_OPT_TOOLBAR, FALSE ); ID_OPT_TOOLBAR, FALSE );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString,
wxBitmap( drc_off_xpm ), wxBitmap( drc_off_xpm ),
_( "Drc OFF" ), wxITEM_CHECK ); _( "Enable design rule checking" ),
wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
wxBitmap( grid_xpm ), wxBitmap( grid_xpm ),
_( "Display Grid OFF" ), wxITEM_CHECK ); _( "Hide grid" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
wxBitmap( polar_coord_xpm ), wxBitmap( polar_coord_xpm ),
_( "Display Polar Coord ON" ), wxITEM_CHECK ); _( "Display polar coordinates" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
wxBitmap( unit_inch_xpm ), wxBitmap( unit_inch_xpm ),
_( "Units in inches" ), wxITEM_CHECK ); _( "Units in inches" ), wxITEM_CHECK );
...@@ -336,57 +328,63 @@ void WinEDA_PcbFrame::ReCreateOptToolbar() ...@@ -336,57 +328,63 @@ void WinEDA_PcbFrame::ReCreateOptToolbar()
_( "Units in millimeters" ), wxITEM_CHECK ); _( "Units in millimeters" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
wxBitmap( cursor_shape_xpm ), wxBitmap( cursor_shape_xpm ),
_( "Change Cursor Shape" ), wxITEM_CHECK ); _( "Change cursor shape" ), wxITEM_CHECK );
m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString,
wxBitmap( general_ratsnet_xpm ), wxBitmap( general_ratsnet_xpm ),
_( "Show General Ratsnest" ), wxITEM_CHECK ); _( "Show board ratsnest" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, wxEmptyString,
wxBitmap( local_ratsnet_xpm ), wxBitmap( local_ratsnet_xpm ),
_( "Show Module Ratsnest when moving" ), _( "Show module ratsnest when moving" ),
wxITEM_CHECK ); wxITEM_CHECK );
m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString,
wxBitmap( auto_delete_track_xpm ), wxBitmap( auto_delete_track_xpm ),
_( "Enable Auto Del Track" ), wxITEM_CHECK ); _( "Enable automatic track deletion" ),
wxITEM_CHECK );
m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddRadioTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString, m_OptionsToolBar->AddRadioTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString,
wxBitmap( show_zone_xpm ), wxNullBitmap, wxBitmap( show_zone_xpm ), wxNullBitmap,
_( "Show filled areas in zones" ) ); _( "Show filled areas in zones" ) );
m_OptionsToolBar->AddRadioTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, wxEmptyString, m_OptionsToolBar->AddRadioTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE,
wxBitmap( show_zone_disable_xpm ), wxNullBitmap, wxEmptyString,
wxBitmap( show_zone_disable_xpm ),
wxNullBitmap,
_( "Do not show filled areas in zones" )); _( "Do not show filled areas in zones" ));
m_OptionsToolBar->AddRadioTool( ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY, wxEmptyString, m_OptionsToolBar->AddRadioTool( ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY,
wxBitmap( show_zone_outline_only_xpm ), wxNullBitmap, wxEmptyString,
wxBitmap( show_zone_outline_only_xpm ),
wxNullBitmap,
_( "Show outlines of filled areas only in zones" ) ); _( "Show outlines of filled areas only in zones" ) );
m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
wxBitmap( pad_sketch_xpm ), wxBitmap( pad_sketch_xpm ),
_( "Show Pads Sketch" ), wxITEM_CHECK ); _( "Show pads in outline mode" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
wxBitmap( via_sketch_xpm ), wxBitmap( via_sketch_xpm ),
_( "Show Vias Sketch" ), wxITEM_CHECK ); _( "Show vias in outline mode" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
wxBitmap( showtrack_xpm ), wxBitmap( showtrack_xpm ),
_( "Show Tracks Sketch" ), wxITEM_CHECK ); _( "Show tracks in outline mode" ),
wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
wxEmptyString, wxEmptyString,
wxBitmap( palette_xpm ), wxBitmap( palette_xpm ),
_( "High Contrast Mode Display" ), _( "Enable high contrast display mode" ),
wxITEM_CHECK ); wxITEM_CHECK );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
DisplayOpt.ContrastModeDisplay ); DisplayOpt.ContrastModeDisplay );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE,
wxEmptyString, wxEmptyString,
wxBitmap( invisible_text_xpm ), wxBitmap( invisible_text_xpm ),
_( "Show Invisible Text" ), _( "Show invisible text" ),
wxITEM_CHECK ); wxITEM_CHECK );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE,
g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE )); g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE ));
...@@ -408,12 +406,9 @@ void WinEDA_PcbFrame::ReCreateOptToolbar() ...@@ -408,12 +406,9 @@ void WinEDA_PcbFrame::ReCreateOptToolbar()
} }
/********************************************/
void WinEDA_PcbFrame::ReCreateVToolbar()
/********************************************/
/* Create the main vertical right toolbar, showing usual tools /* Create the main vertical right toolbar, showing usual tools
*/ */
void WinEDA_PcbFrame::ReCreateVToolbar()
{ {
if( m_VToolBar ) if( m_VToolBar )
return; return;
...@@ -490,12 +485,10 @@ void WinEDA_PcbFrame::ReCreateVToolbar() ...@@ -490,12 +485,10 @@ void WinEDA_PcbFrame::ReCreateVToolbar()
} }
/*********************************************/ /* Create the auxiliary vertical right toolbar, showing tools for
void WinEDA_PcbFrame::ReCreateAuxVToolbar() * microwave applications
/*********************************************/
/* Create the auxiliary vertical right toolbar, showing tools for microwave applications
*/ */
void WinEDA_PcbFrame::ReCreateAuxVToolbar()
{ {
if( m_AuxVToolBar ) if( m_AuxVToolBar )
return; return;
...@@ -533,10 +526,6 @@ void WinEDA_PcbFrame::ReCreateAuxVToolbar() ...@@ -533,10 +526,6 @@ void WinEDA_PcbFrame::ReCreateAuxVToolbar()
} }
/****************************************************/
void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
/****************************************************/
/* Creates auxiliary horizontal toolbar /* Creates auxiliary horizontal toolbar
* displays: * displays:
* existing track width choice * existing track width choice
...@@ -546,6 +535,7 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -546,6 +535,7 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
* grid size choice * grid size choice
* zoom level choice * zoom level choice
*/ */
void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
{ {
size_t i; size_t i;
wxString msg; wxString msg;
...@@ -676,16 +666,13 @@ an existing track use its width\notherwise, use current width setting" ), ...@@ -676,16 +666,13 @@ an existing track use its width\notherwise, use current width setting" ),
} }
/**************************************************************************/
void WinEDA_PcbFrame::UpdateToolbarLayerInfo() void WinEDA_PcbFrame::UpdateToolbarLayerInfo()
/**************************************************************************/
{ {
wxASSERT( m_SelLayerBox ); wxASSERT( m_SelLayerBox );
// Activation de l'affichage sur la bonne couche // Enable the display on the correct layer
// Pour eviter la reentrance (Bug wxGTK version Linux?), la selection n'est faite que si // To avoid reentrancy ( Bug wxGTK Linux version? ), the selection is
// elle est mauvaise (Pb corrige sur wxGTK 2.6.0) // made where it is bad ( corrected on wxGTK 2.6.0 )
int count = m_SelLayerBox->GetCount(); int count = m_SelLayerBox->GetCount();
int choice = m_SelLayerBox->GetChoice(); int choice = m_SelLayerBox->GetChoice();
int layer = GetScreen()->m_Active_Layer; int layer = GetScreen()->m_Active_Layer;
...@@ -702,9 +689,7 @@ void WinEDA_PcbFrame::UpdateToolbarLayerInfo() ...@@ -702,9 +689,7 @@ void WinEDA_PcbFrame::UpdateToolbarLayerInfo()
} }
/**************************************************************************/
WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
/**************************************************************************/
{ {
if( m_SelLayerBox == NULL ) if( m_SelLayerBox == NULL )
{ {
...@@ -716,7 +701,8 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) ...@@ -716,7 +701,8 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
#if defined (__UNIX__) #if defined (__UNIX__)
// Width enough for the longest string: "Component (Page Down)" // Width enough for the longest
// string: "Component (Page Down)"
// Maybe that string is too long? // Maybe that string is too long?
wxSize( 230, -1 ) wxSize( 230, -1 )
#else #else
......
/**************************************************************** /****************************************************************
* toolbars_update_user_interface.cpp * toolbars_update_user_interface.cpp
****************************************************************/ ****************************************************************/
/* /*
* function to update toolbars UI after changing parameters * function to update toolbars UI after changing parameters
...@@ -144,14 +144,15 @@ void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI() ...@@ -144,14 +144,15 @@ void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI()
} }
/***************************************/
void WinEDA_PcbFrame::SetToolbars()
/***************************************/
/* /*
* Active ou desactive les tools des toolbars, en fonction des commandes * Enable or disable the toolbar's controls, depending on the current
* en cours * state.
*
* @todo: All of this should be perform in appropriate wxUpdateUIEvent
* handles. This is not how it how updating user interface controls
* is handle in wxWidgets.
*/ */
void WinEDA_PcbFrame::SetToolbars()
{ {
bool state; bool state;
...@@ -187,10 +188,8 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -187,10 +188,8 @@ void WinEDA_PcbFrame::SetToolbars()
!Drc_On ); !Drc_On );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF,
Drc_On ? Drc_On ?
_( _( "Disable design rule checking" ) :
"DRC Off (Disable !!!), Currently: DRC is active" ) _( "Enable design rule checking" ) );
:
_( "DRC On (Currently: DRC is inactive !!!)" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric == MILLIMETRE ? TRUE : false ); g_UnitMetric == MILLIMETRE ? TRUE : false );
...@@ -201,13 +200,15 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -201,13 +200,15 @@ void WinEDA_PcbFrame::SetToolbars()
DisplayOpt.DisplayPolarCood ); DisplayOpt.DisplayPolarCood );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood ? DisplayOpt.DisplayPolarCood ?
_( "Polar coords not show" ) : _( "Display rectangular coordinates" ) :
_( "Display polar coords" ) ); _( "Display polar coordinates" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid ); m_Draw_Grid );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid ? _( "Grid not show" ) : _( "Show grid" ) ); m_Draw_Grid ?
_( "Hide grid" ) :
_( "Show grid" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
m_CursorShape ); m_CursorShape );
...@@ -216,8 +217,8 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -216,8 +217,8 @@ void WinEDA_PcbFrame::SetToolbars()
g_Show_Ratsnest ); g_Show_Ratsnest );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_RATSNEST, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_RATSNEST,
g_Show_Ratsnest ? g_Show_Ratsnest ?
_( "Hide general ratsnest" ) : _( "Hide board ratsnest" ) :
_( "Show general ratsnest" ) ); _( "Show board ratsnest" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,
g_Show_Module_Ratsnest ); g_Show_Module_Ratsnest );
...@@ -239,31 +240,31 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -239,31 +240,31 @@ void WinEDA_PcbFrame::SetToolbars()
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
m_DisplayPadFill ? m_DisplayPadFill ?
_( "Show pads sketch mode" ) : _( "Show pads in outline mode" ) :
_( "Show pads filled mode" ) ); _( "Show pads in fill mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
!m_DisplayViaFill ); !m_DisplayViaFill );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
m_DisplayViaFill ? m_DisplayViaFill ?
_( "Show vias sketch mode" ) : _( "Show vias in outline mode" ) :
_( "Show vias filled mode" ) ); _( "Show vias in fill mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
!m_DisplayPcbTrackFill ); !m_DisplayPcbTrackFill );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
m_DisplayPcbTrackFill ? m_DisplayPcbTrackFill ?
_( "Show tracks sketch mode" ) : _( "Show tracks in outline mode" ) :
_( "Show tracks filled mode" ) ); _( "Show tracks in fill mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
DisplayOpt.ContrastModeDisplay ); DisplayOpt.ContrastModeDisplay );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
DisplayOpt.ContrastModeDisplay ? DisplayOpt.ContrastModeDisplay ?
_( "Normal contrast mode display" ) : _( "Normal contrast display mode" ) :
_( "High contrast mode display" ) ); _( "High contrast display mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_INVISIBLE_TEXT_MODE,
g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE ) ); g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE ) );
......
/**************************************************/ /******************/
/* Edition des pistes */ /* Trace editing. */
/* Routines de modification automatique de pistes */ /******************/
/**************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -13,109 +12,113 @@ ...@@ -13,109 +12,113 @@
/** function EraseRedundantTrack /** function EraseRedundantTrack
* Called after creating a track * Called after creating a track
* Remove (if exists) the old track that have the same starting and the same ending point as the new created track * Remove (if exists) the old track that have the same starting and the same
* (this is the redunding track) * ending point as the new created track (this is the redunding track)
* @param aDC = the current device context (can be NULL) * @param aDC = the current device context (can be NULL)
* @param aNewTrack = the new created track (a pointer to a segment of the track list) * @param aNewTrack = the new created track (a pointer to a segment of the
* track list)
* @param aNewTrackSegmentsCount = number of segments in this new track * @param aNewTrackSegmentsCount = number of segments in this new track
* @param aItemsListPicker = the list picker to use for an undo command (can be NULL) * @param aItemsListPicker = the list picker to use for an undo command (can
* be NULL)
*/ */
int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewTrackSegmentsCount, PICKED_ITEMS_LIST* aItemsListPicker ) int WinEDA_PcbFrame::EraseRedundantTrack(
wxDC* aDC,
TRACK* aNewTrack,
int aNewTrackSegmentsCount,
PICKED_ITEMS_LIST* aItemsListPicker )
{ {
TRACK* StartTrack, * EndTrack;/* Pointeurs des segments de debut et fin TRACK* StartTrack, * EndTrack;
* (extremites) de la nouvelle piste */
TRACK* pt_segm; TRACK* pt_segm;
TRACK* pt_del; TRACK* pt_del;
int ii, jj, nb_segm, nbconnect; int ii, jj, nb_segm, nbconnect;
wxPoint start; /* coord du point de depart de la piste */ wxPoint start;
wxPoint end; /* coord du point de fin de la piste */ wxPoint end;
int startmasklayer, endmasklayer; /* masque couche de depart et de fin */ int startmasklayer, endmasklayer;
TRACK* BufDeb, * BufEnd; /* Pointeurs de debut et de fin de la zone TRACK* BufDeb, * BufEnd;
* des pistes equipotentielles */
int netcode = aNewTrack->GetNet(); int netcode = aNewTrack->GetNet();
/* Reconstitution de la piste complete ( la nouvelle piste /* Reconstruct the complete track (the new track has to start on a
* a pu demarrer sur un segment de piste en l'air * segment of track).
*/ */
ListSetState( aNewTrack, aNewTrackSegmentsCount, BUSY, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, BUSY, OFF );
/* si la nouvelle piste commence par une via, il est plus sur de rechercher /* If the new track begins with a via, complete the track segment using
* la piste complete en utilisant le segment suivant comme reference, car * the following segment as a reference because a via is often a hub of
* une via est souvent sur un carrefour de segments, et ne caracterise pas * segments, and does not characterize track.
* une piste */ */
if( aNewTrack->Type() == TYPE_VIA && (aNewTrackSegmentsCount > 1 ) ) if( aNewTrack->Type() == TYPE_VIA && ( aNewTrackSegmentsCount > 1 ) )
aNewTrack = aNewTrack->Next(); aNewTrack = aNewTrack->Next();
aNewTrack = Marque_Une_Piste( GetBoard(), aNewTrack, &aNewTrackSegmentsCount, NULL, true ); aNewTrack = Marque_Une_Piste( GetBoard(), aNewTrack,
&aNewTrackSegmentsCount, NULL, true );
wxASSERT( aNewTrack ); wxASSERT( aNewTrack );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
TRACK* EndNewTrack; /* Pointeur sur le dernier segment de la liste TRACK* EndNewTrack; /* The last segment of the list chained to
* chainee de la mouvelle piste */ * the track */
EndNewTrack = aNewTrack; EndNewTrack = aNewTrack;
for( ii = 1; ii < aNewTrackSegmentsCount; ii++ ) for( ii = 1; ii < aNewTrackSegmentsCount; ii++ )
{ {
wxASSERT( EndNewTrack->GetState(-1) != 0 ); wxASSERT( EndNewTrack->GetState( -1 ) != 0 );
D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );) D( printf( "track %p is newly part of net %d\n", EndNewTrack,
netcode ); )
EndNewTrack = EndNewTrack->Next(); EndNewTrack = EndNewTrack->Next();
} }
wxASSERT( EndNewTrack->GetState(-1) != 0 ); wxASSERT( EndNewTrack->GetState( -1 ) != 0 );
D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );) D( printf( "track %p is newly part of net %d\n", EndNewTrack, netcode ); )
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
track->Show( 0, std::cout ); track->Show( 0, std::cout );
#endif #endif
/* Calcul des limites de recherche des segments de piste */ /* Calculate search in terms of segments of track, 1st edge BufDeb useful
/* BufDeb pointe le 1er segment utile */ * segment. */
BufDeb = m_Pcb->m_Track->GetStartNetCode( netcode ); BufDeb = m_Pcb->m_Track->GetStartNetCode( netcode );
/* BufEnd Pointe le dernier segment */ /* Point BufEnd the last segment. */
BufEnd = BufDeb->GetEndNetCode( netcode ); BufEnd = BufDeb->GetEndNetCode( netcode );
/* nettoyage des flags pour tout le net */ /* Flags for cleaning the net. */
for( pt_del = BufDeb; pt_del; pt_del = pt_del->Next() ) for( pt_del = BufDeb; pt_del; pt_del = pt_del->Next() )
{ {
D(printf("track %p turning off BUSY | EDIT | CHAIN\n", pt_del );) D( printf( "track %p turning off BUSY | EDIT | CHAIN\n", pt_del ); )
pt_del->SetState( BUSY | EDIT | CHAIN, OFF ); pt_del->SetState( BUSY | EDIT | CHAIN, OFF );
if( pt_del == BufEnd ) // Last segment reached if( pt_del == BufEnd ) // Last segment reached
break; break;
} }
/* Calcul des points limites de la nouvelle piste */
if( ReturnEndsTrack( aNewTrack, aNewTrackSegmentsCount, if( ReturnEndsTrack( aNewTrack, aNewTrackSegmentsCount,
&StartTrack, &EndTrack ) == 0 ) &StartTrack, &EndTrack ) == 0 )
return 0; return 0;
if( (StartTrack == NULL) || (EndTrack == NULL) ) if( ( StartTrack == NULL ) || ( EndTrack == NULL ) )
return 0; return 0;
/* Calcul des caracteristiques des points de debut et de fin */
start = StartTrack->m_Start; start = StartTrack->m_Start;
end = EndTrack->m_End; end = EndTrack->m_End;
/* Les points de depart et de fin doivent etre distincts */ /* The start and end points cannot be the same. */
if( start == end ) if( start == end )
return 0; return 0;
/* Determinations des couches interconnectees a ces points */ /* Determine layers interconnected these points. */
startmasklayer = StartTrack->ReturnMaskLayer(); startmasklayer = StartTrack->ReturnMaskLayer();
endmasklayer = EndTrack->ReturnMaskLayer(); endmasklayer = EndTrack->ReturnMaskLayer();
/* Il peut y avoir une via ou un pad sur les extremites: */ /* There may be a via or a pad on the end points. */
pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, start, startmasklayer ); pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, start, startmasklayer );
if( pt_segm ) if( pt_segm )
startmasklayer |= pt_segm->ReturnMaskLayer(); startmasklayer |= pt_segm->ReturnMaskLayer();
if( StartTrack->start && (StartTrack->start->Type() == TYPE_PAD) ) if( StartTrack->start && ( StartTrack->start->Type() == TYPE_PAD ) )
{ {
/* start sur pad */ /* Start on pad. */
D_PAD* pt_pad = (D_PAD*) (StartTrack->start); D_PAD* pt_pad = (D_PAD*)(StartTrack->start);
startmasklayer |= pt_pad->m_Masque_Layer; startmasklayer |= pt_pad->m_Masque_Layer;
} }
...@@ -123,33 +126,33 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -123,33 +126,33 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
if( pt_segm ) if( pt_segm )
endmasklayer |= pt_segm->ReturnMaskLayer(); endmasklayer |= pt_segm->ReturnMaskLayer();
if( EndTrack->end && ( EndTrack->end->Type() == TYPE_PAD) ) if( EndTrack->end && ( EndTrack->end->Type() == TYPE_PAD ) )
{ {
D_PAD* pt_pad = (D_PAD*) (EndTrack->end); D_PAD* pt_pad = (D_PAD*)(EndTrack->end);
endmasklayer |= pt_pad->m_Masque_Layer; endmasklayer |= pt_pad->m_Masque_Layer;
} }
/* Marquage a DELETED de la piste nouvelle (qui ne doit pas intervenir /* Mark as deleted a new track (which is not involved in the search for
* dans la recherche d'autres connexions) * other connections)
*/ */
ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, ON ); ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, ON );
/* test : un segment doit etre connecte au point de depart car sinon /* A segment must be connected to the starting point, otherwise
* il est inutile d'analyser l'autre point * it is unnecessary to analyze the other point
*/ */
pt_segm = Fast_Locate_Piste( BufDeb, BufEnd, start, startmasklayer ); pt_segm = Fast_Locate_Piste( BufDeb, BufEnd, start, startmasklayer );
if( pt_segm == NULL ) /* Pas de piste reliee au point de depart */ if( pt_segm == NULL ) /* Not connected to the track starting point. */
{ {
/* Suppression du flag DELETED */ /* Clear the delete flag. */
ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, OFF );
return 0; return 0;
} }
/* Marquage a CHAIN des segments candidats connectes au point de fin /* Marking a list of candidate segmented connect to endpoint
* Remarque: les vias ne sont pas prises en compte car elles ne permettent * Note: the vias are not taken into account because they do
* pas de definir une piste, puisque elles sont sur un carrefour */ * not define a track, since they are on an intersection.
*/
for( pt_del = BufDeb, nbconnect = 0; ; ) for( pt_del = BufDeb, nbconnect = 0; ; )
{ {
pt_segm = Fast_Locate_Piste( pt_del, BufEnd, end, endmasklayer ); pt_segm = Fast_Locate_Piste( pt_del, BufEnd, end, endmasklayer );
...@@ -158,7 +161,6 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -158,7 +161,6 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
if( pt_segm->Type() != TYPE_VIA ) if( pt_segm->Type() != TYPE_VIA )
{ {
/* Segment trouve */
if( pt_segm->GetState( CHAIN ) == 0 ) if( pt_segm->GetState( CHAIN ) == 0 )
{ {
pt_segm->SetState( CHAIN, ON ); pt_segm->SetState( CHAIN, ON );
...@@ -173,7 +175,7 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -173,7 +175,7 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
if( nbconnect == 0 ) if( nbconnect == 0 )
{ {
/* Clear used flagss */ /* Clear used flags */
for( pt_del = BufDeb; pt_del; pt_del = pt_del->Next() ) for( pt_del = BufDeb; pt_del; pt_del = pt_del->Next() )
{ {
pt_del->SetState( BUSY | DELETED | EDIT | CHAIN, OFF ); pt_del->SetState( BUSY | DELETED | EDIT | CHAIN, OFF );
...@@ -184,13 +186,13 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -184,13 +186,13 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
return 0; return 0;
} }
/* Marquage a EDIT de la piste nouvelle (qui ne doit pas intervenir /* Mark trace as edited (which does not involve searching for other
* dans la recherche d'autres pistes) */ * tracks)
*/
ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, DELETED, OFF );
ListSetState( aNewTrack, aNewTrackSegmentsCount, EDIT, ON ); ListSetState( aNewTrack, aNewTrackSegmentsCount, EDIT, ON );
/* Examen de tous les segments marques */ /* Test all marked segments. */
while( nbconnect ) while( nbconnect )
{ {
for( pt_del = BufDeb; pt_del; pt_del = pt_del->Next() ) for( pt_del = BufDeb; pt_del; pt_del = pt_del->Next() )
...@@ -206,8 +208,8 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -206,8 +208,8 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
pt_del = Marque_Une_Piste( GetBoard(), pt_del, &nb_segm, NULL, true ); pt_del = Marque_Une_Piste( GetBoard(), pt_del, &nb_segm, NULL, true );
/* Test si La piste marquee est redondante, c'est a dire si l'un des /* Test if the marked track is redundant, ie if one of marked segments
* segments marques est connecte au point de depart de la piste nouvelle * is connected to the starting point of the new track.
*/ */
ii = 0; ii = 0;
pt_segm = pt_del; pt_segm = pt_del;
...@@ -218,9 +220,10 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -218,9 +220,10 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
if( pt_segm->m_Start == start || pt_segm->m_End == start ) if( pt_segm->m_Start == start || pt_segm->m_End == start )
{ {
/* la piste marquee peut etre effacee */ /* Marked track can be erased. */
TRACK* NextS; TRACK* NextS;
Trace_Une_Piste( DrawPanel, aDC, pt_del, nb_segm, GR_XOR | GR_SURBRILL ); Trace_Une_Piste( DrawPanel, aDC, pt_del, nb_segm,
GR_XOR | GR_SURBRILL );
for( jj = 0; jj < nb_segm; jj++, pt_del = NextS ) for( jj = 0; jj < nb_segm; jj++, pt_del = NextS )
{ {
...@@ -237,8 +240,9 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -237,8 +240,9 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
pt_del->DeleteStructure(); pt_del->DeleteStructure();
} }
/* nettoyage des flags */ /* Clean up flags. */
for( pt_del = m_Pcb->m_Track; pt_del != NULL; pt_del = pt_del->Next() ) for( pt_del = m_Pcb->m_Track; pt_del != NULL;
pt_del = pt_del->Next() )
{ {
if( pt_del->GetState( EDIT ) ) if( pt_del->GetState( EDIT ) )
{ {
...@@ -253,8 +257,8 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT ...@@ -253,8 +257,8 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
} }
} }
/* nettoyage du flag BUSY puisque ici la piste marquee n'a pas /* Clear BUSY flag here because the track did not get marked.
* ete retenuee */ */
ListSetState( pt_del, nb_segm, BUSY, OFF ); ListSetState( pt_del, nb_segm, BUSY, OFF );
} }
......
/*************************/ /*******************/
/* affichage des modules */ /* Display modules */
/*************************/ /*******************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -11,29 +11,22 @@ ...@@ -11,29 +11,22 @@
#include "pcbnew.h" #include "pcbnew.h"
#include "drag.h" #include "drag.h"
/* Police des caracteres de la routine de trace des textes */ /* Font of characters for the trace text routine. */
extern char* graphic_fonte_shape[]; extern char* graphic_fonte_shape[];
#include "protos.h" #include "protos.h"
#define L_MIN_DESSIN 1 /* seuil de largeur des segments pour trace autre que filaire */ #define L_MIN_DESSIN 1 /* line width for segments other than traces. */
/* fonctions locales : */
/* Trace the pads of a module in sketch mode.
/******************************************************************/ * Used to display a module pads when it is not displayed by the display
void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, * options Module setting.
int ox, int oy,
int MasqueLayer, int draw_mode )
/******************************************************************/
/* Trace les pads d'un module en mode SKETCH.
* Utilisee pour afficher les pastilles d'un module lorsque celui ci n'est
* pas affiche par les options d'affichage des Modules
* *
* Les pads affiches doivent apparaitre sur les couches donnees par * The pads posters must appear on the data layers by MasqueLayer
* MasqueLayer
*/ */
void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module,
int ox, int oy, int MasqueLayer, int draw_mode )
{ {
int tmp; int tmp;
PCB_SCREEN* screen; PCB_SCREEN* screen;
...@@ -45,7 +38,7 @@ void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, ...@@ -45,7 +38,7 @@ void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module,
tmp = frame->m_DisplayPadFill; tmp = frame->m_DisplayPadFill;
frame->m_DisplayPadFill = FALSE; frame->m_DisplayPadFill = FALSE;
/* trace des pastilles */ /* Draw pads. */
for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() )
{ {
if( (pad->m_Masque_Layer & MasqueLayer) == 0 ) if( (pad->m_Masque_Layer & MasqueLayer) == 0 )
......
/*****************************************/ /****************/
/* Routines generales d'affichage du PCB */ /* tracepcb.cpp */
/*****************************************/ /****************/
/* fichier tracepcb.cpp */
/* /*
* Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ... * Routines to display grid box coordinates, cursors, markers ...
*/ */
#include <vector> #include <vector>
...@@ -21,13 +19,9 @@ ...@@ -21,13 +19,9 @@
#include "protos.h" #include "protos.h"
/**********************************************************************/
void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/**********************************************************************/
/* Draw the footprint editor BOARD, and others elements : axis, grid .. /* Draw the footprint editor BOARD, and others elements : axis, grid ..
*/ */
void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
...@@ -59,12 +53,9 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -59,12 +53,9 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
} }
/****************************************************************/
void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/****************************************************************/
/* Draw the BOARD, and others elements : axis, grid .. /* Draw the BOARD, and others elements : axis, grid ..
*/ */
void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
PCB_SCREEN* screen = GetScreen(); PCB_SCREEN* screen = GetScreen();
...@@ -95,25 +86,24 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -95,25 +86,24 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
} }
/********************************************************************/ /* Redraw the BOARD items but not cursors, axis or grid */
void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
int aDrawMode, const wxPoint& offset ) int aDrawMode, const wxPoint& offset )
/********************************************************************/
/* Redraw the BOARD items but not cursors, axis or grid */
{ {
/* The order of drawing is flexible on some systems and not on others. For /* The order of drawing is flexible on some systems and not on others. For
* OSes which use OR to draw, the order is not important except for the * OSes which use OR to draw, the order is not important except for the
* effect of the highlight and its relationship to markers. See comment below. * effect of the highlight and its relationship to markers. See comment
* This order indepence comes from the fact that a binary OR operation is * below.
* This order independence comes from the fact that a binary OR operation is
* commutative in nature. * commutative in nature.
* However on the OSX, the OR operation is not used, and so this sequence * However on the OSX, the OR operation is not used, and so this sequence
* below is chosen to give MODULEs the highest visible priority. * below is chosen to give MODULEs the highest visible priority.
*/ */
/* Draw all tracks and zones. As long as dark colors are used for the
/* Draw all tracks and zones. As long as dark colors are used for the tracks, * tracks, Then the OR draw mode should show tracks underneath other
* Then the OR draw mode should show tracks underneath other tracks. But a white * tracks. But a white track will cover any other color since it has
* track will cover any other color since it has more bits to OR in. * more bits to OR in.
*/ */
for( TRACK* track = m_Track; track; track = track->Next() ) for( TRACK* track = m_Track; track; track = track->Next() )
{ {
...@@ -191,7 +181,8 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, ...@@ -191,7 +181,8 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
if( g_HightLigt_Status ) if( g_HightLigt_Status )
DrawHighLight( aPanel, DC, g_HightLigth_NetCode ); DrawHighLight( aPanel, DC, g_HightLigth_NetCode );
// draw the BOARD's markers last, otherwise the high light will erase any marker on a pad // draw the BOARD's markers last, otherwise the high light will erase
// any marker on a pad
for( unsigned i=0; i < m_markers.size(); ++i ) for( unsigned i=0; i < m_markers.size(); ++i )
{ {
m_markers[i]->Draw( aPanel, DC, aDrawMode ); m_markers[i]->Draw( aPanel, DC, aDrawMode );
...@@ -199,9 +190,7 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, ...@@ -199,9 +190,7 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
} }
/******************************************************************************/
void BOARD::DrawHighLight( WinEDA_DrawPanel* aDrawPanel, wxDC* DC, int aNetCode ) void BOARD::DrawHighLight( WinEDA_DrawPanel* aDrawPanel, wxDC* DC, int aNetCode )
/******************************************************************************/
{ {
int draw_mode; int draw_mode;
...@@ -252,4 +241,3 @@ void BOARD::DrawHighLight( WinEDA_DrawPanel* aDrawPanel, wxDC* DC, int aNetCode ...@@ -252,4 +241,3 @@ void BOARD::DrawHighLight( WinEDA_DrawPanel* aDrawPanel, wxDC* DC, int aNetCode
} }
} }
} }
/********************************************* /*****************
* track.cpp * track.cpp
*********************************************/ *****************/
#include "fctsys.h" #include "fctsys.h"
...@@ -9,34 +9,44 @@ ...@@ -9,34 +9,44 @@
#include "protos.h" #include "protos.h"
/* Functions to reconize a track. /* Functions to recognize a track.
* A track is a list of connected segments (or/and vias) * A track is a list of connected segments (or/and vias)
* from a starting to an ending point * from a starting to an ending point
* starting and ending points are a pad or a point with more than 2 segments connected * starting and ending points are a pad or a point with more than 2 segments
* (and obviouly a dangling segment end) *connected
* (and obviously a dangling segment end)
*/ */
typedef std::vector<TRACK*> TRACK_PTRS; // buffer of item candidates when search for items on the same track typedef std::vector<TRACK*> TRACK_PTRS; // buffer of item candidates when
// search for items on the same track
/* Local functions */ /* Local functions */
static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masklayer, TRACK_PTRS* aList ); static void Marque_Chaine_segments( BOARD* Pcb,
wxPoint ref_pos,
int masklayer,
TRACK_PTRS* aList );
/** /**
* Function Marque_Une_Piste * Function Marque_Une_Piste
* marks a chain of track segments, connected to aTrackList. * marks a chain of track segments, connected to aTrackList.
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical continuity * Each segment is marked by setting the BUSY bit into m_Flags. Electrical
* is detected by walking each segment, and finally the segments are rearranged * continuity is detected by walking each segment, and finally the segments
* into a contiguous chain within the given list. * are rearranged into a contiguous chain within the given list.
* @param aPcb = the board to analyse * @param aPcb = the board to analyze
* @param aStartSegm The first interesting segment within a list of track segment of aPcb * @param aStartSegm - The first interesting segment within a list of track
* @param aSegmCount = a pointer to an integer where to return the number of interesting segments * segment of aPcb
* @param aTrackLen = a pointer to an integer where to return the lenght of the track * @param aSegmCount = a pointer to an integer where to return the number of
* interesting segments
* @param aTrackLen = a pointer to an integer where to return the length of the
* track
* @param aReorder = bool: * @param aReorder = bool:
* true for reorder the interesting segments (useful for track edition/deletion) * true for reorder the interesting segments (useful for track
* in this case the flag BUSY is set (the user is responsible of flag clearing) *edition/deletion)
* false for no reorder : useful when we want just calculate the track lenght * in this case the flag BUSY is set (the user is responsible of flag
*clearing)
* false for no reorder : useful when we want just calculate the track length
* in this case, flags are reset * in this case, flags are reset
* @return TRACK* the first in the chain of interesting segments. * @return TRACK* the first in the chain of interesting segments.
*/ */
...@@ -70,10 +80,11 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, ...@@ -70,10 +80,11 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
trackList.push_back( aStartSegm ); trackList.push_back( aStartSegm );
/* Examine the initial track segment : if it is really a segment, this is easy. /* Examine the initial track segment : if it is really a segment, this is
* easy.
* If it is a via, one must search for connected segments. * If it is a via, one must search for connected segments.
* If <=2, this via connect 2 segments (or is connected to only one segment) * If <=2, this via connect 2 segments (or is connected to only one
* and this via and these 2 segments are a part of a track. * segment) and this via and these 2 segments are a part of a track.
* If > 2 only this via is flagged (the track has only this via) * If > 2 only this via is flagged (the track has only this via)
*/ */
if( aStartSegm->Type() == TYPE_VIA ) if( aStartSegm->Type() == TYPE_VIA )
...@@ -91,34 +102,45 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, ...@@ -91,34 +102,45 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
Segm3 = Fast_Locate_Piste( Segm2->Next(), NULL, Segm3 = Fast_Locate_Piste( Segm2->Next(), NULL,
aStartSegm->m_Start, masque_layer ); aStartSegm->m_Start, masque_layer );
} }
if( Segm3 ) // More than 2 segments are connected to this via. the "track" is only this via if( Segm3 ) // More than 2 segments are connected to this via. the
// "track" is only this via
{ {
if( aSegmCount ) if( aSegmCount )
*aSegmCount = 1; *aSegmCount = 1;
return aStartSegm; return aStartSegm;
} }
if( Segm1 ) // search for others segments connected to the initial segment start point if( Segm1 ) // search for others segments connected to the initial
// segment start point
{ {
masque_layer = Segm1->ReturnMaskLayer(); masque_layer = Segm1->ReturnMaskLayer();
Marque_Chaine_segments( Marque_Chaine_segments( aPcb, aStartSegm->m_Start, masque_layer,
aPcb, aStartSegm->m_Start, masque_layer, &trackList ); &trackList );
} }
if( Segm2 ) // search for others segments connected to the initial segment end point if( Segm2 ) // search for others segments connected to the initial
// segment end point
{ {
masque_layer = Segm2->ReturnMaskLayer(); masque_layer = Segm2->ReturnMaskLayer();
Marque_Chaine_segments( Marque_Chaine_segments( aPcb, aStartSegm->m_Start, masque_layer,
aPcb, aStartSegm->m_Start, masque_layer, &trackList ); &trackList );
} }
} }
else // mark the chain using both ends of the initial segment else // mark the chain using both ends of the initial segment
{ {
Marque_Chaine_segments( aPcb, aStartSegm->m_Start, masque_layer, &trackList ); Marque_Chaine_segments( aPcb,
Marque_Chaine_segments( aPcb, aStartSegm->m_End, masque_layer, &trackList ); aStartSegm->m_Start,
} masque_layer,
&trackList );
// Now we examine selected vias and flag them if they are on the track Marque_Chaine_segments( aPcb,
// If a via is connected to only one or 2 segments, it is flagged (is on the track) aStartSegm->m_End,
// If a via is connected to more than 2 segments, it is a track end, and it is removed from the list masque_layer,
&trackList );
}
// Now examine selected vias and flag them if they are on the track
// If a via is connected to only one or 2 segments, it is flagged (is on
// the track)
// If a via is connected to more than 2 segments, it is a track end, and it
// is removed from the list
// go through the list backwards. // go through the list backwards.
for( int i = trackList.size() - 1; i>=0; --i ) for( int i = trackList.size() - 1; i>=0; --i )
{ {
...@@ -130,23 +152,30 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, ...@@ -130,23 +152,30 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
if( via == aStartSegm ) if( via == aStartSegm )
continue; continue;
via->SetState( BUSY, ON ); // Try to flag it. the flag will be cleared later if needed via->SetState( BUSY, ON ); // Try to flag it. the flag will be cleared
// later if needed
masque_layer = via->ReturnMaskLayer(); masque_layer = via->ReturnMaskLayer();
TRACK* track = Fast_Locate_Piste( aPcb->m_Track, NULL, via->m_Start, masque_layer ); TRACK* track = Fast_Locate_Piste( aPcb->m_Track,
NULL,
via->m_Start,
masque_layer );
// Fast_Locate_Piste does not consider tracks flagged BUSY. // Fast_Locate_Piste does not consider tracks flagged BUSY.
// So if no connected track found, this via is on the current track only: keep it // So if no connected track found, this via is on the current track
// only: keep it
if( track == NULL ) if( track == NULL )
continue; continue;
/* if a track is found, this via connects also others segments of an other track /* If a track is found, this via connects also others segments of an
* This case happens when the vias ends the selected track. * other track. This case happens when the vias ends the selected
* But must we consider this via is on the selected track, or on an other track. * track but must we consider this via is on the selected track, or
* (this is important when selecting a track for deletion: must this via be deleted or not?) * on an other track.
* We consider here this via on the track if others segment connected to this via * (this is important when selecting a track for deletion: must this
* remain connected when removing this via. * via be deleted or not?)
* We consider here this via on the track if others segment connected
* to this via remain connected when removing this via.
* We search for all others segment connected together: * We search for all others segment connected together:
* if there are on the same layer, the via is on the selected track * if there are on the same layer, the via is on the selected track
* if there are on different layers, the via is on an other track * if there are on different layers, the via is on an other track
...@@ -154,26 +183,30 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, ...@@ -154,26 +183,30 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
int layer = track->GetLayer(); int layer = track->GetLayer();
while( ( track = Fast_Locate_Piste( track->Next(), NULL, while( ( track = Fast_Locate_Piste( track->Next(), NULL,
via->m_Start, masque_layer ) ) != NULL ) via->m_Start,
masque_layer ) ) != NULL )
{ {
if( layer != track->GetLayer() ) if( layer != track->GetLayer() )
{ {
// The via connects segments of an other track: it is removed from list // The via connects segments of an other track: it is removed
// because it is member of an other track // from list because it is member of an other track
via->SetState( BUSY, OFF ); via->SetState( BUSY, OFF );
break; break;
} }
} }
} }
/* Rearrange the track list in order to have flagged segments linked from firstTrack /* Rearrange the track list in order to have flagged segments linked
* So the NbSegmBusy segments are consecutive segments in list, the first item * from firstTrack so the NbSegmBusy segments are consecutive segments
* in the full track list is firstTrack, and the NbSegmBusy-1 next items * in list, the first item in the full track list is firstTrack, and
* (NbSegmBusy when including firstTrack) are the flagged segments * the NbSegmBusy-1 next items (NbSegmBusy when including firstTrack)
* are the flagged segments
*/ */
NbSegmBusy = 0; NbSegmBusy = 0;
TRACK* firstTrack; TRACK* firstTrack;
for( firstTrack = aPcb->m_Track; firstTrack; firstTrack = firstTrack->Next() ) for( firstTrack = aPcb->m_Track;
firstTrack;
firstTrack = firstTrack->Next() )
{ {
// Search for the first flagged BUSY segments // Search for the first flagged BUSY segments
if( firstTrack->GetState( BUSY ) ) if( firstTrack->GetState( BUSY ) )
...@@ -233,11 +266,6 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, ...@@ -233,11 +266,6 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
} }
/********************************************************************************/
static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMask,
TRACK_PTRS* aList )
/********************************************************************************/
/** /**
* Function used by Marque_Une_Piste() * Function used by Marque_Une_Piste()
* - Set the BUSY flag of connected segments, the first search point is * - Set the BUSY flag of connected segments, the first search point is
...@@ -247,40 +275,50 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas ...@@ -247,40 +275,50 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
* @param Pcb = the board * @param Pcb = the board
* @param aRef_pos = the reference coordinate of the starting search * @param aRef_pos = the reference coordinate of the starting search
* @param aLayerMask = the allowed layers for segments to search * @param aLayerMask = the allowed layers for segments to search
* (1 layer when starting point is on a segment, but more than one when starting point is on a via) * (1 layer when starting point is on a segment, but more than one when
* starting point is on a via)
* @param aList = the track list to fill with points of segments flagged * @param aList = the track list to fill with points of segments flagged
*/ */
static void Marque_Chaine_segments( BOARD* aPcb,
wxPoint aRef_pos,
int aLayerMask,
TRACK_PTRS* aList )
{ {
TRACK* pt_segm, // Pointe le segment courant analyse TRACK* pt_segm, // The current segment being analyzed.
* pt_via, // pointe la via reperee, eventuellement a detruire * pt_via, // The via identified, eventually destroy
* SegmentCandidate; // pointe le segment a detruire (= NULL ou pt_segm
* SegmentCandidate; // The end segment to destroy (or NULL =
// pt_segm
int NbSegm; int NbSegm;
if( aPcb->m_Track == NULL ) if( aPcb->m_Track == NULL )
return; return;
/* Set the BUSY flag of all connected segments, first search starting at aRef_pos /* Set the BUSY flag of all connected segments, first search starting at
* aRef_pos
* Search ends when: * Search ends when:
* - a pad is found (end of a track) * - a pad is found (end of a track)
* - a segment end has more than one other segment end connected * - a segment end has more than one other segment end connected
* - and obviously when no connected item found * - and obviously when no connected item found
* Vias are a special case, because we must see others segment connected on others layers * Vias are a special case, because we must see others segment connected
* and they change the layer mask. They can be a track end or not * on others layers and they change the layer mask. They can be a track
* They will be analyser later, and vias on terminal points of the track will be * end or not
* considered as part of this track if they do not connect segments of an other track together * They will be analyzer later, and vias on terminal points of the track
* and will be considered as part of an other track * will be considered as part of this track if they do not connect segments
* if when removing the via, the segments of taht other track are disconnected * of an other track together and will be considered as part of an other
* track if when removing the via, the segments of that other track are
* disconnected
*/ */
for( ; ; ) for( ; ; )
{ {
if( Fast_Locate_Pad_Connecte( aPcb, aRef_pos, aLayerMask ) != NULL ) if( Fast_Locate_Pad_Connecte( aPcb, aRef_pos, aLayerMask ) != NULL )
return; return;
/* Test for a via: a via changes the layer mask and can connect a lot of segments /* Test for a via: a via changes the layer mask and can connect a lot
* at location aRef_pos * of segments at location aRef_pos. When found, the via is just
* When found, the via is just pushed in list. * pushed in list. Vias will be examined later, when all connected
* Vias will be examined later, when all connected segment are found and push in list * segment are found and push in list. This is because when a via
* This is because whena via is found we do not know at this time the number of connected items * is found we do not know at this time the number of connected items
* and we do not know if this via is on the track or finish the track * and we do not know if this via is on the track or finish the track
*/ */
pt_via = Fast_Locate_Via( aPcb->m_Track, NULL, aRef_pos, aLayerMask ); pt_via = Fast_Locate_Via( aPcb->m_Track, NULL, aRef_pos, aLayerMask );
...@@ -301,7 +339,8 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas ...@@ -301,7 +339,8 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
while( ( pt_segm = Fast_Locate_Piste( pt_segm, NULL, while( ( pt_segm = Fast_Locate_Piste( pt_segm, NULL,
aRef_pos, aLayerMask ) ) != NULL ) aRef_pos, aLayerMask ) ) != NULL )
{ {
if( pt_segm->GetState( BUSY ) ) // already found and selected: skip it if( pt_segm->GetState( BUSY ) ) // already found and selected: skip
// it
{ {
pt_segm = pt_segm->Next(); pt_segm = pt_segm->Next();
continue; continue;
...@@ -314,21 +353,25 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas ...@@ -314,21 +353,25 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
} }
NbSegm++; NbSegm++;
if( NbSegm == 1 ) /* First time we found a connected item: pt_segm is candidate */ if( NbSegm == 1 ) /* First time we found a connected item: pt_segm
* is candidate */
{ {
SegmentCandidate = pt_segm; SegmentCandidate = pt_segm;
pt_segm = pt_segm->Next(); pt_segm = pt_segm->Next();
} }
else /* More than 1 segment connected -> this location is an end of the track */ else /* More than 1 segment connected -> this location is an end of
* the track */
{ {
return; return;
} }
} }
if( SegmentCandidate ) // A candidate is found: flag it an push it in list if( SegmentCandidate ) // A candidate is found: flag it an push it
// in list
{ {
/* Initialize parameters to search items connected to this candidate: /* Initialize parameters to search items connected to this
* we must analyse connections to its other end * candidate:
* we must analyze connections to its other end
*/ */
aLayerMask = SegmentCandidate->ReturnMaskLayer(); aLayerMask = SegmentCandidate->ReturnMaskLayer();
...@@ -341,7 +384,7 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas ...@@ -341,7 +384,7 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
aRef_pos = SegmentCandidate->m_Start; aRef_pos = SegmentCandidate->m_Start;
} }
pt_segm = aPcb->m_Track; /* restart list of tracks to analyse */ pt_segm = aPcb->m_Track; /* restart list of tracks to analyze */
/* flag this item an push it in list of selected items */ /* flag this item an push it in list of selected items */
aList->push_back( SegmentCandidate ); aList->push_back( SegmentCandidate );
...@@ -353,20 +396,18 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas ...@@ -353,20 +396,18 @@ static void Marque_Chaine_segments( BOARD* aPcb, wxPoint aRef_pos, int aLayerMas
} }
/********************************************************/ /* Calculate the end points coordinates of a track (a list of connected
int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, * segments)
TRACK** StartTrack, TRACK** EndTrack )
/**********************************************************/
/* Calculate the end points coordinates of a track (a list of connected segments)
* RefTrack is a segment of the track * RefTrack is a segment of the track
* return 1 if OK, 0 when a track is a closed loop * return 1 if OK, 0 when a track is a closed loop
* and the beginning and the end of the track in *StartTrack and *EndTrack * and the beginning and the end of the track in *StartTrack and *EndTrack
* Modify *StartTrack en *EndTrack : * Modify *StartTrack en *EndTrack :
* (*StartTrack)->m_Start coordinate is the beginning of the track * (*StartTrack)->m_Start coordinate is the beginning of the track
* (*EndTrack)->m_End coordinate is the end of the track * (*EndTrack)->m_End coordinate is the end of the track
* Segments connected must be consecutives in list * Segments connected must be consecutive in list
*/ */
int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
TRACK** StartTrack, TRACK** EndTrack )
{ {
TRACK* Track, * via, * segm, * TrackListEnd; TRACK* Track, * via, * segm, * TrackListEnd;
int NbEnds, masque_layer, ii, ok = 0; int NbEnds, masque_layer, ii, ok = 0;
...@@ -374,21 +415,21 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, ...@@ -374,21 +415,21 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
if( NbSegm <= 1 ) if( NbSegm <= 1 )
{ {
*StartTrack = *EndTrack = RefTrack; *StartTrack = *EndTrack = RefTrack;
return 1; /* cas trivial */ return 1;
} }
/* calcul de la limite d'analyse */ /* Calculation of the limit analysis. */
*StartTrack = *EndTrack = NULL; *StartTrack = *EndTrack = NULL;
TrackListEnd = Track = RefTrack; ii = 0; TrackListEnd = Track = RefTrack; ii = 0;
for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = Track->Next() ) for( ; ( Track != NULL ) && ( ii < NbSegm ); ii++, Track = Track->Next() )
{ {
TrackListEnd = Track; TrackListEnd = Track;
Track->m_Param = 0; Track->m_Param = 0;
} }
/* Calcul des extremites */ /* Calculate the extremes. */
NbEnds = 0; Track = RefTrack; ii = 0; NbEnds = 0; Track = RefTrack; ii = 0;
for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = Track->Next() ) for( ; ( Track != NULL ) && ( ii < NbSegm ); ii++, Track = Track->Next() )
{ {
if( Track->Type() == TYPE_VIA ) if( Track->Type() == TYPE_VIA )
continue; continue;
...@@ -421,7 +462,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, ...@@ -421,7 +462,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
int BeginPad, EndPad; int BeginPad, EndPad;
*EndTrack = Track; *EndTrack = Track;
/* permutation de ox,oy avec fx,fy */ /* Swap ox, oy with fx, fy */
BeginPad = Track->GetState( BEGIN_ONPAD ); BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD ); EndPad = Track->GetState( END_ONPAD );
...@@ -463,7 +504,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, ...@@ -463,7 +504,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
*StartTrack = Track; *StartTrack = Track;
NbEnds++; NbEnds++;
/* permutation de ox,oy avec fx,fy */ /* Swap ox, oy with fx, fy */
BeginPad = Track->GetState( BEGIN_ONPAD ); BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD ); EndPad = Track->GetState( END_ONPAD );
...@@ -490,17 +531,14 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, ...@@ -490,17 +531,14 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
} }
/***************************************************************************/
void ListSetState( EDA_BaseStruct* Start, int NbItem, int State, int onoff )
/***************************************************************************/
/* Set to onoff the .m_State member, bit mask State of a list of items /* Set to onoff the .m_State member, bit mask State of a list of items
*/ */
void ListSetState( EDA_BaseStruct* Start, int NbItem, int State, int onoff )
{ {
if( Start == NULL ) if( Start == NULL )
return; return;
for( ; (Start != NULL) && (NbItem > 0); NbItem--, Start = Start->Next() ) for( ; (Start != NULL ) && ( NbItem > 0 ); NbItem--, Start = Start->Next() )
{ {
Start->SetState( State, onoff ); Start->SetState( State, onoff );
} }
......
/*****************************************************************/ /********************************/
/* Routines de tracage des pistes ( Toutes, 1 piste, 1 segment ) */ /* Routines for plotting traces */
/*****************************************************************/ /********************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -11,30 +11,24 @@ ...@@ -11,30 +11,24 @@
#include "protos.h" #include "protos.h"
/* variables locales : */
/* Trace consecutive segments in memory.
/************************************************************************/ *
* Parameters:
* Pt_start_piste = first segment in the list
* Nbsegment = number of segments traced
* Draw_mode = mode (GR_XOR, GR_OR ..)
* CAUTION:
* The starting point of a track following MUST exist: may be
* then put a 0 before calling a routine if the track is the last drawn.
*/
void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* aTrackList, void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* aTrackList,
int nbsegment, int draw_mode ) int nbsegment, int draw_mode )
/************************************************************************/
/* routine de trace de n segments consecutifs en memoire.
* Utile pour monter une piste en cours de trace car les segments de cette
* piste sont alors contigus en memoire
* Parametres :
* pt_start_piste = adresse de depart de la liste des segments
* nbsegment = nombre de segments a tracer
* draw_mode = mode ( GR_XOR, GR_OR..)
* ATTENTION:
* le point de depart d'une piste suivante DOIT exister: peut etre
* donc mis a 0 avant appel a la routine si la piste a tracer est la derniere
*/
{ {
// preserve the start of the list for debugging. // preserve the start of the list for debugging.
for( TRACK* track = aTrackList; nbsegment > 0 && track; nbsegment--, track = track->Next() ) for( TRACK* track = aTrackList; nbsegment > 0 && track;
nbsegment--, track = track->Next() )
{ {
track->Draw( panel, DC, draw_mode ); track->Draw( panel, DC, draw_mode );
} }
} }
/********************************************/ /************************/
/* AUTOROUTAGE PCB : routines d'autoroutage */ /* Autorouting routines */
/********************************************/ /************************/
/* fichier WORK.CC */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -13,79 +11,76 @@ ...@@ -13,79 +11,76 @@
#include "cell.h" #include "cell.h"
#include "protos.h" #include "protos.h"
/**/
struct CWORK /* a unit of work is a hole-pair to connect */ struct CWORK /* a unit of work is a hole-pair to connect */
{ {
struct CWORK *Next; struct CWORK* Next;
int FromRow; /* source row */ int FromRow; /* source row */
int FromCol; /* source column */ int FromCol; /* source column */
int net_code; /* net_code */ int net_code; /* net_code */
int ToRow; /* target row */ int ToRow; /* target row */
int ToCol; /* target column */ int ToCol; /* target column */
RATSNEST_ITEM *pt_rats; /* chevelu correspondant*/ RATSNEST_ITEM* pt_rats; /* Corresponding ratsnest */
int ApxDist; /* approximate distance */ int ApxDist; /* approximate distance */
int Cost; /* cost for sort by length */ int Cost; /* cost for sort by length */
int Priority; /* routage priority */ int Priority; /* route priority */
}; };
/* pointers to the first and last item of work to do */ /* pointers to the first and last item of work to do */
static CWORK *Head = NULL; static CWORK* Head = NULL;
static CWORK *Tail = NULL; static CWORK* Tail = NULL;
static CWORK *Current = NULL; static CWORK* Current = NULL;
/* Routines definies ici : */
void InitWork(); void InitWork();
void ReInitWork(); void ReInitWork();
int SetWork( int, int, int, int, int, RATSNEST_ITEM *, int ); int SetWork( int, int, int, int, int, RATSNEST_ITEM*, int );
void GetWork( int *, int *, int *, int *, int *, RATSNEST_ITEM ** ); void GetWork( int*, int*, int*, int*, int*, RATSNEST_ITEM** );
void SortWork(); void SortWork();
/************************/ /* initialize the work list */
/* void InitWork () */
/************************/
/* initialize the work list */
void InitWork() void InitWork()
{ {
CWORK *ptr; CWORK* ptr;
while( (ptr = Head) != NULL ) while( ( ptr = Head ) != NULL )
{ {
Head = ptr->Next; MyFree( ptr ); Head = ptr->Next;
MyFree( ptr );
} }
Tail = Current = NULL; Tail = Current = NULL;
} }
/*************************/ /* initialize the work list */
/* void ReInitWork() */
/*************************/
/* initialize the work list */
void ReInitWork() void ReInitWork()
{ {
Current = Head; Current = Head;
} }
/*****************************************************************************/
/*int SetWork(int r1,int c1,int* n_c,int r2,int c2,RATSNEST_ITEM * pt_ch,int pri )*/
/*****************************************************************************/
/* add a unit of work to the work list /* add a unit of work to the work list
Return: * Return:
1 si OK * 1 if OK
0 si defaut d'allocation memoire * 0 if memory allocation failed
*/ */
static int GetCost(int r1,int c1,int r2,int c2); static int GetCost( int r1, int c1, int r2, int c2 );
int SetWork(int r1,int c1,int n_c,int r2,int c2,RATSNEST_ITEM * pt_ch,int pri ) int SetWork( int r1,
int c1,
int n_c,
int r2,
int c2,
RATSNEST_ITEM* pt_ch,
int pri )
{ {
CWORK *p; CWORK* p;
if( (p = (CWORK *)MyMalloc( sizeof(CWORK) )) != NULL ) if( ( p = (CWORK*) MyMalloc( sizeof(CWORK) ) ) != NULL )
{ {
p->FromRow = r1; p->FromRow = r1;
p->FromCol = c1; p->FromCol = c1;
...@@ -97,26 +92,27 @@ CWORK *p; ...@@ -97,26 +92,27 @@ CWORK *p;
p->Cost = GetCost( r1, c1, r2, c2 ); p->Cost = GetCost( r1, c1, r2, c2 );
p->Priority = pri; p->Priority = pri;
p->Next = NULL; p->Next = NULL;
if (Head) /* attach at end */ if( Head ) /* attach at end */
Tail->Next = p; Tail->Next = p;
else /* first in list */ else /* first in list */
Head = Current = p; Head = Current = p;
Tail = p; Tail = p;
return(1); return 1;
} }
else /* can't get any more memory */ else /* can't get any more memory */
return(0); return 0;
} }
/************************************************************************/ /* fetch a unit of work from the work list */
/* void GetWork (int *r1,int *c1,int *r2,int *c2, char **n1,char **n2 ) */ void GetWork( int* r1,
/************************************************************************/ int* c1,
int* n_c,
void GetWork (int *r1,int *c1,int *n_c,int *r2,int *c2,RATSNEST_ITEM** pt_ch ) int* r2,
/* fetch a unit of work from the work list */ int* c2,
RATSNEST_ITEM** pt_ch )
{ {
if (Current) if( Current )
{ {
*r1 = Current->FromRow; *r1 = Current->FromRow;
*c1 = Current->FromCol; *c1 = Current->FromCol;
...@@ -126,8 +122,8 @@ void GetWork (int *r1,int *c1,int *n_c,int *r2,int *c2,RATSNEST_ITEM** pt_ch ) ...@@ -126,8 +122,8 @@ void GetWork (int *r1,int *c1,int *n_c,int *r2,int *c2,RATSNEST_ITEM** pt_ch )
*pt_ch = Current->pt_rats; *pt_ch = Current->pt_rats;
Current = Current->Next; Current = Current->Next;
} }
else /* none left */
else { /* none left */ {
*r1 = *c1 = *r2 = *c2 = ILLEGAL; *r1 = *c1 = *r2 = *c2 = ILLEGAL;
*n_c = 0; *n_c = 0;
*pt_ch = NULL; *pt_ch = NULL;
...@@ -135,73 +131,83 @@ void GetWork (int *r1,int *c1,int *n_c,int *r2,int *c2,RATSNEST_ITEM** pt_ch ) ...@@ -135,73 +131,83 @@ void GetWork (int *r1,int *c1,int *n_c,int *r2,int *c2,RATSNEST_ITEM** pt_ch )
} }
/***********************/
/* void SortWork() */
/***********************/
/* order the work items; shortest (low cost) first */ /* order the work items; shortest (low cost) first */
void SortWork() void SortWork()
{ {
CWORK *p; CWORK* p;
CWORK *q0; /* put PRIORITY PAD_CONNECTs in q0 */ CWORK* q0; /* put PRIORITY PAD_CONNECTs in q0 */
CWORK *q1; /* sort other PAD_CONNECTs in q1 */ CWORK* q1; /* sort other PAD_CONNECTs in q1 */
CWORK *r; CWORK* r;
q0 = q1 = NULL; q0 = q1 = NULL;
while( (p = Head) != NULL ) while( (p = Head) != NULL ) /* prioritize each work item */
{ /* prioritize each work item */ {
Head = Head->Next; Head = Head->Next;
if (p->Priority) if( p->Priority ) /* put at end of priority list */
{ /* put at end of priority list */ {
p->Next = NULL; p->Next = NULL;
if ((r = q0) == NULL) /* empty list? */ if( (r = q0) == NULL ) /* empty list? */
q0 = p; q0 = p;
else else /* attach at end */
{ /* attach at end */ {
while (r->Next) /* search for end */ while( r->Next ) /* search for end */
r = r->Next; r = r->Next;
r->Next = p; /* attach */ r->Next = p; /* attach */
} }
} }
else if ( ((r = q1) == NULL) || (p->Cost < q1->Cost) ) else if( ( ( r = q1 ) == NULL ) || ( p->Cost < q1->Cost ) )
{ {
p->Next = q1; q1 = p; p->Next = q1;
q1 = p;
} }
else { /* find proper position in list */ else /* find proper position in list */
while (r->Next && p->Cost >= r->Next->Cost) r = r->Next; {
p->Next = r->Next; r->Next = p; while( r->Next && p->Cost >= r->Next->Cost )
r = r->Next;
p->Next = r->Next;
r->Next = p;
} }
} }
if( (p = q0) != NULL) if( (p = q0) != NULL ) /* any priority PAD_CONNECTs? */
{ /* any priority PAD_CONNECTs? */ {
while (q0->Next) q0 = q0->Next; while( q0->Next )
q0 = q0->Next;
q0->Next = q1; q0->Next = q1;
} }
else p = q1; else
p = q1;
/* reposition Head and Tail */ /* reposition Head and Tail */
for(Head = Current = Tail = p; Tail && Tail->Next; Tail = Tail->Next) ; for( Head = Current = Tail = p; Tail && Tail->Next; Tail = Tail->Next )
;
} }
/* routine de calcul du cout d'un chevelu: /* Calculate the cost of a net:
cout = (|dx| + |dy|) * handicap * cost = (| dx | + | dy |) * disability
handicap = 1 si dx ou dy = 0, max si |dx| # |dy| * disability = 1 if dx or dy = 0, max if | dx | # | dy |
*/ */
static int GetCost(int r1,int c1,int r2,int c2) static int GetCost( int r1, int c1, int r2, int c2 )
{ {
int dx, dy, mx, my; int dx, dy, mx, my;
float incl; float incl;
dx = abs(c2 - c1); dx = abs( c2 - c1 );
dy = abs(r2 - r1); dy = abs( r2 - r1 );
incl = 1.0; incl = 1.0;
mx = dx; my = dy; mx = dx;
if ( mx < my ) { mx = dy; my = dx;} my = dy;
if ( mx ) incl += (2*(float)my/mx);
return (int)((dx+dy) * incl) ;
}
if( mx < my )
{
mx = dy; my = dx;
}
if( mx )
incl += (2 * (float) my / mx);
return (int) ( ( dx + dy ) * incl );
}
/******************************/ /*******************************/
/* PCBNEW: echange de modules */ /* Pcbnew: exchange of modules */
/******************************/ /*******************************/
/* Fichier xchmod.cpp */
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -14,12 +12,10 @@ ...@@ -14,12 +12,10 @@
#include "dialog_exchange_modules_base.h" #include "dialog_exchange_modules_base.h"
// Local variables:
int s_SelectionMode = 0; // Remember the last exchange option, when exit dialog.
/************************************/ int s_SelectionMode = 0; // Remember the last exchange option, when exit
/* class DIALOG_EXCHANGE_MODULE */ // dialog.
/************************************/
class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE
{ {
...@@ -28,10 +24,7 @@ private: ...@@ -28,10 +24,7 @@ private:
WinEDA_PcbFrame* m_Parent; WinEDA_PcbFrame* m_Parent;
MODULE* m_CurrentModule; MODULE* m_CurrentModule;
public: public: DIALOG_EXCHANGE_MODULE( WinEDA_PcbFrame* aParent, MODULE* aModule );
// Constructor and destructor
DIALOG_EXCHANGE_MODULE( WinEDA_PcbFrame* aParent, MODULE* aModule );
~DIALOG_EXCHANGE_MODULE() { }; ~DIALOG_EXCHANGE_MODULE() { };
private: private:
...@@ -53,7 +46,8 @@ private: ...@@ -53,7 +46,8 @@ private:
}; };
DIALOG_EXCHANGE_MODULE::DIALOG_EXCHANGE_MODULE( WinEDA_PcbFrame* parent, MODULE* Module ) : DIALOG_EXCHANGE_MODULE::DIALOG_EXCHANGE_MODULE( WinEDA_PcbFrame* parent,
MODULE* Module ) :
DIALOG_EXCHANGE_MODULE_BASE( parent ) DIALOG_EXCHANGE_MODULE_BASE( parent )
{ {
m_Parent = parent; m_Parent = parent;
...@@ -72,7 +66,7 @@ void WinEDA_PcbFrame::InstallExchangeModuleFrame( MODULE* Module ) ...@@ -72,7 +66,7 @@ void WinEDA_PcbFrame::InstallExchangeModuleFrame( MODULE* Module )
} }
void DIALOG_EXCHANGE_MODULE::OnQuit( wxCommandEvent& WXUNUSED(event) ) void DIALOG_EXCHANGE_MODULE::OnQuit( wxCommandEvent& WXUNUSED( event ) )
{ {
s_SelectionMode = m_Selection->GetSelection(); s_SelectionMode = m_Selection->GetSelection();
Close( true ); // true is to force the frame to close Close( true ); // true is to force the frame to close
...@@ -137,15 +131,12 @@ void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event ) ...@@ -137,15 +131,12 @@ void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event )
} }
/************************************************************************/
/* /*
* Met a jour le fichier name.CMP (s'il existe) apres un echange de module * Updates the file name.CMP (if any) after an exchange module
* (par la commande changeMod), si les modules sont geres par ce fichier * (By command changeMod), if the modules are managed by this file
* *
* Si ShowError != 0 affiche message d'erreur si le fichier .cmp n'est pas * If ShowError! = 0 displays error message if the file. Cmp is not found.
* trouve. * Return 1 if error
* Retoure 1 si erreur
*/ */
int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
const wxString& old_name, const wxString& old_name,
...@@ -160,13 +151,12 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -160,13 +151,12 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
char* result; // quiet compiler char* result; // quiet compiler
if( old_name == new_name ) if( old_name == new_name )
return 0; /* pas de changement de nom */ return 0; /* no change of name */
/* Calcul nom fichier CMP par changement de l'extension du nom netliste */ /* Calculation CMP file name by changing the extension name NetList */
fn = m_Parent->GetScreen()->m_FileName; fn = m_Parent->GetScreen()->m_FileName;
fn.SetExt( NetCmpExtBuffer ); fn.SetExt( NetCmpExtBuffer );
// Modification du fichier .cmp correcpondant
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
if( FichCmp == NULL ) if( FichCmp == NULL )
{ {
...@@ -178,7 +168,6 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -178,7 +168,6 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
return 1; return 1;
} }
/* Analyse du fichier et modif */
tmpFileName = fn; tmpFileName = fn;
tmpFileName.SetExt( wxT( "$$$" ) ); tmpFileName.SetExt( wxT( "$$$" ) );
NewFile = wxFopen( tmpFileName.GetFullPath(), wxT( "wt" ) ); NewFile = wxFopen( tmpFileName.GetFullPath(), wxT( "wt" ) );
...@@ -237,13 +226,12 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -237,13 +226,12 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
} }
/* /* Change the module at the current cursor position.
* Routine de changement d'un module: * Retains the following:
* Change le module pointe par la souris, par un autre en conservant * - Same direction
* - meme orientation * - Same position
* - meme position * - Same text value and ref
* - memes textes valeur et ref * - Same NetNames for pads same name
* - memes netnames pour pads de meme nom
*/ */
void DIALOG_EXCHANGE_MODULE::Change_Module() void DIALOG_EXCHANGE_MODULE::Change_Module()
{ {
...@@ -266,15 +254,15 @@ void DIALOG_EXCHANGE_MODULE::Change_Module() ...@@ -266,15 +254,15 @@ void DIALOG_EXCHANGE_MODULE::Change_Module()
/* /*
* Routine de changement de tous les modules de meme nom lib que celui * Change of all modules with the same name as that lib
* selectionne, en conservant * Retains:
* - meme orientation * - Same direction
* - meme position * - Same position
* - memes textes valeur et ref * - Same text value and ref
* - memes netnames pour pads de meme nom * - Same NetNames for pads same name
* et en remplacant l'ancien module par le noveau module * And replacing the old module with the new module
* Attention: m_CurrentModule ne pointe plus sur le module de reference * Note: m_CurrentModule no longer on the module reference
* puisque celui ci a ete change!! * since it has been changed!
*/ */
void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
{ {
...@@ -284,7 +272,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -284,7 +272,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
wxString newmodulename = m_NewModule->GetValue(); wxString newmodulename = m_NewModule->GetValue();
wxString value, lib_reference; wxString value, lib_reference;
bool check_module_value = false; bool check_module_value = false;
int ShowErr = 3; // Affiche 3 messages d'err maxi int ShowErr = 3; // Post 3 error messages max.
if( m_Parent->GetBoard()->m_Modules == NULL ) if( m_Parent->GetBoard()->m_Modules == NULL )
return; return;
...@@ -310,12 +298,13 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -310,12 +298,13 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
/* Le changement s'effectue a partir du dernier module car la routine /* The change is done from the last module for the routine
* Change_1_Module() modifie le dernier module de la liste * Change_1_Module () modifies the last module in the list.
*/ */
PICKED_ITEMS_LIST pickList; PICKED_ITEMS_LIST pickList;
/* note: for the first module in chain (the last here), Module->Back() points the board or is NULL
/* note: for the first module in chain (the last here), Module->Back()
* points the board or is NULL
*/ */
Module = m_Parent->GetBoard()->m_Modules.GetLast(); Module = m_Parent->GetBoard()->m_Modules.GetLast();
for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack ) for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack )
...@@ -346,18 +335,18 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -346,18 +335,18 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
/* /*
* Routine de changement de tous les modules par les modules de meme nom lib: * Change all modules with module of the same name in library.
* en conservant * Maintains:
* - meme orientation * - Same direction
* - meme position * - Same position
* - memes textes valeur et ref * - Same text value and ref
* - memes netnames pour pads de meme nom * - Same NetNames for pads same name
*/ */
void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
{ {
MODULE* Module, * PtBack; MODULE* Module, * PtBack;
bool change = false; bool change = false;
int ShowErr = 3; // Affiche 3 messages d'err maxi int ShowErr = 3; // Post 3 error messages max.
if( m_Parent->GetBoard()->m_Modules == NULL ) if( m_Parent->GetBoard()->m_Modules == NULL )
return; return;
...@@ -365,13 +354,13 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() ...@@ -365,13 +354,13 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
if( !IsOK( this, _( "Change ALL modules ?" ) ) ) if( !IsOK( this, _( "Change ALL modules ?" ) ) )
return; return;
/* Le changement s'effectue a partir du dernier module car la routine /* The change is done from the last module for the routine
* Change_1_Module() modifie le dernier module de la liste * Change_1_Module () modifies the last module in the list
*/ */
PICKED_ITEMS_LIST pickList; PICKED_ITEMS_LIST pickList;
/* note: for the first module in chain (the last here), Module->Back() points the board or is NULL /* note: for the first module in chain (the last here), Module->Back()
* points the board or is NULL
*/ */
Module = m_Parent->GetBoard()->m_Modules.GetLast(); Module = m_Parent->GetBoard()->m_Modules.GetLast();
for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack ) for( ; Module && ( Module->Type() == TYPE_MODULE ); Module = PtBack )
...@@ -394,16 +383,15 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() ...@@ -394,16 +383,15 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
/* /*
* Routine de changement d'un module: * Change the number empr module with the module name new_module
* Change le module de numero empr, avec le module de nom new_module * - Same direction
* - meme orientation * - Same position
* - meme position * - Same text value and ref
* - memes textes valeur et ref * - Same NetNames for pads same name
* - memes netnames pour pads de meme nom * Returns:
* Retourne : * False if no change (if the new module is not free)
* false si pas de changement ( si le nouveau module n'est pas en libr) * True if OK
* true si OK * Ratsnest must be recalculated after module exchange
* Ratsnest *must be recalculated* after modules changes
*/ */
bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
const wxString& new_module, const wxString& new_module,
...@@ -419,13 +407,14 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, ...@@ -419,13 +407,14 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
wxBusyCursor dummy; wxBusyCursor dummy;
/* Memorisation des parametres utiles de l'ancien module */ /* Copy parameters from the old module. */
oldnamecmp = Module->m_LibRef; oldnamecmp = Module->m_LibRef;
namecmp = new_module; namecmp = new_module;
/* Chargement du module */ /* Load module. */
Line.Printf( _( "Change module %s (%s) " ), Line.Printf( _( "Change module %s (%s) " ),
GetChars( Module->m_Reference->m_Text ), GetChars( oldnamecmp ) ); GetChars( Module->m_Reference->m_Text ),
GetChars( oldnamecmp ) );
m_WinMessages->AppendText( Line ); m_WinMessages->AppendText( Line );
namecmp.Trim( true ); namecmp.Trim( true );
...@@ -433,7 +422,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, ...@@ -433,7 +422,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
NewModule = m_Parent->Get_Librairie_Module( wxEmptyString, NewModule = m_Parent->Get_Librairie_Module( wxEmptyString,
namecmp, namecmp,
ShowError ); ShowError );
if( NewModule == NULL ) /* Nouveau module NON trouve, reaffichage de l'ancien */ if( NewModule == NULL ) /* New module not found, redraw the old one. */
{ {
m_WinMessages->AppendText( wxT( "No\n" ) ); m_WinMessages->AppendText( wxT( "No\n" ) );
return false; return false;
...@@ -460,16 +449,18 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, ...@@ -460,16 +449,18 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
* OldModule is deleted or put in undo list. * OldModule is deleted or put in undo list.
* @param aOldModule = footprint to replace * @param aOldModule = footprint to replace
* @param aNewModule = footprint to put * @param aNewModule = footprint to put
* @param aUndoPickList = the undo list used to save OldModule. If null, OldModule is deleted * @param aUndoPickList = the undo list used to save OldModule. If null,
* OldModule is deleted
*/ */
void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule, void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule,
MODULE* aNewModule, MODULE* aNewModule,
PICKED_ITEMS_LIST* aUndoPickList) PICKED_ITEMS_LIST* aUndoPickList )
{ {
wxPoint oldpos; /* memorisation temporaire pos curseur */ wxPoint oldpos;
D_PAD* pad, * old_pad; D_PAD* pad, * old_pad;
if( (aOldModule->Type() != TYPE_MODULE) || (aNewModule->Type() != TYPE_MODULE) ) if( ( aOldModule->Type() != TYPE_MODULE )
|| ( aNewModule->Type() != TYPE_MODULE ) )
{ {
wxMessageBox( wxT( "WinEDA_PcbFrame::Exchange_Module() StuctType error" ) ); wxMessageBox( wxT( "WinEDA_PcbFrame::Exchange_Module() StuctType error" ) );
return; return;
...@@ -481,7 +472,7 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule, ...@@ -481,7 +472,7 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule,
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = aOldModule->m_Pos; GetScreen()->m_Curseur = aOldModule->m_Pos;
/* place module without ratsnets refresh: this will be made later /* place module without ratsnest refresh: this will be made later
* when all modules are on board * when all modules are on board
*/ */
Place_Module( aNewModule, NULL, true ); Place_Module( aNewModule, NULL, true );
...@@ -503,7 +494,7 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule, ...@@ -503,7 +494,7 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule,
aNewModule->m_Reference->m_Text = aOldModule->m_Reference->m_Text; aNewModule->m_Reference->m_Text = aOldModule->m_Reference->m_Text;
aNewModule->m_Value->m_Text = aOldModule->m_Value->m_Text; aNewModule->m_Value->m_Text = aOldModule->m_Value->m_Text;
/* Mise a jour des autres parametres */ /* Updating other parameters */
aNewModule->m_TimeStamp = aOldModule->m_TimeStamp; aNewModule->m_TimeStamp = aOldModule->m_TimeStamp;
aNewModule->m_Path = aOldModule->m_Path; aNewModule->m_Path = aOldModule->m_Path;
...@@ -527,13 +518,13 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule, ...@@ -527,13 +518,13 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule,
if( aUndoPickList ) if( aUndoPickList )
{ {
GetBoard()->Remove(aOldModule); GetBoard()->Remove( aOldModule );
ITEM_PICKER picker_old(aOldModule, UR_DELETED); ITEM_PICKER picker_old( aOldModule, UR_DELETED );
ITEM_PICKER picker_new(aNewModule, UR_NEW); ITEM_PICKER picker_new( aNewModule, UR_NEW );
aUndoPickList->PushItem(picker_old); aUndoPickList->PushItem( picker_old );
aUndoPickList->PushItem(picker_new); aUndoPickList->PushItem( picker_new );
} }
else /* Effacement de l'ancien module */ else
aOldModule->DeleteStructure(); aOldModule->DeleteStructure();
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
...@@ -543,7 +534,7 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule, ...@@ -543,7 +534,7 @@ void WinEDA_PcbFrame::Exchange_Module( MODULE* aOldModule,
/* /*
* affiche la liste des modules en librairie et selectione 1 nom * Displays the list of modules in library name and select 1 name.
*/ */
void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event ) void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event )
{ {
...@@ -580,7 +571,7 @@ void WinEDA_PcbFrame::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -580,7 +571,7 @@ void WinEDA_PcbFrame::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
return; return;
} }
/* Calcul nom fichier CMP par changement de l'extension du nom netliste */ /* Calculation file name by changing the extension name to NetList */
fn = GetScreen()->m_FileName; fn = GetScreen()->m_FileName;
fn.SetExt( NetCmpExtBuffer ); fn.SetExt( NetCmpExtBuffer );
wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) +
......
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