]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
Actual Version : It is possible to define, to create and to save a complex box ....
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / GBlackBoxModel.cxx
index 4fc3e6840e725f4546f401060e64cb9419f4da6c..5351493e280e2ac0459b6aae2469b26acd683d3d 100644 (file)
@@ -38,26 +38,141 @@ Version:   $Revision$
 
 namespace bbtk
 {
-
-
        //=========================================================================
+
        GBlackBoxModel::GBlackBoxModel()
        {               
+               _isExecutable = false;
        }
 
        //=========================================================================
+
        GBlackBoxModel::~GBlackBoxModel()
        {
        }
+
+       //=========================================================================
+       
+       std::string GBlackBoxModel::getBBTKPackage()
+       {
+               return _bbtkPackage;
+       }
+
        //=========================================================================
 
-       void GBlackBoxModel::updateBlackBox(BlackBoxDescriptor::Pointer descriptor)//virtual
+       void GBlackBoxModel::setBBTKPackage(std::string obpackage)
        {
-               _desc=descriptor;
-               std::cout<<"RaC Box author:"<<_desc->GetAuthor()<<std::endl;
+               _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<_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);
+                       }
+               }
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF