2012-05-09 17:37:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2012-09-11 19:03:21 +00:00
|
|
|
*
|
2015-01-22 13:42:24 +00:00
|
|
|
* Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
|
2019-08-15 07:27:28 +00:00
|
|
|
* Copyright (C) 2012-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2021-07-19 23:56:05 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
|
|
|
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-05-09 17:37:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2018-08-11 06:25:09 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h>
|
2020-10-25 04:49:02 +00:00
|
|
|
#include <widgets/msgpanel.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2018-03-21 23:25:36 +00:00
|
|
|
#include <grid_tricks.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2020-05-06 01:45:48 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
2012-05-09 17:37:25 +00:00
|
|
|
#include <pcbnew_id.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2012-05-09 17:37:25 +00:00
|
|
|
#include "footprint_wizard_frame.h"
|
2021-06-03 11:49:49 +00:00
|
|
|
#include <wx/listbox.h>
|
2023-01-08 18:15:20 +00:00
|
|
|
#include <wx/statline.h>
|
2017-01-03 15:01:47 +00:00
|
|
|
#include <wx/tokenzr.h>
|
|
|
|
#include <wx/numformatter.h>
|
2012-05-09 17:37:25 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2012-07-22 22:23:17 +00:00
|
|
|
#include <base_units.h>
|
2020-05-06 01:45:48 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2018-08-11 06:25:09 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tool/tool_dispatcher.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2018-08-11 06:25:09 +00:00
|
|
|
#include <tool/common_tools.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include "tools/pcb_selection_tool.h"
|
|
|
|
#include "tools/pcb_control.h"
|
2018-08-11 06:25:09 +00:00
|
|
|
#include "tools/pcb_actions.h"
|
|
|
|
|
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
2014-01-29 17:01:42 +00:00
|
|
|
|
2014-08-29 20:23:40 +00:00
|
|
|
// Window events
|
|
|
|
EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
|
|
|
|
EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2014-08-29 20:23:40 +00:00
|
|
|
// Toolbar events
|
2019-05-14 19:21:10 +00:00
|
|
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
|
|
|
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, FOOTPRINT_WIZARD_FRAME::DefaultParameters )
|
|
|
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT, FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS, FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE, FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2014-08-29 20:23:40 +00:00
|
|
|
// listbox events
|
|
|
|
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
|
|
|
|
EVT_GRID_CMD_CELL_CHANGED( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
|
|
|
|
FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
|
2012-05-09 17:37:25 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
// Note: our FOOTPRINT_WIZARD_FRAME is always modal.
|
2016-03-21 16:36:06 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
|
|
|
FRAME_T aFrameType ) :
|
2020-10-30 23:33:24 +00:00
|
|
|
PCB_BASE_EDIT_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
|
2021-07-19 23:56:05 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
|
|
|
|
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
|
|
|
|
FOOTPRINT_WIZARD_FRAME_NAME ),
|
2019-05-14 19:21:10 +00:00
|
|
|
m_wizardListShown( false )
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
2019-09-05 22:00:47 +00:00
|
|
|
wxASSERT( aFrameType == FRAME_FOOTPRINT_WIZARD );
|
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
|
|
|
|
2015-06-27 09:12:32 +00:00
|
|
|
// This frame is always show modal:
|
|
|
|
SetModal( true );
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
// Give an icon
|
2013-08-05 13:43:15 +00:00
|
|
|
wxIcon icon;
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::module_wizard ) );
|
2013-08-05 13:43:15 +00:00
|
|
|
SetIcon( icon );
|
2012-05-09 17:37:25 +00:00
|
|
|
|
|
|
|
m_wizardName.Empty();
|
|
|
|
|
2020-09-01 07:32:05 +00:00
|
|
|
// Create the GAL canvas.
|
|
|
|
// Must be created before calling LoadSettings() that needs a valid GAL canvas
|
|
|
|
PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
|
2020-11-16 11:16:44 +00:00
|
|
|
m_frameSize,
|
2020-09-01 07:32:05 +00:00
|
|
|
GetGalDisplayOptions(),
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_FALLBACK );
|
|
|
|
SetCanvas( gal_drawPanel );
|
|
|
|
|
2020-10-30 23:33:24 +00:00
|
|
|
SetBoard( new BOARD() );
|
|
|
|
|
|
|
|
// Ensure all layers and items are visible:
|
|
|
|
GetBoard()->SetVisibleAlls();
|
|
|
|
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
|
|
|
|
GetScreen()->m_Center = true; // Center coordinate origins on screen.
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
LoadSettings( config() );
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
2015-09-02 13:55:36 +00:00
|
|
|
|
|
|
|
// Set some display options here, because the FOOTPRINT_WIZARD_FRAME
|
|
|
|
// does not have a config menu to do that:
|
2018-08-11 06:25:09 +00:00
|
|
|
|
|
|
|
// the footprint wizard frame has no config menu. so use some settings
|
|
|
|
// from the caller, or force some options:
|
|
|
|
PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
|
|
|
|
|
|
|
|
if( caller )
|
|
|
|
SetUserUnits( caller->GetUserUnits() );
|
|
|
|
|
|
|
|
// In viewer, the default net clearance is not known (it depends on the actual board).
|
|
|
|
// So we do not show the default clearance, by setting it to 0
|
|
|
|
// The footprint or pad specific clearance will be shown
|
2022-08-14 11:03:18 +00:00
|
|
|
GetBoard()->GetDesignSettings().m_NetSettings->m_DefaultNetClass->SetClearance( 0 );
|
2015-09-02 13:55:36 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
gal_drawPanel->GetViewControls(), config(), this );
|
2019-05-14 19:21:10 +00:00
|
|
|
m_actions = new PCB_ACTIONS();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2019-05-14 19:21:10 +00:00
|
|
|
gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PCB_CONTROL );
|
|
|
|
m_toolManager->RegisterTool( new PCB_SELECTION_TOOL ); // for std context menus (zoom & grid)
|
2019-05-14 19:21:10 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
|
|
|
// Run the control tool, it is supposed to be always active
|
|
|
|
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
|
|
|
|
|
|
|
// Create the toolbars
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
|
2018-05-20 22:46:24 +00:00
|
|
|
// Create the parameters panel
|
|
|
|
m_parametersPanel = new wxPanel( this, wxID_ANY );
|
|
|
|
|
|
|
|
m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
|
2021-07-19 23:56:05 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
2018-08-11 16:04:46 +00:00
|
|
|
wxLB_HSCROLL | wxNO_BORDER );
|
|
|
|
|
|
|
|
auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2019-03-04 11:02:12 +00:00
|
|
|
m_parameterGrid = new WX_GRID( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
|
2015-09-07 10:52:16 +00:00
|
|
|
initParameterGrid();
|
2018-03-21 23:25:36 +00:00
|
|
|
m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
|
2013-03-15 14:50:54 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
ReCreatePageList();
|
|
|
|
|
2018-05-20 22:46:24 +00:00
|
|
|
wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
|
2018-08-11 16:04:46 +00:00
|
|
|
parametersSizer->Add( m_pageList, 0, wxEXPAND, 5 );
|
|
|
|
parametersSizer->Add( divider, 0, wxEXPAND, 5 );
|
|
|
|
parametersSizer->Add( m_parameterGrid, 1, wxEXPAND, 5 );
|
2018-05-20 22:46:24 +00:00
|
|
|
m_parametersPanel->SetSizer( parametersSizer );
|
|
|
|
m_parametersPanel->Layout();
|
|
|
|
|
|
|
|
// Create the build message box
|
|
|
|
m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2018-08-11 16:04:46 +00:00
|
|
|
wxTE_MULTILINE | wxTE_READONLY | wxNO_BORDER );
|
2018-05-20 22:46:24 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
DisplayWizardInfos();
|
|
|
|
|
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
2019-08-15 07:27:28 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6)
|
2020-11-14 18:11:28 +00:00
|
|
|
.BestSize( -1, m_msgFrameHeight ) );
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_parametersPanel, EDA_PANE().Palette().Name( "Params" ).Left().Position(0)
|
|
|
|
.Caption( _( "Parameters" ) ).MinSize( 360, 180 ) );
|
|
|
|
m_auimgr.AddPane( m_buildMessageBox, EDA_PANE().Palette().Name( "Output" ).Left().Position(1)
|
|
|
|
.CaptionVisible( false ).MinSize( 360, -1 ) );
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
|
2018-08-11 06:25:09 +00:00
|
|
|
|
|
|
|
auto& galOpts = GetGalDisplayOptions();
|
|
|
|
galOpts.m_fullscreenCursor = true;
|
|
|
|
galOpts.m_forceDisplayCursor = true;
|
|
|
|
galOpts.m_axesEnabled = true;
|
|
|
|
|
2019-05-30 12:25:08 +00:00
|
|
|
ActivateGalCanvas();
|
2018-08-11 06:25:09 +00:00
|
|
|
updateView();
|
|
|
|
|
|
|
|
SetActiveLayer( F_Cu );
|
2019-06-04 12:46:02 +00:00
|
|
|
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2015-09-07 10:52:16 +00:00
|
|
|
// Do not Run a dialog here: on some Window Managers, it creates issues.
|
|
|
|
// Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
|
|
|
|
// It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
|
|
|
|
// Event Loop Manager, and stop the one created by the dialog.
|
2015-10-24 17:46:50 +00:00
|
|
|
// It does not happen on all W.M., perhaps due to the way the order events are called
|
2018-12-10 12:43:44 +00:00
|
|
|
// See the call in onActivate instead
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
|
|
|
|
{
|
2018-03-21 23:25:36 +00:00
|
|
|
// Delete the GRID_TRICKS.
|
|
|
|
m_parameterGrid->PopEventHandler( true );
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->StopDrawing();
|
2019-05-27 16:16:54 +00:00
|
|
|
// Be sure any event cannot be fired after frame deletion:
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetEvtHandlerEnabled( false );
|
2018-08-11 06:25:09 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Be sure a active tool (if exists) is deactivated:
|
2018-08-11 06:25:09 +00:00
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->DeactivateTool();
|
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
|
2015-12-21 11:52:00 +00:00
|
|
|
|
|
|
|
if( draw3DFrame )
|
|
|
|
draw3DFrame->Destroy();
|
2018-08-11 06:25:09 +00:00
|
|
|
|
|
|
|
// Now this frame can be deleted
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::doCloseWindow()
|
2012-08-04 22:15:57 +00:00
|
|
|
{
|
2015-09-07 10:52:16 +00:00
|
|
|
SaveSettings( config() );
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( IsModal() )
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// Only dismiss a modal frame once, so that the return values set by
|
|
|
|
// the prior DismissModal() are not bashed for ShowModal().
|
|
|
|
if( !IsDismissed() )
|
|
|
|
DismissModal( false );
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-05 13:43:15 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
|
|
|
|
{
|
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
|
|
|
DismissModal( true );
|
2013-08-05 13:43:15 +00:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2018-05-20 22:46:24 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
|
|
|
|
{
|
|
|
|
// Resize the parameter columns
|
|
|
|
ResizeParamColumns();
|
|
|
|
|
|
|
|
aSizeEvent.Skip();
|
|
|
|
}
|
2013-08-05 13:43:15 +00:00
|
|
|
|
2018-05-20 22:46:24 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
|
|
|
|
{
|
|
|
|
if( m_auimgr.GetManagedWindow() )
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
SizeEv.Skip();
|
|
|
|
}
|
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
COLOR_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetColorSettings( bool aForceRefresh ) const
|
2020-05-06 01:45:48 +00:00
|
|
|
{
|
2020-12-23 23:18:02 +00:00
|
|
|
wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
|
|
|
|
|
|
|
|
return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
|
2020-05-06 01:45:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-11 06:25:09 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::updateView()
|
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
GetCanvas()->UpdateColors();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->DisplayBoard( GetBoard() );
|
2019-05-27 16:16:54 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
|
|
|
UpdateMsgPanel();
|
2018-08-11 06:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel()
|
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
BOARD_ITEM* footprint = GetBoard()->GetFirstFootprint();
|
2018-08-11 06:25:09 +00:00
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
{
|
2021-09-26 23:22:32 +00:00
|
|
|
std::vector<MSG_PANEL_ITEM> items;
|
2018-08-11 06:25:09 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
footprint->GetMsgPanelInfo( this, items );
|
2018-08-11 06:25:09 +00:00
|
|
|
SetMsgPanel( items );
|
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2018-08-11 06:25:09 +00:00
|
|
|
ClearMsgPanel();
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2018-08-11 06:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-07 10:52:16 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
|
|
|
|
{
|
2018-05-20 22:46:24 +00:00
|
|
|
m_parameterGridPage = -1;
|
|
|
|
|
2015-09-07 10:52:16 +00:00
|
|
|
// Prepare the grid where parameters are displayed
|
2018-05-20 22:46:24 +00:00
|
|
|
|
2015-09-07 10:52:16 +00:00
|
|
|
m_parameterGrid->CreateGrid( 0, 3 );
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
|
|
|
|
m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
|
|
|
|
m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
|
|
|
|
|
2018-05-20 22:46:24 +00:00
|
|
|
m_parameterGrid->SetColLabelSize( 22 );
|
2015-09-07 10:52:16 +00:00
|
|
|
m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
|
|
|
|
m_parameterGrid->AutoSizeColumns();
|
|
|
|
|
|
|
|
m_parameterGrid->AutoSizeRows();
|
2018-05-20 22:46:24 +00:00
|
|
|
m_parameterGrid->SetRowLabelSize( 0 );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
|
|
|
m_parameterGrid->DisableDragGridSize();
|
|
|
|
m_parameterGrid->DisableDragColSize();
|
|
|
|
|
2018-03-14 00:32:53 +00:00
|
|
|
m_parameterGrid->Connect( wxEVT_SIZE,
|
|
|
|
wxSizeEventHandler( FOOTPRINT_WIZARD_FRAME::OnGridSize ),
|
2021-07-19 23:56:05 +00:00
|
|
|
nullptr, this );
|
2015-09-07 10:52:16 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
if( m_pageList == nullptr )
|
2012-05-09 17:37:25 +00:00
|
|
|
return;
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2013-03-16 03:27:48 +00:00
|
|
|
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
|
|
|
|
|
|
|
|
if( !footprintWizard )
|
2012-05-09 23:04:08 +00:00
|
|
|
return;
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2014-01-29 17:01:42 +00:00
|
|
|
m_pageList->Clear();
|
2013-03-16 03:27:48 +00:00
|
|
|
int max_page = footprintWizard->GetNumParameterPages();
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( int i = 0; i < max_page; i++ )
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
2013-03-16 03:27:48 +00:00
|
|
|
wxString name = footprintWizard->GetParameterPageName( i );
|
2014-01-29 17:01:42 +00:00
|
|
|
m_pageList->Append( name );
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2014-01-29 17:01:42 +00:00
|
|
|
m_pageList->SetSelection( 0, true );
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2012-05-09 23:04:08 +00:00
|
|
|
ReCreateParameterList();
|
2012-05-09 17:37:25 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
DisplayWizardInfos();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
if( m_parameterGrid == nullptr )
|
2012-05-09 17:37:25 +00:00
|
|
|
return;
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2013-03-16 03:27:48 +00:00
|
|
|
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( footprintWizard == nullptr )
|
2012-05-09 23:04:08 +00:00
|
|
|
return;
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2019-11-02 09:17:35 +00:00
|
|
|
m_parameterGrid->Freeze();
|
|
|
|
|
2017-12-23 17:34:57 +00:00
|
|
|
m_parameterGrid->ClearGrid();
|
2018-03-11 23:10:27 +00:00
|
|
|
m_parameterGridPage = m_pageList->GetSelection();
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2017-12-23 17:34:57 +00:00
|
|
|
if( m_parameterGridPage < 0 ) // Should not happen
|
2012-05-09 23:04:08 +00:00
|
|
|
return;
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
// Get the list of names, values, types, hints and designators
|
2019-05-14 19:21:10 +00:00
|
|
|
wxArrayString designatorsList = footprintWizard->GetParameterDesignators( m_parameterGridPage );
|
|
|
|
wxArrayString namesList = footprintWizard->GetParameterNames( m_parameterGridPage );
|
|
|
|
wxArrayString valuesList = footprintWizard->GetParameterValues( m_parameterGridPage );
|
|
|
|
wxArrayString typesList = footprintWizard->GetParameterTypes( m_parameterGridPage );
|
|
|
|
wxArrayString hintsList = footprintWizard->GetParameterHints( m_parameterGridPage );
|
2012-09-11 19:03:21 +00:00
|
|
|
|
|
|
|
// Dimension the wxGrid
|
2021-08-10 11:59:53 +00:00
|
|
|
m_parameterGrid->ClearRows();
|
2017-01-03 15:01:47 +00:00
|
|
|
m_parameterGrid->AppendRows( namesList.size() );
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
wxString designator, name, value, units, hint;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( unsigned int i = 0; i < namesList.size(); i++ )
|
2012-05-10 22:30:26 +00:00
|
|
|
{
|
2017-01-03 15:01:47 +00:00
|
|
|
designator = designatorsList[i];
|
|
|
|
name = namesList[i];
|
|
|
|
value = valuesList[i];
|
|
|
|
units = typesList[i];
|
|
|
|
hint = hintsList[i];
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
m_parameterGrid->SetRowLabelValue( i, designator );
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
// Set the 'Name'
|
|
|
|
m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
|
|
|
|
m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
|
2013-03-15 16:35:24 +00:00
|
|
|
|
2017-12-23 17:34:57 +00:00
|
|
|
// Boolean parameters are displayed using a checkbox
|
2017-01-03 17:04:35 +00:00
|
|
|
if( units == WIZARD_PARAM_UNITS_BOOL )
|
2017-01-03 15:01:47 +00:00
|
|
|
{
|
2018-03-21 23:25:36 +00:00
|
|
|
// Set to ReadOnly as we delegate interactivity to GRID_TRICKS
|
2018-03-14 00:32:53 +00:00
|
|
|
m_parameterGrid->SetReadOnly( i, WIZ_COL_VALUE );
|
2017-01-03 15:01:47 +00:00
|
|
|
m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer );
|
|
|
|
}
|
|
|
|
// Parameters that can be selected from a list of multiple options
|
2022-02-04 22:44:59 +00:00
|
|
|
else if( units.Contains( wxT( "," ) ) ) // Indicates list of available options
|
2017-01-03 15:01:47 +00:00
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
wxStringTokenizer tokenizer( units, wxT( "," ) );
|
2017-01-03 15:01:47 +00:00
|
|
|
wxArrayString options;
|
2012-07-22 22:23:17 +00:00
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
while( tokenizer.HasMoreTokens() )
|
2012-07-22 22:23:17 +00:00
|
|
|
{
|
2017-01-03 15:01:47 +00:00
|
|
|
options.Add( tokenizer.GetNextToken() );
|
2012-07-22 22:23:17 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE,
|
|
|
|
new wxGridCellChoiceEditor( options ) );
|
2017-01-03 15:01:47 +00:00
|
|
|
|
|
|
|
units = wxT( "" );
|
2012-07-22 22:23:17 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
else if( units == WIZARD_PARAM_UNITS_INTEGER ) // Integer parameters
|
2012-07-22 22:23:17 +00:00
|
|
|
{
|
2017-01-03 15:01:47 +00:00
|
|
|
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
|
|
|
|
}
|
2017-01-03 17:04:35 +00:00
|
|
|
else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
|
|
|
|
( units == WIZARD_PARAM_UNITS_MILS ) ||
|
|
|
|
( units == WIZARD_PARAM_UNITS_FLOAT ) ||
|
|
|
|
( units == WIZARD_PARAM_UNITS_RADIANS ) ||
|
|
|
|
( units == WIZARD_PARAM_UNITS_DEGREES ) ||
|
|
|
|
( units == WIZARD_PARAM_UNITS_PERCENT ) )
|
2017-01-03 15:01:47 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
// Non-integer numerical parameters
|
2017-01-03 15:01:47 +00:00
|
|
|
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
|
|
|
|
|
|
|
|
// Convert separators to the locale-specific character
|
|
|
|
value.Replace( ",", wxNumberFormatter::GetDecimalSeparator() );
|
|
|
|
value.Replace( ".", wxNumberFormatter::GetDecimalSeparator() );
|
2012-07-22 22:23:17 +00:00
|
|
|
}
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
// Set the 'Units'
|
|
|
|
m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
|
|
|
|
m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
|
|
|
|
|
|
|
|
// Set the 'Value'
|
|
|
|
m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
|
2012-05-10 22:30:26 +00:00
|
|
|
}
|
2012-09-11 19:03:21 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
ResizeParamColumns();
|
2019-11-02 09:17:35 +00:00
|
|
|
|
|
|
|
m_parameterGrid->Thaw();
|
2017-01-03 15:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FOOTPRINT_WIZARD_FRAME::ResizeParamColumns()
|
|
|
|
{
|
|
|
|
// Parameter grid is not yet configured
|
2021-07-19 23:56:05 +00:00
|
|
|
if( ( m_parameterGrid == nullptr ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
|
2017-01-03 15:01:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// first auto-size the columns to ensure enough space around text
|
2014-01-29 17:01:42 +00:00
|
|
|
m_parameterGrid->AutoSizeColumns();
|
2017-01-03 15:01:47 +00:00
|
|
|
|
|
|
|
// Auto-size the value column
|
|
|
|
int width = m_parameterGrid->GetClientSize().GetWidth() -
|
|
|
|
m_parameterGrid->GetRowLabelSize() -
|
|
|
|
m_parameterGrid->GetColSize( WIZ_COL_NAME ) -
|
|
|
|
m_parameterGrid->GetColSize( WIZ_COL_UNITS );
|
|
|
|
|
2017-01-03 17:04:35 +00:00
|
|
|
if( width > m_parameterGrid->GetColMinimalAcceptableWidth() )
|
2017-01-03 15:01:47 +00:00
|
|
|
{
|
|
|
|
m_parameterGrid->SetColSize( WIZ_COL_VALUE, width );
|
|
|
|
}
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
|
|
|
|
{
|
2019-08-15 07:27:28 +00:00
|
|
|
if( m_pageList->GetSelection() >= 0 )
|
2019-05-14 19:21:10 +00:00
|
|
|
{
|
|
|
|
ReCreateParameterList();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2019-05-14 19:21:10 +00:00
|
|
|
DisplayWizardInfos();
|
|
|
|
}
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
2020-06-12 10:58:56 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
|
|
|
wxCHECK( cfg, /*void*/ );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
PCB_BASE_FRAME::LoadSettings( cfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
m_auiPerspective = cfg->m_FootprintViewer.perspective;
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
2012-05-09 17:37:25 +00:00
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
2020-06-12 10:58:56 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
|
|
|
wxCHECK( cfg, /*void*/ );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
PCB_BASE_FRAME::SaveSettings( cfg );
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
cfg->m_FootprintViewer.perspective = m_auimgr.SavePerspective().ToStdString();
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
WINDOW_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
|
|
|
wxASSERT( cfg );
|
2020-03-25 13:13:03 +00:00
|
|
|
|
|
|
|
return cfg ? &cfg->m_FootprintWizard : nullptr;
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
|
|
|
|
{
|
|
|
|
// Ensure we do not have old selection:
|
2015-01-22 13:42:24 +00:00
|
|
|
if( !event.GetActive() )
|
2012-05-09 17:37:25 +00:00
|
|
|
return;
|
|
|
|
|
2018-12-10 12:43:44 +00:00
|
|
|
if( !m_wizardListShown )
|
|
|
|
{
|
|
|
|
m_wizardListShown = true;
|
2019-06-23 14:29:29 +00:00
|
|
|
wxPostEvent( this, wxCommandEvent( wxEVT_TOOL, ID_FOOTPRINT_WIZARD_SELECT_WIZARD ) );
|
2018-12-10 12:43:44 +00:00
|
|
|
}
|
2015-08-23 12:35:49 +00:00
|
|
|
#if 0
|
|
|
|
// Currently, we do not have a way to see if a Python wizard has changed,
|
|
|
|
// therefore the lists of parameters and option has to be rebuilt
|
|
|
|
// This code could be enabled when this way exists
|
2013-03-15 16:35:24 +00:00
|
|
|
bool footprintWizardsChanged = false;
|
|
|
|
|
|
|
|
if( footprintWizardsChanged )
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
2013-03-15 16:35:24 +00:00
|
|
|
// If we are here, the library list has changed, rebuild it
|
2012-05-09 17:37:25 +00:00
|
|
|
ReCreatePageList();
|
|
|
|
DisplayWizardInfos();
|
|
|
|
}
|
2015-08-23 12:35:49 +00:00
|
|
|
#endif
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-09 02:09:06 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
|
|
|
wxString frm3Dtitle;
|
2020-10-16 00:39:55 +00:00
|
|
|
frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), m_wizardName );
|
2021-04-09 02:09:06 +00:00
|
|
|
PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &frm3Dtitle );
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
|
|
|
|
{
|
2020-06-17 11:03:25 +00:00
|
|
|
if( m_mainToolBar )
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
2020-06-23 10:42:23 +00:00
|
|
|
m_mainToolBar->ClearToolbar();
|
2020-09-26 23:55:59 +00:00
|
|
|
}
|
2020-06-17 11:03:25 +00:00
|
|
|
else
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
2019-05-14 19:21:10 +00:00
|
|
|
m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
2020-09-26 23:55:59 +00:00
|
|
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
|
|
|
}
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
// Set up toolbar
|
|
|
|
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString,
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::module_wizard ),
|
2020-06-17 11:03:25 +00:00
|
|
|
_( "Select wizard script to run" ) );
|
|
|
|
|
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
|
|
|
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString,
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::reload ),
|
2020-06-17 11:03:25 +00:00
|
|
|
_( "Reset wizard parameters to default") );
|
|
|
|
|
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
|
|
|
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::lib_previous ),
|
2020-06-17 11:03:25 +00:00
|
|
|
_( "Select previous parameters page" ) );
|
|
|
|
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::lib_next ),
|
2020-06-17 11:03:25 +00:00
|
|
|
_( "Select next parameters page" ) );
|
|
|
|
|
2021-02-05 17:30:24 +00:00
|
|
|
#if 0 // Currently: the 3D viewer is not useful
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
|
|
|
m_mainToolBar->Add( ACTIONS::show3DViewer );
|
2021-02-05 17:30:24 +00:00
|
|
|
#endif
|
2020-06-17 11:03:25 +00:00
|
|
|
|
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomRedraw );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomInCenter );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomOutCenter );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomFitScreen );
|
|
|
|
|
|
|
|
// The footprint wizard always can export the current footprint
|
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
|
|
|
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
|
2021-03-08 02:59:07 +00:00
|
|
|
wxEmptyString, KiBitmap( BITMAPS::export_footprint_names ),
|
2020-06-17 11:03:25 +00:00
|
|
|
_( "Export footprint to editor" ) );
|
|
|
|
|
|
|
|
// after adding the buttons to the toolbar, must call Realize() to
|
|
|
|
// reflect the changes
|
|
|
|
m_mainToolBar->Realize();
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-22 18:27:05 +00:00
|
|
|
BOARD_ITEM_CONTAINER* FOOTPRINT_WIZARD_FRAME::GetModel() const
|
|
|
|
{
|
2020-11-08 21:29:04 +00:00
|
|
|
return GetBoard()->GetFirstFootprint();
|
2020-05-22 18:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar()
|
|
|
|
{
|
2015-09-02 13:55:36 +00:00
|
|
|
// Currently, there is no vertical toolbar
|
2012-05-09 17:37:25 +00:00
|
|
|
}
|
2015-09-05 12:10:54 +00:00
|
|
|
|
2017-01-28 17:47:11 +00:00
|
|
|
void FOOTPRINT_WIZARD_FRAME::PythonPluginsReload()
|
|
|
|
{
|
|
|
|
// Reload the Python plugins
|
|
|
|
// Because the board editor has also a plugin python menu,
|
|
|
|
// call PCB_EDIT_FRAME::PythonPluginsReload() if the board editor
|
|
|
|
// is running
|
2019-09-05 22:00:47 +00:00
|
|
|
auto brd_frame = static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB_EDITOR, false ) );
|
2017-01-28 17:47:11 +00:00
|
|
|
|
|
|
|
if( brd_frame )
|
2021-03-19 23:06:29 +00:00
|
|
|
brd_frame->GetToolManager()->RunAction( PCB_ACTIONS::pluginsReload );
|
2017-01-28 17:47:11 +00:00
|
|
|
else
|
2021-03-19 23:06:29 +00:00
|
|
|
GetToolManager()->RunAction( PCB_ACTIONS::pluginsReload );
|
2017-01-28 17:47:11 +00:00
|
|
|
}
|