1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::InterpreterBBS
37 #include "InterpreterBBS.h"
39 #include "bbtkExecuter.h"
40 #include "bbtkMessageManager.h"
41 #include "bbtkFactory.h"
42 #include "bbtkUtilities.h"
51 InterpreterBBS::Pointer InterpreterBBS::New( wxVtkSceneManager* sceneManager, Factory::Pointer factory )
53 return MakePointer( new InterpreterBBS( sceneManager, factory) );
57 //=========================================================================
59 InterpreterBBS::InterpreterBBS( wxVtkSceneManager* sceneManager, Factory::Pointer factory )
63 _sceneManager = sceneManager;
67 _zGeneral = 900; // ?????
71 //=========================================================================
73 InterpreterBBS::~InterpreterBBS()
77 //=========================================================================
80 /// Creates a new black box in current complex box
81 void InterpreterBBS::commandNew( const std::string& boxType, const std::string& boxName)
83 std::string packagename = _factory->GetPackageNameOfaBlackBox(boxType);
84 int idBox = _sceneManager->createGBlackBox( 0,0, packagename ,boxType);
85 _sceneManager->configGBlackBox(idBox, _xGeneral,_yGeneral,_zGeneral,boxName, false , _xGeneral+100, _yGeneral-10 , _zGeneral );
86 _yGeneral = _yGeneral + 30;
87 printf("EED InterpreterBBS::Create packagename=%s boxtype=%s boxname=%s \n", packagename.c_str(), boxType.c_str(), boxName.c_str() );
90 /// Connects the output boxOutput to the input boxInput
91 void InterpreterBBS::commandConnect (const std::string &boxfrom,
92 const std::string &output,
93 const std::string &boxto,
94 const std::string &input)
96 printf("EED InterpreterBBS::Connect\n");
100 /// sets the input of the box with the value
101 void InterpreterBBS::commandSet (const std::string &box,
102 const std::string &input,
103 const std::string &value)
105 printf("EED InterpreterBBS::Set\n");
111 void InterpreterBBS::commandLoad(const std::string &name )
115 /// Unloads a package
116 void InterpreterBBS::commandInclude(const std::string &name )
123 /// Sets the inputs of the workspace :
124 void InterpreterBBS::SetInputs(const std::map<std::string,std::string>& m)
128 /// Puts the executer in "no exec" mode,
129 /// which creates but does not execute pipelines
130 void InterpreterBBS::SetNoExecMode(bool b)
134 bool InterpreterBBS::GetNoExecMode() const
139 /// Sets the mode of dialog of the executer for Root inputs
140 void InterpreterBBS::SetDialogMode(DialogModeType t)
144 /// Puts the executer in "no error" mode,
145 /// Errors do not stop execution (but warnings are produced)
146 void InterpreterBBS::SetNoErrorMode(bool b)
150 bool InterpreterBBS::GetNoErrorMode() const
156 void InterpreterBBS::LoadPackage(const std::string &name )
160 /// Unloads a package
161 void InterpreterBBS::UnLoadPackage(const std::string &name )
165 /// Starts a package block
166 void InterpreterBBS::BeginPackage (const std::string &name )
170 /// Ends a package block
171 void InterpreterBBS::EndPackage ()
175 /// Starts the definition of a new ComplexBlackBox in package pack
176 /// scriptfilename is the file from which the def is read
177 void InterpreterBBS::Define (const std::string &name,
178 const std::string& pack,
179 const std::string &scriptfilename)
183 /// Sets the file name to use for the current definition
184 /// (Used to set it after the Define command)
185 void InterpreterBBS::SetCurrentFileName (const std::string &name )
189 /// End the definition of a ComplexBlackBox
190 void InterpreterBBS::EndDefine ()
194 /// Sets the kind of the currently defined ComplexBlackBox
195 void InterpreterBBS::Kind(const std::string& kind)
199 /// Creates a new black box in current complex box
200 void InterpreterBBS::Create ( const std::string& boxType, const std::string& boxName)
202 std::string packagename = _factory->GetPackageNameOfaBlackBox(boxType);
203 // int idBox = _sceneManager->createGBlackBox( 0,0, packagename ,boxType);
204 // _sceneManager->configGBlackBox(idBox, _xGeneral,_yGeneral,_zGeneral,boxName, false , _xGeneral+100, _yGeneral-10 , _zGeneral );
205 _yGeneral = _yGeneral + 30;
206 printf("EED InterpreterBBS::Create packagename=%s boxtype=%s boxname=%s \n", packagename.c_str(), boxType.c_str(), boxName.c_str() );
209 /// Destroys a black box
210 void InterpreterBBS::Destroy (const std::string &boxName)
214 /// Clears the currently defined ComplexBlackBox
215 void InterpreterBBS::Clear()
219 /// Connects the output boxOutput to the input boxInput
220 void InterpreterBBS::Connect (const std::string &boxfrom,
221 const std::string &output,
222 const std::string &boxto,
223 const std::string &input)
225 printf("EED InterpreterBBS::Connect\n");
229 void InterpreterBBS::Execute (const std::string &box)
233 /// Defines an input of the current complex box
234 void InterpreterBBS::DefineInput (const std::string &name,
235 const std::string &box,
236 const std::string &input,
237 const std::string &help)
241 /// Defines an output of the current complex box
242 void InterpreterBBS::DefineOutput (const std::string &name,
243 const std::string &box,
244 const std::string &output,
245 const std::string &help)
249 /// sets the input of the box with the value
250 void InterpreterBBS::Set (const std::string &box,
251 const std::string &input,
252 const std::string &value)
254 printf("EED InterpreterBBS::Set\n");
257 /// gets the output of the box
258 std::string InterpreterBBS::Get (const std::string &box,
259 const std::string &output)
264 /// changes the workspace name
265 void InterpreterBBS::SetWorkspaceName( const std::string& n )
269 ///Adds the authorName to the Box author list
270 void InterpreterBBS::Author(const std::string &authorName)
274 ///Adds the categories to the Box categoris list
275 void InterpreterBBS::Category(const std::string &categories)
279 /// The description string which explains what does the ComplexBox
280 void InterpreterBBS::Description(const std::string &d)
284 /// prints the list of the boxes of the current box
285 void InterpreterBBS::PrintHelpListBoxes()
289 /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
290 std::string InterpreterBBS::ShowGraph(const std::string &nameblackbox,
291 const std::string &detailStr,
292 const std::string &levelStr,
293 const std::string &output_file,
294 const std::string &custom_header,
295 const std::string &custom_title,
301 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
302 std::string InterpreterBBS::ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display)
307 /// Prints help on a black box
308 void InterpreterBBS::PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr)
312 void InterpreterBBS::Reset()
316 /// Sets the level of message for kind
317 void InterpreterBBS::SetMessageLevel(const std::string &kind, int level)
321 /// Prints help on the messages
322 void InterpreterBBS::HelpMessages()
326 /// Prints the string ... MORE : TO EXPLAIN
327 void InterpreterBBS::Print(const std::string & message)
334 } // EO namespace bbtk