GBoxModel.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002 Program:   bbtk
00003 Module:    $RCSfile: GBoxModel.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2012/05/30 17:18:00 $
00006 Version:   $Revision: 1.4 $
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 
00037 #include "GBoxModel.h"
00038 
00039 namespace bbtk
00040 {
00041         //=========================================================================
00042 
00043         GBoxModel::GBoxModel()
00044         {               
00045         }
00046 
00047         //=========================================================================
00048 
00049         GBoxModel::~GBoxModel()
00050         {
00051         }
00052 
00053         //=========================================================================
00054 
00055         void GBoxModel::setInicPoint(double& x, double& y, double& z)
00056         {
00057                 GObjectModel::setInicPoint(x,y,z);
00058 
00059                 double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
00060                 setFinalPoint(xFin,yFin,z);
00061         }
00062 
00063         //=========================================================================
00064 
00065         void GBoxModel::addInputPort(GPortModel *inputport)
00066         {
00067                 _inputs.push_back(inputport);
00068         }
00069 
00070         //=========================================================================
00071 
00072         void GBoxModel::addOutputPort(GPortModel *outputport)
00073         {
00074                 _outputs.push_back(outputport);
00075         }
00076 
00077         //=========================================================================
00078 
00079         int GBoxModel::getNumInputPorts()
00080         {
00081                 return _inputs.size();
00082         }
00083 
00084         //=========================================================================
00085 
00086         int GBoxModel::getNumOutputPorts()
00087         {
00088                 return _outputs.size();
00089         }
00090 
00091         //=========================================================================
00092 
00093         void GBoxModel::move(double xx,double yy,double zz)
00094         {
00095                 setInicPoint(xx,yy,zz);
00096 
00097                 //Refresh inputs position
00098                 int i;
00099                 for(i=0;i<(int)_inputs.size();i++)
00100                 {
00101                         _inputs[i]->updatePortPosition();
00102                 }
00103                 
00104                 //Refresh outputs position
00105                 for(i=0;i<(int)_outputs.size();i++)
00106                 {
00107                         _outputs[i]->updatePortPosition();
00108                 }
00109 
00110         }
00111         
00112         //=========================================================================
00113         
00114         std::string GBoxModel::getStatusText()
00115         {
00116                 std::string temp = "";
00117                 
00118                 return temp;
00119         }
00120 
00121         //=========================================================================
00122 
00123         std::vector<GPortModel*> GBoxModel::getInputPorts()
00124         {
00125                 return _inputs;
00126         }
00127 
00128         //=========================================================================
00129 
00130         std::vector<GPortModel*> GBoxModel::getOutputPorts()
00131         {
00132                 return _outputs;
00133         }
00134 
00135         //=========================================================================     
00136 
00137         void GBoxModel::save(std::string &content)
00138         {
00139                 content+="\n";
00140         }
00141         
00142 
00143         //=========================================================================
00144 
00145         GPortModel* GBoxModel::getInputPort(std::string name)
00146         {
00147                 for(int i = 0; i<(int)_inputs.size();i++)
00148                 {
00149                         if(_inputs[i]->getBBTKName()==name)
00150                         {
00151                                 return _inputs[i];
00152                         }
00153                 }
00154                 return NULL;
00155         }
00156 
00157         //=========================================================================
00158         
00159         GPortModel* GBoxModel::getOutputPort(std::string name)
00160         {
00161                 for(int i = 0; i<(int)_outputs.size();i++)
00162                 {
00163                         if(_outputs[i]->getBBTKName()==name)
00164                         {
00165                                 return _outputs[i];
00166                         }
00167                 }
00168                 return NULL;
00169         }
00170 
00171         //=========================================================================
00172 
00173         GPortModel* GBoxModel::getInputPort(int pos)
00174         {
00175                 return _inputs[pos];
00176         }
00177 
00178         //=========================================================================
00179         
00180         GPortModel* GBoxModel::getOutputPort(int pos)
00181         {
00182                 return _outputs[pos];
00183         }
00184 
00185         //=========================================================================
00186 
00187         void GBoxModel::updatePorts()
00188         {
00189                 for(int i = 0; i<(int)_inputs.size();i++)
00190                 {       
00191                         _inputs[i]->updatePortPosition();
00192                         _inputs[i]->notifyObservers(_objectId);
00193                 }
00194 
00195                 for(int i = 0; i<_outputs.size();i++)
00196                 {
00197                         _outputs[i]->updatePortPosition();
00198                         _outputs[i]->notifyObservers(_objectId);
00199                 }
00200         }
00201 
00202         void GBoxModel::addColons(std::string &text)
00203         {
00204                 std::string character("&&2P&&");                                
00205                 size_t pos;
00206                 pos = text.find(character);
00207                 while(pos != std::string::npos)
00208                 {
00209                 //We replace the character "&&2P&&" with ":" for all the string
00210                         text.replace(pos, character.length(),":");
00211                         pos = text.find(character, pos);
00212                 }
00213         }
00214 
00215         void GBoxModel::removeColons(std::string &text)
00216         {
00217                 std::string character(":");                             
00218                 size_t pos;
00219                 pos = text.find(character);
00220                 while(pos != std::string::npos)
00221                 {
00222                         //We replace the character ":" with "&&2P&&" for all the string
00223                         text.replace(pos, character.length(),"&&2P&&");
00224                         pos = text.find(character, pos);
00225                         }
00226         }
00227 
00228         //=========================================================================
00229 
00230 
00231 }  // EO namespace bbtk
00232 
00233 // EOF
00234 

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