1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "EditionWhile.hxx"
21 #include "FormLoop.hxx"
22 #include "guiObservers.hxx"
25 #include "YacsTrace.hxx"
33 using namespace YACS::HMI;
35 EditionWhile::EditionWhile(Subject* subject,
38 : EditionNode(subject, parent, name)
40 _formWhile = new FormLoop(this);
42 _wid->gridLayout1->addWidget(_formWhile);
43 _formWhile->sb_nsteps->setMinimum(0);
44 _formWhile->sb_nsteps->setMaximum(1);
45 _formWhile->label->setText("Condition");
46 connect(_formWhile->sb_nsteps, SIGNAL(editingFinished()),
47 this, SLOT(onConditionEdited()));
50 EditionWhile::~EditionWhile()
54 void EditionWhile::onConditionEdited()
56 int newval = _formWhile->sb_nsteps->value();
57 DEBTRACE("EditionWhile::onConditionEdited " << _condition << " --> " << newval);
58 if (newval != _condition)
60 SubjectWhileLoop *swl = dynamic_cast<SubjectWhileLoop*>(_subject);
62 QString text = _formWhile->sb_nsteps->cleanText();
63 swl->setCondition(text.toStdString());
67 void EditionWhile::synchronize()
69 _subject->update(SETVALUE, 0, _subject);
72 void EditionWhile::update(GuiEvent event, int type, Subject* son)
74 DEBTRACE("EditionWhile::update " << eventName(event) << " " << type);
75 EditionNode::update(event, type, son);
79 SubjectComposedNode * scn = dynamic_cast<SubjectComposedNode*>(_subject);
80 string val = scn->getValue();
81 if (val == "True") val = "1";
82 else if (val == "False") val = "0";
84 istringstream ss(val);
88 _formWhile->sb_nsteps->setValue(i);