From 0f5ee38ee28ba5acc57e952cc34a9f7574b1c32d Mon Sep 17 00:00:00 2001 From: aris-kimi Date: Thu, 2 Mar 2023 22:25:48 +0000 Subject: [PATCH] Corrosion table update --- pcb_calculator/CMakeLists.txt | 2 + .../panel_galvanic_corrosion.cpp | 73 ++- .../panel_galvanic_corrosion.h | 2 + .../panel_galvanic_corrosion_base.cpp | 44 +- .../panel_galvanic_corrosion_base.fbp | 582 ++++++++++++------ .../panel_galvanic_corrosion_base.h | 7 + pcb_calculator/galvanic_corrosion_help.h | 7 + pcb_calculator/galvanic_corrosion_help.md | 5 + 8 files changed, 507 insertions(+), 215 deletions(-) create mode 100644 pcb_calculator/galvanic_corrosion_help.h create mode 100644 pcb_calculator/galvanic_corrosion_help.md diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index 119e96914b..93f15b2ac2 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -219,6 +219,7 @@ endfunction() md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula ) md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/eseries_help ) md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/fusing_current_help ) + md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/galvanic_corrosion_help ) set( DOCS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/pi_formula.h @@ -228,6 +229,7 @@ set( DOCS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula.h ${CMAKE_CURRENT_SOURCE_DIR}/eseries_help.h ${CMAKE_CURRENT_SOURCE_DIR}/fusing_current_help.h + ${CMAKE_CURRENT_SOURCE_DIR}/galvanic_corrosion_help.h ) set_source_files_properties( attenuators/attenuator_classes.cpp diff --git a/pcb_calculator/calculator_panels/panel_galvanic_corrosion.cpp b/pcb_calculator/calculator_panels/panel_galvanic_corrosion.cpp index 8e48ffc51d..c82d05e68a 100644 --- a/pcb_calculator/calculator_panels/panel_galvanic_corrosion.cpp +++ b/pcb_calculator/calculator_panels/panel_galvanic_corrosion.cpp @@ -21,6 +21,10 @@ #include #include #include // for KiROUND +#include +#include // For _HKI definition in galvanic_corrosion_help.h +wxString galvanic_corrosion_help = +#include "galvanic_corrosion_help.h" extern double DoubleFromString( const wxString& TextValue ); @@ -70,24 +74,14 @@ PANEL_GALVANIC_CORROSION::PANEL_GALVANIC_CORROSION( wxWindow* parent, wxWindowID m_table->AppendCols( (int) m_entries.size() ); m_table->AppendRows( (int) m_entries.size() ); - // This is not currently HTML because we're in string freeze. But it might be nice to pretty - // it up for the next version.... - wxString help( _( "This table shows the difference in electrochemical potential between " - "various metals and alloys. A positive number indicates that the row is " - "anodic and the column is cathodic.\n" - "Galvanic corrosion affects different metals in contact and under certain " - "conditions.\n" - "The anode of an electrochemical pair gets oxidized and eaten away, while " - "the cathode gets dissolved metals plated onto it but stays protected.\n" - "EN 50310 suggests a voltage difference below 300mV. Known practices make " - "use of a third interface metal in between the main pair(ie the ENIG surface " - "finish)." ) ); - - help.Replace( "\n", "
" ); - - m_helpText->SetPage( help ); + // show markdown formula explanation in lower help panel + wxString msg; + ConvertMarkdown2Html( wxGetTranslation( galvanic_corrosion_help ), msg ); + m_helpText->SetPage( msg ); + m_symbolicStatus = true; m_corFilterValue = 0; + fillTable(); } @@ -98,6 +92,8 @@ PANEL_GALVANIC_CORROSION::~PANEL_GALVANIC_CORROSION() void PANEL_GALVANIC_CORROSION::ThemeChanged() { + // Update the HTML window with the help text + m_helpText->ThemeChanged(); } @@ -113,6 +109,21 @@ void PANEL_GALVANIC_CORROSION::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ) aCfg->m_CorrosionTable.threshold_voltage = wxString( "" ) << m_corFilterValue; } +void PANEL_GALVANIC_CORROSION::OnNomenclatureChange( wxCommandEvent& aEvent ) +{ + + if( m_radioBtnSymbol->GetValue() ) + { + m_symbolicStatus = true; + } + else if( m_radioBtnName->GetValue() ) + { + m_symbolicStatus = false; + } + + fillTable(); +} + void PANEL_GALVANIC_CORROSION::OnCorFilterChange( wxCommandEvent& aEvent ) { @@ -123,19 +134,40 @@ void PANEL_GALVANIC_CORROSION::OnCorFilterChange( wxCommandEvent& aEvent ) void PANEL_GALVANIC_CORROSION::fillTable() { + // Fill the table with data int i = 0; wxColour color_ok( 122, 166, 194 ); wxColour color_text( 0, 0, 0 ); wxString value; + wxString label; for( const CORROSION_TABLE_ENTRY& entryA : m_entries ) { int j = 0; - wxString label = entryA.m_name; - if( entryA.m_symbol.size() > 0 ) - label += " (" + entryA.m_symbol + ")"; + if( m_symbolicStatus == true ) + { + if( entryA.m_symbol.size() > 0 ) + { + label = entryA.m_symbol; + } + else + { + label = entryA.m_name; + } + } + else + { + if( entryA.m_name.size() > 0 ) + { + label = entryA.m_name; + } + else + { + label = entryA.m_symbol; + } + } m_table->SetRowLabelAlignment( wxALIGN_RIGHT, wxALIGN_CENTER ); m_table->SetRowLabelValue( i, label ); @@ -192,5 +224,6 @@ void PANEL_GALVANIC_CORROSION::fillTable() m_table->SetRowLabelSize( wxGRID_AUTOSIZE ); m_table->AutoSizeColumns(); m_table->AutoSizeRows(); - Refresh(); + + Layout(); } diff --git a/pcb_calculator/calculator_panels/panel_galvanic_corrosion.h b/pcb_calculator/calculator_panels/panel_galvanic_corrosion.h index b9d53c452c..eb2825e538 100644 --- a/pcb_calculator/calculator_panels/panel_galvanic_corrosion.h +++ b/pcb_calculator/calculator_panels/panel_galvanic_corrosion.h @@ -51,12 +51,14 @@ public: void LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) override; void SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ) override; void ThemeChanged() override; + void OnNomenclatureChange( wxCommandEvent& aEvent ) override; void OnCorFilterChange( wxCommandEvent& aEvent ) override; private: void fillTable(); private: + bool m_symbolicStatus; double m_corFilterValue; }; diff --git a/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.cpp b/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.cpp index 74f616730c..877b39be27 100644 --- a/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.cpp +++ b/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.cpp @@ -11,10 +11,9 @@ PANEL_GALVANIC_CORROSION_BASE::PANEL_GALVANIC_CORROSION_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : CALCULATOR_PANEL( parent, id, pos, size, style, name ) { - wxBoxSizer* bSizer6; bSizer6 = new wxBoxSizer( wxVERTICAL ); - m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL ); m_scrolledWindow1->SetScrollRate( 5, 5 ); wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxVERTICAL ); @@ -42,8 +41,8 @@ PANEL_GALVANIC_CORROSION_BASE::PANEL_GALVANIC_CORROSION_BASE( wxWindow* parent, // Label Appearance // Cell Defaults - m_table->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - bSizer7->Add( m_table, 1, wxEXPAND, 5 ); + m_table->SetDefaultCellAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM ); + bSizer7->Add( m_table, 0, 0, 5 ); m_scrolledWindow1->SetSizer( bSizer7 ); @@ -52,28 +51,51 @@ PANEL_GALVANIC_CORROSION_BASE::PANEL_GALVANIC_CORROSION_BASE( wxWindow* parent, bSizer6->Add( m_scrolledWindow1, 1, wxEXPAND|wxALL, 5 ); m_helpText = new HTML_WINDOW( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); - m_helpText->SetMinSize( wxSize( 400,100 ) ); + m_helpText->SetMinSize( wxSize( 400,110 ) ); bSizer6->Add( m_helpText, 0, wxALL|wxEXPAND, 5 ); + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizer3; bSizer3 = new wxBoxSizer( wxHORIZONTAL ); m_staticText2 = new wxStaticText( this, wxID_ANY, _("Threshold voltage:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2->Wrap( -1 ); - bSizer3->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + bSizer3->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxTOP, 5 ); m_corFilterCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_corFilterCtrl->SetMinSize( wxSize( 100,-1 ) ); - bSizer3->Add( m_corFilterCtrl, 0, wxALL, 5 ); + bSizer3->Add( m_corFilterCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_staticText3 = new wxStaticText( this, wxID_ANY, _("mV"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText3->Wrap( -1 ); - bSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); + bSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); + m_staticline1->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); + + bSizer3->Add( m_staticline1, 0, wxEXPAND, 5 ); - bSizer6->Add( bSizer3, 0, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); + bSizer5->Add( bSizer3, 0, 0, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + m_radioBtnSymbol = new wxRadioButton( this, wxID_ANY, _("Symbols"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_radioBtnSymbol, 0, 0, 5 ); + + m_radioBtnName = new wxRadioButton( this, wxID_ANY, _("Names"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_radioBtnName, 0, 0, 5 ); + + + bSizer5->Add( bSizer4, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizer6->Add( bSizer5, 0, wxEXPAND, 5 ); this->SetSizer( bSizer6 ); @@ -82,11 +104,15 @@ PANEL_GALVANIC_CORROSION_BASE::PANEL_GALVANIC_CORROSION_BASE( wxWindow* parent, // Connect Events m_corFilterCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_GALVANIC_CORROSION_BASE::OnCorFilterChange ), NULL, this ); + m_radioBtnSymbol->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_GALVANIC_CORROSION_BASE::OnNomenclatureChange ), NULL, this ); + m_radioBtnName->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_GALVANIC_CORROSION_BASE::OnNomenclatureChange ), NULL, this ); } PANEL_GALVANIC_CORROSION_BASE::~PANEL_GALVANIC_CORROSION_BASE() { // Disconnect Events m_corFilterCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_GALVANIC_CORROSION_BASE::OnCorFilterChange ), NULL, this ); + m_radioBtnSymbol->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_GALVANIC_CORROSION_BASE::OnNomenclatureChange ), NULL, this ); + m_radioBtnName->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_GALVANIC_CORROSION_BASE::OnNomenclatureChange ), NULL, this ); } diff --git a/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.fbp b/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.fbp index 9cea0e904d..23a7cea482 100644 --- a/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.fbp +++ b/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.fbp @@ -56,7 +56,7 @@ bSizer6 wxVERTICAL - none + protected 5 wxEXPAND|wxALL @@ -113,17 +113,17 @@ - wxHSCROLL|wxVSCROLL + wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL bSizer7 wxVERTICAL none - + 5 - wxEXPAND - 1 - + + 0 + 1 1 1 @@ -140,9 +140,9 @@ 1 - wxALIGN_LEFT + wxALIGN_CENTER - wxALIGN_TOP + wxALIGN_BOTTOM 0 1 wxALIGN_CENTER @@ -247,7 +247,7 @@ 0 - 400,100 + 400,110 1 m_helpText 1 @@ -270,198 +270,408 @@ 5 - wxEXPAND|wxBOTTOM|wxLEFT + wxEXPAND 0 - bSizer3 + bSizer5 wxHORIZONTAL none 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Threshold voltage: - 0 - - 0 - - - 0 + - 1 - m_staticText2 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 + bSizer3 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Threshold voltage: + 0 + + 0 + + + 0 + + 1 + m_staticText2 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 100,-1 + 1 + m_corFilterCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnCorFilterChange + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mV + 0 + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,90,-1,70,0 + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_VERTICAL + ; ; forward_declare + 0 + + + + + + 5 - wxALL + wxALIGN_CENTER_VERTICAL 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - 100,-1 - 1 - m_corFilterCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnCorFilterChange - - - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mV - 0 - - 0 - - - 0 + - 1 - m_staticText3 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 + bSizer4 + wxHORIZONTAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Symbols + + 0 + + + 0 + + 1 + m_radioBtnSymbol + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnNomenclatureChange + + + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Names + + 0 + + + 0 + + 1 + m_radioBtnName + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnNomenclatureChange + + diff --git a/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.h b/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.h index 0a95fa46ac..39efcc902c 100644 --- a/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.h +++ b/pcb_calculator/calculator_panels/panel_galvanic_corrosion_base.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -36,15 +38,20 @@ class PANEL_GALVANIC_CORROSION_BASE : public CALCULATOR_PANEL private: protected: + wxBoxSizer* bSizer6; wxScrolledWindow* m_scrolledWindow1; wxGrid* m_table; HTML_WINDOW* m_helpText; wxStaticText* m_staticText2; wxTextCtrl* m_corFilterCtrl; wxStaticText* m_staticText3; + wxStaticLine* m_staticline1; + wxRadioButton* m_radioBtnSymbol; + wxRadioButton* m_radioBtnName; // Virtual event handlers, override them in your derived class virtual void OnCorFilterChange( wxCommandEvent& event ) { event.Skip(); } + virtual void OnNomenclatureChange( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcb_calculator/galvanic_corrosion_help.h b/pcb_calculator/galvanic_corrosion_help.h new file mode 100644 index 0000000000..4aa871a2ca --- /dev/null +++ b/pcb_calculator/galvanic_corrosion_help.h @@ -0,0 +1,7 @@ +// Do not edit this file, it is autogenerated by CMake from the .md file +_HKI( "This table shows the difference in electrochemical potential between various metals and alloys. Galvanic corrosion affects different metals in contact and under certain conditions.
\n" +"The anode of an electrochemical pair gets oxidized and eaten away, while the cathode gets dissolved metals plated onto it but stays protected.
\n" +"A positive number indicates that the row is anodic (-) and the column is cathodic (+), cold and warm coloring hues also indicate rows' potential.
\n" +"EN 50310 suggests a voltage difference below 300mV. Known practices make use of a third interface metal in between the main pair(ie the ENIG surface finish).
\n" +"Selected cells shown with the default system's coloring choice after a table refill.\n" +"" ); diff --git a/pcb_calculator/galvanic_corrosion_help.md b/pcb_calculator/galvanic_corrosion_help.md new file mode 100644 index 0000000000..a8609862b4 --- /dev/null +++ b/pcb_calculator/galvanic_corrosion_help.md @@ -0,0 +1,5 @@ +This table shows the difference in electrochemical potential between various metals and alloys. Galvanic corrosion affects different metals in contact and under certain conditions.
+The anode of an electrochemical pair gets oxidized and eaten away, while the cathode gets dissolved metals plated onto it but stays protected.
+A positive number indicates that the row is anodic (-) and the column is cathodic (+), cold and warm coloring hues also indicate rows' potential.
+EN 50310 suggests a voltage difference below 300mV. Known practices make use of a third interface metal in between the main pair(ie the ENIG surface finish).
+Selected cells shown with the default system's coloring choice after a table refill.