PCB Calcs: Reset default units along with values

(cherry picked from commit bd1f6e505cc294457c2960cae6bb955de1af9f5a)
This commit is contained in:
JamesJCode 2025-04-21 21:28:00 +01:00
parent 68b86e6817
commit 072562eb1a
3 changed files with 11 additions and 7 deletions

View File

@ -360,6 +360,10 @@ void PANEL_TRANSLINE::OnTransLineResetButtonClick( wxCommandEvent& event )
{
TRANSLINE_PRM* prm = tr_ident->GetPrm( ii );
prm->m_Value = prm->m_DefaultValue;
UNIT_SELECTOR* unit_ctrl = (UNIT_SELECTOR*) prm->m_UnitCtrl;
if( unit_ctrl )
prm->m_UnitSelection = prm->m_DefaultUnit;
}
// Reinit displayed values

View File

@ -42,9 +42,8 @@
#include "transline_ident.h"
TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg,
const wxString& aDlgLabel, const wxString& aToolTip,
double aValue, bool aConvUnit )
TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg, const wxString& aDlgLabel,
const wxString& aToolTip, double aValue, bool aConvUnit, int aDefaultUnit )
{
m_Type = aType;
m_Id = aId;
@ -53,6 +52,7 @@ TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordC
m_ToolTip = aToolTip;
m_Value = aValue;
m_DefaultValue = aValue;
m_DefaultUnit = aDefaultUnit;
m_ConvUnit = aConvUnit;
m_ValueCtrl = nullptr;
m_UnitCtrl = nullptr;

View File

@ -68,10 +68,9 @@ public:
* @param aDlgLabel is a I18n string used to identify the parameter in dialog.
* usually aDlgLabel is same as aKeywordCfg, but translatable.
*/
TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg = "",
const wxString& aDlgLabel = wxEmptyString,
const wxString& aToolTip = wxEmptyString,
double aValue = 0.0, bool aConvUnit = false );
TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg = "", const wxString& aDlgLabel = wxEmptyString,
const wxString& aToolTip = wxEmptyString, double aValue = 0.0, bool aConvUnit = false,
int aDefaultUnit = 0 );
double ToUserUnit();
double FromUserUnit();
@ -83,6 +82,7 @@ public:
wxString m_ToolTip; // Tool tip for this parameter in dialog
double m_Value; // Value for this parameter in dialog
double m_DefaultValue; // Default value for this parameter from CTOR build
int m_DefaultUnit; // Default unit selection for this parameter
double m_NormalizedValue; // actual value for this parameter
bool m_ConvUnit; // true if an unit selector must be used
void* m_ValueCtrl; // The text ctrl containing the value in dialog