KiCad PCB EDA Suite
dialog_dielectric_list_manager.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2009-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
26 
27 
29  DIELECTRIC_SUBSTRATE_LIST& aMaterialList )
31  m_materialList( aMaterialList )
32 {
34 }
35 
37 {
38 }
39 
40 
42 {
43  // Validate double values from wxTextCtrl
44  double dummy;
45 
46  if( !m_tcEpsilonR->GetValue().ToDouble( &dummy ) || dummy < 0.0 )
47  {
48  wxMessageBox( _( "Incorrect value for Epsilon R" ) );
49  return false;
50  }
51 
52  if( !m_tcLossTg->GetValue().ToDouble( &dummy ) || dummy < 0.0 )
53  {
54  wxMessageBox( _( "Incorrect value for Loss Tangent" ) );
55  return false;
56  }
57 
58  return true;
59 }
60 
61 
63 {
64  // Init m_tcEpsilonR and m_tcLossTg to a dummy (default) value
66  dummy.m_EpsilonR = 1.0;
67  dummy.m_LossTangent = 0.0;
68 
69  m_tcEpsilonR->SetValue( dummy.FormatEpsilonR() );
70  m_tcLossTg->SetValue( dummy.FormatLossTangent() );
71 
72  return true;
73 }
74 
75 
77 {
78  DIELECTRIC_SUBSTRATE substrate;
79 
80  // return the selected/created substrate. A empty substrate can be returned
81  double dummy;
82  substrate.m_Name = m_tcMaterial->GetValue();
83  m_tcEpsilonR->GetValue().ToDouble( &dummy );
84  substrate.m_EpsilonR = dummy;
85  m_tcLossTg->GetValue().ToDouble( &dummy );
86  substrate.m_LossTangent = dummy;
87 
88  return substrate;
89 }
90 
91 
93 {
94  m_lcMaterials->AppendColumn( _( "Material" ) );
95  m_lcMaterials->AppendColumn( _( "Epsilon R" ) );
96  m_lcMaterials->AppendColumn( _( "Loss Tg" ) );
97 
98  // Fills m_lcMaterials with available materials
99  // The first item is expected a not specified material
100  // Other names are proper nouns, and are not translated
101  for( int idx = 0; idx < m_materialList.GetCount(); ++idx )
102  {
104 
105  long tmp = m_lcMaterials->InsertItem( idx,
106  idx == 0 ? wxGetTranslation( item->m_Name ) : item->m_Name );
107 
108  m_lcMaterials->SetItemData(tmp, idx);
109  m_lcMaterials->SetItem(tmp, 1, item->FormatEpsilonR() );
110  m_lcMaterials->SetItem(tmp, 2, item->FormatLossTangent() );
111  }
112 }
113 
114 
116 {
117  int idx = event.GetIndex();
118 
119  if( idx < 0 )
120  return;
121 
122  if( idx == 0 )
123  m_tcMaterial->SetValue( wxGetTranslation( m_materialList.GetSubstrate( 0 )->m_Name ) );
124  else
125  m_tcMaterial->SetValue( m_materialList.GetSubstrate( idx )->m_Name );
128 }
DIELECTRIC_SUBSTRATE * GetSubstrate(int aIdx)
DIELECTRIC_SUBSTRATE_LIST & m_materialList
The list of available materials.
void onListItemSelected(wxListEvent &event) override
DIALOG_DIELECTRIC_MATERIAL(wxWindow *aParent, DIELECTRIC_SUBSTRATE_LIST &aMaterialList)
Class DIALOG_DIELECTRIC_MATERIAL_BASE.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
#define _(s)
Definition: 3d_actions.cpp:33