]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
The app saves and opens diagrams !!!! Allll fiiiinnn se logro !!
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / GBlackBoxModel.cxx
index 672a4bd622018a3ddf9df4a733fe3034b08ae1e4..f7fe2e1a9e3fa9fbcd2be3ff94febd34fcc1307c 100644 (file)
@@ -38,17 +38,19 @@ Version:   $Revision$
 
 namespace bbtk
 {
-
-
        //=========================================================================
+
        GBlackBoxModel::GBlackBoxModel()
        {               
+               _isExecutable = false;
        }
 
        //=========================================================================
+
        GBlackBoxModel::~GBlackBoxModel()
        {
        }
+
        //=========================================================================
 
        void GBlackBoxModel::setInicPoint(double& x, double& y, double& z)
@@ -109,7 +111,6 @@ namespace bbtk
        }
        
        //=========================================================================
-
        
        std::string GBlackBoxModel::getBBTKPackage()
        {
@@ -123,8 +124,161 @@ namespace bbtk
                _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;
+       }
+
+       //=========================================================================
+
+       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);
+       }
+
+       //=========================================================================     
+
+       void GBlackBoxModel::save(std::string &content)
+       {
+               content+="BOX\n";
+               // Box info
+               content+=_bbtkPackage;
+               content+=":";
+               content+=_bbtkType;
+               content+=":";
+               content+=_bbtkName;
+               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<_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<_inputs.size();i++)
+               {
+                       if(_inputs[i]->getBBTKName()==name)
+                       {
+                               _inputs[i]->setValue(value);
+                       }
+               }
+       }
+
+       //=========================================================================
+
+       GPortModel* GBlackBoxModel::getInputPort(std::string name)
+       {
+               for(int i = 0; i<_inputs.size();i++)
+               {
+                       if(_inputs[i]->getBBTKName()==name)
+                       {
+                               return _inputs[i];
+                       }
+               }
+               return NULL;
+       }
+
+       //=========================================================================
+       
+       GPortModel* GBlackBoxModel::getOutputPort(std::string name)
+       {
+               for(int i = 0; i<_outputs.size();i++)
+               {
+                       if(_outputs[i]->getBBTKName()==name)
+                       {
+                               return _outputs[i];
+                       }
+               }
+               return NULL;
+       }
+
+       //=========================================================================
+
+       void GBlackBoxModel::updatePorts()
+       {
+               for(int i = 0; i<_inputs.size();i++)
+               {       
+                       _inputs[i]->updatePortPosition();
+                       _inputs[i]->notifyObservers(_objectId);
+               }
+
+               for(int i = 0; i<_outputs.size();i++)
+               {
+                       _outputs[i]->updatePortPosition();
+                       _outputs[i]->notifyObservers(_objectId);
+               }
+       }
+
+       //=========================================================================
 
 
 }  // EO namespace bbtk