KiCad PCB EDA Suite
PANEL_CORROSION Class Reference

#include <panel_corrosion.h>

Inheritance diagram for PANEL_CORROSION:
PANEL_CORROSION_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_CORROSION (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_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 OnCorFilterChange (wxCommandEvent &aEvent) override
 

Public Attributes

std::vector< CORROSION_TABLE_ENTRYm_entries
 

Protected Attributes

wxScrolledWindow * m_scrolledWindow1
 
wxGrid * m_table
 
wxStaticText * m_staticText16
 
wxStaticText * m_staticText2
 
wxTextCtrl * m_corFilterCtrl
 
wxStaticText * m_staticText3
 

Private Member Functions

void FillTable ()
 

Private Attributes

double m_corFilterValue
 

Detailed Description

Definition at line 40 of file panel_corrosion.h.

Constructor & Destructor Documentation

◆ PANEL_CORROSION()

PANEL_CORROSION::PANEL_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 35 of file panel_corrosion.cpp.

36 :
37 PANEL_CORROSION_BASE( parent, id, pos, size, style, name )
38{
39 m_entries.clear();
40 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Platinum" ), "Pt", -0.57 ) );
41 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Gold" ), "Au", -0.44 ) );
42 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Titanium" ), "Ti", -0.32 ) );
43 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Stainless steel 18-9" ), "X8CrNiS18-9",
44 -0.32 ) );
45 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Silver" ), "Ag", -0.22 ) );
46 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Mercury" ), "Hg", -0.22 ) );
47 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Nickel" ), "Ni", -0.14 ) );
48 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Copper" ), "Cu", 0.0 ) );
49 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Copper-Aluminium" ), "CuAl10", 0.03 ) );
50 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Brass" ), "CuZn39Pb", 0.08 ) );
51 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Bronze" ), "CuSn12", 0.2 ) );
52 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Tin" ), "Sn", 0.23 ) );
53 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Lead" ), "Pb", 0.27 ) );
54 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Aluminium-Copper" ), "AlCu4Mg", 0.37 ) );
55 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Cast iron" ), "", 0.38 ) );
56 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Carbon steel" ), "", 0.43 ) );
57 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Aluminium" ), "Al", 0.52 ) );
58 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Cadmium" ), "Cd", 0.53 ) );
59 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Iron" ), "Fe", 0.535 ) );
60 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Chrome" ), "Cr", 0.63 ) );
61 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Zinc" ), "Zn", 0.83 ) );
62 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Manganese" ), "Mn", 0.9 ) );
63 m_entries.emplace_back( CORROSION_TABLE_ENTRY( _( "Magnesium" ), "Mg", 1.38 ) );
64
65 // Resize the table
66
67 m_table->DeleteCols( 0, m_table->GetNumberCols() );
68 m_table->DeleteRows( 0, m_table->GetNumberRows() );
69 m_table->AppendCols( m_entries.size() );
70 m_table->AppendRows( m_entries.size() );
71
73 FillTable();
74 // Needed on wxWidgets 3.0 to ensure sizers are correctly set
75 GetSizer()->SetSizeHints( this );
76}
const char * name
Definition: DXF_plotter.cpp:56
PANEL_CORROSION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(677, 453), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
std::vector< CORROSION_TABLE_ENTRY > m_entries
#define _(s)

References _, FillTable(), m_corFilterValue, m_entries, and PANEL_CORROSION_BASE::m_table.

◆ ~PANEL_CORROSION()

PANEL_CORROSION::~PANEL_CORROSION ( )

Definition at line 79 of file panel_corrosion.cpp.

80{
81}

Member Function Documentation

◆ FillTable()

void PANEL_CORROSION::FillTable ( )
private

Definition at line 108 of file panel_corrosion.cpp.

