diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index a4a1e14879..b9c38cec84 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -179,9 +179,7 @@ void CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer( const MODULE* aMod std::vector texts; // List of TEXTE_MODULE to convert EDGE_MODULE* outline; - for( EDA_ITEM* item = aModule->GraphicalItemsList(); - item != NULL; - item = item->Next() ) + for( auto item : aModule->GraphicalItems() ) { switch( item->Type() ) { diff --git a/3d-viewer/3d_canvas/create_layer_poly.cpp b/3d-viewer/3d_canvas/create_layer_poly.cpp index 91a7483213..cb965b1137 100644 --- a/3d-viewer/3d_canvas/create_layer_poly.cpp +++ b/3d-viewer/3d_canvas/create_layer_poly.cpp @@ -202,9 +202,7 @@ void CINFO3D_VISU::transformGraphicModuleEdgeToPolygonSet( const MODULE *aModule PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aCornerBuffer ) const { - for( const EDA_ITEM* item = aModule->GraphicalItemsList(); - item != NULL; - item = item->Next() ) + for( auto item : aModule->GraphicalItems() ) { switch( item->Type() ) { diff --git a/common/hash_eda.cpp b/common/hash_eda.cpp index ef328c7daf..d09e423c7c 100644 --- a/common/hash_eda.cpp +++ b/common/hash_eda.cpp @@ -66,7 +66,7 @@ size_t hash_eda( const EDA_ITEM* aItem, int aFlags ) if( aFlags & ROTATION ) ret ^= hash{}( module->GetOrientation() ); - for( const BOARD_ITEM* i = module->GraphicalItemsList(); i; i = i->Next() ) + for( auto i : module->GraphicalItems() ) ret ^= hash_eda( i, aFlags ); for( auto i : module->Pads() ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 0bc9b59c32..de28accf20 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -462,7 +462,6 @@ if( KICAD_SCRIPTING ) # Generate pcbnew.py and pcbnew_wrap.cxx using swig DEPENDS swig/zone.i DEPENDS swig/zone_settings.i - DEPENDS ../common/swig/dlist.i DEPENDS ../common/swig/kicad.i DEPENDS ../common/swig/wx.i DEPENDS ../common/swig/ki_exception.i diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 355c7cda2b..ee781f60de 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -199,7 +199,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( PCB_LAYER_ID aLaye std::vector texts; // List of TEXTE_MODULE to convert EDGE_MODULE* outline; - for( EDA_ITEM* item = GraphicalItemsList(); item != NULL; item = item->Next() ) + for( auto item : GraphicalItems() ) { switch( item->Type() ) { @@ -265,7 +265,7 @@ void MODULE::TransformGraphicTextWithClearanceToPolygonSet( { std::vector texts; // List of TEXTE_MODULE to convert - for( EDA_ITEM* item = GraphicalItemsList(); item != NULL; item = item->Next() ) + for( auto item : GraphicalItems() ) { switch( item->Type() ) { diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index ee95936b7b..8e7a55dfd2 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -109,7 +109,7 @@ MODULE::MODULE( const MODULE& aModule ) : } // Copy auxiliary data: Drawings - for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() ) + for( auto item : aModule.GraphicalItems() ) { switch( item->Type() ) { @@ -187,9 +187,9 @@ MODULE& MODULE::operator=( const MODULE& aOther ) } // Copy auxiliary data: Drawings - m_Drawings.DeleteAll(); + m_drawings.clear(); - for( BOARD_ITEM* item = aOther.m_Drawings; item; item = item->Next() ) + for( auto item : aOther.GraphicalItems() ) { switch( item->Type() ) { @@ -238,9 +238,9 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode ) case PCB_MODULE_EDGE_T: if( aMode == ADD_APPEND ) - m_Drawings.PushBack( aBoardItem ); + m_drawings.push_back( aBoardItem ); else - m_Drawings.PushFront( aBoardItem ); + m_drawings.push_front( aBoardItem ); break; case PCB_PAD_T: @@ -276,7 +276,8 @@ void MODULE::Remove( BOARD_ITEM* aBoardItem ) // no break case PCB_MODULE_EDGE_T: - m_Drawings.Remove( aBoardItem ); + m_drawings.erase( std::remove_if( m_drawings.begin(), m_drawings.end(), + [aBoardItem]( BOARD_ITEM* aItem ) { return aItem == aBoardItem; } ) ); break; case PCB_PAD_T: @@ -322,7 +323,7 @@ void MODULE::CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings ) aModule->SetThermalGap( GetThermalGap() ); } - for( auto pad : m_pads ) + for( auto pad : aModule->Pads() ) { // Fix me: if aCopyLocalSettings == true, for "multiple" pads // (set of pads having the same name/number) this is broken @@ -356,7 +357,7 @@ void MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) if( brd->IsElementVisible( LAYER_MOD_VALUES ) ) m_Value->Print( aFrame, aDC, aOffset ); - for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { switch( item->Type() ) { @@ -394,7 +395,7 @@ EDA_RECT MODULE::GetFootprintRect() const area.SetEnd( m_Pos ); area.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the area - for( const BOARD_ITEM* item = m_Drawings.GetFirst(); item; item = item->Next() ) + for( auto item : m_drawings ) { if( item->Type() == PCB_MODULE_EDGE_T ) area.Merge( item->GetBoundingBox() ); @@ -412,7 +413,7 @@ const EDA_RECT MODULE::GetBoundingBox() const EDA_RECT area = GetFootprintRect(); // Add in items not collected by GetFootprintRect(): - for( const BOARD_ITEM* item = m_Drawings.GetFirst(); item; item = item->Next() ) + for( auto item : m_drawings ) { if( item->Type() != PCB_MODULE_EDGE_T ) area.Merge( item->GetBoundingBox() ); @@ -590,7 +591,7 @@ bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) co return true; } - for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { if( item->HitTest( arect, false, 0 ) ) return true; @@ -756,7 +757,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR inspector, void* testData, const KICAD_T // m_Drawings can hold TYPETEXTMODULE also, so fall thru case PCB_MODULE_EDGE_T: - result = IterateForward( m_Drawings, inspector, testData, p ); + result = IterateForward( m_drawings, inspector, testData, p ); // skip over any types handled in the above call. for( ; ; ) @@ -819,8 +820,8 @@ void MODULE::RunOnChildren( const std::function& aFunction ) for( auto pad : m_pads ) aFunction( static_cast( pad ) ); - for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() ) - aFunction( drawing ); + for( auto drawing : m_drawings ) + aFunction( static_cast( drawing ) ); aFunction( static_cast( m_Reference ) ); aFunction( static_cast( m_Value ) ); @@ -836,7 +837,7 @@ void MODULE::GetAllDrawingLayers( int aLayers[], int& aCount, bool aIncludePads { std::unordered_set layers; - for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { layers.insert( static_cast( item->GetLayer() ) ); } @@ -886,7 +887,7 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const // with the silkscreen layer bool f_silk = false, b_silk = false, non_silk = false; - for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { if( item->GetLayer() == F_SilkS ) f_silk = true; @@ -984,7 +985,7 @@ void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle ) m_Reference->KeepUpright( orientation, newOrientation ); m_Value->KeepUpright( orientation, newOrientation ); - for( EDA_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { if( item->Type() == PCB_MODULE_TEXT_T ) static_cast( item )->KeepUpright( orientation, newOrientation ); @@ -1015,7 +1016,7 @@ void MODULE::Flip( const wxPoint& aCentre ) m_Value->Flip( m_Pos ); // Reverse mirror module graphics and texts. - for( EDA_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { switch( item->Type() ) { @@ -1051,7 +1052,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) pad->SetPosition( pad->GetPosition() + delta ); } - for( EDA_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { switch( item->Type() ) { @@ -1108,7 +1109,7 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector ) } // Update the draw element coordinates. - for( EDA_ITEM* item = GraphicalItemsList(); item; item = item->Next() ) + for( auto item : GraphicalItems() ) { switch( item->Type() ) { @@ -1155,7 +1156,7 @@ void MODULE::SetOrientation( double newangle ) m_Value->SetDrawCoord(); // Displace contours and text of the footprint. - for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) + for( auto item : m_drawings ) { if( item->Type() == PCB_MODULE_EDGE_T ) { @@ -1201,7 +1202,7 @@ BOARD_ITEM* MODULE::Duplicate( const BOARD_ITEM* aItem, TEXTE_MODULE* new_text = new TEXTE_MODULE( *old_text ); if( aAddToModule ) - GraphicalItemsList().PushBack( new_text ); + Add( new_text ); new_item = new_text; } @@ -1214,7 +1215,7 @@ BOARD_ITEM* MODULE::Duplicate( const BOARD_ITEM* aItem, *static_cast(aItem) ); if( aAddToModule ) - GraphicalItemsList().PushBack( new_edge ); + Add( new_edge ); new_item = new_edge; break; @@ -1352,7 +1353,7 @@ bool MODULE::BuildPolyCourtyard() std::vector< DRAWSEGMENT* > list_front; std::vector< DRAWSEGMENT* > list_back; - for( BOARD_ITEM* item = GraphicalItemsList(); item; item = item->Next() ) + for( auto item : GraphicalItems() ) { if( item->GetLayer() == B_CrtYd && item->Type() == PCB_MODULE_EDGE_T ) list_back.push_back( static_cast< DRAWSEGMENT* > ( item ) ); diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 2221f4f506..4d0e04b269 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -37,7 +37,6 @@ #include #include #include -#include #include // ALL_LAYERS definition. #include #include @@ -161,9 +160,6 @@ public: // Virtual function const EDA_RECT GetBoundingBox() const override; - DLIST& GraphicalItemsList() { return m_Drawings; } - const DLIST& GraphicalItemsList() const { return m_Drawings; } - PADS& Pads() { return m_pads; @@ -174,9 +170,14 @@ public: return m_pads; } - DLIST_ITERATOR_WRAPPER GraphicalItems() + DRAWINGS& GraphicalItems() { - return DLIST_ITERATOR_WRAPPER( m_Drawings ); + return m_drawings; + } + + const DRAWINGS& GraphicalItems() const + { + return m_drawings; } std::list& Models() { return m_3D_Drawings; } @@ -670,10 +671,6 @@ public: private: - DLIST m_Drawings; ///< Linked list of graphical items. - - - /// BOARD_ITEMs for drawings on the board, owned by pointer. DRAWINGS m_drawings; diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index c7ee11043c..e4136e7581 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -248,7 +248,7 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow() m_texts->push_back( m_footprint->Reference() ); m_texts->push_back( m_footprint->Value() ); - for( BOARD_ITEM* item = m_footprint->GraphicalItemsList().GetFirst(); item; item = item->Next() ) + for( auto item : m_footprint->GraphicalItems() ) { auto textModule = dyn_cast( item ); @@ -628,11 +628,9 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow() m_footprint->Value() = m_texts->at( 1 ); size_t i = 2; - BOARD_ITEM* next; - for( BOARD_ITEM* item = m_footprint->GraphicalItemsList().GetFirst(); item; item = next ) + for( auto item : m_footprint->GraphicalItems() ) { - next = item->Next(); TEXTE_MODULE* textModule = dyn_cast( item ); if( textModule ) diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index 6bb7d03c62..75001eb8fb 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -204,7 +204,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow() m_texts->push_back( m_footprint->Reference() ); m_texts->push_back( m_footprint->Value() ); - for( BOARD_ITEM* item = m_footprint->GraphicalItemsList().GetFirst(); item; item = item->Next() ) + for( auto item : m_footprint->GraphicalItems() ) { auto textModule = dyn_cast( item ); @@ -580,7 +580,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataFromWindow() m_footprint->Value() = m_texts->at( 1 ); size_t i = 2; - for( BOARD_ITEM* item = m_footprint->GraphicalItemsList().GetFirst(); item; item = item->Next() ) + for( auto item : m_footprint->GraphicalItems() ) { TEXTE_MODULE* textModule = dyn_cast( item ); diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index 3f638de2f8..c6da11ae79 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -382,9 +382,9 @@ void processTextItem( const TEXTE_MODULE& aSrc, TEXTE_MODULE& aDest, TEXTE_MODULE* getMatchingTextItem( TEXTE_MODULE* aRefItem, MODULE* aModule ) { - for( auto iItem = aModule->GraphicalItemsList().GetFirst(); iItem; iItem = iItem->Next() ) + for( auto item : aModule->GraphicalItems() ) { - TEXTE_MODULE* candidate = dyn_cast( iItem ); + TEXTE_MODULE* candidate = dyn_cast( item ); if( candidate && candidate->GetText() == aRefItem->GetText() ) return candidate; @@ -422,7 +422,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aSrc, MODULE* aDest, BOARD_COMMIT& resetTextLayers, resetTextEffects ); // Copy fields in accordance with the reset* flags - for( BOARD_ITEM* item = aSrc->GraphicalItemsList().GetFirst(); item; item = item->Next() ) + for( auto item : aSrc->GraphicalItems() ) { TEXTE_MODULE* srcItem = dyn_cast( item ); @@ -433,7 +433,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aSrc, MODULE* aDest, BOARD_COMMIT& if( destItem ) processTextItem( *srcItem, *destItem, false, resetTextLayers, resetTextEffects ); else if( !deleteExtraTexts ) - aDest->GraphicalItemsList().Append( new TEXTE_MODULE( *srcItem ) ); + aDest->Add( new TEXTE_MODULE( *srcItem ) ); } } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index ed169ea8ad..c0ca9022d2 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -1031,7 +1031,7 @@ void DRC::testCopperTextAndGraphics() if( module->IsNetTie() ) continue; - for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) + for( auto item : module->GraphicalItems() ) { if( IsCopperLayer( item->GetLayer() ) ) { diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 9046ceb4f0..55b596a51c 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -1504,7 +1504,7 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const dwg->SetWidth( width ); dwg->SetDrawCoord(); - aModule->GraphicalItemsList().PushBack( dwg ); + aModule->Add( dwg ); } @@ -1622,7 +1622,7 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, wxXmlNode* aTree ) const { // FIXME: graphical text items are rotated for some reason. txt = new TEXTE_MODULE( aModule ); - aModule->GraphicalItemsList().PushBack( txt ); + aModule->Add( txt ); } txt->SetTimeStamp( EagleTimeStamp( aTree ) ); @@ -1714,7 +1714,7 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const PCB_LAYER_ID layer = kicad_layer( r.layer ); EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON ); - aModule->GraphicalItemsList().PushBack( dwg ); + aModule->Add( dwg ); dwg->SetLayer( layer ); dwg->SetWidth( 0 ); @@ -1749,7 +1749,7 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const PCB_LAYER_ID layer = kicad_layer( p.layer ); EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON ); - aModule->GraphicalItemsList().PushBack( dwg ); + aModule->Add( dwg ); dwg->SetWidth( 0 ); // it's filled, no need for boundary width dwg->SetLayer( layer ); @@ -1832,7 +1832,7 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const radius = radius / 2; } - aModule->GraphicalItemsList().PushBack( gr ); + aModule->Add( gr ); gr->SetWidth( width ); switch ( (int) layer ) diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index d7edea2abf..f24564cb9b 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -704,7 +704,8 @@ static size_t hashModule( const MODULE* aModule ) constexpr int flags = HASH_FLAGS::POSITION | HASH_FLAGS::REL_COORD | HASH_FLAGS::ROTATION | HASH_FLAGS::LAYER; - for( const BOARD_ITEM* i = aModule->GraphicalItemsList(); i; i = i->Next() ) + + for( auto i : aModule->GraphicalItems() ) ret ^= hash_eda( i, flags ); for( auto i : aModule->Pads() ) @@ -1200,7 +1201,6 @@ static void CreateTracksInfoData( FILE* aFile, BOARD* aPcb ) static void FootprintWriteShape( FILE* aFile, MODULE* module, const wxString& aShapeName ) { EDGE_MODULE* PtEdge; - EDA_ITEM* PtStruct; /* creates header: */ fprintf( aFile, "\nSHAPE \"%s\"\n", TO_UTF8( escapeString( aShapeName ) ) ); @@ -1242,7 +1242,7 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module, const wxString& aS // CAM350 read it right but only closed shapes // ProntoPlace double-flip it (at least the pads are correct) // GerberTool usually get it right... - for( PtStruct = module->GraphicalItemsList(); PtStruct; PtStruct = PtStruct->Next() ) + for( auto PtStruct : module->GraphicalItems() ) { switch( PtStruct->Type() ) { diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 3216ae2214..b9d95451f5 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1338,7 +1338,8 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, export_vrml_text_module( &aModule->Value() ); // Export module edges - for( EDA_ITEM* item = aModule->GraphicalItemsList(); item; item = item->Next() ) + + for( auto item : aModule->GraphicalItems() ) { switch( item->Type() ) { diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index 28a9378e79..3b91be4898 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -474,7 +474,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) parseInt( parameters[5], conv_unit ) ) ); drawSeg->SetWidth( parseInt( parameters[6], conv_unit ) ); drawSeg->SetDrawCoord(); - module->GraphicalItemsList().PushBack( drawSeg ); + module->Add( drawSeg ); continue; } @@ -492,7 +492,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) EDGE_MODULE* drawSeg = new EDGE_MODULE( module.get() ); drawSeg->SetLayer( F_SilkS ); drawSeg->SetShape( S_ARC ); - module->GraphicalItemsList().PushBack( drawSeg ); + module->Add( drawSeg ); // for and arc: ibuf[3] = ibuf[4]. Pcbnew does not know ellipses int radius = ( parseInt( parameters[4], conv_unit ) + diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 6fe2464618..5581bcc5e1 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1090,7 +1090,7 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const Format( (BOARD_ITEM*) &aModule->Value(), aNestLevel+1 ); // Save drawing elements. - for( BOARD_ITEM* gr = aModule->GraphicalItemsList(); gr; gr = gr->Next() ) + for( auto gr : aModule->GraphicalItems() ) Format( gr, aNestLevel+1 ); // Save pads. diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index e85c1f10ab..cee7d97623 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1206,7 +1206,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule ) // All other fields greater than 1. default: textm = new TEXTE_MODULE( aModule ); - aModule->GraphicalItemsList().PushBack( textm ); + aModule->Add( textm ); } loadMODULE_TEXT( textm ); @@ -1765,7 +1765,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) EDGE_MODULE* em = dwg.release(); - aModule->GraphicalItemsList().PushBack( em ); + aModule->Add( em ); // this had been done at the MODULE level before, presumably because the // EDGE_MODULE needs to be already added to a module before this function will work. diff --git a/pcbnew/microwave.cpp b/pcbnew/microwave.cpp index 0ff35f68ab..142cc0be9d 100644 --- a/pcbnew/microwave.cpp +++ b/pcbnew/microwave.cpp @@ -495,7 +495,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() edge->SetShape( S_POLYGON ); edge->SetLayer( F_Cu ); - module->GraphicalItemsList().PushFront( edge ); + module->Add( edge, ADD_INSERT ); // Get the corner buffer of the polygonal edge std::vector polyPoints; diff --git a/pcbnew/microwave/microwave_inductor.cpp b/pcbnew/microwave/microwave_inductor.cpp index 5b80715d04..7be5f37917 100644 --- a/pcbnew/microwave/microwave_inductor.cpp +++ b/pcbnew/microwave/microwave_inductor.cpp @@ -398,7 +398,7 @@ MODULE* MWAVE::CreateMicrowaveInductor( INDUCTOR_PATTERN& inductorPattern, PtSegm->SetShape( S_SEGMENT ); PtSegm->SetStart0( PtSegm->GetStart() - module->GetPosition() ); PtSegm->SetEnd0( PtSegm->GetEnd() - module->GetPosition() ); - module->GraphicalItemsList().PushBack( PtSegm ); + module->Add( PtSegm ); } // Place a pad on each end of coil. diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp index 71c895cdf1..c4c047a1e4 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp @@ -161,7 +161,7 @@ void PCB_ARC::AddToModule( MODULE* aModule ) if( IsNonCopperLayer( m_KiCadLayer ) ) { EDGE_MODULE* arc = new EDGE_MODULE( aModule, ( IsCircle() ? S_CIRCLE : S_ARC ) ); - aModule->GraphicalItemsList().PushBack( arc ); + aModule->Add( arc ); arc->SetAngle( -m_angle ); arc->m_Start0 = wxPoint( m_positionX, m_positionY ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp index c2b83abe08..efbbf1d15d 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_line.cpp @@ -120,7 +120,7 @@ void PCB_LINE::AddToModule( MODULE* aModule ) if( IsNonCopperLayer( m_KiCadLayer ) ) { EDGE_MODULE* segment = new EDGE_MODULE( aModule, S_SEGMENT ); - aModule->GraphicalItemsList().PushBack( segment ); + aModule->Add( segment ); segment->m_Start0 = wxPoint( m_positionX, m_positionY ); segment->m_End0 = wxPoint( m_toX, m_toY ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp index 38dabf553e..a0787c1959 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_polygon.cpp @@ -161,7 +161,7 @@ void PCB_POLYGON::AddToModule( MODULE* aModule ) if( IsNonCopperLayer( m_KiCadLayer ) ) { EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON ); - aModule->GraphicalItemsList().PushBack( dwg ); + aModule->Add( dwg ); dwg->SetWidth( 0 ); dwg->SetLayer( m_KiCadLayer ); diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index c33fec7f5a..11cbba3290 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -2140,7 +2140,7 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments ) break; default: - module->GraphicalItemsList().PushBack( text ); + module->Add( text ); } } break; @@ -2154,7 +2154,7 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments ) EDGE_MODULE* em = parseEDGE_MODULE(); em->SetParent( module.get() ); em->SetDrawCoord(); - module->GraphicalItemsList().PushBack( em ); + module->Add( em ); } break; diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 139571e66f..a426152238 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -63,32 +63,6 @@ extern bool IsWxPythonLoaded(); -// Colors for layers and items - -PCB_LAYER_ID g_Route_Layer_TOP; -PCB_LAYER_ID g_Route_Layer_BOTTOM; -bool g_Alternate_Track_Posture = false; -bool g_Raccord_45_Auto = true; - -wxPoint g_Offset_Module; // module offset used when moving a footprint - -/* Name of the document footprint list - * usually located in share/modules/footprints_doc - * this is of the responsibility to users to create this file - * if they want to have a list of footprints - */ -wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" ); - -/* - * 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. - */ -DLIST g_CurrentTrackList; - - - namespace PCB { static struct IFACE : public KIFACE_I diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index cd9435c46e..1599a531fa 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -29,25 +29,11 @@ #ifndef PCBNEW_H #define PCBNEW_H - #include // wxWidgets include. #include // IS_DRAGGED and IN_EDIT definitions. -#include #include // to define Mils2iu() conversion function #include -/* Flag used in locate functions. The locate ref point is the on grid cursor or the off - * grid mouse cursor. */ -#define CURSEUR_ON_GRILLE (0 << 0) -#define CURSEUR_OFF_GRILLE (1 << 0) - -#define IGNORE_LOCKED (1 << 1) ///< if module is locked, do not select for single module operation -#define MATCH_LAYER (1 << 2) ///< if module not on current layer, do not select -#define VISIBLE_ONLY (1 << 3) ///< if module not on a visible layer, do not select - -#define DIM_ANCRE_MODULE 3 // Anchor size (footprint center) - - // These are only here for algorithmic safety, not to tell the user what to do #define TEXTS_MIN_SIZE Mils2iu( 1 ) ///< Minimum text size in internal units (1 mil) #define TEXTS_MAX_SIZE Mils2iu( 10000 ) ///< Maximum text size in internal units (10 inches) @@ -57,30 +43,9 @@ // Flag to force the SKETCH mode to display items (.m_Flags member) #define FORCE_SKETCH ( IS_DRAGGED | IN_EDIT ) -/* Name of the document footprint list - * usually located in share/modules/footprints_doc - * this is of the responsibility to users to create this file - * if they want to have a list of footprints - * default is "footprints_doc/footprints.pdf" - */ -extern wxString g_DocModulesFileName; - -// variables -extern bool g_Raccord_45_Auto; -extern bool g_Alternate_Track_Posture; -// Layer pair for auto routing and switch layers by hotkey -extern PCB_LAYER_ID g_Route_Layer_TOP; -extern PCB_LAYER_ID g_Route_Layer_BOTTOM; - -extern wxPoint g_Offset_Module; // Offset trace when moving footprint. /// List of segments of the trace currently being drawn. class TRACK; -extern DLIST g_CurrentTrackList; -#define g_CurrentTrackSegment g_CurrentTrackList.GetLast() ///< most recently created segment -#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created - - /** * Helper function PythonPluginsReloadBase diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index d7198b5688..18e139726e 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -310,7 +310,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, for( auto module : aBoard->Modules() ) { - for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) + for( auto item : module->GraphicalItems() ) { if( !aLayerMask[ item->GetLayer() ] ) continue; @@ -775,7 +775,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, for( auto module : aBoard->Modules() ) { - for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) + for( auto item : module->GraphicalItems() ) { if( layer != item->GetLayer() ) continue; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index c293381b3a..058fc09927 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -239,7 +239,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) PlotTextModule( textModule, getColor( textLayer ) ); } - for( BOARD_ITEM* item = aModule->GraphicalItemsList().GetFirst(); item; item = item->Next() ) + for( auto item : aModule->GraphicalItems() ) { textModule = dyn_cast( item ); @@ -432,7 +432,7 @@ void BRDITEMS_PLOTTER::Plot_Edges_Modules() { for( auto module : m_board->Modules() ) { - for( BOARD_ITEM* item = module->GraphicalItemsList().GetFirst(); item; item = item->Next() ) + for( auto item : module->GraphicalItems() ) { EDGE_MODULE* edge = dyn_cast( item ); diff --git a/pcbnew/swig/board.i b/pcbnew/swig/board.i index dfd2f84477..ca6d7b119f 100644 --- a/pcbnew/swig/board.i +++ b/pcbnew/swig/board.i @@ -42,8 +42,6 @@ file near the top; only class BOARD functions go in board.i. HANDLE_EXCEPTIONS(BOARD::TracksInNetBetweenPoints) -//%import dlist.h // comes in from kicad.i which wraps & includes board.i - %include board_item.i %include board_item_container.i %include board_connected_item.i diff --git a/pcbnew/swig/footprint.i b/pcbnew/swig/footprint.i index 5d13d8a223..cb703b7a2c 100644 --- a/pcbnew/swig/footprint.i +++ b/pcbnew/swig/footprint.i @@ -51,8 +51,8 @@ %pythoncode %{ - def Pads(self): return self.PadsList() - def GraphicalItems(self): return self.GraphicalItemsList() + def Pads(self): return self.Pads() + def GraphicalItems(self): return self.GraphicalItems() #def SaveToLibrary(self,filename): # return SaveModuleToLibrary(filename,self) diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 1dbee8717e..8586bad044 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -715,10 +715,10 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent ) items.push_back( pad ); } - for( BOARD_ITEM* item = oldModule->GraphicalItemsList(), *next = nullptr; - item; item = next ) + for( auto it = oldModule->GraphicalItems().begin(); + it != oldModule->GraphicalItems().end(); it++ ) { - next = item->Next(); + auto item = *it; oldModule->Remove( item ); item->SetParent( newModule ); items.push_back( item ); diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index c41429f6a6..b6268044ab 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -243,7 +243,7 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis clone->SetParent( GetBoard() ); // Clear current flags (which can be temporary set by a current edit command) - for( EDA_ITEM* child = clone->GraphicalItemsList(); child; child = child->Next() ) + for( auto child : clone->GraphicalItems() ) child->ClearEditFlags(); for( auto pad : clone->Pads() ) diff --git a/qa/pcbnew_utils/board_construction_utils.cpp b/qa/pcbnew_utils/board_construction_utils.cpp index 46e1e43c9f..1e22b46379 100644 --- a/qa/pcbnew_utils/board_construction_utils.cpp +++ b/qa/pcbnew_utils/board_construction_utils.cpp @@ -44,7 +44,7 @@ void DrawSegment( MODULE& aMod, const SEG& aSeg, int aWidth, PCB_LAYER_ID aLayer seg->SetWidth( aWidth ); seg->SetLayer( aLayer ); - aMod.GraphicalItemsList().PushBack( seg.release() ); + aMod.Add( seg.release() ); } @@ -70,7 +70,7 @@ void DrawArc( MODULE& aMod, const VECTOR2I& aCentre, const VECTOR2I& aStart, dou seg->SetWidth( aWidth ); seg->SetLayer( aLayer ); - aMod.GraphicalItemsList().PushBack( seg.release() ); + aMod.Add( seg.release() ); } diff --git a/qa/qa_utils/mocks.cpp b/qa/qa_utils/mocks.cpp index 1248e1d0a1..6b94490eed 100644 --- a/qa/qa_utils/mocks.cpp +++ b/qa/qa_utils/mocks.cpp @@ -66,37 +66,6 @@ #include #include -bool g_Drc_On = true; -bool g_AutoDeleteOldTrack = true; -bool g_Raccord_45_Auto = true; -bool g_Alternate_Track_Posture = false; -bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. and 45deg only tracks -bool g_Segments_45_Only; // True to allow horiz, vert. and 45deg only graphic segments -bool g_TwoSegmentTrackBuild = true; - -PCB_LAYER_ID g_Route_Layer_TOP; -PCB_LAYER_ID g_Route_Layer_BOTTOM; -int g_MagneticPadOption; -int g_MagneticTrackOption; - -wxPoint g_Offset_Module; // module offset used when moving a footprint - -/* Name of the document footprint list - * usually located in share/modules/footprints_doc - * this is of the responsibility to users to create this file - * if they want to have a list of footprints - */ -wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" ); - -/* - * 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. - */ -DLIST g_CurrentTrackList; - -bool g_DumpZonesWhenFilling = false; static struct IFACE : public KIFACE_I {