2012-02-09 20:33:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-22 13:42:24 +00:00
|
|
|
* Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2016-10-28 13:11:23 +00:00
|
|
|
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
2019-04-15 21:09:14 +00:00
|
|
|
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-02-09 20:33:38 +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
|
|
|
|
*/
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <board_commit.h>
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <confirm.h>
|
2013-09-26 17:22:35 +00:00
|
|
|
#include <dialog_helpers.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <eda_pattern_match.h>
|
|
|
|
#include <fctsys.h>
|
|
|
|
#include <footprint_info.h>
|
|
|
|
#include <footprint_viewer_frame.h>
|
2013-05-20 14:49:20 +00:00
|
|
|
#include <fp_lib_table.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <kiway.h>
|
|
|
|
#include <msgpanel.h>
|
|
|
|
#include <pcb_draw_panel_gal.h>
|
2018-09-11 15:28:57 +00:00
|
|
|
#include <pcb_painter.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
#include <pcbnew_id.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2019-08-27 13:07:35 +00:00
|
|
|
#include <tool/common_control.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/common_tools.h>
|
2020-08-13 23:09:17 +00:00
|
|
|
#include <tool/selection.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2020-05-23 17:14:49 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
|
|
|
#include <tools/pcb_viewer_tools.h>
|
2019-08-27 13:07:35 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2020-08-13 23:09:17 +00:00
|
|
|
#include <tools/pcb_editor_conditions.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tools/pcbnew_control.h>
|
|
|
|
#include <tools/pcbnew_picker_tool.h>
|
|
|
|
#include <tools/selection_tool.h>
|
|
|
|
#include <wildcards_and_files_ext.h>
|
2019-08-14 19:44:57 +00:00
|
|
|
#include <wx/tokenzr.h>
|
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
using namespace std::placeholders;
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
#define NEXT_PART 1
|
|
|
|
#define NEW_PART 0
|
|
|
|
#define PREVIOUS_PART -1
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
|
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
|
|
|
// Window events
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_SIZE( FOOTPRINT_VIEWER_FRAME::OnSize )
|
|
|
|
EVT_ACTIVATE( FOOTPRINT_VIEWER_FRAME::OnActivate )
|
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad )
|
|
|
|
EVT_MENU( wxID_CLOSE, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
|
2014-10-15 11:40: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
|
|
|
// Toolbar events
|
2018-08-01 10:00:10 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_NEXT, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
|
|
|
EVT_TOOL( ID_MODVIEW_PREVIOUS, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
2019-04-15 21:09:14 +00:00
|
|
|
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB )
|
2019-01-28 14:15:32 +00:00
|
|
|
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectZoom )
|
|
|
|
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectGrid )
|
2018-09-11 15:28:57 +00:00
|
|
|
|
2019-05-12 15:07:23 +00:00
|
|
|
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
EVT_TEXT( ID_MODVIEW_LIB_FILTER, FOOTPRINT_VIEWER_FRAME::OnLibFilter )
|
|
|
|
EVT_TEXT( ID_MODVIEW_FOOTPRINT_FILTER, FOOTPRINT_VIEWER_FRAME::OnFPFilter )
|
|
|
|
|
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
|
|
|
// listbox events
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList )
|
|
|
|
EVT_LISTBOX( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList )
|
2013-02-14 21:20:56 +00:00
|
|
|
EVT_LISTBOX_DCLICK( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2020-06-18 13:49:32 +00:00
|
|
|
/*
|
|
|
|
* Note: FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
|
2015-06-22 17:21:34 +00:00
|
|
|
*/
|
2018-09-11 15:28:57 +00:00
|
|
|
#define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
|
|
|
|
#define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
|
|
|
|
#define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
|
2018-08-03 19:41:57 +00:00
|
|
|
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
2018-09-11 15:28:57 +00:00
|
|
|
FRAME_T aFrameType ) :
|
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
|
|
|
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
|
* 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
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2019-09-05 22:00:47 +00:00
|
|
|
aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
|
|
|
|
: NONMODAL_STYLE,
|
|
|
|
aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? FOOTPRINT_VIEWER_FRAME_NAME_MODAL
|
|
|
|
: FOOTPRINT_VIEWER_FRAME_NAME )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2019-09-05 22:00:47 +00:00
|
|
|
wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
|
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
|
|
|
|
2019-09-05 22:00:47 +00:00
|
|
|
if( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL )
|
2014-05-04 18:22:27 +00:00
|
|
|
SetModal( true );
|
|
|
|
|
2019-11-09 18:41:02 +00:00
|
|
|
m_AboutTitle = "Footprint Library Viewer";
|
|
|
|
|
2020-05-23 17:14:49 +00:00
|
|
|
// Force the items to always snap
|
|
|
|
m_magneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
|
|
|
|
m_magneticItems.tracks = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
|
|
|
|
m_magneticItems.graphics = true;
|
|
|
|
|
2015-12-22 11:58:26 +00:00
|
|
|
// Force the frame name used in config. the footprint viewer frame has a name
|
|
|
|
// depending on aFrameType (needed to identify the frame by wxWidgets),
|
|
|
|
// but only one configuration is preferable.
|
2019-06-08 22:14:57 +00:00
|
|
|
m_configName = FOOTPRINT_VIEWER_FRAME_NAME;
|
2015-12-22 11:58:26 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
// Give an icon
|
|
|
|
wxIcon icon;
|
2012-02-13 14:27:34 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
SetIcon( icon );
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
wxPanel* libPanel = new wxPanel( this );
|
|
|
|
wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
m_libFilter = new wxTextCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
|
|
|
m_libFilter->SetHint( _( "Filter" ) );
|
|
|
|
libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
m_libList = new wxListBox( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
|
2018-08-11 16:04:46 +00:00
|
|
|
0, NULL, wxLB_HSCROLL | wxNO_BORDER );
|
2019-08-14 19:44:57 +00:00
|
|
|
libSizer->Add( m_libList, 1, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
libPanel->SetSizer( libSizer );
|
|
|
|
libPanel->Fit();
|
|
|
|
|
|
|
|
wxPanel* fpPanel = new wxPanel( this );
|
|
|
|
wxSizer* fpSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
m_fpFilter = new wxTextCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
|
|
|
m_fpFilter->SetHint( _( "Filter" ) );
|
2019-11-09 18:41:02 +00:00
|
|
|
m_fpFilter->SetToolTip(
|
|
|
|
_( "Filter on footprint name, keywords, description and pad count.\n"
|
|
|
|
"Search terms are separated by spaces. All search terms must match.\n"
|
|
|
|
"A term which is a number will also match against the pad count." ) );
|
2019-08-14 19:44:57 +00:00
|
|
|
fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
|
|
|
|
0, NULL, wxLB_HSCROLL | wxNO_BORDER );
|
|
|
|
fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
fpPanel->SetSizer( fpSizer );
|
|
|
|
fpPanel->Fit();
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2020-08-19 19:11:10 +00:00
|
|
|
// Create GAL canvas
|
|
|
|
m_canvasType = LoadCanvasTypeSetting();
|
|
|
|
auto drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
|
|
|
|
GetGalDisplayOptions(), m_canvasType );
|
|
|
|
SetCanvas( drawPanel );
|
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
SetBoard( new BOARD() );
|
2015-01-10 10:27:49 +00:00
|
|
|
// In viewer, the default net clearance is not known (it depends on the actual board).
|
|
|
|
// So we do not show the default clearance, by setting it to 0
|
|
|
|
// The footprint or pad specific clearance will be shown
|
2020-05-18 00:20:16 +00:00
|
|
|
GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
|
2014-07-09 13:10:32 +00:00
|
|
|
|
2018-08-28 17:00:31 +00:00
|
|
|
// Don't show the default board solder mask clearance in the footprint viewer. Only the
|
|
|
|
// footprint or pad clearance setting should be shown if it is not 0.
|
|
|
|
GetBoard()->GetDesignSettings().m_SolderMaskMargin = 0;
|
|
|
|
|
2012-02-26 18:49:00 +00:00
|
|
|
// Ensure all layers and items are visible:
|
|
|
|
GetBoard()->SetVisibleAlls();
|
2013-09-24 18:45:57 +00:00
|
|
|
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
GetScreen()->m_Center = true; // Center coordinate origins on screen.
|
* 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
|
|
|
LoadSettings( config() );
|
2018-02-19 00:04:03 +00:00
|
|
|
GetGalDisplayOptions().m_axesEnabled = true;
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
drawPanel->GetViewControls(), config(), this );
|
2017-02-21 12:42:08 +00:00
|
|
|
m_actions = new PCB_ACTIONS();
|
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
2014-07-09 09:22:43 +00:00
|
|
|
drawPanel->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
|
|
|
|
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
2019-05-14 19:21:10 +00:00
|
|
|
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
|
2019-08-27 13:07:35 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2019-10-26 15:25:19 +00:00
|
|
|
m_toolManager->RegisterTool( new PCBNEW_PICKER_TOOL ); // for setting grid origin
|
2020-05-23 17:14:49 +00:00
|
|
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
|
|
|
|
|
|
|
|
m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
|
|
|
|
|
2017-01-30 12:21:22 +00:00
|
|
|
m_toolManager->InitTools();
|
2018-06-11 10:37:05 +00:00
|
|
|
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
setupUIConditions();
|
2019-05-14 19:21:10 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
2020-05-23 17:14:49 +00:00
|
|
|
ReCreateOptToolbar();
|
2019-05-14 19:21:10 +00:00
|
|
|
|
|
|
|
ReCreateLibraryList();
|
|
|
|
UpdateTitle();
|
|
|
|
|
2013-09-24 18:45:57 +00:00
|
|
|
// If a footprint was previously loaded, reload it
|
2014-06-16 19:00:26 +00:00
|
|
|
if( getCurNickname().size() && getCurFootprintName().size() )
|
2013-05-20 14:49:20 +00:00
|
|
|
{
|
2016-11-20 23:35:08 +00:00
|
|
|
LIB_ID id;
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2017-07-24 19:02:59 +00:00
|
|
|
id.SetLibNickname( getCurNickname() );
|
|
|
|
id.SetLibItemName( getCurFootprintName() );
|
2013-05-20 14:49:20 +00:00
|
|
|
GetBoard()->Add( loadFootprint( id ) );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-07-09 14:57:01 +00:00
|
|
|
drawPanel->DisplayBoard( m_Pcb );
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
// Horizontal items; layers 4 - 6
|
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
2020-05-23 17:14:49 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
|
2014-01-29 17:01:42 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
// Vertical items; layers 1 - 3
|
2019-08-14 19:44:57 +00:00
|
|
|
m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
|
2018-08-11 16:04:46 +00:00
|
|
|
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
|
2019-08-14 19:44:57 +00:00
|
|
|
m_auimgr.AddPane( fpPanel, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer( 1)
|
2018-08-11 16:04:46 +00:00
|
|
|
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
// after changing something to the aui manager call Update() to reflect the changes
|
2014-01-13 15:09:52 +00:00
|
|
|
m_auimgr.Update();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-08-30 14:03:39 +00:00
|
|
|
// The canvas should not steal the focus from the list boxes
|
|
|
|
GetCanvas()->SetCanFocus( false );
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
2019-05-30 12:25:08 +00:00
|
|
|
ActivateGalCanvas();
|
2018-09-11 15:28:57 +00:00
|
|
|
|
|
|
|
// Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
|
2020-05-23 17:14:49 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = GetPcbNewSettings();
|
|
|
|
wxASSERT( cfg );
|
|
|
|
GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
|
2018-09-11 15:28:57 +00:00
|
|
|
|
2018-06-12 12:38:31 +00:00
|
|
|
updateView();
|
2019-06-25 04:44:34 +00:00
|
|
|
InitExitKey();
|
2017-04-13 16:28:16 +00:00
|
|
|
|
2015-06-22 17:21:34 +00:00
|
|
|
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
|
2015-07-15 08:18:48 +00:00
|
|
|
{
|
2019-11-08 16:41:39 +00:00
|
|
|
ReCreateFootprintList();
|
2015-07-15 08:18:48 +00:00
|
|
|
Raise(); // On some window managers, this is needed
|
2015-06-22 17:21:34 +00:00
|
|
|
Show( true );
|
2015-07-15 08:18:48 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
|
|
|
|
{
|
2020-02-03 14:00:48 +00:00
|
|
|
// Shutdown all running tools
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ShutdownAllTools();
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->StopDrawing();
|
|
|
|
GetCanvas()->GetView()->Clear();
|
2018-09-11 15:28:57 +00:00
|
|
|
// Be sure any event cannot be fired after frame deletion:
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetEvtHandlerEnabled( false );
|
2012-09-12 09:53:11 +00:00
|
|
|
}
|
|
|
|
|
2013-09-24 18:45:57 +00:00
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
SELECTION& FOOTPRINT_VIEWER_FRAME::GetCurrentSelection()
|
|
|
|
{
|
|
|
|
return m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::setupUIConditions()
|
|
|
|
{
|
|
|
|
PCB_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
PCB_EDITOR_CONDITIONS cond( this );
|
|
|
|
|
|
|
|
wxASSERT( mgr );
|
|
|
|
|
|
|
|
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
|
|
|
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
|
|
|
|
|
|
|
|
|
|
|
|
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::measureTool, CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::textOutlines, CHECK( !cond.TextFillDisplay() ) );
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::graphicsOutlines, CHECK( !cond.GraphicsFillDisplay() ) );
|
|
|
|
|
|
|
|
auto autoZoomCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return GetAutoZoom();
|
|
|
|
};
|
|
|
|
|
|
|
|
mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) );
|
|
|
|
|
|
|
|
#undef ENABLE
|
|
|
|
#undef CHECK
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::doCloseWindow()
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2016-03-21 16:36:06 +00:00
|
|
|
// A workaround to avoid flicker, in modal mode when modview frame is destroyed,
|
|
|
|
// when the aui toolbar is not docked (i.e. shown in a miniframe)
|
2019-11-09 18:41:02 +00:00
|
|
|
// (useful on windows only)
|
2016-03-21 16:36:06 +00:00
|
|
|
m_mainToolBar->SetFocus();
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->StopDrawing();
|
2014-07-09 09:22:43 +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
|
|
|
if( IsModal() )
|
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
|
|
|
// Only dismiss a modal frame once, so that the return values set by
|
|
|
|
// the prior DismissModal() are not bashed for ShowModal().
|
|
|
|
if( !IsDismissed() )
|
|
|
|
DismissModal( false );
|
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
// window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
|
|
|
|
{
|
|
|
|
if( m_auimgr.GetManagedWindow() )
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
SizeEv.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
m_libList->Clear();
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
|
|
|
|
std::set<wxString> excludes;
|
|
|
|
|
|
|
|
if( !m_libFilter->GetValue().IsEmpty() )
|
|
|
|
{
|
|
|
|
wxStringTokenizer tokenizer( m_libFilter->GetValue() );
|
|
|
|
|
|
|
|
while( tokenizer.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
const wxString term = tokenizer.GetNextToken().Lower();
|
|
|
|
EDA_COMBINED_MATCHER matcher( term );
|
|
|
|
int matches, position;
|
|
|
|
|
|
|
|
for( const wxString& nickname : nicknames )
|
|
|
|
{
|
|
|
|
if( !matcher.Find( nickname.Lower(), matches, position ) )
|
|
|
|
excludes.insert( nickname );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
for( const wxString& nickname : nicknames )
|
|
|
|
{
|
|
|
|
if( !excludes.count( nickname ) )
|
|
|
|
m_libList->Append( nickname );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
// Search for a previous selection:
|
2019-06-24 12:00:21 +00:00
|
|
|
int index = m_libList->FindString( getCurNickname(), true );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-08-17 11:22:18 +00:00
|
|
|
if( index == wxNOT_FOUND )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2019-08-17 11:22:18 +00:00
|
|
|
if( m_libList->GetCount() > 0 )
|
|
|
|
{
|
|
|
|
m_libList->SetSelection( 0 );
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
ClickOnLibList( dummy );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setCurNickname( wxEmptyString );
|
|
|
|
setCurFootprintName( wxEmptyString );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-17 11:22:18 +00:00
|
|
|
m_libList->SetSelection( index, true );
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
ClickOnLibList( dummy );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
|
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
m_fpList->Clear();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
if( !getCurNickname() )
|
|
|
|
setCurFootprintName( wxEmptyString );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2018-03-25 12:48:13 +00:00
|
|
|
auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
wxString nickname = getCurNickname();
|
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? NULL : &nickname );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
if( fp_info_list->GetErrorCount() )
|
2013-09-22 00:28:02 +00:00
|
|
|
{
|
2017-03-23 00:59:25 +00:00
|
|
|
fp_info_list->DisplayErrors( this );
|
2017-06-11 20:20:44 +00:00
|
|
|
|
|
|
|
// For footprint libraries that support one footprint per file, there may have been
|
|
|
|
// valid footprints read so show the footprints that loaded properly.
|
2019-08-14 19:44:57 +00:00
|
|
|
if( fp_info_list->GetList().empty() )
|
2017-06-11 20:20:44 +00:00
|
|
|
return;
|
2013-09-22 00:28:02 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
std::set<wxString> excludes;
|
|
|
|
|
|
|
|
if( !m_fpFilter->GetValue().IsEmpty() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
|
|
|
|
|
|
|
|
while( tokenizer.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
const wxString term = tokenizer.GetNextToken().Lower();
|
|
|
|
EDA_COMBINED_MATCHER matcher( term );
|
|
|
|
int matches, position;
|
|
|
|
|
2020-05-08 07:39:47 +00:00
|
|
|
for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
|
2019-08-14 19:44:57 +00:00
|
|
|
{
|
2019-08-21 13:06:41 +00:00
|
|
|
wxString search = footprint->GetFootprintName() + " " + footprint->GetSearchText();
|
2019-08-14 19:44:57 +00:00
|
|
|
bool matched = matcher.Find( search.Lower(), matches, position );
|
|
|
|
|
|
|
|
if( !matched && term.IsNumber() )
|
2019-08-18 07:13:55 +00:00
|
|
|
matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
|
2019-08-14 19:44:57 +00:00
|
|
|
|
|
|
|
if( !matched )
|
|
|
|
excludes.insert( footprint->GetFootprintName() );
|
|
|
|
}
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2013-09-22 00:28:02 +00:00
|
|
|
|
2020-05-08 07:39:47 +00:00
|
|
|
for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
|
2019-08-14 19:44:57 +00:00
|
|
|
{
|
|
|
|
if( !excludes.count( footprint->GetFootprintName() ) )
|
|
|
|
m_fpList->Append( footprint->GetFootprintName() );
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = m_fpList->FindString( getCurFootprintName(), true );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( index == wxNOT_FOUND )
|
2019-08-17 11:22:18 +00:00
|
|
|
{
|
|
|
|
if( m_fpList->GetCount() > 0 )
|
|
|
|
{
|
|
|
|
m_fpList->SetSelection( 0 );
|
2019-08-18 21:49:20 +00:00
|
|
|
m_fpList->EnsureVisible( 0 );
|
|
|
|
|
2019-08-17 11:22:18 +00:00
|
|
|
wxCommandEvent dummy;
|
|
|
|
ClickOnFootprintList( dummy );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
setCurFootprintName( wxEmptyString );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
else
|
2018-10-02 20:53:00 +00:00
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
m_fpList->SetSelection( index, true );
|
|
|
|
m_fpList->EnsureVisible( index );
|
2018-10-02 20:53:00 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
ReCreateLibraryList();
|
|
|
|
|
|
|
|
// Required to avoid interaction with SetHint()
|
|
|
|
// See documentation for wxTextEntry::SetHint
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
ReCreateFootprintList();
|
|
|
|
|
|
|
|
// Required to avoid interaction with SetHint()
|
|
|
|
// See documentation for wxTextEntry::SetHint
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-17 11:22:18 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetKeyCode() == WXK_UP )
|
|
|
|
{
|
2019-08-27 14:42:43 +00:00
|
|
|
wxWindow* focused = FindFocus();
|
|
|
|
|
|
|
|
if( m_libFilter->HasFocus() || m_libList->HasFocus() )
|
2019-08-17 11:22:18 +00:00
|
|
|
selectPrev( m_libList );
|
|
|
|
else
|
|
|
|
selectPrev( m_fpList );
|
2019-08-27 14:42:43 +00:00
|
|
|
|
|
|
|
// Need to reset the focus after selection due to GTK mouse-refresh
|
|
|
|
// that captures the mouse into the canvas to update scrollbars
|
|
|
|
if( focused )
|
|
|
|
focused->SetFocus();
|
2019-08-17 11:22:18 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_DOWN )
|
|
|
|
{
|
2019-08-27 14:42:43 +00:00
|
|
|
wxWindow* focused = FindFocus();
|
|
|
|
|
|
|
|
if( m_libFilter->HasFocus() || m_libList->HasFocus() )
|
2019-08-17 11:22:18 +00:00
|
|
|
selectNext( m_libList );
|
|
|
|
else
|
|
|
|
selectNext( m_fpList );
|
2019-08-27 14:42:43 +00:00
|
|
|
|
|
|
|
// Need to reset the focus after selection due to GTK mouse-refresh
|
|
|
|
// that captures the mouse into the canvas to update scrollbars
|
|
|
|
if( focused )
|
|
|
|
focused->SetFocus();
|
2019-08-17 11:22:18 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
|
|
|
|
{
|
2019-08-27 14:42:43 +00:00
|
|
|
if( !aEvent.ShiftDown() )
|
|
|
|
m_fpFilter->SetFocus();
|
|
|
|
else
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
|
|
|
|
{
|
|
|
|
if( aEvent.ShiftDown() )
|
|
|
|
m_libFilter->SetFocus();
|
|
|
|
else
|
|
|
|
aEvent.Skip();
|
2019-08-17 11:22:18 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
AddFootprintToPCB( dummy );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::selectPrev( wxListBox* aListBox )
|
|
|
|
{
|
|
|
|
int prev = aListBox->GetSelection() - 1;
|
|
|
|
|
|
|
|
if( prev >= 0 )
|
|
|
|
{
|
|
|
|
aListBox->SetSelection( prev );
|
2019-08-18 21:49:20 +00:00
|
|
|
aListBox->EnsureVisible( prev );
|
2019-08-17 11:22:18 +00:00
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
|
|
|
|
if( aListBox == m_libList )
|
|
|
|
ClickOnLibList( dummy );
|
|
|
|
else
|
|
|
|
ClickOnFootprintList( dummy );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::selectNext( wxListBox* aListBox )
|
|
|
|
{
|
|
|
|
int next = aListBox->GetSelection() + 1;
|
|
|
|
|
2019-08-18 07:13:55 +00:00
|
|
|
if( next < (int)aListBox->GetCount() )
|
2019-08-17 11:22:18 +00:00
|
|
|
{
|
|
|
|
aListBox->SetSelection( next );
|
2019-08-18 21:49:20 +00:00
|
|
|
aListBox->EnsureVisible( next );
|
2019-08-17 11:22:18 +00:00
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
|
|
|
|
if( aListBox == m_libList )
|
|
|
|
ClickOnLibList( dummy );
|
|
|
|
else
|
|
|
|
ClickOnFootprintList( dummy );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
int ii = m_libList->GetSelection();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
wxString name = m_libList->GetString( ii );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
if( getCurNickname() == name )
|
2012-02-09 20:33:38 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
setCurNickname( name );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
ReCreateFootprintList();
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2020-05-03 18:11:33 +00:00
|
|
|
|
|
|
|
// The m_libList has now the focus, in order to be able to use arrow keys
|
|
|
|
// to navigate inside the list.
|
|
|
|
// the gal canvas must not steal the focus to allow navigation
|
|
|
|
GetCanvas()->SetStealsFocus( false );
|
|
|
|
m_libList->SetFocus();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
if( m_fpList->GetCount() == 0 )
|
2013-09-22 17:20:46 +00:00
|
|
|
return;
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
int ii = m_fpList->GetSelection();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
wxString name = m_fpList->GetString( ii );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
if( getCurFootprintName().CmpNoCase( name ) != 0 )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2014-06-16 19:00:26 +00:00
|
|
|
setCurFootprintName( name );
|
|
|
|
|
2018-06-14 08:54:49 +00:00
|
|
|
// Delete the current footprint (MUST reset tools first)
|
|
|
|
GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2019-05-31 00:15:57 +00:00
|
|
|
|
|
|
|
GetBoard()->DeleteAllModules();
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2016-11-20 23:35:08 +00:00
|
|
|
LIB_ID id;
|
2017-07-24 19:02:59 +00:00
|
|
|
id.SetLibNickname( getCurNickname() );
|
|
|
|
id.SetLibItemName( getCurFootprintName() );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
GetBoard()->Add( loadFootprint( id ) );
|
|
|
|
}
|
2014-04-04 14:57:26 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-05-20 14:49:20 +00:00
|
|
|
{
|
2019-08-17 11:22:18 +00:00
|
|
|
wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
|
|
|
|
"\n\n%s" ),
|
|
|
|
getCurFootprintName(),
|
|
|
|
getCurNickname(),
|
|
|
|
ioe.Problem() );
|
2013-05-20 14:49:20 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
updateView();
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2019-06-02 14:34:19 +00:00
|
|
|
Update3DView( true );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2020-05-03 18:11:33 +00:00
|
|
|
|
|
|
|
// The m_fpList has now the focus, in order to be able to use arrow keys
|
|
|
|
// to navigate inside the list.
|
|
|
|
// the gal canvas must not steal the focus to allow navigation
|
|
|
|
GetCanvas()->SetStealsFocus( false );
|
|
|
|
m_fpList->SetFocus();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& aEvent )
|
2019-04-15 21:09:14 +00:00
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
AddFootprintToPCB( aEvent );
|
2019-04-15 21:09:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
|
2013-02-14 21:20:56 +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
|
|
|
if( IsModal() )
|
2013-02-14 21:20:56 +00:00
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
if( m_fpList->GetSelection() >= 0 )
|
2019-04-15 21:09:14 +00:00
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
LIB_ID fpid( getCurNickname(), m_fpList->GetStringSelection() );
|
2019-04-15 21:09:14 +00:00
|
|
|
DismissModal( true, fpid.Format() );
|
|
|
|
}
|
|
|
|
else
|
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
|
|
|
{
|
2019-04-15 21:09:14 +00:00
|
|
|
DismissModal( false );
|
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
|
|
|
}
|
2013-02-14 21:20:56 +00:00
|
|
|
}
|
2019-05-31 00:15:57 +00:00
|
|
|
else if( GetBoard()->GetFirstModule() )
|
2019-04-15 21:09:14 +00:00
|
|
|
{
|
2019-09-05 22:00:47 +00:00
|
|
|
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
if( pcbframe == NULL ) // happens when the board editor is not active (or closed)
|
|
|
|
{
|
|
|
|
DisplayErrorMessage( this, _( "No board currently open." ) );
|
|
|
|
return;
|
|
|
|
}
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
BOARD_COMMIT commit( pcbframe );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
// Create the "new" module
|
2020-02-20 12:11:04 +00:00
|
|
|
MODULE* newmodule = (MODULE*) GetBoard()->GetFirstModule()->Duplicate();
|
2019-04-15 21:09:14 +00:00
|
|
|
newmodule->SetParent( pcbframe->GetBoard() );
|
|
|
|
newmodule->SetLink( 0 );
|
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
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
|
2019-06-13 13:34:38 +00:00
|
|
|
VECTOR2D cursorPos = viewControls->GetCursorPosition();
|
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
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
commit.Add( newmodule );
|
2019-06-13 13:34:38 +00:00
|
|
|
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
2019-05-28 23:23:58 +00:00
|
|
|
pcbframe->PlaceModule( newmodule );
|
2019-04-15 21:09:14 +00:00
|
|
|
newmodule->SetPosition( wxPoint( 0, 0 ) );
|
2019-06-13 13:34:38 +00:00
|
|
|
viewControls->SetCrossHairCursorPosition( cursorPos, false );
|
2019-04-15 21:09:14 +00:00
|
|
|
commit.Push( wxT( "Insert module" ) );
|
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
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
pcbframe->Raise();
|
|
|
|
pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::placeModule, true, newmodule );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
newmodule->ClearFlags();
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
2020-04-04 11:41:45 +00:00
|
|
|
wxCHECK( cfg, /*void*/ );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-24 20:10:16 +00:00
|
|
|
// We don't allow people to change this right now, so make sure it's on
|
|
|
|
GetWindowSettings( cfg )->cursor.always_show_cursor = true;
|
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
PCB_BASE_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2020-09-21 12:11:05 +00:00
|
|
|
// Fetch display and grid settings from Footprint Editor
|
2020-01-13 01:44:19 +00:00
|
|
|
auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
2020-09-21 12:11:05 +00:00
|
|
|
m_DisplayOptions = fpedit->m_Display;
|
2020-01-13 01:44:19 +00:00
|
|
|
GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
|
|
|
|
}
|
2019-03-30 17:45:10 +00:00
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
|
|
|
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
2020-03-30 07:24:56 +00:00
|
|
|
wxCHECK( cfg, /*void*/ );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
// We don't want to store anything other than the window settings
|
2020-06-12 10:58:56 +00:00
|
|
|
PCB_BASE_FRAME::SaveSettings( cfg );
|
2018-09-11 15:28:57 +00:00
|
|
|
|
2020-05-23 17:14:49 +00:00
|
|
|
cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
WINDOW_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
2020-03-30 07:24:56 +00:00
|
|
|
wxCHECK_MSG( cfg, nullptr, "config not existing" );
|
2018-09-11 15:28:57 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
return &cfg->m_FootprintViewer;
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-16 17:15:43 +00:00
|
|
|
COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetColorSettings()
|
2020-05-06 01:45:48 +00:00
|
|
|
{
|
|
|
|
auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
|
|
|
|
|
|
|
if( settings )
|
|
|
|
return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
|
|
|
|
else
|
|
|
|
return Pgm().GetSettingsManager().GetColorSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-23 17:14:49 +00:00
|
|
|
bool FOOTPRINT_VIEWER_FRAME::GetAutoZoom()
|
|
|
|
{
|
|
|
|
// It is stored in pcbnew's settings
|
|
|
|
PCBNEW_SETTINGS* cfg = GetPcbNewSettings();
|
|
|
|
wxCHECK( cfg, false );
|
|
|
|
return cfg->m_FootprintViewerAutoZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::SetAutoZoom( bool aAutoZoom )
|
|
|
|
{
|
|
|
|
// It is stored in pcbnew's settings
|
|
|
|
PCBNEW_SETTINGS* cfg = GetPcbNewSettings();
|
|
|
|
wxASSERT( cfg );
|
|
|
|
cfg->m_FootprintViewerAutoZoom = aAutoZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2019-06-24 09:22:49 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2019-06-24 09:22:49 +00:00
|
|
|
|
|
|
|
if( aEnvVarsChanged )
|
|
|
|
ReCreateLibraryList();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
const wxString FOOTPRINT_VIEWER_FRAME::getCurNickname()
|
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
return Prj().GetRString( PROJECT::PCB_FOOTPRINT_VIEWER_LIB_NICKNAME );
|
2014-06-16 19:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
|
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_VIEWER_LIB_NICKNAME, aNickname );
|
2014-06-16 19:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString FOOTPRINT_VIEWER_FRAME::getCurFootprintName()
|
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
return Prj().GetRString( PROJECT::PCB_FOOTPRINT_VIEWER_FP_NAME );
|
2014-06-16 19:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
|
|
|
|
{
|
2020-06-18 13:49:32 +00:00
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_VIEWER_FP_NAME, aName );
|
2014-06-16 19:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
|
|
|
|
{
|
2019-08-27 12:51:01 +00:00
|
|
|
if( event.GetActive() )
|
2013-09-24 18:45:57 +00:00
|
|
|
{
|
2019-08-27 12:51:01 +00:00
|
|
|
// Ensure we have the right library list:
|
|
|
|
std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
|
|
|
|
bool stale = false;
|
2013-09-24 18:45:57 +00:00
|
|
|
|
2019-08-27 12:51:01 +00:00
|
|
|
if( libNicknames.size() != m_libList->GetCount() )
|
|
|
|
stale = true;
|
|
|
|
else
|
2013-09-24 18:45:57 +00:00
|
|
|
{
|
2019-08-27 12:51:01 +00:00
|
|
|
for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
|
|
|
|
{
|
|
|
|
if( libNicknames[ii] != m_libList->GetString( ii ) )
|
|
|
|
{
|
|
|
|
stale = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-09-24 18:45:57 +00:00
|
|
|
}
|
|
|
|
|
2019-08-27 12:51:01 +00:00
|
|
|
if( stale )
|
|
|
|
{
|
|
|
|
ReCreateLibraryList();
|
|
|
|
UpdateTitle();
|
|
|
|
}
|
2013-09-24 18:45:57 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2019-08-27 12:51:01 +00:00
|
|
|
event.Skip(); // required under wxMAC
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-12 15:07:23 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2019-05-31 00:15:57 +00:00
|
|
|
aEvent.Enable( GetBoard()->GetFirstModule() != nullptr );
|
2019-05-12 15:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 16:58:23 +00:00
|
|
|
bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
|
2018-03-21 21:13:10 +00:00
|
|
|
{
|
2018-03-22 10:37:54 +00:00
|
|
|
if( aFootprint && !aFootprint->IsEmpty() )
|
2018-03-21 21:13:10 +00:00
|
|
|
{
|
2018-08-03 16:58:23 +00:00
|
|
|
wxString msg;
|
|
|
|
LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
2018-07-26 14:38:30 +00:00
|
|
|
LIB_ID fpid;
|
|
|
|
|
|
|
|
fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
|
|
|
|
|
|
|
|
if( fpid.IsValid() )
|
2018-03-21 21:13:10 +00:00
|
|
|
{
|
2018-08-03 16:58:23 +00:00
|
|
|
wxString nickname = fpid.GetLibNickname();
|
|
|
|
|
|
|
|
if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
|
|
|
|
{
|
|
|
|
msg.sprintf( _( "The current configuration does not include a library with the\n"
|
|
|
|
"nickname \"%s\". Use Manage Footprint Libraries\n"
|
|
|
|
"to edit the configuration." ), nickname );
|
|
|
|
DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
|
|
|
|
}
|
|
|
|
else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
|
|
|
|
{
|
|
|
|
msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
|
|
|
|
"in the current configuration. Use Manage Footprint Libraries to\n"
|
|
|
|
"edit the configuration." ), nickname );
|
|
|
|
DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-08 16:41:39 +00:00
|
|
|
// Update last selection:
|
2018-08-03 16:58:23 +00:00
|
|
|
setCurNickname( nickname );
|
|
|
|
setCurFootprintName( fpid.GetLibItemName() );
|
2019-06-26 23:40:08 +00:00
|
|
|
m_libList->SetStringSelection( nickname );
|
2018-08-03 16:58:23 +00:00
|
|
|
}
|
2018-03-21 21:13:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-08 16:41:39 +00:00
|
|
|
// Rebuild the fp list from the last selected library,
|
|
|
|
// and show the last selected footprint
|
|
|
|
ReCreateFootprintList();
|
|
|
|
SelectAndViewFootprint( NEW_PART );
|
|
|
|
|
2019-08-17 11:22:18 +00:00
|
|
|
bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
|
|
|
|
|
|
|
|
m_libFilter->SetFocus();
|
|
|
|
return retval;
|
2018-03-21 21:13:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-02 14:34:19 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
|
2012-02-10 08:49:43 +00:00
|
|
|
{
|
2018-03-12 19:16:09 +00:00
|
|
|
wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
|
|
|
|
getCurFootprintName() );
|
2019-06-02 14:34:19 +00:00
|
|
|
PCB_BASE_FRAME::Update3DView( aForceReload, &title );
|
2012-02-10 08:49:43 +00:00
|
|
|
}
|
2013-04-11 18:29:56 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
COLOR4D FOOTPRINT_VIEWER_FRAME::GetGridColor()
|
2013-04-11 18:29:56 +00:00
|
|
|
{
|
2020-05-16 17:15:43 +00:00
|
|
|
return GetColorSettings()->GetColor( LAYER_GRID );
|
2013-04-11 18:29:56 +00:00
|
|
|
}
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
|
|
|
case ID_MODVIEW_NEXT:
|
|
|
|
SelectAndViewFootprint( NEXT_PART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODVIEW_PREVIOUS:
|
|
|
|
SelectAndViewFootprint( PREVIOUS_PART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-10-28 13:11:23 +00:00
|
|
|
wxString id = wxString::Format( "%i", event.GetId() );
|
|
|
|
wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::UpdateTitle()
|
2013-09-26 17:22:35 +00:00
|
|
|
{
|
2016-09-26 17:15:33 +00:00
|
|
|
wxString title;
|
|
|
|
wxString path;
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2020-04-13 20:02:35 +00:00
|
|
|
title.Printf( getCurNickname().IsEmpty() ? _( "no library selected" ) : getCurNickname() );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2016-08-19 07:45:59 +00:00
|
|
|
// Now, add the full path, for info
|
2019-04-15 21:09:14 +00:00
|
|
|
if( !getCurNickname().IsEmpty() )
|
2016-08-19 07:45:59 +00:00
|
|
|
{
|
|
|
|
FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
|
2016-11-19 22:15:34 +00:00
|
|
|
const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
|
2016-08-19 07:45:59 +00:00
|
|
|
|
|
|
|
if( row )
|
2016-09-26 17:15:33 +00:00
|
|
|
title << L" \u2014 " << row->GetFullURI( true );
|
2016-08-19 07:45:59 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 20:02:35 +00:00
|
|
|
title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
|
|
|
|
|
2016-09-26 17:15:33 +00:00
|
|
|
SetTitle( title );
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
|
|
|
|
{
|
2014-06-16 19:00:26 +00:00
|
|
|
if( !getCurNickname() )
|
2013-09-26 17:22:35 +00:00
|
|
|
return;
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
int selection = m_fpList->FindString( getCurFootprintName(), true );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( aMode == NEXT_PART )
|
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
|
2013-09-26 17:22:35 +00:00
|
|
|
selection++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aMode == PREVIOUS_PART )
|
|
|
|
{
|
|
|
|
if( selection != wxNOT_FOUND && selection > 0 )
|
|
|
|
selection--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
2019-08-14 19:44:57 +00:00
|
|
|
m_fpList->SetSelection( selection );
|
|
|
|
m_fpList->EnsureVisible( selection );
|
2018-08-01 10:00:10 +00:00
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
setCurFootprintName( m_fpList->GetString((unsigned) selection ) );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
// Delete the current footprint
|
2019-05-31 00:15:57 +00:00
|
|
|
GetBoard()->DeleteAllModules();
|
2014-01-27 07:23:02 +00:00
|
|
|
|
2018-08-01 10:00:10 +00:00
|
|
|
MODULE* footprint = Prj().PcbFootprintLibs()->FootprintLoad( getCurNickname(),
|
|
|
|
getCurFootprintName() );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( footprint )
|
2019-12-28 00:55:11 +00:00
|
|
|
GetBoard()->Add( footprint, ADD_MODE::APPEND );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2019-06-02 14:34:19 +00:00
|
|
|
Update3DView( true );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
updateView();
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2018-09-11 15:28:57 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::updateView()
|
2014-07-09 09:22:42 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
GetCanvas()->UpdateColors();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->DisplayBoard( GetBoard() );
|
2018-09-11 15:28:57 +00:00
|
|
|
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
|
2020-05-23 17:14:49 +00:00
|
|
|
if( GetAutoZoom() )
|
2017-02-20 18:10:20 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
2018-09-11 15:28:57 +00:00
|
|
|
else
|
|
|
|
m_toolManager->RunAction( ACTIONS::centerContents, true );
|
|
|
|
|
|
|
|
UpdateMsgPanel();
|
2014-07-09 09:22:42 +00:00
|
|
|
}
|
2014-10-15 11:40:38 +00:00
|
|
|
|
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-15 11:40:38 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer( wxCommandEvent& event )
|
|
|
|
{
|
2019-06-25 04:44:34 +00:00
|
|
|
Close( false );
|
2014-10-15 11:40:38 +00:00
|
|
|
}
|
2020-05-22 18:27:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
BOARD_ITEM_CONTAINER* FOOTPRINT_VIEWER_FRAME::GetModel() const
|
|
|
|
{
|
|
|
|
return GetBoard()->GetFirstModule();
|
|
|
|
}
|
2020-05-23 17:14:49 +00:00
|
|
|
|