Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
ExponentialForm.cpp
1/*
2 * Copyright (C) 2017 Thales Lima Oliveira <thales@ufu.br>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#include "ExponentialForm.h"
19#include "../elements/controlElement/Exponential.h"
20
21ExponentialForm::ExponentialForm(wxWindow* parent, Exponential* exponential) : ExponentialFormBase(parent)
22{
23 SetSize(GetBestSize());
24
25 wxString expSymbol = wxString::FromUTF8("\xF0\x9D\x91\x92");
26 wxString superscriptCapitalB = wxString::FromUTF8("\xE1\xB4\xAE");
27 wxString superscriptSmallX = wxString::FromUTF8("\xCB\xA3");
28 m_staticTextExp->SetLabel("y = A" + expSymbol + superscriptCapitalB + superscriptSmallX);
29
30 wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
31 font.SetPointSize(14);
32 m_staticTextExp->SetFont(font);
33
34 m_parent = parent;
35 m_exponential = exponential;
36
37 double a, b;
38 m_exponential->GetValues(a, b);
39 m_textCtrlAValue->SetValue(m_exponential->StringFromDouble(a));
40 m_textCtrlBValue->SetValue(m_exponential->StringFromDouble(b));
41
42 SetInitialSize();
43 Layout();
44}
45
46ExponentialForm::~ExponentialForm() {}
47void ExponentialForm::OnOKButtonClick(wxCommandEvent& event)
48{
49 if(ValidateData()) EndModal(wxID_OK);
50}
51
52bool ExponentialForm::ValidateData()
53{
54 double a, b;
55 if(!m_exponential->DoubleFromString(this, m_textCtrlAValue->GetValue(), a,
56 _("Value entered incorrectly in the field \"A value\".")))
57 return false;
58 if(!m_exponential->DoubleFromString(this, m_textCtrlBValue->GetValue(), b,
59 _("Value entered incorrectly in the field \"B value\".")))
60 return false;
61 m_exponential->SetValues(a, b);
62 return true;
63}
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.
Definition Element.cpp:505
Generates an output following an exponential function.
Definition Exponential.h:33