[Insight-users] How does SimpleMemberCommand work in ThresholdSegmentationLevelSetFltkGui?

Luis Ibanez luis.ibanez at kitware.com
Mon, 05 Jan 2004 12:04:14 -0500


Hi Chunyan,


ITK uses the design pattern of Command/Observers/Event
for communicating with GUIs.

These concepts are described in the SoftwareGuide

    http://www.itk.org/ItkSoftwareGuide.pdf

Section 3.2.6, Event Handling, pdf-page 50.

You will find multiple examples on how to use observer
for monitoring the pipeline in the registration examples
in section 8.3, pdf-page 251.


You will also find details about the Command/Event
architecture in the Tutorial sessions:

           http://www.itk.org/HTML/Tutorials.htm

in particular in
http://www.itk.org/CourseWare/Training/GettingStarted-III.pdf

A family of default Command observers classes in ITK can be
found in the header file:

               Insight/Code/Common/itkCommand.h

You can derive from them, or use the ones that are templated.

What the commands are doing is to listen to the IterationEvent
sent from the ITK filters. Each time an iteration event is
invoked from the filter, the "Execute()" method of the Command
is called.   You can think about this as callbacks in any other
GUI system, or as Signals/Slots in Qt.

More examples on using Command/Event for communicating with
GUIs are available on the Tutorial session:
"ITK and Graphical User Interface"

http://www.itk.org/CourseWare/Training/GettingStarted-IV.pdf




Regards,


   Luis




----------------
jiang wrote:
> Hi ITK users,
> In the example application ThresholdSegmentationLevelSetFltkGui, when the
> segmentation is running, the output window will be updated in every
> iteration progress. I look into the code and find that it may be realized
> by:
>   // set up the segmentation observer
>   typedef itk::SimpleMemberCommand< SegmenterConsole > SimpleCommandType;
> 
>   SimpleCommandType::Pointer iterationCommand = SimpleCommandType::New();
>   iterationCommand->SetCallbackFunction( this,
>       & SegmenterConsole::UpdateViewerAfterIteration );
> 
>   m_thresholdSegmentation->AddObserver( itk::IterationEvent(),
> iterationCommand );
> 
> And another function SegmenterConsole::UpdateViewerAfterIteration draws the
> result in every iteration. I don't know how SimpleMemberCommand works in
> this case. How to evoke the iterationCommand. If I want to realize the
> similar function, what should I do?
> Please show me step by step. For example, if the first step is to click one
> button to do the segmentation work in one function Segment(), then what is
> the next step?
> 
> 
> Thank you very much!
> 
> 
> Chunyan
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>