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 )
62 _sceneManager = sceneManager;
66 _zGeneral = 900; // ?????
68 bbtk::InterpreterVirtual::Init();
72 //=========================================================================
74 InterpreterBBS::~InterpreterBBS()
78 //=========================================================================
81 /// Creates a new black box in current complex box
82 void InterpreterBBS::commandNew( const std::string& boxType, const std::string& boxName)
84 std::string packagename = _factory->GetPackageNameOfaBlackBox(boxType);
85 int idBox = _sceneManager->createGBlackBox( 0,0, packagename ,boxType);
86 _sceneManager->configGBlackBox(idBox, _xGeneral,_yGeneral,_zGeneral,boxName, false , _xGeneral+100, _yGeneral-10 , _zGeneral );
87 _yGeneral = _yGeneral + 30;
88 printf("EED InterpreterBBS::Create packagename=%s boxtype=%s boxname=%s \n", packagename.c_str(), boxType.c_str(), boxName.c_str() );
91 /// Connects the output boxOutput to the input boxInput
92 void InterpreterBBS::commandConnect (const std::string &boxfrom,
93 const std::string &output,
94 const std::string &boxto,
95 const std::string &input)
97 printf("EED InterpreterBBS::Connect\n");
101 /// sets the input of the box with the value
102 void InterpreterBBS::commandSet (const std::string &box,
103 const std::string &input,
104 const std::string &value)
106 printf("EED InterpreterBBS::Set\n");
112 void InterpreterBBS::commandLoad(const std::string &name )
116 /// Unloads a package
117 void InterpreterBBS::commandInclude(const std::string &name )
124 /// Sets the inputs of the workspace :
125 void InterpreterBBS::SetInputs(const std::map<std::string,std::string>& m)
129 /// Puts the executer in "no exec" mode,
130 /// which creates but does not execute pipelines
131 void InterpreterBBS::SetNoExecMode(bool b)
135 bool InterpreterBBS::GetNoExecMode() const
140 /// Sets the mode of dialog of the executer for Root inputs
141 void InterpreterBBS::SetDialogMode(DialogModeType t)
145 /// Puts the executer in "no error" mode,
146 /// Errors do not stop execution (but warnings are produced)
147 void InterpreterBBS::SetNoErrorMode(bool b)
151 bool InterpreterBBS::GetNoErrorMode() const
157 void InterpreterBBS::LoadPackage(const std::string &name )
161 /// Unloads a package
162 void InterpreterBBS::UnLoadPackage(const std::string &name )
166 /// Starts a package block
167 void InterpreterBBS::BeginPackage (const std::string &name )
171 /// Ends a package block
172 void InterpreterBBS::EndPackage ()
176 /// Starts the definition of a new ComplexBlackBox in package pack
177 /// scriptfilename is the file from which the def is read
178 void InterpreterBBS::Define (const std::string &name,
179 const std::string& pack,
180 const std::string &scriptfilename)
184 /// Sets the file name to use for the current definition
185 /// (Used to set it after the Define command)
186 void InterpreterBBS::SetCurrentFileName (const std::string &name )
190 /// End the definition of a ComplexBlackBox
191 void InterpreterBBS::EndDefine ()
195 /// Sets the kind of the currently defined ComplexBlackBox
196 void InterpreterBBS::Kind(const std::string& kind)
200 /// Creates a new black box in current complex box
201 void InterpreterBBS::Create ( const std::string& boxType, const std::string& boxName)
203 std::string packagename = _factory->GetPackageNameOfaBlackBox(boxType);
204 // int idBox = _sceneManager->createGBlackBox( 0,0, packagename ,boxType);
205 // _sceneManager->configGBlackBox(idBox, _xGeneral,_yGeneral,_zGeneral,boxName, false , _xGeneral+100, _yGeneral-10 , _zGeneral );
206 _yGeneral = _yGeneral + 30;
207 printf("EED InterpreterBBS::Create packagename=%s boxtype=%s boxname=%s \n", packagename.c_str(), boxType.c_str(), boxName.c_str() );
210 /// Destroys a black box
211 void InterpreterBBS::Destroy (const std::string &boxName)
215 /// Clears the currently defined ComplexBlackBox
216 void InterpreterBBS::Clear()
220 /// Connects the output boxOutput to the input boxInput
221 void InterpreterBBS::Connect (const std::string &boxfrom,
222 const std::string &output,
223 const std::string &boxto,
224 const std::string &input)
226 printf("EED InterpreterBBS::Connect\n");
230 void InterpreterBBS::Execute (const std::string &box)
234 /// Defines an input of the current complex box
235 void InterpreterBBS::DefineInput (const std::string &name,
236 const std::string &box,
237 const std::string &input,
238 const std::string &help)
242 /// Defines an output of the current complex box
243 void InterpreterBBS::DefineOutput (const std::string &name,
244 const std::string &box,
245 const std::string &output,
246 const std::string &help)
250 /// sets the input of the box with the value
251 void InterpreterBBS::Set (const std::string &box,
252 const std::string &input,
253 const std::string &value)
255 printf("EED InterpreterBBS::Set\n");
258 /// gets the output of the box
259 std::string InterpreterBBS::Get (const std::string &box,
260 const std::string &output)
265 /// changes the workspace name
266 void InterpreterBBS::SetWorkspaceName( const std::string& n )
270 ///Adds the authorName to the Box author list
271 void InterpreterBBS::Author(const std::string &authorName)
275 ///Adds the categories to the Box categoris list
276 void InterpreterBBS::Category(const std::string &categories)
280 /// The description string which explains what does the ComplexBox
281 void InterpreterBBS::Description(const std::string &d)
285 /// prints the list of the boxes of the current box
286 void InterpreterBBS::PrintHelpListBoxes()
290 /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
291 std::string InterpreterBBS::ShowGraph(const std::string &nameblackbox,
292 const std::string &detailStr,
293 const std::string &levelStr,
294 const std::string &output_file,
295 const std::string &custom_header,
296 const std::string &custom_title,
302 /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path
303 std::string InterpreterBBS::ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display)
308 /// Prints help on a black box
309 void InterpreterBBS::PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr)
313 void InterpreterBBS::Reset()
317 /// Sets the level of message for kind
318 void InterpreterBBS::SetMessageLevel(const std::string &kind, int level)
322 /// Prints help on the messages
323 void InterpreterBBS::HelpMessages()
327 /// Prints the string ... MORE : TO EXPLAIN
328 void InterpreterBBS::Print(const std::string & message)
335 } // EO namespace bbtk