]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
v1.1.0
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / GBlackBoxModel.cxx
index 47259aaa576c7a9fc0106dfdeb56cca54628a07f..7eb35180731366b3fb4463de71192b919f300561 100644 (file)
@@ -28,12 +28,14 @@ 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
@@ -51,65 +53,6 @@ namespace bbtk
        {
        }
 
-       //=========================================================================
-
-       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()
-       {
-               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()
@@ -154,20 +97,6 @@ namespace bbtk
 
        //=========================================================================
 
-       std::vector<GPortModel*> GBlackBoxModel::getInputPorts()
-       {
-               return _inputs;
-       }
-
-       //=========================================================================
-
-       std::vector<GPortModel*> GBlackBoxModel::getOutputPorts()
-       {
-               return _outputs;
-       }
-
-       //=========================================================================
-
        void GBlackBoxModel::setValueToInputPort(int pos,std::string value)
        {
                _inputs[pos]->setValue(value);
@@ -220,7 +149,7 @@ namespace bbtk
                content+="\n";
 
                //Ports with a value
-               for(int i = 0; i<_inputs.size();i++)
+               for(int i = 0; i<(int)_inputs.size();i++)
                {
                        if(_inputs[i]->isValueSet())
                        {
@@ -235,7 +164,7 @@ namespace bbtk
 
        void GBlackBoxModel::setValueToInput(std::string name,std::string value)
        {
-               for(int i = 0; i<_inputs.size();i++)
+               for(int i = 0; i<(int)_inputs.size();i++)
                {
                        if(_inputs[i]->getBBTKName()==name)
                        {
@@ -246,53 +175,58 @@ namespace bbtk
 
        //=========================================================================
 
-       GPortModel* GBlackBoxModel::getInputPort(std::string name)
+       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<_inputs.size();i++)
+               for(int i = 0; i<(int)_inputs.size();i++)
                {
                        if(_inputs[i]->getBBTKName()==name)
                        {
-                               return _inputs[i];
+                               return _inputs[i]->getValue();
                        }
                }
                return NULL;
        }
 
        //=========================================================================
-       
-       GPortModel* GBlackBoxModel::getOutputPort(std::string name)
+
+       std::vector<int> GBlackBoxModel::getConnectedInputs()
        {
-               for(int i = 0; i<_outputs.size();i++)
+               std::vector<int> connected;
+               for(int i = 0; i<(int)_inputs.size();i++)
                {
-                       if(_outputs[i]->getBBTKName()==name)
+                       if(_inputs[i]->isConnected())
                        {
-                               return _outputs[i];
+                               connected.push_back(i);
                        }
                }
-               return NULL;
+               return connected;
        }
 
        //=========================================================================
 
-       void GBlackBoxModel::updatePorts()
+       std::vector<int> GBlackBoxModel::getConnectedOutputs()
        {
-               for(int i = 0; i<_inputs.size();i++)
-               {       
-                       _inputs[i]->updatePortPosition();
-                       _inputs[i]->notifyObservers(_objectId);
-               }
-
-               for(int i = 0; i<_outputs.size();i++)
+               std::vector<int> connected;
+               for(int i = 0; i<(int)_outputs.size();i++)
                {
-                       _outputs[i]->updatePortPosition();
-                       _outputs[i]->notifyObservers(_objectId);
+                       if(_outputs[i]->isConnected())
+                       {
+                               connected.push_back(i);
+                       }
                }
+               return connected;
        }
 
        //=========================================================================
-
-
-}  // EO namespace bbtk
+}   // EO namespace bbtk
 
 // EOF