19#include "../elements/controlElement/Sum.h"
21SumForm::SumForm(wxWindow* parent,
Sum* sum) : SumFormBase(parent)
23 SetSize(GetBestSize());
28 wxString signalStr =
"";
29 auto signalList = m_sum->GetSignalList();
30 for(
auto it = signalList.begin(), itEnd = signalList.end(); it != itEnd; ++it) {
31 Sum::Signal signal = *it;
33 case Sum::SIGNAL_POSITIVE: {
36 case Sum::SIGNAL_NEGATIVE: {
40 if(it != itEnd - 1) signalStr +=
" ";
42 m_textCtrlSigns->SetValue(signalStr);
46void SumForm::OnOKClick(wxCommandEvent& event)
48 if(ValidateData()) EndModal(wxID_OK);
51bool SumForm::ValidateData()
53 wxString signalStr =
"";
54 for(
int i = 0; i < (int)m_textCtrlSigns->GetValue().length(); ++i) {
55 if(m_textCtrlSigns->GetValue()[i] !=
' ') signalStr += m_textCtrlSigns->GetValue()[i];
57 if(signalStr.size() < 2) {
58 wxMessageDialog msg(
this, _(
"You must assign at least two signals."), _(
"Error"),
59 wxOK | wxCENTRE | wxICON_ERROR);
64 std::vector<Sum::Signal> signalList;
65 for(
int i = 0; i < (int)signalStr.length(); ++i) {
66 switch(signalStr[i].GetValue()) {
68 signalList.push_back(Sum::SIGNAL_POSITIVE);
71 signalList.push_back(Sum::SIGNAL_NEGATIVE);
74 wxMessageDialog msg(
this, _(
"Value entered incorrectly in the field \"Signs\"."), _(
"Error"),
75 wxOK | wxCENTRE | wxICON_ERROR);
82 int diff = (int)signalList.size() - (int)m_sum->GetSignalList().size();
85 diff = std::abs(diff);
86 for(
int i = 0; i < diff; ++i) {
87 m_sum->RemoveInNode();
90 for(
int i = 0; i < diff; ++i) {
94 m_sum->SetSignalList(signalList);
95 m_sum->UpdatePoints();
Sum the all inputs (can choose the input signal).