2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2015-09-15 17:16:23 +00:00
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56:32 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file pcbnew/loadcmp.cpp
|
|
|
|
* @brief Footprints selection and loading functions.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
#include <functional>
|
|
|
|
using namespace std::placeholders;
|
2015-04-02 11:18:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
2014-07-09 09:22:43 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <eda_doc.h>
|
|
|
|
#include <kicad_string.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>
|
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>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <filter_reader.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <macros.h>
|
2013-05-20 14:49:20 +00:00
|
|
|
#include <fp_lib_table.h>
|
|
|
|
#include <fpid.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
2012-04-17 01:35:43 +00:00
|
|
|
#include <io_mgr.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <module_editor_frame.h>
|
|
|
|
#include <footprint_info.h>
|
|
|
|
#include <dialog_get_component.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
#include <modview_frame.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2014-07-09 09:59:23 +00:00
|
|
|
#include <class_pcb_layer_widget.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
static void DisplayCmpDoc( wxString& aName, void* aData );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-22 20:59:16 +00:00
|
|
|
static FOOTPRINT_LIST MList;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
static void clearModuleItemFlags( BOARD_ITEM* aItem )
|
2015-02-18 00:01:02 +00:00
|
|
|
{
|
|
|
|
aItem->ClearFlags();
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-12-07 05:28:49 +00:00
|
|
|
MODULE* newModule;
|
2014-05-05 07:46:07 +00:00
|
|
|
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
|
|
|
|
|
|
|
|
if( frame == NULL ) // happens if no board editor opened
|
|
|
|
return false;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
if( aModule == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-05-05 07:46:07 +00:00
|
|
|
if( ! frame->GetBoard() || ! frame->GetBoard()->m_Modules )
|
2010-06-14 20:16:47 +00:00
|
|
|
return false;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2014-05-05 07:46:07 +00:00
|
|
|
aModule = SelectFootprint( frame->GetBoard() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
if( aModule == NULL )
|
2010-06-14 20:16:47 +00:00
|
|
|
return false;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-06-14 20:16:47 +00:00
|
|
|
Clear_Pcb( false );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2012-01-14 19:50:32 +00:00
|
|
|
newModule = new MODULE( *aModule );
|
|
|
|
newModule->SetParent( GetBoard() );
|
2013-03-13 18:53:58 +00:00
|
|
|
newModule->SetLink( aModule->GetTimeStamp() );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
aModule = newModule;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2014-04-24 18:54:49 +00:00
|
|
|
newModule->ClearFlags();
|
2016-06-29 10:23:11 +00:00
|
|
|
newModule->RunOnChildren( std::bind( &clearModuleItemFlags, _1 ) );
|
2015-02-18 00:01:02 +00:00
|
|
|
|
|
|
|
GetBoard()->Add( newModule );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-02-17 16:32:47 +00:00
|
|
|
// Clear references to any net info, because the footprint editor
|
2014-04-24 18:54:49 +00:00
|
|
|
// does know any thing about nets handled by the current edited board.
|
2015-02-17 16:32:47 +00:00
|
|
|
// Morever we do not want to save any reference to an unknown net when
|
|
|
|
// saving the footprint in lib cache
|
|
|
|
// so we force the ORPHANED dummy net info for all pads
|
2015-02-18 09:13:17 +00:00
|
|
|
newModule->ClearAllNets();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
2014-04-24 18:54:49 +00:00
|
|
|
PlaceModule( newModule, NULL );
|
2014-07-09 12:23:13 +00:00
|
|
|
newModule->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2012-01-04 19:10:33 +00:00
|
|
|
// Put it on FRONT layer,
|
|
|
|
// because this is the default in ModEdit, and in libs
|
2014-06-24 16:17:18 +00:00
|
|
|
if( newModule->GetLayer() != F_Cu )
|
2014-04-24 18:54:49 +00:00
|
|
|
newModule->Flip( newModule->GetPosition() );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2012-01-04 19:10:33 +00:00
|
|
|
// Put it in orientation 0,
|
|
|
|
// because this is the default orientation in ModEdit, and in libs
|
2014-04-24 18:54:49 +00:00
|
|
|
Rotate_Module( NULL, newModule, 0, false );
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->ClrModify();
|
2011-03-01 18:45:21 +00:00
|
|
|
Zoom_Automatique( false );
|
2010-06-14 20:16:47 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
if( IsGalCanvasActive() )
|
2014-07-09 11:50:27 +00:00
|
|
|
updateView();
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2010-06-14 20:16:47 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-11-12 01:14:17 +00:00
|
|
|
|
|
|
|
wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
|
2012-02-09 20:33:38 +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
|
|
|
// Close the current non-modal Lib browser if opened, and open a new one, in "modal" mode:
|
|
|
|
FOOTPRINT_VIEWER_FRAME* viewer;
|
|
|
|
viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
|
2012-09-12 09:53:11 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( viewer )
|
|
|
|
viewer->Destroy();
|
|
|
|
|
2016-03-21 16:36:06 +00:00
|
|
|
SetFocus();
|
|
|
|
|
2015-12-30 07:46:32 +00:00
|
|
|
// Creates the modal Lib browser:
|
2016-03-21 16:36:06 +00:00
|
|
|
viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true, this );
|
2012-02-09 20:33:38 +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
|
|
|
wxString fpid;
|
2015-04-02 11:18:19 +00:00
|
|
|
int ret = viewer->ShowModal( &fpid, this );
|
|
|
|
(void) ret; // make static analyser quiet
|
2013-11-12 01:14:17 +00:00
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
viewer->Destroy();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-11-12 01:14:17 +00:00
|
|
|
return fpid;
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
|
|
|
|
FP_LIB_TABLE* aTable,
|
|
|
|
bool aUseFootprintViewer,
|
|
|
|
wxDC* aDC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-26 05:29:54 +00:00
|
|
|
MODULE* module = NULL;
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint curspos = GetCrossHairPosition();
|
2011-12-07 05:28:49 +00:00
|
|
|
wxString moduleName, keys;
|
2013-04-11 17:40:20 +00:00
|
|
|
wxString libName = aLibrary;
|
2012-04-17 01:35:43 +00:00
|
|
|
bool allowWildSeach = true;
|
2011-12-07 05:28:49 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static wxArrayString HistoryList;
|
2012-02-09 20:33:38 +00:00
|
|
|
static wxString lastComponentName;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-04-16 03:18:41 +00:00
|
|
|
// Ask for a component name or key words
|
2014-10-08 05:50:56 +00:00
|
|
|
DIALOG_GET_COMPONENT dlg( this, HistoryList, _( "Load Footprint" ), aUseFootprintViewer );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
dlg.SetComponentName( lastComponentName );
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2009-10-16 17:18:23 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( dlg.m_GetExtraFunction )
|
|
|
|
{
|
2013-05-08 20:47:23 +00:00
|
|
|
// SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e.
|
|
|
|
// <lib_name>/<footprint name> or FPID format "lib_name:fp_name:rev#"
|
2013-05-28 16:54:59 +00:00
|
|
|
moduleName = SelectFootprintFromLibBrowser();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
moduleName = dlg.GetComponentName();
|
|
|
|
}
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2012-04-16 03:18:41 +00:00
|
|
|
if( moduleName.IsEmpty() ) // Cancel command
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-12-22 11:58:26 +00:00
|
|
|
if( dlg.IsKeyword() ) // Selection by keywords
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
allowWildSeach = false;
|
2012-02-19 19:53:11 +00:00
|
|
|
keys = moduleName;
|
2013-05-20 14:49:20 +00:00
|
|
|
moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2015-12-22 11:58:26 +00:00
|
|
|
if( moduleName.IsEmpty() ) // Cancel command
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-05-08 20:47:23 +00:00
|
|
|
else if( moduleName.Contains( wxT( "?" ) )
|
|
|
|
|| moduleName.Contains( wxT( "*" ) ) ) // Selection wild card
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
allowWildSeach = false;
|
2013-05-20 14:49:20 +00:00
|
|
|
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
if( moduleName.IsEmpty() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2013-05-08 20:47:23 +00:00
|
|
|
return NULL; // Cancel command.
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
FPID fpid;
|
|
|
|
|
2013-09-17 00:52:08 +00:00
|
|
|
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
|
2013-11-02 00:24:38 +00:00
|
|
|
wxString::Format( wxT( "Could not parse FPID string '%s'." ),
|
2013-05-28 16:54:59 +00:00
|
|
|
GetChars( moduleName ) ) );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
module = loadFootprint( fpid );
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-05-28 16:54:59 +00:00
|
|
|
{
|
2013-11-02 00:24:38 +00:00
|
|
|
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
2013-05-28 16:54:59 +00:00
|
|
|
fpid.Format().c_str(), GetChars( ioe.errorText ) );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
if( !module && allowWildSeach ) // Search with wild card
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-04-17 01:35:43 +00:00
|
|
|
allowWildSeach = false;
|
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
|
|
|
|
moduleName = wildname;
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
if( moduleName.IsEmpty() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2012-04-16 03:18:41 +00:00
|
|
|
return NULL; // Cancel command.
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2013-09-17 00:52:08 +00:00
|
|
|
wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
|
2013-11-02 00:24:38 +00:00
|
|
|
wxString::Format( wxT( "Could not parse FPID string '%s'." ),
|
2013-05-28 16:54:59 +00:00
|
|
|
GetChars( moduleName ) ) );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
module = loadFootprint( fpid );
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-05-28 16:54:59 +00:00
|
|
|
{
|
2013-11-02 00:24:38 +00:00
|
|
|
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
2013-05-28 16:54:59 +00:00
|
|
|
fpid.Format().c_str(), GetChars( ioe.errorText ) );
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( curspos );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module )
|
|
|
|
{
|
2013-05-28 16:54:59 +00:00
|
|
|
GetBoard()->Add( module, ADD_APPEND );
|
2015-02-17 16:32:47 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
lastComponentName = moduleName;
|
2011-12-07 05:28:49 +00:00
|
|
|
AddHistoryComponentName( HistoryList, moduleName );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
module->SetFlags( IS_NEW );
|
2013-03-13 18:53:58 +00:00
|
|
|
module->SetLink( 0 );
|
2014-07-22 07:50:40 +00:00
|
|
|
|
|
|
|
if( IsGalCanvasActive() )
|
|
|
|
module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
|
|
|
|
else
|
|
|
|
module->SetPosition( curspos );
|
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
module->SetTimeStamp( GetNewTimeStamp() );
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-01-04 19:10:33 +00:00
|
|
|
// Put it on FRONT layer,
|
2012-09-13 12:15:24 +00:00
|
|
|
// (Can be stored flipped if the lib is an archive built from a board)
|
|
|
|
if( module->IsFlipped() )
|
2013-03-13 18:53:58 +00:00
|
|
|
module->Flip( module->GetPosition() );
|
2012-04-17 01:35:43 +00:00
|
|
|
|
2012-09-13 12:15:24 +00:00
|
|
|
// Place it in orientation 0,
|
|
|
|
// even if it is not saved with orientation 0 in lib
|
2012-01-04 19:10:33 +00:00
|
|
|
// (Can happen if the lib is an archive built from a board)
|
|
|
|
Rotate_Module( NULL, module, 0, false );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
|
|
|
RecalculateAllTracksNetcode();
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
if( aDC )
|
|
|
|
module->Draw( m_canvas, aDC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 20:41:26 +00:00
|
|
|
|
2013-11-22 19:47:10 +00:00
|
|
|
MODULE* PCB_BASE_FRAME::LoadFootprint( const FPID& aFootprintId )
|
|
|
|
{
|
|
|
|
MODULE* module = NULL;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
module = loadFootprint( aFootprintId );
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-11-22 19:47:10 +00:00
|
|
|
{
|
|
|
|
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
|
|
|
aFootprintId.Format().c_str(), GetChars( ioe.errorText ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
|
2015-02-21 00:41:10 +00:00
|
|
|
throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception )
|
2013-04-25 16:29:35 +00:00
|
|
|
{
|
2014-05-09 18:35:48 +00:00
|
|
|
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
* 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
|
|
|
|
|
|
|
wxCHECK_MSG( fptbl, NULL, wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) );
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2015-02-17 16:32:47 +00:00
|
|
|
MODULE* module = fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
|
|
|
|
|
2015-02-18 09:13:17 +00:00
|
|
|
// If the module is found, clear all net info,
|
|
|
|
// to be sure there is no broken links
|
|
|
|
// to any netinfo list (should be not needed, but it can be edited from
|
|
|
|
// the footprint editor )
|
|
|
|
if( module )
|
|
|
|
module->ClearAllNets();
|
2015-02-17 16:32:47 +00:00
|
|
|
|
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
|
2013-10-13 21:33:58 +00:00
|
|
|
const wxString& aLibraryName,
|
2013-05-08 20:47:23 +00:00
|
|
|
const wxString& aMask,
|
2013-05-20 14:49:20 +00:00
|
|
|
const wxString& aKeyWord,
|
|
|
|
FP_LIB_TABLE* aTable )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-11-18 19:27:27 +00:00
|
|
|
static wxString oldName; // Save the name of the last module loaded.
|
|
|
|
|
|
|
|
wxString fpname;
|
|
|
|
wxString msg;
|
|
|
|
wxArrayString libraries;
|
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
std::vector< wxArrayString > rows;
|
|
|
|
|
2013-10-13 21:33:58 +00:00
|
|
|
wxASSERT( aTable != NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-12-09 18:09:58 +00:00
|
|
|
MList.ReadFootprintFiles( aTable, !aLibraryName ? NULL : &aLibraryName );
|
2013-09-22 17:20:46 +00:00
|
|
|
|
2013-12-09 18:09:58 +00:00
|
|
|
if( MList.GetErrorCount() )
|
|
|
|
{
|
|
|
|
MList.DisplayErrors( this );
|
2013-09-22 17:20:46 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
if( MList.GetCount() == 0 )
|
|
|
|
{
|
|
|
|
wxString tmp;
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < libraries.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
tmp += libraries[i] + wxT( "\n" );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
msg.Printf( _( "No footprints could be read from library file(s):\n\n%s\nin any of "
|
|
|
|
"the library search paths. Verify your system is configured properly "
|
|
|
|
"so the footprint libraries can be found." ), GetChars( tmp ) );
|
|
|
|
DisplayError( aWindow, msg );
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
2011-05-09 19:44:06 +00:00
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
if( !aKeyWord.IsEmpty() ) // Create a list of modules found by keyword.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-22 20:59:16 +00:00
|
|
|
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-12-12 16:01:03 +00:00
|
|
|
if( KeyWordOk( aKeyWord, MList.GetItem( ii ).GetKeywords() ) )
|
2013-05-08 20:47:23 +00:00
|
|
|
{
|
|
|
|
wxArrayString cols;
|
|
|
|
cols.Add( MList.GetItem( ii ).GetFootprintName() );
|
2013-10-31 21:30:57 +00:00
|
|
|
cols.Add( MList.GetItem( ii ).GetNickname() );
|
2013-05-08 20:47:23 +00:00
|
|
|
rows.push_back( cols );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-08 20:47:23 +00:00
|
|
|
else if( !aMask.IsEmpty() ) // Create a list of modules found by pattern
|
2011-05-09 19:44:06 +00:00
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
|
|
|
{
|
2013-12-12 16:01:03 +00:00
|
|
|
const wxString& candidate = MList.GetItem( ii ).GetFootprintName();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-05-09 19:44:06 +00:00
|
|
|
if( WildCompareString( aMask, candidate, false ) )
|
2013-05-08 20:47:23 +00:00
|
|
|
{
|
|
|
|
wxArrayString cols;
|
|
|
|
cols.Add( MList.GetItem( ii ).GetFootprintName() );
|
2013-10-31 21:30:57 +00:00
|
|
|
cols.Add( MList.GetItem( ii ).GetNickname() );
|
2013-05-08 20:47:23 +00:00
|
|
|
rows.push_back( cols );
|
|
|
|
}
|
2011-05-09 19:44:06 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-08 20:47:23 +00:00
|
|
|
else // Create the full list of modules
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2011-02-22 20:59:16 +00:00
|
|
|
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
2013-05-08 20:47:23 +00:00
|
|
|
{
|
|
|
|
wxArrayString cols;
|
|
|
|
cols.Add( MList.GetItem( ii ).GetFootprintName() );
|
2013-10-31 21:30:57 +00:00
|
|
|
cols.Add( MList.GetItem( ii ).GetNickname() );
|
2013-05-08 20:47:23 +00:00
|
|
|
rows.push_back( cols );
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
if( !rows.empty() )
|
2011-07-06 16:40:54 +00:00
|
|
|
{
|
2013-03-19 01:25:19 +00:00
|
|
|
wxArrayString headers;
|
2013-04-10 07:23:20 +00:00
|
|
|
|
2014-11-02 12:44:57 +00:00
|
|
|
headers.Add( _( "Footprint" ) );
|
2013-05-08 20:47:23 +00:00
|
|
|
headers.Add( _( "Library" ) );
|
2013-04-10 07:23:20 +00:00
|
|
|
|
2014-11-02 12:44:57 +00:00
|
|
|
msg.Printf( _( "Footprints [%d items]" ), (int) rows.size() );
|
2013-10-13 21:33:58 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
EDA_LIST_DIALOG dlg( aWindow, msg, headers, rows, oldName, DisplayCmpDoc );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-07-06 16:40:54 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2013-01-10 12:18:43 +00:00
|
|
|
{
|
2013-11-18 19:27:27 +00:00
|
|
|
fpname = dlg.GetTextSelection();
|
2013-05-08 20:47:23 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
fpname = dlg.GetTextSelection( 1 ) + wxT( ":" ) + fpname;
|
2013-05-08 20:47:23 +00:00
|
|
|
|
2013-01-10 12:18:43 +00:00
|
|
|
SkipNextLeftButtonReleaseEvent();
|
|
|
|
}
|
2011-07-06 16:40:54 +00:00
|
|
|
else
|
2013-11-18 19:27:27 +00:00
|
|
|
fpname.Empty();
|
2011-07-06 16:40:54 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2011-07-06 16:40:54 +00:00
|
|
|
{
|
2013-05-08 20:47:23 +00:00
|
|
|
DisplayError( aWindow, _( "No footprint found." ) );
|
2013-11-18 19:27:27 +00:00
|
|
|
fpname.Empty();
|
2011-07-06 16:40:54 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
if( fpname != wxEmptyString )
|
|
|
|
oldName = fpname;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
wxLogDebug( wxT( "Footprint '%s' was selected." ), GetChars( fpname ) );
|
2013-05-08 20:47:23 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
return fpname;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
static void DisplayCmpDoc( wxString& aName, void* aData )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-12-12 16:01:03 +00:00
|
|
|
FOOTPRINT_INFO* module_info = MList.GetModuleInfo( aName );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-22 20:59:16 +00:00
|
|
|
if( !module_info )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-12-09 18:09:58 +00:00
|
|
|
aName.Empty();
|
2009-04-05 20:49:15 +00:00
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 16:01:03 +00:00
|
|
|
aName = _( "Description: " ) + module_info->GetDoc();
|
|
|
|
aName += _( "\nKey words: " ) + module_info->GetKeywords();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprint( BOARD* aPcb )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-11-18 19:27:27 +00:00
|
|
|
static wxString oldName; // Save name of last module selected.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
wxString fpname;
|
|
|
|
wxString msg;
|
|
|
|
wxArrayString listnames;
|
|
|
|
MODULE* module = aPcb->m_Modules;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
for( ; module; module = module->Next() )
|
2013-03-13 18:53:58 +00:00
|
|
|
listnames.Add( module->GetReference() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2015-11-17 16:18:00 +00:00
|
|
|
msg.Printf( _( "Footprints [%u items]" ), (unsigned) listnames.GetCount() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-03-19 01:25:19 +00:00
|
|
|
wxArrayString headers;
|
2013-11-18 19:27:27 +00:00
|
|
|
|
2015-11-17 16:18:00 +00:00
|
|
|
headers.Add( _( "Footprint" ) );
|
2013-11-18 19:27:27 +00:00
|
|
|
|
2013-03-19 01:25:19 +00:00
|
|
|
std::vector<wxArrayString> itemsToDisplay;
|
2013-04-10 07:23:20 +00:00
|
|
|
|
2013-03-19 01:25:19 +00:00
|
|
|
// Conversion from wxArrayString to vector of ArrayString
|
|
|
|
for( unsigned i = 0; i < listnames.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
wxArrayString item;
|
2013-11-18 19:27:27 +00:00
|
|
|
|
2013-03-19 01:25:19 +00:00
|
|
|
item.Add( listnames[i] );
|
|
|
|
itemsToDisplay.push_back( item );
|
2013-04-10 07:23:20 +00:00
|
|
|
}
|
2013-05-08 20:47:23 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
EDA_LIST_DIALOG dlg( this, msg, headers, itemsToDisplay, wxEmptyString, NULL, NULL, SORT_LIST );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-19 18:50:23 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
2013-11-18 19:27:27 +00:00
|
|
|
fpname = dlg.GetTextSelection();
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
oldName = fpname;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
module = aPcb->m_Modules;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-11-18 19:27:27 +00:00
|
|
|
for( ; module; module = module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-11-18 19:27:27 +00:00
|
|
|
if( fpname == module->GetReference() )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
return module;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2012-10-07 15:37:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs( wxCommandEvent& aEvent )
|
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
wxString curLibPath = getLibPath();
|
|
|
|
wxString dstLibPath = CreateNewLibrary();
|
2012-10-07 15:37:25 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
if( !dstLibPath )
|
|
|
|
return; // user aborted in CreateNewLibrary()
|
2012-10-07 15:37:25 +00:00
|
|
|
|
2014-12-11 12:00:59 +00:00
|
|
|
wxBusyCursor dummy;
|
|
|
|
wxString msg;
|
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
IO_MGR::PCB_FILE_T dstType = IO_MGR::GuessPluginTypeFromLibPath( dstLibPath );
|
|
|
|
IO_MGR::PCB_FILE_T curType = IO_MGR::GuessPluginTypeFromLibPath( curLibPath );
|
2012-10-07 15:37:25 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
PLUGIN::RELEASER cur( IO_MGR::PluginFind( curType ) );
|
|
|
|
PLUGIN::RELEASER dst( IO_MGR::PluginFind( dstType ) );
|
2012-10-07 15:37:25 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
wxArrayString mods = cur->FootprintEnumerate( curLibPath );
|
2014-12-11 12:00:59 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
for( unsigned i = 0; i < mods.size(); ++i )
|
2012-10-07 15:37:25 +00:00
|
|
|
{
|
2016-05-29 15:02:34 +00:00
|
|
|
std::unique_ptr<MODULE> m( cur->FootprintLoad( curLibPath, mods[i] ) );
|
2012-11-19 16:19:38 +00:00
|
|
|
dst->FootprintSave( dstLibPath, m.get() );
|
2012-10-07 15:37:25 +00:00
|
|
|
|
2014-12-11 12:00:59 +00:00
|
|
|
msg = wxString::Format( _( "Footprint '%s' saved" ),
|
|
|
|
GetChars( mods[i] ) );
|
|
|
|
SetStatusText( msg );
|
|
|
|
|
2016-05-29 15:02:34 +00:00
|
|
|
// m is deleted here by unique_ptr.
|
2012-10-07 15:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2012-10-07 15:37:25 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, ioe.errorText );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-11 12:00:59 +00:00
|
|
|
msg = wxString::Format(
|
2013-11-02 00:24:38 +00:00
|
|
|
_( "Footprint library '%s' saved as '%s'." ),
|
2012-11-19 16:19:38 +00:00
|
|
|
GetChars( curLibPath ), GetChars( dstLibPath ) );
|
2012-10-07 15:37:25 +00:00
|
|
|
|
|
|
|
DisplayInfoMessage( this, msg );
|
2014-12-11 12:00:59 +00:00
|
|
|
|
|
|
|
SetStatusText( wxEmptyString );
|
2012-10-07 15:37:25 +00:00
|
|
|
}
|