[vtkusers] vtkSeedWidget

Ken Urish ken.urish at gmail.com
Tue Apr 29 12:44:07 EDT 2008


Karthik

Yes I am passing vtkImageReslice through an actor.
No, I am not declaring any bounds on the reslice. I am using the
example based off the ImageReslice test file. I assume I should set
the bounds in the Reslice callback (below). Could you offer me what
command to use? I dont see object that looks like it will set bounds?
I really appreciate your help with this, I was up most of last night
trying to power through it.
Thanks, Ken

//------------------------------------------------------------------------------
// IMAGE RESLICE CALLBACK
// The mouse motion callback, to turn "Slicing" on and off
//-------------------------------------------------------------------------------
class vtkImageInteractionCallback : public vtkCommand
{
public:

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

  vtkImageInteractionCallback() {
    this->Slicing = 0;
    this->ImageReslice = 0;
    this->Interactor = 0; };

  void SetImageReslice(vtkImageReslice *reslice) {
    this->ImageReslice = reslice; };

  vtkImageReslice *GetImageReslice() {
    return this->ImageReslice; };

  void SetInteractor(vtkRenderWindowInteractor *interactor) {
    this->Interactor = interactor; };

  vtkRenderWindowInteractor *GetInteractor() {
    return this->Interactor; };

  virtual void Execute(vtkObject *, unsigned long event, void *)
    {
    vtkRenderWindowInteractor *interactor = this->GetInteractor();

    int lastPos[2];
    interactor->GetLastEventPosition(lastPos);
    int currPos[2];
    interactor->GetEventPosition(currPos);

    if (event == vtkCommand::LeftButtonPressEvent)
      {
      this->Slicing = 1;
      }
    else if (event == vtkCommand::LeftButtonReleaseEvent)
      {
      this->Slicing = 0;
      }
    else if (event == vtkCommand::MouseMoveEvent)
      {
      if (this->Slicing)
        {
        vtkImageReslice *reslice = this->ImageReslice;

        // Increment slice position by deltaY of mouse
        int deltaY = (lastPos[1] - currPos[1]);

        reslice->GetOutput()->UpdateInformation();
        double sliceSpacing = reslice->GetOutput()->GetSpacing()[2];
        vtkMatrix4x4 *matrix = reslice->GetResliceAxes();
        // move the center point that we are slicing through
        double point[4];
        double center[4];
        point[0] = 0.0;
        point[1] = 0.0;
        point[2] = sliceSpacing * deltaY;
        point[3] = 1.0;
		std::cout<<point[2]<<std::endl;
        matrix->MultiplyPoint(point, center);
        matrix->SetElement(0, 3, center[0]);
        matrix->SetElement(1, 3, center[1]);
        matrix->SetElement(2, 3, center[2]);
        interactor->Render();
        }
      else
        {
        vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(
          interactor->GetInteractorStyle());
        if (style)
          {
          style->OnMouseMove();
          }
        }
      }
    };


On Tue, Apr 29, 2008 at 8:31 AM, Karthik Krishnan
<karthik.krishnan at kitware.com> wrote:
> The Seed widget uses a vtkHandleWidget internally for each seed, with
>  the default representation being the 3D vtkPointHandleRepresentation3D
>  class. The resulting primitives exist in world coordinates (and not on
>  the overlay plane). So they should disappear when you move to the next
>  slice.
>
>  What is the output display bounds of the result of vtkImageReslice. I
>  presume you are passing it through to vtkImageActor. If the display
>  bounds, as you scroll through slices do change, the seeds should
>  appear and disappear automatically.
>
>  HTH
>  --
>  karthik
>
>
>
>  On Tue, Apr 29, 2008 at 9:30 AM, Ken Urish <ken.urish at gmail.com> wrote:
>  > Hey all,
>  >
>  >  Im using vtkSeedWidget on a 3D image that I am viewing through
>  >  ImageReslice. When I place my seed points on a 2D slice, how can I
>  >  have the seed points disappear when I move to the next slice? Im
>  >  moving through ~100 slices and I dont want them building up. Is this
>  >  even possible? I appreciate the help.
>  >
>  >  Thanks
>  >  --Ken--
>  >  _______________________________________________
>  >  This is the private VTK discussion list.
>  >  Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>  >  Follow this link to subscribe/unsubscribe:
>  >  http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list