1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
17 Last modified on : September 16, 2008 \\
21 Laurent Guigues, Jean-Pierre Roux
24 % ==========================================
26 % ==========================================
32 % ==========================================
34 % ==========================================
36 % ==========================================
38 \section{What is {\bf bbtk} ?}
39 % ==========================================
40 \BBTK(\bbtkns) is a set of tools
41 (\CPP libraries and executables)
42 providing a \CPP framework for the definition
43 of elementary processing \emph{units}, called {\bf black boxes},
44 and the definition and execution of processing \emph{chains}
45 made up of these black boxes. \\
46 It's a part of the \texttt{Creatools suite} composed mainly of :
58 % ==========================================
59 \subsection{The black box philosophy}
60 % ==========================================
62 \href{http://www.answers.com/topic/black-box-theater}{The Answers Dictionary} defines a {\bf black box} as
63 \emph{``A device or theoretical construct with known or specified performance characteristics
64 but unknown or unspecified constituents and means of operation''} \\
65 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
66 defines a {\bf black box} as
67 \emph{``any component in a system in which only the input and output
68 characteristics are of interest, without regard to its internal mechanism
70 We should merge theese definitions. :
71 not only the inputs and outputs are of interest but also
72 \emph{what the box does} !
73 Hence, I would say that a black box is any \emph{\bf documented}
74 component of a system, letting the user know
75 \emph{\bf what} the box is supposed to do and
76 \emph{\bf how to use it}
77 but not \emph{\bf how it does it}. \\
79 \BBTK provides a systematic framework
80 to encapsulate (or ``wrap'') any
81 existing \texttt{C} or \CPP processing code into an object
82 (a black box) having a {\bf generic symbolic interface}, where
85 \item{\bf generic} means that the interface is \emph{the same}
86 for all boxes. Hence one does not need to know which particular
87 method allows, say, to set a particular input or
88 get a particular output of the box.
89 One can use a black box in a purely abstract way.
90 \item{\bf symbolic} means that a particular
91 input or output is referenced by a 'name', that is by a symbol
92 which identifies the input or output.
93 It also means that symbolic information (text!) is
94 attached to a box: description of the box, author,
95 description of its inputs and outputs, etc.
98 (Actually, genericity is achieved because the interface is symbolic.
99 We let you think about this\dots)
101 Of course, symbolic data attached to a box may be
102 {\bf queried} : what are the inputs/outputs of the box ?
103 what are their type ? their description ? etc.
104 This allows {\bf automatic documentation} of boxes.
106 The abstract definition of black boxes is the most basic
107 aspect of \BBTK architecture.
108 Another key aspect is the groupement of black boxes into
109 so called {\bf packages},
110 which are \emph{dynamic libraries} which can also
111 be queried, in particular about the boxes they provide.
112 The package structure then offers a mechanism which
113 is like a \emph{'plug-in'} mechanism.
114 \BBTK provides the methods to load a package at run-time,
115 and create instances of the boxes it contains.
117 These two mechanisms (black boxes and packages)
118 then gives the way to:
121 \item The definition of an {\bf interpreted script language},
122 which allows to manipulate packages and boxes very easily in symbolic way.
123 \BBTK provides one : \bbi (the Black Box Interpreter).
124 \item {\bf Automatic documentation} of existing packages.
125 \texttt{html} documentation of packages is proposed by
129 Finally, these different components allow {\bf efficient} :
132 \item {\bf capitalization and reuse} of existing processing units,
133 including {\bf documentation}
134 \item {\bf testing, prototyping} in a very simple script language
135 \item {\bf inter-operability} between atomic processings which
136 have been written by different persons, using different libraries, etc.
139 % ==========================================
140 \subsection{\bbtk components}
141 % ==========================================
144 \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework
145 (abstract classes) to develop black boxes and store them into
146 dynamic libraries, called black box \emph{packages}.
147 \item Different {\bf\emph{black box packages}} :
149 \item {\bf\emph{std}} : the 'standard' package including basic useful boxes.
150 \item {\bf\emph{wx}} : basic graphical interface elements (widgets : sliders, buttons, etc. based on the \texttt{wxWidgets} library).
151 \item {\bf\emph{itk}} : the basic image processing package, based on the \itk library.
152 \item {\bf\emph{vtk}} : the basic images and surfaces processing and vizualization package, based on the \vtk library.
153 \item {\bf\emph{wxvtk}} : widget boxes based on the \vtk library (2D and 3D vizualization and
155 \item {\bf\emph{itkvtk}} : special boxes (adaptors) to convert \itk structures into \vtk structures and conversally.
156 \item {\bf\emph{creaReaders}} : Provides hight level widgets to read images, including DICOM.
157 \item {\bf\emph{toolsbbtk}} : Tools for bbtk administration and package development..
159 \item A {\bf\emph{Developement environment}}, called \bbStudio, which provides
161 \item An online {\bf\emph{script editor}}
162 \item A powerfull {\bf\emph{Help environment}}, called \bbPackageBrowser
165 \item Online documentation scaning
166 \item Retreiving boxes on various criterions
167 \item Checking Demo and examples
170 \item An {\bf\emph{interpreter}}, called \bbins, which allows to
171 load black box packages and to define and execute
172 processing chains by connecting various black boxes of the already loaded packages.
173 \item {\bf\emph{Utilities}} :
175 \item \bbfy generates the \CPP code of a black box from a
176 description file written in \texttt{xml}.
177 %\item \bbdoc generates the html documentation of a black box package
178 %(author, description, description of its black boxes :
179 %author, description, inputs, outputs, and so on).
180 \item \bbCreatePackage allows to create the basic file architecture
181 to start the development of a new black box package.
185 The general architecture of \BBTK
186 is shown in figure \ref{bb-architecture}.
189 \caption{\label{bb-architecture}\BBTK architecture}
191 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
197 % ==========================================
198 \subsection{Structure of this guide}
199 % ==========================================
201 This guide is divided into three parts.
203 The first part (\ref{bbStudio}) is a brief presentation of the very intuitive Development
204 environment, \bbStudions.
206 The second part (\ref{bb0})
207 is devoted to the use of the \emph{black box interpreter} \bbins.
208 This is the highest level of use of the toolkit, which
209 allows to create and execute processing chains by connecting
210 black boxes of existing packages.
212 The third part (\ref{cpp}) explains how to
213 use the black box toolkit framework in \CPP code,
214 typically to develop large applications which
215 involve complex graphical interfaces.
218 % ==========================================
219 % ==========================================
220 % ==========================================
221 % ==========================================
222 % ==========================================
223 % ==========================================
225 \section{The Development environment (bbStudio)}
228 Just run it, typing in a console \bbStudio
229 or clicking on its icon or its menu entry.
230 At start, \bbStudio opens with a very minimal 'How to use' in the middle. \\
231 Don't forget to read it : it will vanish at the first mouse click. \\
233 1) Click on the 'Demo' or 'Examples' link.
234 2) Select a Demo or an Example
235 3) Click on the [Source] link : the source file is loaded in bbStudio
236 4) Click on the 'Run button' (the down arrow at the bottom right
240 You'll get something like in figure
241 \ref{bbi-fig-bbStudio-gui-start}
242 (the exact appearance of \bbStudio is Operating System and \bbtk version dependent)
245 \caption{\label{bbi-fig-bbStudio-gui-start}The bbStudio Development environment interface at start time}
247 \includegraphics[width=0.7\textwidth]{bbStudioMainPageStart.png}
252 Feel free to resize any part you want.
253 Your preferences will be kept next time you run again \bbStudio. \\
255 Let's have a look at the resized window :
258 \caption{\label{bbi-fig-bbStudio-gui}The bbStudio Development environment interface}
260 \includegraphics[width=0.7\textwidth]{bbStudioMainPage.png}
264 You can see four parts :
267 \item {\bf{Messages}}
272 The stuff is written using the Advanced User Interface library of wxWidgets,
273 whose 'docking manager' allows windows and toolbars to be floated/docked
275 Please don't use this feature at learning time (the snapshots of this document
276 wouldn't match with your screen ...)
278 \subsection{'Files' part}
279 \label{bbi-FilesPart}
281 It's the .bbs script editor.\\
282 If you load a file holding a script, it will be displayed here, and you'll be
283 able to modify it, to save it, to save-as it, to run it, using the
287 \subsection{'Messages' part}
288 \label{bbi-MessagesPart}
290 Two kinds of messages will be output here:\\
291 System messages : produced by the kernel, in case of a user mistyping, or an execution error\\
292 Script messages : produced by the \bbtk equivalent of \texttt{printf} or \texttt{std::cout} in user programs
294 \subsection{'Command' part}
295 \label{bbi-CommandPart}
297 This is where user will type his requirements.
299 \subsection{'Help Contents' part}
300 \label{bbi-HelpContentsPart}
302 The 'Help Contents' part of \bbStudio is used to browse the html help of \BBTK.
303 All the entries of the starting page are self-explanatory :
305 \item {\bf\emph{Help Contents}}
307 %\item {\bf\emph{Wiki}} : Direct link to the bbtk Wiki (intranet only, right now, www
309 \item {\bf\emph{Demo}} : Link to some 'sophisticated' demonstrations.
310 \item {\bf\emph{Examples}} : Link to some detailed 'How to use' examples
313 \item {\bf\emph{Guides}}
315 \item {\bf\emph{User's Guide}} : Step to step How-to for user who wants to create his own
316 application, just using already existing boxes.
317 \item {\bf\emph{Package Developper's Guide}} : Step to step How-to for user who wants to create his own
319 \item {\bf\emph{Developper's Guide}} : For bbtk kernel developpers. Sorry, not yet written.
320 \item {\bf\emph{Reference Manual}} : Sorry, not yet written.
321 \item {\bf\emph{Booklet}} : Vade mecum. Sorry, not yet written.
322 \item {\bf\emph{Doxygen Documentation}} : Doxygen source browser.
325 \item {\bf\emph{Boxes}} : Box retrieving on various criterions :
327 \item {\bf\emph{By name}} (Alphabetical list)
328 \item {\bf\emph{By package}} (see table : \ref{bbi-list_of_packages})
329 \item {\bf\emph{By category}} (see table : \ref{categories})
330 \item {\bf\emph{Adaptors}} Used internaly to perform type conversions (not end user intended)
335 % ==========================================
337 \caption{\label{bbi-list_of_packages} List of bbtk supplied packages.}
339 \begin{tabular}{|lp{10cm}|}
341 Package & What it's used for \\ \hline
342 \texttt{std} & : the 'standard' package including basic useful boxes \\ \hline
343 \texttt{wx} & : basic graphical interface elements (widgets : sliders, buttons, etc.) based on the \texttt{wxWidgets} library \\ \hline
344 \itk & : the basic image processing package, based on the \itk library. (without description)\\ \hline
345 \vtk & : prints help on the package \texttt{package-name} and its boxes (with brief description). The package must have been previously loaded\\ \hline
346 \texttt{wxvtk} & : widget boxes based on the \vtk library.\\ \hline
347 \texttt{itkvtk} & : adaptors to convert \itk structures into \vtk structures and conversally.\\ \hline
348 \texttt{creaReaders} & : provides high level widgets to read images including DICOM.\\ \hline
349 \texttt{toolsbbtk} & : Tools for bbtk administration and package development.\\ \hline
353 % ==========================================
358 % ==========================================
360 \caption{\label{categories} \texttt{Black Box} categories}
362 \begin{tabular}{|lp{10cm}|}
364 \texttt{Category name} & : Meaning \\ \hline \\ \hline
365 \texttt{adaptor} & : Adaptor box \\ \hline
366 \texttt{application} & : Final application, end user intended \\ \hline
367 \texttt{atomic box} & : System category.
368 Automatically assigned to Atomic Black Boxes (c++ defined) \\ \hline
369 \texttt{complex box} & : System category.
370 Automatically assigned to Complex Black Boxes (script defined) \\ \hline
371 \texttt{command line} & : Script which defines a command line application \\
372 & :(no embedded GUI, but command line imput parameters) \\ \hline
373 \texttt{demo} & : Demonstration \\ \hline
374 \texttt{devel} & : Developer tool (bbCreatePackage.bbs, ...) \\ \hline
375 \texttt{dicom} & : DICOM aware box \\ \hline
376 \texttt{example} & : Example script showing a box use-case \\ \hline
377 \texttt{filter} & : Image processing box \\ \hline
378 \texttt{image} & : Image processing related box \\ \hline
379 \texttt{interaction} & : \\ \hline
380 \texttt{math} & : Mathematical operations \\ \hline
381 \texttt{mesh} & : Mesh processing related box \\ \hline
382 \texttt{misc} & : A box that cannot be put in other category ! \\ \hline
383 \texttt{read/write} & : Box that read or write data from or to disk \\ \hline
384 \texttt{viewer} & : Box which displays some data \\ \hline
385 \texttt{widget} & : Piece of graphical interface \\ \hline
386 \texttt{3D object creator} & : Sophisticated 3D widget \\ \hline
387 \texttt{toolsbbtk} & : Component of bbStudio \\ \hline
391 % ==========================================
394 \caption{\label{kinds} \texttt{Black Box} kinds}
396 \begin{tabular}{|ll|}
398 \texttt{Kind name} & : Meaning \\ \hline \\ \hline
399 \texttt{ADAPTOR} & : Adaptor Box \\ \hline
400 \texttt{DEFAULT\_ADAPTOR} & : \\ \hline
401 \texttt{WIDGET\_ADAPTOR} & : \\ \hline
402 \texttt{DEFAULT\_WIDGET\_ADAPTOR} & : \\ \hline
403 \texttt{GUI} & : \\ \hline
404 \texttt{DEFAULT\_GUI} & : \\ \hline
405 \texttt{ALL} & : If kind='ALL' then sets the level for all kinds \\ \hline
419 % ==========================================
420 % ==========================================
421 % ==========================================
422 % ==========================================
423 % ==========================================
424 % ==========================================
426 \section{The script manager}
428 % ==========================================
430 Atomatically open in the left upper part of bbStudio.
434 \caption{\label{bbi-fig-bbStudio-file0}The bbStudio script manager}
436 \includegraphics[width=0.7\textwidth]{bbFile0.png}
440 Using the lower tool bar (see figure : \ref{lowertoolbar}), you can :
444 \caption{\label{lowertoolbar}The lower tool bar}
446 \includegraphics[width=0.7\textwidth]{lowertoolbar.png}
452 \item {\bf\emph{New file}} : Create a new file to hold a script
453 \item {\bf\emph{Open file}} : Open a already existing file holding a script
454 \item {\bf\emph{Close file}} : Close a file holding a script
455 \item {\bf\emph{Save file}} : Save he current file (if modified)
456 \item {\bf\emph{Save file as}} : Save he current file under a different name
457 \item {\bf\emph{Run file}} : Execute the script you just loaded/modified/written
461 The script language is very simple.
462 Everything is done with only a very few commands (See table \ref{bbi-reference-box}).
463 The philosophy of this part is also very simple :
464 it introduces the \bbi commands using examples,
465 starting with the most simple commands.
466 The first section of this part
467 (\ref{bbi-getting-started})
468 is designed like a tutorial,
469 which progressively introduces all the concepts of the command interpretor.
470 We suggest you run \bbStudio and follow the examples,
471 to see how it works in practice.
472 At the end of this section,
473 you will be able to use \bbStudio and write
474 own black box processing scripts.
477 the section \ref{bbi-more-on}
478 (called \emph{more on...})
479 goes deeper into various issues of the command interpretor.
480 Read it at your convenience,
481 either linearly to learn more about \bbStudio,
482 or in random order to get an answer
483 to a particular question.
485 Finally, the section \ref{bbi-reference}
486 summarizes all the commands of \bbStudions,
487 their parameters and effect.
488 Use it as a reference.
494 % ==========================================
495 \subsection{Getting started}
496 \label{bbi-getting-started}
498 % ==============================================
499 \subsubsection{Installed tree \emph{vs} Built tree}
500 % ==============================================
502 If you want to use the 'installed' version (it means you downloaded and run the Windows
503 installer, or the Fedora package, or you downloaded, compiled and installed the
504 cvs version), just open a console and type \bbStudions, or double click on the application icon. \\
506 If you want to run your own uninstalled version (say : you downloaded and compiled the
507 cvs version in order to use a recently commited patch, but you want to be able to still use the standard version),
508 you have to open a console, cd in the bin directory of the built tree and type \texttt{./bbStudio}.
510 % ==============================================
511 \subsubsection{Using an already existing script}
512 % ==============================================
514 Run \bbStudio the way you need. \\
515 In the part 'Help contents' (See figure \ref{HelpContents}), select \texttt{Examples} link.
518 \caption{\label{HelpContents}Help Contents}
520 \includegraphics[width=0.7\textwidth]{HelpContents.png}
524 You will be asked to select a Box category (See figure \ref{BoxCategories}); \\
525 Select \texttt{example}.
529 \caption{\label{BoxCategories}Box Categories}
531 \includegraphics[width=0.7\textwidth]{BoxCategories.png}
535 You will be asked to choose a script (See figure \ref{example}).
538 \caption{\label{example}example list}
540 \includegraphics[width=0.7\textwidth]{example.png}
546 Select \texttt{wx::exampleSlider} (See figure \ref{exampleSlider});
549 \caption{\label{exampleSlider}example 'exampleSlider'}
551 \includegraphics[width=0.7\textwidth]{exampleSlider.png}
555 You can see the graphical summary representation of the current script (the elementary boxes that compose it, and their
557 Click on \texttt{source}, and you'll be able to see the (very simple) script,
558 in the 'Files' part, within the script editor (See figure \ref{exampleSliderSource});
561 \caption{\label{exampleSliderSource}source code of 'exampleSlider'}
563 \includegraphics[width=0.7\textwidth]{exampleSliderSource.png}
567 Run it, using the lower toolbar (see figure : \ref{lowertoolbar})
569 You'll get something like in \ref{execSliderSource}.
572 \caption{\label{execSliderSource}execution of 'exampleSlider'}
574 \includegraphics[width=0.7\textwidth]{execSliderSource.png}
578 Feel free to move the slider, to check it actually works...
583 % ==========================================
584 \subsubsection{Creating and executing black boxes}
585 % ==========================================
587 To learn interactivelly the script language features, you can use the black box
589 open a console and type \bbStudio
590 or double click on the application icon.
591 You get a window which looks like the one in figure
592 \ref{bbi-fig-bbi-gui}
593 (the exact appearance of \bbStudio is system and \bbtk version dependent)
595 %\footnote{If you compiled \bbtk without \wx then \bbi does not have a
596 %graphical interface but a simple prompt}.
599 \caption{\label{bbi-fig-bbi-gui}The black box interpreter interface}
601 \includegraphics[width=0.7\textwidth]{bbi-gui0.png}
605 The 'working' area (the left one, as opposed to the 'help' area, on the right side) is composed of :
606 one single line zone (Command), at the bottom in which you can enter your commands and
607 a multiple line zone in which the Command interpreter prints out the result of your commands.
608 The upper part contains the script editor; we shall not use it right now, you may reduce it
610 Try typing in the input zone (in this manual,
611 the commands entered by the user will be preceded by a prompt \textgreater) :
616 you get the list of the commands of the interpreter :
649 To get help on a particular command type \texttt{help <command-name>},
657 usage : author <string>
658 Adds the string <string> to the author information of the black box being defined
661 The \texttt{help} command has multiple usages.
662 It is used to get help about almost anything in the interpretor!
663 Type \texttt{'help help'} to get help on the \texttt{help} command itself :
668 (2) help <command name>
669 (3) help packages [all]
670 (4) help <package name> [all]
671 (5) help <black box type>
672 (6) help <black box name>
674 (1) Lists all available commands;
675 (2) Prints help on a particular command;
676 (3) Lists the packages loaded and their black boxes.
677 Add 'all' to list adaptors;
678 (4) Prints short help on the black boxes of a package.
679 Add 'all' to include adaptors;
680 (5) Prints full help on a black box type;
681 (6) Prints information on the inputs, outputs and connectionns
682 of a black box instance.
685 At start the interpretor does not know any black box.
686 If you type \texttt{'help packages'}, which is
687 the third form of the \texttt{help} command, you get :
694 which means that the interpretor only knows one package
695 (library of black boxes) called \texttt{user}
696 and which contains a black box called \texttt{workspace}.
697 The \texttt{user} package is an internal package of the interpreter,
698 which stores user-defined black box types.
699 At start, it already contains
700 one box, called \texttt{workspace}.
701 \texttt{workspace} is a special type of black box,
702 called complex black box, whose purpose is
703 to store other black boxes.
704 Any black box you create in \bbStudio is stored
705 in \texttt{workspace}
706 (this will be explained in details in sections
707 \ref{bbi-writing-scripts} and
708 \ref{bbi-more-on-complex-black-boxes}).
710 If you type \texttt{'help workspace'}, you get :
713 Complex Black Box <user::workspace>
716 Category(s) : complex box;
722 In the text displayed,
723 the \texttt{user::} prepended to the name \texttt{workspace}
724 means that the box \texttt{workspace}
725 belongs to the \texttt{user} package.
726 Then comes a description and three lines which
727 tell that \texttt{workspace} does not have any input
728 nor output nor boxes yet.
730 In order to let the interpreter know of some black boxes,
731 you must load another package.
732 The \texttt{std} package is the ``standard'' package,
733 which contains basic useful black boxes.
745 you get something like :
755 % GetVectorCharElement
757 % GetVectorUShortElement
763 % PrependPackageDataPath
774 ASCII : ascii codes sequence to string - string to ascii...
775 Add : Adds its inputs
776 ConcatStrings : String concatenation
777 Configuration : Gets configuration informations
778 Div : Divides its inputs
779 ExecBbiCommand : Executes bbi commands
780 ExecSystemCommand : Executes system (O.S.) commands
781 GetVectorCharElement : Gets the i-th element from the input vector (std...
783 MagicBox : Takes *any kind* of data and copies it to its ou...
784 MakeFileName : Makes a kosher file name
785 Mul : Multiplies its inputs
786 MultipleInputs : This box has multiple Void inputs and one Void o...
787 StringRelay : Just copies the value of its input to its output...
788 StringSelect : Outputs the string set to the ith input Ini (In0...
793 Now the interpreter knows the package \texttt{std} and the black boxes it provides,
794 such as the \texttt{'Add'} box, the \texttt{'ConcatStrings'} box, and so on. Remark that the
795 content of \texttt{std} may vary from one version to another
796 as new black boxes might be added to it.
802 You'll get a text help, in the 'Message' part :
806 By : laurent.guigues@creatis.insa-lyon.fr
807 Categories : atomic box;math;
809 'BoxExecute' <bbtk::Void> [signal] : Any signal received by this input
811 'BoxProcessMode' <String> [] : Sets the processing mode of the box
812 (Pipeline | Always | Reactive)
813 'In1' <Double> [] : First number to add
814 'In2' <Double> [] : Second number to add
816 'BoxChange' <bbtk::Void> [signal] : Signals modifications of the box
817 'Out' <Double> [] : Result
820 You'll get as well the same information in the 'Help' Part, in html format (see figure : \ref{HelpAdd}) :
823 \caption{\label{HelpAdd}The html Help}
825 \includegraphics[width=0.7\textwidth]{HelpAdd.png}
830 the \texttt{std::} prepended to the name \texttt{Add}
831 means that the box \texttt{Add}
832 belongs to the \texttt{std} package.
833 Then comes a description
834 (the one which was provided by the author of the box),
835 the author(s) of the box (usually e-mail adress(es)) and
836 the categories to which the box belongs.
837 Finally comes the lists of inputs and outputs of the box.
838 For each input or output, \bbi provides
839 its \emph{name} (between quotes, e.g. \texttt{'ProcessMode'}),
840 its \emph{type} (between \texttt{<} and \texttt{>}, e.g. \texttt{<Int>})
842 Remark that the box \texttt{Add} is not a 'complex' black box
843 but an 'atomic' box, hence its help does not
844 mention any information concerning possible internal boxes.
846 You can create an \emph{instance} of an \texttt{Add} box by
847 the command \texttt{new} :
852 The \texttt{'a'} at the end is the \emph{name} of the instance,
853 which will be used to reference it later.
854 It is important to distinguish a box \emph{type}
855 and an \emph{instance} of a box type.
856 The \texttt{Add} box of the package \texttt{std} is actually
857 a \emph{box type} , like \texttt{int} is a data type
858 in \texttt{C} langage. The \texttt{new} command allows to create
859 an instance of a box type, exactly like \texttt{int i;} in
860 a \texttt{C} code, it declares a variable of type \texttt{int} whose
862 Of course, like in \texttt{C} Language, you can declare multiple boxes of the
865 After the creation of the box \texttt{a}, type :
872 Complex Black Box <user::workspace>
875 Category(s) : complex box;
882 which means that \bbi workspace now contains a black box named \texttt{a},
883 of type \texttt{std::Add}.
885 Now look back at the help on \texttt{Add} boxes :
886 you can see that this type of box has two inputs,
887 with name \texttt{In1} and \texttt{In2},
888 and an output, with name \texttt{Out}.
890 You can set the input \texttt{In1}
891 of the \texttt{Add} box \texttt{a} to the value $1$
897 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $2$
903 And you print the output \texttt{Out} of the box \texttt{a} with :
905 > print "result=$a.Out$"
909 In the string passed to the \texttt{print} command,
910 each substring enclosed between a couple of \$ is considered
911 as the name of an output of a box.
912 To process this special substrings, the interpretor :
914 \item Processes the box if needed (see below)
915 \item Converts the output of the box to a string if possible
917 \item Substitutes the result in the string to print
918 \item Postpones an implicit 'new line' character to the string
923 Box processing is needed if :
926 \item either at least input has changed since last processing
927 \item or the input \texttt{'BoxProcessMode'} of the box is set to
928 \texttt{'Always'}, which forces box reprocessing.
931 Note that all boxes have an input named \texttt{'BoxProcessMode'}.\\
933 Another way to process the box \texttt{a} is to issue the command :
938 however this command does not display anything (except if the
939 box itself displays something in its processing).
940 It just processes the box if needed.
941 This command is used to execute boxes that do not have any output,
942 such as boxes that write something to a file or, display a
943 graphical interface, and so on. \\
945 %To exit \bbi, type :
951 % ==========================================
957 \item The \texttt{include} command allows to load a package, and the complex black boxes that come with it..
958 \item \texttt{help} gives help on :
960 \item Available commands if you just type \texttt{help}.
961 \item A particular command if you type \texttt{help <command-name>}.
962 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
963 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
964 \item A particular black box type (with full description) if you type \texttt{help <box-type-name>}. In particular, \texttt{help workspace} displays information on the content of the \texttt{'workspace'} black box, which stores the boxes created by the user (by \texttt{new}).
966 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
967 \item \texttt{new} : creates an instance of a black box.
968 \item \texttt{set} : sets the value of an input of a black box.
969 \item Under any component of \bbStudions, to reference the input called \texttt{i}
970 of a black box called \texttt{b} you must type \texttt{'b.i'}.
971 The same syntax holds for outputs.
972 \item \texttt{print} : prints a string, substituting each substring of the form \$b.o\$ by the value of the output \texttt{o} of the black box \texttt{b}. Note that an
973 implicit trailing 'new line character' is added at the final string.
974 \item \texttt{exec} : runs, if needed, the process of a box.
975 %\item \texttt{quit} : quits \bbi.
980 %A more 'modern' way to proceed is to run \texttt{bbStudio}, drag and drop the \texttt{Command} bookmark to the lower \texttt{Welcome to bbStudio!} bar.
981 %Wou'll get something like in figure \ref{bbCommandPlusHelp} :
984 %\caption{\label{bbCommandPlusHelp}
985 %An other way to run the command interpreter}
987 %\includegraphics[width=0.5\textwidth]{bbCommandPlusHelp.png}
991 % ==========================================
993 % ==========================================
994 \subsubsection{Connecting black boxes}
995 \label{bbi-connecting-black-boxes}
996 % ==========================================
998 \BBTK allows to create
999 and execute processing chains,
1000 also called \emph{pipelines},
1001 by connecting black boxes.
1002 This section explains how to do it with examples.
1003 Read section \ref{bbi-more-on-pipeline-processing} to get
1004 more information on pipeline processing.
1006 First start \bbStudio and load the package \texttt{std}, typing :
1010 in the 'Command' part.
1012 Assume you want to compute $1+2+3$. You can do it by
1013 chaining two \texttt{Add} boxes, as shown in figure
1014 \ref{bbi-fig-connecting-black-boxes-1}.
1017 \caption{\label{bbi-fig-connecting-black-boxes-1} A simple pipeline which adds 3 numbers}
1019 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
1024 The \bbi instructions to create and execute this pipeline are :
1028 > connect a.Out b.In1
1035 You will see the (very expected) result :
1040 The first three commands build the pipeline,
1041 the next three set \texttt{a} and \texttt{b} black boxes inputs and the last one
1042 prints \texttt{b} black boxe output (the pipeline is executed before printing, because the interpretor 'knows' the box \texttt{b},
1043 whose output is requested, is not up to date.
1045 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output
1046 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the
1048 Once the boxes connected, the processing of the two boxes are chained :
1049 getting the output of \texttt{b} requires getting its inputs,
1050 hence getting the output of \texttt{a} which is connected to it.
1051 This pipeline mechanism can recurse into arbitrary long
1052 chains of boxes (see \ref{bbi-more-on-pipeline-processing}
1056 Lets' consider an other, more image oriented, example :
1064 > new FileSelector fileDialog
1065 > new ImageReader reader
1067 > new Viewer2D viewer
1069 > connect fileDialog.Out reader.In
1070 > connect reader.Out viewer.In
1071 > connect slider.Out viewer.Slice
1072 > connect slider.BoxChange viewer.BoxExecute
1077 Some explainations : the \texttt{include} instructions load the necessary packages. \\
1079 \texttt{new FileSelector} will pop a File Selector, at run time, that will out the user chosen file name. \\
1080 \texttt{new Slider} will pop a Slider, at run time, that will out an integer, used later as a slice number.\\
1081 \texttt{new ImageReader} will read any itk readable file, whose name is passed as a std::string, and return a itk::ImagePointer.\\
1082 \texttt{new Viewer2D} display a plane, whose number id specified by an integer.\\
1084 \texttt{connect fileDialog.Out reader.In} plugs the output of the File Selector (a std::string) to the input of the reader (a std::string, too).\\
1085 \texttt{connect reader.Out viewer.In} plugs the output of the reader (an itk::ImagePointer) to the input of the Viewer (a vtkImageData *)\\
1086 \texttt{connect slider.Out viewer.Slice} plugs the output of the slider (an int) to an other output (named Slide) of the viewer.\\
1087 \texttt{connect slider.BoxChange viewer.BoxExecute} says the viewer it must re process itself any time the slider is modified.\\
1089 \texttt{exec viewer} processes the viewer.
1092 This would correspond to the graph in figure \ref{bbi-simplegraph}
1096 \caption{\label{bbi-simplegraph}(Very) simple Graph of a (very) simple pipeline}
1098 \includegraphics[width=0.8\textwidth]{bbi-simplegraph.png}
1102 Of course, to be able to connect two boxes,
1103 the output and the input must be compatibles.
1104 You can always connect an output to an input of the \emph{same} type,
1105 but you can do more, thanks to particular (hidden) black boxes called {\bf adaptors}.
1107 An adaptor is a black box which has at least one input, called \texttt{In},
1108 and at least one ouput called \texttt{Out} and whose role is to convert
1109 a data of the type of \texttt{In}
1110 into a data of the type of \texttt{Out} (other inputs or outputs may serve
1111 to parameter the adaptor or retreive other usefull information).
1113 Under \bbStudions, if you type :
1120 Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
1121 Basic useful black boxes
1124 BoolToString [DA] : Converts a Bool (bool) into a string
1125 CastBoolToChar [DA] : Static cast from Bool (bool) to Char (signed c...
1126 CastBoolToDouble [DA] : Static cast from Bool (bool) to Double (double...
1128 CastBoolToUChar [DA] : Static cast from Bool (bool) to UChar (unsigne...
1129 CastBoolToUInt [DA] : Static cast from Bool (bool) to UInt (unsigned...
1131 CastUIntToBool [DA] : Static cast from UInt (unsigned int) to Bool (...
1132 CastUIntToChar [DA] : Static cast from UInt (unsigned int) to Char (...
1133 CastUIntToDouble [DA] : Static cast from UInt (unsigned int) to Double...
1138 \texttt{[DA]} stands for \emph{default adaptor}.
1140 Once you have loaded the package \texttt{std}, you can
1141 plug an output of type \texttt{char} into an input of type \texttt{double}.
1142 When the interpreter encounters the \texttt{connect} command,
1143 it looks for an adequate \emph{adaptor} in the loaded packages.
1144 In our case, as the package \texttt{std} provides the
1145 \texttt{CastUCharToDouble} adaptor, the interpreter automatically creates an
1146 instance of this adaptor and place it \emph{between}
1147 the output and the input you want to connect
1148 (however this adaptor is hidden to you,
1149 it is embedded into the created connection and does not appear
1150 as an existing black box).
1151 When the pipeline is processed the
1152 adaptor converts the output data into the required input type,
1153 in a totally transparent way.
1154 In our example, the \texttt{CastUCharToDouble} adaptor
1155 would simply cast the value of the \texttt{char} into a \texttt{double},
1156 however arbitrarily complex type conversion may be done.
1159 Question (for info-dev):
1160 if two adaptors with the same input and output types exist
1161 in two different packages, currenly loaded,
1162 which one is chosen by the interpreter at connection time?
1163 A feature is missing to specify explicitely which one user wants to choose
1164 (use a namespace notation ?)
1166 -> Role of default adaptors
1169 Note that the \texttt{set} and \texttt{print} commands of interpreter
1170 work with adaptors from \texttt{string} to the type of the input to set
1171 or from the type of the output to print to \texttt{string}.
1172 Hence in order to \texttt{set} or \texttt{print} values the adequate
1173 adaptors must be available in the packages currently loaded. \\
1176 % ==========================================
1181 \item The \texttt{connect} command allows to connect two black boxes
1182 \item You can connect two black boxes if (and only if) :
1184 \item The output and the input are of the same type, or
1185 \item There is an adaptor black box in the packages loaded which
1186 converts data of the output type into data of the input type
1188 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use : \texttt{help <package name> all}.
1192 % ==========================================
1194 % ==========================================
1195 \subsubsection{Creating complex black boxes}
1196 \label{bbi-complex-black-boxes}
1197 % ==========================================
1199 Remember the pipeline of figure
1200 \ref{bbi-fig-connecting-black-boxes-1}, which
1201 computed the sum of three doubles?
1202 You can consider it as a whole and define
1203 a new black box type, which will be a \emph{complex black box},
1204 having three inputs and one output,
1205 as shown in figure \ref{bbi-fig-complex-black-box-1}.
1208 \caption{\label{bbi-fig-complex-black-box-1} Creating the complex black box \texttt{Add3}}
1210 \includegraphics[width=0.5\textwidth]{Add3.png}
1214 The \bbi commands to define this complex black box are
1224 > connect a.Out b.In1
1227 > description "adds 3 doubles"
1228 > input x a.In1 "first double to add"
1229 > input y a.In2 "second double to add"
1230 > input z b.In2 "third double to add"
1231 > output result b.Out "output"
1238 As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in first line.
1240 The command \texttt{define} then starts the definition
1241 of the complex box type, which will be called \texttt{Add3}.
1243 The next three lines define the pipeline,
1244 exactly in the same way than outside a complex box definition.
1246 The commands \texttt{author}, \texttt{description}, \texttt{input}
1247 and \texttt{output} are commands specific to complex boxes definition :
1249 \texttt{author} and \texttt{description} are used for the documentation
1250 of the new box. You can provide multiple \texttt{author} or
1251 \texttt{description} commands, the arguments of the commands will
1252 be concatenated to produce the final author and description strings.
1254 \texttt{input} and \texttt{output} are used to define the inputs and outputs
1255 of the new complex box.
1256 Their syntax is the same : for each new input/output you need to say
1257 to which internal input/output it corresponds and to provide
1258 a help string documenting the input/output.
1259 In our example, we define that the box \texttt{Add3} has
1260 three inputs : \texttt{x}, \texttt{y} and \texttt{z}.
1261 The input \texttt{x} corresponds to the input \texttt{In1} of the
1262 internal box \texttt{a}.
1263 In the same way, the external input \texttt{y}
1264 corresponds to the internal input \texttt{a.In2}, and
1265 the external input \texttt{In3} to \texttt{b.In2}.
1266 The only output of the new box is called \texttt{result}
1267 and corresponds to \texttt{b.Out}.
1268 The figure \ref{bbi-fig-complex-black-box-1}
1269 illustrates the external to internal
1270 input/output correspondence.
1272 Finally, the \texttt{endefine} command ends the definition of the
1275 After this definition, if you ask for help
1276 on packages, you get :
1287 The \texttt{user} package now contains a new black box type, called
1288 \texttt{Add3}. If you ask for help on this type of box, you get :
1291 Complex Black Box <user::Add3>
1295 'x' <double> : first double to add
1296 'y' <double> : second double to add
1297 'z' <double> : third double to add
1299 'result' <double> : output
1305 and you can use it like any other box, for example type :
1317 As a side note, we can say that, for consistency reasons, it would have been better to name
1318 \texttt{In1}, \texttt{In2} and \texttt{In3} the inputs of the black box \texttt{Add3},
1319 since all the 'natural entry' of a box is named \texttt{In}, or \texttt{In}\emph{x} if there are more than one 'natural
1322 % ==========================================
1327 \item The \texttt{define/endefine} commands allows to define complex black box types, i.e. types of black boxes made up of other black boxes.
1328 Inside a \texttt{define/endefine} block :
1330 \item The \texttt{author} and \texttt{description} commands allow to document the new type of box
1331 \item The \texttt{input} and \texttt{output} commands allow to define the inputs and outputs of the new type of box, that is to which inputs and outputs
1332 of internal boxes they correspond.
1336 % ==========================================
1338 % ==========================================
1339 \subsubsection{Writing scripts}
1340 \label{bbi-writing-scripts}
1341 % ==========================================
1343 Once you have defined a new type of complex box, you
1344 may like to reuse it. To do this, you can simply
1345 write the \bbi commands defining the new box
1346 into a text file and afterwards include that file in \bbi.
1347 Doing this, you start writing \bbi scripts.
1348 The conventionnal (and mandatory) extension for such scripts is \texttt{bbs}
1350 For consistency reasons, you are requested to prepend \texttt{bb} to the name.
1352 For example, the \texttt{Add3} complex box we previously worked on
1353 can be defined in the \texttt{bbAdd3.bbs} file :
1355 \begin{file}{bbAdd3.bbs}
1357 # Defines the Add3 black box which adds 3 doubles
1363 description "adds 3 doubles"
1369 input x a.In1 "first double to add
1370 input y a.In2 "second double to add
1371 input z b.In2 "third double to add"
1373 output result b.Out "output"
1378 Lines starting with a \texttt{\#} character or a \texttt{\//\//} character are ignored, they
1379 are considered as comments by the interpreter.
1380 To use this file in \bbStudions, click on the \texttt{include} button, and browse your filestore to find the file.
1383 > include bbAdd3.bbs
1385 Complex Black Box <user::Add3>
1389 'x' <double> : first double to add
1390 'y' <double> : second double to add
1391 'z' <double> : third double to add
1393 'result' <double> : output
1401 If the file has the \texttt{bbs} extension, you can ommit it and just type :
1406 \subsubsection{Creating complex black boxes that use complex black boxes}
1407 \label{bbi-complex-complex-black-boxes}
1410 Of course, you can include script files in other script files,
1411 like in the following example :
1413 \begin{file}{bbAdd4.bbs}
1415 # Defines the Add4 black box which adds 4 doubles
1420 description "adds 4 doubles"
1424 input In1 a.In1 "first double to add
1425 input In2 a.In2 "second double to add
1426 input In3 a.In3 "third double to add"
1427 input In4 b.In2 "fourth double to add"
1428 output Out b.Out "output"
1435 \subsubsection{Naming Conventions}
1436 \label{bbi-Naming Conventions}
1439 % ==========================================
1441 %\paragraph{Naming Conventions}
1445 % ==========================================
1449 For consistency reasons, you are requested to prepend \texttt{bb}, and postpone an extention \texttt{.bbs},
1450 to the names of the files that hold a \texttt{complex black box} definition.
1452 For example, the \texttt{Add3} complex box we previously worked on
1453 can be defined in the \texttt{bbAdd3.bbs} file.
1456 For consistency reasons, the names of dynamic libraries holding the packages must start by \texttt{libbb}.
1457 For instance, the package \texttt{wx} will be in the library \texttt{libbbwx.dll} (Windows) or \texttt{libbbwx.so}
1462 % ==========================================
1468 \item The \texttt{include} command tells the interpreter to include a script file.
1469 \item Lines starting with a \texttt{\#} or with a \texttt{\//\//} are considered as comments by the interpreter.
1470 \item Lines between a line starting with a \texttt{\//*} an a line starting with a \texttt{*\//} are considered as comments by the interpreter.
1474 % ==========================================
1476 % ==========================================
1477 \subsubsection{Creating command line applications}
1478 \label{bbi-command-line-app}
1479 % ==========================================
1481 Now that you know how to create complex black boxes
1482 (with \texttt{define/endefine}), think
1483 back to the \texttt{workspace} object.
1484 Remember that it is also
1485 a \texttt{complex black box}.
1486 Actually, when you type interpreter commands
1487 outside a \texttt{define/endefine} block,
1488 you progressively define the \texttt{workspace}
1490 You can think of it like if at start the interpreter
1491 was issuing a command \texttt{'define workspace'}
1492 and then letting you define the interior of the box
1495 Remember that the command \texttt{inputs}
1496 allows to define an input of a complex box.
1497 Now, if you use the command \texttt{input}
1498 outside a \texttt{define/endefine} block then
1499 it defines an input of the \texttt{workspace} box,
1500 that is an input of the \emph{main program}.
1501 This input will then be connected to the
1502 parameters that the user passes to the command line.
1504 For example, consider the script :
1506 \begin{file}{add.bbs}
1510 input x a.In1 "first number to add"
1511 input y a.In2 "second number to add"
1516 The third and fourth lines define two inputs \texttt{x}
1517 and \texttt{y}. When you execute this script,
1518 you can pass these two arguments on the command line,
1526 You can also invoke \bbi the option \texttt{-h},
1527 which gives help on the \texttt{workspace} box :
1534 'x' <double> : first number to add
1535 'y' <double> : second number to add
1538 To get a better help, use the \texttt{description}
1539 and \texttt{author} commands :
1541 \begin{file}{add.bbs}
1543 description "Adds two numbers"
1544 author "foo@bar.com"
1547 input x a.In1 "first number to add"
1548 input y a.In2 "second number to add"
1553 Now if you ask for help on the \texttt{add} script, you get :
1560 'x' <double> : first number to add
1561 'y' <double> : second number to add
1564 Rather than getting the inputs of a script
1565 from the command line, you can ask \bbi to
1566 prompt the user for the values, using the \texttt{-t}
1571 x=[the program waits for user answer]2
1572 y=[the program waits for user answer]5
1576 \bbStudio is always compiled in graphical mode (with \wx), therefore
1577 you can also use the \texttt{-g} commutator.
1578 \bbi then prompts the user in graphical mode,
1579 displaying a dialog box for each input,
1580 like in fig. \ref{bb-input-dialog-box}.
1583 \caption{\label{bb-input-dialog-box}Input dialog box}
1585 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1589 % ==========================================
1594 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1595 when they are used outside a \texttt{define/endefine} block allow
1596 to define the inputs, description and author of the main program.
1597 \item Inputs of the main program can be passed on the command line
1598 using the syntax \texttt{<input-name>=<value>}.
1599 No white space is allowed, if the value or the input name
1600 contains white spaces, enclose them
1601 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1602 \item The \texttt{-h} option of \bbi prints help on the main program.
1603 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1604 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1607 % ==========================================
1609 % ==========================================
1610 \subsubsection{Using graphical interface boxes (widget boxes)}
1612 % ==========================================
1614 % ==========================================
1615 \subsubsection{Overwiew}
1616 \label{bbi-overview}
1617 % ==========================================
1619 \bbStudio is always compiled in graphical mode
1620 (option \texttt{BUILD\_bbi\_GRAPHICAL} of \cmakens, requires \wxns),
1621 then you can use special black boxes which are
1622 graphical interface components (widgets).
1623 Basic components are provided in the package \texttt{wx},
1624 such as buttons, sliders, file open/save dialogs, etc.
1626 As first example, type the following commands in \bbi :
1633 When you type \texttt{enter} after the last line,
1634 a window pops up in which you can entrer a text.
1635 When you close the window, the text you entered is printed by
1636 the \texttt{print} command.
1638 Type \texttt{help wx}, you get something like :
1640 Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1641 Basic graphical interface elements (sliders, buttons ...) based on wxWidgets
1643 ColourSelector : Colour Selector dialog (bbfication of wxColourSele...
1644 ColourSelectorButton : A button which displays a colour picker dialog whe...
1645 CommandButton : Button which executes bbi commands
1646 DirectorySelector : Pops up a directory selection dialog (wxDirDialog)
1647 FileSelector : Pops up a file selection dialog for reading or sav...
1648 InputText : A zone in which the user can enter a text (wxTextC...
1649 LayoutLine : LayoutLine widget (wxBoxSizer)
1650 LayoutSplit : Widget which splits a window in two fixed size par...
1651 LayoutTab : LayoutTab widget (wxNotebook)
1652 OutputText : Text zone to be inserted into a window (wxStaticTe...
1653 RadioButton : RadioButton group widget 0-9 entries
1654 Slider : Slider widget (wxSlider)
1657 You can reproduce the same experiment as above using a
1658 \texttt{Slider} or a \texttt{FileDialog} rather than a \texttt{InputText}.
1659 See the files \texttt{test*.bbs} in the \texttt{scripts/test} directory.
1661 There are two kinds of widgets : ``terminal'' widgets and ``container'' widgets.
1662 The \texttt{InputText}, \texttt{FileDialog} or \texttt{Slider} widgets
1663 are ``terminal'' widgets.
1664 ``container'' widgets are of another kind : they are designed to
1665 contain other widgets in order to build larger dialog boxes.
1666 For example, the \texttt{LayoutSplit} widget is a container which
1667 ``splits'' horizontally a window into two parts,
1668 each part including another widget.
1669 The size of the two parts can be adjusted by the user thanks
1672 The script \texttt{scripts/test/testSplit.bbs} demonstrate its use.
1673 Run it : it displays a window with two sliders.
1674 Move the sliders and close the window.
1675 The final positions of the sliders are printed out.
1676 Now edit the file to see how this is done :
1678 \begin{file}{scripts/test/testSplit.bbs}
1687 connect s1.Widget s.Widget1
1688 connect s2.Widget s.Widget2
1690 print s1=$s1.Out$\\n
1691 print s2=$s2.Out$\\n
1695 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1696 A \texttt{LayoutSplit} box \texttt{s} is also created.
1697 The \texttt{connect} commands then ``includes'' the sliders in the
1698 split ``container''.
1699 The input \texttt{Widget} is common to all widget boxes :
1700 every widget can be inserted into another widget.
1701 The outputs \texttt{Widget1},\texttt{Widget2} are specific of \emph{container}
1703 (in \bbi type \texttt{help Slider} :
1704 you will see the output \texttt{Widget};
1705 type \texttt{help LayoutSplit} :
1706 you will see the inputs \texttt{Widget1} and \texttt{Widget2}
1707 and the output \texttt{Widget}).
1708 When you connect the \texttt{Widget} output of a container
1709 to the \texttt{Widget}i input of a widget,
1710 you order to include the widget in the container.
1711 Of course, the order of connection is important.
1712 In our case, the slider \texttt{s1} is included first,
1713 then the slider \texttt{s2} : \texttt{s1} will be placed
1714 on top of \texttt{s2} (the \texttt{LayoutSplit} box is
1715 implemented that way, but this is arbitrary choice).
1717 Right now, there are only \emph{three} container widgets in the \texttt{wx} package :
1719 \item {the \texttt{LayoutSplit} widget} we just described, the \texttt{LayoutLine} , and the \texttt{LayoutTab}
1722 \item {the \texttt{LayoutLine} widget} can have multiple children and
1723 divides its window into as much parts as children,
1724 each part of equal size.
1725 The orientation of the \texttt{LayoutSplit} or of the \texttt{LayoutLine} can be changed by the input \texttt{Orientation}.
1726 See the example \texttt{test/testSizer.bbs}.
1727 With only those two containers you can already create
1728 complex dialog boxes (of course containers can be nested, which leads to tree-like structures of widgets).
1729 See the script \texttt{bbtk/share/bbtk/bbs/wx/appli/ExampleLayoutSplit.bbs} for an example.
1731 \item {The \texttt{LayoutTab} widget} is based on the \texttt{wxNotebook.}\\
1732 The label of each 'note book' is the name of the object it contains.
1739 One word about a special widget in the package \texttt{wx} :
1740 the \texttt{Button}... to be continued.
1742 % ==========================================
1743 \subsubsection{Deeper in the boxes}
1744 \label{bbi-deep-box}
1745 % ==========================================
1747 Any widget box has two mandatory Inputs :
1749 \item {\bf\emph{BoxExecute}} : Any signal received by this input executes the box
1750 \item {\bf\emph{BoxProcessMode}} : Sets the processing mode of the box :
1752 \item {\bf\emph{Pipeline}} : bbBackwardUpdate() calls Process() only if Status == MODIFIED \\
1753 The box executes itself only when an entry was changed (normal pipeline processing).
1754 \item {\bf\emph{Reactive}} : bbSetModifiedStatus() calls bbUpdate() \\
1755 Warning : Re-processed immediately when \emph{any entry} changed.\\
1756 To be more selective, better use \texttt{connect A.BoxChange \emph{currentBox}.BoxExecute}.
1757 \item {\bf\emph{Always}} : bbUpdate() always calls Process. \\
1758 Usefull for 'sources', that must be processed, even when no entry changed (e.g. : FileSelector, ColorSelector)\\
1759 This one is not end user intended (for Package developer only)
1763 Any widget box has five Inputs, that will be dealt with only if the box is not connected to the \emph{Widget}i of any \emph{Layout box} :
1765 \item {\bf\emph{WinHeight}} : Height of the window
1766 \item {\bf\emph{WinWidth}} : Width of the window
1767 \item {\bf\emph{WinTitle}} : Title of the window
1768 \item {\bf\emph{WinClose}} : Any received signal closes the window
1769 \item {\bf\emph{WinHide}} : Any received signal hides the window
1770 \item {\bf\emph{WinDialog}} : When set to 'true', creates a \emph{dialog window}, that blocks the pipeline until it is closed (\emph{modal})
1774 Any \emph{Layout box} (i.e. \emph{LayoutLine}, \emph{LayoutSplit} or \emph{LayoutTab}) has at one or more mandatory Inputs :
1776 \item {\bf\emph{Widget}}\texttt{i} : e.g. a \emph{LayoutSplit} box (Widget which splits a window in two resizeable parts)
1777 has two Input parameters \emph{Widget1} and \emph{Widget2}, used to embed the child windows.\\
1778 e.g. a \emph{LayoutLine} divides the window in up to 9 (depending on the number of inputs \emph{Widget}i) fixed size parts.
1782 Any widget box has two mandatory Outputs :
1785 \item {\bf\emph{Widget}} : that is the \texttt{wxWindow} itself. If it's not connected to the \texttt{Widget}\emph{i} of any \emph{Layout box}, it
1786 will popup. If it's connected to the \texttt{Widget}\texttt{\emph{i}} of any \texttt{Layout box}, it will be embedded in its parent window.
1787 \item {\bf\emph{Boxchange}} : Signals any modification of the box. This output may be connect if necessary to the \emph{BoxExecute} entry of an other box,
1788 further within the execution pipeline.
1793 % ==========================================
1794 \subsection{More on ...}
1796 % ==========================================
1798 % ==========================================
1799 \subsubsection{Black box packages}
1800 \label{bbi-more-on-packages}
1801 % ==========================================
1802 There are various others user-intended packages :
1805 ---> Were moved in a 'Reference Manual' ?\\
1806 ---> Any suggestion welcome!
1814 % ==========================================
1815 \subsubsection{Pipeline processing}
1816 \label{bbi-more-on-pipeline-processing}
1817 % ==========================================
1819 \item the ``control'' mechanism in bbi.
1821 When a box is requested to update itself, it asks (recursively) each one of its inputs if it was modified.\\
1822 In normal pipe-line mode, it will be re-processed if at least one of its imputs was actually modified, as the output of a previous box.
1824 (switch exec commands, e.g. Button)
1825 \item the role of ProcessMode to update widgets.
1827 % ==========================================
1828 \subsubsection{Complex black boxes}
1829 \label{bbi-more-on-complex-black-boxes}
1830 Creation of complex widgets (containers, contained...)
1832 %\subsubsection{Advanced issues}
1833 %\paragraph{Reducing the number of inputs of a box}
1835 % ==========================================
1836 \subsubsection{Errors}
1837 \label{bbi-more-on-errors}
1839 % ==========================================
1840 \subsubsection{Creating and using your own uninstalled version of bbStudio}
1841 \label{bbi-more-on-your_own_version}
1843 Suppose you want to run your own uninstalled version (say : you downloaded and compiled the
1844 cvs version in order to use a recently commited patch, but you want to be able
1845 to still use the standard version).
1849 \item cvs checkout the sources :
1854 create a build directory
1858 \item cd in the build directory:
1867 Don't forget to switch ON the flag \textttBBTK\_COMPILE\_DEBUG\_MESSAGE \\
1868 (see figure : \ref{bb-ccmake})
1871 \caption{\label{bb-ccmake}\Running ccmake}
1873 \includegraphics[width=0.6\textwidth]{ccmake.png}
1877 \item As usual, type \texttt{c} untill there is no longer any area quoted with a * (or enlighted in red)\\
1878 Ask for generation (type \texttt{g} -once is always enough-)
1880 \item Ask for compilation and link.
1884 For some strange reasons (?!?), you may be warned that an error occured while documentation generation.\\
1885 Take it easy, \texttt{make} again!\\
1887 The dynamic libraries (\texttt{.dll} or {.so} ans the executable programs will be created in the \testtt{bin}
1888 directory of the built tree.
1890 \item choose to install or not your own version.
1894 Linux users : Don't forget to \texttt{sudo} before.
1896 % ==========================================
1897 \subsubsection{\bbtk configuration file and search pathes}
1898 \label{bbi-more-on-configuration}
1900 At start, \bbi tries to open an \texttt{xml}
1901 configuration file named \texttt{bbtk\_config.xml}.
1904 \item The current directory
1905 \item The subdir \texttt{.bbtk} of the user's home directory.
1907 \item On \texttt{Unix}, the home directory is the
1908 one stored by the environnement variable \texttt{HOME},
1909 typically \texttt{/home/username}.
1910 \item On \texttt{Windows}, the home directory is
1911 the user's profile directory stored by the environnement
1912 variable \texttt{USERPROFILE},
1913 typically \texttt{C:\\...}.
1915 \item If none of these two pathes contains the file then it creates
1916 a new one in the \texttt{.bbtk} directory.
1919 Once created, you can edit the \texttt{bbtk\_config.xml} file located
1920 in your \texttt{.bbtk} directory. It contains :
1922 \begin{file}{bbtk\_config.xml}
1924 <?xml version="1.0" encoding="iso-8859-1"?>
1926 <description> </description>
1927 <bbs_path> </bbs_path>
1931 <data_path> </data_path>
1932 <default_temp_dir>$</default_temp_dir>
1937 You can add pathes to
1939 \item A custom folder in which to search for \texttt{.bbs} scripts (\texttt{include} command of \bbi) by adding an \texttt{xml} tag :
1940 \texttt{<bbs\_path>complete\_path\_to\_folder<\/bbs\_path>}.
1941 \item A custom folder in which to search for packages (\texttt{load} command of \bbi) by adding an \texttt{xml} tag :
1942 \texttt{<package\_path>complete\_path\_to\_folder<\/package\_path>}.
1948 % ==========================================
1949 \subsection{Language reference}
1950 \label{bbi-reference}
1951 % ==========================================
1954 % ==========================================
1955 \subsubsection{pipeline creation and execution related commands}
1956 \label{bbi-reference-creation-execution}
1957 % ==========================================
1960 % ==========================================
1962 \caption{\label{bbi-reference-box} \bbi pipeline creation and execution related commands.}
1964 \begin{tabular}{|lcm{6cm}|}
1966 Command & Parameters & Effect \\ \hline
1968 \texttt{new} & \texttt{<boxtype>} \texttt{<box-name>}&
1969 Creates a box of type \texttt{boxtype} and name
1970 \texttt{box-name}.\\ \hline
1972 \texttt{delete} & \texttt{<box-name>} &
1973 Destroys the box named \texttt{box-name}.\\ \hline
1975 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} &
1977 \texttt{output} of the box named \texttt{box1}
1978 to the input \texttt{input} of the box named \texttt{box2} \\ \hline
1980 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
1981 Sets the input \texttt{input} of
1982 the box named \texttt{box} to the value \texttt{value}.
1983 There must exist an \texttt{adaptor}
1984 in the packages loaded which converts a \texttt{std::string}
1985 to the type of the input \texttt{input}. \\ \hline
1987 \texttt{print} & \texttt{<string>} &
1988 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the
1989 output \texttt{output} of the box named \texttt{box}.
1990 There must exist an \texttt{adaptor}
1991 in the packages loaded which converts
1992 the type of the output \texttt{output}
1993 to a \texttt{std::string}.
1996 \texttt{exec} & \texttt{<box-name>} &
1997 Executes the box named \texttt{box-name}.
1999 connected to its inputs
2000 are also processed recursively (pipeline processing).\\ \hline
2001 \texttt{exec} & \texttt{freeze} &
2002 allows to block execution commands while keeping definition commands active.\\ \hline
2003 \texttt{exec} & \texttt{unfreeze} &
2004 turns back to 'normal' mode.\\ \hline
2007 % ==========================================
2011 % ==========================================
2012 \subsubsection{Interpreter related commands}
2013 \label{bbi-reference-interpreter}
2014 % ==========================================
2016 % ==========================================
2018 \caption{\label{bbi-reference-interpreter}\bbi intepreter related commands.}
2020 \begin{tabular}{|lcm{6cm}|}
2022 Command & Parameters & Effect \\ \hline
2024 \texttt{author} & - &
2025 Adds the string <string> to the author information of the black box being defined \\ \hline
2027 \texttt{category} & - &
2028 Adds the string <string> to the category information of the black box being defined \\ \hline
2031 Prints help on available commands \\ \hline
2033 & \texttt{<command-name>} &
2034 Prints help on the command \texttt{command-name} \\ \hline
2036 & \texttt{packages} &
2037 Prints help on available packages and their box types
2038 (without description)\\ \hline
2040 & \texttt{<package-name>} &
2041 Prints help on the package \texttt{package-name} and its boxes
2042 (with brief description).
2043 The package must have been previously loaded \\ \hline
2045 & \texttt{<box-type>} &
2046 Prints help (with full description) on the type of box
2048 The box type must belong to a package which has been previously loaded \\ \hline
2050 \texttt{include} & \texttt{<file-name>} &
2051 Includes and executes the content of the file named \texttt{file-name}
2052 exactly like if you were typing its content at the place were the
2053 \texttt{include} command is. \\ \hline
2055 \texttt{load} & \texttt{<package-name>} &
2056 Loads the package \texttt{package-name}\\ \hline
2058 \texttt{include} & \texttt{<package-name>} &
2059 Loads the package \texttt{package-name} and includes all the complex black boxes that comes with it \\ \hline
2061 \texttt{kind} & \texttt{<box kind>} &
2062 Specifies the \texttt{kind} of the complex black boxes you are describing \\ \hline
2064 \texttt{unload} & \texttt{<package-name>}&
2065 Unloads the package \texttt{package-name}.
2066 The package must have been previously loaded.
2067 No box of a type defined in this package must still exist.\\ \hline
2069 \texttt{message} & \texttt{<category>} \texttt{<level>} &
2070 Sets the level of verbosity of \bbi for the category of messages
2071 \texttt{category} to \texttt{level}.\\ \hline
2072 %See \ref{verbosity}.
2074 \texttt{config} & - & Displays the Configuration parameters\\ \hline
2076 \texttt{reset} & - & Deletes all boxes and unloads all packages so
2077 that \bbi gets back to its initial state \\ \hline
2079 \texttt{quit} & - & Exits the interpreter\\ \hline
2083 % ==========================================
2087 % ==========================================
2088 \subsubsection{complex black box definition related commands}
2089 \label{bbi-reference-black-box-definition}
2090 % ==========================================
2092 % ==========================================
2094 \caption{\label{bbi-reference-complex-box} \bbi complex black box definition related commands.}
2096 \begin{tabular}{|lcm{6cm}|}
2098 Command & Parameters & Effect \\ \hline
2101 \texttt{define} & \texttt{<box-type>} &
2102 Starts the definition of a complex black box of type
2103 \texttt{box-type}\\ \hline
2105 \texttt{endefine} & - &
2106 Ends the definition of a complex black box type\\ \hline
2108 \texttt{author} & \texttt{<string>} &
2109 Sets the author(s) of the complex black box currently being defined \\ \hline
2111 \texttt{description} & \texttt{<string>} &
2112 Sets the description of the complex black box currently being defined \\ \hline
2114 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} &
2115 Defines a new input for the current complex black box,
2116 named \texttt{name}.
2117 It is defined as corresponding to
2118 the input \texttt{input} of the box \texttt{box}.
2120 \texttt{<help>} is the help string for the new input.
2121 The box \texttt{box} must already have been created in the complex box
2122 and of course have an input named \texttt{input}.\\ \hline
2124 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} &
2125 Defines a new output for the current complex black box,
2126 named \texttt{name}.
2127 It is defined as corresponding to
2128 the output \texttt{output} of the box \texttt{box}.
2129 \texttt{<help>} is the help string for the new output.
2130 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. \\ \hline
2135 % ==========================================
2139 % ==========================================
2140 \vspace{0.5cm}\hrule \\
2141 \section{The Package Browser}
2142 \label{Package_Browser}
2143 % ==========================================
2146 \caption{\label{Package_Browser}The Package Browser}
2148 \includegraphics[width=0.6\textwidth]{Package_Browser.png}
2152 % ==========================================
2153 \vspace{0.5cm}\hrule \\
2154 \section{Using third party Package}
2155 \label{Third_Party_Package}
2156 % ==========================================
2159 % ==========================================
2160 \vspace{0.5cm}\hrule \\
2161 \section{Using black boxes in \CPP programs}
2163 % ==========================================
2165 A very usefull feature is that you may use any black box within a \CPP program witout worrying about wxWigets main window.\\
2167 Let's look a the following bbs script :
2174 # Create the Objects
2177 new LayoutLine layout
2179 # Graphical pipeline
2180 connect slider.Widget layout.Widget1
2181 connect text.Widget layout.Widget2
2183 # Execution pipeline
2184 connect slider.BoxChange text.BoxExecute
2185 connect slider.Out text.In
2191 User wants to create a slider and an output text, within a layoutline, and display the slider value in the output text.\\
2192 Think about the (little!) nightmare to code the same, in 'raw C++', using wxWidgets.\\
2194 Using \bbtk you just 'convert' the script :
2197 #include <bbwxSlider.h>
2198 #include <bbwxOutputText.h>
2199 #include <bbtkFactory.h>
2200 #include <bbwxLayoutLine.h>
2202 int main(int argv, char* argc[])
2204 // we need to intanciate a bbtk::Factory to be aware of the adaptors
2205 bbtk::Factory::Pointer factory = bbtk::Factory::New();
2207 // Load the packages
2209 factory->LoadPackage("std");
2210 factory->LoadPackage("wx");
2212 // Create the Objects
2213 // ------------------
2214 bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
2215 bbwx::OutputText::Pointer text = bbwx::OutputText::New("text");
2216 bbwx::LayoutLine::Pointer layout = bbwx::LayoutLine::New("layout");
2218 // Graphical pipeline
2219 bbtk::Connection::Pointer c1 = bbtk::Connection::New(slider,"Widget",
2222 bbtk::Connection::Pointer c2 = bbtk::Connection::New(text,"Widget",
2225 // Execution pipeline
2226 // ------------------
2228 // We have to pass the 'factory', in order to call automatically an adaptor, if necessary.
2229 bbtk::Connection::Pointer s2t = bbtk::Connection::New(slider,"Out",
2232 bbtk::Connection::Pointer c3 = bbtk::Connection::New(slider,"BoxChange",
2234 layout->bbSetInputWinDialog(true);
2238 layout->bbExecute();
2241 catch (bbtk::Exception e)
2243 bbtk::MessageManager::SetMessageLevel("Error",1);
2253 %\section{Conclusion}