1 // Copyright (C) 2006-2008 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
19 #include "EditionWhile.hxx"
20 #include "FormLoop.hxx"
21 #include "guiObservers.hxx"
24 #include "YacsTrace.hxx"
32 using namespace YACS::HMI;
34 EditionWhile::EditionWhile(Subject* subject,
37 : EditionNode(subject, parent, name)
39 _formWhile = new FormLoop(this);
40 _wid->gridLayout1->addWidget(_formWhile);
41 _formWhile->sb_nsteps->setMinimum(0);
42 _formWhile->sb_nsteps->setMaximum(1);
43 _formWhile->label->setText("Condition");
44 connect(_formWhile->sb_nsteps, SIGNAL(valueChanged(const QString &)),
45 this, SLOT(onModifyCondition(const QString &)));
48 EditionWhile::~EditionWhile()
52 void EditionWhile::onModifyCondition(const QString &text)
54 DEBTRACE("EditionWhile::onModifyCondition " << text.toStdString());
55 SubjectWhileLoop *swl = dynamic_cast<SubjectWhileLoop*>(_subject);
57 swl->setCondition(text.toStdString());
60 void EditionWhile::synchronize()
62 _subject->update(SETVALUE, 0, _subject);
65 void EditionWhile::update(GuiEvent event, int type, Subject* son)
67 DEBTRACE("EditionWhile::update " << eventName(event) << " " << type);
68 EditionNode::update(event, type, son);
72 SubjectComposedNode * scn = dynamic_cast<SubjectComposedNode*>(_subject);
73 string val = scn->getValue();
74 if (val == "True") val = "1";
75 else if (val == "False") val = "0";
77 istringstream ss(val);
81 _formWhile->sb_nsteps->setValue(i);