X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FGBlackBoxModel.cxx;h=a806ea8d347e44aea9fa3c9a7ce371f6ffc53eaa;hb=61a38c679e47c9f102d2834c835c3c6eac487a9b;hp=c7778f3667705f21563641cc50a613daae6e6aeb;hpb=c2ceb1ba52ffe871ccb9f835a0330e12484d2f0e;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx index c7778f3..a806ea8 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx @@ -28,87 +28,31 @@ Version: $Revision$ * knowledge of the CeCILL-B license and that you accept its terms. * ------------------------------------------------------------------------ */ -/** -* \file -* \brief Class bbtk::GBlackBox -*/ +/**** +* Design and Developpement of BBTK GEditor +* Ricardo A Corredor J +* RaC - 2010 +****/ + #include "GBlackBoxModel.h" namespace bbtk { - - //========================================================================= + GBlackBoxModel::GBlackBoxModel() { _isExecutable = false; } - //========================================================================= - GBlackBoxModel::~GBlackBoxModel() - { - } //========================================================================= - void GBlackBoxModel::setInicPoint(double& x, double& y, double& z) - { - GObjectModel::setInicPoint(x,y,z); - - double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT; - setFinalPoint(xFin,yFin,z); - } - - //========================================================================= - - void GBlackBoxModel::addInputPort(GPortModel *inputport) - { - _inputs.push_back(inputport); - } - - //========================================================================= - - void GBlackBoxModel::addOutputPort(GPortModel *outputport) - { - _outputs.push_back(outputport); - } - - //========================================================================= - - int GBlackBoxModel::getNumInputPorts() - { - return _inputs.size(); - } - - //========================================================================= - - int GBlackBoxModel::getNumOutputPorts() + GBlackBoxModel::~GBlackBoxModel() { - return _outputs.size(); } - //========================================================================= - - void GBlackBoxModel::move(double xx,double yy,double zz) - { - setInicPoint(xx,yy,zz); - - //Refresh inputs position - int i; - for(i=0;i<_inputs.size();i++) - { - _inputs[i]->updatePortPosition(); - } - - //Refresh outputs position - for(i=0;i<_outputs.size();i++) - { - _outputs[i]->updatePortPosition(); - } - - } - //========================================================================= std::string GBlackBoxModel::getBBTKPackage() @@ -153,29 +97,135 @@ namespace bbtk //========================================================================= - std::vector GBlackBoxModel::getInputPorts() + void GBlackBoxModel::setValueToInputPort(int pos,std::string value) { - return _inputs; + _inputs[pos]->setValue(value); } + //========================================================================= + + void GBlackBoxModel::save(std::string &content) + { + content+="BOX\n"; + // Box info + content+=_bbtkPackage; + content+=":"; + content+=_bbtkType; + content+=":"; + content+=_bbtkName; + content+="\n"; + content+="ISEXEC:"; + if(_isExecutable) + { + content+="TRUE"; + } + else + { + content+="FALSE"; + } + content+="\n"; + + + //Box Position + char buffer [50]; + sprintf (buffer, "%f", _xInic); + content+=buffer; + content+=":"; + sprintf (buffer, "%f", _yInic); + content+=buffer; + content+=":"; + sprintf (buffer, "%f", _zInic); + content+=buffer; + content+="\n"; + + sprintf (buffer, "%f", _xFin); + content+=buffer; + content+=":"; + sprintf (buffer, "%f", _yFin); + content+=buffer; + content+=":"; + sprintf (buffer, "%f", _zFin); + content+=buffer; + content+="\n"; + + //Ports with a value + for(int i = 0; i<(int)_inputs.size();i++) + { + if(_inputs[i]->isValueSet()) + { + _inputs[i]->save(content); + } + } + content+="FIN_BOX\n"; + + } + //========================================================================= - std::vector GBlackBoxModel::getOutputPorts() + void GBlackBoxModel::setValueToInput(std::string name,std::string value) { - return _outputs; + for(int i = 0; i<(int)_inputs.size();i++) + { + if(_inputs[i]->getBBTKName()==name) + { + _inputs[i]->setValue(value); + } + } } //========================================================================= - void GBlackBoxModel::setValueToInputPort(int pos,std::string value) + std::string GBlackBoxModel::getValueInputPort(int pos) { - _inputs[pos]->setValue(value); + return _inputs[pos]->getValue(); } - //========================================================================= + //========================================================================= + + std::string GBlackBoxModel::getValueInput(std::string name) + { + for(int i = 0; i<(int)_inputs.size();i++) + { + if(_inputs[i]->getBBTKName()==name) + { + return _inputs[i]->getValue(); + } + } + return NULL; + } + + //========================================================================= + + std::vector GBlackBoxModel::getConnectedInputs() + { + std::vector connected; + for(int i = 0; i<(int)_inputs.size();i++) + { + if(_inputs[i]->isConnected()) + { + connected.push_back(i); + } + } + return connected; + } + + //========================================================================= + std::vector GBlackBoxModel::getConnectedOutputs() + { + std::vector connected; + for(int i = 0; i<(int)_outputs.size();i++) + { + if(_outputs[i]->isConnected()) + { + connected.push_back(i); + } + } + return connected; + } -} // EO namespace bbtk + //========================================================================= +} // EO namespace bbtk // EOF