From 21d3662ed3e4735712bd97a627be6f4399d45ce1 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 4 Oct 2021 10:22:34 +0200 Subject: [PATCH] pcb_calculator rework: move attenuators panel to its own files panel_attenuators_xx --- pcb_calculator/CMakeLists.txt | 3 +- pcb_calculator/attenuators.cpp | 160 -- pcb_calculator/dialogs/panel_attenuators.h | 53 + .../dialogs/panel_attenuators_base.cpp | 195 ++ .../dialogs/panel_attenuators_base.fbp | 1767 +++++++++++++++++ .../dialogs/panel_attenuators_base.h | 80 + .../dialogs/pcb_calculator_frame_base.cpp | 176 +- .../dialogs/pcb_calculator_frame_base.fbp | 1719 +--------------- .../dialogs/pcb_calculator_frame_base.h | 44 +- pcb_calculator/panel_attenuators.cpp | 223 +++ pcb_calculator/pcb_calculator_frame.cpp | 48 +- pcb_calculator/pcb_calculator_frame.h | 24 - 12 files changed, 2343 insertions(+), 2149 deletions(-) delete mode 100644 pcb_calculator/attenuators.cpp create mode 100644 pcb_calculator/dialogs/panel_attenuators.h create mode 100644 pcb_calculator/dialogs/panel_attenuators_base.cpp create mode 100644 pcb_calculator/dialogs/panel_attenuators_base.fbp create mode 100644 pcb_calculator/dialogs/panel_attenuators_base.h create mode 100644 pcb_calculator/panel_attenuators.cpp diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index f987ba3e54..8441118b70 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -9,7 +9,6 @@ include_directories( set( PCB_CALCULATOR_SRCS eserie.cpp - attenuators.cpp board_classes_values.cpp colorcode.cpp common_data.cpp @@ -18,6 +17,7 @@ set( PCB_CALCULATOR_SRCS pcb_calculator_frame.cpp pcb_calculator_settings.cpp datafile_read_write.cpp + panel_attenuators.cpp panel_regulator.cpp tracks_width_versus_current.cpp via.cpp @@ -36,6 +36,7 @@ set( PCB_CALCULATOR_SRCS dialogs/pcb_calculator_frame_base.cpp dialogs/dialog_regulator_form_base.cpp dialogs/dialog_regulator_form.cpp + dialogs/panel_attenuators_base.cpp dialogs/panel_regulator_base.cpp ../common/env_vars.cpp # needed on MSW to avoid a link issue (a symbol not found) ) diff --git a/pcb_calculator/attenuators.cpp b/pcb_calculator/attenuators.cpp deleted file mode 100644 index fdee6e62a0..0000000000 --- a/pcb_calculator/attenuators.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @file attenuators.cpp - */ - -/* - * This program source code file is part of KICAD, a free EDA CAD application. - * - * Copyright (C) 2015 jean-pierre.charras - * Copyright (C) 2015 Kicad Developers, see change_log.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pcb_calculator_frame.h" - -extern double DoubleFromString( const wxString& TextValue ); - -// Called on a attenuator selection -void PCB_CALCULATOR_FRAME::OnAttenuatorSelection( wxCommandEvent& event ) -{ - SetAttenuator( (unsigned) event.GetSelection() ); - Refresh(); -} - - -void PCB_CALCULATOR_FRAME::SetAttenuator( unsigned aIdx ) -{ - if( aIdx >=m_attenuator_list.size() ) - aIdx = m_attenuator_list.size() - 1; - - m_currAttenuator = m_attenuator_list[aIdx]; - TransfAttenuatorDataToPanel(); - m_Attenuator_Messages->SetPage( wxEmptyString ); - m_Att_R1_Value->SetValue( wxEmptyString ); - m_Att_R2_Value->SetValue( wxEmptyString ); - m_Att_R3_Value->SetValue( wxEmptyString ); -} - - -void PCB_CALCULATOR_FRAME::OnCalculateAttenuator( wxCommandEvent& event ) -{ - TransfPanelDataToAttenuator(); - m_currAttenuator->Calculate(); - TransfAttenuatorResultsToPanel(); -} - - -void PCB_CALCULATOR_FRAME::TransfPanelDataToAttenuator() -{ - wxString msg; - - msg = m_AttValueCtrl->GetValue(); - m_currAttenuator->m_Attenuation = DoubleFromString(msg); - msg = m_ZinValueCtrl->GetValue(); - m_currAttenuator->m_Zin = DoubleFromString(msg); - msg = m_ZoutValueCtrl->GetValue(); - m_currAttenuator->m_Zout = DoubleFromString(msg); -} - - -void PCB_CALCULATOR_FRAME::TransfAttenuatorDataToPanel() -{ - m_attenuatorBitmap->SetBitmap( *m_currAttenuator->m_SchBitMap ); - - wxString msg; - - msg.Printf( wxT( "%g" ), m_currAttenuator->m_Attenuation ); - m_AttValueCtrl->SetValue( msg ); - m_AttValueCtrl->Enable( m_currAttenuator->m_Attenuation_Enable ); - - m_ZinValueCtrl->Enable( m_currAttenuator->m_Zin_Enable ); - - if( m_currAttenuator->m_Zin_Enable ) - msg.Printf( wxT( "%g" ), m_currAttenuator->m_Zin ); - else - msg.Clear(); - - m_ZinValueCtrl->SetValue( msg ); - - msg.Printf( wxT( "%g" ), m_currAttenuator->m_Zout ); - m_ZoutValueCtrl->SetValue( msg ); - - if( m_currAttenuator->m_FormulaName ) - { - if( m_currAttenuator->m_FormulaName->StartsWith( "SetPage( *m_currAttenuator->m_FormulaName ); - } - else - { - wxString html_txt; - ConvertMarkdown2Html( wxGetTranslation( *m_currAttenuator->m_FormulaName ), html_txt ); - m_panelAttFormula->SetPage( html_txt ); - } - } - else - { - m_panelAttFormula->SetPage( wxEmptyString ); - } -} - - -void PCB_CALCULATOR_FRAME::TransfAttenuatorResultsToPanel() -{ - wxString msg; - - m_Attenuator_Messages->SetPage( wxEmptyString ); - - if( m_currAttenuator->m_Error ) - { - msg.Printf( _( "Attenuation more than %f dB" ), - m_currAttenuator->m_MinimumATT ); - m_Attenuator_Messages->AppendToPage( wxT( "
Error!

" ) ); - m_Attenuator_Messages->AppendToPage( msg ); - m_Attenuator_Messages->AppendToPage( wxT( "
" ) ); - - // Display -- as resistor values: - msg = wxT( "--" ); - m_Att_R1_Value->SetValue( msg ); - m_Att_R2_Value->SetValue( msg ); - if( m_currAttenuator->m_ResultCount >= 3 ) - m_Att_R3_Value->SetValue( msg ); - - return; - } - - msg.Printf( wxT( "%g" ), m_currAttenuator->m_R1 ); - m_Att_R1_Value->SetValue( msg ); - msg.Printf( wxT( "%g" ), m_currAttenuator->m_R2 ); - m_Att_R2_Value->SetValue( msg ); - - if( m_currAttenuator->m_ResultCount < 3 ) - { - m_Att_R3_Value->SetValue( wxEmptyString ); - } - else - { - msg.Printf( wxT( "%g" ), m_currAttenuator->m_R3 ); - m_Att_R3_Value->SetValue( msg ); - } -} - - diff --git a/pcb_calculator/dialogs/panel_attenuators.h b/pcb_calculator/dialogs/panel_attenuators.h new file mode 100644 index 0000000000..c134718ff7 --- /dev/null +++ b/pcb_calculator/dialogs/panel_attenuators.h @@ -0,0 +1,53 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef PANEL_ATTENUATORS_H +#define PANEL_ATTENUATORS_H +#include "panel_attenuators_base.h" + +class ATTENUATOR; + +class PANEL_ATTENUATORS : public PANEL_ATTENUATORS_BASE +{ +public: + PANEL_ATTENUATORS( wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_ATTENUATORS(); + + wxRadioBox* GetAttenuatorsSelector() { return m_AttenuatorsSelection; } + void LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ); + void SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ); + void UpdateUI(); // Update bitmaps + + void OnAttenuatorSelection( wxCommandEvent& event ) override; + void SetAttenuator( unsigned aIdx ); + void OnCalculateAttenuator( wxCommandEvent& event ) override; + void TransfPanelDataToAttenuator(); + void TransfAttenuatorDataToPanel(); + void TransfAttenuatorResultsToPanel(); + +public: + ATTENUATOR* m_CurrAttenuator; + std::vector m_AttenuatorList; + +}; + +#endif \ No newline at end of file diff --git a/pcb_calculator/dialogs/panel_attenuators_base.cpp b/pcb_calculator/dialogs/panel_attenuators_base.cpp new file mode 100644 index 0000000000..7a9284bd50 --- /dev/null +++ b/pcb_calculator/dialogs/panel_attenuators_base.cpp @@ -0,0 +1,195 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_attenuators_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_ATTENUATORS_BASE::PANEL_ATTENUATORS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + wxBoxSizer* bSizerAtt; + bSizerAtt = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bLeftSizerAtt; + bLeftSizerAtt = new wxBoxSizer( wxVERTICAL ); + + bLeftSizerAtt->SetMinSize( wxSize( 260,-1 ) ); + wxString m_AttenuatorsSelectionChoices[] = { _("PI"), _("Tee"), _("Bridged tee"), _("Resistive splitter") }; + int m_AttenuatorsSelectionNChoices = sizeof( m_AttenuatorsSelectionChoices ) / sizeof( wxString ); + m_AttenuatorsSelection = new wxRadioBox( this, wxID_ANY, _("Attenuators"), wxDefaultPosition, wxDefaultSize, m_AttenuatorsSelectionNChoices, m_AttenuatorsSelectionChoices, 1, wxRA_SPECIFY_COLS ); + m_AttenuatorsSelection->SetSelection( 2 ); + bLeftSizerAtt->Add( m_AttenuatorsSelection, 0, wxEXPAND|wxALL, 5 ); + + + bLeftSizerAtt->Add( 0, 5, 0, wxEXPAND, 5 ); + + m_attenuatorBitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizerAtt->Add( m_attenuatorBitmap, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 10 ); + + + bSizerAtt->Add( bLeftSizerAtt, 0, wxEXPAND|wxRIGHT, 5 ); + + wxBoxSizer* bMiddleSizerAtt; + bMiddleSizerAtt = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizerAttPrms; + sbSizerAttPrms = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Parameters") ), wxVERTICAL ); + + wxFlexGridSizer* fgSizerAttPrms; + fgSizerAttPrms = new wxFlexGridSizer( 3, 3, 3, 0 ); + fgSizerAttPrms->AddGrowableRow( 1 ); + fgSizerAttPrms->SetFlexibleDirection( wxBOTH ); + fgSizerAttPrms->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_attenuationLabel = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Attenuation:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attenuationLabel->Wrap( -1 ); + fgSizerAttPrms->Add( m_attenuationLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_AttValueCtrl = new wxTextCtrl( sbSizerAttPrms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerAttPrms->Add( m_AttValueCtrl, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_attUnit = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("dB"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attUnit->Wrap( -1 ); + fgSizerAttPrms->Add( m_attUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_attenuationZinLabel = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Zin:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attenuationZinLabel->Wrap( -1 ); + fgSizerAttPrms->Add( m_attenuationZinLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_ZinValueCtrl = new wxTextCtrl( sbSizerAttPrms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerAttPrms->Add( m_ZinValueCtrl, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_attZinUnit = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attZinUnit->Wrap( -1 ); + fgSizerAttPrms->Add( m_attZinUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_ZoutLabel = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Zout:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ZoutLabel->Wrap( -1 ); + fgSizerAttPrms->Add( m_ZoutLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_ZoutValueCtrl = new wxTextCtrl( sbSizerAttPrms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerAttPrms->Add( m_ZoutValueCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_attZoutUnit = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attZoutUnit->Wrap( -1 ); + fgSizerAttPrms->Add( m_attZoutUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + + sbSizerAttPrms->Add( fgSizerAttPrms, 0, wxEXPAND|wxBOTTOM, 5 ); + + + bMiddleSizerAtt->Add( sbSizerAttPrms, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + wxBoxSizer* bSizerAttButt; + bSizerAttButt = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonAlcAtt = new wxButton( this, wxID_ANY, _("Calculate"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerAttButt->Add( m_buttonAlcAtt, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButtonCalcAtt = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + bSizerAttButt->Add( m_bpButtonCalcAtt, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + + bMiddleSizerAtt->Add( bSizerAttButt, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + + wxStaticBoxSizer* sbSizerAttValues; + sbSizerAttValues = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Values") ), wxVERTICAL ); + + wxFlexGridSizer* fgSizerAttResults; + fgSizerAttResults = new wxFlexGridSizer( 3, 3, 3, 0 ); + fgSizerAttResults->AddGrowableCol( 1 ); + fgSizerAttResults->SetFlexibleDirection( wxBOTH ); + fgSizerAttResults->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_attenuatorR1Label = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("R1:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attenuatorR1Label->Wrap( -1 ); + fgSizerAttResults->Add( m_attenuatorR1Label, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_Att_R1_Value = new wxTextCtrl( sbSizerAttValues->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerAttResults->Add( m_Att_R1_Value, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_attR1Unit = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attR1Unit->Wrap( -1 ); + fgSizerAttResults->Add( m_attR1Unit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_attenuatorR2Label = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("R2:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attenuatorR2Label->Wrap( -1 ); + fgSizerAttResults->Add( m_attenuatorR2Label, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_Att_R2_Value = new wxTextCtrl( sbSizerAttValues->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerAttResults->Add( m_Att_R2_Value, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_attR2Unit = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attR2Unit->Wrap( -1 ); + fgSizerAttResults->Add( m_attR2Unit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_attenuatorR3Label = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("R3:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attenuatorR3Label->Wrap( -1 ); + fgSizerAttResults->Add( m_attenuatorR3Label, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_Att_R3_Value = new wxTextCtrl( sbSizerAttValues->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerAttResults->Add( m_Att_R3_Value, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_attR3Unit = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); + m_attR3Unit->Wrap( -1 ); + fgSizerAttResults->Add( m_attR3Unit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + + sbSizerAttValues->Add( fgSizerAttResults, 0, wxEXPAND|wxBOTTOM, 5 ); + + + bMiddleSizerAtt->Add( sbSizerAttValues, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + wxBoxSizer* bSizerMessages; + bSizerMessages = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizerIndentLabel; + bSizerIndentLabel = new wxBoxSizer( wxHORIZONTAL ); + + m_staticTextAttMsg = new wxStaticText( this, wxID_ANY, _("Messages"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextAttMsg->Wrap( -1 ); + bSizerIndentLabel->Add( m_staticTextAttMsg, 0, wxALL, 2 ); + + + bSizerMessages->Add( bSizerIndentLabel, 0, wxLEFT, 6 ); + + m_Attenuator_Messages = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO ); + bSizerMessages->Add( m_Attenuator_Messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 8 ); + + + bMiddleSizerAtt->Add( bSizerMessages, 1, wxEXPAND|wxLEFT, 3 ); + + + bSizerAtt->Add( bMiddleSizerAtt, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + wxStaticBoxSizer* sbRightSizerFormula; + sbRightSizerFormula = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Formula") ), wxVERTICAL ); + + m_panelAttFormula = new wxHtmlWindow( sbRightSizerFormula->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); + sbRightSizerFormula->Add( m_panelAttFormula, 1, wxEXPAND|wxBOTTOM, 5 ); + + + bSizerAtt->Add( sbRightSizerFormula, 1, wxEXPAND|wxALL, 5 ); + + + this->SetSizer( bSizerAtt ); + this->Layout(); + + // Connect Events + m_AttenuatorsSelection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( PANEL_ATTENUATORS_BASE::OnAttenuatorSelection ), NULL, this ); + m_buttonAlcAtt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_ATTENUATORS_BASE::OnCalculateAttenuator ), NULL, this ); + m_bpButtonCalcAtt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_ATTENUATORS_BASE::OnCalculateAttenuator ), NULL, this ); +} + +PANEL_ATTENUATORS_BASE::~PANEL_ATTENUATORS_BASE() +{ + // Disconnect Events + m_AttenuatorsSelection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( PANEL_ATTENUATORS_BASE::OnAttenuatorSelection ), NULL, this ); + m_buttonAlcAtt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_ATTENUATORS_BASE::OnCalculateAttenuator ), NULL, this ); + m_bpButtonCalcAtt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_ATTENUATORS_BASE::OnCalculateAttenuator ), NULL, this ); + +} diff --git a/pcb_calculator/dialogs/panel_attenuators_base.fbp b/pcb_calculator/dialogs/panel_attenuators_base.fbp new file mode 100644 index 0000000000..b803ea43e5 --- /dev/null +++ b/pcb_calculator/dialogs/panel_attenuators_base.fbp @@ -0,0 +1,1767 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_attenuators_base + 1000 + none + + 1 + panel_attenuators_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_ATTENUATORS_BASE + + 500,300 + ; ; forward_declare + + + + wxTAB_TRAVERSAL + + + bSizerAtt + wxHORIZONTAL + none + + 5 + wxEXPAND|wxRIGHT + 0 + + 260,-1 + bLeftSizerAtt + wxVERTICAL + none + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "PI" "Tee" "Bridged tee" "Resistive splitter" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Attenuators + 1 + + 0 + + + 0 + + 1 + m_AttenuatorsSelection + 1 + + + protected + 1 + + Resizable + 2 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAttenuatorSelection + + + + 5 + wxEXPAND + 0 + + 5 + protected + 0 + + + + 10 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_attenuatorBitmap + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + + + + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + + bMiddleSizerAtt + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + 0 + + wxID_ANY + Parameters + + sbSizerAttPrms + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxBOTTOM + 0 + + 3 + wxBOTH + + 1 + 0 + + fgSizerAttPrms + wxFLEX_GROWMODE_SPECIFIED + none + 3 + 3 + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Attenuation: + 0 + + 0 + + + 0 + + 1 + m_attenuationLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_AttValueCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + dB + 0 + + 0 + + + 0 + + 1 + m_attUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Zin: + 0 + + 0 + + + 0 + + 1 + m_attenuationZinLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_ZinValueCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Ohms + 0 + + 0 + + + 0 + + 1 + m_attZinUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Zout: + 0 + + 0 + + + 0 + + 1 + m_ZoutLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_ZoutValueCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Ohms + 0 + + 0 + + + 0 + + 1 + m_attZoutUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + 5 + wxALIGN_CENTER_HORIZONTAL + 0 + + + bSizerAttButt + wxHORIZONTAL + none + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Calculate + + 0 + + 0 + + + 0 + + 1 + m_buttonAlcAtt + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCalculateAttenuator + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Calculate + + 0 + + 0 + + + 0 + + 1 + m_bpButtonCalcAtt + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCalculateAttenuator + + + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + 0 + + wxID_ANY + Values + + sbSizerAttValues + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxBOTTOM + 0 + + 3 + wxBOTH + 1 + + 0 + + fgSizerAttResults + wxFLEX_GROWMODE_SPECIFIED + none + 3 + 3 + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + R1: + 0 + + 0 + + + 0 + + 1 + m_attenuatorR1Label + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_Att_R1_Value + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Ohms + 0 + + 0 + + + 0 + + 1 + m_attR1Unit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + R2: + 0 + + 0 + + + 0 + + 1 + m_attenuatorR2Label + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_Att_R2_Value + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Ohms + 0 + + 0 + + + 0 + + 1 + m_attR2Unit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + R3: + 0 + + 0 + + + 0 + + 1 + m_attenuatorR3Label + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_Att_R3_Value + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Ohms + 0 + + 0 + + + 0 + + 1 + m_attR3Unit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + 3 + wxEXPAND|wxLEFT + 1 + + + bSizerMessages + wxVERTICAL + none + + 6 + wxLEFT + 0 + + + bSizerIndentLabel + wxHORIZONTAL + none + + 2 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Messages + 0 + + 0 + + + 0 + + 1 + m_staticTextAttMsg + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + 8 + wxEXPAND|wxBOTTOM|wxRIGHT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_Attenuator_Messages + 1 + + + protected + 1 + + Resizable + 1 + + wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO + + 0 + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 1 + + wxID_ANY + Formula + + sbRightSizerFormula + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxBOTTOM + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelAttFormula + 1 + + + protected + 1 + + Resizable + 1 + + wxHW_SCROLLBAR_AUTO + + 0 + + + + + + + + + + + + diff --git a/pcb_calculator/dialogs/panel_attenuators_base.h b/pcb_calculator/dialogs/panel_attenuators_base.h new file mode 100644 index 0000000000..dda78e06da --- /dev/null +++ b/pcb_calculator/dialogs/panel_attenuators_base.h @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_ATTENUATORS_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_ATTENUATORS_BASE : public wxPanel +{ + private: + + protected: + wxRadioBox* m_AttenuatorsSelection; + wxStaticBitmap* m_attenuatorBitmap; + wxStaticText* m_attenuationLabel; + wxTextCtrl* m_AttValueCtrl; + wxStaticText* m_attUnit; + wxStaticText* m_attenuationZinLabel; + wxTextCtrl* m_ZinValueCtrl; + wxStaticText* m_attZinUnit; + wxStaticText* m_ZoutLabel; + wxTextCtrl* m_ZoutValueCtrl; + wxStaticText* m_attZoutUnit; + wxButton* m_buttonAlcAtt; + wxBitmapButton* m_bpButtonCalcAtt; + wxStaticText* m_attenuatorR1Label; + wxTextCtrl* m_Att_R1_Value; + wxStaticText* m_attR1Unit; + wxStaticText* m_attenuatorR2Label; + wxTextCtrl* m_Att_R2_Value; + wxStaticText* m_attR2Unit; + wxStaticText* m_attenuatorR3Label; + wxTextCtrl* m_Att_R3_Value; + wxStaticText* m_attR3Unit; + wxStaticText* m_staticTextAttMsg; + wxHtmlWindow* m_Attenuator_Messages; + wxHtmlWindow* m_panelAttFormula; + + // Virtual event handlers, overide them in your derived class + virtual void OnAttenuatorSelection( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCalculateAttenuator( wxCommandEvent& event ) { event.Skip(); } + + + public: + + PANEL_ATTENUATORS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_ATTENUATORS_BASE(); + +}; + diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp index f18c3b8c5f..e8459f32c4 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp @@ -24,175 +24,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow m_Notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_panelRegulators = new PANEL_REGULATOR( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_Notebook->AddPage( m_panelRegulators, _("Regulators"), true ); - m_panelAttenuators = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerAtt; - bSizerAtt = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bLeftSizerAtt; - bLeftSizerAtt = new wxBoxSizer( wxVERTICAL ); - - bLeftSizerAtt->SetMinSize( wxSize( 260,-1 ) ); - wxString m_AttenuatorsSelectionChoices[] = { _("PI"), _("Tee"), _("Bridged tee"), _("Resistive splitter") }; - int m_AttenuatorsSelectionNChoices = sizeof( m_AttenuatorsSelectionChoices ) / sizeof( wxString ); - m_AttenuatorsSelection = new wxRadioBox( m_panelAttenuators, wxID_ANY, _("Attenuators"), wxDefaultPosition, wxDefaultSize, m_AttenuatorsSelectionNChoices, m_AttenuatorsSelectionChoices, 1, wxRA_SPECIFY_COLS ); - m_AttenuatorsSelection->SetSelection( 2 ); - bLeftSizerAtt->Add( m_AttenuatorsSelection, 0, wxEXPAND|wxALL, 5 ); - - - bLeftSizerAtt->Add( 0, 5, 0, wxEXPAND, 5 ); - - m_attenuatorBitmap = new wxStaticBitmap( m_panelAttenuators, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - bLeftSizerAtt->Add( m_attenuatorBitmap, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 10 ); - - - bSizerAtt->Add( bLeftSizerAtt, 0, wxEXPAND|wxRIGHT, 5 ); - - wxBoxSizer* bMiddleSizerAtt; - bMiddleSizerAtt = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* sbSizerAttPrms; - sbSizerAttPrms = new wxStaticBoxSizer( new wxStaticBox( m_panelAttenuators, wxID_ANY, _("Parameters") ), wxVERTICAL ); - - wxFlexGridSizer* fgSizerAttPrms; - fgSizerAttPrms = new wxFlexGridSizer( 3, 3, 3, 0 ); - fgSizerAttPrms->AddGrowableRow( 1 ); - fgSizerAttPrms->SetFlexibleDirection( wxBOTH ); - fgSizerAttPrms->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_attenuationLabel = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Attenuation:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attenuationLabel->Wrap( -1 ); - fgSizerAttPrms->Add( m_attenuationLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_AttValueCtrl = new wxTextCtrl( sbSizerAttPrms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerAttPrms->Add( m_AttValueCtrl, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - - m_attUnit = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("dB"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attUnit->Wrap( -1 ); - fgSizerAttPrms->Add( m_attUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_attenuationZinLabel = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Zin:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attenuationZinLabel->Wrap( -1 ); - fgSizerAttPrms->Add( m_attenuationZinLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_ZinValueCtrl = new wxTextCtrl( sbSizerAttPrms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerAttPrms->Add( m_ZinValueCtrl, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - - m_attZinUnit = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attZinUnit->Wrap( -1 ); - fgSizerAttPrms->Add( m_attZinUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_ZoutLabel = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Zout:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ZoutLabel->Wrap( -1 ); - fgSizerAttPrms->Add( m_ZoutLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_ZoutValueCtrl = new wxTextCtrl( sbSizerAttPrms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerAttPrms->Add( m_ZoutValueCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_attZoutUnit = new wxStaticText( sbSizerAttPrms->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attZoutUnit->Wrap( -1 ); - fgSizerAttPrms->Add( m_attZoutUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - sbSizerAttPrms->Add( fgSizerAttPrms, 0, wxEXPAND|wxBOTTOM, 5 ); - - - bMiddleSizerAtt->Add( sbSizerAttPrms, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - - wxBoxSizer* bSizerAttButt; - bSizerAttButt = new wxBoxSizer( wxHORIZONTAL ); - - m_buttonAlcAtt = new wxButton( m_panelAttenuators, wxID_ANY, _("Calculate"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerAttButt->Add( m_buttonAlcAtt, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButtonCalcAtt = new wxBitmapButton( m_panelAttenuators, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - bSizerAttButt->Add( m_bpButtonCalcAtt, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - - bMiddleSizerAtt->Add( bSizerAttButt, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - - wxStaticBoxSizer* sbSizerAttValues; - sbSizerAttValues = new wxStaticBoxSizer( new wxStaticBox( m_panelAttenuators, wxID_ANY, _("Values") ), wxVERTICAL ); - - wxFlexGridSizer* fgSizerAttResults; - fgSizerAttResults = new wxFlexGridSizer( 3, 3, 3, 0 ); - fgSizerAttResults->AddGrowableCol( 1 ); - fgSizerAttResults->SetFlexibleDirection( wxBOTH ); - fgSizerAttResults->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_attenuatorR1Label = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("R1:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attenuatorR1Label->Wrap( -1 ); - fgSizerAttResults->Add( m_attenuatorR1Label, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_Att_R1_Value = new wxTextCtrl( sbSizerAttValues->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerAttResults->Add( m_Att_R1_Value, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - - m_attR1Unit = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attR1Unit->Wrap( -1 ); - fgSizerAttResults->Add( m_attR1Unit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_attenuatorR2Label = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("R2:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attenuatorR2Label->Wrap( -1 ); - fgSizerAttResults->Add( m_attenuatorR2Label, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_Att_R2_Value = new wxTextCtrl( sbSizerAttValues->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerAttResults->Add( m_Att_R2_Value, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - - m_attR2Unit = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attR2Unit->Wrap( -1 ); - fgSizerAttResults->Add( m_attR2Unit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_attenuatorR3Label = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("R3:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attenuatorR3Label->Wrap( -1 ); - fgSizerAttResults->Add( m_attenuatorR3Label, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_Att_R3_Value = new wxTextCtrl( sbSizerAttValues->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerAttResults->Add( m_Att_R3_Value, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - m_attR3Unit = new wxStaticText( sbSizerAttValues->GetStaticBox(), wxID_ANY, _("Ohms"), wxDefaultPosition, wxDefaultSize, 0 ); - m_attR3Unit->Wrap( -1 ); - fgSizerAttResults->Add( m_attR3Unit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - sbSizerAttValues->Add( fgSizerAttResults, 0, wxEXPAND|wxBOTTOM, 5 ); - - - bMiddleSizerAtt->Add( sbSizerAttValues, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - - wxBoxSizer* bSizerMessages; - bSizerMessages = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizerIndentLabel; - bSizerIndentLabel = new wxBoxSizer( wxHORIZONTAL ); - - m_staticTextAttMsg = new wxStaticText( m_panelAttenuators, wxID_ANY, _("Messages"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextAttMsg->Wrap( -1 ); - bSizerIndentLabel->Add( m_staticTextAttMsg, 0, wxALL, 2 ); - - - bSizerMessages->Add( bSizerIndentLabel, 0, wxLEFT, 6 ); - - m_Attenuator_Messages = new wxHtmlWindow( m_panelAttenuators, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO ); - bSizerMessages->Add( m_Attenuator_Messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 8 ); - - - bMiddleSizerAtt->Add( bSizerMessages, 1, wxEXPAND|wxLEFT, 3 ); - - - bSizerAtt->Add( bMiddleSizerAtt, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - wxStaticBoxSizer* sbRightSizerFormula; - sbRightSizerFormula = new wxStaticBoxSizer( new wxStaticBox( m_panelAttenuators, wxID_ANY, _("Formula") ), wxVERTICAL ); - - m_panelAttFormula = new wxHtmlWindow( sbRightSizerFormula->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); - sbRightSizerFormula->Add( m_panelAttFormula, 1, wxEXPAND|wxBOTTOM, 5 ); - - - bSizerAtt->Add( sbRightSizerFormula, 1, wxEXPAND|wxALL, 5 ); - - - m_panelAttenuators->SetSizer( bSizerAtt ); - m_panelAttenuators->Layout(); - bSizerAtt->Fit( m_panelAttenuators ); + m_panelAttenuators = new PANEL_ATTENUATORS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_Notebook->AddPage( m_panelAttenuators, _("RF Attenuators"), false ); m_panelESeries = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerESerie; @@ -1756,9 +1588,6 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME_BASE::OnClosePcbCalc ) ); this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME_BASE::OnUpdateUI ) ); - m_AttenuatorsSelection->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnAttenuatorSelection ), NULL, this ); - m_buttonAlcAtt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnCalculateAttenuator ), NULL, this ); - m_bpButtonCalcAtt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnCalculateAttenuator ), NULL, this ); m_e1->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnESeriesSelection ), NULL, this ); m_e3->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnESeriesSelection ), NULL, this ); m_e6->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnESeriesSelection ), NULL, this ); @@ -1819,9 +1648,6 @@ PCB_CALCULATOR_FRAME_BASE::~PCB_CALCULATOR_FRAME_BASE() // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME_BASE::OnClosePcbCalc ) ); this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME_BASE::OnUpdateUI ) ); - m_AttenuatorsSelection->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnAttenuatorSelection ), NULL, this ); - m_buttonAlcAtt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnCalculateAttenuator ), NULL, this ); - m_bpButtonCalcAtt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnCalculateAttenuator ), NULL, this ); m_e1->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnESeriesSelection ), NULL, this ); m_e3->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnESeriesSelection ), NULL, this ); m_e6->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnESeriesSelection ), NULL, this ); diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp index 43c143d7b7..494c0560cf 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp @@ -198,11 +198,11 @@ wxTAB_TRAVERSAL - + RF Attenuators 0 - + 1 1 1 @@ -247,1725 +247,12 @@ Resizable 1 - + PANEL_ATTENUATORS; panel_attenuators.h; Not forward_declare 0 wxTAB_TRAVERSAL - - - bSizerAtt - wxHORIZONTAL - none - - 5 - wxEXPAND|wxRIGHT - 0 - - 260,-1 - bLeftSizerAtt - wxVERTICAL - none - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "PI" "Tee" "Bridged tee" "Resistive splitter" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Attenuators - 1 - - 0 - - - 0 - - 1 - m_AttenuatorsSelection - 1 - - - protected - 1 - - Resizable - 2 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAttenuatorSelection - - - - 5 - wxEXPAND - 0 - - 5 - protected - 0 - - - - 10 - wxALL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_attenuatorBitmap - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - - bMiddleSizerAtt - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT - 0 - - wxID_ANY - Parameters - - sbSizerAttPrms - wxVERTICAL - 1 - none - - 5 - wxEXPAND|wxBOTTOM - 0 - - 3 - wxBOTH - - 1 - 0 - - fgSizerAttPrms - wxFLEX_GROWMODE_SPECIFIED - none - 3 - 3 - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Attenuation: - 0 - - 0 - - - 0 - - 1 - m_attenuationLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_AttValueCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - dB - 0 - - 0 - - - 0 - - 1 - m_attUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Zin: - 0 - - 0 - - - 0 - - 1 - m_attenuationZinLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_ZinValueCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Ohms - 0 - - 0 - - - 0 - - 1 - m_attZinUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Zout: - 0 - - 0 - - - 0 - - 1 - m_ZoutLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_ZoutValueCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Ohms - 0 - - 0 - - - 0 - - 1 - m_attZoutUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - 5 - wxALIGN_CENTER_HORIZONTAL - 0 - - - bSizerAttButt - wxHORIZONTAL - none - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Calculate - - 0 - - 0 - - - 0 - - 1 - m_buttonAlcAtt - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCalculateAttenuator - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Calculate - - 0 - - 0 - - - 0 - - 1 - m_bpButtonCalcAtt - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCalculateAttenuator - - - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT - 0 - - wxID_ANY - Values - - sbSizerAttValues - wxVERTICAL - 1 - none - - 5 - wxEXPAND|wxBOTTOM - 0 - - 3 - wxBOTH - 1 - - 0 - - fgSizerAttResults - wxFLEX_GROWMODE_SPECIFIED - none - 3 - 3 - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - R1: - 0 - - 0 - - - 0 - - 1 - m_attenuatorR1Label - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_Att_R1_Value - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Ohms - 0 - - 0 - - - 0 - - 1 - m_attR1Unit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - R2: - 0 - - 0 - - - 0 - - 1 - m_attenuatorR2Label - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_Att_R2_Value - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Ohms - 0 - - 0 - - - 0 - - 1 - m_attR2Unit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - R3: - 0 - - 0 - - - 0 - - 1 - m_attenuatorR3Label - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_Att_R3_Value - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Ohms - 0 - - 0 - - - 0 - - 1 - m_attR3Unit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - 3 - wxEXPAND|wxLEFT - 1 - - - bSizerMessages - wxVERTICAL - none - - 6 - wxLEFT - 0 - - - bSizerIndentLabel - wxHORIZONTAL - none - - 2 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Messages - 0 - - 0 - - - 0 - - 1 - m_staticTextAttMsg - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - 8 - wxEXPAND|wxBOTTOM|wxRIGHT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_Attenuator_Messages - 1 - - - protected - 1 - - Resizable - 1 - - wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO - - 0 - - - - - - - - - - - - 5 - wxEXPAND|wxALL - 1 - - wxID_ANY - Formula - - sbRightSizerFormula - wxVERTICAL - 1 - none - - 5 - wxEXPAND|wxBOTTOM - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelAttFormula - 1 - - - protected - 1 - - Resizable - 1 - - wxHW_SCROLLBAR_AUTO - - 0 - - - - - - - - - diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.h b/pcb_calculator/dialogs/pcb_calculator_frame_base.h index b822f1bb8d..ef8351645a 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.h +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.h @@ -17,6 +17,7 @@ class UNIT_SELECTOR_RESISTOR; class UNIT_SELECTOR_THICKNESS; #include "panel_regulator.h" +#include "panel_attenuators.h" #include "widgets/unit_selector.h" #include "kiway_player.h" #include @@ -29,18 +30,18 @@ class UNIT_SELECTOR_THICKNESS; #include #include #include -#include -#include -#include #include #include -#include -#include -#include -#include +#include #include #include +#include +#include +#include +#include +#include #include +#include #include #include #include @@ -59,32 +60,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER wxMenuBar* m_menubar; wxNotebook* m_Notebook; PANEL_REGULATOR* m_panelRegulators; - wxPanel* m_panelAttenuators; - wxRadioBox* m_AttenuatorsSelection; - wxStaticBitmap* m_attenuatorBitmap; - wxStaticText* m_attenuationLabel; - wxTextCtrl* m_AttValueCtrl; - wxStaticText* m_attUnit; - wxStaticText* m_attenuationZinLabel; - wxTextCtrl* m_ZinValueCtrl; - wxStaticText* m_attZinUnit; - wxStaticText* m_ZoutLabel; - wxTextCtrl* m_ZoutValueCtrl; - wxStaticText* m_attZoutUnit; - wxButton* m_buttonAlcAtt; - wxBitmapButton* m_bpButtonCalcAtt; - wxStaticText* m_attenuatorR1Label; - wxTextCtrl* m_Att_R1_Value; - wxStaticText* m_attR1Unit; - wxStaticText* m_attenuatorR2Label; - wxTextCtrl* m_Att_R2_Value; - wxStaticText* m_attR2Unit; - wxStaticText* m_attenuatorR3Label; - wxTextCtrl* m_Att_R3_Value; - wxStaticText* m_attR3Unit; - wxStaticText* m_staticTextAttMsg; - wxHtmlWindow* m_Attenuator_Messages; - wxHtmlWindow* m_panelAttFormula; + PANEL_ATTENUATORS* m_panelAttenuators; wxPanel* m_panelESeries; wxStaticText* m_ESrequired; wxTextCtrl* m_ResRequired; @@ -351,8 +327,6 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER // Virtual event handlers, overide them in your derived class virtual void OnClosePcbCalc( wxCloseEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } - virtual void OnAttenuatorSelection( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCalculateAttenuator( wxCommandEvent& event ) { event.Skip(); } virtual void OnESeriesSelection( wxCommandEvent& event ) { event.Skip(); } virtual void OnCalculateESeries( wxCommandEvent& event ) { event.Skip(); } virtual void OnToleranceSelection( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcb_calculator/panel_attenuators.cpp b/pcb_calculator/panel_attenuators.cpp new file mode 100644 index 0000000000..73954a8ae1 --- /dev/null +++ b/pcb_calculator/panel_attenuators.cpp @@ -0,0 +1,223 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2011 jean-pierre.charras + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + +#include +#include + +#include "pcb_calculator_settings.h" +#include "attenuators/attenuator_classes.h" +#include "../dialogs/panel_attenuators.h" + +#include +#include +#include + +extern double DoubleFromString( const wxString& TextValue ); + + +PANEL_ATTENUATORS::PANEL_ATTENUATORS( wxWindow* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style, const wxString& name ) : + PANEL_ATTENUATORS_BASE( parent, id, pos, size, style, name ) +{ + m_CurrAttenuator = nullptr; + m_bpButtonCalcAtt->SetBitmap( KiBitmap( BITMAPS::small_down ) ); + + // Populate attenuator list ordered like in dialog menu list + m_AttenuatorList.push_back( new ATTENUATOR_PI() ); + m_AttenuatorList.push_back( new ATTENUATOR_TEE() ); + m_AttenuatorList.push_back( new ATTENUATOR_BRIDGE() ); + m_AttenuatorList.push_back( new ATTENUATOR_SPLITTER() ); + m_CurrAttenuator = m_AttenuatorList[0]; + + m_staticTextAttMsg->SetFont( KIUI::GetInfoFont( this ).Italic() ); + + m_attZinUnit->SetLabel( wxT( "Ω" ) ); + m_attZoutUnit->SetLabel( wxT( "Ω" ) ); + m_attR1Unit->SetLabel( wxT( "Ω" ) ); + m_attR2Unit->SetLabel( wxT( "Ω" ) ); + m_attR3Unit->SetLabel( wxT( "Ω" ) ); +} + + +PANEL_ATTENUATORS::~PANEL_ATTENUATORS() +{ + for( unsigned ii = 0; ii < m_AttenuatorList.size(); ii++ ) + delete m_AttenuatorList[ii]; +} + + +void PANEL_ATTENUATORS::UpdateUI() +{ + m_attenuatorBitmap->SetBitmap( *m_CurrAttenuator->m_SchBitMap ); + + m_attenuatorBitmap->GetParent()->Layout(); + m_attenuatorBitmap->GetParent()->Refresh(); +} + + +void PANEL_ATTENUATORS::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) +{ + wxASSERT( aCfg ); + + for( ATTENUATOR* attenuator : m_AttenuatorList ) + attenuator->ReadConfig(); + + m_AttenuatorsSelection->SetSelection( aCfg->m_Attenuators.type ); + SetAttenuator( m_AttenuatorsSelection->GetSelection() ); +} + + +void PANEL_ATTENUATORS::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ) +{ + wxASSERT( aCfg ); + + aCfg->m_Attenuators.type = m_AttenuatorsSelection->GetSelection(); + + for( unsigned ii = 0; ii < m_AttenuatorList.size(); ii++ ) + m_AttenuatorList[ii]->WriteConfig(); +} + + +// Called on a attenuator selection +void PANEL_ATTENUATORS::OnAttenuatorSelection( wxCommandEvent& event ) +{ + SetAttenuator( (unsigned) event.GetSelection() ); + Refresh(); +} + + +void PANEL_ATTENUATORS::SetAttenuator( unsigned aIdx ) +{ + if( aIdx >=m_AttenuatorList.size() ) + aIdx = m_AttenuatorList.size() - 1; + + m_CurrAttenuator = m_AttenuatorList[aIdx]; + TransfAttenuatorDataToPanel(); + m_Attenuator_Messages->SetPage( wxEmptyString ); + m_Att_R1_Value->SetValue( wxEmptyString ); + m_Att_R2_Value->SetValue( wxEmptyString ); + m_Att_R3_Value->SetValue( wxEmptyString ); +} + + +void PANEL_ATTENUATORS::OnCalculateAttenuator( wxCommandEvent& event ) +{ + TransfPanelDataToAttenuator(); + m_CurrAttenuator->Calculate(); + TransfAttenuatorResultsToPanel(); +} + + +void PANEL_ATTENUATORS::TransfPanelDataToAttenuator() +{ + wxString msg; + + msg = m_AttValueCtrl->GetValue(); + m_CurrAttenuator->m_Attenuation = DoubleFromString(msg); + msg = m_ZinValueCtrl->GetValue(); + m_CurrAttenuator->m_Zin = DoubleFromString(msg); + msg = m_ZoutValueCtrl->GetValue(); + m_CurrAttenuator->m_Zout = DoubleFromString(msg); +} + + +void PANEL_ATTENUATORS::TransfAttenuatorDataToPanel() +{ + m_attenuatorBitmap->SetBitmap( *m_CurrAttenuator->m_SchBitMap ); + + wxString msg; + + msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Attenuation ); + m_AttValueCtrl->SetValue( msg ); + m_AttValueCtrl->Enable( m_CurrAttenuator->m_Attenuation_Enable ); + + m_ZinValueCtrl->Enable( m_CurrAttenuator->m_Zin_Enable ); + + if( m_CurrAttenuator->m_Zin_Enable ) + msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Zin ); + else + msg.Clear(); + + m_ZinValueCtrl->SetValue( msg ); + + msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Zout ); + m_ZoutValueCtrl->SetValue( msg ); + + if( m_CurrAttenuator->m_FormulaName ) + { + if( m_CurrAttenuator->m_FormulaName->StartsWith( "SetPage( *m_CurrAttenuator->m_FormulaName ); + } + else + { + wxString html_txt; + ConvertMarkdown2Html( wxGetTranslation( *m_CurrAttenuator->m_FormulaName ), html_txt ); + m_panelAttFormula->SetPage( html_txt ); + } + } + else + { + m_panelAttFormula->SetPage( wxEmptyString ); + } +} + + +void PANEL_ATTENUATORS::TransfAttenuatorResultsToPanel() +{ + wxString msg; + + m_Attenuator_Messages->SetPage( wxEmptyString ); + + if( m_CurrAttenuator->m_Error ) + { + msg.Printf( _( "Attenuation more than %f dB" ), + m_CurrAttenuator->m_MinimumATT ); + m_Attenuator_Messages->AppendToPage( wxT( "
Error!

" ) ); + m_Attenuator_Messages->AppendToPage( msg ); + m_Attenuator_Messages->AppendToPage( wxT( "
" ) ); + + // Display -- as resistor values: + msg = wxT( "--" ); + m_Att_R1_Value->SetValue( msg ); + m_Att_R2_Value->SetValue( msg ); + if( m_CurrAttenuator->m_ResultCount >= 3 ) + m_Att_R3_Value->SetValue( msg ); + + return; + } + + msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R1 ); + m_Att_R1_Value->SetValue( msg ); + msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R2 ); + m_Att_R2_Value->SetValue( msg ); + + if( m_CurrAttenuator->m_ResultCount < 3 ) + { + m_Att_R3_Value->SetValue( wxEmptyString ); + } + else + { + msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R3 ); + m_Att_R3_Value->SetValue( msg ); + } +} diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index 17093a4a16..a41871a8e6 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -35,14 +35,12 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_lastNotebookPage( -1 ), m_macHack( true ) { - m_bpButtonCalcAtt->SetBitmap( KiBitmap( BITMAPS::small_down ) ); m_bpButtonAnalyze->SetBitmap( KiBitmap( BITMAPS::small_down ) ); m_bpButtonSynthetize->SetBitmap( KiBitmap( BITMAPS::small_up ) ); SetKiway( this, aKiway ); m_currTransLine = nullptr; m_currTransLineType = DEFAULT_TYPE; - m_currAttenuator = nullptr; m_TWMode = TW_MASTER_CURRENT; m_TWNested = false; @@ -65,21 +63,6 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : 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]; - - m_staticTextAttMsg->SetFont( KIUI::GetInfoFont( this ).Italic() ); - - m_attZinUnit->SetLabel( wxT( "Ω" ) ); - m_attZoutUnit->SetLabel( wxT( "Ω" ) ); - m_attR1Unit->SetLabel( wxT( "Ω" ) ); - m_attR2Unit->SetLabel( wxT( "Ω" ) ); - m_attR3Unit->SetLabel( wxT( "Ω" ) ); - m_reqResUnits->SetLabel( wxT( "kΩ" ) ); m_exclude1Units->SetLabel( wxT( "kΩ" ) ); m_exclude2Units->SetLabel( wxT( "kΩ" ) ); @@ -111,8 +94,6 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : initViaSizePanel(); initESeriesPanel(); - SetAttenuator( m_AttenuatorsSelection->GetSelection() ); - ToleranceSelection( m_rbToleranceSelection->GetSelection() ); BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() ); @@ -151,9 +132,6 @@ 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]; - delete m_ccValueNamesBitmap; delete m_ccValuesBitmap; delete m_ccMultipliersBitmap; @@ -177,28 +155,26 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event ) event2.SetInt( m_currTransLineType ); m_TranslineSelection->Command( event2 ); - for( int i = 0; i < m_attenuator_list.size(); ++i ) + for( int i = 0; i < m_panelAttenuators->m_AttenuatorList.size(); ++i ) { - if( m_attenuator_list[i] == m_currAttenuator ) + if( m_panelAttenuators->m_AttenuatorList[i] == m_panelAttenuators->m_CurrAttenuator ) { - event2.SetEventObject( m_AttenuatorsSelection ); + event2.SetEventObject( m_panelAttenuators->GetAttenuatorsSelector() ); event2.SetInt( i ); - m_AttenuatorsSelection->Command( event2 ); + m_panelAttenuators->GetAttenuatorsSelector()->Command( event2 ); break; } } + m_panelAttenuators->UpdateUI(); + ToleranceSelection( m_rbToleranceSelection->GetSelection() ); m_viaBitmap->SetBitmap( KiBitmap( BITMAPS::viacalc ) ); m_panelViaSize->Layout(); - m_attenuatorBitmap->SetBitmap( *m_currAttenuator->m_SchBitMap ); m_panelRegulators->Layout(); - m_attenuatorBitmap->GetParent()->Layout(); - m_attenuatorBitmap->GetParent()->Refresh(); - m_panelESeriesHelp->Refresh(); m_htmlWinFormulas->Refresh(); @@ -276,9 +252,11 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) m_currTransLineType = static_cast( 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 ); + // Attenuators panel config: + m_panelAttenuators->LoadSettings( cfg ); + // Regul panel config: m_panelRegulators->LoadSettings( cfg ); @@ -288,9 +266,6 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) for( TRANSLINE_IDENT* transline : m_transline_list ) transline->ReadConfig(); - - for( ATTENUATOR* attenuator : m_attenuator_list ) - attenuator->ReadConfig(); } @@ -308,7 +283,6 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { 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(); @@ -316,6 +290,7 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) cfg->m_Electrical.spacing_voltage = m_ElectricalSpacingVoltage->GetValue(); m_panelRegulators->Regulators_WriteConfig( cfg ); + m_panelAttenuators->SaveSettings( cfg ); } writeTrackWidthConfig(); @@ -324,9 +299,6 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) for( unsigned ii = 0; ii < m_transline_list.size(); ii++ ) m_transline_list[ii]->WriteConfig(); - - for( unsigned ii = 0; ii < m_attenuator_list.size(); ii++ ) - m_attenuator_list[ii]->WriteConfig(); } diff --git a/pcb_calculator/pcb_calculator_frame.h b/pcb_calculator/pcb_calculator_frame.h index d6f95a937d..c43b997af8 100644 --- a/pcb_calculator/pcb_calculator_frame.h +++ b/pcb_calculator/pcb_calculator_frame.h @@ -271,27 +271,6 @@ private: void OnToleranceSelection( wxCommandEvent& event ) override; void ToleranceSelection( int aSelection ); - // Attenuators Panel - void OnAttenuatorSelection( wxCommandEvent& event ) override; - void SetAttenuator( unsigned aIdx ); - void OnCalculateAttenuator( wxCommandEvent& event ) override; - void TransfPanelDataToAttenuator(); - void TransfAttenuatorDataToPanel(); - void TransfAttenuatorResultsToPanel(); - - // Regulators Panel -#if 0 - void OnRegulatorCalcButtonClick( wxCommandEvent& event ) override; - void OnRegulatorResetButtonClick( wxCommandEvent& event ) override; - void OnRegulTypeSelection( wxCommandEvent& event ) override; - void OnRegulatorSelection( wxCommandEvent& event ) override; - void OnDataFileSelection( wxCommandEvent& event ) override; - void OnAddRegulator( wxCommandEvent& event ) override; - void OnEditRegulator( wxCommandEvent& event ) override; - void OnRemoveRegulator( wxCommandEvent& event ) override; -#endif - - private: enum // Which dimension is controlling the track width / current { // calculations: @@ -306,9 +285,6 @@ private: TRANSLINE* m_currTransLine; std::vector m_transline_list; - ATTENUATOR* m_currAttenuator; - std::vector m_attenuator_list; - wxBitmap* m_ccValueNamesBitmap; wxBitmap* m_ccValuesBitmap; wxBitmap* m_ccMultipliersBitmap;