KiCad PCB EDA Suite
PANEL_GALVANIC_CORROSION Class Reference

#include <panel_galvanic_corrosion.h>

Inheritance diagram for PANEL_GALVANIC_CORROSION:
PANEL_GALVANIC_CORROSION_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_GALVANIC_CORROSION (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_GALVANIC_CORROSION ()
 
void LoadSettings (PCB_CALCULATOR_SETTINGS *aCfg) override
 Load the settings into the panel. More...
 
void SaveSettings (PCB_CALCULATOR_SETTINGS *aCfg) override
 Save the settings from the panel. More...
 
void ThemeChanged () override
 Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appropriate for the new theme. More...
 
void OnNomenclatureChange (wxCommandEvent &aEvent) override
 
void OnCorFilterChange (wxCommandEvent &aEvent) override
 

Public Attributes

std::vector< CORROSION_TABLE_ENTRYm_entries
 

Protected Attributes

wxBoxSizer * bSizer6
 
wxScrolledWindow * m_scrolledWindow1
 
wxGrid * m_table
 
HTML_WINDOWm_helpText
 
wxStaticText * m_staticText2
 
wxTextCtrl * m_corFilterCtrl
 
wxStaticText * m_staticText3
 
wxStaticLine * m_staticline1
 
wxRadioButton * m_radioBtnSymbol
 
wxRadioButton * m_radioBtnName
 

Private Member Functions

void fillTable ()
 

Private Attributes

bool m_symbolicStatus
 
double m_corFilterValue
 

Detailed Description

Definition at line 40 of file panel_galvanic_corrosion.h.

Constructor & Destructor Documentation

◆ PANEL_GALVANIC_CORROSION()

PANEL_GALVANIC_CORROSION::PANEL_GALVANIC_CORROSION ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxTAB_TRAVERSAL,
const wxString &  name = wxEmptyString 
)

Definition at line 40 of file panel_galvanic_corrosion.cpp.

42 :
43 PANEL_GALVANIC_CORROSION_BASE( parent, id, pos, size, style, name )
44{
45 m_entries.clear();
46 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Platinum" ), "Pt", -0.57 ) );
47 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Gold" ), "Au", -0.44 ) );
48 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Titanium" ), "Ti", -0.32 ) );
49 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Stainless steel 18-9" ), "X8CrNiS18-9", -0.32 ) );
50 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Silver" ), "Ag", -0.22 ) );
51 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Mercury" ), "Hg", -0.22 ) );
52 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Nickel" ), "Ni", -0.14 ) );
53 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Copper" ), "Cu", 0.0 ) );
54 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Copper-Aluminium" ), "CuAl10", 0.03 ) );
55 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Brass" ), "CuZn39Pb", 0.08 ) );
56 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Bronze" ), "CuSn12", 0.2 ) );
57 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Tin" ), "Sn", 0.23 ) );
58 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Lead" ), "Pb", 0.27 ) );
59 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Aluminium-Copper" ), "AlCu4Mg", 0.37 ) );
60 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Cast iron" ), "", 0.38 ) );
61 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Carbon steel" ), "", 0.43 ) );
62 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Aluminium" ), "Al", 0.52 ) );
63 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Cadmium" ), "Cd", 0.53 ) );
64 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Iron" ), "Fe", 0.535 ) );
65 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Chrome" ), "Cr", 0.63 ) );
66 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Zinc" ), "Zn", 0.83 ) );
67 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Manganese" ), "Mn", 0.9 ) );
68 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Magnesium" ), "Mg", 1.38 ) );
69
70 // Resize the table
71
72 m_table->DeleteCols( 0, m_table->GetNumberCols() );
73 m_table->DeleteRows( 0, m_table->GetNumberRows() );
74 m_table->AppendCols( (int) m_entries.size() );
75 m_table->AppendRows( (int) m_entries.size() );
76
77 // show markdown formula explanation in lower help panel
78 wxString msg;
79 ConvertMarkdown2Html( wxGetTranslation( galvanic_corrosion_help ), msg );
80 m_helpText->SetPage( msg );
81
82 m_symbolicStatus = true;
84
85 fillTable();
86}
const char * name
Definition: DXF_plotter.cpp:56
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
PANEL_GALVANIC_CORROSION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
std::vector< CORROSION_TABLE_ENTRY > m_entries
#define _(s)
wxString galvanic_corrosion_help
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)

