2011-08-05 19:53:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2015-08-09 09:03:25 +00:00
|
|
|
* Copyright (C) 1992-2015 jean-pierre.charras
|
2023-01-27 22:41:05 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-08-05 19:53:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2019-05-01 18:57:59 +00:00
|
|
|
* as published by the Free Software Foundation; either version 3
|
2011-08-05 19:53:42 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2019-05-01 18:57:59 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-05 19:53:42 +00:00
|
|
|
*/
|
2021-06-07 22:26:55 +00:00
|
|
|
#include <wx/msgdlg.h>
|
2022-01-27 20:54:57 +00:00
|
|
|
#include <wx/treebook.h>
|
2021-10-08 17:28:10 +00:00
|
|
|
#include <wx/sizer.h>
|
|
|
|
|
2021-10-12 12:08:42 +00:00
|
|
|
#include <typeinfo>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <bitmaps.h>
|
2021-10-08 16:30:36 +00:00
|
|
|
#include <bitmap_store.h>
|
2019-06-11 14:20:28 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2023-08-07 23:51:22 +00:00
|
|
|
#include <tool/actions.h>
|
2023-06-16 14:29:31 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/common_control.h>
|
2021-10-08 17:28:10 +00:00
|
|
|
#include <attenuators/attenuator_classes.h>
|
|
|
|
#include <pcb_calculator_frame.h>
|
|
|
|
#include <pcb_calculator_settings.h>
|
2023-06-16 14:29:31 +00:00
|
|
|
#include <pcb_calculator_control.h>
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2022-12-29 17:37:52 +00:00
|
|
|
#include <calculator_panels/panel_rf_attenuators.h>
|
2021-10-08 17:13:41 +00:00
|
|
|
#include <calculator_panels/panel_board_class.h>
|
2022-06-16 22:04:45 +00:00
|
|
|
#include <calculator_panels/panel_cable_size.h>
|
2022-12-29 17:37:52 +00:00
|
|
|
#include <calculator_panels/panel_galvanic_corrosion.h>
|
2021-10-08 17:13:41 +00:00
|
|
|
#include <calculator_panels/panel_color_code.h>
|
|
|
|
#include <calculator_panels/panel_electrical_spacing.h>
|
2023-06-26 23:21:40 +00:00
|
|
|
#include <calculator_panels/panel_r_calculator.h>
|
2022-06-21 23:34:36 +00:00
|
|
|
#include <calculator_panels/panel_fusing_current.h>
|
2021-10-08 17:13:41 +00:00
|
|
|
#include <calculator_panels/panel_regulator.h>
|
|
|
|
#include <calculator_panels/panel_track_width.h>
|
|
|
|
#include <calculator_panels/panel_transline.h>
|
|
|
|
#include <calculator_panels/panel_via_size.h>
|
2022-07-06 18:28:59 +00:00
|
|
|
#include <calculator_panels/panel_wavelength.h>
|
2023-06-26 23:21:40 +00:00
|
|
|
#include <calculator_panels/panel_eseries_display.h>
|
2023-06-16 14:29:31 +00:00
|
|
|
#include "widgets/wx_menubar.h"
|
2021-10-08 17:13:41 +00:00
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2024-05-01 02:42:13 +00:00
|
|
|
BEGIN_EVENT_TABLE( PCB_CALCULATOR_FRAME, KIWAY_PLAYER )
|
2023-06-28 06:56:40 +00:00
|
|
|
EVT_MENU( wxID_CLOSE, PCB_CALCULATOR_FRAME::OnExit )
|
|
|
|
EVT_MENU( wxID_EXIT, PCB_CALCULATOR_FRAME::OnExit )
|
|
|
|
END_EVENT_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
|
|
|
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
2023-06-14 11:52:20 +00:00
|
|
|
KIWAY_PLAYER( aKiway, aParent, FRAME_CALC, _( "Calculator Tools" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
2023-01-27 22:41:05 +00:00
|
|
|
wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL,
|
2023-06-14 11:52:20 +00:00
|
|
|
wxT( "calculator_tools" ), unityScale ),
|
2022-01-03 22:09:56 +00:00
|
|
|
m_lastNotebookPage( -1 )
|
2011-08-05 19:53:42 +00:00
|
|
|
{
|
2023-06-16 14:29:31 +00:00
|
|
|
m_aboutTitle = _HKI( "KiCad Calculator Tools" );
|
|
|
|
|
2019-06-11 14:20:28 +00:00
|
|
|
SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
|
2019-06-16 18:35:32 +00:00
|
|
|
// some methods in code and avoid link errors
|
2019-06-11 14:20:28 +00:00
|
|
|
|
2021-10-08 17:28:10 +00:00
|
|
|
SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
|
|
|
|
|
|
m_mainSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
2022-01-27 20:54:57 +00:00
|
|
|
m_treebook = new wxTreebook( this, wxID_ANY );
|
|
|
|
m_treebook->SetFont( KIUI::GetControlFont( this ) );
|
|
|
|
m_mainSizer->Add( m_treebook, 1, wxEXPAND | wxLEFT | wxTOP, 0 );
|
|
|
|
|
2021-10-08 17:28:10 +00:00
|
|
|
SetSizer( m_mainSizer );
|
|
|
|
Layout();
|
|
|
|
Centre( wxBOTH );
|
|
|
|
|
2023-06-16 14:29:31 +00:00
|
|
|
loadPages();
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2011-09-09 19:30:59 +00:00
|
|
|
// Give an icon
|
|
|
|
wxIcon icon;
|
2020-12-22 19:41:32 +00:00
|
|
|
wxIconBundle icon_bundle;
|
|
|
|
|
2024-01-16 22:21:01 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbcalculator, 48 ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbcalculator, 128 ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbcalculator, 256 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbcalculator_32 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbcalculator_16 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
|
|
|
|
SetIcons( icon_bundle );
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2023-06-16 14:29:31 +00:00
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
|
|
|
|
|
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
|
|
|
|
|
|
|
// Register tools
|
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
|
|
|
m_toolManager->RegisterTool( new PCB_CALCULATOR_CONTROL );
|
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
|
|
|
ReCreateMenuBar();
|
2024-05-01 02:42:13 +00:00
|
|
|
setupUIConditions();
|
2023-06-16 14:29:31 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
|
|
|
|
// Set previous size and position
|
2020-11-16 11:16:44 +00:00
|
|
|
SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
if( m_framePos == wxDefaultPosition )
|
2011-08-05 19:53:42 +00:00
|
|
|
Centre();
|
2021-10-08 16:30:36 +00:00
|
|
|
|
2022-03-20 09:00:34 +00:00
|
|
|
// Expand treebook to show all options:
|
|
|
|
for( size_t pageId = 0; pageId < m_treebook->GetPageCount(); pageId++ )
|
|
|
|
m_treebook->ExpandNode( pageId );
|
|
|
|
|
2021-10-08 17:28:10 +00:00
|
|
|
// Connect Events
|
|
|
|
Bind( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME::OnClosePcbCalc ), this );
|
|
|
|
Bind( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME::OnUpdateUI ), this );
|
|
|
|
|
2021-10-08 16:30:36 +00:00
|
|
|
Bind( wxEVT_SYS_COLOUR_CHANGED,
|
|
|
|
wxSysColourChangedEventHandler( PCB_CALCULATOR_FRAME::onThemeChanged ), this );
|
2022-02-21 02:31:37 +00:00
|
|
|
|
2022-01-27 20:54:57 +00:00
|
|
|
m_treebook->Connect( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, wxTreebookEventHandler(
|
2022-12-29 14:02:25 +00:00
|
|
|
PCB_CALCULATOR_FRAME::OnPageChanged ), nullptr, this );
|
2011-08-05 19:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
|
|
|
|
{
|
2022-01-27 20:54:57 +00:00
|
|
|
m_treebook->Disconnect( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, wxTreebookEventHandler(
|
2022-12-29 14:02:25 +00:00
|
|
|
PCB_CALCULATOR_FRAME::OnPageChanged ), nullptr, this );
|
2021-06-09 19:32:58 +00:00
|
|
|
// This needed for OSX: avoids further OnDraw processing after this destructor and before
|
2021-02-11 23:43:08 +00:00
|
|
|
// the native window is destroyed
|
2011-08-05 19:53:42 +00:00
|
|
|
this->Freeze();
|
|
|
|
}
|
|
|
|
|
2023-06-16 14:29:31 +00:00
|
|
|
|
2023-06-28 06:56:40 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnExit( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetId() == wxID_EXIT )
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
|
|
|
|
if( aEvent.GetId() == wxID_CLOSE || Kiface().IsSingle() )
|
|
|
|
Close( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-16 14:29:31 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::loadPages()
|
|
|
|
{
|
|
|
|
m_treebook->AddPage( nullptr, _( "General system design" ) );
|
|
|
|
|
|
|
|
AddCalculator( new PANEL_REGULATOR( m_treebook ), _( "Regulators" ) );
|
2023-06-26 23:21:40 +00:00
|
|
|
AddCalculator( new PANEL_R_CALCULATOR( m_treebook ), _( "Resistor Calculator" ) );
|
2023-06-16 14:29:31 +00:00
|
|
|
|
|
|
|
m_treebook->AddPage( nullptr, _( "Power, current and isolation" ) );
|
|
|
|
|
|
|
|
AddCalculator( new PANEL_ELECTRICAL_SPACING( m_treebook ), _( "Electrical Spacing" ) );
|
|
|
|
AddCalculator( new PANEL_VIA_SIZE( m_treebook ), _( "Via Size" ) );
|
|
|
|
AddCalculator( new PANEL_TRACK_WIDTH( m_treebook ), _( "Track Width" ) );
|
|
|
|
AddCalculator( new PANEL_FUSING_CURRENT( m_treebook ), _( "Fusing Current" ) );
|
|
|
|
AddCalculator( new PANEL_CABLE_SIZE( m_treebook ), _( "Cable Size" ) );
|
|
|
|
|
|
|
|
m_treebook->AddPage( nullptr, _( "High Speed" ) );
|
|
|
|
|
|
|
|
AddCalculator( new PANEL_WAVELENGTH( m_treebook ), _( "Wavelength" ) );
|
|
|
|
AddCalculator( new PANEL_RF_ATTENUATORS( m_treebook ), _( "RF Attenuators" ) );
|
|
|
|
AddCalculator( new PANEL_TRANSLINE( m_treebook ), _( "Transmission Lines") );
|
|
|
|
|
|
|
|
m_treebook->AddPage( nullptr, _( "Memo" ) );
|
|
|
|
|
2023-06-26 23:21:40 +00:00
|
|
|
AddCalculator( new PANEL_ESERIES_DISPLAY( m_treebook ), _( "E-Series" ) );
|
2023-06-16 14:29:31 +00:00
|
|
|
AddCalculator( new PANEL_COLOR_CODE( m_treebook ), _( "Color Code" ) );
|
|
|
|
AddCalculator( new PANEL_BOARD_CLASS( m_treebook ), _( "Board Classes" ) );
|
|
|
|
AddCalculator( new PANEL_GALVANIC_CORROSION( m_treebook ), _( "Galvanic Corrosion" ) );
|
|
|
|
|
|
|
|
LoadSettings( config() );
|
|
|
|
|
|
|
|
if( PANEL_REGULATOR* regPanel = GetCalculator<PANEL_REGULATOR>() )
|
|
|
|
regPanel->ReadDataFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_CALCULATOR_FRAME::doReCreateMenuBar()
|
|
|
|
{
|
|
|
|
COMMON_CONTROL* tool = m_toolManager->GetTool<COMMON_CONTROL>();
|
|
|
|
EDA_BASE_FRAME* base_frame = dynamic_cast<EDA_BASE_FRAME*>( this );
|
|
|
|
|
|
|
|
// base_frame == nullptr should not happen, but it makes Coverity happy
|
|
|
|
wxCHECK( base_frame, /* void */ );
|
|
|
|
|
|
|
|
// wxWidgets handles the OSX Application menu behind the scenes, but that means
|
|
|
|
// we always have to start from scratch with a new wxMenuBar.
|
|
|
|
wxMenuBar* oldMenuBar = base_frame->GetMenuBar();
|
|
|
|
WX_MENUBAR* menuBar = new WX_MENUBAR();
|
|
|
|
|
|
|
|
//-- File menu -----------------------------------------------------------
|
|
|
|
//
|
|
|
|
ACTION_MENU* fileMenu = new ACTION_MENU( false, tool );
|
|
|
|
|
2023-06-28 14:00:26 +00:00
|
|
|
fileMenu->AddClose( _( "Calculator Tools" ) );
|
2023-06-16 14:29:31 +00:00
|
|
|
fileMenu->AddQuit( _( "Calculator Tools" ) );
|
|
|
|
|
|
|
|
//-- Preferences menu -----------------------------------------------
|
|
|
|
//
|
|
|
|
ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
|
|
|
|
|
2023-08-07 23:51:22 +00:00
|
|
|
prefsMenu->Add( ACTIONS::openPreferences );
|
2023-06-16 14:29:31 +00:00
|
|
|
|
|
|
|
prefsMenu->AppendSeparator();
|
|
|
|
AddMenuLanguageList( prefsMenu, tool );
|
|
|
|
|
|
|
|
|
|
|
|
//-- Menubar -------------------------------------------------------------
|
|
|
|
//
|
|
|
|
menuBar->Append( fileMenu, _( "&File" ) );
|
|
|
|
menuBar->Append( prefsMenu, _( "&Preferences" ) );
|
|
|
|
base_frame->AddStandardHelpMenu( menuBar );
|
|
|
|
|
|
|
|
base_frame->SetMenuBar( menuBar );
|
|
|
|
delete oldMenuBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_CALCULATOR_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::ShowChangedLanguage();
|
|
|
|
|
|
|
|
SetTitle( _( "Calculator Tools" ) );
|
|
|
|
|
|
|
|
SaveSettings( config() );
|
|
|
|
Freeze();
|
|
|
|
|
|
|
|
int page = m_treebook->GetSelection();
|
|
|
|
m_treebook->DeleteAllPages();
|
|
|
|
m_panels.clear();
|
|
|
|
|
|
|
|
loadPages();
|
|
|
|
Layout();
|
|
|
|
|
|
|
|
m_treebook->SetSelection( page );
|
|
|
|
LoadSettings( config() );
|
|
|
|
|
|
|
|
Thaw();
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-27 20:54:57 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnPageChanged ( wxTreebookEvent& aEvent )
|
|
|
|
{
|
|
|
|
int page = aEvent.GetSelection();
|
2022-02-21 02:31:37 +00:00
|
|
|
|
2022-01-27 20:54:57 +00:00
|
|
|
// If the selected page is a top level page
|
|
|
|
if ( m_treebook->GetPageParent( page ) == wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
m_treebook->ExpandNode( page );
|
2023-06-16 14:29:31 +00:00
|
|
|
|
2022-01-27 20:54:57 +00:00
|
|
|
// Select the first child
|
2023-06-16 14:29:31 +00:00
|
|
|
if( page + 1 < m_treebook->GetPageCount() )
|
|
|
|
m_treebook->ChangeSelection( page + 1 );
|
2022-01-27 20:54:57 +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
|
|
|
|
2023-06-16 14:29:31 +00:00
|
|
|
|
2021-10-08 17:13:41 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::AddCalculator( CALCULATOR_PANEL *aPanel, const wxString& panelUIName )
|
|
|
|
{
|
|
|
|
// Update internal structures
|
|
|
|
m_panels.push_back( aPanel );
|
2021-10-12 12:08:42 +00:00
|
|
|
m_panelTypes[ typeid( *aPanel ).hash_code() ] = aPanel;
|
|
|
|
|
2022-01-27 20:54:57 +00:00
|
|
|
m_treebook->AddSubPage( aPanel, panelUIName );
|
2021-10-08 17:13:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_CALCULATOR_FRAME::onThemeChanged( wxSysColourChangedEvent& aEvent )
|
2021-10-08 16:30:36 +00:00
|
|
|
{
|
|
|
|
// Force the bitmaps to refresh
|
|
|
|
GetBitmapStore()->ThemeChanged();
|
|
|
|
|
|
|
|
// Update the panels
|
2021-10-08 17:13:41 +00:00
|
|
|
for( auto& panel : m_panels )
|
|
|
|
panel->ThemeChanged();
|
2021-10-08 16:30:36 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
|
|
|
|
{
|
2022-01-27 20:54:57 +00:00
|
|
|
if( m_treebook->GetSelection() != m_lastNotebookPage )
|
2021-02-11 23:43:08 +00:00
|
|
|
{
|
|
|
|
// Kick all the things that wxWidgets can't seem to redraw on its own.
|
2021-02-13 22:28:43 +00:00
|
|
|
// This is getting seriously ridiculous....
|
2021-10-12 12:08:42 +00:00
|
|
|
PANEL_TRANSLINE* translinePanel = GetCalculator<PANEL_TRANSLINE>();
|
2023-01-27 22:41:05 +00:00
|
|
|
PANEL_RF_ATTENUATORS* attenPanel = GetCalculator<PANEL_RF_ATTENUATORS>();
|
2021-10-12 12:08:42 +00:00
|
|
|
PANEL_VIA_SIZE* viaSizePanel = GetCalculator<PANEL_VIA_SIZE>();
|
|
|
|
PANEL_REGULATOR* regulPanel = GetCalculator<PANEL_REGULATOR>();
|
|
|
|
PANEL_ELECTRICAL_SPACING* elecSpacingPanel = GetCalculator<PANEL_ELECTRICAL_SPACING>();
|
|
|
|
|
|
|
|
wxASSERT( translinePanel );
|
|
|
|
wxASSERT( attenPanel );
|
|
|
|
wxASSERT( viaSizePanel );
|
|
|
|
wxASSERT( regulPanel );
|
|
|
|
wxASSERT( elecSpacingPanel );
|
|
|
|
|
2021-10-08 17:13:41 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent event2( wxEVT_RADIOBUTTON );
|
|
|
|
event2.SetEventObject( translinePanel->GetTranslineSelector() );
|
|
|
|
event2.SetInt( translinePanel->GetCurrTransLineType() );
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2021-10-08 17:13:41 +00:00
|
|
|
translinePanel->GetTranslineSelector()->Command( event2 );
|
|
|
|
}
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2021-10-12 12:08:42 +00:00
|
|
|
for( int i = 0; i < attenPanel->m_AttenuatorList.size(); ++i )
|
2021-02-11 23:43:08 +00:00
|
|
|
{
|
2021-10-12 12:08:42 +00:00
|
|
|
if( attenPanel->m_AttenuatorList[i] == attenPanel->m_CurrAttenuator )
|
2021-02-11 23:43:08 +00:00
|
|
|
{
|
2021-10-12 12:08:42 +00:00
|
|
|
wxCommandEvent event2( wxEVT_RADIOBUTTON );
|
|
|
|
event2.SetEventObject( attenPanel->GetAttenuatorsSelector() );
|
|
|
|
event2.SetInt( i );
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2021-10-12 12:08:42 +00:00
|
|
|
attenPanel->GetAttenuatorsSelector()->Command( event2 );
|
|
|
|
break;
|
|
|
|
}
|
2021-10-08 17:13:41 +00:00
|
|
|
}
|
2021-10-04 08:22:34 +00:00
|
|
|
|
2021-10-12 12:08:42 +00:00
|
|
|
attenPanel->UpdateUI();
|
|
|
|
viaSizePanel->Layout();
|
|
|
|
regulPanel->Layout();
|
2021-02-11 23:43:08 +00:00
|
|
|
|
|
|
|
// Until it's shown on screen the above won't work; but doing it anyway at least keeps
|
|
|
|
// putting new OnUpdateUI events into the queue until it *is* shown on screen.
|
2022-01-27 20:54:57 +00:00
|
|
|
if( m_treebook->IsShownOnScreen() )
|
|
|
|
m_lastNotebookPage = m_treebook->GetSelection();
|
2021-02-11 23:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-03 18:26:05 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
|
|
|
|
{
|
2021-10-08 17:13:41 +00:00
|
|
|
PANEL_REGULATOR* regPanel = GetCalculator<PANEL_REGULATOR>();
|
|
|
|
|
2021-10-12 12:08:42 +00:00
|
|
|
wxASSERT( regPanel );
|
|
|
|
|
|
|
|
if( regPanel->m_RegulatorListChanged )
|
2012-04-03 18:26:05 +00:00
|
|
|
{
|
2021-02-11 23:43:08 +00:00
|
|
|
wxString msg;
|
|
|
|
wxString title = _( "Write Data Failed" );
|
|
|
|
|
2021-10-08 17:13:41 +00:00
|
|
|
if( regPanel->GetDataFilename().IsEmpty() )
|
2012-04-03 18:26:05 +00:00
|
|
|
{
|
2021-02-11 23:43:08 +00:00
|
|
|
msg = _( "No data filename to save modifications.\n"
|
|
|
|
"Do you want to exit and abandon your changes?" );
|
2015-08-09 09:03:25 +00:00
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
if( wxMessageBox( msg, title, wxYES_NO | wxICON_QUESTION ) == wxNO )
|
2012-04-03 18:26:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-08 17:13:41 +00:00
|
|
|
if( !regPanel->WriteDataFile() )
|
2012-04-03 18:26:05 +00:00
|
|
|
{
|
2021-02-11 23:43:08 +00:00
|
|
|
msg.Printf( _( "Unable to write file '%s'\n"
|
|
|
|
"Do you want to exit and abandon your changes?"),
|
2021-10-08 17:13:41 +00:00
|
|
|
regPanel->GetDataFilename() );
|
2012-04-03 18:26:05 +00:00
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
if( wxMessageBox( msg, title, wxYES_NO | wxICON_ERROR ) == wxNO )
|
2012-04-03 18:26:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-09 09:03:25 +00:00
|
|
|
event.Skip();
|
2012-04-03 18:26:05 +00:00
|
|
|
}
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2011-08-05 19:53:42 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
if( aCfg == nullptr )
|
2011-08-05 19:53:42 +00:00
|
|
|
return;
|
|
|
|
|
2015-08-09 09:03:25 +00:00
|
|
|
EDA_BASE_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2020-08-24 10:40:38 +00:00
|
|
|
PCB_CALCULATOR_SETTINGS* cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2022-01-27 20:54:57 +00:00
|
|
|
m_treebook->ChangeSelection( cfg->m_LastPage );
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2023-01-27 22:41:05 +00:00
|
|
|
for( CALCULATOR_PANEL* panel : m_panels )
|
2021-10-08 17:13:41 +00:00
|
|
|
panel->LoadSettings( cfg );
|
2011-08-05 19:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2011-08-05 19:53:42 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
if( aCfg == nullptr )
|
2011-08-05 19:53:42 +00:00
|
|
|
return;
|
|
|
|
|
2015-08-09 09:03:25 +00:00
|
|
|
EDA_BASE_FRAME::SaveSettings( aCfg );
|
|
|
|
|
2020-08-24 10:40:38 +00:00
|
|
|
// Save current parameters values in config.
|
|
|
|
auto cfg = dynamic_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
|
|
|
|
|
|
|
|
if( cfg )
|
2012-04-02 18:11:00 +00:00
|
|
|
{
|
2022-01-27 20:54:57 +00:00
|
|
|
cfg->m_LastPage = m_treebook->GetSelection();
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2023-01-27 22:41:05 +00:00
|
|
|
for( CALCULATOR_PANEL* panel : m_panels )
|
2021-10-08 17:13:41 +00:00
|
|
|
panel->SaveSettings( cfg );
|
2020-08-24 10:40:38 +00:00
|
|
|
}
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
}
|