]> Creatis software - bbtk.git/blob - kernel/doc/bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.tex
partial revision
[bbtk.git] / kernel / doc / bbtkPackageDevelopersGuide / bbtkPackageDevelopersGuide.tex
1
2
3 % ==========================================
4 \documentclass[11pt,final,a4paper]{article}
5 \input{config.tex}
6 \begin{document}
7 \bbtkGuide[Package Developers' Guide]
8 \newpage
9 % ==========================================
10
11
12
13
14 % ==========================================
15 \section{Introduction}
16 % ==========================================
17
18 This guide describes how to 
19 create new \bbtk packages and black boxes. 
20 How to use them is described in \bbtk Users' guide. 
21
22 Any black box must be included in a \bbtk package, 
23 that is in a particular shared library that can be loaded 
24 dynamically by \bbtkns, either in \CPP code or in \bbs scripts 
25 with the commands \texttt{include} or \texttt{load}.
26 The steps to create new boxes are thus:
27
28 \begin{enumerate}
29         \item \textbf{Create a new package. }
30         This process (see section \ref{CreatePackage}), consists of two steps:
31         \begin{enumerate}
32                 \item Generation of the project structure by use of \bbCreatePackage utility that creates both the
33                  directories tree (for sources, documentation, etc.) and configuration files (particularly \texttt{CMakelists}). See section
34                  \ref{sec:bbCreatePackage-files}.
35                 \item Customization of the \texttt{CMakelists}. See section \ref{RootCMakeLists}.
36         \end{enumerate}
37         \item \textbf{Describe your new box.} This is explained in section \ref{CreateBlackBox}.
38         You can do it either:
39         \begin{itemize}
40                 \item In \xml code. You will mainly have to customize an \xml skeleton automatically generated by \bbCreateBlackBox utility.
41                 See section \ref{sec:XML-box}.
42                 When configuring your project with \cmakens, 
43                 the utility \bbfy will then automatically generate the corresponding \CPP code. 
44                 \item In \CPP code. You will have to write the class for 
45                 your box, mostly using \bbtk macros. See section \ref{sec:CPP-box}. 
46         \end{itemize}
47         \item \textbf{Configure your project with \cmakens.} See section \ref{sec:CMake}.
48         \item \textbf{Compile your project.} See section \ref{sec:compile}.
49         \item \textbf{Plug the new package} if you use  \bbStudio See section \ref{sec:plugin}.
50 \end{enumerate}
51
52 % ==========================================
53 \section{Creating a new package}
54 \label{CreatePackage}
55 % ==========================================
56
57 % ==========================================
58 \subsection{Creating the file tree}
59 \label{sec:bbCreatePackage-files}
60 % ==========================================
61 Before defining any black box you  
62 have to create a package, or more precisely  
63 the source files that will allow you to generate the package 
64 (compile and link the shared library) and maybe install it. 
65 The \bbtk command-line application \bbCreatePackage 
66 allows to create the basic file architecture 
67 to start the development of a new black box package.
68 Type \bbCreatePackage in a console to get its usage:
69 \begin{verbatim}
70 bbCreatePackage <package-path> <package-name> [author] [description]
71 \end{verbatim}
72
73 In \bbStudio you can run this application via a graphical interface, by use of the menu \texttt{Tools $>$ Create Package}. 
74 In both cases (using the command-line tool or \bbStudio interface), 
75 you have to choose: 
76
77 \begin{itemize}
78 \item The {\bf directory} of your new package. 
79 Two cases occur:
80 \begin{itemize}
81 \item The black boxes you want to create are based on 
82 a processing code (\CPP classes or \C functions), which 
83 is in an existing project handled by \cmake
84 and you want the new package to be part of your existing project. 
85 You will have to create your new package within the source tree of your 
86 project and add a \texttt{SUBDIRS} command in the \texttt{CMakeLists.txt} 
87 file of the parent directory of your package.
88 \item You do not have an already existing project (you want 
89 to create the new boxes from scratch) or you want/are imposed  
90 that the existing project remain external to the package project.
91 You will have to create your new package in a new location and 
92 maybe include/link against existing libraries. 
93 \end{itemize}
94
95 \item The {\bf name} of your new package. 
96 This name will be used to load the package in \CPP and \bbs scripts.
97 \end{itemize}
98
99 You must also provide the \texttt{author} list 
100 and a \texttt{description} which will be used for your package documentation.
101
102 After running \bbCreatePackage or clicking 'Run' in \bbStudio interface 
103 you should get a file structure like this (Linux users can verify it with the \texttt{tree} command):
104 \begin{verbatim}
105     NEW_PACKAGE
106     |-- CMakeLists.txt
107     |-- Configure.cmake
108     |-- PackageConfig.cmake.in
109     |-- README.txt
110     |-- UsePackage.cmake.in
111     |-- bbs
112     |   |-- CMakeLists.txt
113     |   |-- appli
114     |   |   `-- README.txt
115     |   `-- boxes
116     |       `-- README.txt
117     |-- data
118     |   `-- CMakeLists.txt
119     |-- doc
120     |   |-- CMakeLists.txt
121     |   |-- bbdoc
122     |   |   |-- CMakeLists.txt
123     |   |   `-- header.html.in
124     |   `-- doxygen
125     |       |-- CMakeLists.txt
126     |       |-- DoxyMainPage.txt.in
127     |       `-- Doxyfile.txt.in
128     `-- src
129         `-- CMakeLists.txt
130 \end{verbatim}
131
132 You can then:
133 \begin{itemize}
134 \item Edit the root \texttt{CMakeLists.txt} file to customize your package build settings (see section \ref{RootCMakeLists})
135
136 \item Put your \CPP/\xml boxes sources in '\texttt{src}' subdirectory (see section \ref{CreateBlackBox}).
137  
138   Please use the convention: If the name of your package is \texttt{Pack} and the name of your box is \texttt{Box} then name the source files \texttt{bbPackBox.\{h;cxx;xml\}}. Note that this is automatically done when using the \bbCreateBlackBox utility.
139
140 \item Put your script-defined boxes (complex boxes) in '\texttt{bbs/boxes}' subdirectory. 
141
142   Please use the convention: If the name of your box is '\texttt{Box}' then call the file '\texttt{bbBox.bbs}' to let others know that the script defines a complex black box type.
143
144 \item Put your script-defined applications in '\texttt{bbs/appli}' subdirectory. 
145
146   Please use the convention: Do {\bf not} prefix '\texttt{bb}' to the files.
147
148 \item Put your data in '\texttt{data}' subdirectory. 
149 Any data put there will be installed and accessible in your scripts. The box 
150 \texttt{std::PrependPackageDataPath} provides the package data path.
151
152
153 \item Customize the header of your package \texttt{html} doc. To do so, you have to edit the file '\texttt{doc/bbdoc/header.html.in}' either with an \texttt{html} editor or by use of a text editor (directly editing the \texttt{html} code). You can include images or links to other \texttt{html} pages. The images and pages must be put in the folder '\texttt{doc/bbdoc}' and will be properly installed. The same way, you can link to these images or pages in your boxes descriptions without giving any path. If you create subdirs for your material then you have to install the materials yourself by editing the \texttt{CMakeLists.txt} and links must use paths relative to '\texttt{doc/bbdoc}'.
154
155 \item Customize the main page of your \texttt{doxygen} doc. To do so, you have to edit the file '\texttt{doc/doxygen/DoxyMainPage.txt.in}'.
156 \end{itemize}
157
158 \subsection{Configuring the root \texttt{CMakeLists.txt}}
159 \label{RootCMakeLists}
160
161 \texttt{CMake} is a family of tools designed to build, test and package software (\url{http://www.cmake.org/}). It is used to control the software compilation process using platform- and compiler-independent configuration files. \texttt{CMake} generates native makefiles and workspaces that can be used in the compiler environment of your choice. To do this, each branch of your project directory tree contains an appropriate \texttt{CMakeLists.txt} file. These files have been filled-up, so as to minimize your effort. Normally, you only have to edit the file \texttt{CMakeLists.txt} in the package root directory, in order to configure your new package build settings.
162 The listing of this file is given below. Hopefully, the comments in the file are easy to understand!
163
164 \begin{file}{CMakeLists.txt}
165 \small
166 \begin{verbatim}
167 #==========================================================================
168 # CMAKE SETTINGS FOR BUILDING A BBTK PACKAGE
169 #==========================================================================
170
171 #==========================================================================
172 # THE NAME OF THE BBTK PACKAGE
173 SET(BBTK_PACKAGE_NAME MyPackage)
174 #==========================================================================
175
176 #==========================================================================
177 # IF IT IS A STANDALONE PROJECT UNCOMMENT NEXT LINE TO DECLARE YOUR PROJECT
178 # PROJECT(bb${BBTK_PACKAGE_NAME})
179 #==========================================================================
180
181 #==========================================================================
182 # PACKAGE AUTHOR
183 # !!! NO COMMA ALLOWED !!!
184 SET(${BBTK_PACKAGE_NAME}_AUTHOR "myself")
185 #==========================================================================
186
187 #==========================================================================
188 # PACKAGE DESCRIPTION
189 SET(${BBTK_PACKAGE_NAME}_DESCRIPTION "My super package does nothing yet")
190 #==========================================================================
191
192 #==========================================================================
193 # PACKAGE VERSION NUMBER 
194 SET(${BBTK_PACKAGE_NAME}_MAJOR_VERSION 1)
195 SET(${BBTK_PACKAGE_NAME}_MINOR_VERSION 0)
196 SET(${BBTK_PACKAGE_NAME}_BUILD_VERSION 0)
197 #==========================================================================
198
199 #==========================================================================
200 # UNCOMMENT EACH LIBRARY NEEDED (WILL BE FOUND AND USED AUTOMATICALLY)
201 # SET(${BBTK_PACKAGE_NAME}_USE_VTK  ON)
202 # SET(${BBTK_PACKAGE_NAME}_USE_ITK  ON)
203 # SET(${BBTK_PACKAGE_NAME}_USE_GDCM ON)
204 # SET(${BBTK_PACKAGE_NAME}_USE_GSMIS ON)
205 # SET(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS ON)
206 #==========================================================================
207
208 #==========================================================================
209 # LIST HERE THE OTHER bbtk PACKAGES NEEDED
210 # (WILL BE FOUND AND USED AUTOMATICALLY)
211 SET(${BBTK_PACKAGE_NAME}_USE_PACKAGES 
212   # std
213   # wx
214   # itk
215   # vtk
216   # ...
217   )
218 #==========================================================================
219
220 #==========================================================================
221 # THE SOURCES OF THE PACKAGE
222 # EITHER UNCOMMENT NEXT LINE TO COMPILE ALL .cxx OF THE src DIRECTORY :
223 SET(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX ON)
224 # ... OR LIST THE FILES TO COMPILE MANUALLY :
225 #SET(${BBTK_PACKAGE_NAME}_SOURCES
226 # LIST HERE THE FILES TO COMPILE TO BUILD THE LIB
227 # E.G. TO COMPILE "toto.cxx" ADD "toto" (NO EXTENSION)
228 # THE PATH MUST BE RELATIVE TO THE src FOLDER
229 #    )
230 #==========================================================================
231
232 #==========================================================================
233 # THE xml SOURCES OF THE PACKAGE
234 # EITHER UNCOMMENT NEXT LINE TO bbfy ALL .xml OF THE src DIRECTORY :
235 SET(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML ON)
236 # ... OR LIST THE FILES TO COMPILE MANUALLY :
237 #SET(${BBTK_PACKAGE_NAME}_XML_SOURCES
238 # LIST HERE THE FILES TO bbfy TO BUILD THE LIB
239 # E.G. TO bbfy "toto.xml" ADD "toto" (NO EXTENSION)
240 # THE PATH MUST BE RELATIVE TO THE src FOLDER
241 #    )
242 #==========================================================================
243
244 #==========================================================================
245 # THE SCRIPT-DEFINED BOXES OF THE PACKAGE (bbs)
246 # EITHER UNCOMMENT NEXT LINE TO INCLUDE ALL .bbs OF THE bbs/boxes DIRECTORY:
247 SET(${BBTK_PACKAGE_NAME}_INCLUDE_ALL_BBS_BOXES ON)
248 # ... OR LIST THE FILES TO INCLUDE MANUALLY :
249 # SET(${BBTK_PACKAGE_NAME}_BBS_BOXES
250 # LIST HERE THE bbs FILES TO INCLUDE 
251 # E.G. TO INCLUDE "boxes/bbtoto.bbs" ADD "boxes/bbtoto" (NO EXTENSION)
252 # !! THE PATH MUST BE RELATIVE TO THE bbs FOLDER !!
253 #)
254 #==========================================================================
255
256 #==========================================================================
257 # THE SCRIPT-DEFINED APPLICATIONS OF THE PACKAGE (bbs)
258 # EITHER UNCOMMENT NEXT LINE TO INCLUDE ALL .bbs OF THE bbs/appli DIRECTORY:
259 SET(${BBTK_PACKAGE_NAME}_INCLUDE_ALL_BBS_APPLI ON)
260 # ... OR LIST THE FILES TO INCLUDE MANUALLY :
261 # SET(${BBTK_PACKAGE_NAME}_BBS_APPLI
262 # LIST HERE THE bbs FILES TO INCLUDE 
263 # E.G. TO INCLUDE "appli/testToto.bbs" ADD "appli/testToto" (NO EXTENSION)
264 # !! THE PATH MUST BE RELATIVE TO THE bbs FOLDER !!
265 #)
266 #==========================================================================
267
268 #==========================================================================
269 SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS
270   # LIST HERE YOUR ADDITIONAL INCLUDE DIRECTORIES 
271   # EXCEPT :
272   #  - src
273   #  - bbtk dirs
274   #  - automatically handled libraries or packages: wx, vtk... (see above)
275   #  - the dirs automatically set by other libraries found by FIND_PACKAGE
276   )
277 #==========================================================================
278
279 #==========================================================================
280 SET(${BBTK_PACKAGE_NAME}_LIBS 
281   # LIST HERE THE ADDITIONAL LIBS TO LINK AGAINST
282   # EXCEPT : the same libs than for INCLUDE_DIRS 
283   )
284 #==========================================================================
285
286 #==========================================================================
287 # IF NEEDED : UNCOMMENT NEXT LINE 
288 # AND LIST ADDITIONNAL DIRECTORIES 
289 # IN WHICH TO LOOK FOR LIBRARIES TO LINK AGAINST
290 # LINK_DIRECTORIES()
291 #==========================================================================
292
293 #==========================================================================
294 # SET TO TRUE TO HAVE INFORMATION ON LIBRARIES FOUND DURING CMAKE CONFIGURE
295 SET(FIND_PACKAGE_VERBOSE TRUE)
296 #==========================================================================
297
298 #==========================================================================
299 # END OF USER SECTION
300 #==========================================================================
301
302 #==========================================================================
303 # Include configuration script
304 INCLUDE(Configure.cmake)
305 #==========================================================================
306
307 #==========================================================================
308 # EOF
309 #==========================================================================
310
311 \end{verbatim}
312 \end{file}
313
314 You can see in the file some of the informations you supplied  when running the  \bbCreatePackage utility:
315 \begin{itemize}
316   \item The \textbf{name} of your package. This will be the name used to load it in \bbins. The shared library however will be called \texttt{bb}name hence on 
317     \lin the object file will be called \texttt{libbb}name\texttt{.so} 
318     and on \win it  will be called \texttt{bb}name\texttt{.dll}.
319   \item The \textbf{author(s)} of the package. Preferably provide e-mail addresses.
320   \item A \textbf{description} of the package, which will appear in the help of your package or in its html documentation automatically generated by \bbtkns.  
321 \end{itemize}
322
323 You can additionally set:
324 \begin{itemize}
325 \item The \textbf{version} of the package.
326
327 \item The \textbf{libraries} that will be used by the package. The mechanisms to find these libraries, their sources and to link against them are automatically handled by the \cmake files installed by \bbCreatePackagens. You just have to uncomment a line to use one of these libraries: \vtkns, \itkns, \gdcmns, \gsmisns, \wxns.
328 \item The \textbf{core \bbtk packages} that will be used by the package as \CPP libraries
329 (if you need to use the black boxes of these packages in your \CPP code, 
330 i.e. include some header and link with the library). 
331 The mechanisms to find these libraries, 
332 their sources and to link against them are automatically handled 
333 by the \cmake files installed by \bbCreatePackagens. 
334 You just have to uncomment a line to use one of these libraries.
335
336 \item The \textbf{\CPP sources} of the package: you can list each input \CPP 
337 file explicitly or tell \cmake to include in the project all the \CPP files 
338 of the 'src' directory (default). To do this, you have to comment/uncomment appropriate lines in the file. Be careful with lines containing the opening and closing parentheses.
339
340 \item The \textbf{\xml sources} of the package: you can list each input \xml
341 file explicitly or tell \cmake to include in the project all the \xml files 
342 of the 'src' directory (default). Here you also have to be careful when commenting/uncommenting lines with opening and closing parentheses.
343
344 \item The \textbf{boxes \bbs sources} of the package: you can list each 
345 input \bbs
346 file explicitly or tell \cmake to include in the project \emph{all} 
347 the \bbs files of the 'bbs/boxes' directory (default, recommended). Here you also have to be careful when commenting/uncommenting lines with opening and closing parentheses.
348
349 \item The \textbf{appli \bbs sources} of the package: 
350 you can list each input \bbs
351 file explicitly or tell \cmake to include in the project \emph{all} 
352 the \bbs files of the 'bbs/appli' directory (default, recommended). Here you also have to be careful when commenting/uncommenting lines with opening and closing parentheses.
353
354 \item \textbf{Additional include directories}. Set it if your package needs to include source files that are not in the package directory, typically if it depends on another library that is not one of the libraries automatically handled (\vtkns, \itkns...) and that you did not find with the 
355 \texttt{FIND\_PACKAGE} mechanism of \cmakens.
356
357 \item \textbf{Additional libraries} to link against. Set it if your package needs to link against another library that is not one of the libraries automatically handled (\vtkns, \itkns...) and that you did not find with the 
358 \texttt{FIND\_PACKAGE} mechanism of \cmakens.
359
360 \item \textbf{Additional link directories} in which to find libraries not 
361 automatically handled and that you did not find with the 
362 \texttt{FIND\_PACKAGE} mechanism of \cmakens. 
363
364 \end{itemize}
365
366 Of course, this is only a framework and you can add any other \cmake commands
367 in the file.
368
369 % ==========================================
370 \section{Creating a new box}
371 \label{CreateBlackBox}
372 % ==========================================
373
374 % ==========================================
375 \subsection{Principles}
376 % ==========================================
377
378 % ==========================================
379 \subsubsection{\texttt{C++} or \texttt{XML}?}
380 % ==========================================
381 There are two ways to create a new black box in an existing package:
382 \begin{itemize}
383 \item Write an \xml description file that will be automatically 
384 translated into \CPP by the \bbfy application during build (recommended).
385 \item Write the \CPP code of the box using \bbtk macros.
386 \end{itemize}
387
388 % ==========================================
389 \subsubsection{From which \bbtk class inherit?}
390 % ==========================================
391
392 Apart from the choice of the description language to be used, 
393 there is an important choice to make concerning the implementation of the box. 
394 In \CPPns, a black box is nothing but a class that has the standard 
395 interface of all black boxes, giving access to its name, inputs, outputs, and so on. 
396
397 The abstract description of this interface is done in the class 
398 \texttt{bbtk::BlackBox} of the \bbtk library 
399 and is implemented in its children classes: 
400 \texttt{bbtk::AtomicBlackBox} and \texttt{bbtk::WxBlackBox} 
401 \footnote{all the classes of the \bbtk library are in a \emph{namespace} 
402 called \texttt{bbtk} 
403 and the \CPP header of a class called \texttt{NameOfAClass} is 
404 in the file called \texttt{bbtkNameOfAClass.h}}.
405
406 To create a new black box, you have to inherit from one of these two  
407 actual classes in order to inherit the black box interface and a 
408 particular implementation of this interface. 
409
410 If your black box is a \emph{Widget} black box, 
411 that is a black box that has (or is) 
412 a piece of a graphical interface based on the \wx library,
413 then it must inherit from the class \texttt{bbtk::WxBlackBox}. 
414
415 Concretely, a \texttt{bbtk::WxBlackBox} is associated to 
416 a \texttt{wxWindow} and must be able to return a pointer to it. 
417 If your black box is not a widget black box 
418 (that is: does not return a pointer to a \texttt{wxWindow}),
419  it must inherit from \texttt{bbtk::AtomicBlackBox}.
420  
421 NOTE: \emph{modal dialogs} 
422 that are created and destroyed at the end of the process 
423 method of the box are NOT \texttt{WxBlackBoxes}: 
424 they do not return a \texttt{wxWindow}, 
425 see the code of \texttt{wx::FileSelector} for example.
426
427 % ==========================================
428 \subsubsection{Inherit or encapsulate?}
429 % ==========================================
430
431 Now, your black box will do something (hopefully!). 
432 When you decide to write a new black box, 
433 you should be in one of these three cases :
434 \begin{enumerate}
435 \item You already have a \texttt{C}-like function that 
436 does the processing and that you wish to 'blackboxify' ('bbfy' in short).
437 \item You already have a \CPP class that 
438 does the processing and that you wish to 'bbfy'
439 \item You start from scratch without any existing code
440 \end{enumerate}
441
442 The idea of \BBTK is to embed processing codes into 
443 \CPP objects that have a standard and generic interface - 
444 namely black boxes - to be able to chain arbitrary 
445 processes afterwards. 
446
447 In \CPPns, in order to embed an existing processing \emph{class}  
448 into a standard interface you only have two possibilities:
449 \begin{enumerate}
450 \item {\bf Inherit} from the interface class (e.g. \texttt{bbtk::AtomicBlackBox})
451 \emph{and} from the existing processing class.
452 In this case you have to:
453 \begin{enumerate}
454 \item make the link between the inputs and outputs of the black box 
455 and the interface of the inherited class
456 \item call the processing 
457 method of the inherited class in the processing method of the black box.
458 \end{enumerate}
459 \item {\bf Encapsulate} the existing processing class 
460 in a class inherited from 
461 the interface class (e.g. \texttt{bbtk::AtomicBlackBox}).
462 In this case you have to:
463 \begin{enumerate}
464 \item declare an instance of the processing class 
465 as a member of the black box, 
466 \item instantiate it at the right time 
467 (either in the constructor or in the processing method of the black box)
468 \item in the processing method of the black box : 
469 \begin{enumerate}
470 \item set the inputs of the member processing class with the inputs of the black box, 
471 \item call the processing method of the encapsulated class  
472 \item set the ouputs of the black box with the outputs of the encapsulated 
473 class.
474 \end{enumerate}
475 \end{enumerate}
476 \end{enumerate}
477
478 If you wish to 'bbfy' a C-like \emph{function}, 
479 you do not have the choice, you can only use the second mechanism, 
480 namely encapsulation.
481
482 Obviously, the inheritance mechanism is more powerful 
483 and - when it is possible to use it - it demands less effort. 
484 Indeed, as we will see, in \bbtk you can directly 
485 link the accessors to the input and output data of the box 
486 to the accessors of the inherited processing class, 
487 as well as the processing method of the black box 
488 to the processing method of the inherited processing class, 
489 very much like a callback mechanism.
490 %\itk and \vtk classes 
491
492 % ==========================================
493 \subsubsection{Input and output accessors}
494 % ==========================================
495
496 When you encapsulate a processing class or a C function 
497 or when you write down a black box from scratch, 
498 you must access the inputs and outputs of the black box, 
499 in order to interface it manually with your processing method 
500 or simply write your processing code 
501 (there are other cases in which you also need to access the 
502 inputs and outputs, we will talk about them later). 
503
504 The only thing you must know about the \CPP code generated 
505 from your \xml or your \CPP macro-based description 
506 is that when you declare an input 
507 or an output of a black box then 
508 two \emph{accessors} for this input or output are generated : 
509 one to \emph{get} the value of the input or output and 
510 one to \emph{set} it. 
511 These accessors have normalized names: 
512
513 \begin{itemize} 
514 \item The declaration of an {\bf input} called \texttt{NAME} and 
515 of type \texttt{TYPE} generates the two accessors
516 \footnote{For the sake of simplicity, the parameters and return value are 
517 shown here as if they were all passed by value. 
518 However the actual code can use references. 
519 The same way, the issue of const or non const methods is eluded here. 
520 Different cases occur in practice.}: 
521 \begin{itemize} 
522 \item \texttt{void bbSetInput<NAME>(<TYPE>);} 
523 \item \texttt{<TYPE> bbGetInput<NAME>();} 
524 \end{itemize}
525 \item The declaration of an {\bf output} called \texttt{NAME} and  
526 of type \texttt{TYPE} generates the two accessors:
527 \begin{itemize} 
528 \item \texttt{void bbSetOutput<NAME>(<TYPE>);} 
529 \item \texttt{<TYPE> bbGetOutput<NAME>();} 
530 \end{itemize}
531 \end{itemize}
532
533 For example, declaring an input called \texttt{Image} 
534 would generate the two accessors \texttt{bbSetInputImage} and 
535 \texttt{bbGetInputImage}. 
536
537 Note that:
538 \begin{itemize}
539 \item All \bbtk methods are prefixed by \texttt{bb} 
540 to avoid conflicts with potential inherited methods. 
541 \item An input and an output can have the same name (e.g. 'Image') and no conflict between accessors occurs, since
542 four distinct accessors are created, as follows: 
543 \texttt{bbSetInputImage}, 
544 \texttt{bbGetInputImage}, 
545 \texttt{bbSetOutputImage}, 
546 \texttt{bbGetOutputImage}.
547 \end{itemize}
548
549
550 % ==========================================
551 \subsection{Generate the black box skeleton}
552 % ==========================================
553
554 The command line application \bbCreateBlackBox 
555 allows to create a skeleton \CPP or \xml files for a new black box. 
556 It has a rather complex usage, 
557 we recommend you use the graphical interface to it 
558 which is accessible with \bbStudio menu \texttt{Tools $>$ Create black box}.
559 You will first be prompted to choose the location for the new black box, which should be the \texttt{src} directory of your package sources tree.
560 Then the actual interface will appear, which looks like in fig. \ref{bbCreateBlackBox}.
561
562 \begin{figure}[!ht]
563 \caption{\label{bbCreateBlackBox}Create Black Box interface}
564 \begin{center}
565 \includegraphics[width=0.6\textwidth]{bbCreateBackBox.png}
566 \end{center}
567 \end{figure}
568
569 You will have to give:
570 \begin{enumerate}
571   \item The {\bf name} of the box.
572   \item The {\bf package} to which the box belongs. Caution! You may not make a mistake, otherwise you will be unable to carry out the final build of your project.
573   \item The {\bf author}(s) of the box.
574   \item A {\bf description} of the box.
575
576  \item Its {\bf type}, which is one of the following: 
577    \begin{enumerate} 
578      \item  \emph{Basic}, has no particular Input/Output, inherits from \texttt{AtomicBlackBox};
579      \item  \emph{Widget}, has an output \texttt{Widget}, type \texttt{wxWindow*}, inherits from \texttt{WxBlackBox};
580      \item \emph{VTK PolyDataAlgorithm}, has standard vtk Inputs/Outputs, inherits from \texttt{AtomicBlackBox} and from \texttt{vtkPolyDataAlgorithm};
581      \item \emph{VTK ImageAlgorithm}, has standard vtk Inputs/Outputs, inherits from \texttt{AtomicBlackBox} and from \texttt{vtkImageAlgorithm}.
582
583    \end{enumerate}
584    
585   \item The output format of the file, either a C++ file or an XML file.
586 \end{enumerate}
587
588 % ==========================================
589 \subsection{\texttt{XML} description of a box}
590 \label{sec:XML-box}
591 % ==========================================
592
593 % ==========================================
594 \subsubsection{General \texttt{xml} tags}
595 % ==========================================
596
597 Let us examine the \texttt{xml} file 
598 describing the \texttt{Add} box of the \texttt{std} package:
599
600 \begin{file}{\texttt{packages/std/src/bbAdd.xml}}
601 \small
602 \begin{verbatim}
603 <?xml version="1.0" encoding="iso-8859-1"?>
604
605 <blackbox name="Add">
606
607   <author>laurent.guigues@creatis.insa-lyon.fr </author>
608   <description>Adds its inputs                 </description>
609   <category>math                               </category>
610
611   <input name="In1"  type="double" description="First number to add"/>
612   <input name="In2"  type="double" description="Second number to add"/>
613   <output name="Out" type="double" description="Result"/>
614
615   <process><PRE>
616     bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
617   </PRE></process>
618   
619   <constructor><PRE>
620     bbSetInputIn1(0);
621     bbSetInputIn2(0);
622     bbSetOutputOut(0);
623   </PRE></constructor>    
624
625 </blackbox>
626 \end{verbatim}
627 \end{file}
628
629 As the box is not a widget, it implicitly inherits from 
630 \texttt{bbtk::AtomicBlackBox} (the default).
631
632 The tags and their role are (hopefully) easily understandable.
633 The only part of the file, which needs a bit of explanation, is 
634 the body of the \texttt{process} tag, which describes the 
635 actual code to execute in the box. 
636 This code must be enclosed in a \texttt{<PRE></PRE>} tag 
637 to tell the \xml parser not to interpret it as \xml instructions. 
638 Thus we will be able to use such symbols as \texttt{<} and \texttt{>}, which have a 
639 special meaning in \xmlns. 
640
641 In the case of the \texttt{Add} box, the process code 
642 is very simple. Remember that 
643 \texttt{bbGetInputIn1()} and 
644 \texttt{bbGetInputIn2()} respectively are the 
645 accessors to the inputs \texttt{In1} and \texttt{In2} declared above;  
646 the code simply adds the values of the two inputs 
647 and sets the output \texttt{Out} with the resulting value.
648
649 Note that the afore cited code of the \texttt{Add} box was cleaned so as to only contain the necessary lines.
650 The actual \xml file generated by \bbCreateBlackBox utility is more complete. 
651 It contains many comments to guide you, it already includes the informations you provided when running the \bbCreateBlackBoxns, and it looks like this:
652
653 \begin{file}{\texttt{MyPackage/bbMyPackageMyBox.xml}}
654 \small
655 \begin{verbatim}
656 <!--=======================================================================
657    STARTS THE DESCRIPTION OF THE BLACK BOX -->
658 <blackbox name="MyBox">
659 <!--====================================================================-->
660
661   <!--=====================================================================
662     THE BOX DOCUMENTATION -->
663
664   <author>myself</author>
665   <description>no idea of what it can do</description>
666   <category>__CATEGORY__</category>
667   <!--==================================================================-->
668
669   <!--=====================================================================
670     #include directives to be put in the .h generated
671     There must be one tag per file to include
672     Here we include the standard header iostream.h -->
673   <include><PRE>iostream</PRE></include>
674   <!--==================================================================-->
675
676   <!--=====================================================================
677     INPUTS/OUTPUTS DECLARATION -->
678   <!-- Declares an input with name 'In', type 'double' 
679       and description 'First input' -->
680
681   <input name="In" type="double" description="First input"/>
682   
683   <!-- Declares an output with name 'Out', type 'double' 
684       and description 'First output' -->
685   <output name="Out" type="double" description="First output"/>
686   <!--==================================================================-->
687
688   <!--=====================================================================
689     THE PROCESSING METHOD BODY :
690     Here simply copies the value of the input 'In' to the output 'Out'
691     And prints out the value
692     INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
693       void bbSet{Input|Output}NAME(const TYPE&)
694       const TYPE& bbGet{Input|Output}NAME() const 
695     Where :
696     * NAME is the name of the input/output
697       (the one provided in the attribute 'name' of the tag 'input')
698     * TYPE is the C++ type of the input/output
699       (the one provided in the attribute 'type' of the tag 'input')     -->
700
701   <process>
702   <PRE>
703     bbSetOutputOut( bbGetInputIn() );
704     std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
705   </PRE>
706   </process>
707   <!--==================================================================-->
708
709   <!--=====================================================================
710     CONSTRUCTORS / DESTRUCTORS (OPTIONAL) 
711     THE CONSTRUCTION METHOD BODY :
712     Here initializes the input 'In' to 0
713     This is also where you should allocate the output pointers -->
714   <constructor>
715   <PRE>
716     bbSetInputIn(0);
717   </PRE>
718   </constructor>
719
720   <!-- THE COPY-CONSTRUCTION METHOD BODY :
721     Here does nothing 
722     But this is where you should allocate the output pointers if any
723     and copy the pointed values (to avoid bug caused by multiple refs)  -->
724   <copyconstructor>
725   <PRE>
726   </PRE>
727   </copyconstructor>
728
729   <!-- THE DESTRUCTION METHOD BODY :
730     Here does nothing 
731     but this is where you should desallocate the output pointers if any -->
732   <destructor>
733   <PRE>
734   </PRE>
735   </destructor>
736   <!--==================================================================-->
737
738 <!--====================================================================-->
739 <!-- END OF BLACK BOX DESCRIPTION -->
740 </blackbox>
741 <!--====================================================================-->
742 <!--====================================================================-->
743 <!--====================================================================-->
744 <!--====================================================================-->
745 \end{verbatim}
746 \end{file}
747
748 To describe your own black box in \xml code, 
749 you have to modify this \xml file as follows: 
750
751 \begin{enumerate}
752   \item Complete the category, description and author tags if you feel like.
753   \item Add the \texttt{\#include} directives to be put in the generated \texttt{.h} file (the example given in the \xml file includes the standard \texttt{iostream} header; depending on the actual file to be included, you will have to put or omit the \texttt{.h} extension).
754   \item Create your inputs and outputs
755   \item Fill in the process tag
756   \item Fill in the constructor tag
757   \item Fill in the copyconstructor tag
758   \item Fill in the destructor tag
759 \end{enumerate}
760
761
762
763 % ==========================================
764 \subsubsection{Writing new widget boxes in \xml}
765 % ==========================================
766 See the example \texttt{packages/wx/src/bbwxOutputText.xml}
767
768 \begin{file}{\texttt{packages/wx/src/bbwxOutputText.xml}}
769 \small
770 \begin{verbatim}
771 <blackbox name="OutputText" widget>
772
773   <author>laurent.guigues at creatis.insa-lyon.fr</author>
774   <description>Text zone to be inserted into a window (wxStaticText)
775                                                              </description>
776   <category></category>
777
778   <input name="Title" type="std::string" 
779                                  description="Title prefixed to the text"/>
780   <input name="In" type="std::string" description="Text"/>
781
782   <createwidget><PRE>
783    bbSetOutputWidget( new wxStaticText ( bbGetWxParent() , -1 , _T("") ) );
784    Process();
785   </PRE></createwidget>
786  
787   <process><PRE>
788    std::string msg;
789     if (bbGetInputTitle()!="")
790       {
791         msg = bbGetInputTitle()+": " + bbGetInputIn();
792       }  
793     else 
794       {
795         msg = bbGetInputIn();
796       }
797    ((wxStaticText*)bbGetOutputWidget())->SetLabel( bbtk::std2wx( msg ) ); 
798   </PRE></process>
799   
800   <constructor><PRE> 
801     bbSetInputIn("");
802     bbSetInputTitle("");
803   </PRE></constructor>    
804
805 </blackbox>
806 \end{verbatim}
807 \end{file}
808
809 Explanations:
810 \begin{itemize}
811         \item The attribute \texttt{widget} of the \texttt{blackbox} tag instructs 
812                 \bbfy that the box inherits from \texttt{bbtk::WxBlackBox}.
813         \item An output called \texttt{'Widget'} of type \texttt{wxWindow*} is 
814                 automatically declared (you do not have to do it).
815         \item The tag \texttt{createwidget} provides the body of the method which creates the widget. 
816                 At the end of this method the output \texttt{'Widget'} must 
817                 have been set with the newly created \texttt{wxWindow}. 
818                 Here we create a new \texttt{wxStaticText}.
819                 The parent of the widget to create MUST BE the one provided by the method 
820                 \texttt{bbGetWxParent()} which returns a \texttt{wxWindow*}. 
821                 To update the static text after creation we simply call the \texttt{Process} 
822                 method.
823         \item The body of the \texttt{process} method simply concatenates the 
824                 input \texttt{'Title'} (if non empty) and the input \texttt{'In'} and 
825                 updates the \texttt{wxStaticText}. 
826                 Remark that to get it, we use the \texttt{bbGetOutputWidget()} method 
827                 which returns a \texttt{wxWindow*} which we cast into a 
828                 \texttt{wxStaticText*} to use its specific method \texttt{SetLabel}.
829 \end{itemize}
830
831 More complex examples can be found in the \texttt{package/wx/src} folder.
832
833 % ==========================================
834 \subsubsection{Specific \texttt{xml} tags for \texttt{vtkImageAlgorithm} classes bbfication by inheritance}
835 \label{sec:Specific-VTK}
836 % ==========================================
837 To 'bbfy' \texttt{vtkImageAlgorithm} classes such as \texttt{vtkImageAnisotropicDiffusion3D},  
838 we recommend you the use of \xmlns. You can have a look at the examples 
839 in the \vtk core package 'src' folder. 
840 The bbfication mechanism is inheritance. In the \xml file you have to add:
841
842 \begin{itemize}
843 \item the attribute \texttt{type="VTK\_ImageAlgorithm"} 
844         to the \texttt{blackbox} tag:
845         \begin{verbatim}
846                 <blackbox name="..." type="VTK_ImageAlgorithm">
847         \end{verbatim}
848
849 \item the tag \texttt{vtkparent} which gives the \vtk parent of the box, e.g.:
850         \begin{verbatim}
851                 <vtkparent> vtkImageAnisotropicDiffusion3D </vtkparent>
852         \end{verbatim}
853
854 \item an \texttt{include} tag to include the appropriate \vtk parent header, such as:
855         \begin{verbatim}
856                 <include> vtkImageAnisotropicDiffusion3D.h </include> 
857         \end{verbatim}
858 \end{itemize}
859
860 The \vtk algorithm inputs/ouputs are wrapped directly using the 
861 \texttt{special} attributes of the \texttt{input} and \texttt{output} tags. 
862 A typical example is:
863 \begin{verbatim}
864 <input name="In"   type="vtkImageData*" special="vtk input" 
865        description="Input image"/>
866 <output name="Out"  type="vtkImageData*" special="vtk output"    
867         description="Output image"/>
868 \end{verbatim}
869 In this example, the attribute \texttt{special="vtk input"} of the input 'In' definition 
870 directly connects it to the input of the vtk object the box inherits. 
871 No additional code is needed, the vtk object will directly receive 
872 the value of this input. 
873 The same mechanism holds for the output.
874
875 Similarly, the attribute \texttt{special="vtk parameter"} of the \texttt{input} tag permits to directly 
876 wrap the parameters of the vtk object, which are declared using 
877 \texttt{vtkSetMacro} and \texttt{vtkGetMacro}, e.g.:
878 \begin{verbatim}
879 <input name="DiffusionThreshold" type="double" special="vtk parameter" 
880         description="Difference threshold that stops diffusion"/>
881 \end{verbatim}
882 Here, the attribute \texttt{special="vtk parameter"} 
883 of the input \texttt{DiffusionThreshold} instructs \bbfy to call the \texttt{SetDiffusionThreshold} and 
884 \texttt{GetDiffusionThreshold} 
885 methods of the \vtk parent, when needed. 
886
887 {\bf NOTE:} 
888 For this mechanism to work, 
889 the name of the \bbtk input MUST be the same as the name 
890 of the \vtk parent parameter. 
891
892 No \texttt{process} method has to be given, 
893 \bbfy generates a process body for you, which simply calls the 
894 \texttt{Update()} method of the \vtk parent.
895
896 {\bf NOTE:}
897 You can write your own \texttt{process} code which will overload 
898 the default. Don't forget to call \texttt{Update()}. 
899 See \texttt{packages/vtk/src/bbvtkConeSource.xml} for an example.
900
901 % ==========================================
902 \subsubsection{Specific \texttt{xml} tags for \texttt{vtkPolyDataAlgorithm} classes bbfication by inheritance}
903 % ==========================================
904 To bbfy \texttt{vtkPolyDataAlgorithm} classes such as \texttt{vtkConeSource},  
905 we also recommend the use of \xml (you can have a look at the examples 
906 in the \vtk core package 'src' folder). 
907 The bbfication mechanism is inheritance. 
908 You have to use the same \xml tags and attributes as for wrapping a 
909 \texttt{vtkImageAlgorithm} (see above): 
910
911 \begin{verbatim}
912 <blackbox name="..." type="VTK_PolyDataAlgorithm">
913
914 <vtkparent>the vtk Polydata class it inherits from</vtkparent>
915 <input  name="..."  type="vtkPolyData*" special="vtk input"    
916         description="..."/>
917 <output name="..."  type="vtkPolyData*" special="vtk output"    
918         description="..."/>
919 <input  name="..."  type="double"       special="vtk parameter" 
920         description="..."/>
921 \end{verbatim}
922
923 % ==========================================
924 \subsubsection{Specific \texttt{xml} tags for \texttt{itk::ImageToImageFilter} classes bbfication by inheritance}
925 \label{sec:Specific-ITK}
926 % ==========================================
927
928 to be written...
929
930 \newpage
931
932 % ==========================================
933 \subsubsection{\bbfy \texttt{xml} tags reference}
934 % ==========================================
935
936 % See tables \ref{xml_tags}, \ref{xml_tags2}
937 % ==========================================
938 \begin{table}[!ht]
939 \caption{\label{xml_tags}
940 \bbfy \texttt{xml} tags reference (part 1). \emph{'Cond' stands for 'Condition' (see Tab.\ref{xml_tags-conditions}), while 'Mult' stands for 'Multiplicity'}}
941 \small
942 \begin{tabular}{|lcllm{5.7cm}|}
943 \hline
944 Tag & Attributes & Cond & Mult & Description \\ \hline
945
946 \texttt{<blackbox>} & \texttt{name} & - & 1 & The name of the box \\ \cline{5-5}
947                 & \texttt{type} & - & 1 & The type of the box, belongs to: 
948                 
949                                                         \{\texttt{standard} (default), 
950         
951                                                         \texttt{ITK\_ImageToImageFilter},
952                                                         \texttt{VTK\_ImageAlgorithm},
953                                                         \texttt{VTK\_PolyDataAlgorithm}\} \\ \cline{5-5}
954                 & \texttt{generic} & a) & 0-1 & Generate the generic filter (see text)\\ \cline{5-5} 
955                 & \texttt{widget} & - & 1 & If present then the box inherits from \texttt{WxBlackBox}, otherwise it inherits from  \texttt{AtomicBlackBox} \\ \hline 
956 \texttt{<description>} & - & - & 0-n &  The description of the box. Multiple occurrences are concatenated \\ \hline 
957 \texttt{<author>} & - & - & 0-n &  The author of the box. Multiple occurrences are concatenated \\ \hline 
958 \texttt{<category>} & - & - & 0-1 &  Categories the box belongs to (see Tab.~\ref{categories}), separated by semi-colons \\ \hline 
959 \texttt{<namespace>} & - & - & 0-1 &  The namespace of the box, use \texttt{bb\emph{PACKAGE}}, where \texttt{\emph{PACKAGE}} is the name of the package\\ \hline 
960 \texttt{<include>} & - & - & 0-n & Additional file to include, generates \texttt{\#include \emph{filename}}\\ \hline 
961 \texttt{<itkparent>} &  - & a) &  1 & The parent \itk class (with namespace) \\ \hline
962 \texttt{<vtkparent>} &  - & b) &  1 & The parent \vtk class \\ \hline
963 \texttt{<input>} & \texttt{name} & - & 1 &  The name of the input \\ \cline{5-5} 
964          & \texttt{type} & - & 1 &  The type of the input \\ \cline{5-5} 
965          & \texttt{special} & - & 0-1 & Directly wraps either of the following: \{\texttt{vtk input, vtk parameter, itk input, itk parameter}\}, see sections \ref{sec:Specific-VTK} and \ref{sec:Specific-ITK}.\\ \cline{5-5} 
966          & \texttt{generic\_type} & c) & 0-1 & The ``generic'' type of the input (see text). \\ \hline 
967  \texttt{<output>} & \texttt{name} & - & 1 &  The name of the output \\ \cline{5-5} 
968          & \texttt{type} & - & 1 &  The type of the output \\ \cline{5-5} 
969          & \texttt{special} & - & 0-1 & Directly wraps either of the following: \{\texttt{itk output, vtk output}\}, see sections \ref{sec:Specific-VTK} and \ref{sec:Specific-ITK}.\\ \cline{5-5}
970          & \texttt{generic\_type} & c) & 0-1 & The ``generic'' type  of the output (see text).\\ \cline{5-5}  
971          & \texttt{nature} & c) & 0-1 & The ``nature'' of the output (used for automatic GUI generation).\\\hline 
972 \end{tabular}
973 \end{table}
974
975 \begin{table}[!ht]
976 \caption{\label{xml_tags2}
977 \bbfy \texttt{xml} tags reference (part 2). \emph{'Cond' stands for 'Condition' (see Tab.\ref{xml_tags-conditions}), while 'Mult' stands for 'Multiplicity'}}
978 \small
979 \begin{tabular}{|lcllm{5.5cm}|}
980 \hline
981 Tag & Attributes & Cond & Mult & Description\\ \hline
982 \texttt{<template>} & - & - & 0-n &  Template parameter of the box. The template parameter list is generated in the order of appearance of the tag. \\ \hline 
983 \texttt{<process>} & - & - & 0-1 & The code of the processing method of the box. Must be put between clear tags: \texttt{<PRE></PRE>} \\ \hline 
984 \texttt{<createwidget>} & - & d) & 0-1 & The code of the widget creation method of the box. Must be put between clear tags: \texttt{<PRE></PRE>} \\ \hline 
985 \texttt{<constructor>} & - & - & 0-1 & The code of the user Constructor of the box (may contains default initialisations). Must be put between clear tags: \texttt{<PRE></PRE>} \\ \hline 
986 \texttt{<copyconstructor>} & - & - & 0-1 & The code of the user Copy Constructor of the box. Must be put between clear tags: \texttt{<PRE></PRE>} \\ \hline
987 \texttt{<destructor>} & - & - & 0-1 & The code of the user Destructor of the box. Must be put between clear tags: \texttt{<PRE></PRE>} \\ \hline
988 \end{tabular}
989 \end{table}
990  
991 %\newpage
992  
993 % ==========================================
994 \begin{table}[!ht]
995 \caption{\label{xml_tags-conditions}
996 \bbfy \texttt{xml} tags conditions}
997 \begin{centering}
998 \small
999 \begin{tabular}{|ll|}
1000 \hline
1001 a) & \texttt{<blackbox type == 'ITK\_ImageToImageFilter'>} \\ \hline
1002 b) & \texttt{<blackbox type == 'VTK\_ImageAlgorithm'} \texttt{or 'VTK\_PolyDataAlgorithm'>} \\ \hline
1003 c) & \texttt{<blackbox type == 'ITK\_ImageToImageFilter'>} \\
1004 \multicolumn{2}{|r|}{and \texttt{<blackbox generic>} is present.} \\ \hline
1005 d) & \texttt{<blackbox widget>} is present \\ \hline
1006 \end{tabular}
1007
1008 \end{centering}
1009 \end{table}
1010
1011 %\begin{table}[!ht]
1012 %\caption{\label{basic_parent}}
1013 %\bbfy \texttt{Basic box parent}
1014 %\small
1015 %\begin{tabular}{|ll|}
1016 %\hline
1017 %\texttt{bbtk::WxBlackBox}b) & If the blackbox associated to
1018 %a \texttt{wxWindow} and is be able to return a pointer to it.... \\ \hline
1019 %\texttt{bbtk::AtomicBlackBox} & Any other blackbox that doesn't return a pointer to a \texttt{wxWindow}%
1020 %\end{tabular}
1021 %\end{table}
1022
1023
1024
1025
1026 % ==========================================
1027 \begin{table}[!ht]
1028 \caption{\label{categories} \texttt{Black Box} categories}
1029 \small
1030 \begin{tabular}{|p{4cm}p{8cm}|}
1031 \hline
1032  \texttt{Category name}     & : Meaning                                          \\ \hline 
1033 & \\ \hline
1034  \texttt{adaptor}        & : Adaptor box                                      \\ \hline
1035  \texttt{application}    & : Final application, end user intended             \\ \hline
1036  \texttt{atomic box}     & : System category.
1037                Automatically assigned to (\CPP defined) Atomic Black Boxes     \\ \hline
1038  \texttt{complex box}    & : System category.
1039                Automatically assigned to (script defined) Complex Black Boxes \\ \hline  
1040  \texttt{command line}   & : Script that defines an application without embedded GUI, but with command-line input parameters) \\ \hline
1041  \texttt{demo}           & : Demonstration                             \\ \hline
1042  %\texttt{devel}          & : Developer tool (bbCreatePackage.bbs, ...) \\ \hline
1043  \texttt{dicom}          & : DICOM aware box \\ \hline 
1044  \texttt{example}        & : Example script showing a box use-case      \\ \hline
1045  \texttt{filter}         & : Filtering box                       \\ \hline
1046  \texttt{image}          & : Image processing related box               \\ \hline
1047 % \texttt{interaction}    & :                                            \\ \hline
1048  \texttt{math}           & : Mathematical operations\\ \hline
1049  \texttt{mesh}           & : Mesh processing related box \\ \hline
1050  \texttt{misc}           & : A box that cannot be put in other category ! \\ \hline
1051  \texttt{read/write}     & : Box that read or write data from or to disk  \\ \hline
1052  \texttt{viewer}         & : Box which displays some data \\ \hline
1053  \texttt{widget}         & : Piece of graphical interface  \\ \hline 
1054  
1055  \texttt{3D object creator} & : Sophisticated 3D widget  \\ \hline  
1056  \texttt{toolsbbtk}         & : \bbtk development tools such as \\
1057                                                                                                                 & GUICreatePackage, GUICreateBlackBox, etc.   \\ \hline  
1058 \end{tabular}
1059 \end{table}
1060
1061
1062 % ==========================================
1063 \begin{table}[!ht]
1064 \caption{\label{kinds}\texttt{Black box} kinds. The notion of 'kind' corresponds to special black boxes that are automatically added to the user-defined pipeline} 
1065 \small
1066 \begin{tabular}{|p{4cm}p{8cm}|}
1067 \hline
1068  \texttt{Kind}     &   Description    \\ \hline & \\ \hline
1069  \texttt{ADAPTOR} & black box that carries out a type-conversion (cast), so that a connection between an output and an input can be properly made \\ \hline
1070  \texttt{DEFAULT\_ADAPTOR} & indicates the preferred one, if several boxes can carry out the same type-conversion\\ \hline 
1071  \texttt{GUI} & black box usable by the \texttt{newgui} command that tries to automatically assign a graphical interface according to the input types\\ \hline 
1072  \texttt{DEFAULT\_GUI} & indicates the preferred one, if several boxes can provide the expected features\\ \hline 
1073 \end{tabular}
1074 \end{table}
1075
1076
1077 % ==========================================
1078 \begin{table}[!ht]
1079 \caption{\label{nature}Input/output \texttt{natures}}
1080 \small
1081 \begin{tabular}{|p{4cm}p{8cm}|}
1082 \hline
1083  \texttt{Nature}     &   : Associated \texttt{DEFAULT\_GUI} box   \\ \hline 
1084 & \\ \hline
1085
1086  \texttt{'file name'} & \texttt{wx::FileSelector}\\ \hline
1087  \texttt{'directory name'} & \texttt{wx::DirectorySelector}\\ \hline 
1088 % \texttt{'file extension'} & \\ \hline  
1089  \texttt{'colour'} & \texttt{wx::ColourSelector}\\ \hline 
1090 % \texttt{pixel type} & \\ \hline 
1091 % \texttt{image dimension} & \\ \hline
1092 % \texttt{image index} & \\ \hline 
1093 % \texttt{image size} & \\ \hline 
1094 % \texttt{voxel size} & \\ \hline  
1095 \end{tabular}
1096 \end{table}
1097
1098 %\newpage 
1099
1100
1101 % ==========================================
1102 \subsection{\CPP description of a box}
1103 \label{sec:CPP-box}
1104 % ==========================================
1105
1106 Almost everything is performed using macros.
1107
1108 For a quick start, the best you have to do is to run \texttt{bbStudio}, then in the menu \texttt{Tools}, choose the item
1109  \texttt{Create black box}, click on \texttt{C++}, and have a look to the generated files, or have a look at the source files of \bbtk core packages.
1110  
1111 % ==========================================
1112 \subsubsection{Black box basic header file (.h)}
1113 % ========================================== 
1114
1115 Let's have a look at the file \texttt{packages/std/bbstdMakeFileName.h}
1116
1117 \begin{file}{\texttt{packages/std/bbstdMakeFileName.h}}
1118 \small
1119 \begin{verbatim}
1120 #ifndef __bbstdMakeFileName_h_INCLUDED__
1121 #define __bbstdMakeFileName_h_INCLUDED__
1122
1123 #include "bbtkAtomicBlackBox.h"
1124
1125 namespace bbstd
1126 {
1127   class MakeFileName : public bbtk::AtomicBlackBox
1128   {
1129     BBTK_BLACK_BOX_INTERFACE(MakeFileName,bbtk::AtomicBlackBox);
1130     BBTK_DECLARE_INPUT(Directory, std::string);
1131     BBTK_DECLARE_INPUT(File,      std::string);
1132     BBTK_DECLARE_INPUT(Extent,    std::string);
1133     BBTK_DECLARE_OUTPUT(Out,      std::string);
1134     BBTK_PROCESS(DoProcess);
1135     void DoProcess();
1136   protected:
1137     virtual void bbUserConstructor();
1138   };
1139
1140   BBTK_BEGIN_DESCRIBE_BLACK_BOX(MakeFileName,bbtk::AtomicBlackBox);
1141   BBTK_NAME("MakeFileName");
1142   BBTK_AUTHOR("jpr@creatis.insa-lyon.fr");
1143   BBTK_CATEGORY("misc");
1144   BBTK_DESCRIPTION("Makes a kosher file name");
1145   BBTK_INPUT(MakeFileName,Directory,"Directory Name",std::string,
1146              "directory name");
1147   BBTK_INPUT(MakeFileName,File,     "File Name",     std::string,
1148              "file name");
1149   BBTK_INPUT(MakeFileName,Extent,   "Extention",     std::string,
1150              "file extension");
1151   
1152   BBTK_OUTPUT(MakeFileName,Out,"Full File Name",std::string,"file name");
1153   BBTK_END_DESCRIBE_BLACK_BOX(MakeFileName);
1154
1155 }
1156 // EO namespace bbstd
1157
1158 #endif //  __bbstdMakeFileName_h_INCLUDED__
1159 \end{verbatim}
1160 \end{file}
1161
1162 It includes \texttt{bbtkAtomicBlackBox.h}.
1163 The box class is \texttt{MakeFileName}.
1164 It inherits \texttt{bbtk::AtomicBlackBox}.
1165 It is in the \texttt{bbstd} namespace : 
1166 each box of a given package, say PACK, must be inserted into 
1167 the namespace \texttt{bbPACK}.
1168
1169 The macro \texttt{BBTK\_BLACK\_BOX\_INTERFACE} 
1170 declares the interface of the class: constructor, destructor,
1171 standard methods (e.g. New), etc. 
1172 The following macros then declare inputs and outputs of the box, 
1173 with their types.
1174 The macro \texttt{BBTK\_PROCESS} then declares which method to call 
1175 when processing the box (the process callback).
1176 The callback itself is declared just below.
1177
1178 The line \texttt{virtual void bbUserConstructor();} then 
1179 overloads the virtual method \texttt{bbUserConstructor} 
1180 which is used to perform specific things at construction time.
1181 You can also overload \texttt{bbUserCopyConstructor} 
1182 and \texttt{bbUserDestructor} with the same signature.
1183 The black box interface macros are summarized in table 
1184 \ref{CPPInterfaceBasicMacros}.
1185
1186 % ==========================================
1187 \begin{table}[!ht]
1188 \caption{\label{CPPInterfaceBasicMacros}Black box interface \CPP macros}
1189 \begin{tabular}{p{\textwidth}}\hline
1190     \\ \small \texttt{BBTK\_BLACK\_BOX\_INTERFACE(BOX\_NAME,BBTK\_PARENT)}:
1191     Yes, we know the \bbtk parent is redundant with the inheritance list... That's why we allow you to describe your class in \xml format!
1192      \\ \small \texttt{BBTK\_VTK\_BLACK\_BOX\_INTERFACE(CLASS,BBTK\_PARENT,VTK\_PARENT) }: Black box interface for \vtk object inherited boxes
1193         \dots
1194     \\ \small \texttt{BBTK\_ITK\_BLACK\_BOX\_INTERFACE(CLASS,BBTK\_PARENT,ITK\_PARENT) }: Black box interface for \itk object inherited boxes
1195         \dots
1196     \\ \small \texttt{BBTK\_DECLARE\_INPUT (NAME,TYPE) }: Declares an input of the box, with \texttt{NAME}: the input name (as it will appear to the users of your black box) and \texttt{TYPE}: \CPP type of the input (e.g. double, std::string, vtkImageData*, ...).
1197   \\ \small \texttt{BBTK\_DECLARE\_INHERITED\_INPUT(NAME,TYPE,GETMETHOD,SETMETHOD)}: Declares an input of the box which wraps the \texttt{GETMETHOD / SETMETHOD} accessors
1198     \\ \small \texttt{BBTK\_DECLARE\_VTK\_INPUT(NAME,TYPE)}:
1199          Declares a vtk object-inherited input
1200    \\ \small \texttt{BBTK\_DECLARE\_VTK\_IMAGE\_ALGORITHM\_INPUT(NAME,TYPE)}:    Declares a vtkImageAlgorithm-inherited input 
1201     \\ \small \texttt{BBTK\_DECLARE\_VTK\_POLY\_DATA\_ALGORITHM\_INPUT(NAME,TYPE)}: Declares a vtkPolyDataAlgorithm-inherited input  
1202     \\ \small \texttt{BBTK\_DECLARE\_ITK\_INPUT (NAME,TYPE)}:
1203          Declares a itk object-inherited input
1204   \\ \small \texttt{BBTK\_DECLARE\_OUTPUT (NAME,TYPE) }:
1205         Declares an output of the box 
1206   \\ \small \texttt{BBTK\_DECLARE\_INHERITED\_OUTPUT(NAME,TYPE,GETMETHOD,SETMETHOD)}:
1207     Declares an output of the box which wraps the \texttt{GETMETHOD / SETMETHOD} accessors
1208     \\ \small \texttt{BBTK\_DECLARE\_VTK\_OUTPUT(NAME,TYPE)}:
1209         Declares a vtk object-inherited output    
1210      \\ \small \texttt{BBTK\_DECLARE\_ITK\_OUTPUT(NAME,TYPE)}:
1211          Declares a itk object-inherited output
1212    \\ \small \texttt{BBTK\_DECLARE\_VTK\_PARAM(VTK\_PARENT,NAME,TYPE)}:
1213  Declares an input corresponding to an inherited vtk parameter 
1214      (you know, the ones that are declared by vtkSetMacro/vtkGetMacro). Its name must be the same than the vtk parameter name.  
1215     \\ \small \texttt{BBTK\_DECLARE\_ITK\_PARAM(NAME,TYPE)}:
1216  Declares an input corresponding to an inherited itk parameter 
1217     \\ \small \texttt{BBTK\_PROCESS(METHOD\_NAME)}:
1218         Defines the method to call when the box is processed. 
1219     \\ \small \texttt{BBTK\_VTK\_PROCESS}:                                                      Defines AND implements the default processing method for vtk 
1220         inherited black boxes (calls \texttt{vtkParent::Update})
1221   \\ \small \texttt{BBTK\_ITK\_PROCESS}:                                                        Defines AND implements the default processing method for itk 
1222         inherited black boxes (calls \texttt{itkParent::Update})
1223 \\ 
1224 \hline\end{tabular}
1225
1226 \end{table}
1227 %================================================
1228
1229 After the black box class declaration 
1230 then comes a zone in which you describe your black box, 
1231 between the macros \texttt{BBTK\_BEGIN\_DESCRIBE\_BLACK\_BOX} 
1232 and \\ \texttt{BBTK\_END\_DESCRIBE\_BLACK\_BOX}.
1233
1234 The macro \texttt{BBTK\_BEGIN\_DESCRIBE\_BLACK\_BOX} 
1235 actually starts the declaration of another class, 
1236 called \texttt{\textless BOXNAME \textgreater Descriptor} 
1237 (in our case \texttt{MakeFileNameDescriptor}).
1238 The descriptor of a black box :
1239 \begin{itemize}
1240 \item has only one instance, which is stored in the package
1241 \item provides information about the box type (author, description, ...) 
1242 which is used for documentation.
1243 \item provides information about the box I/Os, mainly their types
1244 (uses RTTI : \texttt{std::type\_info} ).
1245 \item is responsible for creating new instances of the box it describes.
1246 \end{itemize}
1247
1248 As you can see, 
1249 the macros which are between \texttt{BBTK\_BEGIN\_DESCRIBE\_BLACK\_BOX} 
1250 and \texttt{BBTK\_END\_DESCRIBE\_BLACK\_BOX} 
1251 provide the box name (the string), 
1252 its authors, description, category, 
1253 the descriptions of its inputs and outputs.
1254 Black box descriptor related 
1255 are described in table \ref{CPPDescriptorBasicMacros}.
1256
1257 % ==========================================
1258 \begin{table}[!ht]
1259 \caption{\label{CPPDescriptorBasicMacros}Black box descriptor \CPP macros}
1260 \begin{tabular}{p{\textwidth}}\hline
1261     \\ \small \texttt{BBTK\_BEGIN\_DESCRIBE\_BLACK\_BOX(BOX\_NAME,BBTK\_PARENT) } : 
1262     Yes, we know it's redundant with public inheritance ... That's why we allow you to describe your class in xml format! 
1263     All the following items will be used in the Help interface; describe them carefully (i.e. in a Human understandable way!).
1264   \\ \small \texttt{BBTK\_ADAPTOR}: Declares that the box is an adaptor
1265   \\ \small \texttt{BBTK\_DEFAULT\_ADAPTOR}: Declares that the box is the default adaptor for its I/O types
1266    \\ \small \texttt{BBTK\_NAME(STRING)}: The name of your box 
1267     \\ \small \texttt{BBTK\_AUTHOR(STRING)}: The author(s) (better you put e-mail adresses)
1268     \\ \small \texttt{BBTK\_DESCRIPTION(STRING)}: Brief description of what does the box
1269     \\ \small \texttt{BBTK\_CATEGORY(STRING)}: Box categories, semicolon separated  (see table \ref{categories})
1270     \\ \small \texttt{BBTK\_INPUT(BOX\_NAME,INPUT\_NAME,DESCRIPTION,CPP\_TYPE,INPUT\_NATURE)} 
1271        \begin{itemize}
1272          \item \texttt{BOX\_NAME}: The current black box name.
1273          \item \texttt{INPUT\_NAME}: The input name
1274          \item \texttt{DESCRIPTION} (string): A brief description of what the parameter is used for.
1275          \item \texttt{CPP\_TYPE}: The \CPP type of the input (e.g. double, std::string, vtkImageData*, ...) 
1276          \item \texttt{INPUT\_NATURE}: The 'nature' of the parameter (see table \ref{nature}) if you wish your box may be used by automatic GUI generator.
1277          Supply an empty string ("") if you don't care.          
1278        \end{itemize}
1279     \\ \small\texttt{BBTK\_OUTPUT(BOX\_NAME,OUTPUT\_NAME,DESCRIPTION,CPP\_TYPE)}: The same
1280      \\ \small \texttt{BBTK\_END\_DESCRIBE\_BLACK\_BOX(BOX\_NAME)} 
1281  \\ \hline\end{tabular}
1282 \end{table}
1283
1284 % ==========================================
1285 \subsubsection{Black box basic implementation file (.cxx)}
1286 % ========================================== 
1287
1288 Now let's have a look at the file \texttt{packages/std/bbstdMakeFileName.cxx}
1289
1290 \begin{file}{\texttt{packages/std/bbstdMakeFileName.cxx}}
1291 \small
1292 \begin{verbatim}
1293 #include "bbstdMakeFileName.h"
1294 #include "bbstdPackage.h"
1295
1296 namespace bbstd
1297 {
1298
1299   BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MakeFileName);
1300   BBTK_BLACK_BOX_IMPLEMENTATION(MakeFileName,bbtk::AtomicBlackBox);
1301   
1302   void MakeFileName::bbUserConstructor()
1303   {
1304     bbSetInputDirectory("");
1305     bbSetInputFile("");
1306     bbSetInputExtent("");
1307   }
1308   
1309   void MakeFileName::DoProcess()
1310   {
1311     ...
1312   }
1313 }
1314 // EO namespace bbstd
1315 \end{verbatim}
1316 \end{file}
1317
1318 The first line includes the header file.
1319 The second one includes the \texttt{std} package header file.
1320 This file is automatically generated during cmake configuration :
1321 for a package named \texttt{\textless PACK \textgreater}, \cmake
1322 creates the files \texttt{bb\textless PACK \textgreater Package.h} 
1323 and \texttt{bb\textless PACK \textgreater Package.cxx}.
1324 The header is to be included in any box implementation file and 
1325 the second one is compiled in the package library.
1326
1327 The macro \texttt{BBTK\_ADD\_BLACK\_BOX\_TO\_PACKAGE} 
1328 then registers the box \texttt{MakeFileName} into the package \texttt{std}.
1329
1330 The macro \texttt{BBTK\_BLACK\_BOX\_IMPLEMENTATION} is the 
1331 mirror macro of the macro \texttt{BBTK\_BLACK\_BOX\_INTERFACE} that 
1332 was used in the header : it implements the methods declared in the header.
1333
1334 We then need to write the body of \texttt{bbUserConstrutor} 
1335 and of the processing callback (here \texttt{DoProcess}).
1336
1337 That's all we need for a 'basic' black box.
1338 The implementation related macros are summarized in table \ref{CPPImplementationBasicMacros}.
1339
1340 % ==========================================
1341 \begin{table}[!ht]
1342 \caption{\label{CPPImplementationBasicMacros}Black box implementation \CPP macros}
1343 \begin{tabular}{p{\textwidth}}\hline
1344     \\ \small \texttt{BBTK\_ADD\_BLACK\_BOX\_TO\_PACKAGE(PACKAGE\_NAME,BOX\_NAME)}
1345    \\ \small  \texttt{BBTK\_BLACK\_BOX\_IMPLEMENTATION(BOX\_NAME,BBTK\_PARENT)}
1346 \\ \hline
1347 \end{tabular}
1348 \end{table}
1349  
1350 % ==========================================
1351 \subsubsection{Widget black boxes \CPP macros}
1352 % ==========================================
1353
1354 See the example of \texttt{package/wx/src/bbwxLayoutLine.h\textbar cxx}.
1355 The only differences with a non-widget black box are :
1356 \begin{itemize}
1357 \item The header must include \texttt{bbtkWxBlackBox.h} and \\ 
1358 the class must inherit \texttt{bbtk::WxBlackBox}.
1359 \item The black box interface must declare the widget creation callback 
1360 with the macro \texttt{BBTK\_CREATE\_WIDGET(CALLBACK)}. 
1361 The callback must be declared in the interface and implemented. 
1362 \item You can overload the method \texttt{void bbUserOnShow()} which 
1363 is called just after the \texttt{wxWindow} has been shown, e.g. 
1364 to refresh its content. Note that \texttt{Layout} widget \emph{MUST}
1365 overload this method and call \texttt{bbUserOnShowWidget(INPUT\_NAME)} 
1366 for all inputs which correspond to an 'embedded' window
1367 (the 'Widget1' ... 'WidgetN' inputs, 
1368 see \texttt{package/wx/src/bbwxLayoutLine.cxx})
1369 \end{itemize}
1370
1371 % ==========================================
1372 \subsubsection{VTK black boxes \CPP macros}
1373 % ==========================================
1374
1375 See the example of \texttt{package/wx/src/bbvtkMarchingCubes.h\textbar cxx}.
1376 The macros are summarized in table \ref{CPPInterfaceBasicMacros}.
1377
1378 % ==========================================
1379 \subsubsection{Template black boxes \CPP macros}
1380 % ==========================================
1381
1382 You can write down black box classes \emph{templates}. 
1383 However, only \emph{actual} classes, that is instanciated templates, 
1384 can be inserted into a package.
1385
1386 The files \texttt{package/std/src/bbstdStringTo.h\textbar cxx} 
1387 provide an example of a class template with one template parameter. 
1388
1389 The files \texttt{package/std/src/bbstdCast.h\textbar cxx} 
1390 provide an example of a class template with two template parameters. 
1391
1392 Class templates related macros are summarized in table \ref{CPPTemplateMacros}.
1393 % ==========================================
1394 \begin{table}[!ht]
1395 \caption{\label{CPPTemplateMacros}Black box templates-related \CPP macros}
1396 \begin{tabular}{p{\textwidth}}\hline
1397 % \begin{itemize}
1398     \\  \small\texttt{BBTK\_TEMPLATE\_BLACK\_BOX\_INTERFACE(BOX\_NAME,BBTK\_PARENT, TEMPLATE\_PARAMETER)}
1399     \\  \small\texttt{BBTK\_TEMPLATE2\_BLACK\_BOX\_INTERFACE(BOX\_NAME,BBTK\_PARENT, TEMPLATE\_PARAMETER\_1, TEMPLATE\_PARAMETER\_2)}
1400     \\  \small\texttt{BBTK\_BEGIN\_DESCRIBE\_TEMPLATE\_BLACK\_BOX(BOX\_NAME,BBTK\_PARENT)}: Note that in the descriptor, the template parameter name is \texttt{T}
1401 \\ \small\texttt{BBTK\_BEGIN\_DESCRIBE\_TEMPLATE2\_BLACK\_BOX(BOX\_NAME,BBTK\_PARENT)}: Note that in the descriptor, the template parameters names are \texttt{T1} and \texttt{T2}
1402     \\ \small\texttt{BBTK\_END\_DESCRIBE\_TEMPLATE\_BLACK\_BOX(BOX\_NAME)}
1403    \\ \small\texttt{BBTK\_END\_DESCRIBE\_TEMPLATE2\_BLACK\_BOX(BOX\_NAME)}
1404      \\ \small\texttt{BBTK\_TEMPLATE\_INPUT(BOX\_NAME,INPUT\_NAME,DESCRIPTION,CPP\_TYPE, INPUT\_NATURE)}: Same than for non-templates, except that the \texttt{CPP\_TYPE} can be the template parameter.
1405     \\ \small\texttt{BBTK\_TEMPLATE2\_INPUT(BOX\_NAME,INPUT\_NAME,DESCRIPTION,CPP\_TYPE, INPUT\_NATURE)}: Same remark
1406  \\\small \texttt{BBTK\_TEMPLATE\_OUTPUT(BOX\_NAME,OUTPUT\_NAME,DESCRIPTION,CPP\_TYPE)}: Same remark 
1407  \\ \small\texttt{BBTK\_TEMPLATE2\_OUTPUT(BOX\_NAME,OUTPUT\_NAME,DESCRIPTION,CPP\_TYPE)}: Same remark 
1408  \\ \small\texttt{BBTK\_BLACK\_BOX\_TEMPLATE\_IMPLEMENTATION(BOX\_NAME,BBTK\_PARENT)}
1409  \\ \small\texttt{BBTK\_BLACK\_BOX\_TEMPLATE2\_IMPLEMENTATION(BOX\_NAME,BBTK\_PARENT)}
1410  \\ \small\texttt{BBTK\_ADD\_TEMPLATE\_BLACK\_BOX\_TO\_PACKAGE(PACKAGE\_NAME,BOX\_NAME, TEMPLATE\_PARAMETER\_VALUE)}: Adds the black box template instanciated on a certain value of its template parameter to the package. You can put as many such lines with different template parameter values as you want (see e.g. \texttt{package/std/src/bbstdStringTo.cxx})
1411  \\ \small\texttt{BBTK\_ADD\_TEMPLATE2\_BLACK\_BOX\_TO\_PACKAGE(PACKAGE\_NAME,BOX\_NAME, TEMPLATE\_PARAMETER\_1\_VALUE, TEMPLATE\_PARAMETER\_2\_VALUE)}:
1412 The same for two template parameters (see  e.g. \texttt{package/std/src/bbstdCast.cxx})
1413 \\
1414 %\end{itemize}
1415 \\ \hline
1416 \end{tabular}
1417 \end{table}
1418
1419
1420 {\bf IMPORTANT NOTE ON TEMPLATE BLACK BOXES NAMES:}
1421
1422 Two different boxes registered in a package must have two different names. 
1423 Hence when using black box classes templates, 
1424 one must give different names to two instanciations of the template on 
1425 two different types. 
1426 This is typically done with inserting the template parameter type name in the 
1427 black box class name.
1428 An example is provided in \texttt{package/std/src/bbstdStringTo.h}: 
1429
1430 \begin{verbatim}
1431   BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ToString,bbtk::AtomicBlackBox);
1432   BBTK_NAME(bbtk::HumanTypeName<T>()+"ToString");
1433    ... 
1434   BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(ToString);
1435 \end{verbatim}
1436
1437 To get the string corresponding to the name of a \CPP type
1438 (here the template parameter \texttt{T})
1439 one must use the template \bbtk function \texttt{bbtk::HumanTypeName<T>()}
1440 \footnote{\texttt{HumanTypeName} returns a human readable type name, 
1441 without special chars such as \texttt{::} or \textless. For example the 
1442 human readable type name of \texttt{std::vector\textless std::string \textgreater} is \texttt{VectorOfString}. The 'inhuman' type name is given 
1443 by the function \texttt{bbtk::TypeName<T>()}.}.
1444 It is then concatenated to the name \texttt{ToString}.
1445 This thus gives the name \texttt{IntToString} to the black box \texttt{ToString\textless int \textgreater}, 
1446 \texttt{DoubleToString} to the black box \texttt{ToString\textless double \textgreater}, etc.
1447
1448 You can also use \texttt{bbtk::HumanTypeName<T>()} 
1449 in the macro \texttt{BBTK\_DESCRIPTION}, like for example: 
1450 \begin{verbatim}
1451   BBTK_DESCRIPTION("Converts a "+bbtk::HumanTypeName<T>()+" ("
1452                    +bbtk::TypeName<T>()+") into a string");
1453 \end{verbatim}
1454
1455
1456 % ==========================================
1457 \subsubsection{ITK black boxes \CPP macros}
1458 % ==========================================
1459
1460 It is a special case of black box templates with also 
1461 special macros for \itk object inherited black boxes. 
1462
1463 See the example of \texttt{package/wx/src/bbitkBinaryThresholdImageFilter.h\textbar cxx}, 
1464 the tables \ref{CPPInterfaceBasicMacros} and \ref{CPPTemplateMacros}.
1465
1466 Note that 
1467 there is also a mechanism for making 
1468 ``generic'' untemplatized itk black boxes.
1469 See the example in the file above.
1470
1471 % ==========================================
1472 \section{Configure your project with \cmakens.} 
1473 \label{sec:CMake}
1474 % ==========================================
1475 You have to run the \texttt{CMakeSetup} application with your project root directory as location of the sources (this can be done by dragging the icon of the \texttt{CmakeLists.txt} file toward the icon of \texttt{CMakeSetup}). You will have to indicate a location for the binaries, which must be different from the location of the sources. You are likely to encounter some warnings about the compiler version, which you (generally) can ignore. Be careful however with various options, the default state of which is \texttt{OFF}, e.g.: at the very beginning, you will have to put \texttt{ON} the attribute \texttt{BUILD\_BBTK\_PACKAGE\_\emph{your\_package\_name}}. Click on 'Configure' as long as new elements appear or remain in red, then click on 'OK'. \cmake will generate an entire directory tree, with the workspace file (e.g. \texttt{bb\emph{your\_package\_name}.sln} for Microsoft Visual Studio) in the root directory. Note that the tree includes a \texttt{src} directory where the \CPP code of the package is automatically generated.
1476
1477 % ==========================================
1478 \section{Compile your project.}
1479 \label{sec:compile}
1480 % ==========================================
1481 Open the workspace file generated by \texttt{CMakeSetup} (e.g. \texttt{bb\emph{your\_package\_name}.sln} for Microsoft Visual Studio), select either the appropriate project to be built, or \texttt{ALL\_BUILD} if applies. Build it in RelWithDebInfo configuration, which corresponds to the configuration in which the bbtk libraries provided by the installer were compiled. The first step of the \texttt{build} process is the generation of \CPP code from \xml files. Note that these new \texttt{.cxx} and \texttt{.h} files are put into the \texttt{src} subdirectory of the directory tree containing the binaries and {\bf not} of the one containing the sources. Indeed, the 'sources' directory tree is intended to contain actual source files, that are to be saved (e.g. with CVS), while the 'binaries' directory tree is intended to contain all the files generated either by \cmake or by the \texttt{build} process.
1482
1483 % ==========================================
1484 \section{Plug the new package.}
1485 \label{sec:plugin}
1486 % ==========================================
1487 If you want to use the new package with \bbStudio you can plug it dynamically. Use the menu
1488 \texttt{Tools > Plug package}. You will be prompted to indicate the package directory. Browse the root of the 'binaries' directory tree (the one generated by \cmakens).
1489 The plug-in mechanism actually consists in automatic adding of appropriate paths into the configuration file.
1490
1491 \end{document}
1492