109{
110 // Fill the table with data
111 int i = 0;
112
113 wxColour color_ok( 122, 166, 194 );
114
115 wxColour color_text( 0, 0, 0 );
116 wxString value;
117
118
119 for( CORROSION_TABLE_ENTRY entryA : m_entries )
120 {
121 int j = 0;
122
123 wxString label = entryA.m_name;
124
125 if( entryA.m_symbol.size() > 0 )
126 {
127 label += " (" + entryA.m_symbol + ")";
128 }
129 m_table->SetRowLabelValue( i, label );
130 m_table->SetColLabelValue( i, label );
131
132 for( CORROSION_TABLE_ENTRY entryB : m_entries )
133 {
134 double diff = entryA.m_potential - entryB.m_potential;
135 int diff_temp = KiROUND( abs( diff * 100 ) );
136 value = "";
137 value << diff * 1000; // Let's display it in mV instead of V.
138 m_table->SetCellValue( i, j, value );
139
140 // Overide anything that could come from a dark them
141 m_table->SetCellTextColour( i, j, color_text );
142
143 if( ( abs( diff ) ) == 0 )
144 {
145 m_table->SetCellBackgroundColour( i, j, wxColor( 193, 231, 255 ) );
146 }
147 else if( ( KiROUND( abs( diff * 1000 ) ) ) > m_corFilterValue )
148 {
149 m_table->SetCellBackgroundColour(
150 i, j, wxColour( 202 - diff_temp, 206 - diff_temp, 225 - diff_temp ) );
151 }
152 else
153 {
154 m_table->SetCellBackgroundColour( i, j, color_ok );
155 }
156 m_table->SetReadOnly( i, j, true );
157 j++;
158 }
159 i++;
160 }
161
162 m_table->SetColLabelTextOrientation( wxVERTICAL );
163
164 m_table->SetColLabelSize( wxGRID_AUTOSIZE );
165 m_table->SetRowLabelSize( wxGRID_AUTOSIZE );
166 m_table->AutoSizeColumns();
167 m_table->AutoSizeRows();
168 Refresh();
169}
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
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, PANEL_CORROSION_BASE::m_table, and Refresh().

Referenced by OnCorFilterChange(), and PANEL_CORROSION().

◆ LoadSettings()

void PANEL_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 88 of file panel_corrosion.cpp.

89{
92}
double DoubleFromString(const wxString &TextValue)

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

◆ OnCorFilterChange()

void PANEL_CORROSION::OnCorFilterChange ( wxCommandEvent &  aEvent)
overridevirtual

◆ SaveSettings()

void PANEL_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 95 of file panel_corrosion.cpp.

96{
97 aCfg->m_CorrosionTable.threshold_voltage = wxString( "" ) << m_corFilterValue;
98}

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

◆ ThemeChanged()

void PANEL_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 83 of file panel_corrosion.cpp.

84{
85}

Member Data Documentation

◆ m_corFilterCtrl

wxTextCtrl* PANEL_CORROSION_BASE::m_corFilterCtrl
protectedinherited

◆ m_corFilterValue

double PANEL_CORROSION::m_corFilterValue
private

◆ m_entries

std::vector<CORROSION_TABLE_ENTRY> PANEL_CORROSION::m_entries

Definition at line 48 of file panel_corrosion.h.

Referenced by FillTable(), and PANEL_CORROSION().

◆ m_scrolledWindow1

wxScrolledWindow* PANEL_CORROSION_BASE::m_scrolledWindow1
protectedinherited

Definition at line 37 of file panel_corrosion_base.h.

Referenced by PANEL_CORROSION_BASE::PANEL_CORROSION_BASE().

◆ m_staticText16

wxStaticText* PANEL_CORROSION_BASE::m_staticText16
protectedinherited

Definition at line 39 of file panel_corrosion_base.h.

Referenced by PANEL_CORROSION_BASE::PANEL_CORROSION_BASE().

◆ m_staticText2

wxStaticText* PANEL_CORROSION_BASE::m_staticText2
protectedinherited

Definition at line 40 of file panel_corrosion_base.h.

Referenced by PANEL_CORROSION_BASE::PANEL_CORROSION_BASE().

◆ m_staticText3

wxStaticText* PANEL_CORROSION_BASE::m_staticText3
protectedinherited

Definition at line 42 of file panel_corrosion_base.h.

Referenced by PANEL_CORROSION_BASE::PANEL_CORROSION_BASE().

◆ m_table

wxGrid* PANEL_CORROSION_BASE::m_table
protectedinherited

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