KiCad PCB EDA Suite
params_read_write.cpp File Reference
#include <wx/app.h>
#include <wx/colour.h>
#include <wx/msgdlg.h>
#include <calculator_panels/panel_transline.h>
#include <pcb_calculator_frame.h>
#include <transline/transline.h>

Go to the source code of this file.

Macros

#define MSG_CNT_MAX   8
 

Functions

double DoubleFromString (const wxString &TextValue)
 
PANEL_TRANSLINEgetTranslinePanel ()
 
void SetPropertyInDialog (enum PRMS_ID aPrmId, double value)
 
void SetPropertyBgColorInDialog (enum PRMS_ID aPrmId, const KIGFX::COLOR4D *aCol)
 Function SetPropertyBgColorInDialog Set the background color of a parameter. More...
 
void SetResultInDialog (int line, const char *aText)
 
void SetResultInDialog (int aLineNumber, double aValue, const char *aText)
 
double GetPropertyInDialog (enum PRMS_ID aPrmId)
 
bool IsSelectedInDialog (enum PRMS_ID aPrmId)
 

Macro Definition Documentation

◆ MSG_CNT_MAX

#define MSG_CNT_MAX   8

Function Documentation

◆ DoubleFromString()

double DoubleFromString ( const wxString &  TextValue)

Definition at line 37 of file params_read_write.cpp.

38 {
39  double value = 0;
40 
41  /* Acquire the 'right' decimal point separator */
42  const struct lconv* lc = localeconv();
43  wxChar decimal_point = lc->decimal_point[0];
44  wxString buf( TextValue.Strip( wxString::both ) );
45 
46  /* Convert the period in decimal point */
47  buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
48  // An ugly fix needed by WxWidgets 2.9.1 that sometimes
49  // back to a point as separator, although the separator is the comma
50  buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
51 
52  /* Find the end of the numeric part
53  *(when units are append to the number, remove them)
54  */
55  unsigned brk_point = 0;
56  while( brk_point < buf.Len() )
57  {
58  wxChar ch = buf[brk_point];
59  if( !( ( ch >= '0' && ch <= '9' ) || ( ch == decimal_point ) || ( ch == '-' )
60  || ( ch == '+' ) || ( ch == 'e' ) || ( ch == 'E' ) ) )
61  {
62  break;
63  }
64  ++brk_point;
65  }
66 
67  // Check for strings that cannot qualify as a number
68  if( brk_point == 0 )
69  return std::nan( "" );
70 
71  /* Extract the numeric part */
72  if( !buf.Left( brk_point ).ToDouble( &value ) )
73  return std::nan( "" );
74 
75  return value;
76 }

Referenced by DIALOG_REGULATOR_FORM::BuildRegulatorFromData(), PANEL_ELECTRICAL_SPACING::ElectricalSpacingUpdateData(), PANEL_E_SERIE::OnCalculateESeries(), PANEL_TRACK_WIDTH::OnTWCalculateFromCurrent(), PANEL_TRACK_WIDTH::OnTWCalculateFromExtWidth(), PANEL_TRACK_WIDTH::OnTWCalculateFromIntWidth(), PANEL_VIA_SIZE::onUpdateViaCalcErrorText(), PANEL_VIA_SIZE::OnViaCalculate(), PANEL_REGULATOR::RegulatorsSolve(), PANEL_TRANSLINE::TransfDlgDataToTranslineParams(), DIALOG_REGULATOR_FORM::TransferDataFromWindow(), PANEL_ATTENUATORS::TransfPanelDataToAttenuator(), and PANEL_TRACK_WIDTH::TWDisplayValues().

◆ GetPropertyInDialog()

double GetPropertyInDialog ( enum PRMS_ID  aPrmId)

Definition at line 123 of file params_read_write.cpp.

124 {
125  return getTranslinePanel()->GetPrmValue( aPrmId );
126 }
double GetPrmValue(enum PRMS_ID aPrmId) const
Return a param value.
PANEL_TRANSLINE * getTranslinePanel()

