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 :
118 which depend on the OpenSource libraries:
125 % ==========================================
126 \subsection{The black box philosophy}
127 % ==========================================
129 \href{http://www.answers.com/topic/black-box-theater}{The Answers Dictionary} defines a {\bf black box} as
130 \emph{``A device or theoretical construct with known or specified performance characteristics
131 but unknown or unspecified constituents and means of operation''} \\
132 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
133 defines a {\bf black box} as
134 \emph{``any component in a system in which only the input and output
135 characteristics are of interest, without regard to its internal mechanism
137 We should merge theese definitions. :
138 not only the inputs and outputs are of interest but also
139 \emph{what the box does} !
140 Hence, I would say that a black box is any \emph{\bf documented}
141 component of a system, letting the user know
142 \emph{\bf what} the box is supposed to do and
143 \emph{\bf how to use it}
144 but not \emph{\bf how it does it}. \\
146 \BBTK provides a systematic framework
147 to encapsulate (or ``wrap'') any
148 existing \texttt{C} or \CPP processing code into an object
149 (a black box) having a {\bf generic symbolic interface}, where
152 \item{\bf generic} means that the interface is \emph{the same}
153 for all boxes. Hence one does not need to know which particular
154 method allows, say, to set a particular input or
155 get a particular output of the box.
156 One can use a black box in a purely abstract way.
157 \item{\bf symbolic} means that a particular
158 input or output is referenced by a 'name', that is by a symbol
159 which identifies the input or output.
160 It also means that symbolic information (text!) is
161 attached to a box: description of the box, author,
162 description of its inputs and outputs, etc.
165 (Actually, genericity is achieved because the interface is symbolic.
166 We let you think about this\dots)
168 Of course, symbolic data attached to a box may be
169 {\bf queried} : what are the inputs/outputs of the box ?
170 what are their type ? their description ? etc.
171 This allows {\bf automatic documentation} of boxes.
173 The abstract definition of black boxes is the most basic
174 aspect of \BBTK architecture.
175 Another key aspect is the groupement of black boxes into
176 so called {\bf packages},
177 which are \emph{dynamic libraries} which can also
178 be queried, in particular about the boxes they provide.
179 The package structure then offers a mechanism which
180 is like a \emph{'plug-in'} mechanism.
181 \BBTK provides the methods to load a package at run-time,
182 and create instances of the boxes it contains.
184 These two mechanisms (black boxes and packages)
185 then gives the way to:
188 \item The definition of an {\bf interpreted script language},
189 which allows to manipulate packages and boxes very easily in symbolic way.
190 \BBTK provides one : \bbi (the Black Box Interpreter).
191 \item {\bf Automatic documentation} of existing packages.
192 \texttt{html} documentation of packages is proposed by
196 Finally, these different components allow {\bf efficient} :
199 \item {\bf capitalization and reuse} of existing processing units,
200 including {\bf documentation}
201 \item {\bf testing, prototyping} in a very simple script language
202 \item {\bf inter-operability} between atomic processings which
203 have been written by different persons, using different libraries, etc.
206 % ==========================================
207 \subsection{\bbtk components}
208 % ==========================================
211 \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework
212 (abstract classes) to develop black boxes and store them into
213 dynamic libraries, called black box \emph{packages}.
214 \item Different {\bf\emph{black box packages}} :
216 \item {\bf\emph{std}} : the 'standard' package including basic useful boxes.
217 \item {\bf\emph{wx}} : basic graphical interface elements (widgets : sliders, buttons, etc. based on the \texttt{wxWidgets} library).
218 \item {\bf\emph{itk}} : the basic image processing package, based on the \itk library.
219 \item {\bf\emph{vtk}} : the basic images and surfaces processing and vizualization package, based on the \vtk library.
220 \item {\bf\emph{wxvtk}} : widget boxes based on the \vtk library (2D and 3D vizualization and
222 \item {\bf\emph{itkvtk}} : special boxes (adaptors) to convert \itk structures into \vtk structures and conversally.
223 %\item {\bf\emph{creaImageIO}} : Provides hight level widgets to read images, including DICOM.
224 \item {\bf\emph{toolsbbtk}} : Tools for bbtk administration and package development..
226 \item A {\bf\emph{Developement environment}}, called \bbStudio, which provides
228 \item An online {\bf\emph{script editor and interpretor}}
229 \item A powerfull html {\bf\emph{Help environment}},whith integrated :
231 \item Online documentation scaning
232 \item Retreiving boxes on various criterions
233 \item Checking Demo and examples
236 \item An standalone {\bf\emph{interpreter}}, called \bbins, which allows to
237 load black box packages and to define and execute
238 processing chains by connecting various black boxes.
239 \item {\bf\emph{Various Development Utilities}} :
241 \item \bbfy generates the \CPP code of a black box from a
242 description file written in \texttt{xml}.
243 %\item \bbdoc generates the html documentation of a black box package
244 %(author, description, description of its black boxes :
245 %author, description, inputs, outputs, and so on).
246 \item \bbCreatePackage allows to create the basic file architecture
247 to start the development of a new black box package.
248 \item \texttt{bbs2cpp} translates a \texttt{.bbs} script into a \CPP file.
249 \item \texttt{bbc} that
251 \item A full {\bf\emph{documentation}} printable (pdf), browsable (html), queryable thru keywords.
253 The general architecture of \BBTK
254 is shown in figure \ref{bb-architecture}.
257 \caption{\label{bb-architecture}\BBTK architecture}
259 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
265 % ==========================================
266 \section{Getting started with bbStudio}
267 % ==========================================
269 % ==========================================
270 % ==========================================
271 % ==========================================
272 % ==========================================
273 % ==========================================
274 % ==========================================
276 % ==========================================
277 \subsection{The interface}
278 % ==========================================
281 %\vspace{0.5cm}\hrule
282 %\section{The Development environment (bbStudio)}
285 Just run it, typing in a console \bbStudio
286 or clicking on its icon or its menu entry.
287 At start, \bbStudio opens with a very minimal 'How to use' in the middle. \\
288 Don't forget to read it : it will vanish at the first mouse click. \\
290 1) Click on the 'Demo' or 'Examples' link.
291 2) Select a Demo or an Example
292 3) Click on the [Source] link : the source file is loaded in bbStudio
293 4) Click on the 'Run button' (the down arrow at the bottom right
297 You'll get something like in figure
298 \ref{bbi-fig-bbStudio-gui-start}
299 (the exact appearance of \bbStudio is Operating System and \bbtk version dependent)
305 \caption{\label{bbi-fig-bbStudio-gui-start}The bbStudio Development environment interface at start time}
307 \includegraphics[width=0.7\textwidth]{bbStudioMainPageStart.png}
312 Feel free to resize any part you want.
313 Your preferences will be kept next time you run again \bbStudio. \\
315 Let's have a look at the resized window :
318 \caption{\label{bbi-fig-bbStudio-gui}The bbStudio Development environment interface}
320 \includegraphics[width=0.7\textwidth]{bbStudioMainPage.png}
324 You can see four parts : \texttt{Files}, \texttt{Messages},
325 \texttt{Command}, \texttt{Help}.\\
327 The stuff is written using the Advanced User Interface library of wxWidgets,
328 whose 'docking manager' allows windows and toolbars to be floated/docked
330 Please don't use this feature at learning time (the snapshots of this document
331 wouldn't match with your screen ...)
333 \subsubsection{'Files' part}
334 \label{bbi-FilesPart}
336 It's the .bbs script editor.\\
337 If you load a file holding a script, it will be displayed here, and you'll be
338 able to modify it, to save it, to save-as it, to run it, using the
339 lower toolbar (see figure : \ref{lowertoolbar})
342 \caption{\label{lowertoolbar}The lower tool bar}
344 \includegraphics[width=0.7\textwidth]{lowertoolbar.png}
350 \item {\bf\emph{New file}} : Create a new file to hold a script
351 \item {\bf\emph{Open file}} : Open an already existing file holding a script
352 \item {\bf\emph{Close file}} : Close a file holding a script
353 \item {\bf\emph{Save file}} : Save he current file (if modified)
354 \item {\bf\emph{Save file as}} : Save he current file under a different name
355 \item {\bf\emph{Run file}} : Execute the script you just loaded/modified/written
356 \item {\bf\emph{cursor position}} : column number : line number
360 \subsubsection{'Messages' part}
361 \label{bbi-MessagesPart}
363 Two kinds of messages will be output here:\\
364 System messages : produced by the kernel, in case of a user mistyping, or an execution error\\
365 Script messages : produced by the \bbtk equivalent of \texttt{printf}
366 or \texttt{std::cout} in user programs
368 \subsubsection{'Command' part}
369 \label{bbi-CommandPart}
371 This is where user will type his requirements.
373 \subsubsection{'Help Contents' part}
374 \label{bbi-HelpContentsPart}
376 The 'Help Contents' part of \bbStudio is used to browse the html help of \BBTK.
377 All the entries of the starting page are self-explanatory :
379 \item {\bf\emph{Help Contents}}
381 %\item {\bf\emph{Wiki}} : Direct link to the bbtk Wiki (intranet only, right now, www
383 \item {\bf\emph{Demo}} : Link to some 'sophisticated' demonstrations.
384 \item {\bf\emph{Examples}} : Link to some detailed 'How to use' examples
387 \item {\bf\emph{Guides}}
389 \item {\bf\emph{User's Guide}} : Step to step How-to for user who wants to create his own
390 application, just using already existing boxes.
391 \item {\bf\emph{Package Developper's Guide}} : Step to step How-to for user who wants to create his own
393 \item {\bf\emph{Developper's Guide}} : For bbtk kernel developpers. Sorry, not yet written.
394 \item {\bf\emph{Reference Manual}} : Sorry, not yet written.
395 \item {\bf\emph{Booklet}} : Vade mecum. Sorry, not yet written.
396 \item {\bf\emph{Doxygen Documentation}} : Doxygen source browser.
399 \item {\bf\emph{Boxes}} : Box retrieving on various criterions :
401 \item {\bf\emph{ \texttt{By name}}} (Alphabetical list),
402 \item {\bf\emph{ \texttt{{By package}}},
403 \item {\bf\emph{ \texttt{{By category}}}.
406 A special hidden Box category, called \texttt{{Adaptors}} exists. \\
407 They are used internaly to perform type conversions. Thought there are not end user intended, an aware user may query them.
413 % ==========================================
418 % ==========================================
419 % ==========================================
420 % ==========================================
421 % ==========================================
422 % ==========================================
427 % ==========================================
431 % ==============================================
432 \subsection{Running Demo and Examples}
433 % ==============================================
435 Run \bbStudio the way you need. \\
436 In the part 'Help contents' (See figure \ref{HelpContents}), select \texttt{Examples} link.
439 \caption{\label{HelpContents}Help Contents}
441 \includegraphics[width=0.7\textwidth]{HelpContents.png}
447 You will be asked to select a Box category (See figure \ref{BoxCategories}); \\
448 Select \texttt{example}.
452 \caption{\label{BoxCategories}Box Categories}
454 \includegraphics[width=0.7\textwidth]{BoxCategories.png}
458 You will be asked to choose a script (See figure \ref{example}).
461 \caption{\label{example}example list}
463 \includegraphics[width=0.7\textwidth]{example.png}
469 Select \texttt{wx::exampleSlider} (See figure \ref{exampleSlider});
472 \caption{\label{exampleSlider}example 'exampleSlider'}
474 \includegraphics[width=0.7\textwidth]{exampleSlider.png}
478 You can see the graphical summary representation of the current script (the elementary boxes that compose it, and their
480 Click on \texttt{source}, and you'll be able to see the (very simple) script,
481 in the 'Files' part, within the script editor (See figure \ref{exampleSliderSource});
484 \caption{\label{exampleSliderSource}source code of 'exampleSlider'}
486 \includegraphics[width=0.7\textwidth]{exampleSliderSource.png}
490 Run it, using the lower toolbar (see figure : \ref{lowertoolbar})
492 You'll get something like in figure \ref{execSliderSource}.
495 \caption{\label{execSliderSource}execution of 'exampleSlider'}
497 \includegraphics[width=0.7\textwidth]{execSliderSource.png}
501 Feel free to move the slider, to check it actually works...
505 Just a few words on what you saw :
507 \item{in the File part} \\
508 The source code of the script
511 set slider.ReactiveOnTrack 1
513 We create a \texttt{Slider} called \emph{slider}\\
514 We tell it to inform anybody that's interested in, that the cursor moved, each time it moved. \\
515 The standard behaviour is to inform, only when cursor is released.
519 We create a \texttt{OutputText} called \emph{text}
520 (in which slider value will be displayed)
523 new LayoutLine layout
525 We create a \texttt{LayoutLine} called \emph{layout},
526 a \emph{container} widget, designed to embed other wigets (say, a main window)
528 connect slider.Widget layout.Widget1
529 connect text.Widget layout.Widget2
531 We embed \emph{slider} and \emph{text} into \emph{layout}.
533 connect slider.BoxChange text.BoxExecute
534 connect slider.Out text.In
536 We tell \emph{slider} to inform \emph{text} every time it's modified.\\
537 We tell \emph{slider} to pass its output value (\texttt{Out} to \emph{text} input value (\testtt{In})
541 We tell \emph{layout} to process itself (it will do it only if it's warned
542 that one of its entries was modified since its (own) last processing.
544 \item{in the Help part}
546 You can see the graphical representation of the script, as in figure \ref{SmallGraph}.
550 \caption{\label{SmallGraph}Graphical representation of a script}
552 \includegraphics[width=0.7\textwidth]{SmallGraph.png}
556 Both graphical pipe line (\emph{slider} and \emph{text} are embedded into \emph{layout})
557 and processing pipe line (\emph{slider} warns \emph{text} immedialtely when it's modified, \emph{slider} passed \emph{text} its new value).\\
558 Yes, we know : all the arrows (pipe line arrows and processing arrows) are blue; we are sorry about that...\\
560 You could get a much more detailled graph, just clicking on the button \\ \texttt{graph (detailled)} in the toolbar of the \texttt{Command} part, like in
561 figure \ref{LargeGraph}.
564 \caption{\label{LargeGraph}Detailled graphical representation of a script}
566 \includegraphics[width=0.75\textwidth]{LargeGraph.png}
573 % ==============================================
574 \subsection{Online Help}
575 % ==============================================
577 Various levels or help are supllid by \bbStudions.
579 % ==========================================
580 \subsubsection{Command line help}
581 % ==========================================
584 The 'working' area (the left one, as opposed to the 'help' area, on the right side) is composed of :
585 one single line zone (Command), at the bottom in which you can enter your commands and
586 a multiple line zone in which the Command interpreter prints out the result of your commands.
587 The upper part contains the script editor; we shall not use it right now, you may reduce it
589 Try typing in the \texttt{Command} area (in this manual,
590 the commands entered by the user will be preceded by a prompt \textgreater) :
595 you get the list of the commands of the interpreter :
628 To get help on a particular command type \texttt{help <command-name>},
636 usage : author <string>
637 Adds the string <string> to the author information of the black box being defined
640 The \texttt{help} command has multiple usages.
641 It is used to get help about almost anything in the interpretor!
642 Type \texttt{'help help'} to get help on the \texttt{help} command itself :
647 (2) help <command name>
648 (3) help packages [all]
649 (4) help <package name> [all]
650 (5) help <black box type>
651 (6) help <black box name>
653 (1) Lists all available commands;
654 (2) Prints help on a particular command;
655 (3) Lists the packages loaded and their black boxes.
656 Add 'all' to list adaptors;
657 (4) Prints short help on the black boxes of a package.
658 Add 'all' to include adaptors;
659 (5) Prints full help on a black box type;
660 (6) Prints information on the inputs, outputs and connectionns
661 of a black box instance.
664 At start the interpretor does not know any black box.
665 If you type \texttt{'help packages'}, which is
666 the third form of the \texttt{help} command, you get :
673 which means that the interpretor only knows one package
674 (library of black boxes) called \texttt{user}
675 and which contains a black box called \texttt{workspace}.
676 The \texttt{user} package is an internal package of the interpreter,
677 which stores user-defined black box types.
678 At start, it already contains
679 one box, called \texttt{workspace}.
680 \texttt{workspace} is a special type of black box,
681 called complex black box, whose purpose is
682 to store other black boxes.
683 Any black box you create in \bbStudio is stored
684 in \texttt{workspace}
685 (this will be explained in details in sections
686 \ref{bbi-writing-scripts} and
687 \ref{bbi-more-on-complex-black-boxes}).
689 If you type \texttt{'help workspace'}, you get :
692 Complex Black Box <user::workspace>
695 Category(s) : complex box;
701 In the text displayed,
702 the \texttt{user::} prepended to the name \texttt{workspace}
703 means that the box \texttt{workspace}
704 belongs to the \texttt{user} package.
705 Then comes a description and three lines which
706 tell that \texttt{workspace} does not have any input
707 nor output nor boxes yet.
709 In order to let the interpreter know of some black boxes,
710 you must load another package.
711 The \texttt{std} package is the ``standard'' package,
712 which contains basic useful black boxes.
724 you get something like :
729 ASCII : ascii codes sequence to string - string to ascii...
730 Add : Adds its inputs
731 ConcatStrings : String concatenation
732 Configuration : Gets configuration informations
733 Div : Divides its inputs
734 ExecBbiCommand : Executes bbi commands
735 ExecSystemCommand : Executes system (O.S.) commands
736 GetVectorCharElement : Gets the i-th element from the input vector (std...
738 MagicBox : Takes *any kind* of data and copies it to its ou...
739 MakeFileName : Makes a kosher file name
740 Mul : Multiplies its inputs
741 MultipleInputs : This box has multiple Void inputs and one Void o...
742 StringRelay : Just copies the value of its input to its output...
743 StringSelect : Outputs the string set to the ith input Ini (In0...
748 Now the interpreter knows the package \texttt{std} and the black boxes it provides,
749 such as the \texttt{'Add'} box, the \texttt{'ConcatStrings'} box, and so on. Remark that the
750 content of \texttt{std} may vary from one version to another
751 as new black boxes might be added to it.
757 You'll get a text help, in the 'Message' part :
761 By : laurent.guigues@creatis.insa-lyon.fr
762 Categories : atomic box;math;
764 'BoxExecute' <bbtk::Void> [signal] : Any signal received by this input
766 'BoxProcessMode' <String> [] : Sets the processing mode of the box
767 (Pipeline | Always | Reactive)
768 'In1' <Double> [] : First number to add
769 'In2' <Double> [] : Second number to add
771 'BoxChange' <bbtk::Void> [signal] : Signals modifications of the box
772 'Out' <Double> [] : Result
775 More information about what is a 'box' will be given in the 'Scriptting' part of this manual.
777 % ==========================================
778 \subsubsection{Guides}
779 % ==========================================
781 An html version of all the guides is browsable in the \texttt{Help} part of \bbStudions.
783 \item {\bf\emph{User's Guide}} : Step to step How-to for user who wants to create his own
784 application, just using already existing boxes.
785 \item {\bf\emph{Package Developper's Guide}} : Step to step How-to for programmer who wants to create his own
786 black boxes/packages.
787 \item {\bf\emph{Developper's Guide}} : For bbtk kernel developpers only. (This one is probabely not very much
788 up-to-date, since we spend more time in developping than writing documentation that's not of user concern).
789 \item {\bf\emph{Reference Manual}} : Contains a exaustive description of all the features for all the commands.
790 \item {\bf\emph{Booklet}} : Vade mecum.
791 \item {\bf\emph{Doxygen Documentation}} : Doxygen source browser.\\ Automatically generated from source file
792 headers. Should concern only the kernel developpers (i.e. : us).
798 % ==========================================
799 \subsubsection{Boxes Help}
800 % ==========================================
801 Box retrieving on various criterions :
803 \item {\bf\emph{Alphabetical list}} \\ This is the 'zero-level' of retrieving.
804 \item {\bf\emph{List by package}} \\ Several packages are supplied with bbtk :
806 \item {\bf\emph{std}} : the 'standard' package including basic useful boxes.
807 \item {\bf\emph{wx}} : basic graphical interface elements (widgets : sliders, buttons, etc. based on the \texttt{wxWidgets} library).
808 \item {\bf\emph{itk}} : the basic image processing package, based on the \itk library.
809 \item {\bf\emph{vtk}} : the basic images and surfaces processing and vizualization package, based on the \vtk library.
810 \item {\bf\emph{wxvtk}} : widget boxes based on the \vtk library (2D and 3D vizualization and
812 \item {\bf\emph{itkvtk}} : special boxes (adaptors) to convert \itk structures into \vtk structures and conversally.
813 %\item {\bf\emph{creaImageIO}} : Provides hight level widgets to read images, including DICOM.
814 \item {\bf\emph{toolsbbtk}} : Tools for bbtk administration and package development, such as :
816 \item{GUICreateBlackBox} For creating the XML or C++ code for a new black box
817 \item{GUICreatePackage} For creating a new bbtk package file structure on disk (Graphical user interface for the shell script bbCreatePackage)
818 \item{MakePackageDoc} For creating the html documentation of a package. The doc is generated at the 'canonical' location. Works both for a build tree or an installed toolkit.
821 \item {\bf\emph{{List by category}}.
822 % ==========================================
823 \subsection{Creating and executing black boxes}
824 % ==========================================
826 % ==============================================
827 \subsection{The Menu}
828 % ==============================================
832 You'll get as well the same information in the 'Help' Part, in html format (see figure : \ref{HelpAdd}) :
835 \caption{\label{HelpAdd}The html Help}
837 \includegraphics[width=0.7\textwidth]{HelpAdd.png}
842 the \texttt{std::} prepended to the name \texttt{Add}
843 means that the box \texttt{Add}
844 belongs to the \texttt{std} package.
845 Then comes a description
846 (the one which was provided by the author of the box),
847 the author(s) of the box (usually e-mail adress(es)) and
848 the categories to which the box belongs.
849 Finally comes the lists of inputs and outputs of the box.
850 For each input or output, \bbi provides
851 its \emph{name} (between quotes, e.g. \texttt{'ProcessMode'}),
852 its \emph{type} (between \texttt{<} and \texttt{>}, e.g. \texttt{<Int>})
854 Remark that the box \texttt{Add} is not a 'complex' black box
855 but an 'atomic' box, hence its help does not
856 mention any information concerning possible internal boxes.
858 You can create an \emph{instance} of an \texttt{Add} box by
859 the command \texttt{new} :
864 The \texttt{'a'} at the end is the \emph{name} of the instance,
865 which will be used to reference it later.
866 It is important to distinguish a box \emph{type}
867 and an \emph{instance} of a box type.
868 The \texttt{Add} box of the package \texttt{std} is actually
869 a \emph{box type} , like \texttt{int} is a data type
870 in \texttt{C} langage. The \texttt{new} command allows to create
871 an instance of a box type, exactly like \texttt{int i;} in
872 a \texttt{C} code, it declares a variable of type \texttt{int} whose
874 Of course, like in \texttt{C} Language, you can declare multiple boxes of the
877 After the creation of the box \texttt{a}, type :
884 Complex Black Box <user::workspace>
887 Category(s) : complex box;
894 which means that \bbi workspace now contains a black box named \texttt{a},
895 of type \texttt{std::Add}.
897 Now look back at the help on \texttt{Add} boxes :
898 you can see that this type of box has two inputs,
899 with name \texttt{In1} and \texttt{In2},
900 and an output, with name \texttt{Out}.
902 You can set the input \texttt{In1}
903 of the \texttt{Add} box \texttt{a} to the value $1$
909 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $2$
915 And you print the output \texttt{Out} of the box \texttt{a} with :
917 > print "result=$a.Out$"
921 In the string passed to the \texttt{print} command,
922 each substring enclosed between a couple of \$ is considered
923 as the name of an output of a box.
924 To process this special substrings, the interpretor :
926 \item Processes the box if needed (see below)
927 \item Converts the output of the box to a string if possible
929 \item Substitutes the result in the string to print
930 \item Postpones an implicit 'new line' character to the string
935 Box processing is needed if :
938 \item either at least input has changed since last processing
939 \item or the input \texttt{'BoxProcessMode'} of the box is set to
940 \texttt{'Always'}, which forces box reprocessing.
943 Note that all boxes have an input named \texttt{'BoxProcessMode'}.\\
945 Another way to process the box \texttt{a} is to issue the command :
950 however this command does not display anything (except if the
951 box itself displays something in its processing).
952 It just processes the box if needed.
953 This command is used to execute boxes that do not have any output,
954 such as boxes that write something to a file or, display a
955 graphical interface, and so on. \\
957 %To exit \bbi, type :
963 % ==========================================
969 \item The \texttt{include} command allows to load a package, and the complex black boxes that come with it..
970 \item \texttt{help} gives help on :
972 \item Available commands if you just type \texttt{help}.
973 \item A particular command if you type \texttt{help <command-name>}.
974 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
975 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
976 \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}).
978 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
979 \item \texttt{new} : creates an instance of a black box.
980 \item \texttt{set} : sets the value of an input of a black box.
981 \item Under any component of \bbStudions, to reference the input called \texttt{i}
982 of a black box called \texttt{b} you must type \texttt{'b.i'}.
983 The same syntax holds for outputs.
984 \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
985 implicit trailing 'new line character' is added at the final string.
986 \item \texttt{exec} : runs, if needed, the process of a box.
987 %\item \texttt{quit} : quits \bbi.
992 %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.
993 %Wou'll get something like in figure \ref{bbCommandPlusHelp} :
996 %\caption{\label{bbCommandPlusHelp}
997 %An other way to run the command interpreter}
999 %\includegraphics[width=0.5\textwidth]{bbCommandPlusHelp.png}
1003 % ==========================================
1005 % ==========================================
1006 \subsubsection{Connecting black boxes}
1007 \label{bbi-connecting-black-boxes}
1008 % ==========================================
1010 \BBTK allows to create
1011 and execute processing chains,
1012 also called \emph{pipelines},
1013 by connecting black boxes.
1014 This section explains how to do it with examples.
1015 Read section \ref{bbi-more-on-pipeline-processing} to get
1016 more information on pipeline processing.
1018 First start \bbStudio and load the package \texttt{std}, typing :
1022 in the 'Command' part.
1024 Assume you want to compute $1+2+3$. You can do it by
1025 chaining two \texttt{Add} boxes, as shown in figure
1026 \ref{bbi-fig-connecting-black-boxes-1}.
1029 \caption{\label{bbi-fig-connecting-black-boxes-1} A simple pipeline which adds 3 numbers}
1031 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
1036 The \bbi instructions to create and execute this pipeline are :
1040 > connect a.Out b.In1
1047 You will see the (very expected) result :
1052 The first three commands build the pipeline,
1053 the next three set \texttt{a} and \texttt{b} black boxes inputs and the last one
1054 prints \texttt{b} black boxe output (the pipeline is executed before printing, because the interpretor 'knows' the box \texttt{b},
1055 whose output is requested, is not up to date.
1057 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output
1058 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the
1060 Once the boxes connected, the processing of the two boxes are chained :
1061 getting the output of \texttt{b} requires getting its inputs,
1062 hence getting the output of \texttt{a} which is connected to it.
1063 This pipeline mechanism can recurse into arbitrary long
1064 chains of boxes (see \ref{bbi-more-on-pipeline-processing}
1068 Lets' consider an other, more image oriented, example :
1076 > new FileSelector fileDialog
1077 > new ImageReader reader
1079 > new Viewer2D viewer
1081 > connect fileDialog.Out reader.In
1082 > connect reader.Out viewer.In
1083 > connect slider.Out viewer.Slice
1084 > connect slider.BoxChange viewer.BoxExecute
1089 Some explainations : the \texttt{include} instructions load the necessary packages. \\
1091 \texttt{new FileSelector} will pop a File Selector, at run time, that will out the user chosen file name. \\
1092 \texttt{new Slider} will pop a Slider, at run time, that will out an integer, used later as a slice number.\\
1093 \texttt{new ImageReader} will read any itk readable file, whose name is passed as a std::string, and return a itk::ImagePointer.\\
1094 \texttt{new Viewer2D} display a plane, whose number id specified by an integer.\\
1096 \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).\\
1097 \texttt{connect reader.Out viewer.In} plugs the output of the reader (an itk::ImagePointer) to the input of the Viewer (a vtkImageData *)\\
1098 \texttt{connect slider.Out viewer.Slice} plugs the output of the slider (an int) to an other output (named Slide) of the viewer.\\
1099 \texttt{connect slider.BoxChange viewer.BoxExecute} says the viewer it must re process itself any time the slider is modified.\\
1101 \texttt{exec viewer} processes the viewer.
1104 This would correspond to the graph in figure \ref{bbi-simplegraph}
1108 \caption{\label{bbi-simplegraph}(Very) simple Graph of a (very) simple pipeline}
1110 \includegraphics[width=0.8\textwidth]{bbi-simplegraph.png}
1114 Of course, to be able to connect two boxes,
1115 the output and the input must be compatibles.
1116 You can always connect an output to an input of the \emph{same} type,
1117 but you can do more, thanks to particular (hidden) black boxes called {\bf adaptors}.
1119 An adaptor is a black box which has at least one input, called \texttt{In},
1120 and at least one ouput called \texttt{Out} and whose role is to convert
1121 a data of the type of \texttt{In}
1122 into a data of the type of \texttt{Out} (other inputs or outputs may serve
1123 to parameter the adaptor or retreive other usefull information).
1125 Under \bbStudions, if you type :
1132 Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
1133 Basic useful black boxes
1136 BoolToString [DA] : Converts a Bool (bool) into a string
1137 CastBoolToChar [DA] : Static cast from Bool (bool) to Char (signed c...
1138 CastBoolToDouble [DA] : Static cast from Bool (bool) to Double (double...
1140 CastBoolToUChar [DA] : Static cast from Bool (bool) to UChar (unsigne...
1141 CastBoolToUInt [DA] : Static cast from Bool (bool) to UInt (unsigned...
1143 CastUIntToBool [DA] : Static cast from UInt (unsigned int) to Bool (...
1144 CastUIntToChar [DA] : Static cast from UInt (unsigned int) to Char (...
1145 CastUIntToDouble [DA] : Static cast from UInt (unsigned int) to Double...
1150 \texttt{[DA]} stands for \emph{default adaptor}.
1152 Once you have loaded the package \texttt{std}, you can
1153 plug an output of type \texttt{char} into an input of type \texttt{double}.
1154 When the interpreter encounters the \texttt{connect} command,
1155 it looks for an adequate \emph{adaptor} in the loaded packages.
1156 In our case, as the package \texttt{std} provides the
1157 \texttt{CastUCharToDouble} adaptor, the interpreter automatically creates an
1158 instance of this adaptor and place it \emph{between}
1159 the output and the input you want to connect
1160 (however this adaptor is hidden to you,
1161 it is embedded into the created connection and does not appear
1162 as an existing black box).
1163 When the pipeline is processed the
1164 adaptor converts the output data into the required input type,
1165 in a totally transparent way.
1166 In our example, the \texttt{CastUCharToDouble} adaptor
1167 would simply cast the value of the \texttt{char} into a \texttt{double},
1168 however arbitrarily complex type conversion may be done.
1171 %Question (for info-dev):
1172 %if two adaptors with the same input and output types exist
1173 %in two different packages, currenly loaded,
1174 %which one is chosen by the interpreter at connection time?
1175 %A feature is missing to specify explicitely which one user wants to choose
1176 %(use a namespace notation ?)
1178 %-> Role of default adaptors
1181 Note that the \texttt{set} and \texttt{print} commands of interpreter
1182 work with adaptors from \texttt{string} to the type of the input to set
1183 or from the type of the output to print to \texttt{string}.
1184 Hence in order to \texttt{set} or \texttt{print} values the adequate
1185 adaptors must be available in the packages currently loaded. \\
1188 % ==========================================
1193 \item The \texttt{connect} command allows to connect two black boxes
1194 \item You can connect two black boxes if (and only if) :
1196 \item The output and the input are of the same type, or
1197 \item There is an adaptor black box in the packages loaded which
1198 converts data of the output type into data of the input type
1200 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use : \texttt{help <package name> all}.
1204 % ==========================================
1206 % ==========================================
1207 \subsubsection{Creating complex black boxes}
1208 \label{bbi-complex-black-boxes}
1209 % ==========================================
1211 Remember the pipeline of figure
1212 \ref{bbi-fig-connecting-black-boxes-1}, which
1213 computed the sum of three doubles?
1214 You can consider it as a whole and define
1215 a new black box type, which will be a \emph{complex black box},
1216 having three inputs and one output,
1217 as shown in figure \ref{bbi-fig-complex-black-box-1}.
1220 \caption{\label{bbi-fig-complex-black-box-1} Creating the complex black box \texttt{Add3}}
1222 \includegraphics[width=0.5\textwidth]{Add3.png}
1226 The \bbi commands to define this complex black box are
1236 > connect a.Out b.In1
1239 > description "adds 3 doubles"
1240 > input x a.In1 "first double to add"
1241 > input y a.In2 "second double to add"
1242 > input z b.In2 "third double to add"
1243 > output result b.Out "output"
1250 As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in first line.
1252 The command \texttt{define} then starts the definition
1253 of the complex box type, which will be called \texttt{Add3}.
1255 The next three lines define the pipeline,
1256 exactly in the same way than outside a complex box definition.
1258 The commands \texttt{author}, \texttt{description}, \texttt{input}
1259 and \texttt{output} are commands specific to complex boxes definition :
1261 \texttt{author} and \texttt{description} are used for the documentation
1262 of the new box. You can provide multiple \texttt{author} or
1263 \texttt{description} commands, the arguments of the commands will
1264 be concatenated to produce the final author and description strings.
1266 \texttt{input} and \texttt{output} are used to define the inputs and outputs
1267 of the new complex box.
1268 Their syntax is the same : for each new input/output you need to say
1269 to which internal input/output it corresponds and to provide
1270 a help string documenting the input/output.
1271 In our example, we define that the box \texttt{Add3} has
1272 three inputs : \texttt{x}, \texttt{y} and \texttt{z}.
1273 The input \texttt{x} corresponds to the input \texttt{In1} of the
1274 internal box \texttt{a}.
1275 In the same way, the external input \texttt{y}
1276 corresponds to the internal input \texttt{a.In2}, and
1277 the external input \texttt{In3} to \texttt{b.In2}.
1278 The only output of the new box is called \texttt{result}
1279 and corresponds to \texttt{b.Out}.
1280 The figure \ref{bbi-fig-complex-black-box-1}
1281 illustrates the external to internal
1282 input/output correspondence.
1284 Finally, the \texttt{endefine} command ends the definition of the
1287 After this definition, if you ask for help
1288 on packages, you get :
1299 The \texttt{user} package now contains a new black box type, called
1300 \texttt{Add3}. If you ask for help on this type of box, you get :
1303 Complex Black Box <user::Add3>
1307 'x' <double> : first double to add
1308 'y' <double> : second double to add
1309 'z' <double> : third double to add
1311 'result' <double> : output
1317 and you can use it like any other box, for example type :
1329 As a side note, we can say that, for consistency reasons, it would have been better to name
1330 \texttt{In1}, \texttt{In2} and \texttt{In3} the inputs of the black box \texttt{Add3},
1331 since all the 'natural entry' of a box is named \texttt{In}, or \texttt{In}\emph{x} if there are more than one 'natural
1334 % ==========================================
1339 \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.
1340 Inside a \texttt{define/endefine} block :
1342 \item The \texttt{author} and \texttt{description} commands allow to document the new type of box
1343 \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
1344 of internal boxes they correspond.
1348 % ==========================================
1350 % ==========================================
1351 \subsubsection{Writing scripts}
1352 \label{bbi-writing-scripts}
1353 % ==========================================
1355 Once you have defined a new type of complex box, you
1356 may like to reuse it. To do this, you can simply
1357 write the \bbi commands defining the new box
1358 into a text file and afterwards include that file in \bbi.
1359 Doing this, you start writing \bbi scripts.
1360 The conventionnal (and mandatory) extension for such scripts is \texttt{bbs}
1362 For consistency reasons, you are requested to prepend \texttt{bb} to the name.
1364 For example, the \texttt{Add3} complex box we previously worked on
1365 can be defined in the \texttt{bbAdd3.bbs} file :
1367 \begin{file}{bbAdd3.bbs}
1369 # Defines the Add3 black box which adds 3 doubles
1375 description "adds 3 doubles"
1381 input x a.In1 "first double to add
1382 input y a.In2 "second double to add
1383 input z b.In2 "third double to add"
1385 output result b.Out "output"
1390 Lines starting with a \texttt{\#} character or a \texttt{\//\//} character are ignored, they
1391 are considered as comments by the interpreter.
1392 To use this file in \bbStudions, click on the \texttt{include} button, and browse your filestore to find the file.
1395 > include bbAdd3.bbs
1397 Complex Black Box <user::Add3>
1401 'x' <double> : first double to add
1402 'y' <double> : second double to add
1403 'z' <double> : third double to add
1405 'result' <double> : output
1413 If the file has the \texttt{bbs} extension, you can ommit it and just type :
1418 \subsubsection{Creating complex black boxes that use complex black boxes}
1419 \label{bbi-complex-complex-black-boxes}
1422 Of course, you can include script files in other script files,
1423 like in the following example :
1425 \begin{file}{bbAdd4.bbs}
1427 # Defines the Add4 black box which adds 4 doubles
1432 description "adds 4 doubles"
1436 input In1 a.In1 "first double to add
1437 input In2 a.In2 "second double to add
1438 input In3 a.In3 "third double to add"
1439 input In4 b.In2 "fourth double to add"
1440 output Out b.Out "output"
1447 \subsubsection{Naming Conventions}
1448 \label{bbi-Naming Conventions}
1451 % ==========================================
1453 %\paragraph{Naming Conventions}
1457 % ==========================================
1461 For consistency reasons, you are requested to prepend \texttt{bb}, and postpone an extention \texttt{.bbs},
1462 to the names of the files that hold a \texttt{complex black box} definition.
1464 For example, the \texttt{Add3} complex box we previously worked on
1465 can be defined in the \texttt{bbAdd3.bbs} file.
1468 For consistency reasons, the names of dynamic libraries holding the packages must start by \texttt{libbb}.
1469 For instance, the package \texttt{wx} will be in the library \texttt{libbbwx.dll} (Windows) or \texttt{libbbwx.so}
1474 % ==========================================
1480 \item The \texttt{include} command tells the interpreter to include a script file.
1481 \item Lines starting with a \texttt{\#} or with a \texttt{\//\//} are considered as comments by the interpreter.
1482 \item Lines between a line starting with a \texttt{\//*} an a line starting with a \texttt{*\//} are considered as comments by the interpreter.
1486 % ==========================================
1488 % ==========================================
1489 \subsubsection{Creating command line applications}
1490 \label{bbi-command-line-app}
1491 % ==========================================
1493 Now that you know how to create complex black boxes
1494 (with \texttt{define/endefine}), think
1495 back to the \texttt{workspace} object.
1496 Remember that it is also
1497 a \texttt{complex black box}.
1498 Actually, when you type interpreter commands
1499 outside a \texttt{define/endefine} block,
1500 you progressively define the \texttt{workspace}
1502 You can think of it like if at start the interpreter
1503 was issuing a command \texttt{'define workspace'}
1504 and then letting you define the interior of the box
1507 Remember that the command \texttt{inputs}
1508 allows to define an input of a complex box.
1509 Now, if you use the command \texttt{input}
1510 outside a \texttt{define/endefine} block then
1511 it defines an input of the \texttt{workspace} box,
1512 that is an input of the \emph{main program}.
1513 This input will then be connected to the
1514 parameters that the user passes to the command line.
1516 For example, consider the script :
1518 \begin{file}{add.bbs}
1522 input x a.In1 "first number to add"
1523 input y a.In2 "second number to add"
1528 The third and fourth lines define two inputs \texttt{x}
1529 and \texttt{y}. When you execute this script,
1530 you can pass these two arguments on the command line,
1538 You can also invoke \bbi the option \texttt{-h},
1539 which gives help on the \texttt{workspace} box :
1546 'x' <double> : first number to add
1547 'y' <double> : second number to add
1550 To get a better help, use the \texttt{description}
1551 and \texttt{author} commands :
1553 \begin{file}{add.bbs}
1555 description "Adds two numbers"
1556 author "foo@bar.com"
1559 input x a.In1 "first number to add"
1560 input y a.In2 "second number to add"
1565 Now if you ask for help on the \texttt{add} script, you get :
1572 'x' <double> : first number to add
1573 'y' <double> : second number to add
1576 Rather than getting the inputs of a script
1577 from the command line, you can ask \bbi to
1578 prompt the user for the values, using the \texttt{-t}
1583 x=[the program waits for user answer]2
1584 y=[the program waits for user answer]5
1588 \bbStudio is always compiled in graphical mode (with \wx), therefore
1589 you can also use the \texttt{-g} commutator.
1590 \bbi then prompts the user in graphical mode,
1591 displaying a dialog box for each input,
1592 like in fig. \ref{bb-input-dialog-box}.
1595 \caption{\label{bb-input-dialog-box}Input dialog box}
1597 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1601 % ==========================================
1606 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1607 when they are used outside a \texttt{define/endefine} block allow
1608 to define the inputs, description and author of the main program.
1609 \item Inputs of the main program can be passed on the command line
1610 using the syntax \texttt{<input-name>=<value>}.
1611 No white space is allowed, if the value or the input name
1612 contains white spaces, enclose them
1613 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1614 \item The \texttt{-h} option of \bbi prints help on the main program.
1615 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1616 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1619 % ==========================================
1621 % ==========================================
1622 \subsubsection{Using graphical interface boxes (widget boxes)}
1624 % ==========================================
1626 % ==========================================
1627 \subsubsection{Overwiew}
1628 \label{bbi-overview}
1629 % ==========================================
1631 \bbStudio is always compiled in graphical mode
1632 (option \texttt{BUILD\_bbi\_GRAPHICAL} of \cmakens, requires \wxns),
1633 then you can use special black boxes which are
1634 graphical interface components (widgets).
1635 Basic components are provided in the package \texttt{wx},
1636 such as buttons, sliders, file open/save dialogs, etc.
1638 As first example, type the following commands in \bbi :
1645 When you type \texttt{enter} after the last line,
1646 a window pops up in which you can entrer a text.
1647 When you close the window, the text you entered is printed by
1648 the \texttt{print} command.
1650 Type \texttt{help wx}, you get something like :
1652 Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1653 Basic graphical interface elements (sliders, buttons ...) based on wxWidgets
1655 ColourSelector : Colour Selector dialog (bbfication of wxColourSele...
1656 ColourSelectorButton : A button which displays a colour picker dialog whe...
1657 CommandButton : Button which executes bbi commands
1658 DirectorySelector : Pops up a directory selection dialog (wxDirDialog)
1659 FileSelector : Pops up a file selection dialog for reading or sav...
1660 InputText : A zone in which the user can enter a text (wxTextC...
1661 LayoutLine : LayoutLine widget (wxBoxSizer)
1662 LayoutSplit : Widget which splits a window in two fixed size par...
1663 LayoutTab : LayoutTab widget (wxNotebook)
1664 OutputText : Text zone to be inserted into a window (wxStaticTe...
1665 RadioButton : RadioButton group widget 0-9 entries
1666 Slider : Slider widget (wxSlider)
1669 You can reproduce the same experiment as above using a
1670 \texttt{Slider} or a \texttt{FileDialog} rather than a \texttt{InputText}.
1671 See the files \texttt{test*.bbs} in the \texttt{scripts/test} directory.
1673 There are two kinds of widgets : ``terminal'' widgets and ``container'' widgets.
1674 The \texttt{InputText}, \texttt{FileDialog} or \texttt{Slider} widgets
1675 are ``terminal'' widgets.
1676 ``container'' widgets are of another kind : they are designed to
1677 contain other widgets in order to build larger dialog boxes.
1678 For example, the \texttt{LayoutSplit} widget is a container which
1679 ``splits'' horizontally a window into two parts,
1680 each part including another widget.
1681 The size of the two parts can be adjusted by the user thanks
1684 The script \texttt{scripts/test/testSplit.bbs} demonstrate its use.
1685 Run it : it displays a window with two sliders.
1686 Move the sliders and close the window.
1687 The final positions of the sliders are printed out.
1688 Now edit the file to see how this is done :
1690 \begin{file}{scripts/test/testSplit.bbs}
1699 connect s1.Widget s.Widget1
1700 connect s2.Widget s.Widget2
1702 print s1=$s1.Out$\\n
1703 print s2=$s2.Out$\\n
1707 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1708 A \texttt{LayoutSplit} box \texttt{s} is also created.
1709 The \texttt{connect} commands then ``includes'' the sliders in the
1710 split ``container''.
1711 The input \texttt{Widget} is common to all widget boxes :
1712 every widget can be inserted into another widget.
1713 The outputs \texttt{Widget1},\texttt{Widget2} are specific of \emph{container}
1715 (in \bbi type \texttt{help Slider} :
1716 you will see the output \texttt{Widget};
1717 type \texttt{help LayoutSplit} :
1718 you will see the inputs \texttt{Widget1} and \texttt{Widget2}
1719 and the output \texttt{Widget}).
1720 When you connect the \texttt{Widget} output of a container
1721 to the \texttt{Widget}i input of a widget,
1722 you order to include the widget in the container.
1723 Of course, the order of connection is important.
1724 In our case, the slider \texttt{s1} is included first,
1725 then the slider \texttt{s2} : \texttt{s1} will be placed
1726 on top of \texttt{s2} (the \texttt{LayoutSplit} box is
1727 implemented that way, but this is arbitrary choice).
1729 Right now, there are only \emph{three} container widgets in the \texttt{wx} package :
1731 \item {the \texttt{LayoutSplit} widget} we just described, the \texttt{LayoutLine} , and the \texttt{LayoutTab}
1734 \item {the \texttt{LayoutLine} widget} can have multiple children and
1735 divides its window into as much parts as children,
1736 each part of equal size.
1737 The orientation of the \texttt{LayoutSplit} or of the \texttt{LayoutLine} can be changed by the input \texttt{Orientation}.
1738 See the example \texttt{test/testSizer.bbs}.
1739 With only those two containers you can already create
1740 complex dialog boxes (of course containers can be nested, which leads to tree-like structures of widgets).
1741 See the script \texttt{bbtk/share/bbtk/bbs/wx/appli/ExampleLayoutSplit.bbs} for an example.
1743 \item {The \texttt{LayoutTab} widget} is based on the \texttt{wxNotebook.}\\
1744 The label of each 'note book' is the name of the object it contains.
1751 %One word about a special widget in the package \texttt{wx} :
1752 %the \texttt{Button}... to be continued.
1754 % ==========================================
1755 \subsubsection{Deeper in the boxes}
1756 \label{bbi-deep-box}
1757 % ==========================================
1759 Any widget box has two mandatory Inputs :
1761 \item {\bf\emph{BoxExecute}} : Any signal received by this input executes the box
1762 \item {\bf\emph{BoxProcessMode}} : Sets the processing mode of the box :
1764 \item {\bf\emph{Pipeline}} : bbBackwardUpdate() calls Process() only if Status == MODIFIED \\
1765 The box executes itself only when an entry was changed (normal pipeline processing).
1766 \item {\bf\emph{Reactive}} : bbSetModifiedStatus() calls bbUpdate() \\
1767 Warning : Re-processed immediately when \emph{any entry} changed.\\
1768 To be more selective, better use \texttt{connect A.BoxChange \emph{currentBox}.BoxExecute}.
1769 \item {\bf\emph{Always}} : bbUpdate() always calls Process. \\
1770 Usefull for 'sources', that must be processed, even when no entry changed (e.g. : FileSelector, ColorSelector)\\
1771 This one is not end user intended (for Package developer only)
1775 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} :
1777 \item {\bf\emph{WinHeight}} : Height of the window
1778 \item {\bf\emph{WinWidth}} : Width of the window
1779 \item {\bf\emph{WinTitle}} : Title of the window
1780 \item {\bf\emph{WinClose}} : Any received signal closes the window
1781 \item {\bf\emph{WinHide}} : Any received signal hides the window
1782 \item {\bf\emph{WinDialog}} : When set to 'true', creates a \emph{dialog window}, that blocks the pipeline until it is closed (\emph{modal})
1786 Any \emph{Layout box} (i.e. \emph{LayoutLine}, \emph{LayoutSplit} or \emph{LayoutTab}) has at one or more mandatory Inputs :
1788 \item {\bf\emph{Widget}}\texttt{i} : e.g. a \emph{LayoutSplit} box (Widget which splits a window in two resizeable parts)
1789 has two Input parameters \emph{Widget1} and \emph{Widget2}, used to embed the child windows.\\
1790 e.g. a \emph{LayoutLine} divides the window in up to 9 (depending on the number of inputs \emph{Widget}i) fixed size parts.
1794 Any widget box has two mandatory Outputs :
1797 \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
1798 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.
1799 \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,
1800 further within the execution pipeline.
1805 % ==========================================
1806 \subsection{More on ...}
1808 % ==========================================
1810 % ==========================================
1811 \subsubsection{Black box packages}
1812 \label{bbi-more-on-packages}
1813 % ==========================================
1814 There are various others user-intended packages :
1817 ---> Were moved in a 'Reference Manual' ?\\
1818 ---> Any suggestion welcome!
1826 % ==========================================
1827 \subsubsection{Pipeline processing}
1828 \label{bbi-more-on-pipeline-processing}
1829 % ==========================================
1831 \item the ``control'' mechanism in bbi.
1833 When a box is requested to update itself, it asks (recursively) each one of its inputs if it was modified.\\
1834 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.
1836 (switch exec commands, e.g. Button)
1837 \item the role of ProcessMode to update widgets.
1839 % ==========================================
1840 \subsubsection{Complex black boxes}
1841 \label{bbi-more-on-complex-black-boxes}
1842 Creation of complex widgets (containers, contained...)
1844 You can include script files in other script files,
1845 like in the following example :
1849 # Defines the Add4 black box which adds 4 doubles
1853 description "adds 4 doubles"
1857 input In1 a.In1 "first double to add"
1858 input In2 a.In2 "second double to add"
1859 input In3 a.In3 "third double to add"
1860 input In4 b.In2 "fourth double to add"
1861 output Out b.Out "output"
1865 The inner boxes have they own entries (In1, In2, In3 for box a, In1, In2 for box b )\\
1866 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
1867 care neither about the inner boxes name, nor about the names of their Inputs.\\
1868 The writer of the complex box has the ability to give these inputs a meaningfull name !
1870 input In3 a.In3 "third double to add"
1871 input In4 b.In2 "fourth double to add"
1874 %\subsubsection{Advanced issues}
1875 %\paragraph{Reducing the number of inputs of a box}
1877 % ==========================================
1878 \subsubsection{Errors}
1879 \label{bbi-more-on-errors}
1881 % ==========================================
1882 \subsubsection{Creating and using your own uninstalled version of bbStudio}
1883 \label{bbi-more-on-your_own_version}
1885 Suppose you want to run your own uninstalled version (say : you downloaded and compiled the
1886 cvs version in order to use a recently commited patch, but you want to be able
1887 to still use the standard version).
1891 \item cvs checkout the sources :
1896 create a build directory
1900 \item cd in the build directory:
1909 Don't forget to switch ON the flag \textttBBTK\_COMPILE\_DEBUG\_MESSAGE \\
1910 (see figure : \ref{bb-ccmake})
1913 \caption{\label{bb-ccmake}\Running ccmake}
1915 \includegraphics[width=0.6\textwidth]{ccmake.png}
1919 \item As usual, type \texttt{c} untill there is no longer any area quoted with a * (or enlighted in red)\\
1920 Ask for generation (type \texttt{g} -once is always enough-)
1922 \item Ask for compilation and link.
1926 For some strange reasons (?!?), you may be warned that an error occured while documentation generation.\\
1927 Take it easy, \texttt{make} again!\\
1929 The dynamic libraries (\texttt{.dll} or \texttt{.so} and the executable programs will be created in the \testtt{bin}
1930 directory of the built tree.
1932 \item choose to install or not your own version.
1936 Linux users : Don't forget to \texttt{sudo} before.
1938 % ==========================================
1939 \subsubsection{\bbtk configuration file and search pathes}
1940 \label{bbi-more-on-configuration}
1942 At start, \bbi tries to open an \texttt{xml}
1943 configuration file named \texttt{bbtk\_config.xml}.
1946 \item The current directory
1947 \item The subdir \texttt{.bbtk} of the user's home directory.
1949 \item On \texttt{Unix}, the home directory is the
1950 one stored by the environnement variable \texttt{HOME},
1951 typically \texttt{/home/username}.
1952 \item On \texttt{Windows}, the home directory is
1953 the user's profile directory stored by the environnement
1954 variable \texttt{USERPROFILE},
1955 typically \texttt{C:\\...}.
1957 \item If none of these two pathes contains the file then it creates
1958 a new one in the \texttt{.bbtk} directory.
1961 Once created, you can edit the \texttt{bbtk\_config.xml} file located
1962 in your \texttt{.bbtk} directory. It contains :
1964 \begin{file}{bbtk\_config.xml}
1966 <?xml version="1.0" encoding="iso-8859-1"?>
1968 <description> </description>
1969 <bbs_path> </bbs_path>
1973 <data_path> </data_path>
1974 <default_temp_dir>$</default_temp_dir>
1979 You can add pathes to
1981 \item A custom folder in which to search for \texttt{.bbs} scripts (\texttt{include} command of \bbi) by adding an \texttt{xml} tag :
1982 \texttt{<bbs\_path>complete\_path\_to\_folder<\/bbs\_path>}.
1983 \item A custom folder in which to search for packages (\texttt{load} command of \bbi) by adding an \texttt{xml} tag :
1984 \texttt{<package\_path>complete\_path\_to\_folder<\/package\_path>}.
1990 % ==========================================
1991 \subsection{Language reference}
1992 \label{bbi-reference}
1993 % ==========================================
1996 % ==========================================
1997 \subsubsection{pipeline creation and execution related commands}
1998 \label{bbi-reference-creation-execution}
1999 % ==========================================
2002 % ==========================================
2004 \caption{\label{bbi-reference-box} \bbi pipeline creation and execution related commands.}
2006 \begin{tabular}{|lcm{6cm}|}
2008 Command & Parameters & Effect \\ \hline
2010 \texttt{new} & \texttt{<boxtype>} \texttt{<box-name>}&
2011 Creates a box of type \texttt{boxtype} and name
2012 \texttt{box-name}.\\ \hline
2014 \texttt{delete} & \texttt{<box-name>} &
2015 Destroys the box named \texttt{box-name}.\\ \hline
2017 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} &
2019 \texttt{output} of the box named \texttt{box1}
2020 to the input \texttt{input} of the box named \texttt{box2} \\ \hline
2022 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
2023 Sets the input \texttt{input} of
2024 the box named \texttt{box} to the value \texttt{value}.
2025 An \texttt{adaptor} must exist
2026 in the packages loaded which converts a \texttt{std::string}
2027 to the type of the input \texttt{input}. \\ \hline
2029 \texttt{print} & \texttt{<string>} &
2030 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the
2031 output \texttt{output} of the box named \texttt{box}.
2032 An \texttt{adaptor} must exist
2033 in the packages loaded which converts
2034 the type of the output \texttt{output}
2035 to a \texttt{std::string}.
2038 \texttt{exec} & \texttt{<box-name>} &
2039 Executes the box named \texttt{box-name}.
2041 connected to its inputs
2042 are also processed recursively (pipeline processing).\\ \hline
2043 \texttt{exec} & \texttt{freeze} &
2044 Allows to block execution commands while keeping definition commands active.(This one is not for end user)\\ \hline
2045 \texttt{exec} & \texttt{unfreeze} &
2046 Turns back to 'normal' mode (This one is not for end user).\\ \hline
2049 % ==========================================
2053 % ==========================================
2054 \subsubsection{Interpreter related commands}
2055 \label{bbi-reference-interpreter}
2056 % ==========================================
2058 % ==========================================
2060 \caption{\label{bbi-reference-interpreter}\bbi intepreter related commands.}
2062 \begin{tabular}{|lcm{6cm}|}
2064 Command & Parameters & Effect \\ \hline
2066 \texttt{author} & \texttt{<author-name>} &
2067 Adds the string \texttt{<author-name>} to the author information of the black box being defined \\ \hline
2069 \texttt{category} & \texttt{<category-name>} &
2070 Adds the string \texttt{<category-name>} to the category information of the black box being defined \\ \hline
2073 Prints help on available commands \\ \hline
2075 & \texttt{<command-name>} &
2076 Prints help on the command \texttt{command-name} \\ \hline
2078 & \texttt{packages} &
2079 Prints help on available packages and their box types
2080 (without description)\\ \hline
2082 & \texttt{<package-name>} &
2083 Prints help on the package \texttt{package-name} and its boxes
2084 (with brief description).
2085 The package must have been previously loaded \\ \hline
2087 & \texttt{<box-type>} &
2088 Prints help (with full description) on the type of box
2090 The box type must belong to a package which has been previously loaded \\ \hline
2092 & \texttt{<debug-directive>} &
2094 Prints debug info on living bbtk objects containing the string \texttt{expr} (default expr='').
2095 \texttt{-C} checks the factory integrity.
2096 \texttt{-D} turns on objects debug info after main ends\\ \hline
2098 \texttt{include} & \texttt{<file-name>} &
2099 Includes and executes the content of the file named \texttt{file-name}
2100 exactly like if you were typing its content at the place were the
2101 \texttt{include} command is. \\ \hline
2103 \texttt{load} & \texttt{<package-name>} &
2104 Loads the package \texttt{package-name} (use it only if you know that you won't work with complex black boxes) \\ \hline
2106 \texttt{include} & \texttt{<package-name>} &
2107 Loads the package \texttt{package-name} and includes all the complex black boxes that comes with it \\ \hline
2109 \texttt{kind} & \texttt{<box kind>} &
2110 Specifies the \texttt{kind} of the complex black boxes you are describing \\ \hline
2112 \texttt{unload} & \texttt{<package-name>}&
2113 Unloads the package \texttt{package-name}.
2114 The package must have been previously loaded.
2115 No box of a type defined in this package must still exist.\\ \hline
2117 \texttt{message} & \texttt{<category>} \texttt{<level>} &
2118 Sets the level of verbosity of \bbi for the category of messages
2119 \texttt{category} to \texttt{level}.\\ \hline
2120 %See \ref{verbosity}.
2122 \texttt{config} & - & Displays the Configuration parameters\\ \hline
2124 \texttt{reset} & - & Deletes all boxes and unloads all packages so
2125 that \bbi gets back to its initial state \\ \hline
2127 \texttt{quit} & - & Exits the interpreter (Don't use it under \bbStudions)\\ \hline
2131 % ==========================================
2135 % ==========================================
2136 \subsubsection{complex black box definition related commands}
2137 \label{bbi-reference-black-box-definition}
2138 % ==========================================
2140 % ==========================================
2142 \caption{\label{bbi-reference-complex-box} \bbi complex black box definition related commands.}
2144 \begin{tabular}{|lcm{6cm}|}
2146 Command & Parameters & Effect \\ \hline
2149 \texttt{define} & \texttt{<box-type>} &
2150 Starts the definition of a complex black box of type
2151 \texttt{box-type}\\ \hline
2153 \texttt{endefine} & - &
2154 Ends the definition of a complex black box type\\ \hline
2156 \texttt{author} & \texttt{<string>} &
2157 Sets the author(s) of the complex black box currently being defined \\ \hline
2159 \texttt{description} & \texttt{<string>} &
2160 Sets the description of the complex black box currently being defined \\ \hline
2162 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} &
2163 Defines a new input for the current complex black box,
2164 named \texttt{name}.
2165 It is defined as corresponding to
2166 the input \texttt{input} of the box \texttt{box}.
2168 \texttt{<help>} is the help string for the new input.
2169 The box \texttt{box} must already have been created in the complex box
2170 and of course have an input named \texttt{input}.\\ \hline
2172 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} &
2173 Defines a new output for the current complex black box,
2174 named \texttt{name}.
2175 It is defined as corresponding to
2176 the output \texttt{output} of the box \texttt{box}.
2177 \texttt{<help>} is the help string for the new output.
2178 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. \\ \hline
2183 % ==========================================
2187 % ==========================================
2188 \vspace{0.5cm}\hrule \\
2189 \section{The Package Browser}
2190 \label{Package_Browser}
2191 % ==========================================
2194 You can run it using the tool bar of the 'Command' part.
2196 See figure \ref{Package_Browser}.
2199 \caption{\label{Package_Browser}The Package Browser}
2201 \includegraphics[width=0.6\textwidth]{Package_Browser.png}
2205 It allows you to query informations about what you can find in the packages (boxes and applications), using several criterions
2206 (warning : it's case sensitive, i.e \texttt{Button} will give different results thn \texttt{button} ...)
2209 All the boxes and applications held in a given package (e.g. \texttt{wxvtk}, \texttt{std}, ...)
2211 You can query on a subpart of the name of a box or an application (e.g. \texttt{DICOM})
2212 \item Description :\\
2213 You can query on a substring of the description of a box or an application (e.g. \texttt{utton} : user wants to get all
2214 the\texttt{Button} as well as the \texttt{button} )
2216 You can query on a sub part of the category name of a box or an application (e.g. \texttt{3D})
2217 \item Input Type :\\
2218 You can query all the boxes or applications that have at least one Input entry of the given type (e.g. \texttt{int})
2219 \item Output Type :\\
2220 You can query all the boxes or applications that have at least one Output entry of the given type (e.g. \texttt{int})
2221 \item Input Nature :\\
2222 You can query all the boxes or applications that have at least one Input entry of the given nature (e.g. \texttt{signal})
2223 \item Output Nature :\\
2224 You can query all the boxes or applications that have at least one Output entry of the given nature (e.g.
2225 \texttt{signal},\texttt{file name})
2229 All these criterions are \emph{AND}ed while the query process.\\
2230 You can get the whole description of a given box or application clicking on its name.
2233 % ==========================================
2234 \vspace{0.5cm}\hrule \\
2235 \section{Using third party Package}
2236 \label{Third_Party_Package}
2237 % ==========================================
2239 You will have to update the \emph{bbtk\_config.xml} file.\\
2240 To know where it is stored, just click on \texttt{Config} button of the \texttt{Command} part toolbar.
2242 You'll get something like :
2248 bbtk_config.xml : [/home/jpr/Creatis/bbtk/binLIN/bin/bbtk_config.xml]
2249 Documentation Path : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/doc]
2250 Data Path : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/data]
2251 Temp Directory : [/home/jpr/Creatis/bbtk/binLIN]
2252 File Separator : [/]
2255 --- [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/bbs]
2256 --- [/home/jpr/Creatis/bbtk/binLIN/share/bbtk/bbs]
2259 --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2260 --- [/home/jpr/Creatis/bbtk/binLIN/bin/../lib]
2261 --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2262 --- [/home/jpr/Creatis/bbtk/binLIN/bin\Debug]
2263 --- [/home/jpr/Creatis/bbtk/binLIN/bin\Release]
2266 (depending on who you are, and whether \texttt{bbStudio} is installed or not.)\\
2268 Just use your favourite text editor to add :
2271 at the end of the \texttt{BBS Paths} part
2272 the name of the directory that contains the \texttt{.bbs} scripts of the package you
2274 \item at the end of the \texttt{PACKAGE Paths} part
2275 the name of the directory that contains the dynamic libraries (\texttt{.dll} or \texttt{.so}) of the package
2278 If you want (and sure you will) to be able to use the Help tools as well on the features provided by this package, you must use the
2279 option \texttt{Generate index} in the menu \texttt{Tools} of the \texttt{Files} part toolbar.
2280 % ==========================================
2281 \vspace{0.5cm}\hrule \\
2282 \section{Using black boxes in \CPP programs}
2284 % ==========================================
2286 A very usefull feature is that you may use any black box within a \CPP program witout worrying about wxWigets main window.\\
2288 Let's look a the following bbs script :
2295 # Create the Objects
2298 new LayoutLine layout
2300 # Graphical pipeline
2301 connect slider.Widget layout.Widget1
2302 connect text.Widget layout.Widget2
2304 # Execution pipeline
2305 connect slider.BoxChange text.BoxExecute
2306 connect slider.Out text.In
2312 User wants to create a slider and an output text, within a layoutline, and display the slider value in the output text.\\
2313 Think about the (little!) nightmare to code the same, in 'raw C++', using wxWidgets.\\
2315 Using \bbtk you just 'convert' the script :
2318 #include <bbwxSlider.h>
2319 #include <bbwxOutputText.h>
2320 #include <bbtkFactory.h>
2321 #include <bbwxLayoutLine.h>
2323 int main(int argv, char* argc[])
2325 // we need to intanciate a bbtk::Factory to be aware of the adaptors
2326 bbtk::Factory::Pointer factory = bbtk::Factory::New();
2328 // Load the packages
2330 factory->LoadPackage("std");
2331 factory->LoadPackage("wx");
2333 // Create the Objects
2334 // ------------------
2335 bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
2336 bbwx::OutputText::Pointer text = bbwx::OutputText::New("text");
2337 bbwx::LayoutLine::Pointer layout = bbwx::LayoutLine::New("layout");
2339 // Graphical pipeline
2340 bbtk::Connection::Pointer c1 = bbtk::Connection::New(slider,"Widget",
2343 bbtk::Connection::Pointer c2 = bbtk::Connection::New(text,"Widget",
2346 // Execution pipeline
2347 // ------------------
2349 // We have to pass the 'factory', in order to call automatically an adaptor,
2351 bbtk::Connection::Pointer s2t = bbtk::Connection::New(slider,"Out",
2354 bbtk::Connection::Pointer c3 = bbtk::Connection::New(slider,"BoxChange",
2356 layout->bbSetInputWinDialog(true);
2360 layout->bbExecute();
2363 catch (bbtk::Exception e)
2365 bbtk::MessageManager::SetMessageLevel("Error",1);
2375 %\section{Conclusion}