More Module -> Footprint.

This commit is contained in:
Jeff Young 2020-11-10 21:20:03 +00:00
parent 812b714ccd
commit 13e939ffa0
13 changed files with 143 additions and 144 deletions

View File

@ -126,7 +126,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
if( !saveCurrentTheme( false ) )
return;
MODULE_NAME_CHAR_VALIDATOR themeNameValidator;
FOOTPRINT_NAME_VALIDATOR themeNameValidator;
wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
dlg.SetTextValidator( themeNameValidator );

View File

@ -68,7 +68,7 @@ void GRID_CELL_TEXT_EDITOR::StartingKey( wxKeyEvent& event )
}
MODULE_NAME_CHAR_VALIDATOR::MODULE_NAME_CHAR_VALIDATOR( wxString* aValue ) :
FOOTPRINT_NAME_VALIDATOR::FOOTPRINT_NAME_VALIDATOR( wxString* aValue ) :
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{
// This list of characters follows the string from class_module.cpp

View File

@ -305,10 +305,9 @@ public:
* places \a aModule at the current cursor position and updates module coordinates
* with the new position.
*
* @param aModule A MODULE object point of the module to be placed.
* @param aRecreateRatsnest A bool true redraws the module rats nest.
*/
void PlaceModule( MODULE* aModule, bool aRecreateRatsnest = true );
void PlaceFootprint( MODULE* aFootprint, bool aRecreateRatsnest = true );
void ShowPadPropertiesDialog( D_PAD* aPad );

View File

@ -60,10 +60,10 @@ protected:
* footprint names cannot have any characters that would prevent file creation on any platform.
* The characters \/:*?|"<> are illegal and filtered by the validator.
*/
class MODULE_NAME_CHAR_VALIDATOR : public wxTextValidator
class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator
{
public:
MODULE_NAME_CHAR_VALIDATOR( wxString* aValue = NULL );
FOOTPRINT_NAME_VALIDATOR( wxString* aValue = NULL );
};

View File

@ -112,7 +112,7 @@ DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aP
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
m_FootprintNameCtrl->SetValidator( MODULE_NAME_CHAR_VALIDATOR() );
m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() );
// Set font sizes
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );

View File

