From 78c43158f419d31e108d25592d32a1851c8a494b Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 27 Feb 2020 17:46:49 +0000 Subject: [PATCH] Annotate the board class with if it is for a footprint edit/view --- 3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp | 4 +++ cvpcb/display_footprints_frame.cpp | 4 +++ pcbnew/class_board.cpp | 1 + pcbnew/class_board.h | 37 ++++++++++++++++++++ pcbnew/footprint_edit_frame.cpp | 4 +++ pcbnew/footprint_viewer_frame.cpp | 4 +++ pcbnew/initpcb.cpp | 3 ++ 7 files changed, 57 insertions(+) diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp index a10b4b754e..df51a938b3 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp @@ -51,6 +51,10 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* m_userUnits = aFrame->GetUserUnits(); m_dummyBoard = new BOARD(); + + // This board will only be used to hold a footprint for viewing + m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER ); + m_selected = -1; // Set the bitmap of 3D view buttons: diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index eb039727e7..ab5d90b626 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -75,6 +75,10 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa SetIcon( icon ); SetBoard( new BOARD() ); + + // This board will only be used to hold a footprint for viewing + GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); + SetScreen( new PCB_SCREEN( GetPageSizeIU() ) ); // Create GAL canvas before loading settings diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 423cb42a76..48410bb5a3 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -58,6 +58,7 @@ wxPoint BOARD_ITEM::ZeroOffset( 0, 0 ); BOARD::BOARD() : BOARD_ITEM_CONTAINER( (BOARD_ITEM*) NULL, PCB_T ), + m_boardUse( BOARD_USE::NORMAL ), m_paper( PAGE_INFO::A4 ), m_project( nullptr ), m_designSettings( new BOARD_DESIGN_SETTINGS( nullptr, "board.design_settings" ) ), diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index d03746ee55..f7100a5caf 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -170,6 +170,16 @@ 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. + */ +enum class BOARD_USE +{ + NORMAL, // A normal board + FPHOLDER // A board that holds a single footprint +}; + + /** * Information pertinent to a Pcbnew printed circuit board. */ @@ -178,6 +188,9 @@ class BOARD : public BOARD_ITEM_CONTAINER friend class PCB_EDIT_FRAME; private: + /// What is this board being used for + BOARD_USE m_boardUse; + wxString m_fileName; MARKERS m_markers; DRAWINGS m_drawings; @@ -237,6 +250,30 @@ public: return aItem && PCB_T == aItem->Type(); } + /** + * Set what the board is going to be used for. + * + * @param aUse is the flag + */ + void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; } + + /** + * Get what the board use is. + * + * @return what the board is being used for + */ + BOARD_USE GetBoardUse() { return m_boardUse; } + + /** + * Find out if the board is being used to hold a single footprint for editing/viewing. + * + * @return if the board is just holding a footprint + */ + bool IsFootprintHolder() + { + return m_boardUse == BOARD_USE::FPHOLDER; + } + void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; } const wxString &GetFileName() const { return m_fileName; } diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 6c1ecc6a50..86b0475d92 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -135,6 +135,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, SetCanvas( drawPanel ); SetBoard( new BOARD() ); + + // This board will only be used to hold a footprint for editing + GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); + // In modedit, the default net clearance is not known (it depends on the actual board). // So we do not show the default clearance, by setting it to 0. // The footprint or pad specific clearance will be shown. diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 2c94a42042..bc342e8dd3 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -175,6 +175,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent SetCanvas( drawPanel ); SetBoard( new BOARD() ); + + // This board will only be used to hold a footprint for viewing + GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); + // In viewer, the default net clearance is not known (it depends on the actual board). // So we do not show the default clearance, by setting it to 0 // The footprint or pad specific clearance will be shown diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 094b81701a..f6761a3518 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -119,6 +119,9 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) board->SynchronizeNetsAndNetClasses(); SetBoard( board ); + // This board will only be used to hold a footprint for editing + GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER ); + // clear filename, to avoid overwriting an old file GetBoard()->SetFileName( wxEmptyString );