2011-11-07 19:04:24 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-10-30 16:51:12 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-09-02 18:12:50 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-01-28 19:08:38 +00:00
|
|
|
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-11-07 19:04:24 +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
|
|
|
|
*/
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2022-01-29 19:07:07 +00:00
|
|
|
#include <symbol_library_common.h>
|
2019-01-31 01:07:53 +00:00
|
|
|
#include <confirm.h>
|
2023-01-23 00:25:15 +00:00
|
|
|
#include <dialogs/html_message_box.h>
|
2019-12-19 14:05:46 +00:00
|
|
|
#include <eeschema_id.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <eeschema_settings.h>
|
2023-09-18 23:52:27 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2019-12-19 14:05:46 +00:00
|
|
|
#include <kiway.h>
|
2023-01-19 00:14:31 +00:00
|
|
|
#include <kiway_express.h>
|
2023-01-23 00:25:15 +00:00
|
|
|
#include <locale_io.h>
|
2020-12-25 23:37:01 +00:00
|
|
|
#include <symbol_viewer_frame.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>
|
|
|
|
#include <widgets/wx_progress_reporters.h>
|
2019-12-19 14:05:46 +00:00
|
|
|
#include <sch_view.h>
|
|
|
|
#include <sch_painter.h>
|
|
|
|
#include <symbol_lib_table.h>
|
|
|
|
#include <symbol_tree_model_adapter.h>
|
|
|
|
#include <pgm_base.h>
|
2022-07-09 18:41:03 +00:00
|
|
|
#include <project/project_file.h>
|
2023-09-28 03:04:53 +00:00
|
|
|
#include <project_sch.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2023-01-23 00:25:15 +00:00
|
|
|
#include <symbol_async_loader.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-08-06 23:03:58 +00:00
|
|
|
#include <tool/common_tools.h>
|
|
|
|
#include <tool/editor_conditions.h>
|
|
|
|
#include <tool/selection.h>
|
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
2019-08-27 13:07:35 +00:00
|
|
|
#include <tools/ee_actions.h>
|
2020-12-12 03:13:52 +00:00
|
|
|
#include <tools/symbol_editor_control.h>
|
2019-06-01 18:36:49 +00:00
|
|
|
#include <tools/ee_inspection_tool.h>
|
2019-12-19 14:05:46 +00:00
|
|
|
#include <view/view_controls.h>
|
2022-07-09 18:41:03 +00:00
|
|
|
#include <wx/srchctrl.h>
|
2018-10-30 16:51:12 +00:00
|
|
|
|
2020-05-03 12:35:52 +00:00
|
|
|
#include <default_values.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2022-07-09 18:41:03 +00:00
|
|
|
#include "eda_pattern_match.h"
|
2020-05-03 12:35:52 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
// Save previous symbol library viewer state.
|
2023-01-23 00:25:15 +00:00
|
|
|
LIB_ID SYMBOL_VIEWER_FRAME::m_currentSymbol;
|
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-12-25 23:37:01 +00:00
|
|
|
int SYMBOL_VIEWER_FRAME::m_unit = 1;
|
|
|
|
int SYMBOL_VIEWER_FRAME::m_convert = 1;
|
2023-01-23 00:25:15 +00:00
|
|
|
bool SYMBOL_VIEWER_FRAME::m_show_progress = true;
|
2010-11-20 21:59:00 +00:00
|
|
|
|
2011-11-07 19:04:24 +00:00
|
|
|
|
2023-01-28 19:08:38 +00:00
|
|
|
BEGIN_EVENT_TABLE( SYMBOL_VIEWER_FRAME, SCH_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
|
2020-12-25 23:37:01 +00:00
|
|
|
EVT_SIZE( SYMBOL_VIEWER_FRAME::OnSize )
|
|
|
|
EVT_ACTIVATE( SYMBOL_VIEWER_FRAME::OnActivate )
|
2009-05-21 17:42:42 +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
|
2020-12-25 23:37:01 +00:00
|
|
|
EVT_TOOL( ID_LIBVIEW_NEXT, SYMBOL_VIEWER_FRAME::onSelectNextSymbol )
|
|
|
|
EVT_TOOL( ID_LIBVIEW_PREVIOUS, SYMBOL_VIEWER_FRAME::onSelectPreviousSymbol )
|
2021-06-15 12:31:28 +00:00
|
|
|
EVT_CHOICE( ID_LIBVIEW_SELECT_UNIT_NUMBER, SYMBOL_VIEWER_FRAME::onSelectSymbolUnit )
|
2009-05-21 17:42:42 +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
|
|
|
// listbox events
|
2022-07-09 18:41:03 +00:00
|
|
|
EVT_TEXT( ID_LIBVIEW_LIB_FILTER, SYMBOL_VIEWER_FRAME::OnLibFilter )
|
2020-12-25 23:37:01 +00:00
|
|
|
EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, SYMBOL_VIEWER_FRAME::ClickOnLibList )
|
2022-07-09 18:41:03 +00:00
|
|
|
EVT_TEXT( ID_LIBVIEW_SYM_FILTER, SYMBOL_VIEWER_FRAME::OnSymFilter )
|
|
|
|
EVT_LISTBOX( ID_LIBVIEW_SYM_LIST, SYMBOL_VIEWER_FRAME::ClickOnSymbolList )
|
|
|
|
EVT_LISTBOX_DCLICK( ID_LIBVIEW_SYM_LIST, SYMBOL_VIEWER_FRAME::DClickOnSymbolList )
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2014-10-15 11:40:38 +00:00
|
|
|
// Menu (and/or hotkey) events
|
2020-12-25 23:37:01 +00:00
|
|
|
EVT_MENU( wxID_CLOSE, SYMBOL_VIEWER_FRAME::CloseLibraryViewer )
|
2014-10-15 11:40:38 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBVIEW_SELECT_UNIT_NUMBER, SYMBOL_VIEWER_FRAME::onUpdateUnitChoice )
|
2016-11-04 11:13:22 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2023-09-28 13:09:45 +00:00
|
|
|
SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|
|
|
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_VIEWER, _( "Symbol Library Browser" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
|
|
|
|
LIB_VIEW_FRAME_NAME ),
|
2020-12-17 23:56:47 +00:00
|
|
|
m_unitChoice( nullptr ),
|
|
|
|
m_libList( nullptr ),
|
2023-04-16 13:21:05 +00:00
|
|
|
m_symbolList( nullptr )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2023-09-28 13:09:45 +00:00
|
|
|
m_aboutTitle = _HKI( "KiCad Symbol Library Browser" );
|
2019-11-09 18:41:02 +00:00
|
|
|
|
2015-12-22 11:58:26 +00:00
|
|
|
// Force the frame name used in config. the lib viewer frame has a name
|
|
|
|
// depending on aFrameType (needed to identify the frame by wxWidgets),
|
|
|
|
// but only one configuration is preferable.
|
2023-09-28 13:09:45 +00:00
|
|
|
m_configName = LIB_VIEW_FRAME_NAME;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
// Give an icon
|
2011-09-08 05:58:45 +00:00
|
|
|
wxIcon icon;
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::library_browser ) );
|
2011-09-08 05:58:45 +00:00
|
|
|
SetIcon( icon );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_libListWidth = 200;
|
2020-12-17 23:56:47 +00:00
|
|
|
m_symbolListWidth = 300;
|
2021-06-14 18:00:08 +00:00
|
|
|
m_listPowerOnly = false;
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2020-05-21 02:27:48 +00:00
|
|
|
SetScreen( new SCH_SCREEN );
|
2012-09-11 19:03:21 +00:00
|
|
|
GetScreen()->m_Center = true; // Axis origin centered 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() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2019-05-22 08:04:34 +00:00
|
|
|
// Ensure axis are always drawn (initial default display was not drawn)
|
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
|
|
|
|
gal_opts.m_axesEnabled = true;
|
2021-02-09 01:43:03 +00:00
|
|
|
gal_opts.m_gridMinSpacing = 10.0;
|
|
|
|
gal_opts.NotifyChanged();
|
2019-05-22 08:04:34 +00:00
|
|
|
|
2021-01-31 15:28:37 +00:00
|
|
|
GetRenderSettings()->LoadColors( GetColorSettings() );
|
|
|
|
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
|
|
|
|
|
2022-09-16 23:25:07 +00:00
|
|
|
GetRenderSettings()->SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS );
|
2020-05-03 12:35:52 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
setupTools();
|
2020-08-06 23:03:58 +00:00
|
|
|
setupUIConditions();
|
2020-04-25 13:06:57 +00:00
|
|
|
|
2009-04-10 13:39:03 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
2020-08-13 23:14:53 +00:00
|
|
|
ReCreateMenuBar();
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
wxPanel* libPanel = new wxPanel( this );
|
|
|
|
wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
|
2018-08-11 16:04:46 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
m_libFilter = new wxSearchCtrl( libPanel, ID_LIBVIEW_LIB_FILTER, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
|
|
|
m_libFilter->SetDescriptiveText( _( "Filter" ) );
|
|
|
|
libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
m_libList = new WX_LISTBOX( libPanel, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
|
|
|
|
0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
|
|
|
|
libSizer->Add( m_libList, 1, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
libPanel->SetSizer( libSizer );
|
|
|
|
libPanel->Fit();
|
|
|
|
|
|
|
|
wxPanel* symbolPanel = new wxPanel( this );
|
|
|
|
wxSizer* symbolSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
m_symbolFilter = new wxSearchCtrl( symbolPanel, ID_LIBVIEW_SYM_FILTER, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
|
|
|
m_symbolFilter->SetDescriptiveText( _( "Filter" ) );
|
|
|
|
m_symbolFilter->SetToolTip(
|
|
|
|
_( "Filter on symbol name, keywords, description and pin 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 pin count." ) );
|
|
|
|
symbolSizer->Add( m_symbolFilter, 0, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
#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_symbolFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_symbolList = new WX_LISTBOX( symbolPanel, ID_LIBVIEW_SYM_LIST, wxDefaultPosition, wxDefaultSize,
|
|
|
|
0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
|
|
|
|
symbolSizer->Add( m_symbolList, 1, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
symbolPanel->SetSizer( symbolSizer );
|
|
|
|
symbolPanel->Fit();
|
2018-08-11 16:04:46 +00:00
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
// Preload libraries
|
|
|
|
loadAllLibraries();
|
2023-09-28 13:09:45 +00:00
|
|
|
ReCreateLibList();
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2017-07-17 20:57:15 +00:00
|
|
|
m_selection_changed = false;
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
DisplayLibInfos();
|
2009-12-22 20:08:56 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2022-11-06 23:50:29 +00:00
|
|
|
CreateInfoBar();
|
|
|
|
|
2017-07-17 20:57:15 +00:00
|
|
|
// Manage main toolbar
|
2022-07-09 18:41:03 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer(6) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
|
2022-07-11 03:00:46 +00:00
|
|
|
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
|
2022-07-09 18:41:03 +00:00
|
|
|
m_auimgr.AddPane( symbolPanel, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
|
2022-07-11 03:00:46 +00:00
|
|
|
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
2014-01-19 16:36:12 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2011-04-09 18:53:39 +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_symbolListWidth > 0 )
|
2023-06-17 11:44:36 +00:00
|
|
|
SetAuiPaneSize( m_auimgr, m_auimgr.GetPane( "Symbols" ), m_symbolListWidth, -1 );
|
2022-07-11 03:00:46 +00:00
|
|
|
|
2022-11-06 23:50:29 +00:00
|
|
|
FinishAUIInitialization();
|
|
|
|
|
2023-09-28 17:18:19 +00:00
|
|
|
Raise();
|
|
|
|
Show( true );
|
2018-08-27 13:28:44 +00:00
|
|
|
|
|
|
|
SyncView();
|
2019-08-30 14:00:16 +00:00
|
|
|
GetCanvas()->SetCanFocus( false );
|
2018-11-20 14:11:22 +00:00
|
|
|
|
2020-10-05 19:26:33 +00:00
|
|
|
setupUnits( config() );
|
|
|
|
|
2018-11-20 14:11:22 +00:00
|
|
|
// Set the working/draw area size to display a symbol to a reasonable value:
|
|
|
|
// A 450mm x 450mm with a origin at the area center looks like a large working area
|
2022-09-16 11:33:56 +00:00
|
|
|
double max_size_x = schIUScale.mmToIU( 450 );
|
|
|
|
double max_size_y = schIUScale.mmToIU( 450 );
|
2018-11-20 14:11:22 +00:00
|
|
|
BOX2D bbox;
|
2021-07-16 20:13:26 +00:00
|
|
|
bbox.SetOrigin( -max_size_x / 2, -max_size_y / 2 );
|
2018-11-20 14:11:22 +00:00
|
|
|
bbox.SetSize( max_size_x, max_size_y );
|
|
|
|
GetCanvas()->GetView()->SetBoundary( bbox );
|
2023-06-26 22:16:51 +00:00
|
|
|
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
|
2023-01-21 10:29:01 +00:00
|
|
|
|
|
|
|
// If a symbol was previously selected in m_symbolList from a previous run, show it
|
|
|
|
wxString symbName = m_symbolList->GetStringSelection();
|
|
|
|
|
|
|
|
if( !symbName.IsEmpty() )
|
|
|
|
{
|
|
|
|
SetSelectedSymbol( symbName );
|
|
|
|
updatePreviewSymbol();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
SYMBOL_VIEWER_FRAME::~SYMBOL_VIEWER_FRAME()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-02-03 14:00:48 +00:00
|
|
|
// Shutdown all running tools
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ShutdownAllTools();
|
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
if( m_previewItem )
|
2023-04-16 13:21:05 +00:00
|
|
|
{
|
|
|
|
GetCanvas()->GetView()->Remove( m_previewItem.get() );
|
|
|
|
m_previewItem = nullptr;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2013-11-09 16:30:49 +00:00
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::loadAllLibraries()
|
|
|
|
{
|
|
|
|
// TODO: deduplicate with SYMBOL_TREE_MODEL_ADAPTER::AddLibraries
|
2023-09-28 03:04:53 +00:00
|
|
|
std::vector<wxString> libraryNames = PROJECT_SCH::SchSymbolLibTable( &Prj() )->GetLogicalLibs();
|
2023-01-23 00:25:15 +00:00
|
|
|
std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter = nullptr;
|
|
|
|
|
|
|
|
if( m_show_progress )
|
|
|
|
{
|
|
|
|
progressReporter = std::make_unique<WX_PROGRESS_REPORTER>( this,
|
|
|
|
_( "Loading Symbol Libraries" ),
|
|
|
|
libraryNames.size(), true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable KIID generation: not needed for library parts; sometimes very slow
|
|
|
|
KIID::CreateNilUuids( true );
|
|
|
|
|
|
|
|
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbols;
|
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_ASYNC_LOADER loader( libraryNames, PROJECT_SCH::SchSymbolLibTable( &Prj() ), false, nullptr,
|
2023-01-23 00:25:15 +00:00
|
|
|
progressReporter.get() );
|
|
|
|
|
|
|
|
LOCALE_IO toggle;
|
|
|
|
|
|
|
|
loader.Start();
|
|
|
|
|
|
|
|
while( !loader.Done() )
|
|
|
|
{
|
|
|
|
if( progressReporter && !progressReporter->KeepRefreshing() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
wxMilliSleep( 33 );
|
|
|
|
}
|
|
|
|
|
|
|
|
loader.Join();
|
|
|
|
|
|
|
|
KIID::CreateNilUuids( false );
|
|
|
|
|
|
|
|
if( !loader.GetErrors().IsEmpty() )
|
|
|
|
{
|
|
|
|
HTML_MESSAGE_BOX dlg( this, _( "Load Error" ) );
|
|
|
|
|
|
|
|
dlg.MessageSet( _( "Errors loading symbols:" ) );
|
|
|
|
|
|
|
|
wxString msg = loader.GetErrors();
|
|
|
|
msg.Replace( "\n", "<BR>" );
|
|
|
|
|
|
|
|
dlg.AddHTML_Text( msg );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::setupTools()
|
2019-05-04 11:23:04 +00:00
|
|
|
{
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2019-05-10 17:19:48 +00:00
|
|
|
m_actions = new EE_ACTIONS();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2019-05-04 11:23:04 +00:00
|
|
|
|
|
|
|
// Register tools
|
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
2019-08-27 13:07:35 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
2022-09-06 16:28:44 +00:00
|
|
|
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet
|
|
|
|
m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu
|
|
|
|
m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL ); // manage render settings
|
2019-05-04 11:23:04 +00:00
|
|
|
|
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
2019-05-25 08:09:26 +00:00
|
|
|
// Run the selection tool, it is supposed to be always active
|
|
|
|
// It also manages the mouse right click to show the context menu
|
|
|
|
m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
|
|
|
|
|
2019-05-04 11:23:04 +00:00
|
|
|
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::setupUIConditions()
|
2020-08-06 23:03:58 +00:00
|
|
|
{
|
|
|
|
SCH_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
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() ) );
|
|
|
|
|
|
|
|
auto electricalTypesShownCondition =
|
2022-09-06 16:28:44 +00:00
|
|
|
[this]( const SELECTION& aSel )
|
|
|
|
{
|
2023-06-12 11:38:50 +00:00
|
|
|
return GetRenderSettings() && GetRenderSettings()->m_ShowPinsElectricalType;
|
2022-09-06 16:28:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto pinNumbersShownCondition =
|
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
2023-06-12 11:38:50 +00:00
|
|
|
return GetRenderSettings() && GetRenderSettings()->m_ShowPinNumbers;
|
2022-09-06 16:28:44 +00:00
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto demorganCond =
|
2022-09-06 16:28:44 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
LIB_SYMBOL* symbol = GetSelectedSymbol();
|
|
|
|
return symbol && symbol->HasConversion();
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto demorganStandardCond =
|
2022-09-06 16:28:44 +00:00
|
|
|
[]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto demorganAlternateCond =
|
2022-09-06 16:28:44 +00:00
|
|
|
[]( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
auto haveDatasheetCond =
|
2022-09-06 16:28:44 +00:00
|
|
|
[this]( const SELECTION& )
|
|
|
|
{
|
|
|
|
LIB_SYMBOL* symbol = GetSelectedSymbol();
|
|
|
|
return symbol && !symbol->GetDatasheetField().GetText().IsEmpty();
|
|
|
|
};
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( electricalTypesShownCondition ) );
|
2022-09-06 16:28:44 +00:00
|
|
|
mgr->SetConditions( EE_ACTIONS::showPinNumbers, CHECK( pinNumbersShownCondition ) );
|
2020-08-06 23:03:58 +00:00
|
|
|
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showDeMorganStandard,
|
|
|
|
ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
|
|
|
|
mgr->SetConditions( EE_ACTIONS::showDeMorganAlternate,
|
|
|
|
ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
|
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
#undef ENABLE
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
|
2017-07-17 20:57:15 +00:00
|
|
|
{
|
|
|
|
m_unit = aUnit > 0 ? aUnit : 1;
|
2019-04-15 13:59:36 +00:00
|
|
|
m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
|
2017-07-17 20:57:15 +00:00
|
|
|
m_selection_changed = false;
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2019-06-01 19:48:01 +00:00
|
|
|
updatePreviewSymbol();
|
2017-07-17 20:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* SYMBOL_VIEWER_FRAME::GetSelectedSymbol() const
|
2016-10-21 12:38:08 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* symbol = nullptr;
|
2016-10-21 12:38:08 +00:00
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
if( m_currentSymbol.IsValid() )
|
2023-09-28 03:04:53 +00:00
|
|
|
symbol = PROJECT_SCH::SchSymbolLibTable( &Prj() )->LoadSymbol( m_currentSymbol );
|
2016-10-21 12:38:08 +00:00
|
|
|
|
|
|
|
return symbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::updatePreviewSymbol()
|
2018-08-29 18:31:43 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* symbol = GetSelectedSymbol();
|
2018-08-29 18:31:43 +00:00
|
|
|
KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
|
|
|
|
|
|
|
|
if( m_previewItem )
|
|
|
|
{
|
2023-04-16 13:21:05 +00:00
|
|
|
view->Remove( m_previewItem.get() );
|
2018-08-29 18:31:43 +00:00
|
|
|
m_previewItem = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClearMsgPanel();
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
if( symbol )
|
2018-08-29 18:31:43 +00:00
|
|
|
{
|
2018-09-02 20:19:22 +00:00
|
|
|
GetRenderSettings()->m_ShowUnit = m_unit;
|
|
|
|
GetRenderSettings()->m_ShowConvert = m_convert;
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2023-04-16 13:21:05 +00:00
|
|
|
m_previewItem = symbol->Flatten();
|
|
|
|
view->Add( m_previewItem.get() );
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2021-02-21 20:32:35 +00:00
|
|
|
wxString parentName;
|
2023-04-16 13:21:05 +00:00
|
|
|
std::shared_ptr<LIB_SYMBOL> parent = symbol->GetParent().lock();
|
2019-11-06 19:15:42 +00:00
|
|
|
|
|
|
|
if( parent )
|
|
|
|
parentName = parent->GetName();
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2021-06-30 10:53:04 +00:00
|
|
|
AppendMsgPanel( _( "Name" ), UnescapeString( m_previewItem->GetName() ) );
|
|
|
|
AppendMsgPanel( _( "Parent" ), UnescapeString( parentName ) );
|
2020-11-18 15:36:47 +00:00
|
|
|
AppendMsgPanel( _( "Description" ), m_previewItem->GetDescription() );
|
|
|
|
AppendMsgPanel( _( "Keywords" ), m_previewItem->GetKeyWords() );
|
2018-08-29 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
|
2022-01-21 15:37:06 +00:00
|
|
|
GetCanvas()->Refresh();
|
2018-08-29 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::doCloseWindow()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2018-08-29 18:31:43 +00:00
|
|
|
GetCanvas()->StopDrawing();
|
2023-09-28 17:18:19 +00:00
|
|
|
Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
if( m_auimgr.GetManagedWindow() )
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
2009-04-10 13:39:03 +00:00
|
|
|
SizeEv.Skip();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
|
2018-08-08 09:48:29 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* symbol = GetSelectedSymbol();
|
2018-08-08 09:48:29 +00:00
|
|
|
|
|
|
|
int unit_count = 1;
|
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( symbol )
|
|
|
|
unit_count = std::max( symbol->GetUnitCount(), 1 );
|
2018-08-08 09:48:29 +00:00
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
m_unitChoice->Enable( unit_count > 1 );
|
2018-08-08 09:48:29 +00:00
|
|
|
|
|
|
|
if( unit_count > 1 )
|
|
|
|
{
|
2018-10-30 16:51:12 +00:00
|
|
|
// rebuild the unit list if it is not suitable (after a new selection for instance)
|
2018-08-29 18:31:43 +00:00
|
|
|
if( unit_count != (int)m_unitChoice->GetCount() )
|
2018-08-08 09:48:29 +00:00
|
|
|
{
|
2018-08-29 18:31:43 +00:00
|
|
|
m_unitChoice->Clear();
|
2018-08-08 09:48:29 +00:00
|
|
|
|
|
|
|
for( int ii = 0; ii < unit_count; ii++ )
|
2022-06-21 23:22:32 +00:00
|
|
|
{
|
2022-09-14 22:11:37 +00:00
|
|
|
wxString unit = symbol->GetUnitDisplayName( ii + 1 );
|
2022-06-21 23:22:32 +00:00
|
|
|
m_unitChoice->Append( unit );
|
|
|
|
}
|
2018-10-30 16:51:12 +00:00
|
|
|
|
2018-08-08 09:48:29 +00:00
|
|
|
}
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2018-10-30 16:51:12 +00:00
|
|
|
if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) )
|
|
|
|
m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) );
|
2018-08-08 09:48:29 +00:00
|
|
|
}
|
2018-08-29 18:31:43 +00:00
|
|
|
else if( m_unitChoice->GetCount() )
|
2021-07-16 20:13:26 +00:00
|
|
|
{
|
2018-08-29 18:31:43 +00:00
|
|
|
m_unitChoice->Clear();
|
2021-07-16 20:13:26 +00:00
|
|
|
}
|
2018-08-08 09:48:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( !m_libList )
|
2017-07-17 20:57:15 +00:00
|
|
|
return false;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2014-01-19 16:36:12 +00:00
|
|
|
m_libList->Clear();
|
2015-04-16 15:26:51 +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:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* libTable = PROJECT_SCH::SchSymbolLibTable( &Prj() );
|
2023-01-23 00:25:15 +00:00
|
|
|
std::vector<wxString> libs = libTable->GetLogicalLibs();
|
2023-01-27 23:38:10 +00:00
|
|
|
std::vector<wxString> pinnedMatches;
|
|
|
|
std::vector<wxString> otherMatches;
|
2015-04-16 15:26:51 +00:00
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
auto doAddLib =
|
|
|
|
[&]( const wxString& aLib )
|
|
|
|
{
|
|
|
|
if( alg::contains( project.m_PinnedSymbolLibs, aLib )
|
|
|
|
|| alg::contains( cfg->m_Session.pinned_symbol_libs, aLib ) )
|
|
|
|
{
|
2023-01-27 23:38:10 +00:00
|
|
|
pinnedMatches.push_back( aLib );
|
2023-01-23 00:25:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-27 23:38:10 +00:00
|
|
|
otherMatches.push_back( aLib );
|
2023-01-23 00:25:15 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
auto process =
|
|
|
|
[&]( const wxString& aLib )
|
|
|
|
{
|
|
|
|
// Remove not allowed libs, if the allowed lib list is not empty
|
|
|
|
if( m_allowedLibs.GetCount() )
|
|
|
|
{
|
|
|
|
if( m_allowedLibs.Index( aLib ) == wxNOT_FOUND )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove libs which have no power symbols, if this filter is activated
|
|
|
|
if( m_listPowerOnly )
|
|
|
|
{
|
|
|
|
wxArrayString aliasNames;
|
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
PROJECT_SCH::SchSymbolLibTable( &Prj() )->EnumerateSymbolLib( aLib, aliasNames, true );
|
2022-07-09 18:41:03 +00:00
|
|
|
|
|
|
|
if( aliasNames.IsEmpty() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
SYMBOL_LIB_TABLE_ROW* row = libTable->FindRow( aLib );
|
|
|
|
|
2023-06-03 11:28:03 +00:00
|
|
|
wxCHECK( row, /* void */ );
|
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
if( !row->GetIsVisible() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( row->SupportsSubLibraries() )
|
2022-07-23 18:30:32 +00:00
|
|
|
{
|
2023-01-23 00:25:15 +00:00
|
|
|
std::vector<wxString> subLibraries;
|
|
|
|
row->GetSubLibraryNames( subLibraries );
|
|
|
|
|
|
|
|
for( const wxString& lib : subLibraries )
|
|
|
|
{
|
2023-02-12 21:29:26 +00:00
|
|
|
wxString suffix = lib.IsEmpty() ? wxString( wxT( "" ) )
|
2023-01-23 00:25:15 +00:00
|
|
|
: wxString::Format( wxT( " - %s" ), lib );
|
|
|
|
wxString name = wxString::Format( wxT( "%s%s" ), aLib, suffix );
|
|
|
|
|
|
|
|
doAddLib( name );
|
|
|
|
}
|
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-23 00:25:15 +00:00
|
|
|
doAddLib( aLib );
|
2022-07-23 18:30:32 +00:00
|
|
|
}
|
2022-07-09 18:41:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if( m_libFilter->GetValue().IsEmpty() )
|
2015-04-16 15:26:51 +00:00
|
|
|
{
|
2022-07-09 18:41:03 +00:00
|
|
|
for( const wxString& lib : libs )
|
|
|
|
process( lib );
|
2015-04-16 15:26:51 +00:00
|
|
|
}
|
2022-07-09 18:41:03 +00:00
|
|
|
else
|
2015-04-16 15:26:51 +00:00
|
|
|
{
|
2022-07-09 18:41:03 +00:00
|
|
|
wxStringTokenizer tokenizer( m_libFilter->GetValue() );
|
2015-04-16 15:26:51 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
while( tokenizer.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
const wxString term = tokenizer.GetNextToken().Lower();
|
2022-08-12 23:51:19 +00:00
|
|
|
EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
|
2017-09-02 18:12:50 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
for( const wxString& lib : libs )
|
|
|
|
{
|
2023-04-14 22:34:14 +00:00
|
|
|
if( matcher.Find( lib.Lower() ) )
|
2022-07-09 18:41:03 +00:00
|
|
|
process( lib );
|
|
|
|
}
|
2015-04-16 15:26:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-02 18:12:50 +00:00
|
|
|
if( libs.empty() )
|
2017-07-17 20:57:15 +00:00
|
|
|
return true;
|
2016-10-21 12:38:08 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
for( const wxString& name : pinnedMatches )
|
|
|
|
m_libList->Append( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + UnescapeString( name ) );
|
2017-09-02 18:12:50 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
for( const wxString& name : otherMatches )
|
|
|
|
m_libList->Append( UnescapeString( name ) );
|
2009-06-04 10:42:59 +00:00
|
|
|
|
|
|
|
// Search for a previous selection:
|
2023-01-23 00:25:15 +00:00
|
|
|
int index = m_libList->FindString( UnescapeString( m_currentSymbol.GetUniStringLibNickname() ) );
|
2009-10-01 14:17:47 +00:00
|
|
|
|
|
|
|
if( index != wxNOT_FOUND )
|
2009-06-04 10:42:59 +00:00
|
|
|
{
|
2014-01-19 16:36:12 +00:00
|
|
|
m_libList->SetSelection( index, true );
|
2008-04-14 19:22:48 +00:00
|
|
|
}
|
2009-10-01 14:17:47 +00:00
|
|
|
else
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2022-08-31 23:20:53 +00:00
|
|
|
// If not found, clear current library selection because it can be deleted after a
|
|
|
|
// config change.
|
2023-01-23 00:25:15 +00:00
|
|
|
m_currentSymbol.SetLibNickname( m_libList->GetCount() > 0
|
2023-02-12 21:29:26 +00:00
|
|
|
? m_libList->GetBaseString( 0 ) : wxString( wxT( "" ) ) );
|
2023-01-23 00:25:15 +00:00
|
|
|
m_currentSymbol.SetLibItemName( wxEmptyString );
|
2009-10-01 14:17:47 +00:00
|
|
|
m_unit = 1;
|
2019-04-15 13:59:36 +00:00
|
|
|
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
2008-04-14 19:22:48 +00:00
|
|
|
}
|
|
|
|
|
2020-12-17 23:56:47 +00:00
|
|
|
bool cmp_changed = ReCreateSymbolList();
|
2008-04-14 19:22:48 +00:00
|
|
|
DisplayLibInfos();
|
2019-05-31 17:37:07 +00:00
|
|
|
GetCanvas()->Refresh();
|
2017-07-17 20:57:15 +00:00
|
|
|
|
|
|
|
return cmp_changed;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
bool SYMBOL_VIEWER_FRAME::ReCreateSymbolList()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
if( m_symbolList == nullptr )
|
2017-07-17 20:57:15 +00:00
|
|
|
return false;
|
2009-04-10 13:39:03 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
m_symbolList->Clear();
|
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
wxString libName = m_currentSymbol.GetUniStringLibNickname();
|
|
|
|
|
|
|
|
if( libName.IsEmpty() )
|
2022-07-09 18:41:03 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
std::vector<LIB_SYMBOL*> symbols;
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE_ROW* row = PROJECT_SCH::SchSymbolLibTable( &Prj() )->FindRow( libName );
|
2017-09-02 18:12:50 +00:00
|
|
|
|
2017-11-12 13:23:46 +00:00
|
|
|
try
|
|
|
|
{
|
2023-01-23 00:25:15 +00:00
|
|
|
if( row )
|
2023-09-28 03:04:53 +00:00
|
|
|
PROJECT_SCH::SchSymbolLibTable( &Prj() )->LoadSymbolLib( symbols, libName, m_listPowerOnly );
|
2017-11-12 13:23:46 +00:00
|
|
|
}
|
2018-04-18 07:10:29 +00:00
|
|
|
catch( const IO_ERROR& ) {} // ignore, it is handled below
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
std::set<wxString> excludes;
|
|
|
|
|
|
|
|
if( !m_symbolFilter->GetValue().IsEmpty() )
|
|
|
|
{
|
|
|
|
wxStringTokenizer tokenizer( m_symbolFilter->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 );
|
2022-07-09 18:41:03 +00:00
|
|
|
|
|
|
|
for( LIB_SYMBOL* symbol : symbols )
|
|
|
|
{
|
2023-05-01 20:26:29 +00:00
|
|
|
std::vector<SEARCH_TERM> searchTerms = symbol->GetSearchTerms();
|
|
|
|
int matched = matcher.ScoreTerms( searchTerms );
|
2022-07-09 18:41:03 +00:00
|
|
|
|
2023-05-01 20:26:29 +00:00
|
|
|
if( filterTerm.IsNumber() && wxAtoi( filterTerm ) == (int)symbol->GetPinCount() )
|
|
|
|
matched++;
|
2022-07-09 18:41:03 +00:00
|
|
|
|
|
|
|
if( !matched )
|
|
|
|
excludes.insert( symbol->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
wxString subLib = m_currentSymbol.GetSubLibraryName();
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
for( const LIB_SYMBOL* symbol : symbols )
|
|
|
|
{
|
2023-01-23 03:44:01 +00:00
|
|
|
if( row && row->SupportsSubLibraries()
|
2023-01-23 00:25:15 +00:00
|
|
|
&& !subLib.IsSameAs( symbol->GetLibId().GetSubLibraryName() ) )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
if( !excludes.count( symbol->GetName() ) )
|
|
|
|
m_symbolList->Append( UnescapeString( symbol->GetName() ) );
|
|
|
|
}
|
2018-10-30 16:51:12 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
if( m_symbolList->IsEmpty() )
|
2009-10-01 14:17:47 +00:00
|
|
|
{
|
2023-01-21 10:29:01 +00:00
|
|
|
SetSelectedSymbol( wxEmptyString );
|
2019-04-15 13:59:36 +00:00
|
|
|
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
2009-10-01 14:17:47 +00:00
|
|
|
m_unit = 1;
|
2017-07-17 20:57:15 +00:00
|
|
|
return true;
|
2009-10-01 14:17:47 +00:00
|
|
|
}
|
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
int index = m_symbolList->FindString( UnescapeString( m_currentSymbol.GetUniStringLibItemName() ) );
|
2017-07-17 20:57:15 +00:00
|
|
|
bool changed = false;
|
2009-10-01 14:17:47 +00:00
|
|
|
|
|
|
|
if( index == wxNOT_FOUND )
|
|
|
|
{
|
2016-10-21 12:38:08 +00:00
|
|
|
// Select the first library entry when the previous entry name does not exist in
|
|
|
|
// the current library.
|
2019-04-15 13:59:36 +00:00
|
|
|
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
2016-10-21 12:38:08 +00:00
|
|
|
m_unit = 1;
|
2023-01-21 10:29:01 +00:00
|
|
|
index = -1;
|
2017-07-17 20:57:15 +00:00
|
|
|
changed = true;
|
2023-01-21 10:29:01 +00:00
|
|
|
SetSelectedSymbol( wxEmptyString );
|
2009-10-01 14:17:47 +00:00
|
|
|
}
|
2016-10-21 12:38:08 +00:00
|
|
|
|
2020-12-17 23:56:47 +00:00
|
|
|
m_symbolList->SetSelection( index, true );
|
2016-10-21 12:38:08 +00:00
|
|
|
|
2017-07-17 20:57:15 +00:00
|
|
|
return changed;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-01-19 16:36:12 +00:00
|
|
|
int ii = m_libList->GetSelection();
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
2017-07-17 20:57:15 +00:00
|
|
|
m_selection_changed = true;
|
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
wxString selection = EscapeString( m_libList->GetBaseString( ii ), CTX_LIBID );
|
|
|
|
|
2023-09-28 03:04:53 +00:00
|
|
|
if( !PROJECT_SCH::SchSymbolLibTable( &Prj() )->FindRow( selection )
|
2023-01-23 00:25:15 +00:00
|
|
|
&& selection.Find( '-' ) != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
// Probably a sub-library
|
|
|
|
wxString sublib;
|
|
|
|
selection = selection.BeforeLast( '-', &sublib ).Trim();
|
|
|
|
sublib.Trim( false );
|
|
|
|
SetSelectedLibrary( selection, sublib );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetSelectedLibrary( selection );
|
|
|
|
}
|
2014-02-24 10:52:08 +00:00
|
|
|
}
|
|
|
|
|
2010-11-20 21:59:00 +00:00
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::SetSelectedLibrary( const wxString& aLibraryName,
|
|
|
|
const wxString& aSubLibName )
|
2014-02-24 10:52:08 +00:00
|
|
|
{
|
2023-06-08 01:11:27 +00:00
|
|
|
if( m_currentSymbol.GetUniStringLibNickname() == aLibraryName
|
|
|
|
&& wxString( m_currentSymbol.GetSubLibraryName().wx_str() ) == aSubLibName )
|
2008-04-14 19:22:48 +00:00
|
|
|
return;
|
2010-11-20 21:59:00 +00:00
|
|
|
|
2023-01-23 00:25:15 +00:00
|
|
|
m_currentSymbol.SetLibNickname( aLibraryName );
|
|
|
|
m_currentSymbol.SetSubLibraryName( aSubLibName );
|
2020-12-17 23:56:47 +00:00
|
|
|
ReCreateSymbolList();
|
2019-05-31 17:37:07 +00:00
|
|
|
GetCanvas()->Refresh();
|
2008-04-14 19:22:48 +00:00
|
|
|
DisplayLibInfos();
|
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
|
|
|
|
2014-02-24 19:07:24 +00:00
|
|
|
// Ensure the corresponding line in m_libList is selected
|
|
|
|
// (which is not necessary the case if SetSelectedLibrary is called
|
2018-04-08 10:28:59 +00:00
|
|
|
// by another caller than ClickOnLibList.
|
2023-01-23 00:25:15 +00:00
|
|
|
m_libList->SetStringSelection( UnescapeString( m_currentSymbol.GetFullLibraryName() ), true );
|
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 );
|
2019-08-30 14:00:16 +00:00
|
|
|
m_libList->SetFocus();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::ClickOnSymbolList( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-12-17 23:56:47 +00:00
|
|
|
int ii = m_symbolList->GetSelection();
|
2008-04-14 19:22:48 +00:00
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
2017-07-17 20:57:15 +00:00
|
|
|
m_selection_changed = true;
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
SetSelectedSymbol( EscapeString( m_symbolList->GetBaseString( ii ), CTX_LIBID ) );
|
2020-05-03 18:11:33 +00:00
|
|
|
|
2020-12-17 23:56:47 +00:00
|
|
|
// The m_symbolList has now the focus, in order to be able to use arrow keys
|
2020-05-03 18:11:33 +00:00
|
|
|
// to navigate inside the list.
|
|
|
|
// the gal canvas must not steal the focus to allow navigation
|
|
|
|
GetCanvas()->SetStealsFocus( false );
|
2020-12-17 23:56:47 +00:00
|
|
|
m_symbolList->SetFocus();
|
2014-02-24 10:52:08 +00:00
|
|
|
}
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2014-02-24 10:52:08 +00:00
|
|
|
|
2021-03-19 20:27:30 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::SetSelectedSymbol( const wxString& aSymbolName )
|
2014-02-24 10:52:08 +00:00
|
|
|
{
|
2023-01-23 00:25:15 +00:00
|
|
|
if( m_currentSymbol.GetUniStringLibItemName() != aSymbolName )
|
2009-10-01 14:17:47 +00:00
|
|
|
{
|
2023-01-23 00:25:15 +00:00
|
|
|
m_currentSymbol.SetLibItemName( aSymbolName );
|
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-12-17 23:56:47 +00:00
|
|
|
// Ensure the corresponding line in m_symbolList is selected
|
2021-03-19 20:27:30 +00:00
|
|
|
// (which is not necessarily the case if SetSelectedSymbol is called
|
2022-07-09 18:41:03 +00:00
|
|
|
// by another caller than ClickOnSymbolList.
|
2021-07-01 21:00:46 +00:00
|
|
|
m_symbolList->SetStringSelection( UnescapeString( aSymbolName ), true );
|
2009-10-01 14:17:47 +00:00
|
|
|
DisplayLibInfos();
|
2017-07-17 20:57:15 +00:00
|
|
|
|
|
|
|
if( m_selection_changed )
|
|
|
|
{
|
|
|
|
m_unit = 1;
|
2019-04-15 13:59:36 +00:00
|
|
|
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
2017-07-17 20:57:15 +00:00
|
|
|
m_selection_changed = false;
|
|
|
|
}
|
|
|
|
|
2018-08-29 18:31:43 +00:00
|
|
|
updatePreviewSymbol();
|
2009-10-01 14:17:47 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-02-24 10:52:08 +00:00
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::DClickOnSymbolList( wxCommandEvent& event )
|
2012-12-04 19:04:04 +00:00
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( EE_ACTIONS::addSymbolToSchematic );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2009-04-10 13:39:03 +00:00
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2009-04-10 13:39:03 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
2018-12-06 23:45:38 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
SCH_BASE_FRAME::LoadSettings( cfg );
|
2018-12-06 23:45:38 +00:00
|
|
|
|
|
|
|
// Grid shape, etc.
|
2020-01-13 01:44:19 +00:00
|
|
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
|
2018-12-06 23:45:38 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_libListWidth = cfg->m_LibViewPanel.lib_list_width;
|
2020-12-17 23:56:47 +00:00
|
|
|
m_symbolListWidth = cfg->m_LibViewPanel.cmp_list_width;
|
2020-05-22 23:11:04 +00:00
|
|
|
|
|
|
|
GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type;
|
2022-09-06 16:28:44 +00:00
|
|
|
GetRenderSettings()->m_ShowPinNumbers = cfg->m_LibViewPanel.show_pin_numbers;
|
2009-04-11 15:12:58 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Set parameters to a reasonable value.
|
2022-07-11 03:00:46 +00:00
|
|
|
int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
|
2009-04-10 13:39:03 +00:00
|
|
|
|
2022-07-11 03:00:46 +00:00
|
|
|
if( m_libListWidth + m_symbolListWidth > maxWidth )
|
|
|
|
{
|
|
|
|
m_libListWidth = maxWidth * ( m_libListWidth / ( m_libListWidth + m_symbolListWidth ) );
|
|
|
|
m_symbolListWidth = maxWidth - m_libListWidth;
|
|
|
|
}
|
2009-04-10 13:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg)
|
2009-04-10 13:39:03 +00:00
|
|
|
{
|
2020-05-22 23:11:04 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
SCH_BASE_FRAME::SaveSettings( cfg );
|
2009-04-10 13:39:03 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
if( m_libListWidth && m_libList )
|
2014-01-19 16:36:12 +00:00
|
|
|
m_libListWidth = m_libList->GetSize().x;
|
2010-11-20 21:59:00 +00:00
|
|
|
|
2020-12-17 23:56:47 +00:00
|
|
|
m_symbolListWidth = m_symbolList->GetSize().x;
|
2016-11-04 11:13:22 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
cfg->m_LibViewPanel.lib_list_width = m_libListWidth;
|
2020-12-17 23:56:47 +00:00
|
|
|
cfg->m_LibViewPanel.cmp_list_width = m_symbolListWidth;
|
2021-11-22 19:47:17 +00:00
|
|
|
|
2022-09-06 16:28:44 +00:00
|
|
|
if( KIGFX::SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings() )
|
|
|
|
{
|
|
|
|
cfg->m_LibViewPanel.show_pin_electrical_type = renderSettings->m_ShowPinsElectricalType;
|
|
|
|
cfg->m_LibViewPanel.show_pin_numbers = renderSettings->m_ShowPinNumbers;
|
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
WINDOW_SETTINGS* SYMBOL_VIEWER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
2023-09-28 17:18:19 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
wxASSERT( cfg );
|
|
|
|
return &cfg->m_LibViewPanel.window;
|
2009-04-10 13:39:03 +00:00
|
|
|
}
|
2009-12-22 20:08:56 +00:00
|
|
|
|
2011-11-07 19:04:24 +00:00
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2019-06-24 09:22:49 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2019-06-24 09:22:49 +00:00
|
|
|
|
2023-09-28 17:18:19 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
2021-08-29 23:33:08 +00:00
|
|
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
|
|
|
|
|
2021-01-31 15:28:37 +00:00
|
|
|
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
|
|
|
|
GetCanvas()->GetGAL()->DrawGrid();
|
2021-08-29 23:33:08 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
2021-01-31 15:28:37 +00:00
|
|
|
|
2019-06-24 09:22:49 +00:00
|
|
|
if( aEnvVarsChanged )
|
2020-12-17 23:56:47 +00:00
|
|
|
ReCreateLibList();
|
2019-06-24 09:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
|
2009-12-22 20:08:56 +00:00
|
|
|
{
|
2019-08-27 12:51:01 +00:00
|
|
|
if( event.GetActive() )
|
|
|
|
{
|
2020-12-17 23:56:47 +00:00
|
|
|
bool changed = m_libList ? ReCreateLibList() : false;
|
2017-07-17 20:57:15 +00:00
|
|
|
|
2019-08-27 12:51:01 +00:00
|
|
|
if (changed)
|
|
|
|
m_selection_changed = true;
|
2010-11-20 21:59:00 +00:00
|
|
|
|
2019-08-27 12:51:01 +00:00
|
|
|
updatePreviewSymbol();
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2019-08-27 12:51:01 +00:00
|
|
|
DisplayLibInfos();
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip(); // required under wxMAC
|
2009-12-22 20:08:56 +00:00
|
|
|
}
|
2014-10-15 11:40:38 +00:00
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::CloseLibraryViewer( wxCommandEvent& event )
|
2014-10-15 11:40:38 +00:00
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
2015-04-16 15:26:51 +00:00
|
|
|
|
2016-10-21 12:38:08 +00:00
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
const BOX2I SYMBOL_VIEWER_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
|
2018-08-27 13:28:44 +00:00
|
|
|
{
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* symbol = GetSelectedSymbol();
|
2018-08-27 13:28:44 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
if( !symbol )
|
2018-08-27 13:28:44 +00:00
|
|
|
{
|
2022-08-31 12:56:58 +00:00
|
|
|
return BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) );
|
2018-08-27 13:28:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-31 12:56:58 +00:00
|
|
|
std::shared_ptr<LIB_SYMBOL> tmp = symbol->IsAlias() ? symbol->GetParent().lock()
|
|
|
|
: symbol->SharedPtr();
|
2018-09-07 16:13:20 +00:00
|
|
|
|
2022-08-31 12:56:58 +00:00
|
|
|
wxCHECK( tmp, BOX2I( VECTOR2I( -200, -200 ), VECTOR2I( 400, 400 ) ) );
|
2019-11-07 14:09:24 +00:00
|
|
|
|
2022-08-31 12:56:58 +00:00
|
|
|
return tmp->GetUnitBoundingBox( m_unit, m_convert );
|
2018-08-27 13:28:44 +00:00
|
|
|
}
|
2019-02-05 15:06:36 +00:00
|
|
|
}
|
2019-04-15 21:09:14 +00:00
|
|
|
|
|
|
|
|
2022-07-09 18:41:03 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
ReCreateLibList();
|
|
|
|
|
|
|
|
// Required to avoid interaction with SetHint()
|
|
|
|
// See documentation for wxTextEntry::SetHint
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SYMBOL_VIEWER_FRAME::OnSymFilter( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
ReCreateSymbolList();
|
|
|
|
|
|
|
|
// Required to avoid interaction with SetHint()
|
|
|
|
// See documentation for wxTextEntry::SetHint
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SYMBOL_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetKeyCode() == WXK_UP )
|
|
|
|
{
|
|
|
|
if( m_libFilter->HasFocus() || m_libList->HasFocus() )
|
|
|
|
{
|
|
|
|
int prev = m_libList->GetSelection() - 1;
|
|
|
|
|
|
|
|
if( prev >= 0 )
|
|
|
|
{
|
|
|
|
m_libList->SetSelection( prev );
|
|
|
|
m_libList->EnsureVisible( prev );
|
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
ClickOnLibList( dummy );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
onSelectPreviousSymbol( dummy );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_DOWN )
|
|
|
|
{
|
|
|
|
if( m_libFilter->HasFocus() || m_libList->HasFocus() )
|
|
|
|
{
|
|
|
|
int next = m_libList->GetSelection() + 1;
|
|
|
|
|
|
|
|
if( next < (int)m_libList->GetCount() )
|
|
|
|
{
|
|
|
|
m_libList->SetSelection( next );
|
|
|
|
m_libList->EnsureVisible( next );
|
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
ClickOnLibList( dummy );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
onSelectNextSymbol( dummy );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
|
|
|
|
{
|
|
|
|
if( !aEvent.ShiftDown() )
|
|
|
|
m_symbolFilter->SetFocus();
|
|
|
|
else
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
else if( aEvent.GetKeyCode() == WXK_TAB && m_symbolFilter->HasFocus() )
|
|
|
|
{
|
|
|
|
if( aEvent.ShiftDown() )
|
|
|
|
m_libFilter->SetFocus();
|
|
|
|
else
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
2023-03-10 21:24:21 +00:00
|
|
|
else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
|
|
|
|
&& m_symbolList->GetSelection() >= 0 )
|
2022-07-09 18:41:03 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
DClickOnSymbolList( dummy );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::onSelectNextSymbol( wxCommandEvent& aEvent )
|
2019-12-19 14:05:46 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
|
2020-12-17 23:56:47 +00:00
|
|
|
int ii = m_symbolList->GetSelection();
|
2019-12-19 14:05:46 +00:00
|
|
|
|
|
|
|
// Select the next symbol or stop at the end of the list.
|
2020-12-17 23:56:47 +00:00
|
|
|
if( ii != wxNOT_FOUND || ii != (int) m_symbolList->GetCount() - 1 )
|
2019-12-19 14:05:46 +00:00
|
|
|
ii += 1;
|
|
|
|
|
2020-12-17 23:56:47 +00:00
|
|
|
m_symbolList->SetSelection( ii );
|
2019-12-19 14:05:46 +00:00
|
|
|
ProcessEvent( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::onSelectPreviousSymbol( wxCommandEvent& aEvent )
|
2019-12-19 14:05:46 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_SYM_LIST );
|
2020-12-17 23:56:47 +00:00
|
|
|
int ii = m_symbolList->GetSelection();
|
2019-12-19 14:05:46 +00:00
|
|
|
|
|
|
|
// Select the previous symbol or stop at the beginning of list.
|
|
|
|
if( ii != wxNOT_FOUND && ii != 0 )
|
|
|
|
ii -= 1;
|
|
|
|
|
2020-12-17 23:56:47 +00:00
|
|
|
m_symbolList->SetSelection( ii );
|
2019-12-19 14:05:46 +00:00
|
|
|
ProcessEvent( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent )
|
2019-12-19 14:05:46 +00:00
|
|
|
{
|
|
|
|
int ii = m_unitChoice->GetSelection();
|
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_unit = ii + 1;
|
|
|
|
|
|
|
|
updatePreviewSymbol();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
void SYMBOL_VIEWER_FRAME::DisplayLibInfos()
|
2019-12-19 14:05:46 +00:00
|
|
|
{
|
2023-01-23 00:25:15 +00:00
|
|
|
wxString libName = m_currentSymbol.GetUniStringLibNickname();
|
|
|
|
|
|
|
|
if( m_libList && !m_libList->IsEmpty() && !libName.IsEmpty() )
|
2019-12-19 14:05:46 +00:00
|
|
|
{
|
2023-01-23 00:25:15 +00:00
|
|
|
const SYMBOL_LIB_TABLE_ROW* row =
|
2023-09-28 03:04:53 +00:00
|
|
|
PROJECT_SCH::SchSymbolLibTable( &Prj() )->FindRow( libName, true );
|
2019-12-19 14:05:46 +00:00
|
|
|
|
2021-06-20 21:46:41 +00:00
|
|
|
wxString title = row ? row->GetFullURI( true ) : _( "[no library selected]" );
|
|
|
|
|
|
|
|
title += wxT( " \u2014 " ) + _( "Symbol Library Browser" );
|
2019-12-19 14:05:46 +00:00
|
|
|
SetTitle( title );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-06 23:03:58 +00:00
|
|
|
|
2020-12-25 23:37:01 +00:00
|
|
|
SELECTION& SYMBOL_VIEWER_FRAME::GetCurrentSelection()
|
2020-08-06 23:03:58 +00:00
|
|
|
{
|
|
|
|
return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
|
|
|
|
}
|
2023-01-19 00:14:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SYMBOL_VIEWER_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|
|
|
{
|
2023-05-31 20:37:58 +00:00
|
|
|
|
2023-01-19 00:14:31 +00:00
|
|
|
switch( mail.Command() )
|
|
|
|
{
|
|
|
|
case MAIL_RELOAD_LIB:
|
|
|
|
{
|
|
|
|
ReCreateLibList();
|
|
|
|
break;
|
|
|
|
}
|
2023-05-31 20:37:58 +00:00
|
|
|
case MAIL_REFRESH_SYMBOL:
|
|
|
|
{
|
2023-09-28 03:04:53 +00:00
|
|
|
SYMBOL_LIB_TABLE* tbl = PROJECT_SCH::SchSymbolLibTable( &Prj() );
|
2023-05-31 20:37:58 +00:00
|
|
|
LIB_SYMBOL* symbol = GetSelectedSymbol();
|
2023-06-03 11:28:03 +00:00
|
|
|
|
|
|
|
wxCHECK2( tbl && symbol, break );
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
const SYMBOL_LIB_TABLE_ROW* row = tbl->FindRow( symbol->GetLibId().GetLibNickname() );
|
|
|
|
|
|
|
|
if( !row )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString libfullname = row->GetFullURI( true );
|
|
|
|
|
2023-06-03 11:28:03 +00:00
|
|
|
wxString lib( mail.GetPayload() );
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Received refresh symbol request for %s, current symbols "
|
|
|
|
"is %s", lib, libfullname );
|
2023-05-31 20:37:58 +00:00
|
|
|
|
2023-06-03 11:28:03 +00:00
|
|
|
if( lib == libfullname )
|
|
|
|
{
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Refreshing symbol %s", symbol->GetName() );
|
|
|
|
updatePreviewSymbol();
|
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
2023-05-31 20:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2023-01-19 00:14:31 +00:00
|
|
|
default:;
|
|
|
|
}
|
|
|
|
}
|