From aab39d1de775952d09f6299e31217e3cdc1fa7c9 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Thu, 4 Dec 2008 04:28:11 +0000 Subject: [PATCH] injected DLIST<> into many list heads, see change_log.txt --- 3d-viewer/3d_class.cpp | 8 +- 3d-viewer/3d_draw.cpp | 12 +- 3d-viewer/3d_struct.h | 4 +- change_log.txt | 31 ++ common/dlist.cpp | 4 +- cvpcb/setvisu.cpp | 8 +- eeschema/block.cpp | 10 +- eeschema/class_screen.cpp | 2 +- eeschema/protos.h | 2 +- gerbview/CMakeLists.txt | 1 + gerbview/affiche.cpp | 2 +- gerbview/block.cpp | 6 +- gerbview/deltrack.cpp | 20 +- gerbview/edit.cpp | 2 +- gerbview/export_to_pcbnew.cpp | 8 +- gerbview/initpcb.cpp | 33 +- gerbview/locate.cpp | 12 +- gerbview/makefile.include | 5 +- gerbview/onrightclick.cpp | 2 +- gerbview/rs274d.cpp | 82 ++-- gerbview/rs274x.cpp | 12 + gerbview/tracepcb.cpp | 42 +- gerbview/trpiste.cpp | 64 +-- gerbview/undelete.cpp | 8 +- include/base_struct.h | 39 +- include/board_item_struct.h | 148 ++++++- include/dlist.h | 15 +- include/pcbstruct.h | 32 +- include/wxPcbStruct.h | 2 +- pcbnew/affiche.cpp | 4 +- pcbnew/attribut.cpp | 2 +- pcbnew/autoplac.cpp | 66 +-- pcbnew/autorout.cpp | 6 +- pcbnew/basepcbframe.cpp | 2 +- pcbnew/block.cpp | 301 +++++++------- pcbnew/block_module_editor.cpp | 66 ++- pcbnew/board.cpp | 160 +++---- pcbnew/class_board.cpp | 201 ++++----- pcbnew/class_board.h | 26 +- pcbnew/class_board_connected_item.cpp | 4 +- pcbnew/class_board_item.cpp | 72 ++-- pcbnew/class_cotation.cpp | 29 +- pcbnew/class_cotation.h | 5 +- pcbnew/class_drawsegment.cpp | 27 +- pcbnew/class_drawsegment.h | 8 +- pcbnew/class_edge_mod.cpp | 31 +- pcbnew/class_edge_mod.h | 9 - pcbnew/class_equipot.cpp | 29 +- pcbnew/class_equipot.h | 6 +- pcbnew/class_marker.cpp | 8 +- pcbnew/class_marker.h | 2 +- pcbnew/class_mire.cpp | 28 +- pcbnew/class_mire.h | 5 +- pcbnew/class_module.cpp | 229 +++------- pcbnew/class_module.h | 19 +- pcbnew/class_pad.cpp | 34 +- pcbnew/class_pad.h | 4 - pcbnew/class_pcb_text.cpp | 30 +- pcbnew/class_pcb_text.h | 5 - pcbnew/class_text_mod.cpp | 31 +- pcbnew/class_text_mod.h | 4 - pcbnew/class_track.cpp | 303 ++++++-------- pcbnew/class_track.h | 45 +- pcbnew/class_zone.cpp | 2 +- pcbnew/class_zone.h | 3 - pcbnew/classpcb.cpp | 2 +- pcbnew/clean.cpp | 78 ++-- pcbnew/collectors.cpp | 128 +++--- pcbnew/collectors.h | 2 +- pcbnew/connect.cpp | 180 ++++---- pcbnew/controle.cpp | 36 +- pcbnew/cotation.cpp | 7 +- pcbnew/cross-probing.cpp | 6 +- pcbnew/deltrack.cpp | 101 +++-- pcbnew/dialog_edit_module.cpp | 4 +- pcbnew/dialog_track_options.cpp | 18 +- pcbnew/dragsegm.cpp | 18 +- pcbnew/drc.cpp | 129 +++--- pcbnew/drc_stuff.h | 4 +- pcbnew/edgemod.cpp | 20 +- pcbnew/edit.cpp | 67 ++- pcbnew/edit_track_width.cpp | 4 +- pcbnew/editedge.cpp | 26 +- pcbnew/editmod.cpp | 12 +- pcbnew/editrack-part2.cpp | 117 +++--- pcbnew/editrack.cpp | 391 ++++++++++-------- pcbnew/edtxtmod.cpp | 6 +- pcbnew/export_gencad.cpp | 42 +- pcbnew/gen_drill_report_files.cpp | 10 +- .../gen_holes_and_tools_lists_for_drill.cpp | 2 +- pcbnew/gen_modules_placefile.cpp | 2 +- pcbnew/gen_self.h | 19 +- pcbnew/gendrill.cpp | 2 +- pcbnew/gpcb_exchange.cpp | 58 +-- pcbnew/graphpcb.cpp | 28 +- pcbnew/hotkeys.cpp | 20 +- pcbnew/initpcb.cpp | 31 +- pcbnew/ioascii.cpp | 211 +++------- pcbnew/lay2plot.cpp | 18 +- pcbnew/librairi.cpp | 16 +- pcbnew/loadcmp.cpp | 24 +- pcbnew/locate.cpp | 52 +-- pcbnew/mirepcb.cpp | 7 +- pcbnew/modedit.cpp | 21 +- pcbnew/modedit_onclick.cpp | 42 +- pcbnew/modedit_undo_redo.cpp | 15 +- pcbnew/modules.cpp | 19 +- pcbnew/move-drag_pads.cpp | 21 +- pcbnew/move_or_drag_track.cpp | 105 +++-- pcbnew/muonde.cpp | 27 +- pcbnew/onleftclick.cpp | 58 +-- pcbnew/onrightclick.cpp | 38 +- pcbnew/pcbnew.h | 14 +- pcbnew/pcbtexte.cpp | 6 +- pcbnew/plot_rtn.cpp | 22 +- pcbnew/plotgerb.cpp | 16 +- pcbnew/plothpgl.cpp | 16 +- pcbnew/plotps.cpp | 18 +- pcbnew/ratsnest.cpp | 181 ++++---- pcbnew/router.cpp | 59 +-- pcbnew/solve.cpp | 106 ++--- pcbnew/specctra_export.cpp | 20 +- pcbnew/specctra_import.cpp | 6 +- pcbnew/surbrill.cpp | 10 +- pcbnew/swap_layers.cpp | 4 +- pcbnew/tr_modif.cpp | 88 ++-- pcbnew/tracepcb.cpp | 8 +- pcbnew/track.cpp | 205 ++++----- pcbnew/trpiste.cpp | 8 +- pcbnew/undelete.cpp | 126 +++--- pcbnew/via_edit.cpp | 4 +- pcbnew/xchgmod.cpp | 2 +- pcbnew/zones_by_polygon.cpp | 7 +- .../zones_convert_brd_items_to_polygons.cpp | 6 +- ...ones_polygons_insulated_copper_islands.cpp | 2 +- pcbnew/zones_polygons_test_connections.cpp | 6 +- share/drawpanel.cpp | 6 +- 137 files changed, 2533 insertions(+), 3079 deletions(-) diff --git a/3d-viewer/3d_class.cpp b/3d-viewer/3d_class.cpp index 192e1fd78e..cedf78efff 100644 --- a/3d-viewer/3d_class.cpp +++ b/3d-viewer/3d_class.cpp @@ -70,8 +70,8 @@ void Struct3D_Master::Copy( Struct3D_Master* pattern ) /***************************************************************/ -Struct3D_Master::Struct3D_Master( EDA_BaseStruct* StructFather ) : - EDA_BaseStruct( StructFather, NOT_USED ) +Struct3D_Master::Struct3D_Master( EDA_BaseStruct* aParent ) : + EDA_BaseStruct( aParent, NOT_USED ) /***************************************************************/ { 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 ) : - EDA_BaseStruct( StructFather, NOT_USED ) +Struct3D_Shape::Struct3D_Shape( EDA_BaseStruct* aParent ) : + EDA_BaseStruct( aParent, NOT_USED ) /***************************************************************/ { m_3D_Coord = NULL; diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 93498c4b7d..28c3d35f66 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -197,7 +197,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() /* draw tracks and vias : */ for( track = pcb->m_Track; track != NULL; track = track->Next() ) { - if( track->Type() == TYPEVIA ) + if( track->Type() == TYPE_VIA ) Draw3D_Via( (SEGVIA*) track ); else Draw3D_Track( track ); @@ -207,7 +207,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() { for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() ) { - if( segzone->Type() == TYPEZONE ) + if( segzone->Type() == TYPE_ZONE ) Draw3D_Track( segzone ); } } @@ -218,11 +218,11 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: Draw3D_DrawSegment( (DRAWSEGMENT*) PtStruct ); break; - case TYPETEXTE: + case TYPE_TEXTE: Draw3D_DrawText( (TEXTE_PCB*) PtStruct ); break; @@ -513,10 +513,10 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) { switch( Struct->Type() ) { - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: ( (EDGE_MODULE*) Struct )->Draw3D( glcanvas ); break; diff --git a/3d-viewer/3d_struct.h b/3d-viewer/3d_struct.h index e19085d829..66107f4e4c 100644 --- a/3d-viewer/3d_struct.h +++ b/3d-viewer/3d_struct.h @@ -70,7 +70,7 @@ public: public: - Struct3D_Master( EDA_BaseStruct * StructFather ); + Struct3D_Master( EDA_BaseStruct * aParent ); ~Struct3D_Master(); Struct3D_Master* Next() const { return (Struct3D_Master*) Pnext; } @@ -105,7 +105,7 @@ public: public: - Struct3D_Shape( EDA_BaseStruct * StructFather ); + Struct3D_Shape( EDA_BaseStruct * aParent ); ~Struct3D_Shape(); Struct3D_Shape* Next() const { return (Struct3D_Shape*) Pnext; } diff --git a/change_log.txt b/change_log.txt index 8fd8f2243d..6144f389df 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,36 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. + +2008-Dec-3 UPDATE Dick Hollenbeck +================================================================================ +++pcbnew & gerbview + * added g_CurrentTrackList, and made g_CurrentTrackSegment and g_FirstTrackSegment + be #defines into this DLIST, 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 ::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::PushFront() + and other member functions of DLIST. + * Switched to std::vector in track.cpp to hold the temporary static list. + * Made g_UnDeleteStack be a DLIST. + * 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 ================================================================================ ++pcbnew @@ -13,6 +43,7 @@ email address. results are same, but using segments can be better (faster redraw time) for polygons having a lot of segments (more than 10000) +>>>>>>> .r1441 2008-Dec-02 UPDATE Wayne Stambaugh ================================================================================ ++build fixes diff --git a/common/dlist.cpp b/common/dlist.cpp index 43b8ce779b..fa1caa4c37 100644 --- a/common/dlist.cpp +++ b/common/dlist.cpp @@ -156,8 +156,6 @@ void DHEAD::remove( EDA_BaseStruct* aElement ) aElement->SetList( 0 ); --count; - - D( VerifyListIntegrity(); ); } #if defined(DEBUG) @@ -191,6 +189,8 @@ void DHEAD::VerifyListIntegrity() wxASSERT( item == NULL ); wxASSERT( i == count ); + + // printf("list %p has %d items.\n", this, count ); } #endif diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp index 0c9228c5c8..7d304c6976 100644 --- a/cvpcb/setvisu.cpp +++ b/cvpcb/setvisu.cpp @@ -51,15 +51,13 @@ void WinEDA_CvpcbFrame::CreateScreenCmp() 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 - DrawFrame->m_Pcb->m_Modules->DeleteStructure(); - - DrawFrame->m_Pcb->m_Modules = NULL; + DrawFrame->m_Pcb->m_Modules.DeleteAll(); } - DrawFrame->m_Pcb->m_Modules = DrawFrame->Get_Module( FootprintName ); + DrawFrame->m_Pcb->m_Modules.PushBack( DrawFrame->Get_Module( FootprintName ) ); DrawFrame->Zoom_Automatique( FALSE ); if( DrawFrame->m_Draw3DFrame ) diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 9b9cea836d..ae7a200db4 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -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(); } @@ -900,7 +900,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc RedrawOneStruct( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE ); - SetStructFather( NewDrawStruct, screen ); + SetaParent( NewDrawStruct, screen ); NewDrawStruct->SetNext( screen->EEDrawList ); screen->EEDrawList = NewDrawStruct; } @@ -1052,7 +1052,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) { ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) Struct )->ClearAnnotation(NULL); - SetStructFather( Struct, GetScreen() ); + SetaParent( Struct, GetScreen() ); } PickedList = (DrawPickedStruct*) PickedList->Next(); } @@ -1062,7 +1062,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) { SCH_ITEM * Struct = PickedList->m_PickedStruct; Struct->SetNext( GetScreen()->EEDrawList ); - SetStructFather( Struct, GetScreen() ); + SetaParent( Struct, GetScreen() ); GetScreen()->EEDrawList = Struct; PickedList = PickedList->Next(); } @@ -1077,7 +1077,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) ( (SCH_COMPONENT*) DrawStruct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) DrawStruct )->ClearAnnotation(NULL); } - SetStructFather( DrawStruct, GetScreen() ); + SetaParent( DrawStruct, GetScreen() ); RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); DrawStruct->SetNext( GetScreen()->EEDrawList ); GetScreen()->EEDrawList = DrawStruct; diff --git a/eeschema/class_screen.cpp b/eeschema/class_screen.cpp index 879929af9d..4c7c4c74c9 100644 --- a/eeschema/class_screen.cpp +++ b/eeschema/class_screen.cpp @@ -11,7 +11,7 @@ /******************************************************************/ -void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) +void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) /******************************************************************/ { switch( Struct->Type() ) diff --git a/eeschema/protos.h b/eeschema/protos.h index 13cfd163b3..a8621a2ff6 100644 --- a/eeschema/protos.h +++ b/eeschema/protos.h @@ -371,7 +371,7 @@ DrawPickedStruct * BreakSegment(SCH_SCREEN * screen, wxPoint breakpoint, /* EECLASS.CPP */ /**************/ -void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen); +void SetaParent(EDA_BaseStruct * Struct, BASE_SCREEN * Screen); /***************/ /* LIBALIAS.CPP */ diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index d0f4349e3d..d0278cc88a 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -43,6 +43,7 @@ set(GERBVIEW_SRCS set(GERBVIEW_EXTRA_SRCS ../pcbnew/basepcbframe.cpp ../pcbnew/class_board.cpp + ../pcbnew/class_board_item.cpp ../pcbnew/class_board_connected_item.cpp ../pcbnew/class_drawsegment.cpp ../pcbnew/class_drc_item.cpp diff --git a/gerbview/affiche.cpp b/gerbview/affiche.cpp index ae4a9672b5..b537246d84 100644 --- a/gerbview/affiche.cpp +++ b/gerbview/affiche.cpp @@ -25,7 +25,7 @@ void Affiche_Infos_PCB_Texte( WinEDA_BasePcbFrame* frame, TEXTE_PCB* pt_texte ) 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 ); else diff --git a/gerbview/block.cpp b/gerbview/block.cpp index 0c93943853..850da9e60e 100644 --- a/gerbview/block.cpp +++ b/gerbview/block.cpp @@ -398,7 +398,8 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) /* this track segment must be duplicated */ m_Pcb->m_Status_Pcb = 0; TRACK* new_track = track->Copy(); - new_track->Insert( m_Pcb, NULL ); + + m_Pcb->Add( new_track ); new_track->m_Start += delta; new_track->m_End += delta; @@ -417,7 +418,8 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) { /* this zone segment must be duplicated */ 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_End += delta; diff --git a/gerbview/deltrack.cpp b/gerbview/deltrack.cpp index edad130d86..df7aa6b317 100644 --- a/gerbview/deltrack.cpp +++ b/gerbview/deltrack.cpp @@ -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( g_TrackSegmentCount > 0 ) + if( g_CurrentTrackList.GetCount() > 0 ) { // modification du trace - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); + delete g_CurrentTrackList.PopBack(); - delete Track; - - g_TrackSegmentCount--; - - if( g_TrackSegmentCount && (g_CurrentTrackSegment->Type() == TYPEVIA) ) + if( g_CurrentTrackList.GetCount() && g_CurrentTrackSegment->Type() == TYPE_VIA ) { - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); - delete Track; - g_TrackSegmentCount--; + delete g_CurrentTrackList.PopBack(); } - if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->SetNext( NULL ); Affiche_Status_Box(); - if( g_TrackSegmentCount == 0 ) + if( g_CurrentTrackList.GetCount() == 0 ) { DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index a295cab2f5..40f01eb678 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -60,7 +60,7 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) DrawStruct = GerberGeneralLocateAndDisplay(); if( DrawStruct == NULL ) break; - if( DrawStruct->Type() == TYPETRACK ) + if( DrawStruct->Type() == TYPE_TRACK ) { Delete_Segment( DC, (TRACK*) DrawStruct ); GetScreen()->SetCurItem( NULL ); diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 86f0d4028a..6f9327449b 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -155,14 +155,14 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, 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->m_Start = track->m_Start; drawitem->m_End = track->m_End; drawitem->m_Width = track->m_Width; - drawitem->SetNext( pcb->m_Drawings ); - pcb->m_Drawings = drawitem; + + pcb->Add( drawitem ); } else { @@ -195,7 +195,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, newtrack->SetLayer( pcb_layer_number ); } - newtrack->Insert( pcb, NULL ); + pcb->Add( newtrack ); } } diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index 5fcc2f922c..903706fa32 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -36,16 +36,11 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) } } - m_Pcb->m_Drawings->DeleteStructList(); - m_Pcb->m_Drawings = NULL; + m_Pcb->m_Drawings.DeleteAll(); - m_Pcb->m_Track->DeleteStructList(); - m_Pcb->m_Track = NULL; - m_Pcb->m_NbSegmTrack = 0; + m_Pcb->m_Track.DeleteAll(); - m_Pcb->m_Zone->DeleteStructList(); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; + m_Pcb->m_Zone.DeleteAll(); for( ; g_UnDeleteStackPtr != 0; ) { @@ -66,12 +61,8 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) m_Pcb->m_Status_Pcb = 0; m_Pcb->m_NbLoclinks = 0; m_Pcb->m_NbLinks = 0; - m_Pcb->m_NbPads = 0; - m_Pcb->m_NbNets = 0; m_Pcb->m_NbNodes = 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 */ SetBaseScreen( ActiveScreen = ScreenPcb ); @@ -88,12 +79,8 @@ void WinEDA_GerberFrame::Erase_Zones( bool query ) if( query && !IsOK( this, _( "Delete zones ?" ) ) ) return; - if( m_Pcb->m_Zone ) - { - m_Pcb->m_Zone->DeleteStructList( ); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; - } + m_Pcb->m_Zone.DeleteAll(); + ScreenPcb->SetModify(); } @@ -116,10 +103,10 @@ void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query ) switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: - case TYPETEXTE: - case TYPECOTATION: - case TYPEMIRE: + case TYPE_DRAWSEGMENT: + case TYPE_TEXTE: + case TYPE_COTATION: + case TYPE_MIRE: if( PtStruct->GetLayer() == layer || layer < 0 ) PtStruct->DeleteStructure(); break; @@ -177,7 +164,7 @@ void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query ) for( ; PtStruct != NULL; PtStruct = PtNext ) { PtNext = PtStruct->Next(); - if( PtStruct->Type() == TYPETEXTE ) + if( PtStruct->Type() == TYPE_TEXTE ) PtStruct->DeleteStructure(); } diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 97541530f0..3290525dc1 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -57,7 +57,7 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc ) while( ( TrackLocate = Locate_Pistes( TrackLocate, layer, typeloc ) ) != NULL ) { Track = TrackLocate; - if( TrackLocate->Type() == TYPEVIA ) + if( TrackLocate->Type() == TYPE_VIA ) break; 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 { pt_texte_pcb->Display_Infos( this ); @@ -79,7 +79,7 @@ BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc ) 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 ) { TrackLocate->Display_Infos( this ); @@ -112,7 +112,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int typeloc ) PtStruct = Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() != TYPEDRAWSEGMENT ) + if( PtStruct->Type() != TYPE_DRAWSEGMENT ) continue; pts = (DRAWSEGMENT*) PtStruct; 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; 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) ) { @@ -289,7 +289,7 @@ TEXTE_PCB* Locate_Texte_Pcb( TEXTE_PCB* pt_txt_pcb, int typeloc ) PtStruct = (EDA_BaseStruct*) pt_txt_pcb; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() != TYPETEXTE ) + if( PtStruct->Type() != TYPE_TEXTE ) continue; pt_txt_pcb = (TEXTE_PCB*) PtStruct; diff --git a/gerbview/makefile.include b/gerbview/makefile.include index 7f69f520d4..2b046cbf50 100644 --- a/gerbview/makefile.include +++ b/gerbview/makefile.include @@ -22,10 +22,11 @@ OBJECTS= \ gerberframe.o\ onrightclick.o\ class_board.o\ + class_board_item.o\ class_drawsegment.o\ class_track.o \ class_drc_item.o \ - class_board_connected_item.o\ + class_board_connected_item.o\ drawframe.o\ drawpanel.o\ set_color.o \ @@ -53,7 +54,7 @@ OBJECTS= \ controle.o\ basepcbframe.o\ export_to_pcbnew.o\ - collectors.o + collectors.o setpage.o: ../share/setpage.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp index 9504f766c4..6054dde47f 100644 --- a/gerbview/onrightclick.cpp +++ b/gerbview/onrightclick.cpp @@ -72,7 +72,7 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu switch( DrawStruct->Type() ) { - case TYPETRACK: + case TYPE_TRACK: // PopMenu->AppendSeparator(); // PopMenu->Append(ID_POPUP_PCB_EDIT_TRACK, _("Edit")); diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index 34b1287bba..0d16a299bc 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -102,6 +102,13 @@ static void fillRoundFlashTRACK( TRACK* aTrack, int Dcode_index, int aLayer, NEGATE( aTrack->m_End.y ); aTrack->SetNet( Dcode_index ); 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_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 ); 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 ) /*****************************************************************/ -/* creation d'un arc: - * si multiquadrant == true arc de 0 a 360 degres - * et rel_center est la coordonn�e du centre relativement au startpoint - * - * si multiquadrant == false arc de 0 � 90 entierement contenu dans le meme quadrant - * et rel_center est la coordonn�e du centre relativement au startpoint, - * mais en VALEUR ABSOLUE et le signe des valeurs x et y de rel_center doit - * etre deduit de cette limite de 90 degres - * - */ +/* + creation d'un arc: + si multiquadrant == true arc de 0 a 360 degres + et rel_center est la coordonn�e du centre relativement au startpoint + + si multiquadrant == false arc de 0 � 90 entierement contenu dans le meme quadrant + et rel_center est la coordonn�e du centre relativement au startpoint, + 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 @@ -291,6 +311,12 @@ static void fillArcTRACK( TRACK* aTrack, int Dcode_index, int aLayer, NEGATE( aTrack->m_End.y ); 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 { m_Exposure = true; - SEGZONE* edge_poly, * last; - edge_poly = new SEGZONE( frame->m_Pcb ); - - last = (SEGZONE*) frame->m_Pcb->m_Zone; - if( last ) - while( last->Next() ) - last = (SEGZONE*) last->Next(); - - edge_poly->Insert( frame->m_Pcb, last ); + SEGZONE* edge_poly = new SEGZONE( frame->m_Pcb ); + frame->m_Pcb->m_Zone.Append( edge_poly ); edge_poly->SetLayer( activeLayer ); 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; NEGATE( edge_poly->m_End.y ); edge_poly->SetNet( m_PolygonFillModeState ); + m_PreviousPos = m_CurrentPos; m_PolygonFillModeState = 1; break; @@ -862,10 +882,10 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, { case GERB_INTERPOL_LINEAR_1X: track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillLineTRACK( track, dcode, activeLayer, m_PreviousPos, m_CurrentPos, - size.x, m_Exposure ^ m_ImageNegative ); + size.x, !(m_LayerNegative ^ m_ImageNegative) ); break; 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_POS: track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillArcTRACK( track, dcode, activeLayer, m_PreviousPos, m_CurrentPos, m_IJPos, 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; 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_CIRCLE: track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillRoundFlashTRACK( track, dcode, activeLayer, m_CurrentPos, - size.x, true ^ m_ImageNegative ); + size.x, !(m_LayerNegative ^ m_ImageNegative) ); break; case APT_OVAL: case APT_RECT: track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillOvalOrRectFlashTRACK( track, dcode, activeLayer, m_CurrentPos, size, aperture == APT_RECT ? S_SPOT_RECT : S_SPOT_OVALE, - true ^ m_ImageNegative ); + !(m_LayerNegative ^ m_ImageNegative) ); break; 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 ); track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillRoundFlashTRACK( track, dcode, activeLayer, m_CurrentPos, 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 ); curPos += midPoint; track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillOvalOrRectFlashTRACK( track, dcode, activeLayer, curPos, size, S_SPOT_RECT, exposure ); @@ -993,7 +1013,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, size.y = msize.y; curPos += mapPt( p->params[3].GetValue( tool ), p->params[4].GetValue( tool ), m_GerbMetric ); track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillOvalOrRectFlashTRACK( track, dcode, activeLayer, curPos, size, S_SPOT_RECT, exposure ); @@ -1012,7 +1032,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, curPos.y += size.y/2; curPos.x += size.x/2; track = new TRACK( frame->m_Pcb ); - track->Insert( frame->m_Pcb, NULL ); + frame->m_Pcb->m_Track.Append( track ); fillOvalOrRectFlashTRACK( track, dcode, activeLayer, curPos, size, S_SPOT_RECT, exposure ); diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index 8c586f2fc9..50262951b3 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -309,16 +309,28 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t case IMAGE_POLARITY: if( strnicmp( text, "NEG", 3 ) == 0 ) + { + D(printf("%s: m_ImageNegative=true\n", __func__);) m_ImageNegative = TRUE; + } else + { + D(printf("%s: m_ImageNegative=false\n", __func__);) m_ImageNegative = FALSE; + } break; case LAYER_POLARITY: if( *text == 'C' ) + { + D(printf("%s: m_LayerNegative=true\n", __func__);) m_LayerNegative = TRUE; + } else + { + D(printf("%s: m_LayerNegative=false\n", __func__);) m_LayerNegative = FALSE; + } break; case INCLUDE_FILE: diff --git a/gerbview/tracepcb.cpp b/gerbview/tracepcb.cpp index 0c7969a35e..99faf65e40 100644 --- a/gerbview/tracepcb.cpp +++ b/gerbview/tracepcb.cpp @@ -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 */ { DISPLAY_OPTIONS save_opt; - int DisplayPolygonsModeImg; + int DisplayPolygonsModeImg; save_opt = DisplayOpt; 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.DisplayDrawItems = FILLED; DisplayOpt.DisplayZones = 1; - DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch; - g_DisplayPolygonsModeSketch = 0; + DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch; + g_DisplayPolygonsModeSketch = 0; m_PrintIsMirrored = aPrintMirrorMode; @@ -57,7 +57,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl m_PrintIsMirrored = false; DisplayOpt = save_opt; - g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg; + g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg; } @@ -80,7 +80,7 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) DrawPanel->DrawBackGround( DC ); - Trace_Gerber( DC, GR_OR, -1 ); + Trace_Gerber( DC, GR_COPY, -1 ); TraceWorkSheet( DC, screen, 0 ); Affiche_Status_Box(); @@ -117,32 +117,35 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay // Draw filled polygons #define NBMAX 20000 - TRACK* track; int nbpoints = 0; int nbpointsmax = NBMAX; int* coord = (int*) malloc( nbpointsmax * sizeof(int) * 2 ); 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 ( (track->ReturnMaskLayer() & printmasklayer) == 0 ) continue; + if( printmasklayer != -1 && !(track->ReturnMaskLayer() & printmasklayer) ) + continue; if( track->GetNet() == 0 ) // StartPoint { if( nbpoints ) // we have found a new polygon: Draw the old polygon { 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, filled, Color, Color ); } + nbpoints = 2; ptcoord = coord; - *ptcoord = track->m_Start.x; ptcoord++; - *ptcoord = track->m_Start.y; ptcoord++; - *ptcoord = track->m_End.x; ptcoord++; - *ptcoord = track->m_End.y; ptcoord++; + + *ptcoord++ = track->m_Start.x; + *ptcoord++ = track->m_Start.y; + + *ptcoord++ = track->m_End.x; + *ptcoord++ = track->m_End.y; } else { @@ -153,13 +156,16 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ptcoord = coord + nbpointsmax; } 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 { 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, filled, Color, Color ); } diff --git a/gerbview/trpiste.cpp b/gerbview/trpiste.cpp index 72104f1096..d0f5b0f9c1 100644 --- a/gerbview/trpiste.cpp +++ b/gerbview/trpiste.cpp @@ -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) */ { - TRACK* Track; 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; if( gerber ) dcode_hightlight = gerber->m_Selected_Tool; - Track = Pcb->m_Track; - for( ; Track != NULL; Track = Track->Next() ) + for( TRACK* track = Pcb->m_Track; track; track = track->Next() ) { - if( printmasklayer != -1 ) - if( (Track->ReturnMaskLayer() & printmasklayer) == 0 ) - continue; + if( !(track->ReturnMaskLayer() & printmasklayer) ) + continue; - if( (dcode_hightlight == Track->GetNet()) - && (Track->GetLayer() == layer) ) - Trace_Segment( panel, DC, Track, draw_mode | GR_SURBRILL ); + if( dcode_hightlight == track->GetNet() && track->GetLayer()==layer ) + Trace_Segment( panel, DC, track, draw_mode | GR_SURBRILL ); 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 ) /***********************************************************************************/ @@ -70,22 +68,30 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo int fillopt; static bool show_err; - color = g_DesignSettings.m_LayerColor[track->GetLayer()]; - if( color & ITEM_NOT_SHOW ) - return; + if( track->m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview + { + 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 ); - 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; + + zoom = panel->GetZoom(); 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; - case S_SPOT_RECT: - case S_RECT: + case S_SPOT_RECT: + case S_RECT: fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; 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; - case S_SPOT_OVALE: + case S_SPOT_OVALE: fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; - case S_SEGMENT: + case S_SEGMENT: if( (l_piste / zoom) < L_MIN_DESSIN ) { 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 ) diff --git a/gerbview/undelete.cpp b/gerbview/undelete.cpp index 05716dcfca..301d8c0384 100644 --- a/gerbview/undelete.cpp +++ b/gerbview/undelete.cpp @@ -34,8 +34,8 @@ void WinEDA_GerberFrame::UnDeleteItem( wxDC* DC ) switch( item->Type() ) { - case TYPEVIA: - case TYPETRACK: + case TYPE_VIA: + case TYPE_TRACK: for( ; item; item = next ) { next = item->Next(); @@ -87,8 +87,8 @@ BOARD_ITEM* SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) switch( PtStruct->Type() ) { - case TYPEVIA: - case TYPETRACK: + case TYPE_VIA: + case TYPE_TRACK: { EDA_BaseStruct* Back = NULL; g_UnDeleteStack[g_UnDeleteStackPtr - 1] = PtStruct; diff --git a/include/base_struct.h b/include/base_struct.h index c7ff88705d..3844d12e31 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -22,27 +22,28 @@ enum KICAD_T { EOT = 0, // search types array terminator (End Of Types) TYPE_NOT_INIT = 0, - TYPEPCB, + TYPE_PCB, // Items in pcb - PCB_EQUIPOT_STRUCT_TYPE, - TYPEMODULE, - TYPEPAD, - TYPEDRAWSEGMENT, - TYPETEXTE, - TYPETEXTEMODULE, - TYPEEDGEMODULE, - TYPETRACK, - TYPEZONE, - TYPEVIA, - TYPEMARKER, - TYPECOTATION, - TYPEMIRE, - TYPESCREEN, - TYPEBLOCK, - TYPEZONE_UNUSED, - TYPEZONE_EDGE_CORNER, - TYPEZONE_CONTAINER, + TYPE_EQUIPOT, + TYPE_MODULE, + TYPE_PAD, + TYPE_DRAWSEGMENT, + TYPE_TEXTE, + TYPE_TEXTE_MODULE, + TYPE_EDGE_MODULE, + TYPE_TRACK, + TYPE_ZONE, + TYPE_VIA, + TYPE_MARKER, + TYPE_COTATION, + TYPE_MIRE, + TYPE_SCREEN, + TYPE_BLOCK, + TYPE_ZONE_UNUSED, + TYPE_ZONE_EDGE_CORNER, + TYPE_ZONE_CONTAINER, + TYPE_BOARD_ITEM_LIST, // Draw Items in schematic DRAW_POLYLINE_STRUCT_TYPE, diff --git a/include/board_item_struct.h b/include/board_item_struct.h index 0f2f8bee84..a18bc0956a 100644 --- a/include/board_item_struct.h +++ b/include/board_item_struct.h @@ -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 #define BOARD_ITEM_STRUCT_H -/** - * 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 - * - */ +#include /* Shapes for segments (graphic segments and tracks) ( .shape member ) */ @@ -51,8 +37,8 @@ protected: public: - BOARD_ITEM( BOARD_ITEM* StructFather, KICAD_T idtype ) : - EDA_BaseStruct( StructFather, idtype ) + BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) : + EDA_BaseStruct( aParent, idtype ) , m_Layer( 0 ) { } @@ -62,6 +48,7 @@ public: EDA_BaseStruct( src.m_Parent, src.Type() ) , m_Layer( src.m_Layer ) { + m_Flags = src.m_Flags; } @@ -130,9 +117,10 @@ public: /** * 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 { protected: @@ -196,7 +190,7 @@ protected: // handle block number in zone connection 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 ); /** @@ -221,5 +215,117 @@ public: void SetZoneSubNet( int aSubNetCode ); }; + +class BOARD_ITEM_LIST : public BOARD_ITEM +{ + typedef boost::ptr_vector 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; + } + + //---------------------------------- + + + /** + * 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 */ diff --git a/include/dlist.h b/include/dlist.h index c17017639d..35b14b0fe6 100644 --- a/include/dlist.h +++ b/include/dlist.h @@ -39,7 +39,7 @@ class DHEAD protected: EDA_BaseStruct* first; ///< first element in list, or NULL if list 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 /** @@ -66,7 +66,10 @@ protected: /** * Function insert * 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 ); @@ -210,9 +213,13 @@ public: 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 ); } //------------------------------------------- diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 4b6257d7ed..05ddd986c1 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -18,21 +18,23 @@ /* 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 BEGIN_ONPAD 0x800 /* flag indiquant un debut de segment sur pad */ -#define END_ONPAD 0x400 /* flag indiquant une fin de segment sur pad */ -#define BUSY 0x0200 /* flag indiquant que la structure a deja - * ete examinee, dans certaines routines */ -#define DELETED 0x0100 /* Bit flag de Status pour structures effacee - * et mises en chaine "DELETED" */ -#define NO_TRACE 0x80 /* l'element ne doit pas etre affiche */ -#define SURBRILL 0x20 /* element en surbrillance */ -#define DRAG 0x10 /* segment en mode drag */ -#define EDIT 0x8 /* element en cours d'edition */ -#define SEGM_FIXE 0x04 /* segment FIXE ( pas d'effacement global ) */ -#define SEGM_AR 0x02 /* segment Auto_Route */ -#define CHAIN 0x01 /* segment marque */ + +#define FLAG1 (1 << 13) /* flag libre pour calculs locaux */ +#define FLAG0 (1 << 12) /* flag libre pour calculs locaux */ +#define BEGIN_ONPAD (1 << 11) /* flag indiquant un debut de segment sur pad */ +#define END_ONPAD (1 << 10) /* flag indiquant une fin de segment sur pad */ +#define BUSY (1 << 9) /* flag indiquant que la structure a deja + * ete examinee, dans certaines routines */ +#define DELETED (1 << 8) /* Bit flag de Status pour structures effacee + * et mises en chaine "DELETED" */ +#define NO_TRACE (1 << 7) /* l'element ne doit pas etre affiche */ + +#define SURBRILL (1 << 5) /* element en surbrillance */ +#define DRAG (1 << 4) /* segment en mode drag */ +#define EDIT (1 << 3) /* element en cours d'edition */ +#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) */ diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 29b8e6b86b..9a0a88c208 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -511,7 +511,7 @@ public: bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end ); void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ); 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 ); // zone handling diff --git a/pcbnew/affiche.cpp b/pcbnew/affiche.cpp index a727054fe7..76f4b1f0a2 100644 --- a/pcbnew/affiche.cpp +++ b/pcbnew/affiche.cpp @@ -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() ) { ii++; - if( Struct->Type() == TYPEVIA ) + if( Struct->Type() == TYPE_VIA ) if( ( (SEGVIA*) Struct )->GetNet() == netcode ) nb_vias++; - if( Struct->Type() == TYPETRACK ) + if( Struct->Type() == TYPE_TRACK ) if( ( (TRACK*) Struct )->GetNet() == netcode ) lengthnet += ( (TRACK*) Struct )->GetLength(); } diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp index 726a10a046..b2f947c223 100644 --- a/pcbnew/attribut.cpp +++ b/pcbnew/attribut.cpp @@ -41,7 +41,7 @@ void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) TRACK* Track; int nb_segm; - if( (track == NULL ) || (track->Type() == TYPEZONE) ) + if( (track == NULL ) || (track->Type() == TYPE_ZONE) ) return; DrawPanel->CursorOff( DC ); // Erase cursor shape diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index b5e90ca76b..5574292f8d 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -458,7 +458,7 @@ int WinEDA_PcbFrame::GenPlaceBoard() switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: DrawSegm = (DRAWSEGMENT*) PtStruct; if( DrawSegm->GetLayer() != EDGE_N ) break; @@ -471,7 +471,7 @@ int WinEDA_PcbFrame::GenPlaceBoard() TraceSegmentPcb( m_Pcb, &TmpSegm, HOLE | CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL ); break; - case TYPETEXTE: + case TYPE_TEXTE: default: 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 */ { - LISTE_PAD* pt_liste_pad; - MODULE* Module; - D_PAD* PtPad; + aPcb->m_Pads.clear(); - if( Pcb->m_Pads ) - MyFree( Pcb->m_Pads ); + aPcb->m_NbNodes = 0; - pt_liste_pad = Pcb->m_Pads = NULL; - Pcb->m_NbPads = Pcb->m_NbNodes = 0; - - /* Calcul du nombre de pads utiles */ - Module = Pcb->m_Modules; - for( ; Module != NULL; Module = Module->Next() ) + // Initialisation du buffer et des variables de travail + for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { - if( Module->m_ModuleStatus & MODULE_to_PLACE ) + if( module->m_ModuleStatus & MODULE_to_PLACE ) 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 */ - if( Pcb->m_NbPads > 0 ) - { - 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); + aPcb->m_Status_Pcb |= LISTE_PAD_OK; + aPcb->m_Status_Pcb &= ~(LISTE_CHEVELU_OK | CHEVELU_LOCAL_OK); adr_lowmem = buf_work; } @@ -1217,7 +1189,7 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly() PtStruct = m_Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() != TYPEDRAWSEGMENT ) + if( PtStruct->Type() != TYPE_DRAWSEGMENT ) continue; succes = TRUE; ptr = (DRAWSEGMENT*) PtStruct; diff --git a/pcbnew/autorout.cpp b/pcbnew/autorout.cpp index 8817fac7b3..bf16b92fed 100644 --- a/pcbnew/autorout.cpp +++ b/pcbnew/autorout.cpp @@ -46,7 +46,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) { switch( GetScreen()->GetCurItem()->Type() ) { - case TYPEPAD: + case TYPE_PAD: Pad = (D_PAD*) GetScreen()->GetCurItem(); autoroute_net_code = Pad->GetNet(); break; @@ -63,7 +63,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) case ROUTE_MODULE: Module = (MODULE*) GetScreen()->GetCurItem(); - if( (Module == NULL) || (Module->Type() != TYPEMODULE) ) + if( (Module == NULL) || (Module->Type() != TYPE_MODULE) ) { DisplayError( this, _( "Module not selected" ) ); return; } @@ -71,7 +71,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode ) case ROUTE_PAD: Pad = (D_PAD*) GetScreen()->GetCurItem(); - if( (Pad == NULL) || (Pad->Type() != TYPEPAD) ) + if( (Pad == NULL) || (Pad->Type() != TYPE_PAD) ) { DisplayError( this, _( "Pad not selected" ) ); return; } diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 0ef9213656..191c4b4ad7 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -295,7 +295,7 @@ void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem ) { aItem->Display_Infos( this ); -#if 1 && defined(DEBUG) +#if 0 && defined(DEBUG) aItem->Show( 0, std::cout ); #endif diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index de5a1d4f82..1ef369b2f0 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -502,7 +502,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -513,7 +513,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) PtStruct->DeleteStructure(); break; - case TYPETEXTE: + case TYPE_TEXTE: if( !Block_Include_PcbTextes ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -524,7 +524,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) PtStruct->DeleteStructure(); break; - case TYPEMIRE: + case TYPE_MIRE: if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -533,7 +533,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) PtStruct->DeleteStructure(); break; - case TYPECOTATION: + case TYPE_COTATION: if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -688,9 +688,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + case TYPE_DRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -699,9 +699,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) RotatePoint( &STRUCT->m_End, centre, 900 ); break; - case TYPETEXTE: - #undef STRUCT - #define STRUCT ( (TEXTE_PCB*) PtStruct ) + case TYPE_TEXTE: + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) PtStruct ) if( !Block_Include_PcbTextes ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -714,9 +714,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) STRUCT->CreateDrawData(); break; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ( (MIREPCB*) PtStruct ) + case TYPE_MIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -725,9 +725,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) RotatePoint( &STRUCT->m_Pos, centre, 900 ); break; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ( (COTATION*) PtStruct ) + case TYPE_COTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -818,7 +818,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) m_Pcb->m_Status_Pcb = 0; INVERT( track->m_Start.y ); INVERT( track->m_End.y ); - if( track->Type() != TYPEVIA ) + if( track->Type() != TYPE_VIA ) { track->SetLayer( ChangeSideNumLayer( track->GetLayer() ) ); } @@ -864,9 +864,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + case TYPE_DRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) PtStruct ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -881,9 +881,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); break; - case TYPETEXTE: - #undef STRUCT - #define STRUCT ( (TEXTE_PCB*) PtStruct ) + case TYPE_TEXTE: + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) PtStruct ) if( !Block_Include_PcbTextes ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -899,9 +899,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) STRUCT->CreateDrawData(); break; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ( (MIREPCB*) PtStruct ) + case TYPE_MIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) PtStruct ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -911,9 +911,9 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) STRUCT->SetLayer( ChangeSideNumLayer( STRUCT->GetLayer() ) ); break; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ( (COTATION*) PtStruct ) + case TYPE_COTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) PtStruct ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) @@ -943,8 +943,6 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) * Function to move items withing the selected block */ { - MODULE* module; - EDA_BaseStruct* PtStruct; int masque_layer; wxPoint oldpos; wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector; @@ -964,13 +962,13 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) if( Block_Include_Modules ) { bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; - module = m_Pcb->m_Modules; 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 ) ) continue; + /* le module est ici bon a etre deplace */ m_Pcb->m_Status_Pcb = 0; module->m_Flags = 0; @@ -985,9 +983,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) /* Deplacement des Segments de piste */ if( Block_Include_Tracks ) { - TRACK* track; - track = m_Pcb->m_Track; - while( track ) + for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) { if( track->HitTest( GetScreen()->BlockLocate ) ) { /* 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_End += MoveVector; } - track = track->Next(); } } /* Deplacement des Segments de Zone */ if( Block_Include_Zones ) { - TRACK* track; - track = (TRACK*) m_Pcb->m_Zone; - while( track ) + for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() ) { if( track->HitTest( GetScreen()->BlockLocate ) ) { /* la piste est ici bonne a etre deplacee */ track->m_Start += MoveVector; track->m_End += MoveVector; } - track = track->Next(); } 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 ) masque_layer &= ~EDGE_LAYER; - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() ) { - switch( PtStruct->Type() ) + switch( item->Type() ) { - case TYPEDRAWSEGMENT: - #undef STRUCT - #define STRUCT ( (DRAWSEGMENT*) PtStruct ) + case TYPE_DRAWSEGMENT: + #undef STRUCT + #define STRUCT ( (DRAWSEGMENT*) item ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; - if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) + if( ! item->HitTest( GetScreen()->BlockLocate ) ) break; /* l'element est ici bon a etre efface */ STRUCT->m_Start += MoveVector; STRUCT->m_End += MoveVector; break; - case TYPETEXTE: - #undef STRUCT - #define STRUCT ( (TEXTE_PCB*) PtStruct ) + case TYPE_TEXTE: + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) item ) if( !Block_Include_PcbTextes ) break; - if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) + if( ! item->HitTest( GetScreen()->BlockLocate ) ) break; /* le texte est ici bon a etre deplace */ /* Redessin du Texte */ STRUCT->m_Pos += MoveVector; break; - case TYPEMIRE: - #undef STRUCT - #define STRUCT ( (MIREPCB*) PtStruct ) + case TYPE_MIRE: + #undef STRUCT + #define STRUCT ( (MIREPCB*) item ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; - if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) + if( ! item->HitTest( GetScreen()->BlockLocate ) ) break; /* l'element est ici bon a etre efface */ STRUCT->m_Pos += MoveVector; break; - case TYPECOTATION: - #undef STRUCT - #define STRUCT ( (COTATION*) PtStruct ) + case TYPE_COTATION: + #undef STRUCT + #define STRUCT ( (COTATION*) item ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) break; - if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) + if( ! item->HitTest( GetScreen()->BlockLocate ) ) break; /* l'element est ici bon a etre efface */ - ( (COTATION*) PtStruct )->Move( wxPoint(MoveVector) ); + ( (COTATION*) item )->Move( wxPoint(MoveVector) ); break; default: @@ -1098,8 +1089,6 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) * routine de duplication des elements du block deja selectionne */ { - MODULE* module; - EDA_BaseStruct* PtStruct; int masque_layer; wxPoint oldpos; wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector; @@ -1120,24 +1109,23 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) { bool Show_Ratsnest_tmp = g_Show_Ratsnest; g_Show_Ratsnest = false; - module = m_Pcb->m_Modules; oldpos = GetScreen()->m_Curseur; - for( ; module != NULL; module = module->Next() ) + for( MODULE* module= m_Pcb->m_Modules; module; module = module->Next() ) { MODULE* new_module; if( ! module->HitTest( GetScreen()->BlockLocate ) ) continue; + /* le module est ici bon a etre deplace */ m_Pcb->m_Status_Pcb = 0; module->m_Flags = 0; new_module = new MODULE( m_Pcb ); new_module->Copy( module ); new_module->m_TimeStamp = GetTimeStamp(); - new_module->SetNext( m_Pcb->m_Modules ); - new_module->SetBack( m_Pcb ); - m_Pcb->m_Modules->SetBack( new_module ); - m_Pcb->m_Modules = new_module; + + m_Pcb->m_Modules.PushFront( new_module ); + GetScreen()->m_Curseur = module->m_Pos + MoveVector; Place_Module( new_module, DC ); } @@ -1158,10 +1146,13 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) { /* la piste est ici bonne a etre deplacee */ m_Pcb->m_Status_Pcb = 0; + 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_End += MoveVector; + new_track->Draw( DrawPanel, DC, GR_OR ); // reaffichage } track = next_track; @@ -1171,19 +1162,19 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) /* Duplicate Zones */ if( Block_Include_Zones ) { - SEGZONE* segzone, * new_segzone; - segzone = m_Pcb->m_Zone; - while( segzone ) + for( SEGZONE* segzone = m_Pcb->m_Zone; segzone; segzone = segzone->Next() ) { if( segzone->HitTest( GetScreen()->BlockLocate ) ) { - new_segzone = (SEGZONE*) segzone->Copy(); - new_segzone->Insert( m_Pcb, NULL ); + SEGZONE* new_segzone = (SEGZONE*) segzone->Copy(); + + m_Pcb->m_Zone.PushFront( new_segzone ); + new_segzone->m_Start += MoveVector; new_segzone->m_End += MoveVector; + new_segzone->Draw( DrawPanel, DC, GR_OR ); } - segzone = segzone->Next(); } unsigned imax = m_Pcb->GetAreaCount(); @@ -1207,94 +1198,88 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) if( !Block_Include_Edges_Items ) masque_layer &= ~EDGE_LAYER; - PtStruct = m_Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() ) { - switch( PtStruct->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: + switch( item->Type() ) { + case TYPE_DRAWSEGMENT: + { #undef STRUCT - #define STRUCT ( (TEXTE_PCB*) PtStruct ) - if( !Block_Include_PcbTextes ) - break; - if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) - 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; - } + #define STRUCT ( (DRAWSEGMENT*) item ) + if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) + break; + if( ! item->HitTest( GetScreen()->BlockLocate ) ) + break; - case TYPEMIRE: - { - #undef 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; - } + /* l'element est ici bon a etre copie */ + DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb ); + new_drawsegment->Copy( STRUCT ); - case TYPECOTATION: - { - #undef STRUCT - #define STRUCT ( (COTATION*) PtStruct ) - if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) - break; - if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) - break; - /* l'element est ici bon a etre copie */ - COTATION* new_cotation = new COTATION( m_Pcb ); - new_cotation->Copy( STRUCT ); - new_cotation->SetNext( m_Pcb->m_Drawings ); - new_cotation->SetBack( m_Pcb ); - m_Pcb->m_Drawings->SetBack( new_cotation ); - m_Pcb->m_Drawings = new_cotation; - new_cotation->Move( MoveVector ); - new_cotation->Draw( DrawPanel, DC, GR_OR ); + m_Pcb->Add( new_drawsegment ); + + new_drawsegment->m_Start += MoveVector; + new_drawsegment->m_End += MoveVector; + new_drawsegment->Draw( DrawPanel, DC, GR_OR ); + } + break; + + case TYPE_TEXTE: + { + #undef STRUCT + #define STRUCT ( (TEXTE_PCB*) item ) + if( !Block_Include_PcbTextes ) + break; + if( ! item->HitTest( GetScreen()->BlockLocate ) ) + break; + /* 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; - } default: break; diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index ec058bf4c4..19dd90b061 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -319,8 +319,8 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, switch( item->Type() ) { - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: item->Draw( panel, DC, g_XorMode, move_offset ); break; @@ -361,8 +361,8 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, switch( item->Type() ) { - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: item->Draw( panel, DC, g_XorMode, move_offset ); break; @@ -389,14 +389,10 @@ void CopyMarkedItems( MODULE* module, wxPoint offset ) /* Copy marked items, at new position = old position + offset */ { - BOARD_ITEM* item; - BOARD_ITEM* NewStruct; - if( module == NULL ) return; - D_PAD* pad = module->m_Pads; - for( ; pad != NULL; pad = pad->Next() ) + for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() ) { if( pad->m_Selected == 0 ) continue; @@ -404,44 +400,38 @@ void CopyMarkedItems( MODULE* module, wxPoint offset ) D_PAD* NewPad = new D_PAD( module ); NewPad->Copy( pad ); NewPad->m_Selected = IS_SELECTED; - NewPad->SetNext( module->m_Pads ); - NewPad->SetBack( module ); - module->m_Pads->SetBack( NewPad ); - module->m_Pads = NewPad; + module->m_Pads.PushBack( NewPad ); } - item = module->m_Drawings; - for( ; item != NULL; item = item->Next() ) + for( BOARD_ITEM* item = module->m_Drawings; item; item->Next() ) { if( item->m_Selected == 0 ) continue; + item->m_Selected = 0; - NewStruct = NULL; switch( item->Type() ) { - case TYPETEXTEMODULE: - NewStruct = new TEXTE_MODULE( module ); - ( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) item ); + case TYPE_TEXTE_MODULE: + TEXTE_MODULE* textm; + textm = new TEXTE_MODULE( module ); + textm->Copy( (TEXTE_MODULE*) item ); + textm->m_Selected = IS_SELECTED; + module->m_Drawings.PushFront( textm ); break; - case TYPEEDGEMODULE: - NewStruct = new EDGE_MODULE( module ); - ( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) item ); + case TYPE_EDGE_MODULE: + EDGE_MODULE* edge; + edge = new EDGE_MODULE( module ); + edge->Copy( (EDGE_MODULE*) item ); + edge->m_Selected = IS_SELECTED; + module->m_Drawings.PushFront( edge ); break; default: DisplayError( NULL, wxT( "Internal Err: CopyMarkedItems: type indefini" ) ); 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 ); @@ -479,14 +469,14 @@ void MoveMarkedItems( MODULE* module, wxPoint offset ) switch( item->Type() ) { - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: ( (TEXTE_MODULE*) item )->GetPosition().x += offset.x; ( (TEXTE_MODULE*) item )->GetPosition().y += offset.y; ( (TEXTE_MODULE*) item )->m_Pos0.x += offset.x; ( (TEXTE_MODULE*) item )->m_Pos0.y += offset.y; break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: ( (EDGE_MODULE*) item )->m_Start.x += offset.x; ( (EDGE_MODULE*) item )->m_Start.y += offset.y; @@ -578,7 +568,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) switch( item->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: SETMIRROR( ( (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 ); @@ -586,7 +576,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) ( (EDGE_MODULE*) item )->m_Angle = -( (EDGE_MODULE*) item )->m_Angle; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x ); ( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x; break; @@ -632,14 +622,14 @@ void RotateMarkedItems( MODULE* module, wxPoint offset ) switch( item->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: ROTATE( ( (EDGE_MODULE*) item )->m_Start ); ( (EDGE_MODULE*) item )->m_Start0 = ( (EDGE_MODULE*) item )->m_Start; ROTATE( ( (EDGE_MODULE*) item )->m_End ); ( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() ); ( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition(); ( (TEXTE_MODULE*) item )->m_Orient += 900; @@ -708,7 +698,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) switch( item->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: pos = ( (EDGE_MODULE*) item )->m_Start; if( Rect.Inside( pos ) ) { @@ -723,7 +713,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) } break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: pos = ( (TEXTE_MODULE*) item )->GetPosition(); if( Rect.Inside( pos ) ) { diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 0f99f4a42b..ab1886fb77 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -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 @@ -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 */ { - 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 marge, via_marge; int masque_layer; @@ -198,47 +192,50 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) ///////////////////////////////////// // 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; im_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 // /////////////////////////////////////////////// - PtStruct = Pcb->m_Modules; - for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { - BOARD_ITEM* PtModStruct = ( (MODULE*) PtStruct )->m_Drawings; - for( ; PtModStruct != NULL; PtModStruct = PtModStruct->Next() ) + for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() ) { - switch( PtModStruct->Type() ) + switch( item->Type() ) { - case TYPEEDGEMODULE: - { - TRACK* TmpSegm = new TRACK( NULL ); - TmpSegm->SetLayer( ( (EDGE_MODULE*) PtModStruct )->GetLayer() ); - if( TmpSegm->GetLayer() == EDGE_N ) - TmpSegm->SetLayer( -1 ); + case TYPE_EDGE_MODULE: + { + EDGE_MODULE* edge = (EDGE_MODULE*) item; - TmpSegm->m_Start = ( (EDGE_MODULE*) PtModStruct )->m_Start; - 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 ); + TRACK* TmpSegm = new TRACK( NULL ); - TraceSegmentPcb( Pcb, TmpSegm, HOLE, marge, WRITE_CELL ); - TraceSegmentPcb( Pcb, TmpSegm, VIA_IMPOSSIBLE, via_marge, - WRITE_OR_CELL ); - delete TmpSegm; + TmpSegm->SetLayer( edge->GetLayer() ); + if( TmpSegm->GetLayer() == EDGE_N ) + TmpSegm->SetLayer( -1 ); + + 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; - } default: break; @@ -249,57 +246,67 @@ void PlaceCells( BOARD* Pcb, int net_code, int flag ) //////////////////////////////////////////// // Placement des contours et segments PCB // //////////////////////////////////////////// - PtStruct = Pcb->m_Drawings; - for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) + for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() ) { - switch( PtStruct->Type() ) + switch( item->Type() ) { - case TYPEDRAWSEGMENT: - { - int type_cell = HOLE; - TRACK* TmpSegm = new TRACK( NULL ); - DrawSegm = (DRAWSEGMENT*) PtStruct; - TmpSegm->SetLayer( DrawSegm->GetLayer() ); - if( DrawSegm->GetLayer() == EDGE_N ) + case TYPE_DRAWSEGMENT: { - TmpSegm->SetLayer( -1 ); - type_cell |= CELL_is_EDGE; + DRAWSEGMENT* DrawSegm; + + 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; - } - case TYPETEXTE: - PtText = (TEXTE_PCB*) PtStruct; + case TYPE_TEXTE: + TEXTE_PCB* PtText; + PtText = (TEXTE_PCB*) item; + if( PtText->GetLength() == 0 ) break; + ux0 = PtText->m_Pos.x; uy0 = PtText->m_Pos.y; dx = PtText->Pitch() * PtText->GetLength(); dy = PtText->m_Size.y + PtText->m_Width; /* Put bounding box (rectangle) on matrix */ - dx /= 2; dy /= 2; /* dx et dy = demi dimensionx X et Y */ - ux1 = ux0 + dx; uy1 = uy0 + dy; - ux0 -= dx; uy0 -= dy; + dx /= 2; + dy /= 2; /* dx et dy = demi dimensionx X et Y */ + + ux1 = ux0 + dx; + uy1 = uy0 + dy; + + ux0 -= dx; + uy0 -= dy; 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), 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, (int) (PtText->m_Orient), 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 */ - pt_segm = Pcb->m_Track; - for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) + for( TRACK* track = aPcb->m_Track; track; track = track->Next() ) { - if( net_code == pt_segm->GetNet() ) + if( net_code == track->GetNet() ) continue; - TraceSegmentPcb( Pcb, pt_segm, HOLE, marge, WRITE_CELL ); - TraceSegmentPcb( Pcb, pt_segm, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); + TraceSegmentPcb( aPcb, track, HOLE, marge, WRITE_CELL ); + TraceSegmentPcb( aPcb, track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); } - /* Put zone filling on matrix */ - pt_segm = (TRACK*) Pcb->m_Zone; - for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) + // Put zone filling on matrix + for( SEGZONE* zone = aPcb->m_Zone; zone; zone = zone->Next() ) { - if( net_code == pt_segm->GetNet() ) + if( net_code == zone->GetNet() ) 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 ); } } diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 4c09b00584..5eb9eb9e43 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -30,30 +30,20 @@ void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) /* Constructor */ 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_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule - m_NbNets = 0; // Nombre de nets (equipotentielles) m_BoardSettings = &g_DesignSettings; - m_NbPads = 0; // nombre total de pads m_NbNodes = 0; // nombre de pads connectes m_NbLinks = 0; // nombre de chevelus (donc aussi nombre // 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_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_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 for( int layer=0; layerDeleteStructList(); - 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() ) { ZONE_CONTAINER* area_to_remove = m_ZoneDescriptorList[0]; Delete( area_to_remove ); } - - MyFree( m_Pads ); - m_Pads = 0; - MyFree( m_Ratsnest ); m_Ratsnest = 0; @@ -226,7 +197,7 @@ void BOARD::UnLink() /* Update back link */ if( Back() ) { - if( Back()->Type() == TYPEPCB ) + if( Back()->Type() == TYPE_PCB ) { Back()->SetNext( Next() ); } @@ -252,47 +223,59 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) switch( aBoardItem->Type() ) { // this one uses a vector - case TYPEMARKER: + case TYPE_MARKER: aBoardItem->SetParent( this ); m_markers.push_back( (MARKER*) aBoardItem ); break; // this one uses a vector - case TYPEZONE_CONTAINER: + case TYPE_ZONE_CONTAINER: aBoardItem->SetParent( this ); m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem ); break; - case TYPETRACK: - case TYPEVIA: + case TYPE_TRACK: + case TYPE_VIA: { TRACK* insertAid = ((TRACK*)aBoardItem)->GetBestInsertPoint( this ); - ((TRACK*)aBoardItem)->Insert( this, insertAid ); + m_Track.Insert( (TRACK*)aBoardItem, insertAid ); } break; - case TYPEZONE: - { // Add item to head of list (starting in m_Zone) - aBoardItem->SetParent( this ); - aBoardItem->SetBack( this ); // item will be the first item: back chain to the board - BOARD_ITEM* next_item = m_Zone; // Remember old the first item - aBoardItem->SetNext( next_item ); // Chain the new one ton the old item - 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 - } + case TYPE_ZONE: + if( aControl & ADD_APPEND ) + m_Zone.PushBack( (SEGZONE*) aBoardItem ); + else + m_Zone.PushFront( (SEGZONE*) aBoardItem ); + aBoardItem->SetParent( this ); break; - case TYPEMODULE: - // this is an insert, not an append which may also be needed. - { - aBoardItem->SetBack( this ); - BOARD_ITEM* next = m_Modules; - aBoardItem->SetNext( next ); - if( next ) - next->SetBack( aBoardItem ); - m_Modules = (MODULE*) aBoardItem; - } + case TYPE_MODULE: + if( aControl & ADD_APPEND ) + m_Modules.PushBack( (MODULE*) aBoardItem ); + else + m_Modules.PushFront( (MODULE*) aBoardItem ); + aBoardItem->SetParent( this ); + break; + + 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; // other types may use linked list @@ -308,7 +291,7 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem ) 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. for( unsigned i=0; iNext() ) - ii++; - - m_NbSegmTrack = ii; - return ii; + return m_Track.GetCount(); } /* Calculate the zone segment count */ int BOARD::GetNumSegmZone() { - TRACK* CurTrack = m_Zone; - int ii = 0; - - for( ; CurTrack != NULL; CurTrack = CurTrack->Next() ) - ii++; - - m_NbSegmZone = ii; - return ii; + return m_Zone.GetCount(); } @@ -435,7 +404,7 @@ bool BOARD::ComputeBoundaryBox() PtStruct = m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() != TYPEDRAWSEGMENT ) + if( PtStruct->Type() != TYPE_DRAWSEGMENT ) continue; ptr = (DRAWSEGMENT*) PtStruct; @@ -560,13 +529,13 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame ) 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 ); int nb_vias = 0; for( BOARD_ITEM* item = m_Track; item; item = item->Next() ) { - if( item->Type() == TYPEVIA ) + if( item->Type() == TYPE_VIA ) nb_vias++; } @@ -579,7 +548,7 @@ void BOARD::Display_Infos( WinEDA_DrawFrame* frame ) txt.Printf( wxT( "%d" ), m_NbLinks ); 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 ); txt.Printf( wxT( "%d" ), m_NbLinks - GetNumNoconnect() ); @@ -608,7 +577,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, stype = *p; switch( stype ) { - case TYPEPCB: + case TYPE_PCB: result = inspector->Inspect( this, testData ); // inspect me // skip over any types handled in the above call. ++p; @@ -621,10 +590,10 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, IterateForward( m_Modules, ... ) call. */ - case TYPEMODULE: - case TYPEPAD: - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_MODULE: + case TYPE_PAD: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: // this calls MODULE::Visit() on each module. result = IterateForward( m_Modules, inspector, testData, p ); // 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 ) { - case TYPEMODULE: - case TYPEPAD: - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_MODULE: + case TYPE_PAD: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: continue; default:; } @@ -643,20 +612,20 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, } break; - case TYPEDRAWSEGMENT: - case TYPETEXTE: - case TYPECOTATION: - case TYPEMIRE: + case TYPE_DRAWSEGMENT: + case TYPE_TEXTE: + case TYPE_COTATION: + case TYPE_MIRE: result = IterateForward( m_Drawings, inspector, testData, p ); // skip over any types handled in the above call. for(;;) { switch( stype = *++p ) { - case TYPEDRAWSEGMENT: - case TYPETEXTE: - case TYPECOTATION: - case TYPEMIRE: + case TYPE_DRAWSEGMENT: + case TYPE_TEXTE: + case TYPE_COTATION: + case TYPE_MIRE: continue; 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. // If not found (and only in this case) an exhaustive (and time consumming) search is made, // but this case is statistically rare. - case TYPEVIA: - case TYPETRACK: + case TYPE_VIA: + case TYPE_TRACK: result = IterateForward( m_Track, inspector, testData, p ); // skip over any types handled in the above call. for(;;) { switch( stype = *++p ) { - case TYPEVIA: - case TYPETRACK: + case TYPE_VIA: + case TYPE_TRACK: continue; default:; } @@ -695,18 +664,18 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, } break; #else - case TYPEVIA: + case TYPE_VIA: result = IterateForward( m_Track, inspector, testData, p ); ++p; break; - case TYPETRACK: + case TYPE_TRACK: result = IterateForward( m_Track, inspector, testData, p ); ++p; break; #endif - case TYPEMARKER: + case TYPE_MARKER: // MARKERS are in the m_markers std::vector for( unsigned i=0; iVisit( inspector, testData, p ); @@ -728,17 +697,17 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, ++p; break; - case PCB_EQUIPOT_STRUCT_TYPE: + case TYPE_EQUIPOT: result = IterateForward( m_Equipots, inspector, testData, p ); ++p; break; - case TYPEZONE: + case TYPE_ZONE: result = IterateForward( m_Zone, inspector, testData, p ); ++p; break; - case TYPEZONE_UNUSED: // Unused type + case TYPE_ZONE_UNUSED: // Unused type break; 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; const wxPoint& refPos = *(const wxPoint*) testData; - if( item->Type() == TYPEPAD ) + if( item->Type() == TYPE_PAD ) { D_PAD* pad = (D_PAD*) item; 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; @@ -823,7 +792,7 @@ BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) PadOrModule inspector( layer ); // 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( &inspector, &refPos, scanTypes ); @@ -900,7 +869,7 @@ MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const } inspector; // 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 BOARD* nonconstMe = (BOARD*) this; @@ -1008,10 +977,10 @@ bool BOARD::Save( FILE* aFile ) const { switch( item->Type() ) { - case TYPETEXTE: - case TYPEDRAWSEGMENT: - case TYPEMIRE: - case TYPECOTATION: + case TYPE_TEXTE: + case TYPE_DRAWSEGMENT: + case TYPE_MIRE: + case TYPE_COTATION: if( !item->Save( aFile ) ) goto out; break; diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 9c38cdd6bd..f1bd6d5a0e 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -5,6 +5,10 @@ #ifndef CLASS_BOARD_H #define CLASS_BOARD_H + +#include "dlist.h" + + class ZONE_CONTAINER; class EDA_BoardDesignSettings; @@ -80,27 +84,27 @@ public: int m_Unused; int m_Status_Pcb; // Flags used in ratsnet calculation and update 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_NbLinks; // Ratsnet count int m_NbLoclinks; // Rastests to shew while creating a track 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 - MODULE* m_Modules; // linked list of MODULEs - EQUIPOT* m_Equipots; // linked list of nets - TRACK* m_Track; // linked list of TRACKs and SEGVIAs - SEGZONE* m_Zone; // linked list of SEGZONEs - D_PAD** m_Pads; // Entry for a sorted pad list (used in ratsnest calculations) - int m_NbPads; // Pad count + DLIST m_Drawings; // linked list of lines & texts + DLIST m_Modules; // linked list of MODULEs + DLIST m_Equipots; // linked list of nets + + DLIST m_Track; // linked list of TRACKs and SEGVIAs + + DLIST m_Zone; // linked list of SEGZONEs + + std::vector m_Pads; // Entry for a sorted pad list (used in ratsnest calculations) + CHEVELU* m_Ratsnest; // Rastnest list CHEVELU* m_LocalRatsnest; // Rastnest list used while moving a footprint ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress - BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame ); + BOARD( EDA_BaseStruct* aParent, WinEDA_BasePcbFrame* frame ); ~BOARD(); /** diff --git a/pcbnew/class_board_connected_item.cpp b/pcbnew/class_board_connected_item.cpp index b1b883f23a..26707e861b 100644 --- a/pcbnew/class_board_connected_item.cpp +++ b/pcbnew/class_board_connected_item.cpp @@ -12,8 +12,8 @@ #include "cvpcb.h" #endif -BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* StructFather, KICAD_T idtype ) : - BOARD_ITEM( StructFather, idtype ) +BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) : + BOARD_ITEM( aParent, idtype ) { m_NetCode = 0; m_Subnet = 0; diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index c92f430ddb..240b518893 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -36,6 +36,8 @@ wxString BOARD_ITEM::ShowShape( Track_Shapes aShape ) } +#if !defined(GERBVIEW) + /********************************************************/ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const /********************************************************/ @@ -53,17 +55,17 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const switch( item->Type() ) { - case PCB_EQUIPOT_STRUCT_TYPE: + case TYPE_EQUIPOT: text << _( "Net" ) << ( (EQUIPOT*) item )->m_Netname << wxT( " " ) << ( (EQUIPOT*) item )->GetNet(); break; - case TYPEMODULE: + case TYPE_MODULE: text << _( "Footprint" ) << wxT( " " ) << ( (MODULE*) item )->GetReference(); text << wxT( " (" ) << aPcb->GetLayerName( item->m_Layer ).Trim() << wxT( ")" ); break; - case TYPEPAD: + case TYPE_PAD: pad = (D_PAD *) this; text << _( "Pad" ) << wxT( " \"" ) << pad->ReturnStringPadName() << wxT( "\" (" ); @@ -77,14 +79,14 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference(); break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: text << _( "Pcb Graphic" ) << wxT(": ") << ShowShape( (Track_Shapes) ((DRAWSEGMENT*)item)->m_Shape ) << wxChar(' ') << _("Length:") << valeur_param( (int) ((DRAWSEGMENT*)item)->GetLength(), temp ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); break; - case TYPETEXTE: + case TYPE_TEXTE: text << _( "Pcb Text" ) << wxT( " " );; if( ( (TEXTE_PCB*) item )->m_Text.Len() < 12 ) 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(); break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: switch( ( (TEXTE_MODULE*) item )->m_Type ) { case TEXT_is_REFERENCE: @@ -113,7 +115,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const } break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: text << _( "Graphic" ) << wxT( " " ); text << ShowShape( (Track_Shapes) ( (EDGE_MODULE*) item )->m_Shape ); 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(); break; - case TYPETRACK: + case TYPE_TRACK: // deleting tracks requires all the information we can get to // disambiguate all the choices under the cursor! 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 ); break; - case TYPEZONE_CONTAINER: + case TYPE_ZONE_CONTAINER: text = _( "Zone Outline" ); { 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(); break; - case TYPEZONE: + case TYPE_ZONE: text = _( "Zone" ); text << wxT( " " ); { @@ -185,7 +187,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); break; - case TYPEVIA: + case TYPE_VIA: { SEGVIA* via = (SEGVIA*) item; text << _( "Via" ) << wxT( " " ) << via->ShowWidth(); @@ -216,23 +218,23 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const } break; - case TYPEMARKER: + case TYPE_MARKER: text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->GetPos().x << wxT(",") << ((MARKER*)item)->GetPos().y << wxT(")"); break; - case TYPECOTATION: + case TYPE_COTATION: text << _( "Dimension" ) << wxT( " \"" ) << ( (COTATION*) item )->GetText() << wxT( "\"" ); break; - case TYPEMIRE: + case TYPE_MIRE: valeur_param( ((MIREPCB*)item)->m_Size, msg ); text << _( "Target" ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim() << wxT( " " ) << _( "size" ) << wxT( " " ) << msg ; break; - case TYPEZONE_UNUSED: + case TYPE_ZONE_UNUSED: text << wxT( "Unused" ); break; @@ -258,60 +260,60 @@ const char** BOARD_ITEM::MenuIcon() const switch( item->Type() ) { - case PCB_EQUIPOT_STRUCT_TYPE: + case TYPE_EQUIPOT: xpm = general_ratsnet_xpm; break; - case TYPEMODULE: + case TYPE_MODULE: xpm = module_xpm; break; - case TYPEPAD: + case TYPE_PAD: xpm = pad_xpm; break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: xpm = add_dashed_line_xpm; break; - case TYPETEXTE: + case TYPE_TEXTE: xpm = add_text_xpm; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: xpm = footprint_text_xpm; break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: xpm = show_mod_edge_xpm; break; - case TYPETRACK: + case TYPE_TRACK: xpm = showtrack_xpm; break; - case TYPEZONE_CONTAINER: - case TYPEZONE: + case TYPE_ZONE_CONTAINER: + case TYPE_ZONE: xpm = add_zone_xpm; break; - case TYPEVIA: + case TYPE_VIA: xpm = pad_sketch_xpm; break; - case TYPEMARKER: + case TYPE_MARKER: xpm = pad_xpm; // @todo: create and use marker xpm break; - case TYPECOTATION: + case TYPE_COTATION: xpm = add_cotation_xpm; break; - case TYPEMIRE: + case TYPE_MIRE: xpm = add_mires_xpm; break; - case TYPEZONE_UNUSED: + case TYPE_ZONE_UNUSED: xpm = 0; // unused break; @@ -323,3 +325,13 @@ const char** BOARD_ITEM::MenuIcon() const return (const char**) xpm; } +#endif // !defined(GERBVIEW) + +void BOARD_ITEM::UnLink() +{ + DLIST* list = (DLIST*) GetList(); + wxASSERT( list ); + if( list ) + list->Remove( this ); +} + diff --git a/pcbnew/class_cotation.cpp b/pcbnew/class_cotation.cpp index 5fab9d1daf..3a1b0d3d56 100644 --- a/pcbnew/class_cotation.cpp +++ b/pcbnew/class_cotation.cpp @@ -11,8 +11,8 @@ #include "wxstruct.h" -COTATION::COTATION( BOARD_ITEM* StructFather ) : - BOARD_ITEM( StructFather, TYPECOTATION ) +COTATION::COTATION( BOARD_ITEM* aParent ) : + BOARD_ITEM( aParent, TYPE_COTATION ) { m_Layer = DRAW_LAYER; 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 */ void COTATION:: SetText( const wxString& NewText ) { diff --git a/pcbnew/class_cotation.h b/pcbnew/class_cotation.h index 825ea25e68..6a1ee023df 100644 --- a/pcbnew/class_cotation.h +++ b/pcbnew/class_cotation.h @@ -25,7 +25,7 @@ public: int FlecheG2_ox, FlecheG2_oy, FlecheG2_fx, FlecheG2_fy; public: - COTATION( BOARD_ITEM* StructFather ); + COTATION( BOARD_ITEM* aParent ); ~COTATION(); COTATION* Next() const { return (COTATION*) Pnext; } @@ -47,9 +47,6 @@ public: */ bool Save( FILE* aFile ) const; - /* supprime du chainage la structure Struct */ - void UnLink(); - /* Modification du texte de la cotation */ void SetText( const wxString& NewText ); wxString GetText( void ); diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 6173a27339..89334aa6e5 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -17,8 +17,8 @@ #include "trigo.h" /* DRAWSEGMENT: constructor */ -DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype ) : - BOARD_ITEM( StructFather, idtype ) +DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) : + BOARD_ITEM( aParent, idtype ) { 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 ) /*******************************************/ diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index ca95d8727e..29931ff2cb 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -17,7 +17,7 @@ public: int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg public: - DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT ); + DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype = TYPE_DRAWSEGMENT ); ~DRAWSEGMENT(); DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; } @@ -57,12 +57,6 @@ public: bool ReadDrawSegmentDescr( FILE* File, int* LineNum ); - /** - * Function UnLink - * remove item from linked list. - */ - void UnLink(); - void Copy( DRAWSEGMENT* source ); diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 7d369580c0..0e65306b5e 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -29,7 +29,7 @@ /******************************************/ EDGE_MODULE::EDGE_MODULE( MODULE* parent ) : - BOARD_ITEM( parent, TYPEEDGEMODULE ) + BOARD_ITEM( parent, TYPE_EDGE_MODULE ) { m_Width = 0; 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() /***********************************/ @@ -148,7 +121,7 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, WinEDA_BasePcbFrame* frame; MODULE* Module = NULL; - if( m_Parent && (m_Parent->Type() == TYPEMODULE) ) + if( m_Parent && (m_Parent->Type() == TYPE_MODULE) ) Module = (MODULE*) m_Parent; color = g_DesignSettings.m_LayerColor[m_Layer]; diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 0705a4a933..0cb687f21b 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -33,11 +33,6 @@ public: EDGE_MODULE* Back() const { return (EDGE_MODULE*) Pback; } -/** - * Function UnLink - * remove item from linked list. - */ - /** * Function GetPosition * returns the position of this object. @@ -48,10 +43,6 @@ public: return m_Start; } - - /* supprime du chainage la structure Struct */ - void UnLink(); - void Copy( EDGE_MODULE* source ); // copy structure /** diff --git a/pcbnew/class_equipot.cpp b/pcbnew/class_equipot.cpp index 3a22060d85..4866e91d23 100644 --- a/pcbnew/class_equipot.cpp +++ b/pcbnew/class_equipot.cpp @@ -22,8 +22,8 @@ /*********************************************************/ /* Constructeur de la classe EQUIPOT */ -EQUIPOT::EQUIPOT( BOARD_ITEM* StructFather ) : - BOARD_ITEM( StructFather, PCB_EQUIPOT_STRUCT_TYPE ) +EQUIPOT::EQUIPOT( BOARD_ITEM* aParent ) : + BOARD_ITEM( aParent, TYPE_EQUIPOT ) { SetNet( 0 ); m_NbNodes = m_NbLink = m_NbNoconn = 0; @@ -51,31 +51,6 @@ wxPoint& EQUIPOT::GetPosition() 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 ) /*********************************************************/ diff --git a/pcbnew/class_equipot.h b/pcbnew/class_equipot.h index 20f79e3a6d..1b84250256 100644 --- a/pcbnew/class_equipot.h +++ b/pcbnew/class_equipot.h @@ -25,7 +25,7 @@ public: CHEVELU* m_RatsnestStart; // pointeur sur debut 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* Next() const { return (EQUIPOT*) Pnext; } @@ -40,10 +40,6 @@ public: */ wxPoint& GetPosition(); - - /* Effacement memoire de la structure */ - void UnLink(); - /* Readind and writing data on files */ int ReadEquipotDescr( FILE* File, int* LineNum ); diff --git a/pcbnew/class_marker.cpp b/pcbnew/class_marker.cpp index 7f69494571..375ed1192e 100644 --- a/pcbnew/class_marker.cpp +++ b/pcbnew/class_marker.cpp @@ -48,8 +48,8 @@ void MARKER::init() m_Size.y = Default_MarkerBitmap[1]; } -MARKER::MARKER( BOARD_ITEM* StructFather ) : - BOARD_ITEM( StructFather, TYPEMARKER ), +MARKER::MARKER( BOARD_ITEM* aParent ) : + BOARD_ITEM( aParent, TYPE_MARKER ), m_drc() { init(); @@ -59,7 +59,7 @@ MARKER::MARKER( BOARD_ITEM* StructFather ) : MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, const wxString& aText, const wxPoint& aPos, 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(); @@ -70,7 +70,7 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, 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(); diff --git a/pcbnew/class_marker.h b/pcbnew/class_marker.h index 22eee8bbb4..990a48b7e4 100644 --- a/pcbnew/class_marker.h +++ b/pcbnew/class_marker.h @@ -23,7 +23,7 @@ protected: public: - MARKER( BOARD_ITEM* StructFather ); + MARKER( BOARD_ITEM* aParent ); /** * Constructor diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index cd187fa692..b481f0cff8 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -9,8 +9,8 @@ #include "pcbnew.h" -MIREPCB::MIREPCB( BOARD_ITEM* StructFather ) : - BOARD_ITEM( StructFather, TYPEMIRE ) +MIREPCB::MIREPCB( BOARD_ITEM* aParent ) : + BOARD_ITEM( aParent, TYPE_MIRE ) { m_Shape = 0; 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 ) /**********************************/ diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index 948b4b983d..1cbaa440c7 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -16,7 +16,7 @@ public: int m_Size; public: - MIREPCB( BOARD_ITEM* StructFather ); + MIREPCB( BOARD_ITEM* aParent ); ~MIREPCB(); MIREPCB* Next() const { return (MIREPCB*) Pnext; } @@ -38,9 +38,6 @@ public: bool ReadMirePcbDescr( FILE* File, int* LineNum ); - /* supprime du chainage la structure Struct */ - void UnLink(); - void Copy( MIREPCB* source ); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& offset = ZeroOffset ); diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index ae7a18ec7e..53aee0069b 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -55,10 +55,8 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset /* Class MODULE : description d'un composant pcb */ /*************************************************/ MODULE::MODULE( BOARD* parent ) : - BOARD_ITEM( parent, TYPEMODULE ) + BOARD_ITEM( parent, TYPE_MODULE ) { - m_Pads = NULL; - m_Drawings = NULL; m_3D_Drawings = NULL; m_Attributs = MOD_DEFAULT; m_Layer = CMP_N; @@ -92,31 +90,6 @@ MODULE::~MODULE() next = item->Next(); 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 ) /*********************************/ { - D_PAD* lastpad; - m_Pos = Module->m_Pos; m_Layer = Module->m_Layer; m_LibRef = Module->m_LibRef; @@ -144,65 +115,37 @@ void MODULE::Copy( MODULE* Module ) m_Value->Copy( Module->m_Value ); /* Copie des structures auxiliaires: Pads */ - lastpad = NULL; - for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() ) { D_PAD* newpad = new D_PAD( this ); newpad->Copy( pad ); - if( m_Pads == NULL ) - { - newpad->SetBack( this ); - m_Pads = newpad; - } - else - { - newpad->SetBack( lastpad ); - lastpad->SetNext( newpad ); - } - lastpad = newpad; + m_Pads.PushBack( newpad ); } /* Copy des structures auxiliaires: Drawings */ - BOARD_ITEM* NewStruct, * LastStruct = NULL; - - BOARD_ITEM* OldStruct = Module->m_Drawings; - for( ; OldStruct; OldStruct = OldStruct->Next() ) + for( BOARD_ITEM* item = Module->m_Drawings; item; item = item->Next() ) { - NewStruct = NULL; - - switch( OldStruct->Type() ) + switch( item->Type() ) { - case TYPETEXTEMODULE: - NewStruct = new TEXTE_MODULE( this ); - ( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) OldStruct ); + case TYPE_TEXTE_MODULE: + TEXTE_MODULE* textm; + textm = new TEXTE_MODULE( this ); + textm->Copy( (TEXTE_MODULE*) item ); + m_Drawings.PushBack( textm ); break; - case TYPEEDGEMODULE: - NewStruct = new EDGE_MODULE( this ); - ( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) OldStruct ); + case TYPE_EDGE_MODULE: + EDGE_MODULE* edge; + edge = new EDGE_MODULE( this ); + edge->Copy( (EDGE_MODULE*) item ); + m_Drawings.PushBack( edge ); break; default: DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) ); 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 */ @@ -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, int draw_mode, const wxPoint& offset ) @@ -301,8 +211,8 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, switch( item->Type() ) { - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: item->Draw( panel, DC, draw_mode, offset ); break; @@ -330,7 +240,7 @@ void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC, { switch( item->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: item->Draw( panel, DC, draw_mode, offset ); break; @@ -412,8 +322,8 @@ bool MODULE::Save( FILE* aFile ) const { switch( item->Type() ) { - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: if( !item->Save( aFile ) ) goto out; break; @@ -567,10 +477,6 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) * 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; int itmp1, itmp2; @@ -582,23 +488,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) break; if( Line[1] == 'P' ) { - ptpad = new D_PAD( this ); - ptpad->ReadDescr( File, LineNum ); - RotatePoint( &ptpad->m_Pos.x, &ptpad->m_Pos.y, m_Orient ); - ptpad->m_Pos.x += m_Pos.x; - ptpad->m_Pos.y += m_Pos.y; + D_PAD* pad = new D_PAD( this ); + pad->ReadDescr( File, LineNum ); + RotatePoint( &pad->m_Pos.x, &pad->m_Pos.y, m_Orient ); + pad->m_Pos.x += m_Pos.x; + pad->m_Pos.y += m_Pos.y; - if( LastPad == NULL ) - { - ptpad->SetBack( this ); - m_Pads = ptpad; - } - else - { - ptpad->SetBack( LastPad ); - LastPad->SetNext( ptpad ); - } - LastPad = ptpad; + m_Pads.PushBack( pad ); continue; } if( Line[1] == 'S' ) @@ -673,47 +569,26 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) break; case 'T': /* Read a footprint text description (ref, value, or drawing */ + TEXTE_MODULE* textm; sscanf( Line + 1, "%d", &itmp1 ); if( itmp1 == TEXT_is_REFERENCE ) - DrawText = m_Reference; + textm = m_Reference; else if( itmp1 == TEXT_is_VALUE ) - DrawText = m_Value; + textm = m_Value; else /* text is a drawing */ { - DrawText = new TEXTE_MODULE( this ); - if( LastModStruct == NULL ) - { - DrawText->SetBack( this ); - m_Drawings = DrawText; - } - else - { - DrawText->SetBack( LastModStruct ); - LastModStruct->SetNext( DrawText ); - } - LastModStruct = DrawText; + textm = new TEXTE_MODULE( this ); + m_Drawings.PushBack( textm ); } - - DrawText->ReadDescr( Line, File, LineNum ); + textm->ReadDescr( Line, File, LineNum ); break; case 'D': /* lecture du contour */ - DrawSegm = new EDGE_MODULE( this ); - - if( LastModStruct == NULL ) - { - DrawSegm->SetBack( this ); - m_Drawings = DrawSegm; - } - else - { - DrawSegm->SetBack( LastModStruct ); - LastModStruct->SetNext( DrawSegm ); - } - - LastModStruct = DrawSegm; - DrawSegm->ReadDescr( Line, File, LineNum ); - DrawSegm->SetDrawCoord(); + EDGE_MODULE* edge; + edge = new EDGE_MODULE( this ); + m_Drawings.PushBack( edge ); + edge->ReadDescr( Line, File, LineNum ); + edge->SetDrawCoord(); break; case 'C': /* Lecture de la doc */ @@ -769,14 +644,14 @@ void MODULE::SetPosition( const wxPoint& newpos ) { switch( PtStruct->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: { EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct; pt_edgmod->SetDrawCoord(); break; } - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: { TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct; pt_texte->m_Pos.x += deltaX; @@ -829,12 +704,12 @@ void MODULE::SetOrientation( int newangle ) EDA_BaseStruct* PtStruct = m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() == TYPEEDGEMODULE ) + if( PtStruct->Type() == TYPE_EDGE_MODULE ) { EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct; pt_edgmod->SetDrawCoord(); } - if( PtStruct->Type() == TYPETEXTEMODULE ) + if( PtStruct->Type() == TYPE_TEXTE_MODULE ) { /* deplacement des inscriptions : */ TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct; @@ -871,10 +746,10 @@ void MODULE::Set_Rectangle_Encadrement() m_BoundaryBox.m_Pos.y = -500; ymax = 500; /* 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() ) { - if( pt_edge_mod->Type() != TYPEEDGEMODULE ) + if( pt_edge_mod->Type() != TYPE_EDGE_MODULE ) continue; width = pt_edge_mod->m_Width / 2; @@ -944,9 +819,9 @@ void MODULE::SetRectangleExinscrit() m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y; /* 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; width = edge->m_Width / 2; @@ -1020,9 +895,9 @@ EDA_Rect MODULE::GetBoundingBox() text_area = m_Value->GetBoundingBox(); 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; text_area = ((TEXTE_MODULE*)edge)->GetBoundingBox(); area.Merge( text_area ); @@ -1201,17 +1076,17 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, switch( stype ) { - case TYPEMODULE: + case TYPE_MODULE: result = inspector->Inspect( this, testData ); // inspect me ++p; break; - case TYPEPAD: + case TYPE_PAD: result = IterateForward( m_Pads, inspector, testData, p ); ++p; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: result = inspector->Inspect( m_Reference, testData ); if( result == SEARCH_QUIT ) break; @@ -1222,7 +1097,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, // m_Drawings can hold TYPETEXTMODULE also, so fall thru - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: result = IterateForward( m_Drawings, inspector, testData, p ); // 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 ) { - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: continue; default: diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 3577b66af4..44c1eb5af7 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -38,14 +38,14 @@ enum Mod_Attribut /* Attributs used for modules */ class MODULE : public BOARD_ITEM { public: - wxPoint m_Pos; // Real coord on board - D_PAD* m_Pads; /* Pad list (linked list) */ - BOARD_ITEM* m_Drawings; /* Graphic items list (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_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_AlternateReference; /* Used when m_Reference cannot be used to + wxPoint m_Pos; // Real coord on board + DLIST m_Pads; /* Pad list (linked list) */ + DLIST m_Drawings; /* Graphic items list (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_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_AlternateReference; /* Used when m_Reference cannot be used to * identify the footprint ( after a full reannotation of the schematic */ int m_Attributs; /* Flags(ORed bits) ( see Mod_Attribut ) */ @@ -124,9 +124,6 @@ public: void SetPosition( const wxPoint& newpos ); void SetOrientation( int newangle ); - /* Remove this from the linked list */ - void UnLink(); - /** * Function IsLocked diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index ae80183286..b6186584c3 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -26,7 +26,7 @@ /* 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_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; - if( m_Parent && (m_Parent->Type() == TYPEMODULE) ) + if( m_Parent && (m_Parent->Type() == TYPE_MODULE) ) { 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 ) /*******************************************************************************************/ diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 1e2e0a2840..83eff82da4 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -89,10 +89,6 @@ public: m_Pos = aPos; } - - /* remove from linked list */ - void UnLink(); - /* Reading and writing data on files */ int ReadDescr( FILE* File, int* LineNum = NULL ); diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 8abea9fc97..d6a3a16aba 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -16,7 +16,7 @@ /*******************/ TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) : - BOARD_ITEM( parent, TYPETEXTE ), + BOARD_ITEM( parent, TYPE_TEXTE ), 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 ) /****************************************************************/ @@ -175,7 +151,7 @@ void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame ) BOARD_ITEM* parent = (BOARD_ITEM*) m_Parent; wxASSERT( parent ); - if( parent->Type() == TYPECOTATION ) + if( parent->Type() == TYPE_COTATION ) board = (BOARD*) parent->GetParent(); else board = (BOARD*) parent; @@ -183,7 +159,7 @@ void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame ) 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 ); else Affiche_1_Parametre( frame, 1, _( "PCB Text" ), m_Text, DARKGREEN ); diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index f788da230e..2cf92f9622 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -13,7 +13,6 @@ public: TEXTE_PCB( TEXTE_PCB* textepcb ); ~TEXTE_PCB(); - /** * Function GetPosition * returns the position of this object. @@ -25,10 +24,6 @@ public: return m_Pos; // within EDA_TextStruct } - - /* supprime du chainage la structure Struct */ - void UnLink(); - /* duplicate structure */ void Copy( TEXTE_PCB* source ); diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 69b78c28ff..a3a476c6fd 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -28,7 +28,7 @@ /* Constructeur de TEXTE_MODULE */ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : - BOARD_ITEM( parent, TYPETEXTEMODULE ) + BOARD_ITEM( parent, TYPE_TEXTE_MODULE ) { MODULE* Module = (MODULE*) m_Parent; @@ -43,7 +43,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : m_Unused = 0; SetLayer( SILKSCREEN_N_CMP ); - if( Module && (Module->Type() == TYPEMODULE) ) + if( Module && (Module->Type() == TYPE_MODULE) ) { 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() /******************************************/ diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 87a9fc7413..6df677a1b5 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -47,10 +47,6 @@ public: return m_Pos; } - - /* supprime du chainage la structure Struct */ - void UnLink(); - void Copy( TEXTE_MODULE* source ); // copy structure /* Gestion du texte */ diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index bb6f802d94..971460385b 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -8,7 +8,6 @@ #include "common.h" #include "pcbnew.h" - #ifdef CVPCB #include "cvpcb.h" #endif @@ -39,9 +38,9 @@ void DbgDisplayTrackInfos( TRACK* track ) wxMessageBox( msg ); } - #endif + /** * Function ShowClearance * 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 ) { - // maybe return true for (for tracks and vias, not for zone segments - return ( DisplayOpt.DisplayTrackIsol && ( aTrack->GetLayer() <= LAST_COPPER_LAYER ) - && ( aTrack->Type() == TYPETRACK || aTrack->Type() == TYPEVIA) ); + // maybe return true for tracks and vias, not for zone segments + return !(aTrack->m_Flags & DRAW_ERASED) + && DisplayOpt.DisplayTrackIsol + && aTrack->GetLayer() <= LAST_COPPER_LAYER + && ( aTrack->Type() == TYPE_TRACK || aTrack->Type() == TYPE_VIA ); } /**********************************************************/ -TRACK::TRACK( BOARD_ITEM* StructFather, KICAD_T idtype ) : - BOARD_CONNECTED_ITEM( StructFather, idtype ) +TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) : + BOARD_CONNECTED_ITEM( aParent, idtype ) /**********************************************************/ { m_Width = 0; @@ -81,14 +82,14 @@ wxString TRACK::ShowWidth() } -SEGZONE::SEGZONE( BOARD_ITEM* StructFather ) : - TRACK( StructFather, TYPEZONE ) +SEGZONE::SEGZONE( BOARD_ITEM* aParent ) : + TRACK( aParent, TYPE_ZONE ) { } -SEGVIA::SEGVIA( BOARD_ITEM* StructFather ) : - TRACK( StructFather, TYPEVIA ) +SEGVIA::SEGVIA( BOARD_ITEM* aParent ) : + TRACK( aParent, TYPE_VIA ) { } @@ -99,6 +100,7 @@ TRACK::TRACK( const TRACK& Source ) : { m_Shape = Source.m_Shape; SetNet( Source.GetNet() ); + m_Flags = Source.m_Flags; m_TimeStamp = Source.m_TimeStamp; SetStatus( Source.ReturnStatus() ); @@ -119,13 +121,13 @@ TRACK::TRACK( const TRACK& Source ) : */ TRACK* TRACK::Copy() const { - if( Type() == TYPETRACK ) + if( Type() == TYPE_TRACK ) return new TRACK( *this ); - if( Type() == TYPEVIA ) + if( Type() == TYPE_VIA ) return new SEGVIA( (const SEGVIA &) * this ); - if( Type() == TYPEZONE ) + if( Type() == TYPE_ZONE ) return new SEGZONE( (const SEGZONE &) * this ); return NULL; // should never happen @@ -139,7 +141,7 @@ TRACK* TRACK::Copy() const */ int TRACK::GetDrillValue() const { - if ( Type() != TYPEVIA ) + if ( Type() != TYPE_VIA ) return 0; if ( m_Drill >= 0 ) @@ -158,7 +160,7 @@ bool TRACK::IsNull() // return TRUE if segment length = 0 { - if( ( Type() != TYPEVIA ) && ( m_Start == m_End ) ) + if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) ) return TRUE; else return FALSE; @@ -228,7 +230,7 @@ EDA_Rect TRACK::GetBoundingBox() int ymin; int xmin; - if( Type() == TYPEVIA ) + if( Type() == TYPE_VIA ) { // Because vias are sometimes drawn larger than their m_Width would // 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 */ { - if( Type() == TYPEVIA ) + if( Type() == TYPE_VIA ) { 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 ) /***********************************************/ @@ -502,29 +416,20 @@ TRACK* TRACK::GetBestInsertPoint( BOARD* Pcb ) * @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; else track = Pcb->m_Track; - /* Traitement du debut de liste */ - 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 ) + for( ; track; track = track->Next() ) { - if( NextTrack->GetNet() > this->GetNet() ) - break; - - track = NextTrack; + if( GetNet() <= track->GetNet() ) + return track; } - return track; + return NULL; } @@ -606,7 +511,7 @@ bool TRACK::Save( FILE* aFile ) const { int type = 0; - if( Type() == TYPEVIA ) + if( Type() == TYPE_VIA ) type = 1; if( GetState( DELETED ) ) @@ -634,38 +539,47 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin int rayon; int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - if( Type() == TYPEZONE && !DisplayOpt.DisplayZones ) + if( Type() == TYPE_ZONE && !DisplayOpt.DisplayZones ) 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 ); - 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(); l_piste = m_Width >> 1; @@ -705,7 +619,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin return; } - if( (!DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) ) + if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) ) { GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, 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 curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; - if( Type() == TYPEZONE && !DisplayOpt.DisplayZones ) - return; - GRSetDrawMode( DC, draw_mode ); color = g_DesignSettings.m_ViaColor[m_Shape]; @@ -874,15 +785,15 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) switch( Type() ) { - case TYPEVIA: + case TYPE_VIA: msg = g_ViaType_Name[Shape()]; break; - case TYPETRACK: + case TYPE_TRACK: msg = _( "Track" ); break; - case TYPEZONE: + case TYPE_ZONE: msg = _( "Zone" ); break; default: @@ -890,15 +801,17 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) } text_pos = 1; + 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 - || Type() == TYPEZONE - || Type() == TYPEVIA ) + if( Type() == TYPE_TRACK + || Type() == TYPE_ZONE + || Type() == TYPE_VIA ) { + /* Display NetName pour les segments de piste type cuivre */ + EQUIPOT* equipot = board->FindNet( GetNet() ); if( equipot ) @@ -907,11 +820,13 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) msg = wxT( "" ); Affiche_1_Parametre( frame, text_pos, _( "NetName" ), msg, RED ); + text_pos += 20; /* Display net code : (usefull in test or debug) */ msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() ); - text_pos += 18; + Affiche_1_Parametre( frame, text_pos, _( "NetCode" ), msg, RED ); + text_pos += 8; } else { @@ -920,9 +835,19 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED ); else 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( ". . " ); if( GetState( SEGM_FIXE ) ) msg[0] = 'F'; @@ -930,11 +855,11 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) if( GetState( SEGM_AR ) ) msg[2] = 'A'; - text_pos = 42; Affiche_1_Parametre( frame, text_pos, _( "Stat" ), msg, MAGENTA ); + text_pos += 6; /* Display layer or layer pair) */ - if( Type() == TYPEVIA ) + if( Type() == TYPE_VIA ) { SEGVIA* Via = (SEGVIA*) this; int top_layer, bottom_layer; @@ -946,22 +871,21 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) else msg = board->GetLayerName( m_Layer ); - text_pos += 5; Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN ); + text_pos += 15; /* Display width */ 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 ); + text_pos += 8; int drill_value = GetDrillValue(); valeur_param( (unsigned) drill_value, msg ); - text_pos += 8; wxString title = _( "Drill" ); 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_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 <= (double) radius * radius; @@ -1037,8 +961,11 @@ void TRACK::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << // " shape=\"" << m_Shape << '"' << + " addr=\"" << std::hex << this << std::dec << '"' << " layer=\"" << m_Layer << '"' << " width=\"" << m_Width << '"' << + " flags=\"" << m_Flags << '"' << + " status=\"" << GetState(-1) << '"' << // " drill=\"" << GetDrillValue() << '"' << " 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 diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 09ff92fce0..d63b43eeb5 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -18,6 +18,13 @@ 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 only. +private: + void SetNext( EDA_BaseStruct* aNext ) { Pnext = aNext; } + void SetBack( EDA_BaseStruct* aBack ) { Pback = aBack; } + + public: int m_Width; // 0 = line, > 0 = tracks, bus ... wxPoint m_Start; // Line start point @@ -38,7 +45,7 @@ protected: TRACK( const TRACK& track ); // protected so Copy() is used instead. public: - TRACK( BOARD_ITEM* StructFather, KICAD_T idtype = TYPETRACK ); + TRACK( BOARD_ITEM* aParent, KICAD_T idtype = TYPE_TRACK ); /** * Function Copy @@ -66,10 +73,6 @@ public: EDA_Rect GetBoundingBox(); - /* Remove "this" from the linked list */ - void UnLink(); - - /** * Function Save * writes the data structures for this object out to a FILE in "*.brd" format. @@ -78,19 +81,6 @@ public: */ 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 * searches the "best" insertion point within the track linked list. @@ -167,8 +157,11 @@ public: 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 @@ -242,6 +235,14 @@ public: */ 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 }; @@ -249,7 +250,7 @@ public: class SEGZONE : public TRACK { public: - SEGZONE( BOARD_ITEM* StructFather ); + SEGZONE( BOARD_ITEM* aParent ); /** * Function GetClass @@ -269,7 +270,7 @@ public: class SEGVIA : public TRACK { public: - SEGVIA( BOARD_ITEM* StructFather ); + SEGVIA( BOARD_ITEM* aParent ); SEGVIA( const SEGVIA& source ) : TRACK( source ) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index fdd789f347..c99bd02a0c 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -19,7 +19,7 @@ /************************/ 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 diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 46b4034aec..a31259b0bf 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -59,9 +59,6 @@ public: */ wxPoint& GetPosition(); - void UnLink( void ) - { - }; /** * Function copy diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 801e5b20b8..89d46d172a 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -22,7 +22,7 @@ /* Class SCREEN: classe de gestion d'un affichage */ /***************************************************/ /* 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 static const int zoom_list[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0 }; diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index a3419e3825..a05b611f56 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -180,15 +180,13 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC ) frame->Affiche_Message( _( "Delete unconnected tracks:" ) ); frame->DrawPanel->m_AbortRequest = FALSE; - // correct via m_End defects and count number of segments - frame->m_Pcb->m_NbSegmTrack = 0; + // correct via m_End defects ii = 0; for( segment = frame->m_Pcb->m_Track; segment; segment = next ) { - frame->m_Pcb->m_NbSegmTrack++; next = segment->Next(); - if( segment->Type() == TYPEVIA ) + if( segment->Type() == TYPE_VIA ) { if( segment->m_Start != segment->m_End ) { @@ -213,13 +211,13 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC ) next = segment->Next(); // display activity - percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount(); if( percent != oldpercent ) { oldpercent = percent; 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 ); 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( segment->Type() != TYPEVIA ) + if( segment->Type() != TYPE_VIA ) { 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; // 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( other && other->Type() == TYPEVIA ) + if( other && other->Type() == TYPE_VIA ) { // search for another segment following the via @@ -318,7 +316,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC ) NULL, END ); 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() ); else @@ -334,9 +332,10 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC ) else // segment, via or zone connected to this end { segment->end = other; + // 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( other && other->Type() == TYPEVIA ) + if( other && other->Type() == TYPE_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++ ) { /* Display activity */ - percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount(); if( percent != oldpercent ) { frame->DisplayActivity( percent, wxT( "Id segm: " ) ); 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 ); msg.Printf( wxT( "%d" ), ii ); @@ -519,13 +518,13 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) next = segment->Next(); ii++; - percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount(); if( percent != oldpercent ) { frame->DisplayActivity( percent, _( "Merge: " ) ); 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 ); msg.Printf( wxT( "%d" ), ii ); @@ -535,7 +534,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) return -1; } - if( segment->Type() != TYPETRACK ) + if( segment->Type() != TYPE_TRACK ) continue; flag = no_inc = 0; @@ -552,7 +551,7 @@ static int clean_segments( WinEDA_PcbFrame* frame, wxDC* DC ) break; // it cannot be a via - if( segStart->Type() != TYPETRACK ) + if( segStart->Type() != TYPE_TRACK ) break; /* 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 ) break; - if( segEnd->Type() != TYPETRACK ) + if( segEnd->Type() != TYPE_TRACK ) break; /* We must have only one segment connected */ @@ -764,16 +763,16 @@ int Netliste_Controle_piste( WinEDA_PcbFrame* frame, wxDC* DC, int affiche ) { // display activity ii++; - percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount(); if( percent != oldpercent ) { frame->DisplayActivity( percent, wxT( "Drc: " ) ); 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 ); - 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 ); 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" 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. 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" 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(); } @@ -885,13 +884,13 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC ) { // display activity ii++; - percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount(); if( percent != oldpercent ) { frame->DisplayActivity( percent, wxT( "Tracks: " ) ); 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 ); msg.Printf( wxT( "%d" ), ii ); @@ -915,7 +914,7 @@ static void Gen_Raccord_Track( WinEDA_PcbFrame* frame, wxDC* DC ) if( other == segment ) continue; - if( other->Type() == TYPEVIA ) + if( other->Type() == TYPE_VIA ) continue; 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 ); 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. newTrack = other->Copy(); - newTrack->Insert( frame->m_Pcb, other ); + + frame->m_Pcb->m_Track.Insert( newTrack, other->Next() ); other->m_End = 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 ) continue; - if( other->Type() == TYPEVIA ) + if( other->Type() == TYPE_VIA ) continue; 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 ); 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. newTrack = other->Copy(); - newTrack->Insert( frame->m_Pcb, other ); + frame->m_Pcb->m_Track.Insert( newTrack, other->Next() ); other->m_End = segment->m_End; newTrack->m_Start = segment->m_End; @@ -1023,7 +1019,7 @@ static void ConnectDanglingEndToVia( BOARD* pcb ) { SEGVIA* via; - if( track->Type()!=TYPEVIA || (via = (SEGVIA*)track)->GetNet()!=0 ) + if( track->Type()!=TYPE_VIA || (via = (SEGVIA*)track)->GetNet()!=0 ) continue; 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 ) { TRACK* newTrack = other->Copy(); - newTrack->Insert( pcb, other ); + + pcb->m_Track.Insert( newTrack, other->Next() ); 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 ) { TRACK* newTrack = other->Copy(); - newTrack->Insert( pcb, other ); + + pcb->m_Track.Insert( newTrack, other->Next() ); newTrack->m_Start = via->GetPosition(); @@ -1111,13 +1109,13 @@ void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC ) D_PAD* pad; ii++; - percent = (100 * ii) / frame->m_Pcb->m_NbSegmTrack; + percent = (100 * ii) / frame->m_Pcb->m_Track.GetCount(); if( percent != oldpercent ) { frame->DisplayActivity( percent, _( "Pads: " ) ); 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 ); msg.Printf( wxT( "%d" ), ii ); @@ -1137,7 +1135,8 @@ void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC ) NULL, START ) == NULL ) { 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; @@ -1162,7 +1161,8 @@ void ConnectDanglingEndToPad( WinEDA_PcbFrame* frame, wxDC* DC ) NULL, END ) == NULL ) { 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; diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 989c03dec2..02fc286e89 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -36,86 +36,86 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { // 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 a same list (shown here) must be contiguous **** - TYPEMARKER, // in m_markers - TYPETEXTE, // in m_Drawings - TYPEDRAWSEGMENT, // in m_Drawings - TYPECOTATION, // in m_Drawings - TYPEMIRE, // in m_Drawings - TYPEVIA, // in m_Tracks - TYPETRACK, // in m_Tracks - TYPEPAD, // in modules - TYPETEXTEMODULE, // in modules - TYPEMODULE, // in m_Modules - TYPEZONE, // in m_Zones - TYPEZONE_CONTAINER, // in m_ZoneDescriptorList + TYPE_MARKER, // in m_markers + TYPE_TEXTE, // in m_Drawings + TYPE_DRAWSEGMENT, // in m_Drawings + TYPE_COTATION, // in m_Drawings + TYPE_MIRE, // in m_Drawings + TYPE_VIA, // in m_Tracks + TYPE_TRACK, // in m_Tracks + TYPE_PAD, // in modules + TYPE_TEXTE_MODULE, // in modules + TYPE_MODULE, // in m_Modules + TYPE_ZONE, // in m_Zones + TYPE_ZONE_CONTAINER, // in m_ZoneDescriptorList EOT }; /* * const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = { - * TYPETEXTE, - * TYPEDRAWSEGMENT, - * TYPECOTATION, - * TYPEVIA, - * TYPETRACK, - * TYPEMODULE, + * TYPE_TEXTE, + * TYPE_DRAWSEGMENT, + * TYPE_COTATION, + * TYPE_VIA, + * TYPE_TRACK, + * TYPE_MODULE, * EOT * }; */ const KICAD_T GENERAL_COLLECTOR::AllButZones[] = { - TYPEMARKER, - TYPETEXTE, - TYPEDRAWSEGMENT, - TYPECOTATION, - TYPEMIRE, - TYPEVIA, - TYPETRACK, - TYPEPAD, - TYPETEXTEMODULE, - TYPEMODULE, - TYPEZONE_CONTAINER, // if it is visible on screen, it should be selectable + TYPE_MARKER, + TYPE_TEXTE, + TYPE_DRAWSEGMENT, + TYPE_COTATION, + TYPE_MIRE, + TYPE_VIA, + TYPE_TRACK, + TYPE_PAD, + TYPE_TEXTE_MODULE, + TYPE_MODULE, + TYPE_ZONE_CONTAINER, // if it is visible on screen, it should be selectable EOT }; const KICAD_T GENERAL_COLLECTOR::ModuleItems[] = { - TYPEMODULE, + TYPE_MODULE, EOT }; const KICAD_T GENERAL_COLLECTOR::PadsOrModules[] = { - TYPEPAD, - TYPEMODULE, + TYPE_PAD, + TYPE_MODULE, EOT }; const KICAD_T GENERAL_COLLECTOR::PadsTracksOrZones[] = { - TYPEPAD, - TYPEVIA, - TYPETRACK, - TYPEZONE, - TYPEZONE_CONTAINER, + TYPE_PAD, + TYPE_VIA, + TYPE_TRACK, + TYPE_ZONE, + TYPE_ZONE_CONTAINER, EOT }; const KICAD_T GENERAL_COLLECTOR::ModulesAndTheirItems[] = { - TYPETEXTEMODULE, - TYPEEDGEMODULE, - TYPEPAD, - TYPEMODULE, + TYPE_TEXTE_MODULE, + TYPE_EDGE_MODULE, + TYPE_PAD, + TYPE_MODULE, EOT }; const KICAD_T GENERAL_COLLECTOR::Tracks[] = { - TYPETRACK, - TYPEVIA, + TYPE_TRACK, + TYPE_VIA, EOT }; @@ -142,7 +142,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* switch( item->Type() ) { - case TYPEPAD: + case TYPE_PAD: { MODULE* m = (MODULE*) item->GetParent(); if( m->GetReference() == wxT( "Y2" ) ) @@ -152,31 +152,31 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* } break; - case TYPEVIA: + case TYPE_VIA: breakhere++; break; - case TYPETRACK: + case TYPE_TRACK: breakhere++; break; - case TYPEZONE: + case TYPE_ZONE: breakhere++; break; - case TYPETEXTE: + case TYPE_TEXTE: breakhere++; break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: breakhere++; break; - case TYPECOTATION: + case TYPE_COTATION: breakhere++; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: { TEXTE_MODULE* tm = (TEXTE_MODULE*) item; if( tm->m_Text == wxT( "10uH" ) ) @@ -186,7 +186,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* } break; - case TYPEMODULE: + case TYPE_MODULE: { MODULE* m = (MODULE*) item; if( m->GetReference() == wxT( "C98" ) ) @@ -206,7 +206,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* 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( ( (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(); break; - case TYPEVIA: + case TYPE_VIA: break; - case TYPETRACK: + case TYPE_TRACK: break; - case TYPEZONE: + case TYPE_ZONE: break; - case TYPEZONE_CONTAINER: + case TYPE_ZONE_CONTAINER: break; - case TYPETEXTE: + case TYPE_TEXTE: break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: break; - case TYPECOTATION: + case TYPE_COTATION: break; - case TYPEMIRE: + case TYPE_MIRE: break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: module = (MODULE*) item->GetParent(); if( m_Guide->IgnoreMTextsMarkedNoShow() && ( (TEXTE_MODULE*) item )->m_NoShow ) @@ -259,7 +259,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* } break; - case TYPEMODULE: + case TYPE_MODULE: module = (MODULE*) item; break; @@ -269,7 +269,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* // 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 ) goto exit; diff --git a/pcbnew/collectors.h b/pcbnew/collectors.h index adc9b547f4..7fab810ba0 100644 --- a/pcbnew/collectors.h +++ b/pcbnew/collectors.h @@ -121,7 +121,7 @@ public: * Function IgnoreZones * @return bool - true if should ignore zones. virtual bool IgnoreZones() const = 0; - can simply omit from scanTypes[] TYPEZONE */ + can simply omit from scanTypes[] TYPE_ZONE */ /** * Function IgnoreMTextsOnCu diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index 00d238da2c..378ade8179 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -11,6 +11,7 @@ #include "protos.h" +//#include extern void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb ); 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 Build_Pads_Info_Connections_By_Tracks( TRACK* pt_start_conn, TRACK* pt_end_conn ); 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++; 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); if( pt_pad->GetSubNet() == old_val ) 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); 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 ); PtStruct = pt_conn->start; - if( PtStruct && (PtStruct->Type() == TYPEPAD) ) + if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) ( (D_PAD*) PtStruct )->SetSubNet( 0); PtStruct = pt_conn->end; - if( PtStruct && (PtStruct->Type() == TYPEPAD) ) + if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) ( (D_PAD*) PtStruct )->SetSubNet( 0); 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; /* The segment starts on a pad */ - if( PtStruct && (PtStruct->Type() == TYPEPAD) ) + if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) { pt_pad = (D_PAD*) PtStruct; 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; - if( PtStruct && (PtStruct->Type() == TYPEPAD) ) + if( PtStruct && (PtStruct->Type() == TYPE_PAD) ) /* The segment end on a pad */ { 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 */ PtStruct = pt_conn->start; - if( PtStruct && (PtStruct->Type() != TYPEPAD) ) + if( PtStruct && (PtStruct->Type() != TYPE_PAD) ) { /* The segment starts on an other track */ 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 - if( PtStruct && (PtStruct->Type() != TYPEPAD) ) + if( PtStruct && (PtStruct->Type() != TYPE_PAD) ) { pt_autre_piste = (TRACK*) PtStruct; @@ -276,31 +276,29 @@ void WinEDA_BasePcbFrame::test_connexions( wxDC* DC ) * @param DC = current Device Context */ { - TRACK* pt_start_conn, * pt_end_conn; - int ii; - 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++ ) + // Clear the cluster identifier for all pads + for( unsigned i = 0; i< m_Pcb->m_Pads.size(); ++i ) { - (*pt_pad)->SetZoneSubNet( 0 ); - (*pt_pad)->SetSubNet( 0 ); + D_PAD* pad = m_Pcb->m_Pads[i]; + + 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 */ - pt_start_conn = m_Pcb->m_Track; // this is the first segment of the first net - while( pt_start_conn != NULL ) + // Test existing connections net by net + for( TRACK* track = m_Pcb->m_Track; track; ) { - current_net_code = pt_start_conn->GetNet(); // 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 + // this is the current net because pt_start_conn is the first segment of the 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 ); @@ -319,9 +317,6 @@ void WinEDA_BasePcbFrame::test_1_net_connexion( wxDC* DC, int net_code ) * @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; 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 ) Compile_Ratsnest( DC, TRUE ); - pt_pad = (LISTE_PAD*) m_Pcb->m_Pads; - for( ii = 0; ii < m_Pcb->m_NbPads; ii++, pt_pad++ ) + for( unsigned i=0; im_Pads.size(); ++i ) { - 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 ) continue; if( pad_net_code > net_code ) break; - (*pt_pad)->SetSubNet( 0 ); + pad->SetSubNet( 0 ); } 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 */ if( m_Pcb->m_Track ) { + TRACK* pt_start_conn; + TRACK* pt_end_conn; + 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 ) 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 ); /* 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 */ 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 */ 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; 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 -/******************************************************************************/ -static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, - const wxPoint & posref, int masque_layer ) -/******************************************************************************/ - -/** 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 +/** + * Function SuperFast_Locate_Pad_Connecte + * 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. + * * @param aPcb = the board. * @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 @@ -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 ) */ +static D_PAD* SuperFast_Locate_Pad_Connecte( BOARD* aPcb, LISTE_PAD* pt_liste, + const wxPoint& posref, int masque_layer ) { D_PAD* pad; - LISTE_PAD* ptr_pad, * lim; - int nb_pad = aPcb->m_NbPads; 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; 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* 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* 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_NbPads, sizeof( D_PAD*), SortPadsByXCoord ); + qsort( &(*aVector)[0], aBoard->m_Pads.size(), sizeof( D_PAD*), SortPadsByXCoord ); } @@ -584,7 +585,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) int masque_layer; wxString msg; - if( m_Pcb->m_NbPads == 0 ) + if( m_Pcb->m_Pads.size() == 0 ) return; a_color = CYAN; @@ -692,7 +693,7 @@ void WinEDA_BasePcbFrame::reattribution_reference_piste( int affiche ) /* look for vias which could be connect many tracks */ for( TRACK* via = m_Pcb->m_Track; via != NULL; via = via->Next() ) { - if( via->Type() != TYPEVIA ) + if( via->Type() != TYPE_VIA ) continue; 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 */ PtStruct = (BOARD_ITEM*) pt_piste->start; - if( PtStruct && (PtStruct->Type() != TYPEPAD) ) + if( PtStruct && (PtStruct->Type() != TYPE_PAD) ) { // Begin on an other track segment 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 */ PtStruct = pt_piste->end; - if( PtStruct &&(PtStruct->Type() != TYPEPAD) ) + if( PtStruct &&(PtStruct->Type() != TYPE_PAD) ) { 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) - * The sorting is made by net code +/** + * Function Sort_By_NetCode + * 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(); - return ii; + int ret = pt_ref->GetNet() - pt_compare->GetNet(); + + return ret; } -/*****************************************/ -static void RebuildTrackChain( BOARD* pcb ) -/*****************************************/ - -/** Function RebuildTrackChain() +/** + * Function RebuildTrackChain + * rebuilds the track segment linked list in order to have a chain + * sorted by increasing netcodes. * @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 ) return; - Liste = (TRACK**) MyZMalloc( (nbsegm + 1) * sizeof(TRACK*) ); + int nbsegm = pcb->m_Track.GetCount(); - ii = 0; Track = pcb->m_Track; - for( ; Track != NULL; ii++, Track = Track->Next() ) + TRACK** array = (TRACK**) MyZMalloc( nbsegm * sizeof(TRACK*) ); + + for( int i=0; im_Track.PopFront(); + wxASSERT( array[i] ); } - qsort( Liste, nbsegm, sizeof(TRACK*), - ( int( * ) ( const void*, const void* ) )Sort_By_NetCode ); + // the list is empty now + 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]; - Track->SetBack( pcb ); - Track->SetNext( Liste[1] ); - - pcb->m_Track = Track; - for( ii = 1; ii < nbsegm; ii++ ) + // add them back to the list + for( int i=0; iSetBack( Liste[ii - 1] ); - Track->SetNext( Liste[ii + 1] ); + pcb->m_Track.PushBack( array[i] ); } - MyFree( Liste ); + MyFree( array ); } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 46d8dede97..34b8332247 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -30,7 +30,7 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle for( int i = 0; iType() != TYPEMODULE ) + if( (*aCollector)[i]->Type() != TYPE_MODULE ) return NULL; } @@ -131,7 +131,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) for( int ii = 0; ii < m_Collector->GetCount(); ii++ ) { item = (*m_Collector)[ii]; - if( item->Type() != TYPEZONE ) + if( item->Type() != TYPE_ZONE ) continue; /* 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: else if( m_Collector->GetCount() == 2 - && ( (*m_Collector)[0]->Type() == TYPEPAD || (*m_Collector)[0]->Type() == - TYPETEXTEMODULE ) - && (*m_Collector)[1]->Type() == TYPEMODULE && (*m_Collector)[0]->GetParent()== + && ( (*m_Collector)[0]->Type() == TYPE_PAD || (*m_Collector)[0]->Type() == + TYPE_TEXTE_MODULE ) + && (*m_Collector)[1]->Type() == TYPE_MODULE && (*m_Collector)[0]->GetParent()== (*m_Collector)[1] ) { 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 ) { - wxPoint vec; - double t; - if( track->m_Start == track->m_End ) 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; 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 ); ) - if( !currTrack && currItem && currItem->Type()==TYPEVIA && currItem->m_Flags ) + if( !currTrack && currItem && currItem->Type()==TYPE_VIA && currItem->m_Flags ) { // moving a VIA currTrack = (TRACK*) currItem; @@ -381,7 +378,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, } 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]; 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; + } // D( printf( "Project\n" ); ) 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() ) { - if( track->Type() != TYPETRACK ) + if( track->Type() != TYPE_TRACK ) continue; if( doCheckNet && currTrack && currTrack->GetNet() != track->GetNet() ) continue; - if( (g_DesignSettings.m_LayerColor[track->GetLayer()] & ITEM_NOT_SHOW) ) + if( g_DesignSettings.m_LayerColor[track->GetLayer()] & ITEM_NOT_SHOW ) continue; // 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 ) ) continue; + D(printf( "have track prospect\n");) + if( Join( curpos, track->m_Start, track->m_End, currTrack->m_Start, currTrack->m_End ) ) { // 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 )); // if track not via, or if its a via dragging but not with its adjacent track - if( currTrack->Type() != TYPEVIA - || ( currTrack->m_Start!=track->m_Start && currTrack->m_Start!=track->m_End )) + if( currTrack->Type() != TYPE_VIA + || ( currTrack->m_Start != track->m_Start && currTrack->m_Start != track->m_End )) { if( distStart <= currTrack->m_Width/2 ) { diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp index a751b5ea63..e228c54b65 100644 --- a/pcbnew/cotation.cpp +++ b/pcbnew/cotation.cpp @@ -280,12 +280,7 @@ COTATION* WinEDA_PcbFrame::Begin_Cotation( COTATION* Cotation, wxDC* DC ) Cotation->m_Flags = 0; /* Insertion de la structure dans le Chainage .Drawings du PCB */ - Cotation->SetBack( m_Pcb ); - Cotation->SetNext( m_Pcb->m_Drawings ); - - if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->SetBack( Cotation ); - m_Pcb->m_Drawings = Cotation; + m_Pcb->Add( Cotation ); GetScreen()->SetModify(); DrawPanel->ManageCurseur = NULL; diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index ebee5d99fe..063c5a234b 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -148,13 +148,13 @@ void WinEDA_PcbFrame::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) switch( objectToSync->Type() ) { - case TYPEMODULE: + case TYPE_MODULE: module = (MODULE*) objectToSync; sprintf( cmd, "$PART: \"%s\"", CONV_TO_UTF8( module->m_Reference->m_Text ) ); break; - case TYPEPAD: + case TYPE_PAD: module = (MODULE*) objectToSync->GetParent(); pad = (D_PAD*) objectToSync; msg = pad->ReturnStringPadName(); @@ -163,7 +163,7 @@ void WinEDA_PcbFrame::SendMessageToEESCHEMA( BOARD_ITEM* objectToSync ) CONV_TO_UTF8( msg ) ); break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: #define REFERENCE 0 #define VALUE 1 module = (MODULE*) objectToSync->GetParent(); diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index da458d726e..e4d20f117a 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -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. @@ -29,58 +29,49 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) { int current_net_code; - if( Track == NULL ) + if( aTrack == NULL ) return NULL; - if( Track->GetState( DELETED ) ) + if( aTrack->GetState( DELETED ) ) { D( printf( "WinEDA_PcbFrame::Delete_Segment(): bug deleted already deleted TRACK\n" ); ) 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; + D( g_CurrentTrackList.VerifyListIntegrity(); ) + // effacement de la piste en cours ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); - // modification du trace - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); - delete Track; - g_TrackSegmentCount--; + // delete the most recently entered + delete g_CurrentTrackList.PopBack(); if( g_TwoSegmentTrackBuild ) { - // g_CurrentTrackSegment->Back() must not be a via, or we want delete also the via - if( (g_TrackSegmentCount >= 2) - && (g_CurrentTrackSegment->Type() != TYPEVIA) - && (g_CurrentTrackSegment->Back()->Type() == TYPEVIA) ) + // if in 2 track mode, and the next most recent is a segment not a via, + // and the one previous to that is a via, then delete up to the via. + if( g_CurrentTrackList.GetCount() >= 2 + && g_CurrentTrackSegment->Type() != TYPE_VIA + && g_CurrentTrackSegment->Back()->Type() == TYPE_VIA ) { - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); - delete Track; - g_TrackSegmentCount--; + delete g_CurrentTrackList.PopBack(); } } - while( g_TrackSegmentCount && g_CurrentTrackSegment - && (g_CurrentTrackSegment->Type() == TYPEVIA) ) + while( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() == TYPE_VIA ) { - Track = g_CurrentTrackSegment; - g_CurrentTrackSegment = g_CurrentTrackSegment->Back(); - delete Track; - g_TrackSegmentCount--; - if( g_CurrentTrackSegment && (g_CurrentTrackSegment->Type() != TYPEVIA) ) + delete g_CurrentTrackList.PopBack(); + + if( g_CurrentTrackSegment && g_CurrentTrackSegment->Type() != TYPE_VIA ) previous_layer = g_CurrentTrackSegment->GetLayer(); } - if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->SetNext( NULL ); - // Rectification couche active qui a pu changer si une via // a ete effacee ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer; @@ -88,21 +79,20 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) Affiche_Status_Box(); if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 { - if( ( g_TrackSegmentCount == 1 ) - && (g_CurrentTrackSegment->Type() != TYPEVIA) ) + if( g_CurrentTrackList.GetCount()==1 && g_CurrentTrackSegment->Type() != TYPE_VIA ) { - delete g_CurrentTrackSegment; - g_TrackSegmentCount = 0; + delete g_CurrentTrackList.PopBack(); } } - if( g_TrackSegmentCount == 0 ) + + if( g_CurrentTrackList.GetCount() == 0 ) { DrawPanel->ManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL; + if( g_HightLigt_Status ) Hight_Light( DC ); - g_CurrentTrackSegment = NULL; - g_FirstTrackSegment = NULL; + SetCurItem( NULL ); return NULL; } @@ -110,19 +100,19 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) { if( DrawPanel->ManageCurseur ) DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + return g_CurrentTrackSegment; } } return NULL; - } // Fin traitement si trace en cours + } - - current_net_code = Track->GetNet(); + current_net_code = aTrack->GetNet(); // redraw the area where the track was - DrawPanel->PostDirtyRect( Track->GetBoundingBox() ); + DrawPanel->PostDirtyRect( aTrack->GetBoundingBox() ); - SaveItemEfface( Track, 1 ); + SaveItemEfface( aTrack, 1 ); GetScreen()->SetModify(); 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(); - Remove_One_Track( DC, Track ); + int current_net_code = aTrack->GetNet(); + Remove_One_Track( DC, aTrack ); GetScreen()->SetModify(); 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; 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 */ TRACK* trackList = m_Pcb->m_Track->GetStartNetCode( net_code_delete ); /* Decompte du nombre de segments de la sous-chaine */ - int ii; - TRACK* segm = trackList; - for( ii = 0; segm; segm = segm->Next(), ++ii ) + int ii = 0; + for( TRACK* segm = trackList; segm; segm = segm->Next(), ++ii ) { if( segm->GetNet() != net_code_delete ) 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 */ { - TRACK* trackList; int nb_segm; if( pt_segm == NULL ) 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 */ { - TRACK* t; - int ii; - for( t = trackList, ii=0; iiNext() ) + int ii = 0; + for( TRACK* t = trackList; iiNext() ) { 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() ); } diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp index bd4e10e7ae..6a63d8604f 100644 --- a/pcbnew/dialog_edit_module.cpp +++ b/pcbnew/dialog_edit_module.cpp @@ -735,7 +735,7 @@ void WinEDA_ModulePropertiesFrame::ReCreateFieldListBox() EDA_BaseStruct* item = m_CurrentModule->m_Drawings; while( item ) { - if( item->Type() == TYPETEXTEMODULE ) + if( item->Type() == TYPE_TEXTE_MODULE ) m_TextListBox->Append( ( (TEXTE_MODULE*) item )->m_Text ); item = item->Next(); } @@ -789,7 +789,7 @@ void WinEDA_ModulePropertiesFrame::EditOrDelTextModule( wxCommandEvent& event ) int jj = 2; while( item ) { - if( item->Type() == TYPETEXTEMODULE ) + if( item->Type() == TYPE_TEXTE_MODULE ) { if( jj == TextType ) // Texte trouvé { diff --git a/pcbnew/dialog_track_options.cpp b/pcbnew/dialog_track_options.cpp index cafe4e6cb7..a9bcf4d7dc 100644 --- a/pcbnew/dialog_track_options.cpp +++ b/pcbnew/dialog_track_options.cpp @@ -445,8 +445,8 @@ void WinEDA_PcbTracksDialog::AcceptPcbOptions( wxCommandEvent& event ) m_Parent->DisplayTrackSettings(); - m_Parent->AddHistory( g_DesignSettings.m_CurrentViaSize, TYPEVIA ); - m_Parent->AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPETRACK ); + m_Parent->AddHistory( g_DesignSettings.m_CurrentViaSize, TYPE_VIA ); + m_Parent->AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPE_TRACK ); EndModal( 1 ); } @@ -462,19 +462,19 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type ) switch( type ) { - case TYPETRACK: + case TYPE_TRACK: for( ii = 0; ii < HISTORY_NUMBER; ii++ ) { if( g_DesignSettings.m_TrackWidthHistory[ii] == value ) { - addhistory = FALSE; + addhistory = FALSE; break; } } if( !addhistory ) break; - + for( ii = HISTORY_NUMBER-1; ii > 0; ii-- ) { 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 ) break; // Fin de liste - + if( g_DesignSettings.m_TrackWidthHistory[ii] > g_DesignSettings.m_TrackWidthHistory[ii+1] ) { @@ -498,12 +498,12 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type ) break; - case TYPEVIA: + case TYPE_VIA: for( ii = 0; ii < HISTORY_NUMBER; ii++ ) { if( g_DesignSettings.m_ViaSizeHistory[ii] == value ) { - addhistory = FALSE; + addhistory = FALSE; break; } } @@ -523,7 +523,7 @@ void WinEDA_BasePcbFrame::AddHistory( int value, KICAD_T type ) { if( g_DesignSettings.m_ViaSizeHistory[ii+1] == 0 ) break; // Fin de liste - + if( g_DesignSettings.m_ViaSizeHistory[ii] > g_DesignSettings.m_ViaSizeHistory[ii+1] ) { EXCHG( g_DesignSettings.m_ViaSizeHistory[ii], diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index 101245e6e9..8812f479f2 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -198,26 +198,26 @@ void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, { BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->m_Parent) )->m_Pcb; - TRACK* Track = pcb->m_Track->GetStartNetCode( net_code ); - for( ; Track; Track = Track->Next() ) + TRACK* track = pcb->m_Track->GetStartNetCode( net_code ); + for( ; track; track = track->Next() ) { - if( Track->GetNet() != net_code ) + if( track->GetNet() != net_code ) break; /* hors zone */ - if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) + if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 ) continue; /* couches differentes */ - if( Track->m_Flags & IS_DRAGGED ) + if( track->m_Flags & IS_DRAGGED ) 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 ); } } } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 435faa04e6..638e1a2f85 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -145,7 +145,7 @@ int DRC::Drc( TRACK* aRefSegm, TRACK* aList ) { updatePointers(); - if( !doTrackDrc( aRefSegm, aList ) ) + if( !doTrackDrc( aRefSegm, aList, true ) ) { wxASSERT( m_currentMarker ); @@ -239,7 +239,7 @@ void DRC::testTracks() { 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 ); m_pcb->Add( m_currentMarker ); @@ -336,29 +336,22 @@ void DRC::testZones(bool adoTestFillSegments) TRACK* zoneSeg; - /* this was for display purposes, don't know that we need it anymore - m_pcb->m_NbSegmZone = 0; - for( zoneSeg = m_pcb->m_Zone; zoneSeg; zoneSeg = zoneSeg->Next() ) - ++m_pcb->m_NbSegmZone; - */ - if ( ! adoTestFillSegments ) return; - 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 - if( !doTrackDrc( zoneSeg, zoneSeg->Next() ) ) + if( !doTrackDrc( zoneSeg, zoneSeg->Next(), true ) ) { wxASSERT( m_currentMarker ); m_pcb->Add( m_currentMarker ); m_currentMarker = 0; } - // Test zoneSeg with all track segments - 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; + // Pads already tested: disable pad test + bool rc = doTrackDrc( zoneSeg, m_pcb->m_Track, false ); if( !rc ) { wxASSERT( m_currentMarker ); @@ -382,13 +375,13 @@ MARKER* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* aItem, int aErrorCode, MARKE textB = aItem->MenuText( m_pcb ); posB = aItem->GetPosition(); - if( aItem->Type() == TYPEPAD ) + if( aItem->Type() == TYPE_PAD ) position = aItem->GetPosition(); - else if( aItem->Type() == TYPEVIA ) + else if( aItem->Type() == TYPE_VIA ) position = aItem->GetPosition(); - else if( aItem->Type() == TYPETRACK ) + else if( aItem->Type() == TYPE_TRACK ) { TRACK* track = (TRACK*) aItem; 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; @@ -508,7 +501,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) /* Phase 0 : Test vias : */ - if( aRefSeg->Type() == TYPEVIA ) + if( aRefSeg->Type() == TYPE_VIA ) { // test if via's hole is bigger than its diameter // 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 w_dist = aRefSeg->m_Width >> 1; - for( int ii=0; iim_NbPads; ++ii ) - { - D_PAD* pad = m_pcb->m_Pads[ii]; - /* 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_Masque_Layer & layerMask ) == 0 ) + if( testPads ) + { + for( unsigned ii=0; iim_Pads.size(); ++ii ) { - /* 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 + D_PAD* pad = m_pcb->m_Pads[ii]; + + /* 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; - 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 ) ) + // 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_THROUGH_HOLE, m_currentMarker ); + DRCE_TRACK_NEAR_PAD, 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; - - // 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; // 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 angle = 0; // angle du segment a tester; @@ -668,7 +665,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) x0 = aRefSeg->m_Start.x - orgx; y0 = aRefSeg->m_Start.y - orgy; - if( track->Type() == TYPEVIA ) + if( track->Type() == TYPE_VIA ) { // Test distance between two vias if( (int) hypot( x0, y0 ) < w_dist ) @@ -710,7 +707,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) RotatePoint( &x0, &y0, m_segmAngle ); RotatePoint( &xf, &yf, m_segmAngle ); - if( track->Type() == TYPEVIA ) + if( track->Type() == TYPE_VIA ) { if( checkMarginToCircle( x0, y0, w_dist, m_segmLength ) ) continue; diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h index 294a692505..decb7d5abf 100644 --- a/pcbnew/drc_stuff.h +++ b/pcbnew/drc_stuff.h @@ -428,10 +428,11 @@ private: * tests the current segment. * @param aRefSeg The segment to test * @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 * 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. * @return bool - false if DRC error or true if OK */ - bool doEdgeZoneDrc( ZONE_CONTAINER * aArea, int aCornerIndex ); //--------------------------------------------------- diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index 033a1ecfe3..a73142238d 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -159,10 +159,10 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge, wxDC* DC ) if( Edge == NULL ) { - Edge = (EDGE_MODULE*) Module->m_Drawings; + Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings; for( ; Edge != NULL; Edge = Edge->Next() ) { - if( Edge->Type() != TYPEEDGEMODULE ) + if( Edge->Type() != TYPE_EDGE_MODULE ) continue; Edge->m_Width = ModuleSegmentWidth; } @@ -209,10 +209,10 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge, wxDC* DC ) if( Edge == NULL ) { - Edge = (EDGE_MODULE*) Module->m_Drawings; + Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings; for( ; Edge != NULL; Edge = Edge->Next() ) { - if( Edge->Type() != TYPEEDGEMODULE ) + if( Edge->Type() != TYPE_EDGE_MODULE ) continue; Edge->SetLayer( new_layer ); } @@ -276,9 +276,9 @@ void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge, wxDC* DC ) { if( Edge == NULL ) 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; } @@ -301,7 +301,7 @@ static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC ) { 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 */ { @@ -348,11 +348,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge, MoveVector.x = MoveVector.y = 0; /* Add the new item to the Drawings list head*/ - Edge->SetBack( Module ); - Edge->SetNext( Module->m_Drawings ); - if( Module->m_Drawings ) - Module->m_Drawings->SetBack( Edge ); - Module->m_Drawings = Edge; + Module->m_Drawings.PushFront( Edge ); /* Mise a jour des caracteristiques du segment ou de l'arc */ Edge->m_Flags = IS_NEW; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 19346206ab..df8fed3698 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -545,8 +545,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) Fill_All_Zones( &dc ); break; - case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE: - if ( ( GetCurItem())->Type() == TYPEZONE_CONTAINER) + case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE: + if ( ( GetCurItem())->Type() == TYPE_ZONE_CONTAINER) { ZONE_CONTAINER* zone_container = (ZONE_CONTAINER* )GetCurItem(); zone_container->m_FilledPolysList.clear(); @@ -557,12 +557,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones : - if( m_Pcb->m_Zone ) - { - m_Pcb->m_Zone->DeleteStructList(); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; - } + m_Pcb->m_Zone.DeleteAll(); for( int ii = 0; ii < m_Pcb->GetAreaCount(); 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: // If the current Item is a pad, text module ...: Get the parent - if( GetCurItem()->Type() != TYPEMODULE ) + if( GetCurItem()->Type() != TYPE_MODULE ) SetCurItem( GetCurItem()->GetParent() ); - if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) + if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) { g_Drag_Pistes_On = FALSE; break; @@ -620,10 +615,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->MouseToCursorSchema(); // If the current Item is a pad, text module ...: Get the parent - if( GetCurItem()->Type() != TYPEMODULE ) + if( GetCurItem()->Type() != TYPE_MODULE ) SetCurItem( GetCurItem()->GetParent() ); - if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) + if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) ) { @@ -635,10 +630,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->MouseToCursorSchema(); // If the current Item is a pad, text module ...: Get the parent - if( GetCurItem()->Type() != TYPEMODULE ) + if( GetCurItem()->Type() != TYPE_MODULE ) SetCurItem( GetCurItem()->GetParent() ); - if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) + if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, TRUE ); break; @@ -647,10 +642,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->MouseToCursorSchema(); // If the current Item is a pad, text module ...: Get the parent - if( GetCurItem()->Type() != TYPEMODULE ) + if( GetCurItem()->Type() != TYPE_MODULE ) SetCurItem( GetCurItem()->GetParent() ); - if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) + if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, TRUE ); break; @@ -659,9 +654,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->MouseToCursorSchema(); // If the current Item is a pad, text module ...: Get the parent - if( GetCurItem()->Type() != TYPEMODULE ) + if( GetCurItem()->Type() != TYPE_MODULE ) SetCurItem( GetCurItem()->GetParent() ); - if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) + if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; m_Pcb->Change_Side_Module( (MODULE*) GetCurItem(), &dc ); break; @@ -669,9 +664,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_EDIT_MODULE: // If the current Item is a pad, text module ...: Get the parent - if( GetCurItem()->Type() != TYPEMODULE ) + if( GetCurItem()->Type() != TYPE_MODULE ) SetCurItem( GetCurItem()->GetParent() ); - if( !GetCurItem() || GetCurItem()->Type() != TYPEMODULE ) + if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE ) break; InstallModuleOptionsFrame( (MODULE*) GetCurItem(), &dc, pos ); DrawPanel->MouseToCursorSchema(); @@ -1031,7 +1026,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame, switch( DrawStruct->Type() ) { - case TYPETEXTE: + case TYPE_TEXTE: frame->StartMoveTextePcb( (TEXTE_PCB*) DrawStruct, DC ); break; @@ -1055,39 +1050,39 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) switch( Item->Type() ) { - case TYPEMODULE: + case TYPE_MODULE: Delete_Module( (MODULE*) Item, DC, true ); break; - case TYPECOTATION: + case TYPE_COTATION: Delete_Cotation( (COTATION*) Item, DC ); break; - case TYPEMIRE: + case TYPE_MIRE: Delete_Mire( (MIREPCB*) Item, DC ); break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC ); break; - case TYPETEXTE: + case TYPE_TEXTE: Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC ); break; - case TYPETRACK: + case TYPE_TRACK: Delete_Track( DC, (TRACK*) Item ); break; - case TYPEVIA: + case TYPE_VIA: Delete_Segment( DC, (TRACK*) Item ); break; - case TYPEZONE: + case TYPE_ZONE: Delete_Zone_Fill( DC, (SEGZONE*) Item ); break; - case TYPEMARKER: + case TYPE_MARKER: if( Item == GetCurItem() ) SetCurItem( NULL ); ( (MARKER*) Item )->Draw( DrawPanel, DC, GR_XOR ); @@ -1096,14 +1091,14 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) m_Pcb->Delete( Item ); break; - case TYPEPAD: - case TYPETEXTEMODULE: - case TYPEEDGEMODULE: + case TYPE_PAD: + case TYPE_TEXTE_MODULE: + case TYPE_EDGE_MODULE: break; case TYPE_NOT_INIT: - case PCB_EQUIPOT_STRUCT_TYPE: - case TYPEPCB: + case TYPE_EQUIPOT: + case TYPE_PCB: default: { 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? 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 - // see the implementation of Other_Layer_Route - the working diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index b57bbc96c1..7fb605ea03 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -31,7 +31,7 @@ int WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* DC, TRACK* pt_segm ) /* Test DRC and width change */ old_w = pt_segm->m_Width; 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; 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; 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 ) { diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index 07133b94dc..06c4fbe6c3 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -110,7 +110,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) Segment->Draw( DrawPanel, DC, GR_XOR ); PtStruct = Segment->Back(); Segment ->DeleteStructure(); - if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) ) + if( PtStruct && (PtStruct->Type() == TYPE_DRAWSEGMENT ) ) Segment = (DRAWSEGMENT*) PtStruct; DisplayOpt.DisplayDrawItems = track_fill_copy; SetCurItem( NULL ); @@ -181,9 +181,9 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC switch( item->Type() ) { - case TYPEDRAWSEGMENT: - case TYPETEXTE: - case TYPECOTATION: + case TYPE_DRAWSEGMENT: + case TYPE_TEXTE: + case TYPE_COTATION: if( item->GetLayer() == layer ) { 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 * a jour par la routine Montre_Position_NewSegment*/ { - if( (Segment->m_Start.x != Segment->m_End.x ) - || (Segment->m_Start.y != Segment->m_End.y ) ) + if( Segment->m_Start != Segment->m_End ) { if( Segment->m_Shape == S_SEGMENT ) { - Segment->SetNext( m_Pcb->m_Drawings ); - Segment->SetBack( m_Pcb ); - if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->SetBack( Segment ); - m_Pcb->m_Drawings = Segment; + m_Pcb->Add( Segment ); + GetScreen()->SetModify(); Segment->m_Flags = 0; @@ -320,11 +316,9 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC ) else { Segment->m_Flags = 0; - Segment->SetNext( m_Pcb->m_Drawings ); - Segment->SetBack( m_Pcb ); - if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->SetBack( Segment ); - m_Pcb->m_Drawings = Segment; + + m_Pcb->Add( Segment ); + GetScreen()->SetModify(); } diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 8944d40651..a35a550b7c 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -101,14 +101,14 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod, wxDC* DC ) { switch( PtStruct->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: #undef STRUCT #define STRUCT ( (EDGE_MODULE*) PtStruct ) STRUCT->m_Start0.x += deltaX; STRUCT->m_Start0.y += deltaY; STRUCT->m_End0.x += deltaX; STRUCT->m_End0.y += deltaY; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: #undef STRUCT #define STRUCT ( (TEXTE_MODULE*) PtStruct ) 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() ) { - case TYPEPAD: + case TYPE_PAD: DeletePad( (D_PAD*) Item, DC ); break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: { TEXTE_MODULE* text = (TEXTE_MODULE*) Item; if( text->m_Type == TEXT_is_REFERENCE ) @@ -154,11 +154,11 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item, wxDC* DC ) } break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: Delete_Edge_Module( (EDGE_MODULE*) Item, DC ); break; - case TYPEMODULE: + case TYPE_MODULE: break; default: diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 9d40a25d76..c3ba165ab1 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -93,7 +93,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) TRACK* pt_track; int l1, l2, nb_segm; - if( (pt_segm == NULL ) || ( pt_segm->Type() == TYPEZONE ) ) + if( (pt_segm == NULL ) || ( pt_segm->Type() == TYPE_ZONE ) ) { return; } @@ -114,7 +114,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ii = 0; pt_segm = pt_track; for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() ) { - if( pt_segm->Type() == TYPEVIA ) + if( pt_segm->Type() == TYPE_VIA ) continue; /* inversion des couches */ @@ -127,7 +127,7 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) { /* Annulation du changement */ 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 ); } @@ -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 ); /* controle des extremites de segments: sont-ils sur un pad */ 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->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; - SEGVIA* Via; - int ii; - int itmp; + unsigned itmp; - if( track == NULL ) + if( aTrack == NULL ) { 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; else ((PCB_SCREEN*)GetScreen())->m_Active_Layer = ((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM; + Affiche_Status_Box(); SetToolbars(); 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() ) ) return false; - pt_segm = g_FirstTrackSegment; - for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Next() ) + for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() ) { - if( (pt_segm->Type() == TYPEVIA) - && (g_CurrentTrackSegment->m_End == pt_segm->m_Start) ) + if( segm->Type()==TYPE_VIA && g_CurrentTrackSegment->m_End==segm->m_Start ) return false; } @@ -200,20 +196,21 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) } } - /* Saving current state before placing a via. - * If the via canot be placed this current state will be reused */ - itmp = g_TrackSegmentCount; + /* Save current state before placing a via. + * If the via canot be placed this current state will be reused + */ + itmp = g_CurrentTrackList.GetCount(); Begin_Route( g_CurrentTrackSegment, DC ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); /* create the via */ - Via = new SEGVIA( m_Pcb ); - Via->m_Flags = IS_NEW; - Via->m_Shape = g_DesignSettings.m_CurrentViaType; - Via->m_Width = g_DesignSettings.m_CurrentViaSize; - Via->SetNet( g_HightLigth_NetCode ); - Via->m_Start = Via->m_End = g_CurrentTrackSegment->m_End; + SEGVIA* via = new SEGVIA( m_Pcb ); + via->m_Flags = IS_NEW; + via->m_Shape = g_DesignSettings.m_CurrentViaType; + via->m_Width = g_DesignSettings.m_CurrentViaSize; + via->SetNet( g_HightLigth_NetCode ); + via->m_Start = via->m_End = g_CurrentTrackSegment->m_End; int old_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer; //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; /* Adjust the via layer pair */ - switch ( Via->Shape() ) + switch ( via->Shape() ) { 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; 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 ) ((PCB_SCREEN*)GetScreen())->m_Active_Layer = LAYER_CMP_N; // else error - Via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); - Via->m_Width = g_DesignSettings.m_CurrentMicroViaSize; + via->SetLayerPair( old_layer, ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); + via->m_Width = g_DesignSettings.m_CurrentMicroViaSize; break; default: // 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; } - 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 ... */ - delete Via; + delete via; ((PCB_SCREEN*)GetScreen())->m_Active_Layer = old_layer; DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); // delete the track(s) added in Begin_Route() - while( g_TrackSegmentCount > itmp ) + while( g_CurrentTrackList.GetCount() > itmp ) { Delete_Segment( DC, g_CurrentTrackSegment ); } @@ -272,51 +269,45 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) return false; } + TRACK* lastNonVia = g_CurrentTrackSegment; + /* 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 - * 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_CurrentTrackList.PushBack( via ); - 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, - * 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_CurrentTrackSegment->SetBack( Via ); - - Via->SetNext( g_CurrentTrackSegment ); + g_CurrentTrackList.PushBack( track ); if( g_TwoSegmentTrackBuild ) { // Create a second segment (we must have 2 track segments to adjust) - TRACK* track = g_CurrentTrackSegment; - - g_CurrentTrackSegment = track->Copy(); - - g_TrackSegmentCount++; - g_CurrentTrackSegment->SetBack( track ); - track->SetNext( g_CurrentTrackSegment ); + g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() ); } DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); - Via->Display_Infos( this ); + via->Display_Infos( this ); Affiche_Status_Box(); - D(printf("Other_Layer_Route\n");) SetToolbars(); return true; @@ -368,7 +359,7 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) if( item ) { - if( item->Type() == TYPEPAD ) + if( item->Type() == TYPE_PAD ) { pt_pad = (D_PAD*) item; Module = (MODULE*) pt_pad->GetParent(); @@ -400,12 +391,12 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) } 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(); } - else if( item->Type() == TYPEMODULE ) + else if( item->Type() == TYPE_MODULE ) { Module = (MODULE*) item; } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 07f94b26e0..19dfc713fb 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -21,7 +21,8 @@ static void Exit_Editrack( WinEDA_DrawPanel* panel, wxDC* DC ); void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void ComputeBreakPoint( TRACK* track, int n, wxPoint end ); -static TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ); +static void DeleteNullTrackSegments( BOARD* pcb, DLIST& aTrackList ); + static void EnsureEndTrackOnPad( D_PAD* Pad ); /* variables locales */ @@ -40,7 +41,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->m_Parent; 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 */ ShowNewTrackWhenMovingCursor( Panel, DC, FALSE ); @@ -54,12 +55,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC ) frame->MsgPanel->EraseMsgBox(); // Delete current (new) track - TRACK* previoustrack; - for( ; track; track = previoustrack ) - { - previoustrack = track->Back(); - delete track; - } + g_CurrentTrackList.DeleteAll(); } 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; - TRACK* TrackOnStartPoint = NULL, * Track; + TRACK* TrackOnStartPoint = NULL; int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; EDA_BaseStruct* LockPoint; wxPoint pos = GetScreen()->m_Curseur; + static int InitialTrackWidthValue; /* first track segment width. * used when we are in the auto tack width mode */ DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor; 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 */ OldNetCodeSurbrillance = g_HightLigth_NetCode; OldEtatSurbrillance = g_HightLigt_Status; @@ -107,17 +106,18 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) Hight_Light( DC ); 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_TrackSegmentCount = 1; + 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 ); if( LockPoint ) // An item (pad or track) is found { - if( LockPoint->Type() == TYPEPAD ) + if( LockPoint->Type() == TYPE_PAD ) { 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. { - ZONE_CONTAINER* zone = m_Pcb->HitTestForAnyFilledArea(pos, GetScreen()->m_Active_Layer ); - if ( zone ) + ZONE_CONTAINER* zone = m_Pcb->HitTestForAnyFilledArea( pos, GetScreen()->m_Active_Layer ); + if( zone ) g_HightLigth_NetCode = zone->GetNet(); } + D( g_CurrentTrackList.VerifyListIntegrity(); ); + build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), TRUE ); + + D( g_CurrentTrackList.VerifyListIntegrity(); ); + Hight_Light( DC ); + /* done above g_CurrentTrackSegment->m_Flags = IS_NEW; + */ + g_CurrentTrackSegment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer ); g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + if( g_DesignSettings.m_UseConnectedTrackWidth ) { - if( TrackOnStartPoint && TrackOnStartPoint->Type() == TYPETRACK ) + if( TrackOnStartPoint && TrackOnStartPoint->Type() == TYPE_TRACK ) { InitialTrackWidthValue = TrackOnStartPoint->m_Width; g_CurrentTrackSegment->m_Width = InitialTrackWidthValue; } } + g_CurrentTrackSegment->m_Start = pos; - g_CurrentTrackSegment->m_End = g_CurrentTrackSegment->m_Start; + g_CurrentTrackSegment->m_End = pos; g_CurrentTrackSegment->SetNet( g_HightLigth_NetCode ); + if( pt_pad ) { g_CurrentTrackSegment->start = pt_pad; @@ -167,15 +178,19 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) if( g_TwoSegmentTrackBuild ) { - // Create 2 segments - g_CurrentTrackSegment = g_CurrentTrackSegment->Copy(); - g_TrackSegmentCount++; - g_CurrentTrackSegment->SetBack( g_FirstTrackSegment ); - g_FirstTrackSegment->SetNext( g_CurrentTrackSegment ); + // Create 2nd segment + g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() ); + + D( g_CurrentTrackList.VerifyListIntegrity(); ); + g_CurrentTrackSegment->start = g_FirstTrackSegment; - g_FirstTrackSegment->end = g_CurrentTrackSegment; + g_FirstTrackSegment->end = g_CurrentTrackSegment; + g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); } + + D( g_CurrentTrackList.VerifyListIntegrity(); ); + g_CurrentTrackSegment->Display_Infos( this ); SetCurItem( g_CurrentTrackSegment ); 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*/ { + D(printf("Begin_Route in progress\n");) + /* Tst for a D.R.C. error: */ if( Drc_On ) { if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) ) return NULL; - if( g_TwoSegmentTrackBuild // We must handle 2 segments - && g_CurrentTrackSegment->Back() ) + // We must handle 2 segments + if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() ) { if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), m_Pcb->m_Track ) ) 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 - * 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; if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() ) CanCreateNewSegment = FALSE; + if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() && g_CurrentTrackSegment->Back() && g_CurrentTrackSegment->Back()->IsNull() ) CanCreateNewSegment = FALSE; + if( CanCreateNewSegment ) { /* Erase old track on screen */ + D( g_CurrentTrackList.VerifyListIntegrity(); ); + ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); + D( g_CurrentTrackList.VerifyListIntegrity(); ); + if( g_Raccord_45_Auto ) { - if( Add_45_degrees_Segment( DC, g_CurrentTrackSegment ) != 0 ) - g_TrackSegmentCount++; + Add_45_degrees_Segment( DC ); } - Track = g_CurrentTrackSegment->Copy(); - Track->Insert( m_Pcb, g_CurrentTrackSegment ); - Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); - g_CurrentTrackSegment->end = Locate_Pad_Connecte( m_Pcb, g_CurrentTrackSegment, END ); - if( g_CurrentTrackSegment->end ) + TRACK* oneBeforeLatest = g_CurrentTrackSegment; + + 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 ); - Track->SetState( BEGIN_ONPAD, ON ); + oneBeforeLatest->SetState( END_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 ) { - g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + newTrack->m_Width = g_DesignSettings.m_CurrentTrackWidth; } + + D( g_CurrentTrackList.VerifyListIntegrity(); ); + /* Show the new position */ 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 @@ -270,57 +301,54 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ) * 0 si impossible */ { - TRACK* Previous; - TRACK* NewTrack; int pas_45; int dx0, dy0, dx1, dy1; - if( g_TrackSegmentCount < 2 ) - return 0; /* il faut au moins 2 segments */ + if( g_CurrentTrackList.GetCount() < 2 ) + 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 - if( (pt_segm->Type() != TYPETRACK ) - || (Previous->Type() != TYPETRACK) ) + if( curTrack->Type() != TYPE_TRACK || prevTrack->Type() != TYPE_TRACK ) { - return 0; + return false; } pas_45 = GetScreen()->GetGrid().x / 2; - if( pas_45 < pt_segm->m_Width ) + if( pas_45 < curTrack->m_Width ) pas_45 = GetScreen()->GetGrid().x; - while( pas_45 < pt_segm->m_Width ) + while( pas_45 < curTrack->m_Width ) pas_45 *= 2; // OK : tst si les segments sont a 90 degre et vertic ou horiz - dx0 = Previous->m_End.x - Previous->m_Start.x; - dy0 = Previous->m_End.y - Previous->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; + dx0 = prevTrack->m_End.x - prevTrack->m_Start.x; + dy0 = prevTrack->m_End.y - prevTrack->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: if( MAX( abs( dx0 ), abs( dy0 ) ) < (pas_45 * 2) ) - return 0; + return false; if( MAX( abs( dx1 ), abs( dy1 ) ) < (pas_45 * 2) ) - return 0; + return false; /* 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.y = Previous->m_End.y; - NewTrack->m_End.x = pt_segm->m_Start.x; - NewTrack->m_End.y = pt_segm->m_Start.y; + newTrack->m_Start = prevTrack->m_End; + newTrack->m_End = curTrack->m_Start; if( dx0 == 0 ) // Segment precedent Vertical { if( dy1 != 0 ) // les 2 segments ne sont pas a 90 ; { - delete NewTrack; - return 0; + delete newTrack; + return false; } /* 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 */ if( dy0 > 0 ) - NewTrack->m_Start.y -= pas_45; + newTrack->m_Start.y -= pas_45; else - NewTrack->m_Start.y += pas_45; + newTrack->m_Start.y += pas_45; if( dx1 > 0 ) - NewTrack->m_End.x += pas_45; + newTrack->m_End.x += pas_45; 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; - return 0; + delete newTrack; + return false; } - Previous->m_End = NewTrack->m_Start; - pt_segm->m_Start = NewTrack->m_End; - NewTrack->Insert( m_Pcb, Previous ); - return 1; + prevTrack->m_End = newTrack->m_Start; + curTrack->m_Start = newTrack->m_End; + + g_CurrentTrackList.Insert( newTrack, curTrack ); + return true; } if( dy0 == 0 ) // Segment precedent Horizontal : dy0 = 0 { if( dx1 != 0 ) // les 2 segments ne sont pas a 90 ; { - delete NewTrack; - return 0; + delete newTrack; + return false; } // Segments a 90 @@ -364,67 +393,69 @@ int WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ) * au 2eme segment Vertical */ if( dx0 > 0 ) - NewTrack->m_Start.x -= pas_45; + newTrack->m_Start.x -= pas_45; else - NewTrack->m_Start.x += pas_45; + newTrack->m_Start.x += pas_45; if( dy1 > 0 ) - NewTrack->m_End.y += pas_45; + newTrack->m_End.y += pas_45; 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; - return 0; + delete newTrack; + return false; } - Previous->m_End = NewTrack->m_Start; - pt_segm->m_Start = NewTrack->m_End; - NewTrack->Insert( m_Pcb, Previous ); - return 1; + prevTrack->m_End = newTrack->m_Start; + curTrack->m_Start = newTrack->m_End; + + 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) */ { - int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; - wxPoint pos; - EDA_BaseStruct* LockPoint; - TRACK* adr_buf; + int masquelayer = g_TabOneLayerMask[((PCB_SCREEN*)GetScreen())->m_Active_Layer]; - if( track == NULL ) + if( aTrack == NULL ) return; if( Drc_On && BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) ) return; /* 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; ShowNewTrackWhenMovingCursor( DrawPanel, DC, TRUE ); /* mise a jour trace reel */ ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); /* efface trace piste*/ trace_ratsnest_pad( DC ); /* efface trace chevelu*/ - - // cleanup + /* cleanup if( g_CurrentTrackSegment->Next() != NULL ) { delete g_CurrentTrackSegment->Next(); g_CurrentTrackSegment->SetNext( NULL ); } + */ + + D( g_CurrentTrackList.VerifyListIntegrity(); ); /* 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 */ /* 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->Type() == TYPEPAD ) + if( LockPoint->Type() == TYPE_PAD ) { EnsureEndTrackOnPad( (D_PAD*) LockPoint ); } else /* la fin de la piste est sur une autre piste: il faudra * peut-etre creer un point d'ancrage */ { - adr_buf = (TRACK*) LockPoint; + TRACK* adr_buf = (TRACK*) LockPoint; g_HightLigth_NetCode = adr_buf->GetNet(); /* creation eventuelle d'un point d'accrochage */ @@ -455,42 +486,50 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC ) } } - // Delete Null segments: - g_FirstTrackSegment = DeleteNullTrackSegments( m_Pcb, - g_FirstTrackSegment, - &g_TrackSegmentCount ); - /* Test if no segment left. Can happend on a double click on the start point */ + DeleteNullTrackSegments( m_Pcb, g_CurrentTrackList ); + + // Insert new segments if they exist. This can be NULL on a double click on the start point if( g_FirstTrackSegment != NULL ) { - // Put new track in board - m_Pcb->Add( g_FirstTrackSegment ); + int netcode = g_FirstTrackSegment->GetNet(); + TRACK* firstTrack = g_FirstTrackSegment; + int newCount = g_CurrentTrackList.GetCount(); - trace_ratsnest_pad( DC ); - Trace_Une_Piste( DrawPanel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR ); - - // Reset flags: - TRACK* ptr = g_FirstTrackSegment; int ii; - for( ii = 0; (ptr != NULL) && (ii < g_TrackSegmentCount); ii++ ) + // Put entire new current segment list in BOARD + TRACK* track; + TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( m_Pcb ); + while( (track = g_CurrentTrackList.PopFront()) != NULL ) { - ptr->m_Flags = 0; - ptr = ptr->Next(); + m_Pcb->m_Track.Insert( track, insertBeforeMe ); } - /* 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 && iNext() ) + { + track->m_Flags = 0; + } + + // erase the old track, if exists if( g_AutoDeleteOldTrack ) { - EraseOldTrack( this, m_Pcb, DC, g_FirstTrackSegment, g_TrackSegmentCount ); + EraseOldTrack( this, m_Pcb, DC, firstTrack, newCount ); } /* compute the new rastnest : */ - test_1_net_connexion( DC, g_FirstTrackSegment->GetNet() ); + test_1_net_connexion( DC, netcode ); GetScreen()->SetModify(); 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 ) Hight_Light( DC ); @@ -515,7 +554,7 @@ TRACK* LocateIntrusion( TRACK* start, int net, int width ) 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 ) ) continue; @@ -631,6 +670,8 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase * est aussi affichee */ { + D( g_CurrentTrackList.VerifyListIntegrity(); ); + int IsolTmp, Track_fill_copy; 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 */ 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 ); } @@ -652,10 +693,11 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer ); if( ! g_DesignSettings.m_UseConnectedTrackWidth ) g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; + if( g_TwoSegmentTrackBuild ) { 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 ); if( ! g_DesignSettings.m_UseConnectedTrackWidth ) @@ -665,17 +707,21 @@ void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase if( Track_45_Only ) { - if( g_TwoSegmentTrackBuild ) { - g_CurrentTrackSegment->m_End = ActiveScreen->m_Curseur; - if (Drc_On) - PushTrack(panel); - ComputeBreakPoint( g_CurrentTrackSegment, g_TrackSegmentCount, - g_CurrentTrackSegment->m_End); - } + if( g_TwoSegmentTrackBuild ) + { + g_CurrentTrackSegment->m_End = ActiveScreen->m_Curseur; + + if( Drc_On ) + PushTrack(panel); + + ComputeBreakPoint( g_CurrentTrackSegment, g_CurrentTrackList.GetCount(), + g_CurrentTrackSegment->m_End ); + } else { /* 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, g_CurrentTrackSegment->m_Start.y, &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; } - 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.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; deltay = ActiveScreen->m_Curseur.y - oy; + /* 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 == 0 ) @@ -724,6 +775,7 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ) else { angle = 45; + if( deltay == 0 ) angle = 90; else if( ( (deltax << 6 ) / deltay ) < 26 ) @@ -738,12 +790,15 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy ) break; case 45: - deltax = MIN( deltax, deltay ); deltay = deltax; + deltax = MIN( deltax, deltay ); + deltay = deltax; + /* recalcul des signes de deltax et deltay */ if( (ActiveScreen->m_Curseur.x - ox) < 0 ) deltax = -deltax; if( (ActiveScreen->m_Curseur.y - oy) < 0 ) deltay = -deltay; + *fx = ox + deltax; *fy = oy + deltay; break; @@ -773,7 +828,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) if( track == NULL ) return; - TRACK* NewTrack = track; + TRACK* newTrack = track; track = track->Back(); SegmentCount--; if( track ) @@ -785,11 +840,11 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) iDy = abs( iDy ); } - TRACK* LastTrack = track ? track->Back() : NULL; - if( LastTrack ) + TRACK* lastTrack = track ? track->Back() : NULL; + if( lastTrack ) { - if( (LastTrack->m_End.x == LastTrack->m_Start.x) - || (LastTrack->m_End.y == LastTrack->m_Start.y) ) + if( (lastTrack->m_End.x == lastTrack->m_Start.x) + || (lastTrack->m_End.y == lastTrack->m_Start.y) ) { iAngle = 45; } @@ -822,11 +877,13 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) case 45: iDx = MIN( iDx, iDy ); iDy = iDx; + /* recalcul des signes de deltax et deltay */ if( (end.x - track->m_Start.x) < 0 ) iDx = -iDx; if( (end.y - track->m_Start.y) < 0 ) iDy = -iDy; + track->m_End.x = track->m_Start.x + iDx; track->m_End.y = track->m_Start.y + iDy; break; @@ -836,6 +893,7 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) track->m_End.y = end.y + iDx; else track->m_End.y = end.y - iDx; + track->m_End.x = track->m_Start.x; break; } @@ -844,51 +902,47 @@ void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end ) { if( track->IsNull() ) 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& aTrackList ) /****************************************************************************/ /* Delete track segments which have len = 0; after creating a new track * return a pointer on the first segment (start of track list) */ { + if( aTrackList.GetCount() == 0 ) + return; + + TRACK* track = aTrackList.GetFirst(); TRACK* firsttrack = track; TRACK* oldtrack; - int nn = 0; - BOARD_ITEM* LockPoint; - if( track == 0 ) - return NULL; - LockPoint = track->start; + BOARD_ITEM* LockPoint = track->start; while( track != NULL ) { oldtrack = track; track = track->Next(); if( !oldtrack->IsNull() ) { - nn++; continue; } // NULL segment, delete it if( firsttrack == oldtrack ) firsttrack = track; - oldtrack->UnLink(); - delete oldtrack; + + delete aTrackList.Remove( oldtrack ); } - if( segmcount ) - *segmcount = nn; - - if( nn == 0 ) - return NULL; // all the new track segments have been deleted - + if( aTrackList.GetCount() == 0 ) + return; // all the new track segments have been deleted // we must set the pointers on connected items and the connection status oldtrack = track = firsttrack; @@ -898,13 +952,15 @@ TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ) oldtrack = track; track = track->Next(); oldtrack->end = track; + if( track ) track->start = oldtrack; + oldtrack->SetStatus( 0 ); } firsttrack->start = LockPoint; - if( LockPoint && (LockPoint->Type() == TYPEPAD ) ) + if( LockPoint && LockPoint->Type()==TYPE_PAD ) firsttrack->SetState( BEGIN_ONPAD, ON ); track = firsttrack; @@ -924,8 +980,6 @@ TRACK* DeleteNullTrackSegments( BOARD* pcb, TRACK* track, int* segmcount ) } track = next_track; } - - return firsttrack; } @@ -949,10 +1003,8 @@ void EnsureEndTrackOnPad( D_PAD* Pad ) if( !g_CurrentTrackSegment->IsNull() ) { /* Must create a new segment, from track end to pad center */ - g_CurrentTrackSegment = lasttrack->Copy(); - g_TrackSegmentCount++; - lasttrack->SetNext( g_CurrentTrackSegment ); - g_CurrentTrackSegment->SetBack( lasttrack ); + g_CurrentTrackList.PushBack( lasttrack->Copy() ); + lasttrack->end = g_CurrentTrackSegment; } @@ -962,3 +1014,4 @@ void EnsureEndTrackOnPad( D_PAD* Pad ) g_CurrentTrackSegment->end = Pad; g_CurrentTrackSegment->SetState( END_ONPAD, ON ); } + diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index ae0c82ff7d..c9ccc6736c 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -38,12 +38,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) Text = new TEXTE_MODULE( Module ); /* Chainage de la nouvelle structure en tete de liste drawings */ - Text->SetNext( Module->m_Drawings ); - Text->SetBack( Module ); + Module->m_Drawings.PushFront( Text ); - if( Module->m_Drawings ) - Module->m_Drawings->SetBack( Text ); - Module->m_Drawings = Text; Text->m_Flags = IS_NEW; Text->m_Text = wxT( "text" ); diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 8bde0438e6..563a7654d1 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -162,30 +162,24 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) * pour les formes de pad PAD1 a PADn */ { - D_PAD* pad; - D_PAD** padlist; - D_PAD** pad_list_base = NULL; + std::vector pads; const char* pad_type; - int memsize, ii, dx, dy; - D_PAD* old_pad = NULL; - int pad_name_number; 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: - memsize = (pcb->m_NbPads + 1) * sizeof(D_PAD *); - 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 ); + pads.insert( pads.end(), pcb->m_Pads.begin(), pcb->m_Pads.end() ); + qsort( &pads[0], pcb->m_Pads.size(), sizeof( D_PAD* ), Pad_list_Sort_by_Shapes ); } - pad_name_number = 0; - for( padlist = pad_list_base, ii = 0; ii < pcb->m_NbPads; padlist++, ii++ ) + D_PAD* old_pad = NULL; + int pad_name_number = 0; + for( unsigned i=0; iSetSubRatsnest( pad_name_number ); 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() ); - dx = pad->m_Size.x / 2; - dy = pad->m_Size.y / 2; + int dx = pad->m_Size.x / 2; + int dy = pad->m_Size.y / 2; switch( pad->m_PadShape ) { @@ -273,8 +267,6 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) } 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() ) { - if( track->Type() == TYPEZONE ) + if( track->Type() == TYPE_ZONE ) nbitems++; } @@ -576,7 +568,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) for( track = pcb->m_Zone; track != NULL; track = track->Next() ) { - if( track->Type() == TYPEZONE ) + if( track->Type() == TYPE_ZONE ) tracklist[nbitems++] = track; } @@ -608,7 +600,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) 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() ) { @@ -621,7 +613,7 @@ void CreateRoutesSection( FILE* file, BOARD* pcb ) mapXto( track->m_Start.x ), mapYto( track->m_Start.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", track->m_Width, @@ -816,10 +808,10 @@ void ModuleWriteShape( FILE* file, MODULE* module ) { switch( PtStruct->Type() ) { - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: PtEdge = (EDGE_MODULE*) PtStruct; switch( PtEdge->m_Shape ) diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp index 73c7c6464a..beff09151d 100644 --- a/pcbnew/gen_drill_report_files.cpp +++ b/pcbnew/gen_drill_report_files.cpp @@ -131,23 +131,23 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, w { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format, EDGE_LAYER ); break; - case TYPETEXTE: + case TYPE_TEXTE: PlotTextePcb( (TEXTE_PCB*) PtStruct, format, EDGE_LAYER ); break; - case TYPECOTATION: + case TYPE_COTATION: PlotCotation( (COTATION*) PtStruct, format, EDGE_LAYER ); break; - case TYPEMIRE: + case TYPE_MIRE: PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER ); break; - case TYPEMARKER: // do not draw + case TYPE_MARKER: // do not draw break; default: diff --git a/pcbnew/gen_holes_and_tools_lists_for_drill.cpp b/pcbnew/gen_holes_and_tools_lists_for_drill.cpp index 69f21acb6c..d285a1827a 100644 --- a/pcbnew/gen_holes_and_tools_lists_for_drill.cpp +++ b/pcbnew/gen_holes_and_tools_lists_for_drill.cpp @@ -66,7 +66,7 @@ void Build_Holes_List( BOARD* aPcb, TRACK* track = aPcb->m_Track; for( ; track != NULL; track = track->Next() ) { - if( track->Type() != TYPEVIA ) + if( track->Type() != TYPE_VIA ) continue; SEGVIA* via = (SEGVIA*) track; hole_value = via->GetDrillValue(); diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 4ab6daafdd..5e905385dd 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -449,7 +449,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event ) EDA_BaseStruct* PtStruct; for( PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() != TYPEDRAWSEGMENT ) + if( PtStruct->Type() != TYPE_DRAWSEGMENT ) continue; if( ( (DRAWSEGMENT*) PtStruct )->GetLayer() != EDGE_N ) continue; diff --git a/pcbnew/gen_self.h b/pcbnew/gen_self.h index 28725b9c70..b709660dd4 100644 --- a/pcbnew/gen_self.h +++ b/pcbnew/gen_self.h @@ -288,21 +288,10 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) Module->Draw( DrawPanel, DC, GR_XOR ); /* 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 ); - if( LastSegm ) - { - LastSegm->SetNext( PtSegm ); - PtSegm->SetBack( LastSegm ); - } - else - { - Module->m_Drawings = PtSegm; PtSegm->SetBack( Module ); - } + Module->m_Drawings.PushBack( PtSegm ); + PtSegm->m_Start = Mself.m_Start; PtSegm->m_End.x = Mself.m_Start.x; PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta; @@ -336,6 +325,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) newedge->AddToChain( PtSegm ); PtSegm = newedge; PtSegm->m_Start = PtSegm->m_End; + if( ii & 1 ) /* brin d'ordre impair : cercles de sens > 0 */ arc_angle = 1800; else @@ -427,8 +417,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC ) /* Placement des 2 pads sur extremite */ PtPad = new D_PAD( Module ); - Module->m_Pads = PtPad; - PtPad->SetBack( Module ); + Module->m_Pads.PushFront( PtPad ); PtPad->SetPadName( wxT( "1" ) ); PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y; diff --git a/pcbnew/gendrill.cpp b/pcbnew/gendrill.cpp index 41d57d92bc..2dbf85f810 100644 --- a/pcbnew/gendrill.cpp +++ b/pcbnew/gendrill.cpp @@ -108,7 +108,7 @@ void WinEDA_DrillFrame::InitDisplayParams( void ) m_BlindOrBuriedViasCount = 0; for( TRACK* track = m_Parent->m_Pcb->m_Track; track != NULL; track = track->Next() ) { - if( track->Type() != TYPEVIA ) + if( track->Type() != TYPE_VIA ) continue; if( track->Shape() == VIA_THROUGH ) m_ThroughViasCount++; diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 4ab0556a2c..e64c72d6d1 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -159,8 +159,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) char Line[1024]; int NbLine = 0; long ibuf[100]; - EDGE_MODULE* DrawSegm, * LastModStruct = NULL; - D_PAD* LastPad = NULL, * Pad; + EDGE_MODULE* DrawSegm; + D_PAD* Pad; wxArrayString params; int iprmcnt, icnt_max, iflgidx; @@ -251,21 +251,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) DrawSegm->SetLayer( SILKSCREEN_N_CMP ); DrawSegm->m_Shape = S_SEGMENT; - if( LastModStruct == NULL ) - { - DrawSegm->SetBack( this ); - m_Drawings = DrawSegm; - } - else - { - DrawSegm->SetBack( LastModStruct ); - LastModStruct->SetNext( DrawSegm ); - } + m_Drawings.PushBack( DrawSegm ); + int* list[5] = { &DrawSegm->m_Start0.x, &DrawSegm->m_Start0.y, &DrawSegm->m_End0.x, &DrawSegm->m_End0.y, &DrawSegm->m_Width }; + for( unsigned ii = 0; ii < 5; ii++ ) { long dim; @@ -277,7 +270,6 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) } DrawSegm->SetDrawCoord(); - LastModStruct = DrawSegm; continue; } @@ -288,16 +280,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) DrawSegm->SetLayer( SILKSCREEN_N_CMP ); DrawSegm->m_Shape = S_ARC; - if( LastModStruct == NULL ) - { - DrawSegm->SetBack( this ); - m_Drawings = DrawSegm; - } - else - { - DrawSegm->SetBack( LastModStruct ); - LastModStruct->SetNext( DrawSegm ); - } + m_Drawings.PushBack( DrawSegm ); + for( unsigned ii = 0; ii < 7; ii++ ) { long dim; @@ -327,7 +311,6 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) DrawSegm->m_Width = (int) round( ibuf[6] * conv_unit ); DrawSegm->SetDrawCoord(); - LastModStruct = DrawSegm; continue; } @@ -376,18 +359,7 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) Pad->m_PadShape = PAD_OVAL; } - - if( LastPad == NULL ) - { - Pad->SetBack( (EDA_BaseStruct*) this ); - m_Pads = Pad; - } - else - { - Pad->SetBack( (EDA_BaseStruct*) LastPad ); - LastPad->SetNext( (EDA_BaseStruct*) Pad ); - } - LastPad = Pad; + m_Pads.PushBack( Pad ); continue; } @@ -400,8 +372,10 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) SOLDERMASK_LAYER_CMP | SOLDERMASK_LAYER_CU; iflgidx = params.GetCount() - 2; + if( TestFlags( params[iflgidx], 0x0100, wxT( "square" ) ) ) Pad->m_PadShape = PAD_RECT; + for( unsigned ii = 0; ii < 6; ii++ ) { 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) ) Pad->m_PadShape = PAD_OVAL; - if( LastPad == NULL ) - { - Pad->SetBack( (EDA_BaseStruct*) this ); - m_Pads = Pad; - } - else - { - Pad->SetBack( (EDA_BaseStruct*) LastPad ); - LastPad->SetNext( (EDA_BaseStruct*) Pad ); - } - LastPad = Pad; + m_Pads.PushBack( Pad ); continue; } } diff --git a/pcbnew/graphpcb.cpp b/pcbnew/graphpcb.cpp index 368c633d78..325b56dc74 100644 --- a/pcbnew/graphpcb.cpp +++ b/pcbnew/graphpcb.cpp @@ -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; /* Test si VIA (cercle plein a tracer) */ - if( pt_segm->Type() == TYPEVIA ) + if( pt_segm->Type() == TYPE_VIA ) { - int mask_layer = 0; - if ( pt_segm->IsOnLayer(Route_Layer_BOTTOM) ) - mask_layer = 1 << Route_Layer_BOTTOM; - if ( pt_segm->IsOnLayer(Route_Layer_TOP) ) - { - if ( mask_layer == 0 ) - mask_layer = 1 << Route_Layer_TOP; - else mask_layer = -1; - } + int mask_layer = 0; + if ( pt_segm->IsOnLayer(Route_Layer_BOTTOM) ) + mask_layer = 1 << Route_Layer_BOTTOM; + if ( pt_segm->IsOnLayer(Route_Layer_TOP) ) + { + if ( mask_layer == 0 ) + mask_layer = 1 << Route_Layer_TOP; + else mask_layer = -1; + } - if( color == VIA_IMPOSSIBLE ) - mask_layer = -1; + if( color == VIA_IMPOSSIBLE ) + mask_layer = -1; - if ( mask_layer ) - TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur, + if ( mask_layer ) + TraceFilledCercle( Pcb, pt_segm->m_Start.x, pt_segm->m_Start.y, demi_largeur, mask_layer, color, op_logique ); return; } diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index f8dee1234e..11903587c8 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -315,15 +315,15 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, DrawStruct = PcbGeneralLocateAndDisplay(); // don't let backspace delete modules!! - if( DrawStruct && (DrawStruct->Type() == TYPETRACK - || DrawStruct->Type() == TYPEVIA) ) + if( DrawStruct && (DrawStruct->Type() == TYPE_TRACK + || DrawStruct->Type() == TYPE_VIA) ) { Delete_Segment( DC, (TRACK*) DrawStruct ); SetCurItem(NULL); } GetScreen()->SetModify(); } - else if( GetCurItem()->Type() == TYPETRACK ) + else if( GetCurItem()->Type() == TYPE_TRACK ) { // then an element is being edited - remove the last segment. // simple lines for debugger: @@ -336,7 +336,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, break; 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() DrawPanel->MouseToCursorSchema(); @@ -387,7 +387,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, return; if( ItemFree ) // no track in progress: nothing to do break; - if( GetCurItem()->Type() != TYPETRACK ) // Should not occur + if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur return; if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) return; @@ -412,7 +412,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, Other_Layer_Route( NULL, DC ); break; } - if( GetCurItem()->Type() != TYPETRACK ) + if( GetCurItem()->Type() != TYPE_TRACK ) return; if( (GetCurItem()->m_Flags & IS_NEW) == 0 ) 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 if( ItemFree ) 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(); 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(); @@ -606,11 +606,11 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct ) if( ItemFree ) { DrawStruct = PcbGeneralLocateAndDisplay(); - if( DrawStruct && DrawStruct->Type() != TYPETRACK ) + if( DrawStruct && DrawStruct->Type() != TYPE_TRACK ) return FALSE; Delete_Track( DC, (TRACK*) DrawStruct ); } - else if( GetCurItem()->Type() == TYPETRACK ) + else if( GetCurItem()->Type() == TYPE_TRACK ) { // simple lines for debugger: TRACK* track = (TRACK*) GetCurItem(); diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 2b670b5193..ae42e38812 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -131,10 +131,10 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query ) // layer names are put into the BOARD. SetBOARD( new BOARD( NULL, this ) ); - for( ; g_UnDeleteStackPtr != 0; ) + while( g_UnDeleteStackPtr > 0 ) { g_UnDeleteStackPtr--; - g_UnDeleteStack[g_UnDeleteStackPtr]->DeleteStructList(); + g_UnDeleteStack[g_UnDeleteStackPtr]->DeleteStructList(); } /* init pointeurs et variables */ @@ -175,13 +175,7 @@ void WinEDA_PcbFrame::Erase_Zones( bool query ) if( query && !IsOK( this, _( "Delete Zones ?" ) ) ) return; - if( m_Pcb->m_Zone ) - { - m_Pcb->m_Zone->DeleteStructList(); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; - } - + m_Pcb->m_Zone.DeleteAll(); m_Pcb->DeleteZONEOutlines(); GetScreen()->SetModify(); @@ -215,10 +209,10 @@ void WinEDA_PcbFrame::Erase_Segments_Pcb( bool is_edges, bool query ) switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: - case TYPETEXTE: - case TYPECOTATION: - case TYPEMIRE: + case TYPE_DRAWSEGMENT: + case TYPE_TEXTE: + case TYPE_COTATION: + case TYPE_MIRE: if( g_TabOneLayerMask[ PtStruct->GetLayer()] & masque_layer ) PtStruct->DeleteStructure(); break; @@ -272,12 +266,9 @@ void WinEDA_PcbFrame::Erase_Modules( bool query ) if( query && !IsOK( this, _( "Delete Modules?" ) ) ) return; - m_Pcb->m_Modules->DeleteStructList(); - m_Pcb->m_Modules = 0; + m_Pcb->m_Modules.DeleteAll(); m_Pcb->m_Status_Pcb = 0; - m_Pcb->m_NbNets = 0; - m_Pcb->m_NbPads = 0; m_Pcb->m_NbNodes = 0; m_Pcb->m_NbLinks = 0; m_Pcb->m_NbNoconnect = 0; @@ -299,8 +290,10 @@ void WinEDA_PcbFrame::Erase_Textes_Pcb( bool query ) for( ; PtStruct != NULL; PtStruct = PtNext ) { PtNext = PtStruct->Next(); - if( PtStruct->Type() == TYPETEXTE ) - PtStruct ->DeleteStructure(); + if( PtStruct->Type() == TYPE_TEXTE ) + { + PtStruct->DeleteStructure(); + } } GetScreen()->SetModify(); diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 447227f129..4b1285eb16 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -79,7 +79,7 @@ int NbDraw, NbTrack, NbZone, NbMod, NbNets; /**********************************************************************/ 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) @@ -91,7 +91,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, char line1[256]; char line2[256]; - TRACK* NewTrack; + TRACK* newTrack; 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: - // TYPETRACK, TYPEVIA, or TYPEZONE. The type field in 2nd line - // differentiates between TYPETRACK and TYPEVIA. With virtual - // functions in use, it is critical to instantiate the TYPEVIA exactly. + // TYPE_TRACK, TYPE_VIA, or TYPE_ZONE. The type field in 2nd line + // differentiates between TYPE_TRACK and TYPE_VIA. With virtual + // functions in use, it is critical to instantiate the TYPE_VIA exactly. if( GetLine( File, line2, LineNum ) == NULL ) break; @@ -117,49 +117,48 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, sscanf( line2 + 2, " %d %d %d %lX %X", &layer, &type, &net_code, &timeStamp, &flags ); - if( StructType==TYPETRACK && type==1 ) - makeType = TYPEVIA; + if( StructType==TYPE_TRACK && type==1 ) + makeType = TYPE_VIA; else makeType = StructType; switch( makeType ) { default: - case TYPETRACK: - NewTrack = new TRACK( m_Pcb ); + case TYPE_TRACK: + newTrack = new TRACK( m_Pcb ); + m_Pcb->m_Track.Insert( newTrack, insertBeforeMe ); break; - case TYPEVIA: - NewTrack = new SEGVIA( m_Pcb ); + case TYPE_VIA: + newTrack = new SEGVIA( m_Pcb ); + m_Pcb->m_Track.Insert( newTrack, insertBeforeMe ); break; - case TYPEZONE: - NewTrack = new SEGZONE( m_Pcb ); + case TYPE_ZONE: + newTrack = new SEGZONE( m_Pcb ); + m_Pcb->m_Zone.Insert( (SEGZONE*)newTrack, (SEGZONE*)insertBeforeMe ); break; } - NewTrack->Insert( m_Pcb, PtSegm ); - - PtSegm = NewTrack; - - PtSegm->m_TimeStamp = timeStamp; + newTrack->m_TimeStamp = timeStamp; int arg_count = sscanf( line1 + 2, " %d %d %d %d %d %d %d", &shape, - &PtSegm->m_Start.x, &PtSegm->m_Start.y, - &PtSegm->m_End.x, &PtSegm->m_End.y, &width, + &newTrack->m_Start.x, &newTrack->m_Start.y, + &newTrack->m_End.x, &newTrack->m_End.y, &width, &drill ); - PtSegm->m_Width = width; - PtSegm->m_Shape = shape; + newTrack->m_Width = width; + newTrack->m_Shape = shape; if( arg_count < 7 || drill <= 0 ) - PtSegm->SetDrillDefault(); + newTrack->SetDrillDefault(); else - PtSegm->SetDrillValue(drill); + newTrack->SetDrillValue(drill); - PtSegm->SetLayer( layer ); - PtSegm->SetNet( net_code ); - PtSegm->SetState( flags, ON ); + newTrack->SetLayer( layer ); + newTrack->SetNet( net_code ); + newTrack->SetState( flags, ON ); } DisplayError( this, _( "Error: Unexpected end of file !" ) ); @@ -330,14 +329,14 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) if( stricmp( Line, "TrackWidth" ) == 0 ) { g_DesignSettings.m_CurrentTrackWidth = atoi( data ); - AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPETRACK ); + AddHistory( g_DesignSettings.m_CurrentTrackWidth, TYPE_TRACK ); continue; } if( stricmp( Line, "TrackWidthHistory" ) == 0 ) { int tmp = atoi( data ); - AddHistory( tmp, TYPETRACK ); + AddHistory( tmp, TYPE_TRACK ); continue; } @@ -407,7 +406,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) if( stricmp( Line, "ViaSize" ) == 0 ) { g_DesignSettings.m_CurrentViaSize = atoi( data ); - AddHistory( g_DesignSettings.m_CurrentViaSize, TYPEVIA ); + AddHistory( g_DesignSettings.m_CurrentViaSize, TYPE_VIA ); continue; } @@ -420,7 +419,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) if( stricmp( Line, "ViaSizeHistory" ) == 0 ) { int tmp = atoi( data ); - AddHistory( tmp, TYPEVIA ); + AddHistory( tmp, TYPE_VIA ); continue; } @@ -616,7 +615,7 @@ bool WinEDA_PcbFrame::WriteGeneralDescrPcb( FILE* File ) fprintf( File, "Nzone %d\n", m_Pcb->GetNumSegmZone() ); 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" ); return TRUE; @@ -762,10 +761,6 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) { char Line[1024]; int LineNum = 0; - int nbsegm, nbmod; - BOARD_ITEM* LastStructPcb = NULL, * StructPcb; - MODULE* LastModule = NULL, * Module; - EQUIPOT* LastEquipot = NULL, * Equipot; wxBusyCursor dummy; @@ -773,33 +768,7 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) SetLocaleTo_C_standard( ); NbDraw = NbTrack = NbZone = NbMod = NbNets = -1; - m_Pcb->m_NbNets = 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 ) { @@ -835,20 +804,9 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) 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 ); - 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; } @@ -864,140 +822,67 @@ int WinEDA_PcbFrame::ReadPcbFile( FILE* File, bool Append ) if( strnicmp( Line, "$MODULE", 7 ) == 0 ) { - Module = new MODULE( m_Pcb ); + MODULE* Module = new MODULE( m_Pcb ); + if( Module == NULL ) continue; - Module->ReadDescr( File, &LineNum ); - if( LastModule == NULL ) - { - m_Pcb->m_Modules = Module; - Module->SetBack( m_Pcb ); - } - else - { - Module->SetBack( LastModule ); - LastModule->SetNext( Module ); - } - LastModule = Module; - nbmod++; + m_Pcb->Add( Module, ADD_APPEND ); + Module->ReadDescr( File, &LineNum ); continue; } if( strnicmp( Line, "$TEXTPCB", 8 ) == 0 ) { TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_Pcb ); - StructPcb = pcbtxt; + m_Pcb->Add( pcbtxt, ADD_APPEND ); 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; } if( strnicmp( Line, "$DRAWSEGMENT", 10 ) == 0 ) { DRAWSEGMENT* DrawSegm = new DRAWSEGMENT( m_Pcb ); + m_Pcb->Add( DrawSegm, ADD_APPEND ); 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; } - if( strnicmp( Line, "$COTATION", 9 ) == 0 ) { COTATION* Cotation = new COTATION( m_Pcb ); + m_Pcb->Add( Cotation, ADD_APPEND ); 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; } if( strnicmp( Line, "$MIREPCB", 8 ) == 0 ) { MIREPCB* Mire = new MIREPCB( m_Pcb ); + m_Pcb->Add( Mire, ADD_APPEND ); 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; } 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 - int ii = ReadListeSegmentDescr( File, StartTrack, TYPETRACK, + TRACK* insertBeforeMe = Append ? NULL : m_Pcb->m_Track.GetFirst(); + ReadListeSegmentDescr( File, insertBeforeMe, TYPE_TRACK, &LineNum, NbTrack ); - m_Pcb->m_NbSegmTrack += ii; + D( m_Pcb->m_Track.VerifyListIntegrity(); ) #endif continue; } 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 - int ii = ReadListeSegmentDescr( File, StartZone, TYPEZONE, + SEGZONE* insertBeforeMe = Append ? NULL : m_Pcb->m_Zone.GetFirst(); + + ReadListeSegmentDescr( File, insertBeforeMe, TYPE_ZONE, &LineNum, NbZone ); - m_Pcb->m_NbSegmZone += ii; + D( m_Pcb->m_Zone.VerifyListIntegrity(); ) #endif continue; } diff --git a/pcbnew/lay2plot.cpp b/pcbnew/lay2plot.cpp index 472b27080e..e56016dcc8 100644 --- a/pcbnew/lay2plot.cpp +++ b/pcbnew/lay2plot.cpp @@ -58,17 +58,17 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl { switch( item->Type() ) { - case TYPEDRAWSEGMENT: - case TYPECOTATION: - case TYPETEXTE: - case TYPEMIRE: + case TYPE_DRAWSEGMENT: + case TYPE_COTATION: + case TYPE_TEXTE: + case TYPE_MIRE: if( ((1<GetLayer()) & printmasklayer) == 0 ) break; item->Draw( this, DC, drawmode ); break; - case TYPEMARKER: /* Trace des marqueurs */ + case TYPE_MARKER: /* Trace des marqueurs */ default: break; } @@ -80,7 +80,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl { if( ( printmasklayer & pt_piste->ReturnMaskLayer() ) == 0 ) continue; - if( pt_piste->Type() == TYPEVIA ) /* VIA rencontree */ + if( pt_piste->Type() == TYPE_VIA ) /* VIA rencontree */ { int rayon = pt_piste->m_Width >> 1; 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 ) continue; - if( pt_piste->Type() == TYPEVIA ) /* VIA rencontree */ + if( pt_piste->Type() == TYPE_VIA ) /* VIA rencontree */ { GRSetDrawMode( DC, drawmode ); 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() ) { - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: if( (mlayer & masklayer ) == 0 ) break; @@ -214,7 +214,7 @@ static void Plot_Module( WinEDA_DrawPanel* panel, wxDC* DC, TextMod->Draw( panel, DC, draw_mode ); break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: { EDGE_MODULE* edge = (EDGE_MODULE*) PtStruct; if( (g_TabOneLayerMask[edge->GetLayer()] & masklayer ) == 0 ) diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index ae315cec14..d00db94ee2 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -123,13 +123,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) } /* Insert footprint in list*/ - if( m_Pcb->m_Modules ) - { - m_Pcb->m_Modules->SetBack( module ); - } - module->SetNext( m_Pcb->m_Modules ); - module->SetBack( m_Pcb ); - m_Pcb->m_Modules = module; + m_Pcb->Add( module ); /* Display info : */ 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 Module = new MODULE( m_Pcb ); - Module->SetNext( m_Pcb->m_Modules ); - Module->SetBack( m_Pcb ); - if( m_Pcb->m_Modules ) - { - m_Pcb->m_Modules->SetBack( Module ); - } - m_Pcb->m_Modules = Module; + m_Pcb->Add( Module ); /* Update parameters: position, timestamp ... */ newpos = GetScreen()->m_Curseur; diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 014a0af865..7dc7626b62 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -69,11 +69,8 @@ void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE* Module ) NewModule->m_Link = Module->m_TimeStamp; Module = NewModule; - Module->SetParent( m_Pcb ); - Module->SetBack( m_Pcb->m_Modules ); - Module->SetNext( NULL ); - m_Pcb->m_Modules = Module; + m_Pcb->Add( Module ); Module->m_Flags = 0; @@ -192,19 +189,12 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, char Line[512]; wxString Name; wxString ComponentName, msg; - MODULE* Module; MODULE* NewModule; FILE* lib_module = NULL; unsigned ii; ComponentName = ModuleName; - /* Calcul de l'adresse du dernier module: */ - Module = m_Pcb->m_Modules; - if( Module ) - while( Module->Next() ) - Module = (MODULE*) Module->Next(); - for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) { fulllibname = g_LibName_List[ii]; @@ -273,16 +263,8 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, SetLocaleTo_C_standard( ); NewModule->ReadDescr( lib_module, &LineNum ); SetLocaleTo_Default( ); // revert to the current locale - if( Module == NULL ) /* 1er Module */ - { - m_Pcb->m_Modules = NewModule; - NewModule->SetBack( m_Pcb ); - } - else - { - Module->SetNext( NewModule ); - NewModule->SetBack( Module ); - } + + m_Pcb->Add( NewModule, ADD_APPEND ); fclose( lib_module ); Affiche_Message( wxEmptyString ); return NewModule; diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index 0bd5698c7b..b339362d51 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -46,7 +46,7 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer ) for( track = Pcb->m_Track; track; track = track->Next() ) { - if( track->Type() != TYPEVIA ) + if( track->Type() != TYPE_VIA ) continue; if( track->m_Start != pos ) continue; @@ -70,7 +70,7 @@ TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer ) for( track = aStart; track; track = track->Next() ) { - if( track->Type() != TYPEVIA ) + if( track->Type() != TYPE_VIA ) continue; if( !track->HitTest(pos) ) continue; @@ -353,7 +353,8 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base, * @param extr = START or END = end of ref track segment to use in tests */ { - #define NEIGHTBOUR_COUNT_MAX 50 + const int NEIGHTBOUR_COUNT_MAX = 50; + TRACK* PtSegmB, * PtSegmN; int Reflayer; wxPoint pos_ref; @@ -426,7 +427,7 @@ suite: suite1: if( PtSegmB == pt_base ) PtSegmB = NULL; - else if( PtSegmB->Type() != TYPEPCB ) + else if( PtSegmB->Type() != TYPE_PCB ) PtSegmB = PtSegmB->Back(); else PtSegmB = NULL; @@ -495,27 +496,31 @@ TRACK* Locate_Pistes( TRACK* start_adresse, int MasqueLayer, int typeloc ) TRACK* Locate_Pistes( TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLayer ) { - for( TRACK* Track = start_adresse; Track; Track = Track->Next() ) + for( TRACK* track = start_adresse; track; track = track->Next() ) { - if( Track->GetState( BUSY | DELETED ) ) - continue; + int layer = track->GetLayer(); - if( (g_DesignSettings.m_LayerColor[Track->GetLayer()] & ITEM_NOT_SHOW) ) - continue; - - if( Track->Type() == TYPEVIA ) /* VIA rencontree */ + if( track->GetState( BUSY | DELETED ) ) { - if( Track->HitTest( ref_pos ) ) - return Track; + // D(printf("track %p is BUSY | DELETED. BUSY=%d DELETED=%d\n", track, track->GetState(BUSY), track->GetState(DELETED) );) + continue; + } + + if( g_DesignSettings.m_LayerColor[layer] & ITEM_NOT_SHOW ) + continue; + + if( track->Type() == TYPE_VIA ) /* VIA rencontree */ + { + if( track->HitTest( ref_pos ) ) + return track; } else { - if( MasqueLayer != -1 ) - if( (g_TabOneLayerMask[Track->GetLayer()] & MasqueLayer) == 0 ) - continue; /* Segments sur couches differentes */ + if( (g_TabOneLayerMask[layer] & MasqueLayer) == 0 ) + continue; /* Segments sur couches differentes */ - if( Track->HitTest( ref_pos ) ) - return Track; + if( track->HitTest( ref_pos ) ) + return track; } } @@ -578,13 +583,10 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_ * (bonne position ET bonne couche). */ { - D_PAD* pad; - LISTE_PAD* ptr_pad, * lim; - - lim = (LISTE_PAD*) Pcb->m_Pads + Pcb->m_NbPads; - for( ptr_pad = (LISTE_PAD*) Pcb->m_Pads; ptr_pad < lim; ptr_pad++ ) + for( unsigned i=0; im_Pads.size(); ++i ) { - pad = *ptr_pad; + D_PAD* pad = Pcb->m_Pads[i]; + if( pad->m_Pos != ref_pos ) continue; @@ -657,7 +659,7 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, for( PtSegm = start_adr; PtSegm != NULL; PtSegm = PtSegm->Next() ) { - if( PtSegm->Type() == TYPEVIA ) + if( PtSegm->Type() == TYPE_VIA ) { if( pos == PtSegm->m_Start ) { diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 9c42e7ba3e..f662625776 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -208,12 +208,7 @@ MIREPCB* WinEDA_PcbFrame::Create_Mire( wxDC* DC ) { MIREPCB* MirePcb = new MIREPCB( m_Pcb ); - MirePcb->SetNext( m_Pcb->m_Drawings ); - MirePcb->SetBack( m_Pcb ); - - if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->SetBack( MirePcb ); - m_Pcb->m_Drawings = MirePcb; + m_Pcb->Add( MirePcb ); MirePcb->SetLayer( EDGE_N ); MirePcb->m_Width = g_DesignSettings.m_EdgeSegmentWidth; diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 53e1171acb..4da7309684 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -55,7 +55,7 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode ) for( int ii = 0; ii < m_Collector->GetCount(); ii++ ) { item = (*m_Collector)[ii]; - if( item->Type() != TYPEMODULE ) + if( item->Type() != TYPE_MODULE ) continue; m_Collector->Remove( ii ); ii--; @@ -284,15 +284,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) // Create the "new" module MODULE* newmodule = new MODULE( mainpcb ); newmodule->Copy( module_in_edit ); - newmodule->SetParent( mainpcb ); // modifie par la copie newmodule->m_Link = 0; // Put the footprint in the main pcb linked list. - newmodule->SetNext( mainpcb->m_Modules ); - mainpcb->m_Modules = newmodule; - newmodule->SetBack( mainpcb ); - if( newmodule->Next() ) - newmodule->Next()->SetBack( newmodule ); + mainpcb->Add( newmodule ); if( source_module ) // this is an update command { @@ -525,7 +520,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) EDGE_MODULE* edge = NULL; if( GetScreen()->GetCurItem() && ( GetScreen()->GetCurItem()->m_Flags & IS_NEW) - && (GetScreen()->GetCurItem()->Type() == TYPEEDGEMODULE) ) + && (GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE) ) { edge = (EDGE_MODULE*) GetScreen()->GetCurItem(); } @@ -579,7 +574,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) BOARD_ITEM* item = GetCurItem(); if( item ) { - if( item->Type() != TYPEPAD ) + if( item->Type() != TYPE_PAD ) item = NULL; } InstallPadOptionsFrame( (D_PAD*) item, &dc, pos ); @@ -693,13 +688,13 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform /* Rectification des contours et textes de l'empreinte : */ for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() == TYPEEDGEMODULE ) + if( PtStruct->Type() == TYPE_EDGE_MODULE ) { edgemod = (EDGE_MODULE*) PtStruct; edgemod->m_Start0 = edgemod->m_Start; edgemod->m_End0 = edgemod->m_End; } - if( PtStruct->Type() == TYPETEXTEMODULE ) + if( PtStruct->Type() == TYPE_TEXTE_MODULE ) { /* deplacement des inscriptions : */ textmod = (TEXTE_MODULE*) PtStruct; @@ -741,7 +736,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform { switch( PtStruct->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: edgemod = (EDGE_MODULE*) PtStruct; edgemod->m_Start.y = -edgemod->m_Start.y; edgemod->m_End.y = -edgemod->m_End.y; @@ -750,7 +745,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform edgemod->m_End0.y = -edgemod->m_End0.y; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: /* Inversion miroir de la position et mise en miroir : */ textmod = (TEXTE_MODULE*) PtStruct; textmod->m_Pos.y = -textmod->m_Pos.y; diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index a6cc4dafd0..e192de9226 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -31,17 +31,17 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { switch( DrawStruct->Type() ) { - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: SaveCopyInUndoList( m_Pcb->m_Modules ); PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC ); break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: SaveCopyInUndoList( m_Pcb->m_Modules ); Place_EdgeMod( (EDGE_MODULE*) DrawStruct, DC ); break; - case TYPEPAD: + case TYPE_PAD: PlacePad( (D_PAD*) DrawStruct, DC ); break; @@ -234,7 +234,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, switch( DrawStruct->Type() ) { - case TYPEMODULE: + case TYPE_MODULE: { wxMenu* transform_choice = new wxMenu; ADD_MENUITEM( transform_choice, ID_MODEDIT_MODULE_ROTATE, @@ -254,7 +254,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, break; } - case TYPEPAD: + case TYPE_PAD: if( !flags ) { ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_PAD_REQUEST, @@ -275,7 +275,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, } break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: if( !flags ) { ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST, @@ -290,7 +290,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, _( "Delete Text Mod." ), delete_text_xpm ); break; - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: { if( (flags & IS_NEW) ) ADD_MENUITEM( PopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING, @@ -318,20 +318,20 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, } break; - case TYPEDRAWSEGMENT: - case TYPETEXTE: - case TYPEVIA: - case TYPETRACK: - case TYPEZONE: - case TYPEMARKER: - case TYPECOTATION: - case TYPEMIRE: + case TYPE_DRAWSEGMENT: + case TYPE_TEXTE: + case TYPE_VIA: + case TYPE_TRACK: + case TYPE_ZONE: + case TYPE_MARKER: + case TYPE_COTATION: + case TYPE_MIRE: break; - case TYPESCREEN: + case TYPE_SCREEN: case TYPE_NOT_INIT: - case TYPEPCB: - case PCB_EQUIPOT_STRUCT_TYPE: + case TYPE_PCB: + case TYPE_EQUIPOT: msg.Printf( wxT( "WinEDA_ModuleEditFrame::OnRightClick Error: illegal DrawType %d" ), DrawStruct->Type() ); @@ -392,19 +392,19 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) switch( DrawStruct->Type() ) { - case TYPEPAD: + case TYPE_PAD: InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; - case TYPEMODULE: + case TYPE_MODULE: InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc, pos ); DrawPanel->MouseToCursorSchema(); diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index 835b7dbcfe..d12c9dcf29 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -51,11 +51,10 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList() if( GetScreen()->m_RedoList == NULL ) return; - GetScreen()->AddItemToUndoList( m_Pcb->m_Modules ); - m_Pcb->m_Modules = - (MODULE*) GetScreen()->GetItemFromRedoList(); - if( m_Pcb->m_Modules ) - m_Pcb->m_Modules->SetNext( NULL ); + GetScreen()->AddItemToUndoList( m_Pcb->m_Modules.PopFront() ); + + m_Pcb->Add( (MODULE*) GetScreen()->GetItemFromRedoList() ); + SetCurItem( NULL );; GetScreen()->SetModify(); ReCreateHToolbar(); @@ -75,9 +74,9 @@ void WinEDA_ModuleEditFrame::GetComponentFromUndoList() if( GetScreen()->m_UndoList == NULL ) return; - GetScreen()->AddItemToRedoList( m_Pcb->m_Modules ); - m_Pcb->m_Modules = - (MODULE*) GetScreen()->GetItemFromUndoList(); + GetScreen()->AddItemToRedoList( m_Pcb->m_Modules.PopFront() ); + + m_Pcb->Add( (MODULE*) GetScreen()->GetItemFromUndoList() ); if( m_Pcb->m_Modules ) m_Pcb->m_Modules->SetNext( NULL ); diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 2d3ec648d4..0ff3f9e970 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -290,7 +290,6 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, wxDC* DC, bool aAskBeforeDe * @param aPromptBeforeDeleting : if true: ask for confirmation before deleting */ { - EDA_BaseStruct* PtBack, * PtNext; wxString msg; /* Si l'empreinte est selectee , on ne peut pas l'effacer ! */ @@ -319,20 +318,6 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, wxDC* DC, bool aAskBeforeDe if( g_Show_Ratsnest ) DrawGeneralRatsnest( DC ); - /* Suppression du chainage */ - PtBack = module->Back(); - PtNext = module->Next(); - if( PtBack == (EDA_BaseStruct*) m_Pcb ) - { - m_Pcb->m_Modules = (MODULE*) PtNext; - } - else - { - PtBack->SetNext( PtNext ); - } - if( PtNext ) - PtNext->SetBack( PtBack ); - /* Sauvegarde en buffer des undelete */ SaveItemEfface( module, 1 ); @@ -473,7 +458,7 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) { switch( PtStruct->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: pt_edgmod = (EDGE_MODULE*) PtStruct; pt_edgmod->m_Start.y -= Module->m_Pos.y; pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y; @@ -492,7 +477,7 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC ) pt_edgmod->SetLayer( ChangeSideNumLayer( pt_edgmod->GetLayer() ) ); break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: /* Inversion miroir de la position et mise en miroir : */ pt_texte = (TEXTE_MODULE*) PtStruct; pt_texte->m_Pos.y -= Module->m_Pos.y; diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index fc4c0abccb..4b8f94f24b 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -193,7 +193,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw ) /***********************************************************/ /* Routine d'ajout d'un pad sur l'module selectionnee */ { - D_PAD* Pad, * ptliste; + D_PAD* Pad; int rX, rY; m_Pcb->m_Status_Pcb = 0; @@ -202,24 +202,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw ) Pad = new D_PAD( Module ); /* Chainage de la structure en fin de liste des pads : */ - ptliste = Module->m_Pads; - if( ptliste == NULL ) /* 1er pad */ - { - Module->m_Pads = Pad; - Pad->SetBack( Module ); - } - else - { - while( ptliste ) - { - if( ptliste->Next() == NULL ) - break; - ptliste = (D_PAD*) ptliste->Next(); - } - - Pad->SetBack( ptliste ); - ptliste->SetNext( Pad ); - } + Module->m_Pads.PushBack( Pad ); /* Mise a jour des caract de la pastille : */ Import_Pad_Settings( Pad, false ); diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 5114474f85..0f31e49a7d 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -48,15 +48,17 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) TRACK* NextS; int ii; - /* Erase the current drawings */ wxPoint oldpos = Panel->GetScreen()->m_Curseur; Panel->GetScreen()->m_Curseur = PosInit; + if( Panel->ManageCurseur ) Panel->ManageCurseur( Panel, DC, TRUE ); + Panel->GetScreen()->m_Curseur = oldpos; g_HightLigt_Status = FALSE; + ( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode ); if( NewTrack ) @@ -67,7 +69,8 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) { if( NewTrack == NULL ) break; - NextS = (TRACK*) NewTrack->Next(); + + NextS = NewTrack->Next(); delete NewTrack; } } @@ -76,14 +79,17 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC ) TRACK* Track = NewTrack; int dx = s_LastPos.x - PosInit.x; int dy = s_LastPos.y - PosInit.y; - for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Next() ) + for( ii = 0; ii < NbPtNewTrack; ii++, Track = Track->Next() ) { if( Track == NULL ) break; + Track->m_Start.x -= dx; Track->m_Start.y -= dy; + Track->m_End.x -= dx; Track->m_End.y -= dy; + Track->m_Flags = 0; } @@ -141,19 +147,25 @@ static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) /* set the new track coordinates */ wxPoint Pos = screen->m_Curseur; + dx = Pos.x - s_LastPos.x; dy = Pos.y - s_LastPos.y; + s_LastPos = Pos; - ii = NbPtNewTrack, Track = NewTrack; + + ii = NbPtNewTrack; + Track = NewTrack; for( ; (ii > 0) && (Track != NULL); ii--, Track = Track->Next() ) { if( Track->m_Flags & STARTPOINT ) { - Track->m_Start.x += dx; Track->m_Start.y += dy; + Track->m_Start.x += dx; + Track->m_Start.y += dy; } if( Track->m_Flags & ENDPOINT ) { - Track->m_End.x += dx; Track->m_End.y += dy; + Track->m_End.x += dx; + Track->m_End.y += dy; } } @@ -166,14 +178,19 @@ static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) Track = pt_drag->m_Segm; if( erase ) Track->Draw( panel, DC, draw_mode ); + if( Track->m_Flags & STARTPOINT ) { - Track->m_Start.x += dx; Track->m_Start.y += dy; + Track->m_Start.x += dx; + Track->m_Start.y += dy; } + if( Track->m_Flags & ENDPOINT ) { - Track->m_End.x += dx; Track->m_End.y += dy; + Track->m_End.x += dx; + Track->m_End.y += dy; } + Track->Draw( panel, DC, draw_mode ); } @@ -619,7 +636,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co Hight_Light( DC ); PosInit = GetScreen()->m_Curseur; - if( track->Type() == TYPEVIA ) + if( track->Type() == TYPE_VIA ) { track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT; if( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT ) @@ -749,7 +766,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC s_StartSegmentPresent = s_EndSegmentPresent = TRUE; - if( (track->start == NULL) || (track->start->Type() == TYPETRACK) ) + if( (track->start == NULL) || (track->start->Type() == TYPE_TRACK) ) TrackToStartPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, START ); // Test if more than one segment is connected to this point @@ -761,7 +778,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC TrackToStartPoint->SetState( BUSY, OFF ); } - if( (track->end == NULL) || (track->end->Type() == TYPETRACK) ) + if( (track->end == NULL) || (track->end->Type() == TYPE_TRACK) ) TrackToEndPoint = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, END ); // Test if more than one segment is connected to this point @@ -779,10 +796,10 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC return; } - if( !TrackToStartPoint || (TrackToStartPoint->Type() != TYPETRACK) ) + if( !TrackToStartPoint || (TrackToStartPoint->Type() != TYPE_TRACK) ) s_StartSegmentPresent = FALSE; - if( !TrackToEndPoint || (TrackToEndPoint->Type() != TYPETRACK) ) + if( !TrackToEndPoint || (TrackToEndPoint->Type() != TYPE_TRACK) ) s_EndSegmentPresent = FALSE; /* Change hight light net: the new one will be hightlighted */ @@ -917,25 +934,19 @@ EDA_BaseStruct* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask ) * masque des couches a tester */ { - D_PAD* pt_pad; - TRACK* ptsegm; - MODULE* Module; - - /* detection du point type PAD */ - pt_pad = NULL; - Module = Pcb->m_Modules; - for( ; Module != NULL; Module = (MODULE*) Module->Next() ) + for( MODULE* module = Pcb->m_Modules; module; module = module->Next() ) { - pt_pad = Locate_Pads( Module, pos, LayerMask ); - if( pt_pad ) - return pt_pad; + D_PAD* pad = Locate_Pads( module, pos, LayerMask ); + if( pad ) + return pad; } /* ici aucun pad n'a ete localise: detection d'un segment de piste */ - ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask ); + TRACK* ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask ); if( ptsegm == NULL ) ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask ); + return ptsegm; } @@ -963,28 +974,31 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm ) int cX, cY; int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */ int ox, oy, fx, fy; /* coord de refsegm / origine de prsegm */ - TRACK* NewTrack; if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) ) return NULL; + if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) ) return NULL; /* le point n'est pas sur une extremite de piste */ - if( ptsegm->Type() == TYPEVIA ) + if( ptsegm->Type() == TYPE_VIA ) { - *pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y; + *pX = ptsegm->m_Start.x; + *pY = ptsegm->m_Start.y; return ptsegm; } /* calcul des coord vraies du point intermediaire dans le repere d'origine - * = origine de ptsegm */ + * = origine de ptsegm + */ cX = *pX - ptsegm->m_Start.x; cY = *pY - ptsegm->m_Start.y; + dx = ptsegm->m_End.x - ptsegm->m_Start.x; dy = ptsegm->m_End.y - ptsegm->m_Start.y; -// ***** A COMPLETER : non utilise + // ***** A COMPLETER : non utilise if( refsegm ) { ox = refsegm->m_Start.x - ptsegm->m_Start.x; @@ -995,29 +1009,40 @@ TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm ) /* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */ if( dx == 0 ) - cX = 0;/* segm horizontal */ + cX = 0; /* segm horizontal */ else cY = (cX * dy) / dx; /* creation du point intermediaire ( c'est a dire creation d'un nouveau - * segment, debutant au point intermediaire */ + * segment, debutant au point intermediaire + */ - cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y; - NewTrack = ptsegm->Copy(); + cX += ptsegm->m_Start.x; + cY += ptsegm->m_Start.y; + + TRACK* newTrack = ptsegm->Copy(); + + DLIST* list = (DLIST*)ptsegm->GetList(); + wxASSERT( list ); + list->Insert( newTrack, ptsegm->Next() ); - NewTrack->Insert( NULL, ptsegm ); /* correction du pointeur de fin du nouveau segment */ - NewTrack->end = ptsegm->end; + newTrack->end = ptsegm->end; /* le segment primitif finit au nouveau point : */ - ptsegm->m_End.x = cX; ptsegm->m_End.y = cY; + ptsegm->m_End.x = cX; + ptsegm->m_End.y = cY; + ptsegm->SetState( END_ONPAD, OFF ); /* le nouveau segment debute au nouveau point : */ - ptsegm = NewTrack;; - ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY; + ptsegm = newTrack;; + ptsegm->m_Start.x = cX; + ptsegm->m_Start.y = cY; ptsegm->SetState( BEGIN_ONPAD, OFF ); - *pX = cX; *pY = cY; + + *pX = cX; + *pY = cY; return ptsegm; } diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index b3e95de1cf..c3249b20c5 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -62,19 +62,10 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( wxDC* DC, /* Creation des pastilles formant le gap */ while( pad_count-- ) { - D_PAD* pad; - pad = new D_PAD( Module ); - pad->SetBack( Module ); - if( Module->m_Pads == NULL ) - { - Module->m_Pads = pad; - } - else - { - Module->m_Pads->SetBack( pad ); - pad->SetNext( Module->m_Pads ); - Module->m_Pads = pad; - } + D_PAD* pad= new D_PAD( Module ); + + Module->m_Pads.PushFront( pad ); + pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth; pad->m_Pos = Module->m_Pos; pad->m_PadShape = PAD_RECT; @@ -239,9 +230,10 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( wxDC* DC, int shape_type ) { EDGE_MODULE* edge; int* ptr, theta; ii = angle / 50; + edge = new EDGE_MODULE( Module ); - Module->m_Drawings = edge; - edge->SetBack( Module ); + Module->m_Drawings.PushFront( edge ); + edge->m_Shape = S_POLYGON; edge->SetLayer( LAYER_CMP_N ); edge->m_PolyCount = ii + 3; @@ -567,8 +559,9 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( wxDC* DC ) pad2->m_Pos.x += pad2->m_Pos0.x; edge = new EDGE_MODULE( Module ); - Module->m_Drawings = edge; - edge->SetBack( Module ); + + Module->m_Drawings.PushFront( edge ); + edge->m_Shape = S_POLYGON; edge->SetLayer( LAYER_CMP_N ); npoints = PolyEdgesCount; diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 1fe3d1ff51..48084147c3 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -38,7 +38,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) switch( DrawStruct->Type() ) { - case TYPEZONE_CONTAINER: + case TYPE_ZONE_CONTAINER: if ( (DrawStruct->m_Flags & IS_NEW) ) Begin_Zone( DC ); else @@ -46,8 +46,8 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) exit = true; break; - case TYPETRACK: - case TYPEVIA: + case TYPE_TRACK: + case TYPE_VIA: if( DrawStruct->m_Flags & IS_DRAGGED ) { PlaceDraggedTrackSegment( (TRACK*) DrawStruct, DC ); @@ -55,32 +55,32 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } break; - case TYPETEXTE: + case TYPE_TEXTE: Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC ); exit = true; break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC ); exit = true; break; - case TYPEPAD: + case TYPE_PAD: PlacePad( (D_PAD*) DrawStruct, DC ); exit = true; break; - case TYPEMODULE: + case TYPE_MODULE: Place_Module( (MODULE*) DrawStruct, DC ); exit = true; break; - case TYPEMIRE: + case TYPE_MIRE: Place_Mire( (MIREPCB*) DrawStruct, DC ); exit = true; break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: if( m_ID_current_state == 0 ) { Place_DrawItem( (DRAWSEGMENT*) DrawStruct, DC ); @@ -153,12 +153,12 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) SetCurItem( Create_Mire( DC ) ); DrawPanel->MouseToCursorSchema(); } - else if( DrawStruct->Type() == TYPEMIRE ) + else if( DrawStruct->Type() == TYPE_MIRE ) { Place_Mire( (MIREPCB*) DrawStruct, DC ); } else - DisplayError( this, wxT( "Internal err: Struct not TYPEMIRE" ) ); + DisplayError( this, wxT( "Internal err: Struct not TYPE_MIRE" ) ); break; case ID_PCB_CIRCLE_BUTT: @@ -183,7 +183,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) DrawPanel->m_AutoPAN_Request = TRUE; } else if( DrawStruct - && (DrawStruct->Type() == TYPEDRAWSEGMENT) + && (DrawStruct->Type() == TYPE_DRAWSEGMENT) && (DrawStruct->m_Flags & IS_NEW) ) { DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, DC ); @@ -209,7 +209,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } else if( DrawStruct && -// (DrawStruct->Type() == TYPETRACK) && +// (DrawStruct->Type() == TYPE_TRACK) && (DrawStruct->m_Flags & IS_NEW) ) { TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC ); @@ -230,7 +230,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } } else if( DrawStruct - && (DrawStruct->Type() == TYPEZONE_CONTAINER) + && (DrawStruct->Type() == TYPE_ZONE_CONTAINER) && (DrawStruct->m_Flags & IS_NEW) ) { Begin_Zone( DC ); @@ -248,13 +248,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) DrawPanel->MouseToCursorSchema(); DrawPanel->m_AutoPAN_Request = TRUE; } - else if( DrawStruct->Type() == TYPETEXTE ) + else if( DrawStruct->Type() == TYPE_TEXTE ) { Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC ); DrawPanel->m_AutoPAN_Request = FALSE; } else - DisplayError( this, wxT( "Internal err: Struct not TYPETEXTE" ) ); + DisplayError( this, wxT( "Internal err: Struct not TYPE_TEXTE" ) ); break; case ID_COMPONENT_BUTT: @@ -266,13 +266,13 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) if( DrawStruct ) StartMove_Module( (MODULE*) DrawStruct, DC ); } - else if( DrawStruct->Type() == TYPEMODULE ) + else if( DrawStruct->Type() == TYPE_MODULE ) { Place_Module( (MODULE*) DrawStruct, DC ); DrawPanel->m_AutoPAN_Request = FALSE; } else - DisplayError( this, wxT( "Internal err: Struct not TYPEMODULE" ) ); + DisplayError( this, wxT( "Internal err: Struct not TYPE_MODULE" ) ); break; case ID_PCB_COTATION_BUTT: @@ -288,7 +288,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) DrawPanel->m_AutoPAN_Request = TRUE; } else if( DrawStruct - && (DrawStruct->Type() == TYPECOTATION) + && (DrawStruct->Type() == TYPE_COTATION) && (DrawStruct->m_Flags & IS_NEW) ) { DrawStruct = Begin_Cotation( (COTATION*) DrawStruct, DC ); @@ -358,8 +358,8 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) switch( DrawStruct->Type() ) { - case TYPETRACK: - case TYPEVIA: + case TYPE_TRACK: + case TYPE_VIA: if( DrawStruct->m_Flags & IS_NEW ) { End_Route( (TRACK*) DrawStruct, DC ); @@ -371,36 +371,36 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) } break; - case TYPETEXTE: + case TYPE_TEXTE: InstallTextPCBOptionsFrame( (TEXTE_PCB*) DrawStruct, DC, ( (TEXTE_PCB*) DrawStruct )->m_Pos ); DrawPanel->MouseToCursorSchema(); break; - case TYPEPAD: + case TYPE_PAD: InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; - case TYPEMODULE: + case TYPE_MODULE: InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; - case TYPEMIRE: + case TYPE_MIRE: InstallMireOptionsFrame( (MIREPCB*) DrawStruct, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc, pos ); DrawPanel->MouseToCursorSchema(); break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: break; - case TYPEZONE_CONTAINER: + case TYPE_ZONE_CONTAINER: if( DrawStruct->m_Flags ) break; Edit_Zone_Params( &dc, (ZONE_CONTAINER*) DrawStruct ); @@ -433,7 +433,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) case ID_PCB_CIRCLE_BUTT: if( DrawStruct == NULL ) break; - if( DrawStruct->Type() != TYPEDRAWSEGMENT ) + if( DrawStruct->Type() != TYPE_DRAWSEGMENT ) { DisplayError( this, wxT( "DrawStruct Type error" ) ); DrawPanel->m_AutoPAN_Request = FALSE; diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 7d66709ee6..d5f215168e 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -182,7 +182,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) { switch( item->Type() ) { - case TYPEMODULE: + case TYPE_MODULE: createPopUpMenuForFootprints( (MODULE*) item, aPopMenu ); if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE ) @@ -218,15 +218,15 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) } break; - case TYPEPAD: + case TYPE_PAD: createPopUpMenuForFpPads( (D_PAD*) item, aPopMenu ); break; - case TYPETEXTEMODULE: + case TYPE_TEXTE_MODULE: createPopUpMenuForFpTexts( (TEXTE_MODULE*) item, aPopMenu ); break; - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: if( !flags ) { ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, @@ -243,12 +243,12 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) _( "Delete Drawing" ), delete_xpm ); break; - case TYPEZONE: // Item used to fill a zone + case TYPE_ZONE: // Item used to fill a zone ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_ZONE, _( "Delete Zone Filling" ), delete_xpm ); break; - case TYPEZONE_CONTAINER: // Item used to handle a zone area (outlines, holes ...) + case TYPE_ZONE_CONTAINER: // Item used to handle a zone area (outlines, holes ...) if( flags & IS_NEW ) { ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE, @@ -260,22 +260,22 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) createPopUpMenuForZones( (ZONE_CONTAINER*) item, aPopMenu ); break; - case TYPETEXTE: + case TYPE_TEXTE: createPopUpMenuForTexts( (TEXTE_PCB*) item, aPopMenu ); break; - case TYPETRACK: - case TYPEVIA: + case TYPE_TRACK: + case TYPE_VIA: locate_track = TRUE; createPopupMenuForTracks( (TRACK*) item, aPopMenu ); break; - case TYPEMARKER: + case TYPE_MARKER: ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, _( "Delete Marker" ), delete_xpm ); break; - case TYPECOTATION: + case TYPE_COTATION: if( !flags ) { ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_COTATION, @@ -285,7 +285,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) _( "Delete Dimension" ), delete_xpm ); break; - case TYPEMIRE: + case TYPE_MIRE: if( !flags ) { ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, @@ -297,11 +297,11 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) _( "Delete Target" ), delete_xpm ); break; - case TYPEEDGEMODULE: - case TYPESCREEN: + case TYPE_EDGE_MODULE: + case TYPE_SCREEN: case TYPE_NOT_INIT: - case TYPEPCB: - case PCB_EQUIPOT_STRUCT_TYPE: + case TYPE_PCB: + case TYPE_EQUIPOT: msg.Printf( wxT( "WinEDA_PcbFrame::OnRightClick() Error: illegal DrawType %d" ), item->Type() ); @@ -477,7 +477,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) if( flags == 0 ) { - if( Track->Type() == TYPEVIA ) + if( Track->Type() == TYPE_VIA ) { ADD_MENUITEM( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, _( "Drag Via" ), move_xpm ); wxMenu* via_mnu = new wxMenu(); @@ -564,7 +564,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, ID_POPUP_PCB_EDIT_TRACK_MNU, _( "Change Width" ), width_track_xpm ); ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_TRACKSEG, - Track->Type()==TYPEVIA ? _( "Change Via Size" ) : _( "Change Segment Width" ), width_segment_xpm ); + Track->Type()==TYPE_VIA ? _( "Change Via Size" ) : _( "Change Segment Width" ), width_segment_xpm ); ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_TRACK, _( "Change Track Width" ), width_track_xpm ); @@ -583,7 +583,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu, ID_POPUP_PCB_DELETE_TRACK_MNU, _( "Delete" ), delete_xpm ); - msg = AddHotkeyName( Track->Type()==TYPEVIA ? _( "Delete Via" ) : _( "Delete Segment" ), + msg = AddHotkeyName( Track->Type()==TYPE_VIA ? _( "Delete Via" ) : _( "Delete Segment" ), s_Board_Editor_Hokeys_Descr, HK_BACK_SPACE ); ADD_MENUITEM( track_mnu, ID_POPUP_PCB_DELETE_TRACKSEG, diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index a58f20fd51..155afbaf4a 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -279,11 +279,17 @@ eda_global int g_HightLigth_NetCode #endif ; -/* used in track creation : */ -eda_global TRACK* g_CurrentTrackSegment; // current created segment -eda_global TRACK* g_FirstTrackSegment; // first segment created -eda_global int g_TrackSegmentCount; // New created segment count +/** + * Used in track creation, a list of track segments currently being created, + * with the newest track at the end of the list, sorted by new-ness. e.g. use + * TRACK->Back() to get the next older track, TRACK->Next() to get the next + * newer track. + */ +eda_global DLIST g_CurrentTrackList; + +#define g_CurrentTrackSegment g_CurrentTrackList.GetLast() ///< most recently created segment +#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created eda_global wxString g_ViaType_Name[4] #if defined MAIN diff --git a/pcbnew/pcbtexte.cpp b/pcbnew/pcbtexte.cpp index 3824493b8b..e7e2625751 100644 --- a/pcbnew/pcbtexte.cpp +++ b/pcbnew/pcbtexte.cpp @@ -361,11 +361,7 @@ TEXTE_PCB* WinEDA_PcbFrame::Create_Texte_Pcb( wxDC* DC ) TextePcb = new TEXTE_PCB( m_Pcb ); /* Chainage de la nouvelle structure en debut de liste */ - TextePcb->SetNext( m_Pcb->m_Drawings ); - TextePcb->SetBack( m_Pcb ); - if( m_Pcb->m_Drawings ) - m_Pcb->m_Drawings->SetBack( TextePcb ); - m_Pcb->m_Drawings = TextePcb; + m_Pcb->Add( TextePcb ); /* Mise a jour des caracteristiques */ TextePcb->m_Flags = IS_NEW; diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index f63e3b8923..739e4df570 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -44,23 +44,23 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: PlotDrawSegment( (DRAWSEGMENT*) PtStruct, format_plot, masque_layer ); break; - case TYPETEXTE: + case TYPE_TEXTE: PlotTextePcb( (TEXTE_PCB*) PtStruct, format_plot, masque_layer ); break; - case TYPECOTATION: + case TYPE_COTATION: PlotCotation( (COTATION*) PtStruct, format_plot, masque_layer ); break; - case TYPEMIRE: + case TYPE_MIRE: PlotMirePcb( (MIREPCB*) PtStruct, format_plot, masque_layer ); break; - case TYPEMARKER: + case TYPE_MARKER: break; default: @@ -261,10 +261,10 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( int format_plot, Affiche_1_Parametre( this, 64, wxEmptyString, msg, LIGHTBLUE ); } - pt_texte = (TEXTE_MODULE*) Module->m_Drawings; + pt_texte = (TEXTE_MODULE*) Module->m_Drawings.GetFirst(); for( ; pt_texte != NULL; pt_texte = pt_texte->Next() ) { - if( pt_texte->Type() != TYPETEXTEMODULE ) + if( pt_texte->Type() != TYPE_TEXTE_MODULE ) continue; if( !Sel_Texte_Divers ) @@ -447,10 +447,10 @@ void Plot_Edges_Modules( BOARD* pcb, int format_plot, int masque_layer ) Module = pcb->m_Modules; for( ; Module != NULL; Module = Module->Next() ) { - PtEdge = (EDGE_MODULE*) Module->m_Drawings; + PtEdge = (EDGE_MODULE*) Module->m_Drawings.GetFirst(); for( ; PtEdge != NULL; PtEdge = PtEdge->Next() ) { - if( PtEdge->Type() != TYPEEDGEMODULE ) + if( PtEdge->Type() != TYPE_EDGE_MODULE ) continue; if( (g_TabOneLayerMask[PtEdge->GetLayer()] & masque_layer) == 0 ) continue; @@ -475,7 +475,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) int StAngle, EndAngle; wxPoint pos, end; /* Coord des segments a tracer */ - if( PtEdge->Type() != TYPEEDGEMODULE ) + if( PtEdge->Type() != TYPE_EDGE_MODULE ) return; type_trace = PtEdge->m_Shape; thickness = PtEdge->m_Width; @@ -527,7 +527,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) // which are relative to module position, orientation 0 int ii, * source, * ptr, * ptr_base; MODULE* Module = NULL; - if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPEMODULE) ) + if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) ) Module = (MODULE*) PtEdge->GetParent(); ptr = ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyCount * sizeof(int) ); source = PtEdge->m_PolyList; diff --git a/pcbnew/plotgerb.cpp b/pcbnew/plotgerb.cpp index b5f1166f74..5d796b25d3 100644 --- a/pcbnew/plotgerb.cpp +++ b/pcbnew/plotgerb.cpp @@ -166,27 +166,27 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_GERBER, masque_layer ); break; - case TYPETEXTE: + case TYPE_TEXTE: PlotTextePcb( (TEXTE_PCB*) PtStruct, PLOT_FORMAT_GERBER, masque_layer ); break; - case TYPECOTATION: + case TYPE_COTATION: PlotCotation( (COTATION*) PtStruct, PLOT_FORMAT_GERBER, masque_layer ); break; - case TYPEMIRE: + case TYPE_MIRE: PlotMirePcb( (MIREPCB*) PtStruct, PLOT_FORMAT_GERBER, masque_layer ); break; - case TYPEMARKER: + case TYPE_MARKER: break; default: @@ -206,7 +206,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, { switch( PtStruct->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: if( masque_layer & g_TabOneLayerMask[( (EDGE_MODULE*) PtStruct )->GetLayer()] ) Plot_1_EdgeModule( PLOT_FORMAT_GERBER, (EDGE_MODULE*) PtStruct ); break; @@ -282,7 +282,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, Affiche_1_Parametre( this, 56, wxT( "Vias" ), wxEmptyString, RED ); for( track = m_Pcb->m_Track; track != NULL; track = (TRACK*) track->Next() ) { - if( track->Type() != TYPEVIA ) + if( track->Type() != TYPE_VIA ) continue; SEGVIA* Via = (SEGVIA*) track; @@ -316,7 +316,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_GERBER( FILE* File, int masque_layer, { wxPoint end; - if( track->Type() == TYPEVIA ) + if( track->Type() == TYPE_VIA ) continue; if( (g_TabOneLayerMask[track->GetLayer()] & masque_layer) == 0 ) continue; diff --git a/pcbnew/plothpgl.cpp b/pcbnew/plothpgl.cpp index 1dc6f2772c..c6d07048cc 100644 --- a/pcbnew/plothpgl.cpp +++ b/pcbnew/plothpgl.cpp @@ -215,27 +215,27 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_HPGL, masque_layer ); break; - case TYPETEXTE: + case TYPE_TEXTE: PlotTextePcb( (TEXTE_PCB*) PtStruct, PLOT_FORMAT_HPGL, masque_layer ); break; - case TYPECOTATION: + case TYPE_COTATION: PlotCotation( (COTATION*) PtStruct, PLOT_FORMAT_HPGL, masque_layer ); break; - case TYPEMIRE: + case TYPE_MIRE: PlotMirePcb( (MIREPCB*) PtStruct, PLOT_FORMAT_HPGL, masque_layer ); break; - case TYPEMARKER: + case TYPE_MARKER: break; default: @@ -255,7 +255,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, { switch( PtStruct->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: if( masque_layer & g_TabOneLayerMask[ PtStruct->GetLayer() ] ) Plot_1_EdgeModule( PLOT_FORMAT_HPGL, (EDGE_MODULE*) PtStruct ); @@ -330,7 +330,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { - if( pts->Type() != TYPEVIA ) + if( pts->Type() != TYPE_VIA ) continue; SEGVIA* Via = (SEGVIA*) pts; @@ -362,7 +362,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer, Affiche_1_Parametre( this, 64, wxT( "Tracks " ), wxEmptyString, YELLOW ); for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { - if( pts->Type() == TYPEVIA ) + if( pts->Type() == TYPE_VIA ) continue; if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) == 0 ) diff --git a/pcbnew/plotps.cpp b/pcbnew/plotps.cpp index debd6b62e1..5bbc70c0f2 100644 --- a/pcbnew/plotps.cpp +++ b/pcbnew/plotps.cpp @@ -255,27 +255,27 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, { switch( PtStruct->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: PlotDrawSegment( (DRAWSEGMENT*) PtStruct, PLOT_FORMAT_POST, masque_layer ); break; - case TYPETEXTE: + case TYPE_TEXTE: PlotTextePcb( (TEXTE_PCB*) PtStruct, PLOT_FORMAT_POST, masque_layer ); break; - case TYPECOTATION: + case TYPE_COTATION: PlotCotation( (COTATION*) PtStruct, PLOT_FORMAT_POST, masque_layer ); break; - case TYPEMIRE: + case TYPE_MIRE: PlotMirePcb( (MIREPCB*) PtStruct, PLOT_FORMAT_POST, masque_layer ); break; - case TYPEMARKER: + case TYPE_MARKER: break; default: @@ -296,7 +296,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, { switch( PtStruct->Type() ) { - case TYPEEDGEMODULE: + case TYPE_EDGE_MODULE: if( masque_layer & g_TabOneLayerMask[ PtStruct->GetLayer() ] ) Plot_1_EdgeModule( PLOT_FORMAT_POST, (EDGE_MODULE*) PtStruct ); break; @@ -363,7 +363,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, Affiche_1_Parametre( this, 56, _( "Vias" ), wxEmptyString, RED ); for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { - if( pts->Type() != TYPEVIA ) + if( pts->Type() != TYPE_VIA ) continue; SEGVIA* Via = (SEGVIA*) pts; @@ -393,7 +393,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer, for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) { - if( pts->Type() == TYPEVIA ) + if( pts->Type() == TYPE_VIA ) continue; if( (g_TabOneLayerMask[pts->GetLayer()] & masque_layer) == 0 ) @@ -469,7 +469,7 @@ static void PrintDrillMark( BOARD* Pcb ) for( pts = Pcb->m_Track; pts != NULL; pts = pts->Next() ) { - if( pts->Type() != TYPEVIA ) + if( pts->Type() != TYPE_VIA ) continue; pos = pts->m_Start; if( g_DrillShapeOpt == DRILL_MARK ) diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index 1bf05e9b15..d62f7319b1 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -116,10 +116,10 @@ void WinEDA_BasePcbFrame::Compile_Ratsnest( wxDC* DC, bool display_status_pcb ) MsgPanel->EraseMsgBox(); - msg.Printf( wxT( " %d" ), m_Pcb->m_NbPads ); + msg.Printf( wxT( " %d" ), m_Pcb->m_Pads.size() ); Affiche_1_Parametre( this, 1, wxT( "pads" ), msg, RED ); - msg.Printf( wxT( " %d" ), m_Pcb->m_NbNets ); + msg.Printf( wxT( " %d" ), m_Pcb->m_Equipots.GetCount() ); Affiche_1_Parametre( this, 8, wxT( "Nets" ), msg, CYAN ); reattribution_reference_piste( display_status_pcb ); @@ -423,7 +423,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) * b - Create the ratsnest between blocks: * Test the pads of the 1st block and create a link (ratsnest) * with the nearest pad found in an other block. - * Thi other block is merged with the first block. + * The other block is merged with the first block. * until only one block is left. * * A ratnest can be seen as a logical connection. @@ -437,30 +437,29 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) { LISTE_PAD* pt_liste_pad, * pt_start_liste, * pt_end_liste, * pt_liste_pad_limite; D_PAD* pad; - int ii, num_block, nbpads; + int num_block, nbpads; + int ii; CHEVELU* pt_deb_liste_ch; int current_net_code, noconn; - EQUIPOT* equipot; m_Pcb->m_NbNoconnect = 0; m_Pcb->m_NbLinks = 0; - if( m_Pcb->m_NbPads == 0 ) + if( m_Pcb->m_Pads.size() == 0 ) return; /* Created pad list and the net_codes if needed */ if( (m_Pcb->m_Status_Pcb & NET_CODES_OK) == 0 ) recalcule_pad_net_code(); - pt_liste_pad = m_Pcb->m_Pads; - for( ii = m_Pcb->m_NbPads; ii > 0; pt_liste_pad++, ii-- ) + for( unsigned i=0; im_Pads.size(); ++i ) { - pad = *pt_liste_pad; + pad = m_Pcb->m_Pads[i]; pad->SetSubRatsnest( 0 ); } /* Sort the pad list by nets */ - qsort( m_Pcb->m_Pads, m_Pcb->m_NbPads, sizeof(LISTE_PAD), tri_par_net ); + qsort( &m_Pcb->m_Pads[0], m_Pcb->m_Pads.size(), sizeof(LISTE_PAD), tri_par_net ); /* Allocate memory for buffer ratsnest: there are nb_nodes - 1 ratsnest * maximum ( 1 node = 1 active pad ). @@ -478,16 +477,17 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) if( m_Pcb->m_Ratsnest == NULL ) return; - /* Ratsnest computation */ DisplayRastnestInProgress = TRUE; g_pt_chevelu = m_Pcb->m_Ratsnest; - pt_liste_pad = pt_start_liste = m_Pcb->m_Pads; - pt_liste_pad_limite = pt_start_liste + m_Pcb->m_NbPads; + pt_liste_pad = pt_start_liste = &m_Pcb->m_Pads[0]; + pt_liste_pad_limite = pt_start_liste + m_Pcb->m_Pads.size(); + current_net_code = 1; // 1er net_code a analyser (net_code = 0 -> no connect) - equipot = m_Pcb->m_Equipots; + + EQUIPOT* equipot = m_Pcb->m_Equipots; noconn = 0; for( ; pt_liste_pad < pt_liste_pad_limite; ) @@ -498,7 +498,8 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) /* Skip the not connected pads */ if( pad->GetNet() == 0 ) { - pt_liste_pad++; pt_start_liste = pt_liste_pad; + pt_liste_pad++; + pt_start_liste = pt_liste_pad; continue; } @@ -548,6 +549,7 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) if( equipot ) { equipot->m_RatsnestEnd = g_pt_chevelu; + /* sort by lenght */ qsort( equipot->m_RatsnestStart, equipot->m_RatsnestEnd - equipot->m_RatsnestStart, @@ -566,12 +568,14 @@ void WinEDA_BasePcbFrame::Build_Board_Ratsnest( wxDC* DC ) // erase the ratsnest displayed on screen if needed CHEVELU* Chevelu = (CHEVELU*) m_Pcb->m_Ratsnest; - if ( DC ) GRSetDrawMode( DC, GR_XOR ); + if ( DC ) + GRSetDrawMode( DC, GR_XOR ); for( ii = m_Pcb->GetNumRatsnests(); ii > 0; ii--, Chevelu++ ) { if( !g_Show_Ratsnest ) Chevelu->status &= ~CH_VISIBLE; + if( DC ) GRLine( &DrawPanel->m_ClipBox, DC, Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y, @@ -778,7 +782,7 @@ void WinEDA_BasePcbFrame::Tst_Ratsnest( wxDC* DC, int ref_netcode ) int net_code; EQUIPOT* equipot; - if( m_Pcb->m_NbPads == 0 ) + if( m_Pcb->m_Pads.size() == 0 ) return; for( net_code = 1; ; net_code++ ) @@ -859,21 +863,21 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() */ { LISTE_PAD* pad_ref, * pad_courant; - int ii, jj; - EQUIPOT* pt_equipot; - EDA_BaseStruct* PtStruct; + int ii; EQUIPOT** BufPtEquipot; /* Build the PAD list */ build_liste_pads(); /* calcul des net_codes des pads */ - ii = m_Pcb->m_NbPads; + ii = m_Pcb->m_Pads.size(); + m_Pcb->m_NbNodes = 0; - m_Pcb->m_NbNets = 0; + + int netcode = 0; /* search for differents netnames, and create a netcode for each netname */ - pad_courant = m_Pcb->m_Pads; + pad_courant = &m_Pcb->m_Pads[0]; for( ; ii > 0; pad_courant++, ii-- ) { if( (*pad_courant)->m_Netname.IsEmpty() ) // pad not connected @@ -885,7 +889,7 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() m_Pcb->m_NbNodes++; /* if the current netname was already found: use the current net_code , else create a new net_code */ - pad_ref = m_Pcb->m_Pads; + pad_ref = &m_Pcb->m_Pads[0]; while( pad_ref < pad_courant ) { if( (*pad_ref)->m_Netname == (*pad_courant)->m_Netname ) @@ -900,66 +904,55 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() */ if( pad_ref == pad_courant ) // create a new net_code { - m_Pcb->m_NbNets++; (*pad_courant)->SetNet( m_Pcb->m_NbNets ); + netcode++; + (*pad_courant)->SetNet( netcode ); } else // Use the current net_code for pad_courant (*pad_courant)->SetNet( (*pad_ref)->GetNet() ); } /* Build or update the equipotent list: we reuse the old list */ - BufPtEquipot = (EQUIPOT**) MyMalloc( sizeof(EQUIPOT*) * (m_Pcb->m_NbNets + 1) ); - pt_equipot = m_Pcb->m_Equipots; - PtStruct = (EDA_BaseStruct*) m_Pcb; - for( ii = 0; ii <= m_Pcb->m_NbNets; ii++ ) - { - if( pt_equipot == NULL ) /* Create a new equipot if no more equipot in old list */ - { - pt_equipot = new EQUIPOT( m_Pcb ); + BufPtEquipot = (EQUIPOT**) MyMalloc( sizeof(EQUIPOT*) * (netcode + 1) ); - if( ii == 0 ) - { - m_Pcb->m_Equipots = pt_equipot; - pt_equipot->SetBack( m_Pcb ); - } - else - { - PtStruct->SetNext( pt_equipot ); - pt_equipot->SetBack( PtStruct ); - } - pt_equipot->SetNext( NULL ); + EQUIPOT* equipot = m_Pcb->m_Equipots; + for( ii = 0; ii<= netcode; equipot = equipot->Next(), ++ii ) + { + if( equipot == NULL ) /* Create a new equipot if no more equipot in old list */ + { + equipot = new EQUIPOT( m_Pcb ); + m_Pcb->Add( equipot, ADD_APPEND ); } // Set the net_code for this equipot and reset other values - pt_equipot->SetNet(ii); - pt_equipot->m_NbNodes = 0; - pt_equipot->m_Netname.Empty(); + equipot->SetNet(ii); + equipot->m_NbNodes = 0; + equipot->m_Netname.Empty(); - BufPtEquipot[ii] = pt_equipot; - PtStruct = (EDA_BaseStruct*) pt_equipot; - pt_equipot = pt_equipot->Next(); + BufPtEquipot[ii] = equipot; } /* Delete the unused equipots in the old list */ - - while( pt_equipot ) + while( equipot ) { - PtStruct = pt_equipot->Next(); - pt_equipot->DeleteStructure(); - pt_equipot = (EQUIPOT*) PtStruct; + EQUIPOT* next =equipot->Next(); + equipot->DeleteStructure(); + equipot = next; } - pad_courant = m_Pcb->m_Pads; - pt_equipot = m_Pcb->m_Equipots; + pad_courant = &m_Pcb->m_Pads[0]; + equipot = m_Pcb->m_Equipots; /* Set the equpot net name and node count for each equipot in equipot list */ - for( ii = m_Pcb->m_NbPads; ii > 0; pad_courant++, ii-- ) + for( ii = m_Pcb->m_Pads.size(); ii > 0; pad_courant++, ii-- ) { - jj = (*pad_courant)->GetNet(); - pt_equipot = BufPtEquipot[jj]; - pt_equipot->m_NbNodes++; - if( pt_equipot->m_Netname.IsEmpty() ) + int net = (*pad_courant)->GetNet(); + + equipot = BufPtEquipot[net]; + equipot->m_NbNodes++; + + if( equipot->m_Netname.IsEmpty() ) { - pt_equipot->m_Netname = (*pad_courant)->m_Netname; + equipot->m_Netname = (*pad_courant)->m_Netname; } } @@ -978,65 +971,35 @@ void WinEDA_BasePcbFrame::build_liste_pads() * Create the pad list * initialise: * m_Pcb->m_Pads (list of pads) - * m_Pcb->m_NbPads = pad count * m_Pcb->m_NbNodes = node count * set m_Pcb->m_Status_Pcb = LISTE_PAD_OK; * and clear for all pad their m_SubRatsnest member; * delete ( free memory) m_Pcb->m_Ratsnest and set m_Pcb->m_Ratsnest to NULL */ { - LISTE_PAD* pt_liste_pad; - MODULE* Module; - D_PAD* PtPad; - if( m_Pcb->m_Status_Pcb & LISTE_PAD_OK ) return; - /* delete the old list */ - if( m_Pcb->m_Pads ) - { - MyFree( m_Pcb->m_Pads ); - m_Pcb->m_Pads = NULL; - } + // empty the old list + m_Pcb->m_Pads.clear(); - /* Set the pad count */ - m_Pcb->m_NbPads = 0; - Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = Module->Next() ) - { - PtPad = Module->m_Pads; - for( ; PtPad != NULL; PtPad = PtPad->Next() ) - m_Pcb->m_NbPads++; - } - - if( m_Pcb->m_NbPads == 0 ) - return; - - /* Allocate memory for the pad list */ - pt_liste_pad = m_Pcb->m_Pads - = (D_PAD**) MyZMalloc( (m_Pcb->m_NbPads + 1) * sizeof(D_PAD*) ); m_Pcb->m_NbNodes = 0; /* Clear variables used in rastnest computation */ - Module = m_Pcb->m_Modules; - for( ; Module != NULL; Module = Module->Next() ) + for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) { - PtPad = Module->m_Pads; - for( ; PtPad != NULL; PtPad = PtPad->Next() ) + for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() ) { - *pt_liste_pad = PtPad; - PtPad->SetSubRatsnest( 0 ); - PtPad->SetParent( Module ); + m_Pcb->m_Pads.push_back( pad ); - if( PtPad->GetNet() ) + pad->SetSubRatsnest( 0 ); + pad->SetParent( module ); + + if( pad->GetNet() ) m_Pcb->m_NbNodes++; - - pt_liste_pad++; } } - *pt_liste_pad = NULL; // set end of list - adr_lowmem = buf_work; if( m_Pcb->m_Ratsnest ) @@ -1130,8 +1093,8 @@ char* WinEDA_BasePcbFrame::build_ratsnest_module( wxDC* DC, MODULE* Module ) current_net_code = pad_ref->GetNet(); - pt_liste_generale = m_Pcb->m_Pads; - for( jj = m_Pcb->m_NbPads; jj > 0; jj-- ) + pt_liste_generale = &m_Pcb->m_Pads[0]; + for( jj = m_Pcb->m_Pads.size(); jj > 0; jj-- ) { pad_externe = *pt_liste_generale; pt_liste_generale++; if( pad_externe->GetNet() != current_net_code ) @@ -1410,14 +1373,14 @@ int* WinEDA_BasePcbFrame::build_ratsnest_pad( EDA_BaseStruct* ref, switch( ref->Type() ) { - case TYPEPAD: + case TYPE_PAD: pad_ref = (D_PAD*) ref; current_net_code = pad_ref->GetNet(); conn_number = pad_ref->GetSubNet(); break; - case TYPETRACK: - case TYPEVIA: + case TYPE_TRACK: + case TYPE_VIA: { TRACK* track_ref = (TRACK*) ref; current_net_code = track_ref->GetNet(); @@ -1438,8 +1401,8 @@ int* WinEDA_BasePcbFrame::build_ratsnest_pad( EDA_BaseStruct* ref, if( m_Pcb->m_Ratsnest == NULL ) return NULL; - padlist = m_Pcb->m_Pads; - for( ii = 0; ii < m_Pcb->m_NbPads; padlist++, ii++ ) + padlist = &m_Pcb->m_Pads[0]; + for( ii = 0; ii < (int) m_Pcb->m_Pads.size(); padlist++, ii++ ) { D_PAD* pad = *padlist; if( pad->GetNet() != current_net_code ) diff --git a/pcbnew/router.cpp b/pcbnew/router.cpp index 22dc547f55..34e86c209b 100644 --- a/pcbnew/router.cpp +++ b/pcbnew/router.cpp @@ -87,7 +87,7 @@ void WinEDA_PcbFrame::GlobalRoute( wxDC* DC ) fprintf( outfile, " %d %d", min_layer, max_layer ); - net_number = m_Pcb->m_NbNets; + net_number = m_Pcb->m_Equipots.GetCount(); fprintf( outfile, " %d", net_number ); @@ -154,17 +154,19 @@ void Out_Pads( BOARD* Pcb, FILE* outfile ) LISTE_PAD* pt_liste_pad, * pt_start_liste, * pt_end_liste, * pt_liste_pad_limite; int pin_min_layer, pin_max_layer; - int no_conn = Pcb->m_NbPads + 1;/* valeur incrementee pour indiquer + int no_conn = Pcb->m_Pads.size() + 1;/* valeur incrementee pour indiquer * que le pad n'est pas deja connecte a une piste*/ - pt_liste_pad = pt_start_liste = Pcb->m_Pads; - pt_liste_pad_limite = pt_start_liste + Pcb->m_NbPads; + pt_liste_pad = pt_start_liste = &Pcb->m_Pads[0]; + pt_liste_pad_limite = pt_start_liste + Pcb->m_Pads.size(); if( pt_liste_pad == NULL ) return; netcode = (*pt_liste_pad)->GetNet(); - nb_pads = 1; plink = 0; + nb_pads = 1; + plink = 0; + for( ; pt_liste_pad < pt_liste_pad_limite; ) { /* Recherche de la fin de la liste des pads du net courant */ @@ -301,8 +303,8 @@ void Out_Pads( BOARD* Pcb, FILE* outfile ) if( netcode ) { - GenExistantTracks( Pcb, outfile, netcode, TYPEVIA ); - GenExistantTracks( Pcb, outfile, netcode, TYPETRACK ); + GenExistantTracks( Pcb, outfile, netcode, TYPE_VIA ); + GenExistantTracks( Pcb, outfile, netcode, TYPE_TRACK ); } nb_pads = 1; @@ -336,9 +338,9 @@ void ReturnNbViasAndTracks( BOARD* Pcb, int netcode, int* nb_vias, return; if( track->GetNet() != netcode ) continue; - if( track->Type() == TYPEVIA ) + if( track->Type() == TYPE_VIA ) (*nb_vias)++; - if( track->Type() == TYPETRACK ) + if( track->Type() == TYPE_TRACK ) (*nb_tracks)++; } } @@ -373,7 +375,7 @@ void GenExistantTracks( BOARD* Pcb, FILE* outfile, if( track->Type() != type ) continue; - if( track->Type() == TYPEVIA ) + if( track->Type() == TYPE_VIA ) { via_min_layer &= 15; via_max_layer = (track->GetLayer() >> 4) & 15; @@ -406,7 +408,7 @@ void GenExistantTracks( BOARD* Pcb, FILE* outfile, fprintf( outfile, "q c 0 %d 0 0 0\n", track->m_Width / PSCALE ); } - if( track->Type() == TYPETRACK ) + if( track->Type() == TYPE_TRACK ) { fprintf( outfile, "t 0 %d", track->m_Width / PSCALE ); fprintf( outfile, " %d %d", track->m_Start.x / PSCALE, track->m_Start.y / PSCALE ); @@ -449,7 +451,7 @@ int GenEdges( BOARD* Pcb, FILE* outfile ) /* impression des contours */ for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() != TYPEDRAWSEGMENT ) + if( PtStruct->Type() != TYPE_DRAWSEGMENT ) continue; PtDrawSegment = (DRAWSEGMENT*) PtStruct; @@ -550,8 +552,8 @@ void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC ) wxString FullFileName, msg; int LineNum = 0, NbTrack = 0, NetCode = 0; FILE* File; - TRACK* NewTrack; - SEGVIA* NewVia; + TRACK* newTrack; + SEGVIA* newVia; int track_count, track_layer, image, track_width; int via_layer1, via_layer2, via_size; wxPoint track_start, track_end; @@ -598,17 +600,17 @@ void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC ) via_layer1 = CMP_N; if( via_layer2 == max_layer - 1 ) via_layer2 = CMP_N; - NewVia = new SEGVIA( m_Pcb ); + newVia = new SEGVIA( m_Pcb ); - NewVia->m_Start = NewVia->m_End = track_start; - NewVia->m_Width = via_size; - NewVia->SetLayer( via_layer1 + (via_layer2 << 4) ); - if( NewVia->GetLayer() == 0x0F || NewVia->GetLayer() == 0xF0 ) - NewVia->m_Shape = VIA_THROUGH; + newVia->m_Start = newVia->m_End = track_start; + newVia->m_Width = via_size; + newVia->SetLayer( via_layer1 + (via_layer2 << 4) ); + if( newVia->GetLayer() == 0x0F || newVia->GetLayer() == 0xF0 ) + newVia->m_Shape = VIA_THROUGH; else - NewVia->m_Shape = VIA_BLIND_BURIED; + newVia->m_Shape = VIA_BLIND_BURIED; - NewVia->Insert( m_Pcb, NULL ); + m_Pcb->m_Track.PushFront( newVia ); NbTrack++; break; @@ -630,14 +632,15 @@ void WinEDA_PcbFrame::ReadAutoroutedTracks( wxDC* DC ) else { sscanf( Line + 2, "%d %d", &track_end.x, &track_end.y ); - NewTrack = new TRACK( m_Pcb ); + newTrack = new TRACK( m_Pcb ); - NewTrack->m_Width = track_width; - NewTrack->SetLayer( track_layer ); - NewTrack->m_Start = track_start; - NewTrack->m_End = track_end; + newTrack->m_Width = track_width; + newTrack->SetLayer( track_layer ); + newTrack->m_Start = track_start; + newTrack->m_End = track_end; track_start = track_end; - NewTrack->Insert( m_Pcb, NULL ); + + m_Pcb->m_Track.PushFront( newTrack ); NbTrack++; } } diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index 836f60cd58..28fb396a76 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -424,7 +424,8 @@ static int Route_1_Trace( WinEDA_PcbFrame* pcbframe, wxDC* DC, /* Regenere les barrieres restantes (qui peuvent empieter sur le placement * des bits precedents) */ - ptr = (LISTE_PAD*) pcbframe->m_Pcb->m_Pads; i = pcbframe->m_Pcb->m_NbPads; + ptr = (LISTE_PAD*) &pcbframe->m_Pcb->m_Pads[0]; + i = pcbframe->m_Pcb->m_Pads.size(); for( ; i > 0; i--, ptr++ ) { if( (pt_cur_ch->pad_start != *ptr) && (pt_cur_ch->pad_end != *ptr) ) @@ -744,8 +745,7 @@ static int Retrace( WinEDA_PcbFrame* pcbframe, wxDC* DC, s1 = target_side; r0 = c0 = s0 = ILLEGAL; - g_FirstTrackSegment = g_CurrentTrackSegment = NULL; - g_TrackSegmentCount = 0; + wxASSERT( g_CurrentTrackList.GetCount() == 0 ); do { /* find where we came from to get here */ @@ -908,45 +908,33 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, /* appelle la routine OrCell et place la piste reelle sur le pcb */ { int dx0, dy0, dx1, dy1; - TRACK* NewTrack, * OldTrack; + TRACK* newTrack; - if( orient == HOLE ) /* Placement d'une VIA */ + if( orient == HOLE ) // placement of a via { - NewTrack = new SEGVIA( pcb ); + newTrack = new SEGVIA( pcb ); - g_TrackSegmentCount++; - NewTrack->SetBack( g_CurrentTrackSegment ); - if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->SetNext( NewTrack ); - else - g_FirstTrackSegment = NewTrack; - - g_CurrentTrackSegment = NewTrack; + g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackSegment->SetState( SEGM_AR, ON ); g_CurrentTrackSegment->SetLayer( 0x0F ); - g_CurrentTrackSegment->m_Start.x = g_CurrentTrackSegment->m_End.x = - pcb->m_BoundaryBox.m_Pos.x + - (g_GridRoutingSize * row); - g_CurrentTrackSegment->m_Start.y = g_CurrentTrackSegment->m_End.y = - pcb->m_BoundaryBox.m_Pos.y + - (g_GridRoutingSize * col); + + g_CurrentTrackSegment->m_Start.x = + g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + (g_GridRoutingSize * row); + + g_CurrentTrackSegment->m_Start.y = + g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + (g_GridRoutingSize * col); + g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentViaSize; g_CurrentTrackSegment->m_Shape = g_DesignSettings.m_CurrentViaType; + g_CurrentTrackSegment->SetNet( current_net_code ); } - else /* Placement d'un segment standard */ + else // placement of a standard segment { - NewTrack = new TRACK( pcb ); + newTrack = new TRACK( pcb ); - g_TrackSegmentCount++; - NewTrack->SetBack( g_CurrentTrackSegment ); - if( g_CurrentTrackSegment ) - g_CurrentTrackSegment->SetNext( NewTrack ); - else - g_FirstTrackSegment = NewTrack; - - g_CurrentTrackSegment = NewTrack; + g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackSegment->SetLayer( Route_Layer_BOTTOM ); if( side == TOP ) @@ -965,6 +953,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, /* Replacement sur le centre du pad si hors grille */ dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; + dx0 = pt_cur_ch->pad_end->GetPosition().x - g_CurrentTrackSegment->m_Start.x; dy0 = pt_cur_ch->pad_end->GetPosition().y - g_CurrentTrackSegment->m_Start.y; @@ -973,17 +962,14 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, { g_CurrentTrackSegment->m_Start = pt_cur_ch->pad_end->GetPosition(); } - else /* Creation d'un segment suppl raccord */ + else // Creation of a supplemental segment { - NewTrack = g_CurrentTrackSegment->Copy(); - g_TrackSegmentCount++; - NewTrack->Insert( pcb, g_CurrentTrackSegment ); - g_CurrentTrackSegment->m_Start = pt_cur_ch->pad_end->GetPosition(); - NewTrack->m_Start = g_CurrentTrackSegment->m_End; + newTrack = g_CurrentTrackSegment->Copy(); + newTrack->m_Start = g_CurrentTrackSegment->m_End; - g_CurrentTrackSegment = NewTrack; + g_CurrentTrackList.PushBack( newTrack ); } } else @@ -995,25 +981,24 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, } g_CurrentTrackSegment->m_Width = g_DesignSettings.m_CurrentTrackWidth; - if( (g_CurrentTrackSegment->m_Start.x != g_CurrentTrackSegment->m_End.x) - || (g_CurrentTrackSegment->m_Start.y != g_CurrentTrackSegment->m_End.y) ) + if( g_CurrentTrackSegment->m_Start != g_CurrentTrackSegment->m_End ) { /* Reduction des segments alignes a 1 seul */ - OldTrack = g_CurrentTrackSegment->Back(); - if( OldTrack && (OldTrack->Type() != TYPEVIA) ) + TRACK* oldTrack = g_CurrentTrackSegment->Back(); + if( oldTrack && oldTrack->Type() != TYPE_VIA ) { dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; - dx0 = OldTrack->m_End.x - OldTrack->m_Start.x; - dy0 = OldTrack->m_End.y - OldTrack->m_Start.y; + + dx0 = oldTrack->m_End.x - oldTrack->m_Start.x; + dy0 = oldTrack->m_End.y - oldTrack->m_Start.y; + if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) /* le dernier segment est en ligne*/ { - OldTrack->m_End.x = g_CurrentTrackSegment->m_End.x; - OldTrack->m_End.y = g_CurrentTrackSegment->m_End.y; - delete g_CurrentTrackSegment; - g_CurrentTrackSegment = OldTrack; - g_CurrentTrackSegment->SetNext( NULL ); - g_TrackSegmentCount--; + oldTrack->m_End.x = g_CurrentTrackSegment->m_End.x; + oldTrack->m_End.y = g_CurrentTrackSegment->m_End.y; + + delete g_CurrentTrackList.PopBack(); } } } @@ -1031,7 +1016,6 @@ static void OrCell_Trace( BOARD* pcb, int col, int row, */ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) { - TRACK* pt_track; int dx0, dy0, dx1, dy1; int marge, via_marge; WinEDA_DrawPanel* panel = pcbframe->DrawPanel; @@ -1055,18 +1039,14 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) } else /* Creation d'un segment suppl raccord */ { - TRACK* NewTrack = g_CurrentTrackSegment->Copy(); - NewTrack->Insert( pcbframe->m_Pcb, g_CurrentTrackSegment ); + TRACK* newTrack = g_CurrentTrackSegment->Copy(); - NewTrack->m_End = pt_cur_ch->pad_start->GetPosition(); + newTrack->m_End = pt_cur_ch->pad_start->GetPosition(); + newTrack->m_Start = g_CurrentTrackSegment->m_End; - NewTrack->m_Start = g_CurrentTrackSegment->m_End; - - g_CurrentTrackSegment = NewTrack; - g_TrackSegmentCount++; + g_CurrentTrackList.PushBack( newTrack ); } - g_FirstTrackSegment->start = Locate_Pad_Connecte( pcbframe->m_Pcb, g_FirstTrackSegment, START ); if( g_FirstTrackSegment->start ) g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON ); @@ -1078,17 +1058,15 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) /* recherche de la zone de rangement et insertion de la nouvelle piste */ pcbframe->m_Pcb->Add( g_FirstTrackSegment ); - Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_TrackSegmentCount, GR_OR ); + Trace_Une_Piste( panel, DC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_OR ); pcbframe->test_1_net_connexion( DC, g_FirstTrackSegment->GetNet() ); /* Trace de la forme exacte de la piste en BOARD */ - for( pt_track = g_FirstTrackSegment; ; pt_track = (TRACK*) pt_track->Next() ) + for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() ) { - TraceSegmentPcb( pcbframe->m_Pcb, pt_track, HOLE, marge, WRITE_CELL ); - TraceSegmentPcb( pcbframe->m_Pcb, pt_track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); - if( pt_track == g_CurrentTrackSegment ) - break; + TraceSegmentPcb( pcbframe->m_Pcb, track, HOLE, marge, WRITE_CELL ); + TraceSegmentPcb( pcbframe->m_Pcb, track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL ); } ActiveScreen->SetModify(); diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 8732b41493..302f5850a3 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -133,7 +133,7 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event ) namespace DSN { -const KICAD_T SPECCTRA_DB::scanPADs[] = { TYPEPAD, EOT }; +const KICAD_T SPECCTRA_DB::scanPADs[] = { TYPE_PAD, EOT }; /** @@ -187,7 +187,7 @@ static DRAWSEGMENT* findPoint( const wxPoint& aPoint, TYPE_COLLECTOR* items ) { DRAWSEGMENT* graphic = (DRAWSEGMENT*) (*items)[i]; - wxASSERT( graphic->Type() == TYPEDRAWSEGMENT ); + wxASSERT( graphic->Type() == TYPE_DRAWSEGMENT ); if( aPoint == graphic->GetStart() || aPoint == graphic->GetEnd() ) { @@ -553,7 +553,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) } #if 1 // enable image (outline) scopes. - static const KICAD_T scanEDGEs[] = { TYPEEDGEMODULE, EOT }; + static const KICAD_T scanEDGEs[] = { TYPE_EDGE_MODULE, EOT }; // get all the MODULE's EDGE_MODULEs and convert those to DSN outlines. moduleItems.Collect( aModule, scanEDGEs ); @@ -683,7 +683,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IOErr // get all the DRAWSEGMENTS into 'items', then look for layer == EDGE_N, // and those segments comprise the board's perimeter. - static const KICAD_T scanDRAWSEGMENTS[] = { TYPEDRAWSEGMENT, EOT }; + static const KICAD_T scanDRAWSEGMENTS[] = { TYPE_DRAWSEGMENT, EOT }; items.Collect( aBoard, scanDRAWSEGMENTS ); @@ -693,7 +693,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IOErr { DRAWSEGMENT* item = (DRAWSEGMENT*) items[i]; - wxASSERT( item->Type() == TYPEDRAWSEGMENT ); + wxASSERT( item->Type() == TYPE_DRAWSEGMENT ); if( item->GetLayer() != EDGE_N ) { @@ -847,7 +847,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError ) { TYPE_COLLECTOR items; - static const KICAD_T scanMODULEs[] = { TYPEMODULE, EOT }; + static const KICAD_T scanMODULEs[] = { TYPE_MODULE, EOT }; // Not all boards are exportable. Check that all reference Ids are unique. // Unless they are unique, we cannot import the session file which comes @@ -1024,7 +1024,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError ) //------------------------------------- { - static const KICAD_T scanZONEs[] = { TYPEZONE_CONTAINER, EOT }; + static const KICAD_T scanZONEs[] = { TYPE_ZONE_CONTAINER, EOT }; items.Collect( aBoard, scanZONEs ); for( int i=0; iType() == TYPEVIA ); + wxASSERT( via->Type() == TYPE_VIA ); int netcode = via->GetNet(); if( netcode == 0 ) diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index d54ffc4b02..ff8eff6ec9 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -355,12 +355,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError ) if( !session->route->library ) ThrowIOError( _("Session file is missing the \"library_out\" section") ); -#if 1 // delete all the old tracks and vias - aBoard->m_Track->DeleteStructList(); - aBoard->m_Track = NULL; - aBoard->m_NbSegmTrack = 0; -#endif + aBoard->m_Track.DeleteAll(); aBoard->DeleteMARKERs(); diff --git a/pcbnew/surbrill.cpp b/pcbnew/surbrill.cpp index 4d14eaad7f..3ee6a4a2b8 100644 --- a/pcbnew/surbrill.cpp +++ b/pcbnew/surbrill.cpp @@ -117,22 +117,22 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC ) { switch( item->Type() ) { - case TYPEPAD: + case TYPE_PAD: g_HightLigth_NetCode = ((D_PAD*)item)->GetNet(); Hight_Light( DC ); SendMessageToEESCHEMA( item ); return g_HightLigth_NetCode; - case TYPETRACK: - case TYPEVIA: - case TYPEZONE: + case TYPE_TRACK: + case TYPE_VIA: + case TYPE_ZONE: // since these classes are all derived from TRACK, use a common // GetNet() function: g_HightLigth_NetCode = ((TRACK*)item)->GetNet(); Hight_Light( DC ); return g_HightLigth_NetCode; - case TYPEZONE_CONTAINER: + case TYPE_ZONE_CONTAINER: g_HightLigth_NetCode = ((ZONE_CONTAINER*)item)->GetNet(); Hight_Light( DC ); return g_HightLigth_NetCode; diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp index fd32f1b93d..8cdb25d542 100644 --- a/pcbnew/swap_layers.cpp +++ b/pcbnew/swap_layers.cpp @@ -336,7 +336,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) for( ; pt_segm != NULL; pt_segm = pt_segm->Next() ) { GetScreen()->SetModify(); - if( pt_segm->Type() == TYPEVIA ) + if( pt_segm->Type() == TYPE_VIA ) { SEGVIA* Via = (SEGVIA*) pt_segm; if( Via->Shape() == VIA_THROUGH ) @@ -370,7 +370,7 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) PtStruct = m_Pcb->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Next() ) { - if( PtStruct->Type() == TYPEDRAWSEGMENT ) + if( PtStruct->Type() == TYPE_DRAWSEGMENT ) { GetScreen()->SetModify(); pt_drawsegm = (DRAWSEGMENT*) PtStruct; diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp index 088d8e104d..d1d6bff321 100644 --- a/pcbnew/tr_modif.cpp +++ b/pcbnew/tr_modif.cpp @@ -26,9 +26,8 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, { TRACK* StartTrack, * EndTrack;/* Pointeurs des segments de debut et fin * (extremites) de la nouvelle piste */ - TRACK* EndNewTrack, /* Pointeur sur le dernier segment de la liste - * chainee de la mouvelle piste */ - * pt_segm, * pt_del; + TRACK* pt_segm; + TRACK* pt_del; int ii, jj, nb_segm, nbconnect; wxPoint start; /* coord du point de depart de la piste */ wxPoint end; /* coord du point de fin de la piste */ @@ -36,8 +35,12 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, TRACK* BufDeb, * BufEnd; /* Pointeurs de debut et de fin de la zone * des pistes equipotentielles */ + int netcode = pt_new_track->GetNet(); + + /* Reconstitution de la piste complete ( la nouvelle piste - * a pu demarrer sur un segment de piste en l'air */ + * a pu demarrer sur un segment de piste en l'air + */ ListSetState( pt_new_track, nbptnewpiste, BUSY, OFF ); @@ -45,29 +48,43 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, * la piste complete en utilisant le segment suivant comme reference, car * une via est souvent sur un carrefour de segments, et ne caracterise pas * une piste */ - if( pt_new_track->Type() == TYPEVIA && (nbptnewpiste > 1 ) ) + if( pt_new_track->Type() == TYPE_VIA && (nbptnewpiste > 1 ) ) pt_new_track = pt_new_track->Next(); + pt_new_track = Marque_Une_Piste( frame, DC, pt_new_track, &nbptnewpiste, 0 ); + wxASSERT( pt_new_track ); + +#if 0 && defined(DEBUG) + TRACK* EndNewTrack; /* Pointeur sur le dernier segment de la liste + * chainee de la mouvelle piste */ EndNewTrack = pt_new_track; for( ii = 1; ii < nbptnewpiste; ii++ ) { + wxASSERT( EndNewTrack->GetState(-1) != 0 ); + D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );) EndNewTrack = EndNewTrack->Next(); } + wxASSERT( EndNewTrack->GetState(-1) != 0 ); + D(printf("track %p is newly part of net %d\n", EndNewTrack, netcode );) + + for( TRACK* track = Pcb->m_Track; track; track = track->Next() ) + track->Show( 0, std::cout ); +#endif + /* Calcul des limites de recherche des segments de piste */ /* BufDeb pointe le 1er segment utile */ - BufDeb = Pcb->m_Track->GetStartNetCode( pt_new_track->GetNet() ); + BufDeb = Pcb->m_Track->GetStartNetCode( netcode ); /* BufEnd Pointe le dernier segment */ - BufEnd = BufDeb->GetEndNetCode( pt_new_track->GetNet() ); + BufEnd = BufDeb->GetEndNetCode( netcode ); /* nettoyage des flags pour tout le net */ - for( pt_del = BufDeb; pt_del != NULL; pt_del = pt_del->Next() ) + for( pt_del = BufDeb; pt_del && pt_del != BufEnd; pt_del = pt_del->Next() ) { + D(printf("track %p turning off BUSY | EDIT | CHAIN\n", pt_del );) pt_del->SetState( BUSY | EDIT | CHAIN, OFF ); - if( pt_del == BufEnd ) - break; } /* Calcul des points limites de la nouvelle piste */ @@ -89,12 +106,15 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, /* Determinations des couches interconnectees a ces points */ startmasklayer = StartTrack->ReturnMaskLayer(); endmasklayer = EndTrack->ReturnMaskLayer(); + /* Il peut y avoir une via ou un pad sur les extremites: */ pt_segm = Fast_Locate_Via( Pcb->m_Track, NULL, start, startmasklayer ); if( pt_segm ) startmasklayer |= pt_segm->ReturnMaskLayer(); - if( StartTrack->start && (StartTrack->start->Type() == TYPEPAD) ) - { /* start sur pad */ + + if( StartTrack->start && (StartTrack->start->Type() == TYPE_PAD) ) + { + /* start sur pad */ D_PAD* pt_pad = (D_PAD*) (StartTrack->start); startmasklayer |= pt_pad->m_Masque_Layer; } @@ -102,18 +122,21 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, pt_segm = Fast_Locate_Via( Pcb->m_Track, NULL, end, endmasklayer ); if( pt_segm ) endmasklayer |= pt_segm->ReturnMaskLayer(); - if( EndTrack->end && ( EndTrack->end->Type() == TYPEPAD) ) + + if( EndTrack->end && ( EndTrack->end->Type() == TYPE_PAD) ) { D_PAD* pt_pad = (D_PAD*) (EndTrack->end); endmasklayer |= pt_pad->m_Masque_Layer; } /* Marquage a DELETED de la piste nouvelle (qui ne doit pas intervenir - * dans la recherche d'autres connexions) */ + * dans la recherche d'autres connexions) + */ ListSetState( pt_new_track, nbptnewpiste, DELETED, ON ); /* test : un segment doit etre connecte au point de depart car sinon - * il est inutile d'analyser l'autre point */ + * il est inutile d'analyser l'autre point + */ pt_segm = Fast_Locate_Piste( BufDeb, BufEnd, start, startmasklayer ); @@ -133,8 +156,9 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, if( pt_segm == NULL ) break; - if( pt_segm->Type() != TYPEVIA ) - { /* Segment trouve */ + if( pt_segm->Type() != TYPE_VIA ) + { + /* Segment trouve */ if( pt_segm->GetState( CHAIN ) == 0 ) { pt_segm->SetState( CHAIN, ON ); @@ -143,17 +167,16 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, } if( pt_del == BufEnd ) break; + pt_del = pt_segm->Next(); } if( nbconnect == 0 ) { /* nettoyage des flags */ - for( pt_del = BufDeb; pt_del != NULL; pt_del = pt_del->Next() ) + for( pt_del = BufDeb; pt_del && pt_del != BufEnd; pt_del = pt_del->Next() ) { pt_del->SetState( DELETED | EDIT | CHAIN, OFF ); - if( pt_del == BufEnd ) - break; } return 0; @@ -168,30 +191,33 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, /* Examen de tous les segments marques */ while( nbconnect ) { - for( pt_del = BufDeb; pt_del != NULL; pt_del = pt_del->Next() ) + for( pt_del = BufDeb; pt_del && pt_del != BufEnd; pt_del = pt_del->Next() ) { if( pt_del->GetState( CHAIN ) ) break; - if( pt_del == BufEnd ) - break; } - nbconnect--; pt_del->SetState( CHAIN, OFF ); + nbconnect--; + pt_del->SetState( CHAIN, OFF ); + pt_del = Marque_Une_Piste( frame, DC, pt_del, &nb_segm, 0 ); /* Test si La piste marquee est redondante, c'est a dire si l'un des - * segments marques est connecte au point de depart de la piste nouvelle + * segments marques est connecte au point de depart de la piste nouvelle */ - ii = 0; pt_segm = pt_del; + ii = 0; + pt_segm = pt_del; for( ; pt_segm && (ii < nb_segm); pt_segm = pt_segm->Next(), ii++ ) { - if( ( pt_segm->GetState( BUSY ) ) == 0 ) + if( pt_segm->GetState( BUSY ) == 0 ) break; - if( (pt_segm->m_Start == start) || (pt_segm->m_End == start) ) - { /* la piste marquee peut etre effacee */ + if( pt_segm->m_Start == start || pt_segm->m_End == start ) + { + /* la piste marquee peut etre effacee */ TRACK* NextS; Trace_Une_Piste( frame->DrawPanel, DC, pt_del, nb_segm, GR_XOR | GR_SURBRILL ); + for( jj = 0; jj < nb_segm; jj++, pt_del = NextS ) { NextS = pt_del->Next(); @@ -219,11 +245,9 @@ int EraseOldTrack( WinEDA_BasePcbFrame* frame, BOARD* Pcb, wxDC* DC, } /* nettoyage des flags */ - for( pt_del = Pcb->m_Track; pt_del != NULL; pt_del = pt_del->Next() ) + for( pt_del = Pcb->m_Track; pt_del && pt_del != BufEnd; pt_del = pt_del->Next() ) { pt_del->SetState( DELETED | EDIT | CHAIN, OFF ); - if( pt_del == BufEnd ) - break; } return 0; diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index eeacdcdab3..8a48674363 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -144,10 +144,10 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, switch( item->Type() ) { - case TYPECOTATION: - case TYPETEXTE: - case TYPEMIRE: - case TYPEDRAWSEGMENT: + case TYPE_COTATION: + case TYPE_TEXTE: + case TYPE_MIRE: + case TYPE_DRAWSEGMENT: item->Draw( aPanel, DC, aDrawMode ); break; diff --git a/pcbnew/track.cpp b/pcbnew/track.cpp index d6dcf33d76..0632277b21 100644 --- a/pcbnew/track.cpp +++ b/pcbnew/track.cpp @@ -10,33 +10,19 @@ #include "protos.h" -class TSTSEGM /* memorisation des segments marques */ -{ -public: - TSTSEGM* Pnext, * Pback; - TRACK* RefTrack; -public: - TSTSEGM( TRACK * Father ) { - Pback = Pnext = NULL; - RefTrack = Father; - } -}; +typedef std::vector TRACK_PTRS; + /* Routines externes : */ void Montre_Position_New_Piste( int flag );/* defini dans editrack.cc */ /* Routines Locales */ -static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masklayer ); +static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masklayer, TRACK_PTRS* aList ); /* Variables locales */ -TSTSEGM* ListSegm = NULL; -/****************************************************************************/ -TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, - TRACK* pt_segm, int* nb_segm, int flagcolor ) -/****************************************************************************/ /* Routine de Marquage de 1 piste, a partir du segment pointe par pt_segm. * le segment pointe est marque puis les segments connectes @@ -47,144 +33,163 @@ TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, * adresse du 1er segment de la chaine creee * nombre de segments */ + +/** + * Function Marque_Une_Piste + * marks a chain of track segments, starting at aTrackList. + * Each segment is marked by setting the BUSY bit into m_Flags. Electrical continuity + * is detected by walking each segment, and finally the segments are rearranged + * into a contiguous chain within the given list. + * @param aTrackList The first interesting segment within a list of many + * interesting and uninteresting segments. + * @return TRACK* the first in the chain of interesting segments. + */ +TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC, + TRACK* aTrackList, int* nb_segm, int flagcolor ) { - int NbSegmBusy, masque_layer; - TRACK* Track, * FirstTrack, * NextTrack; - TSTSEGM* Segm, * NextSegm; + int NbSegmBusy; + + TRACK_PTRS trackList; *nb_segm = 0; - if( pt_segm == NULL ) + if( aTrackList == NULL ) return NULL; /* Marquage du segment pointe */ if( flagcolor ) - pt_segm->Draw( frame->DrawPanel, DC, flagcolor ); + aTrackList->Draw( frame->DrawPanel, DC, flagcolor ); - pt_segm->SetState( BUSY, ON ); - masque_layer = pt_segm->ReturnMaskLayer(); - ListSegm = new TSTSEGM( pt_segm ); + aTrackList->SetState( BUSY, ON ); + int masque_layer = aTrackList->ReturnMaskLayer(); + + trackList.push_back( aTrackList ); /* Traitement du segment pointe : si c'est un segment, le cas est simple. * Si c'est une via, on doit examiner le nombre de segments connectes. * Si <=2, on doit detecter une piste, si > 2 seule la via est marquee */ - if( pt_segm->Type() == TYPEVIA ) + if( aTrackList->Type() == TYPE_VIA ) { TRACK* Segm1, * Segm2 = NULL, * Segm3 = NULL; Segm1 = Fast_Locate_Piste( frame->m_Pcb->m_Track, NULL, - pt_segm->m_Start, masque_layer ); + aTrackList->m_Start, masque_layer ); if( Segm1 ) { Segm2 = Fast_Locate_Piste( Segm1->Next(), NULL, - pt_segm->m_Start, masque_layer ); + aTrackList->m_Start, masque_layer ); } if( Segm2 ) { Segm3 = Fast_Locate_Piste( Segm2->Next(), NULL, - pt_segm->m_Start, masque_layer ); + aTrackList->m_Start, masque_layer ); } if( Segm3 ) { - *nb_segm = 1; return pt_segm; + *nb_segm = 1; + return aTrackList; } if( Segm1 ) { masque_layer = Segm1->ReturnMaskLayer(); - Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_Start, masque_layer ); + Marque_Chaine_segments( frame->m_Pcb, aTrackList->m_Start, masque_layer, &trackList ); } if( Segm2 ) { masque_layer = Segm2->ReturnMaskLayer(); - Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_Start, masque_layer ); + Marque_Chaine_segments( frame->m_Pcb, aTrackList->m_Start, masque_layer, &trackList ); } } - else /* Marquage de la chaine connectee aux extremites du segment */ + + else // mark the chain using both ends of the initial segment { - Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_Start, masque_layer ); - Marque_Chaine_segments( frame->m_Pcb, pt_segm->m_End, masque_layer ); + Marque_Chaine_segments( frame->m_Pcb, aTrackList->m_Start, masque_layer, &trackList ); + Marque_Chaine_segments( frame->m_Pcb, aTrackList->m_End, masque_layer, &trackList ); } - /* marquage des vias (vias non connectees ou inutiles */ - for( Segm = ListSegm; Segm != NULL; Segm = Segm->Pnext ) + // marquage des vias (vias non connectees ou inutiles + // go through the list backwards. + for( int i = trackList.size()-1; i>=0; --i ) { - int layer; - if( Segm->RefTrack->Type() != TYPEVIA ) + TRACK* via = trackList[i]; + + if( via->Type() != TYPE_VIA ) continue; - if( Segm->RefTrack == pt_segm ) + if( via == aTrackList ) continue; - Segm->RefTrack->SetState( BUSY, ON ); + via->SetState( BUSY, ON ); - masque_layer = Segm->RefTrack->ReturnMaskLayer(); + masque_layer = via->ReturnMaskLayer(); - Track = Fast_Locate_Piste( frame->m_Pcb->m_Track, NULL, - Segm->RefTrack->m_Start, - masque_layer ); - if( Track == NULL ) + TRACK* track = Fast_Locate_Piste( frame->m_Pcb->m_Track, + NULL, via->m_Start, masque_layer ); + if( track == NULL ) continue; /* Test des connexions: si via utile: suppression marquage */ - layer = Track->GetLayer(); + int layer = track->GetLayer(); - while( ( Track = Fast_Locate_Piste( (TRACK*) Track->Next(), NULL, - Segm->RefTrack->m_Start, - masque_layer ) ) != NULL ) + while( ( track = Fast_Locate_Piste( track->Next(), NULL, + via->m_Start, masque_layer ) ) != NULL ) { - if( layer != Track->GetLayer() ) + if( layer != track->GetLayer() ) { - Segm->RefTrack->SetState( BUSY, OFF ); + via->SetState( BUSY, OFF ); break; } } } - /* liberation memoire */ - for( Segm = ListSegm; Segm != NULL; Segm = NextSegm ) - { - NextSegm = Segm->Pnext; - delete Segm; - } - - ListSegm = NULL; - /* Reclassement des segments marques en une chaine */ - FirstTrack = frame->m_Pcb->m_Track; NbSegmBusy = 0; - for( ; FirstTrack != NULL; FirstTrack = (TRACK*) FirstTrack->Next() ) + NbSegmBusy = 0; + TRACK* firstTrack; + for( firstTrack = frame->m_Pcb->m_Track; firstTrack; firstTrack = firstTrack->Next() ) { - /* recherche du debut de la liste des segments marques a BUSY */ - if( FirstTrack->GetState( BUSY ) ) + // recherche du debut de la liste des segments marques a BUSY + if( firstTrack->GetState( BUSY ) ) { NbSegmBusy = 1; break; } } - /* Reclassement de la chaine debutant a FirstTrack et finissant - * au dernier segment marque. FirstTrack n'est pas modifie */ - Track = (TRACK*) FirstTrack->Next(); - for( ; Track != NULL; Track = NextTrack ) + wxASSERT( firstTrack ); + + if( firstTrack ) { - NextTrack = (TRACK*) Track->Next(); - if( Track->GetState( BUSY ) ) + DLIST* list = (DLIST*)firstTrack->GetList(); + wxASSERT(list); + + /* Reclassement de la chaine debutant a FirstTrack et finissant + * au dernier segment marque. FirstTrack n'est pas modifie + */ + TRACK* next; + for( TRACK* track = firstTrack->Next(); track; track = next ) { - NbSegmBusy++; - Track->UnLink(); - Track->Insert( frame->m_Pcb, FirstTrack ); + next = track->Next(); + if( track->GetState( BUSY ) ) + { + NbSegmBusy++; + + track->UnLink(); + + list->Insert( track, firstTrack->Next() ); + } } } *nb_segm = NbSegmBusy; if( flagcolor ) - Trace_Une_Piste( frame->DrawPanel, DC, FirstTrack, NbSegmBusy, flagcolor ); + Trace_Une_Piste( frame->DrawPanel, DC, firstTrack, NbSegmBusy, flagcolor ); - return FirstTrack; + return firstTrack; } /********************************************************************************/ -static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_layer ) +static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_layer, TRACK_PTRS* aList ) /********************************************************************************/ /* @@ -200,7 +205,6 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye * pt_via, // pointe la via reperee, eventuellement a detruire * MarqSegm; // pointe le segment a detruire (= NULL ou pt_segm int NbSegm; - TSTSEGM* Segm; if( Pcb->m_Track == NULL ) return; @@ -217,12 +221,10 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye { if( pt_via->GetState( EDIT ) ) return; - masque_layer = pt_via->ReturnMaskLayer(); - Segm = new TSTSEGM( pt_via ); - Segm->Pnext = ListSegm; - ListSegm->Pback = Segm; - ListSegm = Segm; + masque_layer = pt_via->ReturnMaskLayer(); + + aList->push_back( pt_via ); } /* Recherche des segments connectes au point ref_pos @@ -240,13 +242,13 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye if( pt_segm->GetState( BUSY ) ) { - pt_segm = (TRACK*) pt_segm->Next(); + pt_segm = pt_segm->Next(); continue; } if( pt_segm == pt_via ) /* deja traite */ { - pt_segm = (TRACK*) pt_segm->Next(); + pt_segm = pt_segm->Next(); continue; } @@ -254,7 +256,7 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye if( NbSegm == 1 ) /* 1ere detection de segment de piste */ { MarqSegm = pt_segm; - pt_segm = (TRACK*) pt_segm->Next(); + pt_segm = pt_segm->Next(); } else /* 2eme detection de segment -> fin de piste */ { @@ -266,6 +268,7 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye { /* preparation de la nouvelle recherche */ masque_layer = MarqSegm->ReturnMaskLayer(); + if( ref_pos == MarqSegm->m_Start ) { ref_pos = MarqSegm->m_End; @@ -278,11 +281,7 @@ static void Marque_Chaine_segments( BOARD* Pcb, wxPoint ref_pos, int masque_laye pt_segm = Pcb->m_Track; /* reinit recherche des segments */ /* Marquage et mise en liste du segment */ - Segm = new TSTSEGM( MarqSegm ); - - Segm->Pnext = ListSegm; - ListSegm->Pback = Segm; - ListSegm = Segm; + aList->push_back( MarqSegm ); MarqSegm->SetState( BUSY, ON ); } else @@ -316,7 +315,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, /* calcul de la limite d'analyse */ *StartTrack = *EndTrack = NULL; TrackListEnd = Track = RefTrack; ii = 0; - for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Next() ) + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = Track->Next() ) { TrackListEnd = Track; Track->m_Param = 0; @@ -324,9 +323,9 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, /* Calcul des extremites */ NbEnds = 0; Track = RefTrack; ii = 0; - for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = (TRACK*) Track->Next() ) + for( ; (Track != NULL) && (ii < NbSegm); ii++, Track = Track->Next() ) { - if( Track->Type() == TYPEVIA ) + if( Track->Type() == TYPE_VIA ) continue; masque_layer = Track->ReturnMaskLayer(); @@ -356,17 +355,22 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, case 1: int BeginPad, EndPad; *EndTrack = Track; + /* permutation de ox,oy avec fx,fy */ BeginPad = Track->GetState( BEGIN_ONPAD ); EndPad = Track->GetState( END_ONPAD ); + Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); + if( BeginPad ) Track->SetState( END_ONPAD, ON ); if( EndPad ) Track->SetState( BEGIN_ONPAD, ON ); + EXCHG( Track->m_Start, Track->m_End ); EXCHG( Track->start, Track->end ); - ok = 1; return ok; + ok = 1; + return ok; } } @@ -391,22 +395,28 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, { case 0: int BeginPad, EndPad; - *StartTrack = Track; NbEnds++; + *StartTrack = Track; + NbEnds++; + /* permutation de ox,oy avec fx,fy */ BeginPad = Track->GetState( BEGIN_ONPAD ); EndPad = Track->GetState( END_ONPAD ); + Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF ); + if( BeginPad ) Track->SetState( END_ONPAD, ON ); if( EndPad ) Track->SetState( BEGIN_ONPAD, ON ); + EXCHG( Track->m_Start, Track->m_End ); EXCHG( Track->start, Track->end ); break; case 1: *EndTrack = Track; - ok = 1; return ok; + ok = 1; + return ok; } } } @@ -424,6 +434,7 @@ void ListSetState( EDA_BaseStruct* Start, int NbItem, int State, int onoff ) { if( Start == NULL ) return; + for( ; (Start != NULL) && (NbItem > 0); NbItem--, Start = Start->Next() ) { Start->SetState( State, onoff ); diff --git a/pcbnew/trpiste.cpp b/pcbnew/trpiste.cpp index 0211ba702f..1404e65263 100644 --- a/pcbnew/trpiste.cpp +++ b/pcbnew/trpiste.cpp @@ -15,7 +15,7 @@ /************************************************************************/ -void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track, +void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* aTrackList, int nbsegment, int draw_mode ) /************************************************************************/ @@ -31,10 +31,10 @@ void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track, * donc mis a 0 avant appel a la routine si la piste a tracer est la derniere */ { - for( ; nbsegment > 0 && Track; nbsegment--, Track = Track->Next() ) + // preserve the start of the list for debugging. + for( TRACK* track = aTrackList; nbsegment > 0 && track; nbsegment--, track = track->Next() ) { - Track->Draw( panel, DC, draw_mode ); + track->Draw( panel, DC, draw_mode ); } } - diff --git a/pcbnew/undelete.cpp b/pcbnew/undelete.cpp index 80b96b852c..5e064a89ee 100644 --- a/pcbnew/undelete.cpp +++ b/pcbnew/undelete.cpp @@ -22,8 +22,7 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) */ { BOARD_ITEM* item; - BOARD_ITEM* next; - int net_code; + int net_code = 0; if( !g_UnDeleteStackPtr ) return; @@ -35,37 +34,53 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) switch( item->Type() ) { - case TYPEVIA: - case TYPETRACK: - for( ; item; item = next ) - { - next = item->Next(); - item->SetState( DELETED, OFF ); /* Effacement du bit DELETED */ - ((TRACK*) item)->Draw( DrawPanel, DC, GR_OR ); - } + case TYPE_VIA: + case TYPE_TRACK: + TRACK* track; + track = (TRACK*) item; - item = g_UnDeleteStack[g_UnDeleteStackPtr]; - net_code = ((TRACK*) item)->GetNet(); + D(printf("%s: track %p status=\"%s\"\n", __func__, track, + CONV_TO_UTF8( TRACK::ShowState( track->GetState(-1)) ) + );) - m_Pcb->Add( item ); + track->SetState( DELETED, OFF ); + DrawPanel->PostDirtyRect( track->GetBoundingBox() ); + m_Pcb->Add( track ); + + net_code = track->GetNet(); g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; - test_1_net_connexion( DC, net_code ); m_Pcb->Display_Infos( this ); break; - case TYPEMODULE: + case TYPE_BOARD_ITEM_LIST: + BOARD_ITEM_LIST* list; + list = (BOARD_ITEM_LIST*) item; + while( list->GetCount() ) + { + TRACK* t = (TRACK*) list->Remove( 0 ); + wxASSERT( t->Type()==TYPE_TRACK || t->Type()==TYPE_VIA ); + t->SetState( DELETED, OFF ); + DrawPanel->PostDirtyRect( t->GetBoundingBox() ); + m_Pcb->Add( t ); + net_code = t->GetNet(); + } + delete list; + g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; + test_1_net_connexion( DC, net_code ); + m_Pcb->Display_Infos( this ); + break; + + case TYPE_MODULE: /* Erase general rastnest if needed */ if( g_Show_Ratsnest ) DrawGeneralRatsnest( DC ); - /* Reinsertion du module dans la liste chainee des modules, - * en debut de chaine */ m_Pcb->Add( item ); g_UnDeleteStack[g_UnDeleteStackPtr] = NULL; - ((MODULE*) item)->Draw( DrawPanel, DC, GR_OR ); + item->Draw( DrawPanel, DC, GR_OR ); item->SetState( DELETED, OFF ); /* Creal DELETED flag */ item->m_Flags = 0; @@ -81,26 +96,20 @@ void WinEDA_PcbFrame::UnDeleteItem( wxDC* DC ) } -/**************************************************************/ -/* void * SaveItemEfface(int type, void * PtItem, int nbitems) */ -/**************************************************************/ - /* Sauvegarde d'un element aux fins de restitution par Undelete * Supporte actuellement : Module et segments de piste */ -BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) +BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* aItem, int nbitems ) { - BOARD_ITEM* NextS, * PtStruct = PtItem; - int ii; - - if( (PtItem == NULL) || (nbitems == 0) ) + if( aItem == NULL || nbitems == 0 ) return NULL; if( g_UnDeleteStackPtr >= UNDELETE_STACK_SIZE ) { - /* Delete last deleted item, and shift stack. */ - g_UnDeleteStack[0]->DeleteStructList(); - for( ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ ) + // Delete last deleted item, and shift stack. + delete g_UnDeleteStack[0]; + + for( int ii = 0; ii < (g_UnDeleteStackPtr - 1); ii++ ) { g_UnDeleteStack[ii] = g_UnDeleteStack[ii + 1]; } @@ -108,40 +117,43 @@ BOARD_ITEM* WinEDA_PcbFrame::SaveItemEfface( BOARD_ITEM* PtItem, int nbitems ) g_UnDeleteStackPtr--;; } - switch( PtStruct->Type() ) + switch( aItem->Type() ) { - case TYPEVIA: - case TYPETRACK: - { - BOARD_ITEM* Back = NULL; - g_UnDeleteStack[g_UnDeleteStackPtr++] = PtStruct; - - for( ; nbitems > 0; nbitems--, PtStruct = NextS ) + case TYPE_VIA: + case TYPE_TRACK: { - NextS = PtStruct->Next(); - ( (TRACK*) PtStruct )->UnLink(); + DLIST* container = (DLIST*) aItem->GetList(); + wxASSERT( container ); - PtStruct->SetState( DELETED, ON ); - if( nbitems <= 1 ) - NextS = NULL; /* fin de chaine */ + if( nbitems == 1 ) + { + container->Remove( (TRACK*) aItem ); + g_UnDeleteStack[g_UnDeleteStackPtr++] = aItem; + } + else + { + BOARD_ITEM_LIST* list = new BOARD_ITEM_LIST(); + g_UnDeleteStack[g_UnDeleteStackPtr++] = list; - PtStruct->SetNext( NextS ); - PtStruct->SetBack( Back ); - Back = PtStruct; - if( NextS == NULL ) - break; + int i = 0; + TRACK* next; + for( TRACK* track = (TRACK*) aItem; track && iNext(); + list->PushBack( container->Remove( track ) ); + } + } } - } break; - case TYPEMODULE: - { - MODULE* Module = (MODULE*) PtItem; - Module->UnLink(); - Module->SetState( DELETED, ON ); - g_UnDeleteStack[g_UnDeleteStackPtr++] = Module; - build_liste_pads(); - } + case TYPE_MODULE: + { + MODULE* module = (MODULE*) aItem; + m_Pcb->m_Modules.Remove( module ); + module->SetState( DELETED, ON ); + g_UnDeleteStack[g_UnDeleteStackPtr++] = module; + build_liste_pads(); + } break; default: diff --git a/pcbnew/via_edit.cpp b/pcbnew/via_edit.cpp index 3207d77b8f..490750889d 100644 --- a/pcbnew/via_edit.cpp +++ b/pcbnew/via_edit.cpp @@ -66,7 +66,7 @@ void WinEDA_PcbFrame::Via_Edit_Control( wxDC* DC, int command_type, SEGVIA* via via_struct = m_Pcb->m_Track; for( ; via_struct != NULL; via_struct = via_struct->Next() ) { - if( via_struct->Type() == TYPEVIA ) /* mise a jour du diametre de la via */ + if( via_struct->Type() == TYPE_VIA ) /* mise a jour du diametre de la via */ { if( via_struct->m_Width != via->m_Width ) continue; @@ -90,7 +90,7 @@ void WinEDA_PcbFrame::Via_Edit_Control( wxDC* DC, int command_type, SEGVIA* via via_struct = m_Pcb->m_Track; for( ; via_struct != NULL; via_struct = via_struct->Next() ) { - if( via_struct->Type() == TYPEVIA ) /* mise a jour du diametre de la via */ + if( via_struct->Type() == TYPE_VIA ) /* mise a jour du diametre de la via */ { if( ! via_struct->IsDrillDefault() ) { diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index d92e375dd3..b267f3057f 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -519,7 +519,7 @@ MODULE* WinEDA_BasePcbFrame::Exchange_Module( wxWindow* winaff, D_PAD* pt_pad, * pt_old_pad; - if( (OldModule->Type() != TYPEMODULE) || (NewModule->Type() != TYPEMODULE) ) + if( (OldModule->Type() != TYPE_MODULE) || (NewModule->Type() != TYPE_MODULE) ) { DisplayError( winaff, wxT( "WinEDA_BasePcbFrame::Exchange_Module() StuctType error" ) ); } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index a6285b7ec5..a475ce392c 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -935,12 +935,7 @@ int WinEDA_PcbFrame::Fill_All_Zones( wxDC* DC, bool verbose ) int error_level = 0; // Remove all zones : - if( m_Pcb->m_Zone ) - { - m_Pcb->m_Zone->DeleteStructList(); - m_Pcb->m_Zone = NULL; - m_Pcb->m_NbSegmZone = 0; - } + m_Pcb->m_Zone.DeleteAll(); for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) { diff --git a/pcbnew/zones_convert_brd_items_to_polygons.cpp b/pcbnew/zones_convert_brd_items_to_polygons.cpp index 90270018c0..c9ab3df689 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons.cpp @@ -220,14 +220,14 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) switch( item->Type() ) { - case TYPEDRAWSEGMENT: + case TYPE_DRAWSEGMENT: AddRoundedEndsSegmentPolygon( booleng, ( (DRAWSEGMENT*) item )->m_Start, ( (DRAWSEGMENT*) item )->m_End, ( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) ); break; - case TYPETEXTE: + case TYPE_TEXTE: if( ( (TEXTE_PCB*) item )->GetLength() == 0 ) break; AddTextBoxWithClearancePolygon( booleng, (TEXTE_PCB*) item, m_ZoneClearance ); @@ -757,7 +757,7 @@ void AddTrackWithClearancePolygon( Bool_Engine* aBooleng, switch( aTrack.Type() ) { - case TYPEVIA: + case TYPE_VIA: if( aBooleng->StartPolygonAdd( GROUP_B ) ) { dx = (int) (dx * s_Correction); diff --git a/pcbnew/zones_polygons_insulated_copper_islands.cpp b/pcbnew/zones_polygons_insulated_copper_islands.cpp index 9de92fbc3b..7c2fd49dd3 100644 --- a/pcbnew/zones_polygons_insulated_copper_islands.cpp +++ b/pcbnew/zones_polygons_insulated_copper_islands.cpp @@ -69,7 +69,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD if( track->GetNet() != GetNet() ) continue; ListPointsCandidates.push_back( track->m_Start ); - if( track->Type() != TYPEVIA ) + if( track->Type() != TYPE_VIA ) ListPointsCandidates.push_back( track->m_End ); } diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp index 70c60e4e86..51dfb3ca0f 100644 --- a/pcbnew/zones_polygons_test_connections.cpp +++ b/pcbnew/zones_polygons_test_connections.cpp @@ -114,15 +114,15 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) if( !item->IsOnLayer( curr_zone->GetLayer() ) ) continue; wxPoint pos1, pos2; - if( item->Type() == TYPEPAD ) + if( item->Type() == TYPE_PAD ) { pos1 = pos2 = ( (D_PAD*) item )->m_Pos; } - else if( item->Type() == TYPEVIA ) + else if( item->Type() == TYPE_VIA ) { pos1 = pos2 = ( (SEGVIA*) item )->m_Start; } - else if( item->Type() == TYPETRACK ) + else if( item->Type() == TYPE_TRACK ) { pos1 = ( (TRACK*) item )->m_Start; pos2 = ( (TRACK*) item )->m_End; diff --git a/share/drawpanel.cpp b/share/drawpanel.cpp index 4063bb1d83..d26e399183 100644 --- a/share/drawpanel.cpp +++ b/share/drawpanel.cpp @@ -300,8 +300,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect ) { - D( printf( "1) PostDirtyRect( x=%d, y=%d, width=%d, height=%d)\n", - aRect.m_Pos.x, aRect.m_Pos.y, aRect.m_Size.x, aRect.m_Size.y ); ) + // D( printf( "1) PostDirtyRect( x=%d, y=%d, width=%d, height=%d)\n", aRect.m_Pos.x, aRect.m_Pos.y, aRect.m_Size.x, aRect.m_Size.y ); ) // Convert the rect coordinates and size to pixels (make a draw clip box): ConvertPcbUnitsToPixelsUnits( &aRect ); @@ -313,8 +312,7 @@ void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect ) aRect.m_Size.x += 2; // += 1 is not enough! aRect.m_Size.y += 2; - D( printf( "2) PostDirtyRect( x=%d, y=%d, width=%d, height=%d)\n", - aRect.m_Pos.x, aRect.m_Pos.y, aRect.m_Size.x, aRect.m_Size.y ); ) + // D( printf( "2) PostDirtyRect( x=%d, y=%d, width=%d, height=%d)\n", aRect.m_Pos.x, aRect.m_Pos.y, aRect.m_Size.x, aRect.m_Size.y ); ) // pass wxRect() via EDA_Rect::operator wxRect() overload RefreshRect( aRect, TRUE );