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
|
2021-07-19 23:56:05 +00:00
|
|
|
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-01-28 19:08:38 +00:00
|
|
|
* Copyright (C) 2004-2023 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
|
|
|
|
*/
|
|
|
|
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <board_commit.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <eda_pattern_match.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>
|
2022-07-24 22:40:47 +00:00
|
|
|
#include <kiway_express.h>
|
|
|
|
#include <netlist_reader/pcb_netlist.h>
|
2020-10-25 04:49:02 +00:00
|
|
|
#include <widgets/msgpanel.h>
|
2022-07-09 18:41:03 +00:00
|
|
|
#include <widgets/wx_listbox.h>
|
2023-06-17 11:44:36 +00:00
|
|
|
#include <widgets/wx_aui_utils.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#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>
|
2023-09-28 03:15:54 +00:00
|
|
|
#include <project_pcb.h>
|
2022-07-09 18:41:03 +00:00
|
|
|
#include <project/project_file.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#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-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_control.h>
|
|
|
|
#include <tools/pcb_picker_tool.h>
|
|
|
|
#include <tools/pcb_selection_tool.h>
|
2021-09-29 15:39:43 +00:00
|
|
|
#include <tools/board_editor_control.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2022-07-09 18:41:03 +00:00
|
|
|
#include <lib_tree_model_adapter.h>
|
2021-07-05 02:06:01 +00:00
|
|
|
#include <wx/srchctrl.h>
|
2019-08-14 19:44:57 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2021-09-19 16:31:10 +00:00
|
|
|
#include <wx/choice.h>
|
2023-08-23 22:05:44 +00:00
|
|
|
#include <wx/hyperlink.h>
|
|
|
|
|
|
|
|
#include "invoke_pcb_dialog.h"
|
2019-08-14 19:44:57 +00:00
|
|
|
|
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 NEW_PART 0
|
2023-05-31 20:37:58 +00:00
|
|
|
#define NEXT_PART 1
|
|
|
|
#define PREVIOUS_PART 2
|
|
|
|
#define RELOAD_PART 3
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
|
2023-01-28 19:08:38 +00:00
|
|
|
BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, PCB_BASE_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 )
|
2023-04-09 21:59:01 +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 )
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2023-09-26 17:31:45 +00:00
|
|
|
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|
|
|
PCB_BASE_FRAME( aKiway, aParent, FRAME_FOOTPRINT_VIEWER, _( "Footprint Library Browser" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
|
|
|
|
FOOTPRINT_VIEWER_FRAME_NAME ),
|
2022-07-24 22:40:47 +00:00
|
|
|
m_comp( LIB_ID(), wxEmptyString, wxEmptyString, KIID_PATH(), {} )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2023-09-27 15:36:49 +00:00
|
|
|
m_aboutTitle = _HKI( "KiCad Footprint Library Browser" );
|
2019-11-09 18:41:02 +00:00
|
|
|
|
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;
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
SetIcon( icon );
|
|
|
|
|
2022-07-11 03:00:46 +00:00
|
|
|
m_libListWidth = 200;
|
|
|
|
m_fpListWidth = 300;
|
|
|
|
|
2019-08-14 19:44:57 +00:00
|
|
|
wxPanel* libPanel = new wxPanel( this );
|
|
|
|
wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
2021-07-09 02:29:32 +00:00
|
|
|
m_libFilter = new wxSearchCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
|
2022-07-24 22:40:47 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
2021-07-09 02:29:32 +00:00
|
|
|
m_libFilter->SetDescriptiveText( _( "Filter" ) );
|
2019-08-14 19:44:57 +00:00
|
|
|
libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
m_libList = new WX_LISTBOX( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
|
|
|
|
0, nullptr, 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 );
|
|
|
|
|
2021-07-09 02:29:32 +00:00
|
|
|
m_fpFilter = new wxSearchCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
|
2022-07-24 22:40:47 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
2021-07-09 02:29:32 +00:00
|
|
|
m_fpFilter->SetDescriptiveText( _( "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
|
|
|
|
2021-08-25 03:04:20 +00:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
// wxSearchCtrl vertical height is not calculated correctly on some GTK setups
|
|
|
|
// See https://gitlab.com/kicad/code/kicad/-/issues/9019
|
|
|
|
m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
|
|
|
|
m_fpFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
|
|
|
|
#endif
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
m_fpList = new WX_LISTBOX( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
|
|
|
|
0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
|
2022-02-26 00:51:28 +00:00
|
|
|
|
2023-09-27 15:36:49 +00:00
|
|
|
m_fpList->Connect( wxEVT_LEFT_DCLICK,
|
|
|
|
wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ),
|
|
|
|
nullptr, this );
|
2019-08-14 19:44:57 +00:00
|
|
|
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
|
2020-11-16 11:16:44 +00:00
|
|
|
m_canvasType = loadCanvasTypeSetting();
|
2021-11-21 20:32:39 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
|
2020-10-14 23:37:26 +00:00
|
|
|
GetGalDisplayOptions(), m_canvasType );
|
2020-08-19 19:11:10 +00:00
|
|
|
SetCanvas( drawPanel );
|
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
SetBoard( new BOARD() );
|
2020-02-27 17:46:49 +00:00
|
|
|
|
|
|
|
// This board will only be used to hold a footprint for viewing
|
|
|
|
GetBoard()->SetBoardUse( BOARD_USE::FPHOLDER );
|
|
|
|
|
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
|
2022-08-12 23:51:19 +00:00
|
|
|
GetBoard()->GetDesignSettings().m_NetSettings->m_DefaultNetClass->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.
|
2021-08-22 22:05:47 +00:00
|
|
|
GetBoard()->GetDesignSettings().m_SolderMaskExpansion = 0;
|
2018-08-28 17:00:31 +00:00
|
|
|
|
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();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2014-07-09 09:22:43 +00:00
|
|
|
drawPanel->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_CONTROL );
|
|
|
|
m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
|
2019-05-14 19:21:10 +00:00
|
|
|
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 );
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_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();
|
|
|
|
|
2022-12-22 16:59:45 +00:00
|
|
|
// Call resolveCanvasType after loading settings:
|
|
|
|
resolveCanvasType();
|
|
|
|
|
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() );
|
2022-06-11 21:28:42 +00:00
|
|
|
|
|
|
|
FOOTPRINT* footprint = loadFootprint( id );
|
|
|
|
|
|
|
|
if( footprint )
|
2023-05-31 20:37:58 +00:00
|
|
|
{
|
2022-06-11 21:28:42 +00:00
|
|
|
GetBoard()->Add( footprint );
|
2023-05-31 20:37:58 +00:00
|
|
|
setFPWatcher( footprint );
|
|
|
|
}
|
2013-05-20 14:49:20 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2020-09-30 22:02:05 +00:00
|
|
|
drawPanel->DisplayBoard( m_pcb );
|
2014-07-09 14:57:01 +00:00
|
|
|
|
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 ) );
|
2022-07-09 18:41:03 +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
|
|
|
|
2022-07-11 03:00:46 +00:00
|
|
|
if( m_libListWidth > 0 )
|
2023-06-17 11:44:36 +00:00
|
|
|
SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "Libraries" ), m_libListWidth, -1 );
|
2022-07-11 03:00:46 +00:00
|
|
|
|
|
|
|
if( m_fpListWidth > 0 )
|
2023-06-17 11:44:36 +00:00
|
|
|
SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "Footprints" ), m_fpListWidth, -1 );
|
2022-07-11 03:00:46 +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
|
|
|
|
2022-04-18 08:32:36 +00:00
|
|
|
// Restore last zoom and auto zoom option. (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
|
|
|
|
2022-04-18 08:32:36 +00:00
|
|
|
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
|
|
|
|
|
|
|
|
if( cfg->m_FootprintViewerAutoZoomOnSelect )
|
|
|
|
toolOpt->SetState( wxAUI_BUTTON_STATE_CHECKED );
|
|
|
|
else
|
|
|
|
toolOpt->SetState( 0 );
|
|
|
|
|
2018-06-12 12:38:31 +00:00
|
|
|
updateView();
|
2020-10-05 19:26:33 +00:00
|
|
|
setupUnits( config() );
|
2017-04-13 16:28:16 +00:00
|
|
|
|
2023-09-27 15:36:49 +00:00
|
|
|
ReCreateFootprintList();
|
|
|
|
Raise(); // On some window managers, this is needed
|
|
|
|
Show( true );
|
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 );
|
2023-09-27 15:36:49 +00:00
|
|
|
m_fpList->Disconnect( wxEVT_LEFT_DCLICK,
|
|
|
|
wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ),
|
|
|
|
nullptr, this );
|
2023-05-31 20:37:58 +00:00
|
|
|
setFPWatcher( nullptr );
|
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()
|
|
|
|
{
|
2020-12-16 13:31:32 +00:00
|
|
|
return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-25 16:46:49 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::UpdateMsgPanel()
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::UpdateMsgPanel();
|
|
|
|
|
2023-09-27 15:36:49 +00:00
|
|
|
if( FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetModel() ) )
|
2023-01-25 16:46:49 +00:00
|
|
|
{
|
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
|
|
|
fp->GetMsgPanelInfo( this, msgItems );
|
|
|
|
SetMsgPanel( msgItems );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
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 )
|
|
|
|
|
2022-01-17 11:55:55 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
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 ) ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
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() ) );
|
2022-01-17 11:55:55 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
|
2020-08-13 23:09:17 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
2023-09-27 15:36:49 +00:00
|
|
|
Destroy();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-07-23 18:30:32 +00:00
|
|
|
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
2022-07-09 18:41:03 +00:00
|
|
|
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
|
2023-09-28 03:15:54 +00:00
|
|
|
std::vector<wxString> nicknames = PROJECT_PCB::PcbFootprintLibs( &Prj() )->GetLogicalLibs();
|
2023-01-27 23:38:10 +00:00
|
|
|
std::vector<wxString> pinnedMatches;
|
|
|
|
std::vector<wxString> otherMatches;
|
2022-07-09 18:41:03 +00:00
|
|
|
|
|
|
|
auto process =
|
|
|
|
[&]( const wxString& aNickname )
|
|
|
|
{
|
2022-07-23 18:30:32 +00:00
|
|
|
if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
|
|
|
|
|| alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
|
|
|
|
{
|
2023-01-27 23:38:10 +00:00
|
|
|
pinnedMatches.push_back( aNickname );
|
2022-07-23 18:30:32 +00:00
|
|
|
}
|
2022-07-09 18:41:03 +00:00
|
|
|
else
|
2022-07-23 18:30:32 +00:00
|
|
|
{
|
2023-01-27 23:38:10 +00:00
|
|
|
otherMatches.push_back( aNickname );
|
2022-07-23 18:30:32 +00:00
|
|
|
}
|
2022-07-09 18:41:03 +00:00
|
|
|
};
|
2019-08-14 19:44:57 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
if( m_libFilter->GetValue().IsEmpty() )
|
|
|
|
{
|
|
|
|
for( const wxString& nickname : nicknames )
|
|
|
|
process( nickname );
|
|
|
|
}
|
|
|
|
else
|
2019-08-14 19:44:57 +00:00
|
|
|
{
|
|
|
|
wxStringTokenizer tokenizer( m_libFilter->GetValue() );
|
|
|
|
|
|
|
|
while( tokenizer.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
const wxString term = tokenizer.GetNextToken().Lower();
|
2022-08-12 23:51:19 +00:00
|
|
|
EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
|
2019-08-14 19:44:57 +00:00
|
|
|
|
|
|
|
for( const wxString& nickname : nicknames )
|
|
|
|
{
|
2023-04-14 22:34:14 +00:00
|
|
|
if( matcher.Find( nickname.Lower() ) )
|
2022-07-09 18:41:03 +00:00
|
|
|
process( nickname );
|
2019-08-14 19:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
for( const wxString& nickname : pinnedMatches )
|
|
|
|
m_libList->Append( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + nickname );
|
|
|
|
|
|
|
|
for( const wxString& nickname : otherMatches )
|
|
|
|
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();
|
|
|
|
|
2023-09-28 03:15:54 +00:00
|
|
|
fp_info_list->ReadFootprintFiles( PROJECT_PCB::PcbFootprintLibs( &Prj() ), !nickname ? nullptr : &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() )
|
|
|
|
{
|
2023-05-01 20:26:29 +00:00
|
|
|
const wxString filterTerm = tokenizer.GetNextToken().Lower();
|
|
|
|
EDA_COMBINED_MATCHER matcher( filterTerm, CTX_LIBITEM );
|
2019-08-14 19:44:57 +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
|
|
|
{
|
2023-05-01 20:26:29 +00:00
|
|
|
std::vector<SEARCH_TERM> searchTerms = footprint->GetSearchTerms();
|
|
|
|
int matched = matcher.ScoreTerms( searchTerms );
|
2019-08-14 19:44:57 +00:00
|
|
|
|
2023-05-01 20:26:29 +00:00
|
|
|
if( filterTerm.IsNumber() && wxAtoi( filterTerm ) == (int)footprint->GetPadCount() )
|
|
|
|
matched++;
|
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
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2019-08-17 11:22:18 +00:00
|
|
|
setCurFootprintName( wxEmptyString );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2019-08-17 11:22:18 +00:00
|
|
|
}
|
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
|
|
|
if( m_libFilter->HasFocus() || m_libList->HasFocus() )
|
2019-08-17 11:22:18 +00:00
|
|
|
selectPrev( m_libList );
|
|
|
|
else
|
|
|
|
selectPrev( m_fpList );
|
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_DOWN )
|
|
|
|
{
|
2019-08-27 14:42:43 +00:00
|
|
|
if( m_libFilter->HasFocus() || m_libList->HasFocus() )
|
2019-08-17 11:22:18 +00:00
|
|
|
selectNext( m_libList );
|
|
|
|
else
|
|
|
|
selectNext( m_fpList );
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2023-03-10 21:24:21 +00:00
|
|
|
else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
|
|
|
|
&& m_fpList->GetSelection() >= 0 )
|
2019-08-17 11:22:18 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
AddFootprintToPCB( dummy );
|
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2019-08-17 11:22:18 +00:00
|
|
|
aEvent.Skip();
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2019-08-17 11:22:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::selectPrev( WX_LISTBOX* aListBox )
|
2019-08-17 11:22:18 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::selectNext( WX_LISTBOX* aListBox )
|
2019-08-17 11:22:18 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
wxString name = m_libList->GetBaseString( 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
|
|
|
|
2023-03-29 14:53:49 +00:00
|
|
|
// Ensure the displayed footprint is loade/reloaded from the new library
|
|
|
|
setCurFootprintName( wxEmptyString );
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
ReCreateFootprintList();
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
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;
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
wxString name = m_fpList->GetBaseString( 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 );
|
2023-05-31 20:37:58 +00:00
|
|
|
SelectAndViewFootprint( NEW_PART );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::displayFootprint( FOOTPRINT* aFootprint )
|
|
|
|
{
|
|
|
|
for( PAD* pad : aFootprint->Pads() )
|
|
|
|
{
|
|
|
|
const COMPONENT_NET& net = m_comp.GetNet( pad->GetNumber() );
|
|
|
|
|
|
|
|
if( !net.GetPinFunction().IsEmpty() )
|
|
|
|
{
|
|
|
|
NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
|
|
|
|
netinfo->SetNetname( net.GetPinFunction() );
|
|
|
|
GetBoard()->Add( netinfo );
|
|
|
|
pad->SetNet( netinfo );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetBoard()->Add( aFootprint );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-26 00:51:28 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxMouseEvent& aEvent )
|
2019-04-15 21:09:14 +00:00
|
|
|
{
|
2022-02-26 00:51:28 +00:00
|
|
|
wxCommandEvent evt;
|
|
|
|
AddFootprintToPCB( evt );
|
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
|
|
|
{
|
2023-09-27 15:36:49 +00:00
|
|
|
if( GetBoard()->GetFirstFootprint() )
|
2019-04-15 21:09:14 +00:00
|
|
|
{
|
2022-07-24 15:49:46 +00:00
|
|
|
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
|
|
|
|
PCBNEW_SETTINGS* cfg = pcbframe->GetPcbNewSettings();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( pcbframe == nullptr ) // happens when the board editor is not active (or closed)
|
2019-04-15 21:09:14 +00:00
|
|
|
{
|
|
|
|
DisplayErrorMessage( this, _( "No board currently open." ) );
|
|
|
|
return;
|
|
|
|
}
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2021-09-29 15:39:43 +00:00
|
|
|
TOOL_MANAGER* toolMgr = pcbframe->GetToolManager();
|
|
|
|
|
|
|
|
if( toolMgr->GetTool<BOARD_EDITOR_CONTROL>()->PlacingFootprint() )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Previous footprint placement still in progress." ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-14 18:36:07 +00:00
|
|
|
wxWindow* blocking_dialog = pcbframe->Kiway().GetBlockingDialog();
|
|
|
|
|
|
|
|
if( blocking_dialog )
|
|
|
|
blocking_dialog->Close( true );
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2019-04-15 21:09:14 +00:00
|
|
|
BOARD_COMMIT commit( pcbframe );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
// Create the "new" footprint
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
|
2020-10-14 23:37:26 +00:00
|
|
|
newFootprint->SetParent( pcbframe->GetBoard() );
|
2021-01-11 19:23:26 +00:00
|
|
|
newFootprint->SetLink( niluuid );
|
|
|
|
newFootprint->SetFlags(IS_NEW ); // whatever
|
|
|
|
|
|
|
|
for( PAD* pad : newFootprint->Pads() )
|
|
|
|
{
|
2021-01-25 01:19:35 +00:00
|
|
|
// Set the pads ratsnest settings to the global settings
|
2022-07-24 15:49:46 +00:00
|
|
|
pad->SetLocalRatsnestVisible( cfg->m_Display.m_ShowGlobalRatsnest );
|
2021-01-25 01:19:35 +00:00
|
|
|
|
|
|
|
// Pads in the library all have orphaned nets. Replace with Default.
|
2021-01-11 19:23:26 +00:00
|
|
|
pad->SetNetCode( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put it on FRONT layer,
|
|
|
|
// (Can be stored flipped if the lib is an archive built from a board)
|
|
|
|
if( newFootprint->IsFlipped() )
|
2022-07-24 15:49:46 +00:00
|
|
|
newFootprint->Flip( newFootprint->GetPosition(), cfg->m_FlipLeftRight );
|
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
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
commit.Add( newFootprint );
|
2019-06-13 13:34:38 +00:00
|
|
|
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
2020-11-10 21:20:03 +00:00
|
|
|
pcbframe->PlaceFootprint( newFootprint );
|
2021-01-11 19:23:26 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
|
2019-06-13 13:34:38 +00:00
|
|
|
viewControls->SetCrossHairCursorPosition( cursorPos, false );
|
2020-10-14 23:37:26 +00:00
|
|
|
commit.Push( wxT( "Insert footprint" ) );
|
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();
|
2023-06-26 22:16:51 +00:00
|
|
|
toolMgr->PostAction( PCB_ACTIONS::placeFootprint, newFootprint );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
newFootprint->ClearFlags();
|
2019-04-15 21:09:14 +00:00
|
|
|
}
|
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-10-14 23:37:26 +00:00
|
|
|
PCBNEW_SETTINGS* 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-30 22:02:05 +00:00
|
|
|
m_displayOptions = fpedit->m_Display;
|
2020-01-13 01:44:19 +00:00
|
|
|
GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
|
2022-07-11 03:00:46 +00:00
|
|
|
|
|
|
|
m_libListWidth = cfg->m_FootprintViewerLibListWidth;
|
|
|
|
m_fpListWidth = cfg->m_FootprintViewerFPListWidth;
|
|
|
|
|
|
|
|
// Set parameters to a reasonable value.
|
|
|
|
int maxWidth = cfg->m_FootprintViewer.state.size_x - 80;
|
|
|
|
|
|
|
|
if( m_libListWidth + m_fpListWidth > maxWidth )
|
|
|
|
{
|
|
|
|
m_libListWidth = maxWidth * ( m_libListWidth / ( m_libListWidth + m_fpListWidth ) );
|
|
|
|
m_fpListWidth = maxWidth - m_libListWidth;
|
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
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 )
|
|
|
|
{
|
2020-10-14 23:37:26 +00:00
|
|
|
PCBNEW_SETTINGS* 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
|
|
|
|
2021-03-01 20:29:17 +00:00
|
|
|
GetGalDisplayOptions().m_axesEnabled = true;
|
|
|
|
|
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
|
|
|
|
2021-11-22 19:47:17 +00:00
|
|
|
if( GetCanvas() && GetCanvas()->GetView() )
|
|
|
|
cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
|
2022-04-18 08:32:36 +00:00
|
|
|
|
|
|
|
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
|
|
|
|
cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
|
2023-08-27 20:17:10 +00:00
|
|
|
cfg->m_FootprintViewerLibListWidth = m_libList->GetSize().x;
|
|
|
|
cfg->m_FootprintViewerFPListWidth = m_fpList->GetSize().x;
|
2022-07-11 03:00:46 +00:00
|
|
|
|
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-10-14 23:37:26 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
2022-02-04 22:44:59 +00:00
|
|
|
wxCHECK_MSG( cfg, nullptr, wxT( "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
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetColorSettings( bool aForceRefresh ) const
|
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-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
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
|
|
|
|
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:
|
2023-09-28 03:15:54 +00:00
|
|
|
std::vector< wxString > libNicknames = PROJECT_PCB::PcbFootprintLibs( &Prj() )->GetLogicalLibs();
|
2019-08-27 12:51:01 +00:00
|
|
|
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++ )
|
|
|
|
{
|
2022-07-09 18:41:03 +00:00
|
|
|
if( libNicknames[ii] != m_libList->GetBaseString( ii ) )
|
2019-08-27 12:51:01 +00:00
|
|
|
{
|
|
|
|
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 )
|
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
|
2019-05-12 15:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
|
|
|
{
|
|
|
|
setCurNickname( aFootprint->GetFPID().GetLibNickname() );
|
|
|
|
setCurFootprintName( aFootprint->GetFPID().GetLibItemName() );
|
|
|
|
SelectAndViewFootprint( RELOAD_PART );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-10 15:41:39 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::HardRedraw()
|
|
|
|
{
|
|
|
|
ReCreateLibraryList();
|
|
|
|
ReCreateFootprintList();
|
|
|
|
ReloadFootprint( GetBoard()->GetFirstFootprint() );
|
|
|
|
}
|
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|
|
|
{
|
|
|
|
switch( mail.Command() )
|
|
|
|
{
|
2023-01-19 00:14:31 +00:00
|
|
|
case MAIL_RELOAD_LIB:
|
|
|
|
ReCreateLibraryList();
|
|
|
|
break;
|
2022-07-24 22:40:47 +00:00
|
|
|
|
|
|
|
default:
|
2023-09-29 16:02:57 +00:00
|
|
|
break;
|
2022-07-24 22:40:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-09 02:09:06 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
|
2012-02-10 08:49:43 +00:00
|
|
|
{
|
2021-06-20 21:46:41 +00:00
|
|
|
wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
|
2021-04-09 02:09:06 +00:00
|
|
|
PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &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:
|
2022-02-04 22:44:59 +00:00
|
|
|
wxString id = wxString::Format( wxT( "%i" ), event.GetId() );
|
|
|
|
wxFAIL_MSG( wxT( "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;
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
if( !getCurNickname().IsEmpty() )
|
2016-08-19 07:45:59 +00:00
|
|
|
{
|
2022-07-09 18:41:03 +00:00
|
|
|
try
|
|
|
|
{
|
2023-09-28 03:15:54 +00:00
|
|
|
FP_LIB_TABLE* libtable = PROJECT_PCB::PcbFootprintLibs( &Prj() );
|
2022-07-09 18:41:03 +00:00
|
|
|
const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
|
2016-08-19 07:45:59 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
title = getCurNickname() + wxT( " \u2014 " ) + row->GetFullURI( true );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
title = _( "[no library selected]" );
|
|
|
|
}
|
2021-06-20 21:46:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
title = _( "[no library selected]" );
|
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
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
setCurFootprintName( m_fpList->GetBaseString( selection ) );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
// Delete the current footprint
|
2023-06-16 15:29:35 +00:00
|
|
|
if( PCB_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>() )
|
|
|
|
selectionTool->ClearSelection( true /* quiet mode */ );
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
GetBoard()->DeleteAllFootprints();
|
2023-10-04 20:01:33 +00:00
|
|
|
GetBoard()->RemoveUnusedNets( nullptr );
|
2014-01-27 07:23:02 +00:00
|
|
|
|
2023-09-28 03:15:54 +00:00
|
|
|
FOOTPRINT* footprint = PROJECT_PCB::PcbFootprintLibs( &Prj() )->FootprintLoad( getCurNickname(),
|
2020-11-13 15:15:52 +00:00
|
|
|
getCurFootprintName() );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( footprint )
|
2022-07-24 22:40:47 +00:00
|
|
|
displayFootprint( footprint );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
if( aMode != RELOAD_PART )
|
|
|
|
setFPWatcher( footprint );
|
|
|
|
|
2021-04-09 02:09:06 +00:00
|
|
|
Update3DView( true, true );
|
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 );
|
|
|
|
|
2022-04-18 08:32:36 +00:00
|
|
|
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
|
|
|
|
|
|
|
|
if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
2018-09-11 15:28:57 +00:00
|
|
|
else
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::centerContents );
|
2018-09-11 15:28:57 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
return GetBoard()->GetFirstFootprint();
|
2020-05-22 18:27:05 +00:00
|
|
|
}
|
2020-05-23 17:14:49 +00:00
|
|
|
|