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
|
2020-08-24 10:40:38 +00:00
|
|
|
* Copyright (C) 1992-2020 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
|
|
|
*/
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <wx/wx.h>
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <bitmaps.h>
|
2019-06-11 14:20:28 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2020-08-24 10:40:38 +00:00
|
|
|
#include <kiface_i.h>
|
2021-02-12 22:05:45 +00:00
|
|
|
#include "bitmaps/viacalc.cpp"
|
2021-02-13 14:43:25 +00:00
|
|
|
#include "bitmaps/regul.cpp"
|
|
|
|
#include "bitmaps/regul_3pins.cpp"
|
2020-10-13 01:01:25 +00:00
|
|
|
#include "attenuators/attenuator_classes.h"
|
|
|
|
#include "class_regulator_data.h"
|
|
|
|
#include "pcb_calculator_frame.h"
|
|
|
|
#include "pcb_calculator_settings.h"
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2019-08-20 17:22:30 +00:00
|
|
|
// extension of pcb_calculator data filename:
|
2012-04-05 18:56:06 +00:00
|
|
|
const wxString DataFileNameExt( wxT("pcbcalc") );
|
|
|
|
|
* 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 ) :
|
2021-02-11 23:43:08 +00:00
|
|
|
PCB_CALCULATOR_FRAME_BASE( aParent ),
|
2021-02-14 11:17:12 +00:00
|
|
|
m_lastNotebookPage( -1 ),
|
|
|
|
m_macHack( true )
|
2011-08-05 19:53:42 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
m_bpButtonCalcAtt->SetBitmap( KiBitmap( BITMAPS::small_down ) );
|
|
|
|
m_bpButtonAnalyze->SetBitmap( KiBitmap( BITMAPS::small_down ) );
|
|
|
|
m_bpButtonSynthetize->SetBitmap( KiBitmap( BITMAPS::small_up ) );
|
2020-12-24 15:01:52 +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
|
|
|
SetKiway( this, aKiway );
|
2011-08-05 19:53:42 +00:00
|
|
|
m_currTransLine = NULL;
|
2014-03-22 08:28:39 +00:00
|
|
|
m_currTransLineType = DEFAULT_TYPE;
|
2012-04-02 18:11:00 +00:00
|
|
|
m_currAttenuator = NULL;
|
|
|
|
m_RegulatorListChanged = false;
|
2015-08-09 07:15:42 +00:00
|
|
|
m_TWMode = TW_MASTER_CURRENT;
|
|
|
|
m_TWNested = false;
|
2011-08-05 19:53:42 +00:00
|
|
|
|
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
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
// Populate transline list ordered like in dialog menu list
|
2014-03-22 08:28:39 +00:00
|
|
|
const static TRANSLINE_TYPE_ID tltype_list[8] =
|
2021-02-11 23:43:08 +00:00
|
|
|
{
|
|
|
|
MICROSTRIP_TYPE,
|
|
|
|
CPW_TYPE,
|
|
|
|
GROUNDED_CPW_TYPE,
|
|
|
|
RECTWAVEGUIDE_TYPE,
|
|
|
|
COAX_TYPE,
|
|
|
|
C_MICROSTRIP_TYPE,
|
|
|
|
STRIPLINE_TYPE,
|
|
|
|
TWISTEDPAIR_TYPE
|
|
|
|
};
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
for( int ii = 0; ii < 8; ii++ )
|
|
|
|
m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) );
|
|
|
|
|
|
|
|
// Populate attenuator list ordered like in dialog menu list
|
|
|
|
m_attenuator_list.push_back( new ATTENUATOR_PI() );
|
|
|
|
m_attenuator_list.push_back( new ATTENUATOR_TEE() );
|
|
|
|
m_attenuator_list.push_back( new ATTENUATOR_BRIDGE() );
|
|
|
|
m_attenuator_list.push_back( new ATTENUATOR_SPLITTER() );
|
|
|
|
m_currAttenuator = m_attenuator_list[0];
|
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
|
|
|
|
m_staticTextAttMsg->SetFont( infoFont );
|
|
|
|
|
2021-02-13 22:28:43 +00:00
|
|
|
m_IadjUnitLabel->SetLabel( wxT( "µA" ) );
|
|
|
|
|
|
|
|
m_attZinUnit->SetLabel( wxT( "Ω" ) );
|
|
|
|
m_attZoutUnit->SetLabel( wxT( "Ω" ) );
|
|
|
|
m_attR1Unit->SetLabel( wxT( "Ω" ) );
|
|
|
|
m_attR2Unit->SetLabel( wxT( "Ω" ) );
|
|
|
|
m_attR3Unit->SetLabel( wxT( "Ω" ) );
|
|
|
|
|
|
|
|
m_r1Units->SetLabel( wxT( "kΩ" ) );
|
|
|
|
m_r2Units->SetLabel( wxT( "kΩ" ) );
|
|
|
|
|
|
|
|
m_reqResUnits->SetLabel( wxT( "kΩ" ) );
|
|
|
|
m_exclude1Units->SetLabel( wxT( "kΩ" ) );
|
|
|
|
m_exclude2Units->SetLabel( wxT( "kΩ" ) );
|
|
|
|
|
2021-02-15 15:59:19 +00:00
|
|
|
m_EpsilonR_label->SetLabel( wxT( "εr" ) );
|
|
|
|
|
|
|
|
m_trackTempUnits->SetLabel( wxT( "°C" ) );
|
2021-02-13 22:28:43 +00:00
|
|
|
m_resistivityUnits->SetLabel( wxT( "Ω•m" ) );
|
|
|
|
|
2021-02-15 15:59:19 +00:00
|
|
|
m_viaResistivityUnits->SetLabel( wxT( "Ω•m" ) );
|
|
|
|
|
|
|
|
m_viaTempUnits->SetLabel( wxT( "°C" ) );
|
2021-02-13 22:28:43 +00:00
|
|
|
m_viaResUnits->SetLabel( wxT( "Ω" ) );
|
2021-02-15 15:59:19 +00:00
|
|
|
m_viaThermalResUnits->SetLabel( wxT( "°C/W" ) );
|
2021-02-13 22:28:43 +00:00
|
|
|
m_viaReactanceUnits->SetLabel( wxT( "Ω" ) );
|
|
|
|
|
|
|
|
m_extTrackResUnits->SetLabel( wxT( "Ω" ) );
|
|
|
|
m_intTrackResUnits->SetLabel( wxT( "Ω" ) );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
LoadSettings( config() );
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2012-04-02 18:11:00 +00:00
|
|
|
ReadDataFile();
|
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
TranslineTypeSelection( m_currTransLineType );
|
|
|
|
m_TranslineSelection->SetSelection( m_currTransLineType );
|
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
initTrackWidthPanel();
|
|
|
|
initColorCodePanel();
|
|
|
|
initViaSizePanel();
|
|
|
|
initESeriesPanel();
|
2019-04-10 10:24:52 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
SetAttenuator( m_AttenuatorsSelection->GetSelection() );
|
|
|
|
|
|
|
|
ToleranceSelection( m_rbToleranceSelection->GetSelection() );
|
|
|
|
|
|
|
|
BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() );
|
|
|
|
|
2011-08-08 11:40:23 +00:00
|
|
|
ElectricalSpacingUpdateData( m_ElectricalSpacingUnitsSelector->GetUnitScale() );
|
|
|
|
|
2012-04-02 18:11:00 +00:00
|
|
|
m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() );
|
|
|
|
SelectLastSelectedRegulator();
|
|
|
|
|
2011-09-09 19:30:59 +00:00
|
|
|
// Give an icon
|
|
|
|
wxIcon icon;
|
2020-12-22 19:41:32 +00:00
|
|
|
wxIconBundle icon_bundle;
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbcalculator ) );
|
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
|
|
|
|
2021-02-20 15:22:25 +00:00
|
|
|
// Autosize the the row label column to be sure label are not truncated
|
|
|
|
m_gridClassesValuesDisplay->SetRowLabelSize( wxGRID_AUTOSIZE );
|
|
|
|
m_gridElectricalSpacingValues->SetRowLabelSize( wxGRID_AUTOSIZE );
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
|
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < m_transline_list.size(); ii++ )
|
|
|
|
delete m_transline_list[ii];
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < m_attenuator_list.size(); ii++ )
|
|
|
|
delete m_attenuator_list[ii];
|
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
delete m_ccValueNamesBitmap;
|
|
|
|
delete m_ccValuesBitmap;
|
|
|
|
delete m_ccMultipliersBitmap;
|
|
|
|
delete m_ccTolerancesBitmap;
|
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
// This needed for OSX: avoids furter OnDraw processing after this destructor and before
|
|
|
|
// the native window is destroyed
|
2011-08-05 19:53:42 +00:00
|
|
|
this->Freeze();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
if( m_Notebook->GetSelection() != m_lastNotebookPage )
|
|
|
|
{
|
|
|
|
// 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-02-11 23:43:08 +00:00
|
|
|
|
|
|
|
wxCommandEvent event2( wxEVT_RADIOBUTTON );
|
|
|
|
event2.SetEventObject( m_TranslineSelection );
|
|
|
|
event2.SetInt( m_currTransLineType );
|
2021-02-12 15:55:38 +00:00
|
|
|
m_TranslineSelection->Command( event2 );
|
2021-02-11 23:43:08 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < m_attenuator_list.size(); ++i )
|
|
|
|
{
|
|
|
|
if( m_attenuator_list[i] == m_currAttenuator )
|
|
|
|
{
|
|
|
|
event2.SetEventObject( m_AttenuatorsSelection );
|
|
|
|
event2.SetInt( i );
|
2021-02-12 15:55:38 +00:00
|
|
|
m_AttenuatorsSelection->Command( event2 );
|
2021-02-11 23:43:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
ToleranceSelection( m_rbToleranceSelection->GetSelection() );
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2021-02-12 22:05:45 +00:00
|
|
|
m_viaBitmap->SetBitmap( KiBitmap( viacalc_xpm ) );
|
2021-03-10 13:07:40 +00:00
|
|
|
m_panelViaSize->Layout();
|
|
|
|
|
2021-02-13 16:12:52 +00:00
|
|
|
m_attenuatorBitmap->SetBitmap( *m_currAttenuator->m_SchBitMap );
|
2021-02-13 14:43:25 +00:00
|
|
|
m_bitmapRegul3pins->SetBitmap( KiBitmap( regul_3pins_xpm ) );
|
|
|
|
m_bitmapRegul4pins->SetBitmap( KiBitmap( regul_xpm ) );
|
2021-03-10 13:07:40 +00:00
|
|
|
m_panelRegulators->Layout();
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2021-02-13 22:28:43 +00:00
|
|
|
m_attenuatorBitmap->GetParent()->Layout();
|
|
|
|
m_attenuatorBitmap->GetParent()->Refresh();
|
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
m_panelESeriesHelp->Refresh();
|
|
|
|
m_htmlWinFormulas->Refresh();
|
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.
|
|
|
|
if( m_Notebook->IsShownOnScreen() )
|
2021-02-14 11:17:12 +00:00
|
|
|
{
|
|
|
|
// Work around an OSX bug where the wxGrid children don't get placed correctly until
|
|
|
|
// the first resize event.
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
if( m_macHack )
|
|
|
|
{
|
|
|
|
wxSize pageSize = m_panelElectricalSpacing->GetSize();
|
|
|
|
|
|
|
|
pageSize.x -= 100;
|
|
|
|
m_panelElectricalSpacing->SetSize( pageSize );
|
|
|
|
m_panelElectricalSpacing->Layout();
|
|
|
|
|
|
|
|
pageSize.x += 100;
|
|
|
|
m_panelElectricalSpacing->SetSize( pageSize );
|
|
|
|
m_panelElectricalSpacing->Layout();
|
|
|
|
|
|
|
|
m_macHack = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
m_lastNotebookPage = m_Notebook->GetSelection();
|
2021-02-14 11:17:12 +00:00
|
|
|
}
|
2021-02-11 23:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-03 18:26:05 +00:00
|
|
|
void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
if( m_RegulatorListChanged )
|
|
|
|
{
|
2021-02-11 23:43:08 +00:00
|
|
|
wxString msg;
|
|
|
|
wxString title = _( "Write Data Failed" );
|
|
|
|
|
2012-04-03 18:26:05 +00:00
|
|
|
if( GetDataFilename().IsEmpty() )
|
|
|
|
{
|
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
|
|
|
|
{
|
|
|
|
if( !WriteDataFile() )
|
|
|
|
{
|
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?"),
|
2020-08-24 10:40:38 +00:00
|
|
|
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
|
|
|
{
|
2015-08-09 09:03:25 +00:00
|
|
|
if( aCfg == NULL )
|
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
|
|
|
|
|
|
|
m_currTransLineType = static_cast<TRANSLINE_TYPE_ID>( cfg->m_TransLine.type );
|
|
|
|
m_Notebook->ChangeSelection( cfg->m_LastPage );
|
|
|
|
m_rbToleranceSelection->SetSelection( cfg->m_ColorCodeTolerance );
|
|
|
|
m_AttenuatorsSelection->SetSelection( cfg->m_Attenuators.type );
|
|
|
|
m_BoardClassesUnitsSelector->SetSelection( cfg->m_BoardClassUnits );
|
2012-04-02 18:11:00 +00:00
|
|
|
|
|
|
|
// Regul panel config:
|
2020-01-13 01:44:19 +00:00
|
|
|
m_RegulR1Value->SetValue( cfg->m_Regulators.r1 );
|
|
|
|
m_RegulR2Value->SetValue( cfg->m_Regulators.r2 );
|
|
|
|
m_RegulVrefValue->SetValue( cfg->m_Regulators.vref );
|
|
|
|
m_RegulVoutValue->SetValue( cfg->m_Regulators.vout );
|
|
|
|
SetDataFilename( cfg->m_Regulators.data_file );
|
|
|
|
m_lastSelectedRegulatorName = cfg->m_Regulators.selected_regulator;
|
|
|
|
m_choiceRegType->SetSelection( cfg->m_Regulators.type );
|
|
|
|
|
|
|
|
wxRadioButton* regprms[3] = { m_rbRegulR1, m_rbRegulR2, m_rbRegulVout };
|
|
|
|
|
|
|
|
if( cfg->m_Regulators.last_param >= 3 )
|
|
|
|
cfg->m_Regulators.last_param = 0;
|
|
|
|
|
2012-04-02 18:11:00 +00:00
|
|
|
for( int ii = 0; ii < 3; ii++ )
|
2020-01-13 01:44:19 +00:00
|
|
|
regprms[ii]->SetValue( cfg->m_Regulators.last_param == ii );
|
2012-04-02 18:11:00 +00:00
|
|
|
|
|
|
|
// Electrical panel config
|
2020-01-13 01:44:19 +00:00
|
|
|
m_ElectricalSpacingUnitsSelector->SetSelection( cfg->m_Electrical.spacing_units );
|
|
|
|
m_ElectricalSpacingVoltage->SetValue( cfg->m_Electrical.spacing_voltage );
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
for( TRANSLINE_IDENT* transline : m_transline_list )
|
2020-01-13 01:44:19 +00:00
|
|
|
transline->ReadConfig();
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
for( ATTENUATOR* attenuator : m_attenuator_list )
|
2020-01-13 01:44:19 +00:00
|
|
|
attenuator->ReadConfig();
|
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
|
|
|
{
|
2015-08-09 09:03:25 +00:00
|
|
|
if( aCfg == NULL )
|
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
|
|
|
{
|
2020-08-24 10:40:38 +00:00
|
|
|
cfg->m_LastPage = m_Notebook->GetSelection();
|
|
|
|
cfg->m_TransLine.type = m_currTransLineType;
|
|
|
|
cfg->m_Attenuators.type = m_AttenuatorsSelection->GetSelection();
|
|
|
|
cfg->m_ColorCodeTolerance = m_rbToleranceSelection->GetSelection();
|
|
|
|
cfg->m_BoardClassUnits = m_BoardClassesUnitsSelector->GetSelection();
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2020-08-24 10:40:38 +00:00
|
|
|
cfg->m_Electrical.spacing_units = m_ElectricalSpacingUnitsSelector->GetSelection();
|
|
|
|
cfg->m_Electrical.spacing_voltage = m_ElectricalSpacingVoltage->GetValue();
|
|
|
|
|
|
|
|
Regulators_WriteConfig( cfg );
|
|
|
|
}
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
writeTrackWidthConfig();
|
2011-08-05 19:53:42 +00:00
|
|
|
|
2021-02-12 00:47:08 +00:00
|
|
|
writeViaSizeConfig();
|
2019-04-10 10:24:52 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
for( unsigned ii = 0; ii < m_transline_list.size(); ii++ )
|
2020-01-13 01:44:19 +00:00
|
|
|
m_transline_list[ii]->WriteConfig();
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
for( unsigned ii = 0; ii < m_attenuator_list.size(); ii++ )
|
2020-01-13 01:44:19 +00:00
|
|
|
m_attenuator_list[ii]->WriteConfig();
|
2011-08-05 19:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnTranslineAnalyse
|
|
|
|
* Run a new analyse for the current transline with current parameters
|
2019-08-20 17:22:30 +00:00
|
|
|
* and displays the electrical parameters
|
2011-08-05 19:53:42 +00:00
|
|
|
*/
|
|
|
|
void PCB_CALCULATOR_FRAME::OnTranslineAnalyse( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_currTransLine )
|
|
|
|
{
|
|
|
|
TransfDlgDataToTranslineParams();
|
|
|
|
m_currTransLine->analyze();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-02 18:11:00 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
/**
|
|
|
|
* Function OnTranslineSynthetize
|
|
|
|
* Run a new synthezis for the current transline with current parameters
|
2019-08-20 17:22:30 +00:00
|
|
|
* and displays the geometrical parameters
|
2011-08-05 19:53:42 +00:00
|
|
|
*/
|
|
|
|
void PCB_CALCULATOR_FRAME::OnTranslineSynthetize( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_currTransLine )
|
|
|
|
{
|
|
|
|
TransfDlgDataToTranslineParams();
|
|
|
|
m_currTransLine->synthesize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-05 18:56:06 +00:00
|
|
|
/* returns the full filename of the selected pcb_calculator data file
|
2019-08-20 17:22:30 +00:00
|
|
|
* the extension file is forced
|
2012-04-05 18:56:06 +00:00
|
|
|
*/
|
|
|
|
const wxString PCB_CALCULATOR_FRAME::GetDataFilename()
|
|
|
|
{
|
|
|
|
if( m_regulators_fileNameCtrl->GetValue().IsEmpty() )
|
|
|
|
return wxEmptyString;
|
|
|
|
|
|
|
|
wxFileName fn( m_regulators_fileNameCtrl->GetValue() );
|
|
|
|
fn.SetExt( DataFileNameExt );
|
|
|
|
return fn.GetFullPath();
|
|
|
|
}
|
|
|
|
|
2021-02-11 23:43:08 +00:00
|
|
|
|
2012-04-05 18:56:06 +00:00
|
|
|
/* Initialize the full filename of the selected pcb_calculator data file
|
|
|
|
* force the standard extension of the file (.pcbcalc)
|
|
|
|
* aFilename = the full filename, with or without extension
|
|
|
|
*/
|
|
|
|
void PCB_CALCULATOR_FRAME::SetDataFilename( const wxString & aFilename)
|
|
|
|
{
|
|
|
|
if( aFilename.IsEmpty() )
|
|
|
|
m_regulators_fileNameCtrl->SetValue( wxEmptyString );
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxFileName fn( aFilename );
|
|
|
|
fn.SetExt( DataFileNameExt );
|
|
|
|
m_regulators_fileNameCtrl->SetValue( fn.GetFullPath() );
|
|
|
|
}
|
|
|
|
}
|