2021-10-05 15:32:31 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 jean-pierre.charras
|
2023-01-27 22:41:05 +00:00
|
|
|
* Copyright (C) 1992-2023 Kicad Developers, see AUTHORS.txt for contributors.
|
2021-10-05 15:32:31 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-10-10 15:03:24 +00:00
|
|
|
#include "transline_ident.h"
|
2021-10-05 15:32:31 +00:00
|
|
|
#include <bitmaps.h>
|
2021-10-08 14:44:44 +00:00
|
|
|
#include <calculator_panels/panel_transline.h>
|
|
|
|
#include <pcb_calculator_settings.h>
|
2022-12-29 14:17:21 +00:00
|
|
|
#include <widgets/std_bitmap_button.h>
|
2021-10-05 15:32:31 +00:00
|
|
|
|
2021-10-12 12:08:42 +00:00
|
|
|
|
2023-01-27 22:41:05 +00:00
|
|
|
PANEL_TRANSLINE::PANEL_TRANSLINE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
|
|
|
const wxSize& size, long style, const wxString& name ) :
|
2021-10-10 15:03:24 +00:00
|
|
|
PANEL_TRANSLINE_BASE( parent, id, pos, size, style, name ),
|
|
|
|
m_currTransLine( nullptr ),
|
|
|
|
m_currTransLineType( DEFAULT_TYPE )
|
2021-10-05 15:32:31 +00:00
|
|
|
{
|
|
|
|
m_bpButtonAnalyze->SetBitmap( KiBitmap( BITMAPS::small_down ) );
|
|
|
|
m_bpButtonSynthetize->SetBitmap( KiBitmap( BITMAPS::small_up ) );
|
|
|
|
|
|
|
|
|
|
|
|
// Populate transline list ordered like in dialog menu list
|
|
|
|
const static TRANSLINE_TYPE_ID tltype_list[8] =
|
|
|
|
{
|
|
|
|
MICROSTRIP_TYPE,
|
|
|
|
CPW_TYPE,
|
|
|
|
GROUNDED_CPW_TYPE,
|
|
|
|
RECTWAVEGUIDE_TYPE,
|
|
|
|
COAX_TYPE,
|
|
|
|
C_MICROSTRIP_TYPE,
|
|
|
|
STRIPLINE_TYPE,
|
|
|
|
TWISTEDPAIR_TYPE
|
|
|
|
};
|
|
|
|
|
|
|
|
for( int ii = 0; ii < 8; ii++ )
|
|
|
|
m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) );
|
|
|
|
|
|
|
|
m_EpsilonR_label->SetLabel( wxT( "εr" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PANEL_TRANSLINE::~PANEL_TRANSLINE()
|
|
|
|
{
|
2021-10-10 15:03:24 +00:00
|
|
|
for( TRANSLINE_IDENT* transline : m_transline_list )
|
|
|
|
delete transline;
|
2021-10-05 15:32:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-08 16:30:36 +00:00
|
|
|
void PANEL_TRANSLINE::ThemeChanged()
|
|
|
|
{
|
|
|
|
// Update the bitmaps
|
|
|
|
m_bpButtonAnalyze->SetBitmap( KiBitmap( BITMAPS::small_down ) );
|
|
|
|
m_bpButtonSynthetize->SetBitmap( KiBitmap( BITMAPS::small_up ) );
|
|
|
|
m_translineBitmap->SetBitmap( KiBitmap( m_transline_list[m_currTransLineType]->m_BitmapName ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-05 15:32:31 +00:00
|
|
|
void PANEL_TRANSLINE::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
|
|
|
{
|
2023-06-14 09:59:30 +00:00
|
|
|
// Ensure parameters from current selection are up to date before saving
|
|
|
|
if( m_currTransLine )
|
|
|
|
TransfDlgDataToTranslineParams();
|
|
|
|
|
2021-10-05 15:32:31 +00:00
|
|
|
aCfg->m_TransLine.type = m_currTransLineType;
|
|
|
|
|
2021-10-10 15:03:24 +00:00
|
|
|
for( TRANSLINE_IDENT* transline : m_transline_list )
|
|
|
|
transline->WriteConfig();
|
2021-10-05 15:32:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_TRANSLINE::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
|
|
|
{
|
|
|
|
m_currTransLineType = static_cast<TRANSLINE_TYPE_ID>( aCfg->m_TransLine.type );
|
|
|
|
|
|
|
|
for( TRANSLINE_IDENT* transline : m_transline_list )
|
|
|
|
transline->ReadConfig();
|
|
|
|
|
|
|
|
TranslineTypeSelection( m_currTransLineType );
|
|
|
|
m_TranslineSelection->SetSelection( m_currTransLineType );
|
2021-10-09 07:07:18 +00:00
|
|
|
|
|
|
|
// Needed on wxWidgets 3.0 to ensure sizers are correctly set
|
|
|
|
// It also remove a minor cosmetic issue on wxWidgets 3.5 on MSW
|
|
|
|
// Called here after the current selected transline bitmaps are enabled/disabled
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2021-10-05 15:32:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_TRANSLINE::OnTranslineAnalyse( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_currTransLine )
|
|
|
|
{
|
|
|
|
TransfDlgDataToTranslineParams();
|
|
|
|
m_currTransLine->analyze();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_TRANSLINE::OnTranslineSynthetize( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_currTransLine )
|
|
|
|
{
|
|
|
|
TransfDlgDataToTranslineParams();
|
|
|
|
m_currTransLine->synthesize();
|
|
|
|
}
|
|
|
|
}
|