]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
v1.1.0
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / GBlackBoxModel.cxx
index 4fc3e6840e725f4546f401060e64cb9419f4da6c..7eb35180731366b3fb4463de71192b919f300561 100644 (file)
@@ -28,37 +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 <ra.corredor67@uniandes.edu.co>
+* RaC - 2010
+****/
+
 #include "GBlackBoxModel.h"
 
 namespace bbtk
 {
-
-
        //=========================================================================
+
        GBlackBoxModel::GBlackBoxModel()
        {               
+               _isExecutable = false;
        }
 
        //=========================================================================
+
        GBlackBoxModel::~GBlackBoxModel()
        {
        }
+
+       //=========================================================================
+       
+       std::string GBlackBoxModel::getBBTKPackage()
+       {
+               return _bbtkPackage;
+       }
+
+       //=========================================================================
+
+       void GBlackBoxModel::setBBTKPackage(std::string obpackage)
+       {
+               _bbtkPackage = obpackage;
+       }
+
+       //=========================================================================
+       
+       bool GBlackBoxModel::isExecutable()
+       {
+               return _isExecutable;
+       }
+
+       //=========================================================================
+
+       void GBlackBoxModel::setExecutable(bool executable)
+       {
+               _isExecutable = executable;
+       }
+
+       //=========================================================================
+       
+       std::string GBlackBoxModel::getStatusText()
+       {
+               std::string temp = "";
+               temp+=_bbtkPackage;
+               temp+=":";
+               temp+=_bbtkType;
+               temp+=":";
+               temp+=_bbtkName;
+               
+               return temp;
+       }
+
+       //=========================================================================
+
+       void GBlackBoxModel::setValueToInputPort(int pos,std::string value)
+       {
+               _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";
+
+       }
+       
+       //=========================================================================
+
+       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;
+       }
+
+       //=========================================================================
+
+       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;
+       }
+
        //=========================================================================
 
-       void GBlackBoxModel::updateBlackBox(BlackBoxDescriptor::Pointer descriptor)//virtual
+       std::vector<int> GBlackBoxModel::getConnectedOutputs()
        {
-               _desc=descriptor;
-               std::cout<<"RaC Box author:"<<_desc->GetAuthor()<<std::endl;
+               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
+}   // EO namespace bbtk
 
 // EOF