]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx
Feature #1771 Add licence terms for all files.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / GBoxModel.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
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.
14 #
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
19 #  liability. 
20 #
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 # ------------------------------------------------------------------------  
24 */
25
26 /*=========================================================================                                                                               
27 Program:   bbtk
28 Module:    $RCSfile$
29 Language:  C++
30 Date:      $Date$
31 Version:   $Revision$
32 =========================================================================*/
33
34 /* ---------------------------------------------------------------------
35
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
38 *
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.
45 *
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
50 *  liability. 
51 *
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 * ------------------------------------------------------------------------ */                                                                         
55
56 /**
57 *  \file 
58 *  \brief Class bbtk::GBox 
59 */
60
61
62 #include "GBoxModel.h"
63
64 namespace bbtk
65 {
66         //=========================================================================
67
68         GBoxModel::GBoxModel()
69         {               
70         }
71
72         //=========================================================================
73
74         GBoxModel::~GBoxModel()
75         {
76         }
77
78         //=========================================================================
79
80         void GBoxModel::setInicPoint(double& x, double& y, double& z)
81         {
82                 GObjectModel::setInicPoint(x,y,z);
83
84                 double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
85                 setFinalPoint(xFin,yFin,z);
86         }
87
88         //=========================================================================
89
90         void GBoxModel::addInputPort(GPortModel *inputport)
91         {
92                 _inputs.push_back(inputport);
93         }
94
95         //=========================================================================
96
97         void GBoxModel::addOutputPort(GPortModel *outputport)
98         {
99                 _outputs.push_back(outputport);
100         }
101
102         //=========================================================================
103
104         int GBoxModel::getNumInputPorts()
105         {
106                 return _inputs.size();
107         }
108
109         //=========================================================================
110
111         int GBoxModel::getNumOutputPorts()
112         {
113                 return _outputs.size();
114         }
115
116         //=========================================================================
117
118         void GBoxModel::move(double xx,double yy,double zz)
119         {
120                 setInicPoint(xx,yy,zz);
121
122                 //Refresh inputs position
123                 int i;
124                 for(i=0;i<(int)_inputs.size();i++)
125                 {
126                         _inputs[i]->updatePortPosition();
127                 }
128                 
129                 //Refresh outputs position
130                 for(i=0;i<(int)_outputs.size();i++)
131                 {
132                         _outputs[i]->updatePortPosition();
133                 }
134
135         }
136         
137         //=========================================================================
138         
139         std::string GBoxModel::getStatusText()
140         {
141                 std::string temp = "";
142                 
143                 return temp;
144         }
145
146         //=========================================================================
147
148         std::vector<GPortModel*> GBoxModel::getInputPorts()
149         {
150                 return _inputs;
151         }
152
153         //=========================================================================
154
155         std::vector<GPortModel*> GBoxModel::getOutputPorts()
156         {
157                 return _outputs;
158         }
159
160         //=========================================================================     
161
162         void GBoxModel::save(std::string &content)
163         {
164                 content+="\n";
165         }
166         
167
168         //=========================================================================
169
170         GPortModel* GBoxModel::getInputPort(std::string name)
171         {
172                 for(int i = 0; i<(int)_inputs.size();i++)
173                 {
174                         if(_inputs[i]->getBBTKName()==name)
175                         {
176                                 return _inputs[i];
177                         }
178                 }
179                 return NULL;
180         }
181
182         //=========================================================================
183         
184         GPortModel* GBoxModel::getOutputPort(std::string name)
185         {
186                 for(int i = 0; i<(int)_outputs.size();i++)
187                 {
188                         if(_outputs[i]->getBBTKName()==name)
189                         {
190                                 return _outputs[i];
191                         }
192                 }
193                 return NULL;
194         }
195
196         //=========================================================================
197
198         GPortModel* GBoxModel::getInputPort(int pos)
199         {
200                 return _inputs[pos];
201         }
202
203         //=========================================================================
204         
205         GPortModel* GBoxModel::getOutputPort(int pos)
206         {
207                 return _outputs[pos];
208         }
209
210         //=========================================================================
211
212         void GBoxModel::updatePorts()
213         {
214                 for(int i = 0; i<(int)_inputs.size();i++)
215                 {       
216                         _inputs[i]->updatePortPosition();
217                         _inputs[i]->notifyObservers(_objectId);
218                 }
219
220                 for(int i = 0; i<_outputs.size();i++)
221                 {
222                         _outputs[i]->updatePortPosition();
223                         _outputs[i]->notifyObservers(_objectId);
224                 }
225         }
226
227         
228         //=========================================================================
229         //JPR
230         void GBoxModel::addColons(std::string &text)
231         {
232                 printf("EED JPR >>>>>>>>>>>>>>> %s\n",text.c_str() );
233                 std::string character("&&2P&&");                                
234                 size_t pos;
235                 pos = text.find(character);
236                 while(pos != std::string::npos)
237                 {
238                 //We replace the character "&&2P&&" with ":" for all the string
239                         text.replace(pos, character.length(),":");
240                         pos = text.find(character, pos);
241                 }
242         }
243
244         //=========================================================================
245         //JPR
246         void GBoxModel::removeColons(std::string &text)
247         {
248                 std::string character(":");                             
249                 size_t pos;
250                 pos = text.find(character);
251                 while(pos != std::string::npos)
252                 {
253                         //We replace the character ":" with "&&2P&&" for all the string
254                         text.replace(pos, character.length(),"&&2P&&");
255                         pos = text.find(character, pos);
256                         }
257         }
258
259         //=========================================================================
260
261
262 }  // EO namespace bbtk
263
264 // EOF
265