Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
GainForm.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 "GainForm.h"
19#include "../elements/controlElement/Gain.h"
20
21GainForm::GainForm(wxWindow* parent, Gain* gain) : GainFormBase(parent)
22{
23 SetSize(GetBestSize());
24
25 m_parent = parent;
26 m_gain = gain;
27
28 m_textCtrlValue->SetValue(m_gain->StringFromDouble(m_gain->GetValue()));
29}
30
31GainForm::~GainForm() {}
32void GainForm::OnOKButtonClick(wxCommandEvent& event)
33{
34 if(ValidateData()) EndModal(wxID_OK);
35}
36
37bool GainForm::ValidateData()
38{
39 double value;
40 if(!m_gain->DoubleFromString(this, m_textCtrlValue->GetValue(), value,
41 _("Value entered incorrectly in the field \"Gain value\".")))
42 return false;
43
44 m_gain->SetValue(value);
45 return true;
46}
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
Provide an output multiplying the input by a constant.
Definition Gain.h:37