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 //=========================================================================
67 GBoxModel::GBoxModel()
71 //=========================================================================
72 GBoxModel::~GBoxModel()
76 //=========================================================================
77 void GBoxModel::setInicPoint(double& x, double& y, double& z)
79 GObjectModel::setInicPoint(x,y,z);
80 double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
81 setFinalPoint(xFin,yFin,z);
84 //=========================================================================
85 void GBoxModel::addInputPort(GPortModel *inputport)
87 _inputs.push_back(inputport);
90 //=========================================================================
91 void GBoxModel::addOutputPort(GPortModel *outputport)
93 _outputs.push_back(outputport);
96 //=========================================================================
97 int GBoxModel::getNumInputPorts()
99 return _inputs.size();
102 //=========================================================================
103 int GBoxModel::getNumOutputPorts()
105 return _outputs.size();
108 //=========================================================================
109 void GBoxModel::move(double xx,double yy,double zz)
111 setInicPoint(xx,yy,zz);
112 //Refresh inputs position
114 for(i=0;i<(int)_inputs.size();i++)
116 _inputs[i]->updatePortPosition();
118 //Refresh outputs position
119 for(i=0;i<(int)_outputs.size();i++)
121 _outputs[i]->updatePortPosition();
125 //=========================================================================
126 std::string GBoxModel::getStatusText()
128 std::string temp = "";
133 //=========================================================================
134 std::vector<GPortModel*> GBoxModel::getInputPorts()
139 //=========================================================================
140 std::vector<GPortModel*> GBoxModel::getOutputPorts()
145 //=========================================================================
146 void GBoxModel::save(std::string &content)
152 //=========================================================================
153 GPortModel* GBoxModel::getInputPort(std::string name)
155 for(int i = 0; i<(int)_inputs.size();i++)
157 if(_inputs[i]->getBBTKName()==name)
165 //=========================================================================
166 GPortModel* GBoxModel::getOutputPort(std::string name)
168 for(int i = 0; i<(int)_outputs.size();i++)
170 if(_outputs[i]->getBBTKName()==name)
178 //=========================================================================
179 GPortModel* GBoxModel::getInputPort(int pos)
183 //=========================================================================
185 GPortModel* GBoxModel::getOutputPort(int pos)
187 return _outputs[pos];
190 //=========================================================================
192 void GBoxModel::updatePorts()
194 for(int i = 0; i<(int)_inputs.size();i++)
196 _inputs[i]->updatePortPosition();
197 _inputs[i]->notifyObservers(_objectId);
200 for(int i = 0; i<_outputs.size();i++)
202 _outputs[i]->updatePortPosition();
203 _outputs[i]->notifyObservers(_objectId);
208 //=========================================================================
210 void GBoxModel::addColons(std::string &text)
212 std::string character("&&2P&&");
214 pos = text.find(character);
215 while(pos != std::string::npos)
217 //We replace the character "&&2P&&" with ":" for all the string
218 text.replace(pos, character.length(),":");
219 pos = text.find(character, pos);
223 //=========================================================================
225 void GBoxModel::removeColons(std::string &text)
227 std::string character(":");
229 pos = text.find(character);
230 while(pos != std::string::npos)
232 //We replace the character ":" with "&&2P&&" for all the string
233 text.replace(pos, character.length(),"&&2P&&");
234 pos = text.find(character, pos);
238 //=========================================================================
241 } // EO namespace bbtk