41 double luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
43 return ( luminance < 140.0 ) ? *wxWHITE : *wxBLACK;
55 const wxPoint& pos,
const wxSize& size,
56 long style,
const wxString&
name ) :
320 wxColour color_ok( 122, 166, 194 );
321 wxColour color_text( 0, 0, 0 );
331 if( entryA.m_symbol.size() > 0 )
333 label = entryA.m_symbol;
337 label = entryA.m_name;
342 if( entryA.m_name.size() > 0 )
344 label = entryA.m_name;
348 label = entryA.m_symbol;
352 m_table->SetRowLabelAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
353 m_table->SetRowLabelValue( i, label );
354 m_table->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
355 m_table->SetColLabelValue( i, label );
356 m_table->SetCellAlignment( i, j, wxALIGN_CENTER, wxALIGN_CENTER );
360 double diff = entryA.m_potential - entryB.m_potential;
361 int diff_temp =
KiROUND( abs( diff * 99 ) );
363 value = wxString::Format(
"%.0f", diff * 1000 );
364 m_table->SetCellValue( i, j, value );
368 if( abs( diff ) == 0 )
370 aBg = wxColour( 193, 231, 255 );
376 aBg = wxColour( 226 - diff_temp, 226 - diff_temp, 246 - diff_temp );
380 aBg = wxColour( 255 - diff_temp, 222 - diff_temp, 199 - diff_temp );
388 m_table->SetCellBackgroundColour( i, j, aBg );
390 m_table->SetCellAlignment( i, j, wxALIGN_CENTER, wxALIGN_CENTER );
391 m_table->SetReadOnly( i, j,
true );
398 m_table->SetColLabelTextOrientation( wxVERTICAL );
400 m_table->SetColLabelSize( wxGRID_AUTOSIZE );
401 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)
bool SetPage(const wxString &aSource) override
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.
double DoubleFromString(const wxString &TextValue)
static wxColour getContrastingTextColour(const wxColour &aBg)
wxString galvanic_corrosion_help
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
wxString threshold_voltage