]> Creatis software - bbtk.git/blob - kernel/doc/bbtkUsersGuide/bbtkUsersGuide.tex
toute revu, mais section 5 incomplete
[bbtk.git] / kernel / doc / bbtkUsersGuide / bbtkUsersGuide.tex
1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
3 \input{config.tex}
4 \begin{document}
5 \bbtkGuide[User's Guide]
6 % ==========================================
7
8
9 % ==========================================
10 \newpage
11 \hrule
12 \section{Introduction}
13 Note: pdf version of this User's Guide can be retrieved from the following URL:\\
14 \url{http://www.creatis.insa-lyon.fr/creatools/documentation}
15 % ==========================================
16 \subsection{What is bbtk?}
17 % ==========================================
18 \BBTK(\bbtkns) is a set of tools (\CPP libraries and executables) 
19 providing a \CPP framework for the definition of elementary processing \emph{units}, called {\bf black boxes}, and the definition and execution of processing \emph{chains} 
20 made up of these black boxes. \\
21
22 %It's a part of the \texttt{Creatools suite} composed mainly of :
23 %\begin{verbatim}
24 % bbtk
25 % creaContours
26 % creaImageIO
27 % creaLib
28  
29 %\end{verbatim}
30 %which depend on the OpenSource libraries: 
31 %\begin{verbatim}
32 % gdcm 
33 % itk
34 % vtk
35 % wxWidgets
36 %\end{verbatim}
37
38 % ==========================================
39 \subsubsection{The black box philosophy}
40 % ==========================================
41
42 \href{http://www.answers.com/topic/black-box-theater}{The Answers Dictionary} defines a {\bf black box} as 
43 \emph{``A device or theoretical construct with known or specified performance characteristics 
44 but unknown or unspecified constituents and means of operation''} \\
45 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
46 defines a {\bf black box} as 
47 \emph{``any component in a system in which only the input and output 
48 characteristics are of interest, without regard to its internal mechanism 
49 or structure''}. \\
50 We should merge these definitions: 
51 not only the inputs and outputs are of interest but also 
52 \emph{what the box does!}
53 Hence, we would say that a black box is any \emph{\bf documented} 
54 component of a system, letting the user know  
55 \emph{\bf what} the box is supposed to do and 
56 \emph{\bf how to use it}
57 but not \emph{\bf how it does it}. \\
58
59 \BBTK provides a systematic framework 
60 to encapsulate (or ``wrap'') any 
61 existing \texttt{C} or \CPP processing code into an object 
62 (a black box) having a {\bf generic symbolic interface}, where 
63
64 \begin{itemize}
65 \item{\bf generic} means that the interface is \emph{the same} 
66 for all boxes. Hence one does not need to know which particular 
67 method allows, say, to set a particular input or 
68 get a particular output of the box. 
69 One can use a black box in a purely abstract way. 
70 \item{\bf symbolic} means that a particular 
71 input or output is referenced by a 'name', that is by a symbol 
72 which identifies the input or output. 
73 It also means that symbolic information (text) is 
74 attached to a box: description of the box, author, 
75 description of its inputs and outputs, etc.
76 \end{itemize}
77
78 (Actually, genericity is achieved because the interface is symbolic. 
79 We let you think about this\dots)
80
81 Of course, symbolic data attached to a box may be 
82 {\bf queried}: what are the inputs/outputs of the box? 
83 what are their type? their description? etc.
84 This allows {\bf automatic documentation} of boxes. 
85
86 The abstract definition of black boxes is the most basic 
87 aspect of \BBTK architecture. 
88 Another key aspect is the grouping of black boxes into 
89 so called {\bf packages}, 
90 which are \emph{dynamic libraries} that can also 
91 be queried, in particular about the boxes they provide. 
92 The package structure then offers a mechanism similar to \emph{'plug-in'} mechanism.
93 \BBTK provides the methods to load a package at run-time, 
94 and create instances of the boxes it contains. 
95
96 These two mechanisms (black boxes and packages) 
97 then give the way to:
98
99 \begin{itemize}
100 \item The definition of an {\bf interpreted script language}, 
101 which allows to manipulate packages and boxes very easily in symbolic way. 
102 \BBTK provides one:  \bbs (the Black Box Script language) and its interpreter
103 \bbi (the Black Box Interpreter). 
104 \item {\bf Automatic documentation} of existing packages. 
105 \texttt{html} documentation of packages is proposed by 
106 \bbStudions.
107 \end{itemize}
108
109 Finally, these different components allow {\bf efficient}:
110
111 \begin{itemize}
112 \item {\bf capitalization and reuse} of existing processing units, 
113 including {\bf documentation} 
114 \item {\bf testing, prototyping} in a very simple script language
115 \item {\bf inter-operability} between atomic processings that 
116 have been written by different persons, using different libraries, etc. 
117 \end{itemize}
118
119
120 % ==========================================
121 \hrule
122 \paragraph{Summary}
123 %\hrule
124 A \texttt{black box}:
125 \begin{itemize}
126         \item has a name (this is actually a type name),
127         \item has a description and an author, 
128         \item belongs to categories (keywords that allow to index it
129 into automated documentation, and that are specified in the box definition),
130         \item has inputs and outputs that in turn have their:
131         \begin{itemize}
132                 \item names,
133                 \item types (any C++ type),
134                 \item descriptions, 
135         \end{itemize}
136         \item does something and can be executed, i.e. outputs are updated according to inputs.
137 \end{itemize}
138 A \texttt{package}:
139 \begin{itemize}
140         \item is a ``plug-in'' in the \bbtk framework,
141         \item has a name
142         \item has a description and an author. 
143         \item contains:
144         \begin{itemize}
145                 \item a dynamic library (dll/so/dylib) that contains compiled
146 black boxes (e.g.: dynamic library name of the package `std' is `bbstd.dll', `libbbstd.so' or `libbbstd.dylib' depending on the platform),
147                 \item bbs scripts: script-defined boxes, examples, applications,
148                 \item data: test data, resources.
149         \end{itemize}
150         \item is automatically documented.
151 \end{itemize}
152 \hrule
153 % ==========================================
154
155 % ==========================================
156 \subsubsection{{\bbtk} components}
157 % ==========================================
158 \BBTK includes:
159 \begin{itemize}
160   \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework 
161     (abstract classes) to develop black boxes and store them into 
162     dynamic libraries, called black box \emph{packages}.
163   \item Different {\bf\emph{"core" black box packages}}:
164     \begin{itemize}
165       \item {\bf\emph{std}}: the 'standard' package including basic useful boxes.
166       \item {\bf\emph{wx}}: basic graphical interface elements (widgets: sliders, buttons, etc. based on the \texttt{wxWidgets} library).  
167       \item {\bf\emph{itk}}: the basic image processing package, based on the \itk library.
168       \item {\bf\emph{vtk}}: the basic images and surfaces processing and visualization package, based on the \vtk library.
169       \item {\bf\emph{wxvtk}}: widget boxes based on the \vtk library (2D and 3D visualization and
170       interaction).
171       %\item {\bf\emph{creaImageIO}}: Provides hight level widgets to read images, including DICOM.
172       \item {\bf\emph{itkvtk}}: adaptors permitting to connect \itk boxes to \vtk boxes and conversely.
173       \item {\bf\emph{kw}}: widgets based on \texttt{KWWidgets} library (medical-image oriented:
174 slicer, transfer function editors, etc.).
175       \item {\bf\emph{demo}}: some black-box based demos.
176       \item {\bf\emph{appli}}: some black-box based standalone applications.
177       \item {\bf\emph{toolsbbtk}}: tools for bbtk administration and package development.     
178     \end{itemize}
179   \item A {\bf\emph{development environment}}, called \bbStudio, which provides:
180     \begin{itemize}
181       \item An online {\bf\emph{script editor and interpreter}}
182       \item A powerful html {\bf\emph{help environment}}, integrating:       
183         \begin{itemize}
184           \item Online documentation scanning
185           \item Retrieving boxes on various criteria
186           \item Checking demos and examples
187         \end{itemize}
188       \end{itemize}
189       \item A standalone {\bf\emph{interpreter}}, called \bbins, which allows to 
190            execute \bbs scripts.
191       \item {\bf\emph{Various development utilities}}:
192          \begin{itemize}
193             \item \bbfy generates the \CPP code of a black box from a 
194                description file written in \texttt{xml}.
195                 %\item \bbdoc generates the html documentation of a black box package 
196                 %(author, description, description of its black boxes : 
197                 %author, description, inputs, outputs, and so on).
198             \item \bbCreatePackage allows to create the basic file architecture 
199                to start the development of a new black box package.
200             \item \bbCreateBlackBox allows to create the basic file architecture 
201                to start the development of a new black box, that will be included in an already existing package.              
202             \item \texttt{bbs2cpp} translates a \texttt{.bbs} script into a \CPP file.
203             \item \bbc (sorry: Linux only, for the moment) that compiles \texttt{.bbs} scripts into executables.
204             \item \bbRegeneratePackageDoc which creates the html documentation of the Package.
205             \item \bbRegenerateBoxesLists which creates the html pages of the various lists of all the currenly installed boxes.
206             \item \bbPlugPackage which automatically incorporates a new package.                  
207          \end{itemize}
208       \item A full {\bf\emph{documentation}} that can be printed (pdf), browsed (html) and
209       queried through keywords.           
210 \end{itemize}
211
212 The general architecture of \BBTK 
213 is shown in figure \ref{bb-architecture}.
214
215 \begin{figure}[!ht]
216 \caption{\BBTK architecture}
217 \begin{center}
218 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
219 \end{center}
220 \label{bb-architecture}
221 \end{figure}
222
223 %%\newpage
224
225 % ==========================================
226 \subsection{Content of this guide}
227 % ==========================================
228
229 Read this \texttt{Users' Guide} if you want to learn how to use 
230 \bbtk development environnement \bbStudio and how to write black box scripts.\\
231 If your aim is to write your own Packages and Black Boxes, you have to read the
232 \texttt{Package Developper's Guide}.
233
234 % ==========================================
235 \newpage
236 \hrule
237 \section{Getting started with bbStudio}
238 \label{bbStudio}
239 % ==========================================
240
241
242 % ==========================================
243 \subsection{The interface}
244 % ==========================================
245
246
247 %\vspace{0.5cm}\hrule
248 %\section{The Development environment (bbStudio)}
249 %\label{bbStudio}
250
251 Just run it, typing in a console \bbStudio 
252 or clicking on its icon or its menu entry.
253 You'll get something like in figure 
254 \ref{bbi-fig-bbStudio-gui}
255 (the exact appearance of \bbStudio is Operating System and \bbtk version dependent).
256
257 %At start, \bbStudio opens with a very minimal 'How to use' in the middle. 
258 %Don't forget to read it: it will vanish at the first mouse click. 
259
260
261 %\begin{figure}[!ht]
262 %\caption{The bbStudio Development environment interface at start time}
263 %\begin{center}
264 %\includegraphics[width=0.7\textwidth]{bbStudioMainPageStart.png}
265 %\end{center}
266 %\label{bbi-fig-bbStudio-gui-start}
267 %\end{figure}
268
269 %Let's have a look at the resized window :
270 \begin{figure}[!ht]
271 \caption{The bbStudio Development environment interface}
272 \begin{center}
273 \includegraphics[width=0.7\textwidth]{bbStudioMainPage.png}
274 \end{center}
275 \label{bbi-fig-bbStudio-gui}
276 \end{figure}
277
278 The interface is divided into four parts: \texttt{Files}, \texttt{Messages},
279  \texttt{Command}, \texttt{Help}.
280 It is written using the Advanced User Interface library of wxWidgets
281 (a.k.a. AUI),
282 whose 'docking manager' allows windows and toolbars to be floated/docked 
283 onto a frame.
284 Feel free to resize/reposition any part you want.
285 Your preferences will be kept next time you run again \bbStudions. 
286
287 %Please don't use this feature at learning time 
288 %(the snapshots of this document wouldn't match with your screen ...)
289
290 \subsubsection{'Files' part}
291 \label{bbi-FilesPart}
292
293 It is the \bbs script editor (see section \ref{Scripting} to learn about scripting).
294
295 If you load a file holding a script, it will be displayed in this area, and you will be
296 able to modify it, to save it, to save-as it and to run it, using the respective
297 lower-toolbar buttons (see figure \ref{lowertoolbar}).
298
299 \begin{figure}[!ht]
300 \caption{The 'Files' lower toolbar}
301 \begin{center}
302 \includegraphics[width=0.7\textwidth]{lowertoolbar2.png}
303 \end{center}
304 \label{lowertoolbar}
305 \end{figure}
306
307
308 % \begin{itemize}
309 %   \item {\bf\emph{New file}}: Create a new file to hold a script
310 %   \item {\bf\emph{Open file}}: Open an already existing file holding a script 
311 %   \item {\bf\emph{Close file}}: Close a file holding a script
312 %   \item {\bf\emph{Save file}}: Save he current file (if modified)
313 %   \item {\bf\emph{Save file as}}: Save he current file under a different name
314 %   \item {\bf\emph{Run file}}: Execute the script you just loaded/modified/written
315 %   \item {\bf\emph{cursor position}}: column number : line number   
316 % \end{itemize}
317
318
319 \subsubsection{'Messages' part}
320 \label{bbi-MessagesPart}
321
322 Two kinds of messages will be output here:\\
323 \begin{itemize}
324 \item {\bf\emph{System messages:}} produced by the kernel, in case of a user mistyping, or an execution error.\\
325 \item {\bf\emph{Script messages:}} produced by the \bbtk equivalent of \texttt{printf} 
326 or \texttt{std::cout} in user programs.
327 \end{itemize}
328
329
330 \subsubsection{'Command' part}
331 \label{bbi-CommandPart}
332
333 You can type here \bbs commands which are executed on the fly.
334 The buttons are shortcuts to the most frequently used commands.
335 The command (or button) \texttt{help} permits to print in the \texttt{Message} zone the list of all recognized commands, while the command \texttt{help} \emph{command\_name} provides the help on the selected command.
336
337 \subsubsection{'Help' part}
338 \label{bbi-HelpContentsPart}
339
340 The 'Help' part of \bbStudio is used to browse the html help of \BBTKns. You can find there various guides (see section~\ref{sec:guides}) and detailed information about each black box available (see section~\ref{sec:boxes_help}). They can be browsed alphabetically, by package and by category. Two special categories, demos and examples, are available via direct links (see section~\ref{sec:demos_examples}).
341
342
343 % ==========================================
344
345
346
347
348 % ==========================================
349 % ==========================================
350 % ==========================================
351 % ==========================================
352 % ==========================================
353
354
355
356 % ==============================================
357 \subsection{Online Help}
358 % ==============================================
359
360 Various levels of help are supplied by \bbStudions.
361
362 % ==========================================
363 \subsubsection{Command-line help}
364 % ==========================================
365
366
367 The 'working' area (the left one, as opposed to the (\texttt{Help}) area, on the right side) is composed of: 
368 one single line area (\texttt{Command}), at the bottom, in which you can enter your commands, and 
369 a multiple line zone (\texttt{Messages}) in which the command interpreter prints out the result of your commands.
370 %The upper part contains the script editor; we shall not use it right now, you may reduce it.
371 Command-line help for the black box scripting language \bbs (see section \ref{Scripting}) can be obtained in this zone. \par
372 As mentioned above, the command (or button) \texttt{help} permits to print in the \texttt{Message} zone the list of all recognized commands, while the command \texttt{help} \emph{command\_name} displays in this zone the help about the selected command.\par
373 The command \texttt{help} \emph{package\_name} displays in the \texttt{Message} zone a short information about the selected package, provided that this package was previously loaded (Note that you can know which packages were loaded by executing the command \texttt{help packages}). Furthermore, it simultaneously displays in the right zone (\texttt{Help}) the corresponding full html help available.\par
374 In a similar way, one can obtain the information about any box from the loaded packages, by executing the command \texttt{help} \emph{box\_name}. Note that some boxes may be unavailable if the command \texttt{load} was used to load the package, since this command only loads the boxes defined in binary files (dynamic libraries). Some boxes are defined in script files. To be sure that all the boxes from the package are loaded the command \texttt{include} is to be preferred.\par
375  
376 It is important to note that the black boxes are implemented and have to be used according to the {\bf\emph{object-oriented}} programming principles. This means that you have to make difference between a black box {\bf\emph{type}} and an {\bf\emph{instance}} of the given black box type. The former defines a ``pattern'' (a mold), according to which are formed the actual objects. If you query for help on a black box type, you learn about its purpose, its author, the boxes it contains (if it is a complex black box) and the types of its inputs/outputs. The user-defined black box types belong to the package \texttt{user} and can be listed by use of the command \texttt{help user}. If you query for help on a black box instance, you learn about the values and the state of its inputs/outputs. The currently existing black box instances belong to the complex black box \texttt{workspace} and can be listed by use of the command \texttt{help workspace}. 
377
378 % ==========================================
379 \subsubsection{Guides}
380 \label{sec:guides}
381 % ==========================================
382
383 All the guides can be browsed in html version in the \texttt{Help} part of \bbStudions. Their pdf versions (except Doxygen documentation) can be retrieved from:\\
384 \url{http://www.creatis.insa-lyon.fr/creatools/documentation}
385
386  \begin{itemize}      
387      \item {\bf\emph{User's Guide}}: This guide!
388      \item {\bf\emph{Package Developer's Guide}}: Step-by-step "How-to" for programmers who want to create their own
389      black boxes/packages.
390     % \item {\bf\emph{Developper's Guide}}: For bbtk kernel developpers only. (This one is probably not very much
391     %  up-to-date, since we spend more time in developping than writing documentation that's not of user concern).
392     % \item {\bf\emph{Reference Manual}}: Contains a exaustive description of all the features for all the commands.
393     %\item {\bf\emph{Booklet}}: Vade mecum.     
394      \item {\bf\emph{Doxygen Documentation}}: Doxygen source browser.\\ Automatically generated from source files. Should only concern the kernel developers.
395    \end{itemize}
396         
397
398   
399
400 % ==========================================
401 \subsubsection{Boxes Help}
402 \label{sec:boxes_help}
403 % ==========================================
404  Lists of currently available boxes from installed packages, sorted according to the following criteria:
405    \begin{itemize} 
406     \item {\bf\emph{Alphabetical list}}%: This is the 'zero-level' of retrieving.
407     \item {\bf\emph{List by package}}%: The boxes are indexed by package they belong to
408     \item {\bf\emph{List by category}}:
409      Each box is indexed by a list of keywords, called 'categories', such as '\texttt{read/write}',
410      '\texttt{filter}', '\texttt{viewer}', ...
411     A given box may belong to more than one \texttt{category}, however some categories are mutually exclusive.
412     Standard categories are:
413     \begin {itemize}
414        \item\texttt{atomic box}/\texttt{complex box}\\
415        Any box is either atomic or complex.\\
416        The former are 'atomic' units written in C++ and available in binary form.\\
417        Any pipeline built up as an assembly of several black boxes (atomic or complex), and described in \bbs script language is itself viewed as a complex black box, and hence tagged as belonging to the latter category.
418        \item\texttt{example} / \texttt{demo} / \texttt{application} (see \ref{sec:demos_examples})\\
419           These ones are scripts that produce a result when executed (i.e. they
420           execute a pipeline), as opposed to the scripts that only define complex boxes but do not instanciate and execute boxes. 
421           \begin {itemize}
422              \item\texttt{example}: It is just a (simple) example, for programmers, of how to use a given feature. The \texttt{Examples} link on the starting page links to the list of the boxes of this category.
423              \item\texttt{demo}: It can be a 'good looking' (a.k.a 'sexy') example of some sophisticated work, done only by using \texttt{bbtk}. The \texttt{Demos} link on the starting page links to the list of the boxes of this category.
424              \item\texttt{application}: It is a final application, end-user intended (e.g. association of a DICOM image browser, reader, viewer with some interaction and processing)    
425           \end {itemize}
426         \item\texttt{widget}: A piece of graphical interface (based on \texttt{wxWidgets}).
427         \item\texttt{dicom}: A box related to medical images in Dicom format.
428         \item\texttt{viewer}: A box allowing to view something (e.g. an image).
429         \item\texttt{read/write}: An I/O-related box.
430         \item\texttt{mesh}: A mesh-related box.
431         \item\texttt{filter}: A filter, mainly image filters.
432         \item\texttt{image}: An image-related box.
433         \item\texttt{3D object creator}: A box which creates a 3D object to be injected into a 3D view (e.g. a plane, a surface).
434         \item\texttt{math}: Maths of course.
435         \item\texttt{misc}: Miscellaneous...       
436     \end {itemize}
437   Remark that the list of categories is 'auto-extensible': each time a new box is created which belongs to a new category and the boxes list is regenerated, the new category appears in the list, holding the new box. The above list only contains the categories used in the packages provided with current \bbtk release.
438     \item {\bf\emph{List of adaptors}}: The adaptors are a special type of black boxes that are used internally to perform type conversions. Although they are not end user intended, you may see their list. Adaptors belong to the \texttt{adaptor} category.
439   \end {itemize}
440   For each box, the html \texttt{Help} provides the informations necessary to use it: its name, its purpose, the descriptions of its inputs/outputs and the name of the package (or script file) that is to be loaded. Note that for a given box only the inputs/outputs listed in white cells are of actual interest. The remaining ones, grouped after them in colored cells, are standard (have the same names and purpose) in all atomic boxes. Additionally, for all boxes but the atomic ones (i.e. for all boxes defined in \bbs script language), the corresponding script is available via [\texttt{source}] link. Actually, by clicking on this link, one loads the script into the \texttt{Files} area where it can be analyzed, edited and executed.
441   
442 % ==========================================      
443 \subsubsection{The Package Browser}
444 \label{Package_Browser}
445 % ==========================================
446
447 The package browser is a standalone application \texttt{bbPackageBrowser}, which 
448 dynamically loads and queries the available packages. 
449 It is thus a smarter tool than the static html documentation.
450 You can run it independently or from \bbStudio using either the button labeled \texttt{Start Package Browser} of the 'Command' part or the corresponding entry in the menu 'Windows'. 
451 Note that it may take some time to start because it loads all available 
452 packages at start.
453 Its appearance is reproduced in figure \ref{imPackage_Browser}.
454
455 \begin{figure}[!ht]
456 \caption{The Package Browser}
457 \begin{center}
458 \includegraphics[width=0.6\textwidth]{Package_Browser.png}
459 \end{center}
460 \label{imPackage_Browser}
461 \end{figure}
462
463 It allows you to find boxes by use of a multi-criteria filtering principle: 
464 the boxes listed are the ones the attributes of which match \emph{all} the 
465 words entered in the 'Filter' part.
466 You can get the whole description of a given box by clicking on its name.
467 \\
468 Warnings: 
469
470 \begin{itemize}
471 \item It is case sensitive, i.e '\texttt{Button}' 
472 will give different results than '\texttt{button}'.
473 \item After typing a filtering string, you have to validate it by pressing the 'Enter' key, in order to update the display of the boxes list.
474 \item A filtering string only needs to match a subpart of the related attribute of a box.
475 For example, entering 'utt' in the 'Name' attribute will match a box called 'Button'.
476 \end{itemize}
477
478 Attributes:
479
480 \begin {itemize}
481 \item \texttt{Package}: The name of the package to which the box belongs (e.g. \texttt{wxvtk}, \texttt{std}).
482 \item \texttt{Name}: The name of a box or an application (e.g. \texttt{Reader}, \texttt{example}).
483 \item \texttt{Description}: A part of the description of a box (e.g. \texttt{3D}, \texttt{image}).
484 \item \texttt{Category}: The categories of the box (e.g. \texttt{demo}).
485 \item \texttt{Input/Output Type}: The \CPP type of an input/output (e.g. \texttt{vtkImageData*}, \texttt{std::string}).
486 \item \texttt{Input/Output Nature}: The \texttt{nature} of an input or output (e.g. \texttt{file name}, \texttt{signal}).
487 \end {itemize}
488
489 %If 'Show widgets' is selected then 
490
491
492 %%\newpage 
493
494
495
496 % ==========================================
497
498 %\newpage
499
500 % ==============================================
501 \subsection{Running Demos and Examples}
502 \label{sec:demos_examples}
503 % ==============================================
504
505 As previously mentioned, the links \texttt{Demos} and \texttt{Examples} in the 'Help' part (See figure \ref{HelpContents}), give access to special complex boxes from the respective categories. Here, we use an example, both to illustrate the use of this help and to explain a short \bbs script.\\
506
507 \begin{figure}[!ht]
508 \caption{\bbStudio 'Help' panel}
509 \begin{center}
510 \includegraphics[width=0.7\textwidth]{HelpContents.png}
511 \end{center}
512 \label{HelpContents}
513 \end{figure}
514
515 %\newpage
516 Select \texttt{Examples} link. You will get a list of examples (See figure \ref{example}).
517
518 Note: due to an unfixed bug in Linux, you have to click on 'reload' to get it. \\ 
519
520
521 \begin{figure}[!ht]
522 \caption{Examples list}
523 \begin{center}
524 \includegraphics[width=0.7\textwidth]{example.png}
525 \end{center}
526 \label{example}
527 \end{figure}
528
529
530 %\begin{figure}[!ht]
531 %\caption{\label{BoxCategories}Box Categories}
532 %\begin{center}
533 %\includegraphics[width=0.7\textwidth]{BoxCategories.png}
534 %\end{center}
535 %\end{figure} 
536
537
538 Select \texttt{wx::exampleSlider}.
539  
540 \begin{figure}[!ht]
541 \caption{Html documentation of example 'exampleSlider'}
542 \begin{center}
543 \includegraphics[width=0.7\textwidth]{exampleSlider.png}
544 \end{center}
545 \label{exampleSlider}
546 \end{figure}
547
548 You can see information about the example and 
549 the graphical representation of the workflow defined by the script
550 (the elementary boxes that compose it, and their connections, see figure \ref{exampleSlider}).
551
552 Click on \texttt{[source]}, it will be loaded
553 in the 'Files' part, within the script editor (See figure \ref{exampleSliderSource});
554
555 \begin{figure}[!ht]
556 \caption{Source code of 'exampleSlider'}
557 \begin{center}
558 \includegraphics[width=0.7\textwidth]{exampleSliderSource.png}
559 \end{center}
560 \label{exampleSliderSource}
561 \end{figure}
562
563 Run it, using the 'Files' toolbar (see figure \ref{lowertoolbar})
564
565 You'll get something like in figure \ref{execSliderSource}.
566
567 \begin{figure}[!ht]
568 \caption{\label{execSliderSource}Execution of 'exampleSlider'}
569 \begin{center}
570 \includegraphics[width=0.7\textwidth]{execSliderSource.png}
571 \end{center}
572 \end{figure}
573
574 Feel free to move the slider, to check whether it actually works...
575
576 %\newpage
577
578 Just a few words on what you saw:
579 \begin{itemize}
580 \item{In the source code of the script}:
581         \begin{verbatim}
582    load std
583    load wx
584         \end{verbatim}
585         These \bbs commands load the packages \texttt{std} and \texttt{wx}
586         \begin{verbatim}
587    new Slider     slider
588    set slider.ReactiveOnTrack 1
589         \end{verbatim}
590         We create a \texttt{Slider} box called \emph{slider}.
591
592         We tell it to inform anybody that's interested in, that the cursor moved, each time it moved. 
593         The default behaviour is to inform only when cursor is released.
594         \begin{verbatim}
595    new OutputText text
596         \end{verbatim}
597         We create an \texttt{OutputText} box called \emph{text} 
598         (in which slider value will be displayed)
599
600         \begin{verbatim}
601    new LayoutLine layout
602         \end{verbatim}
603         We create a \texttt{LayoutLine} box called \emph{layout},
604         a widget box designed to embed other widgets (say, a main window)
605         \begin{verbatim}
606    connect slider.Widget    layout.Widget1
607    connect text.Widget      layout.Widget2
608         \end{verbatim}
609         We embed \emph{slider} and \emph{text} into  \emph{layout}.
610         \begin{verbatim}
611    connect slider.BoxChange text.BoxExecute
612    connect slider.Out       text.In
613         \end{verbatim}
614         We tell  \emph{slider} to inform \emph{text} every time it's modified.
615
616         We tell  \emph{slider} to pass its output value (\texttt{Out}) 
617         to \emph{text}  input value (\texttt{In})
618         \begin{verbatim}
619    exec layout
620         \end{verbatim}
621         We tell \emph{layout} to process itself. 
622         This also produces the execution of the boxes connected to it (the slider, the text).
623
624 \item{In the Help part}
625
626         You can see the graphical representation of the workflow (pipeline) created by the script, 
627         as in figure \ref{SmallGraph}.
628
629
630         \begin{figure}[!ht]
631         \caption{Graphical representation of a pipeline}
632         \begin{center}
633         \includegraphics[width=0.7\textwidth]{SmallGraph.png}
634         \end{center}
635         \label{SmallGraph}
636         \end{figure}
637
638         The representation includes 
639         both the graphical interface-related pipeline 
640         (\emph{slider} and \emph{text} are embedded into \emph{layout})
641          and the data processing-related pipeline 
642         (\emph{slider} warns \emph{text} immediately when it's modified, 
643         \emph{slider} passes \emph{text} its output value)\footnote{Yes, we know : all the arrows                       (graphical interface pipeline arrows and data processing arrows) 
644         are blue; using different colors is planned for next release...}.
645  
646         You can get a much more detailed graph, 
647         like in figure  \ref{LargeGraph}, 
648         just clicking on the button 
649         '\texttt{graph (detailed)}' in the toolbar of the \texttt{Command} part. 
650
651  
652         \begin{figure}[!ht]
653         \caption{Detailed graphical representation of a pipeline}
654         \begin{center}
655         \includegraphics[width=0.75\textwidth]{LargeGraph.png}
656         \end{center}
657         \label{LargeGraph}
658         \end{figure} 
659
660 \end{itemize}
661 %\newpage
662
663 % ==============================================
664 \subsection{The Menu}
665 % ==============================================
666
667 At last, let us have a look at \bbStudio menu (see figure \ref{themenu}).
668
669 \begin{figure}[!ht]
670 \caption{The bbStudio menu}
671 \begin{center}
672 \includegraphics[width=0.7\textwidth]{themenu.png}
673 \end{center}
674 \label{themenu}
675 \end{figure}
676
677 \begin {itemize}
678   \item{\texttt{File}}
679      \begin {itemize}
680         \item{\texttt{Open the bbtk configuration file}}
681         \item{\texttt{Quit}}
682      \end {itemize}       
683   \item{\texttt{Tools}}
684      \begin {itemize}
685         \item{\texttt{Create package}}:
686         Provides a graphical interface to help package developers to create a new empty package.
687         \item{\texttt{Create black box}}:
688         Provides a graphical interface to help package developers to create a new empty black box, and add it to an already existing package.   
689         \item{\texttt{Plug Package}}:
690         Incorporates a package into the list of known packages. Updates the html documentation.
691         \item{\texttt{Regenerate package doc}}:
692         If a package has changed (e.g. new boxes) this updates the package html documentation.
693         \item{\texttt{Regenerate boxes list}}:
694         Updates the boxes lists (alphabetical, by package, ...)
695         \item{\texttt{Regenerate all}}:
696         Regenerates all the packages documentations and the boxes lists (may be long...).
697         \item{\texttt{Show last graph}}:
698         Shows the last pipeline graph that was generated
699      \end {itemize}     
700   \item{\texttt{Options}}
701      \begin {itemize}
702         \item{\texttt{Reset before running}}: Before running a script, all the already created boxes are destroyed, 
703         all the already loaded packages are unloaded (this is the recommended option).   
704      \end {itemize}     
705   \item{\texttt{Windows}}
706   User may decide, for any reason of his own, to hide one or more panels:
707      \begin {itemize}
708         \item{\texttt{Show 'Files' panel}}
709         \item{\texttt{Show 'Help' panel}}
710         \item{\texttt{Show 'Command' panel}}
711         \item{\texttt{Show 'Messages' panel}}
712         \item{\texttt{Start Package browser}}: starts the package browser (see \ref{Package_Browser}).
713      \end {itemize}     
714   \item{\texttt{About}}
715      \begin {itemize}
716         \item{\texttt{About}}: Info about \texttt{bbStudio}.       
717      \end {itemize}     
718 \end {itemize}
719
720
721
722
723 % ==========================================
724 % ==========================================
725 % ==========================================
726 % ==========================================
727 \newpage
728 \hrule
729 \section{Writing black box scripts (\bbsns)}
730 \label{Scripting}
731 % ==========================================
732 % ==========================================
733 % ==========================================
734
735 This section introduces how to write down black box scripts (\bbsns) 
736 to create and execute pipelines. 
737
738 % ==========================================
739 \subsection{The commands}
740 % ==========================================
741 In the sequel the commands entered by the user will be preceded by a prompt (\texttt{>}).
742 To get started, type in the \texttt{Command} area:
743 \begin{verbatim}
744 > help 
745 \end{verbatim}
746
747 you get the following list of the commands recognized by the interpreter:
748 \begin{verbatim}
749 Available commands :
750  author
751  category
752  config
753  connect
754  debug
755  define
756  delete
757  description
758  endefine
759  endpackage
760  exec
761  graph
762  help
763  include
764  index
765  input
766  kind
767  load
768  message
769  new
770  newgui
771  output
772  package
773  print
774  quit
775  reset
776  set
777  unload
778 \end{verbatim}
779
780 To get the help on a particular command, type \texttt{help <command name>}, e.g.:
781 \begin{verbatim}
782 > help author
783 \end{verbatim}
784
785 gives:
786 \begin{verbatim}
787  usage : author <string>
788   Adds the string <string> to the author information 
789 of the black box being defined
790 \end{verbatim}
791
792 The \texttt{help} command has multiple usages. 
793 It is used to get help about almost anything in the interpreter, including the \texttt{help} command itself! Indeed:
794 \begin{verbatim}
795 > help help
796 \end{verbatim}
797
798 gives:
799 \begin{verbatim}
800  usage : 
801         (1) help 
802         (2) help <command name> 
803         (3) help packages [all]
804         (4) help <package name> [all]
805         (5) help <black box type> 
806         (6) help <black box name>
807   Effect :
808         (1) Lists all available commands;
809         (2) Prints help on a particular command; 
810         (3) Lists the packages loaded and their black boxes.
811             Add 'all' to list adaptors; 
812         (4) Prints short help on the black boxes of a package.
813             Add 'all' to include adaptors; 
814         (5) Prints full help on a black box type; 
815         (6) Prints information on the inputs, outputs and connections
816              of a black box instance.
817 \end{verbatim}
818
819 %More information about what is a 'box' will be given in the 'Scripting' part of this manual.
820
821
822 % ==========================================
823 \subsection{Creating and executing black box instances}
824 % ==========================================
825
826 At start the interpreter does not know any black box. 
827 If you type \texttt{'help packages'}, which is 
828 the third form of the \texttt{help} command, you get:
829 \begin{verbatim}
830 > help packages
831 user
832   workspace
833 \end{verbatim}
834
835 which means that the interpreter only knows one package 
836 (library of black boxes) called \texttt{user}
837 and which contains a black box called \texttt{workspace}.
838 The \texttt{user} package is an internal package of the interpreter, 
839 which stores user-defined black box types. 
840 At start, it already contains 
841 one box, called \texttt{workspace},
842 which is a special type of black box, 
843 called complex black box, the purpose of which is 
844 to store other black boxes. 
845 Any black box instance you create in \bbStudio is stored 
846 in \texttt{workspace}  
847 (see also section \ref{bbi-command-line-app}).
848
849 If you type \texttt{'help workspace'}, you get:
850 \begin{verbatim}
851 > help workspace
852  Complex Black Box <user::workspace>
853   User's workspace
854   By : bbtk
855   Category(s): complex box;
856   * No inputs
857   * No outputs
858   * No boxes
859 \end{verbatim}
860
861 In the text displayed, 
862 the \texttt{user::} prefixed to the name \texttt{workspace} 
863 means that the box \texttt{workspace} 
864 belongs to the \texttt{user} package. 
865 Then comes a description and three lines which 
866 tell that \texttt{workspace} does not have any input 
867 nor output nor boxes yet.
868
869 In order to let the interpreter know of some black boxes, 
870 you must load another package. 
871 The \texttt{std} package is the ``standard'' package, 
872 which contains basic useful black box types. 
873
874 To load it, type:
875 \begin{verbatim}
876 > include std
877 \end{verbatim}
878
879 Then if you type:
880 \begin{verbatim}
881 > help packages
882 \end{verbatim}
883
884 you get something like:
885
886 \begin{verbatim}
887  std
888    ASCII                   
889    Add                     
890    ConcatStrings           
891    Configuration           
892    Div                     
893    ExecBbiCommand          
894    ExecSystemCommand       
895    GetVectorCharElement    
896      ...
897    MagicBox                
898    MakeFileName            
899    Mul                     
900    MultipleInputs          
901    StringRelay             
902    StringSelect            
903  user
904    workspace 
905 \end{verbatim}
906
907 Now the interpreter knows the package \texttt{std} and the black box types it provides,
908 such as the \texttt{Add} box, the \texttt{ConcatStrings} box, and so on. Remark that the 
909 content of \texttt{std} may vary from one version to another 
910 as new black box types might be added to it. Note that you will get a more detailed information about the package loaded (here \texttt{std}) if you type: 
911 \begin{verbatim}
912 > help std
913 \end{verbatim}
914
915 Indeed, each of the items listed is followed by its short description:
916 \begin{verbatim}
917  Package std v1.0.0- laurent.guigues at creatis.insa-lyon.fr
918  Basic useful boxes
919  Black boxes : 
920    ASCII                   : ascii codes sequence to string - ...
921    Add                     : Adds its inputs
922    ConcatStrings           : String concatenation
923    Configuration           : Gets configuration informations
924         ...
925 \end{verbatim}
926 Additionally, in the right part of the screen ('Help' zone) the corresponding html page is displayed.
927
928 Now, if you type:  
929 \begin{verbatim}
930 > help Add
931 \end{verbatim}
932
933 \bbStudio displays the appropriate html page in the 'Help' part (see figure : \ref{HelpAdd}), and the following text in the 'Message' part:
934 \begin{verbatim}
935 Black Box <std::Add>
936  Adds its inputs
937  By : laurent.guigues@creatis.insa-lyon.fr
938  Categories : atomic box;math;
939  * Inputs : 
940    'BoxExecute'     <bbtk::Void> [signal] : Any signal received ...
941                                               executes the box
942    'BoxProcessMode' <String>     []       : Sets the processing ...
943                                               (Pipeline | Always...
944    'In1'            <Double>     []       : First number to add
945    'In2'            <Double>     []       : Second number to add
946  * Outputs : 
947    'BoxChange'      <bbtk::VoidS> [signal]: Signals modifications...
948    'Out'            <Double>     []       : Result
949 \end{verbatim}
950
951 \begin{figure}[!ht]
952 \caption{The html Help}
953 \begin{center}
954 \includegraphics[width=0.7\textwidth]{HelpAdd.png}
955 \end{center}
956 \label{HelpAdd}
957 \end{figure}
958
959 These descriptions 
960 (provided by the author of the box) include: 
961 the author(s) of the box (usually e-mail address(es)) and 
962 the categories to which the box belongs, 
963 the lists of inputs and outputs of the box.
964 For each input or output, the help provides 
965 its \emph{name}, 
966 its \emph{type} (between \texttt{<} and  \texttt{>}, e.g. \texttt{<Int>})
967 and a description.    
968 Remark that the box \texttt{Add} is not a 'complex' black box 
969 but an 'atomic' box, hence its help does not 
970 include a pipeline graph. 
971
972 You can see that  \texttt{Add} boxes have two inputs, 
973 with name \texttt{In1} and \texttt{In2},
974 and an output, named \texttt{Out}.
975
976 After loading the package it belongs to, you can create an \emph{instance} of an \texttt{Add} box, by use of the command \texttt{new}:
977
978 \begin{verbatim}
979 > new Add a
980 \end{verbatim}
981
982 Here \texttt{'a'} is the \emph{name} of the instance, 
983 which will be used to reference it later. 
984 Remind that it is important to distinguish a box \emph{type} 
985 and an \emph{instance} of a box type. 
986 The \texttt{Add} box of the package \texttt{std} is actually 
987 a \emph{box type}, like \texttt{int} is a data type 
988 in \texttt{C} language. The \texttt{new} command allows to create 
989 an instance of a box type, exactly like \texttt{int i;} in 
990 a \texttt{C} code declares a variable of type \texttt{int}, the 
991 name of which is \texttt{i}. 
992 Of course, like in \texttt{C} Language, you can declare multiple boxes of the 
993 same type in \bbs.
994
995 After the creation of the box instance \texttt{a} the command:
996 \begin{verbatim}
997 > help workspace
998 \end{verbatim}
999
1000 gives the following result:
1001 \begin{verbatim}
1002 Complex Black Box <user::workspace>
1003  User's workspace
1004  By : bbtk
1005  Category(s): complex box;
1006  * No inputs
1007  * No outputs
1008  * Boxes : 
1009     'a' <std::Add>
1010 \end{verbatim}
1011
1012 This means that the user's workspace now contains a black box named \texttt{a},
1013 of type \texttt{std::Add}. If you type:
1014 \begin{verbatim}
1015 > help workspace
1016 \end{verbatim}
1017
1018 You get information about the actual instance \texttt{a} of the box type \texttt{std::Add}. It gives something like this:
1019 \begin{verbatim}
1020 > help a
1021  Black Box 'a' <std::Add>
1022   * Inputs : 
1023      'BoxExecute'     = '? (no adaptor found)'  [Modified]
1024      'BoxProcessMode' = 'Pipeline'              [Modified]
1025      'In1'            = '0'                     [Modified]
1026      'In2'            = '0'                     [Modified]
1027   * Outputs : 
1028      'BoxChange'      = '? (no adaptor found)'  [Out-of-date]
1029      'Out'            = '0'                     [Out-of-date]
1030 \end{verbatim}
1031 Note that the inputs appear as \texttt{[Modified]}, since the code defining the box type includes an initialization of the inputs. On the other hand, the outputs appear as \texttt{[Out-of-date]}, as the box has not yet been executed and therefore its outputs have not been updated. See the second part of this section to learn more about the updating. For a moment, just note that one way to process the box \texttt{a} is to use the command:
1032 \begin{verbatim}
1033 > exec a
1034 \end{verbatim}
1035
1036 This command does not display anything (except if the 
1037 box itself displays something in its processing).
1038 It just processes the box if needed. In our case, the result can be seen as follows:
1039 \begin{verbatim}
1040 > exec a
1041 > help a
1042  Black Box 'a' <std::Add>
1043   * Inputs : 
1044      'BoxExecute'     = '? (no adaptor found)'  [Up-to-date]
1045      'BoxProcessMode' = 'Pipeline'              [Up-to-date]
1046      'In1'            = '0'                     [Up-to-date]
1047      'In2'            = '0'                     [Up-to-date]
1048   * Outputs : 
1049      'BoxChange'      = '? (no adaptor found)'  [Up-to-date]
1050      'Out'            = '0'                     [Up-to-date]
1051 \end{verbatim}
1052 Note the change of status of all the inputs and outputs (\texttt{[Up-to-date]}).
1053 In practice, the command \texttt{exec} is useful to execute boxes that do not have any output,  
1054 such as boxes that write something to a file or, display a 
1055 graphical interface, and so on.
1056
1057 Now, let us set the input \texttt{In1} 
1058 of the \texttt{Add} box \texttt{a} to the value $3.5$ 
1059 by the command:
1060 \begin{verbatim}
1061 > set a.In1 3.5 
1062 \end{verbatim}
1063
1064 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $4.3$
1065 is done with:
1066 \begin{verbatim}
1067 > set a.In2 4.3
1068 \end{verbatim}
1069  
1070 And you print the output \texttt{Out} of the box \texttt{a} with:
1071 \begin{verbatim}
1072 > print "result=$a.Out$"
1073 result=7.8
1074 \end{verbatim}
1075
1076 In the string passed to the \texttt{print} command, 
1077 each substring enclosed between a couple of \$ is considered 
1078 as the name of an output of a box. 
1079 To process these special substrings, the interpreter:
1080 \begin{enumerate}
1081 \item Processes the box if needed (see below)
1082 \item Converts the output of the box to a string if possible 
1083 (see below)
1084 \item Substitutes the result in the string to print
1085 \item Places an implicit 'new line' character after the string
1086 \end{enumerate}
1087
1088 %\paragraph
1089
1090 Box processing is needed if:
1091
1092 \begin{itemize}
1093 \item either at least one input has changed since last processing 
1094 \item or the input \texttt{'BoxProcessMode'} of the box is set to 
1095 \texttt{'Always'}, which forces box reprocessing. 
1096 \end{itemize}
1097
1098 Note that all boxes have an input named \texttt{'BoxProcessMode'}. \newline
1099
1100 %To exit \bbi, type :
1101 %\begin{verbatim}
1102 %> quit
1103 %Good bye !
1104 %\end{verbatim}
1105
1106
1107
1108 % ==========================================
1109 \hrule
1110
1111 \paragraph{Summary}
1112 %\hrule
1113 \begin{itemize}
1114 \item The \texttt{include} command allows to load a package, and the complex black boxes that come with it.
1115 \item \texttt{help} gives help on:
1116 \begin{itemize} 
1117 \item Available commands if you just type \texttt{help}.
1118 \item A particular command if you type \texttt{help <command-name>}.
1119 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
1120 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
1121 \item A particular black box type (with full description) if you type \texttt{help <box-type-name>}. In particular, \texttt{help workspace} displays information on the content of the \texttt{'workspace'} black box, which stores the boxes created by the user (by \texttt{new}).
1122 \item A particular black box instance (with full description, as well as the values and the status of the inputs/outputs) if you type \texttt{help <box-name>}.
1123 \end{itemize}
1124 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
1125 \item \texttt{new}: creates an instance of a black box. 
1126 \item \texttt{set}: sets the value of an input of a black box. 
1127 \item Under any component of  \bbStudions, to reference the input called \texttt{i} 
1128 of a black box called \texttt{b} you must type \texttt{'b.i'}. 
1129 The same syntax holds for outputs.
1130 \item \texttt{print}: prints a string, substituting each substring of the form \$b.o\$ by the value of the output \texttt{o} of the black box \texttt{b}. Note that an
1131 implicit trailing 'new line character' is added at the final string.
1132 \item \texttt{exec}: runs, if needed, the process of a box. 
1133 %\item \texttt{quit}: quits \bbi.
1134 \end{itemize}
1135 \hrule
1136
1137 %\paragraph{Note :}
1138 %A more 'modern' way to proceed is to run \texttt{bbStudio}, drag and drop the  \texttt{Command} bookmark to the lower \texttt{Welcome to bbStudio!} bar.
1139 %Wou'll get something like in figure \ref{bbCommandPlusHelp}:
1140
1141 %\begin{figure}[!ht]
1142 %\caption{\label{bbCommandPlusHelp}
1143 %An other way to run the command interpreter}
1144 %\begin{center}
1145 %\includegraphics[width=0.5\textwidth]{bbCommandPlusHelp.png}
1146 %\end{center}
1147 %\end{figure}
1148
1149 % ==========================================
1150
1151 % ==========================================
1152 \subsection{Connecting black boxes}
1153 \label{bbi-connecting-black-boxes}
1154 % ==========================================
1155
1156 \BBTK allows to create 
1157 and execute processing chains, 
1158 also called \emph{pipelines}, 
1159 by connecting black boxes.
1160 This section explains how to do it with examples. 
1161 Read section \ref{bbi-deep-box} to get 
1162 more information on pipeline processing.
1163
1164 First start \bbStudio and load the package \texttt{std}, i.e. type in the 'Command' part the following command:
1165 \begin{verbatim}
1166 > include std
1167 \end{verbatim}
1168
1169 Assume you want to compute a sum of three numbers (e.g. $1+2+3$). You can do it by 
1170 chaining two \texttt{Add} boxes, as shown in figure 
1171 \ref{bbi-fig-connecting-black-boxes-1}. 
1172
1173 \begin{figure}[!ht]
1174 \caption{ A simple pipeline that adds 3 numbers}
1175 \begin{center}
1176 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
1177 \end{center}
1178 \label{bbi-fig-connecting-black-boxes-1}
1179 \end{figure}
1180
1181 The \bbs instructions to create and execute this pipeline are :
1182 \begin{verbatim}
1183 > new Add a
1184 > new Add b
1185 > connect a.Out b.In1
1186 > set a.In1 1
1187 > set a.In2 2
1188 > set b.In2 3
1189 > print $b.Out$
1190 \end{verbatim}
1191
1192 The first three commands build the pipeline, 
1193 the next three set \texttt{a} and \texttt{b} black boxes' inputs and the last one 
1194 prints the output of the black box \texttt{b}. The pipeline is executed before printing, because the interpreter 'knows' that the box \texttt{b}, the output of which is requested, is not up to date.
1195  
1196 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output 
1197 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the 
1198 box \texttt{b}. 
1199 Once the boxes are connected, the processings of the two boxes are chained:
1200 getting the output of \texttt{b} requires getting its inputs, 
1201 hence getting the output of \texttt{a} which is connected to it. 
1202 This pipeline mechanism can recurse into arbitrarily long 
1203 chains of boxes (see \ref{bbi-deep-box} 
1204 for details).
1205
1206 Let us consider another, more image-oriented, example :
1207
1208 \begin{verbatim}
1209 > include vtk
1210 > include wx
1211 > include itk
1212 > include wxvtk
1213 > include itkvtk
1214
1215 > new FileSelector fileDialog
1216 > new ImageReader  reader 
1217 > new Viewer2D     viewer
1218
1219 > connect fileDialog.Out   reader.In 
1220 > connect reader.Out       viewer.In
1221
1222 > exec viewer
1223 \end{verbatim}
1224
1225 Some explanations: 
1226 \begin{itemize}
1227         \item The \texttt{include} instructions load the necessary packages.
1228         \item \texttt{FileSelector} will pop, at run time, a File Selector dialog box that will output the user-selected file name.
1229         \item \texttt{ImageReader} will read any itk readable file, the name of which is passed as a std::string, and return a pointer on an itk image.
1230         \item \texttt{Viewer2D} will display a two-dimensional image.
1231         \item \texttt{connect fileDialog.Out   reader.In} plugs the output of the File Selector (a \texttt{std::string}) to the input of the Image Reader (a \texttt{std::string}, too).
1232         \item \texttt{connect reader.Out       viewer.In} plugs the output of the Image Reader \\(a \texttt{bbtk::any<bbitk::ImagePointer>} which is a type defined by the
1233 itk package, and which can hold any itk image pointer) to the input of the Viewer (a \texttt{vtkImageData *})
1234         \item \texttt{exec viewer} processes the Viewer.
1235 \end{itemize}
1236
1237 This would correspond to the graph in figure \ref{bbi-verysimplegraph}.
1238
1239 \begin{figure}[!ht]
1240 \caption{\label{bbi-verysimplegraph}(Very) simple Graph of a (very) simple pipeline}
1241 \begin{center}
1242 \includegraphics[width=0.8\textwidth]{bbi-verysimplegraph.png}
1243 \end{center}
1244 \end{figure}
1245    
1246 Of course, to be able to connect two boxes, 
1247 the output and the input must be compatible. 
1248 You can always connect an output to an input of the \emph{same} type, 
1249 but you can do more, thanks to particular (hidden) black boxes called {\bf adaptors}.
1250
1251 An adaptor is a black box that has at least one input, called \texttt{In}, 
1252 and at least one output called \texttt{Out} and the role of which is to convert 
1253 a data of the type of \texttt{In} 
1254 into a data of the type of \texttt{Out} (other inputs or outputs may serve 
1255 to parameter the adaptor or retrieve other useful information). In the example above the appropriate adaptor that converts \texttt{bbtk::any<bbitk::ImagePointer>} into \texttt{vtkImageData *} is provided in the package \texttt{itkvtk}.
1256
1257 Most of the useful standard adaptors are provided in the package \texttt{std}. Under \bbStudions, if you type :
1258 \begin{verbatim}
1259 > load std
1260 > help std all
1261 \end{verbatim}
1262 you get :
1263 \begin{verbatim}
1264  Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
1265  Basic useful black boxes
1266  Black boxes : 
1267    ASCII                     : ascii codes sequence to string - ...
1268    Add                       : Adds its inputs
1269    BoolToString        [DA]  : Converts a Bool (bool) into a string
1270    CastBoolToChar      [DA]  : Static cast from Bool (bool) to ...
1271    CastBoolToDouble    [DA]  : Static cast from Bool (bool) to ...
1272       ...
1273    CastBoolToUChar     [DA]  : Static cast from Bool (bool) to ...
1274    CastBoolToUInt      [DA]  : Static cast from Bool (bool) to ...
1275       ...
1276    CastUIntToBool      [DA]  : Static cast from UInt (unsigned ...
1277    CastUIntToChar      [DA]  : Static cast from UInt (unsigned ...
1278    CastUIntToDouble    [DA]  : Static cast from UInt (unsigned ...
1279       ...      
1280
1281 \end{verbatim}
1282
1283 In this long list you find many items marked \texttt{[DA]}, which stands for \emph{default adaptor}.
1284
1285 Once you have loaded the package \texttt{std}, you can 
1286 plug an output of type \texttt{char} into an input of type \texttt{double}. 
1287 When the interpreter encounters the \texttt{connect} command, 
1288 it looks for an adequate \emph{adaptor} in the  loaded packages. 
1289 In our case, as the package \texttt{std} provides the 
1290 \texttt{CastUCharToDouble} adaptor, the interpreter automatically creates an 
1291 instance of this adaptor and places it \emph{between} 
1292 the output and the input you want to connect 
1293 (however this adaptor is hidden to you, 
1294 it is embedded into the created connection and does not appear 
1295 as an existing black box). 
1296 When the pipeline is processed the 
1297 adaptor converts the output data into the required input type, 
1298 in a totally transparent way.
1299 In our example, the \texttt{CastUCharToDouble} adaptor 
1300 would simply cast the value of the \texttt{char} into a \texttt{double}, 
1301 however arbitrarily complex type conversion may be done.\\
1302 \texttt{WARNING}: these adaptors are \texttt{C++ static cast}, i.e., there is, right now,
1303  no 'intelligent' conversion (only truncation) e.g. think of \texttt{CastDoubleToUChar}!
1304
1305 %\begin{verbatim}
1306 %Question (for info-dev): 
1307 %if two adaptors with the same input and output types exist 
1308 %in two different packages, currenly loaded, 
1309 %which one is chosen by the interpreter at connection time?
1310 %A feature is missing to specify explicitely which one user wants to choose 
1311 %(use a namespace notation ?)
1312
1313 %-> Role of default adaptors
1314 %\end{verbatim}
1315
1316 Note that the \texttt{set} and \texttt{print} commands of interpreter 
1317 work with adaptors from \texttt{string} to the type of the input to set 
1318 or from the type of the output to print to \texttt{string}. 
1319 Hence in order to \texttt{set} or \texttt{print} values the adequate 
1320 adaptors must be available in the packages currently loaded. \\
1321
1322
1323 % ==========================================
1324 \hrule
1325 \paragraph{Summary}
1326 %\hrule
1327 \begin{itemize}
1328 \item The \texttt{connect} command allows to connect two black boxes
1329 \item You can connect two black boxes if (and only if): 
1330 \begin{itemize}
1331 \item The output and the input are of the same type, or
1332 \item There is an adaptor black box in the packages loaded which 
1333 converts data of the output type into data of the input type
1334 \end{itemize}
1335 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use: \texttt{help <package name> all}
1336 including adaptors.
1337 \end{itemize}
1338 \hrule
1339 % ==========================================
1340
1341 % ==========================================
1342 \subsection{Writing scripts files}
1343 \label{bbi-writing-scripts}
1344 % ==========================================
1345
1346 Now that you know how to connect the existing black boxes, you will soon realize that you want to save and reuse some sequences of commands that you are particularly glad of. In the following subsections you will learn how to write ``simple'' pipeline applications and new complex black boxes built of existing black boxes. 
1347
1348 % ==========================================
1349 \subsubsection{Stand-alone pipeline applications}
1350 \label{sec:pipeline-appli}
1351 % ==========================================
1352
1353 Let us take an example similar to that from section \ref{bbi-connecting-black-boxes}:
1354
1355 \begin{verbatim}
1356 > include vtk
1357 > include wx
1358 > include itk
1359 > include wxvtk
1360 > include itkvtk
1361
1362 > new DirectorySelector dirSelect
1363 > new DICOMDirReader  reader 
1364 > new Slider     slider
1365 > new Viewer2D     viewer
1366
1367 > connect dirSelect.Out   reader.In 
1368 > connect reader.Out       viewer.In
1369 > connect slider.Out   viewer.Slice 
1370 > connect slider.BoxChange viewer.BoxExecute
1371 > set slider.ReactiveOnTrack 1
1372
1373 > exec viewer
1374 \end{verbatim}
1375
1376 This is an elementary DICOM-image slicer (fig.~\ref{fig:simpleslicer}) designed to view 3D medical images slice-by-slice. The  image is to be composed of a series of DICOM files contained in a separate directory. The index of the slice to be displayed is selected by means of a slider. The command  \texttt{connect slider.BoxChange viewer.BoxExecute} permits the Viewer to update the display every time the output of the Slider changes. The command \texttt{set slider.ReactiveOnTrack 1} on its turn makes that the output of the Slider changes every time its cursor is moved, while the default behavior is to change only when the mouse-button is released after moving the cursor.\\
1377
1378 \begin{figure}[!ht]
1379 \caption{ Graph of a (very) simple 3D slicer}
1380 \begin{center}
1381 \includegraphics[width=0.8\textwidth]{bbi-simplegraph.png}
1382 \end{center}
1383 \label{fig:simpleslicer}
1384 \end{figure}
1385    
1386 Despite its simplicity, this application may already be useful. If you want to reuse it, you have to save the \bbs commands in a text file. The conventional (and mandatory) extension for such script files is \texttt{bbs} 
1387 (black box script). For example, our elementary 3D DICOM-image slicer 
1388 can be defined in the following file:
1389
1390 \begin{file}{my\_slicer.bbs}
1391 \begin{verbatim}
1392 # my_slicer.bbs: elementary 3D image slicer"
1393 /*
1394  the 3D image has to be stored in a separate directory
1395  as a series of DICOM files representing the 2D slices 
1396 */
1397
1398 include vtk
1399 include wx
1400 include itk
1401 include wxvtk
1402 include itkvtk
1403
1404 new DirectorySelector dirSelect
1405 new DICOMDirReader reader 
1406 new Slider       slider
1407 new Viewer2D     viewer
1408
1409 connect dirSelect.Out   reader.In 
1410 connect reader.Out       viewer.In
1411 connect slider.Out       viewer.Slice
1412 connect slider.BoxChange viewer.BoxExecute
1413 set slider.ReactiveOnTrack 1
1414
1415 exec viewer
1416 \end{verbatim}
1417 \end{file}
1418
1419 Lines starting with a \texttt{\#} character or with double slash (\texttt{\//\//}) are ignored, they 
1420 are considered as comments by the interpreter. A longer comment can be placed between the marks \texttt{\//*} and \texttt{*\//}. Each of this mark is to be placed alone in a separate line, like in the example.\par
1421
1422 To use this file in \bbStudions, click on the \texttt{include} button, and browse your filestore to find the file. You can also type the command:
1423
1424 \begin{verbatim}
1425 > include my_slicer.bbs
1426 \end{verbatim}
1427
1428 provided that \bbStudio knows the path to the desired \texttt{bbs} file.
1429 See the section \ref{The_configuration_file} to learn about the configuration file and the way to add a new path to it. Note that, if you modify the configuration file, you will have to close \bbStudio and run it again, so that the new configuration be taken into account.
1430
1431 Actually, since the file has the \texttt{bbs} extension, you can omit it and just type:
1432 \begin{verbatim}
1433 > include my_slicer
1434 \end{verbatim}
1435
1436 % ==========================================
1437 \hrule
1438
1439 \paragraph{Summary}
1440 %\hrule
1441 \begin{itemize}
1442 \item The \texttt{include} command tells the interpreter to include a script file.
1443 \item Lines starting with \texttt{\#} or \texttt{\//\//} are considered as comments by the interpreter.
1444 \item A longer comment can be written between two empty lines only containing \texttt{\//*} and \texttt{*\//} respectively.
1445 \end{itemize}
1446
1447 \hrule
1448 % ==========================================
1449
1450 % ==========================================
1451 \subsubsection{Creating complex black boxes}
1452 \label{bbi-complex-black-boxes}
1453 % ==========================================
1454
1455 Remind the pipeline of figure 
1456 \ref{bbi-fig-connecting-black-boxes-1}, which 
1457 computed the sum of three doubles.
1458 You can consider it as a whole and define 
1459 a new black box type, which will be a \emph{complex black box}, 
1460 having three inputs and one output, 
1461 as shown in figure \ref{bbi-fig-complex-black-box-1}.
1462
1463 \begin{figure}[!ht]
1464 \caption{\label{bbi-fig-complex-black-box-1} Creating the complex black box \texttt{Add3}}
1465 \begin{center}
1466 \includegraphics[width=0.5\textwidth]{Add3.png}
1467 \end{center}
1468 \end{figure}
1469
1470 The \bbs script file defining this complex black box will be as follows:
1471
1472 \begin{verbatim}
1473 # bbAdd3.bbs: defines the Add3 black box which adds 3 doubles 
1474 load std
1475
1476 define Add3
1477   author "myself"
1478   description "adds 3 doubles"
1479   category "example"
1480   category "misc"
1481   # Pipeline creation
1482   new Add a
1483   new Add b
1484   connect a.Out b.In1
1485   # Inputs definition
1486   input x a.In1 "first double to add
1487   input y a.In2 "second double to add
1488   input z b.In2 "third double to add"
1489   # Output definition
1490   output result b.Out "output"
1491 endefine
1492 \end{verbatim}
1493
1494 Explanations:
1495 \begin{itemize}
1496         \item As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in the first line.
1497         \item The command \texttt{define} then starts the definition 
1498 of the complex box type that will be called \texttt{Add3}. 
1499         \item The next three lines define the pipeline, 
1500 exactly in the same way as outside of a complex box definition. 
1501         \item The commands \texttt{author}, \texttt{description}, \texttt{input} 
1502 and \texttt{output} are specific to complex boxes definition:
1503         \begin{itemize}
1504                 \item \texttt{author}, \texttt{description} and \texttt{category} are used for the documentation of the new box. You can provide multiple \texttt{author} or \texttt{description} commands, the arguments of the commands will be concatenated to produce the final author and description strings. As for multiple \texttt{category} commands, each of them produces a separate entry for the documentation.
1505                 \item \texttt{input} and \texttt{output} are used to define the inputs and outputs 
1506 of the new complex box. Their syntax is the same: for each new input/output you need to say 
1507 to which internal input/output it corresponds and to provide 
1508 a help string documenting the input/output.
1509 In our example, we define that the box \texttt{Add3} has 
1510 three inputs: \texttt{x}, \texttt{y} and \texttt{z}. 
1511 The input \texttt{x} corresponds to the input \texttt{In1} of the 
1512 internal box \texttt{a}. 
1513 In the same way, the external input \texttt{y} 
1514 corresponds to the internal input \texttt{a.In2}, and 
1515 the external input \texttt{In3} to \texttt{b.In2}. 
1516 The only output of the new box is called \texttt{result}
1517 and corresponds to \texttt{b.Out}. 
1518 The figure \ref{bbi-fig-complex-black-box-1} 
1519 illustrates the external to internal 
1520 input/output correspondence.
1521         \end{itemize}
1522         \item Finally, the \texttt{endefine} command ends the definition of the 
1523 new box type.
1524 \end{itemize}
1525
1526 If you type the command \texttt{include bbAdd3} and then you ask for help 
1527 on the contents of the \texttt{user} package, you get:
1528
1529 \begin{verbatim}
1530 > help user
1531  Package user - internal
1532  User defined black boxes
1533  Black boxes : 
1534    Add3       : adds three numbers
1535    workspace  : User's workspace
1536 \end{verbatim}
1537
1538 The \texttt{user} package now contains a new black box type, called 
1539 \texttt{Add3}. If you ask for help on this type of box, you get:
1540 \begin{verbatim}
1541 > help Add3
1542 Complex Black Box <user::Add3>
1543  adds 3 doubles
1544  By : myself
1545  Category(s) : complex box;example;misc;
1546  * Inputs : 
1547     'x'      <double> [] : first double to add
1548     'y'      <double> [] : second double to add
1549     'z'      <double> [] : third double to add
1550  * Outputs : 
1551     'result' <double> [] : output
1552  * Boxes : 
1553     'a' <std::Add>
1554     'b' <std::Add>
1555 \end{verbatim}
1556
1557 and you can use it like any other box, for example:
1558
1559 \begin{verbatim}
1560 > new Add3 a
1561 > set a.x 1
1562 > set a.y 2
1563 > set a.z 3
1564 > print $a.result$
1565 6
1566 \end{verbatim}
1567
1568 As a side note, we can say that, for consistency reasons, it would have been better to name  
1569 \texttt{In1}, \texttt{In2} and \texttt{In3} the inputs of the black box \texttt{Add3}. Indeed, 
1570 by convention all the 'natural entries' of a box are named \texttt{In}, or \texttt{In}\emph{x} if there is more than one 'natural entry'.
1571 \newline
1572 % ==========================================
1573 \hrule
1574 \paragraph{Summary}
1575 %\hrule
1576 \begin{itemize}
1577         \item The \texttt{define/endefine} commands allow to define complex black box types, i.e. types of black boxes made up of other black boxes. 
1578 Inside a \texttt{define/endefine} block:
1579         \begin{itemize}
1580                 \item the \texttt{author}, \texttt{description} and \texttt{category} commands allow to document the new type of box,
1581                 \item the \texttt{input} and \texttt{output} commands allow to define the inputs and outputs of the new type of box, that is to which inputs and outputs 
1582 of internal boxes they correspond.  
1583         \end{itemize}
1584 \end{itemize}
1585 \hrule
1586 % ==========================================
1587
1588 % ==========================================
1589 \subsubsection{Creating complex black boxes that use complex black boxes}
1590 \label{bbi-complex-complex-black-boxes}
1591 % ==========================================
1592
1593 Of course, you can include script files in other script files, 
1594 like in the following example:
1595
1596 \begin{file}{bbAdd4.bbs}
1597 \begin{verbatim}
1598 # Defines the Add4 black box which adds 4 doubles 
1599 include bbAdd3
1600
1601 define Add4
1602   author "myself"
1603   description "adds 4 doubles"
1604   new Add3 a
1605   new Add b
1606   connect a.result b.In1
1607   input In1 a.x "first double to add
1608   input In2 a.y "second double to add
1609   input In3 a.z "third double to add"
1610   input In4 b.In2 "fourth double to add"
1611   output Out b.Out "output"
1612 endefine
1613 \end{verbatim}
1614 \end{file}
1615
1616 Here we kept the \texttt{bbAdd3.bbs} file unchanged, so the inner box of type \texttt{Add3} \texttt{a} has the entries \texttt{x, y, z}, while the entries of the inner box \texttt{b} of type \texttt{Add} are \texttt{In1, In2}.\\
1617 Only the inputs \texttt{x, y, z} of box the \texttt{a} and the input \texttt{In2} of the box \texttt{b} are of interest for the end user, but he/she does not need to care neither about the inner boxes name, nor about the names of their inputs.\\
1618 The author of the complex box has the ability to give these inputs meaningful names (here \texttt{In1, In2, In3, In4}) and to properly document them.
1619
1620 \subsubsection{Naming Conventions}
1621 \label{bbi-Naming Conventions}
1622
1623
1624 % ==========================================
1625 %\hrule
1626 %\paragraph{Naming Conventions}
1627 %\hrule
1628
1629 %\hrule
1630 % ==========================================
1631 \begin{itemize}
1632 \item
1633 File names : 
1634 For consistency reasons, you are requested to prefix \texttt{bb} and place an extension \texttt{.bbs},
1635 to the names of the files that hold a \texttt{complex black box} definition.
1636
1637 For example, the \texttt{Add3} complex box we previously worked on 
1638 can be defined in the \texttt{bbAdd3.bbs} file.
1639 \item
1640 Search Paths :
1641 For consistency reasons, the names of dynamic libraries holding the packages start by \texttt{bb}.
1642 For instance, the package \texttt{wx} will be in the library \texttt{bbwx.dll} (Windows) or \texttt{libbbwx.so}
1643 (Linux).
1644
1645
1646 \end{itemize}
1647
1648 % ==========================================
1649 \subsubsection{Creating and using command-line applications}
1650 \label{bbi-command-line-app}
1651 % ==========================================
1652
1653 Command-line applications are those that can be executed by typing, in a console, the name of the application and the values of its parameters. The Linux users are very familiar with this way of working, while the Windows users are not, since they are used to execute the applications by clicking on the corresponding icons. Nevertheless, the command-line execution of the applications is feasible (although not very useful) in Windows. You just need to invoke the black ``console'' available either via \texttt{Start > Execute > cmd}, or via \texttt{Start > Programs > Accessories > Invoke commands}. Furthermore, command-line execution of applications is very useful in both environments in such cases as batches.
1654
1655 You already know how to write script files that define stand-alone pipeline applications.
1656 In fact, these applications \emph{can} be executed directly from the console by typing: 
1657 \begin{verbatim}
1658 > bbi <application-name>
1659 \end{verbatim}
1660 Note that this execution mode invokes the interpreter \texttt{bbi} and passes the name of the application to the interpreter.
1661
1662 So, what more do you need to know? A command-line application may need some inputs. In order to define them, you need to use the (already known) command \texttt{input}.
1663
1664 To understand the underlying mechanism let us think back of the \texttt{workspace} object. 
1665 Remember that it is also 
1666 a \texttt{complex black box}. 
1667 Actually, when you write \bbs commands 
1668 outside of a \texttt{define/}\texttt{endefine} block, 
1669 you progressively define the \texttt{workspace} 
1670 complex black box.
1671 You can think of it as though at start the interpreter
1672 was issuing a command \texttt{'define workspace'} 
1673 and then letting you define the interior of the box 
1674 \texttt{workspace}.
1675
1676 Remember that the command \texttt{input} 
1677 allows to define an input of a complex box. 
1678 Now, if you use the command \texttt{input} 
1679 outside a \texttt{define/endefine} block then 
1680 it defines an input of the \texttt{workspace} box, 
1681 that is an input of the \emph{main program}. 
1682 This input will then be connected to the 
1683 parameters that the user passes to the command line.
1684
1685 For example, consider the script: 
1686
1687 \begin{file}{add.bbs}
1688 \begin{verbatim}
1689 load std
1690 new Add a
1691 input x a.In1 "first number to add"
1692 input y a.In2 "second number to add"
1693 print "x+y=$a.Out$"
1694 \end{verbatim}
1695 \end{file}
1696
1697 The third and fourth lines define two inputs \texttt{x} 
1698 and \texttt{y}. When you execute this script, 
1699 you can pass these two arguments in the command-line, 
1700 like this:
1701
1702 \begin{verbatim}
1703 > bbi add x=1 y=1
1704 x+y=2
1705 \end{verbatim}
1706
1707 You can also note that, in the command-line context, you can invoke \bbi with the option \texttt{-h}, 
1708 which gives help on the \texttt{workspace} box:
1709
1710 \begin{verbatim}
1711 > bbi add -h
1712  User's workspace
1713  By : bbi (internal)
1714  * Inputs : 
1715     'x' <double> : first number to add
1716     'y' <double> : second number to add
1717 \end{verbatim}
1718
1719 This is particularly useful to learn about the usage of the application, namely about the inputs that are to be set at execution. To improve the help provided, use the \texttt{description}, \texttt{author} and \texttt{category} commands at the beginning of the script file defining the application:
1720 \\
1721 \\
1722 \begin{file}{add.bbs}
1723 \begin{verbatim}
1724 description "Adds two numbers"
1725 author "foo@bar.com"
1726 category "example;math"
1727 load std
1728 new Add a
1729 input x a.In1 "first number to add"
1730 input y a.In2 "second number to add"
1731 print "x+y=$a.Out$"
1732 \end{verbatim}
1733 \end{file}
1734
1735 Note that (at least for the moment and contrary to the definition of complex black boxes) you cannot use here multiple \texttt{description}, \texttt{author} and \texttt{author} commands. If the application belongs to several categories, you have to write a single string listing the categories separated by semi-colons, like in the example above. Now if you ask for help on the \texttt{add} script, you get :
1736
1737 \begin{verbatim}
1738 > bbi add -h
1739  Adds two numbers
1740  By : foo@bar.com
1741  Category(s) : example;math;
1742  * Inputs : 
1743     'x' <double> : first number to add
1744     'y' <double> : second number to add
1745 \end{verbatim}
1746
1747 Rather than getting the inputs of a script 
1748 from the command line, you can ask \bbi to 
1749 prompt the user for the values, using the \texttt{-t}
1750 commutator :
1751
1752 \begin{verbatim}
1753 > bbi add -t
1754 x=[the program waits for user answer]2
1755 y=[the program waits for user answer]5
1756 x+y=7
1757 \end{verbatim}
1758
1759 You can also use the \texttt{-g} commutator. 
1760 \bbi then prompts the user in graphical mode, 
1761 displaying a dialog box for each input,
1762 like in fig. \ref{bb-input-dialog-box}.
1763
1764 \begin{figure}[!ht]
1765 \caption{\label{bb-input-dialog-box}Input dialog box}
1766 \begin{center}
1767 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1768 \end{center}
1769 \end{figure}
1770
1771 Note that for both \texttt{-t} and \texttt{-g} options, 
1772 the input from the user is a \texttt{string} and 
1773 \bbi converts it to the right input type using 
1774 an \texttt{adaptor}, hence the right adaptors must be previously loaded.
1775
1776 % ==========================================
1777 \hrule
1778 \paragraph{Summary}
1779 %\hrule
1780 \begin{itemize}
1781 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1782 when they are used outside a \texttt{define/endefine} block allow 
1783 to define the inputs, description and author of the main program.
1784 \item Inputs of the main program can be passed on the command line 
1785 using the syntax \texttt{<input-name>=<value>}. 
1786 No white space is allowed, if the value or the input name 
1787 contains white spaces, enclose them 
1788 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1789 \item The \texttt{-h} option of \bbi prints help on the main program.
1790 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1791 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1792 \end{itemize}
1793 \hrule
1794 % ==========================================
1795
1796 % ==========================================
1797 \subsection{Using graphical interface boxes (widget boxes)}
1798 \label{bbi-widget}
1799 % ==========================================
1800
1801 % ==========================================
1802 %\subsubsection{Overview}
1803 %\label{bbi-overview}
1804 % ==========================================
1805
1806 Basic graphical interface components are provided in the package \texttt{wx}, 
1807 such as buttons, sliders, file open/save dialogs, etc.
1808
1809 As first example, type the following commands in \bbStudio :
1810 \begin{verbatim}
1811 > include wx 
1812 > new DirectorySelector d
1813 > print $d.Out$
1814 \end{verbatim}
1815
1816 When you hit the \texttt{enter} key after the last line, 
1817 the usual directory-selection window pops up.
1818 When you validate your selection, the directory name you selected, preceded by the corresponding path, is printed by 
1819 the \texttt{print} command.
1820 Note that you can determine a default directory by setting the appropriate input as follows:
1821 \begin{verbatim}
1822 > set d.DefaultDir <directory-name>
1823 \end{verbatim}
1824
1825 Now, type \texttt{help wx}, you get something like:
1826 \begin{verbatim}
1827  Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1828  Basic graphical interface elements (sliders, buttons ...) based ...
1829  Black boxes : 
1830    ColourSelector        : Colour Selector dialog (bbfication of ...
1831    ColourSelectorButton  : A button which displays a colour picke...
1832    CommandButton         : Button which executes bbi commands
1833    DirectorySelector     : Pops up a directory selection dialog (...
1834    FileSelector          : Pops up a file selection dialog for re...
1835    InputText             : A zone in which the user can enter a t...
1836    LayoutLine            : LayoutLine widget (wxBoxSizer)
1837    LayoutSplit           : Widget which splits a window in two fi...
1838    LayoutTab             : LayoutTab widget (wxNotebook)
1839    OutputText            : Text zone to be inserted into a window...
1840    RadioButton           : RadioButton group widget 0-9 entries
1841    Slider                : Slider widget (wxSlider)
1842 \end{verbatim}
1843
1844 You can reproduce the same experiment as above using for example
1845 a \texttt{FileDialog} rather than a \texttt{DirectorySelector}. 
1846
1847 If you choose to reproduce the experiment with:\\
1848 \texttt{> new InputText t} (or \texttt{new Slider s}),
1849
1850 you will have to precede the command:\\
1851 \texttt{> print \$t.Out\$} (or \texttt{print \$s.Out\$}) 
1852
1853 by the following command:\\
1854 \texttt{> set t.WinDialog true} (or \texttt{set s.WinDialog true} respectively).
1855
1856 This blocks the pipeline until the widget is closed. Also note that the corresponding widgets do not have a validation button. Therefore, you will have to close them by clicking in the appropriate corner.
1857
1858 %There are two kinds of widgets : ``terminal'' widgets and ``container'' widgets.
1859 %The \texttt{InputText}, \texttt{FileDialog} or \texttt{Slider} widgets 
1860 %are ``terminal'' widgets. 
1861 %``container'' widgets are of another kind : they are 
1862 % ==========================================
1863 %\subsubsection{Layout widgets}
1864 %\label{bbi-layout-widgets}
1865 % ==========================================
1866
1867 There is a special kind of widget, called '\texttt{Layout}', designed to  
1868 contain other widgets in order to build larger dialog boxes. 
1869
1870 For example, the \texttt{LayoutSplit} widget is a container that 
1871 ``splits'' a window into two parts, either horizontally or vertically, 
1872 each part including another widget. 
1873 The initial size of the two parts can be fixed by the input 'Proportion' 
1874 and be adjusted by the user thanks to a ``handle''.
1875
1876 The example \texttt{exampleLayoutSplit} demonstrates its use. 
1877 Run it: it displays a window with two sliders. 
1878 Move the sliders and close the window. 
1879 Now look at the source file to see how this is done:
1880
1881 \begin{file}{CreaTools/bbtk-0.9.1/bbs/wx/appli/exampleLayoutSplit.bbs}
1882 \begin{verbatim}
1883 load wx
1884
1885 new Slider s1
1886 new Slider s2
1887
1888 new LayoutSplit s
1889 connect  s1.Widget s.Widget1
1890 connect  s2.Widget s.Widget2
1891
1892 exec s
1893 \end{verbatim}
1894 \end{file}
1895
1896 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1897 A \texttt{LayoutSplit} box \texttt{s} is also created. 
1898 The \texttt{connect} commands then ``insert'' the sliders in the 
1899 split widget. 
1900 The output \texttt{Widget} is common to all widget boxes: in this way
1901 every widget can be inserted into another widget, provided that the latter has an appropriate input permitting this insertion. 
1902 The inputs \texttt{Widget1}, \texttt{Widget2} of \emph{layout} 
1903 widgets are precisely such special inputs used to ``host'' other widgets.
1904 In \bbStudio type \texttt{help Slider}: 
1905 you will see the output \texttt{Widget}; 
1906 type \texttt{help LayoutSplit}: 
1907 you will see the inputs \texttt{Widget1} and \texttt{Widget2} 
1908 and the output \texttt{Widget}. \\
1909 \emph{Note that the information about the inputs/outputs of widget boxes in html help is displayed in tables having 3 different color cells. From top to bottom you first find the inputs/outputs specific for the given box, then those that are common for all widget boxes, finally those that are common for all black boxes.}\\
1910 When you connect the \texttt{Widget} output of a box  
1911 to the \texttt{Widget}\textit{i} input of a layout widget, 
1912 you order to insert the widget in the layout via its \textit{i}-th special input.
1913 Of course, the order of connection is important. 
1914 In our case, the slider \texttt{s1} is inserted first, 
1915 then the slider \texttt{s2}. So, \texttt{s1} will be placed 
1916 on top of \texttt{s2} (the \texttt{LayoutSplit} box is 
1917 implemented that way, but this is an arbitrary choice).
1918
1919 Right now, there are only \emph{three} layout widgets in the \texttt{wx} package : 
1920 \begin{itemize} 
1921 \item {the \texttt{LayoutSplit} widget} we just described
1922
1923 \item {the \texttt{LayoutLine} widget} can have multiple children 
1924 (\texttt{Widget1}, \texttt{Widget2},{\dots} \texttt{Widget9} inputs) and 
1925 divides its window into as much parts as children, 
1926 each part of equal size. 
1927 The orientation of the \texttt{LayoutSplit} or of the \texttt{LayoutLine} can be changed by the input \texttt{Orientation}.
1928 With only those two layout widgets you can already create 
1929 complex dialog boxes 
1930 (of course layouts can be nested, which leads to tree-like 
1931 structures of widgets). \\
1932 See the script \texttt{exampleComplexLayoutSplit\_In\_LayoutSplit} for an example.
1933
1934 \item {The \texttt{LayoutTab}  widget} arranges its children 
1935 in different pages or 'tabs' (based on \texttt{wxNotebook}).
1936 The label of each page is the name of the widget it contains.
1937
1938 \end{itemize}
1939
1940
1941 %=====> TODO \\
1942
1943
1944 %One word about a special widget in the package \texttt{wx}: 
1945 %the \texttt{Button}... to be continued.
1946
1947 % ==========================================
1948 %\subsection{Deeper into the boxes}
1949 %\label{bbi-deep-box}
1950 % ==========================================
1951 % ==========================================
1952 \subsection{Default and mandatory inputs and outputs}
1953 \label{bbi-deep-box}
1954 % ==========================================
1955
1956 %\subsubsection{Default and mandatory inputs and outputs}
1957 Any {\bf\emph{atomic}} black box has two default inputs and one default output (listed below) that are created by the system. If you create a complex boxes, it is a good idea to also define these two inputs and one output for this new box, in order to be able to use your complex box in the same way as the atomic boxes.
1958 \begin{itemize}
1959         \item Inputs:
1960         \begin{itemize}
1961         \item {\bf\emph{BoxExecute}}: any signal received by this input executes the box.
1962         \item {\bf\emph{BoxProcessMode}}: sets the processing mode of the box:
1963         \begin{itemize}
1964         \item {\bf\emph{Pipeline}}: % bbBackwardUpdate() calls Process() only if Status == MODIFIED \\
1965                                  This is the normal pipeline processing mode, i.e. when an execution of \emph{my\_box} is requested (either by the command '\texttt{exec my\_box}' or because another box dependent on \emph{my\_box}'es output is to be executed), \emph{my\_box} actually executes itself only if at least one of its inputs was changed.
1966         \item {\bf\emph{Reactive}}: %bbSetModifiedStatus() calls bbUpdate() \\
1967                                  \emph{my\_box} re-executes itself immediately when \emph{any input} changes.
1968                                  To be more selective, i.e. if you want to re-execute immediately only when one specific input changes, dependent on the change of a particular \emph{other\_box}, better use 
1969         '\texttt{connect other\_box.BoxChange my\_box.BoxExecute}'.    
1970         \item {\bf\emph{Always}}: % bbUpdate() always calls Process. \\
1971                                  Useful for 'sources', that must be processed in the pipeline mode despite no input change (e.g.: FileSelector, ColorSelector). 
1972                                  This one is not end user intended (for Package developers only).
1973         \end{itemize}   
1974         \end{itemize}
1975         \item Output:
1976         \begin{itemize}
1977         \item {\bf\emph{BoxChange}}: signals any modification of the box. This output may be connected if necessary to the \texttt{BoxExecute} 
1978   input of another box: each time the box changes (e.g. a Slider is moved) the box it is connected to will be forced to update.
1979         \end{itemize}
1980 \end{itemize}
1981
1982 Any {\bf\emph{widget}} box has five \emph{inputs}, that will be dealt with only if the box is not connected to the \texttt{Widget} input of any {\bf\emph{layout}} box. If you define a complex widget box, it is a good idea to define these inputs to be able to customize your window settings. It has also one mandatory \emph{output}. If you define a complex widget box, it is a good idea to use the same standard name for your window output.
1983 \begin{itemize}
1984         \item Inputs:  
1985         \begin{itemize}
1986         \item {\bf\emph{WinHeight}}: Height of the window. 
1987         \item {\bf\emph{WinWidth}}: Width of the window.  
1988         \item {\bf\emph{WinTitle}}: Title of the window.
1989         \item {\bf\emph{WinClose}}: Any signal received by this input closes the window.
1990         \item {\bf\emph{WinHide}}: Any signal received by this input hides the window.
1991         \item {\bf\emph{WinDialog}}: When set to \texttt{true} or $1$, the widget behaves as a \emph{dialog window} that blocks the pipeline until it is closed (\emph{modal}).   
1992         \end{itemize}
1993         \item Output:
1994         \begin{itemize}
1995         \item {\bf\emph{Widget}}: Represents the \texttt{wxWindow} itself. If it is not connected to the \texttt{Widget}\emph{i} of any {\bf\emph{layout}} box, then the box will create its own window (frame or dialog) on execution. If it is connected to the \texttt{Widget}\emph{i} of a {\bf\emph{layout}} box, it will be embedded in its parent window.
1996         \end{itemize}    
1997 \end{itemize}
1998
1999 Any {\bf\emph{layout}} box (i.e. \texttt{LayoutLine}, \texttt{LayoutSplit} or \texttt{LayoutTab}) has one or more mandatory inputs {\bf\emph{Widget}}\texttt{i} indexed by their number \emph{i}, e.g.: a \texttt{LayoutSplit} box (widget that splits a window in two resizable parts) has two inputs \texttt{Widget1} and \texttt{Widget2}, used to embed the child windows. If you define a complex layout box, it is a good idea to use these standard names for your 
2000 sub-windows inputs. 
2001
2002
2003
2004
2005 % ==========================================
2006 %\subsection{More on ...}
2007 %\label{bbi-more-on}
2008 % ==========================================
2009
2010 % ==========================================
2011 %\subsubsection{Black box packages}
2012 %\label{bbi-more-on-packages}
2013 % ==========================================
2014 %There are various others user-intended packages :
2015
2016 %\begin{verbatim}
2017 %---> Were moved in a 'Reference Manual' ?\\
2018 %---> Any suggestion welcome!
2019 %\end{verbatim}
2020
2021 %\begin{itemize}
2022 %\item{vtk} \\
2023 %\item{itk} \\
2024 %\item{...} \\
2025 %\end{itemize}
2026 % ==========================================
2027 %\subsubsection{Pipeline processing}
2028 %\label{bbi-more-on-pipeline-processing}
2029 % ==========================================
2030 %\begin{itemize}
2031 %\item the ``control'' mechanism in bbi.
2032
2033 %When a box is requested to update itself, it asks (recursively) each one of its inputs if it was modified.\\
2034 %In normal pipe-line mode, it will be re-processed if at least one of its imputs was actually modified, as the output of a previous box.
2035
2036 %(switch exec commands, e.g. Button)
2037 %\item the role of ProcessMode to update widgets.
2038 %\end{itemize}
2039
2040 %\subsubsection{Advanced issues}
2041 %\paragraph{Reducing the number of inputs of a box}
2042
2043 % ==========================================
2044 %\subsubsection{Errors}
2045 %\label{bbi-more-on-errors}
2046
2047 % ==========================================
2048
2049
2050 % ==========================================
2051 \vspace{0.5cm}
2052 \hrule 
2053 \newpage
2054 \section{Using third party Packages}
2055 \label{Third_Party_Package}
2056 % ==========================================
2057 % ==========================================
2058 \subsection{Installing a Package}
2059 \label{Installing_a_Package}
2060
2061 % ==========================================
2062 \subsubsection{Linux users}
2063 \label{Installing_a_Package_for_Linux_users}
2064
2065 After compiling a Package, at install time, use:
2066 \begin {verbatim}
2067 su - 
2068 make install
2069 \end{verbatim}
2070
2071 and neither:
2072 \begin {verbatim}
2073 su 
2074 make install
2075 \end{verbatim}
2076
2077 nor:
2078 \begin {verbatim}
2079 sudo make install
2080 \end{verbatim}
2081
2082 otherwise package documentation will not be generated. \\
2083
2084 Then update your environment variable LD\_LIBRARY\_PATH (in .bashrc if
2085 you are using bash), to add the path to the shared library
2086 \texttt{libbb\emph{YourNewPackageName}.so}
2087
2088
2089 % ==========================================
2090 \subsubsection{Windows users}
2091 \label{Installing_a_Package_for_Windows_users}
2092 % ==========================================
2093 Think of updating your environment variable LD\_LIBRARY\_PATH to add the path to the dynamic library
2094 \texttt{bb\emph{YourNewPackageName}.dll}
2095
2096 % ==========================================
2097 \subsection{Plugging in a Package}
2098 \label{Plugging_in_a_Package}
2099 % ==========================================
2100
2101 \bbStudio makes it easy for you: in the menu \texttt{Tools} just click on the 
2102 option \texttt{Plug Package}. You will be asked to '\texttt{Select
2103 package directory}'. Browse until you find the install or the build directory,
2104 depending on whether you installed the package or not.
2105
2106 \bbStudio will update the configuration file, generate the 'Package
2107 documentation', and update the 'Boxes Lists'.
2108
2109 You will be able to use the new package just as you did for any other \bbtk
2110 canonical Package.
2111
2112 % ==========================================
2113 \subsection{Hard incorporating of a Package}
2114 \label{Hard_incorporating_of_a_Package}
2115 % ==========================================
2116
2117 If the Package you want to use is supplied in a non standard way (e.g.: you
2118 where given one ore more dynamic libraries (\texttt{.dll} or \texttt{.so}), and/or
2119 one or more directories containing \bbtk scripts (\texttt{.bbs})
2120 you can edit your \bbtk configuration and add the appropriate 
2121 paths, see \ref{The_configuration_file}.
2122
2123 %\end{itemize}
2124 % ==========================================
2125 \subsection{Updating the documentation}
2126 \label{Updating_the_documentation}
2127 % ==========================================
2128 You may add your own boxes (simple boxes, if you are aware enough of \CPP
2129 language, or complex boxes if you are aware enough in \bbtk scripting).
2130
2131 To update the html help of this package,
2132 use the option \texttt{Regenerate package doc} 
2133 in the menu \texttt{Tools} of \texttt{bbStudio}.
2134 You'll be prompted for the Package name. 
2135 Avoid using the \texttt{-a} option (Regenerate all), since it's time consuming.
2136
2137 To update html boxes lists with the new boxes,
2138 use the option \texttt{Regenerate Boxes Lists} 
2139 in the menu \texttt{Tools} of \texttt{bbStudio}.
2140
2141 % ==========================================
2142 \subsection{Using the package}
2143 \label{Using_the_package}
2144 % ==========================================
2145
2146 The only thing you have to do is to \texttt{include} or \texttt{load} the package, 
2147 within a script, or from the \texttt{Command} part, 
2148 and enjoy the black boxes it contains.
2149
2150 % ==========================================%\subsection{Packages you'll probably want to use }
2151 %\label{Packages_you_ll_want_to_use}
2152 % ==========================================
2153 %\begin {itemize}
2154 %\item{\texttt{creaLib}} \\
2155 %a.k.a \texttt{crea}. It's a set of 'low level' utilities, needed by other
2156 %packages (an, sure,  useful as well for people that doesn't use bbtkns.
2157 %\item{\texttt{creaContours}} \\
2158 %Provides sophisticated widgets for managing 3D R.O.I. (Regions of interest)
2159 %\item{\texttt{creaImageIO}} \\
2160 %Allows browsing, selectionning, ordering directories containing images of almost any type
2161 %(including DICOM)
2162 %\end {itemize}
2163 %\newpage
2164  
2165 % ==========================================
2166 \vspace{0.5cm}
2167 \hrule
2168 \newpage
2169 \section{Using black boxes in \CPP programs}
2170 \label{cpp}
2171 % ==========================================
2172
2173 A very useful feature is that you may use any widget 
2174 black box within a \CPP program 
2175 without worrying about writing a \wx main application.\\
2176
2177 Let us have a look at the following \bbs script:
2178
2179 \begin{verbatim}
2180 # Load the packages
2181 load std
2182 load wx
2183
2184 # Create the Objects
2185 new Slider     slider
2186 new OutputText text
2187 new LayoutLine layout
2188
2189 # Graphical pipeline
2190 connect slider.Widget    layout.Widget1
2191 connect text.Widget      layout.Widget2
2192
2193 # Execution pipeline
2194 connect slider.BoxChange text.BoxExecute
2195 connect slider.Out       text.In
2196
2197 # Go!
2198 exec layout
2199 \end{verbatim}
2200
2201 User wants to create a slider and an output text, within a LayoutLine, 
2202 and display the slider value in the output text.
2203 Think about the (little!) nightmare to code the same, in 'raw C++', using wxWidgets.
2204
2205 The following \CPP code does the same:
2206
2207 \begin{verbatim}
2208 #include <bbtkFactory.h>
2209 #include <bbwxSlider.h>
2210 #include <bbwxOutputText.h>
2211 #include <bbwxLayoutLine.h>
2212
2213 int main(int argv, char* argc[])
2214 {
2215   try
2216     {
2217       /* we need to instanciate a bbtk::Factory 
2218       to be aware of the adaptors*/
2219       
2220       bbtk::Factory::Pointer factory = bbtk::Factory::New();
2221       
2222       // Load the packages
2223       // ----------------  
2224       factory->LoadPackage("std");
2225       factory->LoadPackage("wx");
2226       
2227       // Create the Objects
2228       // ------------------      
2229       bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
2230       bbwx::OutputText::Pointer text = bbwx::OutputText::New("text");
2231       bbwx::LayoutLine::Pointer layout =
2232                                      bbwx::LayoutLine::New("layout");
2233       
2234       // Graphical pipeline
2235       bbtk::Connection::Pointer c1 =
2236              bbtk::Connection::New(slider,"Widget",layout,"Widget1");
2237                                                            
2238       bbtk::Connection::Pointer c2 =
2239                bbtk::Connection::New(text,"Widget",layout,"Widget2");
2240                                                                                                                                                                            
2241       // Execution pipeline
2242       // ------------------
2243       
2244       // We have to pass the 'factory', in order to call
2245       // automatically an adaptor, if necessary.
2246       bbtk::Connection::Pointer s2t =
2247                bbtk::Connection::New(slider,"Out",text,"In",factory);      
2248       bbtk::Connection::Pointer c3 =
2249          bbtk::Connection::New(slider,"BoxChange",text,"BoxExecute");      
2250       layout->bbSetInputWinDialog(true);
2251       
2252       // Go!
2253       // ---     
2254       layout->bbExecute();
2255
2256     }
2257   catch (bbtk::Exception e)
2258     {
2259       bbtk::MessageManager::SetMessageLevel("Error",1);
2260       e.Print();
2261     }
2262 }
2263 \end{verbatim}
2264
2265 In this code, we use the headers of the \texttt{bbwx} \CPP library, 
2266 which define the black boxes of the \texttt{wx} package. 
2267 \vspace{0.5cm}
2268
2269 to be continued ...
2270
2271
2272 % ==========================================
2273 \vspace{0.5cm}
2274 \hrule
2275 \newpage
2276 \section{\bbs language reference}
2277 \label{bbi-reference}
2278 % ==========================================
2279
2280 % ==========================================
2281 \subsection{Pipeline creation and execution related commands}
2282 \label{bbi-reference-creation-execution}
2283 % ==========================================
2284 % See table \ref{bbi-reference-box}
2285
2286 % ==========================================
2287 \begin{table}[!ht]
2288 \caption{\label{bbi-reference-box} \bbs pipeline creation and execution related commands.}
2289 \small
2290 \begin{tabular}{|lcm{6cm}|}
2291 \hline
2292 Command & Parameters & Effect \\ \hline
2293
2294 \texttt{new} & \texttt{<box-type>} \texttt{<box-name>}& 
2295 Creates a box of type \texttt{box-type} and name  
2296 \texttt{box-name}.\\ \hline
2297
2298 \texttt{newgui} & \texttt{<box-name>} \texttt{<gui-box-name>} &
2299 Automatically creates a graphical user interface with name \texttt{gui-box-name}
2300 for the black box \texttt{box-name} and connects it to the box inputs\\ \hline 
2301
2302 \texttt{delete} & \texttt{<box-name>} & 
2303 Destroys the box named \texttt{box-name}\\ \hline 
2304
2305 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} & 
2306 Connects the output 
2307 \texttt{output} of the box named \texttt{box1} 
2308 to the input \texttt{input} of the box named \texttt{box2} \\ \hline 
2309
2310 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
2311 Sets the input \texttt{input} of 
2312 the box named \texttt{box} to the value \texttt{value}.
2313 An \texttt{adaptor} must exist
2314 in the packages loaded, which converts a \texttt{std::string} 
2315 to the type of the input \texttt{input}. \\ \hline 
2316
2317 \texttt{exec} & \texttt{<box-name>} & 
2318 Executes the box named \texttt{box-name}.
2319 If needed the boxes 
2320 connected to its inputs 
2321 are also processed recursively (pipeline processing).\\ \hline 
2322 & \texttt{freeze} & 
2323  Allows to block execution commands while keeping definition commands active (this one is not for end user)\\ \hline 
2324 & \texttt{unfreeze} & 
2325  Turns back to 'normal' mode (this one is not for end user).\\ \hline 
2326 \end{tabular}
2327 \end{table}
2328 % ==========================================
2329
2330 \newpage
2331
2332 % ==========================================
2333 \subsection{Package related commands}
2334 \label{bbi-reference-package}
2335
2336 \begin{table}[!ht]
2337 \caption{\label{tabbbi-reference-package_1}\bbs package related commands. }% (part 1).}
2338 \small
2339 \begin{tabular}{|lcm{6cm}|}
2340 \hline
2341 Command & Parameters & Effect \\ \hline
2342
2343
2344 \texttt{include} & \texttt{<package-name>} & 
2345 Loads the package \texttt{package-name} and includes all its complex box definition scripts. \\ \hline 
2346
2347 \texttt{load} & \texttt{<package-name>} & 
2348 Loads the atomic black boxes of package \texttt{package-name}.
2349 Loads the dynamic library but not the complex boxes defined in the scripts shipped with the package. 
2350 Use it only if you know that you won't work with its complex black boxes \\ \hline 
2351
2352 \texttt{unload} & \texttt{<package-name>}& 
2353 Unloads the package \texttt{package-name}. 
2354 The package must have been previously loaded. 
2355 No box of a type defined in this package must still exist.\\ \hline 
2356
2357 \texttt{reset} & - & Deletes all boxes and unloads all packages so 
2358 that the interpreter gets back to its initial state \\ \hline 
2359
2360
2361 \texttt{package} &  \texttt{<package-name>} &  
2362 All complex black boxes definitions until the next \texttt{endpackage} 
2363 will be stored into the package \texttt{package-name}  \\ \hline 
2364
2365 \texttt{endpackage} & - & 
2366 Closes a \texttt{package} command  \\ \hline 
2367
2368
2369 \end{tabular}
2370 \end{table}
2371 \newpage
2372
2373 % ==========================================
2374 \subsection{Interpreter related commands}
2375 \label{bbi-reference-interpreter}
2376 % ==========================================
2377 %See table \ref{tabbbi-reference-interpreter_1} and \ref{tabbbi-reference-interpreter_2}
2378 % ==========================================
2379 \begin{table}[!ht]
2380 \caption{\label{tabbbi-reference-interpreter_1}\bbs interpreter related commands. }% (part 1).}
2381 \small
2382 \begin{tabular}{|lcm{7cm}|}
2383 \hline
2384 Command & Parameters & Effect \\ \hline
2385
2386
2387 \texttt{help} & - & 
2388 Prints help on available commands \\ \hline 
2389
2390 & \texttt{<command-name>} & 
2391 Prints help on the command \texttt{command-name} \\ \hline 
2392
2393 & \texttt{packages} & 
2394 Prints help on available packages and their box types 
2395 (without description)\\ \hline 
2396
2397 & \texttt{<package-name>} & 
2398 Prints help on the package \texttt{package-name} and its boxes 
2399 (with brief description). 
2400 The package must have been previously loaded \\ \hline 
2401
2402 & \texttt{<box-type>} & 
2403 Prints help (with full description) on the type of box 
2404 \texttt{box-type}. 
2405 The box type must belong to a package which has been previously loaded \\ \hline 
2406
2407 & \texttt{<box-name>} & 
2408 Prints help on the existing box instance named
2409 \texttt{box-name} (i.e. created by \texttt{new} command), including the state of its inputs/outputs \\ \hline 
2410
2411 \texttt{message}
2412 & - & 
2413 Prints information on available kinds of messages and their current level\\ \hline 
2414
2415  & \texttt{<kind>} \texttt{<level>} & 
2416 Sets the level of verbosity of the interpreter for the kind of messages 
2417 \texttt{kind} to \texttt{level}.\\ \hline 
2418
2419
2420 \texttt{include} & \texttt{<file-name>} & 
2421 Includes and executes the content of the file named \texttt{file-name} 
2422 exactly like if you were typing its content at the place were the 
2423 \texttt{include} command is. \\ \hline 
2424
2425 \texttt{print} & \texttt{<string>} & 
2426 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the 
2427 output \texttt{output} of the box named \texttt{box}. 
2428 An \texttt{adaptor} must exist
2429 in the packages loaded, which converts 
2430 the type of the output \texttt{output}
2431 to a \texttt{std::string}.
2432 \\ \hline 
2433
2434 \texttt{graph} & ... & 
2435 Generates the html doc including the pipeline graph for a given complex box \\ \hline
2436
2437 \texttt{index} & ... & 
2438 Generates the html index of currently loaded boxes types \\ \hline
2439
2440 \texttt{config} & - & Displays the configuration parameters\\ \hline 
2441
2442
2443 \texttt{debug} & \texttt{<debug-directive>} & 
2444 [expr|-C|-D] 
2445   Prints debug info on living bbtk objects containing the string \texttt{expr} (default expr=''). 
2446          \texttt{-C} checks the factory integrity.
2447          \texttt{-D} turns on objects debug info after main ends\\ \hline 
2448
2449 \texttt{quit} & - & Stops the interpretation of the current script\\ \hline 
2450
2451 \end{tabular}
2452 \end{table}
2453 % ==========================================
2454
2455 \newpage
2456
2457 % ==========================================
2458 \subsection{Complex black box definition related commands}
2459 \label{bbi-reference-black-box-definition}
2460 % ==========================================
2461
2462 %See table \ref{bbi-reference-complex-box} 
2463 % ==========================================
2464 \begin{table}[!ht]
2465 \caption{\label{bbi-reference-complex-box} \bbs complex black box definition related commands.}
2466 \small
2467 \begin{tabular}{|lcm{6cm}|}
2468 \hline
2469 Command & Parameters & Effect \\ \hline
2470
2471
2472 \texttt{define} & \texttt{<box-type>} [\texttt{<package-name>}] & 
2473 Starts the definition of a complex black box of type
2474 \texttt{box-type}, and includes it either in the given package (if \texttt{<package-name>} is provided) or in the current package, 
2475 i.e. \texttt{user} if outside a \texttt{package/endpackage} block. \\ \hline 
2476
2477 \texttt{endefine} & - & 
2478 Ends the definition of a complex black box type\\ \hline 
2479
2480 \texttt{author} & \texttt{<string>} & 
2481 Concatenates the string to the author string 
2482 of the current complex black box.\\ \hline 
2483
2484 \texttt{description} & \texttt{<string>} & 
2485 Concatenates the string to the description of the current complex black box. 
2486 \\ \hline 
2487
2488 \texttt{category} & \texttt{<string>} & 
2489 Specifies the \texttt{categories} of the current complex black box. 
2490 The categories must be separated by semicolons, e.g. "\texttt{widget;image}"\\ \hline 
2491
2492 \texttt{kind} & \texttt{<box kind>} & 
2493 The following \texttt{kind}s are defined: 
2494
2495 DEFAULT\_ADAPTOR, 
2496 ADAPTOR, DEFAULT\_WIDGET\_ADAPTOR, WIDGET\_ADAPTOR\\ \hline 
2497
2498 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} & 
2499 Defines a new input for the current complex black box, 
2500 named \texttt{name}. 
2501 It is defined as corresponding to 
2502 the input \texttt{input} of the box \texttt{box}.
2503  
2504 \texttt{<help>} is the help string for the new input.
2505 The box \texttt{box} must already have been created in the complex box 
2506 and of course have an input named \texttt{input}.\\ \hline 
2507
2508 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} & 
2509 Defines a new output for the current complex black box, 
2510 named \texttt{name}. 
2511 It is defined as corresponding to 
2512 the output \texttt{output} of the box \texttt{box}. 
2513 \texttt{<help>} is the help string for the new output.
2514 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. \\ \hline 
2515
2516 \end{tabular}
2517 \end{table}
2518
2519 %\newpage
2520 Note : if outside a \texttt{define/endefine} block then the current complex black box 
2521 is '\texttt{user::workspace}', that is the main program equivalent 
2522 (this is how applications are documented).
2523 This remark holds for all complex black box related commands.
2524
2525
2526
2527
2528
2529
2530
2531
2532 % ==========================================
2533 % ==========================================
2534 % ==========================================
2535 % ==========================================
2536 % ==========================================
2537 % ==========================================
2538 % ==========================================
2539 % ==========================================
2540 % ==========================================
2541 % ==========================================
2542 %\hrule
2543 \newpage
2544 \section{Install and run time issues}
2545 % ==========================================
2546
2547
2548
2549
2550 %%==============================================================================================
2551 %%==============================================================================================
2552 \subsection{\bbtk configuration file}
2553 \label{The_configuration_file}
2554 %%==============================================================================================
2555 %%==============================================================================================
2556
2557 At start, \bbtk applications (\bbStudio, \bbi) try 
2558 to open an \texttt{xml} 
2559 configuration file named \texttt{bbtk\_config.xml}. 
2560 The search order is 
2561 \begin{enumerate}
2562 \item The current directory
2563 \item The subdir \texttt{.bbtk} of the user's home directory. 
2564 \begin{itemize} 
2565 \item On \texttt{Unix}, the home directory is the
2566 one stored by the environnement variable \texttt{HOME}, 
2567 typically \texttt{/home/username}.
2568 \item On \texttt{Windows}, the home directory is 
2569 the user's profile directory stored by the environnement 
2570 variable \texttt{USERPROFILE}, 
2571 typically \texttt{C:$\backslash$ Documents and Settings$\backslash$ username}.
2572 \end{itemize}
2573 \item If none of these two paths contains the file then it creates 
2574 a new one in the \texttt{.bbtk} directory. 
2575 \end{enumerate}
2576
2577
2578 Information on \bbtk configuration is 
2579 obtained in \bbStudio by clicking on the 
2580 \texttt{Config} button of the \texttt{Command} part toolbar.
2581
2582 If you did not install other packages than the ones 
2583 provided by \bbtk, you get something like :
2584
2585 \begin{verbatim}
2586  =============
2587  Configuration
2588  =============
2589  bbtk_config.xml    : [/home/guigues/.bbtk/bbtk_config.xml]
2590  Documentation Path : [/usr/local/bin/../share/bbtk/doc]
2591  Data Path          : [/usr/local/bin/../share/bbtk/data]
2592  Temp Directory     : []
2593  File Separator     : [/]
2594  BBS Paths   
2595  --- [.]
2596  --- [/usr/local/bin/../share/bbtk/bbs]
2597  PACKAGE Paths : 
2598  --- [.]
2599  --- [/usr/local/bin/../lib]
2600 \end{verbatim}
2601
2602 The first line let you know which configuration file is currently used.
2603
2604 You can open this file using \bbStudio menu \texttt{Files$>$Open bbtk Config file}.
2605
2606 You will get something like :
2607
2608 \begin{verbatim}
2609 <?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
2610 <config>
2611   <bbs_path>     </bbs_path>
2612   <package_path> </package_path>
2613   <default_temp_dir> $ </default_temp_dir>
2614 </config>
2615 \end{verbatim}
2616
2617 The \texttt{xml} tags \texttt{bbs\_path} and \texttt{package\_path} 
2618 allow to set additionnal directories in which to search 
2619 for \bbs files and packages dynamic libraries.
2620
2621 For example, if you add the line :
2622 \begin{verbatim}
2623   <bbs_path> /home/guigues/bbs </bbs_path>
2624 \end{verbatim}
2625
2626 Then the interpreter will search for \bbs in the folder \texttt{/home/guigues/bbs}, 
2627 which allows a command like \texttt{'include bbMyBox.bbs'} to work if 
2628 the folder \texttt{/home/guigues/bbs} contains the file \texttt{bbMyBox.bbs}.
2629
2630 The same, the \texttt{xml} tag \texttt{<package\_path>} let you 
2631 set additional path in which to find a package dynamic library, 
2632 hence allowing to load additionnal packages with the \texttt{'load'} command.
2633
2634 All \bbs and package paths are summmarized in the 
2635 information output when pressing 'Config' in \bbStudio. 
2636 You can see that two \bbs paths are always set :
2637 \begin{itemize}
2638 \item The current directory (\texttt{.})
2639 \item The \bbs folder of \bbtk 
2640 \end{itemize}
2641 Also, two package paths are always set :
2642 \begin{itemize}
2643 \item The current directory (\texttt{.})
2644 \item The libraries folder of \bbtk 
2645 \end{itemize}
2646
2647 Additional paths set in your \texttt{bbtk\_config.xml} are added after those standard paths.
2648 Note that the order displayed is the one in which the folders are searched when 
2649 \texttt{include} or \texttt{load} commands are issued.
2650
2651
2652 %%==============================================================================================
2653
2654 \subsection{Misc}
2655 \begin {itemize}
2656 %\item{make} \\
2657 %For some strange reasons (?!?), at \texttt{cmake} time, 
2658 %you may be warned that an error occured while documentation generation.\\
2659 %Take it easy, \texttt{make} again!\\
2660
2661 \item{\bbStudio} is written using the Advanced User Interface library of wxWidgets.
2662 If, after some hazardous floating/docking operations onto the frame, you feel
2663 very unhappy with the result, just remove from the hidden directory
2664 \texttt{.bbtk} the file named \texttt{bbStudio.aui}. \\ 
2665
2666  
2667 \end {itemize}
2668
2669
2670
2671 \end{document}
2672
2673