]> Creatis software - bbtk.git/blob - kernel/doc/bbtkUsersGuide/bbtkUsersGuide.tex
Forgot to commit this one!
[bbtk.git] / kernel / doc / bbtkUsersGuide / bbtkUsersGuide.tex
1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
3 \input{config.tex}
4 \begin{document}
5 \title{The Black Box Toolkit\\User's Guide}
6 \date{\today}
7 \author{Laurent Guigues}
8 \maketitle
9 % ==========================================
10 \tableofcontents
11 % ==========================================
12
13 \listoftables
14
15 \listoffigures
16
17 % ==========================================
18 %\section*{Abstract}
19 % ==========================================
20 \newpage
21 % ==========================================
22 \hrule
23 \section{What is {\bf bbtk} ?}
24 % ==========================================
25 \BBTK(\bbtkns) is a set of tools 
26 (\CPP libraries and executables) 
27 providing a \CPP framework for the definition 
28 of elementary processing \emph{units}, called {\bf black boxes}, 
29 and the definition and execution of processing \emph{chains} 
30 made up of these black boxes. 
31
32 % ==========================================
33 \subsection{The black box philosophy}
34 % ==========================================
35 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
36 defines a {\bf black box} as 
37 \emph{``any component in a system in which only the input and output 
38 characteristics are of interest, without regard to its internal mechanism 
39 or structure''}. 
40 I would add something very important to this definition : 
41 not only the inputs and outputs are of interest but also 
42 \emph{what the box does} !
43 Hence, I would say that a black box is any \emph{\bf documented} 
44 component of a system, letting the user know  
45 \emph{\bf what} the box is supposed to do and 
46 \emph{\bf how to use it}
47 but not \emph{\bf how it does it}.
48
49 \BBTK provides a systematic framework 
50 to encapsulate (or ``wrap'') any 
51 existing \texttt{C} or \CPP processing code into an object 
52 (a black box) having a {\bf generic symbolic interface}, where 
53
54 \begin{itemize}
55 \item{\bf generic} means that the interface is \emph{the same} 
56 for all boxes. Hence one does not need to know which particular 
57 method allows, say, to set a particular input or 
58 get a particular output of the box. 
59 One can use a black box in a purely abstract way. 
60 \item{\bf symbolic} means that a particular 
61 input or output is referenced by a 'name', that is by a symbol 
62 which identifies the input or output. 
63 It also means that symbolic information (text!) is 
64 attached to a box: description of the box, author, 
65 description of its inputs and outputs, etc.
66 \end{itemize}
67
68 (in fact, genericity is achieved because the interface is symbolic. 
69 I let you think about this\dots)
70
71 Of course, symbolic data attached to box can be 
72 {\bf queried}: what are the inputs/outputs of the box ? 
73 what are their type ? their description ? etc.
74 This allows {\bf automatic documentation} of boxes. 
75
76 The abstract definition of black boxes is the most basic 
77 aspect of \BBTK architecture. 
78 Another key aspect is the groupement of black boxes into 
79 so called {\bf packages}, 
80 which are \emph{dynamic libraries} which can also 
81 be queried, in particular about the boxes they provide. 
82 The package structure then offers a mechanism which 
83 is like a \emph{'plug-in'} mechanism.
84 \BBTK provides the methods to load a package at run-time, 
85 and create instances of the boxes it contains. 
86
87 These two mechanisms (black boxes and packages) 
88 then gives the way to:
89
90 \begin{itemize}
91 \item The definition of an {\bf interpreted language}, 
92 which allows to manipulate packages and boxes very easily in symbolic way. 
93 \BBTK provides one: \bbi (the Black Box Interpreter). 
94 \item {\bf Automatic documentation} of existing packages. 
95 \texttt{html} documentation of packages is proposed by 
96 \bbi.
97 \end{itemize}
98
99 Finally, these different components allow {\bf efficient}:
100
101 \begin{itemize}
102 \item {\bf capitalization and reuse} of existing processing units, 
103 including {\bf documentation} 
104 \item {\bf testing, prototyping} in a very simple script language
105 \item {\bf inter-operability} between atomic processings which 
106 have been written by different persons, using different libraries, etc. 
107 \end{itemize}
108
109 % ==========================================
110 \subsection{\bbtk components}
111 % ==========================================
112 \BBTK includes:
113 \begin{itemize}
114   \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework 
115     (abstract classes) to develop black boxes and to store them into 
116     dynamic libraries, called black box \emph{packages}.
117   \item Different {\bf\emph{black box packages}}:
118     \begin{itemize}
119       \item {\bf\emph{std}}: the 'standard' package including basic useful boxes.
120       \item {\bf\emph{wx}}: basic graphical interface elements (widgets: sliders, buttons, etc. based on the \texttt{wxWidgets} library).  
121       \item {\bf\emph{itk}}: the basic image processing package, based on the \texttt{itk} library.
122       \item {\bf\emph{vtk}}: the basic image and surfaces processing package, based on the \texttt{vtk} library.
123       \item {\bf\emph{wxvtk}}: widget boxes based on the \texttt{vtk} library.
124       \item {\bf\emph{itkvtk}}: boxes to convert \texttt{itk} structures into \texttt{vtk} structures and conversally. 
125     \end{itemize}
126   \item A {\bf\emph{Developement environment}}, called bbStudio, which provides
127     \begin{itemize}
128       \item An online {\bf\emph{script editor}}, called bbed
129       \item A powerfull {\bf\emph{Help environment}}, called bbhelp
130         whith integrated
131         \begin{itemize}
132           \item Online documentation scaning
133           \item Retreiving boxes on various criterions
134           \item Checking Demo and examples
135         \end{itemize}
136
137       \item An {\bf\emph{interpreter}}, called \bbi, which allows to 
138           load black box packages and to define and execute 
139           processing chains by connecting various black boxes of the already loaded packages.
140       \item {\bf\emph{Utilities}}:
141          \begin{itemize}
142             \item \bbfy generates the \CPP code of a black box from a 
143                description file written in \texttt{xml}.
144                 %\item \bbdoc generates the html documentation of a black box package 
145                 %(author, description, description of its black boxes: 
146                 %author, description, inputs, outputs, and so on).
147             \item \bbCreatePackage allows to create the basic file architecture 
148                to start the development of a new black box package.
149          \end{itemize} 
150     \end{itemize}
151 \end{itemize}
152 The general architecture of \BBTK 
153 is shown in figure \ref{bb-architecture}.
154
155 \begin{figure}[!ht]
156 \caption{\label{bb-architecture}\BBTK architecture}
157 \begin{center}
158 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
159 \end{center}
160 \end{figure}
161
162 % ==========================================
163 \subsection{Structure of this guide}
164 % ==========================================
165
166 This guide is divided into three parts. 
167
168 The first part (\ref{bbStudio}) is a brief presentation of the very intuitive Development
169 environment, \bbStudio.
170
171 The second part (\ref{bb0}) 
172 is devoted to the use of the \emph{black box interpreter} \bbi. 
173 This is the highest level of use of the toolkit, which 
174 allows to create and execute processing chains by connecting 
175 black boxes of existing packages. 
176
177 The third part (\ref{cpp}) explains how to 
178 use the black box toolkit framework in \CPP code, 
179 typically to develop large applications which 
180 involve complex graphical interfaces.
181
182
183 % ==========================================
184 % ==========================================
185 % ==========================================
186 % ==========================================
187 % ==========================================
188 % ==========================================
189 \vspace{0.5cm}\hrule
190 \section{The Development environment (bbStudio)}
191 \label{bbStudio}
192
193 Just run it, typing in a console \texttt{bbed}.
194 You'll get something like in figure 
195 \ref{bbi-fig-bbStudio-gui}
196 (the exact appearance of \bbStudio is system and \bbtk version dependent)
197
198 \begin{figure}[!ht]
199 \caption{\label{bbi-fig-bbStudio-gui}The bbStudio Development environment interface}
200 \begin{center}
201 \includegraphics[width=0.7\textwidth]{bbStudioMainPage.png}
202 \end{center}
203 \end{figure}
204
205 All the entries of this Help 'bookmark' are self-explanatory :
206
207  \begin{itemize}
208    \item {\bf\emph{Wiki}}: Direct link to the bbtk Wiki (intranet only, right now, www
209    later).
210    \item {\bf\emph{Demo}}: Link to some demonstrations.
211    \item {\bf\emph{User's Guide}}: Step to step How-to for user who just wants to create his own
212    application, just using already existing boxes.
213    \item {\bf\emph{Package Developper's Guide}}: Step to step How-to for user who wants to create his own
214    black boxes.
215    \item {\bf\emph{Developper's Guide}}: Sorry, not yet written.
216    \item {\bf\emph{Reference Manual}}: Sorry, not yet written. 
217    \item {\bf\emph{Doxygen Documentation}}: Doxygen source browser.
218    \item {\bf\emph{Boxes}}: Box retrieving on various criterions :
219       \begin{itemize}
220         \item {\bf\emph{By name}}
221         \item {\bf\emph{By package}} (see table : \ref{bbi-list_of_packages})
222         \item {\bf\emph{By category}} (see table :\ref{categories})
223         \item {\bf\emph{Adaptors}} Used internaly to perform type conversions (not end user intended)     
224       \end{itemize}
225  \end{itemize}
226
227
228 % ==========================================
229 \begin{table}[!ht]
230 \caption{\label{bbi-list_of_packages} List of bbtk supplied packages.}
231 \small
232 \begin{tabular}{|ll||}
233 \hline
234 Package         & What it's used for \\ \hline
235 \texttt{std}    & : the 'standard' package including basic useful boxes \\ \hline 
236 \texttt{wx}     & : basic graphical interface elements (widgets: sliders, buttons, etc. based on the \texttt{wxWidgets} library \\ \hline 
237 \texttt{itk}    & : the basic image processing package, based on the \texttt{itk} library. (without description)\\ \hline 
238 \texttt{vtk}    & : Prints help on the package \texttt{package-name} and its boxes (with brief description). The package must have been previously loaded\\ \hline 
239 \texttt{wxvtk}  & : widget boxes based on the \texttt{vtk} library.\\ \hline 
240 \texttt{itkvtk} & : boxes to convert \texttt{itk} structures into \texttt{vtk} structures and conversally.\\ \hline 
241
242 \end{tabular}
243 \end{table}
244 % ==========================================
245
246
247
248
249 % ==========================================
250 \begin{table}[!ht]
251 \caption{\label{categories} \texttt{Black Box} categories}
252 \small
253 \begin{tabular}{|ll|}
254 \hline
255  \texttt{Categ name}     & : Meaning                                          \\ \hline \\ \hline
256  \texttt{adaptor}        & : Adaptor box                                      \\ \hline
257  \texttt{application}    & : Final application, end user intended             \\ \hline
258  \texttt{atomic box}     & : System category.
259                Automatically assigned to Atomic Black Boxes (c++ defined)     \\ \hline
260  \texttt{complex box}    & : System category.
261                Automatically assigned to Complex Black Boxes (script defined) \\ \hline  
262  \texttt{command line}   & : Script which defines a command line application (no embedded GUI, but command line imput parameters) \\ \hline
263  \texttt{demo}           & : Demonstration                             \\ \hline
264  \texttt{devel}          & : Developer tool (bbCreatePackage.bbs, ...) \\ \hline
265  \texttt{dicom}          & : DICOM aware box \\ \hline 
266  \texttt{example}        & : Example script showing a box use-case      \\ \hline
267  \texttt{filter}         & : Image processing box                       \\ \hline
268  \texttt{image}          & : Image processing related box               \\ \hline
269  \texttt{interaction}    & :                                            \\ \hline
270  \texttt{math}           & : Mathematical operations\\ \hline
271  \texttt{mesh}           & : Mesh processing related box \\ \hline
272  \texttt{misc}           & : A box that cannot be put in other category ! \\ \hline
273  \texttt{read/write}     & : Box that read or write data from or to disk  \\ \hline
274  \texttt{viewer}         & : Box which displays some data \\ \hline
275  \texttt{widget}         & : Piece of graphical interface  \\ \hline 
276  
277  \texttt{3D object creator} & : Sophisticated 3D widget  \\ \hline  
278  \texttt{toolsbbtk}         & : Component of bbStudio    \\ \hline  
279 \end{tabular}
280 \end{table}
281
282
283
284
285
286 % ==========================================
287 % ==========================================
288 % ==========================================
289 % ==========================================
290 % ==========================================
291 % ==========================================
292 \vspace{0.5cm}\hrule
293 \section{The script manager}
294 \label{bb0}
295 % ==========================================
296
297  Call it with the bookmark \emph{File}.
298  
299
300 \begin{figure}[!ht]
301 \caption{\label{bbi-fig-bbStudio-file0}The bbStudio script manager}
302 \begin{center}
303 \includegraphics[width=0.7\textwidth]{bbFile0.png}
304 \end{center}
305 \end{figure}
306
307 Using the lower tool bar, you can :
308
309 \begin{figure}[!ht]
310 \caption{\label{lowertoolbar}The lower tool bar}
311 \begin{center}
312 \includegraphics[width=0.7\textwidth]{lowertoolbar.png}
313 \end{center}
314 \end{figure}
315
316
317  \begin{itemize}
318    \item {\bf\emph{new}}: Create a newfile to hold a script
319    \item {\bf\emph{open}}: Open a already existing file holding a script 
320    \item {\bf\emph{close}}: Close a file holding a script
321    \item {\bf\emph{save}}: Save he current file (if modified)
322    \item {\bf\emph{save as}}: Save he current file under a different name
323    \item {\bf\emph{execute}}: Execute the script you just loaded/modified/written
324  \end{itemize}
325
326
327 The script language is very simple. 
328 Everything is done with only a very few commands (See table \ref{bbi-reference-box}).
329 The philosophy of this part is also very simple: 
330 it introduces the \bbi commands using examples, 
331 starting with the most simple commands.  
332 The first section of this part 
333 (\ref{bbi-getting-started})
334 is designed like a tutorial, 
335 which progressively introduces all the concepts of \bbi. 
336 We suggest you run \bbi and follow the examples, 
337 to see how it works in practice. 
338 At the end of this section, 
339 you will be able to use \bbi and write 
340 own black box processing scripts. 
341
342 After this tutorial, 
343 the section \ref{bbi-more-on} 
344 (called \emph{more on...}) 
345 goes deeper into various issues of \bbi. 
346 Read it at your convenience, 
347 either linearly to learn more about \bbi, 
348 or in random order to get an answer 
349 to a particular question. 
350
351 Finally, the section \ref{bbi-reference}
352 summarizes all the commands of \bbi, 
353 their parameters and effect. 
354 Use it as a reference.
355
356 % ==========================================
357 \subsection{Getting started}
358 \label{bbi-getting-started}
359 % ==========================================
360 \subsubsection{Creating and executing black boxes}
361 % ==========================================
362
363 To learn interactivelly the script language features, you can use the black box
364 interpreter : 
365 open a console and type \texttt{bbi} 
366 or double click on the application icon.
367 You get a window which looks like the one in figure 
368 \ref{bbi-fig-bbi-gui} 
369 (the exact appearance of \bbi is system and \bbtk version dependent)
370 \footnote{If you compiled \bbtk without \wx then \bbi does not have a 
371 graphical interface but a simple prompt}.
372
373 \begin{figure}[!ht]
374 \caption{\label{bbi-fig-bbi-gui}The black box interpreter interface}
375 \begin{center}
376 \includegraphics[width=0.7\textwidth]{bbi-gui0.png}
377 \end{center}
378 \end{figure}
379
380 The 'Command' tab is subdivided into two parts : 
381 one single line zone at the bottom in which you can enter your commands and 
382 one multiple line zone in which \bbi prints out the result of your commands.
383 , just using already existing boxes.
384
385 Try typing in the input zone (in this manual, 
386 the commands entered by the user will be preceded by a prompt \textgreater) :
387 \begin{verbatim}
388 > help 
389 \end{verbatim}
390
391 you get the list of the commands of the interpreter:
392 \begin{verbatim}
393 Available commands:
394  author
395  category
396  config
397  connect
398  debug
399  define
400  delete
401  description
402  endefine
403  endpackage
404  exec
405  graph
406  help
407  include
408  index
409  input
410  kind
411  load
412  message
413  new
414  newgui
415  output
416  package
417  print
418  quit
419  reset
420  set
421  unload
422 \end{verbatim}
423
424 To get help on a particular command type \texttt{help <command-name>},
425 for example:
426 \begin{verbatim}
427 > help quit
428 \end{verbatim}
429
430 gives:
431 \begin{verbatim}
432  quit: 
433    usage: quit
434     Quits the program (during script execution it stops the complete execution)
435 \end{verbatim}
436
437 The \texttt{help} command has multiple usages. 
438 It is used to get help on almost anything in \bbi !
439 Type \texttt{'help help'} to get help on the \texttt{help} command itself:
440 \begin{verbatim}
441 > help help
442  usage: 
443          (1) help 
444          (2) help <command name> 
445          (3) help packages [all]
446          (4) help <package name> [all]
447          (5) help <black box type> 
448          (6) help <black box name>
449   Effect:
450          (1) Lists all available commands;
451          (2) Prints help on a particular command; 
452          (3) Lists the packages loaded and their black boxes.
453              Add 'all' to list adaptors; 
454          (4) Prints short help on the black boxes of a package.
455              Add 'all' to include adaptors; 
456          (5) Prints full help on a black box type; 
457          (6) Prints information on the inputs, outputs and connections of a black box instance.
458 \end{verbatim}
459
460 At start \bbi does not know any black box. 
461 If you type \texttt{'help packages'}, which is 
462 the third form of the \texttt{help} command, you get:
463 \begin{verbatim}
464 > help packages
465 user
466   workspace
467 \end{verbatim}
468
469 which means that \bbi only knows one package 
470 (library of black boxes) called \texttt{user}
471 and which contains a black box called \texttt{workspace}.
472 The \texttt{user} package is an internal package to \bbi, 
473 which stores user-defined black box types. 
474 At start, it already contains 
475 one box, called \texttt{workspace}.
476 \texttt{workspace} is a special type of black box, 
477 called complex black box, whose purpose is 
478 to store other black boxes. 
479 Any black box you create in \bbi is stored 
480 in \texttt{workspace}  
481 (this will be explained in details in sections 
482 \ref{bbi-writing-scripts} and 
483 \ref{bbi-more-on-complex-black-boxes}). 
484
485 If you type \texttt{'help workspace'}, you get:
486 \begin{verbatim}
487 > help workspace
488 Complex Black Box <user::workspace>
489  User's workspace
490  By: bbi (internal)
491  Category(s) : complex box;
492  * No inputs
493  * No outputs
494  * No boxes
495 \end{verbatim}
496
497 In the text displayed, 
498 the \texttt{user::} prepended to the name \texttt{workspace} 
499 means that the box \texttt{workspace} 
500 belongs to the \texttt{user} package. 
501 Then comes a description and three lines which 
502 tell that \texttt{workspace} does not have any input 
503 nor output nor boxes yet.
504
505 In order to let \bbi know of some black boxes, 
506 you must load another package. 
507 The \texttt{std} package is the ``standard'' package, 
508 which contains basic useful black boxes. 
509
510 To load it, type:
511 \begin{verbatim}
512 > include std
513 \end{verbatim}
514
515 Then if you type:
516 \begin{verbatim}
517 > help packages
518 \end{verbatim}
519
520 you get something like:
521 \begin{verbatim}
522 std
523   Add 
524   ConcatStrings          
525   Configuration          
526   Div   
527   ...
528   StringRelay            
529   StringSelect    
530 user
531   workspace
532
533 \end{verbatim}
534
535 Now \bbi knows the package \texttt{std} and the black boxes it provides,
536 such as the \texttt{'Add'} box, the  \texttt{'ConcatStrings'}. Remark that the 
537 content of \texttt{std} may vary from one version to another 
538 as new black boxes might be added to it. 
539 If you type:  
540 \begin{verbatim}
541 > help Add
542 \end{verbatim}
543
544 You get:
545 \begin{verbatim}
546 Black Box <std::Add>
547   Adds its inputs
548   By : laurent.guigues@creatis.insa-lyon.fr
549   Categories : atomic box;math;
550   * Inputs : 
551      'BoxExecute'     <bbtk::Void> [signal] : Any signal received by this input executes the box
552      'BoxProcessMode' <String>     []       : Sets the processing mode of the box (Pipeline | Always | Reactive)
553      'In1'            <Double>     []       : First number to add
554      'In2'            <Double>     []       : Second number to add
555   * Outputs : 
556      'BoxChange'      <bbtk::Void> [signal] : Signals modifications of the box
557      'Out'            <Double>     []       : Result
558 \end{verbatim}
559
560 Like previously, 
561 the \texttt{std::} prepended to the name \texttt{Add} 
562 means that the box \texttt{Add} 
563 belongs to the \texttt{std} package. 
564 Then comes a description 
565 (the one which was provided by the author of the box), 
566 the author(s) of the box (usually e-mail adress(es)) and 
567 the categories to which the box belong. 
568 Finally comes the lists of inputs and outputs of the box.
569 For each input or output, \bbi provides 
570 its \emph{name} (between quotes, e.g. \texttt{'ProcessMode'}), 
571 its \emph{type} (between \texttt{<>}, e.g. \texttt{<Int>})
572 and a description.    
573 Remark that the box \texttt{Add} is not a 'complex' black box 
574 but an 'atomic' box, hence its help does not 
575 mention any information concerning possible internal boxes.
576
577 You can create an \emph{instance} of an \texttt{Add} box by 
578 the command \texttt{new}:
579 \begin{verbatim}
580 > new Add a
581 \end{verbatim}
582
583 The \texttt{'a'} at the end is the \emph{name} of the instance, 
584 which will be used to reference it later. 
585 It is important to distinguish a box \emph{type} 
586 and an \emph{instance} of a box type. 
587 The \texttt{Add} box of the package \texttt{std} is actually 
588 a \emph{box type} , like \texttt{int} is a data type 
589 in \texttt{C} langage. The \texttt{new} command allows to create 
590 an instance of a box type, exactly like \texttt{int i;} in 
591 a \texttt{C} code, it declares a variable of type \texttt{int} whose 
592 name is \texttt{i}. 
593 Of course, like in \texttt{C} Language, you can declare multiple boxes of the 
594 same type in \bbi. 
595
596 After the creation of the box \texttt{a}, type:
597 \begin{verbatim}
598 > help workspace
599 \end{verbatim}
600
601 you get:
602 \begin{verbatim}
603 Complex Black Box <user::workspace>
604  User's workspace
605  By: bbi (internal)
606  Category(s) : complex box;
607  * No inputs
608  * No outputs
609  * Boxes: 
610     'a' <std::Add>
611 \end{verbatim}
612
613 which means that \bbi workspace now contains a black box named \texttt{a},
614 of type \texttt{std::Add}.
615
616 Now look back at the help on \texttt{Add} boxes: 
617 you can see that this type of box has two inputs, 
618 with name \texttt{In1} and \texttt{In2},
619 and an output, with name \texttt{Out}.
620
621 You can set the input \texttt{In1} 
622 of the \texttt{Add} box \texttt{a} to the value $1$ 
623 by the command:
624 \begin{verbatim}
625 > set a.In1 1 
626 \end{verbatim}
627
628 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $2$
629 is done with:
630 \begin{verbatim}
631 > set a.In2 2
632 \end{verbatim}
633  
634 And you print the output \texttt{Out} of the box \texttt{a} with:
635 \begin{verbatim}
636 > print "result=$a.Out$"
637 result=3
638 \end{verbatim}
639
640 In the string passed to the \texttt{print} command, 
641 each substring enclosed between a couple of \$ is considered 
642 as the name of an output of a box. 
643 To process this special substrings, \bbi does:
644 \begin{enumerate}
645 \item Processes the box if needed (see below)
646 \item Converts the output of the box to a string if possible 
647 (see below)
648 \item Substitutes the result in the string to print
649 \item postpone an implicit 'new line' character to the string
650 \end{enumerate}
651
652 \paragraph
653 Box processing is needed if:
654 \begin{itemize}
655 \item at least input has changed since last processing or
656 \item the input \texttt{'BoxProcessMode'} of the box is set to 
657 \texttt{'Always'}, which forces box reprocessing. 
658 \end{itemize}
659
660 Note that all boxes have the input \texttt{'BoxProcessMode'}. 
661
662 Another way to process the box \texttt{a} is to issue the command:
663 \begin{verbatim}
664 > exec a
665 \end{verbatim}
666
667 however this command does not display anything (except if the 
668 box itself displays something in its processing).
669 It just processes the box if needed. 
670 This command is used to execute boxes that do not have any output,  
671 such as boxes that write something to a file or, display a 
672 graphical interface, and so on. 
673
674 To exit \bbi, type:
675 \begin{verbatim}
676 > quit
677 Good bye !
678 \end{verbatim}
679
680 % ==========================================
681 \hrule
682 \paragraph{Summary}
683 %\hrule
684 \begin{itemize}
685 \item The \texttt{include} command allows to load a package, and the complex black boxes that come with it..
686 \item \texttt{help} gives help on:
687 \begin{itemize} 
688 \item Available commands if you just type \texttt{help}.
689 \item A particular command if you type \texttt{help <command-name>}.
690 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
691 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
692 \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}).
693 \end{itemize}
694 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
695 \item \texttt{new} : creates an instance of a black box. 
696 \item \texttt{set} : sets the value of an input of a black box. 
697 \item In all \bbi, to reference the input called \texttt{i} 
698 of a black box called \texttt{b} you must type \texttt{'b.i'}. 
699 The same syntax holds for outputs.
700 \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
701 implicit trailing 'new line character' is added at the final string.
702 \item \texttt{exec} : runs the process of a box if needed. 
703 \item \texttt{quit} : quits \bbi.
704 \end{itemize}
705 \hrule
706
707 \paragraph{Note :}
708 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.
709 Wou'll get something like in figure \ref{bbCommandPlusHelp} :
710
711 \begin{figure}[!ht]
712 \caption{\label{bbCommandPlusHelp}
713 An other way to run the command interpreter}
714 \begin{center}
715 \includegraphics[width=0.5\textwidth]{bbCommandPlusHelp.png}
716 \end{center}
717 \end{figure}
718 % ==========================================
719
720 % ==========================================
721 \subsubsection{Connecting black boxes}
722 \label{bbi-connecting-black-boxes}
723 % ==========================================
724
725 \BBTK allows to create 
726 and execute processing chains, 
727 also called \emph{pipelines}, 
728 by connecting black boxes.
729 This section explains how to do it with examples. 
730 Read section \ref{bbi-more-on-pipeline-processing} to get 
731 more information on pipeline processing.
732
733 First start \bbi and load the package \texttt{std}:
734 \begin{verbatim}
735 > include std
736 \end{verbatim}
737
738 Assume you want to compute $1+2+3$. You can do it by 
739 chaining two \texttt{Add} boxes, as shown in figure 
740 \ref{bbi-fig-connecting-black-boxes-1}. 
741
742 \begin{figure}[!ht]
743 \caption{\label{bbi-fig-connecting-black-boxes-1}
744 A simple pipeline which adds 3 numbers}
745 \begin{center}
746 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
747 \end{center}
748 \end{figure}
749
750
751 The \bbi instructions to create and execute this pipeline are:
752 \begin{verbatim}
753 > new Add a
754 > new Add b
755 > connect a.Out b.In1
756 > set a.In1 1
757 > set a.In2 2
758 > set b.In2 3
759 > print $b.Out$
760 \end{verbatim}
761
762 You will see the (very expected) result :
763 \begin{verbatim}
764 6
765 \end{verbatim}
766
767 The first three commands build the pipeline, 
768 the next three set \texttt{a} and \texttt{b} black boxes inputs and the last one 
769 prints \texttt{b} black boxe output (the pipeline is executed before printing, because the interpretor 'knows' he box  \texttt{b}, 
770 whose output is requested, is not up to date.
771  
772 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output 
773 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the 
774 box \texttt{b}. 
775 Once the boxes connected, the processing of the two boxes are chained:
776 getting the output of \texttt{b} requires getting its inputs, 
777 hence getting the output of \texttt{a} which is connected to it. 
778 This pipeline mechanism can recurse into arbitrary long 
779 chains of boxes (see \ref{bbi-more-on-pipeline-processing} 
780 for details).
781
782
783 Lets' consider an other, more image oriented, example :
784
785 \begin{verbatim}
786 > include vtk
787 > include wx
788 > include itk
789 > include wxvtk
790
791 > new FileSelector fileDialog
792 > new ImageReader  reader 
793 > new Slider       slider
794 > new Viewer2D     viewer
795
796 > connect fileDialog.Out   reader.In 
797 > connect reader.Out       viewer.In
798 > connect slider.Out       viewer.Slice
799 > connect slider.BoxChange viewer.BoxExecute
800
801 > exec viewer
802 \end{verbatim}
803
804 Some explainations : the \texttt{include} instructions load the necessary packages. \\
805
806 \texttt{new FileSelector} will pop a File Selector, at run time, that will out the user chosen file name. \\
807 \texttt{new Slider} will pop a Slider, at run time, that will out an integer, used later as a slice number.\\ 
808 \texttt{new ImageReader} will read any itk readable file, whose name is passed as a std::string, and return a itk::ImagePointer.
809 \texttt{new Viewer2D} display a plane, whose number id specified by an integer.\\
810 \\
811 \texttt{connect fileDialog.Out   reader.In} plugs the output of the File Selector (a std::string) to the input of the reader (a std::string, too).\\
812 \texttt{connect reader.Out       viewer.In} plugs the output of the reader (an itk::ImagePointer) to the input of the Viewer (a vtkImageData *)\\
813 \texttt{connect slider.Out       viewer.Slice} plugs the output of the slider (an int) to an other output (named Slide) of the viewer.\\
814 \texttt{connect slider.BoxChange viewer.BoxExecute} says the viewer it must re process itself any time the slider is modified.\\
815 \\
816 \texttt{exec viewer} processes the viewer.
817
818
819 This would correspond to the graph in figure \ref{bbi-simplegraph}
820
821
822 \begin{figure}[!ht]
823 \caption{\label{bbi-simplegraph}(Very) simple Graph of a (very) simple pipeline}
824 \begin{center}
825 \includegraphics[width=0.8\textwidth]{bbi-simplegraph.png}
826 \end{center}
827 \end{figure}
828    
829 Of course, to be able to connect two boxes, 
830 the output and the input must be compatibles. 
831 You can always connect an output to an input of the \emph{same} type, 
832 but you can do more, thanks to particular (hidden) black boxes called {\bf adaptors}.
833
834 An adaptor is a black box which has at least one input, called \texttt{In}, 
835 and at least one ouput called \texttt{Out} and whose role is to convert 
836 a data of the type of \texttt{In} 
837 into a data of the type of \texttt{Out} (other inputs or outputs may serve 
838 to parameter the adaptor or retreive other usefull information).
839
840 In \bbi, if you type:
841 \begin{verbatim}
842 > load std
843 > help std all
844 \end{verbatim}
845 you get:
846 \begin{verbatim}
847  Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
848  Basic useful black boxes
849  Black boxes: 
850    Add                                    : Adds its inputs
851    Cast<double,float>                [DA] : Casts a double into a float
852    Cast<double,int>                  [DA] : Casts a double into a int
853     ... 
854    Convert<unsigned int,string>      [DA] : Converts a unsigned int into a s...
855    Convert<unsigned short,string>    [DA] : Converts a unsigned short into a...
856    Print                                  : Prints its input to standard out...
857 >
858 \end{verbatim}
859
860 The \texttt{Cast<?,?>} and \texttt{Convert<?,?>} boxes are \emph{default adaptors}, which is signaled by the tag \texttt{[DA]} before their descriptions.
861
862 Once you have loaded the package \texttt{std}, you can 
863 plug an output of type \texttt{char} into an input of type \texttt{double}. 
864 When \bbi encounters the \texttt{connect} command, 
865 it looks for an adequate \emph{adaptor} in the  loaded packages. 
866 In our case, as the package \texttt{std} provides the 
867 \texttt{Cast<char,double>} adaptor, \bbi automatically creates an 
868 instance of this adaptor and place it \emph{between} 
869 the output and the input you want to connect 
870 (however this adaptor is hidden to you, 
871 it is embedded into the created connection and does not appear 
872 as an existing black box). 
873 When the pipeline is processed the 
874 adaptor converts the output data into the required input type, 
875 in a totally transparent way.
876 In our example, the \texttt{Cast<char,double>} adaptor 
877 would simply cast the value of the \texttt{char} into a \texttt{double}, 
878 however arbitrarily complex type conversion can be done.
879
880 Question: 
881 if two adaptors with the same input and output types exist 
882 in the packages loaded, 
883 which one is chosen by \bbi at connection ? 
884 -> Role of default adaptors
885
886 Note that the \texttt{set} and \texttt{print} commands of \bbi 
887 work with adaptors from \texttt{string} to the type of the input to set 
888 or from the type of the output to print to \texttt{string}. 
889 Hence in order to \texttt{set} or \texttt{print} values the adequate 
890 adaptors must be available in the packages currently loaded.
891  
892 % ==========================================
893 \hrule
894 \paragraph{Summary}
895 %\hrule
896 \begin{itemize}
897 \item The \texttt{connect} command allows to connect two black boxes
898 \item You can connect two black boxes if (and only if): 
899 \begin{itemize}
900 \item The output and the input are of the same type, or
901 \item There is an adaptor black box in the packages loaded which 
902 converts data of the output type into data of the input type
903 \end{itemize}
904 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use: \texttt{help <package name> all}.
905 including adaptors
906 \end{itemize}
907 \hrule
908 % ==========================================
909
910 % ==========================================
911 \subsubsection{Creating complex black boxes}
912 \label{bbi-complex-black-boxes}
913 % ==========================================
914
915 Remember the pipeline of figure 
916 \ref{bbi-fig-connecting-black-boxes-1}, which 
917 computed the sum of three doubles ?
918 You can view it as a whole and define 
919 a new black box type, which will be a \emph{complex black box}, 
920 having three inputs and one output, 
921 as shown in figure \ref{bbi-fig-complex-black-box-1}.
922
923 \begin{figure}[!ht]
924 \caption{\label{bbi-fig-complex-black-box-1}
925 Creating the complex black box \texttt{Add3}}
926 \begin{center}
927 \includegraphics[width=0.5\textwidth]{Add3.png}
928 \end{center}
929 \end{figure}
930
931 The \bbi commands to define this complex black box are 
932 the following:
933
934 \begin{verbatim}
935 > load std
936 >
937 > define Add3
938 >
939 > new Add a
940 > new Add b
941 > connect a.Out b.In1
942 >
943 > author "myself"
944 > description "adds 3 doubles"
945 > input x a.In1 "first double to add"
946 > input y a.In2 "second double to add"
947 > input z b.In2 "third double to add"
948 > output result b.Out "output"
949 >
950 > endefine
951 \end{verbatim}
952
953 Explainations:
954
955 As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in first line.
956
957 The command \texttt{define} then starts the definition 
958 of the complex box type, which will be called \texttt{Add3}. 
959
960 The next three lines define the pipeline, 
961 exactly in the same way than outside a complex box definition. 
962
963 The commands \texttt{author}, \texttt{description}, \texttt{input} 
964 and \texttt{output} are commands specific to complex boxes definition:
965
966 \texttt{author} and \texttt{description} are used for the documentation 
967 of the new box. You can provide multiple \texttt{author} or 
968 \texttt{description} commands, the arguments of the commands will 
969 be concatenated to produce the final author and description strings.
970
971 \texttt{input} and \texttt{output} are used to define the inputs and outputs 
972 of the new complex box. 
973 Their syntax is the same: for each new input/output you need to say 
974 to which internal input/output it corresponds and to provide 
975 a help string documenting the input/output.
976 In our example, we define that the box \texttt{Add3} has 
977 three inputs: \texttt{x}, \texttt{y} and \texttt{z}. 
978 The input \texttt{x} corresponds to the input \texttt{In1} of the 
979 internal box \texttt{a}. 
980 In the same way, the external input \texttt{y} 
981 corresponds to the internal input \texttt{a.In2}, and 
982 the external input \texttt{In3} to \texttt{b.In2}. 
983 The only output of the new box is called \texttt{result}
984 and corresponds to \texttt{b.Out}. 
985 The figure \ref{bbi-fig-complex-black-box-1} 
986 illustrates the external to internal 
987 input/output correspondence.
988
989 Finally, the \texttt{endefine} command ends the definition of the 
990 new box type.
991
992 After this definition, if you ask for help 
993 on packages, you get:
994 \begin{verbatim}
995 > help packages
996 std
997   Add
998   ...
999 user
1000   Add3
1001   workspace
1002 \end{verbatim}
1003
1004 The \texttt{user} package now contains a new black box type, called 
1005 \texttt{Add3}. If you ask for help on this type of box, you get:
1006 \begin{verbatim}
1007 > help Add3
1008 Complex Black Box <user::Add3>
1009  adds 3 doubles
1010  By: myself
1011  * Inputs: 
1012     'x'      <double>: first double to add
1013     'y'      <double>: second double to add
1014     'z'      <double>: third double to add
1015  * Outputs: 
1016     'result' <double>: output
1017  * Boxes: 
1018     'a' <std::Add>
1019     'b' <std::Add>
1020 \end{verbatim}
1021
1022 and you can use it like any other box, for example type:
1023
1024 \begin{verbatim}
1025 > new Add3 a
1026 > set a.x 1
1027 > set a.y 2
1028 > set a.z 3
1029 > print $a.result$
1030 6
1031 \end{verbatim}
1032
1033
1034 As a side note, we can say that, for consistency reasons, it would have been better to name  
1035 \texttt{In1}, \texttt{In2} and \texttt{In3} the inputs of the black box \texttt{Add3}, 
1036 since all the 'natural entry' of a box is named \texttt{In}, or\texttt{In}x if there are more than one  'natural
1037 entry'.
1038
1039 % ==========================================
1040 \hrule
1041 \paragraph{Summary}
1042 %\hrule
1043 \begin{itemize}
1044 \item The \texttt{define/endefine} commands allows to define complex black box types, i.e. types of black boxes made up of other black boxes. 
1045 Inside a \texttt{define/endefine} block:
1046 \begin{itemize}
1047 \item The \texttt{author} and \texttt{description} commands allow to document the new type of box
1048 \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 
1049 of internal boxes they correspond.  
1050 \end{itemize}
1051 \end{itemize}
1052 \hrule
1053 % ==========================================
1054
1055 % ==========================================
1056 \subsubsection{Writing scripts}
1057 \label{bbi-writing-scripts}
1058 % ==========================================
1059
1060 Once you have defined a new type of complex box, you 
1061 may like to reuse it. To do this, you can simply 
1062 write the \bbi commands defining the new box 
1063 into a text file and afterwards include that file in \bbi. 
1064 Doing this, you start writing \bbi scripts.
1065 The conventionnal extension for such scripts is \texttt{bbs} 
1066 (black box script).
1067 For consistency reasons, you are requested to prepend \texttt{bb} to the name.
1068
1069 For example, the \texttt{Add3} complex box we previously worked on 
1070 can be defined in the \texttt{bbAdd3.bbs} file:
1071
1072 \begin{file}{bbAdd3.bbs}
1073 \begin{verbatim}
1074 # Defines the Add3 black box which adds 3 doubles 
1075 load std
1076
1077 define Add3
1078   # I am the author 
1079   author "myself"
1080   description "adds 3 doubles"
1081   # Pipeline creation
1082   new Add a
1083   new Add b
1084   connect a.Out b.In1
1085   # Inputs definition
1086   input x a.In1 "first double to add
1087   input y a.In2 "second double to add
1088   input z b.In2 "third double to add"
1089   # Output definition
1090   output result b.Out "output"
1091 endefine
1092 \end{verbatim}
1093 \end{file}
1094
1095 Lines starting with a \texttt{\#} character are ignored, they 
1096 are considered as comments by \bbi.
1097 To use this file in \bbi, use the \texttt{include} command:
1098
1099 \begin{verbatim}
1100 > include bbAdd3.bbs
1101 > help Add3
1102 Complex Black Box <user::Add3>
1103  adds 3 doubles
1104  By: myself
1105  * Inputs: 
1106     'x'      <double>: first double to add
1107     'y'      <double>: second double to add
1108     'z'      <double>: third double to add
1109  * Outputs: 
1110     'result' <double>: output
1111  * Boxes: 
1112     'a' <std::Add>
1113     'b' <std::Add>
1114 >
1115 and so on ...
1116 \end{verbatim}
1117
1118 If the file has the \texttt{bbs} extension, you can ommit it and just type:
1119 \begin{verbatim}
1120 > include Add3
1121 \end{verbatim}
1122
1123 Of course, you can include script files in other script files, 
1124 like in the following example:
1125
1126 \begin{file}{bbAdd4.bbs}
1127 \begin{verbatim}
1128 # Defines the Add4 black box which adds 4 doubles 
1129 include Add3
1130
1131 define Add4
1132   author "myself"
1133   description "adds 4 doubles"
1134   new Add3 a
1135   new Add b
1136   connect a.Out b.In1
1137   input In1 a.In1 "first double to add
1138   input In2 a.In2 "second double to add
1139   input In3 a.In3 "third double to add"
1140   input In4 b.In2 "fourth double to add"
1141   output Out b.Out "output"
1142 endefine
1143 \end{verbatim}
1144 \end{file}
1145
1146 % ==========================================
1147 \hrule
1148 \paragraph{Naming Conventions}
1149 %\hrule
1150
1151 \hrule
1152 % ==========================================
1153 \begin{itemize}
1154 \item
1155 File names: 
1156 For consistency reasons, you are requested to prepend \texttt{bb}, and postpone an extention \texttt{.bbs},
1157 to the names of the files that hold a \texttt{complex black box} definition.
1158
1159 For example, the \texttt{Add3} complex box we previously worked on 
1160 can be defined in the \texttt{bbAdd3.bbs} file.
1161 \item
1162 Search Paths 
1163 \end{itemize}
1164 % ==========================================
1165 \hrule
1166
1167 \paragraph{Summary}
1168 %\hrule
1169 \begin{itemize}
1170 \item The \texttt{include} command allows to include a script file in \bbi.
1171 \item Lines starting with a \texttt{\#} or with a \texttt{\//} are treated as comments in \bbi scripts.
1172 \item Lines between a line starting with a \texttt{\//*} an a line starting with a \texttt{*\//} are treated as comments in \bbi scripts.
1173 \end{itemize}
1174
1175 \hrule
1176 % ==========================================
1177
1178 % ==========================================
1179 \subsubsection{Creating command line applications}
1180 \label{bbi-command-line-app}
1181 % ==========================================
1182
1183 Now that you now how to create complex black boxes 
1184 (with \texttt{define/endefine}), think 
1185 back to the \texttt{workspace} object. 
1186 Remember that it is also 
1187 a \texttt{complex black box}. 
1188 In fact what you are doing when you type \bbi commands 
1189 outside a \texttt{define/endefine} block 
1190 is to progressively define the \texttt{workspace} 
1191 complex black box.
1192 You can think of it like if at start 
1193 \bbi was issuing a command \texttt{'define workspace'} 
1194 and then letting you define the interior of the box 
1195 \texttt{workspace}.
1196
1197 Remember that the command \texttt{inputs} 
1198 allows to define an input of a complex box. 
1199 Now, if you use the command \texttt{input} 
1200 outside a \texttt{define/endefine} block then 
1201 it defines an input of the \texttt{workspace} box, 
1202 that is an input of the \emph{main program}. 
1203 This input will then be connected to the 
1204 parameters that the user passes to the command line.
1205
1206 For example, consider the script: 
1207
1208 \begin{file}{add.bbs}
1209 \begin{verbatim}
1210 load std
1211 new Add a
1212 input x a.In1 "first number to add"
1213 input y a.In2 "second number to add"
1214 print "x+y=$a.Out$"
1215 \end{verbatim}
1216 \end{file}
1217
1218 The third and fourth lines define two inputs \texttt{x} 
1219 and \texttt{y}. When you execute this script, 
1220 you can pass these two arguments on the command line, 
1221 like this:
1222
1223 \begin{verbatim}
1224 > bbi add x=1 y=1
1225 x+y=2
1226 \end{verbatim}
1227
1228 You can also invoke \bbi the option \texttt{-h}, 
1229 which gives help on the \texttt{workspace} box:
1230
1231 \begin{verbatim}
1232 > bbi add -h
1233  User's workspace
1234  By: bbi (internal)
1235  * Inputs: 
1236     'x' <double>: first number to add
1237     'y' <double>: second number to add
1238 \end{verbatim}
1239
1240 To get a better help, use the \texttt{description} 
1241 and \texttt{author} commands:
1242
1243 \begin{file}{add.bbs}
1244 \begin{verbatim}
1245 description "Adds two numbers"
1246 author "foo@bar.com"
1247 load std
1248 new Add a
1249 input x a.In1 "first number to add"
1250 input y a.In2 "second number to add"
1251 print "x+y=$a.Out$"
1252 \end{verbatim}
1253 \end{file}
1254
1255 Now if you ask for help on the \texttt{add} script, you get:
1256
1257 \begin{verbatim}
1258 > bbi add -h
1259  Adds two numbers
1260  By: foo@bar.com
1261  * Inputs: 
1262     'x' <double>: first number to add
1263     'y' <double>: second number to add
1264 \end{verbatim}
1265
1266 Rather than getting the inputs of a script 
1267 from the command line, you can ask \bbi to 
1268 prompt the user for the values, using the \texttt{-t}
1269 commutator:
1270
1271 \begin{verbatim}
1272 > bbi add -t
1273 x=[the program waits for user answer]2
1274 y=[the program waits for user answer]5
1275 x+y=7
1276 \end{verbatim}
1277
1278 If \bbi is compiled in graphical mode (with \wx), 
1279 you can also use the \texttt{-g} commutator. 
1280 \bbi then prompts the user in graphical mode, 
1281 displaying a dialog box for each input,
1282 like in fig. \ref{bb-input-dialog-box}.
1283
1284 \begin{figure}[!ht]
1285 \caption{\label{bb-input-dialog-box}Input dialog box}
1286 \begin{center}
1287 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1288 \end{center}
1289 \end{figure}
1290
1291 % ==========================================
1292 \hrule
1293 \paragraph{Summary}
1294 %\hrule
1295 \begin{itemize}
1296 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1297 when they are used outside a \texttt{define/endefine} block allow 
1298 to define the inputs, description and author of the main program.
1299 \item Inputs of the main program can be passed on the command line 
1300 using the syntax \texttt{<input-name>=<value>}. 
1301 No white space is allowed, if the value or the input name 
1302 contains white spaces, enclose them 
1303 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1304 \item The \texttt{-h} option of \bbi prints help on the main program.
1305 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1306 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1307 \end{itemize}
1308 \hrule
1309 % ==========================================
1310
1311 % ==========================================
1312 \subsubsection{Using graphical interface boxes (widget boxes)}
1313 \label{bbi-widget}
1314 % ==========================================
1315
1316 % ==========================================
1317 \subsubsection{Overwiew}
1318 \label{bbi-overview}
1319 % ==========================================
1320
1321 If \bbi is compiled in graphical mode 
1322 (option \texttt{BUILD\_bbi\_GRAPHICAL} of \cmake, requires \wx),
1323 then you can use special black boxes which are 
1324 graphical interface components (widgets). 
1325 Basic components are provided in the package \texttt{wx}, 
1326 such as buttons, sliders, file open/save dialogs, etc.
1327
1328 As first example, type the following commands in \bbi:
1329 \begin{verbatim}
1330 > load wx 
1331 > new InputText t
1332 > print $t.Out$\n
1333 \end{verbatim}
1334
1335 When you type \texttt{enter} after the last line, 
1336 a window pops up in which you can entrer a text.
1337 When you close the window, the text you entered is printed by 
1338 the \texttt{print} command.
1339
1340 Type \texttt{help wx}, you get something like:
1341 \begin{verbatim}
1342  Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1343  Basic graphical interface elements (sliders, buttons ...) based on wxWidgets
1344  Black boxes : 
1345    ColourSelector        : Colour Selector dialog (bbfication of wxColourSele...
1346    ColourSelectorButton  : A button which displays a colour picker dialog whe...
1347    CommandButton         : Button which executes bbi commands
1348    DirectorySelector     : Pops up a directory selection dialog (wxDirDialog)
1349    FileSelector          : Pops up a file selection dialog for reading or sav...
1350    InputText             : A zone in which the user can enter a text (wxTextC...
1351    LayoutLine            : LayoutLine widget (wxBoxSizer)
1352    LayoutSplit           : Widget which splits a window in two fixed size par...
1353    LayoutTab             : LayoutTab widget (wxNotebook)
1354    OutputText            : Text zone to be inserted into a window (wxStaticTe...
1355    RadioButton           : RadioButton group widget 0-9 entries
1356    Slider                : Slider widget (wxSlider)
1357 \end{verbatim}
1358
1359 You can reproduce the same experiment as above using a 
1360 \texttt{Slider} or a \texttt{FileDialog} rather than a \texttt{InputText}.
1361 See the files \texttt{test*.bbs} in the \texttt{scripts/test} directory.
1362
1363 There are two kinds of widgets: ``terminal'' widgets and ``container'' widgets.
1364 The \texttt{InputText}, \texttt{FileDialog} or \texttt{Slider} widgets 
1365 are ``terminal'' widgets. 
1366 ``container'' widgets are of another kind: they are designed to 
1367 contain other widgets in order to build larger dialog boxes. 
1368 For example, the \texttt{LayoutSplit} widget is a container which 
1369 ``splits'' horizontally a window into two parts, 
1370 each part including another widget. 
1371 The size of the two parts can be adjusted by the user thanks 
1372 to a ``handle''.
1373
1374 The script \texttt{scripts/test/testSplit.bbs} demonstrate its use. 
1375 Run it: it displays a window with two sliders. 
1376 Move the sliders and close the window. 
1377 The final positions of the sliders are printed out. 
1378 Now edit the file to see how this is done:
1379
1380 \begin{file}{scripts/test/testSplit.bbs}
1381 \begin{verbatim}
1382 load std
1383 load wx
1384
1385 new Slider s1
1386 new Slider s2
1387
1388 new LayoutSplit s
1389 connect  s1.Widget s.Widget1
1390 connect  s2.Widget s.Widget2
1391
1392 print s1=$s1.Out$\\n
1393 print s2=$s2.Out$\\n
1394 \end{verbatim}
1395 \end{file}
1396
1397 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1398 A \texttt{LayoutSplit} box \texttt{s} is also created. 
1399 The \texttt{connect} commands then ``includes'' the sliders in the 
1400 split ``container''. 
1401 The input \texttt{Widget} is common to all widget boxes: 
1402 every widget can be inserted into another widget. 
1403 The outputs \texttt{Widget1},\texttt{Widget2}  are specific of \emph{container} 
1404 widgets 
1405 (in \bbi type \texttt{help Slider}: 
1406 you will see the output \texttt{Widget}; 
1407 type \texttt{help LayoutSplit}: 
1408 you will see the inputs \texttt{Widget1} and \texttt{Widget2} 
1409 and the output \texttt{Widget}). 
1410 When you connect the \texttt{Widget} output of a container 
1411 to the \texttt{Widget}i input of a widget, 
1412 you order to include the widget in the container.
1413 Of course, the order of connection is important. 
1414 In our case, the slider \texttt{s1} is included first, 
1415 then the slider \texttt{s2}: \texttt{s1} will be placed 
1416 on top of \texttt{s2} (the \texttt{LayoutSplit} box is 
1417 implemented that way, but this is arbitrary choice).
1418
1419 Right now, there are only \emph{three} container widgets in the \texttt{wx} package: 
1420 the \texttt{LayoutSplit} widget we just described, the \texttt{LayoutLine} , and the \texttt{LayoutTab}
1421 widget. 
1422
1423 The \texttt{LayoutLine} widget can have multiple children and 
1424 divides its window into as much parts as children, 
1425 each part of equal size. 
1426 The orientation of the \texttt{LayoutSplit} or of the \texttt{LayoutLine}  can be changed by the input \texttt{Orientation}.
1427 See the example \texttt{test/testSizer.bbs}.
1428 With only those two containers you can already create 
1429 complex dialog boxes (of course containers can be nested, which 
1430 leads to tree-like structures of widgets). 
1431 See the script \texttt{bbtk/share/bbtk/bbs/wx/appli/ExampleLayoutSplit.bbs} for an example.
1432
1433 The \texttt{LayoutTab}  widget is based on the \texttt{wxNotebook.}
1434
1435 One word about a special widget in the package \texttt{wx}: 
1436 the \texttt{Button}... to be continued.
1437
1438 % ==========================================
1439 \subsubsection{Deeper in the boxes}
1440 \label{bbi-deep-box}
1441 % ==========================================
1442
1443 Any widget box has two mandatory Outputs :
1444
1445 \begin{itemize}
1446   \item {\bf\emph{Widget}} : that is the \texttt{wxWindow} itself. If it's not connected to the \texttt{Widget}\emph{i} of any \emph{Layout box}, it
1447      will popup. If it's connected to the \texttt{Widget}\texttt{\emph{i}} of any \texttt{Layout box}, it will be embedded in its parent window.
1448   \item {\bf\emph{Boxchange}}  : Signals any modification of the box. This output may be connect if necessary to the \emph{BoxExecute} of an other box,
1449    further within the execution pipeline.
1450 \end{itemize}    
1451
1452 Any widget box has two mandatory Inputs :
1453 \begin{itemize}
1454   \item {\bf\emph{BoxExecute}}     : Any signal received by this input executes the box
1455   \item {\bf\emph{BoxProcessMode}} : Sets the processing mode of the box :
1456   \begin{itemize}
1457     \item {\bf\emph{Pipeline}} : bbUpdate() calls Process only if Status == MODIFIED (normal pipeline processing)
1458     \item {\bf\emph{Always}}   : bbUpdate() always calls Process
1459     \item {\bf\emph{Reactive}} : bbSetModifiedStatus() calls bbUpdate()    
1460   \end{itemize}   
1461 \end{itemize}
1462
1463 Any widget box has five Inputs, that will be dealt with only if the box is not connected to the \emph{Widget}i of any \emph{Layout box} :  
1464 \begin{itemize}
1465   \item {\bf\emph{WinHeight}} : Height of the window 
1466   \item {\bf\emph{WinWidth}}  : Width of the window  
1467   \item {\bf\emph{WinTitle}}  : Title of the window
1468   \item {\bf\emph{WinClose}}  : Any received signal closes the window
1469   \item {\bf\emph{WinHide}}   : Any received signal hides the window
1470   \item {\bf\emph{WinDialog}} : When set to 'true', creates a \emph{dialog window}, that blocks the pipeline until it is closed (\emph{modal})   
1471 \end{itemize}
1472
1473
1474 Any \emph{Layout box} (i.e. \emph{LayoutLine}, \emph{LayoutSplit} or \emph{LayoutTab}) has at one or more mandatory Inputs :
1475 \begin{itemize}
1476   \item {\bf\emph{Widget}}\texttt{i} : e.g. a \emph{LayoutSplit} box (Widget which splits a window in two fixed size parts) 
1477        has two Input parameters \emph{Widget1} and \emph{Widget2}, used to embed the child windows.
1478 \end{itemize} 
1479
1480
1481 % ==========================================
1482 \subsection{More on ...}
1483 \label{bbi-more-on}
1484 % ==========================================
1485
1486 % ==========================================
1487 \subsubsection{Black box packages}
1488 \label{bbi-more-on-packages}
1489 % ==========================================
1490
1491 There are various others user-intended packages :
1492 \begin{itemize}
1493 \item{vtk} \\
1494 It contains some vtk based image processing filters :
1495 %   \begin{enumerate}
1496
1497      \paragraph{AppendPolyData}
1498      Appends one of more polygonal datasets into a single polygonal dataset 
1499
1500      \paragraph{ConeSource}
1501      Creates a Cone 
1502
1503      \paragraph{ImageAnisotropicDiffusion3D}
1504 vtkImageAnisotropicDiffusion3D diffuses an volume iteratively. \\
1505 The neighborhood of the diffusion is determined by the instance flags. \\
1506 if 'Faces' is on, the 6 voxels adjoined by faces are included in the neighborhood. \\
1507 If 'Edges' is on the 12 edge connected voxels are included, and if 'Corners' is on, the 8 corner connected voxels are included. \\
1508 'DiffusionFactor' determines how far a pixel value moves toward its neighbors, and is insensitive to the number of neighbors chosen.\\ 
1509 The diffusion is anisotropic because it only occurs when a gradient measure is below 'GradientThreshold'. \\
1510 Two gradient measures exist and are toggled by the 'GradientMagnitudeThreshold' flag. \\
1511 When 'GradientMagnitudeThreshold' is on, the magnitude of the gradient, computed by central differences, above 'DiffusionThreshold' a voxel is not
1512 modified. \\
1513 The alternative measure examines each neighbor independently.\\ 
1514 The gradient between the voxel and the neighbor must be below the 'DiffusionThreshold' for diffusion to occur with THAT neighbor.\\
1515      Receives : \\
1516      - In : an image (vtkImageData*)\\
1517      - Diffusion : Difference threshold that stops the diffusion\\
1518      Outputs : \\
1519      - Out : the isosurface mesh (vtkPolyData*)
1520      
1521      \paragraph{ImageCharacteristics}
1522      Exports objet sizes, and Spacings
1523      
1524      \paragraph{ImageDilateErode3D}
1525      Dilates one value and erodes another.\\ 
1526      vtkImageDilateErode3D will dilate one value and erode another. \\
1527      It uses an elliptical foot print, and only erodes/dilates on the boundary of the two values. \\
1528      The filter is restricted to the X, Y, and Z axes for now.\\ 
1529      It can degenerate to a 2 or 1 dimensional filter by setting the kernel size to 1 for a specific axis. \\
1530      (bbfication of vtkImageDilateErode3D) \\
1531      Receives : \\
1532      - In : an image (vtkImageData*)\\
1533      - DilateValue : The dilatation value\\
1534      - ErodeValue : The erosion value\\
1535      Outputs : \\
1536      - Out : the isosurface mesh (vtkPolyData*)     
1537      
1538      \paragraph{ImageGaussianSmooth}\\
1539      Performs a gaussian convolution of the input image\\
1540      Receives : \\
1541      - In : an image (vtkImageData*)\\
1542      - StdDevX : Standard deviation in X direction\\
1543      - StdDevY : Standard deviation in Y direction\\
1544      Outputs : \\
1545      - Out : the isosurface mesh (vtkPolyData*)       
1546      
1547      \paragraph{ImagePlanes}
1548      Creates three 3D planes with the input image mapped onto with which the user can interact; \\ 
1549      The output vtkImagePlaneWidget objects are to be inserted into a 3D scene (e.g. a Viewer3D)
1550      Receives : \\
1551      - In : an image (vtkImageData*)\\
1552      Outputs : \\     
1553      - PlaneX : the image plane in X direction (vtkImagePlaneWidget*)\\
1554      - PlaneY : the image plane in Y direction (vtkImagePlaneWidget*)\\
1555      - PlaneY : the image plane in Z direction (vtkImagePlaneWidget*)\\
1556      
1557           Outputs : \\
1558      - Out : the isosurface mesh (vtkPolyData*)  
1559            
1560      \paragraph{IsoSurfaceExtractor}
1561      Extracts an iso-surface of a 3D image and creates a vtkProp3D object to insert into a 3D scene (e.g. a Viewer3D)
1562      Receives : \\
1563      - In : an image (vtkImageData*)\\
1564      - Isovalue : the isosurface value (double)\\
1565      - Colour : Surface colour (vector of 3 doubles)
1566      Outputs : \\
1567      - Out : the isosurface (vtkProp3D**)
1568      
1569      \paragraph{MarchingCubes}
1570      Extracts an iso-surface of an image using the marching cubes algorithm (bbfication of vtkMarchingCubes)\\
1571      Receives : \\
1572      - In : an image (vtkImageData*)\\
1573      - Value : the isosurface value (double)\\
1574      Outputs : \\
1575      - Out : the isosurface mesh (vtkPolyData*)
1576      
1577      \paragraph{MIPCreator}     
1578      Creates a Maximum Intensity Projection (MIP) view of a 3D image.\\
1579      Receives : \\
1580      - In : an image (vtkImageData*)\\
1581      - Scale : the Gray scale scaling (float) \\
1582      - Shift : the Gray scale shift (float) \\    
1583      Ouputs : \\
1584      - Out : The MIP object (vtkProp3D*) to be plugged into a 3D Viever
1585
1586      \paragraph{MetaImageReader}
1587      Reads .mhd / .mhd image formats (bbfication of vtkMetaImageReader) \\
1588      Receives : \\
1589      - In : the name of the file to be read (std::string)
1590      Outputs :
1591      - Out : The image (vtkImageData*)     
1592      
1593      \paragraph{SegmentationConnectivity} \\
1594      Segmentation with min max threshold and connectivity  \\  
1595      Receives : \\
1596      - In : an image (vtkImageData*)\\
1597      - PositionXYZ : initial position (std::vector<int>) \\
1598      - ThresholdMinMax : min, max threshold values (std::vector<int>) \\
1599      Outputs : \\
1600      - Out : The image (vtkImageData*)       
1601           
1602      \paragraph{SphereSource}
1603      Creates a Sphere      
1604 %   \end{enumerate}
1605
1606 \item{itk} \\
1607 It contains some itk based image processing filters :
1608  
1609      \paragraph{BinaryThresholdImageFilter}
1610      Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter) 
1611
1612      \paragraph{DICOMSeriesFileNames}
1613      Reads a series from a DICOM directory as a 3D itk image     
1614
1615      \paragraph{ExtractImageFilter}
1616      Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)     
1617
1618      \paragraph{ImageProperties}
1619      Outputs different properties of an image (type, dimension, size, spacing, ...)      
1620
1621      \paragraph{ImageRegion}
1622 Creates a generic ImageRegion (bbtk::any) from two vectors providing the index and size of the region. 
1623 The dimension D of the actual itk::ImageRegion created is the max of the sizes of Index and Size 
1624 (the smallest vector is padded by zeros)     
1625
1626      \paragraph{ImageReader}
1627 Generic itk image reader
1628
1629      \paragraph{ImageWriter}
1630 Generic itk image writer
1631
1632      \paragraph{ImageSeriesReader}
1633 Generic itk image series reader.
1634
1635      \paragraph{ResampleImageFilter}
1636 Resamples an image
1637
1638 \item{itkvtk} \\
1639 It doesn't contain any end user intended box, only adaptors : to convert a generic itkImage to a vtkImageData, and vtkImageData* to a generic itkImage pointer 
1640
1641 Sorry nothing is done, right now for meshes. 
1642
1643 \item{wxvtk} \\
1644
1645 It contains two atomic black boxes.
1646
1647      \paragraph{Viewer2D} 
1648      Receives : \\
1649      - a \textless vtkImageData* \textgreater (In),\\
1650      - an Orientation(0:yz / 1:xz / 2:xy),\\
1651      - an initial slice number (Slice).\\
1652      Outputs :\\
1653      - a \textless vtkRenderer* \textgreater (Renderer)
1654      
1655      \paragraph{Viewer3D} 
1656      Receives :\\
1657      - up to 5 Input Actors (\textless vtkProp3D* \textgreater),\\
1658      - up to 5 Input Observers (\textless vtkInteractorObserver* \textgreater), \\
1659      - a boolean 'Stereo' option, to use Red-Blue filter     
1660      Outputs :\\
1661      - an Interactor (\textless wxVTKRenderWindowInteractor* \textgreater) with which vtk widgets can interact, \\
1662      - a Renderer (\textless vtkRenderer* \textgreater) to which actors can be added.
1663
1664 It contains too some sophisticated complex black boxes :
1665  
1666      \paragraph{IsoSurfaceWithControls} 
1667      Image iso-surface extractor (vtk::IsoSurfaceExtractor) with associated control panel (isovalue, opacity and colour)\\
1668      Receives :\\
1669      - an initial isovalue (Isovalue)
1670      - an initial opacity  (Opacity)
1671      - an initial colour   (Colour)
1672      Outputs :\\
1673      \textless vtkProp3D* \textgreater (In)\\
1674       
1675      \paragraph{MIPWithControls}     
1676      Maximum Intensity Projection (MIP) creator (vtk::MIPCreator) with associated control panel (shift and scale) \\
1677     Receives :\\
1678      - an initial scale (Scale)
1679      - an initial shift  (Shift) 
1680      Outputs :\\
1681      \textless vtkProp3D* \textgreater (In)\\
1682          
1683 \item{wx} \\
1684
1685 Some boxes are the bbfication of usefull xwWidgets, some other ones are more
1686 sophisticated.
1687
1688     \paragraph{ColourSelector} Colour Selector dialog (bbfication of wxColourSelector) \\
1689                         %\begin{verbatim}
1690          \texttt{Out} : Colour choosen in format '[0,1] [0,1] [0,1]' 
1691                         %\end{verbatim}
1692
1693     \paragraph{ColourSelectorButton} A button which displays a colour picker dialog when clicked \\
1694                         %\begin{verbatim}
1695           \texttt{In} :Initial colour \\
1696           \texttt{Out} : Colour choosen in format '[0,1] [0,1] [0,1]'
1697                         %\end{verbatim} \\
1698
1699     \paragraph{CommandButton} Button which executes bbi commands \\
1700                         %\begin{verbatim}
1701           \texttt{In} : Commands to be executed separated by commas (;). Each single quote (') is replaced by a double quote ("). \\
1702           \texttt{Label} : Label of the button  \\
1703           \texttt{Widget} : Output widget \\
1704                         %\end{verbatim}
1705
1706     \paragraph{DirectorySelector} Pops up a directory selection dialog (wxDirDialog)\\
1707                         %\begin{verbatim}
1708           \texttt{DefaultDir} : The default directory\\
1709           \texttt{Message} : Message to show on the dialog \\
1710           \texttt{Title} : Title of the dialog \\
1711           \texttt{Out} : The directory selected by the user\\
1712                         %\end{verbatim}
1713  
1714     \paragraph{FileSelector} Pops up a file selection dialog for reading or saving (wxFileDialog)\\
1715                         %\begin{verbatim}
1716           \texttt{DefaultDir} : The default directory \\
1717           \texttt{DefaultFile} : The default filename \\
1718           \texttt{Message} : Message to show on the dialog \\
1719           \texttt{OpenSave} : Open for an open dialog (default) / Save for a save dialog\\ 
1720           \texttt{Title} : Title of the dialog \\
1721           \texttt{Wildcard} : A wildcard, such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif" \\
1722           \texttt{Out} : The file selected by the user \\
1723                         %\end{verbatim}
1724
1725     \paragraph{InputText} A zone in which the user can enter a text (wxTextCtrl)\\
1726                         %\begin{verbatim}
1727           \texttt{In} : Initial text (default '')\\ 
1728           \texttt{Title} : Title of the input zone (default '')\\ 
1729           \texttt{WinTitle} : Title of the window (*)\\
1730           \texttt{Out} :Current text\\
1731                         %\end{verbatim}
1732
1733     \paragraph{LayoutLine} LayoutLine widget (wxBoxSizer)\\
1734                         %\begin{verbatim}
1735           \texttt{Orientation} Orientation (default V), 0=H=HORIZONTAL , 1=V=VERTICAL \\
1736           \texttt{Widget}1 widget 1 \\
1737           \texttt{Widget2} widget 2 \\
1738           \texttt{Widget3} widget 3 \\
1739           \texttt{Widget4} widget 4 \\
1740           \texttt{Widget5} widget 5 \\
1741           \texttt{Widget6} widget 6 \\
1742           \texttt{Widget7} widget 7 \\
1743           \texttt{Widget8} widget 8 \\
1744           \texttt{Widget9} widget 9\\
1745           %\end{verbatim}    
1746     
1747     \paragraph{LayoutSplit} Widget which splits a window in two fixed size parts (wxSplitterWindow)\\ 
1748                         %\begin{verbatim}
1749           \texttt{Orientation} : Orientation (default H), 0=H=HORIZONTAL , 1=V=VERTICAL\\ 
1750           \texttt{Proportion} : Proportion (in percent) of the first children in the window\\ 
1751           \texttt{Widget1} : Upper or left widget\\ 
1752           \texttt{Widget2} : Lower or right widget\\
1753                         %\end{verbatim}
1754
1755     \paragraph{LayoutTDown} Creates a 'T like' complex container : Down {UpLeft, UpRight} \\
1756                         %\begin{verbatim}
1757           \texttt{Widget1} : UpLeft container\\
1758           \texttt{Widget2} : UpRight container\\ 
1759           \texttt{Widget3} : Down container\\
1760                         \begin{verbatim}
1761 //                       ---------------
1762 //                       |      |      |
1763 //                       |  W1  |  W2  |
1764 //                       |-------------|
1765 //                       |             |
1766 //                       |     W3      |
1767 //                       ---------------
1768                         \end{verbatim}
1769    
1770     \paragraph{LayoutTLeft} Creates a 'T like' complex container :  Left {RigthUp, RightDown}\\
1771                         %\begin{verbatim}
1772            \texttt{input}  Widget1 : "UpLeft container"\\ 
1773            \texttt{input}  Widget2 : "UpRight container"\\  
1774            \texttt{input}  Wigdet3 : "Down container"\\ 
1775                         \begin{verbatim} 
1776 //                       ---------------
1777 //                       |      |  W2  |
1778 //                       |  W1  |      |
1779 //                       |      |------|
1780 //                       |      |  W3  |
1781 //                       |      |      |
1782 //                       ---------------   
1783                         \end{verbatim}
1784
1785     \paragraph{LayoutTRight} Creates a 'T like' complex container : Right {LeftUp, LeftDown}\\
1786                         %\begin{verbatim}
1787           \texttt{input} Widget1 currentBox.Widget1 "Up container"\\
1788           \texttt{input} Widget2 down.Widget1       "DownLeft container"\\ 
1789           \texttt{input} Widget3 down.Widget2       "DownRight container"\\    
1790                         \begin{verbatim}  
1791 //                       ---------------
1792 //                       |      |      |
1793 //                       |  W1  |      |
1794 //                       |------|  W2  |
1795 //                       |  W3  |      |
1796 //                       |      |      |
1797 //                       ---------------
1798                         \end{verbatim}
1799   
1800     \paragraph{LayoutTUp} Creates a 'T like' complex container : Up {DownLeft, DownRight} as w1{w2,w3}\\ 
1801                         \begin{verbatim} 
1802          \texttt{ input} Widget1 currentBox.Widget1 "Up"\\
1803           \texttt{input} Widget2 down.Widget1       "DownLeft"\\ 
1804           \texttt{input} Widget3 down.Widget2       "DownRight"\\
1805      
1806 //                       ----------------
1807 //                       |    W1        |
1808 //                       |              |
1809 //                       |------|-------|
1810 //                       | W3   |  W2   |
1811 //                       |      |       |
1812 //                       ----------------
1813                 \end{verbatim}
1814                           
1815     \paragraph{LayoutTab} LayoutTab widget (wxNotebook)\\
1816                         %\begin{verbatim}
1817           \texttt{Orientation} Orientation (default T), 0=T=TOP , 1=R=RIGHT , 2=B=BOTTON , 3=L=LEFT \\
1818           \texttt{Widget1} widget 1 \\
1819           \texttt{Widget2} widget 2 \\
1820           \texttt{Widget3} widget 3 \\
1821           \texttt{Widget4} widget 4 \\
1822           \texttt{Widget5} widget 5 \\
1823           \texttt{Widget6} widget 6 \\
1824           \texttt{Widget7} widget 7 \\
1825           \texttt{Widget8} widget 8 \\
1826           \texttt{Widget9} widget 9 \\   
1827 %\end{verbatim}
1828    
1829     \paragraph{OutputText}              Text zone to be inserted into a window (wxStaticText)\\
1830                         %\begin{verbatim}
1831           \texttt{In} Text \\
1832           \texttt{Title} Title prepended to the text\\   
1833                         %\end{verbatim}
1834                            
1835     \paragraph{RadioButton}             RadioButton group widget 0-9 entries\\
1836                         %\begin{verbatim}
1837           \texttt{In} Set initial item \\
1838           \texttt{In0} option 0\\ 
1839           \texttt{In1} option 1\\ 
1840           \texttt{In2} option 2\\ 
1841           \texttt{In3} option 3\\ 
1842           \texttt{In4} option 4\\ 
1843           \texttt{In5} option 5 \\
1844           \texttt{In6} option 6 \\
1845           \texttt{In7} option 7 \\
1846           \texttt{In8} option 8 \\
1847           \texttt{In9} option 9 \\
1848           \texttt{Title} Title of the widget (default '')\\ 
1849           \texttt{Out} Number of the selected Item 
1850                         %\end{verbatim}
1851                            
1852     \paragraph{Slider}          Slider widget (wxSlider)\\
1853                         %\begin{verbatim}
1854           \texttt{ChangeResolution} Enables the user to change the slider resolution (default FALSE) \\
1855           \texttt{In} Initial slider position(default 0) \\
1856           \texttt{Label} Show slider labels ? (default FALSE) \\
1857           \texttt{Max} Maximum value of the slider (default 500)\\ 
1858           \texttt{Min} Minimum value of the slider (default 0)\\ 
1859           \texttt{Orientation} Orientation : (default H) 0=H=HORIZONTAL, 1=V=VERTICAL\\ 
1860           \texttt{ReactiveOnTrack} Slider sends info when track moves (default 0 = no)\\ 
1861           \texttt{Title} Title shown above the slider (default '')\\     
1862                         %\end{verbatim}
1863 \end{itemize}
1864 % ==========================================
1865 \subsubsection{Pipeline processing}
1866 \label{bbi-more-on-pipeline-processing}
1867 % ==========================================
1868 \begin{itemize}
1869 \item the ``control'' mechanism in bbi (switch exec commands, e.g. Button)
1870 \item the role of ProcessMode to update widgets.
1871 \end{itemize}
1872 % ==========================================
1873 \subsubsection{Complex black boxes}
1874 \label{bbi-more-on-complex-black-boxes}
1875 Creation of complex widgets (containers, contained...)
1876
1877 %\subsubsection{Advanced issues}
1878 %\paragraph{Reducing the number of inputs of a box}
1879
1880 % ==========================================
1881 \subsubsection{Errors}
1882 \label{bbi-more-on-errors}
1883
1884 % ==========================================
1885 \subsubsection{\bbtk configuration file and search pathes}
1886 \label{bbi-more-on-configuration}
1887
1888 At start, \bbi tries to open an \texttt{xml} 
1889 configuration file named \texttt{bbtk\_config.xml}. 
1890 The search order is 
1891 \begin{enumerate}
1892 \item The current directory
1893 \item The subdir \texttt{.bbtk} of the user's home directory. 
1894 \begin{itemize} 
1895 \item On \texttt{Unix}, the home directory is the
1896 one stored by the environnement variable \texttt{HOME}, 
1897 typically \texttt{/home/username}.
1898 \item On \texttt{Windows}, the home directory is 
1899 the user's profile directory stored by the environnement 
1900 variable \texttt{USERPROFILE}, 
1901 typically \texttt{C:\\...}.
1902 \end{itemize}
1903 \item If none of these two pathes contains the file then it creates 
1904 a new one in the \texttt{.bbtk} directory. 
1905 \end{enumerate}
1906
1907 Once created, you can edit the \texttt{bbtk\_config.xml} file located 
1908 in your \texttt{.bbtk} directory. It contains:
1909
1910 \begin{file}{bbtk\_config.xml}
1911 \begin{verbatim}
1912 <?xml version="1.0" encoding="iso-8859-1"?>
1913 <config>
1914   <bbtk_url> http://www.creatis.insa-lyon.fr/software/bbtk </bbtk_url>
1915   <bbs_path> </bbs_path>     
1916   <package_path> </package_path> 
1917   <data_path> </data_path>
1918 </config>
1919 \end{verbatim}
1920 \end{file}
1921
1922 You can add pathes to 
1923 \begin{itemize}
1924 \item A custom folder in which to search for \texttt{.bbs} scripts (\texttt{include} command of \bbi) by adding an \texttt{xml} tag: 
1925 \texttt{<bbs\_path>complete\_path\_to\_folder<\/bbs\_path>}.
1926 \item A custom folder in which to search for packages (\texttt{load} command of \bbi) by adding an \texttt{xml} tag: 
1927 \texttt{<package\_path>complete\_path\_to\_folder<\/package\_path>}.
1928 \end{itemize}
1929
1930 % ==========================================
1931 \subsection{Language reference}
1932 \label{bbi-reference}
1933 % ==========================================
1934
1935
1936
1937
1938
1939 % ==========================================
1940 \begin{table}[!ht]
1941 \caption{\label{bbi-reference-box}
1942 \bbi pipeline creation and execution related commands.}
1943 \small
1944 \begin{tabular}{|lcm{6cm}|}
1945 \hline
1946 Command & Parameters & Effect \\ \hline
1947
1948 \texttt{new} & \texttt{<boxtype>} \texttt{<box-name>}& 
1949 Creates a box of type \texttt{boxtype} and name  
1950 \texttt{box-name}.
1951 \\ \hline
1952
1953 \texttt{delete} & \texttt{<box-name>} & 
1954 Destroys the box named \texttt{box-name}.
1955 \\ \hline 
1956
1957 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} & 
1958 Connects the output 
1959 \texttt{output} of the box named \texttt{box1} 
1960 to the input \texttt{input} of the box named \texttt{box2} \\ \hline 
1961
1962 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
1963 Sets the input \texttt{input} of 
1964 the box named \texttt{box} to the value \texttt{value}.
1965 There must exist an \texttt{adaptor} 
1966 in the packages loaded which converts a \texttt{std::string} 
1967 to the type of the input \texttt{input}.
1968  \\ \hline 
1969
1970 \texttt{print} & \texttt{<string>} & 
1971 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the 
1972 output \texttt{output} of the box named \texttt{box}. 
1973 There must exist an \texttt{adaptor} 
1974 in the packages loaded which converts 
1975 the type of the output \texttt{output}
1976 to a \texttt{std::string}.
1977 \\ \hline 
1978
1979 \texttt{exec} & \texttt{<box-name>} & 
1980 Executes the box named \texttt{box-name}.
1981 If needed the boxes 
1982 connected to its inputs 
1983 are also processed recursively (pipeline processing).\\ \hline 
1984 \texttt{exec} & \texttt{freeze} & 
1985  allows to block execution commands while keeping definition commands active.\\ \hline 
1986 \texttt{exec} & \texttt{unfreeze} & 
1987  turns back to 'normal' mode.\\ \hline 
1988 \end{tabular}
1989 \end{table}
1990 % ==========================================
1991
1992
1993
1994 % ==========================================
1995 \begin{table}[!ht]
1996 \caption{\label{bbi-reference-interpreter}\bbi intepreter related commands.}
1997 \small
1998 \begin{tabular}{|lcm{6cm}|}
1999 \hline
2000 Command & Parameters & Effect \\ \hline
2001
2002
2003 \texttt{help} & - & 
2004 Prints help on available commands \\ \hline 
2005
2006 & \texttt{<command-name>} & 
2007 Prints help on the command \texttt{command-name} \\ \hline 
2008
2009 & \texttt{packages} & 
2010 Prints help on available packages and their box types 
2011 (without description)\\ \hline 
2012
2013 & \texttt{<package-name>} & 
2014 Prints help on the package \texttt{package-name} and its boxes 
2015 (with brief description). 
2016 The package must have been previously loaded
2017 \\ \hline 
2018
2019 & \texttt{<box-type>} & 
2020 Prints help (with full description) on the type of box 
2021 \texttt{box-type}. 
2022 The box type must belong to a package which has been previously loaded
2023 \\ \hline 
2024
2025 \texttt{include} & \texttt{<file-name>} & 
2026 Includes and executes the content of the file named \texttt{file-name} 
2027 exactly like if you were typing its content at the place were the 
2028 \texttt{include} command is.
2029 \\ \hline 
2030
2031 \texttt{load} & \texttt{<package-name>} & 
2032 Loads the package \texttt{package-name}\\ \hline 
2033
2034 \texttt{include} & \texttt{<package-name>} & 
2035 Loads the package \texttt{package-name} and includes all the complex black boxes that comes with it \\ \hline 
2036
2037 \texttt{unload} & \texttt{<package-name>}& 
2038 Unloads the package \texttt{package-name}. 
2039 The package must have been previously loaded. 
2040 No box of a type defined in this package must still exist.
2041 \\ \hline 
2042
2043 \texttt{message} & \texttt{<category>} \texttt{<level>} & 
2044 Sets the level of verbosity of \bbi for the category of messages 
2045 \texttt{category} to \texttt{level}.
2046 %See \ref{verbosity}.
2047 \\ \hline 
2048
2049 \texttt{config} & - & Displays the Configuration parameters\\ \hline 
2050
2051 \texttt{reset} & - & Deletes all boxes and unloads all packages so 
2052 that \bbi gets back to its initial state \\ \hline 
2053
2054 \texttt{quit} & - & Exits the interpreter\\ \hline 
2055
2056 \end{tabular}
2057 \end{table}
2058 % ==========================================
2059
2060
2061
2062
2063
2064 % ==========================================
2065 \begin{table}[!ht]
2066 \caption{\label{bbi-reference-complex-box}
2067 \bbi complex black box definition related commands.}
2068 \small
2069 \begin{tabular}{|lcm{6cm}|}
2070 \hline
2071 Command & Parameters & Effect \\ \hline
2072
2073
2074 \texttt{define} & \texttt{<box-type>} & 
2075 Starts the definition of a complex black box of type  
2076 \texttt{box-type}\\ \hline 
2077
2078 \texttt{endefine} & - & 
2079 Ends the definition of a complex black box type\\ \hline 
2080
2081
2082 \texttt{author} & \texttt{<string>} & 
2083 Sets the author(s) of the complex black box currently being defined \\ \hline 
2084
2085 \texttt{description} & \texttt{<string>} & 
2086 Sets the description of the complex black box currently being defined 
2087 \\ \hline 
2088
2089
2090 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} & 
2091 Defines a new input for the current complex black box, 
2092 named \texttt{name}. 
2093 It is defined as corresponding to 
2094 the input \texttt{input} of the box \texttt{box}. 
2095 \texttt{<help>} is the help string for the new input.
2096 The box \texttt{box} must already have been created in the complex box 
2097 and of course have an input named \texttt{input}.
2098 \\ \hline 
2099
2100
2101 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} & 
2102 Defines a new output for the current complex black box, 
2103 named \texttt{name}. 
2104 It is defined as corresponding to 
2105 the output \texttt{output} of the box \texttt{box}. 
2106 \texttt{<help>} is the help string for the new output.
2107 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. 
2108 \\ \hline 
2109
2110
2111 \end{tabular}
2112 \end{table}
2113 % ==========================================
2114
2115
2116
2117
2118 % ==========================================
2119 \vspace{0.5cm}\hrule
2120 \section{Using black boxes in \CPP programs}
2121 \label{cpp}
2122 % ==========================================
2123
2124
2125
2126
2127 %\bibliography{all}
2128
2129
2130
2131 %\section{Conclusion}
2132 \end{document}
2133