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