1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
16 \bbtk version \bbtkVersion
20 Last modified on : October 9, 2008 \\
24 Laurent Guigues, Jean-Pierre Roux
27 % ==========================================
29 % ==========================================
37 % ==========================================
39 % ==========================================
41 % ==========================================
43 \section{What is {\bf bbtk} ?}
44 % ==========================================
45 \BBTK(\bbtkns) is a set of tools
46 (\CPP libraries and executables)
47 providing a \CPP framework for the definition
48 of elementary processing \emph{units}, called {\bf black boxes},
49 and the definition and execution of processing \emph{chains}
50 made up of these black boxes. \\
51 It's a part of the \texttt{Creatools suite} composed mainly of :
59 which depend on the OpenSource libraries:
66 % ==========================================
67 \subsection{The black box philosophy}
68 % ==========================================
70 \href{http://www.answers.com/topic/black-box-theater}{The Answers Dictionary} defines a {\bf black box} as
71 \emph{``A device or theoretical construct with known or specified performance characteristics
72 but unknown or unspecified constituents and means of operation''} \\
73 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
74 defines a {\bf black box} as
75 \emph{``any component in a system in which only the input and output
76 characteristics are of interest, without regard to its internal mechanism
78 We should merge theese definitions. :
79 not only the inputs and outputs are of interest but also
80 \emph{what the box does} !
81 Hence, I would say that a black box is any \emph{\bf documented}
82 component of a system, letting the user know
83 \emph{\bf what} the box is supposed to do and
84 \emph{\bf how to use it}
85 but not \emph{\bf how it does it}. \\
87 \BBTK provides a systematic framework
88 to encapsulate (or ``wrap'') any
89 existing \texttt{C} or \CPP processing code into an object
90 (a black box) having a {\bf generic symbolic interface}, where
93 \item{\bf generic} means that the interface is \emph{the same}
94 for all boxes. Hence one does not need to know which particular
95 method allows, say, to set a particular input or
96 get a particular output of the box.
97 One can use a black box in a purely abstract way.
98 \item{\bf symbolic} means that a particular
99 input or output is referenced by a 'name', that is by a symbol
100 which identifies the input or output.
101 It also means that symbolic information (text!) is
102 attached to a box: description of the box, author,
103 description of its inputs and outputs, etc.
106 (Actually, genericity is achieved because the interface is symbolic.
107 We let you think about this\dots)
109 Of course, symbolic data attached to a box may be
110 {\bf queried} : what are the inputs/outputs of the box ?
111 what are their type ? their description ? etc.
112 This allows {\bf automatic documentation} of boxes.
114 The abstract definition of black boxes is the most basic
115 aspect of \BBTK architecture.
116 Another key aspect is the groupement of black boxes into
117 so called {\bf packages},
118 which are \emph{dynamic libraries} which can also
119 be queried, in particular about the boxes they provide.
120 The package structure then offers a mechanism which
121 is like a \emph{'plug-in'} mechanism.
122 \BBTK provides the methods to load a package at run-time,
123 and create instances of the boxes it contains.
125 These two mechanisms (black boxes and packages)
126 then gives the way to:
129 \item The definition of an {\bf interpreted script language},
130 which allows to manipulate packages and boxes very easily in symbolic way.
131 \BBTK provides one : \bbi (the Black Box Interpreter).
132 \item {\bf Automatic documentation} of existing packages.
133 \texttt{html} documentation of packages is proposed by
137 Finally, these different components allow {\bf efficient} :
140 \item {\bf capitalization and reuse} of existing processing units,
141 including {\bf documentation}
142 \item {\bf testing, prototyping} in a very simple script language
143 \item {\bf inter-operability} between atomic processings which
144 have been written by different persons, using different libraries, etc.
147 % ==========================================
148 \subsection{\bbtk components}
149 % ==========================================
152 \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework
153 (abstract classes) to develop black boxes and store them into
154 dynamic libraries, called black box \emph{packages}.
155 \item Different {\bf\emph{black box packages}} :
157 \item {\bf\emph{std}} : the 'standard' package including basic useful boxes.
158 \item {\bf\emph{wx}} : basic graphical interface elements (widgets : sliders, buttons, etc. based on the \texttt{wxWidgets} library).
159 \item {\bf\emph{itk}} : the basic image processing package, based on the \itk library.
160 \item {\bf\emph{vtk}} : the basic images and surfaces processing and vizualization package, based on the \vtk library.
161 \item {\bf\emph{wxvtk}} : widget boxes based on the \vtk library (2D and 3D vizualization and
163 %\item {\bf\emph{creaImageIO}} : Provides hight level widgets to read images, including DICOM.
164 \item {\bf\emph{toolsbbtk}} : Tools for bbtk administration and package development..
166 \item A {\bf\emph{Developement environment}}, called \bbStudio, which provides
168 \item An online {\bf\emph{script editor and interpretor}}
169 \item A powerfull html {\bf\emph{Help environment}},whith integrated :
171 \item Online documentation scaning
172 \item Retreiving boxes on various criterions
173 \item Checking Demo and examples
176 \item An standalone {\bf\emph{interpreter}}, called \bbins, which allows to
177 load black box packages and to define and execute
178 processing chains by connecting various black boxes.
179 \item {\bf\emph{Various Development Utilities}} :
181 \item \bbfy generates the \CPP code of a black box from a
182 description file written in \texttt{xml}.
183 %\item \bbdoc generates the html documentation of a black box package
184 %(author, description, description of its black boxes :
185 %author, description, inputs, outputs, and so on).
186 \item \bbCreatePackage allows to create the basic file architecture
187 to start the development of a new black box package.
188 \item \texttt{bbs2cpp} translates a \texttt{.bbs} script into a \CPP file.
189 \item \texttt{bbc} that
191 \item A full {\bf\emph{documentation}} printable (pdf), browsable (html), queryable thru keywords.
194 The general architecture of \BBTK
195 is shown in figure \ref{bb-architecture}.
198 \caption{\label{bb-architecture}\BBTK architecture}
200 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
206 % ==========================================
207 \section{Getting started with bbStudio}
208 % ==========================================
210 % ==========================================
211 % ==========================================
212 % ==========================================
213 % ==========================================
214 % ==========================================
215 % ==========================================
217 % ==========================================
218 \subsection{The interface}
219 % ==========================================
222 %\vspace{0.5cm}\hrule
223 %\section{The Development environment (bbStudio)}
226 Just run it, typing in a console \bbStudio
227 or clicking on its icon or its menu entry.
228 At start, \bbStudio opens with a very minimal 'How to use' in the middle. \\
229 Don't forget to read it : it will vanish at the first mouse click. \\
231 1) Click on the 'Demo' or 'Examples' link.
232 2) Select a Demo or an Example
233 3) Click on the [Source] link : the source file is loaded in bbStudio
234 4) Click on the 'Run button' (the down arrow at the bottom right
238 You'll get something like in figure
239 \ref{bbi-fig-bbStudio-gui-start}
240 (the exact appearance of \bbStudio is Operating System and \bbtk version dependent)
246 \caption{\label{bbi-fig-bbStudio-gui-start}The bbStudio Development environment interface at start time}
248 \includegraphics[width=0.7\textwidth]{bbStudioMainPageStart.png}
253 Feel free to resize any part you want.
254 Your preferences will be kept next time you run again \bbStudio. \\
256 Let's have a look at the resized window :
259 \caption{\label{bbi-fig-bbStudio-gui}The bbStudio Development environment interface}
261 \includegraphics[width=0.7\textwidth]{bbStudioMainPage.png}
265 You can see four parts : \texttt{Files}, \texttt{Messages},
266 \texttt{Command}, \texttt{Help}.\\
268 The stuff is written using the Advanced User Interface library of wxWidgets,
269 whose 'docking manager' allows windows and toolbars to be floated/docked
271 Please don't use this feature at learning time (the snapshots of this document
272 wouldn't match with your screen ...)
274 \subsubsection{'Files' part}
275 \label{bbi-FilesPart}
277 It's the .bbs script editor.\\
278 If you load a file holding a script, it will be displayed here, and you'll be
279 able to modify it, to save it, to save-as it, to run it, using the
280 lower toolbar (see figure : \ref{lowertoolbar})
283 \caption{\label{lowertoolbar}The lower tool bar}
285 \includegraphics[width=0.7\textwidth]{lowertoolbar.png}
291 \item {\bf\emph{New file}} : Create a new file to hold a script
292 \item {\bf\emph{Open file}} : Open an already existing file holding a script
293 \item {\bf\emph{Close file}} : Close a file holding a script
294 \item {\bf\emph{Save file}} : Save he current file (if modified)
295 \item {\bf\emph{Save file as}} : Save he current file under a different name
296 \item {\bf\emph{Run file}} : Execute the script you just loaded/modified/written
297 \item {\bf\emph{cursor position}} : column number : line number
301 \subsubsection{'Messages' part}
302 \label{bbi-MessagesPart}
304 Two kinds of messages will be output here:\\
305 System messages : produced by the kernel, in case of a user mistyping, or an execution error\\
306 Script messages : produced by the \bbtk equivalent of \texttt{printf}
307 or \texttt{std::cout} in user programs
309 \subsubsection{'Command' part}
310 \label{bbi-CommandPart}
312 This is where user will type his requirements.
314 \subsubsection{'Help Contents' part}
315 \label{bbi-HelpContentsPart}
317 The 'Help Contents' part of \bbStudio is used to browse the html help of \BBTK.
318 All the entries of the starting page are self-explanatory :
320 \item {\bf\emph{Help Contents}}
322 %\item {\bf\emph{Wiki}} : Direct link to the bbtk Wiki (intranet only, right now, www
324 \item {\bf\emph{Demo}} : Link to some 'sophisticated' demonstrations.
325 \item {\bf\emph{Examples}} : Link to some detailed 'How to use' examples
328 \item {\bf\emph{Guides}}
330 \item {\bf\emph{User's Guide}} : Step to step How-to for user who wants to create his own
331 application, just using already existing boxes.
332 \item {\bf\emph{Package Developper's Guide}} : Step to step How-to for user who wants to create his own
334 \item {\bf\emph{Developper's Guide}} : For bbtk kernel developpers. Sorry, not yet written.
335 \item {\bf\emph{Reference Manual}} : Sorry, not yet written.
336 \item {\bf\emph{Booklet}} : Vade mecum. Sorry, not yet written.
337 \item {\bf\emph{Doxygen Documentation}} : Doxygen source browser.
340 \item {\bf\emph{Boxes}} : Box retrieving on various criterions :
342 \item {\bf\emph{ \texttt{By name}}} (Alphabetical list),
343 \item {\bf\emph{ \texttt{By package}}},
344 \item {\bf\emph{ \texttt{By category}}}.
347 A special hidden Box category, called \texttt{{Adaptors}} exists. \\
348 They are used internaly to perform type conversions. Thought there are not end user intended, an aware user may query them.
354 % ==========================================
359 % ==========================================
360 % ==========================================
361 % ==========================================
362 % ==========================================
363 % ==========================================
368 % ==========================================
372 % ==============================================
373 \subsection{Running Demo and Examples}
374 % ==============================================
376 Run \bbStudio the way you need. \\
377 In the part 'Help contents' (See figure \ref{HelpContents}), select \texttt{Examples} link.
380 \caption{\label{HelpContents}Help Contents}
382 \includegraphics[width=0.7\textwidth]{HelpContents.png}
388 You will be asked to select a Box category (See figure \ref{BoxCategories}); \\
389 Select \texttt{example}.
393 \caption{\label{BoxCategories}Box Categories}
395 \includegraphics[width=0.7\textwidth]{BoxCategories.png}
399 You will be asked to choose a script (See figure \ref{example}).
402 \caption{\label{example}example list}
404 \includegraphics[width=0.7\textwidth]{example.png}
410 Select \texttt{wx::exampleSlider} (See figure \ref{exampleSlider});
413 \caption{\label{exampleSlider}example 'exampleSlider'}
415 \includegraphics[width=0.7\textwidth]{exampleSlider.png}
419 You can see the graphical summary representation of the current script (the elementary boxes that compose it, and their
421 Click on \texttt{source}, and you'll be able to see the (very simple) script,
422 in the 'Files' part, within the script editor (See figure \ref{exampleSliderSource});
425 \caption{\label{exampleSliderSource}source code of 'exampleSlider'}
427 \includegraphics[width=0.7\textwidth]{exampleSliderSource.png}
431 Run it, using the lower toolbar (see figure : \ref{lowertoolbar})
433 You'll get something like in figure \ref{execSliderSource}.
436 \caption{\label{execSliderSource}execution of 'exampleSlider'}
438 \includegraphics[width=0.7\textwidth]{execSliderSource.png}
442 Feel free to move the slider, to check it actually works...
446 Just a few words on what you saw :
448 \item{in the File part} \\
449 The source code of the script
452 set slider.ReactiveOnTrack 1
454 We create a \texttt{Slider} called \emph{slider}\\
455 We tell it to inform anybody that's interested in, that the cursor moved, each time it moved. \\
456 The standard behaviour is to inform, only when cursor is released.
460 We create a \texttt{OutputText} called \emph{text}
461 (in which slider value will be displayed)
464 new LayoutLine layout
466 We create a \texttt{LayoutLine} called \emph{layout},
467 a \emph{container} widget, designed to embed other wigets (say, a main window)
469 connect slider.Widget layout.Widget1
470 connect text.Widget layout.Widget2
472 We embed \emph{slider} and \emph{text} into \emph{layout}.
474 connect slider.BoxChange text.BoxExecute
475 connect slider.Out text.In
477 We tell \emph{slider} to inform \emph{text} every time it's modified.\\
478 We tell \emph{slider} to pass its output value (\texttt{Out} to \emph{text} input value (\texttt{In})
482 We tell \emph{layout} to process itself (it will do it only if it's warned
483 that one of its entries was modified since its (own) last processing.
485 \item{in the Help part}
487 You can see the graphical representation of the script, as in figure \ref{SmallGraph}.
491 \caption{\label{SmallGraph}Graphical representation of a script}
493 \includegraphics[width=0.7\textwidth]{SmallGraph.png}
497 Both graphical pipe line (\emph{slider} and \emph{text} are embedded into \emph{layout})
498 and processing pipe line (\emph{slider} warns \emph{text} immedialtely when it's modified, \emph{slider} passed \emph{text} its new value).\\
499 Yes, we know : all the arrows (pipe line arrows and processing arrows) are blue; we are sorry about that...\\
501 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
502 figure \ref{LargeGraph}.
505 \caption{\label{LargeGraph}Detailled graphical representation of a script}
507 \includegraphics[width=0.75\textwidth]{LargeGraph.png}
514 % ==============================================
515 \subsection{Online Help}
516 % ==============================================
518 Various levels or help are suplied by \bbStudions.
520 % ==========================================
521 \subsubsection{Command line help}
522 % ==========================================
525 The 'working' area (the left one, as opposed to the 'help' area, on the right side) is composed of :
526 one single line zone (Command), at the bottom in which you can enter your commands and
527 a multiple line zone in which the Command interpreter prints out the result of your commands.
528 The upper part contains the script editor; we shall not use it right now, you may reduce it
530 Try typing in the \texttt{Command} area (in this manual,
531 the commands entered by the user will be preceded by a prompt \textgreater) :
536 you get the list of the commands of the interpreter :
569 To get help on a particular command type \texttt{help <command-name>},
577 usage : author <string>
578 Adds the string <string> to the author information of the black box being defined
581 The \texttt{help} command has multiple usages.
582 It is used to get help about almost anything in the interpretor!
583 Type \texttt{'help help'} to get help on the \texttt{help} command itself :
588 (2) help <command name>
589 (3) help packages [all]
590 (4) help <package name> [all]
591 (5) help <black box type>
592 (6) help <black box name>
594 (1) Lists all available commands;
595 (2) Prints help on a particular command;
596 (3) Lists the packages loaded and their black boxes.
597 Add 'all' to list adaptors;
598 (4) Prints short help on the black boxes of a package.
599 Add 'all' to include adaptors;
600 (5) Prints full help on a black box type;
601 (6) Prints information on the inputs, outputs and connectionns
602 of a black box instance.
605 At start the interpretor does not know any black box.
606 If you type \texttt{'help packages'}, which is
607 the third form of the \texttt{help} command, you get :
614 which means that the interpretor only knows one package
615 (library of black boxes) called \texttt{user}
616 and which contains a black box called \texttt{workspace}.
617 The \texttt{user} package is an internal package of the interpreter,
618 which stores user-defined black box types.
619 At start, it already contains
620 one box, called \texttt{workspace}.
621 \texttt{workspace} is a special type of black box,
622 called complex black box, whose purpose is
623 to store other black boxes.
624 Any black box you create in \bbStudio is stored
625 in \texttt{workspace}
626 (this will be explained in details in sections
627 \ref{bbi-writing-scripts} and
628 \ref{bbi-more-on-complex-black-boxes}).
630 If you type \texttt{'help workspace'}, you get :
633 Complex Black Box <user::workspace>
636 Category(s) : complex box;
642 In the text displayed,
643 the \texttt{user::} prepended to the name \texttt{workspace}
644 means that the box \texttt{workspace}
645 belongs to the \texttt{user} package.
646 Then comes a description and three lines which
647 tell that \texttt{workspace} does not have any input
648 nor output nor boxes yet.
650 In order to let the interpreter know of some black boxes,
651 you must load another package.
652 The \texttt{std} package is the ``standard'' package,
653 which contains basic useful black boxes.
665 you get something like :
670 ASCII : ascii codes sequence to string - string to ascii...
671 Add : Adds its inputs
672 ConcatStrings : String concatenation
673 Configuration : Gets configuration informations
674 Div : Divides its inputs
675 ExecBbiCommand : Executes bbi commands
676 ExecSystemCommand : Executes system (O.S.) commands
677 GetVectorCharElement : Gets the i-th element from the input vector (std...
679 MagicBox : Takes *any kind* of data and copies it to its ou...
680 MakeFileName : Makes a kosher file name
681 Mul : Multiplies its inputs
682 MultipleInputs : This box has multiple Void inputs and one Void o...
683 StringRelay : Just copies the value of its input to its output...
684 StringSelect : Outputs the string set to the ith input Ini (In0...
689 Now the interpreter knows the package \texttt{std} and the black boxes it provides,
690 such as the \texttt{'Add'} box, the \texttt{'ConcatStrings'} box, and so on. Remark that the
691 content of \texttt{std} may vary from one version to another
692 as new black boxes might be added to it.
698 You'll get a text help, in the 'Message' part :
700 Black Box <std::Add>S
702 By : laurent.guigues@creatis.insa-lyon.fr
703 Categories : atomic box;math;
705 'BoxExecute' <bbtk::Void> [signal] : Any signal received by this input
707 'BoxProcessMode' <String> [] : Sets the processing mode of the box
708 (Pipeline | Always | Reactive)
709 'In1' <Double> [] : First number to add
710 'In2' <Double> [] : Second number to add
712 'BoxChange' <bbtk::VoidS> [signal] : Signals modifications of the box
713 'Out' <Double> [] : Result
716 More information about what is a 'box' will be given in the 'Scriptting' part of this manual.
718 % ==========================================
719 \subsubsection{Guides}
720 % ==========================================
722 An html version of all the guides is browsable in the \texttt{Help} part of \bbStudions.
724 \item {\bf\emph{User's Guide}} : Step to step How-to for user who wants to create his own
725 application, just using already existing boxes.
726 \item {\bf\emph{Package Developper's Guide}} : Step to step How-to for programmer who wants to create his own
727 black boxes/packages.
728 \item {\bf\emph{Developper's Guide}} : For bbtk kernel developpers only. (This one is probabely not very much
729 up-to-date, since we spend more time in developping than writing documentation that's not of user concern).
730 \item {\bf\emph{Reference Manual}} : Contains a exaustive description of all the features for all the commands.
731 \item {\bf\emph{Booklet}} : Vade mecum.
732 \item {\bf\emph{Doxygen Documentation}} : Doxygen source browser.\\ Automatically generated from source file
733 headers. Should concern only the kernel developpers (i.e. : us).
738 % ==========================================
739 \subsubsection{Boxes Help}
740 % ==========================================
741 Box retrieving on various criteria :
743 \item {\bf\emph{Alphabetical list}} \\ This is the 'zero-level' of retrieving.
744 \item {\bf\emph{List by package}} \\ Several packages are supplied with bbtk :
746 \item {\bf\emph{std}} : the 'standard' package including basic useful boxes.
747 \item {\bf\emph{wx}} : basic graphical interface elements (widgets : sliders, buttons, etc. based on the \texttt{wxWidgets} library).
748 \item {\bf\emph{itk}} : the basic image processing package, based on the \itk library.
749 \item {\bf\emph{vtk}} : the basic images and surfaces processing and vizualization package, based on the \vtk library.
750 \item {\bf\emph{wxvtk}} : widget boxes based on the \vtk library (2D and 3D vizualization and
752 %\item {\bf\emph{creaImageIO}} : Provides hight level widgets to read images, including DICOM.
753 \item {\bf\emph{toolsbbtk}} : Tools for bbtk administration and package development, such as :
755 \item{GUICreateBlackBox} For creating the XML or C++ code for a new black box
756 \item{GUICreatePackage} For creating a new bbtk package file structure on disk (Graphical user interface for the shell script bbCreatePackage)
757 \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.
760 \item {\bf\emph{List by category}}.
763 A given box may belong to more than one \texttt{category}.\\
764 You have to consider categories like keywords to index black boxes.\\
765 Some of them are mutually exclusive.
768 \item{atomic box / complex box}\\
769 Whether it's written is C++ or it's an assembly of several black boxes (atomic or complex).\\
770 Any box is either atomic ou complex.
771 \item{example / demo / application}\\
772 Theese ones are always complex black boxes.
775 It's just a (simple) example on how to use a given feature.
777 It can be a 'good looking' (a.k.a 'sexy') example on some sophisticated work.
779 It's a Final application, end user intended (e.g. Subscale a huge volume, Crop a DICOM image, etc)
782 Piece of graphical interface (based on \texttt{wxWidgets})
784 Dicom medical image related box.
788 \item{3D Object creator}
794 % ==============================================
795 \subsection{The Menu}
796 % ==============================================
800 % ==========================================
801 \section{bbs scripting}
802 % ==========================================
804 % ==========================================
805 \subsection{Using an already existing}
806 % ==========================================
808 % ==========================================
809 \subsection{Creating and executing black boxes}
810 % ==========================================
812 You'll get as well the same information in the 'Help' Part, in html format (see figure : \ref{HelpAdd}) :
815 \caption{\label{HelpAdd}The html Help}
817 \includegraphics[width=0.7\textwidth]{HelpAdd.png}
822 the \texttt{std::} prepended to the name \texttt{Add}
823 means that the box \texttt{Add}
824 belongs to the \texttt{std} package.
825 Then comes a description
826 (the one which was provided by the author of the box),
827 the author(s) of the box (usually e-mail adress(es)) and
828 the categories to which the box belongs.
829 Finally comes the lists of inputs and outputs of the box.
830 For each input or output, \bbi provides
831 its \emph{name} (between quotes, e.g. \texttt{'ProcessMode'}),
832 its \emph{type} (between \texttt{<} and \texttt{>}, e.g. \texttt{<Int>})
834 Remark that the box \texttt{Add} is not a 'complex' black box
835 but an 'atomic' box, hence its help does not
836 mention any information concerning possible internal boxes.
838 You can create an \emph{instance} of an \texttt{Add} box by
839 the command \texttt{new} :
844 The \texttt{'a'} at the end is the \emph{name} of the instance,
845 which will be used to reference it later.
846 It is important to distinguish a box \emph{type}
847 and an \emph{instance} of a box type.
848 The \texttt{Add} box of the package \texttt{std} is actually
849 a \emph{box type} , like \texttt{int} is a data type
850 in \texttt{C} langage. The \texttt{new} command allows to create
851 an instance of a box type, exactly like \texttt{int i;} in
852 a \texttt{C} code, it declares a variable of type \texttt{int} whose
854 Of course, like in \texttt{C} Language, you can declare multiple boxes of the
857 After the creation of the box \texttt{a}, type :
864 Complex Black Box <user::workspace>
867 Category(s) : complex box;
874 which means that \bbi workspace now contains a black box named \texttt{a},
875 of type \texttt{std::Add}.
877 Now look back at the help on \texttt{Add} boxes :
878 you can see that this type of box has two inputs,
879 with name \texttt{In1} and \texttt{In2},
880 and an output, with name \texttt{Out}.
882 You can set the input \texttt{In1}
883 of the \texttt{Add} box \texttt{a} to the value $1$
889 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $2$
895 And you print the output \texttt{Out} of the box \texttt{a} with :
897 > print "result=$a.Out$"
901 In the string passed to the \texttt{print} command,
902 each substring enclosed between a couple of \$ is considered
903 as the name of an output of a box.
904 To process this special substrings, the interpretor :
906 \item Processes the box if needed (see below)
907 \item Converts the output of the box to a string if possible
909 \item Substitutes the result in the string to print
910 \item Postpones an implicit 'new line' character to the string
915 Box processing is needed if :
918 \item either at least input has changed since last processing
919 \item or the input \texttt{'BoxProcessMode'} of the box is set to
920 \texttt{'Always'}, which forces box reprocessing.
923 Note that all boxes have an input named \texttt{'BoxProcessMode'}.
925 Another way to process the box \texttt{a} is to issue the command :
930 however this command does not display anything (except if the
931 box itself displays something in its processing).
932 It just processes the box if needed.
933 This command is used to execute boxes that do not have any output,
934 such as boxes that write something to a file or, display a
935 graphical interface, and so on.
937 %To exit \bbi, type :
943 % ==========================================
949 \item The \texttt{include} command allows to load a package, and the complex black boxes that come with it..
950 \item \texttt{help} gives help on :
952 \item Available commands if you just type \texttt{help}.
953 \item A particular command if you type \texttt{help <command-name>}.
954 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
955 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
956 \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}).
958 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
959 \item \texttt{new} : creates an instance of a black box.
960 \item \texttt{set} : sets the value of an input of a black box.
961 \item Under any component of \bbStudions, to reference the input called \texttt{i}
962 of a black box called \texttt{b} you must type \texttt{'b.i'}.
963 The same syntax holds for outputs.
964 \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
965 implicit trailing 'new line character' is added at the final string.
966 \item \texttt{exec} : runs, if needed, the process of a box.
967 %\item \texttt{quit} : quits \bbi.
972 %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.
973 %Wou'll get something like in figure \ref{bbCommandPlusHelp} :
976 %\caption{\label{bbCommandPlusHelp}
977 %An other way to run the command interpreter}
979 %\includegraphics[width=0.5\textwidth]{bbCommandPlusHelp.png}
983 % ==========================================
985 % ==========================================
986 \subsubsection{Connecting black boxes}
987 \label{bbi-connecting-black-boxes}
988 % ==========================================
990 \BBTK allows to create
991 and execute processing chains,
992 also called \emph{pipelines},
993 by connecting black boxes.
994 This section explains how to do it with examples.
995 Read section \ref{bbi-more-on-pipeline-processing} to get
996 more information on pipeline processing.
998 First start \bbStudio and load the package \texttt{std}, typing :
1002 in the 'Command' part.
1004 Assume you want to compute $1+2+3$. You can do it by
1005 chaining two \texttt{Add} boxes, as shown in figure
1006 \ref{bbi-fig-connecting-black-boxes-1}.
1009 \caption{\label{bbi-fig-connecting-black-boxes-1} A simple pipeline which adds 3 numbers}
1011 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
1016 The \bbi instructions to create and execute this pipeline are :
1020 > connect a.Out b.In1
1027 You will see the (very expected) result :
1032 The first three commands build the pipeline,
1033 the next three set \texttt{a} and \texttt{b} black boxes inputs and the last one
1034 prints \texttt{b} black boxe output (the pipeline is executed before printing, because the interpretor 'knows' the box \texttt{b},
1035 whose output is requested, is not up to date.
1037 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output
1038 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the
1040 Once the boxes connected, the processing of the two boxes are chained :
1041 getting the output of \texttt{b} requires getting its inputs,
1042 hence getting the output of \texttt{a} which is connected to it.
1043 This pipeline mechanism can recurse into arbitrary long
1044 chains of boxes (see \ref{bbi-more-on-pipeline-processing}
1048 Lets' consider an other, more image oriented, example :
1056 > new FileSelector fileDialog
1057 > new ImageReader reader
1059 > new Viewer2D viewer
1061 > connect fileDialog.Out reader.In
1062 > connect reader.Out viewer.In
1063 > connect slider.Out viewer.Slice
1064 > connect slider.BoxChange viewer.BoxExecute
1069 Some explainations : the \texttt{include} instructions load the necessary packages. \\
1071 \texttt{new FileSelector} will pop a File Selector, at run time, that will out the user chosen file name. \\
1072 \texttt{new Slider} will pop a Slider, at run time, that will out an integer, used later as a slice number.\\
1073 \texttt{new ImageReader} will read any itk readable file, whose name is passed as a std::string, and return a itk::ImagePointer.\\
1074 \texttt{new Viewer2D} display a plane, whose number id specified by an integer.\\
1076 \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).\\
1077 \texttt{connect reader.Out viewer.In} plugs the output of the reader (an itk::ImagePointer) to the input of the Viewer (a vtkImageData *)\\
1078 \texttt{connect slider.Out viewer.Slice} plugs the output of the slider (an int) to an other output (named Slide) of the viewer.\\
1079 \texttt{connect slider.BoxChange viewer.BoxExecute} says the viewer it must re process itself any time the slider is modified.\\
1081 \texttt{exec viewer} processes the viewer.
1084 This would correspond to the graph in figure \ref{bbi-simplegraph}
1088 \caption{\label{bbi-simplegraph}(Very) simple Graph of a (very) simple pipeline}
1090 \includegraphics[width=0.8\textwidth]{bbi-simplegraph.png}
1094 Of course, to be able to connect two boxes,
1095 the output and the input must be compatibles.
1096 You can always connect an output to an input of the \emph{same} type,
1097 but you can do more, thanks to particular (hidden) black boxes called {\bf adaptors}.
1099 An adaptor is a black box which has at least one input, called \texttt{In},
1100 and at least one ouput called \texttt{Out} and whose role is to convert
1101 a data of the type of \texttt{In}
1102 into a data of the type of \texttt{Out} (other inputs or outputs may serve
1103 to parameter the adaptor or retreive other usefull information).
1105 Under \bbStudions, if you type :
1112 Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
1113 Basic useful black boxes
1116 BoolToString [DA] : Converts a Bool (bool) into a string
1117 CastBoolToChar [DA] : Static cast from Bool (bool) to Char (signed c...
1118 CastBoolToDouble [DA] : Static cast from Bool (bool) to Double (double...
1120 CastBoolToUChar [DA] : Static cast from Bool (bool) to UChar (unsigne...
1121 CastBoolToUInt [DA] : Static cast from Bool (bool) to UInt (unsigned...
1123 CastUIntToBool [DA] : Static cast from UInt (unsigned int) to Bool (...
1124 CastUIntToChar [DA] : Static cast from UInt (unsigned int) to Char (...
1125 CastUIntToDouble [DA] : Static cast from UInt (unsigned int) to Double...
1130 \texttt{[DA]} stands for \emph{default adaptor}.
1132 Once you have loaded the package \texttt{std}, you can
1133 plug an output of type \texttt{char} into an input of type \texttt{double}.
1134 When the interpreter encounters the \texttt{connect} command,
1135 it looks for an adequate \emph{adaptor} in the loaded packages.
1136 In our case, as the package \texttt{std} provides the
1137 \texttt{CastUCharToDouble} adaptor, the interpreter automatically creates an
1138 instance of this adaptor and place it \emph{between}
1139 the output and the input you want to connect
1140 (however this adaptor is hidden to you,
1141 it is embedded into the created connection and does not appear
1142 as an existing black box).
1143 When the pipeline is processed the
1144 adaptor converts the output data into the required input type,
1145 in a totally transparent way.
1146 In our example, the \texttt{CastUCharToDouble} adaptor
1147 would simply cast the value of the \texttt{char} into a \texttt{double},
1148 however arbitrarily complex type conversion may be done.
1151 %Question (for info-dev):
1152 %if two adaptors with the same input and output types exist
1153 %in two different packages, currenly loaded,
1154 %which one is chosen by the interpreter at connection time?
1155 %A feature is missing to specify explicitely which one user wants to choose
1156 %(use a namespace notation ?)
1158 %-> Role of default adaptors
1161 Note that the \texttt{set} and \texttt{print} commands of interpreter
1162 work with adaptors from \texttt{string} to the type of the input to set
1163 or from the type of the output to print to \texttt{string}.
1164 Hence in order to \texttt{set} or \texttt{print} values the adequate
1165 adaptors must be available in the packages currently loaded. \\
1168 % ==========================================
1173 \item The \texttt{connect} command allows to connect two black boxes
1174 \item You can connect two black boxes if (and only if) :
1176 \item The output and the input are of the same type, or
1177 \item There is an adaptor black box in the packages loaded which
1178 converts data of the output type into data of the input type
1180 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use : \texttt{help <package name> all}.
1184 % ==========================================
1186 % ==========================================
1187 \subsubsection{Creating complex black boxes}
1188 \label{bbi-complex-black-boxes}
1189 % ==========================================
1191 Remember the pipeline of figure
1192 \ref{bbi-fig-connecting-black-boxes-1}, which
1193 computed the sum of three doubles?
1194 You can consider it as a whole and define
1195 a new black box type, which will be a \emph{complex black box},
1196 having three inputs and one output,
1197 as shown in figure \ref{bbi-fig-complex-black-box-1}.
1200 \caption{\label{bbi-fig-complex-black-box-1} Creating the complex black box \texttt{Add3}}
1202 \includegraphics[width=0.5\textwidth]{Add3.png}
1206 The \bbi commands to define this complex black box are
1216 > connect a.Out b.In1
1219 > description "adds 3 doubles"
1220 > input x a.In1 "first double to add"
1221 > input y a.In2 "second double to add"
1222 > input z b.In2 "third double to add"
1223 > output result b.Out "output"
1230 As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in first line.
1232 The command \texttt{define} then starts the definition
1233 of the complex box type, which will be called \texttt{Add3}.
1235 The next three lines define the pipeline,
1236 exactly in the same way than outside a complex box definition.
1238 The commands \texttt{author}, \texttt{description}, \texttt{input}
1239 and \texttt{output} are commands specific to complex boxes definition :
1241 \texttt{author} and \texttt{description} are used for the documentation
1242 of the new box. You can provide multiple \texttt{author} or
1243 \texttt{description} commands, the arguments of the commands will
1244 be concatenated to produce the final author and description strings.
1246 \texttt{input} and \texttt{output} are used to define the inputs and outputs
1247 of the new complex box.
1248 Their syntax is the same : for each new input/output you need to say
1249 to which internal input/output it corresponds and to provide
1250 a help string documenting the input/output.
1251 In our example, we define that the box \texttt{Add3} has
1252 three inputs : \texttt{x}, \texttt{y} and \texttt{z}.
1253 The input \texttt{x} corresponds to the input \texttt{In1} of the
1254 internal box \texttt{a}.
1255 In the same way, the external input \texttt{y}
1256 corresponds to the internal input \texttt{a.In2}, and
1257 the external input \texttt{In3} to \texttt{b.In2}.
1258 The only output of the new box is called \texttt{result}
1259 and corresponds to \texttt{b.Out}.
1260 The figure \ref{bbi-fig-complex-black-box-1}
1261 illustrates the external to internal
1262 input/output correspondence.
1264 Finally, the \texttt{endefine} command ends the definition of the
1267 After this definition, if you ask for help
1268 on packages, you get :
1279 The \texttt{user} package now contains a new black box type, called
1280 \texttt{Add3}. If you ask for help on this type of box, you get :
1283 Complex Black Box <user::Add3>
1287 'x' <double> : first double to add
1288 'y' <double> : second double to add
1289 'z' <double> : third double to add
1291 'result' <double> : output
1297 and you can use it like any other box, for example type :
1309 As a side note, we can say that, for consistency reasons, it would have been better to name
1310 \texttt{In1}, \texttt{In2} and \texttt{In3} the inputs of the black box \texttt{Add3},
1311 since all the 'natural entry' of a box is named \texttt{In}, or \texttt{In}\emph{x} if there are more than one 'natural
1314 % ==========================================
1319 \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.
1320 Inside a \texttt{define/endefine} block :
1322 \item The \texttt{author} and \texttt{description} commands allow to document the new type of box
1323 \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
1324 of internal boxes they correspond.
1328 % ==========================================
1330 % ==========================================
1331 \subsubsection{Writing scripts}
1332 \label{bbi-writing-scripts}
1333 % ==========================================
1335 Once you have defined a new type of complex box, you
1336 may like to reuse it. To do this, you can simply
1337 write the \bbi commands defining the new box
1338 into a text file and afterwards include that file in \bbi.
1339 Doing this, you start writing \bbi scripts.
1340 The conventionnal (and mandatory) extension for such scripts is \texttt{bbs}
1342 For consistency reasons, you are requested to prepend \texttt{bb} to the name.
1344 For example, the \texttt{Add3} complex box we previously worked on
1345 can be defined in the \texttt{bbAdd3.bbs} file :
1347 \begin{file}{bbAdd3.bbs}
1349 # Defines the Add3 black box which adds 3 doubles
1355 description "adds 3 doubles"
1361 input x a.In1 "first double to add
1362 input y a.In2 "second double to add
1363 input z b.In2 "third double to add"
1365 output result b.Out "output"
1370 Lines starting with a \texttt{\#} character or a \texttt{\//\//} character are ignored, they
1371 are considered as comments by the interpreter.
1372 To use this file in \bbStudions, click on the \texttt{include} button, and browse your filestore to find the file.
1375 > include bbAdd3.bbs
1377 Complex Black Box <user::Add3>
1381 'x' <double> : first double to add
1382 'y' <double> : second double to add
1383 'z' <double> : third double to add
1385 'result' <double> : output
1393 If the file has the \texttt{bbs} extension, you can ommit it and just type :
1398 \subsubsection{Creating complex black boxes that use complex black boxes}
1399 \label{bbi-complex-complex-black-boxes}
1402 Of course, you can include script files in other script files,
1403 like in the following example :
1405 \begin{file}{bbAdd4.bbs}
1407 # Defines the Add4 black box which adds 4 doubles
1412 description "adds 4 doubles"
1416 input In1 a.In1 "first double to add
1417 input In2 a.In2 "second double to add
1418 input In3 a.In3 "third double to add"
1419 input In4 b.In2 "fourth double to add"
1420 output Out b.Out "output"
1427 \subsubsection{Naming Conventions}
1428 \label{bbi-Naming Conventions}
1431 % ==========================================
1433 %\paragraph{Naming Conventions}
1437 % ==========================================
1441 For consistency reasons, you are requested to prepend \texttt{bb}, and postpone an extention \texttt{.bbs},
1442 to the names of the files that hold a \texttt{complex black box} definition.
1444 For example, the \texttt{Add3} complex box we previously worked on
1445 can be defined in the \texttt{bbAdd3.bbs} file.
1448 For consistency reasons, the names of dynamic libraries holding the packages must start by \texttt{libbb}.
1449 For instance, the package \texttt{wx} will be in the library \texttt{libbbwx.dll} (Windows) or \texttt{libbbwx.so}
1454 % ==========================================
1460 \item The \texttt{include} command tells the interpreter to include a script file.
1461 \item Lines starting with a \texttt{\#} or with a \texttt{\//\//} are considered as comments by the interpreter.
1462 \item Lines between a line starting with a \texttt{\//*} an a line starting with a \texttt{*\//} are considered as comments by the interpreter.
1466 % ==========================================
1468 % ==========================================
1469 \subsubsection{Creating command line applications}
1470 \label{bbi-command-line-app}
1471 % ==========================================
1473 Now that you know how to create complex black boxes
1474 (with \texttt{define/endefine}), think
1475 back to the \texttt{workspace} object.
1476 Remember that it is also
1477 a \texttt{complex black box}.
1478 Actually, when you type interpreter commands
1479 outside a \texttt{define/endefine} block,
1480 you progressively define the \texttt{workspace}
1482 You can think of it like if at start the interpreter
1483 was issuing a command \texttt{'define workspace'}
1484 and then letting you define the interior of the box
1487 Remember that the command \texttt{inputs}
1488 allows to define an input of a complex box.
1489 Now, if you use the command \texttt{input}
1490 outside a \texttt{define/endefine} block then
1491 it defines an input of the \texttt{workspace} box,
1492 that is an input of the \emph{main program}.
1493 This input will then be connected to the
1494 parameters that the user passes to the command line.
1496 For example, consider the script :
1498 \begin{file}{add.bbs}
1502 input x a.In1 "first number to add"
1503 input y a.In2 "second number to add"
1508 The third and fourth lines define two inputs \texttt{x}
1509 and \texttt{y}. When you execute this script,
1510 you can pass these two arguments on the command line,
1518 You can also invoke \bbi the option \texttt{-h},
1519 which gives help on the \texttt{workspace} box :
1526 'x' <double> : first number to add
1527 'y' <double> : second number to add
1530 To get a better help, use the \texttt{description}
1531 and \texttt{author} commands :
1533 \begin{file}{add.bbs}
1535 description "Adds two numbers"
1536 author "foo@bar.com"
1539 input x a.In1 "first number to add"
1540 input y a.In2 "second number to add"
1545 Now if you ask for help on the \texttt{add} script, you get :
1552 'x' <double> : first number to add
1553 'y' <double> : second number to add
1556 Rather than getting the inputs of a script
1557 from the command line, you can ask \bbi to
1558 prompt the user for the values, using the \texttt{-t}
1563 x=[the program waits for user answer]2
1564 y=[the program waits for user answer]5
1568 \bbStudio is always compiled in graphical mode (with \wx), therefore
1569 you can also use the \texttt{-g} commutator.
1570 \bbi then prompts the user in graphical mode,
1571 displaying a dialog box for each input,
1572 like in fig. \ref{bb-input-dialog-box}.
1575 \caption{\label{bb-input-dialog-box}Input dialog box}
1577 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1581 % ==========================================
1586 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1587 when they are used outside a \texttt{define/endefine} block allow
1588 to define the inputs, description and author of the main program.
1589 \item Inputs of the main program can be passed on the command line
1590 using the syntax \texttt{<input-name>=<value>}.
1591 No white space is allowed, if the value or the input name
1592 contains white spaces, enclose them
1593 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1594 \item The \texttt{-h} option of \bbi prints help on the main program.
1595 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1596 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1599 % ==========================================
1601 % ==========================================
1602 \subsubsection{Using graphical interface boxes (widget boxes)}
1604 % ==========================================
1606 % ==========================================
1607 \subsubsection{Overwiew}
1608 \label{bbi-overview}
1609 % ==========================================
1611 \bbStudio is always compiled in graphical mode
1612 (option \texttt{BUILD\_bbi\_GRAPHICAL} of \cmakens, requires \wxns),
1613 then you can use special black boxes which are
1614 graphical interface components (widgets).
1615 Basic components are provided in the package \texttt{wx},
1616 such as buttons, sliders, file open/save dialogs, etc.
1618 As first example, type the following commands in \bbi :
1625 When you type \texttt{enter} after the last line,
1626 a window pops up in which you can entrer a text.
1627 When you close the window, the text you entered is printed by
1628 the \texttt{print} command.
1630 Type \texttt{help wx}, you get something like :
1632 Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1633 Basic graphical interface elements (sliders, buttons ...) based on wxWidgets
1635 ColourSelector : Colour Selector dialog (bbfication of wxColourSele...
1636 ColourSelectorButton : A button which displays a colour picker dialog whe...
1637 CommandButton : Button which executes bbi commands
1638 DirectorySelector : Pops up a directory selection dialog (wxDirDialog)
1639 FileSelector : Pops up a file selection dialog for reading or sav...
1640 InputText : A zone in which the user can enter a text (wxTextC...
1641 LayoutLine : LayoutLine widget (wxBoxSizer)
1642 LayoutSplit : Widget which splits a window in two fixed size par...
1643 LayoutTab : LayoutTab widget (wxNotebook)
1644 OutputText : Text zone to be inserted into a window (wxStaticTe...
1645 RadioButton : RadioButton group widget 0-9 entries
1646 Slider : Slider widget (wxSlider)
1649 You can reproduce the same experiment as above using a
1650 \texttt{Slider} or a \texttt{FileDialog} rather than a \texttt{InputText}.
1651 See the files \texttt{test*.bbs} in the \texttt{scripts/test} directory.
1653 There are two kinds of widgets : ``terminal'' widgets and ``container'' widgets.
1654 The \texttt{InputText}, \texttt{FileDialog} or \texttt{Slider} widgets
1655 are ``terminal'' widgets.
1656 ``container'' widgets are of another kind : they are designed to
1657 contain other widgets in order to build larger dialog boxes.
1658 For example, the \texttt{LayoutSplit} widget is a container which
1659 ``splits'' horizontally a window into two parts,
1660 each part including another widget.
1661 The size of the two parts can be adjusted by the user thanks
1664 The script \texttt{scripts/test/testSplit.bbs} demonstrate its use.
1665 Run it : it displays a window with two sliders.
1666 Move the sliders and close the window.
1667 The final positions of the sliders are printed out.
1668 Now edit the file to see how this is done :
1670 \begin{file}{scripts/test/testSplit.bbs}
1679 connect s1.Widget s.Widget1
1680 connect s2.Widget s.Widget2
1682 print s1=$s1.Out$\\n
1683 print s2=$s2.Out$\\n
1687 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1688 A \texttt{LayoutSplit} box \texttt{s} is also created.
1689 The \texttt{connect} commands then ``includes'' the sliders in the
1690 split ``container''.
1691 The input \texttt{Widget} is common to all widget boxes :
1692 every widget can be inserted into another widget.
1693 The outputs \texttt{Widget1},\texttt{Widget2} are specific of \emph{container}
1695 (in \bbi type \texttt{help Slider} :
1696 you will see the output \texttt{Widget};
1697 type \texttt{help LayoutSplit} :
1698 you will see the inputs \texttt{Widget1} and \texttt{Widget2}
1699 and the output \texttt{Widget}).
1700 When you connect the \texttt{Widget} output of a container
1701 to the \texttt{Widget}i input of a widget,
1702 you order to include the widget in the container.
1703 Of course, the order of connection is important.
1704 In our case, the slider \texttt{s1} is included first,
1705 then the slider \texttt{s2} : \texttt{s1} will be placed
1706 on top of \texttt{s2} (the \texttt{LayoutSplit} box is
1707 implemented that way, but this is arbitrary choice).
1709 Right now, there are only \emph{three} container widgets in the \texttt{wx} package :
1711 \item {the \texttt{LayoutSplit} widget} we just described, the \texttt{LayoutLine} , and the \texttt{LayoutTab}
1714 \item {the \texttt{LayoutLine} widget} can have multiple children and
1715 divides its window into as much parts as children,
1716 each part of equal size.
1717 The orientation of the \texttt{LayoutSplit} or of the \texttt{LayoutLine} can be changed by the input \texttt{Orientation}.
1718 See the example \texttt{test/testSizer.bbs}.
1719 With only those two containers you can already create
1720 complex dialog boxes (of course containers can be nested, which leads to tree-like structures of widgets).
1721 See the script \texttt{bbtk/share/bbtk/bbs/wx/appli/ExampleLayoutSplit.bbs} for an example.
1723 \item {The \texttt{LayoutTab} widget} is based on the \texttt{wxNotebook.}\\
1724 The label of each 'note book' is the name of the object it contains.
1731 %One word about a special widget in the package \texttt{wx} :
1732 %the \texttt{Button}... to be continued.
1734 % ==========================================
1735 \subsubsection{Deeper in the boxes}
1736 \label{bbi-deep-box}
1737 % ==========================================
1739 Any widget box has two mandatory Inputs :
1741 \item {\bf\emph{BoxExecute}} : Any signal received by this input executes the box
1742 \item {\bf\emph{BoxProcessMode}} : Sets the processing mode of the box :
1744 \item {\bf\emph{Pipeline}} : bbBackwardUpdate() calls Process() only if Status == MODIFIED \\
1745 The box executes itself only when an entry was changed (normal pipeline processing).
1746 \item {\bf\emph{Reactive}} : bbSetModifiedStatus() calls bbUpdate() \\
1747 Warning : Re-processed immediately when \emph{any entry} changed.\\
1748 To be more selective, better use \texttt{connect A.BoxChange \emph{currentBox}.BoxExecute}.
1749 \item {\bf\emph{Always}} : bbUpdate() always calls Process. \\
1750 Usefull for 'sources', that must be processed, even when no entry changed (e.g. : FileSelector, ColorSelector)\\
1751 This one is not end user intended (for Package developer only)
1755 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} :
1757 \item {\bf\emph{WinHeight}} : Height of the window
1758 \item {\bf\emph{WinWidth}} : Width of the window
1759 \item {\bf\emph{WinTitle}} : Title of the window
1760 \item {\bf\emph{WinClose}} : Any received signal closes the window
1761 \item {\bf\emph{WinHide}} : Any received signal hides the window
1762 \item {\bf\emph{WinDialog}} : When set to 'true', creates a \emph{dialog window}, that blocks the pipeline until it is closed (\emph{modal})
1766 Any \emph{Layout box} (i.e. \emph{LayoutLine}, \emph{LayoutSplit} or \emph{LayoutTab}) has at one or more mandatory Inputs :
1768 \item {\bf\emph{Widget}}\texttt{i} : e.g. a \emph{LayoutSplit} box (Widget which splits a window in two resizeable parts)
1769 has two Input parameters \emph{Widget1} and \emph{Widget2}, used to embed the child windows.\\
1770 e.g. a \emph{LayoutLine} divides the window in up to 9 (depending on the number of inputs \emph{Widget}i) fixed size parts.
1774 Any widget box has two mandatory Outputs :
1777 \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
1778 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.
1779 \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,
1780 further within the execution pipeline.
1785 % ==========================================
1786 \subsection{More on ...}
1788 % ==========================================
1790 % ==========================================
1791 \subsubsection{Black box packages}
1792 \label{bbi-more-on-packages}
1793 % ==========================================
1794 There are various others user-intended packages :
1797 ---> Were moved in a 'Reference Manual' ?\\
1798 ---> Any suggestion welcome!
1806 % ==========================================
1807 \subsubsection{Pipeline processing}
1808 \label{bbi-more-on-pipeline-processing}
1809 % ==========================================
1811 \item the ``control'' mechanism in bbi.
1813 When a box is requested to update itself, it asks (recursively) each one of its inputs if it was modified.\\
1814 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.
1816 (switch exec commands, e.g. Button)
1817 \item the role of ProcessMode to update widgets.
1819 % ==========================================
1820 \subsubsection{Complex black boxes}
1821 \label{bbi-more-on-complex-black-boxes}
1822 Creation of complex widgets (containers, contained...)
1824 You can include script files in other script files,
1825 like in the following example :
1829 # Defines the Add4 black box which adds 4 doubles
1833 description "adds 4 doubles"
1837 input In1 a.In1 "first double to add"
1838 input In2 a.In2 "second double to add"
1839 input In3 a.In3 "third double to add"
1840 input In4 b.In2 "fourth double to add"
1841 output Out b.Out "output"
1845 The inner boxes have they own entries (In1, In2, In3 for box a, In1, In2 for box b )\\
1846 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
1847 care neither about the inner boxes name, nor about the names of their Inputs.\\
1848 The writer of the complex box has the ability to give these inputs a meaningfull name !
1850 input In3 a.In3 "third double to add"
1851 input In4 b.In2 "fourth double to add"
1854 %\subsubsection{Advanced issues}
1855 %\paragraph{Reducing the number of inputs of a box}
1857 % ==========================================
1858 \subsubsection{Errors}
1859 \label{bbi-more-on-errors}
1861 % ==========================================
1862 \subsubsection{Creating and using your own uninstalled version of bbStudio}
1863 \label{bbi-more-on-your_own_version}
1865 Suppose you want to run your own uninstalled version (say : you downloaded and compiled the
1866 cvs version in order to use a recently commited patch, but you want to be able
1867 to still use the standard version).
1871 \item cvs checkout the sources :
1876 create a build directory
1880 \item cd in the build directory:
1889 Don't forget to switch ON the flag \texttt{BBTK\_COMPILE\_DEBUG\_MESSAGE} \\
1890 (see figure : \ref{bb-ccmake})
1893 \caption{\label{bb-ccmake}Running ccmake}
1895 \includegraphics[width=0.6\textwidth]{ccmake.png}
1899 \item As usual, type \texttt{c} untill there is no longer any area quoted with a * (or enlighted in red)\\
1900 Ask for generation (type \texttt{g} -once is always enough-)
1902 \item Ask for compilation and link.
1906 For some strange reasons (?!?), you may be warned that an error occured while documentation generation.\\
1907 Take it easy, \texttt{make} again!\\
1909 The dynamic libraries (\texttt{.dll} or \texttt{.so} and the executable programs will be created in the \texttt{bin}
1910 directory of the built tree.
1912 \item choose to install or not your own version.
1916 Linux users : Don't forget to \texttt{sudo} before.
1918 % ==========================================
1919 \subsubsection{\bbtk configuration file and search pathes}
1920 \label{bbi-more-on-configuration}
1922 At start, \bbi tries to open an \texttt{xml}
1923 configuration file named \texttt{bbtk\_config.xml}.
1926 \item The current directory
1927 \item The subdir \texttt{.bbtk} of the user's home directory.
1929 \item On \texttt{Unix}, the home directory is the
1930 one stored by the environnement variable \texttt{HOME},
1931 typically \texttt{/home/username}.
1932 \item On \texttt{Windows}, the home directory is
1933 the user's profile directory stored by the environnement
1934 variable \texttt{USERPROFILE},
1935 typically \texttt{C:\\...}.
1937 \item If none of these two pathes contains the file then it creates
1938 a new one in the \texttt{.bbtk} directory.
1941 Once created, you can edit the \texttt{bbtk\_config.xml} file located
1942 in your \texttt{.bbtk} directory. It contains :
1944 \begin{file}{bbtk\_config.xml}
1946 <?xml version="1.0" encoding="iso-8859-1"?>
1948 <description> </description>
1949 <bbs_path> </bbs_path>
1953 <data_path> </data_path>
1954 <default_temp_dir>$</default_temp_dir>
1959 You can add pathes to
1961 \item A custom folder in which to search for \texttt{.bbs} scripts (\texttt{include} command of \bbi) by adding an \texttt{xml} tag :
1962 \texttt{<bbs\_path>complete\_path\_to\_folder<\/bbs\_path>}.
1963 \item A custom folder in which to search for packages (\texttt{load} command of \bbi) by adding an \texttt{xml} tag :
1964 \texttt{<package\_path>complete\_path\_to\_folder<\/package\_path>}.
1970 % ==========================================
1971 \subsection{Language reference}
1972 \label{bbi-reference}
1973 % ==========================================
1976 % ==========================================
1977 \subsubsection{pipeline creation and execution related commands}
1978 \label{bbi-reference-creation-execution}
1979 % ==========================================
1982 % ==========================================
1984 \caption{\label{bbi-reference-box} \bbi pipeline creation and execution related commands.}
1986 \begin{tabular}{|lcm{6cm}|}
1988 Command & Parameters & Effect \\ \hline
1990 \texttt{new} & \texttt{<boxtype>} \texttt{<box-name>}&
1991 Creates a box of type \texttt{boxtype} and name
1992 \texttt{box-name}.\\ \hline
1994 \texttt{delete} & \texttt{<box-name>} &
1995 Destroys the box named \texttt{box-name}.\\ \hline
1997 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} &
1999 \texttt{output} of the box named \texttt{box1}
2000 to the input \texttt{input} of the box named \texttt{box2} \\ \hline
2002 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
2003 Sets the input \texttt{input} of
2004 the box named \texttt{box} to the value \texttt{value}.
2005 An \texttt{adaptor} must exist
2006 in the packages loaded which converts a \texttt{std::string}
2007 to the type of the input \texttt{input}. \\ \hline
2009 \texttt{print} & \texttt{<string>} &
2010 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the
2011 output \texttt{output} of the box named \texttt{box}.
2012 An \texttt{adaptor} must exist
2013 in the packages loaded which converts
2014 the type of the output \texttt{output}
2015 to a \texttt{std::string}.
2018 \texttt{exec} & \texttt{<box-name>} &
2019 Executes the box named \texttt{box-name}.
2021 connected to its inputs
2022 are also processed recursively (pipeline processing).\\ \hline
2023 \texttt{exec} & \texttt{freeze} &
2024 Allows to block execution commands while keeping definition commands active.(This one is not for end user)\\ \hline
2025 \texttt{exec} & \texttt{unfreeze} &
2026 Turns back to 'normal' mode (This one is not for end user).\\ \hline
2029 % ==========================================
2033 % ==========================================
2034 \subsubsection{Interpreter related commands}
2035 \label{bbi-reference-interpreter}
2036 % ==========================================
2038 % ==========================================
2040 \caption{\label{bbi-reference-interpreter}\bbi intepreter related commands.}
2042 \begin{tabular}{|lcm{6cm}|}
2044 Command & Parameters & Effect \\ \hline
2046 \texttt{author} & \texttt{<author-name>} &
2047 Adds the string \texttt{<author-name>} to the author information of the black box being defined \\ \hline
2049 \texttt{category} & \texttt{<category-name>} &
2050 Adds the string \texttt{<category-name>} to the category information of the black box being defined \\ \hline
2053 Prints help on available commands \\ \hline
2055 & \texttt{<command-name>} &
2056 Prints help on the command \texttt{command-name} \\ \hline
2058 & \texttt{packages} &
2059 Prints help on available packages and their box types
2060 (without description)\\ \hline
2062 & \texttt{<package-name>} &
2063 Prints help on the package \texttt{package-name} and its boxes
2064 (with brief description).
2065 The package must have been previously loaded \\ \hline
2067 & \texttt{<box-type>} &
2068 Prints help (with full description) on the type of box
2070 The box type must belong to a package which has been previously loaded \\ \hline
2072 & \texttt{<debug-directive>} &
2074 Prints debug info on living bbtk objects containing the string \texttt{expr} (default expr='').
2075 \texttt{-C} checks the factory integrity.
2076 \texttt{-D} turns on objects debug info after main ends\\ \hline
2078 \texttt{include} & \texttt{<file-name>} &
2079 Includes and executes the content of the file named \texttt{file-name}
2080 exactly like if you were typing its content at the place were the
2081 \texttt{include} command is. \\ \hline
2083 \texttt{load} & \texttt{<package-name>} &
2084 Loads the package \texttt{package-name} (use it only if you know that you won't work with complex black boxes) \\ \hline
2086 \texttt{include} & \texttt{<package-name>} &
2087 Loads the package \texttt{package-name} and includes all the complex black boxes that comes with it \\ \hline
2089 \texttt{kind} & \texttt{<box kind>} &
2090 Specifies the \texttt{kind} of the complex black boxes you are describing \\ \hline
2092 \texttt{unload} & \texttt{<package-name>}&
2093 Unloads the package \texttt{package-name}.
2094 The package must have been previously loaded.
2095 No box of a type defined in this package must still exist.\\ \hline
2097 \texttt{message} & \texttt{<category>} \texttt{<level>} &
2098 Sets the level of verbosity of \bbi for the category of messages
2099 \texttt{category} to \texttt{level}.\\ \hline
2100 %See \ref{verbosity}.
2102 \texttt{config} & - & Displays the Configuration parameters\\ \hline
2104 \texttt{reset} & - & Deletes all boxes and unloads all packages so
2105 that \bbi gets back to its initial state \\ \hline
2107 \texttt{quit} & - & Exits the interpreter (Don't use it under \bbStudions)\\ \hline
2111 % ==========================================
2115 % ==========================================
2116 \subsubsection{complex black box definition related commands}
2117 \label{bbi-reference-black-box-definition}
2118 % ==========================================
2120 % ==========================================
2122 \caption{\label{bbi-reference-complex-box} \bbi complex black box definition related commands.}
2124 \begin{tabular}{|lcm{6cm}|}
2126 Command & Parameters & Effect \\ \hline
2129 \texttt{define} & \texttt{<box-type>} &
2130 Starts the definition of a complex black box of type
2131 \texttt{box-type}\\ \hline
2133 \texttt{endefine} & - &
2134 Ends the definition of a complex black box type\\ \hline
2136 \texttt{author} & \texttt{<string>} &
2137 Sets the author(s) of the complex black box currently being defined \\ \hline
2139 \texttt{description} & \texttt{<string>} &
2140 Sets the description of the complex black box currently being defined \\ \hline
2142 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} &
2143 Defines a new input for the current complex black box,
2144 named \texttt{name}.
2145 It is defined as corresponding to
2146 the input \texttt{input} of the box \texttt{box}.
2148 \texttt{<help>} is the help string for the new input.
2149 The box \texttt{box} must already have been created in the complex box
2150 and of course have an input named \texttt{input}.\\ \hline
2152 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} &
2153 Defines a new output for the current complex black box,
2154 named \texttt{name}.
2155 It is defined as corresponding to
2156 the output \texttt{output} of the box \texttt{box}.
2157 \texttt{<help>} is the help string for the new output.
2158 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. \\ \hline
2163 % ==========================================
2167 % ==========================================
2168 %\vspace{0.5cm}\hrule \\
2171 \section{The Package Browser}
2172 \label{Package_Browser}
2173 % ==========================================
2176 You can run it using the tool bar of the 'Command' part.
2178 See figure \ref{Package_Browser}.
2181 \caption{\label{Package_Browser}The Package Browser}
2183 \includegraphics[width=0.6\textwidth]{Package_Browser.png}
2187 It allows you to query informations about what you can find in the packages (boxes and applications), using several criterions
2188 (warning : it's case sensitive, i.e \texttt{Button} will give different results thn \texttt{button} ...)
2191 All the boxes and applications held in a given package (e.g. \texttt{wxvtk}, \texttt{std}, ...)
2193 You can query on a subpart of the name of a box or an application (e.g. \texttt{DICOM})
2194 \item Description :\\
2195 You can query on a substring of the description of a box or an application (e.g. \texttt{utton} : user wants to get all
2196 the\texttt{Button} as well as the \texttt{button} )
2198 You can query on a sub part of the category name of a box or an application (e.g. \texttt{3D})
2199 \item Input Type :\\
2200 You can query all the boxes or applications that have at least one Input entry of the given type (e.g. \texttt{int})
2201 \item Output Type :\\
2202 You can query all the boxes or applications that have at least one Output entry of the given type (e.g. \texttt{int})
2203 \item Input Nature :\\
2204 You can query all the boxes or applications that have at least one Input entry of the given nature (e.g. \texttt{signal})
2205 \item Output Nature :\\
2206 You can query all the boxes or applications that have at least one Output entry of the given nature (e.g.
2207 \texttt{signal},\texttt{file name})
2211 All these criterions are \emph{AND}ed while the query process.\\
2212 You can get the whole description of a given box or application clicking on its name.
2215 % ==========================================
2216 %\vspace{0.5cm}\hrule \\
2218 \section{Using third party Package}
2219 \label{Third_Party_Package}
2220 % ==========================================
2222 You will have to update the \emph{bbtk\_config.xml} file.\\
2223 To know where it is stored, just click on \texttt{Config} button of the \texttt{Command} part toolbar.
2225 You'll get something like :
2231 bbtk_config.xml : [/home/jpr/Creatis/bbtk/binLIN/bin/bbtk_config.xml]
2232 Documentation Path : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/doc]
2233 Data Path : [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/data]
2234 Temp Directory : [/home/jpr/Creatis/bbtk/binLIN]
2235 File Separator : [/]
2238 --- [/home/jpr/Creatis/bbtk/binLIN/bin/../share/bbtk/bbs]
2239 --- [/home/jpr/Creatis/bbtk/binLIN/share/bbtk/bbs]
2242 --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2243 --- [/home/jpr/Creatis/bbtk/binLIN/bin/../lib]
2244 --- [/home/jpr/Creatis/bbtk/binLIN/bin]
2245 --- [/home/jpr/Creatis/bbtk/binLIN/bin\Debug]
2246 --- [/home/jpr/Creatis/bbtk/binLIN/bin\Release]
2249 (depending on who you are, and whether \texttt{bbStudio} is installed or not.)\\
2251 Just use your favourite text editor to add :
2254 at the end of the \texttt{BBS Paths} part
2255 the name of the directory that contains the \texttt{.bbs} scripts of the package you
2257 \item at the end of the \texttt{PACKAGE Paths} part
2258 the name of the directory that contains the dynamic libraries (\texttt{.dll} or \texttt{.so}) of the package
2261 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
2262 option \texttt{Generate index} in the menu \texttt{Tools} of the \texttt{Files} part toolbar.
2263 % ==========================================
2264 %\vspace{0.5cm}\hrule \\
2265 \section{Using black boxes in \CPP programs}
2267 % ==========================================
2269 A very usefull feature is that you may use any black box within a \CPP program witout worrying about wxWigets main window.\\
2271 Let's look a the following bbs script :
2278 # Create the Objects
2281 new LayoutLine layout
2283 # Graphical pipeline
2284 connect slider.Widget layout.Widget1
2285 connect text.Widget layout.Widget2
2287 # Execution pipeline
2288 connect slider.BoxChange text.BoxExecute
2289 connect slider.Out text.In
2295 User wants to create a slider and an output text, within a layoutline, and display the slider value in the output text.\\
2296 Think about the (little!) nightmare to code the same, in 'raw C++', using wxWidgets.\\
2298 Using \bbtk you just 'convert' the script :
2301 #include <bbwxSlider.h>
2302 #include <bbwxOutputText.h>
2303 #include <bbtkFactory.h>
2304 #include <bbwxLayoutLine.h>
2306 int main(int argv, char* argc[])
2308 // we need to intanciate a bbtk::Factory to be aware of the adaptors
2309 bbtk::Factory::Pointer factory = bbtk::Factory::New();
2311 // Load the packages
2313 factory->LoadPackage("std");
2314 factory->LoadPackage("wx");
2316 // Create the Objects
2317 // ------------------
2318 bbwx::Slider::Pointer slider = bbwx::Slider::New("slider");
2319 bbwx::OutputText::Pointer text = bbwx::OutputText::New("text");
2320 bbwx::LayoutLine::Pointer layout = bbwx::LayoutLine::New("layout");
2322 // Graphical pipeline
2323 bbtk::Connection::Pointer c1 = bbtk::Connection::New(slider,"Widget",
2326 bbtk::Connection::Pointer c2 = bbtk::Connection::New(text,"Widget",
2329 // Execution pipeline
2330 // ------------------
2332 // We have to pass the 'factory', in order to call automatically an adaptor,
2334 bbtk::Connection::Pointer s2t = bbtk::Connection::New(slider,"Out",
2337 bbtk::Connection::Pointer c3 = bbtk::Connection::New(slider,"BoxChange",
2339 layout->bbSetInputWinDialog(true);
2343 layout->bbExecute();
2346 catch (bbtk::Exception e)
2348 bbtk::MessageManager::SetMessageLevel("Error",1);
2358 %\section{Conclusion}