1 // Copyright (C) 2016-2020 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
19 // Author : Anthony Geay (EDF R&D)
21 #include "YDFXGUIWrap.hxx"
23 #include "YACSEvalYFX.hxx"
24 #include "YACSEvalPort.hxx"
25 #include "YACSEvalSeqAny.hxx"
29 std::vector< YACSEvalInputPort * > YACSEvalYFXWrap::getFreeInputPorts() const
31 return _efx->getFreeInputPorts();
34 std::vector< YACSEvalOutputPort * > YACSEvalYFXWrap::getFreeOutputPorts() const
36 return _efx->getFreeOutputPorts();
39 YACSEvalExecParams *YACSEvalYFXWrap::getParams() const
41 return _efx->getParams();
44 bool YACSEvalYFXWrap::isLocked() const
46 return _efx->isLocked();
49 YACSEvalListOfResources *YACSEvalYFXWrap::giveResources()
51 return _efx->giveResources();
54 class AutoRunningDeclarator
57 AutoRunningDeclarator(YACSEvalYFXWrap *wrap):_wrap(wrap) { _wrap->setRunningStatus(true); }
58 ~AutoRunningDeclarator() { _wrap->setRunningStatus(false); }
60 YACSEvalYFXWrap *_wrap;
63 bool YACSEvalYFXWrap::run(YACSEvalSession *session, int& nbOfBranches)
65 AutoRunningDeclarator ard(this);
66 return _efx->run(session,nbOfBranches);
69 void YACSEvalYFXWrap::registerObserver(YACSEvalObserver *observer)
71 _efx->registerObserver(observer);
74 void YACSEvalYFXWrap::unlockAll()
77 Q_EMIT lockSignal(false);
80 void YACSEvalYFXWrap::lockPortsForEvaluation()
82 bool lockedOrNot(isLocked());
83 std::vector< YACSEvalInputPort * > inps(getFreeInputPorts()),inps2;
84 foreach(YACSEvalInputPort *inp,inps)
86 if(inp->isRandomVar())
89 std::vector< YACSEvalOutputPort * > outps(getFreeOutputPorts()),outps2;
90 foreach(YACSEvalOutputPort *outp,outps)
92 if(outp->isQOfInterest())
93 outps2.push_back(outp);
97 _efx->lockPortsForEvaluation(inps2,outps2);
98 _efx->giveResources();//do not remove this line to generate resource info
100 Q_EMIT lockSignal(true);
103 int YACSEvalYFXWrap::getNbOfItems() const
105 std::vector< YACSEvalInputPort * > inps(getFreeInputPorts());
106 int nbOfRandom(0),refSz(std::numeric_limits<int>::max());
107 foreach(YACSEvalInputPort *inp,inps)
109 if(!inp->isRandomVar())
111 YACSEvalSeqAny *seq(inp->getSequenceOfValuesToEval());
116 if(refSz!=seq->size())
125 void lockPortsForEvaluation(const std::vector< YACSEvalInputPort * >& inputsOfInterest, const std::vector< YACSEvalOutputPort * >& outputsOfInterest);
127 YACSEvalYFXWrap::~YACSEvalYFXWrap()
132 void YACSEvalYFXWrap::setRunningStatus(bool status)
134 if(_isRunning!=status)
135 Q_EMIT runSignal(status);
139 void YACSEvalYFXWrap::updateSequencesStatus()
142 bool newStatus(computeSequencesStatus(nbOfVals));
143 if(_isSeqOfValsSet!=newStatus)
145 _isSeqOfValsSet=newStatus;
146 Q_EMIT sequencesAreSetSignal(_isSeqOfValsSet);
150 bool YACSEvalYFXWrap::computeSequencesStatus(int& nbOfVals)
152 std::vector< YACSEvalInputPort * > inputs(_efx->getFreeInputPorts());
153 std::size_t sz(0),nbOfRandomVars(0);
154 foreach(YACSEvalInputPort *input,inputs)
156 if(!input->isRandomVar())
159 if(!input->hasSequenceOfValuesToEval())
161 YACSEvalSeqAny *seq(input->getSequenceOfValuesToEval());
164 if(nbOfRandomVars==0 || sz==0)
166 foreach(YACSEvalInputPort *input,inputs)
168 if(!input->isRandomVar())
170 if(sz!=input->getSequenceOfValuesToEval()->size())