kicad/pcbnew/footprint_editor_utils.cpp

453 lines
13 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
2018-01-31 16:09:26 +00:00
* @file footprint_editor_utils.cpp
*/
2007-05-06 16:03:28 +00:00
#include <fctsys.h>
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
#include <kiface_i.h>
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
#include <kiway.h>
#include <kiway_express.h>
#include <pcb_draw_panel_gal.h>
#include <confirm.h>
#include <gestfich.h>
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
#include <pgm_base.h>
#include <trigo.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <macros.h>
#include <invoke_pcb_dialog.h>
2018-01-31 08:23:20 +00:00
#include <pcb_layer_widget.h>
#include <board_commit.h>
#include <view/view.h>
#include <class_board.h>
#include <class_module.h>
#include <class_edge_mod.h>
#include <ratsnest_data.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
2018-01-29 20:58:58 +00:00
#include <footprint_edit_frame.h>
#include <footprint_viewer_frame.h>
#include <footprint_tree_pane.h>
#include <fp_lib_table.h>
#include <widgets/lib_tree.h>
#include <collectors.h>
2014-07-09 11:50:27 +00:00
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
2018-02-16 19:26:55 +00:00
#include <dialog_edit_footprint_for_fp_editor.h>
#include <dialog_move_exact.h>
2015-02-12 03:22:24 +00:00
#include <dialog_create_array.h>
#include <wildcards_and_files_ext.h>
#include <menus_helpers.h>
#include <footprint_wizard_frame.h>
#include <config_params.h>
#include <functional>
using namespace std::placeholders;
void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event )
{
Load_Module_From_BOARD( NULL );
}
void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
{
bool is_last_fp_from_brd = IsCurrentFPFromBoard();
MODULE* module = LoadFootprint( aFPID );
if( !module )
return;
if( !Clear_Pcb( true ) )
return;
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
AddModuleToBoard( module );
auto fp = GetBoard()->GetFirstModule();
if( fp )
{
fp->ClearFlags();
// if either m_Reference or m_Value are gone, reinstall them -
// otherwise you cannot see what you are doing on board
TEXTE_MODULE* ref = &fp->Reference();
TEXTE_MODULE* val = &fp->Value();
if( val && ref )
{
ref->SetType( TEXTE_MODULE::TEXT_is_REFERENCE ); // just in case ...
if( ref->GetLength() == 0 )
ref->SetText( wxT( "Ref**" ) );
val->SetType( TEXTE_MODULE::TEXT_is_VALUE ); // just in case ...
if( val->GetLength() == 0 )
val->SetText( wxT( "Val**" ) );
}
}
Zoom_Automatique( false );
2019-06-02 14:34:19 +00:00
Update3DView( true );
GetScreen()->ClrModify();
updateView();
GetCanvas()->Refresh();
2019-06-03 23:50:44 +00:00
// Update the save items if needed.
if( is_last_fp_from_brd )
2019-06-03 23:50:44 +00:00
{
ReCreateMenuBar();
ReCreateHToolbar();
2019-06-03 23:50:44 +00:00
}
m_treePane->GetLibTree()->ExpandLibId( aFPID );
m_treePane->GetLibTree()->CenterLibId( aFPID );
m_treePane->GetLibTree()->Refresh(); // update highlighting
}
void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
int id = event.GetId();
wxPoint pos;
wxGetMousePosition( &pos.x, &pos.y );
pos.y += 20;
switch( id )
{
case ID_MODEDIT_NEW_MODULE:
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
{
LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
MODULE* module = CreateNewModule( wxEmptyString );
2018-08-11 20:46:03 +00:00
if( !module )
break;
2018-08-11 20:46:03 +00:00
if( !Clear_Pcb( true ) )
break;
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
2018-08-11 20:46:03 +00:00
AddModuleToBoard( module );
2018-08-11 20:46:03 +00:00
// 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()->GetFirstModule() )
GetBoard()->GetFirstModule()->ClearFlags();
2018-08-11 20:46:03 +00:00
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();
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
}
updateView();
GetCanvas()->Refresh();
2019-06-02 14:34:19 +00:00
Update3DView( true );
SyncLibraryTree( false );
2008-09-18 12:07:34 +00:00
}
break;
2012-08-31 19:19:48 +00:00
case ID_MODEDIT_NEW_MODULE_FROM_WIZARD:
{
LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
{
if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. "
"Save changes?" ),
[&]() -> bool {
return SaveFootprint( GetBoard()->GetFirstModule() );
} ) )
2018-08-11 20:46:03 +00:00
{
break;
2018-08-11 20:46:03 +00:00
}
}
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
FOOTPRINT_WIZARD_FRAME* wizard = (FOOTPRINT_WIZARD_FRAME*) Kiway().Player(
FRAME_PCB_FOOTPRINT_WIZARD, true, this );
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
if( wizard->ShowModal( NULL, this ) )
{
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
// Creates the new footprint from python script wizard
MODULE* module = wizard->GetBuiltFootprint();
if( module == NULL ) // i.e. if create module command aborted
break;
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();
2019-06-02 14:34:19 +00:00
Update3DView( true );
SyncLibraryTree( false );
}
wizard->Destroy();
}
break;
case ID_MODEDIT_SAVE:
if( !GetBoard()->GetFirstModule() ) // no loaded footprint
break;
2019-06-03 23:50:44 +00:00
if( GetTargetFPID() == GetLoadedFPID() )
{
if( SaveFootprint( GetBoard()->GetFirstModule() ) )
{
m_toolManager->GetView()->Update( GetBoard()->GetFirstModule() );
GetCanvas()->ForceRefresh();
GetScreen()->ClrModify();
}
}
m_treePane->GetLibTree()->Refresh();
break;
case ID_MODEDIT_SAVE_AS:
2019-06-03 23:50:44 +00:00
if( GetTargetFPID().GetLibItemName().empty() )
{
// Save Library As
2019-06-03 23:50:44 +00:00
const wxString& src_libNickname = GetTargetFPID().GetLibNickname();
wxString src_libFullName = Prj().PcbFootprintLibs()->GetFullURI( src_libNickname );
if( SaveLibraryAs( src_libFullName ) )
SyncLibraryTree( true );
}
2019-06-03 23:50:44 +00:00
else if( GetTargetFPID() == GetLoadedFPID() )
{
// Save Board Footprint As
MODULE* footprint = GetBoard()->GetFirstModule();
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
2019-06-03 23:50:44 +00:00
MODULE* footprint = LoadFootprint( GetTargetFPID() );
if( footprint && SaveFootprintAs( footprint ) )
SyncLibraryTree( true );
}
m_treePane->GetLibTree()->Refresh();
break;
case ID_ADD_FOOTPRINT_TO_BOARD:
SaveFootprintToBoard( true );
break;
case ID_MODEDIT_CHECK:
// Currently: not implemented
break;
default:
wxLogDebug( wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) );
break;
}
2007-05-06 16:03:28 +00:00
}
void FOOTPRINT_EDIT_FRAME::editFootprintProperties( MODULE* aModule )
{
LIB_ID oldFPID = aModule->GetFPID();
DIALOG_FOOTPRINT_FP_EDITOR dialog( this, aModule );
dialog.ShowModal();
updateTitle(); // in case of a name change...
}
void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
{
switch( aItem->Type() )
{
case PCB_PAD_T:
InstallPadOptionsFrame( static_cast<D_PAD*>( aItem ) );
break;
case PCB_MODULE_T:
editFootprintProperties( (MODULE*) aItem );
GetCanvas()->Refresh();
break;
case PCB_MODULE_TEXT_T:
InstallTextOptionsFrame( aItem );
break;
case PCB_MODULE_EDGE_T :
InstallGraphicItemPropertiesDialog( aItem );
break;
default:
break;
}
}
COLOR4D FOOTPRINT_EDIT_FRAME::GetGridColor()
{
return Settings().Colors().GetItemColor( LAYER_GRID );
}
void FOOTPRINT_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
{
PCB_BASE_FRAME::SetActiveLayer( aLayer );
m_Layers->SelectLayer( GetActiveLayer() );
m_Layers->OnLayerSelected();
GetCanvas()->SetHighContrastLayer( aLayer );
GetCanvas()->Refresh();
}
bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
if( ! Clear_Pcb( true ) )
return false; // //this command is aborted
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
Import_Module( aFileSet[0] );
if( GetBoard()->GetFirstModule() )
GetBoard()->GetFirstModule()->ClearFlags();
GetScreen()->ClrModify();
Zoom_Automatique( false );
GetCanvas()->Refresh();
return true;
}
void FOOTPRINT_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
const std::string& payload = mail.GetPayload();
switch( mail.Command() )
{
case MAIL_FP_EDIT:
if( !payload.empty() )
{
wxFileName fpFileName( payload );
wxString libNickname;
wxString msg;
FP_LIB_TABLE* libTable = Prj().PcbFootprintLibs();
const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( fpFileName.GetPath() );
if( !libTableRow )
{
msg.Printf( _( "The current configuration does not include the footprint library\n"
"\"%s\".\nUse Manage Footprint Libraries to edit the configuration." ),
fpFileName.GetPath() );
DisplayErrorMessage( this, _( "Library not found in footprint library table." ), msg );
break;
}
libNickname = libTableRow->GetNickName();
if( !libTable->HasLibrary( libNickname, true ) )
{
msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n"
"in the current configuration. Use Manage Footprint Libraries to\n"
"edit the configuration." ), libNickname );
DisplayErrorMessage( this, _( "Footprint library not enabled." ), msg );
break;
}
LIB_ID fpId( libNickname, fpFileName.GetName() );
if( m_treePane )
{
m_treePane->GetLibTree()->SelectLibId( fpId );
wxCommandEvent event( COMPONENT_SELECTED );
wxPostEvent( m_treePane, event );
}
}
break;
default:
;
}
}