References _, ConvertMarkdown2Html(), fillTable(), galvanic_corrosion_help, m_corFilterValue, m_entries, PANEL_GALVANIC_CORROSION_BASE::m_helpText, m_symbolicStatus, PANEL_GALVANIC_CORROSION_BASE::m_table, and HTML_WINDOW::SetPage().

◆ ~PANEL_GALVANIC_CORROSION()

PANEL_GALVANIC_CORROSION::~PANEL_GALVANIC_CORROSION ( )

Definition at line 89 of file panel_galvanic_corrosion.cpp.

90{
91}

Member Function Documentation

◆ fillTable()

void PANEL_GALVANIC_CORROSION::fillTable ( )
private

Definition at line 135 of file panel_galvanic_corrosion.cpp.

136{
137
138 // Fill the table with data
139 int i = 0;
140 wxColour color_ok( 122, 166, 194 );
141 wxColour color_text( 0, 0, 0 );
142 wxString value;
143 wxString label;
144
145 for( const CORROSION_TABLE_ENTRY& entryA : m_entries )
146 {
147 int j = 0;
148
149 if( m_symbolicStatus == true )
150 {
151 if( entryA.m_symbol.size() > 0 )
152 {
153 label = entryA.m_symbol;
154 }
155 else
156 {
157 label = entryA.m_name;
158 }
159 }
160 else
161 {
162 if( entryA.m_name.size() > 0 )
163 {
164 label = entryA.m_name;
165 }
166 else
167 {
168 label = entryA.m_symbol;
169 }
170 }
171
172 m_table->SetRowLabelAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
173 m_table->SetRowLabelValue( i, label );
174 m_table->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
175 m_table->SetColLabelValue( i, label );
176 m_table->SetCellAlignment( i, j, wxALIGN_CENTER, wxALIGN_CENTER );
177
178 for( const CORROSION_TABLE_ENTRY& entryB : m_entries )
179 {
180 double diff = entryA.m_potential - entryB.m_potential;
181 int diff_temp = KiROUND( abs( diff * 84 ) );
182 value = "";
183 value << diff * 1000; // Let's display it in mV instead of V.
184 m_table->SetCellValue( i, j, value );
185
186 // Overide anything that could come from a dark them
187 m_table->SetCellTextColour( i, j, color_text );
188
189 if( abs( diff ) == 0 )
190 {
191 m_table->SetCellBackgroundColour( i, j, wxColor( 193, 231, 255 ) );
192 }
193 else if( ( KiROUND( abs( diff * 1000 ) ) ) > m_corFilterValue )
194 {
195
196 if( diff > 0 )
197 {
198 m_table->SetCellBackgroundColour( i, j, wxColour( 202 - diff_temp,
199 206 - diff_temp,
200 225 - diff_temp ) );
201 }
202 else if( diff < 0 )
203 {
204 m_table->SetCellBackgroundColour( i, j, wxColour( 255 - diff_temp,
205 217 - diff_temp,
206 194 - diff_temp ) );
207 }
208 }
209 else
210 {
211 m_table->SetCellBackgroundColour( i, j, color_ok );
212 }
213
214 m_table->SetReadOnly( i, j, true );
215 j++;
216 }
217
218 i++;
219 }
220
221 m_table->SetColLabelTextOrientation( wxVERTICAL );
222
223 m_table->SetColLabelSize( wxGRID_AUTOSIZE );
224 m_table->SetRowLabelSize( wxGRID_AUTOSIZE );
225 m_table->AutoSizeColumns();
226 m_table->AutoSizeRows();
227
228 Layout();
229}
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References std::abs(), KiROUND(), m_corFilterValue, m_entries, m_symbolicStatus, and PANEL_GALVANIC_CORROSION_BASE::m_table.

Referenced by OnCorFilterChange(), OnNomenclatureChange(), and PANEL_GALVANIC_CORROSION().

◆ LoadSettings()

void PANEL_GALVANIC_CORROSION::LoadSettings ( PCB_CALCULATOR_SETTINGS aCfg)
overridevirtual

Load the settings into the panel.

Parameters
aCfgis the settings structure to load from

Implements CALCULATOR_PANEL.

Definition at line 100 of file panel_galvanic_corrosion.cpp.

101{
104}
double DoubleFromString(const wxString &TextValue)