@ -474,7 +474,7 @@ void PCB_EDIT_FRAME::ExchangeFootprint( MODULE* aExisting, MODULE* aNew, BOARD_C
aNew->SetParent( GetBoard() );
PlaceModule( aNew, false );
PlaceFootprint( aNew, false );
// PlaceModule will move the footprint to the cursor position, which we don't want. Copy
// the original position across.

View File

@ -200,25 +200,25 @@ static MODULE* parse_module_kicad( const wxFileName& aFileName )
MODULE* try_load_footprint( const wxFileName& aFileName, IO_MGR::PCB_FILE_T aFileType,
const wxString& aName )
{
MODULE* module;
MODULE* footprint;
switch( aFileType )
{
case IO_MGR::GEDA_PCB:
case IO_MGR::LEGACY:
module = parse_module_with_plugin( aFileName, aFileType, aName );
footprint = parse_module_with_plugin( aFileName, aFileType, aName );
break;
case IO_MGR::KICAD_SEXP:
module = parse_module_kicad( aFileName );
footprint = parse_module_kicad( aFileName );
break;
default:
wxFAIL_MSG( wxT( "unexpected IO_MGR::PCB_FILE_T" ) );
module = NULL;
footprint = NULL;
}
return module;
return footprint;
}
@ -251,8 +251,8 @@ MODULE* FOOTPRINT_EDIT_FRAME::ImportFootprint( const wxString& aName )
cfg->m_LastImportExportPath = lastOpenedPathForLoading;
wxString moduleName;
IO_MGR::PCB_FILE_T fileType = detect_file_type( fp, fn.GetFullPath(), &moduleName );
wxString footprintName;
IO_MGR::PCB_FILE_T fileType = detect_file_type( fp, fn.GetFullPath(), &footprintName );
if( fileType == IO_MGR::FILE_TYPE_NONE )
{
@ -260,16 +260,16 @@ MODULE* FOOTPRINT_EDIT_FRAME::ImportFootprint( const wxString& aName )
return NULL;
}
MODULE* module = NULL;
MODULE* footprint = NULL;
try
{
module = try_load_footprint( fn, fileType, moduleName );
footprint = try_load_footprint( fn, fileType, footprintName );
if( !module )
if( !footprint )
{
wxString msg = wxString::Format( _( "Unable to load footprint '%s' from '%s'" ),
moduleName,
footprintName,
fn.GetFullPath() );
DisplayError( this, msg );
return NULL;
@ -284,25 +284,25 @@ MODULE* FOOTPRINT_EDIT_FRAME::ImportFootprint( const wxString& aName )
// a fp library is a set of separate files, and the error(s) are not necessary when
// reading the selected file
if( !module )
if( !footprint )
return NULL;
}
module->SetFPID( LIB_ID( wxEmptyString, moduleName ) );
footprint->SetFPID( LIB_ID( wxEmptyString, footprintName ) );
// Insert footprint in list
AddFootprintToBoard( module );
AddFootprintToBoard( footprint );
// Display info :
SetMsgPanel( module );
PlaceModule( module );
SetMsgPanel( footprint );
PlaceFootprint( footprint );
module->SetPosition( wxPoint( 0, 0 ) );
footprint->SetPosition( wxPoint( 0, 0 ) );
GetBoard()->BuildListOfNets();
UpdateView();
return module;
return footprint;
}
@ -341,11 +341,11 @@ void FOOTPRINT_EDIT_FRAME::ExportFootprint( MODULE* aFootprint )
PCB_IO pcb_io( CTL_FOR_LIBRARY );
/* This module should *already* be "normalized" in a way such that
orientation is zero, etc., since it came from module editor.
/* This footprint should *already* be "normalized" in a way such that
orientation is zero, etc., since it came from the Footprint Editor.
module->SetParent( 0 );
module->SetOrientation( 0 );
aFootprint->SetParent( 0 );
aFootprint->SetOrientation( 0 );
*/
pcb_io.Format( aFootprint );
@ -795,26 +795,26 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
}
BOARD* mainpcb = pcbframe->GetBoard();
MODULE* source_module = NULL;
MODULE* module_in_edit = GetBoard()->GetFirstFootprint();
MODULE* sourceFootprint = NULL;
MODULE* editorFootprint = GetBoard()->GetFirstFootprint();
// Search the old module (source) if exists
// Search the old footprint (source) if exists
// Because this source could be deleted when editing the main board...
if( module_in_edit->GetLink() != niluuid ) // this is not a new module ...
if( editorFootprint->GetLink() != niluuid ) // this is not a new footprint ...
{
source_module = nullptr;
sourceFootprint = nullptr;
for( MODULE* mod : mainpcb->Modules() )
for( MODULE* candidate : mainpcb->Modules() )
{
if( module_in_edit->GetLink() == mod->m_Uuid )
if( editorFootprint->GetLink() == candidate->m_Uuid )
{
source_module = mod;
sourceFootprint = candidate;
break;
}
}
}
if( !aAddNew && source_module == NULL ) // source not found
if( !aAddNew && sourceFootprint == NULL ) // source not found
{
DisplayError( this, _( "Unable to find the footprint on the main board.\nCannot save." ) );
return false;
@ -825,18 +825,19 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
BOARD_COMMIT commit( pcbframe );
// Create the "new" module
MODULE* newmodule = new MODULE( *module_in_edit );
const_cast<KIID&>( newmodule->m_Uuid ) = KIID();
MODULE* newFootprint = new MODULE( *editorFootprint );
const_cast<KIID&>( newFootprint->m_Uuid ) = KIID();
newmodule->SetParent( mainpcb );
newmodule->SetLink( niluuid );
newFootprint->SetParent( mainpcb );
newFootprint->SetLink( niluuid );
if( source_module ) // this is an update command
if( sourceFootprint ) // this is an update command
{
// In the main board the new module replaces the old module (pos, orient, ref, value,
// connections and properties are kept) and the source_module (old module) is deleted
pcbframe->ExchangeFootprint( source_module, newmodule, commit );
const_cast<KIID&>( newmodule->m_Uuid ) = module_in_edit->GetLink();
// In the main board the new footprint replaces the old one (pos, orient, ref, value,
// connections and properties are kept) and the sourceFootprint (old footprint) is
// deleted
pcbframe->ExchangeFootprint( sourceFootprint, newFootprint, commit );
const_cast<KIID&>( newFootprint->m_Uuid ) = editorFootprint->GetLink();
commit.Push( wxT( "Update module" ) );
}
else // This is an insert command
@ -844,19 +845,19 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
VECTOR2D cursorPos = viewControls->GetCursorPosition();
commit.Add( newmodule );
commit.Add( newFootprint );
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
pcbframe->PlaceModule( newmodule );
newmodule->SetPosition( wxPoint( 0, 0 ) );
pcbframe->PlaceFootprint( newFootprint );
newFootprint->SetPosition( wxPoint( 0, 0 ) );
viewControls->SetCrossHairCursorPosition( cursorPos, false );
const_cast<KIID&>( newmodule->m_Uuid ) = KIID();
const_cast<KIID&>( newFootprint->m_Uuid ) = KIID();
commit.Push( wxT( "Insert module" ) );
pcbframe->Raise();
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newFootprint );
}
newmodule->ClearFlags();
newFootprint->ClearFlags();
return true;
}
@ -957,9 +958,9 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aFootprint )
return false;
}
bool module_exists = tbl->FootprintExists( libraryName, footprintName );
bool footprintExists = tbl->FootprintExists( libraryName, footprintName );
if( module_exists )
if( footprintExists )
{
wxString msg = wxString::Format( _( "Footprint %s already exists in %s." ),
footprintName,
@ -977,8 +978,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aFootprint )
// Once saved-as a board footprint is no longer a board footprint
aFootprint->SetLink( niluuid );
wxString fmt = module_exists ? _( "Component \"%s\" replaced in \"%s\"" ) :
_( "Component \"%s\" added in \"%s\"" );
wxString fmt = footprintExists ? _( "Component \"%s\" replaced in \"%s\"" )
: _( "Component \"%s\" added in \"%s\"" );
wxString msg = wxString::Format( fmt, footprintName.GetData(), libraryName.GetData() );
SetStatusText( msg );
@ -994,7 +995,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
if( GetScreen()->IsModify() && m_revertModule )
{
wxString msg = wxString::Format( _( "Revert \"%s\" to last version saved?" ),
GetLoadedFPID().GetLibItemName().wx_str() );
GetLoadedFPID().GetLibItemName().wx_str() );
if( ConfirmRevertDialog( this, msg ) )
{
@ -1023,12 +1024,12 @@ MODULE* PCB_BASE_FRAME::CreateNewFootprint( const wxString& aFootprintName )
{
wxString footprintName = aFootprintName;
// Ask for the new module name
// Ask for the new footprint name
if( footprintName.IsEmpty() )
{
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ),
footprintName );
dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &footprintName ) );
dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &footprintName ) );
if( dlg.ShowModal() != wxID_OK )
return NULL; //Aborted by user

