]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx
Clean Code
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / InterpreterBBS.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::InterpreterBBS
59 */
60
61
62 #include "InterpreterBBS.h"
63
64 #include "bbtkExecuter.h"
65 #include "bbtkMessageManager.h"
66 #include "bbtkFactory.h"
67 #include "bbtkUtilities.h"
68
69 namespace bbtk
70 {
71
72         //=========================================================================
73         InterpreterBBS::Pointer InterpreterBBS::New( wxVtkSceneManager* sceneManager,  Factory::Pointer factory )
74         {
75                      return MakePointer( new InterpreterBBS( sceneManager, factory) );
76         }
77         //=========================================================================
78
79
80
81         //=========================================================================
82         InterpreterBBS::InterpreterBBS( wxVtkSceneManager* sceneManager, Factory::Pointer factory )
83         {
84                 _factory                = factory;
85                 _sceneManager   = sceneManager;
86
87                 _xGeneral               = -50;
88                 _yGeneral               = 100;
89                 _zGeneral               = GPOSITION_Z;   //  ?????
90
91                 _countBoxes             = 0;
92                 _countInputs    = 0;
93                 _countOutputs   = 0;
94
95                 bbtk::InterpreterVirtual::Init();
96
97         }
98         //=========================================================================
99
100
101         //=========================================================================
102         InterpreterBBS::~InterpreterBBS()
103         {
104         }
105         //=========================================================================
106
107
108         //=========================================================================
109         /// Creates a new black box in current complex box
110     void InterpreterBBS::commandNew( const std::string& boxType, const std::string& boxName) // virtual
111         {
112                 std::string packagename = _factory->GetPackageNameOfaBlackBox(boxType);
113                 std::string boxType2    = _factory->GetTypeNameOfaBlackBox(boxType);
114                 int idBox                               = _sceneManager->createGBlackBox( 0,0, packagename ,boxType2);
115                 _countBoxes++;
116 //EED 2022-01-16
117 //              double px                               = _xGeneral + (_countBoxes%2)*100;
118 //      _yGeneral               = _yGeneral - 30;
119         double px               = _xGeneral + (_countBoxes%2)*BOX_WIDTH*3.0;
120         _yGeneral               = _yGeneral - BOX_HEIGHT*3.0;
121                 double py                               = _yGeneral;
122                 _sceneManager->configGBlackBox(idBox, px,py,_zGeneral,boxName, false , px+BOX_WIDTH, py-BOX_HEIGHT , _zGeneral );
123         }
124         //=========================================================================
125
126
127         //=========================================================================
128         /// Connects the output boxOutput to the input boxInput
129     void InterpreterBBS::commandConnection (const std::string &boxfrom,
130                                                                   const std::string &output,
131                                                                   const std::string &boxto,
132                                                                   const std::string &input)                     // virtual
133         {
134                 _sceneManager->configGConnetion( boxfrom,output,boxto,input);
135         }
136         //=========================================================================
137
138
139         //=========================================================================
140         void InterpreterBBS::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string  &help)
141         {
142                 double xIn      = -100+50+_countInputs*50;
143                 double yIn      = 100;
144                 double zIn      = GPOSITION_Z;
145                 _sceneManager->configGComBoxInputOutputPort(true,name,xIn,yIn,zIn);
146                 _sceneManager->configGConnetion( name,name,box,input);
147                 _countInputs++;
148
149                 printf("EED InterpreterBBS::commandInput  what to do with help information ..???? \n  ");
150         }
151         //=========================================================================
152
153         //=========================================================================
154         void InterpreterBBS::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string  &help)
155         {
156                 _yGeneral       = _yGeneral - 30;
157                 double xIn      = -100+_countOutputs*30;
158                 double yIn      = _yGeneral;
159                 double zIn      = GPOSITION_Z;
160                 _sceneManager->configGComBoxInputOutputPort(false,name,xIn,yIn,zIn);
161                 _sceneManager->configGConnetion( box,output,name,name);
162                 _countOutputs++;
163
164                 printf("EED InterpreterBBS::commandInput  what to do with help information ..???? \n  ");
165         }
166         //=========================================================================
167
168
169         //=========================================================================
170         /// sets the input of the box with the value
171         void InterpreterBBS::commandSet(const std::string &box,const std::string &input,const std::string &value) // virtual
172         {
173                 GBlackBoxModel *bbMod = (GBlackBoxModel *)_sceneManager->findGBox(box);
174                 bbMod->setValueToInput(input,"\""+value+"\"");
175         }
176         //=========================================================================
177
178
179         //=========================================================================
180         void InterpreterBBS::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual
181         {
182                 _sceneManager->setComplexBox(true);
183                 _sceneManager->SetCbName(name);
184                 _sceneManager->SetCbPackageName(pack);
185         }
186         //=========================================================================
187
188
189         //=========================================================================
190         void InterpreterBBS::commandEndDefine() // virtual
191         {
192         }
193         //=========================================================================
194
195
196         //=========================================================================
197         void InterpreterBBS::commandExec(const std::string &word) // virtual
198         {
199                 GBlackBoxModel *bbMod = (GBlackBoxModel *)_sceneManager->findGBox(word);
200                 bbMod->setExecutable(true);
201         }
202         //=========================================================================
203
204
205         //=========================================================================
206         void InterpreterBBS::commandAuthor(const std::string &author)  // virtual
207         {
208         _sceneManager->SetAuthor(author);
209         }
210         //=========================================================================
211
212         //=========================================================================
213         void InterpreterBBS::commandCategory(const std::string &categorytype)  // virtual
214         {
215         _sceneManager->SetCategory(categorytype);
216         }
217         //=========================================================================
218
219         //=========================================================================
220         void InterpreterBBS::commandDescription(const std::string &description)  // virtual
221         {
222         _sceneManager->SetDescription(description);
223         }
224         //=========================================================================
225
226
227
228
229
230 }  // EO namespace bbtk
231
232 // EOF
233