References DoubleFromString(), PANEL_GALVANIC_CORROSION_BASE::m_corFilterCtrl, m_corFilterValue, PCB_CALCULATOR_SETTINGS::m_CorrosionTable, and PCB_CALCULATOR_SETTINGS::CORROSION_TABLE::threshold_voltage.

◆ OnCorFilterChange()

void PANEL_GALVANIC_CORROSION::OnCorFilterChange ( wxCommandEvent &  aEvent)
overridevirtual

◆ OnNomenclatureChange()

void PANEL_GALVANIC_CORROSION::OnNomenclatureChange ( wxCommandEvent &  aEvent)
overridevirtual

Reimplemented from PANEL_GALVANIC_CORROSION_BASE.

Definition at line 112 of file panel_galvanic_corrosion.cpp.

113{
114
115 if( m_radioBtnSymbol->GetValue() )
116 {
117 m_symbolicStatus = true;
118 }
119 else if( m_radioBtnName->GetValue() )
120 {
121 m_symbolicStatus = false;
122 }
123
124 fillTable();
125}

References fillTable(), PANEL_GALVANIC_CORROSION_BASE::m_radioBtnName, PANEL_GALVANIC_CORROSION_BASE::m_radioBtnSymbol, and m_symbolicStatus.

◆ SaveSettings()

void PANEL_GALVANIC_CORROSION::SaveSettings ( PCB_CALCULATOR_SETTINGS aCfg)
overridevirtual

Save the settings from the panel.

Parameters
aCfgis the settings structure to save to

Implements CALCULATOR_PANEL.

Definition at line 107 of file panel_galvanic_corrosion.cpp.

108{
109 aCfg->m_CorrosionTable.threshold_voltage = wxString( "" ) << m_corFilterValue;
110}

References m_corFilterValue, PCB_CALCULATOR_SETTINGS::m_CorrosionTable, and PCB_CALCULATOR_SETTINGS::CORROSION_TABLE::threshold_voltage.

◆ ThemeChanged()

void PANEL_GALVANIC_CORROSION::ThemeChanged ( )
overridevirtual

Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appropriate for the new theme.

Implements CALCULATOR_PANEL.

Definition at line 93 of file panel_galvanic_corrosion.cpp.

94{
95 // Update the HTML window with the help text
97}
void ThemeChanged()
Definition: html_window.cpp:63

References PANEL_GALVANIC_CORROSION_BASE::m_helpText, and HTML_WINDOW::ThemeChanged().

Member Data Documentation

◆ bSizer6

wxBoxSizer* PANEL_GALVANIC_CORROSION_BASE::bSizer6
protectedinherited

◆ m_corFilterCtrl

wxTextCtrl* PANEL_GALVANIC_CORROSION_BASE::m_corFilterCtrl
protectedinherited

◆ m_corFilterValue

double PANEL_GALVANIC_CORROSION::m_corFilterValue
private

◆ m_entries

std::vector<CORROSION_TABLE_ENTRY> PANEL_GALVANIC_CORROSION::m_entries

Definition at line 49 of file panel_galvanic_corrosion.h.

Referenced by fillTable(), and PANEL_GALVANIC_CORROSION().

◆ m_helpText

HTML_WINDOW* PANEL_GALVANIC_CORROSION_BASE::m_helpText
protectedinherited

◆ m_radioBtnName

wxRadioButton* PANEL_GALVANIC_CORROSION_BASE::m_radioBtnName
protectedinherited

◆ m_radioBtnSymbol

wxRadioButton* PANEL_GALVANIC_CORROSION_BASE::m_radioBtnSymbol
protectedinherited

◆ m_scrolledWindow1

wxScrolledWindow* PANEL_GALVANIC_CORROSION_BASE::m_scrolledWindow1
protectedinherited

◆ m_staticline1

wxStaticLine* PANEL_GALVANIC_CORROSION_BASE::m_staticline1
protectedinherited

◆ m_staticText2

wxStaticText* PANEL_GALVANIC_CORROSION_BASE::m_staticText2
protectedinherited

◆ m_staticText3

wxStaticText* PANEL_GALVANIC_CORROSION_BASE::m_staticText3
protectedinherited

◆ m_symbolicStatus

bool PANEL_GALVANIC_CORROSION::m_symbolicStatus
private

◆ m_table

wxGrid* PANEL_GALVANIC_CORROSION_BASE::m_table
protectedinherited

The documentation for this class was generated from the following files: