More Module -> Footprint.
This commit is contained in:
parent
812b714ccd
commit
13e939ffa0
|
@ -126,7 +126,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
|
||||||
if( !saveCurrentTheme( false ) )
|
if( !saveCurrentTheme( false ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MODULE_NAME_CHAR_VALIDATOR themeNameValidator;
|
FOOTPRINT_NAME_VALIDATOR themeNameValidator;
|
||||||
wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
|
wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
|
||||||
dlg.SetTextValidator( themeNameValidator );
|
dlg.SetTextValidator( themeNameValidator );
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
|
||||||
{
|
{
|
||||||
// This list of characters follows the string from class_module.cpp
|
// This list of characters follows the string from class_module.cpp
|
||||||
|
|
|
@ -305,10 +305,9 @@ public:
|
||||||
* places \a aModule at the current cursor position and updates module coordinates
|
* places \a aModule at the current cursor position and updates module coordinates
|
||||||
* with the new position.
|
* 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.
|
* @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 );
|
void ShowPadPropertiesDialog( D_PAD* aPad );
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,10 @@ protected:
|
||||||
* footprint names cannot have any characters that would prevent file creation on any platform.
|
* footprint names cannot have any characters that would prevent file creation on any platform.
|
||||||
* The characters \/:*?|"<> are illegal and filtered by the validator.
|
* The characters \/:*?|"<> are illegal and filtered by the validator.
|
||||||
*/
|
*/
|
||||||
class MODULE_NAME_CHAR_VALIDATOR : public wxTextValidator
|
class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MODULE_NAME_CHAR_VALIDATOR( wxString* aValue = NULL );
|
FOOTPRINT_NAME_VALIDATOR( wxString* aValue = NULL );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aP
|
||||||
|
|
||||||
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
|
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
m_FootprintNameCtrl->SetValidator( MODULE_NAME_CHAR_VALIDATOR() );
|
m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() );
|
||||||
|
|
||||||
// Set font sizes
|
// Set font sizes
|
||||||
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||||
|
|
|
@ -474,7 +474,7 @@ void PCB_EDIT_FRAME::ExchangeFootprint( MODULE* aExisting, MODULE* aNew, BOARD_C
|
||||||
|
|
||||||
aNew->SetParent( GetBoard() );
|
aNew->SetParent( GetBoard() );
|
||||||
|
|
||||||
PlaceModule( aNew, false );
|
PlaceFootprint( aNew, false );
|
||||||
|
|
||||||
// PlaceModule will move the footprint to the cursor position, which we don't want. Copy
|
// PlaceModule will move the footprint to the cursor position, which we don't want. Copy
|
||||||
// the original position across.
|
// the original position across.
|
||||||
|
|
|
@ -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,
|
MODULE* try_load_footprint( const wxFileName& aFileName, IO_MGR::PCB_FILE_T aFileType,
|
||||||
const wxString& aName )
|
const wxString& aName )
|
||||||
{
|
{
|
||||||
MODULE* module;
|
MODULE* footprint;
|
||||||
|
|
||||||
switch( aFileType )
|
switch( aFileType )
|
||||||
{
|
{
|
||||||
case IO_MGR::GEDA_PCB:
|
case IO_MGR::GEDA_PCB:
|
||||||
case IO_MGR::LEGACY:
|
case IO_MGR::LEGACY:
|
||||||
module = parse_module_with_plugin( aFileName, aFileType, aName );
|
footprint = parse_module_with_plugin( aFileName, aFileType, aName );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IO_MGR::KICAD_SEXP:
|
case IO_MGR::KICAD_SEXP:
|
||||||
module = parse_module_kicad( aFileName );
|
footprint = parse_module_kicad( aFileName );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( wxT( "unexpected IO_MGR::PCB_FILE_T" ) );
|
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;
|
cfg->m_LastImportExportPath = lastOpenedPathForLoading;
|
||||||
|
|
||||||
wxString moduleName;
|
wxString footprintName;
|
||||||
IO_MGR::PCB_FILE_T fileType = detect_file_type( fp, fn.GetFullPath(), &moduleName );
|
IO_MGR::PCB_FILE_T fileType = detect_file_type( fp, fn.GetFullPath(), &footprintName );
|
||||||
|
|
||||||
if( fileType == IO_MGR::FILE_TYPE_NONE )
|
if( fileType == IO_MGR::FILE_TYPE_NONE )
|
||||||
{
|
{
|
||||||
|
@ -260,16 +260,16 @@ MODULE* FOOTPRINT_EDIT_FRAME::ImportFootprint( const wxString& aName )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE* module = NULL;
|
MODULE* footprint = NULL;
|
||||||
|
|
||||||
try
|
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'" ),
|
wxString msg = wxString::Format( _( "Unable to load footprint '%s' from '%s'" ),
|
||||||
moduleName,
|
footprintName,
|
||||||
fn.GetFullPath() );
|
fn.GetFullPath() );
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return NULL;
|
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
|
// a fp library is a set of separate files, and the error(s) are not necessary when
|
||||||
// reading the selected file
|
// reading the selected file
|
||||||
|
|
||||||
if( !module )
|
if( !footprint )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
module->SetFPID( LIB_ID( wxEmptyString, moduleName ) );
|
footprint->SetFPID( LIB_ID( wxEmptyString, footprintName ) );
|
||||||
|
|
||||||
// Insert footprint in list
|
// Insert footprint in list
|
||||||
AddFootprintToBoard( module );
|
AddFootprintToBoard( footprint );
|
||||||
|
|
||||||
// Display info :
|
// Display info :
|
||||||
SetMsgPanel( module );
|
SetMsgPanel( footprint );
|
||||||
PlaceModule( module );
|
PlaceFootprint( footprint );
|
||||||
|
|
||||||
module->SetPosition( wxPoint( 0, 0 ) );
|
footprint->SetPosition( wxPoint( 0, 0 ) );
|
||||||
|
|
||||||
GetBoard()->BuildListOfNets();
|
GetBoard()->BuildListOfNets();
|
||||||
UpdateView();
|
UpdateView();
|
||||||
|
|
||||||
return module;
|
return footprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -341,11 +341,11 @@ void FOOTPRINT_EDIT_FRAME::ExportFootprint( MODULE* aFootprint )
|
||||||
|
|
||||||
PCB_IO pcb_io( CTL_FOR_LIBRARY );
|
PCB_IO pcb_io( CTL_FOR_LIBRARY );
|
||||||
|
|
||||||
/* This module should *already* be "normalized" in a way such that
|
/* This footprint should *already* be "normalized" in a way such that
|
||||||
orientation is zero, etc., since it came from module editor.
|
orientation is zero, etc., since it came from the Footprint Editor.
|
||||||
|
|
||||||
module->SetParent( 0 );
|
aFootprint->SetParent( 0 );
|
||||||
module->SetOrientation( 0 );
|
aFootprint->SetOrientation( 0 );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pcb_io.Format( aFootprint );
|
pcb_io.Format( aFootprint );
|
||||||
|
@ -795,26 +795,26 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
||||||
}
|
}
|
||||||
|
|
||||||
BOARD* mainpcb = pcbframe->GetBoard();
|
BOARD* mainpcb = pcbframe->GetBoard();
|
||||||
MODULE* source_module = NULL;
|
MODULE* sourceFootprint = NULL;
|
||||||
MODULE* module_in_edit = GetBoard()->GetFirstFootprint();
|
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...
|
// 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;
|
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." ) );
|
DisplayError( this, _( "Unable to find the footprint on the main board.\nCannot save." ) );
|
||||||
return false;
|
return false;
|
||||||
|
@ -825,18 +825,19 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
||||||
BOARD_COMMIT commit( pcbframe );
|
BOARD_COMMIT commit( pcbframe );
|
||||||
|
|
||||||
// Create the "new" module
|
// Create the "new" module
|
||||||
MODULE* newmodule = new MODULE( *module_in_edit );
|
MODULE* newFootprint = new MODULE( *editorFootprint );
|
||||||
const_cast<KIID&>( newmodule->m_Uuid ) = KIID();
|
const_cast<KIID&>( newFootprint->m_Uuid ) = KIID();
|
||||||
|
|
||||||
newmodule->SetParent( mainpcb );
|
newFootprint->SetParent( mainpcb );
|
||||||
newmodule->SetLink( niluuid );
|
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,
|
// In the main board the new footprint replaces the old one (pos, orient, ref, value,
|
||||||
// connections and properties are kept) and the source_module (old module) is deleted
|
// connections and properties are kept) and the sourceFootprint (old footprint) is
|
||||||
pcbframe->ExchangeFootprint( source_module, newmodule, commit );
|
// deleted
|
||||||
const_cast<KIID&>( newmodule->m_Uuid ) = module_in_edit->GetLink();
|
pcbframe->ExchangeFootprint( sourceFootprint, newFootprint, commit );
|
||||||
|
const_cast<KIID&>( newFootprint->m_Uuid ) = editorFootprint->GetLink();
|
||||||
commit.Push( wxT( "Update module" ) );
|
commit.Push( wxT( "Update module" ) );
|
||||||
}
|
}
|
||||||
else // This is an insert command
|
else // This is an insert command
|
||||||
|
@ -844,19 +845,19 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
||||||
KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
|
KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
|
||||||
VECTOR2D cursorPos = viewControls->GetCursorPosition();
|
VECTOR2D cursorPos = viewControls->GetCursorPosition();
|
||||||
|
|
||||||
commit.Add( newmodule );
|
commit.Add( newFootprint );
|
||||||
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||||
pcbframe->PlaceModule( newmodule );
|
pcbframe->PlaceFootprint( newFootprint );
|
||||||
newmodule->SetPosition( wxPoint( 0, 0 ) );
|
newFootprint->SetPosition( wxPoint( 0, 0 ) );
|
||||||
viewControls->SetCrossHairCursorPosition( cursorPos, false );
|
viewControls->SetCrossHairCursorPosition( cursorPos, false );
|
||||||
const_cast<KIID&>( newmodule->m_Uuid ) = KIID();
|
const_cast<KIID&>( newFootprint->m_Uuid ) = KIID();
|
||||||
commit.Push( wxT( "Insert module" ) );
|
commit.Push( wxT( "Insert module" ) );
|
||||||
|
|
||||||
pcbframe->Raise();
|
pcbframe->Raise();
|
||||||
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
|
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newFootprint );
|
||||||
}
|
}
|
||||||
|
|
||||||
newmodule->ClearFlags();
|
newFootprint->ClearFlags();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -957,9 +958,9 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aFootprint )
|
||||||
return false;
|
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." ),
|
wxString msg = wxString::Format( _( "Footprint %s already exists in %s." ),
|
||||||
footprintName,
|
footprintName,
|
||||||
|
@ -977,8 +978,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aFootprint )
|
||||||
// Once saved-as a board footprint is no longer a board footprint
|
// Once saved-as a board footprint is no longer a board footprint
|
||||||
aFootprint->SetLink( niluuid );
|
aFootprint->SetLink( niluuid );
|
||||||
|
|
||||||
wxString fmt = module_exists ? _( "Component \"%s\" replaced in \"%s\"" ) :
|
wxString fmt = footprintExists ? _( "Component \"%s\" replaced in \"%s\"" )
|
||||||
_( "Component \"%s\" added in \"%s\"" );
|
: _( "Component \"%s\" added in \"%s\"" );
|
||||||
|
|
||||||
wxString msg = wxString::Format( fmt, footprintName.GetData(), libraryName.GetData() );
|
wxString msg = wxString::Format( fmt, footprintName.GetData(), libraryName.GetData() );
|
||||||
SetStatusText( msg );
|
SetStatusText( msg );
|
||||||
|
@ -1023,12 +1024,12 @@ MODULE* PCB_BASE_FRAME::CreateNewFootprint( const wxString& aFootprintName )
|
||||||
{
|
{
|
||||||
wxString footprintName = aFootprintName;
|
wxString footprintName = aFootprintName;
|
||||||
|
|
||||||
// Ask for the new module name
|
// Ask for the new footprint name
|
||||||
if( footprintName.IsEmpty() )
|
if( footprintName.IsEmpty() )
|
||||||
{
|
{
|
||||||
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ),
|
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ),
|
||||||
footprintName );
|
footprintName );
|
||||||
dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &footprintName ) );
|
dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &footprintName ) );
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return NULL; //Aborted by user
|
return NULL; //Aborted by user
|
||||||
|
|
|
@ -742,7 +742,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
commit.Add( newFootprint );
|
commit.Add( newFootprint );
|
||||||
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||||
pcbframe->PlaceModule( newFootprint );
|
pcbframe->PlaceFootprint( newFootprint );
|
||||||
newFootprint->SetPosition( wxPoint( 0, 0 ) );
|
newFootprint->SetPosition( wxPoint( 0, 0 ) );
|
||||||
viewControls->SetCrossHairCursorPosition( cursorPos, false );
|
viewControls->SetCrossHairCursorPosition( cursorPos, false );
|
||||||
commit.Push( wxT( "Insert footprint" ) );
|
commit.Push( wxT( "Insert footprint" ) );
|
||||||
|
|
|
@ -49,14 +49,14 @@ class FOOTPRINT_INFO_GENERATOR
|
||||||
wxString m_html;
|
wxString m_html;
|
||||||
FP_LIB_TABLE* m_fp_lib_table;
|
FP_LIB_TABLE* m_fp_lib_table;
|
||||||
LIB_ID const m_lib_id;
|
LIB_ID const m_lib_id;
|
||||||
MODULE* m_module;
|
MODULE* m_footprint;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FOOTPRINT_INFO_GENERATOR( FP_LIB_TABLE* aFpLibTable, LIB_ID const& aLibId )
|
FOOTPRINT_INFO_GENERATOR( FP_LIB_TABLE* aFpLibTable, LIB_ID const& aLibId )
|
||||||
: m_html( DescriptionFormat ),
|
: m_html( DescriptionFormat ),
|
||||||
m_fp_lib_table( aFpLibTable ),
|
m_fp_lib_table( aFpLibTable ),
|
||||||
m_lib_id( aLibId ),
|
m_lib_id( aLibId ),
|
||||||
m_module( nullptr )
|
m_footprint( nullptr )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_module = m_fp_lib_table->FootprintLoad( m_lib_id.GetLibNickname(),
|
m_footprint = m_fp_lib_table->FootprintLoad( m_lib_id.GetLibNickname(),
|
||||||
m_lib_id.GetLibItemName() );
|
m_lib_id.GetLibItemName() );
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
|
@ -83,11 +83,11 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_module )
|
if( m_footprint )
|
||||||
{
|
{
|
||||||
wxString name = m_lib_id.GetLibItemName();
|
wxString name = m_lib_id.GetLibItemName();
|
||||||
wxString desc = m_module->GetDescription();
|
wxString desc = m_footprint->GetDescription();
|
||||||
wxString keywords = m_module->GetKeywords();
|
wxString keywords = m_footprint->GetKeywords();
|
||||||
wxString doc;
|
wxString doc;
|
||||||
|
|
||||||
// It is currently common practice to store a documentation link in the description.
|
// It is currently common practice to store a documentation link in the description.
|
||||||
|
|
|
@ -80,25 +80,25 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
|
||||||
|
|
||||||
if( aSelected.Size() == 1 && aSelected.Front()->Type() == PCB_MODULE_T )
|
if( aSelected.Size() == 1 && aSelected.Front()->Type() == PCB_MODULE_T )
|
||||||
{
|
{
|
||||||
// make the module safe to transfer to other pcbs
|
// make the footprint safe to transfer to other pcbs
|
||||||
const MODULE* mod = static_cast<MODULE*>( aSelected.Front() );
|
const MODULE* footprint = static_cast<MODULE*>( aSelected.Front() );
|
||||||
// Do not modify existing board
|
// 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 );
|
pad->SetNetCode( 0 );
|
||||||
|
|
||||||
// locked means "locked in place"; copied items therefore can't be locked
|
// 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
|
// 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 )
|
else if( isModEdit )
|
||||||
{
|
{
|
||||||
MODULE partialModule( m_board );
|
MODULE partialFootprint( m_board );
|
||||||
|
|
||||||
for( const EDA_ITEM* item : aSelected )
|
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 ) )
|
if( FP_TEXT* text = dyn_cast<FP_TEXT*>( clone ) )
|
||||||
text->SetType( FP_TEXT::TEXT_is_DIVERS );
|
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 ) )
|
if( D_PAD* pad = dyn_cast<D_PAD*>( clone ) )
|
||||||
pad->SetNetCode( 0 );
|
pad->SetNetCode( 0 );
|
||||||
|
|
||||||
// Add the pad to the new module before moving to ensure the local coords are correct
|
// Add the pad to the new footprint before moving to ensure the local coords are
|
||||||
partialModule.Add( clone );
|
// correct
|
||||||
|
partialFootprint.Add( clone );
|
||||||
|
|
||||||
if( group )
|
if( group )
|
||||||
{
|
{
|
||||||
static_cast<PCB_GROUP*>( clone )->RunOnDescendants(
|
static_cast<PCB_GROUP*>( clone )->RunOnDescendants(
|
||||||
[&]( BOARD_ITEM* descendant )
|
[&]( 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
|
// Set the new relative internal local coordinates of copied items
|
||||||
MODULE* editedModule = m_board->Modules().front();
|
MODULE* editedFootprint = m_board->Modules().front();
|
||||||
wxPoint moveVector = partialModule.GetPosition() + editedModule->GetPosition();
|
wxPoint moveVector = partialFootprint.GetPosition() + editedFootprint->GetPosition();
|
||||||
|
|
||||||
partialModule.MoveAnchorPosition( moveVector );
|
partialFootprint.MoveAnchorPosition( moveVector );
|
||||||
|
|
||||||
Format( &partialModule, 0 );
|
Format( &partialFootprint, 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -172,14 +173,14 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE
|
||||||
else if( item->Type() == PCB_FP_TEXT_T )
|
else if( item->Type() == PCB_FP_TEXT_T )
|
||||||
{
|
{
|
||||||
// Convert to PCB_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 );
|
FP_TEXT* fp_text = static_cast<FP_TEXT*>( item );
|
||||||
PCB_TEXT* pcb_text = new PCB_TEXT( m_board );
|
PCB_TEXT* pcb_text = new PCB_TEXT( m_board );
|
||||||
|
|
||||||
if( fp_text->GetText() == "${VALUE}" )
|
if( fp_text->GetText() == "${VALUE}" )
|
||||||
pcb_text->SetText( mod->GetValue() );
|
pcb_text->SetText( footprint->GetValue() );
|
||||||
else if( fp_text->GetText() == "${REFERENCE}" )
|
else if( fp_text->GetText() == "${REFERENCE}" )
|
||||||
pcb_text->SetText( mod->GetReference() );
|
pcb_text->SetText( footprint->GetReference() );
|
||||||
else
|
else
|
||||||
pcb_text->CopyText( *fp_text );
|
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 )
|
else if( item->Type() == PCB_PAD_T )
|
||||||
{
|
{
|
||||||
// Create a parent to own the copied pad
|
// 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();
|
D_PAD* pad = (D_PAD*) item->Clone();
|
||||||
|
|
||||||
mod->SetPosition( pad->GetPosition() );
|
footprint->SetPosition( pad->GetPosition() );
|
||||||
pad->SetPos0( wxPoint() );
|
pad->SetPos0( wxPoint() );
|
||||||
mod->Add( pad );
|
footprint->Add( pad );
|
||||||
copy = mod;
|
copy = footprint;
|
||||||
}
|
}
|
||||||
else if( item->Type() == PCB_FP_ZONE_AREA_T )
|
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
|
// locked means "locked in place"; copied items therefore can't
|
||||||
// be locked
|
// be locked
|
||||||
if( MODULE* module = dyn_cast<MODULE*>( titem ) )
|
if( MODULE* footprint = dyn_cast<MODULE*>( titem ) )
|
||||||
module->SetLocked( false );
|
footprint->SetLocked( false );
|
||||||
else if( TRACK* track = dyn_cast<TRACK*>( titem ) )
|
else if( TRACK* track = dyn_cast<TRACK*>( titem ) )
|
||||||
track->SetLocked( false );
|
track->SetLocked( false );
|
||||||
};
|
};
|
||||||
|
|
|
@ -121,7 +121,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( MODULE* aFootprint )
|
||||||
newFootprint->ClearAllNets();
|
newFootprint->ClearAllNets();
|
||||||
|
|
||||||
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
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
|
newFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
|
||||||
|
|
||||||
// Put it on FRONT layer,
|
// 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* PCB_BASE_FRAME::LoadFootprint( const LIB_ID& aFootprintId )
|
||||||
{
|
{
|
||||||
MODULE* module = NULL;
|
MODULE* footprint = NULL;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
module = loadFootprint( aFootprintId );
|
footprint = loadFootprint( aFootprintId );
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& )
|
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." ) );
|
wxCHECK_MSG( fptbl, NULL, wxT( "Cannot look up LIB_ID in NULL FP_LIB_TABLE." ) );
|
||||||
|
|
||||||
MODULE *module = nullptr;
|
MODULE *footprint = nullptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
|
footprint = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& )
|
catch( const IO_ERROR& )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the module is found, clear all net info,
|
// If the footprint is found, clear all net info to be sure there are no broken links to
|
||||||
// to be sure there is no broken links
|
// any netinfo list (should be not needed, but it can be edited from the footprint editor )
|
||||||
// to any netinfo list (should be not needed, but it can be edited from
|
if( footprint )
|
||||||
// the footprint editor )
|
footprint->ClearAllNets();
|
||||||
if( module )
|
|
||||||
module->ClearAllNets();
|
|
||||||
|
|
||||||
return module;
|
return footprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprintFromBoard( BOARD* aPcb )
|
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 fpname;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
wxArrayString listnames;
|
wxArrayString listnames;
|
||||||
|
|
||||||
for( auto module : aPcb->Modules() )
|
for( MODULE* footprint : aPcb->Modules() )
|
||||||
listnames.Add( module->GetReference() );
|
listnames.Add( footprint->GetReference() );
|
||||||
|
|
||||||
msg.Printf( _( "Footprints [%u items]" ), (unsigned) listnames.GetCount() );
|
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
|
static PICKED_ITEMS_LIST s_PickedList; // A pick-list to save initial footprint
|
||||||
// and dragged tracks
|
// and dragged tracks
|
||||||
|
|
||||||
|
|
||||||
MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
|
MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
|
||||||
{
|
{
|
||||||
wxString moduleName;
|
wxString footprintName;
|
||||||
wxArrayString fplist;
|
wxArrayString fplist;
|
||||||
|
|
||||||
// Build list of available fp references, to display them in dialog
|
// 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
|
if( dlg.ShowModal() != wxID_OK ) //Aborted by user
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
moduleName = dlg.GetValue();
|
footprintName = dlg.GetValue();
|
||||||
moduleName.Trim( true );
|
footprintName.Trim( true );
|
||||||
moduleName.Trim( false );
|
footprintName.Trim( false );
|
||||||
|
|
||||||
if( !moduleName.IsEmpty() )
|
if( !footprintName.IsEmpty() )
|
||||||
{
|
{
|
||||||
for( auto mod : GetBoard()->Modules() )
|
for( auto mod : GetBoard()->Modules() )
|
||||||
{
|
{
|
||||||
if( mod->GetReference().CmpNoCase( moduleName ) == 0 )
|
if( mod->GetReference().CmpNoCase( footprintName ) == 0 )
|
||||||
return mod;
|
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;
|
return;
|
||||||
|
|
||||||
OnModify();
|
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 );
|
ITEM_PICKER picker( nullptr, aFootprint, UNDO_REDO::CHANGED );
|
||||||
picker.SetLink( s_ModuleInitialCopy );
|
picker.SetLink( s_FootprintInitialCopy );
|
||||||
s_PickedList.PushItem( picker );
|
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() )
|
if( s_PickedList.GetCount() )
|
||||||
|
@ -488,19 +486,19 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, bool aRecreateRatsnest )
|
||||||
s_PickedList.ClearItemsList();
|
s_PickedList.ClearItemsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
aModule->SetPosition( (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
|
aFootprint->SetPosition((wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
|
||||||
aModule->ClearFlags();
|
aFootprint->ClearFlags();
|
||||||
|
|
||||||
delete s_ModuleInitialCopy;
|
delete s_FootprintInitialCopy;
|
||||||
s_ModuleInitialCopy = NULL;
|
s_FootprintInitialCopy = NULL;
|
||||||
|
|
||||||
if( aRecreateRatsnest )
|
if( aRecreateRatsnest )
|
||||||
m_pcb->GetConnectivity()->Update( aModule );
|
m_pcb->GetConnectivity()->Update( aFootprint );
|
||||||
|
|
||||||
if( aRecreateRatsnest )
|
if( aRecreateRatsnest )
|
||||||
Compile_Ratsnest( true );
|
Compile_Ratsnest( true );
|
||||||
|
|
||||||
SetMsgPanel( aModule );
|
SetMsgPanel( aFootprint );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -409,7 +409,7 @@ MODULE* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN& aIn
|
||||||
// Generate footprint. the value is also used as footprint name.
|
// Generate footprint. the value is also used as footprint name.
|
||||||
msg = "L";
|
msg = "L";
|
||||||
WX_TEXT_ENTRY_DIALOG cmpdlg( &editFrame, _( "Component Value:" ), wxEmptyString, msg );
|
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() )
|
if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() )
|
||||||
return nullptr; // Aborted by user
|
return nullptr; // Aborted by user
|
||||||
|
|
|
@ -245,7 +245,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE* aPcbComponent,
|
||||||
{
|
{
|
||||||
wxString msg;
|
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();
|
MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent
|
||||||
{
|
{
|
||||||
wxString msg;
|
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();
|
MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
@ -624,30 +624,30 @@ bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist )
|
||||||
wxString msg;
|
wxString msg;
|
||||||
const COMPONENT* component;
|
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;
|
continue;
|
||||||
|
|
||||||
if( m_lookupByTimestamp )
|
if( m_lookupByTimestamp )
|
||||||
component = aNetlist.GetComponentByPath( module->GetPath() );
|
component = aNetlist.GetComponentByPath( footprint->GetPath() );
|
||||||
else
|
else
|
||||||
component = aNetlist.GetComponentByReference( module->GetReference() );
|
component = aNetlist.GetComponentByReference( footprint->GetReference() );
|
||||||
|
|
||||||
if( component == NULL || component->GetProperties().count( "exclude_from_board" ) )
|
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 );
|
m_reporter->Report( msg, RPT_SEVERITY_WARNING );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.Printf( _( "Remove unused footprint %s." ), module->GetReference() );
|
msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() );
|
||||||
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
|
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
|
||||||
|
|
||||||
if( !m_isDryRun )
|
if( !m_isDryRun )
|
||||||
m_commit.Remove( module );
|
m_commit.Remove( footprint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue