Module -> Footprint.

This commit is contained in:
Jeff Young 2020-11-08 21:29:04 +00:00
parent 74dc7571d7
commit 4dc877d0e9
32 changed files with 318 additions and 308 deletions

View File

@ -500,7 +500,7 @@ void DISPLAY_FOOTPRINTS_FRAME::updateView()
void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel()
{
MODULE* footprint = GetBoard()->GetFirstModule();
MODULE* footprint = GetBoard()->GetFirstFootprint();
MSG_PANEL_ITEMS items;
if( footprint )
@ -523,7 +523,7 @@ COLOR_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetColorSettings()
BOARD_ITEM_CONTAINER* DISPLAY_FOOTPRINTS_FRAME::GetModel() const
{
return GetBoard()->GetFirstModule();
return GetBoard()->GetFirstFootprint();
}

View File

@ -289,17 +289,16 @@ public:
// footprints (footprints)
/**
* Function CreateNewModule
* Creates a new module or footprint, at position 0,0
* The new module contains only 2 texts: a reference and a value:
* Function CreateNewFootprint
* Creates a new footprint, at position 0,0
* The new footprint contains only 2 texts: a reference and a value:
* Reference = REF**
* Value = "VAL**" or Footprint name in lib
* Note: they are dummy texts, which will be replaced by the actual texts
* when the fooprint is placed on a board and a netlist is read
* @param aModuleName = name of the new footprint in library
* @return a reference to the new module
* @param aFootprintName = name of the new footprint in library
*/
MODULE* CreateNewModule( const wxString& aModuleName );
MODULE* CreateNewFootprint( const wxString& aFootprintName );
/**
* Function PlaceModule

View File

@ -52,7 +52,7 @@ void ARRAY_CREATOR::Invoke()
if( m_selection.Size() == 0 )
return;
MODULE* const module = m_editModules ? m_parent.GetBoard()->GetFirstModule() : nullptr;
MODULE* const module = m_editModules ? m_parent.GetBoard()->GetFirstFootprint() : nullptr;
const bool enableArrayNumbering = m_editModules;
const wxPoint rotPoint = (wxPoint) m_selection.GetCenter();

View File

@ -41,14 +41,14 @@ using namespace std::placeholders;
BOARD_COMMIT::BOARD_COMMIT( PCB_TOOL_BASE* aTool )
{
m_toolMgr = aTool->GetManager();
m_editModules = aTool->IsFootprintEditor();
m_isFootprintEditor = aTool->IsFootprintEditor();
}
BOARD_COMMIT::BOARD_COMMIT( EDA_DRAW_FRAME* aFrame )
{
m_toolMgr = aFrame->GetToolManager();
m_editModules = aFrame->IsType( FRAME_FOOTPRINT_EDITOR );
m_isFootprintEditor = aFrame->IsType( FRAME_FOOTPRINT_EDITOR );
}
@ -103,7 +103,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
// Module items need to be saved in the undo buffer before modification
if( m_editModules )
if( m_isFootprintEditor )
{
// Be sure that we are storing a module
if( ent.m_item->Type() != PCB_MODULE_T )
@ -138,7 +138,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
{
case CHT_ADD:
{
if( m_editModules )
if( m_isFootprintEditor )
{
// footprints inside footprints are not supported yet
wxASSERT( boardItem->Type() != PCB_MODULE_T );
@ -172,7 +172,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case CHT_REMOVE:
{
if( !m_editModules && aCreateUndoEntry )
if( !m_isFootprintEditor && aCreateUndoEntry )
undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
if( boardItem->IsSelected() )
@ -189,7 +189,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_FP_TEXT_T:
case PCB_FP_ZONE_AREA_T:
// This level can only handle module items when editing footprints
wxASSERT( m_editModules );
wxASSERT( m_isFootprintEditor );
if( boardItem->Type() == PCB_FP_TEXT_T )
{
@ -234,7 +234,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_MODULE_T:
{
// There are no footprints inside a module yet
wxASSERT( !m_editModules );
wxASSERT( !m_isFootprintEditor );
MODULE* module = static_cast<MODULE*>( boardItem );
view->Remove( module );
@ -248,8 +248,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_GROUP_T:
if( !( changeFlags & CHT_DONE ) )
{
if( m_editModules )
board->GetFirstModule()->Remove( boardItem );
if( m_isFootprintEditor )
board->GetFirstFootprint()->Remove( boardItem );
else
board->Remove( boardItem );
}
@ -270,7 +270,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case CHT_MODIFY:
{
if( !m_editModules && aCreateUndoEntry )
if( !m_isFootprintEditor && aCreateUndoEntry )
{
ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
wxASSERT( ent.m_copy );
@ -284,7 +284,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
connectivity->Update( boardItem );
view->Update( boardItem );
if( m_editModules )
if( m_isFootprintEditor )
{
static_cast<MODULE*>( boardItem )->RunOnChildren( [&]( BOARD_ITEM* aChild )
{
@ -307,7 +307,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
}
}
if ( !m_editModules )
if ( !m_isFootprintEditor )
{
size_t num_changes = m_changes.size();
@ -343,7 +343,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
}
}
if( !m_editModules && aCreateUndoEntry )
if( !m_isFootprintEditor && aCreateUndoEntry )
frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
m_toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } );
@ -439,7 +439,7 @@ void BOARD_COMMIT::Revert()
}
}
if ( !m_editModules )
if ( !m_isFootprintEditor )
connectivity->RecalculateRatsnest();
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();

View File

@ -57,9 +57,11 @@ public:
bool HasRemoveEntry( EDA_ITEM* aItem );
private:
TOOL_MANAGER* m_toolMgr;
bool m_editModules;
virtual EDA_ITEM* parentObject( EDA_ITEM* aItem ) const override;
private:
TOOL_MANAGER* m_toolMgr;
bool m_isFootprintEditor;
};
#endif

View File

@ -341,10 +341,11 @@ public:
void Remove( BOARD_ITEM* aBoardItem ) override;
/**
* Gets the first module in the list (used in footprint viewer/editor) or NULL if none
* Gets the first footprint on the board or nullptr.
* This is used primarily by the footprint editor which knows there is only one.
* @return first module or null pointer
*/
MODULE* GetFirstModule() const
MODULE* GetFirstFootprint() const
{
return m_modules.empty() ? nullptr : m_modules.front();
}

View File

@ -1021,11 +1021,9 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
std::vector<wxPoint>* aIntersections )
{
PCB_TYPE_COLLECTOR items;
SHAPE_POLY_SET outlines;
// Get all the DRAWSEGMENTS and module graphics into 'items',
// then keep only those on layer == Edge_Cuts.
// Get all the SHAPEs into 'items', then keep only those on layer == Edge_Cuts.
static const KICAD_T scan_graphics[] = { PCB_SHAPE_T, PCB_FP_SHAPE_T, EOT };
items.Collect( aBoard, scan_graphics );
@ -1041,12 +1039,12 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
bool success = ConvertOutlineToPolygon( segList, outlines, aTolerance, aErrorText,
aDiscontinuities, aIntersections );
MODULE* boardMod = aBoard->GetFirstModule();
MODULE* footprint = aBoard->GetFirstFootprint();
// No module loaded
if( !boardMod )
// No footprint loaded
if( !footprint )
{
wxLogTrace( traceBoardOutline, "No module found on board" );
wxLogTrace( traceBoardOutline, "No footprint found on board" );
if( aErrorText )
*aErrorText = _( "No footprint loaded" );
@ -1060,7 +1058,7 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
wxLogTrace( traceBoardOutline, "Closed outline found" );
// If copper is outside a closed polygon, treat it as a hole
if( isCopperOutside( boardMod, outlines ) )
if( isCopperOutside( footprint, outlines ) )
{
wxLogTrace( traceBoardOutline, "Treating outline as a hole" );
@ -1315,7 +1313,7 @@ bool BuildFootprintPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
poly2.NewOutline();
poly2.Append( lower );
if( isCopperOutside( boardMod, poly1 ) )
if( isCopperOutside( footprint, poly1 ) )
{
wxLogTrace( traceBoardOutline, "Using lower shape" );
aOutlines = poly2;

View File

@ -29,10 +29,11 @@
#include <pcb_base_frame.h>
DIALOG_CLEANUP_GRAPHICS::DIALOG_CLEANUP_GRAPHICS( PCB_BASE_FRAME* aParent, bool isModEdit ) :
DIALOG_CLEANUP_GRAPHICS::DIALOG_CLEANUP_GRAPHICS( PCB_BASE_FRAME* aParent,
bool aIsFootprintEditor ) :
DIALOG_CLEANUP_GRAPHICS_BASE( aParent ),
m_parentFrame( aParent ),
m_isModEdit( isModEdit )
m_isFootprintEditor( aIsFootprintEditor )
{
m_changesTreeModel = new RC_TREE_MODEL( m_parentFrame, m_changesDataView );
m_changesDataView->AssociateModel( m_changesTreeModel );
@ -41,7 +42,7 @@ DIALOG_CLEANUP_GRAPHICS::DIALOG_CLEANUP_GRAPHICS( PCB_BASE_FRAME* aParent, bool
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
// that requires us to correct the button labels here.
m_sdbSizerOK->SetLabel( isModEdit ? _( "Update Footprint" ) : _( "Update PCB" ) );
m_sdbSizerOK->SetLabel( aIsFootprintEditor ? _( "Update Footprint" ) : _( "Update PCB" ) );
m_sdbSizerOK->SetDefault();
GetSizer()->SetSizeHints(this);
@ -83,7 +84,7 @@ void DIALOG_CLEANUP_GRAPHICS::doCleanup( bool aDryRun )
BOARD_COMMIT commit( m_parentFrame );
BOARD* board = m_parentFrame->GetBoard();
MODULE* fp = m_isModEdit ? board->GetFirstModule() : nullptr;
MODULE* fp = m_isFootprintEditor ? board->GetFirstFootprint() : nullptr;
GRAPHICS_CLEANER cleaner( fp ? fp->GraphicalItems() : board->Drawings(), fp, commit );
if( !aDryRun )

View File

@ -35,10 +35,11 @@ class PCB_BASE_FRAME;
class DIALOG_CLEANUP_GRAPHICS: public DIALOG_CLEANUP_GRAPHICS_BASE
{
PCB_BASE_FRAME* m_parentFrame;
bool m_isModEdit;
std::vector<std::shared_ptr<CLEANUP_ITEM> > m_items;
bool m_isFootprintEditor;
RC_TREE_MODEL* m_changesTreeModel;
std::vector<std::shared_ptr<CLEANUP_ITEM> > m_items;
void doCleanup( bool aDryRun );
void OnCheckBox( wxCommandEvent& anEvent ) override;
@ -49,7 +50,7 @@ class DIALOG_CLEANUP_GRAPHICS: public DIALOG_CLEANUP_GRAPHICS_BASE
bool TransferDataFromWindow() override;
public:
DIALOG_CLEANUP_GRAPHICS( PCB_BASE_FRAME* aParent, bool isModEdit );
DIALOG_CLEANUP_GRAPHICS( PCB_BASE_FRAME* aParent, bool aIsFootprintEditor );
~DIALOG_CLEANUP_GRAPHICS();
};

View File

@ -299,7 +299,7 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
bool FOOTPRINT_EDIT_FRAME::IsContentModified()
{
return GetScreen() && GetScreen()->IsModify() && GetBoard() && GetBoard()->GetFirstModule();
return GetScreen() && GetScreen()->IsModify() && GetBoard() && GetBoard()->GetFirstFootprint();
}
@ -346,7 +346,7 @@ bool FOOTPRINT_EDIT_FRAME::IsSearchTreeShown()
BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const
{
return GetBoard()->GetFirstModule();
return GetBoard()->GetFirstFootprint();
}
@ -375,7 +375,7 @@ LIB_ID FOOTPRINT_EDIT_FRAME::GetTargetFPID() const
LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const
{
MODULE* footprint = GetBoard()->GetFirstModule();
MODULE* footprint = GetBoard()->GetFirstFootprint();
if( footprint )
return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
@ -386,7 +386,7 @@ LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const
bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const
{
MODULE* footprint = GetBoard()->GetFirstModule();
MODULE* footprint = GetBoard()->GetFirstFootprint();
return ( footprint && footprint->GetLink() != niluuid );
}
@ -534,7 +534,7 @@ MAGNETIC_SETTINGS* FOOTPRINT_EDIT_FRAME::GetMagneticItemsSettings()
const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
{
MODULE* footprint = GetBoard()->GetFirstModule();
MODULE* footprint = GetBoard()->GetFirstFootprint();
if( footprint )
{
@ -579,13 +579,13 @@ bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
return false;
}
wxString footprintName = GetBoard()->GetFirstModule()->GetFPID().GetLibItemName();
wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
wxString msg = _( "Save changes to \"%s\" before closing?" );
if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
[&]() -> bool
{
return SaveFootprint( GetBoard()->GetFirstModule() );
return SaveFootprint( GetBoard()->GetFirstFootprint() );
} ) )
{
aEvent.Veto();
@ -629,7 +629,7 @@ void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( GetBoard()->GetFirstModule() != NULL );
aEvent.Enable( GetBoard()->GetFirstFootprint() != NULL );
}
@ -637,7 +637,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent
{
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
aEvent.Enable( frame && frame->GetBoard()->GetFirstModule() != NULL );
aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != NULL );
}
@ -645,7 +645,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent
{
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
MODULE* editorFootprint = GetBoard()->GetFirstModule();
MODULE* editorFootprint = GetBoard()->GetFirstFootprint();
bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
// If the source was deleted, the footprint can inserted but not updated in the board.
@ -708,12 +708,14 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
{
wxString title;
LIB_ID fpid = GetLoadedFPID();
MODULE* footprint = GetBoard()->GetFirstFootprint();
bool writable = true;
if( IsCurrentFPFromBoard() )
{
title += wxString::Format( _( "%s [from %s.%s]" ) + wxT( " \u2014 " ),
GetBoard()->GetFirstModule()->GetReference(), Prj().GetProjectName(),
footprint->GetReference(),
Prj().GetProjectName(),
PcbFileExtension );
}
else if( fpid.IsValid() )
@ -729,14 +731,15 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
// Note: don't used GetLoadedFPID(); footprint name may have been edited
title += wxString::Format( wxT( "%s %s\u2014 " ),
FROM_UTF8( GetBoard()->GetFirstModule()->GetFPID().Format().c_str() ),
writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) + wxS( "" ) + wxS( " " ));
FROM_UTF8( footprint->GetFPID().Format().c_str() ),
writable ? wxString( wxEmptyString )
: _( "[Read Only]" ) + wxS( " " ) );
}
else if( !fpid.GetLibItemName().empty() )
{
// Note: don't used GetLoadedFPID(); footprint name may have been edited
title += wxString::Format( wxT( "%s %s \u2014 " ),
FROM_UTF8( GetBoard()->GetFirstModule()->GetFPID().GetLibItemName().c_str() ),
FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() ),
_( "[Unsaved]" ) );
}
@ -921,7 +924,7 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
auto haveFootprintCond =
[this]( const SELECTION& )
{
return GetBoard()->GetFirstModule() != nullptr;
return GetBoard()->GetFirstFootprint() != nullptr;
};
auto footprintTargettedCond =

View File

@ -175,10 +175,10 @@ public:
/**
* Save in an existing library a given footprint.
*
* @param aModule = the given footprint
* @param aFootprint = the given footprint
* @return : true if OK, false if abort
*/
bool SaveFootprint( MODULE* aModule );
bool SaveFootprint( MODULE* aFootprint );
bool SaveFootprintAs( MODULE* aModule );
bool SaveFootprintToBoard( bool aAddNew );
bool SaveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );

View File

@ -62,27 +62,23 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
{
bool is_last_fp_from_brd = IsCurrentFPFromBoard();
MODULE* module = LoadFootprint( aFPID );
MODULE* footprint = LoadFootprint( aFPID );
if( !module )
if( !footprint )
return;
if( !Clear_Pcb( true ) )
return;
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
AddModuleToBoard( module );
AddModuleToBoard( footprint );
auto fp = GetBoard()->GetFirstModule();
if( fp )
{
fp->ClearFlags();
footprint->ClearFlags();
// if either m_Reference or m_Value are gone, reinstall them -
// otherwise you cannot see what you are doing on board
FP_TEXT* ref = &fp->Reference();
FP_TEXT* val = &fp->Value();
FP_TEXT* ref = &footprint->Reference();
FP_TEXT* val = &footprint->Value();
if( val && ref )
{
@ -96,7 +92,6 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
if( val->GetLength() == 0 )
val->SetText( wxT( "Val**" ) );
}
}
if( m_zoomSelectBox->GetSelection() == 0 )
Zoom_Automatique( false );
@ -134,7 +129,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_NEW_MODULE:
{
LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
MODULE* module = CreateNewModule( wxEmptyString );
MODULE* module = CreateNewFootprint( wxEmptyString );
if( !module )
break;
@ -151,8 +146,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetBoard()->BuildListOfNets();
module->SetPosition( wxPoint( 0, 0 ) );
if( GetBoard()->GetFirstModule() )
GetBoard()->GetFirstModule()->ClearFlags();
if( GetBoard()->GetFirstFootprint() )
GetBoard()->GetFirstFootprint()->ClearFlags();
Zoom_Automatique( false );
GetScreen()->SetModify();
@ -183,8 +178,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. "
"Save changes?" ),
[&]() -> bool {
return SaveFootprint( GetBoard()->GetFirstModule() );
[&]() -> bool
{
return SaveFootprint( GetBoard()->GetFirstFootprint() );
} ) )
{
break;
@ -240,14 +236,14 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_MODEDIT_SAVE:
if( !GetBoard()->GetFirstModule() ) // no loaded footprint
if( !GetBoard()->GetFirstFootprint() ) // no loaded footprint
break;
if( GetTargetFPID() == GetLoadedFPID() )
{
if( SaveFootprint( GetBoard()->GetFirstModule() ) )
if( SaveFootprint( GetBoard()->GetFirstFootprint() ) )
{
m_toolManager->GetView()->Update( GetBoard()->GetFirstModule() );
m_toolManager->GetView()->Update( GetBoard()->GetFirstFootprint() );
GetCanvas()->ForceRefresh();
GetScreen()->ClrModify();
@ -270,7 +266,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
else if( GetTargetFPID() == GetLoadedFPID() )
{
// Save Board Footprint As
MODULE* footprint = GetBoard()->GetFirstModule();
MODULE* footprint = GetBoard()->GetFirstFootprint();
if( footprint && SaveFootprintAs( footprint ) )
{
@ -441,8 +437,8 @@ bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileS
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
Import_Module( aFileSet[0] );
if( GetBoard()->GetFirstModule() )
GetBoard()->GetFirstModule()->ClearFlags();
if( GetBoard()->GetFirstFootprint() )
GetBoard()->GetFirstFootprint()->ClearFlags();
GetScreen()->ClrModify();
Zoom_Automatique( false );

View File

@ -612,7 +612,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aC
void PCB_EDIT_FRAME::HarvestFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName,
wxString* aLibPath )
{
if( GetBoard()->GetFirstModule() == NULL )
if( GetBoard()->GetFirstFootprint() == NULL )
{
DisplayInfoMessage( this, _( "No footprints to harvest!" ) );
return;
@ -698,16 +698,16 @@ void PCB_EDIT_FRAME::HarvestFootprintsToLibrary( bool aStoreInNewLib, const wxSt
}
bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule )
bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aFootprint )
{
if( !aModule ) // Happen if no footprint loaded
if( !aFootprint ) // Happen if no footprint loaded
return false;
wxString libraryName = aModule->GetFPID().GetLibNickname();
wxString footprintName = aModule->GetFPID().GetLibItemName();
wxString libraryName = aFootprint->GetFPID().GetLibNickname();
wxString footprintName = aFootprint->GetFPID().GetLibItemName();
bool nameChanged = m_footprintNameWhenLoaded != footprintName;
if( aModule->GetLink() != niluuid )
if( aFootprint->GetLink() != niluuid )
{
if( SaveFootprintToBoard( false ) )
{
@ -719,7 +719,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule )
}
else if( libraryName.IsEmpty() || footprintName.IsEmpty() )
{
if( SaveFootprintAs( aModule ) )
if( SaveFootprintAs( aFootprint ) )
{
m_footprintNameWhenLoaded = footprintName;
SyncLibraryTree( true );
@ -747,7 +747,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule )
DeleteModuleFromLibrary( oldFPID, false );
}
if( !SaveFootprintInLibrary( aModule, libraryName ) )
if( !SaveFootprintInLibrary( aFootprint, libraryName ) )
return false;
if( nameChanged )
@ -795,7 +795,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
BOARD* mainpcb = pcbframe->GetBoard();
MODULE* source_module = NULL;
MODULE* module_in_edit = GetBoard()->GetFirstModule();
MODULE* module_in_edit = GetBoard()->GetFirstFootprint();
// Search the old module (source) if exists
// Because this source could be deleted when editing the main board...
@ -1018,62 +1018,62 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
}
MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
MODULE* PCB_BASE_FRAME::CreateNewFootprint( const wxString& aFootprintName )
{
wxString moduleName = aModuleName;
wxString footprintName = aFootprintName;
// Ask for the new module name
if( moduleName.IsEmpty() )
if( footprintName.IsEmpty() )
{
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ),
moduleName );
dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &moduleName ) );
footprintName );
dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &footprintName ) );
if( dlg.ShowModal() != wxID_OK )
return NULL; //Aborted by user
}
moduleName.Trim( true );
moduleName.Trim( false );
footprintName.Trim( true );
footprintName.Trim( false );
if( moduleName.IsEmpty() )
if( footprintName.IsEmpty() )
{
DisplayInfoMessage( this, _( "No footprint name defined." ) );
return NULL;
}
// Creates the new module and add it to the head of the linked list of footprints
MODULE* module = new MODULE( GetBoard() );
// Creates the new footprint and add it to the head of the linked list of footprints
MODULE* footprint = new MODULE( GetBoard() );
// Update parameters: timestamp ...
module->SetLastEditTime();
footprint->SetLastEditTime();
// Update its name in lib
module->SetFPID( LIB_ID( wxEmptyString, moduleName ) );
footprint->SetFPID( LIB_ID( wxEmptyString, footprintName ) );
PCB_LAYER_ID txt_layer;
wxPoint default_pos;
BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();
module->Reference().SetText( settings.m_DefaultFPTextItems[0].m_Text );
module->Reference().SetVisible( settings.m_DefaultFPTextItems[0].m_Visible );
footprint->Reference().SetText( settings.m_DefaultFPTextItems[0].m_Text );
footprint->Reference().SetVisible( settings.m_DefaultFPTextItems[0].m_Visible );
txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[0].m_Layer;
module->Reference().SetLayer( txt_layer );
footprint->Reference().SetLayer( txt_layer );
default_pos.y -= settings.GetTextSize( txt_layer ).y / 2;
module->Reference().SetPosition( default_pos );
footprint->Reference().SetPosition( default_pos );
default_pos.y += settings.GetTextSize( txt_layer ).y;
module->Value().SetText( settings.m_DefaultFPTextItems[1].m_Text );
module->Value().SetVisible( settings.m_DefaultFPTextItems[1].m_Visible );
footprint->Value().SetText( settings.m_DefaultFPTextItems[1].m_Text );
footprint->Value().SetVisible( settings.m_DefaultFPTextItems[1].m_Visible );
txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[1].m_Layer;
module->Value().SetLayer( txt_layer );
footprint->Value().SetLayer( txt_layer );
default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
module->Value().SetPosition( default_pos );
footprint->Value().SetPosition( default_pos );
default_pos.y += settings.GetTextSize( txt_layer ).y;
for( size_t i = 2; i < settings.m_DefaultFPTextItems.size(); ++i )
{
FP_TEXT* textItem = new FP_TEXT( module );
FP_TEXT* textItem = new FP_TEXT( footprint );
textItem->SetText( settings.m_DefaultFPTextItems[i].m_Text );
textItem->SetVisible( settings.m_DefaultFPTextItems[i].m_Visible );
txt_layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[i].m_Layer;
@ -1081,16 +1081,16 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
default_pos.y += settings.GetTextSize( txt_layer ).y / 2;
textItem->SetPosition( default_pos );
default_pos.y += settings.GetTextSize( txt_layer ).y;
module->GraphicalItems().push_back( textItem );
footprint->GraphicalItems().push_back( textItem );
}
if( module->GetReference().IsEmpty() )
module->SetReference( moduleName );
if( footprint->GetReference().IsEmpty() )
footprint->SetReference( footprintName );
if( module->GetValue().IsEmpty() )
module->SetValue( moduleName );
if( footprint->GetValue().IsEmpty() )
footprint->SetValue( footprintName );
module->RunOnChildren(
footprint->RunOnChildren(
[&] ( BOARD_ITEM* aChild )
{
if( aChild->Type() == PCB_FP_TEXT_T )
@ -1105,8 +1105,8 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
}
} );
SetMsgPanel( module );
return module;
SetMsgPanel( footprint );
return footprint;
}

