[Insight-users] example style

Luis Ibanez luis.ibanez@kitware.com
Fri, 11 Oct 2002 16:13:42 -0400


Hi Zein,

The coding style for these examples is not related to ITK
but to the fact that FLTK generates code from the GUI .fl files.

Let's repeat once again that FLTK is *not*  a requirement for ITK.
FLTK is only used as GUI for some of the examples. We could
have used Qt of wxWindows for the same purpouse (or even
MFC is we didn't care about portability).

FLTK provides a tool called "fluid" for building the GUI
interactively. Fluid generates files with extension .fl (.fd, fld)
 From this .fl file, fluid can generate .cxx and .h files. Given that
these files are generated you don't want to add any code to them
because your modifications will be lost at any change in the .fl file.

Fluid lets you create the GUI as a class and make the callbacks
be associated with member methods of the class. This results
in very clean code since all the tricky lines that delegate the
callback to the member functions are buried inside the .cxx
generated file that you will never touch.

It is easy to write the declaration of the class in fluid, but it is
quite inconvenient to write the implementation since this has
to be done with the limited editor built-in in fluid.    
The examples then, take advantage of polymorphism and move
the implementation of the methods (associated with callbacks)
to a base class and to a derived class.

The Base class contains all the code that is GUI independent.
The GUI class contains the specification of the GUI itself and
finally, the derived class contains the code that is not GUI
independent.

This structure makes possible to write a layer for other GUI
libraries like Qt since the Base class can be reused for them.

Again, this is just an FLTK issue and it is totally unrelated
with ITK architecture and coding style.


Please let us know if you have further questions.


Thanks


    Luis

===========================================


Zein Salah wrote:

> hello friends,
>
>  
>
> I have notices that most (or all) the examples of ITK have the 
> following style:
>
>  
>
> example.cpp
>
> example.h
>
> exampleBASE.cpp
>
> exampleBASE.h
>
> exampleGUI.cpp
>
> exampleGUI.h
>
> exampleGUI.fl
>
>  
>
> I have no problem in understanding the examples. But I would like to 
> understand this style of dividing the program so that I can develope 
> my programs in the same style. Can somebody explain to me on what 
> basis the program is divided this way. I mean: what should each file 
> contain. Mainly, the relation/interaction between the GUI files and 
> the other group.
>
>  
>
>  
>
> Many thank for any explanations or help,
>
>  
>
> Zein
>
>  
>
>  
>
>  
>
>  
>
>  
>
> ->8<------------->8<------------->8<------------->8<------------->8<------------->8<-
> Zein I. Salah
> Universität Tübingen, WSI-GRIS
> Sand 14
> 72076 Tübingen
> Email: salah@gris.uni-tuebingen.de 
> <mailto:salah@gris.uni-tuebingen.de>   / zeinsalah@hotmail.com 
> <mailto:zeinsalah@hotmail.com>
> Tel.: (07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat)
> Fax: (07071) 29 54 66
>