2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
26 /*=========================================================================
32 =========================================================================*/
34 /* ---------------------------------------------------------------------
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39 * This software is governed by the CeCILL-B license under French law and
40 * abiding by the rules of distribution of free software. You can use,
41 * modify and/ or redistribute the software under the terms of the CeCILL-B
42 * license as circulated by CEA, CNRS and INRIA at the following URL
43 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 * or in the file LICENSE.txt.
46 * As a counterpart to the access to the source code and rights to copy,
47 * modify and redistribute granted by the license, users are provided only
48 * with a limited warranty and the software's author, the holder of the
49 * economic rights, and the successive licensors have only limited
52 * The fact that you are presently reading this means that you have had
53 * knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
58 * \brief Class bbtk::GBox
62 #include "GBoxModel.h"
66 //=========================================================================
68 GBoxModel::GBoxModel()
72 //=========================================================================
74 GBoxModel::~GBoxModel()
78 //=========================================================================
80 void GBoxModel::setInicPoint(double& x, double& y, double& z)
82 GObjectModel::setInicPoint(x,y,z);
83 double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
84 setFinalPoint(xFin,yFin,z);
87 //=========================================================================
89 void GBoxModel::addInputPort(GPortModel *inputport)
91 _inputs.push_back(inputport);
94 //=========================================================================
96 void GBoxModel::addOutputPort(GPortModel *outputport)
98 _outputs.push_back(outputport);
101 //=========================================================================
103 int GBoxModel::getNumInputPorts()
105 return _inputs.size();
108 //=========================================================================
110 int GBoxModel::getNumOutputPorts()
112 return _outputs.size();
115 //=========================================================================
117 void GBoxModel::move(double xx,double yy,double zz)
119 setInicPoint(xx,yy,zz);
121 //Refresh inputs position
123 for(i=0;i<(int)_inputs.size();i++)
125 _inputs[i]->updatePortPosition();
128 //Refresh outputs position
129 for(i=0;i<(int)_outputs.size();i++)
131 _outputs[i]->updatePortPosition();
136 //=========================================================================
138 std::string GBoxModel::getStatusText()
140 std::string temp = "";
145 //=========================================================================
147 std::vector<GPortModel*> GBoxModel::getInputPorts()
152 //=========================================================================
154 std::vector<GPortModel*> GBoxModel::getOutputPorts()
159 //=========================================================================
161 void GBoxModel::save(std::string &content)
167 //=========================================================================
169 GPortModel* GBoxModel::getInputPort(std::string name)
171 for(int i = 0; i<(int)_inputs.size();i++)
173 if(_inputs[i]->getBBTKName()==name)
181 //=========================================================================
183 GPortModel* GBoxModel::getOutputPort(std::string name)
185 for(int i = 0; i<(int)_outputs.size();i++)
187 if(_outputs[i]->getBBTKName()==name)
195 //=========================================================================
197 GPortModel* GBoxModel::getInputPort(int pos)
202 //=========================================================================
204 GPortModel* GBoxModel::getOutputPort(int pos)
206 return _outputs[pos];
209 //=========================================================================
211 void GBoxModel::updatePorts()
213 for(int i = 0; i<(int)_inputs.size();i++)
215 _inputs[i]->updatePortPosition();
216 _inputs[i]->notifyObservers(_objectId);
219 for(int i = 0; i<_outputs.size();i++)
221 _outputs[i]->updatePortPosition();
222 _outputs[i]->notifyObservers(_objectId);
227 //=========================================================================
229 void GBoxModel::addColons(std::string &text)
231 std::string character("&&2P&&");
233 pos = text.find(character);
234 while(pos != std::string::npos)
236 //We replace the character "&&2P&&" with ":" for all the string
237 text.replace(pos, character.length(),":");
238 pos = text.find(character, pos);
242 //=========================================================================
244 void GBoxModel::removeColons(std::string &text)
246 std::string character(":");
248 pos = text.find(character);
249 while(pos != std::string::npos)
251 //We replace the character ":" with "&&2P&&" for all the string
252 text.replace(pos, character.length(),"&&2P&&");
253 pos = text.find(character, pos);
257 //=========================================================================
260 } // EO namespace bbtk