Browse Source

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

pull/16/head
Ian McInerney 6 years ago
committed by Ian McInerney
parent
commit
78c43158f4
  1. 4
      3d-viewer/3d_cache/dialogs/panel_prev_3d.cpp
  2. 4
      cvpcb/display_footprints_frame.cpp
  3. 1
      pcbnew/class_board.cpp
  4. 37
      pcbnew/class_board.h
  5. 4
      pcbnew/footprint_edit_frame.cpp
  6. 4
      pcbnew/footprint_viewer_frame.cpp
  7. 3
      pcbnew/initpcb.cpp

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

4
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

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

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

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

4
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

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

Loading…
Cancel
Save