From 4f05262705651dbda6e0797b910be1977bfa7e0f Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 3 Jun 2021 19:05:43 +0100 Subject: [PATCH] Cleanup includes in board.h and footprint.h --- pcbnew/board.cpp | 25 ++++++++ pcbnew/board.h | 35 ++--------- pcbnew/cross-probing.cpp | 1 + pcbnew/dialogs/dialog_board_statistics.h | 1 + pcbnew/dialogs/dialog_cleanup_graphics.cpp | 1 + pcbnew/dialogs/dialog_find.cpp | 1 + pcbnew/dialogs/dialog_footprint_checker.cpp | 1 + .../dialogs/dialog_track_via_properties.cpp | 1 + pcbnew/dialogs/dialog_unused_pad_layers.cpp | 1 + pcbnew/drc/drc_engine.cpp | 4 +- pcbnew/drc/drc_rtree.h | 2 + .../drc_test_provider_copper_clearance.cpp | 2 + .../drc_test_provider_courtyard_clearance.cpp | 3 +- .../drc_test_provider_diff_pair_coupling.cpp | 1 + pcbnew/drc/drc_test_provider_disallow.cpp | 1 + pcbnew/drc/drc_test_provider_hole_size.cpp | 1 + pcbnew/drc/drc_test_provider_hole_to_hole.cpp | 1 + .../drc/drc_test_provider_silk_clearance.cpp | 1 + pcbnew/exporters/gendrill_gerber_writer.cpp | 1 + pcbnew/footprint.cpp | 2 + pcbnew/footprint.h | 7 +-- pcbnew/kicad_clipboard.cpp | 1 + pcbnew/netinfo_item.cpp | 2 + pcbnew/pcb_base_edit_frame.cpp | 1 + pcbnew/pcb_expr_evaluator.cpp | 1 + pcbnew/pcb_item_containers.h | 58 +++++++++++++++++++ pcbnew/pcb_text.cpp | 1 + pcbnew/plugins/altium/altium_pcb.cpp | 1 + .../cadstar/cadstar_pcb_archive_loader.h | 1 + pcbnew/plugins/fabmaster/import_fabmaster.cpp | 2 + pcbnew/plugins/pcad/pcb_polygon.cpp | 1 + pcbnew/router/router_tool.cpp | 1 + pcbnew/tools/drawing_stackup_table_tool.cpp | 1 + pcbnew/tools/footprint_editor_control.cpp | 1 + pcbnew/tools/global_edit_tool.cpp | 2 + pcbnew/tools/group_tool.cpp | 3 +- pcbnew/tools/position_relative_tool.cpp | 1 + pcbnew/tools/zone_create_helper.cpp | 1 + .../polygon_generator/polygon_generator.cpp | 1 + .../polygon_triangulation.cpp | 1 + 40 files changed, 136 insertions(+), 38 deletions(-) create mode 100644 pcbnew/pcb_item_containers.h diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 1882929010..1f61c7e6a5 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -186,6 +187,21 @@ void BOARD::ClearProject() } +void BOARD::IncrementTimeStamp() +{ + m_timeStamp++; + + { + std::unique_lock cacheLock( m_CachesMutex ); + m_InsideAreaCache.clear(); + m_InsideCourtyardCache.clear(); + m_InsideFCourtyardCache.clear(); + m_InsideBCourtyardCache.clear(); + } + + m_CopperZoneRTrees.clear(); +} + std::vector BOARD::ResolveDRCExclusions() { for( PCB_MARKER* marker : GetBoard()->Markers() ) @@ -813,6 +829,15 @@ void BOARD::DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions ) } +void BOARD::DeleteAllFootprints() +{ + for( FOOTPRINT* footprint : m_footprints ) + delete footprint; + + m_footprints.clear(); +} + + BOARD_ITEM* BOARD::GetItem( const KIID& aID ) const { if( aID == niluuid ) diff --git a/pcbnew/board.h b/pcbnew/board.h index 016d6990ca..721a3b9688 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -27,20 +27,22 @@ #include #include -#include #include // Needed for stl hash extensions +#include // for OUTLINE_ERROR_HANDLER #include #include +#include #include #include #include -#include class BOARD_COMMIT; +class DRC_RTREE; class PCB_BASE_FRAME; class PCB_EDIT_FRAME; class PICKED_ITEMS_LIST; class BOARD; +class FOOTPRINT; class ZONE; class TRACK; class PAD; @@ -168,12 +170,6 @@ public: }; -DECL_VEC_FOR_SWIG( MARKERS, PCB_MARKER* ) -DECL_VEC_FOR_SWIG( ZONES, ZONE* ) -DECL_DEQ_FOR_SWIG( TRACKS, TRACK* ) -// Dequeue rather than Vector just so we can use moveUnflaggedItems in pcbnew_control.cpp -DECL_DEQ_FOR_SWIG( GROUPS, PCB_GROUP* ) - /** * Flags to specify how the board is being used. */ @@ -268,20 +264,7 @@ public: */ BOARD_USE GetBoardUse() const { return m_boardUse; } - void IncrementTimeStamp() - { - m_timeStamp++; - - { - std::unique_lock cacheLock( m_CachesMutex ); - m_InsideAreaCache.clear(); - m_InsideCourtyardCache.clear(); - m_InsideFCourtyardCache.clear(); - m_InsideBCourtyardCache.clear(); - } - - m_CopperZoneRTrees.clear(); - } + void IncrementTimeStamp(); int GetTimeStamp() { return m_timeStamp; } @@ -387,13 +370,7 @@ public: /** * Removes all footprints from the deque and frees the memory associated with them */ - void DeleteAllFootprints() - { - for( FOOTPRINT* footprint : m_footprints ) - delete footprint; - - m_footprints.clear(); - } + void DeleteAllFootprints(); /** * @return null if aID is null. Returns an object of Type() == NOT_USED if diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 26c4a644c5..f179b41cb3 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_board_statistics.h b/pcbnew/dialogs/dialog_board_statistics.h index 110671a6da..a325f4f28f 100644 --- a/pcbnew/dialogs/dialog_board_statistics.h +++ b/pcbnew/dialogs/dialog_board_statistics.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_cleanup_graphics.cpp b/pcbnew/dialogs/dialog_cleanup_graphics.cpp index d4d5d16471..256b4f3c1c 100644 --- a/pcbnew/dialogs/dialog_cleanup_graphics.cpp +++ b/pcbnew/dialogs/dialog_cleanup_graphics.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_find.cpp b/pcbnew/dialogs/dialog_find.cpp index 15509e897c..c1ecd5c703 100644 --- a/pcbnew/dialogs/dialog_find.cpp +++ b/pcbnew/dialogs/dialog_find.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_footprint_checker.cpp b/pcbnew/dialogs/dialog_footprint_checker.cpp index 6f8f98ca19..53e1166644 100644 --- a/pcbnew/dialogs/dialog_footprint_checker.cpp +++ b/pcbnew/dialogs/dialog_footprint_checker.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 23bfa6ee55..7b6ca02e8d 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_unused_pad_layers.cpp b/pcbnew/dialogs/dialog_unused_pad_layers.cpp index caec62fe89..616b3d4de4 100644 --- a/pcbnew/dialogs/dialog_unused_pad_layers.cpp +++ b/pcbnew/dialogs/dialog_unused_pad_layers.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 3592599a9f..5fb2721c64 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -27,12 +27,14 @@ #include #include #include +#include #include #include #include #include -#include #include +#include +#include #include #include #include diff --git a/pcbnew/drc/drc_rtree.h b/pcbnew/drc/drc_rtree.h index 2efa494489..aef78e0abb 100644 --- a/pcbnew/drc/drc_rtree.h +++ b/pcbnew/drc/drc_rtree.h @@ -27,7 +27,9 @@ #include #include +#include #include +#include #include #include #include diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index 4d2c811d41..dba1f184cb 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -23,9 +23,11 @@ #include #include +#include #include #include #include +#include #include #include diff --git a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp index d451b421cf..c3381da3f8 100644 --- a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp @@ -25,6 +25,7 @@ #include #include #include +#include /* Couartyard clearance. Tests for malformed component courtyards and overlapping footprints. @@ -277,4 +278,4 @@ std::set DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::GetConstraintT namespace detail { static DRC_REGISTER_TEST_PROVIDER dummy; -} \ No newline at end of file +} diff --git a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp index c7a21e00b7..1ed01aa85c 100644 --- a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp +++ b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp @@ -34,6 +34,7 @@ #include #include +#include /* Differential pair gap/coupling test. diff --git a/pcbnew/drc/drc_test_provider_disallow.cpp b/pcbnew/drc/drc_test_provider_disallow.cpp index 36055c3500..43e6424c57 100644 --- a/pcbnew/drc/drc_test_provider_disallow.cpp +++ b/pcbnew/drc/drc_test_provider_disallow.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* "Disallow" test. Goes through all items, matching types/conditions drop errors. diff --git a/pcbnew/drc/drc_test_provider_hole_size.cpp b/pcbnew/drc/drc_test_provider_hole_size.cpp index 5d24469ee5..0e38b067fb 100644 --- a/pcbnew/drc/drc_test_provider_hole_size.cpp +++ b/pcbnew/drc/drc_test_provider_hole_size.cpp @@ -21,6 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include diff --git a/pcbnew/drc/drc_test_provider_hole_to_hole.cpp b/pcbnew/drc/drc_test_provider_hole_to_hole.cpp index 5f2c1287f1..f419e3dbf8 100644 --- a/pcbnew/drc/drc_test_provider_hole_to_hole.cpp +++ b/pcbnew/drc/drc_test_provider_hole_to_hole.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/pcbnew/drc/drc_test_provider_silk_clearance.cpp b/pcbnew/drc/drc_test_provider_silk_clearance.cpp index 093dc6f702..f87b389298 100644 --- a/pcbnew/drc/drc_test_provider_silk_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_silk_clearance.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include diff --git a/pcbnew/exporters/gendrill_gerber_writer.cpp b/pcbnew/exporters/gendrill_gerber_writer.cpp index 71abfba86d..d57fb49c50 100644 --- a/pcbnew/exporters/gendrill_gerber_writer.cpp +++ b/pcbnew/exporters/gendrill_gerber_writer.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index f78258acf5..43376e3628 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -37,7 +37,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/pcbnew/footprint.h b/pcbnew/footprint.h index 8bfa14b927..61ede54166 100644 --- a/pcbnew/footprint.h +++ b/pcbnew/footprint.h @@ -37,8 +37,8 @@ #include #include +#include #include -#include #include class LINE_READER; @@ -98,11 +98,6 @@ public: bool m_Show; ///< Include model in rendering }; -DECL_DEQ_FOR_SWIG( PADS, PAD* ) -DECL_DEQ_FOR_SWIG( DRAWINGS, BOARD_ITEM* ) -DECL_VEC_FOR_SWIG( FP_ZONES, FP_ZONE* ) -DECL_VEC_FOR_SWIG( FP_GROUPS, PCB_GROUP* ) -DECL_DEQ_FOR_SWIG( FOOTPRINTS, FOOTPRINT* ) class FOOTPRINT : public BOARD_ITEM_CONTAINER { diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 1c2cb868ee..d2564cb8ae 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/netinfo_item.cpp b/pcbnew/netinfo_item.cpp index af32d6fb2d..57e86fd14b 100644 --- a/pcbnew/netinfo_item.cpp +++ b/pcbnew/netinfo_item.cpp @@ -32,7 +32,9 @@ #include #include #include +#include #include +#include /*********************************************************/ diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index 2542be1f52..3757bce5d3 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -40,6 +40,7 @@ #include #include #include +#include PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index a01b8cbf68..1566c9b9e0 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/pcb_item_containers.h b/pcbnew/pcb_item_containers.h new file mode 100644 index 0000000000..3404470ecb --- /dev/null +++ b/pcbnew/pcb_item_containers.h @@ -0,0 +1,58 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PCB_ITEM_CONTAINERS_H_ +#define PCB_ITEM_CONTAINERS_H_ + +#include + +// Board-level items +class FOOTPRINT; +class TRACK; +class PCB_GROUP; +class PCB_MARKER; +class ZONE; + +DECL_VEC_FOR_SWIG( MARKERS, PCB_MARKER* ) +DECL_VEC_FOR_SWIG( ZONES, ZONE* ) +DECL_DEQ_FOR_SWIG( TRACKS, TRACK* ) +DECL_DEQ_FOR_SWIG( FOOTPRINTS, FOOTPRINT* ) +// Dequeue rather than Vector just so we can use moveUnflaggedItems in pcbnew_control.cpp +DECL_DEQ_FOR_SWIG( GROUPS, PCB_GROUP* ) + + +// Shared with board and footprint +class BOARD_ITEM; + +DECL_DEQ_FOR_SWIG( DRAWINGS, BOARD_ITEM* ) + + +// Footprint-level items +class FP_ZONE; +class PAD; + +DECL_DEQ_FOR_SWIG( PADS, PAD* ) +DECL_VEC_FOR_SWIG( FP_ZONES, FP_ZONE* ) +DECL_VEC_FOR_SWIG( FP_GROUPS, PCB_GROUP* ) + +#endif // PCB_ITEM_CONTAINERS_H_ diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 31ee45f70f..15a37d2318 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 13169d1e12..3940a9045b 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -35,6 +35,7 @@ #include #include +#include #include diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h index b336fefca9..f7bb6ddd7e 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.h @@ -29,6 +29,7 @@ #include #include #include +#include #include class BOARD; diff --git a/pcbnew/plugins/fabmaster/import_fabmaster.cpp b/pcbnew/plugins/fabmaster/import_fabmaster.cpp index 17b63f201a..a20ce4b3a1 100644 --- a/pcbnew/plugins/fabmaster/import_fabmaster.cpp +++ b/pcbnew/plugins/fabmaster/import_fabmaster.cpp @@ -41,11 +41,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/pcbnew/plugins/pcad/pcb_polygon.cpp b/pcbnew/plugins/pcad/pcb_polygon.cpp index aad65b9eeb..057b18c9e1 100644 --- a/pcbnew/plugins/pcad/pcb_polygon.cpp +++ b/pcbnew/plugins/pcad/pcb_polygon.cpp @@ -33,6 +33,7 @@ #include // for KiROUND #include #include +#include namespace PCAD2KICAD { diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 8dedbf95a3..760a4d45a6 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -30,6 +30,7 @@ using namespace std::placeholders; #include #include #include +#include #include #include #include diff --git a/pcbnew/tools/drawing_stackup_table_tool.cpp b/pcbnew/tools/drawing_stackup_table_tool.cpp index 222e5bdc55..a97d6ea890 100644 --- a/pcbnew/tools/drawing_stackup_table_tool.cpp +++ b/pcbnew/tools/drawing_stackup_table_tool.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/tools/footprint_editor_control.cpp b/pcbnew/tools/footprint_editor_control.cpp index 911520f38f..caf820a613 100644 --- a/pcbnew/tools/footprint_editor_control.cpp +++ b/pcbnew/tools/footprint_editor_control.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp index 3df943b56f..3078eb5e70 100644 --- a/pcbnew/tools/global_edit_tool.cpp +++ b/pcbnew/tools/global_edit_tool.cpp @@ -21,7 +21,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include +#include #include #include #include diff --git a/pcbnew/tools/group_tool.cpp b/pcbnew/tools/group_tool.cpp index 6414f7e4eb..140e55db73 100644 --- a/pcbnew/tools/group_tool.cpp +++ b/pcbnew/tools/group_tool.cpp @@ -31,7 +31,8 @@ #include #include #include - +#include +#include class GROUP_CONTEXT_MENU : public ACTION_MENU { diff --git a/pcbnew/tools/position_relative_tool.cpp b/pcbnew/tools/position_relative_tool.cpp index ff821be08c..6d065a0ce5 100644 --- a/pcbnew/tools/position_relative_tool.cpp +++ b/pcbnew/tools/position_relative_tool.cpp @@ -35,6 +35,7 @@ using namespace std::placeholders; #include #include #include +#include POSITION_RELATIVE_TOOL::POSITION_RELATIVE_TOOL() : diff --git a/pcbnew/tools/zone_create_helper.cpp b/pcbnew/tools/zone_create_helper.cpp index e861080c38..3a9505979c 100644 --- a/pcbnew/tools/zone_create_helper.cpp +++ b/pcbnew/tools/zone_create_helper.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp index 790758e383..59d3ebc5d8 100644 --- a/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp +++ b/qa/pcbnew_tools/tools/polygon_generator/polygon_generator.cpp @@ -35,6 +35,7 @@ #include #include #include +#include void process( const BOARD_CONNECTED_ITEM* item, int net ) diff --git a/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp b/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp index 9c5a790408..79c07f6d63 100644 --- a/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp +++ b/qa/pcbnew_tools/tools/polygon_triangulation/polygon_triangulation.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include