1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
6 \def\todo{\scriptsize\fbox{\bf TODO !!}\normalsize}
8 \def\BBTK{{\xspace}The {\bf Black Box Toolkit} }
9 \def\bbtk{{\xspace}$\texttt{bbtk}$ }
10 \def\bbi{{\xspace}$\texttt{bbi}$ }
11 \def\bbStudio{{\xspace}$\texttt{bbStudio}$ }
12 \def\bbfy{{\xspace}$\texttt{bbfy}$ }
13 \def\bbdoc{{\xspace}$\texttt{bbdoc}$ }
14 \def\bbCreatePackage{{\xspace}$\texttt{bbCreatePackage}$ }
16 \def\bb{{\xspace}$\texttt{bb}$ }
17 %\def\bbp{{\xspace}$\texttt{bbp}$\xspace}
19 \def\cmake{{\xspace}$\texttt{cmake}$ }
21 \def\C{{\xspace}$\texttt{C}$ }
22 \def\CPP{{\xspace}$\texttt{C++}$ }
24 \def\xml{{\xspace}$\texttt{xml}$ }
26 \def\itk{{\xspace}$\texttt{itk}$ }
27 \def\vtk{{\xspace}$\texttt{vtk}$ }
28 \def\gdcm{{\xspace}$\texttt{gdcm}$ }
29 \def\gsmis{{\xspace}$\texttt{gsmis}$ }
30 \def\wx{{\xspace}$\texttt{wxWidgets}$ }
32 \def\lin{{\xspace}\textit{Linux} }
33 \def\win{{\xspace}\textit{Windows} }
35 % the same macros with no space at the end
37 \def\BBTKns{{\xspace}The {\bf Black Box Toolkit}}
38 \def\bbtkns{{\xspace}$\texttt{bbtk}$}
39 \def\bbins{{\xspace}$\texttt{bbi}$}
40 \def\bbfyns{{\xspace}$\texttt{bbfy}$}
41 \def\bbdocns{{\xspace}$\texttt{bbdoc}$}
42 \def\bbCreatePackagens{{\xspace}$\texttt{bbCreatePackage}$}
44 \def\bbns{{\xspace}$\texttt{bb}$}
45 %\def\bbp{{\xspace}$\texttt{bbp}$\xspace}
47 \def\cmakens{{\xspace}$\texttt{cmake}$}
49 \def\Cns{{\xspace}$\texttt{C}$}
50 \def\CPPns{{\xspace}$\texttt{C++}$}
52 \def\xmlns{{\xspace}$\texttt{xml}$}
54 \def\itkns{{\xspace}$\texttt{itk}$}
55 \def\vtkns{{\xspace}$\texttt{vtk}$}
56 \def\gdcmns{{\xspace}$\texttt{gdcm}$}
57 \def\gsmisns{{\xspace}$\texttt{gsmis}$}
58 \def\wxns{{\xspace}$\texttt{wxWidgets}$}
60 \def\linns{{\xspace}\textit{Linux}}
61 \def\winns{{\xspace}\textit{Windows}}
65 \title{The Black Box Toolkit\\Package Developers' Guide}
67 \author{Laurent Guigues}
69 % ==========================================
71 % ==========================================
77 % ==========================================
79 % ==========================================
81 % ==========================================
82 % ==========================================
84 %\section{Creating your own black boxes}
86 % ==========================================
88 % ==========================================
89 \section{Steps in the creation of new black boxes}
90 % ==========================================
91 Any black box must be included in a \bbtk package,
92 that is in a particular shared library which can be loaded
93 dynamically by \bbtk (hence applications which use \bbtkns,
94 such as the interpreter \bbi, launched by the development environment
98 \item \textbf{Create a new package. }
99 Before defining any black box you
100 have to create a package, or more precisely
101 the files which will allow you to generate the package
102 (compile and link the shared library) and may be install it.
103 \texttt{bbStudio} does it for you.
108 \item The black boxes you want to create are based on
109 a processing code (\CPP classes or \C functions) which
110 is in an existing project handled by \cmake
111 and you want the new package to be part of your existing project.
112 You will have to create your new package into the source tree of your
114 \item You do not have an already existing project (you want
115 to create the new boxes from scratch) or you want/are imposed
116 that the existing project remain external to the package project.
117 You will have to create your new package in a new location and
118 may be include/link against existing libraries.
121 \item \textbf{Describe your new box. }
122 You can do it either :
124 \item In \CPP code. You will have to write the class for
125 your box, mostly using \bbtk macros.
127 When configuring your project with \cmake,
128 the utility \bbfy will then generate the corresponding \CPP code.
133 % ==========================================
134 \section{Creating a new black box package}
135 % ==========================================
137 Run \texttt{bbStudio}.
139 You'll get something like in fig. \ref{bb-Studio}
142 \caption{\label{bb-Studio} bbStudio}
144 \includegraphics[width=0.6\textwidth]{bbStudio.png}
148 Use the option \texttt{Create package} of the menu \texttt{Tools}.
150 You will be asked to choose the directory where you want to create the package,
151 then you'll get something like in fig. \ref{bbCreatePackage}.
155 \caption{\label{bbCreatePackage} Create Package}
157 \includegraphics[width=0.6\textwidth]{bbCreatePackage.png}
162 That will creates the directory structure and the \texttt{cmake}
163 files necessary to build the project.
165 You must then decide the name of your new package.
166 This name will be used to load the package in \texttt{bbi}.
167 Fill up the form like in fig. \ref{bbFillUpPackageForm}.
171 \caption{\label{bbFillUpPackageForm} Fill up the form}
173 \includegraphics[width=0.6\textwidth]{bbFillUpPackageForm.png}
177 Edit the file \texttt{MyPackage/CMakeLists.txt} to customize your package
180 the file tree obtained is :
183 >tree myPackageFolder
188 |-- PackageConfig.cmake.in
190 |-- UsePackage.cmake.in
202 | | |-- CMakeLists.txt
203 | | `-- header.html.in
206 | |-- DoxyMainPage.txt.in
207 | `-- Doxyfile.txt.in
211 9 directories, 16 files
214 The directory \texttt{MyPackage} is the directory of your new package,
215 in which you will create the files describing your black boxes.
216 But first, you have to customize your new package, by editing the file
217 \texttt{CMakeLists.txt} in the \texttt{MyPackage} directory.
220 \begin{file}{MyPackage/CMakeLists.txt}
223 #===========================================================================
224 # CMAKE SETTINGS FOR BUILDING A BBTK PACKAGE
225 #===========================================================================
227 #===========================================================================
228 # THE NAME OF THE BBTK PACKAGE
229 SET(BBTK_PACKAGE_NAME MyPackage)
230 #===========================================================================
232 #===========================================================================
233 # IF IT IS A STANDALONE PROJECT UNCOMMENT NEXT LINE TO DECLARE YOUR PROJECT
234 # PROJECT(bb${BBTK_PACKAGE_NAME})
235 #===========================================================================
237 #===========================================================================
239 # !!! NO COMMA ALLOWED !!!
240 SET(${BBTK_PACKAGE_NAME}_AUTHOR "myself")
241 #===========================================================================
243 #===========================================================================
244 # PACKAGE DESCRIPTION
245 SET(${BBTK_PACKAGE_NAME}_DESCRIPTION "The kinkiest stuff you ve ever seen.")
246 #===========================================================================
248 #===========================================================================
249 # PACKAGE VERSION NUMBER
250 SET(${BBTK_PACKAGE_NAME}_MAJOR_VERSION 1)
251 SET(${BBTK_PACKAGE_NAME}_MINOR_VERSION 0)
252 SET(${BBTK_PACKAGE_NAME}_BUILD_VERSION 0)
253 #===========================================================================
255 #===========================================================================
256 # UNCOMMENT EACH LIBRARY NEEDED (WILL BE FOUND AND USED AUTOMATICALLY)
257 # SET(${BBTK_PACKAGE_NAME}_USE_VTK ON)
258 # SET(${BBTK_PACKAGE_NAME}_USE_ITK ON)
259 # SET(${BBTK_PACKAGE_NAME}_USE_GDCM ON)
260 # SET(${BBTK_PACKAGE_NAME}_USE_GSMIS ON)
261 # SET(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS ON)
262 #===========================================================================
264 #===========================================================================
265 # LIST HERE THE OTHER bbtk PACKAGES NEEDED
266 # (WILL BE FOUND AND USED AUTOMATICALLY)
267 SET(${BBTK_PACKAGE_NAME}_USE_PACKAGES
274 #===========================================================================
276 #===========================================================================
277 # THE SOURCES OF THE PACKAGE
278 # EITHER UNCOMMENT NEXT LINE TO COMPILE ALL .cxx OF THE src DIRECTORY :
279 SET(${BBTK_PACKAGE_NAME}_COMPILE_ALL_CXX ON)
280 # ... OR LIST THE FILES TO COMPILE MANUALLY :
281 #SET(${BBTK_PACKAGE_NAME}_SOURCES
282 # LIST HERE THE FILES TO COMPILE TO BUILD THE LIB
283 # E.G. TO COMPILE "toto.cxx" ADD "toto" (NO EXTENSION)
284 # THE PATH MUST BE RELATIVE TO THE src FOLDER
286 #===========================================================================
288 #===========================================================================
289 # THE xml SOURCES OF THE PACKAGE
290 # EITHER UNCOMMENT NEXT LINE TO bbfy ALL .xml OF THE src DIRECTORY :
291 SET(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML ON)
292 # ... OR LIST THE FILES TO COMPILE MANUALLY :
293 #SET(${BBTK_PACKAGE_NAME}_XML_SOURCES
294 # LIST HERE THE FILES TO bbfy TO BUILD THE LIB
295 # E.G. TO bbfy "toto.xml" ADD "toto" (NO EXTENSION)
296 # THE PATH MUST BE RELATIVE TO THE src FOLDER
298 #===========================================================================
300 #===========================================================================
301 # THE SCRIPT-DEFINED BOXES OF THE PACKAGE (bbs)
302 # EITHER UNCOMMENT NEXT LINE TO INCLUDE ALL .bbs OF THE bbs/boxes DIRECTORY :
303 SET(${BBTK_PACKAGE_NAME}_INCLUDE_ALL_BBS_BOXES ON)
304 # ... OR LIST THE FILES TO INCLUDE MANUALLY :
305 # SET(${BBTK_PACKAGE_NAME}_BBS_BOXES
306 # LIST HERE THE bbs FILES TO INCLUDE
307 # E.G. TO INCLUDE "boxes/bbtoto.bbs" ADD "boxes/bbtoto" (NO EXTENSION)
308 # !! THE PATH MUST BE RELATIVE TO THE bbs FOLDER !!
310 #===========================================================================
312 #===========================================================================
313 # THE SCRIPT-DEFINED APPLICATIONS OF THE PACKAGE (bbs)
314 # EITHER UNCOMMENT NEXT LINE TO INCLUDE ALL .bbs OF THE bbs/appli DIRECTORY :
315 SET(${BBTK_PACKAGE_NAME}_INCLUDE_ALL_BBS_APPLI ON)
316 # ... OR LIST THE FILES TO INCLUDE MANUALLY :
317 # SET(${BBTK_PACKAGE_NAME}_BBS_APPLI
318 # LIST HERE THE bbs FILES TO INCLUDE
319 # E.G. TO INCLUDE "appli/testToto.bbs" ADD "appli/testToto" (NO EXTENSION)
320 # !! THE PATH MUST BE RELATIVE TO THE bbs FOLDER !!
322 #===========================================================================
324 #===========================================================================
325 SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS
326 # LIST HERE YOUR ADDITIONAL INCLUDE DIRECTORIES
330 # - automatically handled libraries or packages : wx, vtk... (see above)
331 # - the dirs automatically set by other libraries found by FIND_PACKAGE
333 #===========================================================================
335 #===========================================================================
336 SET(${BBTK_PACKAGE_NAME}_LIBS
337 # LIST HERE THE ADDITIONAL LIBS TO LINK AGAINST
338 # EXCEPT : the same libs than for INCLUDE_DIRS
340 #===========================================================================
342 #===========================================================================
343 # IF NEEDED : UNCOMMENT NEXT LINE
344 # AND LIST ADDITIONNAL DIRECTORIES
345 # IN WHICH TO LOOK FOR LIBRARIES TO LINK AGAINST
347 #===========================================================================
349 #===========================================================================
350 # SET TO TRUE TO HAVE INFORMATION ON LIBRARIES FOUND DURING CMAKE CONFIGURE
351 SET(FIND_PACKAGE_VERBOSE TRUE)
352 #===========================================================================
354 #===========================================================================
355 # END OF USER SECTION
356 #===========================================================================
358 #===========================================================================
359 # Include configuration script
360 INCLUDE(Configure.cmake)
361 #===========================================================================
363 #===========================================================================
365 #===========================================================================
370 The comments in the file should be easily understandable !
371 You have to customize the lines which are enclosed
372 between dashed comment lines.
373 In these sections, you can see some of the informations you supplied in previous step:
375 \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
376 \lin the object file will be called \texttt{libbb}name\texttt{.so}
377 and on \win it will be called \texttt{bb}name\texttt{.dll}.
378 \item The \textbf{author(s)} of the package. Preferably provide e-mail adresses.
379 \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.
382 In these sections, you can set :
385 \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.
387 \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.
388 \item The \textbf{version} of the package.
389 \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.
390 \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.
391 \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...).
392 \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...).
395 Of course, this is only a framework and you can add any other \cmake commands
398 % ==========================================
399 \section{Creating a new box}
400 % ==========================================
402 % ==========================================
403 \subsection{Principles}
404 % ==========================================
406 \subsubsection{\texttt{C++} or \texttt{XML} ?}
407 There are two ways to create a new black box in an existing package :
409 \item Write an \xml description file which will be automatically
410 translated in \CPP by the \bbfy application (recommanded).
411 \item Write the \CPP code of the box using \bbtk macros.
414 \subsubsection{From which \bbtk class inherit ?}
416 Apart from this choice of the description langage to use,
417 there is an important choice to do concerning the implementation of the box.
418 In \CPP, a black box is nothing but a class which has the standard
419 interface of all black boxes : what's its name ? inputs ? outputs ? and so on.
422 The abstract description of this interface is done in the class
423 \texttt{bbtk::BlackBox} and is implemented in its child classes :
424 \texttt{bbtk::AtomicBlackBox} and \texttt{bbtk::WxBlackBox}
425 \footnote{all the classes of the \bbtk library are in a \emph{namespace}
427 and the \CPP header of a class called \texttt{NameOfAClass} is
428 in the file called \texttt{bbtkNameOfAClass.h}}.
429 To create a new black box, you have to inherit one of these two
430 concrete classes in order to inherit the black box interface and a
431 particular implementation of this interface.
432 If your black box is a \emph{Widget} black box,
433 that is a black box which has (or is)
434 a piece of a graphical interface based on the \wx library,
435 then it must inherit the class \texttt{bbtk::WxBlackBox}.
437 Concretely, a \texttt{bbtk::WxBlackBox} is associated to
438 a \texttt{wxWindow} and must be able to return a pointer to it.
439 If your black box is not a widget black box
440 (that is : doesn't returns a pointer to a \emph{Widget}),
441 it must inherit from \texttt{bbtk::AtomicBlackBox}.
443 \subsubsection{Inherit or encapsulate ?}
445 Now, your black box will do something (hopefully !).
446 When you decide to write a new black box,
447 you should be in one of these three cases :
449 \item You already have a \texttt{C}-like function which
450 does the processing that you wish to 'blackboxify'
451 \item You already have a \CPP class which
452 does the processing that you wish to 'blackboxify'
453 \item You start from scratch without any existing code
456 The idea of \BBTK is to embed processing codes into
457 \CPP objects which have a standard and generic interface -
458 namely black boxes - to be able to chain arbitrary
459 processes afterwards.
461 In \CPP, in order to embed an existing processing \emph{class}
462 into a standard interface you only have two possibilities :
464 \item {\bf Inherit} the existing processing class
465 \emph{and} the interface class (e.g. \texttt{bbtk::AtomicBlackBox}).
466 In this case you have to :
468 \item make the link between the inputs and outputs of the black box
469 and the interface of the inherited class
470 \item call the processing
471 method of the inherited class in the processing method of the black box.
473 \item {\bf Encapsulate} the existing processing class
474 in a class inherited from
475 the interface class (e.g. \texttt{bbtk::AtomicBlackBox}).
476 In this case you have to :
478 \item declare it as a member of the black box,
479 \item instantiate it at the right time
480 (either in the constructor or in the processing method of the black box)
481 \item in the processing method of the black box :
483 \item set the inputs of the member procesing class with the inputs of the black box,
484 \item call the processing method of the encapsulated class
485 \item set the ouputs of the black box with the outputs of the encapsulated
491 If you wish to 'blackboxify' a C-like \emph{function},
492 you do not have the choice, you can only use the second mechanism,
493 namely encapsulation.
495 Obviously, the inheritance mechanism is more powerfull
496 and - when it is possible to use it - it demands less effort
497 because, as we will see, in \bbtk you can directly
498 link the accessors to the input and output data of the box
499 to the accessors of the inherited processing class,
500 as well as the procesing method of the black box
501 to the processing method of the inherited processing class,
502 very much like a callback mechanism.
504 \subsubsection{How to generate a Black Box skeleton}
506 Run \texttt{bbStudio}, choose \texttt{Tools} in the menu bar, option
507 \texttt{Create Black Box}.
508 You will be shown something like in fig. \ref{bbCreateBlackbox} :
511 \caption{\label{bbCreateBlackbox}Create Black Box}
513 \includegraphics[width=0.6\textwidth]{bbCreateBackbox.png}
518 \subsubsection{Informations to provide}
520 Finally, to create a new black box, you will have to give :
522 \item The {\bf name} of the box
523 \item The {\bf package} to which the box belongs (can we do it automatically ? LG : think about it)
524 \item The {\bf author}(s) of the box
525 \item A {\bf description} of the box
527 \item Its {\bf type}, either
529 \item a standard one (\texttt{std-template})
530 \item a VTK Polydata Algorithm based box (\texttt{VTK\_PolydataAlgorithm-template}),
531 \item a VTK Image Algorithm based box (\texttt{VTK\_ImageaAlgorithm-template}),
532 \item if it uses the wxWidget Library (\texttt{widget-template})
535 \item The output format of the file, either a C++ file or an XML file.
537 %\item $[$Optional$]$ The additional {\bf include files} which are necessary for the code to compile (classes or functions declarations ...)
538 %\item $[$Optional$]$ The other {\bf parent(s)} of the box (which must be known hence their header included)
539 %\item $[$Optional$]$ The {\bf namespace} to which the box belongs
540 %\item The box {\bf inputs} and {\bf outputs}, and for each one :
542 %\item Its {\bf name} : the string which will identify the input or output
543 %\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.
544 %\item Its {\bf help} : a string describing the input / output
546 %\item Its {\bf processing} code, which can be a simple callback or an arbitrary complex code
550 Under Linux, for reasons we shall not discuss here, you'll get an error message :
552 \texttt{No such file or directory}
554 Have a look at the console, you'll see a shell command (whose syntax is OK although there is is a lot of
555 quotes),something like :
557 \texttt{ "/usr/local/bin/bbCreateBlackBox" "/home/jpr/Desktop/essai" MyPackage
558 myVtkPolydataBlackBox VTK-PolyDataAlgorithm C++ 'author1, author2' 'myVtkPolydataBlackBox description'}
560 Just copy the command, and run it manually.
562 \subsubsection{Input and output accessors}
564 When you encapsulate a processing class or a C function
565 or when you write down a black box from scratch,
566 you must access the inputs and outputs of the black box,
567 in order to interface it manually with your processing method
568 or simply write your processing code
569 (there are other cases in which you also need to access the
570 inputs and outputs, we will talk about them later).
572 The only thing you must know about the \CPP code generated
573 from your \xml or your \CPP macro-based description
574 is that when you declare an input
575 or an output of a black box then
576 two \emph{accessors} for this input or output are generated :
577 one to \emph{get} the value of the input or output and
578 one to \emph{set} it.
579 These accessors have normalized names :
582 \item The declaration of an {\bf input} called \texttt{NAME} and
583 of type \texttt{TYPE} generates the two accessors
584 \footnote{For the sake of simplicity, the parameters and return value are
585 shown here as if they were all passed by value.
586 However the actual code can use references.
587 The same way, the issue of const or non const methods is eluded here.
588 Different cases occur in practice.}:
590 \item \texttt{void bbSetInput<NAME>(<TYPE>);}
591 \item \texttt{<TYPE> bbGetInput<NAME>();}
593 \item The declaration of an {\bf output} called \texttt{NAME} and
594 of type \texttt{TYPE} generates the two accessors:
596 \item \texttt{void bbSetOutput<NAME>(<TYPE>);}
597 \item \texttt{<TYPE> bbGetOutput<NAME>();}
601 For example, declaring an input called \texttt{Image}
602 would generate the two accessors \texttt{bbSetInputImage} and
603 \texttt{bbGetInputImage}.
607 \item All \bbtk methods are prefixed by \texttt{bb}
608 to avoid conflicts with potential inherited methods.
609 \item An input and an output can have the same name (e.g. 'Image').
610 No conflict between accessors occur (e.g.
611 four distinct accessors are created :
612 \texttt{bbSetInputImage},
613 \texttt{bbGetInputImage},
614 \texttt{bbSetOutputImage} and
615 \texttt{bbGetOutputImage}).
618 % ==========================================
619 \subsection{\texttt{XML} description of a box}
620 % ==========================================
622 % ==========================================
623 \subsubsection{General \texttt{xml} tags}
624 % ==========================================
626 Let us examine the \texttt{xml} file
627 describing the \texttt{Add} box of the \texttt{std} package :
629 \begin{file}{\texttt{packages/std/src/bbAdd.xml}}
632 <?xml version="1.0" encoding="iso-8859-1"?>
634 <blackbox name="Add">
636 <author>laurent.guigues@creatis.insa-lyon.fr </author>
637 <description>Adds its inputs </description>
638 <category>math </category>
640 <input name="In1" type="double" description="First number to add"/>
641 <input name="In2" type="double" description="Second number to add"/>
642 <output name="Out" type="double" description="Result"/>
645 bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
658 The tags and their role are easily understandable.
660 As the box is not a widget, we inherit implicitely from
661 \texttt{bbtk::AtomicBlackBox}.
664 The only part of the file which needs a bit of explaination is
665 the body of the \texttt{process} tag, which describes the
666 actual code to execute in the box.
667 This code must be enclosed in a \texttt{<PRE></PRE>} tag
668 to tell the \xml parser not to interpret it as \xml instructions.
669 This is necessary to be able to use any symbol,
670 like the \texttt{<} and \texttt{>} which have a
671 special meaning in \xml.
672 In the case of the \texttt{Add} box, the process code
673 is very simple : remember that
674 \texttt{bbGetInputIn1()} is the
675 accessor to the input \texttt{In1} declared above and
676 \texttt{bbGetInputIn2()} is the
677 accessor to the input \texttt{In2};
678 the code simply adds the values of the two inputs
679 and sets the output \texttt{Out} with the resulting value.
681 To describe your own black boxes in \xml code,
682 you must modify the xml file generated in previous step :
685 \item Complete the description and author tags if you feel like.
686 \item add the \texttt{\#include} directives to be put in the generated \texttt{.h} file
687 \item Create your inputs and outputs
688 \item Fill in the process tag
689 \item Fill in the constructor tag
690 \item Fill in the copyconstructor tag
691 \item Fill in the destructor tag
696 % ==========================================
697 \subsubsection{Specific \texttt{xml} tags for \texttt{itk::ImageToImageFilter} classes bbfication}
698 % ==========================================
700 % ==========================================
701 \subsubsection{Specific \texttt{xml} tags for \texttt{vtkImageAlgorithm} classes bbfication}
702 % ==========================================
705 <blackbox name="..." type="VTK\_ImageAlgorithm">
707 <vtkparent>the vtk ImageAlgorithm class it inherits from</vtkparent>
708 <input name="..." type="double" special="vtk parameter" description="..."/>
709 <input name="..." type="vtkImageData*" special="vtk output" description="..."/>
711 <output name="..." type="double" special="vtk parameter" description="..."/>
712 <output name="..." type="vtkImageData*" special="vtk output" description="..."/>
714 % ==========================================
715 \subsubsection{Specific \texttt{xml} tags for \texttt{vtkPolyDataAlgorithm} classes bbfication}
716 % ==========================================
718 <blackbox name="..." type="VTK\_PolyDataAlgorithm">
720 <vtkparent>the vtk Polydata class it inherits from</vtkparent>
721 <input name="..." type="double" special="vtk parameter" description="..."/>
722 <input name="..." type="vtkPolyData*" special="vtk output" description="..."/>
724 <output name="..." type="double" special="vtk parameter" description="..."/>
725 <output name="..." type="vtkPolyData*" special="vtk output" description="..."/>
728 % ==========================================
729 \subsubsection{\bbfy \texttt{xml} tags reference}
730 % ==========================================
733 % ==========================================
735 \caption{\label{xml_tags}
736 \bbfy \texttt{xml} tags reference}
738 \begin{tabular}{|lcllm{6cm}|}
740 Tag & Attributes & Condition & Multiplicity & Description
743 \texttt{<blackbox>} & \texttt{name} & - & 1 & The name of the box \\ \hline
744 & \texttt{type} & - & 1 & The type of the box. In:
745 \{\texttt{standard} (default),
746 \texttt{ITK\_ImageToImageFilter},
747 \texttt{VTK\_ImageAlgorithm},
748 \texttt{VTK\_PolyDataAlgorithm}\} \\\hline
749 & \texttt{generic} & a) & 0-1 &
750 Generate the generic filter (see text)\\ \hline
752 \texttt{<description>} & - & - & 0-n & The description of the box. Multiple occurrence are concatenated \\\hline
753 \texttt{<author>} & - & - & 0-n & The author of the box. Multiple occurrence are concatenated \\\hline
754 \texttt{<category>} & - & - & 0-1 & The box category (if more than one, they are separated with commas) see Tab \ref{categories}\\\hline
755 \texttt{<parentblackbox>} & - & - & 1 & The parent black box of the box.
756 In: \{\texttt{bbtk::BlackBox, bbtk::WxBlackBox, bbtk::WxContainerBlackBox}\}\\\hline
757 \texttt{<package>} & - & - & 1 & The package of the box \\\hline
758 \texttt{<namespace>} & - & - & 0-1 & The namespace of the box.
759 Use \texttt{bbPACKAGE}, where \texttt{PACKAGE} is the name of the package\\\hline
760 \texttt{<include>} & - & - & 0-n & Additionnal file to include
761 (generates : \texttt{\#include 'value'})\\\hline
763 \texttt{<template>} & - & - & 0-n & Template parameter of the box. The template parameter list is generated in the order of appearance of the tag. \\\hline
765 \texttt{<itkparent>} & - & a) & 1 & The parent itk class (with namespace) \\\hline
767 \texttt{<vtkparent>} & - & b) & 1 & The parent vtk class \\\hline
769 \texttt{<input>} & \texttt{name} & - & 1 & The name of the input \\\hline
770 & \texttt{type} & - & 1 & The type of the input \\\hline
771 & \texttt{special} & - & 0-1 & In: \{\texttt{``itk input'',
772 ``vtk input'', ``itk parameter'', ``vtk parameter''}\} (see below).\\\hline
773 & \texttt{generic\_type} & c) & 0-1 & The ``generic'' type of the input (see text). \\\hline
774 \texttt{<output>} & \texttt{name} & - & 1 & The name of the output \\\hline
775 & \texttt{type} & - & 1 & The type of the output \\\hline
776 & \texttt{special} & - & 0-1 & In: \{\texttt{``itk output'',
777 ``vtk output''}\} (see below).\\\hline
778 & \texttt{generic\_type} & c) & 0-1 & The ``generic'' type of the output (see text).\\\hline
779 & \texttt{nature} & c) & 0-1 & The ``nature'' of the output (used for automatic GUI generation).\\\hline
781 \texttt{<process>} & - & - & 0-1 & The code of the processing method of the box. Must be put between clear tags : \texttt{<PRE></PRE>} \\\hline
782 \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
783 \texttt{<copyconstructor>} & - & - & 0-1 & The code of the user Copy Constructor of the box . Must be put between clear tags : \texttt{<PRE></PRE>} \\\hline
784 \texttt{<destructor>} & - & - & 0-1 & The code of the user Destructor of the box. Must be put between clear tags : \texttt{<PRE></PRE>} \\\hline
787 % ==========================================
789 \caption{\label{xml_tags}
790 \bbfy \texttt{xml} tags conditions}
792 \begin{tabular}{|ll|}
794 a) & \texttt{<blackbox type == ''ITK\_ImageToImageFilter''>} \\ \hline
795 b) & \texttt{<blackbox type == ''VTK\_ImageAlgorithm'' or ''VTK\_PolyDataAlgorithm''>} \\ \hline
796 c) & \texttt{<blackbox type == ''ITK\_ImageToImageFilter''>} and
797 \texttt{<blackbox generic>} is present. \\ \hline
802 \caption{\label{basic_parent}}
803 \bbfy \texttt{Basic box parent}
805 \begin{tabular}{|ll|}
807 \texttt{bbtk::WxBlackBox}b) & If the blackbox associated to
808 a \texttt{wxWindow} and is be able to return a pointer to it.... \\ \hline
809 \texttt{bbtk::AtomicBlackBox} & Any other blackbox that doesn't return a pointer to a \texttt{wxWindow}
817 % ==========================================
819 \caption{\label{categories}
820 \bbfy \texttt{Black Box} categories}
822 \begin{tabular}{|ll|}
824 \texttt{Categ name} & : Meaning \\ \hline \\ \hline
825 \texttt{adaptor} & : Adaptor box \\ \hline
826 \texttt{application} & : Final application, end user intended \\ \hline
827 \texttt{atomic box} & : System category.
828 Automatically assigned to Atomic Black Boxes (c++ defined) \\ \hline
829 \texttt{complex box} & : System category.
830 Automatically assigned to Complex Black Boxes (script defined) \\ \hline
831 \texttt{command line} & : Script which defines a command line application (no embedded GUI, but command line imput parameters) \\ \hline
832 \texttt{demo} & : Demonstration \\ \hline
833 \texttt{devel} & : Developer tool (bbCreatePackage.bbs, ...) \\ \hline
834 \texttt{dicom} & : DICOM aware box \\ \hline
835 \texttt{example} & : Example script showing a box use-case \\ \hline
836 \texttt{filter} & : Image processing box \\ \hline
837 \texttt{image} & : Image processing related box \\ \hline
838 \texttt{interaction} & : \\ \hline
839 \texttt{math} & : Mathematical operations\\ \hline
840 \texttt{mesh} & : Mesh processing related box \\ \hline
841 \texttt{misc} & : A box that cannot be put in other category ! \\ \hline
842 \texttt{read/write} & : Box that read or write data from or to disk \\ \hline
843 \texttt{viewer} & : Box which displays some data \\ \hline
844 \texttt{widget} & : Piece of graphical interface \\ \hline
846 \texttt{3D object creator} & : Sophisticated 3D widget \\ \hline
847 \texttt{toolsbbtk} & : Component of bbStudio \\ \hline
852 % ==========================================
854 \caption{\label{kinds}
855 \bbfy \texttt{Black Box} kinds}
857 \begin{tabular}{|ll|}
859 \texttt{Kind} & Use as : \\ \hline \\ \hline
860 \texttt{ADAPTOR} & \\ \hline
861 \texttt{DEFAULT\_ADAPTOR} & \\ \hline
862 \texttt{WIDGET\_ADAPTOR} & \\ \hline
863 \texttt{DEFAULT\_WIDGET\_ADAPTOR} & \\ \hline
864 \texttt{GUI} & \\ \hline
865 \texttt{DEFAULT\_GUI} & \\ \hline
866 \texttt{ALL} & If kind='ALL' then sets the level for all kinds\\ \hline
871 % ==========================================
873 \caption{\label{nature}
874 \bbfy \texttt{nature}}
876 \begin{tabular}{|ll|}
878 \texttt{Nature} & : used for \\ \hline \\ \hline
880 \texttt{file name} & Poping up a File Selector\\ \hline
881 \texttt{directory name} & Poping up a Directory Selector\\ \hline
882 \texttt{file extension} & \\ \hline
883 \texttt{colour} & Poping up a Colour Selector\\ \hline
884 \texttt{pixel type} & \\ \hline
885 \texttt{image dimension} & \\ \hline
886 \texttt{image index} & \\ \hline
887 \texttt{image size} & \\ \hline
888 \texttt{voxel size} & \\ \hline
892 % ==========================================
893 \subsection{\CPP description of a box}
894 % ==========================================
896 Almost everything is performed usig macros.
898 For a quick start, the best you have to do is to run \texttt{bbStudio}, then in the menu \texttt{Tools}, choose the item
899 \texttt{Create blackbox}, click on \texttt{C++}, and have a look to the generated files.
901 % ==========================================
902 \subsubsection{\texttt{.h} description of a box}
903 % ==========================================
905 \item \texttt{namespace} : your package name.
906 \item \texttt{class} : the name of your box
907 \item \texttt{public inheritance} :
909 \item{bbtk::WxBlackBox}
910 Your Black Box is intended to return a wxWidget, able to be included into an other one (you choosed
911 \texttt{widget-template} for \texttt{Type of the blackbox} )
912 \item{bbtk::AtomicBlackBox}
913 Your Black box is any processig box (std, ITK or VTK based)
914 \item{any processing class} (ITK, VTK, ...) your box inherits.
916 \item \texttt{BBTK\_BLACK\_BOX\_INTERFACE} : (yourBoxName, the list of the classes it inherits from, VTK Parent -if any-).
917 Yes, we know it's redundant with previous point... That's why we allow you to describe your class in xml format!
918 \item \texttt{bbUserConstructor} declaration of your own callback function, that will be called in the box constructor method
919 \item \texttt{bbUserCopyConstructor} declaration of your own callback function, that will be called in the box copy constructor method
920 \item \texttt{bbUserDestructor} declaration of your own callback function, that will be called in the box destructor method
921 \item \texttt{BBTK\_DECLARE\_INPUT} : input parameter name (as it will appear to the users of your black box),
922 C++ type of the parameter (e.g. double, std::string, vtkImageData*, ...)
923 \item \texttt{BBTK\_DECLARE\_OUTPUT} : output parameter name (as it will appear to the users of your black box),
924 C++ type of the parameter (e.g. double, std::string, vtkImageData*, ...
925 \item \texttt{BBTK\_DECLARE\_VTK\_INPUT} Declares a vtkAlgorithm-inherited AtomicBlackBox input
926 \item \texttt{BBTK\_DECLARE\_VTK\_OUTPUT} Declares a vtkAlgorithm-inherited AtomicBlackBox output
927 \item \texttt{BBTK\_DECLARE\_VTK\_PARAM} Declares an AtomicBlackBox input corresponding to an inherited vtk parameter
928 (you know, the ones that are declared by vtkSetMacro/vtkGetMacro). Its name must be the same than the vtk parameter name
929 \item \texttt{BBTK\_DECLARE\_VTK\_IMAGE\_ALGORITHM\_INPUT} Declares a vtkImageAlgorithm-inherited AtomicBlackBox input
930 \item \texttt{BBTK\_DECLARE\_VTK\_POLY\_DATA\_ALGORITHM\_INPUT} Declares a vtkPolyDataAlgorithm-inherited AtomicBlackBox input
931 \item \texttt{BBTK\_PROCESS} Defines the default bbUserProcess method for vtk inherited black boxes (actually : calls vtkParent::Update)
933 \item \texttt{BBTK\_BEGIN\_DESCRIBE\_BLACK\_BOX} :
934 (yourBoxName, \texttt{bbtk::WxBlackBox} or \texttt{bbtk::AtomicBlackBox} depending on what you
935 black box inherits from).
936 Yes, we know it's redundant with public inheritance ... That's why we allow you to describe your class in xml format!
937 All the following items will be used in the Help interface; describe them carefully (i.e. in a Human understandable way!).
938 \item \texttt{BBTK\_NAME} : the name of your box
939 \item \texttt{BBTK\_AUTHOR} : author name (better you put e-mail adress)
940 \item \texttt{BBTK\_DESCRIPTION} : brief description of what does the box
941 \item \texttt{BBTK\_CATEGORY} :box category (see table \ref{categories})
942 \item \texttt{BBTK\_INPUT} for each one of the input parameters, you have to supply :
944 \item The current Blackbox name.
945 \item The parameter name
946 \item A brief description of what the parameter is used for.
947 \item The C++ type of the parameter (e.g. double, std::string, vtkImageData*, ...)
948 \item The nature of the parameter (see table \ref{nature}) if you wish your box may be used by automatic GUI generator.
949 Supply an empty string ("") if you don't care.
951 \item \texttt{ BBTK\_OUTPUT} for each one of the output parameters, you have to supply :
953 \item The current Blackbox name.
954 \item The parameter name
955 \item A brief description of what the parameter is used for.
956 \item The C++ type of the parameter (e.g. double, std::string, vtkImageData*, ...)
958 \item \texttt{BBTK\_END\_DESCRIBE\_BLACK\_BOX} : means the torture is (almost) over.
960 % ==========================================
961 \subsubsection{\texttt{.cxx} description of a box}
962 % ==========================================
964 \item \texttt{BBTK\_ADD\_BLACK\_BOX\_TO\_PACKAGE} : (Package name, Blackbox name)
965 \item \texttt{BBTK\_BLACK\_BOX\_IMPLEMENTATION} : (Blackbox name, Blackbox basic parent \\ (bbtk::AtomicBlackBox/ bbtk::WxBlackBox)see :\label{basic_parent}
966 \item \texttt{Process} :definition of your own callback function, that will be called in the box method. \\ At least, you'll write here the default initialisation of the outputs
967 \item \texttt{UserConstructor} : definition of your own callback function, that will be called in the box constructor method. \\
968 At least, you'll write here the default initialisation of the inputs (to avoid unpredictable behaviour if user forgets to
969 Set/Connect any Input).
970 \item \texttt{UserCopyConstructor} : definition of your own callback function, that will be called in the box copy constructor method
971 \item \texttt{UserDestructor} : definition of your own callback function, that will be called in the box destructor method
980 %\section{Conclusion}