View File

@ -719,7 +719,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
DismissModal( false );
}
}
else if( GetBoard()->GetFirstModule() )
else if( GetBoard()->GetFirstFootprint() )
{
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
@ -733,7 +733,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
BOARD_COMMIT commit( pcbframe );
// Create the "new" footprint
MODULE* newFootprint = (MODULE*) GetBoard()->GetFirstModule()->Duplicate();
MODULE* newFootprint = (MODULE*) GetBoard()->GetFirstFootprint()->Duplicate();
newFootprint->SetParent( pcbframe->GetBoard() );
newFootprint->SetLink( 0 );
@ -890,7 +890,7 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( GetBoard()->GetFirstModule() != nullptr );
aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
}
@ -1076,6 +1076,6 @@ void FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer( wxCommandEvent& event )
BOARD_ITEM_CONTAINER* FOOTPRINT_VIEWER_FRAME::GetModel() const
{
return GetBoard()->GetFirstModule();
return GetBoard()->GetFirstFootprint();
}

View File

@ -301,7 +301,7 @@ void FOOTPRINT_WIZARD_FRAME::updateView()
void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel()
{
BOARD_ITEM* footprint = GetBoard()->GetFirstModule();
BOARD_ITEM* footprint = GetBoard()->GetFirstFootprint();
if( footprint )
{
@ -631,7 +631,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
BOARD_ITEM_CONTAINER* FOOTPRINT_WIZARD_FRAME::GetModel() const
{
return GetBoard()->GetFirstModule();
return GetBoard()->GetFirstFootprint();
}

View File

@ -189,7 +189,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
case 1:
if( node->m_LibId == m_frame->GetLoadedFPID() && !m_frame->IsCurrentFPFromBoard() )
node->m_Desc = m_frame->GetBoard()->GetFirstModule()->GetDescription();
node->m_Desc = m_frame->GetBoard()->GetFirstFootprint()->GetDescription();
aVariant = node->m_Desc;
break;

View File

@ -49,7 +49,7 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo
m_parent = aParent;
if( aImportAsFootprintGraphic )
m_importer = std::make_unique<GRAPHICS_IMPORTER_MODULE>( m_parent->GetBoard()->GetFirstModule() );
m_importer = std::make_unique<GRAPHICS_IMPORTER_MODULE>( m_parent->GetBoard()->GetFirstFootprint() );
else
m_importer = std::make_unique<GRAPHICS_IMPORTER_BOARD>( m_parent->GetBoard() );

View File

@ -89,7 +89,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( MODULE* aFootprint )
if( aFootprint == NULL )
{
if( !frame->GetBoard() || !frame->GetBoard()->GetFirstModule() )
if( !frame->GetBoard() || !frame->GetBoard()->GetFirstFootprint() )
return false;
aFootprint = SelectFootprintFromBoard( frame->GetBoard() );

View File

@ -186,14 +186,14 @@ MODULE* MICROWAVE_TOOL::createBaseFootprint( const wxString& aValue,
{
PCB_EDIT_FRAME& editFrame = *getEditFrame<PCB_EDIT_FRAME>();
MODULE* module = editFrame.CreateNewModule( aValue );
MODULE* footprint = editFrame.CreateNewFootprint( aValue );
if( aTextSize > 0 )
{
module->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) );
module->Reference().SetTextThickness( aTextSize / 5 );
module->Value().SetTextSize( wxSize( aTextSize, aTextSize ) );
module->Value().SetTextThickness( aTextSize / 5 );
footprint->Reference().SetTextSize( wxSize( aTextSize, aTextSize ) );
footprint->Reference().SetTextThickness( aTextSize / 5 );
footprint->Value().SetTextSize( wxSize( aTextSize, aTextSize ) );
footprint->Value().SetTextThickness( aTextSize / 5 );
}
// Create 2 pads used in gaps and stubs. The gap is between these 2 pads
@ -203,14 +203,14 @@ MODULE* MICROWAVE_TOOL::createBaseFootprint( const wxString& aValue,
while( aPadCount-- )
{
D_PAD* pad = new D_PAD( module );
D_PAD* pad = new D_PAD( footprint );
module->Add( pad, ADD_MODE::INSERT );
footprint->Add( pad, ADD_MODE::INSERT );
int tw = editFrame.GetDesignSettings().GetCurrentTrackWidth();
pad->SetSize( wxSize( tw, tw ) );
pad->SetPosition( module->GetPosition() );
pad->SetPosition( footprint->GetPosition() );
pad->SetShape( PAD_SHAPE_RECT );
pad->SetAttribute( PAD_ATTRIB_SMD );
pad->SetLayerSet( F_Cu );
@ -220,5 +220,5 @@ MODULE* MICROWAVE_TOOL::createBaseFootprint( const wxString& aValue,
pad_num++;
}
return module;
return footprint;
}

View File

@ -414,52 +414,52 @@ MODULE* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN& aIn
if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() )
return nullptr; // Aborted by user
MODULE* module = editFrame.CreateNewModule( msg );
MODULE* footprint = editFrame.CreateNewFootprint( msg );
module->SetFPID( LIB_ID( wxEmptyString, wxT( "mw_inductor" ) ) );
module->SetAttributes( MOD_EXCLUDE_FROM_POS_FILES | MOD_EXCLUDE_FROM_BOM );
module->ClearFlags();
module->SetPosition( aInductorPattern.m_End );
footprint->SetFPID( LIB_ID( wxEmptyString, wxT( "mw_inductor" ) ) );
footprint->SetAttributes( MOD_EXCLUDE_FROM_POS_FILES | MOD_EXCLUDE_FROM_BOM );
footprint->ClearFlags();
footprint->SetPosition( aInductorPattern.m_End );
// Generate segments
for( unsigned jj = 1; jj < buffer.size(); jj++ )
{
FP_SHAPE* seg;
seg = new FP_SHAPE( module );
seg = new FP_SHAPE( footprint );
seg->SetStart( buffer[jj - 1] );
seg->SetEnd( buffer[jj] );
seg->SetWidth( aInductorPattern.m_Width );
seg->SetLayer( module->GetLayer() );
seg->SetLayer( footprint->GetLayer() );
seg->SetShape( S_SEGMENT );
seg->SetStart0( seg->GetStart() - module->GetPosition() );
seg->SetEnd0( seg->GetEnd() - module->GetPosition() );
module->Add( seg );
seg->SetStart0( seg->GetStart() - footprint->GetPosition() );
seg->SetEnd0( seg->GetEnd() - footprint->GetPosition() );
footprint->Add( seg );
}
// Place a pad on each end of coil.
pad = new D_PAD( module );
pad = new D_PAD( footprint );
module->Add( pad );
footprint->Add( pad );
pad->SetName( "1" );
pad->SetPosition( aInductorPattern.m_End );
pad->SetPos0( pad->GetPosition() - module->GetPosition() );
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );
pad->SetSize( wxSize( aInductorPattern.m_Width, aInductorPattern.m_Width ) );
pad->SetLayerSet( LSET( module->GetLayer() ) );
pad->SetLayerSet( LSET( footprint->GetLayer() ) );
pad->SetAttribute( PAD_ATTRIB_SMD );
pad->SetShape( PAD_SHAPE_CIRCLE );
D_PAD* newpad = new D_PAD( *pad );
const_cast<KIID&>( newpad->m_Uuid ) = KIID();
module->Add( newpad );
footprint->Add( newpad );
pad = newpad;
pad->SetName( "2" );
pad->SetPosition( aInductorPattern.m_Start );
pad->SetPos0( pad->GetPosition() - module->GetPosition() );
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );
// Modify text positions.
wxPoint refPos( ( aInductorPattern.m_Start.x + aInductorPattern.m_End.x ) / 2,
@ -467,11 +467,11 @@ MODULE* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN& aIn
wxPoint valPos = refPos;
refPos.y -= module->Reference().GetTextSize().y;
module->Reference().SetPosition( refPos );
valPos.y += module->Value().GetTextSize().y;
module->Value().SetPosition( valPos );
refPos.y -= footprint->Reference().GetTextSize().y;
footprint->Reference().SetPosition( refPos );
valPos.y += footprint->Value().GetTextSize().y;
footprint->Value().SetPosition( valPos );
module->CalculateBoundingBox();
return module;
footprint->CalculateBoundingBox();
return footprint;
}

View File

@ -477,7 +477,7 @@ int CONVERT_TOOL::PolyToLines( const TOOL_EVENT& aEvent )
MODULE* footprint = nullptr;
if( fpEditor )
footprint = fpEditor->GetBoard()->GetFirstModule();
footprint = fpEditor->GetBoard()->GetFirstFootprint();
for( EDA_ITEM* item : selection )
{

View File

@ -1015,7 +1015,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
if( dlg.ShouldGroupItems() )
{
if( m_isFootprintEditor )
grp = new PCB_GROUP( m_frame->GetBoard()->GetFirstModule() );
grp = new PCB_GROUP( m_frame->GetBoard()->GetFirstFootprint() );
else
grp = new PCB_GROUP( m_frame->GetBoard() );
}

View File

@ -1565,25 +1565,25 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
if( m_isFootprintEditor )
{
MODULE* editModule = editFrame->GetBoard()->GetFirstModule();
dupe_item = editModule->DuplicateItem( orig_item );
MODULE* parentFootprint = editFrame->GetBoard()->GetFirstFootprint();
dupe_item = parentFootprint->DuplicateItem( orig_item );
if( increment && item->Type() == PCB_PAD_T
&& PAD_NAMING::PadCanHaveName( *static_cast<D_PAD*>( dupe_item ) ) )
{
PAD_TOOL* padTool = m_toolMgr->GetTool<PAD_TOOL>();
wxString padName = padTool->GetLastPadName();
padName = editModule->GetNextPadName( padName );
padName = parentFootprint->GetNextPadName( padName );
padTool->SetLastPadName( padName );
static_cast<D_PAD*>( dupe_item )->SetName( padName );
}
}
else if( orig_item->GetParent() && orig_item->GetParent()->Type() == PCB_MODULE_T )
{
MODULE* parent = static_cast<MODULE*>( orig_item->GetParent() );
MODULE* parentFootprint = static_cast<MODULE*>( orig_item->GetParent() );
m_commit->Modify( parent );
dupe_item = parent->DuplicateItem( orig_item, true /* add to parent */ );
m_commit->Modify( parentFootprint );
dupe_item = parentFootprint->DuplicateItem( orig_item, true /* add to parent */ );
}
else
{
@ -1617,7 +1617,8 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{
if( dupe_item->Type() == PCB_GROUP_T )
{
static_cast<PCB_GROUP*>( dupe_item )->RunOnDescendants( [&]( BOARD_ITEM* bItem )
static_cast<PCB_GROUP*>( dupe_item )->RunOnDescendants(
[&]( BOARD_ITEM* bItem )
{
m_commit->Add( bItem );
});

View File

@ -62,19 +62,27 @@ bool FOOTPRINT_EDITOR_TOOLS::Init()
//
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
auto libSelectedCondition = [ this ] ( const SELECTION& aSel ) {
auto libSelectedCondition =
[ this ]( const SELECTION& aSel )
{
LIB_ID sel = m_frame->GetTreeFPID();
return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
};
auto pinnedLibSelectedCondition = [ this ] ( const SELECTION& aSel ) {
auto pinnedLibSelectedCondition =
[ this ]( const SELECTION& aSel )
{
LIB_TREE_NODE* current = m_frame->GetCurrentTreeNode();
return current && current->m_Type == LIB_TREE_NODE::LIB && current->m_Pinned;
};
auto unpinnedLibSelectedCondition = [ this ] (const SELECTION& aSel ) {
auto unpinnedLibSelectedCondition =
[ this ](const SELECTION& aSel )
{
LIB_TREE_NODE* current = m_frame->GetCurrentTreeNode();
return current && current->m_Type == LIB_TREE_NODE::LIB && !current->m_Pinned;
};
auto fpSelectedCondition = [ this ] ( const SELECTION& aSel ) {
auto fpSelectedCondition =
[ this ]( const SELECTION& aSel )
{
LIB_ID sel = m_frame->GetTreeFPID();
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
};
@ -159,9 +167,9 @@ int FOOTPRINT_EDITOR_TOOLS::CutCopyFootprint( const TOOL_EVENT& aEvent )
LIB_ID fpID = m_frame->GetTreeFPID();
if( fpID == m_frame->GetLoadedFPID() )
m_copiedModule.reset( new MODULE( *m_frame->GetBoard()->GetFirstModule() ) );
m_copiedFootprint.reset( new MODULE( *m_frame->GetBoard()->GetFirstFootprint() ) );
else
m_copiedModule.reset( m_frame->LoadFootprint( fpID ) );
m_copiedFootprint.reset( m_frame->LoadFootprint( fpID ) );
if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
DeleteFootprint(aEvent );
@ -172,20 +180,19 @@ int FOOTPRINT_EDITOR_TOOLS::CutCopyFootprint( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_TOOLS::PasteFootprint( const TOOL_EVENT& aEvent )
{
if( m_copiedModule && !m_frame->GetTreeFPID().GetLibNickname().empty() )
if( m_copiedFootprint && !m_frame->GetTreeFPID().GetLibNickname().empty() )
{
wxString newLib = m_frame->GetTreeFPID().GetLibNickname();
MODULE* newModule( m_copiedModule.get() );
wxString newName = newModule->GetFPID().GetLibItemName();
wxString newName = m_copiedFootprint->GetFPID().GetLibItemName();
while( m_frame->Prj().PcbFootprintLibs()->FootprintExists( newLib, newName ) )
newName += _( "_copy" );
newModule->SetFPID( LIB_ID( newLib, newName ) );
m_frame->SaveFootprintInLibrary( newModule, newLib );
m_copiedFootprint->SetFPID( LIB_ID( newLib, newName ) );
m_frame->SaveFootprintInLibrary( m_copiedFootprint.get(), newLib );
m_frame->SyncLibraryTree( true );
m_frame->FocusOnLibID( newModule->GetFPID() );
m_frame->FocusOnLibID( m_copiedFootprint->GetFPID() );
}
return 0;
@ -216,8 +223,8 @@ int FOOTPRINT_EDITOR_TOOLS::ImportFootprint( const TOOL_EVENT& aEvent )
getViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
m_frame->Import_Module();
if( m_frame->GetBoard()->GetFirstModule() )
m_frame->GetBoard()->GetFirstModule()->ClearFlags();
if( m_frame->GetBoard()->GetFirstFootprint() )
m_frame->GetBoard()->GetFirstFootprint()->ClearFlags();
frame()->ClearUndoRedoList();
@ -233,7 +240,7 @@ int FOOTPRINT_EDITOR_TOOLS::ExportFootprint( const TOOL_EVENT& aEvent )
MODULE* fp;
if( !fpID.IsValid() )
fp = m_frame->GetBoard()->GetFirstModule();
fp = m_frame->GetBoard()->GetFirstFootprint();
else
fp = m_frame->LoadFootprint( fpID );
@ -286,7 +293,7 @@ int FOOTPRINT_EDITOR_TOOLS::ToggleFootprintTree( const TOOL_EVENT& aEvent )
int FOOTPRINT_EDITOR_TOOLS::Properties( const TOOL_EVENT& aEvent )
{
MODULE* footprint = m_frame->GetBoard()->GetFirstModule();
MODULE* footprint = m_frame->GetBoard()->GetFirstFootprint();
if( footprint )
{

View File

@ -82,7 +82,7 @@ private:
FOOTPRINT_EDIT_FRAME* m_frame;
// A private clipboard for cut/copy/past of an entire footprint
std::unique_ptr<MODULE> m_copiedModule;
std::unique_ptr<MODULE> m_copiedFootprint;
};
#endif

View File

@ -50,8 +50,7 @@ void GLOBAL_EDIT_TOOL::Reset( RESET_REASON aReason )
bool GLOBAL_EDIT_TOOL::Init()
{
// Find the selection tool, so they can cooperate
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
m_selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
return true;
}
@ -60,7 +59,7 @@ bool GLOBAL_EDIT_TOOL::Init()
int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent )
{
PCBNEW_SELECTION& selection = m_selectionTool->GetSelection();
MODULE* mod = nullptr;
MODULE* footprint = nullptr;
bool updateMode = false;
bool currentMode = false;
@ -68,7 +67,7 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent )
selection = m_selectionTool->RequestSelection( EDIT_TOOL::FootprintFilter );
if( !selection.Empty() )
mod = selection.FirstOfKind<MODULE>();
footprint = selection.FirstOfKind<MODULE>();
if( aEvent.IsAction( &PCB_ACTIONS::updateFootprint ) )
{
@ -100,7 +99,7 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent )
// invoke the exchange dialog process
{
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
DIALOG_EXCHANGE_FOOTPRINTS dialog( editFrame, mod, updateMode, currentMode );
DIALOG_EXCHANGE_FOOTPRINTS dialog( editFrame, footprint, updateMode, currentMode );
dialog.ShowQuasiModal();
}
@ -108,12 +107,12 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent )
}
bool GLOBAL_EDIT_TOOL::swapBoardItem( BOARD_ITEM* aItem, PCB_LAYER_ID* new_layer )
bool GLOBAL_EDIT_TOOL::swapBoardItem( BOARD_ITEM* aItem, PCB_LAYER_ID* aLayerMap )
{
if( new_layer[ aItem->GetLayer() ] != aItem->GetLayer() )
if( aLayerMap[ aItem->GetLayer() ] != aItem->GetLayer() )
{
m_commit->Modify( aItem );
aItem->SetLayer( new_layer[ aItem->GetLayer() ] );
aItem->SetLayer( aLayerMap[ aItem->GetLayer() ] );
frame()->GetCanvas()->GetView()->Update( aItem, KIGFX::GEOMETRY );
return true;
}
@ -124,9 +123,9 @@ bool GLOBAL_EDIT_TOOL::swapBoardItem( BOARD_ITEM* aItem, PCB_LAYER_ID* new_layer
int GLOBAL_EDIT_TOOL::SwapLayers( const TOOL_EVENT& aEvent )
{
PCB_LAYER_ID new_layer[PCB_LAYER_ID_COUNT];
PCB_LAYER_ID layerMap[PCB_LAYER_ID_COUNT];
DIALOG_SWAP_LAYERS dlg( frame(), new_layer );
DIALOG_SWAP_LAYERS dlg( frame(), layerMap );
if( dlg.ShowModal() != wxID_OK )
return 0;
@ -134,7 +133,7 @@ int GLOBAL_EDIT_TOOL::SwapLayers( const TOOL_EVENT& aEvent )
bool hasChanges = false;
// Change tracks.
for( auto segm : frame()->GetBoard()->Tracks() )
for( TRACK* segm : frame()->GetBoard()->Tracks() )
{
if( segm->Type() == PCB_VIA_T )
{
@ -146,25 +145,25 @@ int GLOBAL_EDIT_TOOL::SwapLayers( const TOOL_EVENT& aEvent )
via->LayerPair( &top_layer, &bottom_layer );
if( new_layer[bottom_layer] != bottom_layer || new_layer[top_layer] != top_layer )
if( layerMap[bottom_layer] != bottom_layer || layerMap[top_layer] != top_layer )
{
m_commit->Modify( via );
via->SetLayerPair( new_layer[top_layer], new_layer[bottom_layer] );
via->SetLayerPair( layerMap[top_layer], layerMap[bottom_layer] );
frame()->GetCanvas()->GetView()->Update( via, KIGFX::GEOMETRY );
hasChanges = true;
}
}
else
{
hasChanges |= swapBoardItem( segm, new_layer );
hasChanges |= swapBoardItem( segm, layerMap );
}
}
for( BOARD_ITEM* zone : frame()->GetBoard()->Zones() )
hasChanges |= swapBoardItem( zone, new_layer );
hasChanges |= swapBoardItem( zone, layerMap );
for( BOARD_ITEM* drawing : frame()->GetBoard()->Drawings() )
hasChanges |= swapBoardItem( drawing, new_layer );
hasChanges |= swapBoardItem( drawing, layerMap );
if( hasChanges )
{

View File

@ -64,7 +64,7 @@ public:
int RemoveUnusedPads( const TOOL_EVENT& aEvent );
private:
bool swapBoardItem( BOARD_ITEM* aItem, PCB_LAYER_ID* new_layer );
bool swapBoardItem( BOARD_ITEM* aItem, PCB_LAYER_ID* aLayerMap );
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -355,12 +355,12 @@ int GROUP_TOOL::Group( const TOOL_EVENT& aEvent )
if( m_isFootprintEditor )
{
MODULE* module = board->GetFirstModule();
MODULE* parentFootprint = board->GetFirstFootprint();
m_frame->SaveCopyInUndoList( module, UNDO_REDO::CHANGED );
m_frame->SaveCopyInUndoList( parentFootprint, UNDO_REDO::CHANGED );
group = new PCB_GROUP( module );
module->Add( group );
group = new PCB_GROUP( parentFootprint );
parentFootprint->Add( group );
for( EDA_ITEM* item : selection )
group->AddItem( static_cast<BOARD_ITEM*>( item ) );
@ -413,12 +413,12 @@ int GROUP_TOOL::Ungroup( const TOOL_EVENT& aEvent )
{
if( m_isFootprintEditor )
{
MODULE* module = board->GetFirstModule();
MODULE* parentFootprint = board->GetFirstFootprint();
m_frame->SaveCopyInUndoList( module, UNDO_REDO::CHANGED );
m_frame->SaveCopyInUndoList( parentFootprint, UNDO_REDO::CHANGED );
group->RemoveAll();
module->Remove( group );
parentFootprint->Remove( group );
}
else
{

View File

@ -252,7 +252,7 @@ int PAD_TOOL::pushPadSettings( const TOOL_EVENT& aEvent )
int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
{
if( !board()->GetFirstModule() || board()->GetFirstModule()->Pads().empty() )
if( !board()->GetFirstFootprint() || board()->GetFirstFootprint()->Pads().empty() )
return 0;
DIALOG_ENUM_PADS settingsDlg( frame() );
@ -437,7 +437,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
}
for( auto p : board()->GetFirstModule()->Pads() )
for( D_PAD* p : board()->GetFirstFootprint()->Pads() )
{
p->ClearSelected();
view->Update( p );
@ -450,7 +450,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
{
if( !board()->GetFirstModule() )
if( !board()->GetFirstFootprint() )
return 0;
struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
@ -466,14 +466,14 @@ int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
std::unique_ptr<BOARD_ITEM> CreateItem() override
{
D_PAD* pad = new D_PAD( m_board->GetFirstModule() );
D_PAD* pad = new D_PAD( m_board->GetFirstFootprint() );
pad->ImportSettingsFrom( m_frame->GetDesignSettings().m_Pad_Master );
if( PAD_NAMING::PadCanHaveName( *pad ) )
{
wxString padName = m_padTool->GetLastPadName();
padName = m_board->GetFirstModule()->GetNextPadName( padName );
padName = m_board->GetFirstFootprint()->GetNextPadName( padName );
pad->SetName( padName );
m_padTool->SetLastPadName( padName );
}
@ -582,7 +582,7 @@ PCB_LAYER_ID PAD_TOOL::explodePad( D_PAD* aPad )
for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
{
FP_SHAPE* shape = new FP_SHAPE( board()->GetFirstModule() );
FP_SHAPE* shape = new FP_SHAPE( board()->GetFirstFootprint() );
shape->SetShape( primitive->GetShape() );
shape->SetWidth( primitive->GetWidth() );
@ -622,7 +622,7 @@ void PAD_TOOL::recombinePad( D_PAD* aPad )
aPad->TransformShapeWithClearanceToPolygon( padPoly, aLayer, 0, maxError,
ERROR_INSIDE );
for( BOARD_ITEM* item : board()->GetFirstModule()->GraphicalItems() )
for( BOARD_ITEM* item : board()->GetFirstFootprint()->GraphicalItems() )
{
PCB_SHAPE* draw = dynamic_cast<PCB_SHAPE*>( item );

View File

@ -161,7 +161,7 @@ protected:
MODULE* module() const
{
return board()->GetFirstModule();
return board()->GetFirstFootprint();
}
const PCB_DISPLAY_OPTIONS& displayOptions() const;

View File

@ -112,7 +112,7 @@ protected:
MODULE* module() const
{
return board()->GetFirstModule();
return board()->GetFirstFootprint();
}
};

View File

@ -446,7 +446,7 @@ int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{
if( m_isFootprintEditor && !m_frame->GetBoard()->GetFirstModule() )
if( m_isFootprintEditor && !m_frame->GetBoard()->GetFirstFootprint() )
return 0;
std::string tool = aEvent.GetCommandStr().get();
@ -539,22 +539,22 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
}
void pasteModuleItemsToModEdit( MODULE* aClipModule, BOARD* aBoard,
void pasteFootprintItemsToFootprintEditor( MODULE* aClipFootprint, BOARD* aBoard,
std::vector<BOARD_ITEM*>& aPastedItems )
{
MODULE* editModule = aBoard->GetFirstModule();
MODULE* editorFootprint = aBoard->GetFirstFootprint();
aClipModule->SetParent( aBoard );
aClipFootprint->SetParent( aBoard );
for( D_PAD* pad : aClipModule->Pads() )
for( D_PAD* pad : aClipFootprint->Pads() )
{
pad->SetParent( editModule );
pad->SetParent( editorFootprint );
aPastedItems.push_back( pad );
}
aClipModule->Pads().clear();
aClipFootprint->Pads().clear();
for( BOARD_ITEM* item : aClipModule->GraphicalItems() )
for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
{
if( item->Type() == PCB_FP_SHAPE_T )
{
@ -571,53 +571,53 @@ void pasteModuleItemsToModEdit( MODULE* aClipModule, BOARD* aBoard,
text->SetType( FP_TEXT::TEXT_is_DIVERS );
if( text->GetText() == "${VALUE}" )
text->SetText( aClipModule->GetValue() );
text->SetText( aClipFootprint->GetValue() );
else if( text->GetText() == "${REFERENCE}" )
text->SetText( aClipModule->GetReference() );
text->SetText( aClipFootprint->GetReference() );
text->SetTextAngle( aClipModule->GetOrientation() );
text->SetTextAngle( aClipFootprint->GetOrientation() );
text->SetParent( nullptr );
text->SetLocalCoord();
}
item->SetParent( editModule );
item->SetParent( editorFootprint );
aPastedItems.push_back( item );
}
aClipModule->GraphicalItems().clear();
aClipFootprint->GraphicalItems().clear();
for( PCB_GROUP* group : aClipModule->Groups() )
for( PCB_GROUP* group : aClipFootprint->Groups() )
{
group->SetParent( editModule );
group->SetParent( editorFootprint );
aPastedItems.push_back( group );
}
aClipModule->Groups().clear();
aClipFootprint->Groups().clear();
if( !aClipModule->GetReference().IsEmpty() )
if( !aClipFootprint->GetReference().IsEmpty() )
{
FP_TEXT* text = new FP_TEXT( aClipModule->Reference() );
FP_TEXT* text = new FP_TEXT( aClipFootprint->Reference() );
text->SetType( FP_TEXT::TEXT_is_DIVERS );
text->SetTextAngle( aClipModule->GetOrientation() );
text->SetTextAngle( aClipFootprint->GetOrientation() );
text->SetParent( nullptr );
text->SetLocalCoord();
text->SetParent( editModule );
text->SetParent( editorFootprint );
aPastedItems.push_back( text );
}
if( !aClipModule->GetValue().IsEmpty() )
if( !aClipFootprint->GetValue().IsEmpty() )
{
FP_TEXT* text = new FP_TEXT( aClipModule->Value() );
FP_TEXT* text = new FP_TEXT( aClipFootprint->Value() );
text->SetType( FP_TEXT::TEXT_is_DIVERS );
text->SetTextAngle( aClipModule->GetOrientation() );
text->SetTextAngle( aClipFootprint->GetOrientation() );
text->SetParent( nullptr );
text->SetLocalCoord();
text->SetParent( editModule );
text->SetParent( editorFootprint );
aPastedItems.push_back( text );
}
}
@ -635,23 +635,25 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
return 0;
bool editModules = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
if( clipItem->Type() == PCB_T )
{
if( editModules )
if( isFootprintEditor )
{
for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
item->SetNet( NETINFO_LIST::OrphanedItem() );
}
else
{
static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
}
}
// The clipboard can contain two different things, an entire kicad_pcb
// or a single module
if( editModules && ( !board() || !module() ) )
if( isFootprintEditor && ( !board() || !module() ) )
{
return 0;
}
@ -662,13 +664,13 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
{
BOARD* clipBoard = static_cast<BOARD*>( clipItem );
if( editModules )
if( isFootprintEditor )
{
MODULE* editModule = board()->GetFirstModule();
MODULE* editorFootprint = board()->GetFirstFootprint();
std::vector<BOARD_ITEM*> pastedItems;
for( MODULE* clipModule : clipBoard->Modules() )
pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
for( MODULE* clipFootprint : clipBoard->Modules() )
pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
{
@ -677,12 +679,12 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
PCB_SHAPE* clipShape = static_cast<PCB_SHAPE*>( clipDrawItem );
// Convert to PCB_FP_SHAPE_T
FP_SHAPE* pastedShape = new FP_SHAPE( editModule );
FP_SHAPE* pastedShape = new FP_SHAPE( editorFootprint );
static_cast<PCB_SHAPE*>( pastedShape )->SwapData( clipShape );
pastedShape->SetLocalCoord();
// Replace parent nuked by above call to SwapData()
pastedShape->SetParent( editModule );
pastedShape->SetParent( editorFootprint );
pastedItems.push_back( pastedShape );
}
else if( clipDrawItem->Type() == PCB_TEXT_T )
@ -690,11 +692,11 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
PCB_TEXT* clipTextItem = static_cast<PCB_TEXT*>( clipDrawItem );
// Convert to PCB_FP_TEXT_T
FP_TEXT* pastedTextItem = new FP_TEXT( editModule );
FP_TEXT* pastedTextItem = new FP_TEXT( editorFootprint );
static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
pastedTextItem->SetParent( editModule );
pastedTextItem->SetParent( editorFootprint );
pastedItems.push_back( pastedTextItem );
}
}
@ -716,18 +718,18 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
case PCB_MODULE_T:
{
MODULE* clipModule = static_cast<MODULE*>( clipItem );
MODULE* clipFootprint = static_cast<MODULE*>( clipItem );
std::vector<BOARD_ITEM*> pastedItems;
if( editModules )
if( isFootprintEditor )
{
pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
delete clipModule;
pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
delete clipFootprint;
}
else
{
clipModule->SetParent( board() );
pastedItems.push_back( clipModule );
clipFootprint->SetParent( board() );
pastedItems.push_back( clipFootprint );
}
placeBoardItems( pastedItems, true, true );