Annotate the board class with if it is for a footprint edit/view

This commit is contained in:
Ian McInerney 2020-02-27 17:46:49 +00:00 committed by Ian McInerney
parent 5482307ac8
commit 78c43158f4
7 changed files with 57 additions and 0 deletions

View File

@ -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:

View File

@ -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

View File

@ -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" ) ),

View File

@ -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; }

View File

@ -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.

View File

@ -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

View File

@ -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 );