]> Creatis software - bbtk.git/blob - kernel/doc/bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.tex
de75a2789bc21ec1e1432fcf99805ce200430667
[bbtk.git] / kernel / doc / bbtkPackageDevelopersGuide / bbtkPackageDevelopersGuide.tex
1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
3 \input{config.tex}
4 \begin{document}
5 \title{The Black Box Toolkit\\Package Developers' Guide}
6 \date{\today}
7 \author{Laurent Guigues}
8 \maketitle
9 % ==========================================
10 \tableofcontents
11 % ==========================================
12
13
14 % ==========================================
15 %\section*{Abstract}
16 % ==========================================
17 \newpage
18 % ==========================================
19 % ==========================================
20 \vspace{0.5cm}\hrule
21 %\section{Creating your own black boxes}
22 %\label{bbp}
23 % ==========================================
24
25 % ==========================================
26 \section{Steps in the creation of new black boxes}
27 % ==========================================
28 Any black box must be included in a \bbtk package, 
29 that is in a particular shared library which can be loaded 
30 dynamically by \bbtk (hence applications which use \bbtk, 
31 such as the interpreter \bbi). 
32
33 \begin{enumerate}
34 \item \textbf{Create a new package. }
35 Before defining any black box you  
36 have to create a package, or more precisely  
37 the files which will allow you to generate the package 
38 (compile and link the shared library) and may be install it. 
39  \texttt{bbStudio} does it for you.
40  
41
42 Two cases occur :
43 \begin{itemize}
44 \item The black boxes you want to create are based on 
45 a processing code (\CPP classes or \C functions) which 
46 is in an existing project handled by \cmake
47 and you want the new package to be part of your existing project. 
48 You will have to create your new package into the source tree of your 
49 project. 
50 \item You do not have an already existing project (you want 
51 to create the new boxes from scratch) or you want/are imposed  
52 that the existing project remain external to the package project.
53 You will have to create your new package in a new location and 
54 may be include/link against existing libraries. 
55 \end{itemize}
56
57 \item \textbf{Describe your new box. }
58 You can do it either :
59 \begin{itemize}
60 \item In \CPP code. You will have to write the class for 
61 your box, mostly using \bbtk macros.  
62 \item In \xml code. 
63 When configuring your project with \cmake, 
64 the utility \bbfy will then generate the corresponding \CPP code. 
65 \end{itemize}
66
67 \end{enumerate}
68
69 % ==========================================
70 \section{Creating a new black box package}
71 % ==========================================
72
73 Run \texttt{bbStudio}.
74
75 Use the option \texttt{Create Package} of the menu \texttt{Tools}.
76
77
78 \begin{figure}[!ht]
79 \caption{\label{bb-Studio} bbStudio}
80 \begin{center}
81 \includegraphics[width=0.6\textwidth]{bbStudio.png}
82 \end{center}
83 \end{figure}
84
85 You will be asked to choose the directory where you want to create the package,
86 then you'll get something like in fig. \ref{bbCreatePackage}. 
87
88
89 \begin{figure}[!ht]
90 \caption{\label{bbCreatePackage} Create Package}
91 \begin{center}
92 \includegraphics[width=0.6\textwidth]{bbCreatePackage.png}
93 \end{center}
94 \end{figure}
95
96
97 That will creates the directory structure and the \texttt{cmake} 
98 files necessary to build the project.
99
100 You must then decide the name of your new package. 
101 It will be the name used to load the package in \texttt{bbi}.
102 Fill up the form like in fig. \ref{bbFillUpPackageForm}.
103
104
105 \begin{figure}[!ht]
106 \caption{\label{bbFillUpPackageForm} Fill up the form}
107 \begin{center}
108 \includegraphics[width=0.6\textwidth]{bbFillUpPackageForm.png}
109 \end{center}
110 \end{figure} 
111
112 Edit the file 'MyPackage/CMakeLists.txt' to customize your package
113
114
115 the file tree obtained is :
116
117 \begin{verbatim}
118 >tree  myPackageFolder
119 myPackageFolder
120 `-- MyPackage
121     |-- CMakeLists.txt
122     |-- Configure.cmake
123     |-- PackageConfig.cmake.in
124     |-- README.txt
125     |-- UsePackage.cmake.in
126     |-- bbs
127     |   |-- CMakeLists.txt
128     |   |-- appli
129     |   |   `-- README.txt
130     |   `-- boxes
131     |       `-- README.txt
132     |-- data
133     |   `-- CMakeLists.txt
134     |-- doc
135     |   |-- CMakeLists.txt
136     |   |-- bbdoc
137     |   |   |-- CMakeLists.txt
138     |   |   `-- header.html.in
139     |   `-- doxygen
140     |       |-- CMakeLists.txt
141     |       |-- DoxyMainPage.txt.in
142     |       `-- Doxyfile.txt.in
143     `-- src
144         `-- CMakeLists.txt
145         
146 9 directories, 16 files
147 \end{verbatim}
148
149 The directory \texttt{MyPackage} is the directory of your new package, 
150 in which you will create the files describing your black boxes.
151 But first, you have to customize your new package, by editing the file 
152 \texttt{CMakeLists.txt} in the \texttt{MyPackage} directory.
153 This file contains :
154
155 \begin{file}{MyPackage/CMakeLists.txt}
156 \small
157 \begin{verbatim}
158 #===========================================================================
159 # CMAKE SETTINGS FOR BUILDING A BBTK PACKAGE
160 #===========================================================================
161
162 #===========================================================================
163 # THE NAME OF THE BBTK PACKAGE
164 SET(BBTK_PACKAGE_NAME MyPackage)
165 #===========================================================================
166
167 #===========================================================================
168 # IF IT IS A STANDALONE PROJECT UNCOMMENT NEXT LINE TO DECLARE YOUR PROJECT
169 # PROJECT(bb${BBTK_PACKAGE_NAME})
170 #===========================================================================
171
172 #===========================================================================
173 # PACKAGE AUTHOR
174 # !!! NO COMMA ALLOWED !!!
175 SET(${BBTK_PACKAGE_NAME}_AUTHOR "myself")
176 #===========================================================================
177
178 #===========================================================================
179 # PACKAGE DESCRIPTION
180 SET(${BBTK_PACKAGE_NAME}_DESCRIPTION "The kinkiest stuff you ve ever seen.")
181 #===========================================================================
182
183 #===========================================================================
184 # PACKAGE VERSION NUMBER 
185 SET(${BBTK_PACKAGE_NAME}_MAJOR_VERSION 1)
186 SET(${BBTK_PACKAGE_NAME}_MINOR_VERSION 0)
187 SET(${BBTK_PACKAGE_NAME}_BUILD_VERSION 0)
188 #===========================================================================
189
190 #===========================================================================
191 # UNCOMMENT EACH LIBRARY NEEDED (WILL BE FOUND AND USED AUTOMATICALLY)
192 # SET(${BBTK_PACKAGE_NAME}_USE_VTK  ON)
193 # SET(${BBTK_PACKAGE_NAME}_USE_ITK  ON)
194 # SET(${BBTK_PACKAGE_NAME}_USE_GDCM ON)
195 # SET(${BBTK_PACKAGE_NAME}_USE_GSMIS ON)
196 # SET(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS ON)
197 #===========================================================================
198
199 #===========================================================================
200 # LIST HERE THE OTHER bbtk PACKAGES NEEDED
201 # (WILL BE FOUND AND USED AUTOMATICALLY)
202 SET(${BBTK_PACKAGE_NAME}_USE_PACKAGES 
203   # std
204   # wx
205   # itk
206   # vtk
207   # ...
208   )
209 #===========================================================================
210
211 #===========================================================================
212 # THE SOURCES OF THE PACKAGE
213 # EITHER UNCOMMENT NEXT LINE TO COMPILE ALL .cxx OF THE src DIRECTORY :
214 SET(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX ON)
215 # ... OR LIST THE FILES TO COMPILE MANUALLY :
216 #SET(${BBTK_PACKAGE_NAME}_SOURCES
217 # LIST HERE THE FILES TO COMPILE TO BUILD THE LIB
218 # E.G. TO COMPILE "toto.cxx" ADD "toto" (NO EXTENSION)
219 # THE PATH MUST BE RELATIVE TO THE src FOLDER
220 #    )
221 #===========================================================================
222
223 #===========================================================================
224 # THE xml SOURCES OF THE PACKAGE
225 # EITHER UNCOMMENT NEXT LINE TO bbfy ALL .xml OF THE src DIRECTORY :
226 SET(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML ON)
227 # ... OR LIST THE FILES TO COMPILE MANUALLY :
228 #SET(${BBTK_PACKAGE_NAME}_XML_SOURCES
229 # LIST HERE THE FILES TO bbfy TO BUILD THE LIB
230 # E.G. TO bbfy "toto.xml" ADD "toto" (NO EXTENSION)
231 # THE PATH MUST BE RELATIVE TO THE src FOLDER
232 #    )
233 #===========================================================================
234
235 #===========================================================================
236 # THE SCRIPT-DEFINED BOXES OF THE PACKAGE (bbs)
237 # EITHER UNCOMMENT NEXT LINE TO INCLUDE ALL .bbs OF THE bbs/boxes DIRECTORY :
238 SET(${BBTK_PACKAGE_NAME}_INCLUDE_ALL_BBS_BOXES ON)
239 # ... OR LIST THE FILES TO INCLUDE MANUALLY :
240 # SET(${BBTK_PACKAGE_NAME}_BBS_BOXES
241 # LIST HERE THE bbs FILES TO INCLUDE 
242 # E.G. TO INCLUDE "boxes/bbtoto.bbs" ADD "boxes/bbtoto" (NO EXTENSION)
243 # !! THE PATH MUST BE RELATIVE TO THE bbs FOLDER !!
244 #)
245 #===========================================================================
246
247 #===========================================================================
248 # THE SCRIPT-DEFINED APPLICATIONS OF THE PACKAGE (bbs)
249 # EITHER UNCOMMENT NEXT LINE TO INCLUDE ALL .bbs OF THE bbs/appli DIRECTORY :
250 SET(${BBTK_PACKAGE_NAME}_INCLUDE_ALL_BBS_APPLI ON)
251 # ... OR LIST THE FILES TO INCLUDE MANUALLY :
252 # SET(${BBTK_PACKAGE_NAME}_BBS_APPLI
253 # LIST HERE THE bbs FILES TO INCLUDE 
254 # E.G. TO INCLUDE "appli/testToto.bbs" ADD "appli/testToto" (NO EXTENSION)
255 # !! THE PATH MUST BE RELATIVE TO THE bbs FOLDER !!
256 #)
257 #===========================================================================
258
259 #===========================================================================
260 SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS
261   # LIST HERE YOUR ADDITIONAL INCLUDE DIRECTORIES 
262   # EXCEPT :
263   #  - src
264   #  - bbtk dirs
265   #  - automatically handled libraries or packages : wx, vtk... (see above)
266   #  - the dirs automatically set by other libraries found by FIND_PACKAGE
267   )
268 #===========================================================================
269
270 #===========================================================================
271 SET(${BBTK_PACKAGE_NAME}_LIBS 
272   # LIST HERE THE ADDITIONAL LIBS TO LINK AGAINST
273   # EXCEPT : the same libs than for INCLUDE_DIRS 
274   )
275 #===========================================================================
276
277 #===========================================================================
278 # IF NEEDED : UNCOMMENT NEXT LINE 
279 # AND LIST ADDITIONNAL DIRECTORIES 
280 # IN WHICH TO LOOK FOR LIBRARIES TO LINK AGAINST
281 # LINK_DIRECTORIES()
282 #===========================================================================
283
284 #===========================================================================
285 # SET TO TRUE TO HAVE INFORMATION ON LIBRARIES FOUND DURING CMAKE CONFIGURE
286 SET(FIND_PACKAGE_VERBOSE TRUE)
287 #===========================================================================
288
289 #===========================================================================
290 # END OF USER SECTION
291 #===========================================================================
292
293 #===========================================================================
294 # Include configuration script
295 INCLUDE(Configure.cmake)
296 #===========================================================================
297
298 #===========================================================================
299 # EOF
300 #===========================================================================
301
302 \end{verbatim}
303 \end{file}
304
305 The comments in the file should be easily understandable !
306 You have to customize the lines which are enclosed 
307 between dashed comment lines.
308 In these sections, you can see some of the informations you supplied in previous step:
309 \begin{itemize}
310   \item The \textbf{name} of your package. This will be the name used to load it in \bbi. The shared library however will be called \texttt{bb}name hence on 
311     \lin the object file will be called \texttt{libbb}name\texttt{.so} 
312     and on \win it  will be called \texttt{bb}name\texttt{.dll}.
313   \item The \textbf{author(s)} of the package. Preferably provide e-mail adresses.
314   \item A \textbf{description} of the package, which will appear in the help of your package or in its html documentation automatically generated by \bbdoc.  
315 \end{itemize}
316
317 In these sections, you can set :
318 \begin{itemize}
319
320 \item The \textbf{libraries used} by the package : \vtk, \itk, \gdcm, \gsmis, \wx. The mecanisms to find these libraries, their sources and to link against them are automatically handled by the \cmake files installed by \bbCreatePackage. You just have to uncomment a line to use one of these libraries.
321
322 \item A \textbf{description} of the package, which will appear in the help of your package or in its html documentation automatically generated by \bbdoc.
323 \item The \textbf{version} of the package.
324 \item The \textbf{\xml sources} of the package : you can list each input \xml file explicitly or tell \cmake to include in the project \emph{all} the \xml files of the directory. 
325 \item The \textbf{\CPP sources} of the package :  you can list each input \CPP file explicitly or tell \cmake to include in the project all the \CPP files of the directory.
326 \item \textbf{Additional include directories}. Set it if your package needs to include source files which are not in the package directory, typically if it depends on another library which is not one the libraries automatically handled (\vtk, \itk...).
327 \item \textbf{Additional libraries} to link against. Set it if your package needs to link against another library which is not one the libraries automatically handled (\vtk, \itk...).
328 \end{itemize}
329
330 Of course, this is only a framework and you can add any other \cmake commands
331 in the file.
332
333 % ==========================================
334 \section{Creating a new box}
335 % ==========================================
336
337 % ==========================================
338 \subsection{Principles}
339 % ==========================================
340
341 \subsubsection{\texttt{C++} or \texttt{XML} ?}
342 There are two ways to create a new black box in an existing package :
343 \begin{itemize}
344 \item Write an \xml description file which will be automatically 
345 translated in \CPP by the \bbfy application (recommanded).
346 \item Write the \CPP code of the box using \bbtk macros.
347 \end{itemize}
348
349 \subsubsection{From which \bbtk class inherit ?}
350
351 Apart from this choice of the description langage to use, 
352 there is an important choice to do concerning the implementation of the box. 
353 In \CPP, a black box is nothing but a class which has the standard 
354 interface of all black boxes : what's its name ? inputs ? outputs ? and so on. 
355 The abstract description of this interface is done in the class 
356 \texttt{bbtk::BlackBox} and is implemented in its child classes : 
357 \texttt{bbtk::UserBlackBox} and \texttt{bbtk::WxBlackBox} 
358 \footnote{all the classes of the \bbtk library are in a \emph{namespace} 
359 called \texttt{bbtk} 
360 and the \CPP header of a class called \texttt{NameOfAClass} is 
361 in the file called \texttt{bbtkNameOfAClass.h}}.
362 To create a new black box, you have to inherit one of these two  
363 concrete classes in order to inherit the black box interface and a 
364 particular implementation of this interface. 
365 If your black box is a \emph{Widget} black box, 
366 that is a black box which has (or is) 
367 a piece of a graphical interface based on the \wx library,
368 then it must inherit the class \texttt{bbtk::WxBlackBox}. 
369 Concretely, a \texttt{bbtk::WxBlackBox} is associated 
370 a \texttt{wxWindow} and must be able to return a pointer to it. 
371 If your black box is not a widget black box, it must inherit 
372 \texttt{bbtk::UserBlackBox}.
373
374 \subsubsection{Inherit or encapsulate ?}
375
376 Now, your black box will do something (hopefully !). 
377 When you decide to write a new black box, 
378 you should be in one of these three cases :
379 \begin{enumerate}
380 \item You already have a \texttt{C}-like function which 
381 does the processing that you wish to 'blackboxify'
382 \item You already have a \CPP class which 
383 does the processing that you wish to 'blackboxify'
384 \item You start from scratch without any existing code
385 \end{enumerate}
386
387 The idea of \BBTK is to embed processing codes into 
388 \CPP objects which have a standard and generic interface - 
389 namely black boxes - to be able to chain arbitrary 
390 processes afterwards. 
391
392 In \CPP, in order to embed an existing processing \emph{class}  
393 into a standard interface you only have two possibilities :
394 \begin{enumerate}
395 \item {\bf Inherit} the existing processing class 
396 \emph{and} the interface class (e.g. \texttt{bbtk::UserBlackBox}).
397 In this case you have to :
398 \begin{enumerate}
399 \item make the link between the inputs and outputs of the black box 
400 and the interface of the inherited class
401 \item call the processing 
402 method of the inherited class in the processing method of the black box.
403 \end{enumerate}
404 \item {\bf Encapsulate} the existing processing class 
405 in a class inherited from 
406 the interface class (e.g. \texttt{bbtk::UserBlackBox}).
407 In this case you have to :
408 \begin{enumerate}
409 \item declare it as a member of the black box, 
410 \item instantiate it at the right time 
411 (either in the constructor or in the processing method of the black box)
412 \item in the processing method of the black box : 
413 \begin{enumerate}
414 \item set the inputs of the member procesing class with the inputs of the black box, 
415 \item call the processing method of the encapsulated class  
416 \item set the ouputs of the black box with the outputs of the encapsulated 
417 class.
418 \end{enumerate}
419 \end{enumerate}
420 \end{enumerate}
421
422 If you wish to 'blackboxify' a C-like \emph{function}, 
423 you do not have the choice, you can only use the second mechanism, 
424 namely encapsulation.
425
426 Obviously, the inheritance mechanism is more powerfull 
427 and - when it is possible to use it - it demands less effort 
428 because, as we will see, in \bbtk you can directly 
429 link the accessors to the input and output data of the box 
430 to the accessors of the inherited processing class, 
431 as well as the procesing method of the black box 
432 to the processing method of the inherited processing class, 
433 very much like a callback mechanism.
434
435 \subsubsection{How to generate a Black Box skeleton}
436
437 Run \texttt{bbStudio}, choose \texttt{Tools} in the menu bar, option
438 \texttt{Create Black Box}.
439 You will be shown something like in fig. \ref{bbCreateBlackbox} :
440
441 \begin{figure}[!ht]
442 \caption{\label{bbCreateBlackbox}Create Black Box}
443 \begin{center}
444 \includegraphics[width=0.6\textwidth]{bbCreateBackbox.png}
445 \end{center}
446 \end{figure}
447
448
449 \subsubsection{Informations to provide}
450
451 Finally, to create a new black box, you will have to give :
452 \begin{enumerate}
453   \item The {\bf name} of the box
454   \item The {\bf package} to which the box belongs (can we do it automatically ? LG : think about it) 
455   \item The {\bf author}(s) of the box
456   \item A {\bf description} of the box
457
458  \item Its {\bf type}, either 
459    \begin{enumerate} 
460      \item  a standard one (\texttt{std-template})
461      \item a VTK Polydata Algorithm based box (\texttt{VTK\_PolydataAlgorithm-template}),    
462      \item  a VTK Image Algorithm based box (\texttt{VTK\_ImageaAlgorithm-template}),
463      \item  if it uses the wxWidget Library (\texttt{widget-template})
464    \end{enumerate}
465    
466   \item The output format of the file, either a C++ file or an XML file.
467
468   %\item $[$Optional$]$ The additional {\bf include files} which are necessary for the code to compile (classes or functions declarations ...)  
469   %\item $[$Optional$]$ The other {\bf parent(s)} of the box (which must be known hence their header included)
470   %\item $[$Optional$]$ The {\bf namespace} to which the box belongs
471   %\item The box {\bf inputs} and {\bf outputs}, and for each one :
472   %\begin{enumerate}
473   %\item Its {\bf name} : the string which will identify the input or output
474   %\item Its {\bf type} : any \CPP type, either a basic type or a user defined type (class ...) but which must be known, hence the necessary files must be included.  
475   %\item Its {\bf help} : a string describing the input / output 
476   %\end{enumerate}
477 %\item Its {\bf processing} code, which can be a simple callback or an arbitrary complex code
478 \end{enumerate}
479
480 WARNING:
481 Under Linux, for reasons we shall not discuss here, you'll get an error message :
482
483  \texttt{No such file or directory}
484  
485 Have a look at the console, you'll see a shell command (whose syntax is OK although there is is a lot of
486 quotes),something like :
487
488  \texttt{ "/usr/local/bin/bbCreateBlackBox"  "/home/jpr/Desktop/essai" MyPackage
489  myVtkPolydataBlackBox VTK-PolyDataAlgorithm C++  'author1, author2'  'myVtkPolydataBlackBox description'}
490
491  Just copy the command, and run it manually.
492
493 \subsubsection{Input and output accessors}
494
495 When you encapsulate a processing class or a C function 
496 or when you write down a black box from scratch, 
497 you must access the inputs and outputs of the black box, 
498 in order to interface it manually with your processing method 
499 or simply write your processing code 
500 (there are other cases in which you also need to access the 
501 inputs and outputs, we will talk about them later). 
502
503 The only thing you must know about the \CPP code generated 
504 from your \xml or your \CPP macro-based description 
505 is that when you declare an input 
506 or an output of a black box then 
507 two \emph{accessors} for this input or output are generated : 
508 one to \emph{get} the value of the input or output and 
509 one to \emph{set} it. 
510 These accessors have normalized names : 
511
512 \begin{itemize} 
513 \item The declaration of an {\bf input} called \texttt{NAME} and 
514 of type \texttt{TYPE} generates the two accessors
515 \footnote{For the sake of simplicity, the parameters and return value are 
516 shown here as if they were all passed by value. 
517 However the actual code can use references. 
518 The same way, the issue of const or non const methods is eluded here. 
519 Different cases occur in practice.}: 
520 \begin{itemize} 
521 \item \texttt{void bbSetInput<NAME>(<TYPE>);} 
522 \item \texttt{<TYPE> bbGetInput<NAME>();} 
523 \end{itemize}
524 \item The declaration of an {\bf output} called \texttt{NAME} and  
525 of type \texttt{TYPE} generates the two accessors:
526 \begin{itemize} 
527 \item \texttt{void bbSetOutput<NAME>(<TYPE>);} 
528 \item \texttt{<TYPE> bbGetOutput<NAME>();} 
529 \end{itemize}
530 \end{itemize}
531
532 For example, declaring an input called \texttt{Image} 
533 would generate the two accessors \texttt{bbSetInputImage} and 
534 \texttt{bbGetInputImage}. 
535
536 Note that 
537 \begin{itemize}
538 \item All \bbtk methods are prefixed by \texttt{bb} 
539 to avoid conflicts with potential inherited methods. 
540 \item An input and an output can have the same name (e.g. 'Image').
541 No conflict between accessors occur (e.g. 
542 four distinct accessors are created : 
543 \texttt{bbSetInputImage}, 
544 \texttt{bbGetInputImage}, 
545 \texttt{bbSetOutputImage} and 
546 \texttt{bbGetOutputImage}).
547 \end{itemize}
548
549 % ==========================================
550 \subsection{\texttt{XML} description of a box}
551 % ==========================================
552
553 % ==========================================
554 \subsubsection{General \texttt{xml} tags}
555 % ==========================================
556
557 Let us examine the \texttt{xml} file 
558 describing the \texttt{Add} box of the \texttt{std} package :
559
560 \begin{file}{\texttt{packages/std/src/bbAdd.xml}}
561 \small
562 \begin{verbatim}
563 <?xml version="1.0" encoding="iso-8859-1"?>
564
565 <blackbox name="Add">
566
567   <author>laurent.guigues@creatis.insa-lyon.fr </author>
568   <description>Adds its inputs                 </description>
569   <category>math                               </category>
570
571   <input name="In1"  type="double" description="First number to add"/>
572   <input name="In2"  type="double" description="Second number to add"/>
573   <output name="Out" type="double" description="Result"/>
574
575   <process><PRE>
576     bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
577   </PRE></process>
578   
579   <constructor><PRE>
580     bbSetInputIn1(0);
581     bbSetInputIn2(0);
582     bbSetOutputOut(0);
583   </PRE></constructor>    
584
585 </blackbox>
586 \end{verbatim}
587 \end{file}
588
589 The tags and their role are easily understandable.
590
591 As the box is not a widget, we inherit from 
592 \texttt{bbtk::UserBlackBox} (\texttt{parentblackbox} tag).
593
594
595 The only part of the file which needs a bit of explaination is 
596 the body of the \texttt{process} tag, which describes the 
597 actual code to execute in the box. 
598 This code must be enclosed in a \texttt{<PRE></PRE>} tag 
599 to tell the \xml parser not to interpret it as \xml instructions. 
600 This is necessary to be able to use any symbol, 
601 like the \texttt{<} and \texttt{>} which have a 
602 special meaning in \xml. 
603 In the case of the \texttt{Add} box, the process code 
604 is very simple : remember that 
605 \texttt{bbGetInputIn1} is the 
606 accessor to the input \texttt{In1} declared above and 
607 \texttt{bbGetInputIn2} is the 
608 accessor to the input \texttt{In2};  
609 the code simply adds the values of the two inputs 
610 and sets the output \texttt{Out} with the resulting value.
611
612 To describe your own black boxes in \xml code, 
613 you must modify the xml file generated in previous step : 
614
615 \begin{enumerate}
616   \item Complete the description and author tags if you feel like.
617   \item add the '\#include' directives to be put in the generated .h file
618   \item Create your inputs and outputs
619   \item Fill in the process tag
620   \item Fill in the constructor tag
621   \item Fill in the copyconstructor tag
622   \item Fill in the destructor tag
623   \item Pray
624 \end{enumerate} 
625
626
627 % ==========================================
628 \subsubsection{Specific \texttt{xml} tags for \texttt{itk::ImageToImageFilter} classes bbfication}
629 % ==========================================
630
631 % ==========================================
632 \subsubsection{Specific \texttt{xml} tags for \texttt{vtkImageAlgorithm} classes bbfication}
633 % ==========================================
634
635 % ==========================================
636 \subsubsection{Specific \texttt{xml} tags for \texttt{vtkPolyDataAlgorithm} classes bbfication}
637 % ==========================================
638
639 % ==========================================
640 \subsubsection{\bbfy \texttt{xml} tags reference}
641 % ==========================================
642
643   
644 % ==========================================
645 \begin{table}[!ht]
646 \caption{\label{xml_tags}
647 \bbfy \texttt{xml} tags reference}
648 \small
649 \begin{tabular}{|lcllm{6cm}|}
650 \hline
651 Tag & Attributes & Condition & Multiplicity & Description
652  \\ \hline
653
654 \texttt{<blackbox>} & \texttt{name} & - & 1 & The name of the box \\ \hline
655                 & \texttt{type} & - & 1 & The type of the box. In: 
656         \{\texttt{standard} (default), 
657 \texttt{ITK\_ImageToImageFilter},
658 \texttt{VTK\_ImageAlgorithm},
659 \texttt{VTK\_PolyDataAlgorithm}\} \\\hline
660 & \texttt{generic} & a) & 0-1 &
661 Generate the generic filter (see text)\\ \hline 
662
663 \texttt{<description>} & - & - & 0-n &  The description of the box. Multiple occurrence are concatenated \\\hline 
664 \texttt{<author>} & - & - & 0-n &  The author of the box. Multiple occurrence are concatenated \\\hline 
665 \texttt{<category>} & - & - & 0-1 &  The box category (if more than one, they are separated with commas) see Tab \ref{categories}\\\hline 
666 \texttt{<parentblackbox>} & - & - & 1 &  The parent black box of the box.
667 In: \{\texttt{bbtk::BlackBox, bbtk::WxBlackBox, bbtk::WxContainerBlackBox}\}\\\hline 
668 \texttt{<package>} & - & - & 1 &  The package of the box \\\hline 
669 \texttt{<namespace>} & - & - & 0-1 &  The namespace of the box. 
670 Use \texttt{bbPACKAGE}, where \texttt{PACKAGE} is the name of the package\\\hline 
671 \texttt{<include>} & - & - & 0-n & Additionnal file to include 
672 (generates : \texttt{\#include 'value'})\\\hline 
673
674 \texttt{<template>} & - & - & 0-n &  Template parameter of the box. The template parameter list is generated in the order of appearance of the tag. \\\hline 
675
676 \texttt{<itkparent>} &  - & a) &  1 & The parent itk class (with namespace) \\\hline
677
678 \texttt{<vtkparent>} &  - & b) &  1 & The parent vtk class \\\hline
679
680 \texttt{<input>} & \texttt{name} & - & 1 &  The name of the input \\\hline 
681          & \texttt{type} & - & 1 &  The type of the input \\\hline 
682          & \texttt{special} & - & 0-1 & In: \{\texttt{``itk input'', 
683 ``vtk input'', ``itk parameter'', ``vtk parameter''}\} (see below).\\\hline 
684          & \texttt{generic\_type} & c) & 0-1 & The ``generic'' type of the input (see text). \\\hline 
685 \texttt{<output>} & \texttt{name} & - & 1 &  The name of the output \\\hline 
686          & \texttt{type} & - & 1 &  The type of the output \\\hline 
687          & \texttt{special} & - & 0-1 & In: \{\texttt{``itk output'', 
688 ``vtk output''}\} (see below).\\\hline 
689          & \texttt{generic\_type} & c) & 0-1 & The ``generic'' type of the output (see text).\\\hline 
690
691 \texttt{<process>} & - & - & 0-1 & The code of the processing method of the box. Must be put between clear tags : \texttt{<PRE></PRE>} \\\hline 
692 \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 
693 \texttt{<copyconstructor>} & - & - & 0-1 & The code of the user Copy Constructor of the box . Must be put between clear tags : \texttt{<PRE></PRE>} \\\hline
694 \texttt{<destructor>} & - & - & 0-1 & The code of the user Destructor of the box. Must be put between clear tags : \texttt{<PRE></PRE>} \\\hline
695  \end{tabular}
696  \end{table}
697 % ==========================================
698 \begin{table}[!ht]
699 \caption{\label{xml_tags}
700 \bbfy \texttt{xml} tags conditions}
701 \small
702 \begin{tabular}{|ll|}
703 \hline
704 a) & \texttt{<blackbox type == ''itkImageToImageFilter''>} \\ \hline
705 b) & \texttt{<blackbox type == ''vtkImageAlgorithm'' or ''vtkPolyDataAlgorithm''>} \\ \hline
706 c) & \texttt{<blackbox type == ''itkImageToImageFilter''>} and 
707      \texttt{<blackbox generic>} is present. \\ \hline
708 \end{tabular}
709 \end{table}
710
711
712
713 % ==========================================
714 \begin{table}[!ht]
715 \caption{\label{categories}
716 \bbfy \texttt{Black Box} categories}
717 \small
718 \begin{tabular}{|ll|}
719 \hline
720  \texttt{Categ name}     & : Meaning                                          \\ \hline \\ \hline
721  \texttt{adaptor}        & : Adaptor box                                      \\ \hline
722  \texttt{application}    & : Final application, end user intended             \\ \hline
723  \texttt{atomic box}     & : System category.
724                Automatically assigned to Atomic Black Boxes (c++ defined)     \\ \hline
725  \texttt{complex box}    & : System category.
726                Automatically assigned to Complex Black Boxes (script defined) \\ \hline  
727  \texttt{command line}   & : Script which defines a command line application (no embedded GUI, but command line imput parameters) \\ \hline
728  \texttt{demo}           & : Demonstration                             \\ \hline
729  \texttt{devel}          & : Developer tool (bbCreatePackage.bbs, ...) \\ \hline
730  \texttt{dicom}          & : DICOM aware box \\ \hline 
731  \texttt{example}        & : Example script showing a box use-case      \\ \hline
732  \texttt{filter}         & : Image processing box                       \\ \hline
733  \texttt{image}          & : Image processing related box               \\ \hline
734  \texttt{interaction}    & :  \\ \hline
735  \texttt{math}           & : Mathematical operations\\ \hline
736  \texttt{mesh}           & : Mesh processing related box \\ \hline
737  \texttt{misc}           & : A box that cannot be put in other category ! \\ \hline
738  \texttt{read/write}     & : Box that read or write data from or to disk  \\ \hline
739  \texttt{viewer}         & : Box which displays some data \\ \hline
740  \texttt{widget}         & : Piece of graphical interface  \\ \hline 
741  
742  \texttt{3D object creator} & : Sophisticated 3D widget  \\ \hline  
743  \texttt{toolsbbtk}         & : Component of bbStudio    \\ \hline  
744 \end{tabular}
745 \end{table}
746
747
748 % ==========================================
749 \begin{table}[!ht]
750 \caption{\label{kinds}
751 \bbfy \texttt{Black Box} kinds}
752 \small
753 \begin{tabular}{|ll|}
754 \hline
755  \texttt{Kind}     &  Use as :     \\ \hline \\ \hline
756  \texttt{ADAPTOR} & \\ \hline
757  \texttt{DEFAULT\_ADAPTOR} & \\ \hline 
758  \texttt{ADAPTOR} & \\ \hline 
759  \texttt{WIDGET\_ADAPTOR} & \\ \hline 
760  \texttt{DEFAULT\_WIDGET\_ADAPTOR} & \\ \hline
761  \texttt{GUI} & \\ \hline 
762  \texttt{DEFAULT\_GUI} & \\ \hline 
763  \texttt{ALL} & If kind='ALL' then sets the level for all kinds\\ \hline  
764 \end{tabular}
765 \end{table}
766
767 % ==========================================
768 \subsection{\CPP description of a box}
769 % ==========================================
770
771 TO DO...
772
773 Look at the files \texttt{examples/TEMPLATE\_bbPackagenameBoxname.h/cxx}
774 and \texttt{examples/TEMPLATE\_bbPackagenameWXBoxname.h/cxx}
775
776 %\bibliography{all}
777
778
779
780 %\section{Conclusion}
781 \end{document}
782