Cleanup. Push more editing functions to toolset.
Also cleans up some more Module -> Footprint items.
This commit is contained in:
parent
bc0dcdd5ce
commit
6e0a40e32e
|
@ -87,18 +87,17 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
||||||
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
|
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
|
||||||
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
|
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
|
||||||
|
|
||||||
EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng )
|
EVT_TOOL( ID_FPEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng )
|
||||||
|
|
||||||
EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
EVT_TOOL( ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard )
|
||||||
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard )
|
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard )
|
||||||
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
|
||||||
|
|
||||||
// Horizontal toolbar
|
// Horizontal toolbar
|
||||||
EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings )
|
EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings )
|
||||||
EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::SelectLayer )
|
||||||
|
|
||||||
// UI update events.
|
// UI update events.
|
||||||
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
EVT_UPDATE_UI( ID_LOAD_FOOTPRINT_FROM_BOARD,
|
||||||
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
|
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
|
||||||
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD,
|
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD,
|
||||||
FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
|
FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
|
||||||
|
@ -384,6 +383,15 @@ LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_EDIT_FRAME::ClearModify()
|
||||||
|
{
|
||||||
|
if( GetBoard()->GetFirstFootprint() )
|
||||||
|
m_footprintNameWhenLoaded = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
|
||||||
|
|
||||||
|
GetScreen()->ClrModify();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const
|
bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const
|
||||||
{
|
{
|
||||||
MODULE* footprint = GetBoard()->GetFirstFootprint();
|
MODULE* footprint = GetBoard()->GetFirstFootprint();
|
||||||
|
@ -755,7 +763,7 @@ void FOOTPRINT_EDIT_FRAME::UpdateUserInterface()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::updateView()
|
void FOOTPRINT_EDIT_FRAME::UpdateView()
|
||||||
{
|
{
|
||||||
GetCanvas()->UpdateColors();
|
GetCanvas()->UpdateColors();
|
||||||
GetCanvas()->DisplayBoard( GetBoard() );
|
GetCanvas()->DisplayBoard( GetBoard() );
|
||||||
|
@ -837,6 +845,12 @@ void FOOTPRINT_EDIT_FRAME::RegenerateLibraryTree()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_EDIT_FRAME::RefreshLibraryTree()
|
||||||
|
{
|
||||||
|
m_treePane->GetLibTree()->RefreshLibTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::FocusOnLibID( const LIB_ID& aLibID )
|
void FOOTPRINT_EDIT_FRAME::FocusOnLibID( const LIB_ID& aLibID )
|
||||||
{
|
{
|
||||||
m_treePane->GetLibTree()->SelectLibId( aLibID );
|
m_treePane->GetLibTree()->SelectLibId( aLibID );
|
||||||
|
@ -1016,7 +1030,7 @@ void FOOTPRINT_EDIT_FRAME::ActivateGalCanvas()
|
||||||
// Be sure the axis are enabled
|
// Be sure the axis are enabled
|
||||||
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
||||||
|
|
||||||
updateView();
|
UpdateView();
|
||||||
|
|
||||||
// Ensure the m_Layers settings are using the canvas type:
|
// Ensure the m_Layers settings are using the canvas type:
|
||||||
UpdateUserInterface();
|
UpdateUserInterface();
|
||||||
|
|
|
@ -106,8 +106,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdateUserInterface();
|
void UpdateUserInterface();
|
||||||
|
|
||||||
void Process_Special_Functions( wxCommandEvent& event );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the library tree and redraw the window
|
* Refresh the library tree and redraw the window
|
||||||
*/
|
*/
|
||||||
|
@ -137,6 +135,8 @@ public:
|
||||||
|
|
||||||
void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
|
void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
|
||||||
|
|
||||||
|
void SelectLayer( wxCommandEvent& event );
|
||||||
|
|
||||||
// The Tool Framework initalization, for GAL mode
|
// The Tool Framework initalization, for GAL mode
|
||||||
void setupTools();
|
void setupTools();
|
||||||
|
|
||||||
|
@ -163,7 +163,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Called from the main toolbar to load a footprint from board mainly to edit it.
|
* Called from the main toolbar to load a footprint from board mainly to edit it.
|
||||||
*/
|
*/
|
||||||
void LoadModuleFromBoard( wxCommandEvent& event );
|
void LoadFootprintFromBoard( wxCommandEvent& event );
|
||||||
|
|
||||||
|
void SaveFootprintToBoard( wxCommandEvent& event );
|
||||||
|
|
||||||
void LoadModuleFromLibrary( LIB_ID aFPID );
|
void LoadModuleFromLibrary( LIB_ID aFPID );
|
||||||
|
|
||||||
|
@ -213,6 +215,8 @@ public:
|
||||||
/// there is no selection in the tree.
|
/// there is no selection in the tree.
|
||||||
LIB_ID GetTargetFPID() const;
|
LIB_ID GetTargetFPID() const;
|
||||||
|
|
||||||
|
void ClearModify();
|
||||||
|
|
||||||
// importing / exporting Footprint
|
// importing / exporting Footprint
|
||||||
/**
|
/**
|
||||||
* Create a file containing only one footprint.
|
* Create a file containing only one footprint.
|
||||||
|
@ -319,6 +323,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void RegenerateLibraryTree();
|
void RegenerateLibraryTree();
|
||||||
|
|
||||||
|
void RefreshLibraryTree();
|
||||||
|
|
||||||
|
/// Reloads displayed items and sets view.
|
||||||
|
void UpdateView();
|
||||||
|
|
||||||
void FocusOnLibID( const LIB_ID& aLibID );
|
void FocusOnLibID( const LIB_ID& aLibID );
|
||||||
|
|
||||||
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
||||||
|
@ -344,9 +353,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
|
|
||||||
/// Reloads displayed items and sets view.
|
|
||||||
void updateView();
|
|
||||||
|
|
||||||
void restoreLastFootprint();
|
void restoreLastFootprint();
|
||||||
void retainLastFootprint();
|
void retainLastFootprint();
|
||||||
|
|
||||||
|
|
|
@ -21,38 +21,26 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <3d_viewer/eda_3d_viewer.h>
|
|
||||||
#include <board_commit.h>
|
|
||||||
#include <class_board.h>
|
|
||||||
#include <fp_shape.h>
|
|
||||||
#include <class_module.h>
|
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <dialog_create_array.h>
|
|
||||||
#include <dialog_edit_footprint_for_fp_editor.h>
|
#include <dialog_edit_footprint_for_fp_editor.h>
|
||||||
#include <footprint_edit_frame.h>
|
#include <footprint_edit_frame.h>
|
||||||
#include <footprint_tree_pane.h>
|
#include <footprint_tree_pane.h>
|
||||||
#include <footprint_viewer_frame.h>
|
|
||||||
#include <footprint_wizard_frame.h>
|
|
||||||
#include <fp_lib_table.h>
|
#include <fp_lib_table.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <gestfich.h>
|
|
||||||
#include <kiway.h>
|
|
||||||
#include <kiway_express.h>
|
#include <kiway_express.h>
|
||||||
#include <pcb_layer_box_selector.h>
|
#include <pcb_layer_box_selector.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <ratsnest/ratsnest_data.h>
|
#include <ratsnest/ratsnest_data.h>
|
||||||
#include <pgm_base.h>
|
|
||||||
#include <settings/color_settings.h>
|
#include <settings/color_settings.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <trigo.h>
|
|
||||||
#include <widgets/appearance_controls.h>
|
#include <widgets/appearance_controls.h>
|
||||||
#include <widgets/lib_tree.h>
|
#include <widgets/lib_tree.h>
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event )
|
void FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
LoadFootprintFromBoard( NULL );
|
LoadFootprintFromBoard( NULL );
|
||||||
}
|
}
|
||||||
|
@ -100,7 +88,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
|
||||||
|
|
||||||
GetScreen()->ClrModify();
|
GetScreen()->ClrModify();
|
||||||
|
|
||||||
updateView();
|
UpdateView();
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
|
|
||||||
// Update the save items if needed.
|
// Update the save items if needed.
|
||||||
|
@ -116,202 +104,18 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
void FOOTPRINT_EDIT_FRAME::SelectLayer( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
int id = event.GetId();
|
|
||||||
wxPoint pos;
|
|
||||||
|
|
||||||
wxGetMousePosition( &pos.x, &pos.y );
|
|
||||||
pos.y += 20;
|
|
||||||
|
|
||||||
switch( id )
|
|
||||||
{
|
|
||||||
case ID_MODEDIT_NEW_MODULE:
|
|
||||||
{
|
|
||||||
LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
|
|
||||||
MODULE* module = CreateNewFootprint( wxEmptyString );
|
|
||||||
|
|
||||||
if( !module )
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( !Clear_Pcb( true ) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
|
||||||
AddModuleToBoard( module );
|
|
||||||
|
|
||||||
// Initialize data relative to nets and netclasses (for a new
|
|
||||||
// module the defaults are used)
|
|
||||||
// This is mandatory to handle and draw pads
|
|
||||||
GetBoard()->BuildListOfNets();
|
|
||||||
module->SetPosition( wxPoint( 0, 0 ) );
|
|
||||||
|
|
||||||
if( GetBoard()->GetFirstFootprint() )
|
|
||||||
GetBoard()->GetFirstFootprint()->ClearFlags();
|
|
||||||
|
|
||||||
Zoom_Automatique( false );
|
|
||||||
GetScreen()->SetModify();
|
|
||||||
|
|
||||||
// If selected from the library tree then go ahead and save it there
|
|
||||||
if( !selected.GetLibNickname().empty() )
|
|
||||||
{
|
|
||||||
LIB_ID fpid = module->GetFPID();
|
|
||||||
fpid.SetLibNickname( selected.GetLibNickname() );
|
|
||||||
module->SetFPID( fpid );
|
|
||||||
SaveFootprint( module );
|
|
||||||
GetScreen()->ClrModify();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateView();
|
|
||||||
GetCanvas()->Refresh();
|
|
||||||
Update3DView( true );
|
|
||||||
|
|
||||||
SyncLibraryTree( false );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_MODEDIT_NEW_MODULE_FROM_WIZARD:
|
|
||||||
{
|
|
||||||
LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
|
|
||||||
|
|
||||||
if( IsContentModified() )
|
|
||||||
{
|
|
||||||
if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. "
|
|
||||||
"Save changes?" ),
|
|
||||||
[&]() -> bool
|
|
||||||
{
|
|
||||||
return SaveFootprint( GetBoard()->GetFirstFootprint() );
|
|
||||||
} ) )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FOOTPRINT_WIZARD_FRAME* wizard =
|
|
||||||
(FOOTPRINT_WIZARD_FRAME*) Kiway().Player( FRAME_FOOTPRINT_WIZARD, true, this );
|
|
||||||
|
|
||||||
if( wizard->ShowModal( NULL, this ) )
|
|
||||||
{
|
|
||||||
// Creates the new footprint from python script wizard
|
|
||||||
MODULE* module = wizard->GetBuiltFootprint();
|
|
||||||
|
|
||||||
if( module ) // i.e. if create module command is OK
|
|
||||||
{
|
|
||||||
Clear_Pcb( false );
|
|
||||||
|
|
||||||
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
|
||||||
// Add the new object to board
|
|
||||||
AddModuleToBoard( module );
|
|
||||||
|
|
||||||
// Initialize data relative to nets and netclasses (for a new
|
|
||||||
// module the defaults are used)
|
|
||||||
// This is mandatory to handle and draw pads
|
|
||||||
GetBoard()->BuildListOfNets();
|
|
||||||
module->SetPosition( wxPoint( 0, 0 ) );
|
|
||||||
module->ClearFlags();
|
|
||||||
|
|
||||||
Zoom_Automatique( false );
|
|
||||||
GetScreen()->SetModify();
|
|
||||||
|
|
||||||
// If selected from the library tree then go ahead and save it there
|
|
||||||
if( !selected.GetLibNickname().empty() )
|
|
||||||
{
|
|
||||||
LIB_ID fpid = module->GetFPID();
|
|
||||||
fpid.SetLibNickname( selected.GetLibNickname() );
|
|
||||||
module->SetFPID( fpid );
|
|
||||||
SaveFootprint( module );
|
|
||||||
GetScreen()->ClrModify();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateView();
|
|
||||||
GetCanvas()->Refresh();
|
|
||||||
Update3DView( true );
|
|
||||||
|
|
||||||
SyncLibraryTree( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wizard->Destroy();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_MODEDIT_SAVE:
|
|
||||||
if( !GetBoard()->GetFirstFootprint() ) // no loaded footprint
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( GetTargetFPID() == GetLoadedFPID() )
|
|
||||||
{
|
|
||||||
if( SaveFootprint( GetBoard()->GetFirstFootprint() ) )
|
|
||||||
{
|
|
||||||
m_toolManager->GetView()->Update( GetBoard()->GetFirstFootprint() );
|
|
||||||
|
|
||||||
GetCanvas()->ForceRefresh();
|
|
||||||
GetScreen()->ClrModify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_treePane->GetLibTree()->RefreshLibTree();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_MODEDIT_SAVE_AS:
|
|
||||||
if( GetTargetFPID().GetLibItemName().empty() )
|
|
||||||
{
|
|
||||||
// Save Library As
|
|
||||||
const wxString& src_libNickname = GetTargetFPID().GetLibNickname();
|
|
||||||
wxString src_libFullName = Prj().PcbFootprintLibs()->GetFullURI( src_libNickname );
|
|
||||||
|
|
||||||
if( SaveLibraryAs( src_libFullName ) )
|
|
||||||
SyncLibraryTree( true );
|
|
||||||
}
|
|
||||||
else if( GetTargetFPID() == GetLoadedFPID() )
|
|
||||||
{
|
|
||||||
// Save Board Footprint As
|
|
||||||
MODULE* footprint = GetBoard()->GetFirstFootprint();
|
|
||||||
|
|
||||||
if( footprint && SaveFootprintAs( footprint ) )
|
|
||||||
{
|
|
||||||
m_footprintNameWhenLoaded = footprint->GetFPID().GetLibItemName();
|
|
||||||
m_toolManager->GetView()->Update( footprint );
|
|
||||||
GetScreen()->ClrModify();
|
|
||||||
|
|
||||||
GetCanvas()->ForceRefresh();
|
|
||||||
SyncLibraryTree( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Save Selected Footprint As
|
|
||||||
MODULE* footprint = LoadFootprint( GetTargetFPID() );
|
|
||||||
|
|
||||||
if( footprint && SaveFootprintAs( footprint ) )
|
|
||||||
SyncLibraryTree( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_treePane->GetLibTree()->RefreshLibTree();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_ADD_FOOTPRINT_TO_BOARD:
|
|
||||||
SaveFootprintToBoard( true );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_TOOLBARH_PCB_SELECT_LAYER:
|
|
||||||
SetActiveLayer( ToLAYER_ID( m_selLayerBox->GetLayerSelection() ) );
|
SetActiveLayer( ToLAYER_ID( m_selLayerBox->GetLayerSelection() ) );
|
||||||
|
|
||||||
if( GetDisplayOptions().m_ContrastModeDisplay !=
|
if( GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
|
||||||
HIGH_CONTRAST_MODE::NORMAL )
|
|
||||||
{
|
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_MODEDIT_CHECK:
|
|
||||||
// Currently: not implemented
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
void FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( wxCommandEvent& event )
|
||||||
wxFAIL_MSG( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" );
|
{
|
||||||
break;
|
SaveFootprintToBoard( true );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -300,7 +300,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module( const wxString& aName )
|
||||||
module->SetPosition( wxPoint( 0, 0 ) );
|
module->SetPosition( wxPoint( 0, 0 ) );
|
||||||
|
|
||||||
GetBoard()->BuildListOfNets();
|
GetBoard()->BuildListOfNets();
|
||||||
updateView();
|
UpdateView();
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
|
||||||
ClearUndoRedoList();
|
ClearUndoRedoList();
|
||||||
GetScreen()->ClrModify();
|
GetScreen()->ClrModify();
|
||||||
|
|
||||||
updateView();
|
UpdateView();
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -151,7 +151,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( MODULE* aFootprint )
|
||||||
}
|
}
|
||||||
|
|
||||||
Update3DView( true );
|
Update3DView( true );
|
||||||
updateView();
|
UpdateView();
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
m_treePane->GetLibTree()->RefreshLibTree(); // update any previously-highlighted items
|
m_treePane->GetLibTree()->RefreshLibTree(); // update any previously-highlighted items
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
||||||
submenuExport->Add( PCB_ACTIONS::exportFootprint );
|
submenuExport->Add( PCB_ACTIONS::exportFootprint );
|
||||||
submenuExport->Add( _( "Export View as &PNG..." ),
|
submenuExport->Add( _( "Export View as &PNG..." ),
|
||||||
_( "Create a PNG file from the current view" ),
|
_( "Create a PNG file from the current view" ),
|
||||||
ID_MODEDIT_SAVE_PNG,
|
ID_FPEDIT_SAVE_PNG,
|
||||||
plot_xpm );
|
plot_xpm );
|
||||||
|
|
||||||
fileMenu->Add( submenuExport );
|
fileMenu->Add( submenuExport );
|
||||||
|
@ -213,7 +213,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
||||||
|
|
||||||
toolsMenu->Add( _( "&Load Footprint from PCB..." ),
|
toolsMenu->Add( _( "&Load Footprint from PCB..." ),
|
||||||
_( "Load a footprint from the current board into the editor" ),
|
_( "Load a footprint from the current board into the editor" ),
|
||||||
ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
ID_LOAD_FOOTPRINT_FROM_BOARD,
|
||||||
load_module_board_xpm );
|
load_module_board_xpm );
|
||||||
|
|
||||||
toolsMenu->Add( _( "&Insert Footprint on PCB" ),
|
toolsMenu->Add( _( "&Insert Footprint on PCB" ),
|
||||||
|
|
|
@ -97,14 +97,7 @@ enum pcbnew_ids
|
||||||
|
|
||||||
ID_TOOLBARH_PCB_SELECT_LAYER,
|
ID_TOOLBARH_PCB_SELECT_LAYER,
|
||||||
|
|
||||||
// ID used in module editor:
|
ID_FPEDIT_SAVE_PNG,
|
||||||
ID_MODEDIT_CHECK,
|
|
||||||
ID_MODEDIT_SAVE,
|
|
||||||
ID_MODEDIT_SAVE_AS,
|
|
||||||
ID_MODEDIT_SAVE_PNG,
|
|
||||||
ID_MODEDIT_NEW_MODULE,
|
|
||||||
ID_MODEDIT_NEW_MODULE_FROM_WIZARD,
|
|
||||||
ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
|
||||||
|
|
||||||
ID_MODVIEW_LIB_FILTER,
|
ID_MODVIEW_LIB_FILTER,
|
||||||
ID_MODVIEW_LIB_LIST,
|
ID_MODVIEW_LIB_LIST,
|
||||||
|
@ -122,6 +115,7 @@ enum pcbnew_ids
|
||||||
ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT,
|
ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT,
|
||||||
|
|
||||||
ID_ADD_FOOTPRINT_TO_BOARD,
|
ID_ADD_FOOTPRINT_TO_BOARD,
|
||||||
|
ID_LOAD_FOOTPRINT_FROM_BOARD,
|
||||||
|
|
||||||
ID_PCBNEW_END_LIST
|
ID_PCBNEW_END_LIST
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,7 +84,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
||||||
m_mainToolBar->Add( PCB_ACTIONS::defaultPadProperties );
|
m_mainToolBar->Add( PCB_ACTIONS::defaultPadProperties );
|
||||||
|
|
||||||
m_mainToolBar->AddScaledSeparator( this );
|
m_mainToolBar->AddScaledSeparator( this );
|
||||||
m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
|
m_mainToolBar->AddTool( ID_LOAD_FOOTPRINT_FROM_BOARD, wxEmptyString,
|
||||||
KiScaledBitmap( load_module_board_xpm, this ),
|
KiScaledBitmap( load_module_board_xpm, this ),
|
||||||
_( "Load footprint from current board" ) );
|
_( "Load footprint from current board" ) );
|
||||||
|
|
||||||
|
@ -92,13 +92,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
||||||
KiScaledBitmap( export_xpm, this ),
|
KiScaledBitmap( export_xpm, this ),
|
||||||
_( "Insert footprint into current board" ) );
|
_( "Insert footprint into current board" ) );
|
||||||
|
|
||||||
#if 0 // Currently there is no check footprint function defined, so do not show this tool
|
|
||||||
m_mainToolBar->AddScaledSeparator( this );
|
|
||||||
m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString,
|
|
||||||
KiScaledBitmap( module_check_xpm, this ),
|
|
||||||
_( "Check footprint" ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_mainToolBar->AddScaledSeparator( this );
|
m_mainToolBar->AddScaledSeparator( this );
|
||||||
|
|
||||||
// Grid selection choice box.
|
// Grid selection choice box.
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <fp_lib_table.h>
|
#include <fp_lib_table.h>
|
||||||
#include <dialogs/dialog_cleanup_graphics.h>
|
#include <dialogs/dialog_cleanup_graphics.h>
|
||||||
|
#include <footprint_wizard_frame.h>
|
||||||
|
#include <kiway.h>
|
||||||
|
|
||||||
FOOTPRINT_EDITOR_TOOLS::FOOTPRINT_EDITOR_TOOLS() :
|
FOOTPRINT_EDITOR_TOOLS::FOOTPRINT_EDITOR_TOOLS() :
|
||||||
PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
|
PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
|
||||||
|
@ -125,32 +126,166 @@ bool FOOTPRINT_EDITOR_TOOLS::Init()
|
||||||
|
|
||||||
int FOOTPRINT_EDITOR_TOOLS::NewFootprint( const TOOL_EVENT& aEvent )
|
int FOOTPRINT_EDITOR_TOOLS::NewFootprint( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_NEW_MODULE );
|
LIB_ID selected = m_frame->GetTreeFPID();
|
||||||
getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
|
MODULE* newFootprint = m_frame->CreateNewFootprint( wxEmptyString );
|
||||||
|
|
||||||
|
if( !newFootprint )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( !m_frame->Clear_Pcb( true ) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
canvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||||
|
m_frame->AddModuleToBoard( newFootprint );
|
||||||
|
|
||||||
|
// Initialize data relative to nets and netclasses (for a new
|
||||||
|
// module the defaults are used)
|
||||||
|
// This is mandatory to handle and draw pads
|
||||||
|
board()->BuildListOfNets();
|
||||||
|
newFootprint->SetPosition( wxPoint( 0, 0 ) );
|
||||||
|
newFootprint->ClearFlags();
|
||||||
|
|
||||||
|
m_frame->Zoom_Automatique( false );
|
||||||
|
m_frame->GetScreen()->SetModify();
|
||||||
|
|
||||||
|
// If selected from the library tree then go ahead and save it there
|
||||||
|
if( !selected.GetLibNickname().empty() )
|
||||||
|
{
|
||||||
|
LIB_ID fpid = newFootprint->GetFPID();
|
||||||
|
fpid.SetLibNickname( selected.GetLibNickname() );
|
||||||
|
newFootprint->SetFPID( fpid );
|
||||||
|
m_frame->SaveFootprint( newFootprint );
|
||||||
|
m_frame->ClearModify();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->UpdateView();
|
||||||
|
m_frame->Update3DView( true );
|
||||||
|
|
||||||
|
m_frame->SyncLibraryTree( false );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FOOTPRINT_EDITOR_TOOLS::CreateFootprint( const TOOL_EVENT& aEvent )
|
int FOOTPRINT_EDITOR_TOOLS::CreateFootprint( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_NEW_MODULE_FROM_WIZARD );
|
LIB_ID selected = m_frame->GetTreeFPID();
|
||||||
getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
|
|
||||||
|
if( m_frame->IsContentModified() )
|
||||||
|
{
|
||||||
|
if( !HandleUnsavedChanges( m_frame, _( "The current footprint has been modified. "
|
||||||
|
"Save changes?" ),
|
||||||
|
[&]() -> bool
|
||||||
|
{
|
||||||
|
return m_frame->SaveFootprint( footprint() );
|
||||||
|
} ) )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* wizard = (FOOTPRINT_WIZARD_FRAME*) m_frame->Kiway().Player( FRAME_FOOTPRINT_WIZARD,
|
||||||
|
true, m_frame );
|
||||||
|
|
||||||
|
if( wizard->ShowModal( NULL, m_frame ) )
|
||||||
|
{
|
||||||
|
// Creates the new footprint from python script wizard
|
||||||
|
MODULE* newFootprint = wizard->GetBuiltFootprint();
|
||||||
|
|
||||||
|
if( newFootprint ) // i.e. if create module command is OK
|
||||||
|
{
|
||||||
|
m_frame->Clear_Pcb( false );
|
||||||
|
|
||||||
|
canvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||||
|
// Add the new object to board
|
||||||
|
m_frame->AddModuleToBoard( newFootprint );
|
||||||
|
|
||||||
|
// Initialize data relative to nets and netclasses (for a new
|
||||||
|
// module the defaults are used)
|
||||||
|
// This is mandatory to handle and draw pads
|
||||||
|
board()->BuildListOfNets();
|
||||||
|
newFootprint->SetPosition( wxPoint( 0, 0 ) );
|
||||||
|
newFootprint->ClearFlags();
|
||||||
|
|
||||||
|
m_frame->Zoom_Automatique( false );
|
||||||
|
m_frame->GetScreen()->SetModify();
|
||||||
|
|
||||||
|
// If selected from the library tree then go ahead and save it there
|
||||||
|
if( !selected.GetLibNickname().empty() )
|
||||||
|
{
|
||||||
|
LIB_ID fpid = newFootprint->GetFPID();
|
||||||
|
fpid.SetLibNickname( selected.GetLibNickname() );
|
||||||
|
newFootprint->SetFPID( fpid );
|
||||||
|
m_frame->SaveFootprint( newFootprint );
|
||||||
|
m_frame->ClearModify();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->UpdateView();
|
||||||
|
canvas()->Refresh();
|
||||||
|
m_frame->Update3DView( true );
|
||||||
|
|
||||||
|
m_frame->SyncLibraryTree( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wizard->Destroy();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FOOTPRINT_EDITOR_TOOLS::Save( const TOOL_EVENT& aEvent )
|
int FOOTPRINT_EDITOR_TOOLS::Save( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE );
|
if( !footprint() ) // no loaded footprint
|
||||||
getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
|
return 0;
|
||||||
|
|
||||||
|
if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
|
||||||
|
{
|
||||||
|
if( m_frame->SaveFootprint( footprint() ) )
|
||||||
|
{
|
||||||
|
view()->Update( footprint() );
|
||||||
|
|
||||||
|
canvas()->ForceRefresh();
|
||||||
|
m_frame->ClearModify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->RefreshLibraryTree();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int FOOTPRINT_EDITOR_TOOLS::SaveAs( const TOOL_EVENT& aEvent )
|
int FOOTPRINT_EDITOR_TOOLS::SaveAs( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE_AS );
|
if( m_frame->GetTargetFPID().GetLibItemName().empty() )
|
||||||
getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
|
{
|
||||||
|
// Save Library As
|
||||||
|
const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname();
|
||||||
|
wxString src_libFullName = m_frame->Prj().PcbFootprintLibs()->GetFullURI( src_libNickname );
|
||||||
|
|
||||||
|
if( m_frame->SaveLibraryAs( src_libFullName ) )
|
||||||
|
m_frame->SyncLibraryTree( true );
|
||||||
|
}
|
||||||
|
else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() )
|
||||||
|
{
|
||||||
|
// Save Board Footprint As
|
||||||
|
if( footprint() && m_frame->SaveFootprintAs( footprint() ) )
|
||||||
|
{
|
||||||
|
view()->Update( footprint() );
|
||||||
|
m_frame->ClearModify();
|
||||||
|
|
||||||
|
canvas()->ForceRefresh();
|
||||||
|
m_frame->SyncLibraryTree( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Save Selected Footprint As
|
||||||
|
MODULE* footprint = m_frame->LoadFootprint( m_frame->GetTargetFPID() );
|
||||||
|
|
||||||
|
if( footprint && m_frame->SaveFootprintAs( footprint ) )
|
||||||
|
m_frame->SyncLibraryTree( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->RefreshLibraryTree();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ protected:
|
||||||
|
|
||||||
BOARD* board() const { return getModel<BOARD>(); }
|
BOARD* board() const { return getModel<BOARD>(); }
|
||||||
|
|
||||||
MODULE* module() const
|
MODULE* footprint() const
|
||||||
{
|
{
|
||||||
return board()->GetFirstFootprint();
|
return board()->GetFirstFootprint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -653,7 +653,7 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||||
// The clipboard can contain two different things, an entire kicad_pcb
|
// The clipboard can contain two different things, an entire kicad_pcb
|
||||||
// or a single module
|
// or a single module
|
||||||
|
|
||||||
if( isFootprintEditor && ( !board() || !module() ) )
|
if( isFootprintEditor && ( !board() || !footprint() ) )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue