2011-10-13 20:13:11 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-28 08:51:28 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2019-06-15 16:05:33 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2021-02-09 16:35:43 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 20:13:11 +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
|
|
|
|
*/
|
|
|
|
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <bitmaps.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <eda_dde.h>
|
2013-09-14 20:33:22 +00:00
|
|
|
#include <fp_lib_table.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <kiface_i.h>
|
2020-09-01 10:14:51 +00:00
|
|
|
#include <kiplatform/app.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <kiway_express.h>
|
|
|
|
#include <macros.h>
|
2019-11-17 12:58:38 +00:00
|
|
|
#include <netlist_reader/netlist_reader.h>
|
2019-08-08 21:10:37 +00:00
|
|
|
#include <numeric>
|
2020-07-29 23:50:25 +00:00
|
|
|
#include <tool/action_manager.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
|
|
|
#include <tool/common_control.h>
|
2020-07-29 23:50:25 +00:00
|
|
|
#include <tool/editor_conditions.h>
|
2019-08-08 22:11:59 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2018-02-10 13:32:57 +00:00
|
|
|
#include <widgets/progress_reporter.h>
|
2018-07-17 21:14:02 +00:00
|
|
|
#include <wx/statline.h>
|
2021-06-03 11:49:49 +00:00
|
|
|
#include <wx/stattext.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
|
2019-07-24 20:56:17 +00:00
|
|
|
#include <cvpcb_association.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <cvpcb_id.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
#include <cvpcb_mainframe.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <cvpcb_settings.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <display_footprints_frame.h>
|
2020-06-04 21:54:03 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <listboxes.h>
|
|
|
|
#include <tools/cvpcb_actions.h>
|
2019-08-09 22:13:17 +00:00
|
|
|
#include <tools/cvpcb_association_tool.h>
|
2019-07-18 21:47:01 +00:00
|
|
|
#include <tools/cvpcb_control.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/button.h>
|
2021-05-01 18:04:11 +00:00
|
|
|
#include <wx/settings.h>
|
2018-05-14 17:34:18 +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
|
|
|
|
2021-06-29 11:45:02 +00:00
|
|
|
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
|
2021-06-25 16:41:34 +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
|
|
|
CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
2018-04-04 18:22:28 +00:00
|
|
|
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
|
2019-06-10 22:17:45 +00:00
|
|
|
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
m_symbolsListBox = nullptr;
|
|
|
|
m_footprintListBox = nullptr;
|
|
|
|
m_librariesListBox = nullptr;
|
|
|
|
m_mainToolBar = nullptr;
|
2020-08-15 16:40:58 +00:00
|
|
|
m_modified = false;
|
2021-08-06 11:40:30 +00:00
|
|
|
m_cannotClose = false;
|
2020-08-15 16:40:58 +00:00
|
|
|
m_skipComponentSelect = false;
|
|
|
|
m_filteringOptions = FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST;
|
2021-07-16 20:13:26 +00:00
|
|
|
m_tcFilterString = nullptr;
|
2021-06-29 11:45:02 +00:00
|
|
|
m_FootprintsList = FOOTPRINT_LIST::GetInstance( Kiway() );
|
2020-08-15 16:40:58 +00:00
|
|
|
m_initialized = false;
|
2020-11-16 11:16:44 +00:00
|
|
|
m_aboutTitle = "CvPcb";
|
2013-09-14 20:33:22 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_cvpcb ) );
|
2011-09-09 19:30:59 +00:00
|
|
|
SetIcon( icon );
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
SetAutoLayout( true );
|
2007-12-04 18:23:38 +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
|
|
|
LoadSettings( config() );
|
2011-08-24 19:44:05 +00:00
|
|
|
|
2019-07-18 21:47:01 +00:00
|
|
|
setupTools();
|
2020-07-29 23:50:25 +00:00
|
|
|
setupUIConditions();
|
2007-12-04 18:23:38 +00:00
|
|
|
ReCreateMenuBar();
|
2007-05-06 16:03:28 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Create list of available footprints and symbols of the schematic
|
|
|
|
BuildSymbolsListBox();
|
|
|
|
BuildFootprintsListBox();
|
|
|
|
BuildLibrariesListBox();
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-11-05 19:26:52 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-05 08:52:41 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
m_auimgr.AddPane( m_librariesListBox, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(1)
|
2018-08-11 16:04:46 +00:00
|
|
|
.Caption( _( "Footprint Libraries" ) )
|
2020-11-16 11:16:44 +00:00
|
|
|
.BestSize((int) ( m_frameSize.x * 0.20 ), m_frameSize.y ) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
m_auimgr.AddPane( m_symbolsListBox, EDA_PANE().Palette().Name( "Symbols" ).Center().Layer(0)
|
2018-08-11 16:04:46 +00:00
|
|
|
.Caption( _( "Symbol : Footprint Assignments" ) ) );
|
2009-11-05 08:52:41 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( "Footprints" ).Right().Layer(1)
|
|
|
|
.Caption( _( "Filtered Footprints" ) )
|
2020-11-16 11:16:44 +00:00
|
|
|
.BestSize((int) ( m_frameSize.x * 0.30 ), m_frameSize.y ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2018-04-18 21:26:18 +00:00
|
|
|
// Build the bottom panel, to display 2 status texts and the buttons:
|
2018-03-24 18:28:35 +00:00
|
|
|
auto bottomPanel = new wxPanel( this );
|
2018-04-18 07:25:14 +00:00
|
|
|
auto panelSizer = new wxBoxSizer( wxVERTICAL );
|
2018-07-17 21:14:02 +00:00
|
|
|
|
2019-08-09 22:48:58 +00:00
|
|
|
wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 3, 1, 0, 0 );
|
2018-07-17 21:14:02 +00:00
|
|
|
fgSizerStatus->SetFlexibleDirection( wxBOTH );
|
|
|
|
fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
|
|
|
m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
|
2018-07-18 16:59:05 +00:00
|
|
|
fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
|
|
|
m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
|
2019-08-09 22:48:58 +00:00
|
|
|
fgSizerStatus->Add( m_statusLine2, 0, 0, 5 );
|
|
|
|
|
|
|
|
m_statusLine3 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
|
|
|
|
fgSizerStatus->Add( m_statusLine3, 0, wxBOTTOM, 3 );
|
2018-07-17 21:14:02 +00:00
|
|
|
|
2018-07-18 16:59:05 +00:00
|
|
|
panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
|
2018-07-17 21:14:02 +00:00
|
|
|
|
|
|
|
wxStaticLine* staticline1 = new wxStaticLine( bottomPanel );
|
|
|
|
panelSizer->Add( staticline1, 0, wxEXPAND, 5 );
|
|
|
|
|
2021-06-29 17:27:05 +00:00
|
|
|
m_statusLine1->SetFont( KIUI::GetInfoFont() );
|
|
|
|
m_statusLine2->SetFont( KIUI::GetInfoFont() );
|
|
|
|
m_statusLine3->SetFont( KIUI::GetInfoFont() );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2018-04-18 07:25:14 +00:00
|
|
|
// Add buttons:
|
|
|
|
auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
auto sdbSizer = new wxStdDialogButtonSizer();
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2021-04-01 10:04:59 +00:00
|
|
|
m_saveAndContinue = new wxButton( bottomPanel, wxID_ANY,
|
2018-04-18 21:26:18 +00:00
|
|
|
_( "Apply, Save Schematic && Continue" ) );
|
2018-07-17 21:14:02 +00:00
|
|
|
buttonsSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2018-04-18 07:25:14 +00:00
|
|
|
auto sdbSizerOK = new wxButton( bottomPanel, wxID_OK );
|
|
|
|
sdbSizer->AddButton( sdbSizerOK );
|
|
|
|
auto sdbSizerCancel = new wxButton( bottomPanel, wxID_CANCEL );
|
|
|
|
sdbSizer->AddButton( sdbSizerCancel );
|
|
|
|
sdbSizer->Realize();
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2018-04-18 21:26:18 +00:00
|
|
|
buttonsSizer->Add( sdbSizer, 0, 0, 5 );
|
2018-07-17 21:14:02 +00:00
|
|
|
panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
|
|
|
bottomPanel->SetSizer( panelSizer );
|
|
|
|
bottomPanel->Fit();
|
|
|
|
|
2018-04-18 07:25:14 +00:00
|
|
|
sdbSizerOK->SetDefault();
|
2020-06-04 21:26:15 +00:00
|
|
|
KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( this );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2018-03-25 23:52:02 +00:00
|
|
|
m_initialized = true;
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2020-10-09 20:29:19 +00:00
|
|
|
if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() ) )
|
|
|
|
{
|
|
|
|
if( cfg->m_LibrariesWidth > 0 )
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& librariesPane = m_auimgr.GetPane( "Libraries" );
|
|
|
|
|
|
|
|
// wxAUI hack: force width by setting MinSize() and then Fixed()
|
|
|
|
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
|
|
|
|
librariesPane.MinSize( cfg->m_LibrariesWidth, -1 );
|
|
|
|
librariesPane.BestSize( cfg->m_LibrariesWidth, -1 );
|
|
|
|
librariesPane.MaxSize( cfg->m_LibrariesWidth, -1 );
|
|
|
|
librariesPane.Fixed();
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// now make it resizable again
|
|
|
|
librariesPane.MinSize( 20, -1 );
|
|
|
|
librariesPane.Resizable();
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( cfg->m_FootprintsWidth > 0 )
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& footprintsPane = m_auimgr.GetPane( "Footprints" );
|
|
|
|
|
|
|
|
// wxAUI hack: force width by setting MinSize() and then Fixed()
|
|
|
|
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
|
|
|
|
footprintsPane.MinSize( cfg->m_FootprintsWidth, -1 );
|
|
|
|
footprintsPane.BestSize( cfg->m_FootprintsWidth, -1 );
|
|
|
|
footprintsPane.MaxSize( cfg->m_FootprintsWidth, -1 );
|
|
|
|
footprintsPane.Fixed();
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
// now make it resizable again
|
|
|
|
footprintsPane.MinSize( 20, -1 );
|
|
|
|
footprintsPane.Resizable();
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
// Connect Events
|
2019-08-08 22:11:59 +00:00
|
|
|
setupEventHandlers();
|
|
|
|
|
|
|
|
// Start the main processing loop
|
|
|
|
m_toolManager->InvokeTool( "cvpcb.Control" );
|
2019-07-18 21:47:01 +00:00
|
|
|
|
2020-09-01 10:14:51 +00:00
|
|
|
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Symbol to footprint changes are unsaved" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-02-03 14:00:48 +00:00
|
|
|
// Shutdown all running tools
|
2019-08-11 08:47:51 +00:00
|
|
|
if( m_toolManager )
|
2020-02-03 14:00:48 +00:00
|
|
|
m_toolManager->ShutdownAllTools();
|
2019-08-11 08:47:51 +00:00
|
|
|
|
2019-08-10 09:17:42 +00:00
|
|
|
// Clean up the tool infrastructure
|
|
|
|
delete m_actions;
|
|
|
|
delete m_toolManager;
|
|
|
|
delete m_toolDispatcher;
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.UnInit();
|
2009-04-23 15:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-18 21:47:01 +00:00
|
|
|
void CVPCB_MAINFRAME::setupTools()
|
|
|
|
{
|
|
|
|
// Create the manager
|
2019-08-08 22:11:59 +00:00
|
|
|
m_actions = new CVPCB_ACTIONS();
|
2019-07-18 21:47:01 +00:00
|
|
|
m_toolManager = new TOOL_MANAGER;
|
2020-06-12 10:58:56 +00:00
|
|
|
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2019-07-18 21:47:01 +00:00
|
|
|
|
|
|
|
// Register tools
|
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
|
|
|
m_toolManager->RegisterTool( new CVPCB_CONTROL );
|
2019-08-09 22:13:17 +00:00
|
|
|
m_toolManager->RegisterTool( new CVPCB_ASSOCIATION_TOOL );
|
2019-07-18 21:47:01 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
|
|
|
CVPCB_CONTROL* tool = m_toolManager->GetTool<CVPCB_CONTROL>();
|
|
|
|
|
2019-10-06 10:19:41 +00:00
|
|
|
// Even though these menus will open with the right-click, we treat them as a normal
|
|
|
|
// menu instead of a context menu because we don't care about their position and want
|
|
|
|
// to be able to tell the difference between a menu click and a hotkey activation.
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Create the context menu for the symbols list box
|
|
|
|
m_symbolsContextMenu = new ACTION_MENU( false, tool );
|
|
|
|
m_symbolsContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
|
|
|
m_symbolsContextMenu->AppendSeparator();
|
|
|
|
m_symbolsContextMenu->Add( ACTIONS::cut );
|
|
|
|
m_symbolsContextMenu->Add( ACTIONS::copy );
|
|
|
|
m_symbolsContextMenu->Add( ACTIONS::paste );
|
|
|
|
m_symbolsContextMenu->AppendSeparator();
|
|
|
|
m_symbolsContextMenu->Add( CVPCB_ACTIONS::deleteAssoc );
|
2019-07-18 21:47:01 +00:00
|
|
|
|
|
|
|
// Create the context menu for the footprint list box
|
2021-03-27 19:16:58 +00:00
|
|
|
m_footprintContextMenu = new ACTION_MENU( false, tool );
|
2019-07-18 21:47:01 +00:00
|
|
|
m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
|
|
|
}
|
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
void CVPCB_MAINFRAME::setupUIConditions()
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
EDITOR_CONDITIONS cond( this );
|
|
|
|
|
|
|
|
wxASSERT( mgr );
|
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
|
|
|
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( CVPCB_ACTIONS::saveAssociations, ENABLE( cond.ContentModified() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
auto compFilter =
|
2020-11-07 14:31:50 +00:00
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS;
|
|
|
|
};
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
auto libFilter =
|
2020-11-07 14:31:50 +00:00
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY;
|
|
|
|
};
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
auto pinFilter =
|
2020-11-07 14:31:50 +00:00
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT;
|
|
|
|
};
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( CVPCB_ACTIONS::FilterFPbyFPFilters, CHECK( compFilter ) );
|
|
|
|
mgr->SetConditions( CVPCB_ACTIONS::FilterFPbyLibrary, CHECK( libFilter ) );
|
|
|
|
mgr->SetConditions( CVPCB_ACTIONS::filterFPbyPin, CHECK( pinFilter ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
#undef CHECK
|
|
|
|
#undef ENABLE
|
2020-07-29 23:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-08 22:11:59 +00:00
|
|
|
void CVPCB_MAINFRAME::setupEventHandlers()
|
|
|
|
{
|
|
|
|
// Connect the handlers to launch the context menus in the listboxes
|
|
|
|
m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
|
|
|
|
[this]( wxMouseEvent& )
|
|
|
|
{
|
|
|
|
PopupMenu( m_footprintContextMenu );
|
|
|
|
} );
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->Bind( wxEVT_RIGHT_DOWN,
|
2019-08-08 22:11:59 +00:00
|
|
|
[this]( wxMouseEvent& )
|
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
PopupMenu( m_symbolsContextMenu );
|
2019-08-08 22:11:59 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
// Connect the handler for the save button
|
|
|
|
m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
[this]( wxCommandEvent& )
|
|
|
|
{
|
2019-10-06 10:19:41 +00:00
|
|
|
// saveAssociations must be run immediately
|
2021-02-09 16:35:43 +00:00
|
|
|
GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
|
2019-08-08 22:11:59 +00:00
|
|
|
} );
|
|
|
|
|
2019-08-10 09:17:42 +00:00
|
|
|
// Connect the handlers for the ok/cancel buttons
|
|
|
|
Bind( wxEVT_BUTTON,
|
|
|
|
[this]( wxCommandEvent& )
|
|
|
|
{
|
2019-10-06 10:19:41 +00:00
|
|
|
// saveAssociations must be run immediately, before running Close( true )
|
2021-02-09 16:35:43 +00:00
|
|
|
GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
|
2019-08-10 09:17:42 +00:00
|
|
|
Close( true );
|
|
|
|
}, wxID_OK );
|
|
|
|
Bind( wxEVT_BUTTON,
|
|
|
|
[this]( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
Close( false );
|
|
|
|
}, wxID_CANCEL );
|
|
|
|
|
|
|
|
// Connect the handlers for the close events
|
|
|
|
Bind( wxEVT_MENU,
|
|
|
|
[this]( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
Close( false );
|
|
|
|
}, wxID_CLOSE );
|
|
|
|
Bind( wxEVT_MENU,
|
|
|
|
[this]( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
Close( false );
|
|
|
|
}, wxID_EXIT );
|
|
|
|
|
|
|
|
// Toolbar events
|
|
|
|
Bind( wxEVT_TEXT, &CVPCB_MAINFRAME::OnEnterFilteringText, this, ID_CVPCB_FILTER_TEXT_EDIT );
|
|
|
|
|
|
|
|
// Just skip the resize events
|
|
|
|
Bind( wxEVT_SIZE,
|
2020-11-07 14:31:50 +00:00
|
|
|
[]( wxSizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
} );
|
2019-08-10 09:17:42 +00:00
|
|
|
|
2019-08-08 22:11:59 +00:00
|
|
|
// Attach the events to the tool dispatcher
|
|
|
|
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
|
|
|
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-23 15:02:18 +00:00
|
|
|
if( m_modified )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2019-12-19 14:11:11 +00:00
|
|
|
// Shutdown blocks must be determined and vetoed as early as possible
|
2020-09-01 10:14:51 +00:00
|
|
|
if( KIPLATFORM::APP::SupportsShutdownBlockReason()
|
|
|
|
&& aEvent.GetId() == wxEVT_QUERY_END_SESSION )
|
2019-12-19 14:11:11 +00:00
|
|
|
{
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2019-12-19 14:11:11 +00:00
|
|
|
}
|
|
|
|
|
2019-06-15 16:05:33 +00:00
|
|
|
if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. "
|
2019-06-17 15:59:39 +00:00
|
|
|
"Save changes?" ),
|
2020-11-07 14:31:50 +00:00
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
return SaveFootprintAssociation( false );
|
|
|
|
} ) )
|
2007-12-04 18:23:38 +00:00
|
|
|
{
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-06 11:40:30 +00:00
|
|
|
if( m_cannotClose )
|
|
|
|
return false;
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVPCB_MAINFRAME::doCloseWindow()
|
|
|
|
{
|
2016-01-06 07:36:08 +00:00
|
|
|
if( GetFootprintViewerFrame() )
|
|
|
|
GetFootprintViewerFrame()->Close( true );
|
2011-08-24 19:44:05 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
m_modified = false;
|
2014-01-29 17:01:42 +00:00
|
|
|
|
2018-12-29 08:39:08 +00:00
|
|
|
// clear highlight symbol in schematic:
|
|
|
|
SendMessageToEESCHEMA( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-10 09:17:42 +00:00
|
|
|
void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-08-10 09:17:42 +00:00
|
|
|
// Called when changing the filter string in main toolbar.
|
2019-09-03 18:28:54 +00:00
|
|
|
// If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
|
|
|
|
// of available footprints which match the filter
|
2019-08-10 09:17:42 +00:00
|
|
|
|
|
|
|
wxListEvent l_event;
|
|
|
|
OnSelectComponent( l_event );
|
2018-03-24 18:28:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-10 09:17:42 +00:00
|
|
|
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
|
2018-03-24 18:28:35 +00:00
|
|
|
{
|
2019-08-10 09:17:42 +00:00
|
|
|
if( m_skipComponentSelect )
|
|
|
|
return;
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2019-08-10 09:17:42 +00:00
|
|
|
wxString libraryName;
|
2021-03-29 10:46:05 +00:00
|
|
|
COMPONENT* symbol = GetSelectedComponent();
|
|
|
|
libraryName = m_librariesListBox->GetSelectedLibrary();
|
2019-08-10 09:17:42 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
|
2020-07-09 13:21:28 +00:00
|
|
|
m_tcFilterString->GetValue(), m_filteringOptions );
|
2019-08-10 09:17:42 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
if( symbol && symbol->GetFPID().IsValid() )
|
|
|
|
m_footprintListBox->SetSelectedFootprint( symbol->GetFPID() );
|
2019-08-10 09:17:42 +00:00
|
|
|
else
|
|
|
|
m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
refreshAfterSymbolSearch( symbol );
|
2018-03-24 18:28:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void CVPCB_MAINFRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2018-03-24 18:28:35 +00:00
|
|
|
{
|
2019-08-10 09:17:42 +00:00
|
|
|
EDA_BASE_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2020-11-07 14:31:50 +00:00
|
|
|
CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_filteringOptions = cfg->m_FilterFootprint;
|
2019-08-10 09:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void CVPCB_MAINFRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2019-08-10 09:17:42 +00:00
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::SaveSettings( aCfg );
|
|
|
|
|
2020-11-07 14:31:50 +00:00
|
|
|
CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
cfg->m_FilterFootprint = m_filteringOptions;
|
2020-10-09 20:29:19 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
cfg->m_LibrariesWidth = m_librariesListBox->GetSize().x;
|
2020-10-09 20:29:19 +00:00
|
|
|
cfg->m_FootprintsWidth = m_footprintListBox->GetSize().x;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2019-07-26 18:58:20 +00:00
|
|
|
void CVPCB_MAINFRAME::UndoAssociation()
|
|
|
|
{
|
|
|
|
if( m_undoList.size() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
CVPCB_UNDO_REDO_ENTRIES redoEntries;
|
|
|
|
CVPCB_UNDO_REDO_ENTRIES curEntry = m_undoList.back();
|
|
|
|
m_undoList.pop_back();
|
|
|
|
|
|
|
|
// Iterate over the entries to undo
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& assoc : curEntry )
|
2019-07-26 18:58:20 +00:00
|
|
|
{
|
|
|
|
AssociateFootprint( assoc, true, false );
|
|
|
|
redoEntries.emplace_back( assoc.Reverse() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the redo entries to the redo stack
|
|
|
|
m_redoList.emplace_back( redoEntries );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVPCB_MAINFRAME::RedoAssociation()
|
|
|
|
{
|
|
|
|
if( m_redoList.size() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
CVPCB_UNDO_REDO_ENTRIES curEntry = m_redoList.back();
|
|
|
|
m_redoList.pop_back();
|
|
|
|
|
|
|
|
// Iterate over the entries to undo
|
|
|
|
bool firstAssoc = true;
|
2020-11-07 14:31:50 +00:00
|
|
|
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& assoc : curEntry )
|
2019-07-26 18:58:20 +00:00
|
|
|
{
|
|
|
|
AssociateFootprint( assoc, firstAssoc );
|
|
|
|
firstAssoc = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
|
|
|
|
bool aNewEntry, bool aAddUndoItem )
|
2019-07-24 20:56:17 +00:00
|
|
|
{
|
|
|
|
if( m_netlist.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
COMPONENT* symbol = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
|
2019-07-24 20:56:17 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( symbol == nullptr )
|
2019-07-24 20:56:17 +00:00
|
|
|
return;
|
|
|
|
|
2019-07-26 18:58:20 +00:00
|
|
|
LIB_ID fpid = aAssociation.GetNewFootprint();
|
2021-03-29 10:46:05 +00:00
|
|
|
LIB_ID oldFpid = symbol->GetFPID();
|
2019-07-24 20:56:17 +00:00
|
|
|
|
|
|
|
// Test for validity of the requested footprint
|
|
|
|
if( !fpid.empty() && !fpid.IsValid() )
|
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
wxString msg = wxString::Format( _( "'%s' is not a valid footprint." ),
|
2020-09-06 16:14:47 +00:00
|
|
|
fpid.Format().wx_str() );
|
2019-07-24 20:56:17 +00:00
|
|
|
DisplayErrorMessage( this, msg );
|
2019-10-06 10:19:41 +00:00
|
|
|
return;
|
2019-07-24 20:56:17 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
const KIID& id = symbol->GetKIIDs().front();
|
2019-07-24 20:56:17 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Set new footprint to all instances of the selected symbol
|
2020-09-06 16:14:47 +00:00
|
|
|
for( unsigned int idx : GetComponentIndices() )
|
|
|
|
{
|
|
|
|
COMPONENT* candidate = m_netlist.GetComponent( idx );
|
2021-02-22 19:21:10 +00:00
|
|
|
const std::vector<KIID>& kiids = candidate->GetKIIDs();
|
2020-09-06 16:14:47 +00:00
|
|
|
|
2021-02-22 19:21:10 +00:00
|
|
|
if( std::find( kiids.begin(), kiids.end(), id ) != kiids.end() )
|
2020-09-06 16:14:47 +00:00
|
|
|
{
|
|
|
|
// Set the new footprint
|
|
|
|
candidate->SetFPID( fpid );
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// create the new symbol description and set it
|
2020-09-06 16:14:47 +00:00
|
|
|
wxString description = wxString::Format( CMP_FORMAT,
|
|
|
|
idx + 1,
|
|
|
|
candidate->GetReference(),
|
|
|
|
candidate->GetValue(),
|
|
|
|
candidate->GetFPID().Format().wx_str() );
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->SetString( idx, description );
|
2020-09-06 16:14:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-24 20:56:17 +00:00
|
|
|
|
|
|
|
// Mark the data as being modified
|
|
|
|
m_modified = true;
|
|
|
|
|
|
|
|
// Update the statusbar and refresh the list
|
|
|
|
DisplayStatus();
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->Refresh();
|
2019-07-26 18:58:20 +00:00
|
|
|
|
|
|
|
if( !aAddUndoItem )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Update the undo list
|
|
|
|
if ( aNewEntry )
|
|
|
|
{
|
|
|
|
// Create a new entry for this association
|
|
|
|
CVPCB_UNDO_REDO_ENTRIES newEntry;
|
2020-11-07 14:31:50 +00:00
|
|
|
newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
|
|
|
|
aAssociation.GetNewFootprint() ) );
|
2019-07-26 18:58:20 +00:00
|
|
|
m_undoList.emplace_back( newEntry );
|
|
|
|
|
|
|
|
// Clear the redo list
|
|
|
|
m_redoList.clear();
|
|
|
|
}
|
|
|
|
else
|
2020-11-07 14:31:50 +00:00
|
|
|
{
|
2019-07-26 18:58:20 +00:00
|
|
|
m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
|
2020-11-07 14:31:50 +00:00
|
|
|
oldFpid,
|
|
|
|
aAssociation.GetNewFootprint() ) );
|
|
|
|
}
|
2019-07-26 18:58:20 +00:00
|
|
|
|
2019-07-24 20:56:17 +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
|
|
|
bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
|
|
|
|
{
|
2015-01-01 15:46:11 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
void CVPCB_MAINFRAME::refreshAfterSymbolSearch( COMPONENT* aSymbol )
|
2016-02-24 16:30:35 +00:00
|
|
|
{
|
2016-02-25 09:52:29 +00:00
|
|
|
// Tell AuiMgr that objects are changed !
|
|
|
|
if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
|
2020-11-07 14:31:50 +00:00
|
|
|
m_auimgr.Update(); // (could be not the case when starting CvPcb)
|
2016-02-24 16:30:35 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( aSymbol == nullptr )
|
2018-03-24 18:28:35 +00:00
|
|
|
{
|
|
|
|
DisplayStatus();
|
2016-02-25 09:52:29 +00:00
|
|
|
return;
|
2018-03-24 18:28:35 +00:00
|
|
|
}
|
2016-02-24 16:30:35 +00:00
|
|
|
|
2016-02-25 09:52:29 +00:00
|
|
|
// Preview of the already assigned footprint.
|
2021-03-29 10:46:05 +00:00
|
|
|
// Find the footprint that was already chosen for this aSymbol and select it,
|
|
|
|
// but only if the selection is made from the aSymbol list or the library list.
|
2016-02-25 09:52:29 +00:00
|
|
|
// If the selection is made from the footprint list, do not change the current
|
|
|
|
// selected footprint.
|
2021-03-29 10:46:05 +00:00
|
|
|
if( FindFocus() == m_symbolsListBox || FindFocus() == m_librariesListBox )
|
2016-02-25 09:52:29 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
wxString footprintName = FROM_UTF8( aSymbol->GetFPID().Format().c_str() );
|
2016-02-25 09:52:29 +00:00
|
|
|
|
2018-07-01 15:22:33 +00:00
|
|
|
m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
|
2012-05-25 06:58:52 +00:00
|
|
|
|
2016-02-25 09:52:29 +00:00
|
|
|
for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
|
|
|
|
{
|
2020-11-07 14:31:50 +00:00
|
|
|
wxString candidateName;
|
2016-02-25 09:52:29 +00:00
|
|
|
wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
|
|
|
|
msg.Trim( true );
|
|
|
|
msg.Trim( false );
|
2020-11-07 14:31:50 +00:00
|
|
|
candidateName = msg.AfterFirst( wxChar( ' ' ) );
|
2016-02-24 16:30:35 +00:00
|
|
|
|
2020-11-07 14:31:50 +00:00
|
|
|
if( footprintName.Cmp( candidateName ) == 0 )
|
2012-05-25 06:58:52 +00:00
|
|
|
{
|
2016-02-25 09:52:29 +00:00
|
|
|
m_footprintListBox->SetSelection( ii, true );
|
|
|
|
break;
|
2012-05-25 06:58:52 +00:00
|
|
|
}
|
2016-02-25 09:52:29 +00:00
|
|
|
}
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2018-07-01 15:22:33 +00:00
|
|
|
if( GetFootprintViewerFrame() )
|
2019-07-18 21:47:01 +00:00
|
|
|
m_toolManager->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
|
2016-02-25 09:52:29 +00:00
|
|
|
}
|
2011-12-14 20:23:32 +00:00
|
|
|
|
2016-02-25 09:52:29 +00:00
|
|
|
SendMessageToEESCHEMA();
|
|
|
|
DisplayStatus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-06-15 16:05:33 +00:00
|
|
|
|
2020-01-11 21:14:09 +00:00
|
|
|
void CVPCB_MAINFRAME::SetFootprintFilter( FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter,
|
|
|
|
CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-01-11 21:14:09 +00:00
|
|
|
int option = aFilter;
|
2016-02-25 09:52:29 +00:00
|
|
|
|
2019-07-18 21:47:01 +00:00
|
|
|
// Apply the filter accordingly
|
|
|
|
switch( aAction )
|
|
|
|
{
|
2020-09-06 12:05:07 +00:00
|
|
|
case CVPCB_MAINFRAME::FILTER_DISABLE: m_filteringOptions &= ~option; break;
|
|
|
|
case CVPCB_MAINFRAME::FILTER_ENABLE: m_filteringOptions |= option; break;
|
|
|
|
case CVPCB_MAINFRAME::FILTER_TOGGLE: m_filteringOptions ^= option; break;
|
2016-02-25 09:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxListEvent l_event;
|
2007-12-04 18:23:38 +00:00
|
|
|
OnSelectComponent( l_event );
|
|
|
|
}
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::DisplayStatus()
|
2010-11-07 20:06:07 +00:00
|
|
|
{
|
2018-03-25 23:52:02 +00:00
|
|
|
if( !m_initialized )
|
|
|
|
return;
|
2011-08-04 11:23:19 +00:00
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
wxString filters, msg;
|
2021-03-29 10:46:05 +00:00
|
|
|
COMPONENT* symbol = GetSelectedComponent();
|
2010-11-07 20:06:07 +00:00
|
|
|
|
2019-09-03 18:28:54 +00:00
|
|
|
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS ) )
|
2018-03-24 18:28:35 +00:00
|
|
|
{
|
2013-06-08 16:06:26 +00:00
|
|
|
msg.Empty();
|
2010-11-07 20:06:07 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
if( symbol )
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
for( unsigned ii = 0; ii < symbol->GetFootprintFilters().GetCount(); ii++ )
|
2013-06-08 16:06:26 +00:00
|
|
|
{
|
|
|
|
if( msg.IsEmpty() )
|
2021-03-29 10:46:05 +00:00
|
|
|
msg += symbol->GetFootprintFilters()[ii];
|
2013-06-08 16:06:26 +00:00
|
|
|
else
|
2021-03-29 10:46:05 +00:00
|
|
|
msg += wxT( ", " ) + symbol->GetFootprintFilters()[ii];
|
2013-06-08 16:06:26 +00:00
|
|
|
}
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
|
|
|
|
2020-10-20 20:18:48 +00:00
|
|
|
filters += _( "Keywords" );
|
2020-07-09 13:21:28 +00:00
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
filters += wxString::Format( wxT( " (%s)" ), msg );
|
2013-06-08 16:06:26 +00:00
|
|
|
}
|
2018-03-24 18:28:35 +00:00
|
|
|
|
|
|
|
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) )
|
2013-06-08 16:06:26 +00:00
|
|
|
{
|
2018-03-24 18:28:35 +00:00
|
|
|
msg.Empty();
|
2013-12-09 18:09:58 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
if( symbol )
|
|
|
|
msg = wxString::Format( wxT( "%i" ), symbol->GetPinCount() );
|
2013-06-08 16:06:26 +00:00
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
if( !filters.IsEmpty() )
|
|
|
|
filters += wxT( ", " );
|
2013-06-08 16:06:26 +00:00
|
|
|
|
2020-10-20 20:18:48 +00:00
|
|
|
filters += _( "Pin Count" );
|
2020-07-09 13:21:28 +00:00
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
filters += wxString::Format( wxT( " (%s)" ), msg );
|
2010-11-07 20:06:07 +00:00
|
|
|
}
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) )
|
2011-08-24 19:44:05 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
msg = m_librariesListBox->GetSelectedLibrary();
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
if( !filters.IsEmpty() )
|
|
|
|
filters += wxT( ", " );
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2020-10-20 20:18:48 +00:00
|
|
|
filters += _( "Library" );
|
2020-07-09 13:21:28 +00:00
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
filters += wxString::Format( wxT( " (%s)" ), msg );
|
2018-03-24 18:28:35 +00:00
|
|
|
}
|
2011-08-24 19:44:05 +00:00
|
|
|
|
2020-07-09 13:21:28 +00:00
|
|
|
wxString textFilter = m_tcFilterString->GetValue();
|
|
|
|
|
|
|
|
if( !textFilter.IsEmpty() )
|
2018-03-24 18:28:35 +00:00
|
|
|
{
|
|
|
|
if( !filters.IsEmpty() )
|
|
|
|
filters += wxT( ", " );
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2020-10-20 20:18:48 +00:00
|
|
|
filters += _( "Search Text" ) + wxString::Format( wxT( " (%s)" ), textFilter );
|
2018-03-24 18:28:35 +00:00
|
|
|
}
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
if( filters.IsEmpty() )
|
2020-10-20 20:18:48 +00:00
|
|
|
msg = _( "No Filtering" );
|
2018-03-24 18:28:35 +00:00
|
|
|
else
|
2020-10-16 00:39:55 +00:00
|
|
|
msg.Printf( _( "Filtered by %s" ), filters );
|
2018-03-24 18:28:35 +00:00
|
|
|
|
|
|
|
msg << wxT( ": " ) << m_footprintListBox->GetCount();
|
|
|
|
|
2018-04-12 11:02:01 +00:00
|
|
|
SetStatusText( msg );
|
2016-02-24 16:30:35 +00:00
|
|
|
|
|
|
|
|
2018-03-24 18:28:35 +00:00
|
|
|
msg.Empty();
|
|
|
|
wxString footprintName = GetSelectedFootprint();
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2020-11-07 14:31:50 +00:00
|
|
|
FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName );
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2020-11-07 14:31:50 +00:00
|
|
|
if( fp ) // can be NULL if no netlist loaded
|
2018-03-24 18:28:35 +00:00
|
|
|
{
|
2020-10-20 20:18:48 +00:00
|
|
|
msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
|
2020-11-07 14:31:50 +00:00
|
|
|
fp->GetDescription(),
|
|
|
|
fp->GetKeywords() );
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
2018-03-24 18:28:35 +00:00
|
|
|
|
2018-04-12 11:02:01 +00:00
|
|
|
SetStatusText( msg, 1 );
|
2019-08-09 22:48:58 +00:00
|
|
|
|
|
|
|
msg.Empty();
|
|
|
|
wxString lib;
|
|
|
|
|
|
|
|
// Choose the footprint to get the information on
|
2020-11-07 14:31:50 +00:00
|
|
|
if( fp )
|
2019-08-09 22:48:58 +00:00
|
|
|
{
|
|
|
|
// Use the footprint in the footprint viewer
|
2020-11-07 14:31:50 +00:00
|
|
|
lib = fp->GetLibNickname();
|
2019-08-09 22:48:58 +00:00
|
|
|
}
|
|
|
|
else if( GetFocusedControl() == CVPCB_MAINFRAME::CONTROL_COMPONENT )
|
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
// Use the footprint of the selected symbol
|
|
|
|
if( symbol )
|
|
|
|
lib = symbol->GetFPID().GetLibNickname();
|
2019-08-09 22:48:58 +00:00
|
|
|
}
|
|
|
|
else if( GetFocusedControl() == CVPCB_MAINFRAME::CONTROL_LIBRARY )
|
|
|
|
{
|
|
|
|
// Use the library that is selected
|
2021-03-29 10:46:05 +00:00
|
|
|
lib = m_librariesListBox->GetSelectedLibrary();
|
2019-08-09 22:48:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Extract the library information
|
2021-06-29 11:45:02 +00:00
|
|
|
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
2019-08-09 22:48:58 +00:00
|
|
|
|
|
|
|
if( fptbl->HasLibrary( lib ) )
|
|
|
|
msg = wxString::Format( _( "Library location: %s" ), fptbl->GetFullURI( lib ) );
|
|
|
|
else
|
|
|
|
msg = wxString::Format( _( "Library location: unknown" ) );
|
|
|
|
|
|
|
|
SetStatusText( msg, 2 );
|
2010-11-07 20:06:07 +00:00
|
|
|
}
|
2011-02-22 17:59:46 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
|
|
|
|
bool CVPCB_MAINFRAME::LoadFootprintFiles()
|
2011-02-22 17:59:46 +00:00
|
|
|
{
|
2021-06-29 11:45:02 +00:00
|
|
|
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2014-01-17 20:26:27 +00:00
|
|
|
// Check if there are footprint libraries in the footprint library table.
|
* 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( !fptbl || !fptbl->GetLogicalLibs().size() )
|
2011-02-22 17:59:46 +00:00
|
|
|
{
|
2014-01-17 20:26:27 +00:00
|
|
|
wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
|
|
|
|
"library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
|
2011-02-22 17:59:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-10 13:32:57 +00:00
|
|
|
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
|
2016-04-08 16:45:11 +00:00
|
|
|
|
2018-02-10 13:32:57 +00:00
|
|
|
m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter );
|
2011-02-22 17:59:46 +00:00
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
if( m_FootprintsList->GetErrorCount() )
|
2011-02-22 17:59:46 +00:00
|
|
|
{
|
2017-03-23 00:59:25 +00:00
|
|
|
m_FootprintsList->DisplayErrors( this );
|
2011-02-22 17:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-08-24 19:44:05 +00:00
|
|
|
|
|
|
|
|
2018-12-29 08:39:08 +00:00
|
|
|
void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly )
|
2011-10-12 13:09:12 +00:00
|
|
|
{
|
2013-04-25 16:29:35 +00:00
|
|
|
if( m_netlist.IsEmpty() )
|
2011-10-12 13:09:12 +00:00
|
|
|
return;
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// clear highlight of previously selected symbols (if any):
|
2018-12-29 08:39:08 +00:00
|
|
|
// Selecting a non existing symbol clears any previously highlighted symbols
|
2018-12-31 12:54:26 +00:00
|
|
|
std::string packet = "$CLEAR: \"HIGHLIGHTED\"";
|
2018-12-29 08:39:08 +00:00
|
|
|
|
|
|
|
if( Kiface().IsSingle() )
|
2021-03-22 01:58:53 +00:00
|
|
|
SendCommand( MSG_TO_SCH, packet );
|
2018-12-29 08:39:08 +00:00
|
|
|
else
|
|
|
|
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
|
|
|
|
|
|
|
|
if( aClearHighligntOnly )
|
|
|
|
return;
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
int selection = m_symbolsListBox->GetSelection();
|
2011-10-12 13:09:12 +00:00
|
|
|
|
2018-12-29 08:39:08 +00:00
|
|
|
if ( selection < 0 ) // Nothing selected
|
|
|
|
return;
|
2011-10-12 13:09:12 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( m_netlist.GetComponent( selection ) == nullptr )
|
2011-12-14 20:23:32 +00:00
|
|
|
return;
|
2011-10-12 13:09:12 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Now highlight the selected symbol:
|
|
|
|
COMPONENT* symbol = m_netlist.GetComponent( selection );
|
2011-10-12 13:09:12 +00:00
|
|
|
|
2021-06-27 13:24:02 +00:00
|
|
|
packet = std::string( "$PART: \"" ) + TO_UTF8( symbol->GetReference() ) + "\"";
|
2011-10-12 13:09:12 +00:00
|
|
|
|
2014-04-22 15:16:19 +00:00
|
|
|
if( Kiface().IsSingle() )
|
2021-03-22 01:58:53 +00:00
|
|
|
SendCommand( MSG_TO_SCH, packet );
|
2014-04-22 15:16:19 +00:00
|
|
|
else
|
|
|
|
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
|
2011-10-12 13:09:12 +00:00
|
|
|
}
|
2013-04-26 15:11:52 +00:00
|
|
|
|
|
|
|
|
2015-06-07 18:18:45 +00:00
|
|
|
int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
|
2013-04-26 15:11:52 +00:00
|
|
|
{
|
2015-06-07 18:18:45 +00:00
|
|
|
STRING_LINE_READER* strrdr = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
|
|
|
|
KICAD_NETLIST_READER netrdr( strrdr, &m_netlist );
|
2013-04-26 15:11:52 +00:00
|
|
|
|
|
|
|
m_netlist.Clear();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2015-06-07 18:18:45 +00:00
|
|
|
netrdr.LoadNetlist();
|
2013-04-26 15:11:52 +00:00
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-04-26 15:11:52 +00:00
|
|
|
{
|
2019-06-15 16:05:33 +00:00
|
|
|
wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ),
|
|
|
|
ioe.What().GetData() );
|
2018-03-24 18:28:35 +00:00
|
|
|
wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
|
2013-04-26 15:11:52 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We also remove footprint name if it is "$noname" because this is a dummy name,
|
|
|
|
// not the actual name of the footprint.
|
|
|
|
for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
|
|
|
|
{
|
2016-11-20 23:35:08 +00:00
|
|
|
if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
|
2017-07-25 19:14:31 +00:00
|
|
|
m_netlist.GetComponent( ii )->SetFPID( LIB_ID() );
|
2013-04-26 15:11:52 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Sort symbols by reference:
|
2013-04-26 15:11:52 +00:00
|
|
|
m_netlist.SortByReference();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
void CVPCB_MAINFRAME::BuildFootprintsListBox()
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
|
|
|
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( m_footprintListBox == nullptr )
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
2020-01-11 21:14:09 +00:00
|
|
|
m_footprintListBox = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST );
|
2021-06-29 17:27:05 +00:00
|
|
|
m_footprintListBox->SetFont( KIUI::GetMonospacedUIFont() );
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, nullptr, wxEmptyString,
|
2020-11-07 14:31:50 +00:00
|
|
|
FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST );
|
2013-06-06 15:37:48 +00:00
|
|
|
DisplayStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
void CVPCB_MAINFRAME::BuildSymbolsListBox()
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2021-03-29 10:46:05 +00:00
|
|
|
COMPONENT* symbol;
|
2013-06-06 15:37:48 +00:00
|
|
|
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( m_symbolsListBox == nullptr )
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST );
|
2021-06-29 17:27:05 +00:00
|
|
|
m_symbolsListBox->SetFont( KIUI::GetMonospacedUIFont() );
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->m_ComponentList.Clear();
|
2013-06-06 15:37:48 +00:00
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
|
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
symbol = m_netlist.GetComponent( i );
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2020-01-11 21:14:09 +00:00
|
|
|
msg.Printf( CMP_FORMAT,
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->GetCount() + 1,
|
|
|
|
symbol->GetReference(),
|
|
|
|
symbol->GetValue(),
|
|
|
|
symbol->GetFPID().Format().wx_str() );
|
|
|
|
m_symbolsListBox->m_ComponentList.Add( msg );
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
if( m_symbolsListBox->m_ComponentList.Count() )
|
2013-09-14 20:33:22 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->SetItemCount( m_symbolsListBox->m_ComponentList.Count() );
|
|
|
|
m_symbolsListBox->SetSelection( 0, true );
|
|
|
|
m_symbolsListBox->RefreshItems( 0L, m_symbolsListBox->m_ComponentList.Count() - 1 );
|
|
|
|
m_symbolsListBox->UpdateWidth();
|
2013-09-14 20:33:22 +00:00
|
|
|
}
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
void CVPCB_MAINFRAME::BuildLibrariesListBox()
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
|
|
|
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( m_librariesListBox == nullptr )
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
m_librariesListBox = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST );
|
2021-06-29 17:27:05 +00:00
|
|
|
m_librariesListBox->SetFont( KIUI::GetMonospacedUIFont() );
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
|
|
|
|
2021-06-29 11:45:02 +00:00
|
|
|
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
2014-05-09 18:35:48 +00:00
|
|
|
|
|
|
|
if( tbl )
|
2013-09-14 20:33:22 +00:00
|
|
|
{
|
|
|
|
wxArrayString libNames;
|
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
|
2013-09-14 20:33:22 +00:00
|
|
|
|
2020-01-11 21:14:09 +00:00
|
|
|
for( const wxString& libNickName : libNickNames )
|
|
|
|
libNames.Add( libNickName );
|
2013-09-14 20:33:22 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
m_librariesListBox->SetLibraryList( libNames );
|
2013-09-14 20:33:22 +00:00
|
|
|
}
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
COMPONENT* CVPCB_MAINFRAME::GetSelectedComponent()
|
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
int selection = m_symbolsListBox->GetSelection();
|
2013-06-06 15:37:48 +00:00
|
|
|
|
|
|
|
if( selection >= 0 && selection < (int) m_netlist.GetCount() )
|
|
|
|
return m_netlist.GetComponent( selection );
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
return nullptr;
|
2013-06-06 15:37:48 +00:00
|
|
|
}
|
2014-03-21 11:50:04 +00:00
|
|
|
|
|
|
|
|
2019-08-08 21:10:37 +00:00
|
|
|
void CVPCB_MAINFRAME::SetSelectedComponent( int aIndex, bool aSkipUpdate )
|
|
|
|
{
|
|
|
|
m_skipComponentSelect = aSkipUpdate;
|
|
|
|
|
|
|
|
if( aIndex < 0 )
|
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->DeselectAll();
|
2019-08-08 21:10:37 +00:00
|
|
|
}
|
2021-03-29 10:46:05 +00:00
|
|
|
else if( aIndex < m_symbolsListBox->GetCount() )
|
2019-08-08 21:10:37 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
m_symbolsListBox->DeselectAll();
|
|
|
|
m_symbolsListBox->SetSelection( aIndex );
|
2019-08-08 21:10:37 +00:00
|
|
|
SendMessageToEESCHEMA();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_skipComponentSelect = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
|
|
|
|
CVPCB_MAINFRAME::CRITERIA aCriteria )
|
2019-07-24 20:56:17 +00:00
|
|
|
{
|
|
|
|
std::vector<unsigned int> idx;
|
2020-11-07 14:31:50 +00:00
|
|
|
int lastIdx;
|
2019-07-24 20:56:17 +00:00
|
|
|
|
2019-08-08 21:10:37 +00:00
|
|
|
// Make sure a netlist has been loaded and the box has contents
|
2021-03-29 10:46:05 +00:00
|
|
|
if( m_netlist.IsEmpty() || m_symbolsListBox->GetCount() == 0 )
|
2019-07-24 20:56:17 +00:00
|
|
|
return idx;
|
|
|
|
|
2019-08-08 21:10:37 +00:00
|
|
|
switch( aCriteria )
|
|
|
|
{
|
|
|
|
case CVPCB_MAINFRAME::ALL_COMPONENTS:
|
|
|
|
idx.resize( m_netlist.GetCount() );
|
|
|
|
std::iota( idx.begin(), idx.end(), 0 );
|
|
|
|
break;
|
2019-07-24 20:56:17 +00:00
|
|
|
|
2019-08-08 21:10:37 +00:00
|
|
|
case CVPCB_MAINFRAME::SEL_COMPONENTS:
|
|
|
|
// Check to see if anything is selected
|
2021-03-29 10:46:05 +00:00
|
|
|
if( m_symbolsListBox->GetSelectedItemCount() < 1 )
|
2019-08-08 21:10:37 +00:00
|
|
|
break;
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Get the symbols
|
|
|
|
lastIdx = m_symbolsListBox->GetFirstSelected();
|
2019-07-24 20:56:17 +00:00
|
|
|
idx.emplace_back( lastIdx );
|
2019-08-08 21:10:37 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
|
2019-08-08 21:10:37 +00:00
|
|
|
while( lastIdx > 0 )
|
|
|
|
{
|
|
|
|
idx.emplace_back( lastIdx );
|
2021-03-29 10:46:05 +00:00
|
|
|
lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
|
2019-08-08 21:10:37 +00:00
|
|
|
}
|
|
|
|
break;
|
2020-11-07 14:31:50 +00:00
|
|
|
|
2019-08-08 21:10:37 +00:00
|
|
|
case CVPCB_MAINFRAME::NA_COMPONENTS:
|
|
|
|
for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
if( m_netlist.GetComponent( i )->GetFPID().empty() )
|
|
|
|
idx.emplace_back( i );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2019-09-18 07:57:26 +00:00
|
|
|
case CVPCB_MAINFRAME::ASSOC_COMPONENTS:
|
2019-08-08 21:10:37 +00:00
|
|
|
for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
if( !m_netlist.GetComponent( i )->GetFPID().empty() )
|
|
|
|
idx.emplace_back( i );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-03-29 10:46:05 +00:00
|
|
|
wxASSERT_MSG( false, "Invalid symbol selection criteria" );
|
2019-07-24 20:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-24 01:01:23 +00:00
|
|
|
DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFootprintViewerFrame() const
|
2014-03-21 11:50:04 +00:00
|
|
|
{
|
|
|
|
// returns the Footprint Viewer frame, if exists, or NULL
|
2020-11-07 14:31:50 +00:00
|
|
|
wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME );
|
|
|
|
return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
|
2014-03-21 11:50:04 +00:00
|
|
|
}
|
2015-03-29 21:22:53 +00:00
|
|
|
|
2018-04-12 11:02:01 +00:00
|
|
|
|
2020-03-24 01:01:23 +00:00
|
|
|
wxWindow* CVPCB_MAINFRAME::GetToolCanvas() const
|
|
|
|
{
|
|
|
|
return GetFootprintViewerFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
CVPCB_MAINFRAME::CONTROL_TYPE CVPCB_MAINFRAME::GetFocusedControl() const
|
2019-08-08 22:11:59 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
if( m_librariesListBox->HasFocus() )
|
2019-08-08 22:11:59 +00:00
|
|
|
return CVPCB_MAINFRAME::CONTROL_LIBRARY;
|
2021-03-29 10:46:05 +00:00
|
|
|
else if( m_symbolsListBox->HasFocus() )
|
2019-08-08 22:11:59 +00:00
|
|
|
return CVPCB_MAINFRAME::CONTROL_COMPONENT;
|
|
|
|
else if( m_footprintListBox->HasFocus() )
|
|
|
|
return CVPCB_MAINFRAME::CONTROL_FOOTPRINT;
|
|
|
|
|
|
|
|
return CVPCB_MAINFRAME::CONTROL_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
wxControl* CVPCB_MAINFRAME::GetFocusedControlObject() const
|
2019-08-08 22:11:59 +00:00
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
if( m_librariesListBox->HasFocus() )
|
|
|
|
return m_librariesListBox;
|
|
|
|
else if( m_symbolsListBox->HasFocus() )
|
|
|
|
return m_symbolsListBox;
|
2019-08-08 22:11:59 +00:00
|
|
|
else if( m_footprintListBox->HasFocus() )
|
|
|
|
return m_footprintListBox;
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CVPCB_MAINFRAME::SetFocusedControl( CVPCB_MAINFRAME::CONTROL_TYPE aLB )
|
|
|
|
{
|
|
|
|
switch( aLB )
|
|
|
|
{
|
2021-03-29 10:46:05 +00:00
|
|
|
case CVPCB_MAINFRAME::CONTROL_LIBRARY: m_librariesListBox->SetFocus(); break;
|
|
|
|
case CVPCB_MAINFRAME::CONTROL_COMPONENT: m_symbolsListBox->SetFocus(); break;
|
2020-01-11 21:14:09 +00:00
|
|
|
case CVPCB_MAINFRAME::CONTROL_FOOTPRINT: m_footprintListBox->SetFocus(); break;
|
|
|
|
default: break;
|
2019-08-08 22:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-12 11:02:01 +00:00
|
|
|
wxString CVPCB_MAINFRAME::GetSelectedFootprint()
|
2016-02-25 09:52:29 +00:00
|
|
|
{
|
2016-11-20 23:35:08 +00:00
|
|
|
// returns the LIB_ID of the selected footprint in footprint listview
|
2016-02-25 09:52:29 +00:00
|
|
|
// or a empty string
|
|
|
|
return m_footprintListBox->GetSelectedFootprint();
|
|
|
|
}
|
|
|
|
|
2015-03-29 21:22:53 +00:00
|
|
|
|
2018-04-12 11:02:01 +00:00
|
|
|
void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
|
|
|
|
{
|
2019-08-09 22:48:58 +00:00
|
|
|
switch( aNumber )
|
|
|
|
{
|
2020-01-11 21:14:09 +00:00
|
|
|
case 0: m_statusLine1->SetLabel( aText ); break;
|
|
|
|
case 1: m_statusLine2->SetLabel( aText ); break;
|
|
|
|
case 2: m_statusLine3->SetLabel( aText ); break;
|
|
|
|
default: wxFAIL_MSG( "Invalid status row number" ); break;
|
2019-08-09 22:48:58 +00:00
|
|
|
}
|
2018-04-12 11:02:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-03 22:55:13 +00:00
|
|
|
void CVPCB_MAINFRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::ShowChangedLanguage();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
DisplayStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-07 18:18:45 +00:00
|
|
|
void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|
|
|
{
|
|
|
|
const std::string& payload = mail.GetPayload();
|
|
|
|
|
|
|
|
switch( mail.Command() )
|
|
|
|
{
|
|
|
|
case MAIL_EESCHEMA_NETLIST:
|
2021-08-06 11:40:30 +00:00
|
|
|
// Disable Close events during ReadNetListAndFpFiles() to avoid crash when updating
|
|
|
|
// widgets:
|
|
|
|
m_cannotClose = true;
|
2017-06-15 09:28:36 +00:00
|
|
|
ReadNetListAndFpFiles( payload );
|
2021-08-06 11:40:30 +00:00
|
|
|
m_cannotClose = false;
|
2015-06-07 18:18:45 +00:00
|
|
|
/* @todo
|
|
|
|
Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
; // ignore most
|
|
|
|
}
|
|
|
|
}
|