References PANEL_TRANSLINE::GetPrmValue(), and getTranslinePanel().

Referenced by TRANSLINE::getProperty().

◆ getTranslinePanel()

PANEL_TRANSLINE* getTranslinePanel ( )

Definition at line 80 of file params_read_write.cpp.

81 {
82  PCB_CALCULATOR_FRAME* frame = (PCB_CALCULATOR_FRAME*) wxTheApp->GetTopWindow();
83  PANEL_TRANSLINE* transline = frame->GetCalculator<PANEL_TRANSLINE>();
84 
85  wxASSERT( transline );
86  return transline;
87 }
PCB calculator the main frame.

References PCB_CALCULATOR_FRAME::GetCalculator().

Referenced by GetPropertyInDialog(), IsSelectedInDialog(), SetPropertyBgColorInDialog(), SetPropertyInDialog(), and SetResultInDialog().

◆ IsSelectedInDialog()

bool IsSelectedInDialog ( enum PRMS_ID  aPrmId)

Definition at line 130 of file params_read_write.cpp.

131 {
132  return getTranslinePanel()->IsPrmSelected( aPrmId );
133 }
PANEL_TRANSLINE * getTranslinePanel()
bool IsPrmSelected(enum PRMS_ID aPrmId) const
Function IsPrmSelected.

References getTranslinePanel(), and PANEL_TRANSLINE::IsPrmSelected().

Referenced by TRANSLINE::isSelected().

◆ SetPropertyBgColorInDialog()

void SetPropertyBgColorInDialog ( enum PRMS_ID  aPrmId,
const KIGFX::COLOR4D aCol 
)

Function SetPropertyBgColorInDialog Set the background color of a parameter.

Parameters
aPrmId= param id to set
aCol= new color

Definition at line 98 of file params_read_write.cpp.

99 {
100  getTranslinePanel()->SetPrmBgColor( aPrmId, aCol );
101 }
void SetPrmBgColor(enum PRMS_ID aPrmId, const KIGFX::COLOR4D *aCol)
Set the background color of a parameter.
PANEL_TRANSLINE * getTranslinePanel()

References getTranslinePanel(), and PANEL_TRANSLINE::SetPrmBgColor().

Referenced by TRANSLINE::setErrorLevel().

◆ SetPropertyInDialog()

void SetPropertyInDialog ( enum PRMS_ID  aPrmId,
double  value 
)

Definition at line 93 of file params_read_write.cpp.

94 {
95  getTranslinePanel()->SetPrmValue( aPrmId, value );
96 }
void SetPrmValue(enum PRMS_ID aPrmId, double aValue)
Read/write params values and results.
PANEL_TRANSLINE * getTranslinePanel()

References getTranslinePanel(), and PANEL_TRANSLINE::SetPrmValue().

Referenced by TRANSLINE::setProperty().

◆ SetResultInDialog() [1/2]

void SetResultInDialog ( int  line,
const char *  aText 
)

Definition at line 105 of file params_read_write.cpp.

106 {
107  wxString msg = wxString::FromUTF8( aText );
108  getTranslinePanel()->SetResult( line, msg );
109 }
PANEL_TRANSLINE * getTranslinePanel()
void SetResult(int aLineNumber, const wxString &aText)
Put the text into the given result line.

References getTranslinePanel(), and PANEL_TRANSLINE::SetResult().

Referenced by TRANSLINE::setResult().

◆ SetResultInDialog() [2/2]

void SetResultInDialog ( int  aLineNumber,
double  aValue,
const char *  aText 
)

Definition at line 113 of file params_read_write.cpp.

114 {
115  wxString msg = wxString::FromUTF8( aText );
116  wxString fullmsg;
117  fullmsg.Printf( wxT( "%g " ), aValue );
118  fullmsg += msg;
119  getTranslinePanel()->SetResult( aLineNumber, fullmsg );
120 }
PANEL_TRANSLINE * getTranslinePanel()
void SetResult(int aLineNumber, const wxString &aText)
Put the text into the given result line.

References getTranslinePanel(), and PANEL_TRANSLINE::SetResult().