KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_regulator_form.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) 1992-2011 jean-pierre.charras
5 * Copyright (C) 1992-2024 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
21#include <wx/msgdlg.h>
22
27
28
29extern double DoubleFromString( const wxString& TextValue );
30
31DIALOG_REGULATOR_FORM::DIALOG_REGULATOR_FORM( wxWindow* parent, const wxString& aRegName ) :
33{
34 m_textCtrlName->SetValue( aRegName );
35 m_textCtrlName->Enable( aRegName.IsEmpty() );
37
39
40 // Now all widgets have the size fixed, call FinishDialogSettings
42}
43
45{
46}
47
48
50{
51 wxTextCtrl* vref_values[] = { m_vrefMinVal, m_vrefTypVal, m_vrefMaxVal };
52 wxTextCtrl* iadj_values[] = { m_iadjTypVal, m_iadjMaxVal };
53
54 if( !wxDialog::TransferDataFromWindow() )
55 return false;
56
57 bool success = true;
58
59 if( m_textCtrlName->GetValue().IsEmpty() )
60 success = false;
61
62 for( const auto& val : vref_values )
63 {
64 if( val->GetValue().IsEmpty() )
65 {
66 success = false;
67 }
68 else
69 {
70 double vref = DoubleFromString( val->GetValue() );
71
72 if( fabs( vref ) < 0.1 )
73 success = false;
74 }
75 }
76
77 if( m_choiceRegType->GetSelection() == 1 )
78 {
79 for( const auto& val : iadj_values )
80 {
81 if( val->GetValue().IsEmpty() )
82 {
83 success = false;
84 }
85 else
86 {
87 int iadj = 0;
88 bool res = val->GetValue().ToInt( &iadj );
89
90 if( res == false || fabs( iadj ) < 1 )
91 success = false;
92 }
93 }
94 }
95
96 return success;
97}
98
99
101{
102 bool enbl = m_choiceRegType->GetSelection() == 1;
103 m_RegulIadjTitle->Show( enbl );
104 m_iadjTypVal->Show( enbl );
105 m_iadjMaxVal->Show( enbl );
106 m_labelUnitIadj->Show( enbl );
107}
108
109
111{
112 m_textCtrlName->SetValue( aItem->m_Name );
113 wxString value;
114 value.Printf( wxT( "%.3g" ), aItem->m_VrefMin );
115 m_vrefMinVal->SetValue( value );
116 value.Printf( wxT( "%.3g" ), aItem->m_VrefTyp );
117 m_vrefTypVal->SetValue( value );
118 value.Printf( wxT( "%.3g" ), aItem->m_VrefMax );
119 m_vrefMaxVal->SetValue( value );
120
121
122 value.Printf( wxT( "%.3g" ), aItem->m_IadjTyp );
123 m_iadjTypVal->SetValue( value );
124 value.Printf( wxT( "%.3g" ), aItem->m_IadjMax );
125 m_iadjMaxVal->SetValue( value );
126
127 m_choiceRegType->SetSelection( aItem->m_Type );
128 UpdateDialog();
129}
130
131
133{
134 double vrefmin = DoubleFromString( m_vrefMinVal->GetValue() );
135 double vreftyp = DoubleFromString( m_vrefTypVal->GetValue() );
136 double vrefmax = DoubleFromString( m_vrefMaxVal->GetValue() );
137
138 double iadjtyp = DoubleFromString( m_iadjTypVal->GetValue() );
139 double iadjmax = DoubleFromString( m_iadjMaxVal->GetValue() );
140
141 int type = m_choiceRegType->GetSelection();
142
143 if( type != 1 )
144 {
145 iadjtyp = 0.0;
146 iadjmax = 0.0;
147 }
148
149 REGULATOR_DATA* item = new REGULATOR_DATA( m_textCtrlName->GetValue(), vrefmin, vreftyp,
150 vrefmax, type, iadjtyp, iadjmax );
151 return item;
152}
Class DIALOG_REGULATOR_FORM_BASE.
void UpdateDialog()
Enable/disable Iadj related widgets, according to the regulator type.
REGULATOR_DATA * BuildRegulatorFromData()
Create a new REGULATOR_DATA from dialog data.
void CopyRegulatorDataToDialog(REGULATOR_DATA *aItem)
Transfer data from dialog to aItem.
DIALOG_REGULATOR_FORM(wxWindow *parent, const wxString &aRegName)
bool TransferDataFromWindow() override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Contains structures for storage of regulator data.
double DoubleFromString(const wxString &TextValue)
double DoubleFromString(const wxString &TextValue)
VECTOR3I res