27wxString galvanic_corrosion_help =
32static wxColour getContrastingTextColour(
const wxColour& aBg )
39 double luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
41 return ( luminance < 140.0 ) ? *wxWHITE : *wxBLACK;
53 const wxPoint& pos,
const wxSize& size,
54 long style,
const wxString&
name ) :
240 m_table->DeleteCols( 0, m_table->GetNumberCols() );
241 m_table->DeleteRows( 0, m_table->GetNumberRows() );
242 m_table->AppendCols( (
int) m_entries.size() );
243 m_table->AppendRows( (
int) m_entries.size() );
248 m_helpText->SetPage( msg );
250 m_symbolicStatus =
true;
251 m_corFilterValue = 0;
318 wxColour color_ok( 122, 166, 194 );
319 wxColour color_text( 0, 0, 0 );
323 for(
const CORROSION_TABLE_ENTRY& entryA :
m_entries )
329 if( entryA.m_symbol.size() > 0 )
331 label = entryA.m_symbol;
335 label = entryA.m_name;
340 if( entryA.m_name.size() > 0 )
342 label = entryA.m_name;
346 label = entryA.m_symbol;
350 m_table->SetRowLabelAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
351 m_table->SetRowLabelValue( i, label );
352 m_table->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
353 m_table->SetColLabelValue( i, label );
354 m_table->SetCellAlignment( i, j, wxALIGN_CENTER, wxALIGN_CENTER );
356 for(
const CORROSION_TABLE_ENTRY& entryB :
m_entries )
358 double diff = entryA.m_potential - entryB.m_potential;
361 value = wxString::Format(
"%.0f", diff * 1000 );
362 m_table->SetCellValue( i, j, value );
366 if(
abs( diff ) == 0 )
368 aBg = wxColour( 193, 231, 255 );
374 aBg = wxColour( 226 - diff_temp, 226 - diff_temp, 246 - diff_temp );
378 aBg = wxColour( 255 - diff_temp, 222 - diff_temp, 199 - diff_temp );
386 m_table->SetCellBackgroundColour( i, j, aBg );
387 m_table->SetCellTextColour( i, j, getContrastingTextColour( aBg ) );
388 m_table->SetCellAlignment( i, j, wxALIGN_CENTER, wxALIGN_CENTER );
389 m_table->SetReadOnly( i, j,
true );
396 m_table->SetColLabelTextOrientation( wxVERTICAL );
398 m_table->SetColLabelSize( wxGRID_AUTOSIZE );
399 m_table->SetRowLabelSize( wxGRID_AUTOSIZE );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString m_symbol
Chemical symbol (Cu), not translatable.
wxString m_name
Translatable name ( Copper )
double m_potential
potential in volts, relative to copper
CORROSION_TABLE_ENTRY(const wxString &aName, const wxString &aSymbol, double aPotential)
Class PANEL_GALVANIC_CORROSION_BASE.
wxTextCtrl * m_corFilterCtrl
wxRadioButton * m_radioBtnName
wxRadioButton * m_radioBtnSymbol
void OnNomenclatureChange(wxCommandEvent &aEvent) override
~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)
std::vector< CORROSION_TABLE_ENTRY > m_entries
void ThemeChanged() override
Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appr...
void OnCorFilterChange(wxCommandEvent &aEvent) override
void LoadSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Load the settings into the panel.
void SaveSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Save the settings from the panel.
CORROSION_TABLE m_CorrosionTable
Some functions to handle hotkeys in KiCad.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
double DoubleFromString(const wxString &TextValue)
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
wxString threshold_voltage