* 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 <ra.corredor67@uniandes.edu.co>
+* RaC - 2010
+****/
+
#include "GBlackBoxModel.h"
namespace bbtk
{
-
-
//=========================================================================
+
GBlackBoxModel::GBlackBoxModel()
{
+ _isExecutable = false;
}
//=========================================================================
+
GBlackBoxModel::~GBlackBoxModel()
{
}
- //=========================================================================
- void GBlackBoxModel::setInicPoint(double& x, double& y, double& z)
+ //=========================================================================
+
+ std::string GBlackBoxModel::getBBTKPackage()
{
- GObjectModel::setInicPoint(x,y,z);
-
- double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
- setFinalPoint(xFin,yFin,z);
+ return _bbtkPackage;
}
//=========================================================================
- void GBlackBoxModel::addInputPort(GPortModel *inputport)
+ void GBlackBoxModel::setBBTKPackage(std::string obpackage)
{
- _inputs.push_back(inputport);
+ _bbtkPackage = obpackage;
}
//=========================================================================
-
- void GBlackBoxModel::addOutputPort(GPortModel *outputport)
+
+ bool GBlackBoxModel::isExecutable()
{
- _outputs.push_back(outputport);
+ return _isExecutable;
}
//=========================================================================
- int GBlackBoxModel::getNumInputPorts()
+ void GBlackBoxModel::setExecutable(bool executable)
{
- return _inputs.size();
+ _isExecutable = executable;
}
//=========================================================================
-
- int GBlackBoxModel::getNumOutputPorts()
+
+ std::string GBlackBoxModel::getStatusText()
{
- return _outputs.size();
+ std::string temp = "";
+ temp+=_bbtkPackage;
+ temp+=":";
+ temp+=_bbtkType;
+ temp+=":";
+ temp+=_bbtkName;
+
+ return temp;
}
//=========================================================================
- void GBlackBoxModel::move(double xx,double yy,double zz)
+ void GBlackBoxModel::setValueToInputPort(int pos,std::string value)
{
- setInicPoint(xx,yy,zz);
+ _inputs[pos]->setValue(value);
+ }
+
+ //=========================================================================
- //Refresh inputs position
- int i;
- for(i=0;i<_inputs.size();i++)
+ 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)
{
- _inputs[i]->updatePortPosition();
+ content+="TRUE";
}
-
- //Refresh outputs position
- for(i=0;i<_outputs.size();i++)
+ 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++)
{
- _outputs[i]->updatePortPosition();
+ if(_inputs[i]->isValueSet())
+ {
+ _inputs[i]->save(content);
+ }
}
+ content+="FIN_BOX\n";
}
//=========================================================================
+ void GBlackBoxModel::setValueToInput(std::string name,std::string value)
+ {
+ for(int i = 0; i<(int)_inputs.size();i++)
+ {
+ if(_inputs[i]->getBBTKName()==name)
+ {
+ _inputs[i]->setValue(value);
+ }
+ }
+ }
+
+ //=========================================================================
+
+ std::string GBlackBoxModel::getValueInputPort(int pos)
+ {
+ 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<int> GBlackBoxModel::getConnectedInputs()
+ {
+ std::vector<int> connected;
+ for(int i = 0; i<(int)_inputs.size();i++)
+ {
+ if(_inputs[i]->isConnected())
+ {
+ connected.push_back(i);
+ }
+ }
+ return connected;
+ }
+
+ //=========================================================================
+
+ std::vector<int> GBlackBoxModel::getConnectedOutputs()
+ {
+ std::vector<int> connected;
+ for(int i = 0; i<(int)_outputs.size();i++)
+ {
+ if(_outputs[i]->isConnected())
+ {
+ connected.push_back(i);
+ }
+ }
+ return connected;
+ }
+
+ //=========================================================================
+} // EO namespace bbtk
// EOF