1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
6 \def\todo{\scriptsize\fbox{\bf TODO !!}\normalsize}
8 \def\BBTK{{\xspace}The {\bf Black Box Toolkit} }
9 \def\bbtk{{\xspace}$\texttt{bbtk}$ }
10 \def\bbi{{\xspace}$\texttt{bbi}$ }
11 \def\bbStudio{{\xspace}$\texttt{bbStudio}$ }
12 \def\bbfy{{\xspace}$\texttt{bbfy}$ }
13 \def\bbdoc{{\xspace}$\texttt{bbdoc}$ }
14 \def\bbCreatePackage{{\xspace}$\texttt{bbCreatePackage}$ }
16 \def\bb{{\xspace}$\texttt{bb}$ }
17 %\def\bbp{{\xspace}$\texttt{bbp}$\xspace}
19 \def\cmake{{\xspace}$\texttt{cmake}$ }
21 \def\C{{\xspace}$\texttt{C}$ }
22 \def\CPP{{\xspace}$\texttt{C++}$ }
24 \def\xml{{\xspace}$\texttt{xml}$ }
26 \def\itk{{\xspace}$\texttt{itk}$ }
27 \def\vtk{{\xspace}$\texttt{vtk}$ }
28 \def\gdcm{{\xspace}$\texttt{gdcm}$ }
29 \def\gsmis{{\xspace}$\texttt{gsmis}$ }
30 \def\wx{{\xspace}$\texttt{wxWidgets}$ }
32 \def\lin{{\xspace}\textit{Linux} }
33 \def\win{{\xspace}\textit{Windows} }
35 % the same macros with no space at the end
37 \def\BBTKns{{\xspace}The {\bf Black Box Toolkit}}
38 \def\bbtkns{{\xspace}$\texttt{bbtk}$}
39 \def\bbins{{\xspace}$\texttt{bbi}$}
40 \def\bbfyns{{\xspace}$\texttt{bbfy}$}
41 \def\bbdocns{{\xspace}$\texttt{bbdoc}$}
42 \def\bbCreatePackagens{{\xspace}$\texttt{bbCreatePackage}$}
44 \def\bbns{{\xspace}$\texttt{bb}$}
45 %\def\bbp{{\xspace}$\texttt{bbp}$\xspace}
47 \def\cmakens{{\xspace}$\texttt{cmake}$}
49 \def\Cns{{\xspace}$\texttt{C}$}
50 \def\CPPns{{\xspace}$\texttt{C++}$}
52 \def\xmlns{{\xspace}$\texttt{xml}$}
54 \def\itkns{{\xspace}$\texttt{itk}$}
55 \def\vtkns{{\xspace}$\texttt{vtk}$}
56 \def\gdcmns{{\xspace}$\texttt{gdcm}$}
57 \def\gsmisns{{\xspace}$\texttt{gsmis}$}
58 \def\wxns{{\xspace}$\texttt{wxWidgets}$}
60 \def\linns{{\xspace}\textit{Linux}}
61 \def\winns{{\xspace}\textit{Windows}}
79 Last modified on : September 16, 2008 \\
83 Laurent Guigues, Jean-Pierre Roux
86 % ==========================================
88 % ==========================================
96 % ==========================================
98 % ==========================================
100 % ==========================================
102 \section{What is {\bf bbtk} ?}
103 % ==========================================
104 \BBTK(\bbtkns) is a set of tools
105 (\CPP libraries and executables)
106 providing a \CPP framework for the definition
107 of elementary processing \emph{units}, called {\bf black boxes},
108 and the definition and execution of processing \emph{chains}
109 made up of these black boxes. \\
110 It's a part of the \texttt{Creatools suite} composed mainly of :
122 % ==========================================
123 \subsection{The black box philosophy}
124 % ==========================================
126 \href{http://www.answers.com/topic/black-box-theater}{The Answers Dictionary} defines a {\bf black box} as
127 \emph{``A device or theoretical construct with known or specified performance characteristics
128 but unknown or unspecified constituents and means of operation''} \\
129 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
130 defines a {\bf black box} as
131 \emph{``any component in a system in which only the input and output
132 characteristics are of interest, without regard to its internal mechanism
134 We should merge theese definitions. :
135 not only the inputs and outputs are of interest but also
136 \emph{what the box does} !
137 Hence, I would say that a black box is any \emph{\bf documented}
138 component of a system, letting the user know
139 \emph{\bf what} the box is supposed to do and
140 \emph{\bf how to use it}
141 but not \emph{\bf how it does it}. \\
143 \BBTK provides a systematic framework
144 to encapsulate (or ``wrap'') any
145 existing \texttt{C} or \CPP processing code into an object
146 (a black box) having a {\bf generic symbolic interface}, where
149 \item{\bf generic} means that the interface is \emph{the same}
150 for all boxes. Hence one does not need to know which particular
151 method allows, say, to set a particular input or
152 get a particular output of the box.
153 One can use a black box in a purely abstract way.
154 \item{\bf symbolic} means that a particular
155 input or output is referenced by a 'name', that is by a symbol
156 which identifies the input or output.
157 It also means that symbolic information (text!) is
158 attached to a box: description of the box, author,
159 description of its inputs and outputs, etc.
162 (Actually, genericity is achieved because the interface is symbolic.
163 We let you think about this\dots)
165 Of course, symbolic data attached to a box may be
166 {\bf queried} : what are the inputs/outputs of the box ?
167 what are their type ? their description ? etc.
168 This allows {\bf automatic documentation} of boxes.
170 The abstract definition of black boxes is the most basic
171 aspect of \BBTK architecture.
172 Another key aspect is the groupement of black boxes into
173 so called {\bf packages},
174 which are \emph{dynamic libraries} which can also
175 be queried, in particular about the boxes they provide.
176 The package structure then offers a mechanism which
177 is like a \emph{'plug-in'} mechanism.
178 \BBTK provides the methods to load a package at run-time,
179 and create instances of the boxes it contains.
181 These two mechanisms (black boxes and packages)
182 then gives the way to:
185 \item The definition of an {\bf interpreted script language},
186 which allows to manipulate packages and boxes very easily in symbolic way.
187 \BBTK provides one : \bbi (the Black Box Interpreter).
188 \item {\bf Automatic documentation} of existing packages.
189 \texttt{html} documentation of packages is proposed by
193 Finally, these different components allow {\bf efficient} :
196 \item {\bf capitalization and reuse} of existing processing units,
197 including {\bf documentation}
198 \item {\bf testing, prototyping} in a very simple script language
199 \item {\bf inter-operability} between atomic processings which
200 have been written by different persons, using different libraries, etc.
203 % ==========================================
204 \subsection{\bbtk components}
205 % ==========================================
208 \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework
209 (abstract classes) to develop black boxes and store them into
210 dynamic libraries, called black box \emph{packages}.
211 \item Different {\bf\emph{black box packages}} :
213 \item {\bf\emph{std}} : the 'standard' package including basic useful boxes.
214 \item {\bf\emph{wx}} : basic graphical interface elements (widgets : sliders, buttons, etc. based on the \texttt{wxWidgets} library).
215 \item {\bf\emph{itk}} : the basic image processing package, based on the \itk library.
216 \item {\bf\emph{vtk}} : the basic images and surfaces processing and vizualization package, based on the \vtk library.
217 \item {\bf\emph{wxvtk}} : widget boxes based on the \vtk library (2D and 3D vizualization and
219 \item {\bf\emph{itkvtk}} : special boxes (adaptors) to convert \itk structures into \vtk structures and conversally.
220 %\item {\bf\emph{creaReaders}} : Provides hight level widgets to read images, including DICOM.
221 \item {\bf\emph{toolsbbtk}} : Tools for bbtk administration and package development..
223 \item A {\bf\emph{Developement environment}}, called \bbStudio, which provides
225 \item An online {\bf\emph{script editor}}
226 \item A powerfull {\bf\emph{Help environment}}, called \bbPackageBrowser
229 \item Online documentation scaning
230 \item Retreiving boxes on various criterions
231 \item Checking Demo and examples
234 \item An {\bf\emph{interpreter}}, called \bbins, which allows to
235 load black box packages and to define and execute
236 processing chains by connecting various black boxes of the already loaded packages.
237 \item {\bf\emph{Utilities}} :
239 \item \bbfy generates the \CPP code of a black box from a
240 description file written in \texttt{xml}.
241 %\item \bbdoc generates the html documentation of a black box package
242 %(author, description, description of its black boxes :
243 %author, description, inputs, outputs, and so on).
244 \item \bbCreatePackage allows to create the basic file architecture
245 to start the development of a new black box package.
249 The general architecture of \BBTK
250 is shown in figure \ref{bb-architecture}.
253 \caption{\label{bb-architecture}\BBTK architecture}
255 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
261 % ==========================================
262 \subsection{Structure of this guide}
263 % ==========================================
265 This guide is divided into three parts.
267 The first part (\ref{bbStudio}) is a brief presentation of the very intuitive Development
268 environment, \bbStudions.
270 The second part (\ref{bb0})
271 is devoted to the use of the \emph{black box interpreter} \bbins.
272 This is the highest level of use of the toolkit, which
273 allows to create and execute processing chains by connecting
274 black boxes of existing packages.
276 The third part (\ref{cpp}) explains how to
277 use the black box toolkit framework in \CPP code,
278 typically to develop large applications which
279 involve complex graphical interfaces.
282 % ==========================================
283 % ==========================================
284 % ==========================================
285 % ==========================================
286 % ==========================================
287 % ==========================================
289 \section{The Development environment (bbStudio)}
292 Just run it, typing in a console \bbStudio
293 or clicking on its icon or its menu entry.
294 At start, \bbStudio opens with a very minimal 'How to use' in the middle. \\
295 Don't forget to read it : it will vanish at the first mouse click. \\
297 1) Click on the 'Demo' or 'Examples' link.
298 2) Select a Demo or an Example
299 3) Click on the [Source] link : the source file is loaded in bbStudio
300 4) Click on the 'Run button' (the down arrow at the bottom right
304 You'll get something like in figure
305 \ref{bbi-fig-bbStudio-gui-start}
306 (the exact appearance of \bbStudio is Operating System and \bbtk version dependent)
309 \caption{\label{bbi-fig-bbStudio-gui-start}The bbStudio Development environment interface at start time}
311 \includegraphics[width=0.7\textwidth]{bbStudioMainPageStart.png}
316 Feel free to resize any part you want.
317 Your preferences will be kept next time you run again \bbStudio. \\
319 Let's have a look at the resized window :
322 \caption{\label{bbi-fig-bbStudio-gui}The bbStudio Development environment interface}
324 \includegraphics[width=0.7\textwidth]{bbStudioMainPage.png}
328 You can see four parts :
331 \item {\bf{Messages}}
336 The stuff is written using the Advanced User Interface library of wxWidgets,
337 whose 'docking manager' allows windows and toolbars to be floated/docked
339 Please don't use this feature at learning time (the snapshots of this document
340 wouldn't match with your screen ...)
342 \subsection{'Files' part}
343 \label{bbi-FilesPart}
345 It's the .bbs script editor.\\
346 If you load a file holding a script, it will be displayed here, and you'll be
347 able to modify it, to save it, to save-as it, to run it, using the
351 \subsection{'Messages' part}
352 \label{bbi-MessagesPart}
354 Two kinds of messages will be output here:\\
355 System messages : produced by the kernel, in case of a user mistyping, or an execution error\\
356 Script messages : produced by the \bbtk equivalent of \texttt{printf} or \texttt{std::cout} in user programs
358 \subsection{'Command' part}
359 \label{bbi-CommandPart}
361 This is where user will type his requirements.
363 \subsection{'Help Contents' part}
364 \label{bbi-HelpContentsPart}
366 The 'Help Contents' part of \bbStudio is used to browse the html help of \BBTK.
367 All the entries of the starting page are self-explanatory :
369 \item {\bf\emph{Help Contents}}
371 %\item {\bf\emph{Wiki}} : Direct link to the bbtk Wiki (intranet only, right now, www
373 \item {\bf\emph{Demo}} : Link to some 'sophisticated' demonstrations.
374 \item {\bf\emph{Examples}} : Link to some detailed 'How to use' examples
377 \item {\bf\emph{Guides}}
379 \item {\bf\emph{User's Guide}} : Step to step How-to for user who wants to create his own
380 application, just using already existing boxes.
381 \item {\bf\emph{Package Developper's Guide}} : Step to step How-to for user who wants to create his own
383 \item {\bf\emph{Developper's Guide}} : For bbtk kernel developpers. Sorry, not yet written.
384 \item {\bf\emph{Reference Manual}} : Sorry, not yet written.
385 \item {\bf\emph{Booklet}} : Vade mecum. Sorry, not yet written.
386 \item {\bf\emph{Doxygen Documentation}} : Doxygen source browser.
389 \item {\bf\emph{Boxes}} : Box retrieving on various criterions :
391 \item {\bf\emph{By name}} (Alphabetical list)
392 \item {\bf\emph{By package}} (see table : \ref{bbi-list_of_packages})
393 \item {\bf\emph{By category}} (see table : \ref{categories})
394 \item {\bf\emph{Adaptors}} Used internaly to perform type conversions (not end user intended)
399 % ==========================================
401 \caption{\label{bbi-list_of_packages} List of bbtk supplied packages.}
403 \begin{tabular}{|lp{10cm}|}
405 Package & What it's used for \\ \hline
406 \texttt{std} & : the 'standard' package including basic useful boxes \\ \hline
407 \texttt{wx} & : basic graphical interface elements (widgets : sliders, buttons, etc.) based on the \texttt{wxWidgets} library \\ \hline
408 \itk & : the basic image processing package, based on the \itk library. (without description)\\ \hline
409 \vtk & : prints help on the package \texttt{package-name} and its boxes (with brief description). The package must have been previously loaded\\ \hline
410 \texttt{wxvtk} & : widget boxes based on the \vtk library.\\ \hline
411 \texttt{itkvtk} & : adaptors to convert \itk structures into \vtk structures and conversally.\\ \hline
412 %\texttt{creaReaders} & : provides high level widgets to read images including DICOM.\\ \hline
413 \texttt{toolsbbtk} & : Tools for bbtk administration and package development.\\ \hline
417 % ==========================================
422 % ==========================================
424 \caption{\label{categories} \texttt{Black Box} categories}
426 \begin{tabular}{|lp{10cm}|}
428 \texttt{Category name} & : Meaning \\ \hline \\ \hline
429 \texttt{adaptor} & : Adaptor box \\ \hline
430 \texttt{application} & : Final application, end user intended \\ \hline
431 \texttt{atomic box} & : System category.
432 Automatically assigned to Atomic Black Boxes (c++ defined) \\ \hline
433 \texttt{complex box} & : System category.
434 Automatically assigned to Complex Black Boxes (script defined) \\ \hline
435 \texttt{command line} & : Script which defines a command line application \\
436 & :(no embedded GUI, but command line imput parameters) \\ \hline
437 \texttt{demo} & : Demonstration \\ \hline
438 \texttt{devel} & : Developer tool (bbCreatePackage.bbs, ...) \\ \hline
439 \texttt{dicom} & : DICOM aware box \\ \hline
440 \texttt{example} & : Example script showing a box use-case \\ \hline
441 \texttt{filter} & : Image processing box \\ \hline
442 \texttt{image} & : Image processing related box \\ \hline
443 \texttt{interaction} & : \\ \hline
444 \texttt{math} & : Mathematical operations \\ \hline
445 \texttt{mesh} & : Mesh processing related box \\ \hline
446 \texttt{misc} & : A box that cannot be put in other category ! \\ \hline
447 \texttt{read/write} & : Box that read or write data from or to disk \\ \hline
448 \texttt{viewer} & : Box which displays some data \\ \hline
449 \texttt{widget} & : Piece of graphical interface \\ \hline
450 \texttt{3D object creator} & : Sophisticated 3D widget \\ \hline
451 \texttt{toolsbbtk} & : Component of bbStudio \\ \hline
455 % ==========================================
458 \caption{\label{kinds} \texttt{Black Box} kinds}
460 \begin{tabular}{|ll|}
462 \texttt{Kind name} & : Meaning \\ \hline \\ \hline
463 \texttt{ADAPTOR} & : Adaptor Box \\ \hline
464 \texttt{DEFAULT\_ADAPTOR} & : \\ \hline
465 \texttt{WIDGET\_ADAPTOR} & : \\ \hline
466 \texttt{DEFAULT\_WIDGET\_ADAPTOR} & : \\ \hline
467 \texttt{GUI} & : \\ \hline
468 \texttt{DEFAULT\_GUI} & : \\ \hline
469 \texttt{ALL} & : If kind='ALL' then sets the level for all kinds \\ \hline
483 % ==========================================
484 % ==========================================
485 % ==========================================
486 % ==========================================
487 % ==========================================
488 % ==========================================
490 \section{The script manager}
492 % ==========================================
494 Atomatically open in the left upper part of bbStudio.
498 \caption{\label{bbi-fig-bbStudio-file0}The bbStudio script manager}
500 \includegraphics[width=0.7\textwidth]{bbFile0.png}
504 Using the lower tool bar (see figure : \ref{lowertoolbar}), you can :
508 \caption{\label{lowertoolbar}The lower tool bar}
510 \includegraphics[width=0.7\textwidth]{lowertoolbar.png}
516 \item {\bf\emph{New file}} : Create a new file to hold a script
517 \item {\bf\emph{Open file}} : Open a already existing file holding a script
518 \item {\bf\emph{Close file}} : Close a file holding a script
519 \item {\bf\emph{Save file}} : Save he current file (if modified)
520 \item {\bf\emph{Save file as}} : Save he current file under a different name
521 \item {\bf\emph{Run file}} : Execute the script you just loaded/modified/written
525 The script language is very simple.
526 Everything is done with only a very few commands (See table \ref{bbi-reference-box}).
527 The philosophy of this part is also very simple :
528 it introduces the \bbi commands using examples,
529 starting with the most simple commands.
530 The first section of this part
531 (\ref{bbi-getting-started})
532 is designed like a tutorial,
533 which progressively introduces all the concepts of the command interpretor.
534 We suggest you run \bbStudio and follow the examples,
535 to see how it works in practice.
536 At the end of this section,
537 you will be able to use \bbStudio and write
538 own black box processing scripts.
541 the section \ref{bbi-more-on}
542 (called \emph{more on...})
543 goes deeper into various issues of the command interpretor.
544 Read it at your convenience,
545 either linearly to learn more about \bbStudio,
546 or in random order to get an answer
547 to a particular question.
549 Finally, the section \ref{bbi-reference}
550 summarizes all the commands of \bbStudions,
551 their parameters and effect.
552 Use it as a reference.
558 % ==========================================
559 \subsection{Getting started}
560 \label{bbi-getting-started}
562 % ==============================================
563 \subsubsection{Installed tree \emph{vs} Built tree}
564 % ==============================================
566 If you want to use the 'installed' version (it means you downloaded and run the Windows
567 installer, or the Fedora package, or you downloaded, compiled and installed the
568 cvs version), just open a console and type \bbStudions, or double click on the application icon. \\
570 If you want to run your own uninstalled version (say : you downloaded and compiled the
571 cvs version in order to use a recently commited patch, but you want to be able to still use the standard version),
572 you have to open a console, cd in the bin directory of the built tree and type \texttt{./bbStudio}.
574 % ==============================================
575 \subsubsection{Using an already existing script}
576 % ==============================================
578 Run \bbStudio the way you need. \\
579 In the part 'Help contents' (See figure \ref{HelpContents}), select \texttt{Examples} link.
582 \caption{\label{HelpContents}Help Contents}
584 \includegraphics[width=0.7\textwidth]{HelpContents.png}
588 You will be asked to select a Box category (See figure \ref{BoxCategories}); \\
589 Select \texttt{example}.
593 \caption{\label{BoxCategories}Box Categories}
595 \includegraphics[width=0.7\textwidth]{BoxCategories.png}
599 You will be asked to choose a script (See figure \ref{example}).
602 \caption{\label{example}example list}
604 \includegraphics[width=0.7\textwidth]{example.png}
610 Select \texttt{wx::exampleSlider} (See figure \ref{exampleSlider});
613 \caption{\label{exampleSlider}example 'exampleSlider'}
615 \includegraphics[width=0.7\textwidth]{exampleSlider.png}
619 You can see the graphical summary representation of the current script (the elementary boxes that compose it, and their
621 Click on \texttt{source}, and you'll be able to see the (very simple) script,
622 in the 'Files' part, within the script editor (See figure \ref{exampleSliderSource});
625 \caption{\label{exampleSliderSource}source code of 'exampleSlider'}
627 \includegraphics[width=0.7\textwidth]{exampleSliderSource.png}
631 Run it, using the lower toolbar (see figure : \ref{lowertoolbar})
633 You'll get something like in \ref{execSliderSource}.
636 \caption{\label{execSliderSource}execution of 'exampleSlider'}
638 \includegraphics[width=0.7\textwidth]{execSliderSource.png}
642 Feel free to move the slider, to check it actually works...
647 % ==========================================
648 \subsubsection{Creating and executing black boxes}
649 % ==========================================
651 To learn interactivelly the script language features, you can use the black box
653 open a console and type \bbStudio
654 or double click on the application icon.
655 You get a window which looks like the one in figure
656 \ref{bbi-fig-bbi-gui}
657 (the exact appearance of \bbStudio is system and \bbtk version dependent)
659 %\footnote{If you compiled \bbtk without \wx then \bbi does not have a
660 %graphical interface but a simple prompt}.
663 \caption{\label{bbi-fig-bbi-gui}The black box interpreter interface}
665 \includegraphics[width=0.7\textwidth]{bbi-gui0.png}
669 The 'working' area (the left one, as opposed to the 'help' area, on the right side) is composed of :
670 one single line zone (Command), at the bottom in which you can enter your commands and
671 a multiple line zone in which the Command interpreter prints out the result of your commands.
672 The upper part contains the script editor; we shall not use it right now, you may reduce it
674 Try typing in the input zone (in this manual,
675 the commands entered by the user will be preceded by a prompt \textgreater) :
680 you get the list of the commands of the interpreter :
713 To get help on a particular command type \texttt{help <command-name>},
721 usage : author <string>
722 Adds the string <string> to the author information of the black box being defined
725 The \texttt{help} command has multiple usages.
726 It is used to get help about almost anything in the interpretor!
727 Type \texttt{'help help'} to get help on the \texttt{help} command itself :
732 (2) help <command name>
733 (3) help packages [all]
734 (4) help <package name> [all]
735 (5) help <black box type>
736 (6) help <black box name>
738 (1) Lists all available commands;
739 (2) Prints help on a particular command;
740 (3) Lists the packages loaded and their black boxes.
741 Add 'all' to list adaptors;
742 (4) Prints short help on the black boxes of a package.
743 Add 'all' to include adaptors;
744 (5) Prints full help on a black box type;
745 (6) Prints information on the inputs, outputs and connectionns
746 of a black box instance.
749 At start the interpretor does not know any black box.
750 If you type \texttt{'help packages'}, which is
751 the third form of the \texttt{help} command, you get :
758 which means that the interpretor only knows one package
759 (library of black boxes) called \texttt{user}
760 and which contains a black box called \texttt{workspace}.
761 The \texttt{user} package is an internal package of the interpreter,
762 which stores user-defined black box types.
763 At start, it already contains
764 one box, called \texttt{workspace}.
765 \texttt{workspace} is a special type of black box,
766 called complex black box, whose purpose is
767 to store other black boxes.
768 Any black box you create in \bbStudio is stored
769 in \texttt{workspace}
770 (this will be explained in details in sections
771 \ref{bbi-writing-scripts} and
772 \ref{bbi-more-on-complex-black-boxes}).
774 If you type \texttt{'help workspace'}, you get :
777 Complex Black Box <user::workspace>
780 Category(s) : complex box;
786 In the text displayed,
787 the \texttt{user::} prepended to the name \texttt{workspace}
788 means that the box \texttt{workspace}
789 belongs to the \texttt{user} package.
790 Then comes a description and three lines which
791 tell that \texttt{workspace} does not have any input
792 nor output nor boxes yet.
794 In order to let the interpreter know of some black boxes,
795 you must load another package.
796 The \texttt{std} package is the ``standard'' package,
797 which contains basic useful black boxes.
809 you get something like :
819 % GetVectorCharElement
821 % GetVectorUShortElement
827 % PrependPackageDataPath
838 ASCII : ascii codes sequence to string - string to ascii...
839 Add : Adds its inputs
840 ConcatStrings : String concatenation
841 Configuration : Gets configuration informations
842 Div : Divides its inputs
843 ExecBbiCommand : Executes bbi commands
844 ExecSystemCommand : Executes system (O.S.) commands
845 GetVectorCharElement : Gets the i-th element from the input vector (std...
847 MagicBox : Takes *any kind* of data and copies it to its ou...
848 MakeFileName : Makes a kosher file name
849 Mul : Multiplies its inputs
850 MultipleInputs : This box has multiple Void inputs and one Void o...
851 StringRelay : Just copies the value of its input to its output...
852 StringSelect : Outputs the string set to the ith input Ini (In0...
857 Now the interpreter knows the package \texttt{std} and the black boxes it provides,
858 such as the \texttt{'Add'} box, the \texttt{'ConcatStrings'} box, and so on. Remark that the
859 content of \texttt{std} may vary from one version to another
860 as new black boxes might be added to it.
866 You'll get a text help, in the 'Message' part :
870 By : laurent.guigues@creatis.insa-lyon.fr
871 Categories : atomic box;math;
873 'BoxExecute' <bbtk::Void> [signal] : Any signal received by this input
875 'BoxProcessMode' <String> [] : Sets the processing mode of the box
876 (Pipeline | Always | Reactive)
877 'In1' <Double> [] : First number to add
878 'In2' <Double> [] : Second number to add
880 'BoxChange' <bbtk::Void> [signal] : Signals modifications of the box
881 'Out' <Double> [] : Result
884 You'll get as well the same information in the 'Help' Part, in html format (see figure : \ref{HelpAdd}) :
887 \caption{\label{HelpAdd}The html Help}
889 \includegraphics[width=0.7\textwidth]{HelpAdd.png}
894 the \texttt{std::} prepended to the name \texttt{Add}
895 means that the box \texttt{Add}
896 belongs to the \texttt{std} package.
897 Then comes a description
898 (the one which was provided by the author of the box),
899 the author(s) of the box (usually e-mail adress(es)) and
900 the categories to which the box belongs.
901 Finally comes the lists of inputs and outputs of the box.
902 For each input or output, \bbi provides
903 its \emph{name} (between quotes, e.g. \texttt{'ProcessMode'}),
904 its \emph{type} (between \texttt{<} and \texttt{>}, e.g. \texttt{<Int>})
906 Remark that the box \texttt{Add} is not a 'complex' black box
907 but an 'atomic' box, hence its help does not
908 mention any information concerning possible internal boxes.
910 You can create an \emph{instance} of an \texttt{Add} box by
911 the command \texttt{new} :
916 The \texttt{'a'} at the end is the \emph{name} of the instance,
917 which will be used to reference it later.
918 It is important to distinguish a box \emph{type}
919 and an \emph{instance} of a box type.
920 The \texttt{Add} box of the package \texttt{std} is actually
921 a \emph{box type} , like \texttt{int} is a data type
922 in \texttt{C} langage. The \texttt{new} command allows to create
923 an instance of a box type, exactly like \texttt{int i;} in
924 a \texttt{C} code, it declares a variable of type \texttt{int} whose
926 Of course, like in \texttt{C} Language, you can declare multiple boxes of the
929 After the creation of the box \texttt{a}, type :
936 Complex Black Box <user::workspace>
939 Category(s) : complex box;
946 which means that \bbi workspace now contains a black box named \texttt{a},
947 of type \texttt{std::Add}.
949 Now look back at the help on \texttt{Add} boxes :
950 you can see that this type of box has two inputs,
951 with name \texttt{In1} and \texttt{In2},
952 and an output, with name \texttt{Out}.
954 You can set the input \texttt{In1}
955 of the \texttt{Add} box \texttt{a} to the value $1$
961 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $2$
967 And you print the output \texttt{Out} of the box \texttt{a} with :
969 > print "result=$a.Out$"
973 In the string passed to the \texttt{print} command,
974 each substring enclosed between a couple of \$ is considered
975 as the name of an output of a box.
976 To process this special substrings, the interpretor :
978 \item Processes the box if needed (see below)
979 \item Converts the output of the box to a string if possible
981 \item Substitutes the result in the string to print
982 \item Postpones an implicit 'new line' character to the string
987 Box processing is needed if :
990 \item either at least input has changed since last processing
991 \item or the input \texttt{'BoxProcessMode'} of the box is set to
992 \texttt{'Always'}, which forces box reprocessing.
995 Note that all boxes have an input named \texttt{'BoxProcessMode'}.\\
997 Another way to process the box \texttt{a} is to issue the command :
1002 however this command does not display anything (except if the
1003 box itself displays something in its processing).
1004 It just processes the box if needed.
1005 This command is used to execute boxes that do not have any output,
1006 such as boxes that write something to a file or, display a
1007 graphical interface, and so on. \\
1009 %To exit \bbi, type :
1015 % ==========================================
1021 \item The \texttt{include} command allows to load a package, and the complex black boxes that come with it..
1022 \item \texttt{help} gives help on :
1024 \item Available commands if you just type \texttt{help}.
1025 \item A particular command if you type \texttt{help <command-name>}.
1026 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
1027 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
1028 \item A particular black box type (with full description) if you type \texttt{help <box-type-name>}. In particular, \texttt{help workspace} displays information on the content of the \texttt{'workspace'} black box, which stores the boxes created by the user (by \texttt{new}).
1030 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
1031 \item \texttt{new} : creates an instance of a black box.
1032 \item \texttt{set} : sets the value of an input of a black box.
1033 \item Under any component of \bbStudions, to reference the input called \texttt{i}
1034 of a black box called \texttt{b} you must type \texttt{'b.i'}.
1035 The same syntax holds for outputs.
1036 \item \texttt{print} : prints a string, substituting each substring of the form \$b.o\$ by the value of the output \texttt{o} of the black box \texttt{b}. Note that an
1037 implicit trailing 'new line character' is added at the final string.
1038 \item \texttt{exec} : runs, if needed, the process of a box.
1039 %\item \texttt{quit} : quits \bbi.
1044 %A more 'modern' way to proceed is to run \texttt{bbStudio}, drag and drop the \texttt{Command} bookmark to the lower \texttt{Welcome to bbStudio!} bar.
1045 %Wou'll get something like in figure \ref{bbCommandPlusHelp} :
1047 %\begin{figure}[!ht]
1048 %\caption{\label{bbCommandPlusHelp}
1049 %An other way to run the command interpreter}
1051 %\includegraphics[width=0.5\textwidth]{bbCommandPlusHelp.png}
1055 % ==========================================
1057 % ==========================================
1058 \subsubsection{Connecting black boxes}
1059 \label{bbi-connecting-black-boxes}
1060 % ==========================================
1062 \BBTK allows to create
1063 and execute processing chains,
1064 also called \emph{pipelines},
1065 by connecting black boxes.
1066 This section explains how to do it with examples.
1067 Read section \ref{bbi-more-on-pipeline-processing} to get
1068 more information on pipeline processing.
1070 First start \bbStudio and load the package \texttt{std}, typing :
1074 in the 'Command' part.
1076 Assume you want to compute $1+2+3$. You can do it by
1077 chaining two \texttt{Add} boxes, as shown in figure
1078 \ref{bbi-fig-connecting-black-boxes-1}.
1081 \caption{\label{bbi-fig-connecting-black-boxes-1} A simple pipeline which adds 3 numbers}
1083 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
1088 The \bbi instructions to create and execute this pipeline are :
1092 > connect a.Out b.In1
1099 You will see the (very expected) result :
1104 The first three commands build the pipeline,
1105 the next three set \texttt{a} and \texttt{b} black boxes inputs and the last one
1106 prints \texttt{b} black boxe output (the pipeline is executed before printing, because the interpretor 'knows' the box \texttt{b},
1107 whose output is requested, is not up to date.
1109 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output
1110 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the
1112 Once the boxes connected, the processing of the two boxes are chained :
1113 getting the output of \texttt{b} requires getting its inputs,
1114 hence getting the output of \texttt{a} which is connected to it.
1115 This pipeline mechanism can recurse into arbitrary long
1116 chains of boxes (see \ref{bbi-more-on-pipeline-processing}
1120 Lets' consider an other, more image oriented, example :
1128 > new FileSelector fileDialog
1129 > new ImageReader reader
1131 > new Viewer2D viewer
1133 > connect fileDialog.Out reader.In
1134 > connect reader.Out viewer.In
1135 > connect slider.Out viewer.Slice
1136 > connect slider.BoxChange viewer.BoxExecute
1141 Some explainations : the \texttt{include} instructions load the necessary packages. \\
1143 \texttt{new FileSelector} will pop a File Selector, at run time, that will out the user chosen file name. \\
1144 \texttt{new Slider} will pop a Slider, at run time, that will out an integer, used later as a slice number.\\
1145 \texttt{new ImageReader} will read any itk readable file, whose name is passed as a std::string, and return a itk::ImagePointer.\\
1146 \texttt{new Viewer2D} display a plane, whose number id specified by an integer.\\
1148 \texttt{connect fileDialog.Out reader.In} plugs the output of the File Selector (a std::string) to the input of the reader (a std::string, too).\\
1149 \texttt{connect reader.Out viewer.In} plugs the output of the reader (an itk::ImagePointer) to the input of the Viewer (a vtkImageData *)\\
1150 \texttt{connect slider.Out viewer.Slice} plugs the output of the slider (an int) to an other output (named Slide) of the viewer.\\
1151 \texttt{connect slider.BoxChange viewer.BoxExecute} says the viewer it must re process itself any time the slider is modified.\\
1153 \texttt{exec viewer} processes the viewer.
1156 This would correspond to the graph in figure \ref{bbi-simplegraph}
1160 \caption{\label{bbi-simplegraph}(Very) simple Graph of a (very) simple pipeline}
1162 \includegraphics[width=0.8\textwidth]{bbi-simplegraph.png}
1166 Of course, to be able to connect two boxes,
1167 the output and the input must be compatibles.
1168 You can always connect an output to an input of the \emph{same} type,
1169 but you can do more, thanks to particular (hidden) black boxes called {\bf adaptors}.
1171 An adaptor is a black box which has at least one input, called \texttt{In},
1172 and at least one ouput called \texttt{Out} and whose role is to convert
1173 a data of the type of \texttt{In}
1174 into a data of the type of \texttt{Out} (other inputs or outputs may serve
1175 to parameter the adaptor or retreive other usefull information).
1177 Under \bbStudions, if you type :
1184 Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
1185 Basic useful black boxes
1188 BoolToString [DA] : Converts a Bool (bool) into a string
1189 CastBoolToChar [DA] : Static cast from Bool (bool) to Char (signed c...
1190 CastBoolToDouble [DA] : Static cast from Bool (bool) to Double (double...
1192 CastBoolToUChar [DA] : Static cast from Bool (bool) to UChar (unsigne...
1193 CastBoolToUInt [DA] : Static cast from Bool (bool) to UInt (unsigned...
1195 CastUIntToBool [DA] : Static cast from UInt (unsigned int) to Bool (...
1196 CastUIntToChar [DA] : Static cast from UInt (unsigned int) to Char (...
1197 CastUIntToDouble [DA] : Static cast from UInt (unsigned int) to Double...
1202 \texttt{[DA]} stands for \emph{default adaptor}.
1204 Once you have loaded the package \texttt{std}, you can
1205 plug an output of type \texttt{char} into an input of type \texttt{double}.
1206 When the interpreter encounters the \texttt{connect} command,
1207 it looks for an adequate \emph{adaptor} in the loaded packages.
1208 In our case, as the package \texttt{std} provides the
1209 \texttt{CastUCharToDouble} adaptor, the interpreter automatically creates an
1210 instance of this adaptor and place it \emph{between}
1211 the output and the input you want to connect
1212 (however this adaptor is hidden to you,
1213 it is embedded into the created connection and does not appear
1214 as an existing black box).
1215 When the pipeline is processed the
1216 adaptor converts the output data into the required input type,
1217 in a totally transparent way.
1218 In our example, the \texttt{CastUCharToDouble} adaptor
1219 would simply cast the value of the \texttt{char} into a \texttt{double},
1220 however arbitrarily complex type conversion may be done.
1223 Question (for info-dev):
1224 if two adaptors with the same input and output types exist
1225 in two different packages, currenly loaded,
1226 which one is chosen by the interpreter at connection time?
1227 A feature is missing to specify explicitely which one user wants to choose
1228 (use a namespace notation ?)
1230 -> Role of default adaptors
1233 Note that the \texttt{set} and \texttt{print} commands of interpreter
1234 work with adaptors from \texttt{string} to the type of the input to set
1235 or from the type of the output to print to \texttt{string}.
1236 Hence in order to \texttt{set} or \texttt{print} values the adequate
1237 adaptors must be available in the packages currently loaded. \\
1240 % ==========================================
1245 \item The \texttt{connect} command allows to connect two black boxes
1246 \item You can connect two black boxes if (and only if) :
1248 \item The output and the input are of the same type, or
1249 \item There is an adaptor black box in the packages loaded which
1250 converts data of the output type into data of the input type
1252 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use : \texttt{help <package name> all}.
1256 % ==========================================
1258 % ==========================================
1259 \subsubsection{Creating complex black boxes}
1260 \label{bbi-complex-black-boxes}
1261 % ==========================================
1263 Remember the pipeline of figure
1264 \ref{bbi-fig-connecting-black-boxes-1}, which
1265 computed the sum of three doubles?
1266 You can consider it as a whole and define
1267 a new black box type, which will be a \emph{complex black box},
1268 having three inputs and one output,
1269 as shown in figure \ref{bbi-fig-complex-black-box-1}.
1272 \caption{\label{bbi-fig-complex-black-box-1} Creating the complex black box \texttt{Add3}}
1274 \includegraphics[width=0.5\textwidth]{Add3.png}
1278 The \bbi commands to define this complex black box are
1288 > connect a.Out b.In1
1291 > description "adds 3 doubles"
1292 > input x a.In1 "first double to add"
1293 > input y a.In2 "second double to add"
1294 > input z b.In2 "third double to add"
1295 > output result b.Out "output"
1302 As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in first line.
1304 The command \texttt{define} then starts the definition
1305 of the complex box type, which will be called \texttt{Add3}.
1307 The next three lines define the pipeline,
1308 exactly in the same way than outside a complex box definition.
1310 The commands \texttt{author}, \texttt{description}, \texttt{input}
1311 and \texttt{output} are commands specific to complex boxes definition :
1313 \texttt{author} and \texttt{description} are used for the documentation
1314 of the new box. You can provide multiple \texttt{author} or
1315 \texttt{description} commands, the arguments of the commands will
1316 be concatenated to produce the final author and description strings.
1318 \texttt{input} and \texttt{output} are used to define the inputs and outputs
1319 of the new complex box.
1320 Their syntax is the same : for each new input/output you need to say
1321 to which internal input/output it corresponds and to provide
1322 a help string documenting the input/output.
1323 In our example, we define that the box \texttt{Add3} has
1324 three inputs : \texttt{x}, \texttt{y} and \texttt{z}.
1325 The input \texttt{x} corresponds to the input \texttt{In1} of the
1326 internal box \texttt{a}.
1327 In the same way, the external input \texttt{y}
1328 corresponds to the internal input \texttt{a.In2}, and
1329 the external input \texttt{In3} to \texttt{b.In2}.
1330 The only output of the new box is called \texttt{result}
1331 and corresponds to \texttt{b.Out}.
1332 The figure \ref{bbi-fig-complex-black-box-1}
1333 illustrates the external to internal
1334 input/output correspondence.
1336 Finally, the \texttt{endefine} command ends the definition of the
1339 After this definition, if you ask for help
1340 on packages, you get :
1351 The \texttt{user} package now contains a new black box type, called
1352 \texttt{Add3}. If you ask for help on this type of box, you get :
1355 Complex Black Box <user::Add3>
1359 'x' <double> : first double to add
1360 'y' <double> : second double to add
1361 'z' <double> : third double to add
1363 'result' <double> : output
1369 and you can use it like any other box, for example type :
1381 As a side note, we can say that, for consistency reasons, it would have been better to name
1382 \texttt{In1}, \texttt{In2} and \texttt{In3} the inputs of the black box \texttt{Add3},
1383 since all the 'natural entry' of a box is named \texttt{In}, or \texttt{In}\emph{x} if there are more than one 'natural
1386 % ==========================================
1391 \item The \texttt{define/endefine} commands allows to define complex black box types, i.e. types of black boxes made up of other black boxes.
1392 Inside a \texttt{define/endefine} block :
1394 \item The \texttt{author} and \texttt{description} commands allow to document the new type of box
1395 \item The \texttt{input} and \texttt{output} commands allow to define the inputs and outputs of the new type of box, that is to which inputs and outputs
1396 of internal boxes they correspond.
1400 % ==========================================
1402 % ==========================================
1403 \subsubsection{Writing scripts}
1404 \label{bbi-writing-scripts}
1405 % ==========================================
1407 Once you have defined a new type of complex box, you
1408 may like to reuse it. To do this, you can simply
1409 write the \bbi commands defining the new box
1410 into a text file and afterwards include that file in \bbi.
1411 Doing this, you start writing \bbi scripts.
1412 The conventionnal (and mandatory) extension for such scripts is \texttt{bbs}
1414 For consistency reasons, you are requested to prepend \texttt{bb} to the name.
1416 For example, the \texttt{Add3} complex box we previously worked on
1417 can be defined in the \texttt{bbAdd3.bbs} file :
1419 \begin{file}{bbAdd3.bbs}
1421 # Defines the Add3 black box which adds 3 doubles
1427 description "adds 3 doubles"
1433 input x a.In1 "first double to add
1434 input y a.In2 "second double to add
1435 input z b.In2 "third double to add"
1437 output result b.Out "output"
1442 Lines starting with a \texttt{\#} character or a \texttt{\//\//} character are ignored, they
1443 are considered as comments by the interpreter.
1444 To use this file in \bbStudions, click on the \texttt{include} button, and browse your filestore to find the file.
1447 > include bbAdd3.bbs
1449 Complex Black Box <user::Add3>
1453 'x' <double> : first double to add
1454 'y' <double> : second double to add
1455 'z' <double> : third double to add
1457 'result' <double> : output
1465 If the file has the \texttt{bbs} extension, you can ommit it and just type :
1470 \subsubsection{Creating complex black boxes that use complex black boxes}
1471 \label{bbi-complex-complex-black-boxes}
1474 Of course, you can include script files in other script files,
1475 like in the following example :
1477 \begin{file}{bbAdd4.bbs}
1479 # Defines the Add4 black box which adds 4 doubles
1484 description "adds 4 doubles"
1488 input In1 a.In1 "first double to add
1489 input In2 a.In2 "second double to add
1490 input In3 a.In3 "third double to add"
1491 input In4 b.In2 "fourth double to add"
1492 output Out b.Out "output"
1499 \subsubsection{Naming Conventions}
1500 \label{bbi-Naming Conventions}
1503 % ==========================================
1505 %\paragraph{Naming Conventions}
1509 % ==========================================
1513 For consistency reasons, you are requested to prepend \texttt{bb}, and postpone an extention \texttt{.bbs},
1514 to the names of the files that hold a \texttt{complex black box} definition.
1516 For example, the \texttt{Add3} complex box we previously worked on
1517 can be defined in the \texttt{bbAdd3.bbs} file.
1520 For consistency reasons, the names of dynamic libraries holding the packages must start by \texttt{libbb}.
1521 For instance, the package \texttt{wx} will be in the library \texttt{libbbwx.dll} (Windows) or \texttt{libbbwx.so}
1526 % ==========================================
1532 \item The \texttt{include} command tells the interpreter to include a script file.
1533 \item Lines starting with a \texttt{\#} or with a \texttt{\//\//} are considered as comments by the interpreter.
1534 \item Lines between a line starting with a \texttt{\//*} an a line starting with a \texttt{*\//} are considered as comments by the interpreter.
1538 % ==========================================
1540 % ==========================================
1541 \subsubsection{Creating command line applications}
1542 \label{bbi-command-line-app}
1543 % ==========================================
1545 Now that you know how to create complex black boxes
1546 (with \texttt{define/endefine}), think
1547 back to the \texttt{workspace} object.
1548 Remember that it is also
1549 a \texttt{complex black box}.
1550 Actually, when you type interpreter commands
1551 outside a \texttt{define/endefine} block,
1552 you progressively define the \texttt{workspace}
1554 You can think of it like if at start the interpreter
1555 was issuing a command \texttt{'define workspace'}
1556 and then letting you define the interior of the box
1559 Remember that the command \texttt{inputs}
1560 allows to define an input of a complex box.
1561 Now, if you use the command \texttt{input}
1562 outside a \texttt{define/endefine} block then
1563 it defines an input of the \texttt{workspace} box,
1564 that is an input of the \emph{main program}.
1565 This input will then be connected to the
1566 parameters that the user passes to the command line.
1568 For example, consider the script :
1570 \begin{file}{add.bbs}
1574 input x a.In1 "first number to add"
1575 input y a.In2 "second number to add"
1580 The third and fourth lines define two inputs \texttt{x}
1581 and \texttt{y}. When you execute this script,
1582 you can pass these two arguments on the command line,
1590 You can also invoke \bbi the option \texttt{-h},
1591 which gives help on the \texttt{workspace} box :
1598 'x' <double> : first number to add
1599 'y' <double> : second number to add
1602 To get a better help, use the \texttt{description}
1603 and \texttt{author} commands :
1605 \begin{file}{add.bbs}
1607 description "Adds two numbers"
1608 author "foo@bar.com"
1611 input x a.In1 "first number to add"
1612 input y a.In2 "second number to add"
1617 Now if you ask for help on the \texttt{add} script, you get :
1624 'x' <double> : first number to add
1625 'y' <double> : second number to add
1628 Rather than getting the inputs of a script
1629 from the command line, you can ask \bbi to
1630 prompt the user for the values, using the \texttt{-t}
1635 x=[the program waits for user answer]2
1636 y=[the program waits for user answer]5
1640 \bbStudio is always compiled in graphical mode (with \wx), therefore
1641 you can also use the \texttt{-g} commutator.
1642 \bbi then prompts the user in graphical mode,
1643 displaying a dialog box for each input,
1644 like in fig. \ref{bb-input-dialog-box}.
1647 \caption{\label{bb-input-dialog-box}Input dialog box}
1649 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1653 % ==========================================
1658 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1659 when they are used outside a \texttt{define/endefine} block allow
1660 to define the inputs, description and author of the main program.
1661 \item Inputs of the main program can be passed on the command line
1662 using the syntax \texttt{<input-name>=<value>}.
1663 No white space is allowed, if the value or the input name
1664 contains white spaces, enclose them
1665 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1666 \item The \texttt{-h} option of \bbi prints help on the main program.
1667 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1668 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1671 % ==========================================
1673 % ==========================================
1674 \subsubsection{Using graphical interface boxes (widget boxes)}
1676 % ==========================================
1678 % ==========================================
1679 \subsubsection{Overwiew}
1680 \label{bbi-overview}
1681 % ==========================================
1683 \bbStudio is always compiled in graphical mode
1684 (option \texttt{BUILD\_bbi\_GRAPHICAL} of \cmakens, requires \wxns),
1685 then you can use special black boxes which are
1686 graphical interface components (widgets).
1687 Basic components are provided in the package \texttt{wx},
1688 such as buttons, sliders, file open/save dialogs, etc.
1690 As first example, type the following commands in \bbi :
1697 When you type \texttt{enter} after the last line,
1698 a window pops up in which you can entrer a text.
1699 When you close the window, the text you entered is printed by
1700 the \texttt{print} command.
1702 Type \texttt{help wx}, you get something like :
1704 Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1705 Basic graphical interface elements (sliders, buttons ...) based on wxWidgets
1707 ColourSelector : Colour Selector dialog (bbfication of wxColourSele...
1708 ColourSelectorButton : A button which displays a colour picker dialog whe...
1709 CommandButton : Button which executes bbi commands
1710 DirectorySelector : Pops up a directory selection dialog (wxDirDialog)
1711 FileSelector : Pops up a file selection dialog for reading or sav...
1712 InputText : A zone in which the user can enter a text (wxTextC...
1713 LayoutLine : LayoutLine widget (wxBoxSizer)
1714 LayoutSplit : Widget which splits a window in two fixed size par...
1715 LayoutTab : LayoutTab widget (wxNotebook)
1716 OutputText : Text zone to be inserted into a window (wxStaticTe...
1717 RadioButton : RadioButton group widget 0-9 entries
1718 Slider : Slider widget (wxSlider)
1721 You can reproduce the same experiment as above using a
1722 \texttt{Slider} or a \texttt{FileDialog} rather than a \texttt{InputText}.
1723 See the files \texttt{test*.bbs} in the \texttt{scripts/test} directory.
1725 There are two kinds of widgets : ``terminal'' widgets and ``container'' widgets.
1726 The \texttt{InputText}, \texttt{FileDialog} or \texttt{Slider} widgets
1727 are ``terminal'' widgets.
1728 ``container'' widgets are of another kind : they are designed to
1729 contain other widgets in order to build larger dialog boxes.
1730 For example, the \texttt{LayoutSplit} widget is a container which
1731 ``splits'' horizontally a window into two parts,
1732 each part including another widget.
1733 The size of the two parts can be adjusted by the user thanks
1736 The script \texttt{scripts/test/testSplit.bbs} demonstrate its use.
1737 Run it : it displays a window with two sliders.
1738 Move the sliders and close the window.
1739 The final positions of the sliders are printed out.
1740 Now edit the file to see how this is done :
1742 \begin{file}{scripts/test/testSplit.bbs}
1751 connect s1.Widget s.Widget1
1752 connect s2.Widget s.Widget2
1754 print s1=$s1.Out$\\n
1755 print s2=$s2.Out$\\n
1759 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1760 A \texttt{LayoutSplit} box \texttt{s} is also created.
1761 The \texttt{connect} commands then ``includes'' the sliders in the
1762 split ``container''.
1763 The input \texttt{Widget} is common to all widget boxes :
1764 every widget can be inserted into another widget.
1765 The outputs \texttt{Widget1},\texttt{Widget2} are specific of \emph{container}
1767 (in \bbi type \texttt{help Slider} :
1768 you will see the output \texttt{Widget};
1769 type \texttt{help LayoutSplit} :
1770 you will see the inputs \texttt{Widget1} and \texttt{Widget2}
1771 and the output \texttt{Widget}).
1772 When you connect the \texttt{Widget} output of a container
1773 to the \texttt{Widget}i input of a widget,
1774 you order to include the widget in the container.
1775 Of course, the order of connection is important.
1776 In our case, the slider \texttt{s1} is included first,
1777 then the slider \texttt{s2} : \texttt{s1} will be placed
1778 on top of \texttt{s2} (the \texttt{LayoutSplit} box is
1779 implemented that way, but this is arbitrary choice).
1781 Right now, there are only \emph{three} container widgets in the \texttt{wx} package :
1783 \item {the \texttt{LayoutSplit} widget} we just described, the \texttt{LayoutLine} , and the \texttt{LayoutTab}
1786 \item {the \texttt{LayoutLine} widget} can have multiple children and
1787 divides its window into as much parts as children,
1788 each part of equal size.
1789 The orientation of the \texttt{LayoutSplit} or of the \texttt{LayoutLine} can be changed by the input \texttt{Orientation}.
1790 See the example \texttt{test/testSizer.bbs}.
1791 With only those two containers you can already create
1792 complex dialog boxes (of course containers can be nested, which leads to tree-like structures of widgets).
1793 See the script \texttt{bbtk/share/bbtk/bbs/wx/appli/ExampleLayoutSplit.bbs} for an example.
1795 \item {The \texttt{LayoutTab} widget} is based on the \texttt{wxNotebook.}\\
1796 The label of each 'note book' is the name of the object it contains.
1803 One word about a special widget in the package \texttt{wx} :
1804 the \texttt{Button}... to be continued.
1806 % ==========================================
1807 \subsubsection{Deeper in the boxes}
1808 \label{bbi-deep-box}
1809 % ==========================================
1811 Any widget box has two mandatory Inputs :
1813 \item {\bf\emph{BoxExecute}} : Any signal received by this input executes the box
1814 \item {\bf\emph{BoxProcessMode}} : Sets the processing mode of the box :
1816 \item {\bf\emph{Pipeline}} : bbBackwardUpdate() calls Process() only if Status == MODIFIED \\
1817 The box executes itself only when an entry was changed (normal pipeline processing).
1818 \item {\bf\emph{Reactive}} : bbSetModifiedStatus() calls bbUpdate() \\
1819 Warning : Re-processed immediately when \emph{any entry} changed.\\
1820 To be more selective, better use \texttt{connect A.BoxChange \emph{currentBox}.BoxExecute}.
1821 \item {\bf\emph{Always}} : bbUpdate() always calls Process. \\
1822 Usefull for 'sources', that must be processed, even when no entry changed (e.g. : FileSelector, ColorSelector)\\
1823 This one is not end user intended (for Package developer only)
1827 Any widget box has five Inputs, that will be dealt with only if the box is not connected to the \emph{Widget}i of any \emph{Layout box} :
1829 \item {\bf\emph{WinHeight}} : Height of the window
1830 \item {\bf\emph{WinWidth}} : Width of the window
1831 \item {\bf\emph{WinTitle}} : Title of the window
1832 \item {\bf\emph{WinClose}} : Any received signal closes the window
1833 \item {\bf\emph{WinHide}} : Any received signal hides the window
1834 \item {\bf\emph{WinDialog}} : When set to 'true', creates a \emph{dialog window}, that blocks the pipeline until it is closed (\emph{modal})
1838 Any \emph{Layout box} (i.e. \emph{LayoutLine}, \emph{LayoutSplit} or \emph{LayoutTab}) has at one or more mandatory Inputs :
1840 \item {\bf\emph{Widget}}\texttt{i} : e.g. a \emph{LayoutSplit} box (Widget which splits a window in two resizeable parts)
1841 has two Input parameters \emph{Widget1} and \emph{Widget2}, used to embed the child windows.\\
1842 e.g. a \emph{LayoutLine} divides the window in up to 9 (depending on the number of inputs \emph{Widget}i) fixed size parts.
1846 Any widget box has two mandatory Outputs :
1849 \item {\bf\emph{Widget}} : that is the \texttt{wxWindow} itself. If it's not connected to the \texttt{Widget}\emph{i} of any \emph{Layout box}, it
1850 will popup. If it's connected to the \texttt{Widget}\texttt{\emph{i}} of any \texttt{Layout box}, it will be embedded in its parent window.
1851 \item {\bf\emph{Boxchange}} : Signals any modification of the box. This output may be connect if necessary to the \emph{BoxExecute} entry of an other box,
1852 further within the execution pipeline.
1857 % ==========================================
1858 \subsection{More on ...}
1860 % ==========================================
1862 % ==========================================
1863 \subsubsection{Black box packages}
1864 \label{bbi-more-on-packages}
1865 % ==========================================
1866 There are various others user-intended packages :
1869 ---> Were moved in a 'Reference Manual' ?\\
1870 ---> Any suggestion welcome!
1878 % ==========================================
1879 \subsubsection{Pipeline processing}
1880 \label{bbi-more-on-pipeline-processing}
1881 % ==========================================
1883 \item the ``control'' mechanism in bbi.
1885 When a box is requested to update itself, it asks (recursively) each one of its inputs if it was modified.\\
1886 In normal pipe-line mode, it will be re-processed if at least one of its imputs was actually modified, as the output of a previous box.
1888 (switch exec commands, e.g. Button)
1889 \item the role of ProcessMode to update widgets.
1891 % ==========================================
1892 \subsubsection{Complex black boxes}
1893 \label{bbi-more-on-complex-black-boxes}
1894 Creation of complex widgets (containers, contained...)
1896 You can include script files in other script files,
1897 like in the following example :
1901 # Defines the Add4 black box which adds 4 doubles
1905 description "adds 4 doubles"
1909 input In1 a.In1 "first double to add"
1910 input In2 a.In2 "second double to add"
1911 input In3 a.In3 "third double to add"
1912 input In4 b.In2 "fourth double to add"
1913 output Out b.Out "output"
1917 The inner boxes have they own entries (In1, In2, In3 for box a, In1, In2 for box b )\\
1918 Only the inputs In1, In2, In3 of box a and the input In2 of box b is of interest for the end user, but he dosn't want to have to
1919 care neither about the inner boxes name, nor about the names of their Inputs.\\
1920 The writer of the complex box has the ability to give these inputs a meaningfull name !
1922 input In3 a.In3 "third double to add"
1923 input In4 b.In2 "fourth double to add"
1926 %\subsubsection{Advanced issues}
1927 %\paragraph{Reducing the number of inputs of a box}
1929 % ==========================================
1930 \subsubsection{Errors}
1931 \label{bbi-more-on-errors}
1933 % ==========================================
1934 \subsubsection{Creating and using your own uninstalled version of bbStudio}
1935 \label{bbi-more-on-your_own_version}
1937 Suppose you want to run your own uninstalled version (say : you downloaded and compiled the
1938 cvs version in order to use a recently commited patch, but you want to be able
1939 to still use the standard version).
1943 \item cvs checkout the sources :
1948 create a build directory
1952 \item cd in the build directory:
1961 Don't forget to switch ON the flag \textttBBTK\_COMPILE\_DEBUG\_MESSAGE \\
1962 (see figure : \ref{bb-ccmake})
1965 \caption{\label{bb-ccmake}\Running ccmake}
1967 \includegraphics[width=0.6\textwidth]{ccmake.png}
1971 \item As usual, type \texttt{c} untill there is no longer any area quoted with a * (or enlighted in red)\\
1972 Ask for generation (type \texttt{g} -once is always enough-)
1974 \item Ask for compilation and link.
1978 For some strange reasons (?!?), you may be warned that an error occured while documentation generation.\\
1979 Take it easy, \texttt{make} again!\\
1981 The dynamic libraries (\texttt{.dll} or \texttt{.so} and the executable programs will be created in the \testtt{bin}
1982 directory of the built tree.
1984 \item choose to install or not your own version.
1988 Linux users : Don't forget to \texttt{sudo} before.
1990 % ==========================================
1991 \subsubsection{\bbtk configuration file and search pathes}
1992 \label{bbi-more-on-configuration}
1994 At start, \bbi tries to open an \texttt{xml}
1995 configuration file named \texttt{bbtk\_config.xml}.
1998 \item The current directory
1999 \item The subdir \texttt{.bbtk} of the user's home directory.
2001 \item On \texttt{Unix}, the home directory is the
2002 one stored by the environnement variable \texttt{HOME},
2003 typically \texttt{/home/username}.
2004 \item On \texttt{Windows}, the home directory is
2005 the user's profile directory stored by the environnement
2006 variable \texttt{USERPROFILE},
2007 typically \texttt{C:\\...}.
2009 \item If none of these two pathes contains the file then it creates
2010 a new one in the \texttt{.bbtk} directory.
2013 Once created, you can edit the \texttt{bbtk\_config.xml} file located
2014 in your \texttt{.bbtk} directory. It contains :
2016 \begin{file}{bbtk\_config.xml}
2018 <?xml version="1.0" encoding="iso-8859-1"?>
2020 <description> </description>
2021 <bbs_path> </bbs_path>
2025 <data_path> </data_path>
2026 <default_temp_dir>$</default_temp_dir>
2031 You can add pathes to
2033 \item A custom folder in which to search for \texttt{.bbs} scripts (\texttt{include} command of \bbi) by adding an \texttt{xml} tag :
2034 \texttt{<bbs\_path>complete\_path\_to\_folder<\/bbs\_path>}.
2035 \item A custom folder in which to search for packages (\texttt{load} command of \bbi) by adding an \texttt{xml} tag :
2036 \texttt{<package\_path>complete\_path\_to\_folder<\/package\_path>}.
2042 % ==========================================
2043 \subsection{Language reference}
2044 \label{bbi-reference}
2045 % ==========================================
2048 % ==========================================
2049 \subsubsection{pipeline creation and execution related commands}
2050 \label{bbi-reference-creation-execution}
2051 % ==========================================
2054 % ==========================================
2056 \caption{\label{bbi-reference-box} \bbi pipeline creation and execution related commands.}
2058 \begin{tabular}{|lcm{6cm}|}
2060 Command & Parameters & Effect \\ \hline
2062 \texttt{new} & \texttt{<boxtype>} \texttt{<box-name>}&
2063 Creates a box of type \texttt{boxtype} and name
2064 \texttt{box-name}.\\ \hline
2066 \texttt{delete} & \texttt{<box-name>} &
2067 Destroys the box named \texttt{box-name}.\\ \hline
2069 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} &
2071 \texttt{output} of the box named \texttt{box1}
2072 to the input \texttt{input} of the box named \texttt{box2} \\ \hline
2074 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
2075 Sets the input \texttt{input} of
2076 the box named \texttt{box} to the value \texttt{value}.
2077 There must exist an \texttt{adaptor}
2078 in the packages loaded which converts a \texttt{std::string}
2079 to the type of the input \texttt{input}. \\ \hline
2081 \texttt{print} & \texttt{<string>} &
2082 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the
2083 output \texttt{output} of the box named \texttt{box}.
2084 There must exist an \texttt{adaptor}
2085 in the packages loaded which converts
2086 the type of the output \texttt{output}
2087 to a \texttt{std::string}.
2090 \texttt{exec} & \texttt{<box-name>} &
2091 Executes the box named \texttt{box-name}.
2093 connected to its inputs
2094 are also processed recursively (pipeline processing).\\ \hline
2095 \texttt{exec} & \texttt{freeze} &
2096 allows to block execution commands while keeping definition commands active.\\ \hline
2097 \texttt{exec} & \texttt{unfreeze} &
2098 turns back to 'normal' mode.\\ \hline
2101 % ==========================================
2105 % ==========================================
2106 \subsubsection{Interpreter related commands}
2107 \label{bbi-reference-interpreter}
2108 % ==========================================
2110 % ==========================================
2112 \caption{\label{bbi-reference-interpreter}\bbi intepreter related commands.}
2114 \begin{tabular}{|lcm{6cm}|}
2116 Command & Parameters & Effect \\ \hline
2118 \texttt{author} & - &
2119 Adds the string <string> to the author information of the black box being defined \\ \hline
2121 \texttt{category} & - &
2122 Adds the string <string> to the category information of the black box being defined \\ \hline
2125 Prints help on available commands \\ \hline
2127 & \texttt{<command-name>} &
2128 Prints help on the command \texttt{command-name} \\ \hline
2130 & \texttt{packages} &
2131 Prints help on available packages and their box types
2132 (without description)\\ \hline
2134 & \texttt{<package-name>} &
2135 Prints help on the package \texttt{package-name} and its boxes
2136 (with brief description).
2137 The package must have been previously loaded \\ \hline
2139 & \texttt{<box-type>} &
2140 Prints help (with full description) on the type of box
2142 The box type must belong to a package which has been previously loaded \\ \hline
2144 \texttt{include} & \texttt{<file-name>} &
2145 Includes and executes the content of the file named \texttt{file-name}
2146 exactly like if you were typing its content at the place were the
2147 \texttt{include} command is. \\ \hline
2149 \texttt{load} & \texttt{<package-name>} &
2150 Loads the package \texttt{package-name}\\ \hline
2152 \texttt{include} & \texttt{<package-name>} &
2153 Loads the package \texttt{package-name} and includes all the complex black boxes that comes with it \\ \hline
2155 \texttt{kind} & \texttt{<box kind>} &
2156 Specifies the \texttt{kind} of the complex black boxes you are describing \\ \hline
2158 \texttt{unload} & \texttt{<package-name>}&
2159 Unloads the package \texttt{package-name}.
2160 The package must have been previously loaded.
2161 No box of a type defined in this package must still exist.\\ \hline
2163 \texttt{message} & \texttt{<category>} \texttt{<level>} &
2164 Sets the level of verbosity of \bbi for the category of messages
2165 \texttt{category} to \texttt{level}.\\ \hline
2166 %See \ref{verbosity}.
2168 \texttt{config} & - & Displays the Configuration parameters\\ \hline
2170 \texttt{reset} & - & Deletes all boxes and unloads all packages so
2171 that \bbi gets back to its initial state \\ \hline
2173 \texttt{quit} & - & Exits the interpreter\\ \hline
2177 % ==========================================
2181 % ==========================================
2182 \subsubsection{complex black box definition related commands}
2183 \label{bbi-reference-black-box-definition}
2184 % ==========================================
2186 % ==========================================
2188 \caption{\label{bbi-reference-complex-box} \bbi complex black box definition related commands.}
2190 \begin{tabular}{|lcm{6cm}|}
2192 Command & Parameters & Effect \\ \hline
2195 \texttt{define} & \texttt{<box-type>} &
2196 Starts the definition of a complex black box of type
2197 \texttt{box-type}\\ \hline
2199 \texttt{endefine} & - &
2200 Ends the definition of a complex black box type\\ \hline
2202 \texttt{author} & \texttt{<string>} &
2203 Sets the author(s) of the complex black box currently being defined \\ \hline
2205 \texttt{description} & \texttt{<string>} &
2206 Sets the description of the complex black box currently being defined \\ \hline
2208 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} &
2209 Defines a new input for the current complex black box,
2210 named \texttt{name}.
2211 It is defined as corresponding to
2212 the input \texttt{input} of the box \texttt{box}.
2214 \texttt{<help>} is the help string for the new input.
2215 The box \texttt{box} must already have been created in the complex box
2216 and of course have an input named \texttt{input}.\\ \hline
2218 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} &
2219 Defines a new output for the current complex black box,
2220 named \texttt{name}.
2221 It is defined as corresponding to
2222 the output \texttt{output} of the box \texttt{box}.
2223 \texttt{<help>} is the help string for the new output.
2224 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. \\ \hline
2229 % ==========================================
2233 % ==========================================
2234 \vspace{0.5cm}\hrule \\
2235 \section{The Package Browser}
2236 \label{Package_Browser}
2237 % ==========================================
2240 You can run it using the tool bar of the 'Command' part.
2242 See figure \ref{Package_Browser}.
2245 \caption{\label{Package_Browser}The Package Browser}
2247 \includegraphics[width=0.6\textwidth]{Package_Browser.png}
2251 It allows you to query informations about what you can find in the packages (boxes and applications), using several criterions
2252 (warning : it's case sensitive)
2255 All the boxes and applications held in a given package (e.g. \texttt{wxvtk}, \texttt{std}, ...)
2257 You can query on a subpart of the name of a box or an application (e.g. \texttt{DICOM})
2259 You can query on a substring of the description of a box or an application (e.g. \texttt{DICOM})
2261 You can query on a sub part of the category name of a box or an application (e.g. \texttt{3D})
2263 You can query all the boxes or applications that have at least one Input entry of the given type (e.g. \texttt{int})
2265 You can query all the boxes or applications that have at least one Output entry of the given type (e.g. \texttt{int})
2267 You can query all the boxes or applications that have at least one Input entry of the given nature (e.g. \texttt{signal})
2269 You can query all the boxes or applications that have at least one Output entry of the given nature (e.g.
2270 \texttt{signal},\texttt{file name})
2274 All these criterions are \emph{Added} while the query process.\\
2275 You can get the whole description of a given box or application clicking on its name.
2278 % ==========================================
2279 \vspace{0.5cm}\hrule \\
2280 \section{Using third party Package}
2281 \label{Third_Party_Package}
2282 % ==========================================
2284 You will have to update the \emph{bbtk\_config.xml} file.\\
2285 To know where it is stored, just click on \texttt{Config} button of the Command part tool bar.
2287 You'll get something like :
2293 bbtk_config.xml : [/home/jpr/Creatis/bbtk/binLIN/bin/bbtk_config.xml]
2294 Documentation Path : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/doc]
2295 Data Path : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/data]
2296 Temp Directory : [/home/jpr/Creatis/bbtk/binLIN]
2297 File Separator : [/]
2300 --- [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/bbs]
2301 --- [/home/jpr/Creatis/bbtk/binLIN/share/bbtk/bbs]
2304 --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2305 --- [/home/jpr/Creatis/bbtk/binLIN/bin/../lib]
2306 --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2307 --- [/home/jpr/Creatis/bbtk/binLIN/bin\Debug]
2308 --- [/home/jpr/Creatis/bbtk/binLIN/bin\Release]
2311 (depending on whom you are, and whether \texttt{bbStudio} is installed or not.)\\
2313 Just use your favourite text editor to add :
2316 at the end of the \texttt{BBS Paths} part
2317 the name of the directory that contains the \texttt{.bbs} sripts of the package you
2319 \item at the end of the \texttt{PACKAGE Paths} part
2320 the name of the directory that contains the dynamic libraries (\texttt{.dll} or \texttt{.so}) of the package you
2323 % ==========================================
2324 \vspace{0.5cm}\hrule \\
2325 \section{Using black boxes in \CPP programs}
2327 % ==========================================
2329 A very usefull feature is that you may use any black box within a \CPP program witout worrying about wxWigets main window.\\
2331 Let's look a the following bbs script :
2338 # Create the Objects
2341 new LayoutLine layout
2343 # Graphical pipeline
2344 connect slider.Widget layout.Widget1
2345 connect text.Widget layout.Widget2
2347 # Execution pipeline
2348 connect slider.BoxChange text.BoxExecute
2349 connect slider.Out text.In
2355 User wants to create a slider and an output text, within a layoutline, and display the slider value in the output text.\\
2356 Think about the (little!) nightmare to code the same, in 'raw C++', using wxWidgets.\\
2358 Using \bbtk you just 'convert' the script :
2361 #include <bbwxSlider.h>
2362 #include <bbwxOutputText.h>
2363 #include <bbtkFactory.h>
2364 #include <bbwxLayoutLine.h>
2366 int main(int argv, char* argc[])
2368 // we need to intanciate a bbtk::Factory to be aware of the adaptors
2369 bbtk::Factory::Pointer factory = bbtk::Factory::New();
2371 // Load the packages
2373 factory->LoadPackage("std");
2374 factory->LoadPackage("wx");
2376 // Create the Objects
2377 // ------------------
2378 bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
2379 bbwx::OutputText::Pointer text = bbwx::OutputText::New("text");
2380 bbwx::LayoutLine::Pointer layout = bbwx::LayoutLine::New("layout");
2382 // Graphical pipeline
2383 bbtk::Connection::Pointer c1 = bbtk::Connection::New(slider,"Widget",
2386 bbtk::Connection::Pointer c2 = bbtk::Connection::New(text,"Widget",
2389 // Execution pipeline
2390 // ------------------
2392 // We have to pass the 'factory', in order to call automatically an adaptor, if necessary.
2393 bbtk::Connection::Pointer s2t = bbtk::Connection::New(slider,"Out",
2396 bbtk::Connection::Pointer c3 = bbtk::Connection::New(slider,"BoxChange",
2398 layout->bbSetInputWinDialog(true);
2402 layout->bbExecute();
2405 catch (bbtk::Exception e)
2407 bbtk::MessageManager::SetMessageLevel("Error",1);
2417 %\section{Conclusion}