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);
84 double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
85 setFinalPoint(xFin,yFin,z);
88 //=========================================================================
90 void GBoxModel::addInputPort(GPortModel *inputport)
92 _inputs.push_back(inputport);
95 //=========================================================================
97 void GBoxModel::addOutputPort(GPortModel *outputport)
99 _outputs.push_back(outputport);
102 //=========================================================================
104 int GBoxModel::getNumInputPorts()
106 return _inputs.size();
109 //=========================================================================
111 int GBoxModel::getNumOutputPorts()
113 return _outputs.size();
116 //=========================================================================
118 void GBoxModel::move(double xx,double yy,double zz)
120 setInicPoint(xx,yy,zz);
122 //Refresh inputs position
124 for(i=0;i<(int)_inputs.size();i++)
126 _inputs[i]->updatePortPosition();
129 //Refresh outputs position
130 for(i=0;i<(int)_outputs.size();i++)
132 _outputs[i]->updatePortPosition();
137 //=========================================================================
139 std::string GBoxModel::getStatusText()
141 std::string temp = "";
146 //=========================================================================
148 std::vector<GPortModel*> GBoxModel::getInputPorts()
153 //=========================================================================
155 std::vector<GPortModel*> GBoxModel::getOutputPorts()
160 //=========================================================================
162 void GBoxModel::save(std::string &content)
168 //=========================================================================
170 GPortModel* GBoxModel::getInputPort(std::string name)
172 for(int i = 0; i<(int)_inputs.size();i++)
174 if(_inputs[i]->getBBTKName()==name)
182 //=========================================================================
184 GPortModel* GBoxModel::getOutputPort(std::string name)
186 for(int i = 0; i<(int)_outputs.size();i++)
188 if(_outputs[i]->getBBTKName()==name)
196 //=========================================================================
198 GPortModel* GBoxModel::getInputPort(int pos)
203 //=========================================================================
205 GPortModel* GBoxModel::getOutputPort(int pos)
207 return _outputs[pos];
210 //=========================================================================
212 void GBoxModel::updatePorts()
214 for(int i = 0; i<(int)_inputs.size();i++)
216 _inputs[i]->updatePortPosition();
217 _inputs[i]->notifyObservers(_objectId);
220 for(int i = 0; i<_outputs.size();i++)
222 _outputs[i]->updatePortPosition();
223 _outputs[i]->notifyObservers(_objectId);
228 //=========================================================================
230 void GBoxModel::addColons(std::string &text)
232 std::string character("&&2P&&");
234 pos = text.find(character);
235 while(pos != std::string::npos)
237 //We replace the character "&&2P&&" with ":" for all the string
238 text.replace(pos, character.length(),":");
239 pos = text.find(character, pos);
243 //=========================================================================
245 void GBoxModel::removeColons(std::string &text)
247 std::string character(":");
249 pos = text.find(character);
250 while(pos != std::string::npos)
252 //We replace the character ":" with "&&2P&&" for all the string
253 text.replace(pos, character.length(),"&&2P&&");
254 pos = text.find(character, pos);
258 //=========================================================================
261 } // EO namespace bbtk