20#include "../elements/powerElement/Line.h"
22LineForm::LineForm(wxWindow* parent,
Line* line) : LineFormBase(parent)
24 SetSize(GetBestSize());
25 m_choiceResistance->SetString(1, L
'\u03A9');
26 m_choiceResistance->SetString(2, (wxString)L
'\u03A9' +
"/km");
27 m_choiceResistance->SetInitialSize();
28 m_textCtrlResistance->SetInitialSize();
30 m_choiceReactance->SetString(1, L
'\u03A9');
31 m_choiceReactance->SetString(2, (wxString)L
'\u03A9' +
"/km");
32 m_choiceReactance->SetInitialSize();
33 m_textCtrlReactance->SetInitialSize();
35 ReplaceStaticTextLabelChar(m_staticTextZeroResistance, L
'\u2080');
36 ReplaceStaticTextLabelChar(m_staticTextZeroReactance, L
'\u2080');
37 ReplaceStaticTextLabelChar(m_staticTextZeroSusceptance, L
'\u2080');
39 SetSize(GetBestSize());
46 m_textCtrlName->SetValue(data.name);
49 switch(data.nominalVoltageUnit) {
51 nominalVoltageStr +=
" V";
54 nominalVoltageStr +=
" kV";
59 m_staticTextNominalVoltageValue->SetLabel(nominalVoltageStr);
62 switch(data.nominalPowerUnit) {
64 m_choiceNominalPower->SetSelection(0);
67 m_choiceNominalPower->SetSelection(1);
70 m_choiceNominalPower->SetSelection(2);
77 switch(data.resistanceUnit) {
79 m_choiceResistance->SetSelection(0);
82 m_choiceResistance->SetSelection(1);
85 m_choiceResistance->SetSelection(2);
92 switch(data.indReactanceUnit) {
94 m_choiceReactance->SetSelection(0);
97 m_choiceReactance->SetSelection(1);
100 m_choiceReactance->SetSelection(2);
107 switch(data.capSusceptanceUnit) {
109 m_choiceSusceptance->SetSelection(0);
112 m_choiceSusceptance->SetSelection(1);
115 m_choiceSusceptance->SetSelection(2);
122 m_checkUseLinePower->SetValue(data.useLinePower);
129LineForm::~LineForm() {}
130void LineForm::OnCancelButtonClick(wxCommandEvent& event) { EndModal(wxID_CANCEL); }
131void LineForm::OnOKButtonClick(wxCommandEvent& event)
133 if(ValidateData()) EndModal(wxID_OK);
136void LineForm::OnStabilityButtonClick(wxCommandEvent& event)
140 swForm.SetTitle(_(
"Line: Switching"));
146void LineForm::ReplaceStaticTextLabelChar(wxStaticText* staticText,
wchar_t newChar)
148 wxString label = staticText->GetLabel();
149 label[label.length() - 2] = newChar;
150 staticText->SetLabel(label);
153bool LineForm::ValidateData()
157 data.name = m_textCtrlName->GetValue();
159 if(!m_line->
DoubleFromString(m_parent, m_textCtrlNominalPower->GetValue(), data.nominalPower,
160 _(
"Value entered incorrectly in the field \"Nominal power\".")))
162 switch(m_choiceNominalPower->GetSelection()) {
174 if(!m_line->
DoubleFromString(m_parent, m_textCtrlResistance->GetValue(), data.resistance,
175 _(
"Value entered incorrectly in the field \"Resistance\".")))
177 switch(m_choiceResistance->GetSelection()) {
189 if(!m_line->
DoubleFromString(m_parent, m_textCtrlReactance->GetValue(), data.indReactance,
190 _(
"Value entered incorrectly in the field \"Indutive Reactance\".")))
192 switch(m_choiceReactance->GetSelection()) {
204 if(!m_line->
DoubleFromString(m_parent, m_textCtrlSusceptance->GetValue(), data.capSusceptance,
205 _(
"Value entered incorrectly in the field \"Capacitive Susceptance\".")))
207 switch(m_choiceSusceptance->GetSelection()) {
219 if(!m_line->
DoubleFromString(m_parent, m_textCtrlLineSize->GetValue(), data.lineSize,
220 _(
"Value entered incorrectly in the field \"Line size\".")))
223 data.useLinePower = m_checkUseLinePower->GetValue();
225 if(!m_line->
DoubleFromString(m_parent, m_textCtrlZeroResistance->GetValue(), data.zeroResistance,
226 _(
"Value entered incorrectly in the field \"Zero-sequence resistance\".")))
228 if(!m_line->
DoubleFromString(m_parent, m_textCtrlZeroReactance->GetValue(), data.zeroIndReactance,
229 _(
"Value entered incorrectly in the field \"Zero-sequence indutive reactance\".")))
231 if(!m_line->
DoubleFromString(m_parent, m_textCtrlZeroSusceptance->GetValue(), data.zeroCapSusceptance,
232 _(
"Value entered incorrectly in the field \"Zero-sequence capacitive susceptance\".")))
235 m_line->SetElectricalData(data);
static bool DoubleFromString(wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
Get a double value from a string. Show a error message if the conversion fail.
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.