X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FGBlackBoxModel.cxx;h=7eb35180731366b3fb4463de71192b919f300561;hb=de7c0454ab8fc1b0b97dcd7112dfdb4a55ac0215;hp=2a2081f463a1bec9826708452acaf87bfa475fc0;hpb=311af31f393ba7d5788a0a843ee412eebdf43a82;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx index 2a2081f..7eb3518 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx @@ -28,68 +28,205 @@ 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() { } + + //========================================================================= + + std::string GBlackBoxModel::getBBTKPackage() + { + return _bbtkPackage; + } + //========================================================================= - void GBlackBoxModel::setInicPoint(double& x, double& y, double& z) + void GBlackBoxModel::setBBTKPackage(std::string obpackage) { - GObjectModel::setInicPoint(x,y,z); + _bbtkPackage = obpackage; + } - double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT; - setFinalPoint(xFin,yFin,z); + //========================================================================= + + bool GBlackBoxModel::isExecutable() + { + return _isExecutable; } //========================================================================= - void GBlackBoxModel::addInputPort(GPortModel *inputport) + void GBlackBoxModel::setExecutable(bool executable) { - _inputs.push_back(inputport); + _isExecutable = executable; + } + + //========================================================================= + + std::string GBlackBoxModel::getStatusText() + { + std::string temp = ""; + temp+=_bbtkPackage; + temp+=":"; + temp+=_bbtkType; + temp+=":"; + temp+=_bbtkName; + + return temp; } //========================================================================= - void GBlackBoxModel::addOutputPort(GPortModel *outputport) + void GBlackBoxModel::setValueToInputPort(int pos,std::string value) { - _outputs.push_back(outputport); + _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"; + + } + //========================================================================= - int GBlackBoxModel::getNumInputPorts() + void GBlackBoxModel::setValueToInput(std::string name,std::string value) { - return _inputs.size(); + for(int i = 0; i<(int)_inputs.size();i++) + { + if(_inputs[i]->getBBTKName()==name) + { + _inputs[i]->setValue(value); + } + } } //========================================================================= - int GBlackBoxModel::getNumOutputPorts() + std::string GBlackBoxModel::getValueInputPort(int pos) { - return _outputs.size(); + std::string text = _inputs[pos]->getValue(); + return text; } //========================================================================= -} // EO namespace bbtk + 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 // EOF