[vtkusers] (no subject)

dean.inglis at camris.ca dean.inglis at camris.ca
Tue Dec 9 20:03:21 EST 2003


Hi Thomas,

try code below...no need to add a callback to the mouse, add
it to the widget.

Dean


// Callback for the cursoring interaction
class vtkSliceCallback : public vtkCommand
{
public:

  static vtkSliceCallback *New()
    { return new vtkSliceCallback; }

  virtual void Execute(vtkObject *caller, unsigned long, void* )
    {
      vtkImagePlaneWidget *self = reinterpret_cast<vtkImagePlaneWidget*>(caller);
      self->GetWindowLevel(wl);
      if ( self->GetCursorData(xyzv) )
        {
        sprintf(buff,"( %3d, %3d, %3d ) = %d",
                static_cast<int>(xyzv[0]),
                static_cast<int>(xyzv[1]),
                static_cast<int>(xyzv[2]),
                static_cast<int>(xyzv[3]));
        }
      else
        {
        sprintf(buff,"%s","Cross hairs off");
        }
      Status->Panels->Items[0]->Text = buff;
      sprintf(buff,"W/L = %.1f, %.1f",wl[0],wl[1]);
      Status->Panels->Items[1]->Text = buff;
      Status->Update();

    }
  vtkSliceCallback():Status(0){};
  TStatusBar      *Status;  // a Borland VCL component

private:
  float xyzv[4];
  float wl[2];
  char  buff[256];
};


<in initialization>

  m_planeWidgetX           = vtkImagePlaneWidget::New();
  //
  // do some initializing of the widget ...
  //
  
  vtkSliceCallback* m_slicecb = vtkSliceCallback::New();
  m_slicecb->Status  = StatusBar;
  m_planeWidgetX->AddObserver(vtkCommand::InteractionEvent,m_slicecb);
  m_slicecb->Delete();

<snip>




More information about the vtkusers mailing list