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