A veritable cornucopia of wxWidgets hacks for pcb calculator.
Most of these are display hacks because (at least on OSX) assigning bitmaps or doing a layout before the controls are visible tends to not work. There are also some layout cleanups and some layout hacks (horizontal radio button groups, for instance, lay out on top of each other on OSX). Fixes https://gitlab.com/kicad/code/kicad/issues/7491
This commit is contained in:
parent
baed5ed1cb
commit
9094ba8033
|
@ -78,6 +78,11 @@ void PCB_CALCULATOR_FRAME::TransfPanelDataToAttenuator()
|
||||||
|
|
||||||
void PCB_CALCULATOR_FRAME::TransfAttenuatorDataToPanel()
|
void PCB_CALCULATOR_FRAME::TransfAttenuatorDataToPanel()
|
||||||
{
|
{
|
||||||
|
// TODO: make attenuator bitmaps transparent so we can remove this
|
||||||
|
m_attenuatorPanel->SetBackgroundColour( *wxWHITE );
|
||||||
|
|
||||||
|
m_attenuatorBitmap->SetBitmap( *m_currAttenuator->m_SchBitMap );
|
||||||
|
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
msg.Printf( wxT( "%g" ), m_currAttenuator->m_Attenuation );
|
msg.Printf( wxT( "%g" ), m_currAttenuator->m_Attenuation );
|
||||||
|
@ -99,7 +104,9 @@ void PCB_CALCULATOR_FRAME::TransfAttenuatorDataToPanel()
|
||||||
if( m_currAttenuator->m_FormulaName )
|
if( m_currAttenuator->m_FormulaName )
|
||||||
{
|
{
|
||||||
if( m_currAttenuator->m_FormulaName->StartsWith( "<!" ) )
|
if( m_currAttenuator->m_FormulaName->StartsWith( "<!" ) )
|
||||||
|
{
|
||||||
m_panelAttFormula->SetPage( *m_currAttenuator->m_FormulaName );
|
m_panelAttFormula->SetPage( *m_currAttenuator->m_FormulaName );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxString html_txt;
|
wxString html_txt;
|
||||||
|
@ -108,7 +115,9 @@ void PCB_CALCULATOR_FRAME::TransfAttenuatorDataToPanel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_panelAttFormula->SetPage( wxEmptyString );
|
m_panelAttFormula->SetPage( wxEmptyString );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,8 +149,11 @@ void PCB_CALCULATOR_FRAME::TransfAttenuatorResultsToPanel()
|
||||||
m_Att_R1_Value->SetValue( msg );
|
m_Att_R1_Value->SetValue( msg );
|
||||||
msg.Printf( wxT( "%g" ), m_currAttenuator->m_R2 );
|
msg.Printf( wxT( "%g" ), m_currAttenuator->m_R2 );
|
||||||
m_Att_R2_Value->SetValue( msg );
|
m_Att_R2_Value->SetValue( msg );
|
||||||
|
|
||||||
if( m_currAttenuator->m_ResultCount < 3 )
|
if( m_currAttenuator->m_ResultCount < 3 )
|
||||||
|
{
|
||||||
m_Att_R3_Value->SetValue( wxEmptyString );
|
m_Att_R3_Value->SetValue( wxEmptyString );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg.Printf( wxT( "%g" ), m_currAttenuator->m_R3 );
|
msg.Printf( wxT( "%g" ), m_currAttenuator->m_R3 );
|
||||||
|
@ -150,17 +162,3 @@ void PCB_CALCULATOR_FRAME::TransfAttenuatorResultsToPanel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_CALCULATOR_FRAME::OnPaintAttenuatorPanel( wxPaintEvent& event )
|
|
||||||
{
|
|
||||||
wxPaintDC dc( m_panelDisplayAttenuator );
|
|
||||||
|
|
||||||
if( m_currAttenuator && m_currAttenuator->m_SchBitMap )
|
|
||||||
{
|
|
||||||
wxSize size = m_panelDisplayAttenuator->GetSize();
|
|
||||||
size.x -= m_currAttenuator->m_SchBitMap->GetWidth();
|
|
||||||
size.y -= m_currAttenuator->m_SchBitMap->GetHeight();
|
|
||||||
dc.DrawBitmap( *m_currAttenuator->m_SchBitMap, size.x / 2, size.y / 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -30,13 +30,13 @@ class UNIT_SELECTOR_THICKNESS;
|
||||||
#include <wx/icon.h>
|
#include <wx/icon.h>
|
||||||
#include <wx/statbmp.h>
|
#include <wx/statbmp.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
#include <wx/statbox.h>
|
#include <wx/statbox.h>
|
||||||
#include <wx/radiobut.h>
|
#include <wx/radiobut.h>
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
#include <wx/choice.h>
|
#include <wx/choice.h>
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
#include <wx/panel.h>
|
|
||||||
#include <wx/radiobox.h>
|
#include <wx/radiobox.h>
|
||||||
#include <wx/bmpbuttn.h>
|
#include <wx/bmpbuttn.h>
|
||||||
#include <wx/html/htmlwin.h>
|
#include <wx/html/htmlwin.h>
|
||||||
|
@ -60,6 +60,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
wxStatusBar* m_statusBar;
|
wxStatusBar* m_statusBar;
|
||||||
wxNotebook* m_Notebook;
|
wxNotebook* m_Notebook;
|
||||||
wxPanel* m_panelRegulators;
|
wxPanel* m_panelRegulators;
|
||||||
|
wxPanel* m_panelRegulatorBitmaps;
|
||||||
wxStaticBitmap* m_bitmapRegul4pins;
|
wxStaticBitmap* m_bitmapRegul4pins;
|
||||||
wxStaticBitmap* m_bitmapRegul3pins;
|
wxStaticBitmap* m_bitmapRegul3pins;
|
||||||
wxStaticText* m_RegulFormula;
|
wxStaticText* m_RegulFormula;
|
||||||
|
@ -95,7 +96,8 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
wxStaticText* m_RegulMessage;
|
wxStaticText* m_RegulMessage;
|
||||||
wxPanel* m_panelAttenuators;
|
wxPanel* m_panelAttenuators;
|
||||||
wxRadioBox* m_AttenuatorsSelection;
|
wxRadioBox* m_AttenuatorsSelection;
|
||||||
wxPanel* m_panelDisplayAttenuator;
|
wxPanel* m_attenuatorPanel;
|
||||||
|
wxStaticBitmap* m_attenuatorBitmap;
|
||||||
wxStaticText* m_attenuationLabel;
|
wxStaticText* m_attenuationLabel;
|
||||||
wxTextCtrl* m_AttValueCtrl;
|
wxTextCtrl* m_AttValueCtrl;
|
||||||
wxStaticText* m_attUnit;
|
wxStaticText* m_attUnit;
|
||||||
|
@ -120,7 +122,6 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
wxHtmlWindow* m_Attenuator_Messages;
|
wxHtmlWindow* m_Attenuator_Messages;
|
||||||
wxHtmlWindow* m_panelAttFormula;
|
wxHtmlWindow* m_panelAttFormula;
|
||||||
wxPanel* m_panelESeries;
|
wxPanel* m_panelESeries;
|
||||||
wxStaticText* m_staticTextESeriesMsg111;
|
|
||||||
wxStaticText* m_ESrequired;
|
wxStaticText* m_ESrequired;
|
||||||
wxTextCtrl* m_ResRequired;
|
wxTextCtrl* m_ResRequired;
|
||||||
wxStaticText* m_UnitRegultR111;
|
wxStaticText* m_UnitRegultR111;
|
||||||
|
@ -130,7 +131,11 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
wxStaticText* m_ESrequired11;
|
wxStaticText* m_ESrequired11;
|
||||||
wxTextCtrl* m_ResExclude2;
|
wxTextCtrl* m_ResExclude2;
|
||||||
wxStaticText* m_UnitRegultR1112;
|
wxStaticText* m_UnitRegultR1112;
|
||||||
wxRadioBox* m_rbESerieSelection;
|
wxStaticLine* m_staticline6;
|
||||||
|
wxRadioButton* m_e1;
|
||||||
|
wxRadioButton* m_e3;
|
||||||
|
wxRadioButton* m_e6;
|
||||||
|
wxRadioButton* m_e12;
|
||||||
wxStaticText* m_ESerieSimpleSolution;
|
wxStaticText* m_ESerieSimpleSolution;
|
||||||
wxTextCtrl* m_ESeries_Sol2R;
|
wxTextCtrl* m_ESeries_Sol2R;
|
||||||
wxStaticText* m_ESeriesSimpleErr;
|
wxStaticText* m_ESeriesSimpleErr;
|
||||||
|
@ -146,6 +151,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
wxStaticText* m_ESeriesAltErr1;
|
wxStaticText* m_ESeriesAltErr1;
|
||||||
wxTextCtrl* m_ESeriesError4R;
|
wxTextCtrl* m_ESeriesError4R;
|
||||||
wxStaticText* m_ESeriesAltPercent1;
|
wxStaticText* m_ESeriesAltPercent1;
|
||||||
|
wxStaticLine* m_staticline7;
|
||||||
wxButton* m_buttonEScalculate;
|
wxButton* m_buttonEScalculate;
|
||||||
wxHtmlWindow* m_panelESeriesHelp;
|
wxHtmlWindow* m_panelESeriesHelp;
|
||||||
wxPanel* m_panelColorCode;
|
wxPanel* m_panelColorCode;
|
||||||
|
@ -164,7 +170,8 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
wxStaticBitmap* m_Band_tol_bitmap;
|
wxStaticBitmap* m_Band_tol_bitmap;
|
||||||
wxPanel* m_panelTransline;
|
wxPanel* m_panelTransline;
|
||||||
wxRadioBox* m_TranslineSelection;
|
wxRadioBox* m_TranslineSelection;
|
||||||
wxPanel* m_panelDisplayshape;
|
wxPanel* m_translinePanel;
|
||||||
|
wxStaticBitmap* m_translineBitmap;
|
||||||
wxStaticLine* m_staticline1;
|
wxStaticLine* m_staticline1;
|
||||||
wxStaticText* m_EpsilonR_label;
|
wxStaticText* m_EpsilonR_label;
|
||||||
wxTextCtrl* m_Value_EpsilonR;
|
wxTextCtrl* m_Value_EpsilonR;
|
||||||
|
@ -374,6 +381,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
|
|
||||||
// Virtual event handlers, overide them in your derived class
|
// Virtual event handlers, overide them in your derived class
|
||||||
virtual void OnClosePcbCalc( wxCloseEvent& event ) { event.Skip(); }
|
virtual void OnClosePcbCalc( wxCloseEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||||
virtual void OnRegulTypeSelection( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnRegulTypeSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnRegulatorCalcButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnRegulatorCalcButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnRegulatorResetButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnRegulatorResetButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
@ -383,13 +391,11 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
|
||||||
virtual void OnAddRegulator( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnAddRegulator( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnRemoveRegulator( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnRemoveRegulator( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnAttenuatorSelection( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnAttenuatorSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnPaintAttenuatorPanel( wxPaintEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnCalculateAttenuator( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnCalculateAttenuator( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnESerieSelection( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnESeriesSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnCalculateESeries( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnCalculateESeries( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnToleranceSelection( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnToleranceSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnTranslineSelection( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnTranslineSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnPaintTranslinePanel( wxPaintEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnTranslineEpsilonR_Button( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnTranslineEpsilonR_Button( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnTranslineTanD_Button( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnTranslineTanD_Button( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnTranslineRho_Button( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnTranslineRho_Button( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
|
|
@ -53,11 +53,6 @@ void eserie::set_rb( uint32_t a_rb )
|
||||||
rb_state = a_rb;
|
rb_state = a_rb;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t eserie::get_rb( void )
|
|
||||||
{
|
|
||||||
return rb_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<r_data, S4R + 1> eserie::get_rslt( void )
|
std::array<r_data, S4R + 1> eserie::get_rslt( void )
|
||||||
{
|
{
|
||||||
return results;
|
return results;
|
||||||
|
@ -414,9 +409,16 @@ void PCB_CALCULATOR_FRAME::OnCalculateESeries( wxCommandEvent& event )
|
||||||
m_ESeries_Sol4R->SetValue( fs );
|
m_ESeries_Sol4R->SetValue( fs );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCB_CALCULATOR_FRAME::OnESerieSelection( wxCommandEvent& event )
|
void PCB_CALCULATOR_FRAME::OnESeriesSelection( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
r.set_rb ( event.GetSelection() );
|
if( event.GetEventObject() == m_e1 )
|
||||||
|
r.set_rb( E1 );
|
||||||
|
else if( event.GetEventObject() == m_e3 )
|
||||||
|
r.set_rb( E3 );
|
||||||
|
else if( event.GetEventObject() == m_e12 )
|
||||||
|
r.set_rb( E12 );
|
||||||
|
else
|
||||||
|
r.set_rb( E6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCB_CALCULATOR_FRAME::ES_Init() // initialize ESeries tab at each pcb-calculator start
|
void PCB_CALCULATOR_FRAME::ES_Init() // initialize ESeries tab at each pcb-calculator start
|
||||||
|
|
|
@ -232,10 +232,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Interface for CheckBox, RadioButton, RequriedResistor and calculated Results
|
* Interface for CheckBox, RadioButton, RequriedResistor and calculated Results
|
||||||
*/
|
*/
|
||||||
void set_4R_cb ( bool a_tb );
|
|
||||||
bool get_4R_cb ( void );
|
|
||||||
void set_rb ( uint32_t a_rb );
|
void set_rb ( uint32_t a_rb );
|
||||||
uint32_t get_rb ( void );
|
|
||||||
void set_reqR ( double aR );
|
void set_reqR ( double aR );
|
||||||
std::array<r_data,S4R+1> get_rslt ( void );
|
std::array<r_data,S4R+1> get_rslt ( void );
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,17 +22,22 @@
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <geometry/shape_poly_set.h>
|
#include <geometry/shape_poly_set.h>
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
|
#include "bitmaps/color_code_value_and_name.xpm"
|
||||||
|
#include "bitmaps/color_code_value.xpm"
|
||||||
|
#include "bitmaps/color_code_multiplier.xpm"
|
||||||
|
#include "bitmaps/color_code_tolerance.xpm"
|
||||||
#include "attenuators/attenuator_classes.h"
|
#include "attenuators/attenuator_classes.h"
|
||||||
#include "class_regulator_data.h"
|
#include "class_regulator_data.h"
|
||||||
#include "pcb_calculator_frame.h"
|
#include "pcb_calculator_frame.h"
|
||||||
#include "pcb_calculator_settings.h"
|
#include "pcb_calculator_settings.h"
|
||||||
|
|
||||||
|
|
||||||
// extension of pcb_calculator data filename:
|
// extension of pcb_calculator data filename:
|
||||||
const wxString DataFileNameExt( wxT("pcbcalc") );
|
const wxString DataFileNameExt( wxT("pcbcalc") );
|
||||||
|
|
||||||
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
PCB_CALCULATOR_FRAME_BASE( aParent )
|
PCB_CALCULATOR_FRAME_BASE( aParent ),
|
||||||
|
m_lastNotebookPage( -1 )
|
||||||
{
|
{
|
||||||
m_bpButtonCalcAtt->SetBitmap( KiBitmap( small_down_xpm ) );
|
m_bpButtonCalcAtt->SetBitmap( KiBitmap( small_down_xpm ) );
|
||||||
m_bpButtonAnalyze->SetBitmap( KiBitmap( small_down_xpm ) );
|
m_bpButtonAnalyze->SetBitmap( KiBitmap( small_down_xpm ) );
|
||||||
|
@ -46,16 +51,24 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
m_TWMode = TW_MASTER_CURRENT;
|
m_TWMode = TW_MASTER_CURRENT;
|
||||||
m_TWNested = false;
|
m_TWNested = false;
|
||||||
|
|
||||||
|
// TODO: make regulator bitmaps transparent so we can remove this
|
||||||
|
m_panelRegulatorBitmaps->SetBackgroundColour( *wxWHITE );
|
||||||
|
|
||||||
SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
|
SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
|
||||||
// some methods in code and avoid link errors
|
// some methods in code and avoid link errors
|
||||||
|
|
||||||
// Populate transline list ordered like in dialog menu list
|
// Populate transline list ordered like in dialog menu list
|
||||||
const static TRANSLINE_TYPE_ID tltype_list[8] =
|
const static TRANSLINE_TYPE_ID tltype_list[8] =
|
||||||
{
|
{
|
||||||
MICROSTRIP_TYPE, CPW_TYPE, GROUNDED_CPW_TYPE,
|
MICROSTRIP_TYPE,
|
||||||
RECTWAVEGUIDE_TYPE, COAX_TYPE, C_MICROSTRIP_TYPE,
|
CPW_TYPE,
|
||||||
STRIPLINE_TYPE, TWISTEDPAIR_TYPE
|
GROUNDED_CPW_TYPE,
|
||||||
};
|
RECTWAVEGUIDE_TYPE,
|
||||||
|
COAX_TYPE,
|
||||||
|
C_MICROSTRIP_TYPE,
|
||||||
|
STRIPLINE_TYPE,
|
||||||
|
TWISTEDPAIR_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
for( int ii = 0; ii < 8; ii++ )
|
for( int ii = 0; ii < 8; ii++ )
|
||||||
m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) );
|
m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) );
|
||||||
|
@ -67,6 +80,10 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
m_attenuator_list.push_back( new ATTENUATOR_SPLITTER() );
|
m_attenuator_list.push_back( new ATTENUATOR_SPLITTER() );
|
||||||
m_currAttenuator = m_attenuator_list[0];
|
m_currAttenuator = m_attenuator_list[0];
|
||||||
|
|
||||||
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||||
|
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
|
||||||
|
m_staticTextAttMsg->SetFont( infoFont );
|
||||||
|
|
||||||
LoadSettings( config() );
|
LoadSettings( config() );
|
||||||
|
|
||||||
ReadDataFile();
|
ReadDataFile();
|
||||||
|
@ -120,49 +137,89 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
|
||||||
for( unsigned ii = 0; ii < m_attenuator_list.size(); ii++ )
|
for( unsigned ii = 0; ii < m_attenuator_list.size(); ii++ )
|
||||||
delete m_attenuator_list[ii];
|
delete m_attenuator_list[ii];
|
||||||
|
|
||||||
/* This needed for OSX: avoids furter OnDraw processing after this
|
// This needed for OSX: avoids furter OnDraw processing after this destructor and before
|
||||||
* destructor and before the native window is destroyed
|
// the native window is destroyed
|
||||||
*/
|
|
||||||
this->Freeze();
|
this->Freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
wxCommandEvent event2( wxEVT_RADIOBUTTON );
|
||||||
|
event2.SetEventObject( m_TranslineSelection );
|
||||||
|
event2.SetInt( m_currTransLineType );
|
||||||
|
m_TranslineSelection->ProcessCommand( event2 );
|
||||||
|
|
||||||
|
for( int i = 0; i < m_attenuator_list.size(); ++i )
|
||||||
|
{
|
||||||
|
if( m_attenuator_list[i] == m_currAttenuator )
|
||||||
|
{
|
||||||
|
event2.SetEventObject( m_AttenuatorsSelection );
|
||||||
|
event2.SetInt( i );
|
||||||
|
m_AttenuatorsSelection->ProcessCommand( event2 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static wxBitmap* valueNameBitmap = new wxBitmap( color_code_value_and_name_xpm );
|
||||||
|
m_Band1bitmap->SetBitmap( *valueNameBitmap );
|
||||||
|
|
||||||
|
static wxBitmap* valueBitmap = new wxBitmap( color_code_value_xpm );
|
||||||
|
m_Band2bitmap->SetBitmap( *valueBitmap );
|
||||||
|
m_Band3bitmap->SetBitmap( *valueBitmap );
|
||||||
|
m_Band4bitmap->SetBitmap( *valueBitmap );
|
||||||
|
|
||||||
|
static wxBitmap* multiplierBitmap = new wxBitmap( color_code_multiplier_xpm );
|
||||||
|
m_Band_mult_bitmap->SetBitmap( *multiplierBitmap );
|
||||||
|
|
||||||
|
static wxBitmap* toleranceBitmap = new wxBitmap( color_code_tolerance_xpm );
|
||||||
|
m_Band_tol_bitmap->SetBitmap( *toleranceBitmap );
|
||||||
|
|
||||||
|
// 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() )
|
||||||
|
m_lastNotebookPage = m_Notebook->GetSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
|
void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
|
||||||
{
|
{
|
||||||
if( m_RegulatorListChanged )
|
if( m_RegulatorListChanged )
|
||||||
{
|
{
|
||||||
|
wxString msg;
|
||||||
|
wxString title = _( "Write Data Failed" );
|
||||||
|
|
||||||
if( GetDataFilename().IsEmpty() )
|
if( GetDataFilename().IsEmpty() )
|
||||||
{
|
{
|
||||||
int opt = wxMessageBox(
|
msg = _( "No data filename to save modifications.\n"
|
||||||
_("Data modified, and no data filename to save modifications\n"\
|
"Do you want to exit and abandon your changes?" );
|
||||||
"Do you want to exit and abandon your change?"),
|
|
||||||
_("Regulator list change"),
|
|
||||||
wxYES_NO | wxICON_QUESTION );
|
|
||||||
|
|
||||||
if( opt == wxNO )
|
if( wxMessageBox( msg, title, wxYES_NO | wxICON_QUESTION ) == wxNO )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !WriteDataFile() )
|
if( !WriteDataFile() )
|
||||||
{
|
{
|
||||||
wxString msg;
|
msg.Printf( _( "Unable to write file '%s'\n"
|
||||||
msg.Printf( _("Unable to write file \"%s\"\n"\
|
"Do you want to exit and abandon your changes?"),
|
||||||
"Do you want to exit and abandon your change?"),
|
|
||||||
GetDataFilename() );
|
GetDataFilename() );
|
||||||
|
|
||||||
int opt = wxMessageBox( msg, _("Write Data File Error"),
|
if( wxMessageBox( msg, title, wxYES_NO | wxICON_ERROR ) == wxNO )
|
||||||
wxYES_NO | wxICON_ERROR );
|
|
||||||
if( opt == wxNO )
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
// Destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
{
|
{
|
||||||
if( aCfg == NULL )
|
if( aCfg == NULL )
|
||||||
|
@ -199,10 +256,10 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
m_ElectricalSpacingUnitsSelector->SetSelection( cfg->m_Electrical.spacing_units );
|
m_ElectricalSpacingUnitsSelector->SetSelection( cfg->m_Electrical.spacing_units );
|
||||||
m_ElectricalSpacingVoltage->SetValue( cfg->m_Electrical.spacing_voltage );
|
m_ElectricalSpacingVoltage->SetValue( cfg->m_Electrical.spacing_voltage );
|
||||||
|
|
||||||
for( auto& transline : m_transline_list )
|
for( TRANSLINE_IDENT* transline : m_transline_list )
|
||||||
transline->ReadConfig();
|
transline->ReadConfig();
|
||||||
|
|
||||||
for( auto& attenuator : m_attenuator_list )
|
for( ATTENUATOR* attenuator : m_attenuator_list )
|
||||||
attenuator->ReadConfig();
|
attenuator->ReadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,23 +330,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineSynthetize( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_CALCULATOR_FRAME::OnPaintTranslinePanel( wxPaintEvent& event )
|
|
||||||
{
|
|
||||||
wxPaintDC dc( m_panelDisplayshape );
|
|
||||||
|
|
||||||
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
|
|
||||||
|
|
||||||
if( tr_ident )
|
|
||||||
{
|
|
||||||
wxSize size = m_panelDisplayshape->GetSize();
|
|
||||||
size.x -= tr_ident->m_Icon->GetWidth();
|
|
||||||
size.y -= tr_ident->m_Icon->GetHeight();
|
|
||||||
dc.DrawBitmap( *tr_ident->m_Icon, size.x / 2, size.y / 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* returns the full filename of the selected pcb_calculator data file
|
/* returns the full filename of the selected pcb_calculator data file
|
||||||
* the extension file is forced
|
* the extension file is forced
|
||||||
*/
|
*/
|
||||||
|
@ -303,6 +343,7 @@ const wxString PCB_CALCULATOR_FRAME::GetDataFilename()
|
||||||
return fn.GetFullPath();
|
return fn.GetFullPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the full filename of the selected pcb_calculator data file
|
/* Initialize the full filename of the selected pcb_calculator data file
|
||||||
* force the standard extension of the file (.pcbcalc)
|
* force the standard extension of the file (.pcbcalc)
|
||||||
* aFilename = the full filename, with or without extension
|
* aFilename = the full filename, with or without extension
|
||||||
|
|
|
@ -70,6 +70,9 @@ private:
|
||||||
std::vector<ATTENUATOR*> m_attenuator_list;
|
std::vector<ATTENUATOR*> m_attenuator_list;
|
||||||
wxString m_lastSelectedRegulatorName; // last regulator name selected
|
wxString m_lastSelectedRegulatorName; // last regulator name selected
|
||||||
|
|
||||||
|
int m_lastNotebookPage;
|
||||||
|
int m_lastRadioButton;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
||||||
~PCB_CALCULATOR_FRAME();
|
~PCB_CALCULATOR_FRAME();
|
||||||
|
@ -78,10 +81,7 @@ private:
|
||||||
// Event handlers
|
// Event handlers
|
||||||
void OnClosePcbCalc( wxCloseEvent& event ) override;
|
void OnClosePcbCalc( wxCloseEvent& event ) override;
|
||||||
|
|
||||||
// These 3 functions are called by the OnPaint event, to draw
|
void OnUpdateUI( wxUpdateUIEvent& event ) override;
|
||||||
// icons that show the current item on the specific panels
|
|
||||||
void OnPaintTranslinePanel( wxPaintEvent& event ) override;
|
|
||||||
void OnPaintAttenuatorPanel( wxPaintEvent& event ) override;
|
|
||||||
|
|
||||||
// Config read-write, virtual from EDA_BASE_FRAME
|
// Config read-write, virtual from EDA_BASE_FRAME
|
||||||
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||||
|
@ -127,7 +127,7 @@ private:
|
||||||
* Radio Buttons to select the E-serie for the resistor calculator
|
* Radio Buttons to select the E-serie for the resistor calculator
|
||||||
* @param event contains the radio button state
|
* @param event contains the radio button state
|
||||||
*/
|
*/
|
||||||
void OnESerieSelection( wxCommandEvent& event ) override;
|
void OnESeriesSelection( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function TW_WriteConfig
|
* Function TW_WriteConfig
|
||||||
|
@ -174,23 +174,23 @@ private:
|
||||||
* Function TWCalculateWidth
|
* Function TWCalculateWidth
|
||||||
* Calculate track width required based on given current and temperature rise.
|
* Calculate track width required based on given current and temperature rise.
|
||||||
*/
|
*/
|
||||||
double TWCalculateWidth(
|
double TWCalculateWidth( double aCurrent, double aThickness, double aDeltaT_C,
|
||||||
double aCurrent, double aThickness, double aDeltaT_C, bool aUseInternalLayer );
|
bool aUseInternalLayer );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function TWCalculateCurrent
|
* Function TWCalculateCurrent
|
||||||
* Calculate maximum current based on given width and temperature rise.
|
* Calculate maximum current based on given width and temperature rise.
|
||||||
*/
|
*/
|
||||||
double TWCalculateCurrent(
|
double TWCalculateCurrent( double aWidth, double aThickness, double aDeltaT_C,
|
||||||
double aWidth, double aThickness, double aDeltaT_C, bool aUseInternalLayer );
|
bool aUseInternalLayer );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function TWDisplayValues
|
* Function TWDisplayValues
|
||||||
* Displays the results of a calculation (including resulting values such
|
* Displays the results of a calculation (including resulting values such
|
||||||
* as the resistance and power loss).
|
* as the resistance and power loss).
|
||||||
*/
|
*/
|
||||||
void TWDisplayValues( double aCurrent, double aExtWidth, double aIntWidth, double aExtThickness,
|
void TWDisplayValues( double aCurrent, double aExtWidth, double aIntWidth,
|
||||||
double aIntThickness );
|
double aExtThickness, double aIntThickness );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function TWUpdateModeDisplay
|
* Function TWUpdateModeDisplay
|
||||||
|
@ -246,8 +246,9 @@ private:
|
||||||
* Displays the results of the calculation.
|
* Displays the results of the calculation.
|
||||||
*/
|
*/
|
||||||
void VSDisplayValues( double aViaResistance, double aVoltageDrop, double aPowerLoss,
|
void VSDisplayValues( double aViaResistance, double aVoltageDrop, double aPowerLoss,
|
||||||
double aEstimatedAmpacity, double aThermalResistance, double aCapacitance,
|
double aEstimatedAmpacity, double aThermalResistance,
|
||||||
double aTimeDegradation, double aInductance, double aReactance );
|
double aCapacitance, double aTimeDegradation, double aInductance,
|
||||||
|
double aReactance );
|
||||||
|
|
||||||
// Electrical spacing panel:
|
// Electrical spacing panel:
|
||||||
void OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) override;
|
void OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) override;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include "common_data.h"
|
#include "common_data.h"
|
||||||
#include "pcb_calculator_frame.h"
|
#include "pcb_calculator_frame.h"
|
||||||
|
#include "bitmaps/microstrip_zodd_zeven.xpm"
|
||||||
|
|
||||||
|
|
||||||
extern double DoubleFromString( const wxString& TextValue );
|
extern double DoubleFromString( const wxString& TextValue );
|
||||||
|
|
||||||
|
@ -103,10 +105,10 @@ static bool findMatch(wxArrayString& aList, const wxString& aValue, int& aIdx )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnEpsilonR_Button
|
* Function OnEpsilonR_Button
|
||||||
* Shows a list of current relative dielectric constant(Er)
|
* Shows a list of current relative dielectric constant(Er)
|
||||||
|
@ -122,14 +124,14 @@ void PCB_CALCULATOR_FRAME::OnTranslineEpsilonR_Button( wxCommandEvent& event )
|
||||||
int prevChoice = 0;
|
int prevChoice = 0;
|
||||||
findMatch( list, prevChoiceStr, prevChoice );
|
findMatch( list, prevChoiceStr, prevChoice );
|
||||||
|
|
||||||
int index = wxGetSingleChoiceIndex( wxEmptyString,
|
int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Relative Dielectric Constants" ),
|
||||||
_("Relative Dielectric Constants"),
|
|
||||||
list, prevChoice );
|
list, prevChoice );
|
||||||
|
|
||||||
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
|
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
|
||||||
m_Value_EpsilonR->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
|
m_Value_EpsilonR->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnTanD_Button
|
* Function OnTanD_Button
|
||||||
* Shows a list of current dielectric loss factor (tangent delta)
|
* Shows a list of current dielectric loss factor (tangent delta)
|
||||||
|
@ -145,13 +147,14 @@ void PCB_CALCULATOR_FRAME::OnTranslineTanD_Button( wxCommandEvent& event )
|
||||||
int prevChoice = 0;
|
int prevChoice = 0;
|
||||||
findMatch( list, prevChoiceStr, prevChoice );
|
findMatch( list, prevChoiceStr, prevChoice );
|
||||||
|
|
||||||
int index = wxGetSingleChoiceIndex( wxEmptyString, _("Dielectric Loss Factor"),
|
int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Dielectric Loss Factor" ), list,
|
||||||
list, prevChoice, NULL);
|
prevChoice, NULL );
|
||||||
|
|
||||||
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
|
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
|
||||||
m_Value_TanD->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
|
m_Value_TanD->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnTranslineRho_Button
|
* Function OnTranslineRho_Button
|
||||||
* Shows a list of current Specific resistance list (rho)
|
* Shows a list of current Specific resistance list (rho)
|
||||||
|
@ -167,20 +170,23 @@ void PCB_CALCULATOR_FRAME::OnTranslineRho_Button( wxCommandEvent& event )
|
||||||
int prevChoice = 0;
|
int prevChoice = 0;
|
||||||
findMatch( list, prevChoiceStr, prevChoice );
|
findMatch( list, prevChoiceStr, prevChoice );
|
||||||
|
|
||||||
int index = wxGetSingleChoiceIndex( wxEmptyString, _("Specific Resistance"),
|
int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Specific Resistance" ), list,
|
||||||
list, prevChoice, NULL);
|
prevChoice, NULL );
|
||||||
|
|
||||||
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
|
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
|
||||||
m_Value_Rho->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
|
m_Value_Rho->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Minor helper struct to handle dialog items for a given parameter
|
// Minor helper struct to handle dialog items for a given parameter
|
||||||
struct DLG_PRM_DATA
|
struct DLG_PRM_DATA
|
||||||
{
|
{
|
||||||
wxStaticText * name;
|
wxStaticText* name;
|
||||||
wxTextCtrl * value;
|
wxTextCtrl* value;
|
||||||
UNIT_SELECTOR * unit;
|
UNIT_SELECTOR* unit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function TranslineTypeSelection
|
* Function TranslineTypeSelection
|
||||||
* Must be called after selection of a new transline.
|
* Must be called after selection of a new transline.
|
||||||
|
@ -191,17 +197,25 @@ struct DLG_PRM_DATA
|
||||||
*/
|
*/
|
||||||
void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType )
|
void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType )
|
||||||
{
|
{
|
||||||
wxString msg;
|
|
||||||
#define DOUBLE_TO_CTLR( dlg_item, value ) { msg.Printf( wxT( "%g" ), value );\
|
|
||||||
dlg_item->SetValue( msg ); }
|
|
||||||
m_currTransLineType = aType;
|
m_currTransLineType = aType;
|
||||||
|
|
||||||
if( (m_currTransLineType < START_OF_LIST_TYPE )
|
if( (m_currTransLineType < START_OF_LIST_TYPE )
|
||||||
|| ( m_currTransLineType >= END_OF_LIST_TYPE ) )
|
|| ( m_currTransLineType >= END_OF_LIST_TYPE ) )
|
||||||
|
{
|
||||||
m_currTransLineType = DEFAULT_TYPE;
|
m_currTransLineType = DEFAULT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: make transline bitmaps transparent so we can remove this
|
||||||
|
m_translinePanel->SetBackgroundColour( *wxWHITE );
|
||||||
|
|
||||||
|
m_translineBitmap->SetBitmap( *m_transline_list[m_currTransLineType]->m_Icon );
|
||||||
|
|
||||||
// This helper bitmap is shown for coupled microstrip only:
|
// This helper bitmap is shown for coupled microstrip only:
|
||||||
m_bmCMicrostripZoddZeven->Show( aType == C_MICROSTRIP_TYPE );
|
m_bmCMicrostripZoddZeven->Show( aType == C_MICROSTRIP_TYPE );
|
||||||
|
|
||||||
|
static wxBitmap* microstrip = new wxBitmap( microstrip_zodd_zeven_xpm );
|
||||||
|
m_bmCMicrostripZoddZeven->SetBitmap( *microstrip );
|
||||||
|
|
||||||
m_fgSizerZcomment->Show( aType == C_MICROSTRIP_TYPE );
|
m_fgSizerZcomment->Show( aType == C_MICROSTRIP_TYPE );
|
||||||
|
|
||||||
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
|
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
|
||||||
|
@ -246,28 +260,28 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
{ m_EpsilonR_label,m_Value_EpsilonR, NULL },
|
{ m_EpsilonR_label,m_Value_EpsilonR, NULL },
|
||||||
{ m_TanD_label,m_Value_TanD, NULL },
|
{ m_TanD_label,m_Value_TanD, NULL },
|
||||||
{ m_Rho_label, m_Value_Rho, NULL },
|
{ m_Rho_label, m_Value_Rho, NULL },
|
||||||
{ m_substrate_prm4_label,m_Substrate_prm4_Value, m_SubsPrm4_choiceUnit },
|
{ m_substrate_prm4_label, m_Substrate_prm4_Value, m_SubsPrm4_choiceUnit },
|
||||||
{ m_substrate_prm5_label,m_Substrate_prm5_Value, m_SubsPrm5_choiceUnit },
|
{ m_substrate_prm5_label, m_Substrate_prm5_Value, m_SubsPrm5_choiceUnit },
|
||||||
{ m_substrate_prm6_label,m_Substrate_prm6_Value, m_SubsPrm6_choiceUnit },
|
{ m_substrate_prm6_label, m_Substrate_prm6_Value, m_SubsPrm6_choiceUnit },
|
||||||
{ m_substrate_prm7_label,m_Substrate_prm7_Value, m_SubsPrm7_choiceUnit },
|
{ m_substrate_prm7_label, m_Substrate_prm7_Value, m_SubsPrm7_choiceUnit },
|
||||||
{ m_substrate_prm8_label,m_Substrate_prm8_Value, m_SubsPrm8_choiceUnit },
|
{ m_substrate_prm8_label, m_Substrate_prm8_Value, m_SubsPrm8_choiceUnit },
|
||||||
{ m_substrate_prm9_label,m_Substrate_prm9_Value, m_SubsPrm9_choiceUnit }
|
{ m_substrate_prm9_label, m_Substrate_prm9_Value, m_SubsPrm9_choiceUnit }
|
||||||
};
|
};
|
||||||
#define substrateprms_cnt (sizeof(substrateprms)/sizeof(substrateprms[0]))
|
#define substrateprms_cnt (sizeof(substrateprms)/sizeof(substrateprms[0]))
|
||||||
|
|
||||||
struct DLG_PRM_DATA physprms[] =
|
struct DLG_PRM_DATA physprms[] =
|
||||||
{
|
{
|
||||||
{ m_phys_prm1_label,m_Phys_prm1_Value,m_choiceUnit_Param1 },
|
{ m_phys_prm1_label, m_Phys_prm1_Value, m_choiceUnit_Param1 },
|
||||||
{ m_phys_prm2_label,m_Phys_prm2_Value,m_choiceUnit_Param2 },
|
{ m_phys_prm2_label, m_Phys_prm2_Value, m_choiceUnit_Param2 },
|
||||||
{ m_phys_prm3_label,m_Phys_prm3_Value,m_choiceUnit_Param3 }
|
{ m_phys_prm3_label, m_Phys_prm3_Value, m_choiceUnit_Param3 }
|
||||||
};
|
};
|
||||||
#define physprms_cnt (sizeof(physprms)/sizeof(physprms[0]))
|
#define physprms_cnt (sizeof(physprms)/sizeof(physprms[0]))
|
||||||
|
|
||||||
struct DLG_PRM_DATA elecprms[] =
|
struct DLG_PRM_DATA elecprms[] =
|
||||||
{
|
{
|
||||||
{ m_elec_prm1_label,m_Elec_prm1_Value, m_choiceUnit_ElecPrm1 },
|
{ m_elec_prm1_label, m_Elec_prm1_Value, m_choiceUnit_ElecPrm1 },
|
||||||
{ m_elec_prm2_label,m_Elec_prm2_Value, m_choiceUnit_ElecPrm2 },
|
{ m_elec_prm2_label, m_Elec_prm2_Value, m_choiceUnit_ElecPrm2 },
|
||||||
{ m_elec_prm3_label,m_Elec_prm3_Value, m_choiceUnit_ElecPrm3 }
|
{ m_elec_prm3_label, m_Elec_prm3_Value, m_choiceUnit_ElecPrm3 }
|
||||||
};
|
};
|
||||||
#define elecprms_cnt (sizeof(elecprms)/sizeof(elecprms[0]))
|
#define elecprms_cnt (sizeof(elecprms)/sizeof(elecprms[0]))
|
||||||
|
|
||||||
|
@ -288,31 +302,31 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
struct DLG_PRM_DATA * data = NULL;
|
struct DLG_PRM_DATA * data = NULL;
|
||||||
switch( prm->m_Type )
|
switch( prm->m_Type )
|
||||||
{
|
{
|
||||||
case PRM_TYPE_SUBS:
|
case PRM_TYPE_SUBS:
|
||||||
wxASSERT( idxsubs < substrateprms_cnt );
|
wxASSERT( idxsubs < substrateprms_cnt );
|
||||||
data = &substrateprms[idxsubs];
|
data = &substrateprms[idxsubs];
|
||||||
idxsubs++;
|
idxsubs++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRM_TYPE_PHYS:
|
case PRM_TYPE_PHYS:
|
||||||
wxASSERT( idxphys < physprms_cnt );
|
wxASSERT( idxphys < physprms_cnt );
|
||||||
data = &physprms[idxphys];
|
data = &physprms[idxphys];
|
||||||
idxphys++;
|
idxphys++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRM_TYPE_ELEC:
|
case PRM_TYPE_ELEC:
|
||||||
wxASSERT( idxelec < elecprms_cnt );
|
wxASSERT( idxelec < elecprms_cnt );
|
||||||
data = &elecprms[idxelec];
|
data = &elecprms[idxelec];
|
||||||
idxelec++;
|
idxelec++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRM_TYPE_FREQUENCY:
|
|
||||||
wxASSERT( idxfreq < frequencyprms_cnt );
|
|
||||||
data = &frequencyprms[idxfreq];
|
|
||||||
idxfreq++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
case PRM_TYPE_FREQUENCY:
|
||||||
|
wxASSERT( idxfreq < frequencyprms_cnt );
|
||||||
|
data = &frequencyprms[idxfreq];
|
||||||
|
idxfreq++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxASSERT ( data );
|
wxASSERT ( data );
|
||||||
data->name->SetToolTip( prm->m_ToolTip );
|
data->name->SetToolTip( prm->m_ToolTip );
|
||||||
data->name->SetLabel( prm->m_DlgLabel != "" ? prm->m_DlgLabel + ':' : "" );
|
data->name->SetLabel( prm->m_DlgLabel != "" ? prm->m_DlgLabel + ':' : "" );
|
||||||
|
@ -320,7 +334,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
|
|
||||||
if( prm->m_Id != DUMMY_PRM )
|
if( prm->m_Id != DUMMY_PRM )
|
||||||
{
|
{
|
||||||
DOUBLE_TO_CTLR( data->value, prm->m_Value );
|
data->value->SetValue( wxString::Format( "%g", prm->m_Value ) );
|
||||||
data->value->Enable( true );
|
data->value->Enable( true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -347,6 +361,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
substrateprms[idxsubs].name->SetToolTip(wxEmptyString);
|
substrateprms[idxsubs].name->SetToolTip(wxEmptyString);
|
||||||
substrateprms[idxsubs].value->SetValue(wxEmptyString);
|
substrateprms[idxsubs].value->SetValue(wxEmptyString);
|
||||||
substrateprms[idxsubs].value->Enable( false );
|
substrateprms[idxsubs].value->Enable( false );
|
||||||
|
|
||||||
if( substrateprms[idxsubs].unit)
|
if( substrateprms[idxsubs].unit)
|
||||||
{
|
{
|
||||||
substrateprms[idxsubs].unit->Show( false );
|
substrateprms[idxsubs].unit->Show( false );
|
||||||
|
@ -361,6 +376,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
physprms[idxphys].name->SetToolTip(wxEmptyString);
|
physprms[idxphys].name->SetToolTip(wxEmptyString);
|
||||||
physprms[idxphys].value->SetValue(wxEmptyString);
|
physprms[idxphys].value->SetValue(wxEmptyString);
|
||||||
physprms[idxphys].value->Enable( false );
|
physprms[idxphys].value->Enable( false );
|
||||||
|
|
||||||
if( physprms[idxphys].unit)
|
if( physprms[idxphys].unit)
|
||||||
{
|
{
|
||||||
physprms[idxphys].unit->Show( false );
|
physprms[idxphys].unit->Show( false );
|
||||||
|
@ -375,6 +391,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
elecprms[idxelec].name->SetToolTip(wxEmptyString);
|
elecprms[idxelec].name->SetToolTip(wxEmptyString);
|
||||||
elecprms[idxelec].value->SetValue(wxEmptyString);
|
elecprms[idxelec].value->SetValue(wxEmptyString);
|
||||||
elecprms[idxelec].value->Enable( false );
|
elecprms[idxelec].value->Enable( false );
|
||||||
|
|
||||||
if( elecprms[idxelec].unit)
|
if( elecprms[idxelec].unit)
|
||||||
{
|
{
|
||||||
elecprms[idxelec].unit->Show( false );
|
elecprms[idxelec].unit->Show( false );
|
||||||
|
@ -389,6 +406,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
frequencyprms[idxfreq].name->SetToolTip(wxEmptyString);
|
frequencyprms[idxfreq].name->SetToolTip(wxEmptyString);
|
||||||
frequencyprms[idxfreq].value->SetValue(wxEmptyString);
|
frequencyprms[idxfreq].value->SetValue(wxEmptyString);
|
||||||
frequencyprms[idxfreq].value->Enable( false );
|
frequencyprms[idxfreq].value->Enable( false );
|
||||||
|
|
||||||
if( frequencyprms[idxfreq].unit )
|
if( frequencyprms[idxfreq].unit )
|
||||||
{
|
{
|
||||||
frequencyprms[idxfreq].unit->Show( false );
|
frequencyprms[idxfreq].unit->Show( false );
|
||||||
|
@ -406,6 +424,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
|
||||||
void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams()
|
void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams()
|
||||||
{
|
{
|
||||||
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
|
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < tr_ident->GetPrmsCount(); ii++ )
|
for( unsigned ii = 0; ii < tr_ident->GetPrmsCount(); ii++ )
|
||||||
{
|
{
|
||||||
TRANSLINE_PRM* prm = tr_ident->GetPrm( ii );
|
TRANSLINE_PRM* prm = tr_ident->GetPrm( ii );
|
||||||
|
@ -414,11 +433,13 @@ void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams()
|
||||||
double value = DoubleFromString(value_txt);
|
double value = DoubleFromString(value_txt);
|
||||||
prm->m_Value = value;
|
prm->m_Value = value;
|
||||||
UNIT_SELECTOR * unit_ctrl = (UNIT_SELECTOR * ) prm->m_UnitCtrl;
|
UNIT_SELECTOR * unit_ctrl = (UNIT_SELECTOR * ) prm->m_UnitCtrl;
|
||||||
|
|
||||||
if( unit_ctrl )
|
if( unit_ctrl )
|
||||||
{
|
{
|
||||||
prm->m_UnitSelection = unit_ctrl->GetSelection();
|
prm->m_UnitSelection = unit_ctrl->GetSelection();
|
||||||
value *= unit_ctrl->GetUnitScale();
|
value *= unit_ctrl->GetUnitScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
prm->m_NormalizedValue = value;
|
prm->m_NormalizedValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,7 +448,7 @@ void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams()
|
||||||
/**
|
/**
|
||||||
* Function OnTranslineSelection
|
* Function OnTranslineSelection
|
||||||
* Called on new transmission line selection
|
* Called on new transmission line selection
|
||||||
*/
|
*/
|
||||||
void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event )
|
void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
enum TRANSLINE_TYPE_ID id = (enum TRANSLINE_TYPE_ID) event.GetSelection();
|
enum TRANSLINE_TYPE_ID id = (enum TRANSLINE_TYPE_ID) event.GetSelection();
|
||||||
|
@ -438,22 +459,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event )
|
||||||
// The new size must be taken in account
|
// The new size must be taken in account
|
||||||
m_panelTransline->GetSizer()->Layout();
|
m_panelTransline->GetSizer()->Layout();
|
||||||
m_panelTransline->Refresh();
|
m_panelTransline->Refresh();
|
||||||
// Delete previous warnings / errors
|
|
||||||
wxColour background = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
|
|
||||||
|
|
||||||
m_Value_EpsilonR->SetBackgroundColour( background );
|
|
||||||
m_Value_TanD->SetBackgroundColour( background );
|
|
||||||
m_Value_Rho->SetBackgroundColour( background );
|
|
||||||
m_Substrate_prm4_Value->SetBackgroundColour( background );
|
|
||||||
m_Substrate_prm5_Value->SetBackgroundColour( background );
|
|
||||||
m_Substrate_prm6_Value->SetBackgroundColour( background );
|
|
||||||
m_Substrate_prm7_Value->SetBackgroundColour( background );
|
|
||||||
m_Substrate_prm8_Value->SetBackgroundColour( background );
|
|
||||||
m_Substrate_prm9_Value->SetBackgroundColour( background );
|
|
||||||
m_Value_Frequency_Ctrl->SetBackgroundColour( background );
|
|
||||||
m_Phys_prm1_Value->SetBackgroundColour( background );
|
|
||||||
m_Phys_prm2_Value->SetBackgroundColour( background );
|
|
||||||
m_Phys_prm3_Value->SetBackgroundColour( background );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -461,7 +466,7 @@ void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event )
|
||||||
* Function OnTransLineResetButtonClick
|
* Function OnTransLineResetButtonClick
|
||||||
* Called when the user clicks the reset button. This sets
|
* Called when the user clicks the reset button. This sets
|
||||||
* the parameters to their default values.
|
* the parameters to their default values.
|
||||||
*/
|
*/
|
||||||
void PCB_CALCULATOR_FRAME::OnTransLineResetButtonClick( wxCommandEvent& event )
|
void PCB_CALCULATOR_FRAME::OnTransLineResetButtonClick( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
TranslineTypeSelection( DEFAULT_TYPE );
|
TranslineTypeSelection( DEFAULT_TYPE );
|
||||||
|
|
|
@ -108,10 +108,10 @@ double TRANSLINE_PRM::FromUserUnit()
|
||||||
|
|
||||||
TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
{
|
{
|
||||||
m_Type = aType; // The type of transline handled
|
m_Type = aType; // The type of transline handled
|
||||||
m_Icon = NULL; // An xpm icon to display in dialogs
|
m_Icon = NULL; // An xpm icon to display in dialogs
|
||||||
m_TLine = NULL; // The TRANSLINE itself
|
m_TLine = NULL; // The TRANSLINE itself
|
||||||
m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
|
m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
|
||||||
|
|
||||||
// Add common prms:
|
// Add common prms:
|
||||||
// Default values are for FR4
|
// Default values are for FR4
|
||||||
|
@ -139,7 +139,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
switch( m_Type )
|
switch( m_Type )
|
||||||
{
|
{
|
||||||
case MICROSTRIP_TYPE: // microstrip
|
case MICROSTRIP_TYPE: // microstrip
|
||||||
m_TLine = new MICROSTRIP();
|
m_TLine = new MICROSTRIP();
|
||||||
m_Icon = new wxBitmap( microstrip_xpm );
|
m_Icon = new wxBitmap( microstrip_xpm );
|
||||||
|
|
||||||
m_Messages.Add( _( "ErEff:" ) );
|
m_Messages.Add( _( "ErEff:" ) );
|
||||||
|
@ -178,7 +178,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CPW_TYPE: // coplanar waveguide
|
case CPW_TYPE: // coplanar waveguide
|
||||||
m_TLine = new COPLANAR();
|
m_TLine = new COPLANAR();
|
||||||
m_Icon = new wxBitmap( cpw_xpm );
|
m_Icon = new wxBitmap( cpw_xpm );
|
||||||
m_HasPrmSelection = true;
|
m_HasPrmSelection = true;
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GROUNDED_CPW_TYPE: // grounded coplanar waveguide
|
case GROUNDED_CPW_TYPE: // grounded coplanar waveguide
|
||||||
m_TLine = new GROUNDEDCOPLANAR();
|
m_TLine = new GROUNDEDCOPLANAR();
|
||||||
m_Icon = new wxBitmap( cpw_back_xpm );
|
m_Icon = new wxBitmap( cpw_back_xpm );
|
||||||
m_HasPrmSelection = true;
|
m_HasPrmSelection = true;
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
|
|
||||||
|
|
||||||
case RECTWAVEGUIDE_TYPE: // rectangular waveguide
|
case RECTWAVEGUIDE_TYPE: // rectangular waveguide
|
||||||
m_TLine = new RECTWAVEGUIDE();
|
m_TLine = new RECTWAVEGUIDE();
|
||||||
m_Icon = new wxBitmap( rectwaveguide_xpm );
|
m_Icon = new wxBitmap( rectwaveguide_xpm );
|
||||||
m_HasPrmSelection = true;
|
m_HasPrmSelection = true;
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COAX_TYPE: // coaxial cable
|
case COAX_TYPE: // coaxial cable
|
||||||
m_TLine = new COAX();
|
m_TLine = new COAX();
|
||||||
m_Icon = new wxBitmap( coax_xpm );
|
m_Icon = new wxBitmap( coax_xpm );
|
||||||
m_HasPrmSelection = true;
|
m_HasPrmSelection = true;
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case C_MICROSTRIP_TYPE: // coupled microstrip
|
case C_MICROSTRIP_TYPE: // coupled microstrip
|
||||||
m_TLine = new C_MICROSTRIP();
|
m_TLine = new C_MICROSTRIP();
|
||||||
m_Icon = new wxBitmap( c_microstrip_xpm );
|
m_Icon = new wxBitmap( c_microstrip_xpm );
|
||||||
m_HasPrmSelection = true;
|
m_HasPrmSelection = true;
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STRIPLINE_TYPE: // stripline
|
case STRIPLINE_TYPE: // stripline
|
||||||
m_TLine = new STRIPLINE();
|
m_TLine = new STRIPLINE();
|
||||||
m_Icon = new wxBitmap( stripline_xpm );
|
m_Icon = new wxBitmap( stripline_xpm );
|
||||||
|
|
||||||
m_Messages.Add( _( "ErEff:" ) );
|
m_Messages.Add( _( "ErEff:" ) );
|
||||||
|
@ -408,7 +408,7 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TWISTEDPAIR_TYPE: // twisted pair
|
case TWISTEDPAIR_TYPE: // twisted pair
|
||||||
m_TLine = new TWISTEDPAIR();
|
m_TLine = new TWISTEDPAIR();
|
||||||
m_Icon = new wxBitmap( twistedpair_xpm );
|
m_Icon = new wxBitmap( twistedpair_xpm );
|
||||||
m_HasPrmSelection = true;
|
m_HasPrmSelection = true;
|
||||||
|
|
||||||
|
@ -473,14 +473,12 @@ void TRANSLINE_IDENT::ReadConfig()
|
||||||
{
|
{
|
||||||
wxASSERT( cfg->m_TransLine.param_units.count( name ) );
|
wxASSERT( cfg->m_TransLine.param_units.count( name ) );
|
||||||
|
|
||||||
for( auto& param : m_prms_List )
|
for( auto& p : m_prms_List )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
param->m_Value =
|
p->m_Value = cfg->m_TransLine.param_values.at( name ).at( p->m_KeyWord );
|
||||||
cfg->m_TransLine.param_values.at( name ).at( param->m_KeyWord );
|
p->m_UnitSelection = cfg->m_TransLine.param_units.at( name ).at( p->m_KeyWord );
|
||||||
param->m_UnitSelection =
|
|
||||||
cfg->m_TransLine.param_units.at( name ).at( param->m_KeyWord );
|
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{}
|
{}
|
||||||
|
@ -497,9 +495,7 @@ void TRANSLINE_IDENT::WriteConfig()
|
||||||
for( auto& param : m_prms_List )
|
for( auto& param : m_prms_List )
|
||||||
{
|
{
|
||||||
if( !std::isfinite( param->m_Value ) )
|
if( !std::isfinite( param->m_Value ) )
|
||||||
{
|
|
||||||
param->m_Value = 0;
|
param->m_Value = 0;
|
||||||
}
|
|
||||||
|
|
||||||
cfg->m_TransLine.param_values[ name ][ param->m_KeyWord ] = param->m_Value;
|
cfg->m_TransLine.param_values[ name ][ param->m_KeyWord ] = param->m_Value;
|
||||||
cfg->m_TransLine.param_units[ name ][ param->m_KeyWord ] = param->m_UnitSelection;
|
cfg->m_TransLine.param_units[ name ][ param->m_KeyWord ] = param->m_UnitSelection;
|
||||||
|
|
Loading…
Reference in New Issue