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