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