GBlackBoxModel.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002 Program:   bbtk
00003 Module:    $RCSfile: GBlackBoxModel.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2010/09/10 11:33:08 $
00006 Version:   $Revision: 1.21 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00031 
00032 
00033 /****
00034 * Design and Developpement of BBTK GEditor
00035 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
00036 * RaC - 2010
00037 ****/
00038 
00039 #include "GBlackBoxModel.h"
00040 
00041 namespace bbtk
00042 {
00043         //=========================================================================
00044 
00045         GBlackBoxModel::GBlackBoxModel()
00046         {               
00047                 _isExecutable = false;
00048         }
00049 
00050         //=========================================================================
00051 
00052         GBlackBoxModel::~GBlackBoxModel()
00053         {
00054         }
00055 
00056         //=========================================================================
00057         
00058         std::string GBlackBoxModel::getBBTKPackage()
00059         {
00060                 return _bbtkPackage;
00061         }
00062 
00063         //=========================================================================
00064 
00065         void GBlackBoxModel::setBBTKPackage(std::string obpackage)
00066         {
00067                 _bbtkPackage = obpackage;
00068         }
00069 
00070         //=========================================================================
00071         
00072         bool GBlackBoxModel::isExecutable()
00073         {
00074                 return _isExecutable;
00075         }
00076 
00077         //=========================================================================
00078 
00079         void GBlackBoxModel::setExecutable(bool executable)
00080         {
00081                 _isExecutable = executable;
00082         }
00083 
00084         //=========================================================================
00085         
00086         std::string GBlackBoxModel::getStatusText()
00087         {
00088                 std::string temp = "";
00089                 temp+=_bbtkPackage;
00090                 temp+=":";
00091                 temp+=_bbtkType;
00092                 temp+=":";
00093                 temp+=_bbtkName;
00094                 
00095                 return temp;
00096         }
00097 
00098         //=========================================================================
00099 
00100         void GBlackBoxModel::setValueToInputPort(int pos,std::string value)
00101         {
00102                 _inputs[pos]->setValue(value);
00103         }
00104 
00105         //=========================================================================     
00106 
00107         void GBlackBoxModel::save(std::string &content)
00108         {
00109                 content+="BOX\n";
00110                 // Box info
00111                 content+=_bbtkPackage;
00112                 content+=":";
00113                 content+=_bbtkType;
00114                 content+=":";
00115                 content+=_bbtkName;
00116                 content+="\n";
00117                 content+="ISEXEC:";
00118                 if(_isExecutable)
00119                 {
00120                         content+="TRUE";
00121                 }
00122                 else
00123                 {
00124                         content+="FALSE";
00125                 }
00126                 content+="\n";
00127 
00128 
00129                 //Box Position
00130                 char buffer [50];
00131                 sprintf (buffer, "%f", _xInic);
00132                 content+=buffer;
00133                 content+=":";
00134                 sprintf (buffer, "%f", _yInic);
00135                 content+=buffer;
00136                 content+=":";
00137                 sprintf (buffer, "%f", _zInic);
00138                 content+=buffer;
00139                 content+="\n";
00140 
00141                 sprintf (buffer, "%f", _xFin);
00142                 content+=buffer;
00143                 content+=":";
00144                 sprintf (buffer, "%f", _yFin);
00145                 content+=buffer;
00146                 content+=":";
00147                 sprintf (buffer, "%f", _zFin);
00148                 content+=buffer;
00149                 content+="\n";
00150 
00151                 //Ports with a value
00152                 for(int i = 0; i<(int)_inputs.size();i++)
00153                 {
00154                         if(_inputs[i]->isValueSet())
00155                         {
00156                                 _inputs[i]->save(content);
00157                         }
00158                 }
00159                 content+="FIN_BOX\n";
00160 
00161         }
00162         
00163         //=========================================================================
00164 
00165         void GBlackBoxModel::setValueToInput(std::string name,std::string value)
00166         {
00167                 for(int i = 0; i<(int)_inputs.size();i++)
00168                 {
00169                         if(_inputs[i]->getBBTKName()==name)
00170                         {
00171                                 _inputs[i]->setValue(value);
00172                         }
00173                 }
00174         }
00175 
00176         //=========================================================================
00177 
00178         std::string GBlackBoxModel::getValueInputPort(int pos)
00179         {
00180                 return _inputs[pos]->getValue();
00181         }
00182 
00183         //=========================================================================
00184 
00185         std::string GBlackBoxModel::getValueInput(std::string name)
00186         {
00187                 for(int i = 0; i<(int)_inputs.size();i++)
00188                 {
00189                         if(_inputs[i]->getBBTKName()==name)
00190                         {
00191                                 return _inputs[i]->getValue();
00192                         }
00193                 }
00194                 return NULL;
00195         }
00196 
00197         //=========================================================================
00198 
00199         std::vector<int> GBlackBoxModel::getConnectedInputs()
00200         {
00201                 std::vector<int> connected;
00202                 for(int i = 0; i<(int)_inputs.size();i++)
00203                 {
00204                         if(_inputs[i]->isConnected())
00205                         {
00206                                 connected.push_back(i);
00207                         }
00208                 }
00209                 return connected;
00210         }
00211 
00212         //=========================================================================
00213 
00214         std::vector<int> GBlackBoxModel::getConnectedOutputs()
00215         {
00216                 std::vector<int> connected;
00217                 for(int i = 0; i<(int)_outputs.size();i++)
00218                 {
00219                         if(_outputs[i]->isConnected())
00220                         {
00221                                 connected.push_back(i);
00222                         }
00223                 }
00224                 return connected;
00225         }
00226 
00227         //=========================================================================
00228 }   // EO namespace bbtk
00229 
00230 // EOF
00231 

Generated on Thu May 31 15:12:19 2012 for bbtkGEditor by  doxygen 1.5.7.1