[vtkusers] pipeline updating 2d cursor: vtkAppendPolyData?

Dean Inglis dean.inglis at on.aibn.com
Tue Mar 12 18:48:36 EST 2002


I added a MouseMoveEvent callback to a renderwindowinteractor in which the
coords of a 2D cursor should be updated but the cursor displays once and
remains fixed.  Cursor is made with

void myclass::BuildCursor(void)
{
  cvline = vtkCellArray::New();
  cvline->InsertNextCell(2);
  cvline->InsertCellPoint(0);
  cvline->InsertCellPoint(1);

  chline = vtkCellArray::New();
  chline->InsertNextCell(2);
  chline->InsertCellPoint(0);
  chline->InsertCellPoint(1);

  cvpts = vtkPoints::New();
  cvpts->SetNumberOfPoints(2);
  chpts = vtkPoints::New();
  chpts->SetNumberOfPoints(2);

  cvpd = vtkPolyData::New();
  cvpd->SetPoints(cvpts);
  cvpd->SetLines(cvline);

  chpd = vtkPolyData::New();
  chpd->SetPoints(chpts);
  chpd->SetLines(chline);

  cursorpd = vtkAppendPolyData::New();
  cursorpd->AddInput(cvpd);
  cursorpd->AddInput(chpd);

  cursormapper = vtkPolyDataMapper2D::New();
  cursormapper->SetInput(cursorpd->GetOutput());

  cursoractor = vtkActor2D::New();
  cursoractor->SetMapper(cursormapper);
}

and the mouseevent stuff is in a static member function of class myclass:

void myclass::MouseMove(void* cd)
{
  myclass* me = reinterpret_cast<myclass*>(cd);
    int x = me->iren->GetEventPosition()[0];
    int y = me->iren->GetEventPosition()[1];

   me->cvpts->SetPoint(0, x, y-10, 0);
   me->cvpts->SetPoint(1, x, y+10, 0);
   me->chpts->SetPoint(0, x-10, y, 0);
   me->chpts->SetPoint(1, x+10, y, 0);

  me->renwin->Render();
}

the class manages a renderwindow, renderer, interactor...

Is there something with vtkAppendPolyData that I am missing?  The cursor
will work if I make separate horizontal and vertical mappers, actors...

Dean




More information about the vtkusers mailing list