injected DLIST<> into many list heads, see change_log.txt

This commit is contained in:
dickelbeck 2008-12-04 04:28:11 +00:00
parent 67fa1ddb92
commit aab39d1de7
137 changed files with 2533 additions and 3079 deletions

View File

@ -70,8 +70,8 @@ void Struct3D_Master::Copy( Struct3D_Master* pattern )
/***************************************************************/ /***************************************************************/
Struct3D_Master::Struct3D_Master( EDA_BaseStruct* StructFather ) : Struct3D_Master::Struct3D_Master( EDA_BaseStruct* aParent ) :
EDA_BaseStruct( StructFather, NOT_USED ) EDA_BaseStruct( aParent, NOT_USED )
/***************************************************************/ /***************************************************************/
{ {
m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0; m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0;
@ -102,8 +102,8 @@ Struct3D_Master:: ~Struct3D_Master()
/***************************************************************/ /***************************************************************/
Struct3D_Shape::Struct3D_Shape( EDA_BaseStruct* StructFather ) : Struct3D_Shape::Struct3D_Shape( EDA_BaseStruct* aParent ) :
EDA_BaseStruct( StructFather, NOT_USED ) EDA_BaseStruct( aParent, NOT_USED )
/***************************************************************/ /***************************************************************/
{ {
m_3D_Coord = NULL; m_3D_Coord = NULL;

View File

@ -197,7 +197,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
/* draw tracks and vias : */ /* draw tracks and vias : */
for( track = pcb->m_Track; track != NULL; track = track->Next() ) for( track = pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( track->Type() == TYPEVIA ) if( track->Type() == TYPE_VIA )
Draw3D_Via( (SEGVIA*) track ); Draw3D_Via( (SEGVIA*) track );
else else
Draw3D_Track( track ); Draw3D_Track( track );
@ -207,7 +207,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
{ {
for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() ) for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() )
{ {
if( segzone->Type() == TYPEZONE ) if( segzone->Type() == TYPE_ZONE )
Draw3D_Track( segzone ); Draw3D_Track( segzone );
} }
} }
@ -218,11 +218,11 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List()
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
Draw3D_DrawSegment( (DRAWSEGMENT*) PtStruct ); Draw3D_DrawSegment( (DRAWSEGMENT*) PtStruct );
break; break;
case TYPETEXTE: case TYPE_TEXTE:
Draw3D_DrawText( (TEXTE_PCB*) PtStruct ); Draw3D_DrawText( (TEXTE_PCB*) PtStruct );
break; break;
@ -513,10 +513,10 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas )
{ {
switch( Struct->Type() ) switch( Struct->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
( (EDGE_MODULE*) Struct )->Draw3D( glcanvas ); ( (EDGE_MODULE*) Struct )->Draw3D( glcanvas );
break; break;

View File

@ -70,7 +70,7 @@ public:
public: public:
Struct3D_Master( EDA_BaseStruct * StructFather ); Struct3D_Master( EDA_BaseStruct * aParent );
~Struct3D_Master(); ~Struct3D_Master();
Struct3D_Master* Next() const { return (Struct3D_Master*) Pnext; } Struct3D_Master* Next() const { return (Struct3D_Master*) Pnext; }
@ -105,7 +105,7 @@ public:
public: public:
Struct3D_Shape( EDA_BaseStruct * StructFather ); Struct3D_Shape( EDA_BaseStruct * aParent );
~Struct3D_Shape(); ~Struct3D_Shape();
Struct3D_Shape* Next() const { return (Struct3D_Shape*) Pnext; } Struct3D_Shape* Next() const { return (Struct3D_Shape*) Pnext; }

View File

@ -5,6 +5,36 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Dec-3 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew & gerbview
* added g_CurrentTrackList, and made g_CurrentTrackSegment and g_FirstTrackSegment
be #defines into this DLIST<TRACK>, see pcbnew.h.
* Switched datatype of BOARD::m_Track, BOARD::m_Zone, etc to DLIST<>.
This simplifies BOARD::~BOARD() somewhat, and adds automatic counting of list elements and encapsulation
of all list operations into DHEAD member functions, see common/dlist.cpp.
* Removed TRACK::Insert() since it no long fits with the new BOARD::m_Track and BOARD::m_Zone datatypes.
* Removed the g_UnDeleteStack support from <any>::UnLink(), this may leave a deficiency, but this code needs
to be external to UnLink() anyway.
* Made TRACK::SetNext() and TRACK::SetBack() private so they may not be used,
the only way to put a TRACK on a list is through DLIST<TRACK>::PushFront()
and other member functions of DLIST<TRACK>.
* Switched to std::vector<TRACK*> in track.cpp to hold the temporary static list.
* Made g_UnDeleteStack be a DLIST<TRACK>.
* renamed some KICAD_T to more closely match the corresponding classname.
* Changed to DLIST<> for almost all the list heads in BOARD.
++gerbview
* switched to GR_COPY mode for drawing so we can see the erasures. debugged
erasures in rs274d.cpp.
* Now using order specific TRACK loading, so erasures come after objects they
are intended to erase. Still need layer ordering and polygon ordering support, my todo.
I do not like DeleteStructList() and plan to migrate away from it, DLIST<>:DeletAll()
does something like it.
=======
2008-Dec-03 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-03 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
++pcbnew ++pcbnew
@ -13,6 +43,7 @@ email address.
results are same, but using segments can be better (faster redraw time) for polygons having a lot results are same, but using segments can be better (faster redraw time) for polygons having a lot
of segments (more than 10000) of segments (more than 10000)
>>>>>>> .r1441
2008-Dec-02 UPDATE Wayne Stambaugh <stambaughw@verizon.net> 2008-Dec-02 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================ ================================================================================
++build fixes ++build fixes

View File

@ -156,8 +156,6 @@ void DHEAD::remove( EDA_BaseStruct* aElement )
aElement->SetList( 0 ); aElement->SetList( 0 );
--count; --count;
D( VerifyListIntegrity(); );
} }
#if defined(DEBUG) #if defined(DEBUG)
@ -191,6 +189,8 @@ void DHEAD::VerifyListIntegrity()
wxASSERT( item == NULL ); wxASSERT( item == NULL );
wxASSERT( i == count ); wxASSERT( i == count );
// printf("list %p has %d items.\n", this, count );
} }
#endif #endif

View File

@ -51,15 +51,13 @@ void WinEDA_CvpcbFrame::CreateScreenCmp()
DrawFrame->SetStatusText( msg, 0 ); DrawFrame->SetStatusText( msg, 0 );
if( DrawFrame->m_Pcb->m_Modules ) if( DrawFrame->m_Pcb->m_Modules.GetCount() )
{ {
// there is only one module in the list // there is only one module in the list
DrawFrame->m_Pcb->m_Modules->DeleteStructure(); DrawFrame->m_Pcb->m_Modules.DeleteAll();
DrawFrame->m_Pcb->m_Modules = NULL;
} }
DrawFrame->m_Pcb->m_Modules = DrawFrame->Get_Module( FootprintName ); DrawFrame->m_Pcb->m_Modules.PushBack( DrawFrame->Get_Module( FootprintName ) );
DrawFrame->Zoom_Automatique( FALSE ); DrawFrame->Zoom_Automatique( FALSE );
if( DrawFrame->m_Draw3DFrame ) if( DrawFrame->m_Draw3DFrame )

View File

@ -851,7 +851,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc
; ;
} }
SetStructFather( Struct, screen ); SetaParent( Struct, screen );
PickedList = (DrawPickedStruct*) PickedList->Next(); PickedList = (DrawPickedStruct*) PickedList->Next();
} }
@ -900,7 +900,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc
RedrawOneStruct( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE );
SetStructFather( NewDrawStruct, screen ); SetaParent( NewDrawStruct, screen );
NewDrawStruct->SetNext( screen->EEDrawList ); NewDrawStruct->SetNext( screen->EEDrawList );
screen->EEDrawList = NewDrawStruct; screen->EEDrawList = NewDrawStruct;
} }
@ -1052,7 +1052,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
{ {
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation(NULL); ( (SCH_COMPONENT*) Struct )->ClearAnnotation(NULL);
SetStructFather( Struct, GetScreen() ); SetaParent( Struct, GetScreen() );
} }
PickedList = (DrawPickedStruct*) PickedList->Next(); PickedList = (DrawPickedStruct*) PickedList->Next();
} }
@ -1062,7 +1062,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
{ {
SCH_ITEM * Struct = PickedList->m_PickedStruct; SCH_ITEM * Struct = PickedList->m_PickedStruct;
Struct->SetNext( GetScreen()->EEDrawList ); Struct->SetNext( GetScreen()->EEDrawList );
SetStructFather( Struct, GetScreen() ); SetaParent( Struct, GetScreen() );
GetScreen()->EEDrawList = Struct; GetScreen()->EEDrawList = Struct;
PickedList = PickedList->Next(); PickedList = PickedList->Next();
} }
@ -1077,7 +1077,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
( (SCH_COMPONENT*) DrawStruct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) DrawStruct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) DrawStruct )->ClearAnnotation(NULL); ( (SCH_COMPONENT*) DrawStruct )->ClearAnnotation(NULL);
} }
SetStructFather( DrawStruct, GetScreen() ); SetaParent( DrawStruct, GetScreen() );
RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
DrawStruct->SetNext( GetScreen()->EEDrawList ); DrawStruct->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = DrawStruct; GetScreen()->EEDrawList = DrawStruct;

View File

@ -11,7 +11,7 @@
/******************************************************************/ /******************************************************************/
void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
/******************************************************************/ /******************************************************************/
{ {
switch( Struct->Type() ) switch( Struct->Type() )

View File

@ -371,7 +371,7 @@ DrawPickedStruct * BreakSegment(SCH_SCREEN * screen, wxPoint breakpoint,
/* EECLASS.CPP */ /* EECLASS.CPP */
/**************/ /**************/
void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen); void SetaParent(EDA_BaseStruct * Struct, BASE_SCREEN * Screen);
/***************/ /***************/
/* LIBALIAS.CPP */ /* LIBALIAS.CPP */

View File

@ -43,6 +43,7 @@ set(GERBVIEW_SRCS
set(GERBVIEW_EXTRA_SRCS set(GERBVIEW_EXTRA_SRCS
../pcbnew/basepcbframe.cpp ../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp ../pcbnew/class_board.cpp
../pcbnew/class_board_item.cpp
../pcbnew/class_board_connected_item.cpp ../pcbnew/class_board_connected_item.cpp
../pcbnew/class_drawsegment.cpp ../pcbnew/class_drawsegment.cpp
../pcbnew/class_drc_item.cpp ../pcbnew/class_drc_item.cpp

View File

@ -25,7 +25,7 @@ void Affiche_Infos_PCB_Texte( WinEDA_BasePcbFrame* frame, TEXTE_PCB* pt_texte )
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
if( pt_texte->Type() == TYPECOTATION ) if( pt_texte->Type() == TYPE_COTATION )
Affiche_1_Parametre( frame, 1, _( "COTATION" ), pt_texte->m_Text, DARKGREEN ); Affiche_1_Parametre( frame, 1, _( "COTATION" ), pt_texte->m_Text, DARKGREEN );
else else

View File

@ -398,7 +398,8 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
/* this track segment must be duplicated */ /* this track segment must be duplicated */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
TRACK* new_track = track->Copy(); TRACK* new_track = track->Copy();
new_track->Insert( m_Pcb, NULL );
m_Pcb->Add( new_track );
new_track->m_Start += delta; new_track->m_Start += delta;
new_track->m_End += delta; new_track->m_End += delta;
@ -417,7 +418,8 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{ {
/* this zone segment must be duplicated */ /* this zone segment must be duplicated */
SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy(); SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy();
new_zsegment->Insert( m_Pcb, NULL );
m_Pcb->Add( new_zsegment );
new_zsegment->m_Start += delta; new_zsegment->m_Start += delta;
new_zsegment->m_End += delta; new_zsegment->m_End += delta;

View File

@ -55,29 +55,19 @@ TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track )
if( Track->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment if( Track->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment
{ {
if( g_TrackSegmentCount > 0 ) if( g_CurrentTrackList.GetCount() > 0 )
{ {
// modification du trace // modification du trace
Track = g_CurrentTrackSegment; delete g_CurrentTrackList.PopBack();
g_CurrentTrackSegment = g_CurrentTrackSegment->Back();
delete Track; if( g_CurrentTrackList.GetCount() && g_CurrentTrackSegment->Type() == TYPE_VIA )
g_TrackSegmentCount--;
if( g_TrackSegmentCount && (g_CurrentTrackSegment->Type() == TYPEVIA) )
{ {
Track = g_CurrentTrackSegment; delete g_CurrentTrackList.PopBack();
g_CurrentTrackSegment = g_CurrentTrackSegment->Back();
delete Track;
g_TrackSegmentCount--;
} }
if( g_CurrentTrackSegment )
g_CurrentTrackSegment->SetNext( NULL );
Affiche_Status_Box(); Affiche_Status_Box();
if( g_TrackSegmentCount == 0 ) if( g_CurrentTrackList.GetCount() == 0 )
{ {
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;

View File

@ -60,7 +60,7 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = GerberGeneralLocateAndDisplay(); DrawStruct = GerberGeneralLocateAndDisplay();
if( DrawStruct == NULL ) if( DrawStruct == NULL )
break; break;
if( DrawStruct->Type() == TYPETRACK ) if( DrawStruct->Type() == TYPE_TRACK )
{ {
Delete_Segment( DC, (TRACK*) DrawStruct ); Delete_Segment( DC, (TRACK*) DrawStruct );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );

View File

@ -155,14 +155,14 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
if( pcb_layer_number > LAST_COPPER_LAYER ) if( pcb_layer_number > LAST_COPPER_LAYER )
{ {
DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPEDRAWSEGMENT ); DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPE_DRAWSEGMENT );
drawitem->SetLayer( pcb_layer_number ); drawitem->SetLayer( pcb_layer_number );
drawitem->m_Start = track->m_Start; drawitem->m_Start = track->m_Start;
drawitem->m_End = track->m_End; drawitem->m_End = track->m_End;
drawitem->m_Width = track->m_Width; drawitem->m_Width = track->m_Width;
drawitem->SetNext( pcb->m_Drawings );
pcb->m_Drawings = drawitem; pcb->Add( drawitem );
} }
else else
{ {
@ -195,7 +195,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
newtrack->SetLayer( pcb_layer_number ); newtrack->SetLayer( pcb_layer_number );
} }
newtrack->Insert( pcb, NULL ); pcb->Add( newtrack );
} }
} }

View File

@ -36,16 +36,11 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
} }
} }
m_Pcb->m_Drawings->DeleteStructList(); m_Pcb->m_Drawings.DeleteAll();
m_Pcb->m_Drawings = NULL;
m_Pcb->m_Track->DeleteStructList(); m_Pcb->m_Track.DeleteAll();
m_Pcb->m_Track = NULL;
m_Pcb->m_NbSegmTrack = 0;
m_Pcb->m_Zone->DeleteStructList(); m_Pcb->m_Zone.DeleteAll();
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
for( ; g_UnDeleteStackPtr != 0; ) for( ; g_UnDeleteStackPtr != 0; )
{ {
@ -66,12 +61,8 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
m_Pcb->m_NbLoclinks = 0; m_Pcb->m_NbLoclinks = 0;
m_Pcb->m_NbLinks = 0; m_Pcb->m_NbLinks = 0;
m_Pcb->m_NbPads = 0;
m_Pcb->m_NbNets = 0;
m_Pcb->m_NbNodes = 0; m_Pcb->m_NbNodes = 0;
m_Pcb->m_NbNoconnect = 0; m_Pcb->m_NbNoconnect = 0;
m_Pcb->m_NbSegmTrack = 0;
m_Pcb->m_NbSegmZone = 0;
/* Init parametres de gestion des ecrans PAD et PCB */ /* Init parametres de gestion des ecrans PAD et PCB */
SetBaseScreen( ActiveScreen = ScreenPcb ); SetBaseScreen( ActiveScreen = ScreenPcb );
@ -88,12 +79,8 @@ void WinEDA_GerberFrame::Erase_Zones( bool query )
if( query && !IsOK( this, _( "Delete zones ?" ) ) ) if( query && !IsOK( this, _( "Delete zones ?" ) ) )
return; return;
if( m_Pcb->m_Zone ) m_Pcb->m_Zone.DeleteAll();
{
m_Pcb->m_Zone->DeleteStructList( );
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
}
ScreenPcb->SetModify(); ScreenPcb->SetModify();
} }
@ -116,10 +103,10 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPETEXTE: case TYPE_TEXTE:
case TYPECOTATION: case TYPE_COTATION:
case TYPEMIRE: case TYPE_MIRE:
if( PtStruct->GetLayer() == layer || layer < 0 ) if( PtStruct->GetLayer() == layer || layer < 0 )
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
break; break;
@ -177,7 +164,7 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query )
for( ; PtStruct != NULL; PtStruct = PtNext ) for( ; PtStruct != NULL; PtStruct = PtNext )
{ {
PtNext = PtStruct->Next(); PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPETEXTE ) if( PtStruct->Type() == TYPE_TEXTE )
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
} }

View File

@ -57,7 +57,7 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL ) while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL )
{ {
Track = TrackLocate; Track = TrackLocate;
if( TrackLocate->Type() == TYPEVIA ) if( TrackLocate->Type() == TYPE_VIA )
break; break;
TrackLocate = TrackLocate->Next(); TrackLocate = TrackLocate->Next();
} }
@ -67,7 +67,7 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
} }
pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) m_Pcb->m_Drawings, typeloc ); pt_texte_pcb = Locate_Texte_Pcb( (TEXTE_PCB*) m_Pcb->m_Drawings.GetFirst(), typeloc );
if( pt_texte_pcb ) // texte type PCB localise if( pt_texte_pcb ) // texte type PCB localise
{ {
pt_texte_pcb->Display_Infos( this ); pt_texte_pcb->Display_Infos( this );
@ -79,7 +79,7 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
return DrawSegm; return DrawSegm;
} }
if( ( TrackLocate = Locate_Zone( (TRACK*) m_Pcb->m_Zone, if( ( TrackLocate = Locate_Zone( m_Pcb->m_Zone,
GetScreen()->m_Active_Layer, typeloc ) ) != NULL ) GetScreen()->m_Active_Layer, typeloc ) ) != NULL )
{ {
TrackLocate->Display_Infos( this ); TrackLocate->Display_Infos( this );
@ -112,7 +112,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc )
PtStruct = Pcb->m_Drawings; PtStruct = Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
if( PtStruct->Type() != TYPEDRAWSEGMENT ) if( PtStruct->Type() != TYPE_DRAWSEGMENT )
continue; continue;
pts = (DRAWSEGMENT*) PtStruct; pts = (DRAWSEGMENT*) PtStruct;
ux0 = pts->m_Start.x; uy0 = pts->m_Start.y; ux0 = pts->m_Start.x; uy0 = pts->m_Start.y;
@ -198,7 +198,7 @@ TRACK* Locate_Pistes( TRACK* start_adresse, wxPoint ref, int Layer )
dx -= ux0; dy -= uy0; dx -= ux0; dy -= uy0;
spot_cX = ref.x - ux0; spot_cY = ref.y - uy0; spot_cX = ref.x - ux0; spot_cY = ref.y - uy0;
if( Track->Type() == TYPEVIA ) /* VIA rencontree */ if( Track->Type() == TYPE_VIA ) /* VIA rencontree */
{ {
if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) ) if( (abs( spot_cX ) <= l_piste ) && (abs( spot_cY ) <=l_piste) )
{ {
@ -289,7 +289,7 @@ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc )
PtStruct = (EDA_BaseStruct*) pt_txt_pcb; PtStruct = (EDA_BaseStruct*) pt_txt_pcb;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
if( PtStruct->Type() != TYPETEXTE ) if( PtStruct->Type() != TYPE_TEXTE )
continue; continue;
pt_txt_pcb = (TEXTE_PCB*) PtStruct; pt_txt_pcb = (TEXTE_PCB*) PtStruct;

View File

@ -22,10 +22,11 @@ OBJECTS= \
gerberframe.o\ gerberframe.o\
onrightclick.o\ onrightclick.o\
class_board.o\ class_board.o\
class_board_item.o\
class_drawsegment.o\ class_drawsegment.o\
class_track.o \ class_track.o \
class_drc_item.o \ class_drc_item.o \
class_board_connected_item.o\ class_board_connected_item.o\
drawframe.o\ drawframe.o\
drawpanel.o\ drawpanel.o\
set_color.o \ set_color.o \
@ -53,7 +54,7 @@ OBJECTS= \
controle.o\ controle.o\
basepcbframe.o\ basepcbframe.o\
export_to_pcbnew.o\ export_to_pcbnew.o\
collectors.o collectors.o
setpage.o: ../share/setpage.cpp setpage.o: ../share/setpage.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp

View File

@ -72,7 +72,7 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case TYPETRACK: case TYPE_TRACK:
// PopMenu->AppendSeparator(); // PopMenu->AppendSeparator();
// PopMenu->Append(ID_POPUP_PCB_EDIT_TRACK, _("Edit")); // PopMenu->Append(ID_POPUP_PCB_EDIT_TRACK, _("Edit"));

View File

@ -102,6 +102,13 @@ static void fillRoundFlashTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
NEGATE( aTrack->m_End.y ); NEGATE( aTrack->m_End.y );
aTrack->SetNet( Dcode_index ); aTrack->SetNet( Dcode_index );
aTrack->m_Shape = S_SPOT_CIRCLE; aTrack->m_Shape = S_SPOT_CIRCLE;
D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );)
if( !isDark )
{
aTrack->m_Flags |= DRAW_ERASED;
}
} }
@ -148,6 +155,12 @@ static void fillOvalOrRectFlashTRACK( TRACK* aTrack, int Dcode_index, int aLaye
aTrack->m_Start.y -= len; aTrack->m_Start.y -= len;
aTrack->m_End.y += len; aTrack->m_End.y += len;
} }
D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );)
if( !isDark )
{
aTrack->m_Flags |= DRAW_ERASED;
}
} }
@ -178,6 +191,12 @@ static void fillLineTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
NEGATE( aTrack->m_End.y ); NEGATE( aTrack->m_End.y );
aTrack->SetNet( Dcode_index ); aTrack->SetNet( Dcode_index );
D(printf("%s: isDark=%s\n", __func__, isDark ? "true" : "false" );)
if( !isDark )
{
aTrack->m_Flags |= DRAW_ERASED;
}
} }
@ -190,16 +209,17 @@ static void Append_1_SEG_ARC_GERBER( int Dcode_index,
bool trigo_sens, bool multiquadrant, bool isDark ) bool trigo_sens, bool multiquadrant, bool isDark )
/*****************************************************************/ /*****************************************************************/
/* creation d'un arc: /*
* si multiquadrant == true arc de 0 a 360 degres creation d'un arc:
* et rel_center est la coordonn<EFBFBD>e du centre relativement au startpoint si multiquadrant == true arc de 0 a 360 degres
* et rel_center est la coordonn<EFBFBD>e du centre relativement au startpoint
* si multiquadrant == false arc de 0 <EFBFBD> 90 entierement contenu dans le meme quadrant
* et rel_center est la coordonn<EFBFBD>e du centre relativement au startpoint, si multiquadrant == false arc de 0 <EFBFBD> 90 entierement contenu dans le meme quadrant
* mais en VALEUR ABSOLUE et le signe des valeurs x et y de rel_center doit et rel_center est la coordonn<EFBFBD>e du centre relativement au startpoint,
* etre deduit de cette limite de 90 degres mais en VALEUR ABSOLUE et le signe des valeurs x et y de rel_center doit
* etre deduit de cette limite de 90 degres
*/ */
#endif #endif
@ -291,6 +311,12 @@ static void fillArcTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
NEGATE( aTrack->m_End.y ); NEGATE( aTrack->m_End.y );
aTrack->SetSubNet( -aTrack->GetSubNet() ); aTrack->SetSubNet( -aTrack->GetSubNet() );
if( !isDark )
{
D(printf("%s: isDark=false\n", __func__ );)
aTrack->m_Flags |= DRAW_ERASED;
}
} }
@ -811,16 +837,9 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
case 1: // code D01 Draw line, exposure ON case 1: // code D01 Draw line, exposure ON
{ {
m_Exposure = true; m_Exposure = true;
SEGZONE* edge_poly, * last;
edge_poly = new SEGZONE( frame->m_Pcb ); SEGZONE* edge_poly = new SEGZONE( frame->m_Pcb );
frame->m_Pcb->m_Zone.Append( edge_poly );
last = (SEGZONE*) frame->m_Pcb->m_Zone;
if( last )
while( last->Next() )
last = (SEGZONE*) last->Next();
edge_poly->Insert( frame->m_Pcb, last );
edge_poly->SetLayer( activeLayer ); edge_poly->SetLayer( activeLayer );
edge_poly->m_Width = 1; edge_poly->m_Width = 1;
@ -829,6 +848,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
edge_poly->m_End = m_CurrentPos; edge_poly->m_End = m_CurrentPos;
NEGATE( edge_poly->m_End.y ); NEGATE( edge_poly->m_End.y );
edge_poly->SetNet( m_PolygonFillModeState ); edge_poly->SetNet( m_PolygonFillModeState );
m_PreviousPos = m_CurrentPos; m_PreviousPos = m_CurrentPos;
m_PolygonFillModeState = 1; m_PolygonFillModeState = 1;
break; break;
@ -862,10 +882,10 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
{ {
case GERB_INTERPOL_LINEAR_1X: case GERB_INTERPOL_LINEAR_1X:
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillLineTRACK( track, dcode, activeLayer, fillLineTRACK( track, dcode, activeLayer,
m_PreviousPos, m_CurrentPos, m_PreviousPos, m_CurrentPos,
size.x, m_Exposure ^ m_ImageNegative ); size.x, !(m_LayerNegative ^ m_ImageNegative) );
break; break;
case GERB_INTERPOL_LINEAR_01X: case GERB_INTERPOL_LINEAR_01X:
@ -877,11 +897,11 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
case GERB_INTERPOL_ARC_NEG: case GERB_INTERPOL_ARC_NEG:
case GERB_INTERPOL_ARC_POS: case GERB_INTERPOL_ARC_POS:
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillArcTRACK( track, dcode, activeLayer, fillArcTRACK( track, dcode, activeLayer,
m_PreviousPos, m_CurrentPos, m_IJPos, m_PreviousPos, m_CurrentPos, m_IJPos,
size.x, m_Iterpolation==GERB_INTERPOL_ARC_NEG ? false : true, size.x, m_Iterpolation==GERB_INTERPOL_ARC_NEG ? false : true,
m_360Arc_enbl, m_Exposure ^ m_ImageNegative ); m_360Arc_enbl, !(m_LayerNegative ^ m_ImageNegative) );
break; break;
default: default:
@ -913,20 +933,20 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
case APT_LINE: // APT_LINE is not in the spec, don't know why it's here case APT_LINE: // APT_LINE is not in the spec, don't know why it's here
case APT_CIRCLE: case APT_CIRCLE:
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillRoundFlashTRACK( track, dcode, activeLayer, fillRoundFlashTRACK( track, dcode, activeLayer,
m_CurrentPos, m_CurrentPos,
size.x, true ^ m_ImageNegative ); size.x, !(m_LayerNegative ^ m_ImageNegative) );
break; break;
case APT_OVAL: case APT_OVAL:
case APT_RECT: case APT_RECT:
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
m_CurrentPos, size, m_CurrentPos, size,
aperture == APT_RECT ? S_SPOT_RECT : S_SPOT_OVALE, aperture == APT_RECT ? S_SPOT_RECT : S_SPOT_OVALE,
true ^ m_ImageNegative ); !(m_LayerNegative ^ m_ImageNegative) );
break; break;
case APT_MACRO: case APT_MACRO:
@ -949,7 +969,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
int diameter = scale( p->params[1].GetValue( tool ), m_GerbMetric ); int diameter = scale( p->params[1].GetValue( tool ), m_GerbMetric );
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillRoundFlashTRACK( track, dcode, activeLayer, fillRoundFlashTRACK( track, dcode, activeLayer,
m_CurrentPos, m_CurrentPos,
diameter, exposure ); diameter, exposure );
@ -978,7 +998,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
wxPoint midPoint( (start.x + end.x)/2, (start.y+end.y)/2 ); wxPoint midPoint( (start.x + end.x)/2, (start.y+end.y)/2 );
curPos += midPoint; curPos += midPoint;
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, size, S_SPOT_RECT, curPos, size, S_SPOT_RECT,
exposure ); exposure );
@ -993,7 +1013,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
size.y = msize.y; size.y = msize.y;
curPos += mapPt( p->params[3].GetValue( tool ), p->params[4].GetValue( tool ), m_GerbMetric ); curPos += mapPt( p->params[3].GetValue( tool ), p->params[4].GetValue( tool ), m_GerbMetric );
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, size, S_SPOT_RECT, curPos, size, S_SPOT_RECT,
exposure ); exposure );
@ -1012,7 +1032,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
curPos.y += size.y/2; curPos.y += size.y/2;
curPos.x += size.x/2; curPos.x += size.x/2;
track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb );
track->Insert( frame->m_Pcb, NULL ); frame->m_Pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, size, S_SPOT_RECT, curPos, size, S_SPOT_RECT,
exposure ); exposure );

View File

@ -309,16 +309,28 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t
case IMAGE_POLARITY: case IMAGE_POLARITY:
if( strnicmp( text, "NEG", 3 ) == 0 ) if( strnicmp( text, "NEG", 3 ) == 0 )
{
D(printf("%s: m_ImageNegative=true\n", __func__);)
m_ImageNegative = TRUE; m_ImageNegative = TRUE;
}
else else
{
D(printf("%s: m_ImageNegative=false\n", __func__);)
m_ImageNegative = FALSE; m_ImageNegative = FALSE;
}
break; break;
case LAYER_POLARITY: case LAYER_POLARITY:
if( *text == 'C' ) if( *text == 'C' )
{
D(printf("%s: m_LayerNegative=true\n", __func__);)
m_LayerNegative = TRUE; m_LayerNegative = TRUE;
}
else else
{
D(printf("%s: m_LayerNegative=false\n", __func__);)
m_LayerNegative = FALSE; m_LayerNegative = FALSE;
}
break; break;
case INCLUDE_FILE: case INCLUDE_FILE:

View File

@ -28,7 +28,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
/* routine de trace du pcb, avec selection des couches */ /* routine de trace du pcb, avec selection des couches */
{ {
DISPLAY_OPTIONS save_opt; DISPLAY_OPTIONS save_opt;
int DisplayPolygonsModeImg; int DisplayPolygonsModeImg;
save_opt = DisplayOpt; save_opt = DisplayOpt;
if( printmasklayer & ALL_CU_LAYERS ) if( printmasklayer & ALL_CU_LAYERS )
@ -44,8 +44,8 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
DisplayOpt.DisplayTrackIsol = 0; DisplayOpt.DisplayTrackIsol = 0;
DisplayOpt.DisplayDrawItems = FILLED; DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZones = 1; DisplayOpt.DisplayZones = 1;
DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch; DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch;
g_DisplayPolygonsModeSketch = 0; g_DisplayPolygonsModeSketch = 0;
m_PrintIsMirrored = aPrintMirrorMode; m_PrintIsMirrored = aPrintMirrorMode;
@ -57,7 +57,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
m_PrintIsMirrored = false; m_PrintIsMirrored = false;
DisplayOpt = save_opt; DisplayOpt = save_opt;
g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg; g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg;
} }
@ -80,7 +80,7 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
Trace_Gerber( DC, GR_OR, -1 ); Trace_Gerber( DC, GR_COPY, -1 );
TraceWorkSheet( DC, screen, 0 ); TraceWorkSheet( DC, screen, 0 );
Affiche_Status_Box(); Affiche_Status_Box();
@ -117,32 +117,35 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
// Draw filled polygons // Draw filled polygons
#define NBMAX 20000 #define NBMAX 20000
TRACK* track;
int nbpoints = 0; int nbpoints = 0;
int nbpointsmax = NBMAX; int nbpointsmax = NBMAX;
int* coord = (int*) malloc( nbpointsmax * sizeof(int) * 2 ); int* coord = (int*) malloc( nbpointsmax * sizeof(int) * 2 );
int* ptcoord = coord; int* ptcoord = coord;
track = m_Pcb->m_Zone;
for( ; track != NULL; track = track->Next() ) for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() )
{ {
if ( printmasklayer != -1 ) if( printmasklayer != -1 && !(track->ReturnMaskLayer() & printmasklayer) )
if ( (track->ReturnMaskLayer() & printmasklayer) == 0 ) continue; continue;
if( track->GetNet() == 0 ) // StartPoint if( track->GetNet() == 0 ) // StartPoint
{ {
if( nbpoints ) // we have found a new polygon: Draw the old polygon if( nbpoints ) // we have found a new polygon: Draw the old polygon
{ {
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; int Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0; int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord, GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord,
filled, Color, Color ); filled, Color, Color );
} }
nbpoints = 2; nbpoints = 2;
ptcoord = coord; ptcoord = coord;
*ptcoord = track->m_Start.x; ptcoord++;
*ptcoord = track->m_Start.y; ptcoord++; *ptcoord++ = track->m_Start.x;
*ptcoord = track->m_End.x; ptcoord++; *ptcoord++ = track->m_Start.y;
*ptcoord = track->m_End.y; ptcoord++;
*ptcoord++ = track->m_End.x;
*ptcoord++ = track->m_End.y;
} }
else else
{ {
@ -153,13 +156,16 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
ptcoord = coord + nbpointsmax; ptcoord = coord + nbpointsmax;
} }
nbpoints++; nbpoints++;
*ptcoord = track->m_End.x; ptcoord++;
*ptcoord = track->m_End.y; ptcoord++; *ptcoord++ = track->m_End.x;
*ptcoord++ = track->m_End.y;
} }
if( track->Next() == NULL ) // Last point if( track->Next() == NULL ) // Last point
{ {
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; int Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0; int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord, GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord,
filled, Color, Color ); filled, Color, Color );
} }

View File

@ -29,30 +29,28 @@ void Draw_Track_Buffer( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int draw_
* @param printmasklayer = mask for allowed layer (=-1 to draw all layers) * @param printmasklayer = mask for allowed layer (=-1 to draw all layers)
*/ */
{ {
TRACK* Track;
int layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; int layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
GERBER* gerber = g_GERBER_List[layer]; GERBER* gerber = g_GERBER_List[layer];
int dcode_hightlight = 0; int dcode_hightlight = 0;
if( gerber ) if( gerber )
dcode_hightlight = gerber->m_Selected_Tool; dcode_hightlight = gerber->m_Selected_Tool;
Track = Pcb->m_Track; for( TRACK* track = Pcb->m_Track; track; track = track->Next() )
for( ; Track != NULL; Track = Track->Next() )
{ {
if( printmasklayer != -1 ) if( !(track->ReturnMaskLayer() & printmasklayer) )
if( (Track->ReturnMaskLayer() & printmasklayer) == 0 ) continue;
continue;
if( (dcode_hightlight == Track->GetNet()) if( dcode_hightlight == track->GetNet() && track->GetLayer()==layer )
&& (Track->GetLayer() == layer) ) Trace_Segment( panel, DC, track, draw_mode | GR_SURBRILL );
Trace_Segment( panel, DC, Track, draw_mode | GR_SURBRILL );
else else
Trace_Segment( panel, DC, Track, draw_mode ); Trace_Segment( panel, DC, track, draw_mode );
} }
} }
#if 1
/***********************************************************************************/ /***********************************************************************************/
void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mode ) void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mode )
/***********************************************************************************/ /***********************************************************************************/
@ -70,22 +68,30 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
int fillopt; int fillopt;
static bool show_err; static bool show_err;
color = g_DesignSettings.m_LayerColor[track->GetLayer()]; if( track->m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview
if( color & ITEM_NOT_SHOW ) {
return; color = g_DrawBgColor;
}
else
{
color = g_DesignSettings.m_LayerColor[track->GetLayer()];
if( color & ITEM_NOT_SHOW )
return;
zoom = panel->GetZoom(); if( draw_mode & GR_SURBRILL )
{
if( draw_mode & GR_AND )
color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
}
if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
}
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
if( draw_mode & GR_SURBRILL )
{ zoom = panel->GetZoom();
if( draw_mode & GR_AND )
color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
}
if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
rayon = l_piste = track->m_Width >> 1; rayon = l_piste = track->m_Width >> 1;
@ -151,8 +157,8 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
} }
break; break;
case S_SPOT_RECT: case S_SPOT_RECT:
case S_RECT: case S_RECT:
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
if( (l_piste / zoom) < L_MIN_DESSIN ) if( (l_piste / zoom) < L_MIN_DESSIN )
{ {
@ -179,10 +185,10 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
} }
break; break;
case S_SPOT_OVALE: case S_SPOT_OVALE:
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
case S_SEGMENT: case S_SEGMENT:
if( (l_piste / zoom) < L_MIN_DESSIN ) if( (l_piste / zoom) < L_MIN_DESSIN )
{ {
GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
@ -214,6 +220,8 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
} }
} }
#endif
/*****************************************************************************************/ /*****************************************************************************************/
void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode ) void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode )

View File

@ -34,8 +34,8 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC )
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEVIA: case TYPE_VIA:
case TYPETRACK: case TYPE_TRACK:
for( ; item; item = next ) for( ; item; item = next )
{ {
next = item->Next(); next = item->Next();
@ -87,8 +87,8 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems )
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEVIA: case TYPE_VIA:
case TYPETRACK: case TYPE_TRACK:
{ {
EDA_BaseStruct* Back = NULL; EDA_BaseStruct* Back = NULL;
g_UnDeleteStack[g_UnDeleteStackPtr - 1] = PtStruct; g_UnDeleteStack[g_UnDeleteStackPtr - 1] = PtStruct;

View File

@ -22,27 +22,28 @@ enum KICAD_T {
EOT = 0, // search types array terminator (End Of Types) EOT = 0, // search types array terminator (End Of Types)
TYPE_NOT_INIT = 0, TYPE_NOT_INIT = 0,
TYPEPCB, TYPE_PCB,
// Items in pcb // Items in pcb
PCB_EQUIPOT_STRUCT_TYPE, TYPE_EQUIPOT,
TYPEMODULE, TYPE_MODULE,
TYPEPAD, TYPE_PAD,
TYPEDRAWSEGMENT, TYPE_DRAWSEGMENT,
TYPETEXTE, TYPE_TEXTE,
TYPETEXTEMODULE, TYPE_TEXTE_MODULE,
TYPEEDGEMODULE, TYPE_EDGE_MODULE,
TYPETRACK, TYPE_TRACK,
TYPEZONE, TYPE_ZONE,
TYPEVIA, TYPE_VIA,
TYPEMARKER, TYPE_MARKER,
TYPECOTATION, TYPE_COTATION,
TYPEMIRE, TYPE_MIRE,
TYPESCREEN, TYPE_SCREEN,
TYPEBLOCK, TYPE_BLOCK,
TYPEZONE_UNUSED, TYPE_ZONE_UNUSED,
TYPEZONE_EDGE_CORNER, TYPE_ZONE_EDGE_CORNER,
TYPEZONE_CONTAINER, TYPE_ZONE_CONTAINER,
TYPE_BOARD_ITEM_LIST,
// Draw Items in schematic // Draw Items in schematic
DRAW_POLYLINE_STRUCT_TYPE, DRAW_POLYLINE_STRUCT_TYPE,

View File

@ -1,26 +1,12 @@
/**********************************************************************************************/ /**********************************************************************************************/
/* board_item_struct.h : Basic classes for BOARD_ITEM and BOARD_CONNECTED_ITEM descriptions */ /* board_item_struct.h : Classes BOARD_ITEM and BOARD_CONNECTED_ITEM */
/**********************************************************************************************/ /**********************************************************************************************/
#ifndef BOARD_ITEM_STRUCT_H #ifndef BOARD_ITEM_STRUCT_H
#define BOARD_ITEM_STRUCT_H #define BOARD_ITEM_STRUCT_H
/** #include <boost/ptr_container/ptr_vector.hpp>
* Class BOARD_ITEM
* is a base class for any item which can be embedded within the BOARD
* container class, and therefore instances of derived classes should only be
* found in PCBNEW or other programs that use class BOARD and its contents.
* The corresponding class in EESCHEMA is SCH_ITEM.
*/
/**
* Class BOARD_CONNECTED_ITEM
* This is a base class derived from BOARD_ITEM for items that can be connected
* mainly: tracks and pads
* Handle connection info
*
*/
/* Shapes for segments (graphic segments and tracks) ( .shape member ) */ /* Shapes for segments (graphic segments and tracks) ( .shape member ) */
@ -51,8 +37,8 @@ protected:
public: public:
BOARD_ITEM( BOARD_ITEM* StructFather, KICAD_T idtype ) : BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
EDA_BaseStruct( StructFather, idtype ) EDA_BaseStruct( aParent, idtype )
, m_Layer( 0 ) , m_Layer( 0 )
{ {
} }
@ -62,6 +48,7 @@ public:
EDA_BaseStruct( src.m_Parent, src.Type() ) EDA_BaseStruct( src.m_Parent, src.Type() )
, m_Layer( src.m_Layer ) , m_Layer( src.m_Layer )
{ {
m_Flags = src.m_Flags;
} }
@ -130,9 +117,10 @@ public:
/** /**
* Function UnLink * Function UnLink
* detaches this object from its owner. * detaches this object from its owner. This base class implementation
* should work for all derived classes which are held in a DLIST<>.
*/ */
virtual void UnLink() = 0; virtual void UnLink();
/** /**
@ -183,6 +171,12 @@ public:
}; };
/**
* Class BOARD_CONNECTED_ITEM
* This is a base class derived from BOARD_ITEM for items that can be connected
* mainly: tracks and pads
* Handle connection info
*/
class BOARD_CONNECTED_ITEM : public BOARD_ITEM class BOARD_CONNECTED_ITEM : public BOARD_ITEM
{ {
protected: protected:
@ -196,7 +190,7 @@ protected:
// handle block number in zone connection // handle block number in zone connection
public: public:
BOARD_CONNECTED_ITEM( BOARD_ITEM* StructFather, KICAD_T idtype ); BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& src ); BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& src );
/** /**
@ -221,5 +215,117 @@ public:
void SetZoneSubNet( int aSubNetCode ); void SetZoneSubNet( int aSubNetCode );
}; };
class BOARD_ITEM_LIST : public BOARD_ITEM
{
typedef boost::ptr_vector<BOARD_ITEM> ITEM_ARRAY;
ITEM_ARRAY myItems;
BOARD_ITEM_LIST( const BOARD_ITEM_LIST& other ) :
BOARD_ITEM( NULL, TYPE_BOARD_ITEM_LIST )
{
// copy constructor is not supported, is private to cause compiler error
}
public:
BOARD_ITEM_LIST( BOARD_ITEM* aParent = NULL ) :
BOARD_ITEM( aParent, TYPE_BOARD_ITEM_LIST )
{}
//-----< satisfy some virtual functions >------------------------------
wxPoint& GetPosition()
{
static wxPoint dummy;
return dummy;
}
void Draw( WinEDA_DrawPanel* DrawPanel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset )
{
}
void UnLink()
{
/* if it were needed:
DHEAD* list = GetList();
wxASSERT( list );
list->remove( this );
*/
}
bool Save( FILE* aFile ) const
{
return true;
}
//-----</ satisfy some virtual functions >-----------------------------
/**
* Function GetCount
* returns the number of BOARD_ITEMs.
*/
int GetCount() const
{
return myItems.size();
}
void Append( BOARD_ITEM* aItem )
{
myItems.push_back( aItem );
}
BOARD_ITEM* Replace( int aIndex, BOARD_ITEM* aItem )
{
ITEM_ARRAY::auto_type ret = myItems.replace( aIndex, aItem );
return ret.release();
}
BOARD_ITEM* Remove( int aIndex )
{
ITEM_ARRAY::auto_type ret = myItems.release( myItems.begin()+aIndex );
return ret.release();
}
void Insert( int aIndex, BOARD_ITEM* aItem )
{
myItems.insert( myItems.begin()+aIndex, aItem );
}
BOARD_ITEM* At( int aIndex ) const
{
// we have varying sized objects and are using polymorphism, so we
// must return a pointer not a reference.
return (BOARD_ITEM*) &myItems[aIndex];
}
BOARD_ITEM* operator[]( int aIndex ) const
{
return At( aIndex );
}
void Delete( int aIndex )
{
myItems.erase( myItems.begin()+aIndex );
}
void PushBack( BOARD_ITEM* aItem )
{
Append( aItem );
}
BOARD_ITEM* PopBack()
{
if( GetCount() )
return Remove( GetCount()-1 );
return NULL;
}
};
#endif /* BOARD_ITEM_STRUCT_H */ #endif /* BOARD_ITEM_STRUCT_H */

View File

@ -39,7 +39,7 @@ class DHEAD
protected: protected:
EDA_BaseStruct* first; ///< first element in list, or NULL if list empty EDA_BaseStruct* first; ///< first element in list, or NULL if list empty
EDA_BaseStruct* last; ///< last elment in list, or NULL if empty EDA_BaseStruct* last; ///< last elment in list, or NULL if empty
unsigned count; ///< how many elements are in the list unsigned count; ///< how many elements are in the list, automatically maintained.
bool meOwner; ///< I must delete the objects I hold in my destructor bool meOwner; ///< I must delete the objects I hold in my destructor
/** /**
@ -66,7 +66,10 @@ protected:
/** /**
* Function insert * Function insert
* puts aNewElement just in front of aElementAfterMe in the list sequence. * puts aNewElement just in front of aElementAfterMe in the list sequence.
* If aElementAfterMe is NULL, then simply Append() * If aElementAfterMe is NULL, then simply append().
* @param aNewElement The element to insert.
* @param aElementAfterMe The element to insert \a aNewElement before,
* if NULL then append aNewElement onto end of list.
*/ */
void insert( EDA_BaseStruct* aNewElement, EDA_BaseStruct* aElementAfterMe ); void insert( EDA_BaseStruct* aNewElement, EDA_BaseStruct* aElementAfterMe );
@ -210,9 +213,13 @@ public:
insert( aNewElement ); insert( aNewElement );
} }
void PushBack( T* aElement ) /**
* Function PushBack
* puts aNewElement at the end of the list sequence.
*/
void PushBack( T* aNewElement )
{ {
append( aElement ); append( aNewElement );
} }
//-----</ STL like functions >-------------------------------------- //-----</ STL like functions >--------------------------------------

View File

@ -18,21 +18,23 @@
/* Bits indicateurs du membre .Status, pour pistes, modules... */ /* Bits indicateurs du membre .Status, pour pistes, modules... */
#define FLAG1 0x2000 /* flag libre pour calculs locaux */
#define FLAG0 0x1000 /* flag libre pour calculs locaux */ #define FLAG1 (1 << 13) /* flag libre pour calculs locaux */
#define BEGIN_ONPAD 0x800 /* flag indiquant un debut de segment sur pad */ #define FLAG0 (1 << 12) /* flag libre pour calculs locaux */
#define END_ONPAD 0x400 /* flag indiquant une fin de segment sur pad */ #define BEGIN_ONPAD (1 << 11) /* flag indiquant un debut de segment sur pad */
#define BUSY 0x0200 /* flag indiquant que la structure a deja #define END_ONPAD (1 << 10) /* flag indiquant une fin de segment sur pad */
* ete examinee, dans certaines routines */ #define BUSY (1 << 9) /* flag indiquant que la structure a deja
#define DELETED 0x0100 /* Bit flag de Status pour structures effacee * ete examinee, dans certaines routines */
* et mises en chaine "DELETED" */ #define DELETED (1 << 8) /* Bit flag de Status pour structures effacee
#define NO_TRACE 0x80 /* l'element ne doit pas etre affiche */ * et mises en chaine "DELETED" */
#define SURBRILL 0x20 /* element en surbrillance */ #define NO_TRACE (1 << 7) /* l'element ne doit pas etre affiche */
#define DRAG 0x10 /* segment en mode drag */
#define EDIT 0x8 /* element en cours d'edition */ #define SURBRILL (1 << 5) /* element en surbrillance */
#define SEGM_FIXE 0x04 /* segment FIXE ( pas d'effacement global ) */ #define DRAG (1 << 4) /* segment en mode drag */
#define SEGM_AR 0x02 /* segment Auto_Route */ #define EDIT (1 << 3) /* element en cours d'edition */
#define CHAIN 0x01 /* segment marque */ #define SEGM_FIXE (1 << 2) /* segment FIXE ( pas d'effacement global ) */
#define SEGM_AR (1 << 1) /* segment Auto_Route */
#define CHAIN (1 << 0) /* segment marque */
/* Layer identification (layer number) */ /* Layer identification (layer number) */

View File

@ -511,7 +511,7 @@ public:
bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end ); bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ); void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
void SwitchLayer( wxDC* DC, int layer ); void SwitchLayer( wxDC* DC, int layer );
int Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ); bool Add_45_degrees_Segment( wxDC* DC );
bool Genere_Pad_Connexion( wxDC* DC, int layer ); bool Genere_Pad_Connexion( wxDC* DC, int layer );
// zone handling // zone handling

View File

@ -55,10 +55,10 @@ void Affiche_Infos_Equipot( int netcode, WinEDA_BasePcbFrame* frame )
for( ii = 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Next() ) for( ii = 0, Struct = frame->m_Pcb->m_Track; Struct != NULL; Struct = Struct->Next() )
{ {
ii++; ii++;
if( Struct->Type() == TYPEVIA ) if( Struct->Type() == TYPE_VIA )
if( ( (SEGVIA*) Struct )->GetNet() == netcode ) if( ( (SEGVIA*) Struct )->GetNet() == netcode )
nb_vias++; nb_vias++;
if( Struct->Type() == TYPETRACK ) if( Struct->Type() == TYPE_TRACK )
if( ( (TRACK*) Struct )->GetNet() == netcode ) if( ( (TRACK*) Struct )->GetNet() == netcode )
lengthnet += ( (TRACK*) Struct )->GetLength(); lengthnet += ( (TRACK*) Struct )->GetLength();
} }

View File

@ -41,7 +41,7 @@ void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
TRACK* Track; TRACK* Track;
int nb_segm; int nb_segm;
if( (track == NULL ) || (track->Type() == TYPEZONE) ) if( (track == NULL ) || (track->Type() == TYPE_ZONE) )
return; return;
DrawPanel->CursorOff( DC ); // Erase cursor shape DrawPanel->CursorOff( DC ); // Erase cursor shape

View File

@ -458,7 +458,7 @@ int WinEDA_PcbFrame::GenPlaceBoard()
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
DrawSegm = (DRAWSEGMENT*) PtStruct; DrawSegm = (DRAWSEGMENT*) PtStruct;
if( DrawSegm->GetLayer() != EDGE_N ) if( DrawSegm->GetLayer() != EDGE_N )
break; break;
@ -471,7 +471,7 @@ int WinEDA_PcbFrame::GenPlaceBoard()
TraceSegmentPcb( m_Pcb, &TmpSegm, HOLE | CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL ); TraceSegmentPcb( m_Pcb, &TmpSegm, HOLE | CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL );
break; break;
case TYPETEXTE: case TYPE_TEXTE:
default: default:
break; break;
} }
@ -919,7 +919,7 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
/********************************************/ /********************************************/
void Build_PlacedPads_List( BOARD* Pcb ) void Build_PlacedPads_List( BOARD* aPcb )
/********************************************/ /********************************************/
/* /*
@ -937,57 +937,29 @@ void Build_PlacedPads_List( BOARD* Pcb )
* m_Status_Pcb |= LISTE_PAD_OK * m_Status_Pcb |= LISTE_PAD_OK
*/ */
{ {
LISTE_PAD* pt_liste_pad; aPcb->m_Pads.clear();
MODULE* Module;
D_PAD* PtPad;
if( Pcb->m_Pads ) aPcb->m_NbNodes = 0;
MyFree( Pcb->m_Pads );
pt_liste_pad = Pcb->m_Pads = NULL; // Initialisation du buffer et des variables de travail
Pcb->m_NbPads = Pcb->m_NbNodes = 0; for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
/* Calcul du nombre de pads utiles */
Module = Pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
{ {
if( Module->m_ModuleStatus & MODULE_to_PLACE ) if( module->m_ModuleStatus & MODULE_to_PLACE )
continue; continue;
PtPad = (D_PAD*) Module->m_Pads;
for( ; PtPad != NULL; PtPad = PtPad->Next() ) for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{ {
Pcb->m_NbPads++; aPcb->m_Pads.push_back( pad );
pad->SetSubNet( 0 );
pad->SetSubRatsnest( 0 );
pad->SetParent( module );
if( pad->GetNet() )
aPcb->m_NbNodes++;
} }
} }
/* Allocation memoire du buffer */ aPcb->m_Status_Pcb |= LISTE_PAD_OK;
if( Pcb->m_NbPads > 0 ) aPcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CHEVELU_LOCAL_OK);
{
pt_liste_pad = Pcb->m_Pads
= (D_PAD**) MyMalloc( Pcb->m_NbPads * sizeof(D_PAD *) );
}
/* Initialisation du buffer et des variables de travail */
Module = Pcb->m_Modules;
for( ; (Module != NULL) && (pt_liste_pad != NULL); Module = Module->Next() )
{
if( Module->m_ModuleStatus & MODULE_to_PLACE )
continue;
PtPad = (D_PAD*) Module->m_Pads;
for( ; PtPad != NULL; PtPad = PtPad->Next() )
{
*pt_liste_pad = PtPad;
PtPad->SetSubNet( 0 );
PtPad->SetSubRatsnest( 0 );
PtPad->SetParent( Module );
if( PtPad->GetNet() )
Pcb->m_NbNodes++;
pt_liste_pad++;
}
}
Pcb->m_Status_Pcb |= LISTE_PAD_OK;
Pcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CHEVELU_LOCAL_OK);
adr_lowmem = buf_work; adr_lowmem = buf_work;
} }
@ -1217,7 +1189,7 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
PtStruct = m_Pcb->m_Drawings; PtStruct = m_Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
if( PtStruct->Type() != TYPEDRAWSEGMENT ) if( PtStruct->Type() != TYPE_DRAWSEGMENT )
continue; continue;
succes = TRUE; succes = TRUE;
ptr = (DRAWSEGMENT*) PtStruct; ptr = (DRAWSEGMENT*) PtStruct;

View File

@ -46,7 +46,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
{ {
switch( GetScreen()->GetCurItem()->Type() ) switch( GetScreen()->GetCurItem()->Type() )
{ {
case TYPEPAD: case TYPE_PAD:
Pad = (D_PAD*) GetScreen()->GetCurItem(); Pad = (D_PAD*) GetScreen()->GetCurItem();
autoroute_net_code = Pad->GetNet(); autoroute_net_code = Pad->GetNet();
break; break;
@ -63,7 +63,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
case ROUTE_MODULE: case ROUTE_MODULE:
Module = (MODULE*) GetScreen()->GetCurItem(); Module = (MODULE*) GetScreen()->GetCurItem();
if( (Module == NULL) || (Module->Type() != TYPEMODULE) ) if( (Module == NULL) || (Module->Type() != TYPE_MODULE) )
{ {
DisplayError( this, _( "Module not selected" ) ); return; DisplayError( this, _( "Module not selected" ) ); return;
} }
@ -71,7 +71,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
case ROUTE_PAD: case ROUTE_PAD:
Pad = (D_PAD*) GetScreen()->GetCurItem(); Pad = (D_PAD*) GetScreen()->GetCurItem();
if( (Pad == NULL) || (Pad->Type() != TYPEPAD) ) if( (Pad == NULL) || (Pad->Type() != TYPE_PAD) )
{ {
DisplayError( this, _( "Pad not selected" ) ); return; DisplayError( this, _( "Pad not selected" ) ); return;
} }

View File

@ -295,7 +295,7 @@ void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem )
{ {
aItem->Display_Infos( this ); aItem->Display_Infos( this );
#if 1 && defined(DEBUG) #if 0 && defined(DEBUG)
aItem->Show( 0, std::cout ); aItem->Show( 0, std::cout );
#endif #endif

View File

@ -502,7 +502,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -513,7 +513,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
break; break;
case TYPETEXTE: case TYPE_TEXTE:
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -524,7 +524,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
break; break;
case TYPEMIRE: case TYPE_MIRE:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -533,7 +533,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
break; break;
case TYPECOTATION: case TYPE_COTATION:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -688,9 +688,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
#undef STRUCT #undef STRUCT
#define STRUCT ( (DRAWSEGMENT*) PtStruct ) #define STRUCT ( (DRAWSEGMENT*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -699,9 +699,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
RotatePoint( &STRUCT->m_End, centre, 900 ); RotatePoint( &STRUCT->m_End, centre, 900 );
break; break;
case TYPETEXTE: case TYPE_TEXTE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (TEXTE_PCB*) PtStruct ) #define STRUCT ( (TEXTE_PCB*) PtStruct )
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -714,9 +714,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
STRUCT->CreateDrawData(); STRUCT->CreateDrawData();
break; break;
case TYPEMIRE: case TYPE_MIRE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (MIREPCB*) PtStruct ) #define STRUCT ( (MIREPCB*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -725,9 +725,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
RotatePoint( &STRUCT->m_Pos, centre, 900 ); RotatePoint( &STRUCT->m_Pos, centre, 900 );
break; break;
case TYPECOTATION: case TYPE_COTATION:
#undef STRUCT #undef STRUCT
#define STRUCT ( (COTATION*) PtStruct ) #define STRUCT ( (COTATION*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -818,7 +818,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
INVERT( track->m_Start.y ); INVERT( track->m_Start.y );
INVERT( track->m_End.y ); INVERT( track->m_End.y );
if( track->Type() != TYPEVIA ) if( track->Type() != TYPE_VIA )
{ {
track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) ); track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) );
} }
@ -864,9 +864,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
#undef STRUCT #undef STRUCT
#define STRUCT ( (DRAWSEGMENT*) PtStruct ) #define STRUCT ( (DRAWSEGMENT*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -881,9 +881,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) );
break; break;
case TYPETEXTE: case TYPE_TEXTE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (TEXTE_PCB*) PtStruct ) #define STRUCT ( (TEXTE_PCB*) PtStruct )
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -899,9 +899,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
STRUCT->CreateDrawData(); STRUCT->CreateDrawData();
break; break;
case TYPEMIRE: case TYPE_MIRE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (MIREPCB*) PtStruct ) #define STRUCT ( (MIREPCB*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -911,9 +911,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) );
break; break;
case TYPECOTATION: case TYPE_COTATION:
#undef STRUCT #undef STRUCT
#define STRUCT ( (COTATION*) PtStruct ) #define STRUCT ( (COTATION*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
@ -943,8 +943,6 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
* Function to move items withing the selected block * Function to move items withing the selected block
*/ */
{ {
MODULE* module;
EDA_BaseStruct* PtStruct;
int masque_layer; int masque_layer;
wxPoint oldpos; wxPoint oldpos;
wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector; wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector;
@ -964,13 +962,13 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
if( Block_Include_Modules ) if( Block_Include_Modules )
{ {
bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false;
module = m_Pcb->m_Modules;
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
for( ; module != NULL; module = module->Next() ) for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{ {
if( ! module->HitTest( GetScreen()->BlockLocate ) ) if( ! module->HitTest( GetScreen()->BlockLocate ) )
continue; continue;
/* le module est ici bon a etre deplace */ /* le module est ici bon a etre deplace */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
module->m_Flags = 0; module->m_Flags = 0;
@ -985,9 +983,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
/* Deplacement des Segments de piste */ /* Deplacement des Segments de piste */
if( Block_Include_Tracks ) if( Block_Include_Tracks )
{ {
TRACK* track; for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
track = m_Pcb->m_Track;
while( track )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */ { /* la piste est ici bonne a etre deplacee */
@ -995,23 +991,19 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
track->m_Start += MoveVector; track->m_Start += MoveVector;
track->m_End += MoveVector; track->m_End += MoveVector;
} }
track = track->Next();
} }
} }
/* Deplacement des Segments de Zone */ /* Deplacement des Segments de Zone */
if( Block_Include_Zones ) if( Block_Include_Zones )
{ {
TRACK* track; for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() )
track = (TRACK*) m_Pcb->m_Zone;
while( track )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */ { /* la piste est ici bonne a etre deplacee */
track->m_Start += MoveVector; track->m_Start += MoveVector;
track->m_End += MoveVector; track->m_End += MoveVector;
} }
track = track->Next();
} }
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
@ -1028,55 +1020,54 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
if( !Block_Include_Edges_Items ) if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER; masque_layer &= ~EDGE_LAYER;
PtStruct = m_Pcb->m_Drawings; for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() )
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
switch( PtStruct->Type() ) switch( item->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
#undef STRUCT #undef STRUCT
#define STRUCT ( (DRAWSEGMENT*) PtStruct ) #define STRUCT ( (DRAWSEGMENT*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
STRUCT->m_Start += MoveVector; STRUCT->m_Start += MoveVector;
STRUCT->m_End += MoveVector; STRUCT->m_End += MoveVector;
break; break;
case TYPETEXTE: case TYPE_TEXTE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (TEXTE_PCB*) PtStruct ) #define STRUCT ( (TEXTE_PCB*) item )
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->BlockLocate ) )
break; break;
/* le texte est ici bon a etre deplace */ /* le texte est ici bon a etre deplace */
/* Redessin du Texte */ /* Redessin du Texte */
STRUCT->m_Pos += MoveVector; STRUCT->m_Pos += MoveVector;
break; break;
case TYPEMIRE: case TYPE_MIRE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (MIREPCB*) PtStruct ) #define STRUCT ( (MIREPCB*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
STRUCT->m_Pos += MoveVector; STRUCT->m_Pos += MoveVector;
break; break;
case TYPECOTATION: case TYPE_COTATION:
#undef STRUCT #undef STRUCT
#define STRUCT ( (COTATION*) PtStruct ) #define STRUCT ( (COTATION*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
( (COTATION*) PtStruct )->Move( wxPoint(MoveVector) ); ( (COTATION*) item )->Move( wxPoint(MoveVector) );
break; break;
default: default:
@ -1098,8 +1089,6 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
* routine de duplication des elements du block deja selectionne * routine de duplication des elements du block deja selectionne
*/ */
{ {
MODULE* module;
EDA_BaseStruct* PtStruct;
int masque_layer; int masque_layer;
wxPoint oldpos; wxPoint oldpos;
wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector; wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector;
@ -1120,24 +1109,23 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{ {
bool Show_Ratsnest_tmp = g_Show_Ratsnest; bool Show_Ratsnest_tmp = g_Show_Ratsnest;
g_Show_Ratsnest = false; g_Show_Ratsnest = false;
module = m_Pcb->m_Modules;
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
for( ; module != NULL; module = module->Next() ) for( MODULE* module= m_Pcb->m_Modules; module; module = module->Next() )
{ {
MODULE* new_module; MODULE* new_module;
if( ! module->HitTest( GetScreen()->BlockLocate ) ) if( ! module->HitTest( GetScreen()->BlockLocate ) )
continue; continue;
/* le module est ici bon a etre deplace */ /* le module est ici bon a etre deplace */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
module->m_Flags = 0; module->m_Flags = 0;
new_module = new MODULE( m_Pcb ); new_module = new MODULE( m_Pcb );
new_module->Copy( module ); new_module->Copy( module );
new_module->m_TimeStamp = GetTimeStamp(); new_module->m_TimeStamp = GetTimeStamp();
new_module->SetNext( m_Pcb->m_Modules );
new_module->SetBack( m_Pcb ); m_Pcb->m_Modules.PushFront( new_module );
m_Pcb->m_Modules->SetBack( new_module );
m_Pcb->m_Modules = new_module;
GetScreen()->m_Curseur = module->m_Pos + MoveVector; GetScreen()->m_Curseur = module->m_Pos + MoveVector;
Place_Module( new_module, DC ); Place_Module( new_module, DC );
} }
@ -1158,10 +1146,13 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{ {
/* la piste est ici bonne a etre deplacee */ /* la piste est ici bonne a etre deplacee */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
new_track = track->Copy(); new_track = track->Copy();
new_track->Insert( m_Pcb, NULL ); m_Pcb->m_Track.PushFront( new_track );
new_track->m_Start += MoveVector; new_track->m_Start += MoveVector;
new_track->m_End += MoveVector; new_track->m_End += MoveVector;
new_track->Draw( DrawPanel, DC, GR_OR ); // reaffichage new_track->Draw( DrawPanel, DC, GR_OR ); // reaffichage
} }
track = next_track; track = next_track;
@ -1171,19 +1162,19 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
/* Duplicate Zones */ /* Duplicate Zones */
if( Block_Include_Zones ) if( Block_Include_Zones )
{ {
SEGZONE* segzone, * new_segzone; for( SEGZONE* segzone = m_Pcb->m_Zone; segzone; segzone = segzone->Next() )
segzone = m_Pcb->m_Zone;
while( segzone )
{ {
if( segzone->HitTest( GetScreen()->BlockLocate ) ) if( segzone->HitTest( GetScreen()->BlockLocate ) )
{ {
new_segzone = (SEGZONE*) segzone->Copy(); SEGZONE* new_segzone = (SEGZONE*) segzone->Copy();
new_segzone->Insert( m_Pcb, NULL );
m_Pcb->m_Zone.PushFront( new_segzone );
new_segzone->m_Start += MoveVector; new_segzone->m_Start += MoveVector;
new_segzone->m_End += MoveVector; new_segzone->m_End += MoveVector;
new_segzone->Draw( DrawPanel, DC, GR_OR ); new_segzone->Draw( DrawPanel, DC, GR_OR );
} }
segzone = segzone->Next();
} }
unsigned imax = m_Pcb->GetAreaCount(); unsigned imax = m_Pcb->GetAreaCount();
@ -1207,94 +1198,88 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
if( !Block_Include_Edges_Items ) if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER; masque_layer &= ~EDGE_LAYER;
PtStruct = m_Pcb->m_Drawings; for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() )
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
switch( PtStruct->Type() ) switch( item->Type() )
{
case TYPEDRAWSEGMENT:
{
#undef STRUCT
#define STRUCT ( (DRAWSEGMENT*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
break;
/* l'element est ici bon a etre copie */
DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb );
new_drawsegment->Copy( STRUCT );
new_drawsegment->SetNext( m_Pcb->m_Drawings );
new_drawsegment->SetBack( m_Pcb );
m_Pcb->m_Drawings->SetBack( new_drawsegment );
m_Pcb->m_Drawings = new_drawsegment;
new_drawsegment->m_Start += MoveVector;
new_drawsegment->m_End += MoveVector;
new_drawsegment->Draw( DrawPanel, DC, GR_OR );
break;
}
case TYPETEXTE:
{ {
case TYPE_DRAWSEGMENT:
{
#undef STRUCT #undef STRUCT
#define STRUCT ( (TEXTE_PCB*) PtStruct ) #define STRUCT ( (DRAWSEGMENT*) item )
if( !Block_Include_PcbTextes ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->BlockLocate ) )
break; break;
/* le texte est ici bon a etre deplace */
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb );
new_pcbtext->Copy( STRUCT );
new_pcbtext->SetNext( m_Pcb->m_Drawings );
new_pcbtext->SetBack( m_Pcb );
m_Pcb->m_Drawings->SetBack( new_pcbtext );
m_Pcb->m_Drawings = new_pcbtext;
/* Redessin du Texte */
new_pcbtext->m_Pos += MoveVector;
new_pcbtext->Draw( DrawPanel, DC, GR_OR );
break;
}
case TYPEMIRE: /* l'element est ici bon a etre copie */
{ DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb );
#undef STRUCT new_drawsegment->Copy( STRUCT );
#define STRUCT ( (MIREPCB*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
break;
/* l'element est ici bon a etre efface */
MIREPCB* new_mire = new MIREPCB( m_Pcb );
new_mire->Copy( STRUCT );
new_mire->SetNext( m_Pcb->m_Drawings );
new_mire->SetBack( m_Pcb );
m_Pcb->m_Drawings->SetBack( new_mire );
m_Pcb->m_Drawings = new_mire;
new_mire->m_Pos += MoveVector;
new_mire->Draw( DrawPanel, DC, GR_OR );
break;
}
case TYPECOTATION: m_Pcb->Add( new_drawsegment );
{
#undef STRUCT new_drawsegment->m_Start += MoveVector;
#define STRUCT ( (COTATION*) PtStruct ) new_drawsegment->m_End += MoveVector;
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) new_drawsegment->Draw( DrawPanel, DC, GR_OR );
break; }
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) break;
break;
/* l'element est ici bon a etre copie */ case TYPE_TEXTE:
COTATION* new_cotation = new COTATION( m_Pcb ); {
new_cotation->Copy( STRUCT ); #undef STRUCT
new_cotation->SetNext( m_Pcb->m_Drawings ); #define STRUCT ( (TEXTE_PCB*) item )
new_cotation->SetBack( m_Pcb ); if( !Block_Include_PcbTextes )
m_Pcb->m_Drawings->SetBack( new_cotation ); break;
m_Pcb->m_Drawings = new_cotation; if( ! item->HitTest( GetScreen()->BlockLocate ) )
new_cotation->Move( MoveVector ); break;
new_cotation->Draw( DrawPanel, DC, GR_OR ); /* le texte est ici bon a etre deplace */
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb );
new_pcbtext->Copy( STRUCT );
m_Pcb->Add( new_pcbtext );
/* Redessin du Texte */
new_pcbtext->m_Pos += MoveVector;
new_pcbtext->Draw( DrawPanel, DC, GR_OR );
}
break;
case TYPE_MIRE:
{
#undef STRUCT
#define STRUCT ( (MIREPCB*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->BlockLocate ) )
break;
/* l'element est ici bon a etre efface */
MIREPCB* new_mire = new MIREPCB( m_Pcb );
new_mire->Copy( STRUCT );
m_Pcb->Add( new_mire );
new_mire->m_Pos += MoveVector;
new_mire->Draw( DrawPanel, DC, GR_OR );
}
break;
case TYPE_COTATION:
{
#undef STRUCT
#define STRUCT ( (COTATION*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break;
if( ! item->HitTest( GetScreen()->BlockLocate ) )
break;
/* l'element est ici bon a etre copie */
COTATION* new_cotation = new COTATION( m_Pcb );
new_cotation->Copy( STRUCT );
m_Pcb->Add( new_cotation );
new_cotation->Move( MoveVector );
new_cotation->Draw( DrawPanel, DC, GR_OR );
}
break; break;
}
default: default:
break; break;

View File

@ -319,8 +319,8 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
switch( item->Type() ) switch( item->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
item->Draw( panel, DC, g_XorMode, move_offset ); item->Draw( panel, DC, g_XorMode, move_offset );
break; break;
@ -361,8 +361,8 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
switch( item->Type() ) switch( item->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
item->Draw( panel, DC, g_XorMode, move_offset ); item->Draw( panel, DC, g_XorMode, move_offset );
break; break;
@ -389,14 +389,10 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
/* Copy marked items, at new position = old position + offset /* Copy marked items, at new position = old position + offset
*/ */
{ {
BOARD_ITEM* item;
BOARD_ITEM* NewStruct;
if( module == NULL ) if( module == NULL )
return; return;
D_PAD* pad = module->m_Pads; for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
for( ; pad != NULL; pad = pad->Next() )
{ {
if( pad->m_Selected == 0 ) if( pad->m_Selected == 0 )
continue; continue;
@ -404,44 +400,38 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
D_PAD* NewPad = new D_PAD( module ); D_PAD* NewPad = new D_PAD( module );
NewPad->Copy( pad ); NewPad->Copy( pad );
NewPad->m_Selected = IS_SELECTED; NewPad->m_Selected = IS_SELECTED;
NewPad->SetNext( module->m_Pads ); module->m_Pads.PushBack( NewPad );
NewPad->SetBack( module );
module->m_Pads->SetBack( NewPad );
module->m_Pads = NewPad;
} }
item = module->m_Drawings; for( BOARD_ITEM* item = module->m_Drawings; item; item->Next() )
for( ; item != NULL; item = item->Next() )
{ {
if( item->m_Selected == 0 ) if( item->m_Selected == 0 )
continue; continue;
item->m_Selected = 0; item->m_Selected = 0;
NewStruct = NULL;
switch( item->Type() ) switch( item->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
NewStruct = new TEXTE_MODULE( module ); TEXTE_MODULE* textm;
( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) item ); textm = new TEXTE_MODULE( module );
textm->Copy( (TEXTE_MODULE*) item );
textm->m_Selected = IS_SELECTED;
module->m_Drawings.PushFront( textm );
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
NewStruct = new EDGE_MODULE( module ); EDGE_MODULE* edge;
( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) item ); edge = new EDGE_MODULE( module );
edge->Copy( (EDGE_MODULE*) item );
edge->m_Selected = IS_SELECTED;
module->m_Drawings.PushFront( edge );
break; break;
default: default:
DisplayError( NULL, wxT( "Internal Err: CopyMarkedItems: type indefini" ) ); DisplayError( NULL, wxT( "Internal Err: CopyMarkedItems: type indefini" ) );
break; break;
} }
if( NewStruct == NULL )
break;
NewStruct->m_Selected = IS_SELECTED;
NewStruct->SetNext( module->m_Drawings );
NewStruct->SetBack( module );
module->m_Drawings->SetBack( module );
module->m_Drawings = NewStruct;
} }
MoveMarkedItems( module, offset ); MoveMarkedItems( module, offset );
@ -479,14 +469,14 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() ) switch( item->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
( (TEXTE_MODULE*) item )->GetPosition().x += offset.x; ( (TEXTE_MODULE*) item )->GetPosition().x += offset.x;
( (TEXTE_MODULE*) item )->GetPosition().y += offset.y; ( (TEXTE_MODULE*) item )->GetPosition().y += offset.y;
( (TEXTE_MODULE*) item )->m_Pos0.x += offset.x; ( (TEXTE_MODULE*) item )->m_Pos0.x += offset.x;
( (TEXTE_MODULE*) item )->m_Pos0.y += offset.y; ( (TEXTE_MODULE*) item )->m_Pos0.y += offset.y;
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
( (EDGE_MODULE*) item )->m_Start.x += offset.x; ( (EDGE_MODULE*) item )->m_Start.x += offset.x;
( (EDGE_MODULE*) item )->m_Start.y += offset.y; ( (EDGE_MODULE*) item )->m_Start.y += offset.y;
@ -578,7 +568,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
SETMIRROR( ( (EDGE_MODULE*) item )->m_Start.x ); SETMIRROR( ( (EDGE_MODULE*) item )->m_Start.x );
( (EDGE_MODULE*) item )->m_Start0.x = ( (EDGE_MODULE*) item )->m_Start.x; ( (EDGE_MODULE*) item )->m_Start0.x = ( (EDGE_MODULE*) item )->m_Start.x;
SETMIRROR( ( (EDGE_MODULE*) item )->m_End.x ); SETMIRROR( ( (EDGE_MODULE*) item )->m_End.x );
@ -586,7 +576,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
( (EDGE_MODULE*) item )->m_Angle = -( (EDGE_MODULE*) item )->m_Angle; ( (EDGE_MODULE*) item )->m_Angle = -( (EDGE_MODULE*) item )->m_Angle;
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x ); SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x );
( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x; ( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x;
break; break;
@ -632,14 +622,14 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
ROTATE( ( (EDGE_MODULE*) item )->m_Start ); ROTATE( ( (EDGE_MODULE*) item )->m_Start );
( (EDGE_MODULE*) item )->m_Start0 = ( (EDGE_MODULE*) item )->m_Start; ( (EDGE_MODULE*) item )->m_Start0 = ( (EDGE_MODULE*) item )->m_Start;
ROTATE( ( (EDGE_MODULE*) item )->m_End ); ROTATE( ( (EDGE_MODULE*) item )->m_End );
( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End; ( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End;
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() ); ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() );
( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition(); ( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition();
( (TEXTE_MODULE*) item )->m_Orient += 900; ( (TEXTE_MODULE*) item )->m_Orient += 900;
@ -708,7 +698,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
pos = ( (EDGE_MODULE*) item )->m_Start; pos = ( (EDGE_MODULE*) item )->m_Start;
if( Rect.Inside( pos ) ) if( Rect.Inside( pos ) )
{ {
@ -723,7 +713,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
} }
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
pos = ( (TEXTE_MODULE*) item )->GetPosition(); pos = ( (TEXTE_MODULE*) item )->GetPosition();
if( Rect.Inside( pos ) ) if( Rect.Inside( pos ) )
{ {

View File

@ -167,7 +167,7 @@ void BOARDHEAD::UnInitBoard()
/*****************************************************/ /*****************************************************/
void PlaceCells( BOARD* Pcb, int net_code, int flag ) void PlaceCells( BOARD* aPcb, int net_code, int flag )
/*****************************************************/ /*****************************************************/
/* Initialise les cellules du board a la valeur HOLE et VIA_IMPOSSIBLE /* Initialise les cellules du board a la valeur HOLE et VIA_IMPOSSIBLE
@ -182,12 +182,6 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag )
* si FORCE_PADS : tous les pads seront places meme ceux de meme net_code * si FORCE_PADS : tous les pads seront places meme ceux de meme net_code
*/ */
{ {
int ii;
LISTE_PAD* ptr;
TRACK* pt_segm;
TEXTE_PCB* PtText;
DRAWSEGMENT* DrawSegm;
BOARD_ITEM* PtStruct;
int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy; int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy;
int marge, via_marge; int marge, via_marge;
int masque_layer; int masque_layer;
@ -198,47 +192,50 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag )
///////////////////////////////////// /////////////////////////////////////
// Placement des PADS sur le board // // Placement des PADS sur le board //
///////////////////////////////////// /////////////////////////////////////
ptr = (LISTE_PAD*) Pcb->m_Pads; ii = Pcb->m_NbPads;
for( ; ii > 0; ii--, ptr++ ) for( unsigned i=0; i<aPcb->m_Pads.size(); ++i )
{ {
if( (net_code != (*ptr)->GetNet() ) || (flag & FORCE_PADS) ) D_PAD* pad = aPcb->m_Pads[i];
if( net_code != pad->GetNet() || (flag & FORCE_PADS) )
{ {
Place_1_Pad_Board( Pcb, *ptr, HOLE, marge, WRITE_CELL ); Place_1_Pad_Board( aPcb, pad, HOLE, marge, WRITE_CELL );
} }
Place_1_Pad_Board( Pcb, *ptr, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); Place_1_Pad_Board( aPcb, pad, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
} }
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Placement des elements de modules sur PCB // // Placement des elements de modules sur PCB //
/////////////////////////////////////////////// ///////////////////////////////////////////////
PtStruct = Pcb->m_Modules; for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
BOARD_ITEM* PtModStruct = ( (MODULE*) PtStruct )->m_Drawings; for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() )
for( ; PtModStruct != NULL; PtModStruct = PtModStruct->Next() )
{ {
switch( PtModStruct->Type() ) switch( item->Type() )
{ {
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
{ {
TRACK* TmpSegm = new TRACK( NULL ); EDGE_MODULE* edge = (EDGE_MODULE*) item;
TmpSegm->SetLayer( ( (EDGE_MODULE*) PtModStruct )->GetLayer() );
if( TmpSegm->GetLayer() == EDGE_N )
TmpSegm->SetLayer( -1 );
TmpSegm->m_Start = ( (EDGE_MODULE*) PtModStruct )->m_Start; TRACK* TmpSegm = new TRACK( NULL );
TmpSegm->m_End = ( (EDGE_MODULE*) PtModStruct )->m_End;
TmpSegm->m_Shape = ( (EDGE_MODULE*) PtModStruct )->m_Shape;
TmpSegm->m_Width = ( (EDGE_MODULE*) PtModStruct )->m_Width;
TmpSegm->m_Param = ( (EDGE_MODULE*) PtModStruct )->m_Angle;
TmpSegm->SetNet( -1 );
TraceSegmentPcb( Pcb, TmpSegm, HOLE, marge, WRITE_CELL ); TmpSegm->SetLayer( edge->GetLayer() );
TraceSegmentPcb( Pcb, TmpSegm, VIA_IMPOSSIBLE, via_marge, if( TmpSegm->GetLayer() == EDGE_N )
WRITE_OR_CELL ); TmpSegm->SetLayer( -1 );
delete TmpSegm;
TmpSegm->m_Start = edge->m_Start;
TmpSegm->m_End = edge->m_End;
TmpSegm->m_Shape = edge->m_Shape;
TmpSegm->m_Width = edge->m_Width;
TmpSegm->m_Param = edge->m_Angle;
TmpSegm->SetNet( -1 );
TraceSegmentPcb( aPcb, TmpSegm, HOLE, marge, WRITE_CELL );
TraceSegmentPcb( aPcb, TmpSegm, VIA_IMPOSSIBLE, via_marge,
WRITE_OR_CELL );
delete TmpSegm;
}
break; break;
}
default: default:
break; break;
@ -249,57 +246,67 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag )
//////////////////////////////////////////// ////////////////////////////////////////////
// Placement des contours et segments PCB // // Placement des contours et segments PCB //
//////////////////////////////////////////// ////////////////////////////////////////////
PtStruct = Pcb->m_Drawings; for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() )
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
switch( PtStruct->Type() ) switch( item->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
{
int type_cell = HOLE;
TRACK* TmpSegm = new TRACK( NULL );
DrawSegm = (DRAWSEGMENT*) PtStruct;
TmpSegm->SetLayer( DrawSegm->GetLayer() );
if( DrawSegm->GetLayer() == EDGE_N )
{ {
TmpSegm->SetLayer( -1 ); DRAWSEGMENT* DrawSegm;
type_cell |= CELL_is_EDGE;
int type_cell = HOLE;
TRACK* TmpSegm = new TRACK( NULL );
DrawSegm = (DRAWSEGMENT*) item;
TmpSegm->SetLayer( DrawSegm->GetLayer() );
if( DrawSegm->GetLayer() == EDGE_N )
{
TmpSegm->SetLayer( -1 );
type_cell |= CELL_is_EDGE;
}
TmpSegm->m_Start = DrawSegm->m_Start;
TmpSegm->m_End = DrawSegm->m_End;
TmpSegm->m_Shape = DrawSegm->m_Shape;
TmpSegm->m_Width = DrawSegm->m_Width;
TmpSegm->m_Param = DrawSegm->m_Angle;
TmpSegm->SetNet( -1 );
TraceSegmentPcb( aPcb, TmpSegm, type_cell, marge, WRITE_CELL );
// TraceSegmentPcb(Pcb, TmpSegm, VIA_IMPOSSIBLE, via_marge,WRITE_OR_CELL );
delete TmpSegm;
} }
TmpSegm->m_Start = DrawSegm->m_Start;
TmpSegm->m_End = DrawSegm->m_End;
TmpSegm->m_Shape = DrawSegm->m_Shape;
TmpSegm->m_Width = DrawSegm->m_Width;
TmpSegm->m_Param = DrawSegm->m_Angle;
TmpSegm->SetNet( -1 );
TraceSegmentPcb( Pcb, TmpSegm, type_cell, marge, WRITE_CELL );
// TraceSegmentPcb(Pcb, TmpSegm, VIA_IMPOSSIBLE, via_marge,WRITE_OR_CELL );
delete TmpSegm;
break; break;
}
case TYPETEXTE: case TYPE_TEXTE:
PtText = (TEXTE_PCB*) PtStruct; TEXTE_PCB* PtText;
PtText = (TEXTE_PCB*) item;
if( PtText->GetLength() == 0 ) if( PtText->GetLength() == 0 )
break; break;
ux0 = PtText->m_Pos.x; uy0 = PtText->m_Pos.y; ux0 = PtText->m_Pos.x; uy0 = PtText->m_Pos.y;
dx = PtText->Pitch() * PtText->GetLength(); dx = PtText->Pitch() * PtText->GetLength();
dy = PtText->m_Size.y + PtText->m_Width; dy = PtText->m_Size.y + PtText->m_Width;
/* Put bounding box (rectangle) on matrix */ /* Put bounding box (rectangle) on matrix */
dx /= 2; dy /= 2; /* dx et dy = demi dimensionx X et Y */ dx /= 2;
ux1 = ux0 + dx; uy1 = uy0 + dy; dy /= 2; /* dx et dy = demi dimensionx X et Y */
ux0 -= dx; uy0 -= dy;
ux1 = ux0 + dx;
uy1 = uy0 + dy;
ux0 -= dx;
uy0 -= dy;
masque_layer = g_TabOneLayerMask[PtText->GetLayer()]; masque_layer = g_TabOneLayerMask[PtText->GetLayer()];
TraceFilledRectangle( Pcb, ux0 - marge, uy0 - marge, ux1 + marge, uy1 + marge, TraceFilledRectangle( aPcb, ux0 - marge, uy0 - marge, ux1 + marge, uy1 + marge,
(int) (PtText->m_Orient), (int) (PtText->m_Orient),
masque_layer, HOLE, WRITE_CELL ); masque_layer, HOLE, WRITE_CELL );
TraceFilledRectangle( Pcb, ux0 - via_marge, uy0 - via_marge,
TraceFilledRectangle( aPcb, ux0 - via_marge, uy0 - via_marge,
ux1 + via_marge, uy1 + via_marge, ux1 + via_marge, uy1 + via_marge,
(int) (PtText->m_Orient), (int) (PtText->m_Orient),
masque_layer, VIA_IMPOSSIBLE, WRITE_OR_CELL ); masque_layer, VIA_IMPOSSIBLE, WRITE_OR_CELL );
@ -311,24 +318,23 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag )
} }
/* Put tracks and vias on matrix */ /* Put tracks and vias on matrix */
pt_segm = Pcb->m_Track; for( TRACK* track = aPcb->m_Track; track; track = track->Next() )
for( ; pt_segm != NULL; pt_segm = pt_segm->Next() )
{ {
if( net_code == pt_segm->GetNet() ) if( net_code == track->GetNet() )
continue; continue;
TraceSegmentPcb( Pcb, pt_segm, HOLE, marge, WRITE_CELL ); TraceSegmentPcb( aPcb, track, HOLE, marge, WRITE_CELL );
TraceSegmentPcb( Pcb, pt_segm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); TraceSegmentPcb( aPcb, track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
} }
/* Put zone filling on matrix */ // Put zone filling on matrix
pt_segm = (TRACK*) Pcb->m_Zone; for( SEGZONE* zone = aPcb->m_Zone; zone; zone = zone->Next() )
for( ; pt_segm != NULL; pt_segm = pt_segm->Next() )
{ {
if( net_code == pt_segm->GetNet() ) if( net_code == zone->GetNet() )
continue; continue;
TraceSegmentPcb( Pcb, pt_segm, HOLE, marge, WRITE_CELL );
TraceSegmentPcb( Pcb, pt_segm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); TraceSegmentPcb( aPcb, zone, HOLE, marge, WRITE_CELL );
TraceSegmentPcb( aPcb, zone, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
} }
} }

View File

@ -30,30 +30,20 @@ void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/* Constructor */ /* Constructor */
BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) : BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
BOARD_ITEM( (BOARD_ITEM*) parent, TYPEPCB ) BOARD_ITEM( (BOARD_ITEM*) parent, TYPE_PCB )
{ {
m_PcbFrame = frame; m_PcbFrame = frame;
m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule
m_NbNets = 0; // Nombre de nets (equipotentielles)
m_BoardSettings = &g_DesignSettings; m_BoardSettings = &g_DesignSettings;
m_NbPads = 0; // nombre total de pads
m_NbNodes = 0; // nombre de pads connectes m_NbNodes = 0; // nombre de pads connectes
m_NbLinks = 0; // nombre de chevelus (donc aussi nombre m_NbLinks = 0; // nombre de chevelus (donc aussi nombre
// minimal de pistes a tracer // minimal de pistes a tracer
m_NbSegmTrack = 0; // nombre d'elements de type segments de piste
m_NbSegmZone = 0; // nombre d'elements de type segments de zone
m_NbNoconnect = 0; // nombre de chevelus actifs m_NbNoconnect = 0; // nombre de chevelus actifs
m_NbLoclinks = 0; // nb ratsnest local m_NbLoclinks = 0; // nb ratsnest local
m_Drawings = NULL; // pointeur sur liste drawings
m_Modules = NULL; // pointeur sur liste zone modules
m_Equipots = NULL; // pointeur liste zone equipot
m_Track = NULL; // pointeur relatif zone piste
m_Zone = NULL; // pointeur tableau zone zones de cuivre
m_Pads = NULL; // pointeur liste d'acces aux pads
m_Ratsnest = NULL; // pointeur liste rats m_Ratsnest = NULL; // pointeur liste rats
m_LocalRatsnest = NULL; // pointeur liste rats local m_LocalRatsnest = NULL; // pointeur liste rats local
m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the zone contour currently in progress m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the zone contour cuurently in progress
// de determination des contours de zone // de determination des contours de zone
for( int layer=0; layer<NB_COPPER_LAYERS; ++layer ) for( int layer=0; layer<NB_COPPER_LAYERS; ++layer )
@ -69,31 +59,12 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
/***************/ /***************/
BOARD::~BOARD() BOARD::~BOARD()
{ {
m_Drawings->DeleteStructList();
m_Drawings = 0;
m_Modules->DeleteStructList();
m_Modules = 0;
m_Equipots->DeleteStructList();
m_Equipots = 0;
m_Track->DeleteStructList();
m_Track = 0;
m_Zone->DeleteStructList();
m_Zone = 0;
while ( m_ZoneDescriptorList.size() ) while ( m_ZoneDescriptorList.size() )
{ {
ZONE_CONTAINER* area_to_remove = m_ZoneDescriptorList[0]; ZONE_CONTAINER* area_to_remove = m_ZoneDescriptorList[0];
Delete( area_to_remove ); Delete( area_to_remove );
} }
MyFree( m_Pads );
m_Pads = 0;
MyFree( m_Ratsnest ); MyFree( m_Ratsnest );
m_Ratsnest = 0; m_Ratsnest = 0;
@ -226,7 +197,7 @@ void BOARD::UnLink()
/* Update back link */ /* Update back link */
if( Back() ) if( Back() )
{ {
if( Back()->Type() == TYPEPCB ) if( Back()->Type() == TYPE_PCB )
{ {
Back()->SetNext( Next() ); Back()->SetNext( Next() );
} }
@ -252,47 +223,59 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
// this one uses a vector // this one uses a vector
case TYPEMARKER: case TYPE_MARKER:
aBoardItem->SetParent( this ); aBoardItem->SetParent( this );
m_markers.push_back( (MARKER*) aBoardItem ); m_markers.push_back( (MARKER*) aBoardItem );
break; break;
// this one uses a vector // this one uses a vector
case TYPEZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
aBoardItem->SetParent( this ); aBoardItem->SetParent( this );
m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem ); m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem );
break; break;
case TYPETRACK: case TYPE_TRACK:
case TYPEVIA: case TYPE_VIA:
{ {
TRACK* insertAid = ((TRACK*)aBoardItem)->GetBestInsertPoint( this ); TRACK* insertAid = ((TRACK*)aBoardItem)->GetBestInsertPoint( this );
((TRACK*)aBoardItem)->Insert( this, insertAid ); m_Track.Insert( (TRACK*)aBoardItem, insertAid );
} }
break; break;
case TYPEZONE: case TYPE_ZONE:
{ // Add item to head of list (starting in m_Zone) if( aControl & ADD_APPEND )
aBoardItem->SetParent( this ); m_Zone.PushBack( (SEGZONE*) aBoardItem );
aBoardItem->SetBack( this ); // item will be the first item: back chain to the board else
BOARD_ITEM* next_item = m_Zone; // Remember old the first item m_Zone.PushFront( (SEGZONE*) aBoardItem );
aBoardItem->SetNext( next_item ); // Chain the new one ton the old item aBoardItem->SetParent( this );
if( next_item ) // Back chain the old item to the new one
next_item->SetBack( aBoardItem );
m_Zone = (SEGZONE*) aBoardItem; // Add to head of list
}
break; break;
case TYPEMODULE: case TYPE_MODULE:
// this is an insert, not an append which may also be needed. if( aControl & ADD_APPEND )
{ m_Modules.PushBack( (MODULE*) aBoardItem );
aBoardItem->SetBack( this ); else
BOARD_ITEM* next = m_Modules; m_Modules.PushFront( (MODULE*) aBoardItem );
aBoardItem->SetNext( next ); aBoardItem->SetParent( this );
if( next ) break;
next->SetBack( aBoardItem );
m_Modules = (MODULE*) aBoardItem; case TYPE_COTATION:
} case TYPE_DRAWSEGMENT:
case TYPE_TEXTE:
case TYPE_EDGE_MODULE:
case TYPE_MIRE:
if( aControl & ADD_APPEND )
m_Drawings.PushBack( aBoardItem );
else
m_Drawings.PushFront( aBoardItem );
aBoardItem->SetParent( this );
break;
case TYPE_EQUIPOT:
if( aControl & ADD_APPEND )
m_Equipots.PushBack( (EQUIPOT*) aBoardItem );
else
m_Equipots.PushFront( (EQUIPOT*) aBoardItem );
aBoardItem->SetParent( this );
break; break;
// other types may use linked list // other types may use linked list
@ -308,7 +291,7 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem )
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
case TYPEMARKER: // this one uses a vector case TYPE_MARKER: // this one uses a vector
// find the item in the vector, then delete then erase it. // find the item in the vector, then delete then erase it.
for( unsigned i=0; i<m_markers.size(); ++i ) for( unsigned i=0; i<m_markers.size(); ++i )
{ {
@ -320,7 +303,7 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem )
} }
break; break;
case TYPEZONE_CONTAINER: // this one uses a vector case TYPE_ZONE_CONTAINER: // this one uses a vector
// find the item in the vector, then delete then erase it. // find the item in the vector, then delete then erase it.
for( unsigned i=0; i<m_ZoneDescriptorList.size(); ++i ) for( unsigned i=0; i<m_ZoneDescriptorList.size(); ++i )
{ {
@ -372,28 +355,14 @@ void BOARD::DeleteZONEOutlines()
/* Calculate the track segment count */ /* Calculate the track segment count */
int BOARD::GetNumSegmTrack() int BOARD::GetNumSegmTrack()
{ {
TRACK* CurTrack = m_Track; return m_Track.GetCount();
int ii = 0;
for( ; CurTrack != NULL; CurTrack = CurTrack->Next() )
ii++;
m_NbSegmTrack = ii;
return ii;
} }
/* Calculate the zone segment count */ /* Calculate the zone segment count */
int BOARD::GetNumSegmZone() int BOARD::GetNumSegmZone()
{ {
TRACK* CurTrack = m_Zone; return m_Zone.GetCount();
int ii = 0;
for( ; CurTrack != NULL; CurTrack = CurTrack->Next() )
ii++;
m_NbSegmZone = ii;
return ii;
} }
@ -435,7 +404,7 @@ bool BOARD::ComputeBoundaryBox()
PtStruct = m_Drawings; PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
if( PtStruct->Type() != TYPEDRAWSEGMENT ) if( PtStruct->Type() != TYPE_DRAWSEGMENT )
continue; continue;
ptr = (DRAWSEGMENT*) PtStruct; ptr = (DRAWSEGMENT*) PtStruct;
@ -560,13 +529,13 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame )
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
txt.Printf( wxT( "%d" ), m_NbPads ); txt.Printf( wxT( "%d" ), m_Pads.size() );
Affiche_1_Parametre( frame, POS_AFF_NBPADS, _( "Pads" ), txt, DARKGREEN ); Affiche_1_Parametre( frame, POS_AFF_NBPADS, _( "Pads" ), txt, DARKGREEN );
int nb_vias = 0; int nb_vias = 0;
for( BOARD_ITEM* item = m_Track; item; item = item->Next() ) for( BOARD_ITEM* item = m_Track; item; item = item->Next() )
{ {
if( item->Type() == TYPEVIA ) if( item->Type() == TYPE_VIA )
nb_vias++; nb_vias++;
} }
@ -579,7 +548,7 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame )
txt.Printf( wxT( "%d" ), m_NbLinks ); txt.Printf( wxT( "%d" ), m_NbLinks );
Affiche_1_Parametre( frame, POS_AFF_NBLINKS, _( "Links" ), txt, DARKGREEN ); Affiche_1_Parametre( frame, POS_AFF_NBLINKS, _( "Links" ), txt, DARKGREEN );
txt.Printf( wxT( "%d" ), m_NbNets ); txt.Printf( wxT( "%d" ), m_Equipots.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_NBNETS, _( "Nets" ), txt, RED ); Affiche_1_Parametre( frame, POS_AFF_NBNETS, _( "Nets" ), txt, RED );
txt.Printf( wxT( "%d" ), m_NbLinks - GetNumNoconnect() ); txt.Printf( wxT( "%d" ), m_NbLinks - GetNumNoconnect() );
@ -608,7 +577,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
stype = *p; stype = *p;
switch( stype ) switch( stype )
{ {
case TYPEPCB: case TYPE_PCB:
result = inspector->Inspect( this, testData ); // inspect me result = inspector->Inspect( this, testData ); // inspect me
// skip over any types handled in the above call. // skip over any types handled in the above call.
++p; ++p;
@ -621,10 +590,10 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
IterateForward( m_Modules, ... ) call. IterateForward( m_Modules, ... ) call.
*/ */
case TYPEMODULE: case TYPE_MODULE:
case TYPEPAD: case TYPE_PAD:
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
// this calls MODULE::Visit() on each module. // this calls MODULE::Visit() on each module.
result = IterateForward( m_Modules, inspector, testData, p ); result = IterateForward( m_Modules, inspector, testData, p );
// skip over any types handled in the above call. // skip over any types handled in the above call.
@ -632,10 +601,10 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
{ {
switch( stype = *++p ) switch( stype = *++p )
{ {
case TYPEMODULE: case TYPE_MODULE:
case TYPEPAD: case TYPE_PAD:
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
continue; continue;
default:; default:;
} }
@ -643,20 +612,20 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
} }
break; break;
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPETEXTE: case TYPE_TEXTE:
case TYPECOTATION: case TYPE_COTATION:
case TYPEMIRE: case TYPE_MIRE:
result = IterateForward( m_Drawings, inspector, testData, p ); result = IterateForward( m_Drawings, inspector, testData, p );
// skip over any types handled in the above call. // skip over any types handled in the above call.
for(;;) for(;;)
{ {
switch( stype = *++p ) switch( stype = *++p )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPETEXTE: case TYPE_TEXTE:
case TYPECOTATION: case TYPE_COTATION:
case TYPEMIRE: case TYPE_MIRE:
continue; continue;
default:; default:;
} }
@ -678,16 +647,16 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
// Usually, because of this sort, a connected item (if exists) is found. // Usually, because of this sort, a connected item (if exists) is found.
// If not found (and only in this case) an exhaustive (and time consumming) search is made, // If not found (and only in this case) an exhaustive (and time consumming) search is made,
// but this case is statistically rare. // but this case is statistically rare.
case TYPEVIA: case TYPE_VIA:
case TYPETRACK: case TYPE_TRACK:
result = IterateForward( m_Track, inspector, testData, p ); result = IterateForward( m_Track, inspector, testData, p );
// skip over any types handled in the above call. // skip over any types handled in the above call.
for(;;) for(;;)
{ {
switch( stype = *++p ) switch( stype = *++p )
{ {
case TYPEVIA: case TYPE_VIA:
case TYPETRACK: case TYPE_TRACK:
continue; continue;
default:; default:;
} }
@ -695,18 +664,18 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
} }
break; break;
#else #else
case TYPEVIA: case TYPE_VIA:
result = IterateForward( m_Track, inspector, testData, p ); result = IterateForward( m_Track, inspector, testData, p );
++p; ++p;
break; break;
case TYPETRACK: case TYPE_TRACK:
result = IterateForward( m_Track, inspector, testData, p ); result = IterateForward( m_Track, inspector, testData, p );
++p; ++p;
break; break;
#endif #endif
case TYPEMARKER: case TYPE_MARKER:
// MARKERS are in the m_markers std::vector // MARKERS are in the m_markers std::vector
for( unsigned i=0; i<m_markers.size(); ++i ) for( unsigned i=0; i<m_markers.size(); ++i )
{ {
@ -717,8 +686,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
++p; ++p;
break; break;
case TYPEZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
// TYPEZONE_CONTAINER are in the m_ZoneDescriptorList std::vector // TYPE_ZONE_CONTAINER are in the m_ZoneDescriptorList std::vector
for( unsigned i=0; i< m_ZoneDescriptorList.size(); ++i ) for( unsigned i=0; i< m_ZoneDescriptorList.size(); ++i )
{ {
result = m_ZoneDescriptorList[i]->Visit( inspector, testData, p ); result = m_ZoneDescriptorList[i]->Visit( inspector, testData, p );
@ -728,17 +697,17 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
++p; ++p;
break; break;
case PCB_EQUIPOT_STRUCT_TYPE: case TYPE_EQUIPOT:
result = IterateForward( m_Equipots, inspector, testData, p ); result = IterateForward( m_Equipots, inspector, testData, p );
++p; ++p;
break; break;
case TYPEZONE: case TYPE_ZONE:
result = IterateForward( m_Zone, inspector, testData, p ); result = IterateForward( m_Zone, inspector, testData, p );
++p; ++p;
break; break;
case TYPEZONE_UNUSED: // Unused type case TYPE_ZONE_UNUSED: // Unused type
break; break;
default: // catch EOT or ANY OTHER type here and return. default: // catch EOT or ANY OTHER type here and return.
@ -775,7 +744,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
BOARD_ITEM* item = (BOARD_ITEM*) testItem; BOARD_ITEM* item = (BOARD_ITEM*) testItem;
const wxPoint& refPos = *(const wxPoint*) testData; const wxPoint& refPos = *(const wxPoint*) testData;
if( item->Type() == TYPEPAD ) if( item->Type() == TYPE_PAD )
{ {
D_PAD* pad = (D_PAD*) item; D_PAD* pad = (D_PAD*) item;
if( pad->HitTest( refPos ) ) if( pad->HitTest( refPos ) )
@ -794,7 +763,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
} }
} }
else if( item->Type() == TYPEMODULE ) else if( item->Type() == TYPE_MODULE )
{ {
MODULE* module = (MODULE*) item; MODULE* module = (MODULE*) item;
@ -823,7 +792,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
PadOrModule inspector( layer ); PadOrModule inspector( layer );
// search only for PADs first, then MODULES, and preferably a layer match // search only for PADs first, then MODULES, and preferably a layer match
static const KICAD_T scanTypes[] = { TYPEPAD, TYPEMODULE, EOT }; static const KICAD_T scanTypes[] = { TYPE_PAD, TYPE_MODULE, EOT };
// visit this BOARD with the above inspector // visit this BOARD with the above inspector
Visit( &inspector, &refPos, scanTypes ); Visit( &inspector, &refPos, scanTypes );
@ -900,7 +869,7 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
} inspector; } inspector;
// search only for MODULES // search only for MODULES
static const KICAD_T scanTypes[] = { TYPEMODULE, EOT }; static const KICAD_T scanTypes[] = { TYPE_MODULE, EOT };
// visit this BOARD with the above inspector // visit this BOARD with the above inspector
BOARD* nonconstMe = (BOARD*) this; BOARD* nonconstMe = (BOARD*) this;
@ -1008,10 +977,10 @@ bool BOARD::Save( FILE* aFile ) const
{ {
switch( item->Type() ) switch( item->Type() )
{ {
case TYPETEXTE: case TYPE_TEXTE:
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPEMIRE: case TYPE_MIRE:
case TYPECOTATION: case TYPE_COTATION:
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
goto out; goto out;
break; break;

View File

@ -5,6 +5,10 @@
#ifndef CLASS_BOARD_H #ifndef CLASS_BOARD_H
#define CLASS_BOARD_H #define CLASS_BOARD_H
#include "dlist.h"
class ZONE_CONTAINER; class ZONE_CONTAINER;
class EDA_BoardDesignSettings; class EDA_BoardDesignSettings;
@ -80,27 +84,27 @@ public:
int m_Unused; int m_Unused;
int m_Status_Pcb; // Flags used in ratsnet calculation and update int m_Status_Pcb; // Flags used in ratsnet calculation and update
EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings
int m_NbNets; // Nets (equipotentielles) count
int m_NbNodes; // Active pads (pads attached to a net ) count int m_NbNodes; // Active pads (pads attached to a net ) count
int m_NbLinks; // Ratsnet count int m_NbLinks; // Ratsnet count
int m_NbLoclinks; // Rastests to shew while creating a track int m_NbLoclinks; // Rastests to shew while creating a track
int m_NbNoconnect; // Active ratsnet count (rastnest not alraedy connected by tracks int m_NbNoconnect; // Active ratsnet count (rastnest not alraedy connected by tracks
int m_NbSegmTrack; // Track items count
int m_NbSegmZone; // Zone items count
BOARD_ITEM* m_Drawings; // linked list of lines & texts DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
MODULE* m_Modules; // linked list of MODULEs DLIST<MODULE> m_Modules; // linked list of MODULEs
EQUIPOT* m_Equipots; // linked list of nets DLIST<EQUIPOT> m_Equipots; // linked list of nets
TRACK* m_Track; // linked list of TRACKs and SEGVIAs
SEGZONE* m_Zone; // linked list of SEGZONEs DLIST<TRACK> m_Track; // linked list of TRACKs and SEGVIAs
D_PAD** m_Pads; // Entry for a sorted pad list (used in ratsnest calculations)
int m_NbPads; // Pad count DLIST<SEGZONE> m_Zone; // linked list of SEGZONEs
std::vector<D_PAD*> m_Pads; // Entry for a sorted pad list (used in ratsnest calculations)
CHEVELU* m_Ratsnest; // Rastnest list CHEVELU* m_Ratsnest; // Rastnest list
CHEVELU* m_LocalRatsnest; // Rastnest list used while moving a footprint CHEVELU* m_LocalRatsnest; // Rastnest list used while moving a footprint
ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress
BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame ); BOARD( EDA_BaseStruct* aParent, WinEDA_BasePcbFrame* frame );
~BOARD(); ~BOARD();
/** /**

View File

@ -12,8 +12,8 @@
#include "cvpcb.h" #include "cvpcb.h"
#endif #endif
BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* StructFather, KICAD_T idtype ) : BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype ) BOARD_ITEM( aParent, idtype )
{ {
m_NetCode = 0; m_NetCode = 0;
m_Subnet = 0; m_Subnet = 0;

View File

@ -36,6 +36,8 @@ wxString BOARD_ITEM::ShowShape( Track_Shapes aShape )
} }
#if !defined(GERBVIEW)
/********************************************************/ /********************************************************/
wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
/********************************************************/ /********************************************************/
@ -53,17 +55,17 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_EQUIPOT_STRUCT_TYPE: case TYPE_EQUIPOT:
text << _( "Net" ) << ( (EQUIPOT*) item )->m_Netname << wxT( " " ) << text << _( "Net" ) << ( (EQUIPOT*) item )->m_Netname << wxT( " " ) <<
( (EQUIPOT*) item )->GetNet(); ( (EQUIPOT*) item )->GetNet();
break; break;
case TYPEMODULE: case TYPE_MODULE:
text << _( "Footprint" ) << wxT( " " ) << ( (MODULE*) item )->GetReference(); text << _( "Footprint" ) << wxT( " " ) << ( (MODULE*) item )->GetReference();
text << wxT( " (" ) << aPcb->GetLayerName( item->m_Layer ).Trim() << wxT( ")" ); text << wxT( " (" ) << aPcb->GetLayerName( item->m_Layer ).Trim() << wxT( ")" );
break; break;
case TYPEPAD: case TYPE_PAD:
pad = (D_PAD *) this; pad = (D_PAD *) this;
text << _( "Pad" ) << wxT( " \"" ) << pad->ReturnStringPadName() text << _( "Pad" ) << wxT( " \"" ) << pad->ReturnStringPadName()
<< wxT( "\" (" ); << wxT( "\" (" );
@ -77,14 +79,14 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference(); text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference();
break; break;
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
text << _( "Pcb Graphic" ) << wxT(": ") text << _( "Pcb Graphic" ) << wxT(": ")
<< ShowShape( (Track_Shapes) ((DRAWSEGMENT*)item)->m_Shape ) << ShowShape( (Track_Shapes) ((DRAWSEGMENT*)item)->m_Shape )
<< wxChar(' ') << _("Length:") << valeur_param( (int) ((DRAWSEGMENT*)item)->GetLength(), temp ) << wxChar(' ') << _("Length:") << valeur_param( (int) ((DRAWSEGMENT*)item)->GetLength(), temp )
<< _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
break; break;
case TYPETEXTE: case TYPE_TEXTE:
text << _( "Pcb Text" ) << wxT( " " );; text << _( "Pcb Text" ) << wxT( " " );;
if( ( (TEXTE_PCB*) item )->m_Text.Len() < 12 ) if( ( (TEXTE_PCB*) item )->m_Text.Len() < 12 )
text << ( (TEXTE_PCB*) item )->m_Text; text << ( (TEXTE_PCB*) item )->m_Text;
@ -93,7 +95,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
switch( ( (TEXTE_MODULE*) item )->m_Type ) switch( ( (TEXTE_MODULE*) item )->m_Type )
{ {
case TEXT_is_REFERENCE: case TEXT_is_REFERENCE:
@ -113,7 +115,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
} }
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
text << _( "Graphic" ) << wxT( " " ); text << _( "Graphic" ) << wxT( " " );
text << ShowShape( (Track_Shapes) ( (EDGE_MODULE*) item )->m_Shape ); text << ShowShape( (Track_Shapes) ( (EDGE_MODULE*) item )->m_Shape );
text << wxT( " (" ) << aPcb->GetLayerName( ((EDGE_MODULE*) item )->m_Layer ).Trim() << wxT( ")" ); text << wxT( " (" ) << aPcb->GetLayerName( ((EDGE_MODULE*) item )->m_Layer ).Trim() << wxT( ")" );
@ -121,7 +123,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
<< ( (MODULE*) GetParent() )->GetReference(); << ( (MODULE*) GetParent() )->GetReference();
break; break;
case TYPETRACK: case TYPE_TRACK:
// deleting tracks requires all the information we can get to // deleting tracks requires all the information we can get to
// disambiguate all the choices under the cursor! // disambiguate all the choices under the cursor!
text << _( "Track" ) << wxT( " " ) << ((TRACK*)item)->ShowWidth(); text << _( "Track" ) << wxT( " " ) << ((TRACK*)item)->ShowWidth();
@ -135,7 +137,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
<< wxT(" ") << _("Length:") << valeur_param( (int) ((TRACK*)item)->GetLength(), temp ); << wxT(" ") << _("Length:") << valeur_param( (int) ((TRACK*)item)->GetLength(), temp );
break; break;
case TYPEZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
text = _( "Zone Outline" ); text = _( "Zone Outline" );
{ {
ZONE_CONTAINER* area = (ZONE_CONTAINER*) this; ZONE_CONTAINER* area = (ZONE_CONTAINER*) this;
@ -169,7 +171,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
break; break;
case TYPEZONE: case TYPE_ZONE:
text = _( "Zone" ); text = _( "Zone" );
text << wxT( " " ); text << wxT( " " );
{ {
@ -185,7 +187,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim();
break; break;
case TYPEVIA: case TYPE_VIA:
{ {
SEGVIA* via = (SEGVIA*) item; SEGVIA* via = (SEGVIA*) item;
text << _( "Via" ) << wxT( " " ) << via->ShowWidth(); text << _( "Via" ) << wxT( " " ) << via->ShowWidth();
@ -216,23 +218,23 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
} }
break; break;
case TYPEMARKER: case TYPE_MARKER:
text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->GetPos().x text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->GetPos().x
<< wxT(",") << ((MARKER*)item)->GetPos().y << wxT(")"); << wxT(",") << ((MARKER*)item)->GetPos().y << wxT(")");
break; break;
case TYPECOTATION: case TYPE_COTATION:
text << _( "Dimension" ) << wxT( " \"" ) << ( (COTATION*) item )->GetText() << wxT( "\"" ); text << _( "Dimension" ) << wxT( " \"" ) << ( (COTATION*) item )->GetText() << wxT( "\"" );
break; break;
case TYPEMIRE: case TYPE_MIRE:
valeur_param( ((MIREPCB*)item)->m_Size, msg ); valeur_param( ((MIREPCB*)item)->m_Size, msg );
text << _( "Target" ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim() text << _( "Target" ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim()
<< wxT( " " ) << _( "size" ) << wxT( " " ) << msg << wxT( " " ) << _( "size" ) << wxT( " " ) << msg
; ;
break; break;
case TYPEZONE_UNUSED: case TYPE_ZONE_UNUSED:
text << wxT( "Unused" ); text << wxT( "Unused" );
break; break;
@ -258,60 +260,60 @@ const char** BOARD_ITEM::MenuIcon() const
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_EQUIPOT_STRUCT_TYPE: case TYPE_EQUIPOT:
xpm = general_ratsnet_xpm; xpm = general_ratsnet_xpm;
break; break;
case TYPEMODULE: case TYPE_MODULE:
xpm = module_xpm; xpm = module_xpm;
break; break;
case TYPEPAD: case TYPE_PAD:
xpm = pad_xpm; xpm = pad_xpm;
break; break;
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
xpm = add_dashed_line_xpm; xpm = add_dashed_line_xpm;
break; break;
case TYPETEXTE: case TYPE_TEXTE:
xpm = add_text_xpm; xpm = add_text_xpm;
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
xpm = footprint_text_xpm; xpm = footprint_text_xpm;
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
xpm = show_mod_edge_xpm; xpm = show_mod_edge_xpm;
break; break;
case TYPETRACK: case TYPE_TRACK:
xpm = showtrack_xpm; xpm = showtrack_xpm;
break; break;
case TYPEZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
case TYPEZONE: case TYPE_ZONE:
xpm = add_zone_xpm; xpm = add_zone_xpm;
break; break;
case TYPEVIA: case TYPE_VIA:
xpm = pad_sketch_xpm; xpm = pad_sketch_xpm;
break; break;
case TYPEMARKER: case TYPE_MARKER:
xpm = pad_xpm; // @todo: create and use marker xpm xpm = pad_xpm; // @todo: create and use marker xpm
break; break;
case TYPECOTATION: case TYPE_COTATION:
xpm = add_cotation_xpm; xpm = add_cotation_xpm;
break; break;
case TYPEMIRE: case TYPE_MIRE:
xpm = add_mires_xpm; xpm = add_mires_xpm;
break; break;
case TYPEZONE_UNUSED: case TYPE_ZONE_UNUSED:
xpm = 0; // unused xpm = 0; // unused
break; break;
@ -323,3 +325,13 @@ const char** BOARD_ITEM::MenuIcon() const
return (const char**) xpm; return (const char**) xpm;
} }
#endif // !defined(GERBVIEW)
void BOARD_ITEM::UnLink()
{
DLIST<BOARD_ITEM>* list = (DLIST<BOARD_ITEM>*) GetList();
wxASSERT( list );
if( list )
list->Remove( this );
}

View File

@ -11,8 +11,8 @@
#include "wxstruct.h" #include "wxstruct.h"
COTATION::COTATION( BOARD_ITEM* StructFather ) : COTATION::COTATION( BOARD_ITEM* aParent ) :
BOARD_ITEM( StructFather, TYPECOTATION ) BOARD_ITEM( aParent, TYPE_COTATION )
{ {
m_Layer = DRAW_LAYER; m_Layer = DRAW_LAYER;
m_Width = 50; m_Width = 50;
@ -30,31 +30,6 @@ COTATION::~COTATION()
} }
/* supprime du chainage la structure Struct
* les structures arrieres et avant sont chainees directement
*/
void COTATION::UnLink()
{
if( Back() )
{
if( Back()->Type() != TYPEPCB )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
((BOARD*) Back() )->m_Drawings = Next();
}
}
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/* Setup the dimension text */ /* Setup the dimension text */
void COTATION:: SetText( const wxString& NewText ) void COTATION:: SetText( const wxString& NewText )
{ {

View File

@ -25,7 +25,7 @@ public:
int FlecheG2_ox, FlecheG2_oy, FlecheG2_fx, FlecheG2_fy; int FlecheG2_ox, FlecheG2_oy, FlecheG2_fx, FlecheG2_fy;
public: public:
COTATION( BOARD_ITEM* StructFather ); COTATION( BOARD_ITEM* aParent );
~COTATION(); ~COTATION();
COTATION* Next() const { return (COTATION*) Pnext; } COTATION* Next() const { return (COTATION*) Pnext; }
@ -47,9 +47,6 @@ public:
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/* supprime du chainage la structure Struct */
void UnLink();
/* Modification du texte de la cotation */ /* Modification du texte de la cotation */
void SetText( const wxString& NewText ); void SetText( const wxString& NewText );
wxString GetText( void ); wxString GetText( void );

View File

@ -17,8 +17,8 @@
#include "trigo.h" #include "trigo.h"
/* DRAWSEGMENT: constructor */ /* DRAWSEGMENT: constructor */
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype ) : DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype ) BOARD_ITEM( aParent, idtype )
{ {
m_Width = m_Flags = m_Shape = m_Type = m_Angle = 0; m_Width = m_Flags = m_Shape = m_Type = m_Angle = 0;
} }
@ -30,29 +30,6 @@ DRAWSEGMENT:: ~DRAWSEGMENT()
} }
void DRAWSEGMENT::UnLink()
{
if( Back() )
{
if( Back()->Type() != TYPEPCB )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Back() )->m_Drawings = Next();
}
}
/* erase forward link */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/*******************************************/ /*******************************************/
void DRAWSEGMENT::Copy( DRAWSEGMENT* source ) void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
/*******************************************/ /*******************************************/

View File

@ -17,7 +17,7 @@ public:
int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg
public: public:
DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT ); DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype = TYPE_DRAWSEGMENT );
~DRAWSEGMENT(); ~DRAWSEGMENT();
DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; } DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; }
@ -57,12 +57,6 @@ public:
bool ReadDrawSegmentDescr( FILE* File, int* LineNum ); bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
/**
* Function UnLink
* remove item from linked list.
*/
void UnLink();
void Copy( DRAWSEGMENT* source ); void Copy( DRAWSEGMENT* source );

View File

@ -29,7 +29,7 @@
/******************************************/ /******************************************/
EDGE_MODULE::EDGE_MODULE( MODULE* parent ) : EDGE_MODULE::EDGE_MODULE( MODULE* parent ) :
BOARD_ITEM( parent, TYPEEDGEMODULE ) BOARD_ITEM( parent, TYPE_EDGE_MODULE )
{ {
m_Width = 0; m_Width = 0;
m_Shape = S_SEGMENT; m_Shape = S_SEGMENT;
@ -78,33 +78,6 @@ void EDGE_MODULE:: Copy( EDGE_MODULE* source ) // copy structure
} }
} }
/********************************/
void EDGE_MODULE::UnLink()
/********************************/
{
/* Modification du chainage arriere */
if( Back() )
{
if( Back()->Type() != TYPEMODULE )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (MODULE*) Back() )->m_Drawings = Next();
}
}
/* Modification du chainage avant */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/***********************************/ /***********************************/
void EDGE_MODULE::SetDrawCoord() void EDGE_MODULE::SetDrawCoord()
/***********************************/ /***********************************/
@ -148,7 +121,7 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
WinEDA_BasePcbFrame* frame; WinEDA_BasePcbFrame* frame;
MODULE* Module = NULL; MODULE* Module = NULL;
if( m_Parent && (m_Parent->Type() == TYPEMODULE) ) if( m_Parent && (m_Parent->Type() == TYPE_MODULE) )
Module = (MODULE*) m_Parent; Module = (MODULE*) m_Parent;
color = g_DesignSettings.m_LayerColor[m_Layer]; color = g_DesignSettings.m_LayerColor[m_Layer];

View File

@ -33,11 +33,6 @@ public:
EDGE_MODULE* Back() const { return (EDGE_MODULE*) Pback; } EDGE_MODULE* Back() const { return (EDGE_MODULE*) Pback; }
/**
* Function UnLink
* remove item from linked list.
*/
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
@ -48,10 +43,6 @@ public:
return m_Start; return m_Start;
} }
/* supprime du chainage la structure Struct */
void UnLink();
void Copy( EDGE_MODULE* source ); // copy structure void Copy( EDGE_MODULE* source ); // copy structure
/** /**

View File

@ -22,8 +22,8 @@
/*********************************************************/ /*********************************************************/
/* Constructeur de la classe EQUIPOT */ /* Constructeur de la classe EQUIPOT */
EQUIPOT::EQUIPOT( BOARD_ITEM* StructFather ) : EQUIPOT::EQUIPOT( BOARD_ITEM* aParent ) :
BOARD_ITEM( StructFather, PCB_EQUIPOT_STRUCT_TYPE ) BOARD_ITEM( aParent, TYPE_EQUIPOT )
{ {
SetNet( 0 ); SetNet( 0 );
m_NbNodes = m_NbLink = m_NbNoconn = 0; m_NbNodes = m_NbLink = m_NbNoconn = 0;
@ -51,31 +51,6 @@ wxPoint& EQUIPOT::GetPosition()
return dummy; return dummy;
} }
void EQUIPOT::UnLink()
{
/* Modification du chainage arriere */
if( Back() )
{
if( Back()->Type() != TYPEPCB )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Back() )->m_Equipots = Next();
}
}
/* Modification du chainage avant */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/*********************************************************/ /*********************************************************/
int EQUIPOT:: ReadEquipotDescr( FILE* File, int* LineNum ) int EQUIPOT:: ReadEquipotDescr( FILE* File, int* LineNum )
/*********************************************************/ /*********************************************************/

View File

@ -25,7 +25,7 @@ public:
CHEVELU* m_RatsnestStart; // pointeur sur debut de liste ratsnests du net CHEVELU* m_RatsnestStart; // pointeur sur debut de liste ratsnests du net
CHEVELU* m_RatsnestEnd; // pointeur sur fin de liste ratsnests du net CHEVELU* m_RatsnestEnd; // pointeur sur fin de liste ratsnests du net
EQUIPOT( BOARD_ITEM* StructFather ); EQUIPOT( BOARD_ITEM* aParent );
~EQUIPOT(); ~EQUIPOT();
EQUIPOT* Next() const { return (EQUIPOT*) Pnext; } EQUIPOT* Next() const { return (EQUIPOT*) Pnext; }
@ -40,10 +40,6 @@ public:
*/ */
wxPoint& GetPosition(); wxPoint& GetPosition();
/* Effacement memoire de la structure */
void UnLink();
/* Readind and writing data on files */ /* Readind and writing data on files */
int ReadEquipotDescr( FILE* File, int* LineNum ); int ReadEquipotDescr( FILE* File, int* LineNum );

View File

@ -48,8 +48,8 @@ void MARKER::init()
m_Size.y = Default_MarkerBitmap[1]; m_Size.y = Default_MarkerBitmap[1];
} }
MARKER::MARKER( BOARD_ITEM* StructFather ) : MARKER::MARKER( BOARD_ITEM* aParent ) :
BOARD_ITEM( StructFather, TYPEMARKER ), BOARD_ITEM( aParent, TYPE_MARKER ),
m_drc() m_drc()
{ {
init(); init();
@ -59,7 +59,7 @@ MARKER::MARKER( BOARD_ITEM* StructFather ) :
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos, const wxString& aText, const wxPoint& aPos,
const wxString& bText, const wxPoint& bPos ) : const wxString& bText, const wxPoint& bPos ) :
BOARD_ITEM( NULL, TYPEMARKER ) // parent set during BOARD::Add() BOARD_ITEM( NULL, TYPE_MARKER ) // parent set during BOARD::Add()
{ {
init(); init();
@ -70,7 +70,7 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos ) : const wxString& aText, const wxPoint& aPos ) :
BOARD_ITEM( NULL, TYPEMARKER ) // parent set during BOARD::Add() BOARD_ITEM( NULL, TYPE_MARKER ) // parent set during BOARD::Add()
{ {
init(); init();

View File

@ -23,7 +23,7 @@ protected:
public: public:
MARKER( BOARD_ITEM* StructFather ); MARKER( BOARD_ITEM* aParent );
/** /**
* Constructor * Constructor

View File

@ -9,8 +9,8 @@
#include "pcbnew.h" #include "pcbnew.h"
MIREPCB::MIREPCB( BOARD_ITEM* StructFather ) : MIREPCB::MIREPCB( BOARD_ITEM* aParent ) :
BOARD_ITEM( StructFather, TYPEMIRE ) BOARD_ITEM( aParent, TYPE_MIRE )
{ {
m_Shape = 0; m_Shape = 0;
m_Size = 5000; m_Size = 5000;
@ -22,30 +22,6 @@ MIREPCB::~MIREPCB()
} }
/***************************/
void MIREPCB::UnLink()
/***************************/
{
if( Back() )
{
if( Back()->Type() != TYPEPCB )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Back() )->m_Drawings = Next();
}
}
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/**********************************/ /**********************************/
void MIREPCB::Copy( MIREPCB* source ) void MIREPCB::Copy( MIREPCB* source )
/**********************************/ /**********************************/

View File

@ -16,7 +16,7 @@ public:
int m_Size; int m_Size;
public: public:
MIREPCB( BOARD_ITEM* StructFather ); MIREPCB( BOARD_ITEM* aParent );
~MIREPCB(); ~MIREPCB();
MIREPCB* Next() const { return (MIREPCB*) Pnext; } MIREPCB* Next() const { return (MIREPCB*) Pnext; }
@ -38,9 +38,6 @@ public:
bool ReadMirePcbDescr( FILE* File, int* LineNum ); bool ReadMirePcbDescr( FILE* File, int* LineNum );
/* supprime du chainage la structure Struct */
void UnLink();
void Copy( MIREPCB* source ); void Copy( MIREPCB* source );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& offset = ZeroOffset ); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& offset = ZeroOffset );

View File

@ -55,10 +55,8 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset
/* Class MODULE : description d'un composant pcb */ /* Class MODULE : description d'un composant pcb */
/*************************************************/ /*************************************************/
MODULE::MODULE( BOARD* parent ) : MODULE::MODULE( BOARD* parent ) :
BOARD_ITEM( parent, TYPEMODULE ) BOARD_ITEM( parent, TYPE_MODULE )
{ {
m_Pads = NULL;
m_Drawings = NULL;
m_3D_Drawings = NULL; m_3D_Drawings = NULL;
m_Attributs = MOD_DEFAULT; m_Attributs = MOD_DEFAULT;
m_Layer = CMP_N; m_Layer = CMP_N;
@ -92,31 +90,6 @@ MODULE::~MODULE()
next = item->Next(); next = item->Next();
delete item; delete item;
} }
for( item = m_Pads; item; item = next )
{
next = item->Next();
delete item;
}
/* effacement des elements de trace */
for( item = m_Drawings; item; item = next )
{
next = item->Next();
switch( item->Type() )
{
case TYPEEDGEMODULE:
case TYPETEXTEMODULE:
delete item;
break;
default:
DisplayError( NULL, wxT( "Warning: Item Type not handled in delete MODULE" ) );
next = NULL;
break;
}
}
} }
@ -124,8 +97,6 @@ MODULE::~MODULE()
void MODULE::Copy( MODULE* Module ) void MODULE::Copy( MODULE* Module )
/*********************************/ /*********************************/
{ {
D_PAD* lastpad;
m_Pos = Module->m_Pos; m_Pos = Module->m_Pos;
m_Layer = Module->m_Layer; m_Layer = Module->m_Layer;
m_LibRef = Module->m_LibRef; m_LibRef = Module->m_LibRef;
@ -144,65 +115,37 @@ void MODULE::Copy( MODULE* Module )
m_Value->Copy( Module->m_Value ); m_Value->Copy( Module->m_Value );
/* Copie des structures auxiliaires: Pads */ /* Copie des structures auxiliaires: Pads */
lastpad = NULL;
for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() )
{ {
D_PAD* newpad = new D_PAD( this ); D_PAD* newpad = new D_PAD( this );
newpad->Copy( pad ); newpad->Copy( pad );
if( m_Pads == NULL ) m_Pads.PushBack( newpad );
{
newpad->SetBack( this );
m_Pads = newpad;
}
else
{
newpad->SetBack( lastpad );
lastpad->SetNext( newpad );
}
lastpad = newpad;
} }
/* Copy des structures auxiliaires: Drawings */ /* Copy des structures auxiliaires: Drawings */
BOARD_ITEM* NewStruct, * LastStruct = NULL; for( BOARD_ITEM* item = Module->m_Drawings; item; item = item->Next() )
BOARD_ITEM* OldStruct = Module->m_Drawings;
for( ; OldStruct; OldStruct = OldStruct->Next() )
{ {
NewStruct = NULL; switch( item->Type() )
switch( OldStruct->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
NewStruct = new TEXTE_MODULE( this ); TEXTE_MODULE* textm;
( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) OldStruct ); textm = new TEXTE_MODULE( this );
textm->Copy( (TEXTE_MODULE*) item );
m_Drawings.PushBack( textm );
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
NewStruct = new EDGE_MODULE( this ); EDGE_MODULE* edge;
( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) OldStruct ); edge = new EDGE_MODULE( this );
edge->Copy( (EDGE_MODULE*) item );
m_Drawings.PushBack( edge );
break; break;
default: default:
DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) ); DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) );
break; break;
} }
if( NewStruct == NULL )
break;
if( m_Drawings == NULL )
{
NewStruct->SetBack( this );
m_Drawings = NewStruct;
}
else
{
NewStruct->SetBack( LastStruct );
LastStruct->SetNext( NewStruct );
}
LastStruct = NewStruct;
} }
/* Copy des elements complementaires Drawings 3D */ /* Copy des elements complementaires Drawings 3D */
@ -227,39 +170,6 @@ void MODULE::Copy( MODULE* Module )
} }
/* supprime du chainage la structure Struct
* les structures arrieres et avant sont chainees directement
*/
void MODULE::UnLink()
{
if( Back() )
{
if( Back()->Type() != TYPEPCB )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
if( GetState( DELETED ) ) // A REVOIR car Pback = NULL si place en undelete
{
if( g_UnDeleteStackPtr )
g_UnDeleteStack[g_UnDeleteStackPtr - 1] = Next();
}
else
( (BOARD*) Back() )->m_Modules = Next();
}
}
/* Modification du chainage avant */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/**********************************************************/ /**********************************************************/
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int draw_mode, const wxPoint& offset ) int draw_mode, const wxPoint& offset )
@ -301,8 +211,8 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
switch( item->Type() ) switch( item->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
item->Draw( panel, DC, draw_mode, offset ); item->Draw( panel, DC, draw_mode, offset );
break; break;
@ -330,7 +240,7 @@ void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
item->Draw( panel, DC, draw_mode, offset ); item->Draw( panel, DC, draw_mode, offset );
break; break;
@ -412,8 +322,8 @@ bool MODULE::Save( FILE* aFile ) const
{ {
switch( item->Type() ) switch( item->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
goto out; goto out;
break; break;
@ -567,10 +477,6 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
* retourne 0 si OK * retourne 0 si OK
*/ */
{ {
D_PAD* LastPad = NULL, * ptpad;
EDA_BaseStruct* LastModStruct = NULL;
EDGE_MODULE* DrawSegm;
TEXTE_MODULE* DrawText;
char Line[256], BufLine[256], BufCar1[128], * PtLine; char Line[256], BufLine[256], BufCar1[128], * PtLine;
int itmp1, itmp2; int itmp1, itmp2;
@ -582,23 +488,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
break; break;
if( Line[1] == 'P' ) if( Line[1] == 'P' )
{ {
ptpad = new D_PAD( this ); D_PAD* pad = new D_PAD( this );
ptpad->ReadDescr( File, LineNum ); pad->ReadDescr( File, LineNum );
RotatePoint( &ptpad->m_Pos.x, &ptpad->m_Pos.y, m_Orient ); RotatePoint( &pad->m_Pos.x, &pad->m_Pos.y, m_Orient );
ptpad->m_Pos.x += m_Pos.x; pad->m_Pos.x += m_Pos.x;
ptpad->m_Pos.y += m_Pos.y; pad->m_Pos.y += m_Pos.y;
if( LastPad == NULL ) m_Pads.PushBack( pad );
{
ptpad->SetBack( this );
m_Pads = ptpad;
}
else
{
ptpad->SetBack( LastPad );
LastPad->SetNext( ptpad );
}
LastPad = ptpad;
continue; continue;
} }
if( Line[1] == 'S' ) if( Line[1] == 'S' )
@ -673,47 +569,26 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
break; break;
case 'T': /* Read a footprint text description (ref, value, or drawing */ case 'T': /* Read a footprint text description (ref, value, or drawing */
TEXTE_MODULE* textm;
sscanf( Line + 1, "%d", &itmp1 ); sscanf( Line + 1, "%d", &itmp1 );
if( itmp1 == TEXT_is_REFERENCE ) if( itmp1 == TEXT_is_REFERENCE )
DrawText = m_Reference; textm = m_Reference;
else if( itmp1 == TEXT_is_VALUE ) else if( itmp1 == TEXT_is_VALUE )
DrawText = m_Value; textm = m_Value;
else /* text is a drawing */ else /* text is a drawing */
{ {
DrawText = new TEXTE_MODULE( this ); textm = new TEXTE_MODULE( this );
if( LastModStruct == NULL ) m_Drawings.PushBack( textm );
{
DrawText->SetBack( this );
m_Drawings = DrawText;
}
else
{
DrawText->SetBack( LastModStruct );
LastModStruct->SetNext( DrawText );
}
LastModStruct = DrawText;
} }
textm->ReadDescr( Line, File, LineNum );
DrawText->ReadDescr( Line, File, LineNum );
break; break;
case 'D': /* lecture du contour */ case 'D': /* lecture du contour */
DrawSegm = new EDGE_MODULE( this ); EDGE_MODULE* edge;
edge = new EDGE_MODULE( this );
if( LastModStruct == NULL ) m_Drawings.PushBack( edge );
{ edge->ReadDescr( Line, File, LineNum );
DrawSegm->SetBack( this ); edge->SetDrawCoord();
m_Drawings = DrawSegm;
}
else
{
DrawSegm->SetBack( LastModStruct );
LastModStruct->SetNext( DrawSegm );
}
LastModStruct = DrawSegm;
DrawSegm->ReadDescr( Line, File, LineNum );
DrawSegm->SetDrawCoord();
break; break;
case 'C': /* Lecture de la doc */ case 'C': /* Lecture de la doc */
@ -769,14 +644,14 @@ void MODULE::SetPosition( const wxPoint& newpos )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
{ {
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct; EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->SetDrawCoord(); pt_edgmod->SetDrawCoord();
break; break;
} }
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
{ {
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct; TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.x += deltaX; pt_texte->m_Pos.x += deltaX;
@ -829,12 +704,12 @@ void MODULE::SetOrientation( int newangle )
EDA_BaseStruct* PtStruct = m_Drawings; EDA_BaseStruct* PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
if( PtStruct->Type() == TYPEEDGEMODULE ) if( PtStruct->Type() == TYPE_EDGE_MODULE )
{ {
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct; EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
pt_edgmod->SetDrawCoord(); pt_edgmod->SetDrawCoord();
} }
if( PtStruct->Type() == TYPETEXTEMODULE ) if( PtStruct->Type() == TYPE_TEXTE_MODULE )
{ {
/* deplacement des inscriptions : */ /* deplacement des inscriptions : */
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct; TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
@ -871,10 +746,10 @@ void MODULE::Set_Rectangle_Encadrement()
m_BoundaryBox.m_Pos.y = -500; ymax = 500; m_BoundaryBox.m_Pos.y = -500; ymax = 500;
/* Contours: Recherche des coord min et max et mise a jour du cadre */ /* Contours: Recherche des coord min et max et mise a jour du cadre */
for( EDGE_MODULE* pt_edge_mod = (EDGE_MODULE*) m_Drawings; for( EDGE_MODULE* pt_edge_mod = (EDGE_MODULE*) m_Drawings.GetFirst();
pt_edge_mod; pt_edge_mod = pt_edge_mod->Next() ) pt_edge_mod; pt_edge_mod = pt_edge_mod->Next() )
{ {
if( pt_edge_mod->Type() != TYPEEDGEMODULE ) if( pt_edge_mod->Type() != TYPE_EDGE_MODULE )
continue; continue;
width = pt_edge_mod->m_Width / 2; width = pt_edge_mod->m_Width / 2;
@ -944,9 +819,9 @@ void MODULE::SetRectangleExinscrit()
m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y; m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y;
/* Contours: Recherche des coord min et max et mise a jour du cadre */ /* Contours: Recherche des coord min et max et mise a jour du cadre */
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings; edge; edge = edge->Next() ) for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
{ {
if( edge->Type() != TYPEEDGEMODULE ) if( edge->Type() != TYPE_EDGE_MODULE )
continue; continue;
width = edge->m_Width / 2; width = edge->m_Width / 2;
@ -1020,9 +895,9 @@ EDA_Rect MODULE::GetBoundingBox()
text_area = m_Value->GetBoundingBox(); text_area = m_Value->GetBoundingBox();
area.Merge( text_area ); area.Merge( text_area );
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings; edge; edge = edge->Next() ) for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
{ {
if( edge->Type() != TYPETEXTEMODULE ) if( edge->Type() != TYPE_TEXTE_MODULE )
continue; continue;
text_area = ((TEXTE_MODULE*)edge)->GetBoundingBox(); text_area = ((TEXTE_MODULE*)edge)->GetBoundingBox();
area.Merge( text_area ); area.Merge( text_area );
@ -1201,17 +1076,17 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
switch( stype ) switch( stype )
{ {
case TYPEMODULE: case TYPE_MODULE:
result = inspector->Inspect( this, testData ); // inspect me result = inspector->Inspect( this, testData ); // inspect me
++p; ++p;
break; break;
case TYPEPAD: case TYPE_PAD:
result = IterateForward( m_Pads, inspector, testData, p ); result = IterateForward( m_Pads, inspector, testData, p );
++p; ++p;
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
result = inspector->Inspect( m_Reference, testData ); result = inspector->Inspect( m_Reference, testData );
if( result == SEARCH_QUIT ) if( result == SEARCH_QUIT )
break; break;
@ -1222,7 +1097,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
// m_Drawings can hold TYPETEXTMODULE also, so fall thru // m_Drawings can hold TYPETEXTMODULE also, so fall thru
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
result = IterateForward( m_Drawings, inspector, testData, p ); result = IterateForward( m_Drawings, inspector, testData, p );
// skip over any types handled in the above call. // skip over any types handled in the above call.
@ -1230,8 +1105,8 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
{ {
switch( stype = *++p ) switch( stype = *++p )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
continue; continue;
default: default:

View File

@ -38,14 +38,14 @@ enum Mod_Attribut /* Attributs used for modules */
class MODULE : public BOARD_ITEM class MODULE : public BOARD_ITEM
{ {
public: public:
wxPoint m_Pos; // Real coord on board wxPoint m_Pos; // Real coord on board
D_PAD* m_Pads; /* Pad list (linked list) */ DLIST<D_PAD> m_Pads; /* Pad list (linked list) */
BOARD_ITEM* m_Drawings; /* Graphic items list (linked list) */ DLIST<BOARD_ITEM> m_Drawings; /* Graphic items list (linked list) */
Struct3D_Master* m_3D_Drawings; /* First item of the 3D shapes (linked list)*/ Struct3D_Master* m_3D_Drawings; /* First item of the 3D shapes (linked list)*/
TEXTE_MODULE* m_Reference; // Component reference (U34, R18..) TEXTE_MODULE* m_Reference; // Component reference (U34, R18..)
TEXTE_MODULE* m_Value; // Component value (74LS00, 22K..) TEXTE_MODULE* m_Value; // Component value (74LS00, 22K..)
wxString m_LibRef; /* Name of the module in library (and the default value when loading amodule from the library) */ wxString m_LibRef; /* Name of the module in library (and the default value when loading amodule from the library) */
wxString m_AlternateReference; /* Used when m_Reference cannot be used to wxString m_AlternateReference; /* Used when m_Reference cannot be used to
* identify the footprint ( after a full reannotation of the schematic */ * identify the footprint ( after a full reannotation of the schematic */
int m_Attributs; /* Flags(ORed bits) ( see Mod_Attribut ) */ int m_Attributs; /* Flags(ORed bits) ( see Mod_Attribut ) */
@ -124,9 +124,6 @@ public:
void SetPosition( const wxPoint& newpos ); void SetPosition( const wxPoint& newpos );
void SetOrientation( int newangle ); void SetOrientation( int newangle );
/* Remove this from the linked list */
void UnLink();
/** /**
* Function IsLocked * Function IsLocked

View File

@ -26,7 +26,7 @@
/* classe D_PAD : constructeur */ /* classe D_PAD : constructeur */
/*******************************/ /*******************************/
D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, TYPEPAD ) D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, TYPE_PAD )
{ {
m_NumPadName = 0; m_NumPadName = 0;
m_Masque_Layer = CUIVRE_LAYER; m_Masque_Layer = CUIVRE_LAYER;
@ -34,7 +34,7 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, TYPEPAD )
m_Size.x = m_Size.y = 500; m_Size.x = m_Size.y = 500;
if( m_Parent && (m_Parent->Type() == TYPEMODULE) ) if( m_Parent && (m_Parent->Type() == TYPE_MODULE) )
{ {
m_Pos = ( (MODULE*) m_Parent )->GetPosition(); m_Pos = ( (MODULE*) m_Parent )->GetPosition();
} }
@ -202,36 +202,6 @@ void D_PAD::Copy( D_PAD* source )
} }
/**************************/
void D_PAD::UnLink()
/**************************/
/* supprime du chainage la structure Struct
* les structures arrieres et avant sont chainees directement
*/
{
/* Modification du chainage arriere */
if( Back() )
{
if( Back()->Type() != TYPEMODULE )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (MODULE*) Back() )->m_Pads = Next();
}
}
/* Modification du chainage avant */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/*******************************************************************************************/ /*******************************************************************************************/
void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& offset ) void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& offset )
/*******************************************************************************************/ /*******************************************************************************************/

View File

@ -89,10 +89,6 @@ public:
m_Pos = aPos; m_Pos = aPos;
} }
/* remove from linked list */
void UnLink();
/* Reading and writing data on files */ /* Reading and writing data on files */
int ReadDescr( FILE* File, int* LineNum = NULL ); int ReadDescr( FILE* File, int* LineNum = NULL );

View File

@ -16,7 +16,7 @@
/*******************/ /*******************/
TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) : TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) :
BOARD_ITEM( parent, TYPETEXTE ), BOARD_ITEM( parent, TYPE_TEXTE ),
EDA_TextStruct() EDA_TextStruct()
{ {
} }
@ -48,30 +48,6 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source )
} }
void TEXTE_PCB::UnLink()
{
/* Modification du chainage arriere */
if( Back() )
{
if( Back()->Type() != TYPEPCB )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Back() )->m_Drawings = Next();
}
}
/* Modification du chainage avant */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/****************************************************************/ /****************************************************************/
int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum ) int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
/****************************************************************/ /****************************************************************/
@ -175,7 +151,7 @@ void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame )
BOARD_ITEM* parent = (BOARD_ITEM*) m_Parent; BOARD_ITEM* parent = (BOARD_ITEM*) m_Parent;
wxASSERT( parent ); wxASSERT( parent );
if( parent->Type() == TYPECOTATION ) if( parent->Type() == TYPE_COTATION )
board = (BOARD*) parent->GetParent(); board = (BOARD*) parent->GetParent();
else else
board = (BOARD*) parent; board = (BOARD*) parent;
@ -183,7 +159,7 @@ void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame )
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
if( m_Parent && m_Parent->Type() == TYPECOTATION ) if( m_Parent && m_Parent->Type() == TYPE_COTATION )
Affiche_1_Parametre( frame, 1, _( "COTATION" ), m_Text, DARKGREEN ); Affiche_1_Parametre( frame, 1, _( "COTATION" ), m_Text, DARKGREEN );
else else
Affiche_1_Parametre( frame, 1, _( "PCB Text" ), m_Text, DARKGREEN ); Affiche_1_Parametre( frame, 1, _( "PCB Text" ), m_Text, DARKGREEN );

View File

@ -13,7 +13,6 @@ public:
TEXTE_PCB( TEXTE_PCB* textepcb ); TEXTE_PCB( TEXTE_PCB* textepcb );
~TEXTE_PCB(); ~TEXTE_PCB();
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
@ -25,10 +24,6 @@ public:
return m_Pos; // within EDA_TextStruct return m_Pos; // within EDA_TextStruct
} }
/* supprime du chainage la structure Struct */
void UnLink();
/* duplicate structure */ /* duplicate structure */
void Copy( TEXTE_PCB* source ); void Copy( TEXTE_PCB* source );

View File

@ -28,7 +28,7 @@
/* Constructeur de TEXTE_MODULE */ /* Constructeur de TEXTE_MODULE */
TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
BOARD_ITEM( parent, TYPETEXTEMODULE ) BOARD_ITEM( parent, TYPE_TEXTE_MODULE )
{ {
MODULE* Module = (MODULE*) m_Parent; MODULE* Module = (MODULE*) m_Parent;
@ -43,7 +43,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
m_Unused = 0; m_Unused = 0;
SetLayer( SILKSCREEN_N_CMP ); SetLayer( SILKSCREEN_N_CMP );
if( Module && (Module->Type() == TYPEMODULE) ) if( Module && (Module->Type() == TYPE_MODULE) )
{ {
m_Pos = Module->m_Pos; m_Pos = Module->m_Pos;
@ -205,33 +205,6 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
} }
/* Remove this from the linked list
* Update Pback and Pnext pointers
*/
void TEXTE_MODULE::UnLink()
{
/* Modification du chainage arriere */
if( Back() )
{
if( Back()->Type() != TYPEMODULE )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (MODULE*) Back() )->m_Drawings = Next();
}
}
/* Modification du chainage avant */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/******************************************/ /******************************************/
int TEXTE_MODULE:: GetLength() int TEXTE_MODULE:: GetLength()
/******************************************/ /******************************************/

View File

@ -47,10 +47,6 @@ public:
return m_Pos; return m_Pos;
} }
/* supprime du chainage la structure Struct */
void UnLink();
void Copy( TEXTE_MODULE* source ); // copy structure void Copy( TEXTE_MODULE* source ); // copy structure
/* Gestion du texte */ /* Gestion du texte */

View File

@ -8,7 +8,6 @@
#include "common.h" #include "common.h"
#include "pcbnew.h" #include "pcbnew.h"
#ifdef CVPCB #ifdef CVPCB
#include "cvpcb.h" #include "cvpcb.h"
#endif #endif
@ -39,9 +38,9 @@ void DbgDisplayTrackInfos( TRACK* track )
wxMessageBox( msg ); wxMessageBox( msg );
} }
#endif #endif
/** /**
* Function ShowClearance * Function ShowClearance
* tests to see if the clearance border is drawn on the given track. * tests to see if the clearance border is drawn on the given track.
@ -49,16 +48,18 @@ void DbgDisplayTrackInfos( TRACK* track )
*/ */
static bool ShowClearance( const TRACK* aTrack ) static bool ShowClearance( const TRACK* aTrack )
{ {
// maybe return true for (for tracks and vias, not for zone segments // maybe return true for tracks and vias, not for zone segments
return ( DisplayOpt.DisplayTrackIsol && ( aTrack->GetLayer() <= LAST_COPPER_LAYER ) return !(aTrack->m_Flags & DRAW_ERASED)
&& ( aTrack->Type() == TYPETRACK || aTrack->Type() == TYPEVIA) ); && DisplayOpt.DisplayTrackIsol
&& aTrack->GetLayer() <= LAST_COPPER_LAYER
&& ( aTrack->Type() == TYPE_TRACK || aTrack->Type() == TYPE_VIA );
} }
/**********************************************************/ /**********************************************************/
TRACK::TRACK( BOARD_ITEM* StructFather, KICAD_T idtype ) : TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_CONNECTED_ITEM( StructFather, idtype ) BOARD_CONNECTED_ITEM( aParent, idtype )
/**********************************************************/ /**********************************************************/
{ {
m_Width = 0; m_Width = 0;
@ -81,14 +82,14 @@ wxString TRACK::ShowWidth()
} }
SEGZONE::SEGZONE( BOARD_ITEM* StructFather ) : SEGZONE::SEGZONE( BOARD_ITEM* aParent ) :
TRACK( StructFather, TYPEZONE ) TRACK( aParent, TYPE_ZONE )
{ {
} }
SEGVIA::SEGVIA( BOARD_ITEM* StructFather ) : SEGVIA::SEGVIA( BOARD_ITEM* aParent ) :
TRACK( StructFather, TYPEVIA ) TRACK( aParent, TYPE_VIA )
{ {
} }
@ -99,6 +100,7 @@ TRACK::TRACK( const TRACK& Source ) :
{ {
m_Shape = Source.m_Shape; m_Shape = Source.m_Shape;
SetNet( Source.GetNet() ); SetNet( Source.GetNet() );
m_Flags = Source.m_Flags; m_Flags = Source.m_Flags;
m_TimeStamp = Source.m_TimeStamp; m_TimeStamp = Source.m_TimeStamp;
SetStatus( Source.ReturnStatus() ); SetStatus( Source.ReturnStatus() );
@ -119,13 +121,13 @@ TRACK::TRACK( const TRACK& Source ) :
*/ */
TRACK* TRACK::Copy() const TRACK* TRACK::Copy() const
{ {
if( Type() == TYPETRACK ) if( Type() == TYPE_TRACK )
return new TRACK( *this ); return new TRACK( *this );
if( Type() == TYPEVIA ) if( Type() == TYPE_VIA )
return new SEGVIA( (const SEGVIA &) * this ); return new SEGVIA( (const SEGVIA &) * this );
if( Type() == TYPEZONE ) if( Type() == TYPE_ZONE )
return new SEGZONE( (const SEGZONE &) * this ); return new SEGZONE( (const SEGZONE &) * this );
return NULL; // should never happen return NULL; // should never happen
@ -139,7 +141,7 @@ TRACK* TRACK::Copy() const
*/ */
int TRACK::GetDrillValue() const int TRACK::GetDrillValue() const
{ {
if ( Type() != TYPEVIA ) if ( Type() != TYPE_VIA )
return 0; return 0;
if ( m_Drill >= 0 ) if ( m_Drill >= 0 )
@ -158,7 +160,7 @@ bool TRACK::IsNull()
// return TRUE if segment length = 0 // return TRUE if segment length = 0
{ {
if( ( Type() != TYPEVIA ) && ( m_Start == m_End ) ) if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) )
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -228,7 +230,7 @@ EDA_Rect TRACK::GetBoundingBox()
int ymin; int ymin;
int xmin; int xmin;
if( Type() == TYPEVIA ) if( Type() == TYPE_VIA )
{ {
// Because vias are sometimes drawn larger than their m_Width would // Because vias are sometimes drawn larger than their m_Width would
// provide, erasing them using a dirty rect must also compensate for this // provide, erasing them using a dirty rect must also compensate for this
@ -323,7 +325,7 @@ int TRACK::ReturnMaskLayer()
* for a via, there is more than one layer used * for a via, there is more than one layer used
*/ */
{ {
if( Type() == TYPEVIA ) if( Type() == TYPE_VIA )
{ {
int via_type = Shape(); int via_type = Shape();
@ -404,94 +406,6 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
} }
/* Remove this from the track or zone linked list
*/
void TRACK::UnLink()
{
/* Remove the back link */
if( Back() )
{
if( Back()->Type() != TYPEPCB )
{
Back()->SetNext( Next() );
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
if( GetState( DELETED ) ) // A REVOIR car Pback = NULL si place en undelete
{
if( g_UnDeleteStackPtr )
g_UnDeleteStack[g_UnDeleteStackPtr - 1] = (BOARD_ITEM*) Pnext;
}
else
{
if( Type() == TYPEZONE )
{
( (BOARD*) Back() )->m_Zone = (SEGZONE*) Next();
}
else
{
( (BOARD*) Back() )->m_Track = Next();
}
}
}
}
/* Remove the forward link */
if( Next() )
Next()->SetBack( Back() );
SetNext( 0 );
SetBack( 0 );
}
/************************************************************/
void TRACK::Insert( BOARD* Pcb, TRACK* InsertPoint )
/************************************************************/
/* insert this (and its linked segments is exists)
* in the track linked list
* @param InsertPoint = insert point within the linked list
* if NULL: insert as first element of Pcb->m_Tracks
*/
{
TRACK* track;
TRACK* NextS;
if( InsertPoint == NULL )
{
Pback = Pcb;
if( Type() == TYPEZONE ) // put SEGZONE on front of m_Zone list
{
NextS = Pcb->m_Zone;
Pcb->m_Zone = (SEGZONE*) this;
}
else // put TRACK or SEGVIA on front of m_Track list
{
NextS = Pcb->m_Track;
Pcb->m_Track = this;
}
}
else
{
NextS = InsertPoint->Next();
Pback = InsertPoint;
InsertPoint->SetNext( this );
}
/* Set the forward link */
track = this;
while( track->Next() ) // Search the end of added chain
track = track->Next();
/* Link the end of chain */
track->SetNext( NextS );
if( NextS )
NextS->SetBack( track );
}
/***********************************************/ /***********************************************/
TRACK* TRACK::GetBestInsertPoint( BOARD* Pcb ) TRACK* TRACK::GetBestInsertPoint( BOARD* Pcb )
/***********************************************/ /***********************************************/
@ -502,29 +416,20 @@ TRACK* TRACK::GetBestInsertPoint( BOARD* Pcb )
* @return the item found in the linked list (or NULL if no track) * @return the item found in the linked list (or NULL if no track)
*/ */
{ {
TRACK* track, * NextTrack; TRACK* track;
if( Type() == TYPEZONE ) if( Type() == TYPE_ZONE )
track = Pcb->m_Zone; track = Pcb->m_Zone;
else else
track = Pcb->m_Track; track = Pcb->m_Track;
/* Traitement du debut de liste */ for( ; track; track = track->Next() )
if( track == NULL )
return NULL; /* No tracks ! */
if( GetNet() < track->GetNet() ) /* no net code or net code = 0 (track not connected) */
return NULL;
while( (NextTrack = (TRACK*) track->Pnext) != NULL )
{ {
if( NextTrack->GetNet() > this->GetNet() ) if( GetNet() <= track->GetNet() )
break; return track;
track = NextTrack;
} }
return track; return NULL;
} }
@ -606,7 +511,7 @@ bool TRACK::Save( FILE* aFile ) const
{ {
int type = 0; int type = 0;
if( Type() == TYPEVIA ) if( Type() == TYPE_VIA )
type = 1; type = 1;
if( GetState( DELETED ) ) if( GetState( DELETED ) )
@ -634,38 +539,47 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
int rayon; int rayon;
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
if( Type() == TYPEZONE && !DisplayOpt.DisplayZones ) if( Type() == TYPE_ZONE && !DisplayOpt.DisplayZones )
return; return;
if( m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview
{
color = g_DrawBgColor;
D(printf("DRAW_ERASED in Track::Draw, g_DrawBgColor=%04X\n", g_DrawBgColor );)
}
else
{
color = g_DesignSettings.m_LayerColor[m_Layer];
if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW )
return;
if( DisplayOpt.ContrastModeDisplay )
{
if( !IsOnLayer( curr_layer ) )
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;
}
}
if( draw_mode & GR_SURBRILL )
{
if( draw_mode & GR_AND )
color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
}
if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
SetAlpha( &color, 150 );
}
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
color = g_DesignSettings.m_LayerColor[m_Layer];
if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW )
return;
if( DisplayOpt.ContrastModeDisplay )
{
if( !IsOnLayer( curr_layer ) )
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;
}
}
if( draw_mode & GR_SURBRILL )
{
if( draw_mode & GR_AND )
color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
}
if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
SetAlpha( &color, 150 );
zoom = panel->GetZoom(); zoom = panel->GetZoom();
l_piste = m_Width >> 1; l_piste = m_Width >> 1;
@ -705,7 +619,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
return; return;
} }
if( (!DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) ) if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
{ {
GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width, color ); m_End.x, m_End.y, m_Width, color );
@ -735,9 +649,6 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
int rayon; int rayon;
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
if( Type() == TYPEZONE && !DisplayOpt.DisplayZones )
return;
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
color = g_DesignSettings.m_ViaColor[m_Shape]; color = g_DesignSettings.m_ViaColor[m_Shape];
@ -874,15 +785,15 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame )
switch( Type() ) switch( Type() )
{ {
case TYPEVIA: case TYPE_VIA:
msg = g_ViaType_Name[Shape()]; msg = g_ViaType_Name[Shape()];
break; break;
case TYPETRACK: case TYPE_TRACK:
msg = _( "Track" ); msg = _( "Track" );
break; break;
case TYPEZONE: case TYPE_ZONE:
msg = _( "Zone" ); break; msg = _( "Zone" ); break;
default: default:
@ -890,15 +801,17 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame )
} }
text_pos = 1; text_pos = 1;
Affiche_1_Parametre( frame, text_pos, _( "Type" ), msg, DARKCYAN ); Affiche_1_Parametre( frame, text_pos, _( "Type" ), msg, DARKCYAN );
text_pos += 10;
/* Display NetName pour les segments de piste type cuivre */
text_pos += 15;
if( Type() == TYPETRACK if( Type() == TYPE_TRACK
|| Type() == TYPEZONE || Type() == TYPE_ZONE
|| Type() == TYPEVIA ) || Type() == TYPE_VIA )
{ {
/* Display NetName pour les segments de piste type cuivre */
EQUIPOT* equipot = board->FindNet( GetNet() ); EQUIPOT* equipot = board->FindNet( GetNet() );
if( equipot ) if( equipot )
@ -907,11 +820,13 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame )
msg = wxT( "<noname>" ); msg = wxT( "<noname>" );
Affiche_1_Parametre( frame, text_pos, _( "NetName" ), msg, RED ); Affiche_1_Parametre( frame, text_pos, _( "NetName" ), msg, RED );
text_pos += 20;
/* Display net code : (usefull in test or debug) */ /* Display net code : (usefull in test or debug) */
msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() ); msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() );
text_pos += 18;
Affiche_1_Parametre( frame, text_pos, _( "NetCode" ), msg, RED ); Affiche_1_Parametre( frame, text_pos, _( "NetCode" ), msg, RED );
text_pos += 8;
} }
else else
{ {
@ -920,9 +835,19 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED ); Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED );
else else
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Standard" ), RED ); Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Standard" ), RED );
text_pos += 8;
} }
/* Display the Status flags */ #if defined(DEBUG)
/* Display the flags */
msg.Printf( wxT("0x%08X"), m_Flags );
Affiche_1_Parametre( frame, text_pos, _( "Flags" ), msg, BLUE );
text_pos += 8;
#endif
/* Display the State member */
msg = wxT( ". . " ); msg = wxT( ". . " );
if( GetState( SEGM_FIXE ) ) if( GetState( SEGM_FIXE ) )
msg[0] = 'F'; msg[0] = 'F';
@ -930,11 +855,11 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame )
if( GetState( SEGM_AR ) ) if( GetState( SEGM_AR ) )
msg[2] = 'A'; msg[2] = 'A';
text_pos = 42;
Affiche_1_Parametre( frame, text_pos, _( "Stat" ), msg, MAGENTA ); Affiche_1_Parametre( frame, text_pos, _( "Stat" ), msg, MAGENTA );
text_pos += 6;
/* Display layer or layer pair) */ /* Display layer or layer pair) */
if( Type() == TYPEVIA ) if( Type() == TYPE_VIA )
{ {
SEGVIA* Via = (SEGVIA*) this; SEGVIA* Via = (SEGVIA*) this;
int top_layer, bottom_layer; int top_layer, bottom_layer;
@ -946,22 +871,21 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame )
else else
msg = board->GetLayerName( m_Layer ); msg = board->GetLayerName( m_Layer );
text_pos += 5;
Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN ); Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN );
text_pos += 15;
/* Display width */ /* Display width */
valeur_param( (unsigned) m_Width, msg ); valeur_param( (unsigned) m_Width, msg );
text_pos += 11;
if( Type() == TYPEVIA ) // Display Diam and Drill values if( Type() == TYPE_VIA ) // Display Diam and Drill values
{ {
Affiche_1_Parametre( frame, text_pos, _( "Diam" ), msg, DARKCYAN ); Affiche_1_Parametre( frame, text_pos, _( "Diam" ), msg, DARKCYAN );
text_pos += 8;
int drill_value = GetDrillValue(); int drill_value = GetDrillValue();
valeur_param( (unsigned) drill_value, msg ); valeur_param( (unsigned) drill_value, msg );
text_pos += 8;
wxString title = _( "Drill" ); wxString title = _( "Drill" );
if( g_DesignSettings.m_ViaDrill >= 0 ) if( g_DesignSettings.m_ViaDrill >= 0 )
@ -992,7 +916,7 @@ bool TRACK::HitTest( const wxPoint& ref_pos )
int spot_cX = ref_pos.x - m_Start.x; int spot_cX = ref_pos.x - m_Start.x;
int spot_cY = ref_pos.y - m_Start.y; int spot_cY = ref_pos.y - m_Start.y;
if( Type() == TYPEVIA ) /* VIA rencontree */ if( Type() == TYPE_VIA ) /* VIA rencontree */
{ {
return (double) spot_cX * spot_cX + (double) spot_cY * spot_cY <= return (double) spot_cX * spot_cX + (double) spot_cY * spot_cY <=
(double) radius * radius; (double) radius * radius;
@ -1037,8 +961,11 @@ void TRACK::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
// " shape=\"" << m_Shape << '"' << // " shape=\"" << m_Shape << '"' <<
" addr=\"" << std::hex << this << std::dec << '"' <<
" layer=\"" << m_Layer << '"' << " layer=\"" << m_Layer << '"' <<
" width=\"" << m_Width << '"' << " width=\"" << m_Width << '"' <<
" flags=\"" << m_Flags << '"' <<
" status=\"" << GetState(-1) << '"' <<
// " drill=\"" << GetDrillValue() << '"' << // " drill=\"" << GetDrillValue() << '"' <<
" netcode=\"" << GetNet() << "\">" << " netcode=\"" << GetNet() << "\">" <<
@ -1103,4 +1030,38 @@ void SEGVIA::Show( int nestLevel, std::ostream& os )
} }
wxString TRACK::ShowState( int stateBits )
{
wxString ret;
if( stateBits & CHAIN )
ret << wxT(" | CHAIN");
if( stateBits & SEGM_AR )
ret << wxT(" | SEGM_AR");
if( stateBits & SEGM_FIXE )
ret << wxT(" | SEGM_FIXE");
if( stateBits & EDIT )
ret << wxT(" | EDIT");
if( stateBits & DRAG )
ret << wxT(" | DRAG");
if( stateBits & SURBRILL )
ret << wxT(" | SURBRILL");
if( stateBits & NO_TRACE )
ret << wxT(" | NO_TRACE");
if( stateBits & DELETED )
ret << wxT(" | DELETED");
if( stateBits & BUSY )
ret << wxT(" | BUSY");
if( stateBits & END_ONPAD)
ret << wxT(" | END_ONPAD");
if( stateBits & BEGIN_ONPAD)
ret << wxT(" | BEGIN_ONPAD");
if( stateBits & FLAG0)
ret << wxT(" | FLAG0");
if( stateBits & FLAG1 )
ret << wxT(" | FLAG1");
return ret;
}
#endif #endif

View File

@ -18,6 +18,13 @@
class TRACK : public BOARD_CONNECTED_ITEM class TRACK : public BOARD_CONNECTED_ITEM
{ {
// make SetNext() and SetBack() private so that they may not be called from anywhere.
// list management is done on TRACKs using DLIST<TRACK> only.
private:
void SetNext( EDA_BaseStruct* aNext ) { Pnext = aNext; }
void SetBack( EDA_BaseStruct* aBack ) { Pback = aBack; }
public: public:
int m_Width; // 0 = line, > 0 = tracks, bus ... int m_Width; // 0 = line, > 0 = tracks, bus ...
wxPoint m_Start; // Line start point wxPoint m_Start; // Line start point
@ -38,7 +45,7 @@ protected:
TRACK( const TRACK& track ); // protected so Copy() is used instead. TRACK( const TRACK& track ); // protected so Copy() is used instead.
public: public:
TRACK( BOARD_ITEM* StructFather, KICAD_T idtype = TYPETRACK ); TRACK( BOARD_ITEM* aParent, KICAD_T idtype = TYPE_TRACK );
/** /**
* Function Copy * Function Copy
@ -66,10 +73,6 @@ public:
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
/* Remove "this" from the linked list */
void UnLink();
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
@ -78,19 +81,6 @@ public:
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/**
* Function Insert
* inserts a single TRACK, SEGVIA or SEGZONE, or a list of such,
* into the proper list within a BOARD, either at the
* list's front or immediately after the InsertPoint.
* If Insertpoint == NULL, then insert at the beginning of the proper list.
* If InsertPoint != NULL, then insert immediately after InsertPoint.
* TRACKs and SEGVIAs are put on the m_Track list, SEGZONE on the m_Zone list.
* @param aPcb The BOARD to insert into.
* @param InsertPoint See above
*/
void Insert( BOARD* aPcb, TRACK* InsertPoint );
/** /**
* Function GetBestInsertPoint * Function GetBestInsertPoint
* searches the "best" insertion point within the track linked list. * searches the "best" insertion point within the track linked list.
@ -167,8 +157,11 @@ public:
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 ); int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
bool IsNull(); // return TRUE if segment lenght = 0 /**
* Function IsNull
* returns true if segment length is zero.
*/
bool IsNull();
/** /**
* Function Display_Infos * Function Display_Infos
@ -242,6 +235,14 @@ public:
*/ */
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
/**
* Function ShowState
* converts a set of state bits to a wxString
* @param stateBits Is an OR-ed together set of bits like BUSY, EDIT, etc.
*/
static wxString ShowState( int stateBits );
#endif #endif
}; };
@ -249,7 +250,7 @@ public:
class SEGZONE : public TRACK class SEGZONE : public TRACK
{ {
public: public:
SEGZONE( BOARD_ITEM* StructFather ); SEGZONE( BOARD_ITEM* aParent );
/** /**
* Function GetClass * Function GetClass
@ -269,7 +270,7 @@ public:
class SEGVIA : public TRACK class SEGVIA : public TRACK
{ {
public: public:
SEGVIA( BOARD_ITEM* StructFather ); SEGVIA( BOARD_ITEM* aParent );
SEGVIA( const SEGVIA& source ) : SEGVIA( const SEGVIA& source ) :
TRACK( source ) TRACK( source )

View File

@ -19,7 +19,7 @@
/************************/ /************************/
ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) : ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
BOARD_ITEM( parent, TYPEZONE_CONTAINER ) BOARD_ITEM( parent, TYPE_ZONE_CONTAINER )
{ {
m_NetCode = -1; // Net number for fast comparisons m_NetCode = -1; // Net number for fast comparisons

View File

@ -59,9 +59,6 @@ public:
*/ */
wxPoint& GetPosition(); wxPoint& GetPosition();
void UnLink( void )
{
};
/** /**
* Function copy * Function copy

View File

@ -22,7 +22,7 @@
/* Class SCREEN: classe de gestion d'un affichage */ /* Class SCREEN: classe de gestion d'un affichage */
/***************************************************/ /***************************************************/
/* Constructeur de SCREEN */ /* Constructeur de SCREEN */
PCB_SCREEN::PCB_SCREEN( int idscreen ) : BASE_SCREEN( TYPESCREEN ) PCB_SCREEN::PCB_SCREEN( int idscreen ) : BASE_SCREEN( TYPE_SCREEN )
{ {
// a zero terminated list // a zero terminated list
static const int zoom_list[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0 }; static const int zoom_list[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0 };

View File

@ -180,15 +180,13 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
frame->Affiche_Message( _( "Delete unconnected tracks:" ) ); frame->Affiche_Message( _( "Delete unconnected tracks:" ) );
frame->DrawPanel->m_AbortRequest = FALSE; frame->DrawPanel->m_AbortRequest = FALSE;
// correct via m_End defects and count number of segments // correct via m_End defects
frame->m_Pcb->m_NbSegmTrack = 0;
ii = 0; ii = 0;
for( segment = frame->m_Pcb->m_Track; segment; segment = next ) for( segment = frame->m_Pcb->m_Track; segment; segment = next )
{ {
frame->m_Pcb->m_NbSegmTrack++;
next = segment->Next(); next = segment->Next();
if( segment->Type() == TYPEVIA ) if( segment->Type() == TYPE_VIA )
{ {
if( segment->m_Start != segment->m_End ) if( segment->m_Start != segment->m_End )
{ {
@ -213,13 +211,13 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
next = segment->Next(); next = segment->Next();
// display activity // display activity
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount();
if( percent != oldpercent ) if( percent != oldpercent )
{ {
oldpercent = percent; oldpercent = percent;
frame->DisplayActivity( percent, wxT( "No Conn: " ) ); frame->DisplayActivity( percent, wxT( "No Conn: " ) );
msg.Printf( wxT( "%d " ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d " ), frame->m_Pcb->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d " ), ii ); msg.Printf( wxT( "%d " ), ii );
@ -268,7 +266,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
if( other == NULL ) // Test a connection to zones if( other == NULL ) // Test a connection to zones
{ {
if( segment->Type() != TYPEVIA ) if( segment->Type() != TYPE_VIA )
{ {
zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_Start, segment->GetLayer() ); zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_Start, segment->GetLayer() );
} }
@ -288,7 +286,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
segment->start = other; segment->start = other;
// If a via is connected to this end, test if this via has a second item connected // If a via is connected to this end, test if this via has a second item connected
// if no, remove it with the current segment // if no, remove it with the current segment
if( other && other->Type() == TYPEVIA ) if( other && other->Type() == TYPE_VIA )
{ {
// search for another segment following the via // search for another segment following the via
@ -318,7 +316,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
NULL, END ); NULL, END );
if( other == NULL ) // Test a connection to zones if( other == NULL ) // Test a connection to zones
{ {
if( segment->Type() != TYPEVIA ) if( segment->Type() != TYPE_VIA )
zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_End, segment->GetLayer() ); zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_End, segment->GetLayer() );
else else
@ -334,9 +332,10 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
else // segment, via or zone connected to this end else // segment, via or zone connected to this end
{ {
segment->end = other; segment->end = other;
// If a via is connected to this end, test if this via has a second item connected // If a via is connected to this end, test if this via has a second item connected
// if no, remove it with the current segment // if no, remove it with the current segment
if( other && other->Type() == TYPEVIA ) if( other && other->Type() == TYPE_VIA )
{ {
// search for another segment following the via // search for another segment following the via
@ -442,13 +441,13 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
for( segment = frame->m_Pcb->m_Track, ii = 0; segment; segment = segment->Next(), ii++ ) for( segment = frame->m_Pcb->m_Track, ii = 0; segment; segment = segment->Next(), ii++ )
{ {
/* Display activity */ /* Display activity */
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount();
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, wxT( "Id segm: " ) ); frame->DisplayActivity( percent, wxT( "Id segm: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
@ -519,13 +518,13 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
next = segment->Next(); next = segment->Next();
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount();
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, _( "Merge: " ) ); frame->DisplayActivity( percent, _( "Merge: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
@ -535,7 +534,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
return -1; return -1;
} }
if( segment->Type() != TYPETRACK ) if( segment->Type() != TYPE_TRACK )
continue; continue;
flag = no_inc = 0; flag = no_inc = 0;
@ -552,7 +551,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
break; break;
// it cannot be a via // it cannot be a via
if( segStart->Type() != TYPETRACK ) if( segStart->Type() != TYPE_TRACK )
break; break;
/* We must have only one segment connected */ /* We must have only one segment connected */
@ -588,7 +587,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC )
if( segment->m_Width != segEnd->m_Width ) if( segment->m_Width != segEnd->m_Width )
break; break;
if( segEnd->Type() != TYPETRACK ) if( segEnd->Type() != TYPE_TRACK )
break; break;
/* We must have only one segment connected */ /* We must have only one segment connected */
@ -764,16 +763,16 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
{ {
// display activity // display activity
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount();
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, wxT( "Drc: " ) ); frame->DisplayActivity( percent, wxT( "Drc: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN ); Affiche_1_Parametre( frame, POS_AFF_NUMSEGM, wxT( "Segm" ), msg, CYAN );
if( frame->DrawPanel->m_AbortRequest ) if( frame->DrawPanel->m_AbortRequest )
@ -784,7 +783,7 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
// find the netcode for segment using anything connected to the "start" of "segment" // find the netcode for segment using anything connected to the "start" of "segment"
net_code_s = -1; net_code_s = -1;
if( segment->start && segment->start->Type()==TYPEPAD ) if( segment->start && segment->start->Type()==TYPE_PAD )
{ {
// get the netcode of the pad to propagate. // get the netcode of the pad to propagate.
net_code_s = ((D_PAD*)(segment->start))->GetNet(); net_code_s = ((D_PAD*)(segment->start))->GetNet();
@ -802,7 +801,7 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche )
// find the netcode for segment using anything connected to the "end" of "segment" // find the netcode for segment using anything connected to the "end" of "segment"
net_code_e = -1; net_code_e = -1;
if( segment->end && segment->end->Type()==TYPEPAD ) if( segment->end && segment->end->Type()==TYPE_PAD )
{ {
net_code_e = ((D_PAD*)(segment->end))->GetNet(); net_code_e = ((D_PAD*)(segment->end))->GetNet();
} }
@ -885,13 +884,13 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
{ {
// display activity // display activity
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount();
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, wxT( "Tracks: " ) ); frame->DisplayActivity( percent, wxT( "Tracks: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, wxT( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
@ -915,7 +914,7 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
if( other == segment ) if( other == segment )
continue; continue;
if( other->Type() == TYPEVIA ) if( other->Type() == TYPE_VIA )
continue; continue;
if( segment->m_Start == other->m_Start ) if( segment->m_Start == other->m_Start )
@ -937,11 +936,10 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
msg.Printf( wxT( "%d" ), nn ); msg.Printf( wxT( "%d" ), nn );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New <" ), msg, YELLOW ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New <" ), msg, YELLOW );
frame->m_Pcb->m_NbSegmTrack++;
// create a new segment and insert it next to "other", then shorten other. // create a new segment and insert it next to "other", then shorten other.
newTrack = other->Copy(); newTrack = other->Copy();
newTrack->Insert( frame->m_Pcb, other );
frame->m_Pcb->m_Track.Insert( newTrack, other->Next() );
other->m_End = segment->m_Start; other->m_End = segment->m_Start;
newTrack->m_Start = segment->m_Start; newTrack->m_Start = segment->m_Start;
@ -964,7 +962,7 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
if( other == segment ) if( other == segment )
continue; continue;
if( other->Type() == TYPEVIA ) if( other->Type() == TYPE_VIA )
continue; continue;
if( segment->m_End == other->m_Start ) if( segment->m_End == other->m_Start )
@ -985,11 +983,9 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC )
msg.Printf( wxT( "%d" ), nn ); msg.Printf( wxT( "%d" ), nn );
Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New >" ), msg, YELLOW ); Affiche_1_Parametre( frame, POS_AFF_VAR, wxT( "New >" ), msg, YELLOW );
frame->m_Pcb->m_NbSegmTrack++;
// create a new segment and insert it next to "other", then shorten other. // create a new segment and insert it next to "other", then shorten other.
newTrack = other->Copy(); newTrack = other->Copy();
newTrack->Insert( frame->m_Pcb, other ); frame->m_Pcb->m_Track.Insert( newTrack, other->Next() );
other->m_End = segment->m_End; other->m_End = segment->m_End;
newTrack->m_Start = segment->m_End; newTrack->m_Start = segment->m_End;
@ -1023,7 +1019,7 @@ static void ConnectDanglingEndToVia( BOARD* pcb )
{ {
SEGVIA* via; SEGVIA* via;
if( track->Type()!=TYPEVIA || (via = (SEGVIA*)track)->GetNet()!=0 ) if( track->Type()!=TYPE_VIA || (via = (SEGVIA*)track)->GetNet()!=0 )
continue; continue;
for( TRACK* other = pcb->m_Track; other; other = other->Next() ) for( TRACK* other = pcb->m_Track; other; other = other->Next() )
@ -1039,7 +1035,8 @@ static void ConnectDanglingEndToVia( BOARD* pcb )
if( other->m_End!=via->GetPosition() && via->HitTest( other->m_Start ) && !other->start ) if( other->m_End!=via->GetPosition() && via->HitTest( other->m_Start ) && !other->start )
{ {
TRACK* newTrack = other->Copy(); TRACK* newTrack = other->Copy();
newTrack->Insert( pcb, other );
pcb->m_Track.Insert( newTrack, other->Next() );
newTrack->m_End = via->GetPosition(); newTrack->m_End = via->GetPosition();
@ -1061,7 +1058,8 @@ static void ConnectDanglingEndToVia( BOARD* pcb )
else if( other->m_Start!=via->GetPosition() && via->HitTest( other->m_End ) && !other->end ) else if( other->m_Start!=via->GetPosition() && via->HitTest( other->m_End ) && !other->end )
{ {
TRACK* newTrack = other->Copy(); TRACK* newTrack = other->Copy();
newTrack->Insert( pcb, other );
pcb->m_Track.Insert( newTrack, other->Next() );
newTrack->m_Start = via->GetPosition(); newTrack->m_Start = via->GetPosition();
@ -1111,13 +1109,13 @@ void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC )
D_PAD* pad; D_PAD* pad;
ii++; ii++;
percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount();
if( percent != oldpercent ) if( percent != oldpercent )
{ {
frame->DisplayActivity( percent, _( "Pads: " ) ); frame->DisplayActivity( percent, _( "Pads: " ) );
oldpercent = percent; oldpercent = percent;
msg.Printf( wxT( "%d" ), frame->m_Pcb->m_NbSegmTrack ); msg.Printf( wxT( "%d" ), frame->m_Pcb->m_Track.GetCount() );
Affiche_1_Parametre( frame, POS_AFF_MAX, _( "Max" ), msg, GREEN ); Affiche_1_Parametre( frame, POS_AFF_MAX, _( "Max" ), msg, GREEN );
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), ii );
@ -1137,7 +1135,8 @@ void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC )
NULL, START ) == NULL ) NULL, START ) == NULL )
{ {
TRACK* newTrack = segment->Copy(); TRACK* newTrack = segment->Copy();
newTrack->Insert( frame->m_Pcb, segment );
frame->m_Pcb->m_Track.Insert( newTrack, segment->Next() );
newTrack->m_End = pad->m_Pos; newTrack->m_End = pad->m_Pos;
@ -1162,7 +1161,8 @@ void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC )
NULL, END ) == NULL ) NULL, END ) == NULL )
{ {
TRACK* newTrack = segment->Copy(); TRACK* newTrack = segment->Copy();
newTrack->Insert( frame->m_Pcb, segment );
frame->m_Pcb->m_Track.Insert( newTrack, segment->Next() );
newTrack->m_Start = pad->m_Pos; newTrack->m_Start = pad->m_Pos;

View File

@ -36,86 +36,86 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
// there are some restrictions on the order of items in the general case. // there are some restrictions on the order of items in the general case.
// all items in m_Drawings for instance should be contiguous. // all items in m_Drawings for instance should be contiguous.
// *** all items in a same list (shown here) must be contiguous **** // *** all items in a same list (shown here) must be contiguous ****
TYPEMARKER, // in m_markers TYPE_MARKER, // in m_markers
TYPETEXTE, // in m_Drawings TYPE_TEXTE, // in m_Drawings
TYPEDRAWSEGMENT, // in m_Drawings TYPE_DRAWSEGMENT, // in m_Drawings
TYPECOTATION, // in m_Drawings TYPE_COTATION, // in m_Drawings
TYPEMIRE, // in m_Drawings TYPE_MIRE, // in m_Drawings
TYPEVIA, // in m_Tracks TYPE_VIA, // in m_Tracks
TYPETRACK, // in m_Tracks TYPE_TRACK, // in m_Tracks
TYPEPAD, // in modules TYPE_PAD, // in modules
TYPETEXTEMODULE, // in modules TYPE_TEXTE_MODULE, // in modules
TYPEMODULE, // in m_Modules TYPE_MODULE, // in m_Modules
TYPEZONE, // in m_Zones TYPE_ZONE, // in m_Zones
TYPEZONE_CONTAINER, // in m_ZoneDescriptorList TYPE_ZONE_CONTAINER, // in m_ZoneDescriptorList
EOT EOT
}; };
/* /*
* const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = { * const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
* TYPETEXTE, * TYPE_TEXTE,
* TYPEDRAWSEGMENT, * TYPE_DRAWSEGMENT,
* TYPECOTATION, * TYPE_COTATION,
* TYPEVIA, * TYPE_VIA,
* TYPETRACK, * TYPE_TRACK,
* TYPEMODULE, * TYPE_MODULE,
* EOT * EOT
* }; * };
*/ */
const KICAD_T GENERAL_COLLECTOR::AllButZones[] = { const KICAD_T GENERAL_COLLECTOR::AllButZones[] = {
TYPEMARKER, TYPE_MARKER,
TYPETEXTE, TYPE_TEXTE,
TYPEDRAWSEGMENT, TYPE_DRAWSEGMENT,
TYPECOTATION, TYPE_COTATION,
TYPEMIRE, TYPE_MIRE,
TYPEVIA, TYPE_VIA,
TYPETRACK, TYPE_TRACK,
TYPEPAD, TYPE_PAD,
TYPETEXTEMODULE, TYPE_TEXTE_MODULE,
TYPEMODULE, TYPE_MODULE,
TYPEZONE_CONTAINER, // if it is visible on screen, it should be selectable TYPE_ZONE_CONTAINER, // if it is visible on screen, it should be selectable
EOT EOT
}; };
const KICAD_T GENERAL_COLLECTOR::ModuleItems[] = { const KICAD_T GENERAL_COLLECTOR::ModuleItems[] = {
TYPEMODULE, TYPE_MODULE,
EOT EOT
}; };
const KICAD_T GENERAL_COLLECTOR::PadsOrModules[] = { const KICAD_T GENERAL_COLLECTOR::PadsOrModules[] = {
TYPEPAD, TYPE_PAD,
TYPEMODULE, TYPE_MODULE,
EOT EOT
}; };
const KICAD_T GENERAL_COLLECTOR::PadsTracksOrZones[] = { const KICAD_T GENERAL_COLLECTOR::PadsTracksOrZones[] = {
TYPEPAD, TYPE_PAD,
TYPEVIA, TYPE_VIA,
TYPETRACK, TYPE_TRACK,
TYPEZONE, TYPE_ZONE,
TYPEZONE_CONTAINER, TYPE_ZONE_CONTAINER,
EOT EOT
}; };
const KICAD_T GENERAL_COLLECTOR::ModulesAndTheirItems[] = { const KICAD_T GENERAL_COLLECTOR::ModulesAndTheirItems[] = {
TYPETEXTEMODULE, TYPE_TEXTE_MODULE,
TYPEEDGEMODULE, TYPE_EDGE_MODULE,
TYPEPAD, TYPE_PAD,
TYPEMODULE, TYPE_MODULE,
EOT EOT
}; };
const KICAD_T GENERAL_COLLECTOR::Tracks[] = { const KICAD_T GENERAL_COLLECTOR::Tracks[] = {
TYPETRACK, TYPE_TRACK,
TYPEVIA, TYPE_VIA,
EOT EOT
}; };
@ -142,7 +142,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEPAD: case TYPE_PAD:
{ {
MODULE* m = (MODULE*) item->GetParent(); MODULE* m = (MODULE*) item->GetParent();
if( m->GetReference() == wxT( "Y2" ) ) if( m->GetReference() == wxT( "Y2" ) )
@ -152,31 +152,31 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
} }
break; break;
case TYPEVIA: case TYPE_VIA:
breakhere++; breakhere++;
break; break;
case TYPETRACK: case TYPE_TRACK:
breakhere++; breakhere++;
break; break;
case TYPEZONE: case TYPE_ZONE:
breakhere++; breakhere++;
break; break;
case TYPETEXTE: case TYPE_TEXTE:
breakhere++; breakhere++;
break; break;
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
breakhere++; breakhere++;
break; break;
case TYPECOTATION: case TYPE_COTATION:
breakhere++; breakhere++;
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
{ {
TEXTE_MODULE* tm = (TEXTE_MODULE*) item; TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
if( tm->m_Text == wxT( "10uH" ) ) if( tm->m_Text == wxT( "10uH" ) )
@ -186,7 +186,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
} }
break; break;
case TYPEMODULE: case TYPE_MODULE:
{ {
MODULE* m = (MODULE*) item; MODULE* m = (MODULE*) item;
if( m->GetReference() == wxT( "C98" ) ) if( m->GetReference() == wxT( "C98" ) )
@ -206,7 +206,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEPAD: case TYPE_PAD:
// if pad is a thru hole, then it can be visible when its parent module is not. // if pad is a thru hole, then it can be visible when its parent module is not.
if( ( (D_PAD*) item )->m_Attribut != PAD_SMD ) // a hole is present, so multiple layers if( ( (D_PAD*) item )->m_Attribut != PAD_SMD ) // a hole is present, so multiple layers
@ -219,31 +219,31 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
module = (MODULE*) item->GetParent(); module = (MODULE*) item->GetParent();
break; break;
case TYPEVIA: case TYPE_VIA:
break; break;
case TYPETRACK: case TYPE_TRACK:
break; break;
case TYPEZONE: case TYPE_ZONE:
break; break;
case TYPEZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
break; break;
case TYPETEXTE: case TYPE_TEXTE:
break; break;
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
break; break;
case TYPECOTATION: case TYPE_COTATION:
break; break;
case TYPEMIRE: case TYPE_MIRE:
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
module = (MODULE*) item->GetParent(); module = (MODULE*) item->GetParent();
if( m_Guide->IgnoreMTextsMarkedNoShow() && ( (TEXTE_MODULE*) item )->m_NoShow ) if( m_Guide->IgnoreMTextsMarkedNoShow() && ( (TEXTE_MODULE*) item )->m_NoShow )
@ -259,7 +259,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
} }
break; break;
case TYPEMODULE: case TYPE_MODULE:
module = (MODULE*) item; module = (MODULE*) item;
break; break;
@ -269,7 +269,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
// common tests: // common tests:
if( module ) // true from case TYPEPAD, TYPETEXTEMODULE, or TYPEMODULE if( module ) // true from case TYPE_PAD, TYPE_TEXTE_MODULE, or TYPE_MODULE
{ {
if( m_Guide->IgnoreModulesOnCu() && module->GetLayer()==COPPER_LAYER_N ) if( m_Guide->IgnoreModulesOnCu() && module->GetLayer()==COPPER_LAYER_N )
goto exit; goto exit;

View File

@ -121,7 +121,7 @@ public:
* Function IgnoreZones * Function IgnoreZones
* @return bool - true if should ignore zones. * @return bool - true if should ignore zones.
virtual bool IgnoreZones() const = 0; virtual bool IgnoreZones() const = 0;
can simply omit from scanTypes[] TYPEZONE */ can simply omit from scanTypes[] TYPE_ZONE */
/** /**
* Function IgnoreMTextsOnCu * Function IgnoreMTextsOnCu

View File

@ -11,6 +11,7 @@
#include "protos.h" #include "protos.h"
//#include <algorithm>
extern void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb ); extern void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb );
extern void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode ); extern void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode );
@ -19,7 +20,6 @@ extern void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode );
static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn ); static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn );
static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* pt_end_conn ); static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* pt_end_conn );
static void RebuildTrackChain( BOARD* pcb ); static void RebuildTrackChain( BOARD* pcb );
static int Sort_By_NetCode( TRACK** pt_ref, TRACK** pt_compare );
/*..*/ /*..*/
@ -65,14 +65,14 @@ static int Merge_Two_SubNets( TRACK* pt_start_conn, TRACK* pt_end_conn, int old_
nb_change++; nb_change++;
pt_conn->SetSubNet( new_val ); pt_conn->SetSubNet( new_val );
if( pt_conn->start && ( pt_conn->start->Type() == TYPEPAD) ) if( pt_conn->start && ( pt_conn->start->Type() == TYPE_PAD) )
{ {
pt_pad = (D_PAD*) (pt_conn->start); pt_pad = (D_PAD*) (pt_conn->start);
if( pt_pad->GetSubNet() == old_val ) if( pt_pad->GetSubNet() == old_val )
pt_pad->SetSubNet(pt_conn->GetSubNet()); pt_pad->SetSubNet(pt_conn->GetSubNet());
} }
if( pt_conn->end && (pt_conn->end->Type() == TYPEPAD) ) if( pt_conn->end && (pt_conn->end->Type() == TYPE_PAD) )
{ {
pt_pad = (D_PAD*) (pt_conn->end); pt_pad = (D_PAD*) (pt_conn->end);
if( pt_pad->GetSubNet() == old_val ) if( pt_pad->GetSubNet() == old_val )
@ -114,11 +114,11 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn )
{ {
pt_conn->SetSubNet( 0 ); pt_conn->SetSubNet( 0 );
PtStruct = pt_conn->start; PtStruct = pt_conn->start;
if( PtStruct && (PtStruct->Type() == TYPEPAD) ) if( PtStruct && (PtStruct->Type() == TYPE_PAD) )
( (D_PAD*) PtStruct )->SetSubNet( 0); ( (D_PAD*) PtStruct )->SetSubNet( 0);
PtStruct = pt_conn->end; PtStruct = pt_conn->end;
if( PtStruct && (PtStruct->Type() == TYPEPAD) ) if( PtStruct && (PtStruct->Type() == TYPE_PAD) )
( (D_PAD*) PtStruct )->SetSubNet( 0); ( (D_PAD*) PtStruct )->SetSubNet( 0);
if( pt_conn == pt_end_conn ) if( pt_conn == pt_end_conn )
@ -136,7 +136,7 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn )
PtStruct = pt_conn->start; PtStruct = pt_conn->start;
/* The segment starts on a pad */ /* The segment starts on a pad */
if( PtStruct && (PtStruct->Type() == TYPEPAD) ) if( PtStruct && (PtStruct->Type() == TYPE_PAD) )
{ {
pt_pad = (D_PAD*) PtStruct; pt_pad = (D_PAD*) PtStruct;
if( pt_conn->GetSubNet() ) /* the track segment is already a cluster member */ if( pt_conn->GetSubNet() ) /* the track segment is already a cluster member */
@ -165,7 +165,7 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn )
} }
PtStruct = pt_conn->end; PtStruct = pt_conn->end;
if( PtStruct && (PtStruct->Type() == TYPEPAD) ) if( PtStruct && (PtStruct->Type() == TYPE_PAD) )
/* The segment end on a pad */ /* The segment end on a pad */
{ {
pt_pad = (D_PAD*) PtStruct; pt_pad = (D_PAD*) PtStruct;
@ -197,7 +197,7 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn )
/* Test connections between segments */ /* Test connections between segments */
PtStruct = pt_conn->start; PtStruct = pt_conn->start;
if( PtStruct && (PtStruct->Type() != TYPEPAD) ) if( PtStruct && (PtStruct->Type() != TYPE_PAD) )
{ {
/* The segment starts on an other track */ /* The segment starts on an other track */
pt_autre_piste = (TRACK*) PtStruct; pt_autre_piste = (TRACK*) PtStruct;
@ -230,7 +230,7 @@ static void Propagate_SubNet( TRACK* pt_start_conn, TRACK* pt_end_conn )
} }
PtStruct = pt_conn->end; // Do the same calculations for the segment end point PtStruct = pt_conn->end; // Do the same calculations for the segment end point
if( PtStruct && (PtStruct->Type() != TYPEPAD) ) if( PtStruct && (PtStruct->Type() != TYPE_PAD) )
{ {
pt_autre_piste = (TRACK*) PtStruct; pt_autre_piste = (TRACK*) PtStruct;
@ -276,31 +276,29 @@ void WinEDA_BasePcbFrame::test_connexions( wxDC* DC )
* @param DC = current Device Context * @param DC = current Device Context
*/ */
{ {
TRACK* pt_start_conn, * pt_end_conn; // Clear the cluster identifier for all pads
int ii; for( unsigned i = 0; i< m_Pcb->m_Pads.size(); ++i )
LISTE_PAD* pt_pad;
int current_net_code;
/* Clear the cluster identifier for all pads */
pt_pad = m_Pcb->m_Pads;
for( ii = 0; ii < m_Pcb->m_NbPads; ii++, pt_pad++ )
{ {
(*pt_pad)->SetZoneSubNet( 0 ); D_PAD* pad = m_Pcb->m_Pads[i];
(*pt_pad)->SetSubNet( 0 );
pad->SetZoneSubNet( 0 );
pad->SetSubNet( 0 );
} }
m_Pcb->Test_Connections_To_Copper_Areas( ); m_Pcb->Test_Connections_To_Copper_Areas();
/* Test existing connections net by net */ // Test existing connections net by net
pt_start_conn = m_Pcb->m_Track; // this is the first segment of the first net for( TRACK* track = m_Pcb->m_Track; track; )
while( pt_start_conn != NULL )
{ {
current_net_code = pt_start_conn->GetNet(); // this is the current net because pt_start_conn is the first segment of the net // this is the current net because pt_start_conn is the first segment of the net
pt_end_conn = pt_start_conn->GetEndNetCode( current_net_code ); // this is the last segment of the current net int current_net_code = track->GetNet();
Build_Pads_Info_Connections_By_Tracks( pt_start_conn, pt_end_conn ); // this is the last segment of the current net
TRACK* pt_end_conn = track->GetEndNetCode( current_net_code );
pt_start_conn = pt_end_conn->Next(); // this is now the first segment of the next net Build_Pads_Info_Connections_By_Tracks( track, pt_end_conn );
track = pt_end_conn->Next(); // this is now the first segment of the next net
} }
Merge_SubNets_Connected_By_CopperAreas( m_Pcb ); Merge_SubNets_Connected_By_CopperAreas( m_Pcb );
@ -319,9 +317,6 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code )
* @param net_code = net code to test * @param net_code = net code to test
*/ */
{ {
TRACK* pt_start_conn, * pt_end_conn;
int ii, nb_net_noconnect = 0;
LISTE_PAD* pt_pad;
wxString msg; wxString msg;
if( net_code == 0 ) if( net_code == 0 )
@ -330,17 +325,19 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code )
if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 )
Compile_Ratsnest( DC, TRUE ); Compile_Ratsnest( DC, TRUE );
pt_pad = (LISTE_PAD*) m_Pcb->m_Pads; for( unsigned i=0; i<m_Pcb->m_Pads.size(); ++i )
for( ii = 0; ii < m_Pcb->m_NbPads; ii++, pt_pad++ )
{ {
int pad_net_code = (*pt_pad)->GetNet(); D_PAD* pad = m_Pcb->m_Pads[i];
int pad_net_code = pad->GetNet();
if( pad_net_code < net_code ) if( pad_net_code < net_code )
continue; continue;
if( pad_net_code > net_code ) if( pad_net_code > net_code )
break; break;
(*pt_pad)->SetSubNet( 0 ); pad->SetSubNet( 0 );
} }
m_Pcb->Test_Connections_To_Copper_Areas( net_code ); m_Pcb->Test_Connections_To_Copper_Areas( net_code );
@ -348,8 +345,11 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code )
/* Search for the first and the last segment relative to the given net code */ /* Search for the first and the last segment relative to the given net code */
if( m_Pcb->m_Track ) if( m_Pcb->m_Track )
{ {
TRACK* pt_start_conn;
TRACK* pt_end_conn;
pt_end_conn = NULL; pt_end_conn = NULL;
pt_start_conn = m_Pcb->m_Track->GetStartNetCode( net_code ); pt_start_conn = m_Pcb->m_Track.GetFirst()->GetStartNetCode( net_code );
if( pt_start_conn ) if( pt_start_conn )
pt_end_conn = pt_start_conn->GetEndNetCode( net_code ); pt_end_conn = pt_start_conn->GetEndNetCode( net_code );
@ -362,7 +362,7 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code )
Merge_SubNets_Connected_By_CopperAreas( m_Pcb, net_code ); Merge_SubNets_Connected_By_CopperAreas( m_Pcb, net_code );
/* Test the rastnest for this net */ /* Test the rastnest for this net */
nb_net_noconnect = Test_1_Net_Ratsnest( DC, net_code ); int nb_net_noconnect = Test_1_Net_Ratsnest( DC, net_code );
/* Display results */ /* Display results */
msg.Printf( wxT( "links %d nc %d net:nc %d" ), msg.Printf( wxT( "links %d nc %d net:nc %d" ),
@ -408,7 +408,7 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK*
/* Update connections type track to track */ /* Update connections type track to track */
for( Track = pt_start_conn; Track != NULL; Track = Track->Next() ) for( Track = pt_start_conn; Track != NULL; Track = Track->Next() )
{ {
if( Track->Type() == TYPEVIA ) // A via can connect many tracks, we must search for all track segments in this net if( Track->Type() == TYPE_VIA ) // A via can connect many tracks, we must search for all track segments in this net
{ {
TRACK* pt_segm; TRACK* pt_segm;
int layermask = Track->ReturnMaskLayer(); int layermask = Track->ReturnMaskLayer();
@ -452,14 +452,11 @@ static void Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK*
#define POS_AFF_CHREF 62 #define POS_AFF_CHREF 62
/******************************************************************************/ /**
static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, * Function SuperFast_Locate_Pad_Connecte
const wxPoint & posref, int masque_layer ) * locates the pad connected to a track ended at coord px, py.
/******************************************************************************/ * A track is seen as connected if the px, py position is same as the pad position.
*
/** Function SuperFast_Locate_Pad_Connecte
* Locate the pad connected to a track ended at coord px, py
* A track is seen as connected if the px, py position is same as the pad position
* @param aPcb = the board. * @param aPcb = the board.
* @param pt_liste = Pointers to pads buffer * @param pt_liste = Pointers to pads buffer
* This buffer is a list like the list created by build_liste_pad, but sorted by increasing X pad coordinate * This buffer is a list like the list created by build_liste_pad, but sorted by increasing X pad coordinate
@ -471,13 +468,16 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste,
* *
* (Note: The usual pad list (created by build_liste_pad) m_Pcb->m_Pads is sorted by increasing netcodes ) * (Note: The usual pad list (created by build_liste_pad) m_Pcb->m_Pads is sorted by increasing netcodes )
*/ */
static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste,
const wxPoint& posref, int masque_layer )
{ {
D_PAD* pad; D_PAD* pad;
LISTE_PAD* ptr_pad, * lim;
int nb_pad = aPcb->m_NbPads;
int ii; int ii;
lim = pt_liste + (aPcb->m_NbPads - 1 ); int nb_pad = aPcb->m_Pads.size();
LISTE_PAD* ptr_pad = pt_liste;
LISTE_PAD* lim = pt_liste + nb_pad - 1;
ptr_pad = pt_liste; ptr_pad = pt_liste;
while( nb_pad ) while( nb_pad )
{ {
@ -540,10 +540,12 @@ static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste,
} }
static int SortPadsByXCoord( const void* pt_ref, const void* pt_comp )
/* used to Sort a pad list by x coordinate value /**
* Function SortPadsByXCoord
* is used to Sort a pad list by x coordinate value.
*/ */
static int SortPadsByXCoord( const void* pt_ref, const void* pt_comp )
{ {
D_PAD* ref = *(LISTE_PAD*) pt_ref; D_PAD* ref = *(LISTE_PAD*) pt_ref;
D_PAD* comp = *(LISTE_PAD*) pt_comp; D_PAD* comp = *(LISTE_PAD*) pt_comp;
@ -552,15 +554,14 @@ static int SortPadsByXCoord( const void* pt_ref, const void* pt_comp )
} }
/*****************************************************************************/ /*****************************************************************************/
void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector ) void CreateSortedPadListByXCoord( BOARD* aBoard, std::vector<D_PAD*>* aVector )
/*****************************************************************************/ /*****************************************************************************/
{ {
aVector->resize( aBoard->m_NbPads ); aVector->insert( aVector->end(), aBoard->m_Pads.begin(), aBoard->m_Pads.end() );
memcpy( &(*aVector)[0], aBoard->m_Pads, aBoard->m_NbPads * sizeof( D_PAD*) ); qsort( &(*aVector)[0], aBoard->m_Pads.size(), sizeof( D_PAD*), SortPadsByXCoord );
qsort( &(*aVector)[0], aBoard->m_NbPads, sizeof( D_PAD*), SortPadsByXCoord );
} }
@ -584,7 +585,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
int masque_layer; int masque_layer;
wxString msg; wxString msg;
if( m_Pcb->m_NbPads == 0 ) if( m_Pcb->m_Pads.size() == 0 )
return; return;
a_color = CYAN; a_color = CYAN;
@ -692,7 +693,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
/* look for vias which could be connect many tracks */ /* look for vias which could be connect many tracks */
for( TRACK* via = m_Pcb->m_Track; via != NULL; via = via->Next() ) for( TRACK* via = m_Pcb->m_Track; via != NULL; via = via->Next() )
{ {
if( via->Type() != TYPEVIA ) if( via->Type() != TYPE_VIA )
continue; continue;
if( via->GetNet() > 0 ) if( via->GetNet() > 0 )
@ -729,7 +730,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
{ {
/* look for the connection to the current segment starting point */ /* look for the connection to the current segment starting point */
PtStruct = (BOARD_ITEM*) pt_piste->start; PtStruct = (BOARD_ITEM*) pt_piste->start;
if( PtStruct && (PtStruct->Type() != TYPEPAD) ) if( PtStruct && (PtStruct->Type() != TYPE_PAD) )
{ {
// Begin on an other track segment // Begin on an other track segment
pt_next = (TRACK*) PtStruct; pt_next = (TRACK*) PtStruct;
@ -753,7 +754,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
/* look for the connection to the current segment ending point */ /* look for the connection to the current segment ending point */
PtStruct = pt_piste->end; PtStruct = pt_piste->end;
if( PtStruct &&(PtStruct->Type() != TYPEPAD) ) if( PtStruct &&(PtStruct->Type() != TYPE_PAD) )
{ {
pt_next = (TRACK*) PtStruct; pt_next = (TRACK*) PtStruct;
@ -788,60 +789,53 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche )
} }
/* /**
* Sort function for track segments used in RebuildTrackChain() (for the qsort C function) * Function Sort_By_NetCode
* The sorting is made by net code * sorts track segments used in RebuildTrackChain() (for the qsort C function)
* The sorting is made by net code.
*/ */
int Sort_By_NetCode( TRACK** pt_ref, TRACK** pt_compare ) static int Sort_By_NetCode( const void* left, const void* right )
{ {
int ii; TRACK* pt_ref = *(TRACK**) left;
TRACK* pt_compare = *(TRACK**) right;
ii = (*pt_ref)->GetNet() - (*pt_compare)->GetNet(); int ret = pt_ref->GetNet() - pt_compare->GetNet();
return ii;
return ret;
} }
/*****************************************/ /**
static void RebuildTrackChain( BOARD* pcb ) * Function RebuildTrackChain
/*****************************************/ * rebuilds the track segment linked list in order to have a chain
* sorted by increasing netcodes.
/** Function RebuildTrackChain()
* @param pcb = board to rebuild * @param pcb = board to rebuild
* Rebuild the track segment linked list in order to have a chain sorted by increasing netcodes
*/ */
static void RebuildTrackChain( BOARD* pcb )
{ {
TRACK* Track, ** Liste;
int ii, nbsegm;
/* Count segments */
nbsegm = pcb->GetNumSegmTrack();
if( pcb->m_Track == NULL ) if( pcb->m_Track == NULL )
return; return;
Liste = (TRACK**) MyZMalloc( (nbsegm + 1) * sizeof(TRACK*) ); int nbsegm = pcb->m_Track.GetCount();
ii = 0; Track = pcb->m_Track; TRACK** array = (TRACK**) MyZMalloc( nbsegm * sizeof(TRACK*) );
for( ; Track != NULL; ii++, Track = Track->Next() )
for( int i=0; i<nbsegm; ++i )
{ {
Liste[ii] = Track; array[i] = pcb->m_Track.PopFront();
wxASSERT( array[i] );
} }
qsort( Liste, nbsegm, sizeof(TRACK*), // the list is empty now
( int( * ) ( const void*, const void* ) )Sort_By_NetCode ); wxASSERT( pcb->m_Track == NULL && pcb->m_Track.GetCount()==0 );
/* Update the linked list pointers */ qsort( array, nbsegm, sizeof(TRACK*), Sort_By_NetCode );
Track = Liste[0]; // add them back to the list
Track->SetBack( pcb ); for( int i=0; i<nbsegm; ++i )
Track->SetNext( Liste[1] );
pcb->m_Track = Track;
for( ii = 1; ii < nbsegm; ii++ )
{ {
Track = Liste[ii]; pcb->m_Track.PushBack( array[i] );
Track->SetBack( Liste[ii - 1] );
Track->SetNext( Liste[ii + 1] );
} }
MyFree( Liste ); MyFree( array );
} }

View File

@ -30,7 +30,7 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle
for( int i = 0; i<count; ++i ) for( int i = 0; i<count; ++i )
{ {
if( (*aCollector)[i]->Type() != TYPEMODULE ) if( (*aCollector)[i]->Type() != TYPE_MODULE )
return NULL; return NULL;
} }
@ -131,7 +131,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
for( int ii = 0; ii < m_Collector->GetCount(); ii++ ) for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
{ {
item = (*m_Collector)[ii]; item = (*m_Collector)[ii];
if( item->Type() != TYPEZONE ) if( item->Type() != TYPE_ZONE )
continue; continue;
/* Found a TYPE ZONE */ /* Found a TYPE ZONE */
@ -151,9 +151,9 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
} }
// If the count is 2, and first item is a pad or moduletext, and the 2nd item is its parent module: // If the count is 2, and first item is a pad or moduletext, and the 2nd item is its parent module:
else if( m_Collector->GetCount() == 2 else if( m_Collector->GetCount() == 2
&& ( (*m_Collector)[0]->Type() == TYPEPAD || (*m_Collector)[0]->Type() == && ( (*m_Collector)[0]->Type() == TYPE_PAD || (*m_Collector)[0]->Type() ==
TYPETEXTEMODULE ) TYPE_TEXTE_MODULE )
&& (*m_Collector)[1]->Type() == TYPEMODULE && (*m_Collector)[0]->GetParent()== && (*m_Collector)[1]->Type() == TYPE_MODULE && (*m_Collector)[0]->GetParent()==
(*m_Collector)[1] ) (*m_Collector)[1] )
{ {
item = (*m_Collector)[0]; item = (*m_Collector)[0];
@ -271,15 +271,12 @@ static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
*/ */
bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ) bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track )
{ {
wxPoint vec;
double t;
if( track->m_Start == track->m_End ) if( track->m_Start == track->m_End )
return false; return false;
vec = track->m_End-track->m_Start; wxPoint vec = track->m_End - track->m_Start;
t = double( on_grid.x - track->m_Start.x ) * vec.x + double t = double( on_grid.x - track->m_Start.x ) * vec.x +
double( on_grid.y - track->m_Start.y ) * vec.y; double( on_grid.y - track->m_Start.y ) * vec.y;
t /= (double) vec.x * vec.x + (double) vec.y * vec.y; t /= (double) vec.x * vec.x + (double) vec.y * vec.y;
@ -313,7 +310,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
// D( printf( "currTrack=%p currItem=%p currTrack->Type()=%d currItem->Type()=%d\n", currTrack, currItem, currTrack ? currTrack->Type() : 0, currItem ? currItem->Type() : 0 ); ) // D( printf( "currTrack=%p currItem=%p currTrack->Type()=%d currItem->Type()=%d\n", currTrack, currItem, currTrack ? currTrack->Type() : 0, currItem ? currItem->Type() : 0 ); )
if( !currTrack && currItem && currItem->Type()==TYPEVIA && currItem->m_Flags ) if( !currTrack && currItem && currItem->Type()==TYPE_VIA && currItem->m_Flags )
{ {
// moving a VIA // moving a VIA
currTrack = (TRACK*) currItem; currTrack = (TRACK*) currItem;
@ -381,7 +378,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
} }
else else
{ {
// D( printf( "skipping self\n" ); ) //D( printf( "skipping self\n" ); )
} }
} }
@ -390,8 +387,11 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
int layer_mask = g_TabOneLayerMask[layer]; int layer_mask = g_TabOneLayerMask[layer];
TRACK* track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE ); TRACK* track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE );
if( !track || track->Type() != TYPETRACK ) if( !track || track->Type() != TYPE_TRACK )
{
// D(printf("!currTrack and track=%p not found, layer_mask=0x%X\n", track, layer_mask );)
return false; return false;
}
// D( printf( "Project\n" ); ) // D( printf( "Project\n" ); )
return Project( curpos, on_grid, track ); return Project( curpos, on_grid, track );
@ -413,13 +413,13 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{ {
if( track->Type() != TYPETRACK ) if( track->Type() != TYPE_TRACK )
continue; continue;
if( doCheckNet && currTrack && currTrack->GetNet() != track->GetNet() ) if( doCheckNet && currTrack && currTrack->GetNet() != track->GetNet() )
continue; continue;
if( (g_DesignSettings.m_LayerColor[track->GetLayer()] & ITEM_NOT_SHOW) ) if( g_DesignSettings.m_LayerColor[track->GetLayer()] & ITEM_NOT_SHOW )
continue; continue;
// omit the layer check if moving a via // omit the layer check if moving a via
@ -429,6 +429,8 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
if( !track->HitTest( *curpos ) ) if( !track->HitTest( *curpos ) )
continue; continue;
D(printf( "have track prospect\n");)
if( Join( curpos, track->m_Start, track->m_End, currTrack->m_Start, currTrack->m_End ) ) if( Join( curpos, track->m_Start, track->m_End, currTrack->m_Start, currTrack->m_End ) )
{ {
// D(printf( "join currTrack->Type()=%d\n", currTrack->Type() );) // D(printf( "join currTrack->Type()=%d\n", currTrack->Type() );)
@ -448,8 +450,8 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
double( curpos->y - track->m_End.y )); double( curpos->y - track->m_End.y ));
// if track not via, or if its a via dragging but not with its adjacent track // if track not via, or if its a via dragging but not with its adjacent track
if( currTrack->Type() != TYPEVIA if( currTrack->Type() != TYPE_VIA
|| ( currTrack->m_Start!=track->m_Start && currTrack->m_Start!=track->m_End )) || ( currTrack->m_Start != track->m_Start && currTrack->m_Start != track->m_End ))
{ {
if( distStart <= currTrack->m_Width/2 ) if( distStart <= currTrack->m_Width/2 )
{ {

View File

@ -280,12 +280,7 @@ COTATION* WinEDA_PcbFrame::Begin_Cotation( COTATION* Cotation, wxDC* DC )
Cotation->m_Flags = 0; Cotation->m_Flags = 0;
/* Insertion de la structure dans le Chainage .Drawings du PCB */ /* Insertion de la structure dans le Chainage .Drawings du PCB */
Cotation->SetBack( m_Pcb ); m_Pcb->Add( Cotation );
Cotation->SetNext( m_Pcb->m_Drawings );
if( m_Pcb->m_Drawings )
m_Pcb->m_Drawings->SetBack( Cotation );
m_Pcb->m_Drawings = Cotation;
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;

View File

@ -148,13 +148,13 @@ void WinEDA_PcbFrame::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
switch( objectToSync->Type() ) switch( objectToSync->Type() )
{ {
case TYPEMODULE: case TYPE_MODULE:
module = (MODULE*) objectToSync; module = (MODULE*) objectToSync;
sprintf( cmd, "$PART: \"%s\"", sprintf( cmd, "$PART: \"%s\"",
CONV_TO_UTF8( module->m_Reference->m_Text ) ); CONV_TO_UTF8( module->m_Reference->m_Text ) );
break; break;
case TYPEPAD: case TYPE_PAD:
module = (MODULE*) objectToSync->GetParent(); module = (MODULE*) objectToSync->GetParent();
pad = (D_PAD*) objectToSync; pad = (D_PAD*) objectToSync;
msg = pad->ReturnStringPadName(); msg = pad->ReturnStringPadName();
@ -163,7 +163,7 @@ void WinEDA_PcbFrame::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync )
CONV_TO_UTF8( msg ) ); CONV_TO_UTF8( msg ) );
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
#define REFERENCE 0 #define REFERENCE 0
#define VALUE 1 #define VALUE 1
module = (MODULE*) objectToSync->GetParent(); module = (MODULE*) objectToSync->GetParent();

View File

@ -17,7 +17,7 @@
/***************************************************************/ /***************************************************************/
TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
/***************************************************************/ /***************************************************************/
/* Supprime 1 segment de piste. /* Supprime 1 segment de piste.
@ -29,58 +29,49 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
{ {
int current_net_code; int current_net_code;
if( Track == NULL ) if( aTrack == NULL )
return NULL; return NULL;
if( Track->GetState( DELETED ) ) if( aTrack->GetState( DELETED ) )
{ {
D( printf( "WinEDA_PcbFrame::Delete_Segment(): bug deleted already deleted TRACK\n" ); ) D( printf( "WinEDA_PcbFrame::Delete_Segment(): bug deleted already deleted TRACK\n" ); )
return NULL; return NULL;
} }
if( Track->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment if( aTrack->m_Flags & IS_NEW ) // Trace in progress, erase the last segment
{ {
if( g_TrackSegmentCount > 0 ) if( g_CurrentTrackList.GetCount() > 0 )
{ {
int previous_layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer; int previous_layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
D( g_CurrentTrackList.VerifyListIntegrity(); )
// effacement de la piste en cours // effacement de la piste en cours
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
// modification du trace // delete the most recently entered
Track = g_CurrentTrackSegment; delete g_CurrentTrackList.PopBack();
g_CurrentTrackSegment = g_CurrentTrackSegment->Back();
delete Track;
g_TrackSegmentCount--;
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
// g_CurrentTrackSegment->Back() must not be a via, or we want delete also the via // if in 2 track mode, and the next most recent is a segment not a via,
if( (g_TrackSegmentCount >= 2) // and the one previous to that is a via, then delete up to the via.
&& (g_CurrentTrackSegment->Type() != TYPEVIA) if( g_CurrentTrackList.GetCount() >= 2
&& (g_CurrentTrackSegment->Back()->Type() == TYPEVIA) ) && g_CurrentTrackSegment->Type() != TYPE_VIA
&& g_CurrentTrackSegment->Back()->Type() == TYPE_VIA )
{ {
Track = g_CurrentTrackSegment; delete g_CurrentTrackList.PopBack();
g_CurrentTrackSegment = g_CurrentTrackSegment->Back();
delete Track;
g_TrackSegmentCount--;
} }
} }
while( g_TrackSegmentCount && g_CurrentTrackSegment while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() == TYPE_VIA )
&& (g_CurrentTrackSegment->Type() == TYPEVIA) )
{ {
Track = g_CurrentTrackSegment; delete g_CurrentTrackList.PopBack();
g_CurrentTrackSegment = g_CurrentTrackSegment->Back();
delete Track; if( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() != TYPE_VIA )
g_TrackSegmentCount--;
if( g_CurrentTrackSegment && (g_CurrentTrackSegment->Type() != TYPEVIA) )
previous_layer = g_CurrentTrackSegment->GetLayer(); previous_layer = g_CurrentTrackSegment->GetLayer();
} }
if( g_CurrentTrackSegment )
g_CurrentTrackSegment->SetNext( NULL );
// Rectification couche active qui a pu changer si une via // Rectification couche active qui a pu changer si une via
// a ete effacee // a ete effacee
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer; ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer;
@ -88,21 +79,20 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
Affiche_Status_Box(); Affiche_Status_Box();
if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0
{ {
if( ( g_TrackSegmentCount == 1 ) if( g_CurrentTrackList.GetCount()==1 && g_CurrentTrackSegment->Type() != TYPE_VIA )
&& (g_CurrentTrackSegment->Type() != TYPEVIA) )
{ {
delete g_CurrentTrackSegment; delete g_CurrentTrackList.PopBack();
g_TrackSegmentCount = 0;
} }
} }
if( g_TrackSegmentCount == 0 )
if( g_CurrentTrackList.GetCount() == 0 )
{ {
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
if( g_HightLigt_Status ) if( g_HightLigt_Status )
Hight_Light( DC ); Hight_Light( DC );
g_CurrentTrackSegment = NULL;
g_FirstTrackSegment = NULL;
SetCurItem( NULL ); SetCurItem( NULL );
return NULL; return NULL;
} }
@ -110,19 +100,19 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
{ {
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
return g_CurrentTrackSegment; return g_CurrentTrackSegment;
} }
} }
return NULL; return NULL;
} // Fin traitement si trace en cours }
current_net_code = aTrack->GetNet();
current_net_code = Track->GetNet();
// redraw the area where the track was // redraw the area where the track was
DrawPanel->PostDirtyRect( Track->GetBoundingBox() ); DrawPanel->PostDirtyRect( aTrack->GetBoundingBox() );
SaveItemEfface( Track, 1 ); SaveItemEfface( aTrack, 1 );
GetScreen()->SetModify(); GetScreen()->SetModify();
test_1_net_connexion( DC, current_net_code ); test_1_net_connexion( DC, current_net_code );
@ -132,13 +122,13 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
/**********************************************************/ /**********************************************************/
void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* Track ) void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* aTrack )
/**********************************************************/ /**********************************************************/
{ {
if( Track != NULL ) if( aTrack != NULL )
{ {
int current_net_code = Track->GetNet(); int current_net_code = aTrack->GetNet();
Remove_One_Track( DC, Track ); Remove_One_Track( DC, aTrack );
GetScreen()->SetModify(); GetScreen()->SetModify();
test_1_net_connexion( DC, current_net_code ); test_1_net_connexion( DC, current_net_code );
} }
@ -146,24 +136,23 @@ void WinEDA_PcbFrame::Delete_Track( wxDC* DC, TRACK* Track )
/********************************************************/ /********************************************************/
void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* Track ) void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
/********************************************************/ /********************************************************/
{ {
if( Track == NULL ) if( aTrack == NULL )
return; return;
if( IsOK( this, _( "Delete NET ?" ) ) ) if( IsOK( this, _( "Delete NET ?" ) ) )
{ {
int net_code_delete = Track->GetNet(); int net_code_delete = aTrack->GetNet();
/* Recherche du debut de la zone des pistes du net_code courant */ /* Recherche du debut de la zone des pistes du net_code courant */
TRACK* trackList = m_Pcb->m_Track->GetStartNetCode( net_code_delete ); TRACK* trackList = m_Pcb->m_Track->GetStartNetCode( net_code_delete );
/* Decompte du nombre de segments de la sous-chaine */ /* Decompte du nombre de segments de la sous-chaine */
int ii; int ii = 0;
TRACK* segm = trackList; for( TRACK* segm = trackList; segm; segm = segm->Next(), ++ii )
for( ii = 0; segm; segm = segm->Next(), ++ii )
{ {
if( segm->GetNet() != net_code_delete ) if( segm->GetNet() != net_code_delete )
break; break;
@ -188,22 +177,24 @@ void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
* jusqu'a un pad ou un point de jonction de plus de 2 segments * jusqu'a un pad ou un point de jonction de plus de 2 segments
*/ */
{ {
TRACK* trackList;
int nb_segm; int nb_segm;
if( pt_segm == NULL ) if( pt_segm == NULL )
return; return;
trackList = Marque_Une_Piste( this, DC, pt_segm, &nb_segm, 0 ); TRACK* trackList = Marque_Une_Piste( this, DC, pt_segm, &nb_segm, 0 );
if( nb_segm ) /* Il y a nb_segm segments de piste a effacer */ if( nb_segm ) /* Il y a nb_segm segments de piste a effacer */
{ {
TRACK* t; int ii = 0;
int ii; for( TRACK* t = trackList; ii<nb_segm; ii++, t = t->Next() )
for( t = trackList, ii=0; ii<nb_segm; ii++, t = t->Next() )
{ {
t->SetState( BUSY, OFF ); t->SetState( BUSY, OFF );
D(printf("%s: track %p status=\"%s\"\n", __func__, t,
CONV_TO_UTF8( TRACK::ShowState( t->GetState(-1)) )
);)
DrawPanel->PostDirtyRect( t->GetBoundingBox() ); DrawPanel->PostDirtyRect( t->GetBoundingBox() );
} }

View File

@ -735,7 +735,7 @@ void WinEDA_ModulePropertiesFrame::ReCreateFieldListBox()
EDA_BaseStruct* item = m_CurrentModule->m_Drawings; EDA_BaseStruct* item = m_CurrentModule->m_Drawings;
while( item ) while( item )
{ {
if( item->Type() == TYPETEXTEMODULE ) if( item->Type() == TYPE_TEXTE_MODULE )
m_TextListBox->Append( ( (TEXTE_MODULE*) item )->m_Text ); m_TextListBox->Append( ( (TEXTE_MODULE*) item )->m_Text );
item = item->Next(); item = item->Next();
} }
@ -789,7 +789,7 @@ void WinEDA_ModulePropertiesFrame::EditOrDelTextModule( wxCommandEvent& event )
int jj = 2; int jj = 2;
while( item ) while( item )
{ {
if( item->Type() == TYPETEXTEMODULE ) if( item->Type() == TYPE_TEXTE_MODULE )
{ {
if( jj == TextType ) // Texte trouvé if( jj == TextType ) // Texte trouvé
{ {

View File

@ -445,8 +445,8 @@ void WinEDA_PcbTracksDialog::AcceptPcbOptions( wxCommandEvent& event )
m_Parent->DisplayTrackSettings(); m_Parent->DisplayTrackSettings();
m_Parent->AddHistory( g_DesignSettings.m_CurrentViaSize, TYPEVIA ); m_Parent->AddHistory( g_DesignSettings.m_CurrentViaSize, TYPE_VIA );
m_Parent->AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPETRACK ); m_Parent->AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPE_TRACK );
EndModal( 1 ); EndModal( 1 );
} }
@ -462,19 +462,19 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type )
switch( type ) switch( type )
{ {
case TYPETRACK: case TYPE_TRACK:
for( ii = 0; ii < HISTORY_NUMBER; ii++ ) for( ii = 0; ii < HISTORY_NUMBER; ii++ )
{ {
if( g_DesignSettings.m_TrackWidthHistory[ii] == value ) if( g_DesignSettings.m_TrackWidthHistory[ii] == value )
{ {
addhistory = FALSE; addhistory = FALSE;
break; break;
} }
} }
if( !addhistory ) if( !addhistory )
break; break;
for( ii = HISTORY_NUMBER-1; ii > 0; ii-- ) for( ii = HISTORY_NUMBER-1; ii > 0; ii-- )
{ {
g_DesignSettings.m_TrackWidthHistory[ii] = g_DesignSettings.m_TrackWidthHistory[ii-1]; g_DesignSettings.m_TrackWidthHistory[ii] = g_DesignSettings.m_TrackWidthHistory[ii-1];
@ -487,7 +487,7 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type )
{ {
if( g_DesignSettings.m_TrackWidthHistory[ii+1] == 0 ) if( g_DesignSettings.m_TrackWidthHistory[ii+1] == 0 )
break; // Fin de liste break; // Fin de liste
if( g_DesignSettings.m_TrackWidthHistory[ii] > if( g_DesignSettings.m_TrackWidthHistory[ii] >
g_DesignSettings.m_TrackWidthHistory[ii+1] ) g_DesignSettings.m_TrackWidthHistory[ii+1] )
{ {
@ -498,12 +498,12 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type )
break; break;
case TYPEVIA: case TYPE_VIA:
for( ii = 0; ii < HISTORY_NUMBER; ii++ ) for( ii = 0; ii < HISTORY_NUMBER; ii++ )
{ {
if( g_DesignSettings.m_ViaSizeHistory[ii] == value ) if( g_DesignSettings.m_ViaSizeHistory[ii] == value )
{ {
addhistory = FALSE; addhistory = FALSE;
break; break;
} }
} }
@ -523,7 +523,7 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type )
{ {
if( g_DesignSettings.m_ViaSizeHistory[ii+1] == 0 ) if( g_DesignSettings.m_ViaSizeHistory[ii+1] == 0 )
break; // Fin de liste break; // Fin de liste
if( g_DesignSettings.m_ViaSizeHistory[ii] > g_DesignSettings.m_ViaSizeHistory[ii+1] ) if( g_DesignSettings.m_ViaSizeHistory[ii] > g_DesignSettings.m_ViaSizeHistory[ii+1] )
{ {
EXCHG( g_DesignSettings.m_ViaSizeHistory[ii], EXCHG( g_DesignSettings.m_ViaSizeHistory[ii],

View File

@ -198,26 +198,26 @@ void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->m_Pcb; BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->m_Pcb;
TRACK* Track = pcb->m_Track->GetStartNetCode( net_code ); TRACK* track = pcb->m_Track->GetStartNetCode( net_code );
for( ; Track; Track = Track->Next() ) for( ; track; track = track->Next() )
{ {
if( Track->GetNet() != net_code ) if( track->GetNet() != net_code )
break; /* hors zone */ break; /* hors zone */
if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 )
continue; /* couches differentes */ continue; /* couches differentes */
if( Track->m_Flags & IS_DRAGGED ) if( track->m_Flags & IS_DRAGGED )
continue; // already in list continue; // already in list
if( Track->m_Start == point ) if( track->m_Start == point )
{ {
AddSegmentToDragList( panel, DC, STARTPOINT, Track ); AddSegmentToDragList( panel, DC, STARTPOINT, track );
} }
if( Track->m_End == point ) if( track->m_End == point )
{ {
AddSegmentToDragList( panel, DC, ENDPOINT, Track ); AddSegmentToDragList( panel, DC, ENDPOINT, track );
} }
} }
} }

View File

@ -145,7 +145,7 @@ int DRC::Drc( TRACK* aRefSegm, TRACK* aList )
{ {
updatePointers(); updatePointers();
if( !doTrackDrc( aRefSegm, aList ) ) if( !doTrackDrc( aRefSegm, aList, true ) )
{ {
wxASSERT( m_currentMarker ); wxASSERT( m_currentMarker );
@ -239,7 +239,7 @@ void DRC::testTracks()
{ {
for( TRACK* segm = m_pcb->m_Track; segm && segm->Next(); segm=segm->Next() ) for( TRACK* segm = m_pcb->m_Track; segm && segm->Next(); segm=segm->Next() )
{ {
if( !doTrackDrc( segm, segm->Next() ) ) if( !doTrackDrc( segm, segm->Next(), true ) )
{ {
wxASSERT( m_currentMarker ); wxASSERT( m_currentMarker );
m_pcb->Add( m_currentMarker ); m_pcb->Add( m_currentMarker );
@ -336,29 +336,22 @@ void DRC::testZones(bool adoTestFillSegments)
TRACK* zoneSeg; TRACK* zoneSeg;
/* this was for display purposes, don't know that we need it anymore if( !adoTestFillSegments )
m_pcb->m_NbSegmZone = 0; return;
for( zoneSeg = m_pcb->m_Zone; zoneSeg; zoneSeg = zoneSeg->Next() )
++m_pcb->m_NbSegmZone; for( zoneSeg = m_pcb->m_Zone; zoneSeg && zoneSeg->Next(); zoneSeg = zoneSeg->Next() )
*/
if ( ! adoTestFillSegments ) return;
for( zoneSeg = m_pcb->m_Zone; zoneSeg && zoneSeg->Next(); zoneSeg=zoneSeg->Next() )
{ {
// Test zoneSeg with other zone segments and with all pads // Test zoneSeg with other zone segments and with all pads
if( !doTrackDrc( zoneSeg, zoneSeg->Next() ) ) if( !doTrackDrc( zoneSeg, zoneSeg->Next(), true ) )
{ {
wxASSERT( m_currentMarker ); wxASSERT( m_currentMarker );
m_pcb->Add( m_currentMarker ); m_pcb->Add( m_currentMarker );
m_currentMarker = 0; m_currentMarker = 0;
} }
// Test zoneSeg with all track segments // Pads already tested: disable pad test
int tmp = m_pcb->m_NbPads;
m_pcb->m_NbPads = 0; // Pads already tested: disable pad test
bool rc = doTrackDrc( zoneSeg, m_pcb->m_Track );
m_pcb->m_NbPads = tmp;
bool rc = doTrackDrc( zoneSeg, m_pcb->m_Track, false );
if( !rc ) if( !rc )
{ {
wxASSERT( m_currentMarker ); wxASSERT( m_currentMarker );
@ -382,13 +375,13 @@ MARKER* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKE
textB = aItem->MenuText( m_pcb ); textB = aItem->MenuText( m_pcb );
posB = aItem->GetPosition(); posB = aItem->GetPosition();
if( aItem->Type() == TYPEPAD ) if( aItem->Type() == TYPE_PAD )
position = aItem->GetPosition(); position = aItem->GetPosition();
else if( aItem->Type() == TYPEVIA ) else if( aItem->Type() == TYPE_VIA )
position = aItem->GetPosition(); position = aItem->GetPosition();
else if( aItem->Type() == TYPETRACK ) else if( aItem->Type() == TYPE_TRACK )
{ {
TRACK* track = (TRACK*) aItem; TRACK* track = (TRACK*) aItem;
wxPoint endPos = track->m_End; wxPoint endPos = track->m_End;
@ -483,7 +476,7 @@ MARKER* DRC::fillMarker( const ZONE_CONTAINER * aArea, const wxPoint & aPos, int
/***********************************************************************/ /***********************************************************************/
bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
/***********************************************************************/ /***********************************************************************/
{ {
TRACK* track; TRACK* track;
@ -508,7 +501,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
/* Phase 0 : Test vias : */ /* Phase 0 : Test vias : */
if( aRefSeg->Type() == TYPEVIA ) if( aRefSeg->Type() == TYPE_VIA )
{ {
// test if via's hole is bigger than its diameter // test if via's hole is bigger than its diameter
// This test seems necessary since the dialog box that displays the // This test seems necessary since the dialog box that displays the
@ -570,57 +563,61 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
// Compute the min distance to pads // Compute the min distance to pads
w_dist = aRefSeg->m_Width >> 1; w_dist = aRefSeg->m_Width >> 1;
for( int ii=0; ii<m_pcb->m_NbPads; ++ii )
{
D_PAD* pad = m_pcb->m_Pads[ii];
/* No problem if pads are on an other layer, if( testPads )
* But if a drill hole exists (a pad on a single layer can have a hole!) {
* we must test the hole for( unsigned ii=0; ii<m_pcb->m_Pads.size(); ++ii )
*/
if( (pad->m_Masque_Layer & layerMask ) == 0 )
{ {
/* We must test the pad hole. In order to use the function "checkClearanceSegmToPad", D_PAD* pad = m_pcb->m_Pads[ii];
* a pseudo pad is used, with a shape and a size like the hole
/* No problem if pads are on an other layer,
* But if a drill hole exists (a pad on a single layer can have a hole!)
* we must test the hole
*/ */
if( pad->m_Drill.x == 0 ) if( (pad->m_Masque_Layer & layerMask ) == 0 )
{
/* We must test the pad hole. In order to use the function "checkClearanceSegmToPad",
* a pseudo pad is used, with a shape and a size like the hole
*/
if( pad->m_Drill.x == 0 )
continue;
pseudo_pad.m_Size = pad->m_Drill;
pseudo_pad.SetPosition( pad->GetPosition() );
pseudo_pad.m_PadShape = pad->m_DrillShape;
pseudo_pad.m_Orient = pad->m_Orient;
pseudo_pad.ComputeRayon(); // compute the radius
m_spotcx = pseudo_pad.GetPosition().x - org_X;
m_spotcy = pseudo_pad.GetPosition().y - org_Y;
if( !checkClearanceSegmToPad( &pseudo_pad, w_dist,
g_DesignSettings.m_TrackClearence ) )
{
m_currentMarker = fillMarker( aRefSeg, pad,
DRCE_TRACK_NEAR_THROUGH_HOLE, m_currentMarker );
return false;
}
continue;
}
/* The pad must be in a net (i.e pt_pad->GetNet() != 0 )
* but no problem if the pad netcode is the current netcode (same net)
*/
if( pad->GetNet() && // the pad must be connected
net_code_ref == pad->GetNet() ) // the pad net is the same as current net -> Ok
continue; continue;
pseudo_pad.m_Size = pad->m_Drill; // DRC for the pad
pseudo_pad.SetPosition( pad->GetPosition() ); shape_pos = pad->ReturnShapePos();
pseudo_pad.m_PadShape = pad->m_DrillShape; m_spotcx = shape_pos.x - org_X;
pseudo_pad.m_Orient = pad->m_Orient; m_spotcy = shape_pos.y - org_Y;
pseudo_pad.ComputeRayon(); // compute the radius if( !checkClearanceSegmToPad( pad, w_dist, g_DesignSettings.m_TrackClearence ) )
m_spotcx = pseudo_pad.GetPosition().x - org_X;
m_spotcy = pseudo_pad.GetPosition().y - org_Y;
if( !checkClearanceSegmToPad( &pseudo_pad, w_dist,
g_DesignSettings.m_TrackClearence ) )
{ {
m_currentMarker = fillMarker( aRefSeg, pad, m_currentMarker = fillMarker( aRefSeg, pad,
DRCE_TRACK_NEAR_THROUGH_HOLE, m_currentMarker ); DRCE_TRACK_NEAR_PAD, m_currentMarker );
return false; return false;
} }
continue;
}
/* The pad must be in a net (i.e pt_pad->GetNet() != 0 )
* but no problem if the pad netcode is the current netcode (same net)
*/
if( pad->GetNet() && // the pad must be connected
net_code_ref == pad->GetNet() ) // the pad net is the same as current net -> Ok
continue;
// DRC for the pad
shape_pos = pad->ReturnShapePos();
m_spotcx = shape_pos.x - org_X;
m_spotcy = shape_pos.y - org_Y;
if( !checkClearanceSegmToPad( pad, w_dist, g_DesignSettings.m_TrackClearence ) )
{
m_currentMarker = fillMarker( aRefSeg, pad,
DRCE_TRACK_NEAR_PAD, m_currentMarker );
return false;
} }
} }
@ -654,7 +651,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
w_dist += g_DesignSettings.m_TrackClearence; w_dist += g_DesignSettings.m_TrackClearence;
// If the reference segment is a via, we test it here // If the reference segment is a via, we test it here
if( aRefSeg->Type() == TYPEVIA ) if( aRefSeg->Type() == TYPE_VIA )
{ {
int orgx, orgy; // origine du repere d'axe X = segment a comparer int orgx, orgy; // origine du repere d'axe X = segment a comparer
int angle = 0; // angle du segment a tester; int angle = 0; // angle du segment a tester;
@ -668,7 +665,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
x0 = aRefSeg->m_Start.x - orgx; x0 = aRefSeg->m_Start.x - orgx;
y0 = aRefSeg->m_Start.y - orgy; y0 = aRefSeg->m_Start.y - orgy;
if( track->Type() == TYPEVIA ) if( track->Type() == TYPE_VIA )
{ {
// Test distance between two vias // Test distance between two vias
if( (int) hypot( x0, y0 ) < w_dist ) if( (int) hypot( x0, y0 ) < w_dist )
@ -710,7 +707,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
RotatePoint( &x0, &y0, m_segmAngle ); RotatePoint( &x0, &y0, m_segmAngle );
RotatePoint( &xf, &yf, m_segmAngle ); RotatePoint( &xf, &yf, m_segmAngle );
if( track->Type() == TYPEVIA ) if( track->Type() == TYPE_VIA )
{ {
if( checkMarginToCircle( x0, y0, w_dist, m_segmLength ) ) if( checkMarginToCircle( x0, y0, w_dist, m_segmLength ) )
continue; continue;

View File

@ -428,10 +428,11 @@ private:
* tests the current segment. * tests the current segment.
* @param aRefSeg The segment to test * @param aRefSeg The segment to test
* @param aStart The head of a list of tracks to test against (usually BOARD::m_Track) * @param aStart The head of a list of tracks to test against (usually BOARD::m_Track)
* @param doPads true if should do pads test
* @return bool - true if no poblems, else false and m_currentMarker is * @return bool - true if no poblems, else false and m_currentMarker is
* filled in with the problem information. * filled in with the problem information.
*/ */
bool doTrackDrc( TRACK* aRefSeg, TRACK* aStart ); bool doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool doPads = true );
/** /**
@ -443,7 +444,6 @@ private:
* @param aCornerIndex The first corner of the segment to test. * @param aCornerIndex The first corner of the segment to test.
* @return bool - false if DRC error or true if OK * @return bool - false if DRC error or true if OK
*/ */
bool doEdgeZoneDrc( ZONE_CONTAINER * aArea, int aCornerIndex ); bool doEdgeZoneDrc( ZONE_CONTAINER * aArea, int aCornerIndex );
//-----<single tests>---------------------------------------------- //-----<single tests>----------------------------------------------

View File

@ -159,10 +159,10 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
if( Edge == NULL ) if( Edge == NULL )
{ {
Edge = (EDGE_MODULE*) Module->m_Drawings; Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings;
for( ; Edge != NULL; Edge = Edge->Next() ) for( ; Edge != NULL; Edge = Edge->Next() )
{ {
if( Edge->Type() != TYPEEDGEMODULE ) if( Edge->Type() != TYPE_EDGE_MODULE )
continue; continue;
Edge->m_Width = ModuleSegmentWidth; Edge->m_Width = ModuleSegmentWidth;
} }
@ -209,10 +209,10 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge, wxDC* DC )
if( Edge == NULL ) if( Edge == NULL )
{ {
Edge = (EDGE_MODULE*) Module->m_Drawings; Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings;
for( ; Edge != NULL; Edge = Edge->Next() ) for( ; Edge != NULL; Edge = Edge->Next() )
{ {
if( Edge->Type() != TYPEEDGEMODULE ) if( Edge->Type() != TYPE_EDGE_MODULE )
continue; continue;
Edge->SetLayer( new_layer ); Edge->SetLayer( new_layer );
} }
@ -276,9 +276,9 @@ void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
{ {
if( Edge == NULL ) if( Edge == NULL )
return; return;
if( Edge->Type() != TYPEEDGEMODULE ) if( Edge->Type() != TYPE_EDGE_MODULE )
{ {
DisplayError( this, wxT( "StructType error: TYPEEDGEMODULE expected" ) ); DisplayError( this, wxT( "StructType error: TYPE_EDGE_MODULE expected" ) );
return; return;
} }
@ -301,7 +301,7 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem(); EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
if( Edge && (Edge->Type() == TYPEEDGEMODULE) ) /* error si non */ if( Edge && (Edge->Type() == TYPE_EDGE_MODULE) ) /* error si non */
{ {
if( Edge->m_Flags & IS_NEW ) /* effacement du nouveau contour */ if( Edge->m_Flags & IS_NEW ) /* effacement du nouveau contour */
{ {
@ -348,11 +348,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
/* Add the new item to the Drawings list head*/ /* Add the new item to the Drawings list head*/
Edge->SetBack( Module ); Module->m_Drawings.PushFront( Edge );
Edge->SetNext( Module->m_Drawings );
if( Module->m_Drawings )
Module->m_Drawings->SetBack( Edge );
Module->m_Drawings = Edge;
/* Mise a jour des caracteristiques du segment ou de l'arc */ /* Mise a jour des caracteristiques du segment ou de l'arc */
Edge->m_Flags = IS_NEW; Edge->m_Flags = IS_NEW;

View File

@ -545,8 +545,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
Fill_All_Zones( &dc ); Fill_All_Zones( &dc );
break; break;
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE: case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE:
if ( ( GetCurItem())->Type() == TYPEZONE_CONTAINER) if ( ( GetCurItem())->Type() == TYPE_ZONE_CONTAINER)
{ {
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER* )GetCurItem(); ZONE_CONTAINER* zone_container = (ZONE_CONTAINER* )GetCurItem();
zone_container->m_FilledPolysList.clear(); zone_container->m_FilledPolysList.clear();
@ -557,12 +557,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones : case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
if( m_Pcb->m_Zone ) m_Pcb->m_Zone.DeleteAll();
{
m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
}
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* zone_container = m_Pcb->GetArea( ii ); ZONE_CONTAINER* zone_container = m_Pcb->GetArea( ii );
@ -596,9 +591,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_MOVE_MODULE_REQUEST: case ID_POPUP_PCB_MOVE_MODULE_REQUEST:
// If the current Item is a pad, text module ...: Get the parent // If the current Item is a pad, text module ...: Get the parent
if( GetCurItem()->Type() != TYPEMODULE ) if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() ); SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
{ {
g_Drag_Pistes_On = FALSE; g_Drag_Pistes_On = FALSE;
break; break;
@ -620,10 +615,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent // If the current Item is a pad, text module ...: Get the parent
if( GetCurItem()->Type() != TYPEMODULE ) if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() ); SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break; break;
if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) ) if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) )
{ {
@ -635,10 +630,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent // If the current Item is a pad, text module ...: Get the parent
if( GetCurItem()->Type() != TYPEMODULE ) if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() ); SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break; break;
Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, TRUE ); Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, TRUE );
break; break;
@ -647,10 +642,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent // If the current Item is a pad, text module ...: Get the parent
if( GetCurItem()->Type() != TYPEMODULE ) if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() ); SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break; break;
Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, TRUE ); Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, TRUE );
break; break;
@ -659,9 +654,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// If the current Item is a pad, text module ...: Get the parent // If the current Item is a pad, text module ...: Get the parent
if( GetCurItem()->Type() != TYPEMODULE ) if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() ); SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break; break;
m_Pcb->Change_Side_Module( (MODULE*) GetCurItem(), &dc ); m_Pcb->Change_Side_Module( (MODULE*) GetCurItem(), &dc );
break; break;
@ -669,9 +664,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_EDIT_MODULE: case ID_POPUP_PCB_EDIT_MODULE:
// If the current Item is a pad, text module ...: Get the parent // If the current Item is a pad, text module ...: Get the parent
if( GetCurItem()->Type() != TYPEMODULE ) if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() ); SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break; break;
InstallModuleOptionsFrame( (MODULE*) GetCurItem(), &dc, pos ); InstallModuleOptionsFrame( (MODULE*) GetCurItem(), &dc, pos );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
@ -1031,7 +1026,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame,
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case TYPETEXTE: case TYPE_TEXTE:
frame->StartMoveTextePcb( (TEXTE_PCB*) DrawStruct, DC ); frame->StartMoveTextePcb( (TEXTE_PCB*) DrawStruct, DC );
break; break;
@ -1055,39 +1050,39 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
switch( Item->Type() ) switch( Item->Type() )
{ {
case TYPEMODULE: case TYPE_MODULE:
Delete_Module( (MODULE*) Item, DC, true ); Delete_Module( (MODULE*) Item, DC, true );
break; break;
case TYPECOTATION: case TYPE_COTATION:
Delete_Cotation( (COTATION*) Item, DC ); Delete_Cotation( (COTATION*) Item, DC );
break; break;
case TYPEMIRE: case TYPE_MIRE:
Delete_Mire( (MIREPCB*) Item, DC ); Delete_Mire( (MIREPCB*) Item, DC );
break; break;
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC ); Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
break; break;
case TYPETEXTE: case TYPE_TEXTE:
Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC ); Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
break; break;
case TYPETRACK: case TYPE_TRACK:
Delete_Track( DC, (TRACK*) Item ); Delete_Track( DC, (TRACK*) Item );
break; break;
case TYPEVIA: case TYPE_VIA:
Delete_Segment( DC, (TRACK*) Item ); Delete_Segment( DC, (TRACK*) Item );
break; break;
case TYPEZONE: case TYPE_ZONE:
Delete_Zone_Fill( DC, (SEGZONE*) Item ); Delete_Zone_Fill( DC, (SEGZONE*) Item );
break; break;
case TYPEMARKER: case TYPE_MARKER:
if( Item == GetCurItem() ) if( Item == GetCurItem() )
SetCurItem( NULL ); SetCurItem( NULL );
( (MARKER*) Item )->Draw( DrawPanel, DC, GR_XOR ); ( (MARKER*) Item )->Draw( DrawPanel, DC, GR_XOR );
@ -1096,14 +1091,14 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
m_Pcb->Delete( Item ); m_Pcb->Delete( Item );
break; break;
case TYPEPAD: case TYPE_PAD:
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
break; break;
case TYPE_NOT_INIT: case TYPE_NOT_INIT:
case PCB_EQUIPOT_STRUCT_TYPE: case TYPE_EQUIPOT:
case TYPEPCB: case TYPE_PCB:
default: default:
{ {
wxString Line; wxString Line;
@ -1168,7 +1163,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
// See if we are drawing a segment; if so, add a via? // See if we are drawing a segment; if so, add a via?
if( m_ID_current_state == ID_TRACK_BUTT && current != NULL ) if( m_ID_current_state == ID_TRACK_BUTT && current != NULL )
{ {
if( current->Type() == TYPETRACK && (current->m_Flags & IS_NEW) ) if( current->Type() == TYPE_TRACK && (current->m_Flags & IS_NEW) )
{ {
// Want to set the routing layers so that it switches properly - // Want to set the routing layers so that it switches properly -
// see the implementation of Other_Layer_Route - the working // see the implementation of Other_Layer_Route - the working

View File

@ -31,7 +31,7 @@ int WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* DC, TRACK* pt_segm )
/* Test DRC and width change */ /* Test DRC and width change */
old_w = pt_segm->m_Width; old_w = pt_segm->m_Width;
consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentTrackWidth; consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentTrackWidth;
if( pt_segm->Type() == TYPEVIA ) if( pt_segm->Type() == TYPE_VIA )
{ {
consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentViaSize; consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentViaSize;
if ( pt_segm->m_Shape == VIA_MICROVIA ) if ( pt_segm->m_Shape == VIA_MICROVIA )
@ -144,7 +144,7 @@ bool WinEDA_PcbFrame::Resize_Pistes_Vias( wxDC* DC, bool Track, bool Via )
pt_segm = m_Pcb->m_Track; pt_segm = m_Pcb->m_Track;
for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) for( ; pt_segm != NULL; pt_segm = pt_segm->Next() )
{ {
if( pt_segm->Type() == TYPEVIA ) /* mise a jour du diametre de la via */ if( pt_segm->Type() == TYPE_VIA ) /* mise a jour du diametre de la via */
{ {
if( Via ) if( Via )
{ {

View File

@ -110,7 +110,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
Segment->Draw( DrawPanel, DC, GR_XOR ); Segment->Draw( DrawPanel, DC, GR_XOR );
PtStruct = Segment->Back(); PtStruct = Segment->Back();
Segment ->DeleteStructure(); Segment ->DeleteStructure();
if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) ) if( PtStruct && (PtStruct->Type() == TYPE_DRAWSEGMENT ) )
Segment = (DRAWSEGMENT*) PtStruct; Segment = (DRAWSEGMENT*) PtStruct;
DisplayOpt.DisplayDrawItems = track_fill_copy; DisplayOpt.DisplayDrawItems = track_fill_copy;
SetCurItem( NULL ); SetCurItem( NULL );
@ -181,9 +181,9 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPETEXTE: case TYPE_TEXTE:
case TYPECOTATION: case TYPE_COTATION:
if( item->GetLayer() == layer ) if( item->GetLayer() == layer )
{ {
item->Draw( DrawPanel, DC, GR_XOR ); item->Draw( DrawPanel, DC, GR_XOR );
@ -265,16 +265,12 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
else /* trace en cours : les coord du point d'arrivee ont ete mises else /* trace en cours : les coord du point d'arrivee ont ete mises
* a jour par la routine Montre_Position_NewSegment*/ * a jour par la routine Montre_Position_NewSegment*/
{ {
if( (Segment->m_Start.x != Segment->m_End.x ) if( Segment->m_Start != Segment->m_End )
|| (Segment->m_Start.y != Segment->m_End.y ) )
{ {
if( Segment->m_Shape == S_SEGMENT ) if( Segment->m_Shape == S_SEGMENT )
{ {
Segment->SetNext( m_Pcb->m_Drawings ); m_Pcb->Add( Segment );
Segment->SetBack( m_Pcb );
if( m_Pcb->m_Drawings )
m_Pcb->m_Drawings->SetBack( Segment );
m_Pcb->m_Drawings = Segment;
GetScreen()->SetModify(); GetScreen()->SetModify();
Segment->m_Flags = 0; Segment->m_Flags = 0;
@ -320,11 +316,9 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
else else
{ {
Segment->m_Flags = 0; Segment->m_Flags = 0;
Segment->SetNext( m_Pcb->m_Drawings );
Segment->SetBack( m_Pcb ); m_Pcb->Add( Segment );
if( m_Pcb->m_Drawings )
m_Pcb->m_Drawings->SetBack( Segment );
m_Pcb->m_Drawings = Segment;
GetScreen()->SetModify(); GetScreen()->SetModify();
} }

View File

@ -101,14 +101,14 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod, wxDC* DC )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (EDGE_MODULE*) PtStruct ) #define STRUCT ( (EDGE_MODULE*) PtStruct )
STRUCT->m_Start0.x += deltaX; STRUCT->m_Start0.y += deltaY; STRUCT->m_Start0.x += deltaX; STRUCT->m_Start0.y += deltaY;
STRUCT->m_End0.x += deltaX; STRUCT->m_End0.y += deltaY; STRUCT->m_End0.x += deltaX; STRUCT->m_End0.y += deltaY;
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (TEXTE_MODULE*) PtStruct ) #define STRUCT ( (TEXTE_MODULE*) PtStruct )
STRUCT->m_Pos0.x += deltaX; STRUCT->m_Pos0.y += deltaY; STRUCT->m_Pos0.x += deltaX; STRUCT->m_Pos0.y += deltaY;
@ -133,11 +133,11 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item, wxDC* DC )
switch( Item->Type() ) switch( Item->Type() )
{ {
case TYPEPAD: case TYPE_PAD:
DeletePad( (D_PAD*) Item, DC ); DeletePad( (D_PAD*) Item, DC );
break; break;
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
{ {
TEXTE_MODULE* text = (TEXTE_MODULE*) Item; TEXTE_MODULE* text = (TEXTE_MODULE*) Item;
if( text->m_Type == TEXT_is_REFERENCE ) if( text->m_Type == TEXT_is_REFERENCE )
@ -154,11 +154,11 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item, wxDC* DC )
} }
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
Delete_Edge_Module( (EDGE_MODULE*) Item, DC ); Delete_Edge_Module( (EDGE_MODULE*) Item, DC );
break; break;
case TYPEMODULE: case TYPE_MODULE:
break; break;
default: default:

View File

@ -93,7 +93,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
TRACK* pt_track; TRACK* pt_track;
int l1, l2, nb_segm; int l1, l2, nb_segm;
if( (pt_segm == NULL ) || ( pt_segm->Type() == TYPEZONE ) ) if( (pt_segm == NULL ) || ( pt_segm->Type() == TYPE_ZONE ) )
{ {
return; return;
} }
@ -114,7 +114,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
ii = 0; pt_segm = pt_track; ii = 0; pt_segm = pt_track;
for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() ) for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() )
{ {
if( pt_segm->Type() == TYPEVIA ) if( pt_segm->Type() == TYPE_VIA )
continue; continue;
/* inversion des couches */ /* inversion des couches */
@ -127,7 +127,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
{ {
/* Annulation du changement */ /* Annulation du changement */
ii = 0; pt_segm = pt_track; ii = 0; pt_segm = pt_track;
for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() ) for( ; ii < nb_segm; ii++, pt_segm = pt_segm->Next() )
{ {
pt_segm->SetLayer( pt_segm->m_Param ); pt_segm->SetLayer( pt_segm->m_Param );
} }
@ -141,7 +141,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL ); Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL );
/* controle des extremites de segments: sont-ils sur un pad */ /* controle des extremites de segments: sont-ils sur un pad */
ii = 0; pt_segm = pt_track; ii = 0; pt_segm = pt_track;
for( ; ii < nb_segm; pt_segm = (TRACK*) pt_segm->Next(), ii++ ) for( ; ii < nb_segm; pt_segm = pt_segm->Next(), ii++ )
{ {
pt_segm->start = Locate_Pad_Connecte( m_Pcb, pt_segm, START ); pt_segm->start = Locate_Pad_Connecte( m_Pcb, pt_segm, START );
pt_segm->end = Locate_Pad_Connecte( m_Pcb, pt_segm, END ); pt_segm->end = Locate_Pad_Connecte( m_Pcb, pt_segm, END );
@ -155,20 +155,18 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
/****************************************************************/ /****************************************************************/
bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
/****************************************************************/ /****************************************************************/
{ {
TRACK* pt_segm; unsigned itmp;
SEGVIA* Via;
int ii;
int itmp;
if( track == NULL ) if( aTrack == NULL )
{ {
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP;
else else
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM;
Affiche_Status_Box(); Affiche_Status_Box();
SetToolbars(); SetToolbars();
return true; return true;
@ -178,11 +176,9 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) )
return false; return false;
pt_segm = g_FirstTrackSegment; for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() )
for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Next() )
{ {
if( (pt_segm->Type() == TYPEVIA) if( segm->Type()==TYPE_VIA && g_CurrentTrackSegment->m_End==segm->m_Start )
&& (g_CurrentTrackSegment->m_End == pt_segm->m_Start) )
return false; return false;
} }
@ -200,20 +196,21 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
} }
} }
/* Saving current state before placing a via. /* Save current state before placing a via.
* If the via canot be placed this current state will be reused */ * If the via canot be placed this current state will be reused
itmp = g_TrackSegmentCount; */
itmp = g_CurrentTrackList.GetCount();
Begin_Route( g_CurrentTrackSegment, DC ); Begin_Route( g_CurrentTrackSegment, DC );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
/* create the via */ /* create the via */
Via = new SEGVIA( m_Pcb ); SEGVIA* via = new SEGVIA( m_Pcb );
Via->m_Flags = IS_NEW; via->m_Flags = IS_NEW;
Via->m_Shape = g_DesignSettings.m_CurrentViaType; via->m_Shape = g_DesignSettings.m_CurrentViaType;
Via->m_Width = g_DesignSettings.m_CurrentViaSize; via->m_Width = g_DesignSettings.m_CurrentViaSize;
Via->SetNet( g_HightLigth_NetCode ); via->SetNet( g_HightLigth_NetCode );
Via->m_Start = Via->m_End = g_CurrentTrackSegment->m_End; via->m_Start = via->m_End = g_CurrentTrackSegment->m_End;
int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
//swap the layers. //swap the layers.
@ -223,10 +220,10 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM;
/* Adjust the via layer pair */ /* Adjust the via layer pair */
switch ( Via->Shape() ) switch ( via->Shape() )
{ {
case VIA_BLIND_BURIED: case VIA_BLIND_BURIED:
Via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
break; break;
case VIA_MICROVIA: // from external to the near neghbour inner layer case VIA_MICROVIA: // from external to the near neghbour inner layer
@ -239,27 +236,27 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
else if ( old_layer == m_Pcb->m_BoardSettings->m_CopperLayerCount - 2 ) else if ( old_layer == m_Pcb->m_BoardSettings->m_CopperLayerCount - 2 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N;
// else error // else error
Via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
Via->m_Width = g_DesignSettings.m_CurrentMicroViaSize; via->m_Width = g_DesignSettings.m_CurrentMicroViaSize;
break; break;
default: default:
// Usual via is from copper to component; layer pair is 0 and 0x0F. // Usual via is from copper to component; layer pair is 0 and 0x0F.
Via->SetLayerPair( COPPER_LAYER_N, LAYER_CMP_N ); via->SetLayerPair( COPPER_LAYER_N, LAYER_CMP_N );
break; break;
} }
if( Drc_On && BAD_DRC==m_drc->Drc( Via, m_Pcb->m_Track ) ) if( Drc_On && BAD_DRC==m_drc->Drc( via, m_Pcb->m_Track ) )
{ {
/* DRC fault: the Via cannot be placed here ... */ /* DRC fault: the Via cannot be placed here ... */
delete Via; delete via;
((PCB_SCREEN*)GetScreen())->m_Active_Layer = old_layer; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = old_layer;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
// delete the track(s) added in Begin_Route() // delete the track(s) added in Begin_Route()
while( g_TrackSegmentCount > itmp ) while( g_CurrentTrackList.GetCount() > itmp )
{ {
Delete_Segment( DC, g_CurrentTrackSegment ); Delete_Segment( DC, g_CurrentTrackSegment );
} }
@ -272,51 +269,45 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
return false; return false;
} }
TRACK* lastNonVia = g_CurrentTrackSegment;
/* A new via was created. It was Ok. /* A new via was created. It was Ok.
* Put it in linked list, after the g_CurrentTrackSegment */
Via->SetBack( g_CurrentTrackSegment );
g_CurrentTrackSegment->SetNext( Via );
g_TrackSegmentCount++;
/* The g_CurrentTrackSegment is now in linked list and we need a new track segment
* after the via, starting at via location.
* it will become the new curren segment (from via to the mouse cursor)
*/ */
g_CurrentTrackSegment = g_CurrentTrackSegment->Copy(); /* create a new segment g_CurrentTrackList.PushBack( via );
* from the last entered segment, with the current width, flags, netcode, etc... values
* layer, start and end point are not correct, and will be modified next */
g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); // set the layer to the new value /* The via is now in linked list and we need a new track segment
* after the via, starting at via location.
* it will become the new current segment (from via to the mouse cursor)
*/
TRACK* track = lastNonVia->Copy();
/* the above creates a new segment from the last entered segment, with the
* current width, flags, netcode, etc... values.
* layer, start and end point are not correct,
* and will be modified next
*/
track->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); // set the layer to the new value
/* the start point is the via position, /* the start point is the via position,
* and the end point is the cursor which also is on the via (will change when moving mouse) * and the end point is the cursor which also is on the via (will change when moving mouse)
*/ */
g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End = Via->m_Start; track->m_Start = track->m_End = via->m_Start;
g_TrackSegmentCount++; g_CurrentTrackList.PushBack( track );
g_CurrentTrackSegment->SetBack( Via );
Via->SetNext( g_CurrentTrackSegment );
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
// Create a second segment (we must have 2 track segments to adjust) // Create a second segment (we must have 2 track segments to adjust)
TRACK* track = g_CurrentTrackSegment; g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() );
g_CurrentTrackSegment = track->Copy();
g_TrackSegmentCount++;
g_CurrentTrackSegment->SetBack( track );
track->SetNext( g_CurrentTrackSegment );
} }
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Via->Display_Infos( this ); via->Display_Infos( this );
Affiche_Status_Box(); Affiche_Status_Box();
D(printf("Other_Layer_Route\n");)
SetToolbars(); SetToolbars();
return true; return true;
@ -368,7 +359,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
if( item ) if( item )
{ {
if( item->Type() == TYPEPAD ) if( item->Type() == TYPE_PAD )
{ {
pt_pad = (D_PAD*) item; pt_pad = (D_PAD*) item;
Module = (MODULE*) pt_pad->GetParent(); Module = (MODULE*) pt_pad->GetParent();
@ -400,12 +391,12 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
} }
else else
{ {
if( item->Type() == TYPETEXTEMODULE ) if( item->Type() == TYPE_TEXTE_MODULE )
{ {
if( item->GetParent() && (item->GetParent()->Type() == TYPEMODULE) ) if( item->GetParent() && (item->GetParent()->Type() == TYPE_MODULE) )
Module = (MODULE*) item->GetParent(); Module = (MODULE*) item->GetParent();
} }
else if( item->Type() == TYPEMODULE ) else if( item->Type() == TYPE_MODULE )
{ {
Module = (MODULE*) item; Module = (MODULE*) item;
} }

View File

@ -21,7 +21,8 @@ static void Exit_Editrack( WinEDA_DrawPanel* panel, wxDC* DC );
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC, bool erase ); wxDC* DC, bool erase );
static void ComputeBreakPoint( TRACK* track, int n, wxPoint end ); static void ComputeBreakPoint( TRACK* track, int n, wxPoint end );
static TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ); static void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList );
static void EnsureEndTrackOnPad( D_PAD* Pad ); static void EnsureEndTrackOnPad( D_PAD* Pad );
/* variables locales */ /* variables locales */
@ -40,7 +41,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->m_Parent; WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->m_Parent;
TRACK* track = (TRACK*) frame->GetCurItem(); TRACK* track = (TRACK*) frame->GetCurItem();
if( track && ( track->Type()==TYPEVIA || track->Type()==TYPETRACK ) ) if( track && ( track->Type()==TYPE_VIA || track->Type()==TYPE_TRACK ) )
{ {
/* Erase the current drawing */ /* Erase the current drawing */
ShowNewTrackWhenMovingCursor( Panel, DC, FALSE ); ShowNewTrackWhenMovingCursor( Panel, DC, FALSE );
@ -54,12 +55,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
// Delete current (new) track // Delete current (new) track
TRACK* previoustrack; g_CurrentTrackList.DeleteAll();
for( ; track; track = previoustrack )
{
previoustrack = track->Back();
delete track;
}
} }
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
@ -69,7 +65,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/ /*************************************************************/
TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
/*************************************************************/ /*************************************************************/
/* /*
@ -87,18 +83,21 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
*/ */
{ {
D_PAD* pt_pad = NULL; D_PAD* pt_pad = NULL;
TRACK* TrackOnStartPoint = NULL, * Track; TRACK* TrackOnStartPoint = NULL;
int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer];
EDA_BaseStruct* LockPoint; EDA_BaseStruct* LockPoint;
wxPoint pos = GetScreen()->m_Curseur; wxPoint pos = GetScreen()->m_Curseur;
static int InitialTrackWidthValue; /* first track segment width. static int InitialTrackWidthValue; /* first track segment width.
* used when we are in the auto tack width mode */ * used when we are in the auto tack width mode */
DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor; DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor;
DrawPanel->ForceCloseManageCurseur = Exit_Editrack; DrawPanel->ForceCloseManageCurseur = Exit_Editrack;
if( track == NULL ) /* Starting a new track */ if( aTrack == NULL ) /* Starting a new track */
{ {
D(printf("Begin_Route NULL\n");)
/* erase old highlight */ /* erase old highlight */
OldNetCodeSurbrillance = g_HightLigth_NetCode; OldNetCodeSurbrillance = g_HightLigth_NetCode;
OldEtatSurbrillance = g_HightLigt_Status; OldEtatSurbrillance = g_HightLigt_Status;
@ -107,17 +106,18 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
Hight_Light( DC ); Hight_Light( DC );
InitialTrackWidthValue = -1; // Set to "no value" InitialTrackWidthValue = -1; // Set to "no value"
g_FirstTrackSegment = g_CurrentTrackSegment = new TRACK( m_Pcb );
g_CurrentTrackList.PushBack( new TRACK( m_Pcb ) );
g_CurrentTrackSegment->m_Flags = IS_NEW; g_CurrentTrackSegment->m_Flags = IS_NEW;
g_TrackSegmentCount = 1;
g_HightLigth_NetCode = 0; g_HightLigth_NetCode = 0;
/* Search for a pad at starting point of the new track: */ // Search for a starting point of the new track, a track or pad
LockPoint = LocateLockPoint( m_Pcb, pos, masquelayer ); LockPoint = LocateLockPoint( m_Pcb, pos, masquelayer );
if( LockPoint ) // An item (pad or track) is found if( LockPoint ) // An item (pad or track) is found
{ {
if( LockPoint->Type() == TYPEPAD ) if( LockPoint->Type() == TYPE_PAD )
{ {
pt_pad = (D_PAD*) LockPoint; pt_pad = (D_PAD*) LockPoint;
@ -135,28 +135,39 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
else // no starting point, but a filled zone area can exist. This is also a good starting point. else // no starting point, but a filled zone area can exist. This is also a good starting point.
{ {
ZONE_CONTAINER* zone = m_Pcb->HitTestForAnyFilledArea(pos, GetScreen()->m_Active_Layer ); ZONE_CONTAINER* zone = m_Pcb->HitTestForAnyFilledArea( pos, GetScreen()->m_Active_Layer );
if ( zone ) if( zone )
g_HightLigth_NetCode = zone->GetNet(); g_HightLigth_NetCode = zone->GetNet();
} }
D( g_CurrentTrackList.VerifyListIntegrity(); );
build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), TRUE ); build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), TRUE );
D( g_CurrentTrackList.VerifyListIntegrity(); );
Hight_Light( DC ); Hight_Light( DC );
/* done above
g_CurrentTrackSegment->m_Flags = IS_NEW; g_CurrentTrackSegment->m_Flags = IS_NEW;
*/
g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth;
if( g_DesignSettings.m_UseConnectedTrackWidth ) if( g_DesignSettings.m_UseConnectedTrackWidth )
{ {
if( TrackOnStartPoint && TrackOnStartPoint->Type() == TYPETRACK ) if( TrackOnStartPoint && TrackOnStartPoint->Type() == TYPE_TRACK )
{ {
InitialTrackWidthValue = TrackOnStartPoint->m_Width; InitialTrackWidthValue = TrackOnStartPoint->m_Width;
g_CurrentTrackSegment->m_Width = InitialTrackWidthValue; g_CurrentTrackSegment->m_Width = InitialTrackWidthValue;
} }
} }
g_CurrentTrackSegment->m_Start = pos; g_CurrentTrackSegment->m_Start = pos;
g_CurrentTrackSegment->m_End = g_CurrentTrackSegment->m_Start; g_CurrentTrackSegment->m_End = pos;
g_CurrentTrackSegment->SetNet( g_HightLigth_NetCode ); g_CurrentTrackSegment->SetNet( g_HightLigth_NetCode );
if( pt_pad ) if( pt_pad )
{ {
g_CurrentTrackSegment->start = pt_pad; g_CurrentTrackSegment->start = pt_pad;
@ -167,15 +178,19 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
// Create 2 segments // Create 2nd segment
g_CurrentTrackSegment = g_CurrentTrackSegment->Copy(); g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() );
g_TrackSegmentCount++;
g_CurrentTrackSegment->SetBack( g_FirstTrackSegment ); D( g_CurrentTrackList.VerifyListIntegrity(); );
g_FirstTrackSegment->SetNext( g_CurrentTrackSegment );
g_CurrentTrackSegment->start = g_FirstTrackSegment; g_CurrentTrackSegment->start = g_FirstTrackSegment;
g_FirstTrackSegment->end = g_CurrentTrackSegment; g_FirstTrackSegment->end = g_CurrentTrackSegment;
g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
} }
D( g_CurrentTrackList.VerifyListIntegrity(); );
g_CurrentTrackSegment->Display_Infos( this ); g_CurrentTrackSegment->Display_Infos( this );
SetCurItem( g_CurrentTrackSegment ); SetCurItem( g_CurrentTrackSegment );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
@ -190,14 +205,16 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
} }
else /* Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor*/ else /* Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor*/
{ {
D(printf("Begin_Route in progress\n");)
/* Tst for a D.R.C. error: */ /* Tst for a D.R.C. error: */
if( Drc_On ) if( Drc_On )
{ {
if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) ) if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) )
return NULL; return NULL;
if( g_TwoSegmentTrackBuild // We must handle 2 segments // We must handle 2 segments
&& g_CurrentTrackSegment->Back() ) if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() )
{ {
if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), m_Pcb->m_Track ) ) if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), m_Pcb->m_Track ) )
return NULL; return NULL;
@ -205,45 +222,59 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
} }
/* Current track is Ok: current segment is kept, and a new one is created /* Current track is Ok: current segment is kept, and a new one is created
* unless the current segment is null, or 2 last are null if a 2 segments track build * unless the current segment is null, or 2 last are null if a 2 segments track build
*/ */
bool CanCreateNewSegment = TRUE; bool CanCreateNewSegment = TRUE;
if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() ) if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() )
CanCreateNewSegment = FALSE; CanCreateNewSegment = FALSE;
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull()
&& g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() ) && g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() )
CanCreateNewSegment = FALSE; CanCreateNewSegment = FALSE;
if( CanCreateNewSegment ) if( CanCreateNewSegment )
{ {
/* Erase old track on screen */ /* Erase old track on screen */
D( g_CurrentTrackList.VerifyListIntegrity(); );
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
D( g_CurrentTrackList.VerifyListIntegrity(); );
if( g_Raccord_45_Auto ) if( g_Raccord_45_Auto )
{ {
if( Add_45_degrees_Segment( DC, g_CurrentTrackSegment ) != 0 ) Add_45_degrees_Segment( DC );
g_TrackSegmentCount++;
} }
Track = g_CurrentTrackSegment->Copy();
Track->Insert( m_Pcb, g_CurrentTrackSegment );
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); TRACK* oneBeforeLatest = g_CurrentTrackSegment;
g_CurrentTrackSegment->end = Locate_Pad_Connecte( m_Pcb, g_CurrentTrackSegment, END );
if( g_CurrentTrackSegment->end ) TRACK* newTrack = g_CurrentTrackSegment->Copy();
g_CurrentTrackList.PushBack( newTrack );
newTrack->m_Flags = IS_NEW;
newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
oneBeforeLatest->end = Locate_Pad_Connecte( m_Pcb, oneBeforeLatest, END );
if( oneBeforeLatest->end )
{ {
g_CurrentTrackSegment->SetState( END_ONPAD, ON ); oneBeforeLatest->SetState( END_ONPAD, ON );
Track->SetState( BEGIN_ONPAD, ON ); newTrack->SetState( BEGIN_ONPAD, ON );
} }
Track->start = g_CurrentTrackSegment->end; newTrack->start = oneBeforeLatest->end;
D( g_CurrentTrackList.VerifyListIntegrity(); );
newTrack->m_Start = newTrack->m_End;
newTrack->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
g_CurrentTrackSegment = Track;
g_CurrentTrackSegment->m_Flags = IS_NEW;
g_TrackSegmentCount++;
g_CurrentTrackSegment->m_Start = g_CurrentTrackSegment->m_End;
g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
if( !g_DesignSettings.m_UseConnectedTrackWidth ) if( !g_DesignSettings.m_UseConnectedTrackWidth )
{ {
g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; newTrack->m_Width = g_DesignSettings.m_CurrentTrackWidth;
} }
D( g_CurrentTrackList.VerifyListIntegrity(); );
/* Show the new position */ /* Show the new position */
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
} }
@ -256,7 +287,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
/**************************************************************************/ /**************************************************************************/
int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ) bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
/***************************************************************************/ /***************************************************************************/
/* rectifie un virage a 90 et le modifie par 2 coudes a 45 /* rectifie un virage a 90 et le modifie par 2 coudes a 45
@ -270,57 +301,54 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm )
* 0 si impossible * 0 si impossible
*/ */
{ {
TRACK* Previous;
TRACK* NewTrack;
int pas_45; int pas_45;
int dx0, dy0, dx1, dy1; int dx0, dy0, dx1, dy1;
if( g_TrackSegmentCount < 2 ) if( g_CurrentTrackList.GetCount() < 2 )
return 0; /* il faut au moins 2 segments */ return false; /* il faut au moins 2 segments */
Previous = pt_segm->Back(); // pointe le segment precedent TRACK* curTrack = g_CurrentTrackSegment;
TRACK* prevTrack = curTrack->Back();
// Test s'il y a 2 segments consecutifs a raccorder // Test s'il y a 2 segments consecutifs a raccorder
if( (pt_segm->Type() != TYPETRACK ) if( curTrack->Type() != TYPE_TRACK || prevTrack->Type() != TYPE_TRACK )
|| (Previous->Type() != TYPETRACK) )
{ {
return 0; return false;
} }
pas_45 = GetScreen()->GetGrid().x / 2; pas_45 = GetScreen()->GetGrid().x / 2;
if( pas_45 < pt_segm->m_Width ) if( pas_45 < curTrack->m_Width )
pas_45 = GetScreen()->GetGrid().x; pas_45 = GetScreen()->GetGrid().x;
while( pas_45 < pt_segm->m_Width ) while( pas_45 < curTrack->m_Width )
pas_45 *= 2; pas_45 *= 2;
// OK : tst si les segments sont a 90 degre et vertic ou horiz // OK : tst si les segments sont a 90 degre et vertic ou horiz
dx0 = Previous->m_End.x - Previous->m_Start.x; dx0 = prevTrack->m_End.x - prevTrack->m_Start.x;
dy0 = Previous->m_End.y - Previous->m_Start.y; dy0 = prevTrack->m_End.y - prevTrack->m_Start.y;
dx1 = pt_segm->m_End.x - pt_segm->m_Start.x;
dy1 = pt_segm->m_End.y - pt_segm->m_Start.y; dx1 = curTrack->m_End.x - curTrack->m_Start.x;
dy1 = curTrack->m_End.y - curTrack->m_Start.y;
// les segments doivent etre de longueur suffisante: // les segments doivent etre de longueur suffisante:
if( MAX( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) ) if( MAX( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) )
return 0; return false;
if( MAX( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) ) if( MAX( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) )
return 0; return false;
/* creation du nouveau segment, raccordant des 2 segm: */ /* creation du nouveau segment, raccordant des 2 segm: */
NewTrack = pt_segm->Copy(); TRACK* newTrack = curTrack->Copy();
NewTrack->m_Start.x = Previous->m_End.x; newTrack->m_Start = prevTrack->m_End;
NewTrack->m_Start.y = Previous->m_End.y; newTrack->m_End = curTrack->m_Start;
NewTrack->m_End.x = pt_segm->m_Start.x;
NewTrack->m_End.y = pt_segm->m_Start.y;
if( dx0 == 0 ) // Segment precedent Vertical if( dx0 == 0 ) // Segment precedent Vertical
{ {
if( dy1 != 0 ) // les 2 segments ne sont pas a 90 ; if( dy1 != 0 ) // les 2 segments ne sont pas a 90 ;
{ {
delete NewTrack; delete newTrack;
return 0; return false;
} }
/* Calcul des coordonnees du point de raccord : /* Calcul des coordonnees du point de raccord :
@ -328,33 +356,34 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm )
* au 2eme segment Horizontal */ * au 2eme segment Horizontal */
if( dy0 > 0 ) if( dy0 > 0 )
NewTrack->m_Start.y -= pas_45; newTrack->m_Start.y -= pas_45;
else else
NewTrack->m_Start.y += pas_45; newTrack->m_Start.y += pas_45;
if( dx1 > 0 ) if( dx1 > 0 )
NewTrack->m_End.x += pas_45; newTrack->m_End.x += pas_45;
else else
NewTrack->m_End.x -= pas_45; newTrack->m_End.x -= pas_45;
if( Drc_On && BAD_DRC==m_drc->Drc( pt_segm, m_Pcb->m_Track ) ) if( Drc_On && BAD_DRC==m_drc->Drc( curTrack, m_Pcb->m_Track ) )
{ {
delete NewTrack; delete newTrack;
return 0; return false;
} }
Previous->m_End = NewTrack->m_Start; prevTrack->m_End = newTrack->m_Start;
pt_segm->m_Start = NewTrack->m_End; curTrack->m_Start = newTrack->m_End;
NewTrack->Insert( m_Pcb, Previous );
return 1; g_CurrentTrackList.Insert( newTrack, curTrack );
return true;
} }
if( dy0 == 0 ) // Segment precedent Horizontal : dy0 = 0 if( dy0 == 0 ) // Segment precedent Horizontal : dy0 = 0
{ {
if( dx1 != 0 ) // les 2 segments ne sont pas a 90 ; if( dx1 != 0 ) // les 2 segments ne sont pas a 90 ;
{ {
delete NewTrack; delete newTrack;
return 0; return false;
} }
// Segments a 90 // Segments a 90
@ -364,67 +393,69 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm )
* au 2eme segment Vertical */ * au 2eme segment Vertical */
if( dx0 > 0 ) if( dx0 > 0 )
NewTrack->m_Start.x -= pas_45; newTrack->m_Start.x -= pas_45;
else else
NewTrack->m_Start.x += pas_45; newTrack->m_Start.x += pas_45;
if( dy1 > 0 ) if( dy1 > 0 )
NewTrack->m_End.y += pas_45; newTrack->m_End.y += pas_45;
else else
NewTrack->m_End.y -= pas_45; newTrack->m_End.y -= pas_45;
if( Drc_On && BAD_DRC==m_drc->Drc( NewTrack, m_Pcb->m_Track ) ) if( Drc_On && BAD_DRC==m_drc->Drc( newTrack, m_Pcb->m_Track ) )
{ {
delete NewTrack; delete newTrack;
return 0; return false;
} }
Previous->m_End = NewTrack->m_Start; prevTrack->m_End = newTrack->m_Start;
pt_segm->m_Start = NewTrack->m_End; curTrack->m_Start = newTrack->m_End;
NewTrack->Insert( m_Pcb, Previous );
return 1; g_CurrentTrackList.Insert( newTrack, curTrack );
return true;
} }
return 0; return false;
} }
/**************************************************************/ /**************************************************************/
void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
/*************************************************************/ /*************************************************************/
/* /*
* Routine de fin de trace d'une piste (succession de segments) * Routine de fin de trace d'une piste (succession de segments)
*/ */
{ {
int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer];
wxPoint pos;
EDA_BaseStruct* LockPoint;
TRACK* adr_buf;
if( track == NULL ) if( aTrack == NULL )
return; return;
if( Drc_On && BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) ) if( Drc_On && BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) )
return; return;
/* Sauvegarde des coord du point terminal de la piste */ /* Sauvegarde des coord du point terminal de la piste */
pos = g_CurrentTrackSegment->m_End; wxPoint pos = g_CurrentTrackSegment->m_End;
if( Begin_Route( track, DC ) == NULL ) D( g_CurrentTrackList.VerifyListIntegrity(); );
if( Begin_Route( aTrack, DC ) == NULL )
return; return;
ShowNewTrackWhenMovingCursor( DrawPanel, DC, TRUE ); /* mise a jour trace reel */ ShowNewTrackWhenMovingCursor( DrawPanel, DC, TRUE ); /* mise a jour trace reel */
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); /* efface trace piste*/ ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); /* efface trace piste*/
trace_ratsnest_pad( DC ); /* efface trace chevelu*/ trace_ratsnest_pad( DC ); /* efface trace chevelu*/
/* cleanup
// cleanup
if( g_CurrentTrackSegment->Next() != NULL ) if( g_CurrentTrackSegment->Next() != NULL )
{ {
delete g_CurrentTrackSegment->Next(); delete g_CurrentTrackSegment->Next();
g_CurrentTrackSegment->SetNext( NULL ); g_CurrentTrackSegment->SetNext( NULL );
} }
*/
D( g_CurrentTrackList.VerifyListIntegrity(); );
/* La piste est ici non chainee a la liste des segments de piste. /* La piste est ici non chainee a la liste des segments de piste.
@ -433,18 +464,18 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
* ceci contribue a la reduction du temps de calcul */ * ceci contribue a la reduction du temps de calcul */
/* Accrochage de la fin de la piste */ /* Accrochage de la fin de la piste */
LockPoint = LocateLockPoint( m_Pcb, pos, masquelayer ); EDA_BaseStruct* LockPoint = LocateLockPoint( m_Pcb, pos, masquelayer );
if( LockPoint ) /* La fin de la piste est sur un PAD */ if( LockPoint ) /* La fin de la piste est sur un PAD */
{ {
if( LockPoint->Type() == TYPEPAD ) if( LockPoint->Type() == TYPE_PAD )
{ {
EnsureEndTrackOnPad( (D_PAD*) LockPoint ); EnsureEndTrackOnPad( (D_PAD*) LockPoint );
} }
else /* la fin de la piste est sur une autre piste: il faudra else /* la fin de la piste est sur une autre piste: il faudra
* peut-etre creer un point d'ancrage */ * peut-etre creer un point d'ancrage */
{ {
adr_buf = (TRACK*) LockPoint; TRACK* adr_buf = (TRACK*) LockPoint;
g_HightLigth_NetCode = adr_buf->GetNet(); g_HightLigth_NetCode = adr_buf->GetNet();
/* creation eventuelle d'un point d'accrochage */ /* creation eventuelle d'un point d'accrochage */
@ -455,42 +486,50 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
} }
} }
// Delete Null segments: // Delete Null segments:
g_FirstTrackSegment = DeleteNullTrackSegments( m_Pcb, DeleteNullTrackSegments( m_Pcb, g_CurrentTrackList );
g_FirstTrackSegment,
&g_TrackSegmentCount ); // Insert new segments if they exist. This can be NULL on a double click on the start point
/* Test if no segment left. Can happend on a double click on the start point */
if( g_FirstTrackSegment != NULL ) if( g_FirstTrackSegment != NULL )
{ {
// Put new track in board int netcode = g_FirstTrackSegment->GetNet();
m_Pcb->Add( g_FirstTrackSegment ); TRACK* firstTrack = g_FirstTrackSegment;
int newCount = g_CurrentTrackList.GetCount();
trace_ratsnest_pad( DC ); // Put entire new current segment list in BOARD
Trace_Une_Piste( DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR ); TRACK* track;
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( m_Pcb );
// Reset flags: while( (track = g_CurrentTrackList.PopFront()) != NULL )
TRACK* ptr = g_FirstTrackSegment; int ii;
for( ii = 0; (ptr != NULL) && (ii < g_TrackSegmentCount); ii++ )
{ {
ptr->m_Flags = 0; m_Pcb->m_Track.Insert( track, insertBeforeMe );
ptr = ptr->Next();
} }
/* Delete the old track, if exists */ trace_ratsnest_pad( DC );
Trace_Une_Piste( DrawPanel, DC, firstTrack, newCount, GR_OR );
int i = 0;
for( track=firstTrack; track && i<newCount; ++i, track = track->Next() )
{
track->m_Flags = 0;
}
// erase the old track, if exists
if( g_AutoDeleteOldTrack ) if( g_AutoDeleteOldTrack )
{ {
EraseOldTrack( this, m_Pcb, DC, g_FirstTrackSegment, g_TrackSegmentCount ); EraseOldTrack( this, m_Pcb, DC, firstTrack, newCount );
} }
/* compute the new rastnest : */ /* compute the new rastnest : */
test_1_net_connexion( DC, g_FirstTrackSegment->GetNet() ); test_1_net_connexion( DC, netcode );
GetScreen()->SetModify(); GetScreen()->SetModify();
m_Pcb->Display_Infos( this ); m_Pcb->Display_Infos( this );
} }
/* Finish the work, clear used variables */
g_FirstTrackSegment = NULL; wxASSERT( g_FirstTrackSegment==NULL );
wxASSERT( g_CurrentTrackSegment==NULL );
wxASSERT( g_CurrentTrackList.GetCount()==0 );
if( g_HightLigt_Status ) if( g_HightLigt_Status )
Hight_Light( DC ); Hight_Light( DC );
@ -515,7 +554,7 @@ TRACK* LocateIntrusion( TRACK* start, int net, int width )
for( TRACK* track = start; track; track = track->Next() ) for( TRACK* track = start; track; track = track->Next() )
{ {
if( track->Type() == TYPETRACK ) // skip vias if( track->Type() == TYPE_TRACK ) // skip vias
{ {
if( track->GetState( BUSY | DELETED ) ) if( track->GetState( BUSY | DELETED ) )
continue; continue;
@ -631,6 +670,8 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
* est aussi affichee * est aussi affichee
*/ */
{ {
D( g_CurrentTrackList.VerifyListIntegrity(); );
int IsolTmp, Track_fill_copy; int IsolTmp, Track_fill_copy;
PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen();
@ -644,7 +685,7 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
/* efface ancienne position si elle a ete deja dessinee */ /* efface ancienne position si elle a ete deja dessinee */
if( erase ) if( erase )
{ {
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_XOR ); Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR );
( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->trace_ratsnest_pad( DC ); ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->trace_ratsnest_pad( DC );
} }
@ -652,10 +693,11 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer ); g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer );
if( ! g_DesignSettings.m_UseConnectedTrackWidth ) if( ! g_DesignSettings.m_UseConnectedTrackWidth )
g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth;
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
TRACK* previous_track = g_CurrentTrackSegment->Back(); TRACK* previous_track = g_CurrentTrackSegment->Back();
if( previous_track && (previous_track->Type() == TYPETRACK) ) if( previous_track && previous_track->Type()==TYPE_TRACK )
{ {
previous_track->SetLayer( screen->m_Active_Layer ); previous_track->SetLayer( screen->m_Active_Layer );
if( ! g_DesignSettings.m_UseConnectedTrackWidth ) if( ! g_DesignSettings.m_UseConnectedTrackWidth )
@ -665,17 +707,21 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
if( Track_45_Only ) if( Track_45_Only )
{ {
if( g_TwoSegmentTrackBuild ) { if( g_TwoSegmentTrackBuild )
g_CurrentTrackSegment->m_End = ActiveScreen->m_Curseur; {
if (Drc_On) g_CurrentTrackSegment->m_End = ActiveScreen->m_Curseur;
PushTrack(panel);
ComputeBreakPoint( g_CurrentTrackSegment, g_TrackSegmentCount, if( Drc_On )
g_CurrentTrackSegment->m_End); PushTrack(panel);
}
ComputeBreakPoint( g_CurrentTrackSegment, g_CurrentTrackList.GetCount(),
g_CurrentTrackSegment->m_End );
}
else else
{ {
/* Calcul de l'extremite de la piste pour orientations permises: /* Calcul de l'extremite de la piste pour orientations permises:
* horiz,vertical ou 45 degre */ * horiz,vertical ou 45 degre
*/
Calcule_Coord_Extremite_45( g_CurrentTrackSegment->m_Start.x, Calcule_Coord_Extremite_45( g_CurrentTrackSegment->m_Start.x,
g_CurrentTrackSegment->m_Start.y, g_CurrentTrackSegment->m_Start.y,
&g_CurrentTrackSegment->m_End.x, &g_CurrentTrackSegment->m_End.x,
@ -687,7 +733,8 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
g_CurrentTrackSegment->m_End = screen->m_Curseur; g_CurrentTrackSegment->m_End = screen->m_Curseur;
} }
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_XOR ); D( g_CurrentTrackList.VerifyListIntegrity(); );
Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR );
DisplayOpt.DisplayTrackIsol = IsolTmp; DisplayOpt.DisplayTrackIsol = IsolTmp;
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy; DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
@ -712,8 +759,12 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
deltax = ActiveScreen->m_Curseur.x - ox; deltax = ActiveScreen->m_Curseur.x - ox;
deltay = ActiveScreen->m_Curseur.y - oy; deltay = ActiveScreen->m_Curseur.y - oy;
/* calcul de l'angle preferentiel : 0, 45 , 90 degre */ /* calcul de l'angle preferentiel : 0, 45 , 90 degre */
deltax = abs( deltax ); deltay = abs( deltay ); angle = 45; deltax = abs( deltax );
deltay = abs( deltay );
angle = 45;
if( deltax >= deltay ) if( deltax >= deltay )
{ {
if( deltax == 0 ) if( deltax == 0 )
@ -724,6 +775,7 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
else else
{ {
angle = 45; angle = 45;
if( deltay == 0 ) if( deltay == 0 )
angle = 90; angle = 90;
else if( ( (deltax << 6 ) / deltay ) < 26 ) else if( ( (deltax << 6 ) / deltay ) < 26 )
@ -738,12 +790,15 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
break; break;
case 45: case 45:
deltax = MIN( deltax, deltay ); deltay = deltax; deltax = MIN( deltax, deltay );
deltay = deltax;
/* recalcul des signes de deltax et deltay */ /* recalcul des signes de deltax et deltay */
if( (ActiveScreen->m_Curseur.x - ox) < 0 ) if( (ActiveScreen->m_Curseur.x - ox) < 0 )
deltax = -deltax; deltax = -deltax;
if( (ActiveScreen->m_Curseur.y - oy) < 0 ) if( (ActiveScreen->m_Curseur.y - oy) < 0 )
deltay = -deltay; deltay = -deltay;
*fx = ox + deltax; *fx = ox + deltax;
*fy = oy + deltay; *fy = oy + deltay;
break; break;
@ -773,7 +828,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
if( track == NULL ) if( track == NULL )
return; return;
TRACK* NewTrack = track; TRACK* newTrack = track;
track = track->Back(); track = track->Back();
SegmentCount--; SegmentCount--;
if( track ) if( track )
@ -785,11 +840,11 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
iDy = abs( iDy ); iDy = abs( iDy );
} }
TRACK* LastTrack = track ? track->Back() : NULL; TRACK* lastTrack = track ? track->Back() : NULL;
if( LastTrack ) if( lastTrack )
{ {
if( (LastTrack->m_End.x == LastTrack->m_Start.x) if( (lastTrack->m_End.x == lastTrack->m_Start.x)
|| (LastTrack->m_End.y == LastTrack->m_Start.y) ) || (lastTrack->m_End.y == lastTrack->m_Start.y) )
{ {
iAngle = 45; iAngle = 45;
} }
@ -822,11 +877,13 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
case 45: case 45:
iDx = MIN( iDx, iDy ); iDx = MIN( iDx, iDy );
iDy = iDx; iDy = iDx;
/* recalcul des signes de deltax et deltay */ /* recalcul des signes de deltax et deltay */
if( (end.x - track->m_Start.x) < 0 ) if( (end.x - track->m_Start.x) < 0 )
iDx = -iDx; iDx = -iDx;
if( (end.y - track->m_Start.y) < 0 ) if( (end.y - track->m_Start.y) < 0 )
iDy = -iDy; iDy = -iDy;
track->m_End.x = track->m_Start.x + iDx; track->m_End.x = track->m_Start.x + iDx;
track->m_End.y = track->m_Start.y + iDy; track->m_End.y = track->m_Start.y + iDy;
break; break;
@ -836,6 +893,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
track->m_End.y = end.y + iDx; track->m_End.y = end.y + iDx;
else else
track->m_End.y = end.y - iDx; track->m_End.y = end.y - iDx;
track->m_End.x = track->m_Start.x; track->m_End.x = track->m_Start.x;
break; break;
} }
@ -844,51 +902,47 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
{ {
if( track->IsNull() ) if( track->IsNull() )
track->m_End = end; track->m_End = end;
NewTrack->m_Start = track->m_End;
newTrack->m_Start = track->m_End;
} }
NewTrack->m_End = end; newTrack->m_End = end;
} }
/****************************************************************************/ /****************************************************************************/
TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ) void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
/****************************************************************************/ /****************************************************************************/
/* Delete track segments which have len = 0; after creating a new track /* Delete track segments which have len = 0; after creating a new track
* return a pointer on the first segment (start of track list) * return a pointer on the first segment (start of track list)
*/ */
{ {
if( aTrackList.GetCount() == 0 )
return;
TRACK* track = aTrackList.GetFirst();
TRACK* firsttrack = track; TRACK* firsttrack = track;
TRACK* oldtrack; TRACK* oldtrack;
int nn = 0;
BOARD_ITEM* LockPoint;
if( track == 0 ) BOARD_ITEM* LockPoint = track->start;
return NULL;
LockPoint = track->start;
while( track != NULL ) while( track != NULL )
{ {
oldtrack = track; oldtrack = track;
track = track->Next(); track = track->Next();
if( !oldtrack->IsNull() ) if( !oldtrack->IsNull() )
{ {
nn++;
continue; continue;
} }
// NULL segment, delete it // NULL segment, delete it
if( firsttrack == oldtrack ) if( firsttrack == oldtrack )
firsttrack = track; firsttrack = track;
oldtrack->UnLink();
delete oldtrack; delete aTrackList.Remove( oldtrack );
} }
if( segmcount ) if( aTrackList.GetCount() == 0 )
*segmcount = nn; return; // all the new track segments have been deleted
if( nn == 0 )
return NULL; // all the new track segments have been deleted
// we must set the pointers on connected items and the connection status // we must set the pointers on connected items and the connection status
oldtrack = track = firsttrack; oldtrack = track = firsttrack;
@ -898,13 +952,15 @@ TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount )
oldtrack = track; oldtrack = track;
track = track->Next(); track = track->Next();
oldtrack->end = track; oldtrack->end = track;
if( track ) if( track )
track->start = oldtrack; track->start = oldtrack;
oldtrack->SetStatus( 0 ); oldtrack->SetStatus( 0 );
} }
firsttrack->start = LockPoint; firsttrack->start = LockPoint;
if( LockPoint && (LockPoint->Type() == TYPEPAD ) ) if( LockPoint && LockPoint->Type()==TYPE_PAD )
firsttrack->SetState( BEGIN_ONPAD, ON ); firsttrack->SetState( BEGIN_ONPAD, ON );
track = firsttrack; track = firsttrack;
@ -924,8 +980,6 @@ TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount )
} }
track = next_track; track = next_track;
} }
return firsttrack;
} }
@ -949,10 +1003,8 @@ void EnsureEndTrackOnPad( D_PAD* Pad )
if( !g_CurrentTrackSegment->IsNull() ) if( !g_CurrentTrackSegment->IsNull() )
{ {
/* Must create a new segment, from track end to pad center */ /* Must create a new segment, from track end to pad center */
g_CurrentTrackSegment = lasttrack->Copy(); g_CurrentTrackList.PushBack( lasttrack->Copy() );
g_TrackSegmentCount++;
lasttrack->SetNext( g_CurrentTrackSegment );
g_CurrentTrackSegment->SetBack( lasttrack );
lasttrack->end = g_CurrentTrackSegment; lasttrack->end = g_CurrentTrackSegment;
} }
@ -962,3 +1014,4 @@ void EnsureEndTrackOnPad( D_PAD* Pad )
g_CurrentTrackSegment->end = Pad; g_CurrentTrackSegment->end = Pad;
g_CurrentTrackSegment->SetState( END_ONPAD, ON ); g_CurrentTrackSegment->SetState( END_ONPAD, ON );
} }

View File

@ -38,12 +38,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text = new TEXTE_MODULE( Module ); Text = new TEXTE_MODULE( Module );
/* Chainage de la nouvelle structure en tete de liste drawings */ /* Chainage de la nouvelle structure en tete de liste drawings */
Text->SetNext( Module->m_Drawings ); Module->m_Drawings.PushFront( Text );
Text->SetBack( Module );
if( Module->m_Drawings )
Module->m_Drawings->SetBack( Text );
Module->m_Drawings = Text;
Text->m_Flags = IS_NEW; Text->m_Flags = IS_NEW;
Text->m_Text = wxT( "text" ); Text->m_Text = wxT( "text" );

View File

@ -162,30 +162,24 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
* pour les formes de pad PAD1 a PADn * pour les formes de pad PAD1 a PADn
*/ */
{ {
D_PAD* pad; std::vector<D_PAD*> pads;
D_PAD** padlist;
D_PAD** pad_list_base = NULL;
const char* pad_type; const char* pad_type;
int memsize, ii, dx, dy;
D_PAD* old_pad = NULL;
int pad_name_number;
fputs( "$PADS\n", file ); fputs( "$PADS\n", file );
if( pcb->m_NbPads > 0 ) // pcb->m_Pads is NULL unless this is true if( pcb->m_Pads.size() > 0 )
{ {
// Generation de la liste des pads tries par forme et dimensions: pads.insert( pads.end(), pcb->m_Pads.begin(), pcb->m_Pads.end() );
memsize = (pcb->m_NbPads + 1) * sizeof(D_PAD *); qsort( &pads[0], pcb->m_Pads.size(), sizeof( D_PAD* ), Pad_list_Sort_by_Shapes );
pad_list_base = (D_PAD**) MyZMalloc( memsize );
memcpy( pad_list_base, pcb->m_Pads, memsize );
qsort( pad_list_base, pcb->m_NbPads, sizeof(D_PAD *), Pad_list_Sort_by_Shapes );
} }
pad_name_number = 0; D_PAD* old_pad = NULL;
for( padlist = pad_list_base, ii = 0; ii < pcb->m_NbPads; padlist++, ii++ ) int pad_name_number = 0;
for( unsigned i=0; i<pads.size(); ++i )
{ {
pad = *padlist; D_PAD* pad = pads[i];
pad->SetSubRatsnest( pad_name_number ); pad->SetSubRatsnest( pad_name_number );
if( old_pad && 0==D_PAD::Compare( old_pad, pad ) ) if( old_pad && 0==D_PAD::Compare( old_pad, pad ) )
@ -198,8 +192,8 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
fprintf( file, "PAD PAD%d", pad->GetSubRatsnest() ); fprintf( file, "PAD PAD%d", pad->GetSubRatsnest() );
dx = pad->m_Size.x / 2; int dx = pad->m_Size.x / 2;
dy = pad->m_Size.y / 2; int dy = pad->m_Size.y / 2;
switch( pad->m_PadShape ) switch( pad->m_PadShape )
{ {
@ -273,8 +267,6 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
} }
fputs( "$ENDPADS\n\n", file ); fputs( "$ENDPADS\n\n", file );
MyFree( pad_list_base );
} }
@ -564,7 +556,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
for( track = pcb->m_Zone; track != NULL; track = track->Next() ) for( track = pcb->m_Zone; track != NULL; track = track->Next() )
{ {
if( track->Type() == TYPEZONE ) if( track->Type() == TYPE_ZONE )
nbitems++; nbitems++;
} }
@ -576,7 +568,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
for( track = pcb->m_Zone; track != NULL; track = track->Next() ) for( track = pcb->m_Zone; track != NULL; track = track->Next() )
{ {
if( track->Type() == TYPEZONE ) if( track->Type() == TYPE_ZONE )
tracklist[nbitems++] = track; tracklist[nbitems++] = track;
} }
@ -608,7 +600,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
fprintf( file, "TRACK TRACK%d\n", track->m_Width ); fprintf( file, "TRACK TRACK%d\n", track->m_Width );
} }
if( (track->Type() == TYPETRACK) || (track->Type() == TYPEZONE) ) if( (track->Type() == TYPE_TRACK) || (track->Type() == TYPE_ZONE) )
{ {
if( old_layer != track->GetLayer() ) if( old_layer != track->GetLayer() )
{ {
@ -621,7 +613,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb )
mapXto( track->m_Start.x ), mapYto( track->m_Start.y ), mapXto( track->m_Start.x ), mapYto( track->m_Start.y ),
mapXto( track->m_End.x ), mapYto( track->m_End.y ) ); mapXto( track->m_End.x ), mapYto( track->m_End.y ) );
} }
if( track->Type() == TYPEVIA ) if( track->Type() == TYPE_VIA )
{ {
fprintf( file, "VIA viapad%d %d %d ALL %d via%d\n", fprintf( file, "VIA viapad%d %d %d ALL %d via%d\n",
track->m_Width, track->m_Width,
@ -816,10 +808,10 @@ void ModuleWriteShape( FILE* file, MODULE* module )
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
break; break;
case TYPEEDGEMODULE: case TYPE_EDGE_MODULE:
PtEdge = (EDGE_MODULE*) PtStruct; PtEdge = (EDGE_MODULE*) PtStruct;
switch( PtEdge->m_Shape ) switch( PtEdge->m_Shape )

View File

@ -131,23 +131,23 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format, EDGE_LAYER ); PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPETEXTE: case TYPE_TEXTE:
PlotTextePcb( (TEXTE_PCB*) PtStruct, format, EDGE_LAYER ); PlotTextePcb( (TEXTE_PCB*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPECOTATION: case TYPE_COTATION:
PlotCotation( (COTATION*) PtStruct, format, EDGE_LAYER ); PlotCotation( (COTATION*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPEMIRE: case TYPE_MIRE:
PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER ); PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPEMARKER: // do not draw case TYPE_MARKER: // do not draw
break; break;
default: default:

View File

@ -66,7 +66,7 @@ void Build_Holes_List( BOARD* aPcb,
TRACK* track = aPcb->m_Track; TRACK* track = aPcb->m_Track;
for( ; track != NULL; track = track->Next() ) for( ; track != NULL; track = track->Next() )
{ {
if( track->Type() != TYPEVIA ) if( track->Type() != TYPE_VIA )
continue; continue;
SEGVIA* via = (SEGVIA*) track; SEGVIA* via = (SEGVIA*) track;
hole_value = via->GetDrillValue(); hole_value = via->GetDrillValue();

View File

@ -449,7 +449,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
if( PtStruct->Type() != TYPEDRAWSEGMENT ) if( PtStruct->Type() != TYPE_DRAWSEGMENT )
continue; continue;
if( ( (DRAWSEGMENT*) PtStruct )->GetLayer() != EDGE_N ) if( ( (DRAWSEGMENT*) PtStruct )->GetLayer() != EDGE_N )
continue; continue;

View File

@ -288,21 +288,10 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
Module->Draw( DrawPanel, DC, GR_XOR ); Module->Draw( DrawPanel, DC, GR_XOR );
/* Generation des elements speciaux: drawsegments */ /* Generation des elements speciaux: drawsegments */
LastSegm = (EDGE_MODULE*) Module->m_Drawings;
if( LastSegm )
while( LastSegm->Next() )
LastSegm = (EDGE_MODULE*) LastSegm->Next();
FirstSegm = PtSegm = new EDGE_MODULE( Module ); FirstSegm = PtSegm = new EDGE_MODULE( Module );
if( LastSegm ) Module->m_Drawings.PushBack( PtSegm );
{
LastSegm->SetNext( PtSegm );
PtSegm->SetBack( LastSegm );
}
else
{
Module->m_Drawings = PtSegm; PtSegm->SetBack( Module );
}
PtSegm->m_Start = Mself.m_Start; PtSegm->m_Start = Mself.m_Start;
PtSegm->m_End.x = Mself.m_Start.x; PtSegm->m_End.x = Mself.m_Start.x;
PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta; PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta;
@ -336,6 +325,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
newedge->AddToChain( PtSegm ); newedge->AddToChain( PtSegm );
PtSegm = newedge; PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End; PtSegm->m_Start = PtSegm->m_End;
if( ii & 1 ) /* brin d'ordre impair : cercles de sens > 0 */ if( ii & 1 ) /* brin d'ordre impair : cercles de sens > 0 */
arc_angle = 1800; arc_angle = 1800;
else else
@ -427,8 +417,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
/* Placement des 2 pads sur extremite */ /* Placement des 2 pads sur extremite */
PtPad = new D_PAD( Module ); PtPad = new D_PAD( Module );
Module->m_Pads = PtPad; Module->m_Pads.PushFront( PtPad );
PtPad->SetBack( Module );
PtPad->SetPadName( wxT( "1" ) ); PtPad->SetPadName( wxT( "1" ) );
PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y; PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y;

View File

@ -108,7 +108,7 @@ void WinEDA_DrillFrame::InitDisplayParams( void )
m_BlindOrBuriedViasCount = 0; m_BlindOrBuriedViasCount = 0;
for( TRACK* track = m_Parent->m_Pcb->m_Track; track != NULL; track = track->Next() ) for( TRACK* track = m_Parent->m_Pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( track->Type() != TYPEVIA ) if( track->Type() != TYPE_VIA )
continue; continue;
if( track->Shape() == VIA_THROUGH ) if( track->Shape() == VIA_THROUGH )
m_ThroughViasCount++; m_ThroughViasCount++;

View File

@ -159,8 +159,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
char Line[1024]; char Line[1024];
int NbLine = 0; int NbLine = 0;
long ibuf[100]; long ibuf[100];
EDGE_MODULE* DrawSegm, * LastModStruct = NULL; EDGE_MODULE* DrawSegm;
D_PAD* LastPad = NULL, * Pad; D_PAD* Pad;
wxArrayString params; wxArrayString params;
int iprmcnt, icnt_max, iflgidx; int iprmcnt, icnt_max, iflgidx;
@ -251,21 +251,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
DrawSegm->SetLayer( SILKSCREEN_N_CMP ); DrawSegm->SetLayer( SILKSCREEN_N_CMP );
DrawSegm->m_Shape = S_SEGMENT; DrawSegm->m_Shape = S_SEGMENT;
if( LastModStruct == NULL ) m_Drawings.PushBack( DrawSegm );
{
DrawSegm->SetBack( this );
m_Drawings = DrawSegm;
}
else
{
DrawSegm->SetBack( LastModStruct );
LastModStruct->SetNext( DrawSegm );
}
int* list[5] = { int* list[5] = {
&DrawSegm->m_Start0.x, &DrawSegm->m_Start0.y, &DrawSegm->m_Start0.x, &DrawSegm->m_Start0.y,
&DrawSegm->m_End0.x, &DrawSegm->m_End0.y, &DrawSegm->m_End0.x, &DrawSegm->m_End0.y,
&DrawSegm->m_Width &DrawSegm->m_Width
}; };
for( unsigned ii = 0; ii < 5; ii++ ) for( unsigned ii = 0; ii < 5; ii++ )
{ {
long dim; long dim;
@ -277,7 +270,6 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
} }
DrawSegm->SetDrawCoord(); DrawSegm->SetDrawCoord();
LastModStruct = DrawSegm;
continue; continue;
} }
@ -288,16 +280,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
DrawSegm->SetLayer( SILKSCREEN_N_CMP ); DrawSegm->SetLayer( SILKSCREEN_N_CMP );
DrawSegm->m_Shape = S_ARC; DrawSegm->m_Shape = S_ARC;
if( LastModStruct == NULL ) m_Drawings.PushBack( DrawSegm );
{
DrawSegm->SetBack( this );
m_Drawings = DrawSegm;
}
else
{
DrawSegm->SetBack( LastModStruct );
LastModStruct->SetNext( DrawSegm );
}
for( unsigned ii = 0; ii < 7; ii++ ) for( unsigned ii = 0; ii < 7; ii++ )
{ {
long dim; long dim;
@ -327,7 +311,6 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
DrawSegm->m_Width = (int) round( ibuf[6] * conv_unit ); DrawSegm->m_Width = (int) round( ibuf[6] * conv_unit );
DrawSegm->SetDrawCoord(); DrawSegm->SetDrawCoord();
LastModStruct = DrawSegm;
continue; continue;
} }
@ -376,18 +359,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
Pad->m_PadShape = PAD_OVAL; Pad->m_PadShape = PAD_OVAL;
} }
m_Pads.PushBack( Pad );
if( LastPad == NULL )
{
Pad->SetBack( (EDA_BaseStruct*) this );
m_Pads = Pad;
}
else
{
Pad->SetBack( (EDA_BaseStruct*) LastPad );
LastPad->SetNext( (EDA_BaseStruct*) Pad );
}
LastPad = Pad;
continue; continue;
} }
@ -400,8 +372,10 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
SOLDERMASK_LAYER_CMP | SOLDERMASK_LAYER_CMP |
SOLDERMASK_LAYER_CU; SOLDERMASK_LAYER_CU;
iflgidx = params.GetCount() - 2; iflgidx = params.GetCount() - 2;
if( TestFlags( params[iflgidx], 0x0100, wxT( "square" ) ) ) if( TestFlags( params[iflgidx], 0x0100, wxT( "square" ) ) )
Pad->m_PadShape = PAD_RECT; Pad->m_PadShape = PAD_RECT;
for( unsigned ii = 0; ii < 6; ii++ ) for( unsigned ii = 0; ii < 6; ii++ )
{ {
if( ii < params.GetCount() - 2 ) if( ii < params.GetCount() - 2 )
@ -431,17 +405,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
if( (Pad->m_PadShape == PAD_ROUND) && (Pad->m_Size.x != Pad->m_Size.y) ) if( (Pad->m_PadShape == PAD_ROUND) && (Pad->m_Size.x != Pad->m_Size.y) )
Pad->m_PadShape = PAD_OVAL; Pad->m_PadShape = PAD_OVAL;
if( LastPad == NULL ) m_Pads.PushBack( Pad );
{
Pad->SetBack( (EDA_BaseStruct*) this );
m_Pads = Pad;
}
else
{
Pad->SetBack( (EDA_BaseStruct*) LastPad );
LastPad->SetNext( (EDA_BaseStruct*) Pad );
}
LastPad = Pad;
continue; continue;
} }
} }

View File

@ -272,23 +272,23 @@ void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_l
uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y; uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y;
/* Test si VIA (cercle plein a tracer) */ /* Test si VIA (cercle plein a tracer) */
if( pt_segm->Type() == TYPEVIA ) if( pt_segm->Type() == TYPE_VIA )
{ {
int mask_layer = 0; int mask_layer = 0;
if ( pt_segm->IsOnLayer(Route_Layer_BOTTOM) ) if ( pt_segm->IsOnLayer(Route_Layer_BOTTOM) )
mask_layer = 1 << Route_Layer_BOTTOM; mask_layer = 1 << Route_Layer_BOTTOM;
if ( pt_segm->IsOnLayer(Route_Layer_TOP) ) if ( pt_segm->IsOnLayer(Route_Layer_TOP) )
{ {
if ( mask_layer == 0 ) if ( mask_layer == 0 )
mask_layer = 1 << Route_Layer_TOP; mask_layer = 1 << Route_Layer_TOP;
else mask_layer = -1; else mask_layer = -1;
} }
if( color == VIA_IMPOSSIBLE ) if( color == VIA_IMPOSSIBLE )
mask_layer = -1; mask_layer = -1;
if ( mask_layer ) if ( mask_layer )
TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur, TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur,
mask_layer, color, op_logique ); mask_layer, color, op_logique );
return; return;
} }

View File

@ -315,15 +315,15 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
// don't let backspace delete modules!! // don't let backspace delete modules!!
if( DrawStruct && (DrawStruct->Type() == TYPETRACK if( DrawStruct && (DrawStruct->Type() == TYPE_TRACK
|| DrawStruct->Type() == TYPEVIA) ) || DrawStruct->Type() == TYPE_VIA) )
{ {
Delete_Segment( DC, (TRACK*) DrawStruct ); Delete_Segment( DC, (TRACK*) DrawStruct );
SetCurItem(NULL); SetCurItem(NULL);
} }
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
else if( GetCurItem()->Type() == TYPETRACK ) else if( GetCurItem()->Type() == TYPE_TRACK )
{ {
// then an element is being edited - remove the last segment. // then an element is being edited - remove the last segment.
// simple lines for debugger: // simple lines for debugger:
@ -336,7 +336,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_END_TRACK: case HK_END_TRACK:
if( ! ItemFree && (GetCurItem()->Type() == TYPETRACK) && ((GetCurItem()->m_Flags & IS_NEW) != 0) ) if( ! ItemFree && (GetCurItem()->Type() == TYPE_TRACK) && ((GetCurItem()->m_Flags & IS_NEW) != 0) )
{ {
// A new track is in progress: call to End_Route() // A new track is in progress: call to End_Route()
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
@ -387,7 +387,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
return; return;
if( ItemFree ) // no track in progress: nothing to do if( ItemFree ) // no track in progress: nothing to do
break; break;
if( GetCurItem()->Type() != TYPETRACK ) // Should not occur if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur
return; return;
if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) if( (GetCurItem()->m_Flags & IS_NEW) == 0 )
return; return;
@ -412,7 +412,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
Other_Layer_Route( NULL, DC ); Other_Layer_Route( NULL, DC );
break; break;
} }
if( GetCurItem()->Type() != TYPETRACK ) if( GetCurItem()->Type() != TYPE_TRACK )
return; return;
if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) if( (GetCurItem()->m_Flags & IS_NEW) == 0 )
return; return;
@ -426,7 +426,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
// get any module, locked or not locked and toggle its locked status // get any module, locked or not locked and toggle its locked status
if( ItemFree ) if( ItemFree )
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY ); module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY );
else if( GetCurItem()->Type() == TYPEMODULE ) else if( GetCurItem()->Type() == TYPE_MODULE )
module = (MODULE*) GetCurItem(); module = (MODULE*) GetCurItem();
if( module ) if( module )
{ {
@ -471,7 +471,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
} }
} }
} }
else if( GetCurItem()->Type() == TYPEMODULE ) else if( GetCurItem()->Type() == TYPE_MODULE )
{ {
module = (MODULE*) GetCurItem(); module = (MODULE*) GetCurItem();
@ -606,11 +606,11 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
if( ItemFree ) if( ItemFree )
{ {
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct && DrawStruct->Type() != TYPETRACK ) if( DrawStruct && DrawStruct->Type() != TYPE_TRACK )
return FALSE; return FALSE;
Delete_Track( DC, (TRACK*) DrawStruct ); Delete_Track( DC, (TRACK*) DrawStruct );
} }
else if( GetCurItem()->Type() == TYPETRACK ) else if( GetCurItem()->Type() == TYPE_TRACK )
{ {
// simple lines for debugger: // simple lines for debugger:
TRACK* track = (TRACK*) GetCurItem(); TRACK* track = (TRACK*) GetCurItem();

View File

@ -131,10 +131,10 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
// layer names are put into the BOARD. // layer names are put into the BOARD.
SetBOARD( new BOARD( NULL, this ) ); SetBOARD( new BOARD( NULL, this ) );
for( ; g_UnDeleteStackPtr != 0; ) while( g_UnDeleteStackPtr > 0 )
{ {
g_UnDeleteStackPtr--; g_UnDeleteStackPtr--;
g_UnDeleteStack[g_UnDeleteStackPtr]->DeleteStructList(); g_UnDeleteStack[g_UnDeleteStackPtr]->DeleteStructList();
} }
/* init pointeurs et variables */ /* init pointeurs et variables */
@ -175,13 +175,7 @@ void WinEDA_PcbFrame::Erase_Zones( bool query )
if( query && !IsOK( this, _( "Delete Zones ?" ) ) ) if( query && !IsOK( this, _( "Delete Zones ?" ) ) )
return; return;
if( m_Pcb->m_Zone ) m_Pcb->m_Zone.DeleteAll();
{
m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
}
m_Pcb->DeleteZONEOutlines(); m_Pcb->DeleteZONEOutlines();
GetScreen()->SetModify(); GetScreen()->SetModify();
@ -215,10 +209,10 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( bool is_edges, bool query )
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPETEXTE: case TYPE_TEXTE:
case TYPECOTATION: case TYPE_COTATION:
case TYPEMIRE: case TYPE_MIRE:
if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer ) if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer )
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
break; break;
@ -272,12 +266,9 @@ void WinEDA_PcbFrame::Erase_Modules( bool query )
if( query && !IsOK( this, _( "Delete Modules?" ) ) ) if( query && !IsOK( this, _( "Delete Modules?" ) ) )
return; return;
m_Pcb->m_Modules->DeleteStructList(); m_Pcb->m_Modules.DeleteAll();
m_Pcb->m_Modules = 0;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
m_Pcb->m_NbNets = 0;
m_Pcb->m_NbPads = 0;
m_Pcb->m_NbNodes = 0; m_Pcb->m_NbNodes = 0;
m_Pcb->m_NbLinks = 0; m_Pcb->m_NbLinks = 0;
m_Pcb->m_NbNoconnect = 0; m_Pcb->m_NbNoconnect = 0;
@ -299,8 +290,10 @@ void WinEDA_PcbFrame::Erase_Textes_Pcb( bool query )
for( ; PtStruct != NULL; PtStruct = PtNext ) for( ; PtStruct != NULL; PtStruct = PtNext )
{ {
PtNext = PtStruct->Next(); PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPETEXTE ) if( PtStruct->Type() == TYPE_TEXTE )
PtStruct ->DeleteStructure(); {
PtStruct->DeleteStructure();
}
} }
GetScreen()->SetModify(); GetScreen()->SetModify();

View File

@ -79,7 +79,7 @@ int NbDraw, NbTrack, NbZone, NbMod, NbNets;
/**********************************************************************/ /**********************************************************************/
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
TRACK* PtSegm, int StructType, int* LineNum, int NumSegm ) TRACK* insertBeforeMe, int StructType, int* LineNum, int NumSegm )
/**********************************************************************/ /**********************************************************************/
/** Read a list of segments (Tracks, zones) /** Read a list of segments (Tracks, zones)
@ -91,7 +91,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
char line1[256]; char line1[256];
char line2[256]; char line2[256];
TRACK* NewTrack; TRACK* newTrack;
while( GetLine( File, line1, LineNum ) ) while( GetLine( File, line1, LineNum ) )
{ {
@ -104,9 +104,9 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
} }
// Read the 2nd line to determine the exact type, one of: // Read the 2nd line to determine the exact type, one of:
// TYPETRACK, TYPEVIA, or TYPEZONE. The type field in 2nd line // TYPE_TRACK, TYPE_VIA, or TYPE_ZONE. The type field in 2nd line
// differentiates between TYPETRACK and TYPEVIA. With virtual // differentiates between TYPE_TRACK and TYPE_VIA. With virtual
// functions in use, it is critical to instantiate the TYPEVIA exactly. // functions in use, it is critical to instantiate the TYPE_VIA exactly.
if( GetLine( File, line2, LineNum ) == NULL ) if( GetLine( File, line2, LineNum ) == NULL )
break; break;
@ -117,49 +117,48 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File,
sscanf( line2 + 2, " %d %d %d %lX %X", &layer, &type, &net_code, sscanf( line2 + 2, " %d %d %d %lX %X", &layer, &type, &net_code,
&timeStamp, &flags ); &timeStamp, &flags );
if( StructType==TYPETRACK && type==1 ) if( StructType==TYPE_TRACK && type==1 )
makeType = TYPEVIA; makeType = TYPE_VIA;
else else
makeType = StructType; makeType = StructType;
switch( makeType ) switch( makeType )
{ {
default: default:
case TYPETRACK: case TYPE_TRACK:
NewTrack = new TRACK( m_Pcb ); newTrack = new TRACK( m_Pcb );
m_Pcb->m_Track.Insert( newTrack, insertBeforeMe );
break; break;
case TYPEVIA: case TYPE_VIA:
NewTrack = new SEGVIA( m_Pcb ); newTrack = new SEGVIA( m_Pcb );
m_Pcb->m_Track.Insert( newTrack, insertBeforeMe );
break; break;
case TYPEZONE: case TYPE_ZONE:
NewTrack = new SEGZONE( m_Pcb ); newTrack = new SEGZONE( m_Pcb );
m_Pcb->m_Zone.Insert( (SEGZONE*)newTrack, (SEGZONE*)insertBeforeMe );
break; break;
} }
NewTrack->Insert( m_Pcb, PtSegm ); newTrack->m_TimeStamp = timeStamp;
PtSegm = NewTrack;
PtSegm->m_TimeStamp = timeStamp;
int arg_count = sscanf( line1 + 2, " %d %d %d %d %d %d %d", &shape, int arg_count = sscanf( line1 + 2, " %d %d %d %d %d %d %d", &shape,
&PtSegm->m_Start.x, &PtSegm->m_Start.y, &newTrack->m_Start.x, &newTrack->m_Start.y,
&PtSegm->m_End.x, &PtSegm->m_End.y, &width, &newTrack->m_End.x, &newTrack->m_End.y, &width,
&drill ); &drill );
PtSegm->m_Width = width; newTrack->m_Width = width;
PtSegm->m_Shape = shape; newTrack->m_Shape = shape;
if( arg_count < 7 || drill <= 0 ) if( arg_count < 7 || drill <= 0 )
PtSegm->SetDrillDefault(); newTrack->SetDrillDefault();
else else
PtSegm->SetDrillValue(drill); newTrack->SetDrillValue(drill);
PtSegm->SetLayer( layer ); newTrack->SetLayer( layer );
PtSegm->SetNet( net_code ); newTrack->SetNet( net_code );
PtSegm->SetState( flags, ON ); newTrack->SetState( flags, ON );
} }
DisplayError( this, _( "Error: Unexpected end of file !" ) ); DisplayError( this, _( "Error: Unexpected end of file !" ) );
@ -330,14 +329,14 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "TrackWidth" ) == 0 ) if( stricmp( Line, "TrackWidth" ) == 0 )
{ {
g_DesignSettings.m_CurrentTrackWidth = atoi( data ); g_DesignSettings.m_CurrentTrackWidth = atoi( data );
AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPETRACK ); AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPE_TRACK );
continue; continue;
} }
if( stricmp( Line, "TrackWidthHistory" ) == 0 ) if( stricmp( Line, "TrackWidthHistory" ) == 0 )
{ {
int tmp = atoi( data ); int tmp = atoi( data );
AddHistory( tmp, TYPETRACK ); AddHistory( tmp, TYPE_TRACK );
continue; continue;
} }
@ -407,7 +406,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "ViaSize" ) == 0 ) if( stricmp( Line, "ViaSize" ) == 0 )
{ {
g_DesignSettings.m_CurrentViaSize = atoi( data ); g_DesignSettings.m_CurrentViaSize = atoi( data );
AddHistory( g_DesignSettings.m_CurrentViaSize, TYPEVIA ); AddHistory( g_DesignSettings.m_CurrentViaSize, TYPE_VIA );
continue; continue;
} }
@ -420,7 +419,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "ViaSizeHistory" ) == 0 ) if( stricmp( Line, "ViaSizeHistory" ) == 0 )
{ {
int tmp = atoi( data ); int tmp = atoi( data );
AddHistory( tmp, TYPEVIA ); AddHistory( tmp, TYPE_VIA );
continue; continue;
} }
@ -616,7 +615,7 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Nzone %d\n", m_Pcb->GetNumSegmZone() ); fprintf( File, "Nzone %d\n", m_Pcb->GetNumSegmZone() );
fprintf( File, "Nmodule %d\n", NbModules ); fprintf( File, "Nmodule %d\n", NbModules );
fprintf( File, "Nnets %d\n", m_Pcb->m_NbNets ); fprintf( File, "Nnets %d\n", m_Pcb->m_Equipots.GetCount() );
fprintf( File, "$EndGENERAL\n\n" ); fprintf( File, "$EndGENERAL\n\n" );
return TRUE; return TRUE;
@ -762,10 +761,6 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
{ {
char Line[1024]; char Line[1024];
int LineNum = 0; int LineNum = 0;
int nbsegm, nbmod;
BOARD_ITEM* LastStructPcb = NULL, * StructPcb;
MODULE* LastModule = NULL, * Module;
EQUIPOT* LastEquipot = NULL, * Equipot;
wxBusyCursor dummy; wxBusyCursor dummy;
@ -773,33 +768,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
SetLocaleTo_C_standard( ); SetLocaleTo_C_standard( );
NbDraw = NbTrack = NbZone = NbMod = NbNets = -1; NbDraw = NbTrack = NbZone = NbMod = NbNets = -1;
m_Pcb->m_NbNets = 0;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
nbmod = 0;
if( Append )
{
LastModule = m_Pcb->m_Modules;
for( ; LastModule != NULL; LastModule = (MODULE*) LastModule->Next() )
{
if( LastModule->Next() == NULL )
break;
}
LastStructPcb = m_Pcb->m_Drawings;
for( ; LastStructPcb != NULL; LastStructPcb = LastStructPcb->Next() )
{
if( LastStructPcb->Next() == NULL )
break;
}
LastEquipot = m_Pcb->m_Equipots;
for( ; LastEquipot != NULL; LastEquipot = (EQUIPOT*) LastEquipot->Next() )
{
if( LastEquipot->Next() == NULL )
break;
}
}
while( GetLine( File, Line, &LineNum ) != NULL ) while( GetLine( File, Line, &LineNum ) != NULL )
{ {
@ -835,20 +804,9 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
if( strnicmp( Line, "$EQUIPOT", 7 ) == 0 ) if( strnicmp( Line, "$EQUIPOT", 7 ) == 0 )
{ {
Equipot = new EQUIPOT( m_Pcb ); EQUIPOT* Equipot = new EQUIPOT( m_Pcb );
m_Pcb->m_Equipots.PushBack( Equipot );
Equipot->ReadEquipotDescr( File, &LineNum ); Equipot->ReadEquipotDescr( File, &LineNum );
if( LastEquipot == NULL )
{
m_Pcb->m_Equipots = Equipot;
Equipot->SetBack( m_Pcb );
}
else
{
Equipot->SetBack( LastEquipot );
LastEquipot->SetNext( Equipot );
}
LastEquipot = Equipot;
m_Pcb->m_NbNets++;
continue; continue;
} }
@ -864,140 +822,67 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append )
if( strnicmp( Line, "$MODULE", 7 ) == 0 ) if( strnicmp( Line, "$MODULE", 7 ) == 0 )
{ {
Module = new MODULE( m_Pcb ); MODULE* Module = new MODULE( m_Pcb );
if( Module == NULL ) if( Module == NULL )
continue; continue;
Module->ReadDescr( File, &LineNum );
if( LastModule == NULL ) m_Pcb->Add( Module, ADD_APPEND );
{ Module->ReadDescr( File, &LineNum );
m_Pcb->m_Modules = Module;
Module->SetBack( m_Pcb );
}
else
{
Module->SetBack( LastModule );
LastModule->SetNext( Module );
}
LastModule = Module;
nbmod++;
continue; continue;
} }
if( strnicmp( Line, "$TEXTPCB", 8 ) == 0 ) if( strnicmp( Line, "$TEXTPCB", 8 ) == 0 )
{ {
TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_Pcb ); TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_Pcb );
StructPcb = pcbtxt; m_Pcb->Add( pcbtxt, ADD_APPEND );
pcbtxt->ReadTextePcbDescr( File, &LineNum ); pcbtxt->ReadTextePcbDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = StructPcb;
StructPcb->SetBack( m_Pcb );
}
else
{
StructPcb->SetBack( LastStructPcb );
LastStructPcb->SetNext( StructPcb );
}
LastStructPcb = StructPcb;
continue; continue;
} }
if( strnicmp( Line, "$DRAWSEGMENT", 10 ) == 0 ) if( strnicmp( Line, "$DRAWSEGMENT", 10 ) == 0 )
{ {
DRAWSEGMENT* DrawSegm = new DRAWSEGMENT( m_Pcb ); DRAWSEGMENT* DrawSegm = new DRAWSEGMENT( m_Pcb );
m_Pcb->Add( DrawSegm, ADD_APPEND );
DrawSegm->ReadDrawSegmentDescr( File, &LineNum ); DrawSegm->ReadDrawSegmentDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = DrawSegm;
DrawSegm->SetBack( m_Pcb );
}
else
{
DrawSegm->SetBack( LastStructPcb );
LastStructPcb->SetNext( DrawSegm );
}
LastStructPcb = DrawSegm;
continue; continue;
} }
if( strnicmp( Line, "$COTATION", 9 ) == 0 ) if( strnicmp( Line, "$COTATION", 9 ) == 0 )
{ {
COTATION* Cotation = new COTATION( m_Pcb ); COTATION* Cotation = new COTATION( m_Pcb );
m_Pcb->Add( Cotation, ADD_APPEND );
Cotation->ReadCotationDescr( File, &LineNum ); Cotation->ReadCotationDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = Cotation;
Cotation->SetBack( m_Pcb );
}
else
{
Cotation->SetBack( LastStructPcb );
LastStructPcb->SetNext( Cotation );
}
LastStructPcb = Cotation;
continue; continue;
} }
if( strnicmp( Line, "$MIREPCB", 8 ) == 0 ) if( strnicmp( Line, "$MIREPCB", 8 ) == 0 )
{ {
MIREPCB* Mire = new MIREPCB( m_Pcb ); MIREPCB* Mire = new MIREPCB( m_Pcb );
m_Pcb->Add( Mire, ADD_APPEND );
Mire->ReadMirePcbDescr( File, &LineNum ); Mire->ReadMirePcbDescr( File, &LineNum );
if( LastStructPcb == NULL )
{
m_Pcb->m_Drawings = Mire;
Mire->SetBack( m_Pcb );
}
else
{
Mire->SetBack( LastStructPcb );
LastStructPcb->SetNext( Mire );
}
LastStructPcb = Mire;
continue; continue;
} }
if( strnicmp( Line, "$TRACK", 6 ) == 0 ) if( strnicmp( Line, "$TRACK", 6 ) == 0 )
{ {
TRACK* StartTrack = m_Pcb->m_Track;
nbsegm = 0;
if( Append )
{
for( ; StartTrack != NULL; StartTrack = StartTrack->Next() )
{
if( StartTrack->Next() == NULL )
break;
}
}
#ifdef PCBNEW #ifdef PCBNEW
int ii = ReadListeSegmentDescr( File, StartTrack, TYPETRACK, TRACK* insertBeforeMe = Append ? NULL : m_Pcb->m_Track.GetFirst();
ReadListeSegmentDescr( File, insertBeforeMe, TYPE_TRACK,
&LineNum, NbTrack ); &LineNum, NbTrack );
m_Pcb->m_NbSegmTrack += ii; D( m_Pcb->m_Track.VerifyListIntegrity(); )
#endif #endif
continue; continue;
} }
if( strnicmp( Line, "$ZONE", 5 ) == 0 ) if( strnicmp( Line, "$ZONE", 5 ) == 0 )
{ {
SEGZONE* StartZone = m_Pcb->m_Zone;
if( Append )
{
for( ; StartZone != NULL; StartZone = StartZone->Next() )
{
if( StartZone->Next() == NULL )
break;
}
}
#ifdef PCBNEW #ifdef PCBNEW
int ii = ReadListeSegmentDescr( File, StartZone, TYPEZONE, SEGZONE* insertBeforeMe = Append ? NULL : m_Pcb->m_Zone.GetFirst();
ReadListeSegmentDescr( File, insertBeforeMe, TYPE_ZONE,
&LineNum, NbZone ); &LineNum, NbZone );
m_Pcb->m_NbSegmZone += ii; D( m_Pcb->m_Zone.VerifyListIntegrity(); )
#endif #endif
continue; continue;
} }

View File

@ -58,17 +58,17 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
{ {
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPECOTATION: case TYPE_COTATION:
case TYPETEXTE: case TYPE_TEXTE:
case TYPEMIRE: case TYPE_MIRE:
if( ((1<<item->GetLayer()) & printmasklayer) == 0 ) if( ((1<<item->GetLayer()) & printmasklayer) == 0 )
break; break;
item->Draw( this, DC, drawmode ); item->Draw( this, DC, drawmode );
break; break;
case TYPEMARKER: /* Trace des marqueurs */ case TYPE_MARKER: /* Trace des marqueurs */
default: default:
break; break;
} }
@ -80,7 +80,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
{ {
if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue; continue;
if( pt_piste->Type() == TYPEVIA ) /* VIA rencontree */ if( pt_piste->Type() == TYPE_VIA ) /* VIA rencontree */
{ {
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];
@ -118,7 +118,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
{ {
if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue; continue;
if( pt_piste->Type() == TYPEVIA ) /* VIA rencontree */ if( pt_piste->Type() == TYPE_VIA ) /* VIA rencontree */
{ {
GRSetDrawMode( DC, drawmode ); GRSetDrawMode( DC, drawmode );
GRFilledCircle( &m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y, GRFilledCircle( &m_ClipBox, DC, pt_piste->m_Start.x, pt_piste->m_Start.y,
@ -206,7 +206,7 @@ static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPETEXTEMODULE: case TYPE_TEXTE_MODULE:
if( (mlayer & masklayer ) == 0 ) if( (mlayer & masklayer ) == 0 )
break; break;
@ -214,7 +214,7 @@ static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC,
TextMod->Draw( panel, DC, draw_mode ); TextMod->Draw( panel, DC, draw_mode );
break; break;
case TYPEEDGEMODULE: 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 )

View File

@ -123,13 +123,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
} }
/* Insert footprint in list*/ /* Insert footprint in list*/
if( m_Pcb->m_Modules ) m_Pcb->Add( module );
{
m_Pcb->m_Modules->SetBack( module );
}
module->SetNext( m_Pcb->m_Modules );
module->SetBack( m_Pcb );
m_Pcb->m_Modules = module;
/* Display info : */ /* Display info : */
module->Display_Infos( this ); module->Display_Infos( this );
@ -734,13 +728,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
// Creates the new module and add it to the head of the linked list of modules // Creates the new module and add it to the head of the linked list of modules
Module = new MODULE( m_Pcb ); Module = new MODULE( m_Pcb );
Module->SetNext( m_Pcb->m_Modules ); m_Pcb->Add( Module );
Module->SetBack( m_Pcb );
if( m_Pcb->m_Modules )
{
m_Pcb->m_Modules->SetBack( Module );
}
m_Pcb->m_Modules = Module;
/* Update parameters: position, timestamp ... */ /* Update parameters: position, timestamp ... */
newpos = GetScreen()->m_Curseur; newpos = GetScreen()->m_Curseur;

Some files were not shown because too many files have changed in this diff Show More