View File

@ -742,7 +742,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
commit.Add( newFootprint );
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
pcbframe->PlaceModule( newFootprint );
pcbframe->PlaceFootprint( newFootprint );
newFootprint->SetPosition( wxPoint( 0, 0 ) );
viewControls->SetCrossHairCursorPosition( cursorPos, false );
commit.Push( wxT( "Insert footprint" ) );

View File

@ -49,14 +49,14 @@ class FOOTPRINT_INFO_GENERATOR
wxString m_html;
FP_LIB_TABLE* m_fp_lib_table;
LIB_ID const m_lib_id;
MODULE* m_module;
MODULE* m_footprint;
public:
FOOTPRINT_INFO_GENERATOR( FP_LIB_TABLE* aFpLibTable, LIB_ID const& aLibId )
: m_html( DescriptionFormat ),
m_fp_lib_table( aFpLibTable ),
m_lib_id( aLibId ),
m_module( nullptr )
m_footprint( nullptr )
{ }
/**
@ -71,8 +71,8 @@ public:
try
{
m_module = m_fp_lib_table->FootprintLoad( m_lib_id.GetLibNickname(),
m_lib_id.GetLibItemName() );
m_footprint = m_fp_lib_table->FootprintLoad( m_lib_id.GetLibNickname(),
m_lib_id.GetLibItemName() );
}
catch( const IO_ERROR& ioe )
{
@ -83,11 +83,11 @@ public:
return;
}
if( m_module )
if( m_footprint )
{
wxString name = m_lib_id.GetLibItemName();
wxString desc = m_module->GetDescription();
wxString keywords = m_module->GetKeywords();
wxString desc = m_footprint->GetDescription();
wxString keywords = m_footprint->GetKeywords();
wxString doc;
// It is currently common practice to store a documentation link in the description.

View File

@ -80,25 +80,25 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
if( aSelected.Size() == 1 && aSelected.Front()->Type() == PCB_MODULE_T )
{
// make the module safe to transfer to other pcbs
const MODULE* mod = static_cast<MODULE*>( aSelected.Front() );
// make the footprint safe to transfer to other pcbs
const MODULE* footprint = static_cast<MODULE*>( aSelected.Front() );
// Do not modify existing board
MODULE newModule( *mod );
MODULE newFootprint( *footprint );
for( D_PAD* pad : newModule.Pads() )
for( D_PAD* pad : newFootprint.Pads() )
pad->SetNetCode( 0 );
// locked means "locked in place"; copied items therefore can't be locked
newModule.SetLocked( false );
newFootprint.SetLocked( false );
// locate the reference point at (0, 0) in the copied items
newModule.Move( wxPoint( -refPoint.x, -refPoint.y ) );
newFootprint.Move( wxPoint( -refPoint.x, -refPoint.y ) );
Format( static_cast<BOARD_ITEM*>( &newModule ) );
Format( static_cast<BOARD_ITEM*>( &newFootprint ) );
}
else if( isModEdit )
{
MODULE partialModule( m_board );
MODULE partialFootprint( m_board );
for( const EDA_ITEM* item : aSelected )
{
@ -114,19 +114,20 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
if( FP_TEXT* text = dyn_cast<FP_TEXT*>( clone ) )
text->SetType( FP_TEXT::TEXT_is_DIVERS );
// If it is only a module, clear the nets from the pads
// If it is only a footprint, clear the nets from the pads
if( D_PAD* pad = dyn_cast<D_PAD*>( clone ) )
pad->SetNetCode( 0 );
// Add the pad to the new module before moving to ensure the local coords are correct
partialModule.Add( clone );
// Add the pad to the new footprint before moving to ensure the local coords are
// correct
partialFootprint.Add( clone );
if( group )
{
static_cast<PCB_GROUP*>( clone )->RunOnDescendants(
[&]( BOARD_ITEM* descendant )
{
partialModule.Add( descendant );
partialFootprint.Add( descendant );
} );
}
@ -135,12 +136,12 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
}
// Set the new relative internal local coordinates of copied items
MODULE* editedModule = m_board->Modules().front();
wxPoint moveVector = partialModule.GetPosition() + editedModule->GetPosition();
MODULE* editedFootprint = m_board->Modules().front();
wxPoint moveVector = partialFootprint.GetPosition() + editedFootprint->GetPosition();
partialModule.MoveAnchorPosition( moveVector );
partialFootprint.MoveAnchorPosition( moveVector );
Format( &partialModule, 0 );
Format( &partialFootprint, 0 );
}
else
{
@ -172,14 +173,14 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
else if( item->Type() == PCB_FP_TEXT_T )
{
// Convert to PCB_TEXT_T
MODULE* mod = static_cast<MODULE*>( item->GetParent() );
MODULE* footprint = static_cast<MODULE*>( item->GetParent() );
FP_TEXT* fp_text = static_cast<FP_TEXT*>( item );
PCB_TEXT* pcb_text = new PCB_TEXT( m_board );
if( fp_text->GetText() == "${VALUE}" )
pcb_text->SetText( mod->GetValue() );
pcb_text->SetText( footprint->GetValue() );
else if( fp_text->GetText() == "${REFERENCE}" )
pcb_text->SetText( mod->GetReference() );
pcb_text->SetText( footprint->GetReference() );
else
pcb_text->CopyText( *fp_text );
@ -190,13 +191,13 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
else if( item->Type() == PCB_PAD_T )
{
// Create a parent to own the copied pad
MODULE* mod = new MODULE( m_board );
MODULE* footprint = new MODULE( m_board );
D_PAD* pad = (D_PAD*) item->Clone();
mod->SetPosition( pad->GetPosition() );
footprint->SetPosition( pad->GetPosition() );
pad->SetPos0( wxPoint() );
mod->Add( pad );
copy = mod;
footprint->Add( pad );
copy = footprint;
}
else if( item->Type() == PCB_FP_ZONE_AREA_T )
{
@ -218,8 +219,8 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
{
// locked means "locked in place"; copied items therefore can't
// be locked
if( MODULE* module = dyn_cast<MODULE*>( titem ) )
module->SetLocked( false );
if( MODULE* footprint = dyn_cast<MODULE*>( titem ) )
footprint->SetLocked( false );
else if( TRACK* track = dyn_cast<TRACK*>( titem ) )
track->SetLocked( false );
};

View File

@ -121,7 +121,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( MODULE* aFootprint )
newFootprint->ClearAllNets();
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
PlaceModule( newFootprint );
PlaceFootprint( newFootprint );
newFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
// Put it on FRONT layer,
@ -285,17 +285,17 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
MODULE* PCB_BASE_FRAME::LoadFootprint( const LIB_ID& aFootprintId )
{
MODULE* module = NULL;
MODULE* footprint = NULL;
try
{
module = loadFootprint( aFootprintId );
footprint = loadFootprint( aFootprintId );
}
catch( const IO_ERROR& )
{
}
return module;
return footprint;
}
@ -305,36 +305,34 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const LIB_ID& aFootprintId )
wxCHECK_MSG( fptbl, NULL, wxT( "Cannot look up LIB_ID in NULL FP_LIB_TABLE." ) );
MODULE *module = nullptr;
MODULE *footprint = nullptr;
try
{
module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
footprint = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
}
catch( const IO_ERROR& )
{
}
// If the module is found, clear all net info,
// to be sure there is no broken links
// to any netinfo list (should be not needed, but it can be edited from
// the footprint editor )
if( module )
module->ClearAllNets();
// If the footprint is found, clear all net info to be sure there are no broken links to
// any netinfo list (should be not needed, but it can be edited from the footprint editor )
if( footprint )
footprint->ClearAllNets();
return module;
return footprint;
}
MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprintFromBoard( BOARD* aPcb )
{
static wxString oldName; // Save name of last module selected.
static wxString oldName; // Save name of last footprint selected.
wxString fpname;
wxString msg;
wxArrayString listnames;
for( auto module : aPcb->Modules() )
listnames.Add( module->GetReference() );
for( MODULE* footprint : aPcb->Modules() )
listnames.Add( footprint->GetReference() );
msg.Printf( _( "Footprints [%u items]" ), (unsigned) listnames.GetCount() );
@ -421,15 +419,15 @@ bool FOOTPRINT_EDIT_FRAME::SaveLibraryAs( const wxString& aLibraryPath )
}
static MODULE* s_ModuleInitialCopy = NULL; // Copy of module for abort/undo command
static MODULE* s_FootprintInitialCopy = NULL; // Copy of footprint for abort/undo command
static PICKED_ITEMS_LIST s_PickedList; // a pick-list to save initial module
// and dragged tracks
static PICKED_ITEMS_LIST s_PickedList; // A pick-list to save initial footprint
// and dragged tracks
MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
{
wxString moduleName;
wxString footprintName;
wxArrayString fplist;
// Build list of available fp references, to display them in dialog
@ -443,15 +441,15 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
if( dlg.ShowModal() != wxID_OK ) //Aborted by user
return NULL;
moduleName = dlg.GetValue();
moduleName.Trim( true );
moduleName.Trim( false );
footprintName = dlg.GetValue();
footprintName.Trim( true );
footprintName.Trim( false );
if( !moduleName.IsEmpty() )
if( !footprintName.IsEmpty() )
{
for( auto mod : GetBoard()->Modules() )
{
if( mod->GetReference().CmpNoCase( moduleName ) == 0 )
if( mod->GetReference().CmpNoCase( footprintName ) == 0 )
return mod;
}
}
@ -460,23 +458,23 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
}
void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, bool aRecreateRatsnest )
void PCB_BASE_FRAME::PlaceFootprint( MODULE* aFootprint, bool aRecreateRatsnest )
{
if( aModule == 0 )
if( aFootprint == 0 )
return;
OnModify();
if( aModule->IsNew() )
if( aFootprint->IsNew() )
{
SaveCopyInUndoList( aModule, UNDO_REDO::NEWITEM );
SaveCopyInUndoList( aFootprint, UNDO_REDO::NEWITEM );
}
else if( aModule->IsMoving() )
else if( aFootprint->IsMoving() )
{
ITEM_PICKER picker( nullptr, aModule, UNDO_REDO::CHANGED );
picker.SetLink( s_ModuleInitialCopy );
ITEM_PICKER picker( nullptr, aFootprint, UNDO_REDO::CHANGED );
picker.SetLink( s_FootprintInitialCopy );
s_PickedList.PushItem( picker );
s_ModuleInitialCopy = NULL; // the picker is now owner of s_ModuleInitialCopy.
s_FootprintInitialCopy = NULL; // the picker is now owner of s_ModuleInitialCopy.
}
if( s_PickedList.GetCount() )
@ -488,19 +486,19 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, bool aRecreateRatsnest )
s_PickedList.ClearItemsList();
}
aModule->SetPosition( (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
aModule->ClearFlags();
aFootprint->SetPosition((wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
aFootprint->ClearFlags();
delete s_ModuleInitialCopy;
s_ModuleInitialCopy = NULL;
delete s_FootprintInitialCopy;
s_FootprintInitialCopy = NULL;
if( aRecreateRatsnest )
m_pcb->GetConnectivity()->Update( aModule );
m_pcb->GetConnectivity()->Update( aFootprint );
if( aRecreateRatsnest )
Compile_Ratsnest( true );
SetMsgPanel( aModule );
SetMsgPanel( aFootprint );
}

View File

@ -409,7 +409,7 @@ MODULE* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN& aIn
// Generate footprint. the value is also used as footprint name.
msg = "L";
WX_TEXT_ENTRY_DIALOG cmpdlg( &editFrame, _( "Component Value:" ), wxEmptyString, msg );
cmpdlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &msg ) );
cmpdlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &msg ) );
if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() )
return nullptr; // Aborted by user

View File

@ -245,7 +245,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE* aPcbComponent,
{
wxString msg;
// Create a copy only if the module has not been added during this update
// Create a copy only if the footprint has not been added during this update
MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
bool changed = false;
@ -350,7 +350,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent
{
wxString msg;
// Create a copy only if the module has not been added during this update
// Create a copy only if the footprint has not been added during this update
MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
bool changed = false;
@ -624,30 +624,30 @@ bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist )
wxString msg;
const COMPONENT* component;
for( MODULE* module : m_board->Modules() )
for( MODULE* footprint : m_board->Modules() )
{
if( ( module->GetAttributes() & MOD_BOARD_ONLY ) > 0 )
if(( footprint->GetAttributes() & MOD_BOARD_ONLY ) > 0 )
continue;
if( m_lookupByTimestamp )
component = aNetlist.GetComponentByPath( module->GetPath() );
component = aNetlist.GetComponentByPath( footprint->GetPath() );
else
component = aNetlist.GetComponentByReference( module->GetReference() );
component = aNetlist.GetComponentByReference( footprint->GetReference() );
if( component == NULL || component->GetProperties().count( "exclude_from_board" ) )
{
if( module->IsLocked() )
if( footprint->IsLocked() )
{
msg.Printf( _( "Cannot remove unused footprint %s (locked)." ), module->GetReference() );
msg.Printf( _( "Cannot remove unused footprint %s (locked)." ), footprint->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_WARNING );
continue;
}
msg.Printf( _( "Remove unused footprint %s." ), module->GetReference() );
msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
m_commit.Remove( module );
m_commit.Remove( footprint );
}
}