1 // Copyright (C) 2006-2014 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, or (at your option) any later version.
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"
23 #include "QtGuiContext.hxx"
26 #include "YacsTrace.hxx"
34 using namespace YACS::HMI;
36 EditionWhile::EditionWhile(Subject* subject,
39 : EditionNode(subject, parent, name)
41 _formWhile = new FormLoop(this);
43 _wid->gridLayout1->addWidget(_formWhile);
44 _formWhile->sb_nsteps->setMinimum(0);
45 _formWhile->sb_nsteps->setMaximum(1);
46 _formWhile->label->setText("Condition");
47 if (!QtGuiContext::getQtCurrent()->isEdition())
48 _formWhile->setEnabled (false);
49 connect(_formWhile->sb_nsteps, SIGNAL(editingFinished()),
50 this, SLOT(onConditionEdited()));
53 EditionWhile::~EditionWhile()
57 void EditionWhile::onConditionEdited()
59 int newval = _formWhile->sb_nsteps->value();
60 DEBTRACE("EditionWhile::onConditionEdited " << _condition << " --> " << newval);
61 if (newval != _condition)
63 SubjectWhileLoop *swl = dynamic_cast<SubjectWhileLoop*>(_subject);
65 QString text = _formWhile->sb_nsteps->cleanText();
66 swl->setCondition(text.toStdString());
70 void EditionWhile::synchronize()
72 _subject->update(SETVALUE, 0, _subject);
75 void EditionWhile::update(GuiEvent event, int type, Subject* son)
77 DEBTRACE("EditionWhile::update " << eventName(event) << " " << type);
78 EditionNode::update(event, type, son);
82 SubjectComposedNode * scn = dynamic_cast<SubjectComposedNode*>(_subject);
83 string val = scn->getValue();
84 if (val == "True") val = "1";
85 else if (val == "False") val = "0";
87 istringstream ss(val);
91 _formWhile->sb_nsteps->setValue(i);