]> Creatis software - bbtk.git/blob - kernel/doc/bbtkUsersGuide/bbtkUsersGuide.tex
cosmetics
[bbtk.git] / kernel / doc / bbtkUsersGuide / bbtkUsersGuide.tex
1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
3 \input{config.tex}
4
5
6 \def\todo{\scriptsize\fbox{\bf TODO !!}\normalsize}
7 \def\x{\bm{x}}
8 \def\BBTK{{\xspace}The {\bf Black Box Toolkit} }
9 \def\bbtk{{\xspace}$\texttt{bbtk}$ }
10 \def\bbi{{\xspace}$\texttt{bbi}$ }
11 \def\bbStudio{{\xspace}$\texttt{bbStudio}$ }
12 \def\bbfy{{\xspace}$\texttt{bbfy}$ }
13 \def\bbdoc{{\xspace}$\texttt{bbdoc}$ }
14 \def\bbCreatePackage{{\xspace}$\texttt{bbCreatePackage}$ }
15
16 \def\bb{{\xspace}$\texttt{bb}$ }
17 %\def\bbp{{\xspace}$\texttt{bbp}$\xspace}
18
19 \def\cmake{{\xspace}$\texttt{cmake}$ }
20
21 \def\C{{\xspace}$\texttt{C}$ }
22 \def\CPP{{\xspace}$\texttt{C++}$ }
23
24 \def\xml{{\xspace}$\texttt{xml}$ }
25
26 \def\itk{{\xspace}$\texttt{itk}$ }
27 \def\vtk{{\xspace}$\texttt{vtk}$ }
28 \def\gdcm{{\xspace}$\texttt{gdcm}$ }
29 \def\gsmis{{\xspace}$\texttt{gsmis}$ }
30 \def\wx{{\xspace}$\texttt{wxWidgets}$ }
31
32 \def\lin{{\xspace}\textit{Linux} }
33 \def\win{{\xspace}\textit{Windows} }
34
35 % the same macros with no space at the end
36
37 \def\BBTKns{{\xspace}The {\bf Black Box Toolkit}}
38 \def\bbtkns{{\xspace}$\texttt{bbtk}$}
39 \def\bbins{{\xspace}$\texttt{bbi}$}
40 \def\bbfyns{{\xspace}$\texttt{bbfy}$}
41 \def\bbdocns{{\xspace}$\texttt{bbdoc}$}
42 \def\bbCreatePackagens{{\xspace}$\texttt{bbCreatePackage}$}
43
44 \def\bbns{{\xspace}$\texttt{bb}$}
45 %\def\bbp{{\xspace}$\texttt{bbp}$\xspace}
46
47 \def\cmakens{{\xspace}$\texttt{cmake}$}
48
49 \def\Cns{{\xspace}$\texttt{C}$}
50 \def\CPPns{{\xspace}$\texttt{C++}$}
51
52 \def\xmlns{{\xspace}$\texttt{xml}$}
53
54 \def\itkns{{\xspace}$\texttt{itk}$}
55 \def\vtkns{{\xspace}$\texttt{vtk}$}
56 \def\gdcmns{{\xspace}$\texttt{gdcm}$}
57 \def\gsmisns{{\xspace}$\texttt{gsmis}$}
58 \def\wxns{{\xspace}$\texttt{wxWidgets}$}
59
60 \def\linns{{\xspace}\textit{Linux}}
61 \def\winns{{\xspace}\textit{Windows}}
62
63
64
65
66 \begin{document}
67 \begin{center}
68
69 {\Large \BBTK}
70 \vspace{1cm}
71
72 {\Huge User's Guide}
73 \vspace{1cm}
74
75 \bbtk version 1.0
76 \vspace{0.5cm}
77
78
79 Last modified on : September 16, 2008 \\
80 Generated on : \today 
81 \vspace{0.5cm}
82
83 Laurent Guigues, Jean-Pierre Roux
84 \end{center}
85
86 % ==========================================
87 \tableofcontents
88 % ==========================================
89
90 \listoftables
91
92 \listoffigures
93
94
95
96 % ==========================================
97 %\section*{Abstract}
98 % ==========================================
99 \newpage
100 % ==========================================
101 \hrule
102 \section{What is {\bf bbtk} ?}
103 % ==========================================
104 \BBTK(\bbtkns) is a set of tools 
105 (\CPP libraries and executables) 
106 providing a \CPP framework for the definition 
107 of elementary processing \emph{units}, called {\bf black boxes}, 
108 and the definition and execution of processing \emph{chains} 
109 made up of these black boxes. \\
110 It's a part of the \texttt{Creatools suite} composed mainly of :
111 \begin{verbatim}
112  bbtk
113  creaContours
114  creaImageIO
115  creaLib
116  gdcm 
117  itk
118  vtk
119  wxWidgets
120 \end{verbatim}
121
122 % ==========================================
123 \subsection{The black box philosophy}
124 % ==========================================
125
126 \href{http://www.answers.com/topic/black-box-theater}{The Answers Dictionary} defines a {\bf black box} as 
127 \emph{``A device or theoretical construct with known or specified performance characteristics 
128 but unknown or unspecified constituents and means of operation''} \\
129 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
130 defines a {\bf black box} as 
131 \emph{``any component in a system in which only the input and output 
132 characteristics are of interest, without regard to its internal mechanism 
133 or structure''}. \\
134 We should merge theese definitions. : 
135 not only the inputs and outputs are of interest but also 
136 \emph{what the box does} !
137 Hence, I would say that a black box is any \emph{\bf documented} 
138 component of a system, letting the user know  
139 \emph{\bf what} the box is supposed to do and 
140 \emph{\bf how to use it}
141 but not \emph{\bf how it does it}. \\
142
143 \BBTK provides a systematic framework 
144 to encapsulate (or ``wrap'') any 
145 existing \texttt{C} or \CPP processing code into an object 
146 (a black box) having a {\bf generic symbolic interface}, where 
147
148 \begin{itemize}
149 \item{\bf generic} means that the interface is \emph{the same} 
150 for all boxes. Hence one does not need to know which particular 
151 method allows, say, to set a particular input or 
152 get a particular output of the box. 
153 One can use a black box in a purely abstract way. 
154 \item{\bf symbolic} means that a particular 
155 input or output is referenced by a 'name', that is by a symbol 
156 which identifies the input or output. 
157 It also means that symbolic information (text!) is 
158 attached to a box: description of the box, author, 
159 description of its inputs and outputs, etc.
160 \end{itemize}
161
162 (Actually, genericity is achieved because the interface is symbolic. 
163 We let you think about this\dots)
164
165 Of course, symbolic data attached to a box may be 
166 {\bf queried} : what are the inputs/outputs of the box ? 
167 what are their type ? their description ? etc.
168 This allows {\bf automatic documentation} of boxes. 
169
170 The abstract definition of black boxes is the most basic 
171 aspect of \BBTK architecture. 
172 Another key aspect is the groupement of black boxes into 
173 so called {\bf packages}, 
174 which are \emph{dynamic libraries} which can also 
175 be queried, in particular about the boxes they provide. 
176 The package structure then offers a mechanism which 
177 is like a \emph{'plug-in'} mechanism.
178 \BBTK provides the methods to load a package at run-time, 
179 and create instances of the boxes it contains. 
180
181 These two mechanisms (black boxes and packages) 
182 then gives the way to:
183
184 \begin{itemize}
185 \item The definition of an {\bf interpreted script language}, 
186 which allows to manipulate packages and boxes very easily in symbolic way. 
187 \BBTK provides one : \bbi (the Black Box Interpreter). 
188 \item {\bf Automatic documentation} of existing packages. 
189 \texttt{html} documentation of packages is proposed by 
190 \bbins.
191 \end{itemize}
192
193 Finally, these different components allow {\bf efficient} :
194
195 \begin{itemize}
196 \item {\bf capitalization and reuse} of existing processing units, 
197 including {\bf documentation} 
198 \item {\bf testing, prototyping} in a very simple script language
199 \item {\bf inter-operability} between atomic processings which 
200 have been written by different persons, using different libraries, etc. 
201 \end{itemize}
202
203 % ==========================================
204 \subsection{\bbtk components}
205 % ==========================================
206 \BBTK includes :
207 \begin{itemize}
208   \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework 
209     (abstract classes) to develop black boxes and store them into 
210     dynamic libraries, called black box \emph{packages}.
211   \item Different {\bf\emph{black box packages}} :
212     \begin{itemize}
213       \item {\bf\emph{std}} : the 'standard' package including basic useful boxes.
214       \item {\bf\emph{wx}} : basic graphical interface elements (widgets : sliders, buttons, etc. based on the \texttt{wxWidgets} library).  
215       \item {\bf\emph{itk}} : the basic image processing package, based on the \itk library.
216       \item {\bf\emph{vtk}} : the basic images and surfaces processing and vizualization package, based on the \vtk library.
217       \item {\bf\emph{wxvtk}} : widget boxes based on the \vtk library (2D and 3D vizualization and
218       interaction).
219       \item {\bf\emph{itkvtk}} : special boxes (adaptors) to convert \itk structures into \vtk structures and conversally.
220       %\item {\bf\emph{creaImageIO}} : Provides hight level widgets to read images, including DICOM.
221       \item {\bf\emph{toolsbbtk}} : Tools for bbtk administration and package development..      
222     \end{itemize}
223   \item A {\bf\emph{Developement environment}}, called \bbStudio, which provides
224     \begin{itemize}
225       \item An online {\bf\emph{script editor}}
226       \item A powerfull {\bf\emph{Help environment}}, called \bbPackageBrowser
227         whith integrated
228         \begin{itemize}
229           \item Online documentation scaning
230           \item Retreiving boxes on various criterions
231           \item Checking Demo and examples
232         \end{itemize}
233
234       \item An {\bf\emph{interpreter}}, called \bbins, which allows to 
235           load black box packages and to define and execute 
236           processing chains by connecting various black boxes of the already loaded packages.
237       \item {\bf\emph{Utilities}} :
238          \begin{itemize}
239             \item \bbfy generates the \CPP code of a black box from a 
240                description file written in \texttt{xml}.
241                 %\item \bbdoc generates the html documentation of a black box package 
242                 %(author, description, description of its black boxes : 
243                 %author, description, inputs, outputs, and so on).
244             \item \bbCreatePackage allows to create the basic file architecture 
245                to start the development of a new black box package.
246          \end{itemize} 
247     \end{itemize}
248 \end{itemize}
249 The general architecture of \BBTK 
250 is shown in figure \ref{bb-architecture}.
251
252 \begin{figure}[!ht]
253 \caption{\label{bb-architecture}\BBTK architecture}
254 \begin{center}
255 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
256 \end{center}
257 \end{figure}
258
259 \newpage
260
261 % ==========================================
262 \subsection{Structure of this guide}
263 % ==========================================
264
265 This guide is divided into three parts. 
266
267 The first part (\ref{bbStudio}) is a brief presentation of the very intuitive Development
268 environment, \bbStudions.
269
270 The second part (\ref{bb0}) 
271 is devoted to the use of the \emph{black box interpreter} \bbins. 
272 This is the highest level of use of the toolkit, which 
273 allows to create and execute processing chains by connecting 
274 black boxes of existing packages. 
275
276 The third part (\ref{cpp}) explains how to 
277 use the black box toolkit framework in \CPP code, 
278 typically to develop large applications which 
279 involve complex graphical interfaces.
280
281
282 % ==========================================
283 % ==========================================
284 % ==========================================
285 % ==========================================
286 % ==========================================
287 % ==========================================
288 \vspace{0.5cm}\hrule
289 \section{The Development environment (bbStudio)}
290 \label{bbStudio}
291
292 Just run it, typing in a console \bbStudio 
293 or clicking on its icon or its menu entry.
294 At start, \bbStudio opens with a very minimal 'How to use' in the middle. \\
295 Don't forget to read it : it will vanish at the first mouse click. \\
296 \begin{verbatim}
297 1) Click on the 'Demo' or 'Examples' link.
298 2) Select a Demo or an Example
299 3) Click on the [Source] link : the source file is loaded in bbStudio
300 4) Click on the 'Run button' (the down arrow at the bottom right
301    of the source file).
302 \end{verbatim}
303
304 You'll get something like in figure 
305 \ref{bbi-fig-bbStudio-gui-start}
306 (the exact appearance of \bbStudio is Operating System and \bbtk version dependent)
307
308 \begin{figure}[!ht]
309 \caption{\label{bbi-fig-bbStudio-gui-start}The bbStudio Development environment interface at start time}
310 \begin{center}
311 \includegraphics[width=0.7\textwidth]{bbStudioMainPageStart.png}
312 \end{center}
313 \end{figure}
314
315
316 Feel free to resize any part you want.
317 Your preferences will be kept next time you run again \bbStudio. \\
318
319 Let's have a look at the resized window :
320
321 \begin{figure}[!ht]
322 \caption{\label{bbi-fig-bbStudio-gui}The bbStudio Development environment interface}
323 \begin{center}
324 \includegraphics[width=0.7\textwidth]{bbStudioMainPage.png}
325 \end{center}
326 \end{figure}
327
328 You can see four parts :
329 \begin{itemize}  
330   \item {\bf{Files}}
331   \item {\bf{Messages}}
332   \item {\bf{Command}}
333   \item {\bf{Help}}
334 \end{itemize} 
335
336 The stuff is written using the Advanced User Interface library of wxWidgets,
337 whose 'docking manager' allows windows and toolbars to be floated/docked 
338 onto a frame.\\
339 Please don't use this feature at learning time (the snapshots of this document
340  wouldn't match with your screen ...)
341
342 \subsection{'Files' part}
343 \label{bbi-FilesPart}
344
345 It's the .bbs script editor.\\
346 If you load a file holding a script, it will be displayed here, and you'll be
347 able to modify it, to save it, to save-as it, to run it, using the
348 lower toolbar 
349
350
351 \subsection{'Messages' part}
352 \label{bbi-MessagesPart}
353
354 Two kinds of messages will be output here:\\
355 System messages : produced by the kernel, in case of a user mistyping, or an execution error\\
356 Script messages : produced by the \bbtk equivalent of \texttt{printf} or \texttt{std::cout} in user programs
357
358 \subsection{'Command' part}
359 \label{bbi-CommandPart}
360
361 This is where user will type his requirements.
362
363 \subsection{'Help Contents' part}
364 \label{bbi-HelpContentsPart}
365
366 The 'Help Contents' part of \bbStudio is used to browse the html help of \BBTK.
367 All the entries of the starting page are self-explanatory :
368  \begin{itemize}
369    \item {\bf\emph{Help Contents}}
370    \begin{itemize}
371      %\item {\bf\emph{Wiki}} : Direct link to the bbtk Wiki (intranet only, right now, www
372      %later).
373      \item {\bf\emph{Demo}} : Link to some 'sophisticated' demonstrations.
374      \item {\bf\emph{Examples}} : Link to some detailed 'How to use' examples
375    \end{itemize}
376    
377    \item {\bf\emph{Guides}}   
378    \begin{itemize}      
379      \item {\bf\emph{User's Guide}} : Step to step How-to for user who wants to create his own
380      application, just using already existing boxes.
381      \item {\bf\emph{Package Developper's Guide}} : Step to step How-to for user who wants to create his own
382      black boxes.
383      \item {\bf\emph{Developper's Guide}} : For bbtk kernel developpers. Sorry, not yet written.
384      \item {\bf\emph{Reference Manual}} : Sorry, not yet written.
385      \item {\bf\emph{Booklet}} : Vade mecum. Sorry, not yet written.    
386      \item {\bf\emph{Doxygen Documentation}} : Doxygen source browser.
387    \end{itemize}
388         
389    \item {\bf\emph{Boxes}} : Box retrieving on various criterions :
390       \begin{itemize}
391         \item {\bf\emph{By name}} (Alphabetical list)
392         \item {\bf\emph{By package}} (see table : \ref{bbi-list_of_packages})
393         \item {\bf\emph{By category}} (see table : \ref{categories})
394         \item {\bf\emph{Adaptors}} Used internaly to perform type conversions (not end user intended)     
395       \end{itemize}
396       
397  \end{itemize}
398
399 % ==========================================
400 \begin{table}[!ht]
401 \caption{\label{bbi-list_of_packages} List of bbtk supplied packages.}
402 \small
403 \begin{tabular}{|lp{10cm}|}
404 \hline
405 Package         & What it's used for \\ \hline
406 \texttt{std}    & : the 'standard' package including basic useful boxes \\ \hline 
407 \texttt{wx}     & : basic graphical interface elements (widgets : sliders, buttons, etc.) based on the \texttt{wxWidgets} library \\ \hline 
408 \itk    & : the basic image processing package, based on the \itk library. (without description)\\ \hline 
409 \vtk    & : prints help on the package \texttt{package-name} and its boxes (with brief description). The package must have been previously loaded\\ \hline 
410 \texttt{wxvtk}  & : widget boxes based on the \vtk library.\\ \hline 
411 \texttt{itkvtk} & : adaptors to convert \itk structures into \vtk structures and conversally.\\ \hline 
412 %\texttt{creaImageIO} & : provides high level widgets to read images including DICOM.\\ \hline 
413 \texttt{toolsbbtk} & : Tools for bbtk administration and package development.\\ \hline 
414
415 \end{tabular}
416 \end{table}
417 % ==========================================
418
419
420
421
422 % ==========================================
423 \begin{table}[!ht]
424 \caption{\label{categories} \texttt{Black Box} categories}
425 \small
426 \begin{tabular}{|lp{10cm}|}
427 \hline
428  \texttt{Category name}  & : Meaning                                          \\ \hline \\ \hline
429  \texttt{adaptor}        & : Adaptor box                                      \\ \hline
430  \texttt{application}    & : Final application, end user intended             \\ \hline
431  \texttt{atomic box}     & : System category.
432                Automatically assigned to Atomic Black Boxes (c++ defined)     \\ \hline
433  \texttt{complex box}    & : System category.
434                Automatically assigned to Complex Black Boxes (script defined) \\ \hline  
435  \texttt{command line}   & : Script which defines a command line application \\ 
436                          & :(no embedded GUI, but command line imput parameters) \\ \hline
437  \texttt{demo}           & : Demonstration                             \\ \hline
438  \texttt{devel}          & : Developer tool (bbCreatePackage.bbs, ...) \\ \hline
439  \texttt{dicom}          & : DICOM aware box                            \\ \hline 
440  \texttt{example}        & : Example script showing a box use-case      \\ \hline
441  \texttt{filter}         & : Image processing box                       \\ \hline
442  \texttt{image}          & : Image processing related box               \\ \hline
443  \texttt{interaction}    & :                                            \\ \hline
444  \texttt{math}           & : Mathematical operations                    \\ \hline
445  \texttt{mesh}           & : Mesh processing related box                 \\ \hline
446  \texttt{misc}           & : A box that cannot be put in other category ! \\ \hline
447  \texttt{read/write}     & : Box that read or write data from or to disk  \\ \hline
448  \texttt{viewer}         & : Box which displays some data                \\ \hline
449  \texttt{widget}         & : Piece of graphical interface                \\ \hline  
450  \texttt{3D object creator} & : Sophisticated 3D widget  \\ \hline  
451  \texttt{toolsbbtk}         & : Component of bbStudio    \\ \hline  
452 \end{tabular}
453 \end{table}
454
455 % ==========================================
456
457 \begin{table}[!ht]
458 \caption{\label{kinds} \texttt{Black Box} kinds}
459 \small
460 \begin{tabular}{|ll|}
461 \hline
462 \texttt{Kind name}                & : Meaning                         \\ \hline \\ \hline
463 \texttt{ADAPTOR}                  & : Adaptor Box                     \\ \hline
464 \texttt{DEFAULT\_ADAPTOR}         & :                                  \\ \hline
465 \texttt{WIDGET\_ADAPTOR}          & :                                  \\ \hline
466 \texttt{DEFAULT\_WIDGET\_ADAPTOR} & :                                  \\ \hline
467 \texttt{GUI}                      & :                                  \\ \hline
468 \texttt{DEFAULT\_GUI}             & :                                  \\ \hline
469 \texttt{ALL}                      & : If kind='ALL' then sets the level for all kinds \\ \hline
470 \end{tabular}
471 \end{table}
472
473
474 \newpage
475  .\newline
476  .\newline
477      .\newline
478        .\newline
479          .\newline
480            .\newline
481
482                   . \newline 
483 % ==========================================
484 % ==========================================
485 % ==========================================
486 % ==========================================
487 % ==========================================
488 % ==========================================
489 \vspace{0.5cm}\hrule
490 \section{The script manager}
491 \label{bb0}
492 % ==========================================
493
494  Atomatically open in the left upper part of bbStudio.
495  
496
497 \begin{figure}[!ht]
498 \caption{\label{bbi-fig-bbStudio-file0}The bbStudio script manager}
499 \begin{center}
500 \includegraphics[width=0.7\textwidth]{bbFile0.png}
501 \end{center}
502 \end{figure}
503
504 Using the lower tool bar (see figure : \ref{lowertoolbar}), you can :
505
506
507 \begin{figure}[!ht]
508 \caption{\label{lowertoolbar}The lower tool bar}
509 \begin{center}
510 \includegraphics[width=0.7\textwidth]{lowertoolbar.png}
511 \end{center}
512 \end{figure}
513
514
515  \begin{itemize}
516    \item {\bf\emph{New file}} : Create a new file to hold a script
517    \item {\bf\emph{Open file}} : Open a already existing file holding a script 
518    \item {\bf\emph{Close file}} : Close a file holding a script
519    \item {\bf\emph{Save file}} : Save he current file (if modified)
520    \item {\bf\emph{Save file as}} : Save he current file under a different name
521    \item {\bf\emph{Run file}} : Execute the script you just loaded/modified/written
522  \end{itemize}
523
524
525 The script language is very simple. 
526 Everything is done with only a very few commands (See table \ref{bbi-reference-box}).
527 The philosophy of this part is also very simple : 
528 it introduces the \bbi commands using examples, 
529 starting with the most simple commands.  
530 The first section of this part 
531 (\ref{bbi-getting-started})
532 is designed like a tutorial, 
533 which progressively introduces all the concepts of the command interpretor. 
534 We suggest you run \bbStudio and follow the examples, 
535 to see how it works in practice. 
536 At the end of this section, 
537 you will be able to use \bbStudio and write 
538 own black box processing scripts. 
539
540 After this tutorial, 
541 the section \ref{bbi-more-on} 
542 (called \emph{more on...}) 
543 goes deeper into various issues of the command interpretor. 
544 Read it at your convenience, 
545 either linearly to learn more about \bbStudio, 
546 or in random order to get an answer 
547 to a particular question. 
548
549 Finally, the section \ref{bbi-reference}
550 summarizes all the commands of \bbStudions, 
551 their parameters and effect. 
552 Use it as a reference.
553
554
555 \newpage
556
557
558 % ==========================================
559 \subsection{Getting started}
560 \label{bbi-getting-started}
561
562 % ==============================================
563 \subsubsection{Installed tree \emph{vs} Built tree}
564 % ==============================================
565
566 If you want to use the 'installed' version (it means you downloaded and run the Windows
567 installer, or the Fedora package, or you downloaded, compiled and installed the
568 cvs version), just open a console and type \bbStudions, or double click on the application icon. \\
569
570 If you want to run your own uninstalled version (say : you downloaded and compiled the
571 cvs version in order to use a recently commited patch, but you want to be able to still use the standard version), 
572 you have to open a console, cd in the \texttt{bin} directory of the built tree and type \texttt{./bbStudio}.
573
574 % ==============================================
575 \subsubsection{Using an already existing script}
576 % ==============================================
577
578 Run \bbStudio the way you need. \\
579 In the part 'Help contents' (See figure \ref{HelpContents}), select \texttt{Examples} link.
580
581 \begin{figure}[!ht]
582 \caption{\label{HelpContents}Help Contents}
583 \begin{center}
584 \includegraphics[width=0.7\textwidth]{HelpContents.png}
585 \end{center}
586 \end{figure}
587
588 You will be asked to select a Box category (See figure \ref{BoxCategories}); \\ 
589 Select \texttt{example}.
590
591
592 \begin{figure}[!ht]
593 \caption{\label{BoxCategories}Box Categories}
594 \begin{center}
595 \includegraphics[width=0.7\textwidth]{BoxCategories.png}
596 \end{center}
597 \end{figure} 
598
599 You will be asked to choose a script (See figure \ref{example}).
600
601 \begin{figure}[!ht]
602 \caption{\label{example}example list}
603 \begin{center}
604 \includegraphics[width=0.7\textwidth]{example.png}
605 \end{center}
606 \end{figure}
607
608
609
610 Select \texttt{wx::exampleSlider} (See figure \ref{exampleSlider});
611  
612 \begin{figure}[!ht]
613 \caption{\label{exampleSlider}example 'exampleSlider'}
614 \begin{center}
615 \includegraphics[width=0.7\textwidth]{exampleSlider.png}
616 \end{center}
617 \end{figure}
618
619 You can see the graphical summary representation of the current script (the elementary boxes that compose it, and their
620 connections) \\
621 Click on \texttt{source}, and you'll be able to see the (very simple) script, 
622 in the 'Files' part, within the script editor (See figure \ref{exampleSliderSource});
623
624 \begin{figure}[!ht]
625 \caption{\label{exampleSliderSource}source code of 'exampleSlider'}
626 \begin{center}
627 \includegraphics[width=0.7\textwidth]{exampleSliderSource.png}
628 \end{center}
629 \end{figure}
630
631 Run it, using the lower toolbar  (see figure : \ref{lowertoolbar})
632
633 You'll get something like in \ref{execSliderSource}.
634
635 \begin{figure}[!ht]
636 \caption{\label{execSliderSource}execution of 'exampleSlider'}
637 \begin{center}
638 \includegraphics[width=0.7\textwidth]{execSliderSource.png}
639 \end{center}
640 \end{figure}
641
642 Feel free to move the slider, to check it actually works...
643
644
645 \newpage
646
647 % ==========================================
648 \subsubsection{Creating and executing black boxes}
649 % ==========================================
650
651 To learn interactivelly the script language features, you can use the black box
652 interpreter : 
653 open a console and type \bbStudio 
654 or double click on the application icon.
655 You get a window which looks like the one in figure 
656 \ref{bbi-fig-bbi-gui} 
657 (the exact appearance of \bbStudio is system and \bbtk version dependent)
658
659 %\footnote{If you compiled \bbtk without \wx then \bbi does not have a 
660 %graphical interface but a simple prompt}.
661
662 \begin{figure}[!ht]
663 \caption{\label{bbi-fig-bbi-gui}The black box interpreter interface}
664 \begin{center}
665 \includegraphics[width=0.7\textwidth]{bbi-gui0.png}
666 \end{center}
667 \end{figure}
668
669 The 'working' area (the left one, as opposed to the 'help' area, on the right side) is composed of : 
670 one single line zone (Command), at the bottom in which you can enter your commands and 
671 a multiple line zone in which the Command interpreter prints out the result of your commands.
672 The upper part contains the script editor; we shall not use it right now, you may reduce it
673
674 Try typing in the input zone (in this manual, 
675 the commands entered by the user will be preceded by a prompt \textgreater) :
676 \begin{verbatim}
677 > help 
678 \end{verbatim}
679
680 you get the list of the commands of the interpreter :
681 \begin{verbatim}
682 Available commands :
683  author
684  category
685  config
686  connect
687  debug
688  define
689  delete
690  description
691  endefine
692  endpackage
693  exec
694  graph
695  help
696  include
697  index
698  input
699  kind
700  load
701  message
702  new
703  newgui
704  output
705  package
706  print
707  quit
708  reset
709  set
710  unload
711 \end{verbatim}
712
713 To get help on a particular command type \texttt{help <command-name>},
714 for example :
715 \begin{verbatim}
716 > help author
717 \end{verbatim}
718
719 gives :
720 \begin{verbatim}
721  usage : author <string>
722   Adds the string <string> to the author information of the black box being defined
723 \end{verbatim}
724
725 The \texttt{help} command has multiple usages. 
726 It is used to get help about almost anything in the interpretor!
727 Type \texttt{'help help'} to get help on the \texttt{help} command itself :
728 \begin{verbatim}
729 > help help
730  usage : 
731          (1) help 
732          (2) help <command name> 
733          (3) help packages [all]
734          (4) help <package name> [all]
735          (5) help <black box type> 
736          (6) help <black box name>
737   Effect :
738          (1) Lists all available commands;
739          (2) Prints help on a particular command; 
740          (3) Lists the packages loaded and their black boxes.
741              Add 'all' to list adaptors; 
742          (4) Prints short help on the black boxes of a package.
743              Add 'all' to include adaptors; 
744          (5) Prints full help on a black box type; 
745          (6) Prints information on the inputs, outputs and connectionns
746              of a black box instance.
747 \end{verbatim}
748
749 At start the interpretor does not know any black box. 
750 If you type \texttt{'help packages'}, which is 
751 the third form of the \texttt{help} command, you get :
752 \begin{verbatim}
753 > help packages
754 user
755   workspace
756 \end{verbatim}
757
758 which means that the interpretor only knows one package 
759 (library of black boxes) called \texttt{user}
760 and which contains a black box called \texttt{workspace}.
761 The \texttt{user} package is an internal package of the interpreter, 
762 which stores user-defined black box types. 
763 At start, it already contains 
764 one box, called \texttt{workspace}.
765 \texttt{workspace} is a special type of black box, 
766 called complex black box, whose purpose is 
767 to store other black boxes. 
768 Any black box you create in \bbStudio is stored 
769 in \texttt{workspace}  
770 (this will be explained in details in sections 
771 \ref{bbi-writing-scripts} and 
772 \ref{bbi-more-on-complex-black-boxes}). 
773
774 If you type \texttt{'help workspace'}, you get :
775 \begin{verbatim}
776 > help workspace
777  Complex Black Box <user::workspace>
778   User's workspace
779   By : bbtk
780   Category(s) : complex box;
781   * No inputs
782   * No outputs
783   * No boxes
784 \end{verbatim}
785
786 In the text displayed, 
787 the \texttt{user::} prepended to the name \texttt{workspace} 
788 means that the box \texttt{workspace} 
789 belongs to the \texttt{user} package. 
790 Then comes a description and three lines which 
791 tell that \texttt{workspace} does not have any input 
792 nor output nor boxes yet.
793
794 In order to let the interpreter know of some black boxes, 
795 you must load another package. 
796 The \texttt{std} package is the ``standard'' package, 
797 which contains basic useful black boxes. 
798
799 To load it, type :
800 \begin{verbatim}
801 > include std
802 \end{verbatim}
803
804 Then if you type :
805 \begin{verbatim}
806 > help packages
807 \end{verbatim}
808
809 you get something like :
810
811 % std
812 %   ASCII                  
813 %   Add                    
814 %   ConcatStrings          
815 %   Configuration          
816 %   Div                    
817 %   ExecBbiCommand         
818 %   ExecSystemCommand      
819 %   GetVectorCharElement   
820 %      ... 
821 %   GetVectorUShortElement 
822 %   MagicBox               
823 %   MakeFileName           
824 %   Mul                    
825 %   MultipleInputs         
826 %   PrependDataPath        
827 %   PrependPackageDataPath 
828 %   StringRelay            
829 %   StringSelect           
830 % user
831
832 %   workspace
833
834
835 \begin{verbatim}
836
837  std
838    ASCII                   : ascii codes sequence to string - string to ascii...
839    Add                     : Adds its inputs
840    ConcatStrings           : String concatenation
841    Configuration           : Gets configuration informations
842    Div                     : Divides its inputs
843    ExecBbiCommand          : Executes bbi commands
844    ExecSystemCommand       : Executes system (O.S.) commands
845    GetVectorCharElement    : Gets the i-th element from the input vector (std...
846      ...
847    MagicBox                : Takes *any kind* of data and copies it to its ou...
848    MakeFileName            : Makes a kosher file name
849    Mul                     : Multiplies its inputs
850    MultipleInputs          : This box has multiple Void inputs and one Void o...
851    StringRelay             : Just copies the value of its input to its output...
852    StringSelect            : Outputs the string set to the ith input Ini (In0...
853  user
854    workspace 
855 \end{verbatim}
856
857 Now the interpreter knows the package \texttt{std} and the black boxes it provides,
858 such as the \texttt{'Add'} box, the \texttt{'ConcatStrings'} box, and so on. Remark that the 
859 content of \texttt{std} may vary from one version to another 
860 as new black boxes might be added to it. 
861 If you type :  
862 \begin{verbatim}
863 > help Add
864 \end{verbatim}
865
866 You'll get a text help, in the 'Message' part :
867 \begin{verbatim}
868 Black Box <std::Add>
869   Adds its inputs
870   By : laurent.guigues@creatis.insa-lyon.fr
871   Categories : atomic box;math;
872   * Inputs : 
873      'BoxExecute'     <bbtk::Void> [signal] : Any signal received by this input 
874                                               executes the box
875      'BoxProcessMode' <String>     []       : Sets the processing mode of the box 
876                                               (Pipeline | Always | Reactive)
877      'In1'            <Double>     []       : First number to add
878      'In2'            <Double>     []       : Second number to add
879   * Outputs : 
880      'BoxChange'      <bbtk::Void> [signal] : Signals modifications of the box
881      'Out'            <Double>     []       : Result
882 \end{verbatim}
883
884 You'll get as well the same information in the 'Help' Part, in html format (see figure : \ref{HelpAdd}) :
885
886 \begin{figure}[!ht]
887 \caption{\label{HelpAdd}The html Help}
888 \begin{center}
889 \includegraphics[width=0.7\textwidth]{HelpAdd.png}
890 \end{center}
891 \end{figure}
892
893 Like previously, 
894 the \texttt{std::} prepended to the name \texttt{Add} 
895 means that the box \texttt{Add} 
896 belongs to the \texttt{std} package. 
897 Then comes a description 
898 (the one which was provided by the author of the box), 
899 the author(s) of the box (usually e-mail adress(es)) and 
900 the categories to which the box belongs. 
901 Finally comes the lists of inputs and outputs of the box.
902 For each input or output, \bbi provides 
903 its \emph{name} (between quotes, e.g. \texttt{'ProcessMode'}), 
904 its \emph{type} (between \texttt{<} and  \texttt{>}, e.g. \texttt{<Int>})
905 and a description.    
906 Remark that the box \texttt{Add} is not a 'complex' black box 
907 but an 'atomic' box, hence its help does not 
908 mention any information concerning possible internal boxes.
909
910 You can create an \emph{instance} of an \texttt{Add} box by 
911 the command \texttt{new} :
912 \begin{verbatim}
913 > new Add a
914 \end{verbatim}
915
916 The \texttt{'a'} at the end is the \emph{name} of the instance, 
917 which will be used to reference it later. 
918 It is important to distinguish a box \emph{type} 
919 and an \emph{instance} of a box type. 
920 The \texttt{Add} box of the package \texttt{std} is actually 
921 a \emph{box type} , like \texttt{int} is a data type 
922 in \texttt{C} langage. The \texttt{new} command allows to create 
923 an instance of a box type, exactly like \texttt{int i;} in 
924 a \texttt{C} code, it declares a variable of type \texttt{int} whose 
925 name is \texttt{i}. 
926 Of course, like in \texttt{C} Language, you can declare multiple boxes of the 
927 same type in \bbi. 
928
929 After the creation of the box \texttt{a}, type :
930 \begin{verbatim}
931 > help workspace
932 \end{verbatim}
933
934 you get :
935 \begin{verbatim}
936 Complex Black Box <user::workspace>
937  User's workspace
938  By : bbtk
939  Category(s) : complex box;
940  * No inputs
941  * No outputs
942  * Boxes : 
943     'a' <std::Add>
944 \end{verbatim}
945
946 which means that \bbi workspace now contains a black box named \texttt{a},
947 of type \texttt{std::Add}.
948
949 Now look back at the help on \texttt{Add} boxes : 
950 you can see that this type of box has two inputs, 
951 with name \texttt{In1} and \texttt{In2},
952 and an output, with name \texttt{Out}.
953
954 You can set the input \texttt{In1} 
955 of the \texttt{Add} box \texttt{a} to the value $1$ 
956 by the command :
957 \begin{verbatim}
958 > set a.In1 1 
959 \end{verbatim}
960
961 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $2$
962 is done with :
963 \begin{verbatim}
964 > set a.In2 2
965 \end{verbatim}
966  
967 And you print the output \texttt{Out} of the box \texttt{a} with :
968 \begin{verbatim}
969 > print "result=$a.Out$"
970 result=3
971 \end{verbatim}
972
973 In the string passed to the \texttt{print} command, 
974 each substring enclosed between a couple of \$ is considered 
975 as the name of an output of a box. 
976 To process this special substrings, the interpretor :
977 \begin{enumerate}
978 \item Processes the box if needed (see below)
979 \item Converts the output of the box to a string if possible 
980 (see below)
981 \item Substitutes the result in the string to print
982 \item Postpones an implicit 'new line' character to the string
983 \end{enumerate}
984
985 %\paragraph
986
987 Box processing is needed if :
988
989 \begin{itemize}
990 \item either at least input has changed since last processing 
991 \item or the input \texttt{'BoxProcessMode'} of the box is set to 
992 \texttt{'Always'}, which forces box reprocessing. 
993 \end{itemize}
994
995 Note that all boxes have an input named \texttt{'BoxProcessMode'}.\\ 
996
997 Another way to process the box \texttt{a} is to issue the command :
998 \begin{verbatim}
999 > exec a
1000 \end{verbatim}
1001
1002 however this command does not display anything (except if the 
1003 box itself displays something in its processing).
1004 It just processes the box if needed. 
1005 This command is used to execute boxes that do not have any output,  
1006 such as boxes that write something to a file or, display a 
1007 graphical interface, and so on. \\
1008
1009 %To exit \bbi, type :
1010 %\begin{verbatim}
1011 %> quit
1012 %Good bye !
1013 %\end{verbatim}
1014
1015 % ==========================================
1016 \hrule
1017
1018 \paragraph{Summary}
1019 %\hrule
1020 \begin{itemize}
1021 \item The \texttt{include} command allows to load a package, and the complex black boxes that come with it..
1022 \item \texttt{help} gives help on :
1023 \begin{itemize} 
1024 \item Available commands if you just type \texttt{help}.
1025 \item A particular command if you type \texttt{help <command-name>}.
1026 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
1027 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
1028 \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}).
1029 \end{itemize}
1030 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
1031 \item \texttt{new} : creates an instance of a black box. 
1032 \item \texttt{set} : sets the value of an input of a black box. 
1033 \item Under any component of  \bbStudions, to reference the input called \texttt{i} 
1034 of a black box called \texttt{b} you must type \texttt{'b.i'}. 
1035 The same syntax holds for outputs.
1036 \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
1037 implicit trailing 'new line character' is added at the final string.
1038 \item \texttt{exec} : runs, if needed, the process of a box. 
1039 %\item \texttt{quit} : quits \bbi.
1040 \end{itemize}
1041 \hrule
1042
1043 %\paragraph{Note :}
1044 %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.
1045 %Wou'll get something like in figure \ref{bbCommandPlusHelp} :
1046
1047 %\begin{figure}[!ht]
1048 %\caption{\label{bbCommandPlusHelp}
1049 %An other way to run the command interpreter}
1050 %\begin{center}
1051 %\includegraphics[width=0.5\textwidth]{bbCommandPlusHelp.png}
1052 %\end{center}
1053 %\end{figure}
1054
1055 % ==========================================
1056
1057 % ==========================================
1058 \subsubsection{Connecting black boxes}
1059 \label{bbi-connecting-black-boxes}
1060 % ==========================================
1061
1062 \BBTK allows to create 
1063 and execute processing chains, 
1064 also called \emph{pipelines}, 
1065 by connecting black boxes.
1066 This section explains how to do it with examples. 
1067 Read section \ref{bbi-more-on-pipeline-processing} to get 
1068 more information on pipeline processing.
1069
1070 First start \bbStudio and load the package \texttt{std}, typing :
1071 \begin{verbatim}
1072 > include std
1073 \end{verbatim}
1074 in the 'Command' part.
1075
1076 Assume you want to compute $1+2+3$. You can do it by 
1077 chaining two \texttt{Add} boxes, as shown in figure 
1078 \ref{bbi-fig-connecting-black-boxes-1}. 
1079
1080 \begin{figure}[!ht]
1081 \caption{\label{bbi-fig-connecting-black-boxes-1} A simple pipeline which adds 3 numbers}
1082 \begin{center}
1083 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
1084 \end{center}
1085 \end{figure}
1086
1087
1088 The \bbi instructions to create and execute this pipeline are :
1089 \begin{verbatim}
1090 > new Add a
1091 > new Add b
1092 > connect a.Out b.In1
1093 > set a.In1 1
1094 > set a.In2 2
1095 > set b.In2 3
1096 > print $b.Out$
1097 \end{verbatim}
1098
1099 You will see the (very expected) result :
1100 \begin{verbatim}
1101 6
1102 \end{verbatim}
1103
1104 The first three commands build the pipeline, 
1105 the next three set \texttt{a} and \texttt{b} black boxes inputs and the last one 
1106 prints \texttt{b} black boxe output (the pipeline is executed before printing, because the interpretor 'knows' the box  \texttt{b}, 
1107 whose output is requested, is not up to date.
1108  
1109 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output 
1110 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the 
1111 box \texttt{b}. 
1112 Once the boxes connected, the processing of the two boxes are chained :
1113 getting the output of \texttt{b} requires getting its inputs, 
1114 hence getting the output of \texttt{a} which is connected to it. 
1115 This pipeline mechanism can recurse into arbitrary long 
1116 chains of boxes (see \ref{bbi-more-on-pipeline-processing} 
1117 for details).
1118
1119
1120 Lets' consider an other, more image oriented, example :
1121
1122 \begin{verbatim}
1123 > include vtk
1124 > include wx
1125 > include itk
1126 > include wxvtk
1127
1128 > new FileSelector fileDialog
1129 > new ImageReader  reader 
1130 > new Slider       slider
1131 > new Viewer2D     viewer
1132
1133 > connect fileDialog.Out   reader.In 
1134 > connect reader.Out       viewer.In
1135 > connect slider.Out       viewer.Slice
1136 > connect slider.BoxChange viewer.BoxExecute
1137
1138 > exec viewer
1139 \end{verbatim}
1140
1141 Some explainations : the \texttt{include} instructions load the necessary packages. \\
1142
1143 \texttt{new FileSelector} will pop a File Selector, at run time, that will out the user chosen file name. \\
1144 \texttt{new Slider} will pop a Slider, at run time, that will out an integer, used later as a slice number.\\ 
1145 \texttt{new ImageReader} will read any itk readable file, whose name is passed as a std::string, and return a itk::ImagePointer.\\
1146 \texttt{new Viewer2D} display a plane, whose number id specified by an integer.\\
1147 \\
1148 \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).\\
1149 \texttt{connect reader.Out       viewer.In} plugs the output of the reader (an itk::ImagePointer) to the input of the Viewer (a vtkImageData *)\\
1150 \texttt{connect slider.Out       viewer.Slice} plugs the output of the slider (an int) to an other output (named Slide) of the viewer.\\
1151 \texttt{connect slider.BoxChange viewer.BoxExecute} says the viewer it must re process itself any time the slider is modified.\\
1152 \\
1153 \texttt{exec viewer} processes the viewer.
1154
1155
1156 This would correspond to the graph in figure \ref{bbi-simplegraph}
1157
1158
1159 \begin{figure}[!ht]
1160 \caption{\label{bbi-simplegraph}(Very) simple Graph of a (very) simple pipeline}
1161 \begin{center}
1162 \includegraphics[width=0.8\textwidth]{bbi-simplegraph.png}
1163 \end{center}
1164 \end{figure}
1165    
1166 Of course, to be able to connect two boxes, 
1167 the output and the input must be compatibles. 
1168 You can always connect an output to an input of the \emph{same} type, 
1169 but you can do more, thanks to particular (hidden) black boxes called {\bf adaptors}.
1170
1171 An adaptor is a black box which has at least one input, called \texttt{In}, 
1172 and at least one ouput called \texttt{Out} and whose role is to convert 
1173 a data of the type of \texttt{In} 
1174 into a data of the type of \texttt{Out} (other inputs or outputs may serve 
1175 to parameter the adaptor or retreive other usefull information).
1176
1177 Under \bbStudions, if you type :
1178 \begin{verbatim}
1179 > load std
1180 > help std all
1181 \end{verbatim}
1182 you get :
1183 \begin{verbatim}
1184  Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
1185  Basic useful black boxes
1186  Black boxes : 
1187       ...
1188    BoolToString        [DA]  : Converts a Bool (bool) into a string
1189    CastBoolToChar      [DA]  : Static cast from Bool (bool) to Char (signed c...
1190    CastBoolToDouble    [DA]  : Static cast from Bool (bool) to Double (double...
1191       ...
1192    CastBoolToUChar     [DA]  : Static cast from Bool (bool) to UChar (unsigne...
1193    CastBoolToUInt      [DA]  : Static cast from Bool (bool) to UInt (unsigned...
1194       ...
1195    CastUIntToBool      [DA]  : Static cast from UInt (unsigned int) to Bool (...
1196    CastUIntToChar      [DA]  : Static cast from UInt (unsigned int) to Char (...
1197    CastUIntToDouble    [DA]  : Static cast from UInt (unsigned int) to Double...
1198       ...      
1199
1200 \end{verbatim}
1201
1202 \texttt{[DA]}  stands for \emph{default adaptor}.
1203
1204 Once you have loaded the package \texttt{std}, you can 
1205 plug an output of type \texttt{char} into an input of type \texttt{double}. 
1206 When the interpreter encounters the \texttt{connect} command, 
1207 it looks for an adequate \emph{adaptor} in the  loaded packages. 
1208 In our case, as the package \texttt{std} provides the 
1209 \texttt{CastUCharToDouble} adaptor, the interpreter automatically creates an 
1210 instance of this adaptor and place it \emph{between} 
1211 the output and the input you want to connect 
1212 (however this adaptor is hidden to you, 
1213 it is embedded into the created connection and does not appear 
1214 as an existing black box). 
1215 When the pipeline is processed the 
1216 adaptor converts the output data into the required input type, 
1217 in a totally transparent way.
1218 In our example, the \texttt{CastUCharToDouble} adaptor 
1219 would simply cast the value of the \texttt{char} into a \texttt{double}, 
1220 however arbitrarily complex type conversion may be done.
1221
1222 \begin{verbatim}
1223 Question (for info-dev): 
1224 if two adaptors with the same input and output types exist 
1225 in two different packages, currenly loaded, 
1226 which one is chosen by the interpreter at connection time?
1227 A feature is missing to specify explicitely which one user wants to choose 
1228 (use a namespace notation ?)
1229  
1230 -> Role of default adaptors
1231 \end{verbatim}
1232
1233 Note that the \texttt{set} and \texttt{print} commands of interpreter 
1234 work with adaptors from \texttt{string} to the type of the input to set 
1235 or from the type of the output to print to \texttt{string}. 
1236 Hence in order to \texttt{set} or \texttt{print} values the adequate 
1237 adaptors must be available in the packages currently loaded. \\
1238
1239
1240 % ==========================================
1241 \hrule
1242 \paragraph{Summary}
1243 %\hrule
1244 \begin{itemize}
1245 \item The \texttt{connect} command allows to connect two black boxes
1246 \item You can connect two black boxes if (and only if) : 
1247 \begin{itemize}
1248 \item The output and the input are of the same type, or
1249 \item There is an adaptor black box in the packages loaded which 
1250 converts data of the output type into data of the input type
1251 \end{itemize}
1252 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use : \texttt{help <package name> all}.
1253 including adaptors
1254 \end{itemize}
1255 \hrule
1256 % ==========================================
1257
1258 % ==========================================
1259 \subsubsection{Creating complex black boxes}
1260 \label{bbi-complex-black-boxes}
1261 % ==========================================
1262
1263 Remember the pipeline of figure 
1264 \ref{bbi-fig-connecting-black-boxes-1}, which 
1265 computed the sum of three doubles?
1266 You can consider it as a whole and define 
1267 a new black box type, which will be a \emph{complex black box}, 
1268 having three inputs and one output, 
1269 as shown in figure \ref{bbi-fig-complex-black-box-1}.
1270
1271 \begin{figure}[!ht]
1272 \caption{\label{bbi-fig-complex-black-box-1} Creating the complex black box \texttt{Add3}}
1273 \begin{center}
1274 \includegraphics[width=0.5\textwidth]{Add3.png}
1275 \end{center}
1276 \end{figure}
1277
1278 The \bbi commands to define this complex black box are 
1279 the following :
1280
1281 \begin{verbatim}
1282 > load std
1283 >
1284 > define Add3
1285 >
1286 > new Add a
1287 > new Add b
1288 > connect a.Out b.In1
1289 >
1290 > author "myself"
1291 > description "adds 3 doubles"
1292 > input x a.In1 "first double to add"
1293 > input y a.In2 "second double to add"
1294 > input z b.In2 "third double to add"
1295 > output result b.Out "output"
1296 >
1297 > endefine
1298 \end{verbatim}
1299
1300 Explainations :
1301
1302 As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in first line.
1303
1304 The command \texttt{define} then starts the definition 
1305 of the complex box type, which will be called \texttt{Add3}. 
1306
1307 The next three lines define the pipeline, 
1308 exactly in the same way than outside a complex box definition. 
1309
1310 The commands \texttt{author}, \texttt{description}, \texttt{input} 
1311 and \texttt{output} are commands specific to complex boxes definition :
1312
1313 \texttt{author} and \texttt{description} are used for the documentation 
1314 of the new box. You can provide multiple \texttt{author} or 
1315 \texttt{description} commands, the arguments of the commands will 
1316 be concatenated to produce the final author and description strings.
1317
1318 \texttt{input} and \texttt{output} are used to define the inputs and outputs 
1319 of the new complex box. 
1320 Their syntax is the same : for each new input/output you need to say 
1321 to which internal input/output it corresponds and to provide 
1322 a help string documenting the input/output.
1323 In our example, we define that the box \texttt{Add3} has 
1324 three inputs : \texttt{x}, \texttt{y} and \texttt{z}. 
1325 The input \texttt{x} corresponds to the input \texttt{In1} of the 
1326 internal box \texttt{a}. 
1327 In the same way, the external input \texttt{y} 
1328 corresponds to the internal input \texttt{a.In2}, and 
1329 the external input \texttt{In3} to \texttt{b.In2}. 
1330 The only output of the new box is called \texttt{result}
1331 and corresponds to \texttt{b.Out}. 
1332 The figure \ref{bbi-fig-complex-black-box-1} 
1333 illustrates the external to internal 
1334 input/output correspondence.
1335
1336 Finally, the \texttt{endefine} command ends the definition of the 
1337 new box type.
1338
1339 After this definition, if you ask for help 
1340 on packages, you get :
1341 \begin{verbatim}
1342 > help packages
1343 std
1344   Add
1345   ...
1346 user
1347   Add3
1348   workspace
1349 \end{verbatim}
1350
1351 The \texttt{user} package now contains a new black box type, called 
1352 \texttt{Add3}. If you ask for help on this type of box, you get :
1353 \begin{verbatim}
1354 > help Add3
1355 Complex Black Box <user::Add3>
1356  adds 3 doubles
1357  By : myself
1358  * Inputs : 
1359     'x'      <double> : first double to add
1360     'y'      <double> : second double to add
1361     'z'      <double> : third double to add
1362  * Outputs : 
1363     'result' <double> : output
1364  * Boxes : 
1365     'a' <std::Add>
1366     'b' <std::Add>
1367 \end{verbatim}
1368
1369 and you can use it like any other box, for example type :
1370
1371 \begin{verbatim}
1372 > new Add3 a
1373 > set a.x 1
1374 > set a.y 2
1375 > set a.z 3
1376 > print $a.result$
1377 6
1378 \end{verbatim}
1379
1380
1381 As a side note, we can say that, for consistency reasons, it would have been better to name  
1382 \texttt{In1}, \texttt{In2} and \texttt{In3} the inputs of the black box \texttt{Add3}, 
1383 since all the 'natural entry' of a box is named \texttt{In}, or \texttt{In}\emph{x} if there are more than one  'natural
1384 entry'.
1385
1386 % ==========================================
1387 \hrule
1388 \paragraph{Summary}
1389 %\hrule
1390 \begin{itemize}
1391 \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. 
1392 Inside a \texttt{define/endefine} block :
1393 \begin{itemize}
1394 \item The \texttt{author} and \texttt{description} commands allow to document the new type of box
1395 \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 
1396 of internal boxes they correspond.  
1397 \end{itemize}
1398 \end{itemize}
1399 \hrule
1400 % ==========================================
1401
1402 % ==========================================
1403 \subsubsection{Writing scripts}
1404 \label{bbi-writing-scripts}
1405 % ==========================================
1406
1407 Once you have defined a new type of complex box, you 
1408 may like to reuse it. To do this, you can simply 
1409 write the \bbi commands defining the new box 
1410 into a text file and afterwards include that file in \bbi. 
1411 Doing this, you start writing \bbi scripts.
1412 The conventionnal (and mandatory) extension for such scripts is \texttt{bbs} 
1413 (black box script).
1414 For consistency reasons, you are requested to prepend \texttt{bb} to the name.
1415
1416 For example, the \texttt{Add3} complex box we previously worked on 
1417 can be defined in the \texttt{bbAdd3.bbs} file :
1418
1419 \begin{file}{bbAdd3.bbs}
1420 \begin{verbatim}
1421 # Defines the Add3 black box which adds 3 doubles 
1422 load std
1423
1424 define Add3
1425   # I am the author 
1426   author "myself"
1427   description "adds 3 doubles"
1428   # Pipeline creation
1429   new Add a
1430   new Add b
1431   connect a.Out b.In1
1432   # Inputs definition
1433   input x a.In1 "first double to add
1434   input y a.In2 "second double to add
1435   input z b.In2 "third double to add"
1436   # Output definition
1437   output result b.Out "output"
1438 endefine
1439 \end{verbatim}
1440 \end{file}
1441
1442 Lines starting with a \texttt{\#} character or a \texttt{\//\//} character are ignored, they 
1443 are considered as comments by the interpreter.
1444 To use this file in \bbStudions, click on the \texttt{include} button, and browse your filestore to find the file.
1445
1446 \begin{verbatim}
1447 > include bbAdd3.bbs
1448 > help Add3
1449 Complex Black Box <user::Add3>
1450  adds 3 doubles
1451  By : myself
1452  * Inputs : 
1453     'x'      <double> : first double to add
1454     'y'      <double> : second double to add
1455     'z'      <double> : third double to add
1456  * Outputs : 
1457     'result' <double> : output
1458  * Boxes : 
1459     'a' <std::Add>
1460     'b' <std::Add>
1461 >
1462 and so on ...
1463 \end{verbatim}
1464
1465 If the file has the \texttt{bbs} extension, you can ommit it and just type :
1466 \begin{verbatim}
1467 > include Add3
1468 \end{verbatim}
1469
1470 \subsubsection{Creating complex black boxes that use complex black boxes}
1471 \label{bbi-complex-complex-black-boxes}
1472
1473
1474 Of course, you can include script files in other script files, 
1475 like in the following example :
1476
1477 \begin{file}{bbAdd4.bbs}
1478 \begin{verbatim}
1479 # Defines the Add4 black box which adds 4 doubles 
1480 include Add3
1481
1482 define Add4
1483   author "myself"
1484   description "adds 4 doubles"
1485   new Add3 a
1486   new Add b
1487   connect a.Out b.In1
1488   input In1 a.In1 "first double to add
1489   input In2 a.In2 "second double to add
1490   input In3 a.In3 "third double to add"
1491   input In4 b.In2 "fourth double to add"
1492   output Out b.Out "output"
1493 endefine
1494 \end{verbatim}
1495 \end{file}
1496
1497
1498
1499 \subsubsection{Naming Conventions}
1500 \label{bbi-Naming Conventions}
1501
1502
1503 % ==========================================
1504 %\hrule
1505 %\paragraph{Naming Conventions}
1506 %\hrule
1507
1508 %\hrule
1509 % ==========================================
1510 \begin{itemize}
1511 \item
1512 File names : 
1513 For consistency reasons, you are requested to prepend \texttt{bb}, and postpone an extention \texttt{.bbs},
1514 to the names of the files that hold a \texttt{complex black box} definition.
1515
1516 For example, the \texttt{Add3} complex box we previously worked on 
1517 can be defined in the \texttt{bbAdd3.bbs} file.
1518 \item
1519 Search Paths :
1520 For consistency reasons, the names of dynamic libraries holding the packages must start by \texttt{libbb}.
1521 For instance, the package \texttt{wx} will be in the library \texttt{libbbwx.dll} (Windows) or \texttt{libbbwx.so}
1522 (Linux).
1523
1524
1525 \end{itemize}
1526 % ==========================================
1527 \hrule
1528
1529 \paragraph{Summary}
1530 %\hrule
1531 \begin{itemize}
1532 \item The \texttt{include} command tells the interpreter to include a script file.
1533 \item Lines starting with a \texttt{\#} or with a \texttt{\//\//} are considered as comments by the interpreter.
1534 \item Lines between a line starting with a \texttt{\//*} an a line starting with a \texttt{*\//} are considered as comments by the interpreter.
1535 \end{itemize}
1536
1537 \hrule
1538 % ==========================================
1539
1540 % ==========================================
1541 \subsubsection{Creating command line applications}
1542 \label{bbi-command-line-app}
1543 % ==========================================
1544
1545 Now that you know how to create complex black boxes 
1546 (with \texttt{define/endefine}), think 
1547 back to the \texttt{workspace} object. 
1548 Remember that it is also 
1549 a \texttt{complex black box}. 
1550 Actually, when you type interpreter commands 
1551 outside a \texttt{define/endefine} block, 
1552 you progressively define the \texttt{workspace} 
1553 complex black box.
1554 You can think of it like if at start the interpreter
1555 was issuing a command \texttt{'define workspace'} 
1556 and then letting you define the interior of the box 
1557 \texttt{workspace}.
1558
1559 Remember that the command \texttt{inputs} 
1560 allows to define an input of a complex box. 
1561 Now, if you use the command \texttt{input} 
1562 outside a \texttt{define/endefine} block then 
1563 it defines an input of the \texttt{workspace} box, 
1564 that is an input of the \emph{main program}. 
1565 This input will then be connected to the 
1566 parameters that the user passes to the command line.
1567
1568 For example, consider the script : 
1569
1570 \begin{file}{add.bbs}
1571 \begin{verbatim}
1572 load std
1573 new Add a
1574 input x a.In1 "first number to add"
1575 input y a.In2 "second number to add"
1576 print "x+y=$a.Out$"
1577 \end{verbatim}
1578 \end{file}
1579
1580 The third and fourth lines define two inputs \texttt{x} 
1581 and \texttt{y}. When you execute this script, 
1582 you can pass these two arguments on the command line, 
1583 like this :
1584
1585 \begin{verbatim}
1586 > bbi add x=1 y=1
1587 x+y=2
1588 \end{verbatim}
1589
1590 You can also invoke \bbi the option \texttt{-h}, 
1591 which gives help on the \texttt{workspace} box :
1592
1593 \begin{verbatim}
1594 > bbi add -h
1595  User's workspace
1596  By : bbi (internal)
1597  * Inputs : 
1598     'x' <double> : first number to add
1599     'y' <double> : second number to add
1600 \end{verbatim}
1601
1602 To get a better help, use the \texttt{description} 
1603 and \texttt{author} commands :
1604
1605 \begin{file}{add.bbs}
1606 \begin{verbatim}
1607 description "Adds two numbers"
1608 author "foo@bar.com"
1609 load std
1610 new Add a
1611 input x a.In1 "first number to add"
1612 input y a.In2 "second number to add"
1613 print "x+y=$a.Out$"
1614 \end{verbatim}
1615 \end{file}
1616
1617 Now if you ask for help on the \texttt{add} script, you get :
1618
1619 \begin{verbatim}
1620 > bbi add -h
1621  Adds two numbers
1622  By : foo@bar.com
1623  * Inputs : 
1624     'x' <double> : first number to add
1625     'y' <double> : second number to add
1626 \end{verbatim}
1627
1628 Rather than getting the inputs of a script 
1629 from the command line, you can ask \bbi to 
1630 prompt the user for the values, using the \texttt{-t}
1631 commutator :
1632
1633 \begin{verbatim}
1634 > bbi add -t
1635 x=[the program waits for user answer]2
1636 y=[the program waits for user answer]5
1637 x+y=7
1638 \end{verbatim}
1639
1640 \bbStudio is always compiled in graphical mode (with \wx), therefore
1641 you can also use the \texttt{-g} commutator. 
1642 \bbi then prompts the user in graphical mode, 
1643 displaying a dialog box for each input,
1644 like in fig. \ref{bb-input-dialog-box}.
1645
1646 \begin{figure}[!ht]
1647 \caption{\label{bb-input-dialog-box}Input dialog box}
1648 \begin{center}
1649 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1650 \end{center}
1651 \end{figure}
1652
1653 % ==========================================
1654 \hrule
1655 \paragraph{Summary}
1656 %\hrule
1657 \begin{itemize}
1658 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1659 when they are used outside a \texttt{define/endefine} block allow 
1660 to define the inputs, description and author of the main program.
1661 \item Inputs of the main program can be passed on the command line 
1662 using the syntax \texttt{<input-name>=<value>}. 
1663 No white space is allowed, if the value or the input name 
1664 contains white spaces, enclose them 
1665 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1666 \item The \texttt{-h} option of \bbi prints help on the main program.
1667 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1668 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1669 \end{itemize}
1670 \hrule
1671 % ==========================================
1672
1673 % ==========================================
1674 \subsubsection{Using graphical interface boxes (widget boxes)}
1675 \label{bbi-widget}
1676 % ==========================================
1677
1678 % ==========================================
1679 \subsubsection{Overwiew}
1680 \label{bbi-overview}
1681 % ==========================================
1682
1683 \bbStudio is always compiled in graphical mode 
1684 (option \texttt{BUILD\_bbi\_GRAPHICAL} of \cmakens, requires \wxns),
1685 then you can use special black boxes which are 
1686 graphical interface components (widgets). 
1687 Basic components are provided in the package \texttt{wx}, 
1688 such as buttons, sliders, file open/save dialogs, etc.
1689
1690 As first example, type the following commands in \bbi :
1691 \begin{verbatim}
1692 > load wx 
1693 > new InputText t
1694 > print $t.Out$\n
1695 \end{verbatim}
1696
1697 When you type \texttt{enter} after the last line, 
1698 a window pops up in which you can entrer a text.
1699 When you close the window, the text you entered is printed by 
1700 the \texttt{print} command.
1701
1702 Type \texttt{help wx}, you get something like :
1703 \begin{verbatim}
1704  Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1705  Basic graphical interface elements (sliders, buttons ...) based on wxWidgets
1706  Black boxes : 
1707    ColourSelector        : Colour Selector dialog (bbfication of wxColourSele...
1708    ColourSelectorButton  : A button which displays a colour picker dialog whe...
1709    CommandButton         : Button which executes bbi commands
1710    DirectorySelector     : Pops up a directory selection dialog (wxDirDialog)
1711    FileSelector          : Pops up a file selection dialog for reading or sav...
1712    InputText             : A zone in which the user can enter a text (wxTextC...
1713    LayoutLine            : LayoutLine widget (wxBoxSizer)
1714    LayoutSplit           : Widget which splits a window in two fixed size par...
1715    LayoutTab             : LayoutTab widget (wxNotebook)
1716    OutputText            : Text zone to be inserted into a window (wxStaticTe...
1717    RadioButton           : RadioButton group widget 0-9 entries
1718    Slider                : Slider widget (wxSlider)
1719 \end{verbatim}
1720
1721 You can reproduce the same experiment as above using a 
1722 \texttt{Slider} or a \texttt{FileDialog} rather than a \texttt{InputText}.
1723 See the files \texttt{test*.bbs} in the \texttt{scripts/test} directory.
1724
1725 There are two kinds of widgets : ``terminal'' widgets and ``container'' widgets.
1726 The \texttt{InputText}, \texttt{FileDialog} or \texttt{Slider} widgets 
1727 are ``terminal'' widgets. 
1728 ``container'' widgets are of another kind : they are designed to 
1729 contain other widgets in order to build larger dialog boxes. 
1730 For example, the \texttt{LayoutSplit} widget is a container which 
1731 ``splits'' horizontally a window into two parts, 
1732 each part including another widget. 
1733 The size of the two parts can be adjusted by the user thanks 
1734 to a ``handle''.
1735
1736 The script \texttt{scripts/test/testSplit.bbs} demonstrate its use. 
1737 Run it : it displays a window with two sliders. 
1738 Move the sliders and close the window. 
1739 The final positions of the sliders are printed out. 
1740 Now edit the file to see how this is done :
1741
1742 \begin{file}{scripts/test/testSplit.bbs}
1743 \begin{verbatim}
1744 load std
1745 load wx
1746
1747 new Slider s1
1748 new Slider s2
1749
1750 new LayoutSplit s
1751 connect  s1.Widget s.Widget1
1752 connect  s2.Widget s.Widget2
1753
1754 print s1=$s1.Out$\\n
1755 print s2=$s2.Out$\\n
1756 \end{verbatim}
1757 \end{file}
1758
1759 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1760 A \texttt{LayoutSplit} box \texttt{s} is also created. 
1761 The \texttt{connect} commands then ``includes'' the sliders in the 
1762 split ``container''. 
1763 The input \texttt{Widget} is common to all widget boxes : 
1764 every widget can be inserted into another widget. 
1765 The outputs \texttt{Widget1},\texttt{Widget2}  are specific of \emph{container} 
1766 widgets 
1767 (in \bbi type \texttt{help Slider} : 
1768 you will see the output \texttt{Widget}; 
1769 type \texttt{help LayoutSplit} : 
1770 you will see the inputs \texttt{Widget1} and \texttt{Widget2} 
1771 and the output \texttt{Widget}). 
1772 When you connect the \texttt{Widget} output of a container 
1773 to the \texttt{Widget}i input of a widget, 
1774 you order to include the widget in the container.
1775 Of course, the order of connection is important. 
1776 In our case, the slider \texttt{s1} is included first, 
1777 then the slider \texttt{s2} : \texttt{s1} will be placed 
1778 on top of \texttt{s2} (the \texttt{LayoutSplit} box is 
1779 implemented that way, but this is arbitrary choice).
1780
1781 Right now, there are only \emph{three} container widgets in the \texttt{wx} package : 
1782 \begin{itemize} 
1783 \item {the \texttt{LayoutSplit} widget} we just described, the \texttt{LayoutLine} , and the \texttt{LayoutTab}
1784 widget. 
1785
1786 \item {the \texttt{LayoutLine} widget} can have multiple children and 
1787 divides its window into as much parts as children, 
1788 each part of equal size. 
1789 The orientation of the \texttt{LayoutSplit} or of the \texttt{LayoutLine}  can be changed by the input \texttt{Orientation}.
1790 See the example \texttt{test/testSizer.bbs}.
1791 With only those two containers you can already create 
1792 complex dialog boxes (of course containers can be nested, which leads to tree-like structures of widgets). 
1793 See the script \texttt{bbtk/share/bbtk/bbs/wx/appli/ExampleLayoutSplit.bbs} for an example.
1794
1795 \item {The \texttt{LayoutTab}  widget} is based on the \texttt{wxNotebook.}\\
1796 The label of each 'note book' is the name of the object it contains.
1797 \end{itemize}
1798
1799
1800 =====> TODO \\
1801
1802
1803 One word about a special widget in the package \texttt{wx} : 
1804 the \texttt{Button}... to be continued.
1805
1806 % ==========================================
1807 \subsubsection{Deeper in the boxes}
1808 \label{bbi-deep-box}
1809 % ==========================================
1810
1811 Any widget box has two mandatory Inputs :
1812 \begin{itemize}
1813   \item {\bf\emph{BoxExecute}}     : Any signal received by this input executes the box
1814   \item {\bf\emph{BoxProcessMode}} : Sets the processing mode of the box :
1815   \begin{itemize}
1816     \item {\bf\emph{Pipeline}} : bbBackwardUpdate() calls Process() only if Status == MODIFIED \\
1817                                  The box executes itself only when an entry was changed (normal pipeline processing).
1818     \item {\bf\emph{Reactive}} : bbSetModifiedStatus() calls bbUpdate() \\
1819                                  Warning : Re-processed immediately when \emph{any entry} changed.\\
1820                                  To be more selective, better use \texttt{connect A.BoxChange \emph{currentBox}.BoxExecute}.    
1821     \item {\bf\emph{Always}}   : bbUpdate() always calls Process. \\
1822                                  Usefull for 'sources', that must be processed, even when no entry changed (e.g. : FileSelector, ColorSelector)\\
1823                                  This one is not end user intended (for Package developer only)
1824   \end{itemize}   
1825 \end{itemize}
1826
1827 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} :  
1828 \begin{itemize}
1829   \item {\bf\emph{WinHeight}} : Height of the window 
1830   \item {\bf\emph{WinWidth}}  : Width of the window  
1831   \item {\bf\emph{WinTitle}}  : Title of the window
1832   \item {\bf\emph{WinClose}}  : Any received signal closes the window
1833   \item {\bf\emph{WinHide}}   : Any received signal hides the window
1834   \item {\bf\emph{WinDialog}} : When set to 'true', creates a \emph{dialog window}, that blocks the pipeline until it is closed (\emph{modal})   
1835 \end{itemize}
1836
1837
1838 Any \emph{Layout box} (i.e. \emph{LayoutLine}, \emph{LayoutSplit} or \emph{LayoutTab}) has at one or more mandatory Inputs :
1839 \begin{itemize}
1840   \item {\bf\emph{Widget}}\texttt{i} : e.g. a \emph{LayoutSplit} box (Widget which splits a window in two resizeable parts) 
1841        has two Input parameters \emph{Widget1} and \emph{Widget2}, used to embed the child windows.\\
1842        e.g. a  \emph{LayoutLine} divides the window in up to 9 (depending on the number of inputs \emph{Widget}i) fixed size parts.  
1843 \end{itemize} 
1844
1845
1846 Any widget box has two mandatory Outputs  :
1847
1848 \begin{itemize}
1849   \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
1850      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.
1851   \item {\bf\emph{Boxchange}}  : Signals any modification of the box. This output may be connect if necessary to the \emph{BoxExecute} entry of an other box,
1852    further within the execution pipeline.
1853 \end{itemize}    
1854
1855
1856
1857 % ==========================================
1858 \subsection{More on ...}
1859 \label{bbi-more-on}
1860 % ==========================================
1861
1862 % ==========================================
1863 \subsubsection{Black box packages}
1864 \label{bbi-more-on-packages}
1865 % ==========================================
1866 There are various others user-intended packages :
1867
1868 \begin{verbatim}
1869 ---> Were moved in a 'Reference Manual' ?\\
1870 ---> Any suggestion welcome!
1871 \end{verbatim}
1872
1873 \begin{itemize}
1874 \item{vtk} \\
1875 \item{itk} \\
1876 \item{...} \\
1877 \end{itemize}
1878 % ==========================================
1879 \subsubsection{Pipeline processing}
1880 \label{bbi-more-on-pipeline-processing}
1881 % ==========================================
1882 \begin{itemize}
1883 \item the ``control'' mechanism in bbi.
1884
1885 When a box is requested to update itself, it asks (recursively) each one of its inputs if it was modified.\\
1886 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.
1887
1888 (switch exec commands, e.g. Button)
1889 \item the role of ProcessMode to update widgets.
1890 \end{itemize}
1891 % ==========================================
1892 \subsubsection{Complex black boxes}
1893 \label{bbi-more-on-complex-black-boxes}
1894 Creation of complex widgets (containers, contained...)
1895
1896 You can include script files in other script files, 
1897 like in the following example :
1898
1899
1900 \begin{verbatim}
1901 # Defines the Add4 black box which adds 4 doubles 
1902 include Add3
1903 define Add4
1904   author "myself"
1905   description "adds 4 doubles"
1906   new Add3 a
1907   new Add b
1908   connect a.Out b.In1
1909   input In1 a.In1 "first double to add"
1910   input In2 a.In2 "second double to add"
1911   input In3 a.In3 "third double to add"
1912   input In4 b.In2 "fourth double to add"
1913   output Out b.Out "output"
1914 endefine
1915 \end{verbatim}
1916
1917 The inner boxes have they own entries (In1, In2, In3 for box a, In1, In2 for box b )\\
1918 Only the inputs In1, In2, In3 of box a and the input In2 of box b is of interest for the end user, but he dosn't want to have to
1919 care neither about the inner boxes name, nor about the names of their Inputs.\\
1920 The writer of the complex box has the ability to give these inputs a meaningfull name !
1921 \begin{verbatim}
1922   input In3 a.In3 "third double to add"
1923   input In4 b.In2 "fourth double to add"
1924 \end{verbatim}
1925
1926 %\subsubsection{Advanced issues}
1927 %\paragraph{Reducing the number of inputs of a box}
1928
1929 % ==========================================
1930 \subsubsection{Errors}
1931 \label{bbi-more-on-errors}
1932
1933 % ==========================================
1934 \subsubsection{Creating and using your own uninstalled version of bbStudio}
1935 \label{bbi-more-on-your_own_version}
1936
1937 Suppose you want to run your own uninstalled version (say : you downloaded and compiled the
1938 cvs version in order to use a recently commited patch, but you want to be able
1939 to still use the standard version).
1940  
1941 You have to :
1942 \begin{itemize} 
1943 \item cvs checkout the sources :
1944 \begin{verbatim}
1945 cvs checkout bbtk
1946 \end{verbatim}
1947 \item 
1948 create a build directory
1949 \begin{verbatim}
1950 mkdir buildBBTK
1951 \end{verbatim}
1952 \item cd in the build directory:
1953 \begin{verbatim}
1954 cd buildBBTK
1955 \end{verbatim}
1956 \item run ccmake.
1957 \begin{verbatim}
1958 ccmake ../bbtk
1959 \end{verbatim}
1960
1961 Don't forget to switch ON the flag \textttBBTK\_COMPILE\_DEBUG\_MESSAGE \\
1962 (see figure : \ref{bb-ccmake})
1963
1964 \begin{figure}[!ht]
1965 \caption{\label{bb-ccmake}\Running ccmake}
1966 \begin{center}
1967 \includegraphics[width=0.6\textwidth]{ccmake.png}
1968 \end{center}
1969 \end{figure}
1970
1971 \item As usual, type \texttt{c} untill there is no longer any area quoted with a * (or enlighted in red)\\
1972 Ask for generation (type \texttt{g} -once is always enough-)
1973
1974 \item Ask for compilation and link.
1975 \begin{verbatim}
1976 make
1977 \end{verbatim}
1978 For some strange reasons (?!?), you may be warned that an error occured while documentation generation.\\
1979 Take it easy, \texttt{make} again!\\
1980
1981 The dynamic libraries (\texttt{.dll} or \texttt{.so} and the executable programs will be created in the \testtt{bin}
1982 directory of the built tree.
1983
1984 \item choose to install or not your own version.
1985 \begin{verbatim}
1986 make install
1987 \end{verbatim}
1988 Linux users : Don't forget to \texttt{sudo} before.
1989 \end{itemize}
1990 % ==========================================
1991 \subsubsection{\bbtk configuration file and search pathes}
1992 \label{bbi-more-on-configuration}
1993
1994 At start, \bbi tries to open an \texttt{xml} 
1995 configuration file named \texttt{bbtk\_config.xml}. 
1996 The search order is 
1997 \begin{enumerate}
1998 \item The current directory
1999 \item The subdir \texttt{.bbtk} of the user's home directory. 
2000 \begin{itemize} 
2001 \item On \texttt{Unix}, the home directory is the
2002 one stored by the environnement variable \texttt{HOME}, 
2003 typically \texttt{/home/username}.
2004 \item On \texttt{Windows}, the home directory is 
2005 the user's profile directory stored by the environnement 
2006 variable \texttt{USERPROFILE}, 
2007 typically \texttt{C:\\...}.
2008 \end{itemize}
2009 \item If none of these two pathes contains the file then it creates 
2010 a new one in the \texttt{.bbtk} directory. 
2011 \end{enumerate}
2012
2013 Once created, you can edit the \texttt{bbtk\_config.xml} file located 
2014 in your \texttt{.bbtk} directory. It contains :
2015
2016 \begin{file}{bbtk\_config.xml}
2017 \begin{verbatim}
2018 <?xml version="1.0" encoding="iso-8859-1"?>
2019 <config>
2020    <description>  </description>
2021    <bbs_path>     </bbs_path>
2022    <package_path> 
2023       /usr/local/lib
2024    </package_path>
2025    <data_path> </data_path>
2026    <default_temp_dir>$</default_temp_dir>
2027 </config>
2028 \end{verbatim}
2029 \end{file}
2030
2031 You can add pathes to 
2032 \begin{itemize}
2033 \item A custom folder in which to search for \texttt{.bbs} scripts (\texttt{include} command of \bbi) by adding an \texttt{xml} tag : 
2034 \texttt{<bbs\_path>complete\_path\_to\_folder<\/bbs\_path>}.
2035 \item A custom folder in which to search for packages (\texttt{load} command of \bbi) by adding an \texttt{xml} tag : 
2036 \texttt{<package\_path>complete\_path\_to\_folder<\/package\_path>}.
2037 \end{itemize}
2038
2039
2040 \newpage
2041
2042 % ==========================================
2043 \subsection{Language reference}
2044 \label{bbi-reference}
2045 % ==========================================
2046
2047
2048 % ==========================================
2049 \subsubsection{pipeline creation and execution related commands}
2050 \label{bbi-reference-creation-execution}
2051 % ==========================================
2052
2053
2054 % ==========================================
2055 \begin{table}[!ht]
2056 \caption{\label{bbi-reference-box} \bbi pipeline creation and execution related commands.}
2057 \small
2058 \begin{tabular}{|lcm{6cm}|}
2059 \hline
2060 Command & Parameters & Effect \\ \hline
2061
2062 \texttt{new} & \texttt{<boxtype>} \texttt{<box-name>}& 
2063 Creates a box of type \texttt{boxtype} and name  
2064 \texttt{box-name}.\\ \hline
2065
2066 \texttt{delete} & \texttt{<box-name>} & 
2067 Destroys the box named \texttt{box-name}.\\ \hline 
2068
2069 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} & 
2070 Connects the output 
2071 \texttt{output} of the box named \texttt{box1} 
2072 to the input \texttt{input} of the box named \texttt{box2} \\ \hline 
2073
2074 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
2075 Sets the input \texttt{input} of 
2076 the box named \texttt{box} to the value \texttt{value}.
2077 An \texttt{adaptor} must exist
2078 in the packages loaded which converts a \texttt{std::string} 
2079 to the type of the input \texttt{input}. \\ \hline 
2080
2081 \texttt{print} & \texttt{<string>} & 
2082 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the 
2083 output \texttt{output} of the box named \texttt{box}. 
2084 An \texttt{adaptor} must exist
2085 in the packages loaded which converts 
2086 the type of the output \texttt{output}
2087 to a \texttt{std::string}.
2088 \\ \hline 
2089
2090 \texttt{exec} & \texttt{<box-name>} & 
2091 Executes the box named \texttt{box-name}.
2092 If needed the boxes 
2093 connected to its inputs 
2094 are also processed recursively (pipeline processing).\\ \hline 
2095 \texttt{exec} & \texttt{freeze} & 
2096  Allows to block execution commands while keeping definition commands active.(This one is not for end user)\\ \hline 
2097 \texttt{exec} & \texttt{unfreeze} & 
2098  Turns back to 'normal' mode (This one is not for end user).\\ \hline 
2099 \end{tabular}
2100 \end{table}
2101 % ==========================================
2102
2103 \newpage
2104
2105 % ==========================================
2106 \subsubsection{Interpreter related commands}
2107 \label{bbi-reference-interpreter}
2108 % ==========================================
2109
2110 % ==========================================
2111 \begin{table}[!ht]
2112 \caption{\label{bbi-reference-interpreter}\bbi intepreter related commands.}
2113 \small
2114 \begin{tabular}{|lcm{6cm}|}
2115 \hline
2116 Command & Parameters & Effect \\ \hline
2117
2118 \texttt{author} &  \texttt{<author-name>} & 
2119 Adds the string \texttt{<author-name>} to the author information of the black box being defined \\ \hline 
2120
2121 \texttt{category} & \texttt{<category-name>} & 
2122   Adds the string \texttt{<category-name>} to the category information of the black box being defined \\ \hline 
2123
2124 \texttt{help} & - & 
2125 Prints help on available commands \\ \hline 
2126
2127 & \texttt{<command-name>} & 
2128 Prints help on the command \texttt{command-name} \\ \hline 
2129
2130 & \texttt{packages} & 
2131 Prints help on available packages and their box types 
2132 (without description)\\ \hline 
2133
2134 & \texttt{<package-name>} & 
2135 Prints help on the package \texttt{package-name} and its boxes 
2136 (with brief description). 
2137 The package must have been previously loaded \\ \hline 
2138
2139 & \texttt{<box-type>} & 
2140 Prints help (with full description) on the type of box 
2141 \texttt{box-type}. 
2142 The box type must belong to a package which has been previously loaded \\ \hline 
2143
2144 & \texttt{<debug-directive>} & 
2145 [expr|-C|-D] 
2146   Prints debug info on living bbtk objects containing the string \texttt{expr} (default expr=''). 
2147          \texttt{-C} checks the factory integrity.
2148          \texttt{-D} turns on objects debug info after main ends\\ \hline 
2149
2150 \texttt{include} & \texttt{<file-name>} & 
2151 Includes and executes the content of the file named \texttt{file-name} 
2152 exactly like if you were typing its content at the place were the 
2153 \texttt{include} command is. \\ \hline 
2154
2155 \texttt{load} & \texttt{<package-name>} & 
2156 Loads the package \texttt{package-name} (use it only if you know that you won't work with complex black boxes) \\ \hline 
2157
2158 \texttt{include} & \texttt{<package-name>} & 
2159 Loads the package \texttt{package-name} and includes all the complex black boxes that comes with it \\ \hline 
2160
2161 \texttt{kind} & \texttt{<box kind>} & 
2162 Specifies the \texttt{kind} of the complex black boxes you are describing \\ \hline 
2163
2164 \texttt{unload} & \texttt{<package-name>}& 
2165 Unloads the package \texttt{package-name}. 
2166 The package must have been previously loaded. 
2167 No box of a type defined in this package must still exist.\\ \hline 
2168
2169 \texttt{message} & \texttt{<category>} \texttt{<level>} & 
2170 Sets the level of verbosity of \bbi for the category of messages 
2171 \texttt{category} to \texttt{level}.\\ \hline 
2172 %See \ref{verbosity}. 
2173
2174 \texttt{config} & - & Displays the Configuration parameters\\ \hline 
2175
2176 \texttt{reset} & - & Deletes all boxes and unloads all packages so 
2177 that \bbi gets back to its initial state \\ \hline 
2178
2179 \texttt{quit} & - & Exits the interpreter (Don't use it under \bbStudions)\\ \hline 
2180
2181 \end{tabular}
2182 \end{table}
2183 % ==========================================
2184
2185
2186
2187 % ==========================================
2188 \subsubsection{complex black box definition related commands}
2189 \label{bbi-reference-black-box-definition}
2190 % ==========================================
2191
2192 % ==========================================
2193 \begin{table}[!ht]
2194 \caption{\label{bbi-reference-complex-box} \bbi complex black box definition related commands.}
2195 \small
2196 \begin{tabular}{|lcm{6cm}|}
2197 \hline
2198 Command & Parameters & Effect \\ \hline
2199
2200
2201 \texttt{define} & \texttt{<box-type>} & 
2202 Starts the definition of a complex black box of type  
2203 \texttt{box-type}\\ \hline 
2204
2205 \texttt{endefine} & - & 
2206 Ends the definition of a complex black box type\\ \hline 
2207
2208 \texttt{author} & \texttt{<string>} & 
2209 Sets the author(s) of the complex black box currently being defined \\ \hline 
2210
2211 \texttt{description} & \texttt{<string>} & 
2212 Sets the description of the complex black box currently being defined \\ \hline 
2213
2214 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} & 
2215 Defines a new input for the current complex black box, 
2216 named \texttt{name}. 
2217 It is defined as corresponding to 
2218 the input \texttt{input} of the box \texttt{box}.
2219  
2220 \texttt{<help>} is the help string for the new input.
2221 The box \texttt{box} must already have been created in the complex box 
2222 and of course have an input named \texttt{input}.\\ \hline 
2223
2224 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} & 
2225 Defines a new output for the current complex black box, 
2226 named \texttt{name}. 
2227 It is defined as corresponding to 
2228 the output \texttt{output} of the box \texttt{box}. 
2229 \texttt{<help>} is the help string for the new output.
2230 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. \\ \hline 
2231
2232
2233 \end{tabular}
2234 \end{table}
2235 % ==========================================
2236
2237 \newpage
2238
2239 % ==========================================
2240 \vspace{0.5cm}\hrule \\
2241 \section{The Package Browser}
2242 \label{Package_Browser}
2243 % ==========================================
2244
2245
2246 You can run it using the tool bar of the 'Command' part.
2247
2248 See figure \ref{Package_Browser}.
2249
2250 \begin{figure}[!ht]
2251 \caption{\label{Package_Browser}The Package Browser}
2252 \begin{center}
2253 \includegraphics[width=0.6\textwidth]{Package_Browser.png}
2254 \end{center}
2255 \end{figure}
2256
2257 It allows you to query informations about what you can find in the packages (boxes and applications), using several criterions
2258 (warning : it's case sensitive, i.e \texttt{Button} will give different results thn \texttt{button} ...)
2259 \begin {itemize}
2260 \item Pakages :\\
2261 All the boxes and applications held in a given package (e.g. \texttt{wxvtk}, \texttt{std}, ...)
2262 \item Name :\\
2263 You can query on a subpart of the name of a box or an application (e.g. \texttt{DICOM})
2264 \item Description :\\
2265 You can query on a substring of the description of a box or an application (e.g. \texttt{utton} : user wants to get all
2266 the\texttt{Button} as well as the \texttt{button} )
2267 \item Category :\\
2268 You can query on a sub part of the category name of a box or an application (e.g. \texttt{3D})
2269 \item Input Type :\\
2270 You can query all the boxes or applications that have at least one Input entry of the given type (e.g. \texttt{int})
2271 \item Output Type :\\
2272 You can query all the boxes or applications that have at least one Output entry of the given type (e.g. \texttt{int})
2273 \item Input Nature :\\
2274 You can query all the boxes or applications that have at least one Input entry of the given nature (e.g. \texttt{signal})
2275 \item Output Nature :\\
2276 You can query all the boxes or applications that have at least one Output entry of the given nature (e.g.
2277 \texttt{signal},\texttt{file name})
2278 \end {itemize}
2279
2280
2281 All these criterions are \emph{AND}ed while the query process.\\
2282 You can get the whole description of a given box or application clicking on its name.
2283
2284
2285 % ==========================================
2286 \vspace{0.5cm}\hrule \\
2287 \section{Using third party Package}
2288 \label{Third_Party_Package}
2289 % ==========================================
2290
2291 You will have to update the \emph{bbtk\_config.xml} file.\\
2292 To know where it is stored, just click on \texttt{Config} button of the \texttt{Command} part toolbar.
2293
2294 You'll get something like :
2295
2296 \begin{verbatim}
2297 =============
2298  Configuration
2299  =============
2300  bbtk_config.xml    : [/home/jpr/Creatis/bbtk/binLIN/bin/bbtk_config.xml]
2301  Documentation Path : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/doc]
2302  Data Path          : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/data]
2303  Temp Directory     : [/home/jpr/Creatis/bbtk/binLIN]
2304  File Separator     : [/]
2305  BBS Paths   
2306  --- [.]
2307  --- [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/bbs]
2308  --- [/home/jpr/Creatis/bbtk/binLIN/share/bbtk/bbs]
2309  PACKAGE Paths : 
2310  --- [.]
2311  --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2312  --- [/home/jpr/Creatis/bbtk/binLIN/bin/../lib]
2313  --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2314  --- [/home/jpr/Creatis/bbtk/binLIN/bin\Debug]
2315  --- [/home/jpr/Creatis/bbtk/binLIN/bin\Release] 
2316 \end{verbatim}
2317
2318 (depending on who you are, and whether \texttt{bbStudio} is installed or not.)\\
2319
2320 Just use your favourite text editor to add :
2321 \begin{itemize}
2322 \item
2323  at the end of the \texttt{BBS Paths} part 
2324  the name of the directory that contains the \texttt{.bbs} scripts of the package you
2325 want to use,
2326 \item at the end of the \texttt{PACKAGE Paths} part
2327  the name of the directory that contains the dynamic libraries (\texttt{.dll} or \texttt{.so}) of the package
2328 \end{itemize}
2329
2330 If you want (and sure you will) to be able to use the Help tools as well on the features provided by this package, you must use the
2331 option \texttt{Generate index}  in the menu \texttt{Tools} of the \texttt{Files} part toolbar.  
2332 % ==========================================
2333 \vspace{0.5cm}\hrule \\
2334 \section{Using black boxes in \CPP programs}
2335 \label{cpp}
2336 % ==========================================
2337
2338 A very usefull feature is that you may use any black box within a \CPP program witout worrying about wxWigets main window.\\
2339
2340 Let's look a the following bbs script :
2341
2342 \begin{verbatim}
2343 # Load the packages
2344 load std
2345 load wx
2346
2347 # Create the Objects
2348 new Slider     slider
2349 new OutputText text
2350 new LayoutLine layout
2351
2352 # Graphical pipeline
2353 connect slider.Widget    layout.Widget1
2354 connect text.Widget      layout.Widget2
2355
2356 # Execution pipeline
2357 connect slider.BoxChange text.BoxExecute
2358 connect slider.Out       text.In
2359
2360 # Go!
2361 exec layout
2362 \end{verbatim}
2363
2364 User wants to create a slider and an output text, within a layoutline, and display the slider value in the output text.\\ 
2365 Think about the (little!) nightmare to code the same, in 'raw C++', using wxWidgets.\\
2366
2367 Using \bbtk you just 'convert' the script :
2368 \begin{verbatim}
2369
2370 #include <bbwxSlider.h>
2371 #include <bbwxOutputText.h>
2372 #include <bbtkFactory.h>
2373 #include <bbwxLayoutLine.h>
2374
2375 int main(int argv, char* argc[])
2376 {
2377       // we need to intanciate a bbtk::Factory to be aware of the adaptors
2378       bbtk::Factory::Pointer factory = bbtk::Factory::New();
2379       
2380       // Load the packages
2381       // ----------------  
2382       factory->LoadPackage("std");
2383       factory->LoadPackage("wx");
2384       
2385       // Create the Objects
2386       // ------------------      
2387       bbwx::Slider::Pointer     slider   = bbwx::Slider::New("slider");
2388       bbwx::OutputText::Pointer text     = bbwx::OutputText::New("text");
2389       bbwx::LayoutLine::Pointer layout   = bbwx::LayoutLine::New("layout");
2390       
2391       // Graphical pipeline
2392       bbtk::Connection::Pointer c1       = bbtk::Connection::New(slider,"Widget",
2393                                                            layout,"Widget1");
2394                                                            
2395       bbtk::Connection::Pointer c2       = bbtk::Connection::New(text,"Widget",
2396                                                            layout,"Widget2");
2397                                                                                                                                                                            
2398       // Execution pipeline
2399       // ------------------
2400       
2401       // We have to pass the 'factory', in order to call automatically an adaptor,
2402       // if necessary.
2403       bbtk::Connection::Pointer s2t      = bbtk::Connection::New(slider,"Out",
2404                                                             text,"In",
2405                                                             factory);      
2406        bbtk::Connection::Pointer c3       = bbtk::Connection::New(slider,"BoxChange",
2407                                                             text,"BoxExecute");      
2408       layout->bbSetInputWinDialog(true);
2409       
2410       // Go!
2411       // ---     
2412       layout->bbExecute();
2413
2414     }
2415   catch (bbtk::Exception e)
2416     {
2417       bbtk::MessageManager::SetMessageLevel("Error",1);
2418       e.Print();
2419     }
2420 }
2421 \end{verbatim}
2422
2423 %\bibliography{all}
2424
2425
2426
2427 %\section{Conclusion}
2428
2429
2430 \end{document}
2431