[vtkusers] synchronous update between vtkImagePlaneWidget and vtkResliceCursorWidget

Dean Inglis inglis.dl at gmail.com
Mon Jun 24 10:44:29 EDT 2013


Hi,

try the following code snippet.  Basically, create a callback class wherein
you decide how to update the reslice cursor widget from the image plane
widget.
Add the callback to listen for the image plane widget's InteractionEvent.

regards,
Dean


class myCallback : public vtkCommand
{
  public:
    static myCallback *New() {
      return new myCallback; }

    void Execute( vtkObject* vtkNotUsed(caller), unsigned long
vtkNotUsed(event),
                  void * vtkNotUsed(callData) )
    {
      /** do something with ipwidget and rcwidget when the ipwidget fires a
           an interaction event signal */
    }

 myCallback():ipwidget( 0 ), rcwidget( 0 ){}
  ~myCallback(){ this->ipwidget= 0; this->rcwidget = 0; }
  vtkImagePlaneWidget* ipwidget;
  vtkResliceCursorWidget* rcwidget;
};


void myclass::some_setup_method()
{
  vtkSmartPointer<myCallback> cbk = vtkSmartPointer<myCallback>::New();
  cbk->ipwidget = this->ipwidget;
  cbk->rcwidget = this->rcwidget;
  this->ipwidget->AddObserver( vtkCommand::InteractionEvent, cbk );
}



On Thu, Jun 20, 2013 at 10:15 PM, nil_debug <ljp19890525 at 163.com> wrote:

> **
> Hello,
> Is anyone can help me? Now I have defined a vtkImagePlaneWidget and a
> vtkResliceCursorWidget,  I would like to when dragging the
>  vtkImagePlaneWidget the   vtkResliceCursorWidget can move.In a word  I
> don't know how to a "AddObserver" for the vtkImagePlaneWidget from
> the vtkResliceCursorWidget! I do know  I should define a "myCallBack",but
> How?
> Will be deeply grateful !
>
> ------------------------------
> nil_debug
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130624/2a076878/attachment.htm>


More information about the vtkusers mailing list