3D Axis

Steve Boyd boyd at champagne.kin.ucalgary.ca
Wed Jun 30 16:33:59 EDT 1999


Hello,

I believe a similar question was asked recently, but I don't have the
response and I'm not sure it would have applied to my question anyway.

I have an isosurface rendered, and I'd like to put a 'reference' 3D axis
in the corner of the rendering window.  I'd like the axis to be labelled
with simple text X,Y,Z, and not have any units.  When I change the
camera view of the isosurface by interacting with the mouse, I'd like
the 3D axis to change accordingly, but remain in the bottom corner of
the window.  I've been 'playing' with vtkAxis and vtkFollower (to keep
the XYZ labels oriented properly), but my ad hoc solution seems to be
getting very complicated for a task that I'd imagine is quite routine
for many people.  Also, the axis doesn't stay in the corner of the
window as I'd like it to.  I've included some parts of my code below
which seems way too long for what it needs to do...

Can anybody give me a hand or some suggestions?

Sincerely,

Steve


Snippet:

  // create an axis, and label it.
    axisScale = 1;
    axisTScale[0] = axisTScale[1] = axisTScale[2] = axisScale*0.1;
  vtkAxes *axisObj = vtkAxes::New();
    axisObj->SetOrigin(0,0,0);
    axisObj->SetScaleFactor(axisScale);
  vtkPolyDataMapper *axisMapper = vtkPolyDataMapper::New();
    axisMapper->SetInput(axisObj->GetOutput());
  vtkActor *axis = vtkActor::New();
    axis->SetMapper(axisMapper);
    axis->PickableOff();
    axis->SetPosition(lims[0],lims[1],lims[2]);
    axis->GetProperty()->SetColor(1,1,1);
    
  vtkVectorText *textXObj = vtkVectorText::New();
    textXObj->SetText("X");
  vtkPolyDataMapper *textXMap = vtkPolyDataMapper::New();
    textXMap->SetInput(textXObj->GetOutput());
  vtkFollower *textX = vtkFollower::New();
    textX->SetMapper(textXMap);
    textX->SetScale(axisTScale);
    textX->AddPosition(lims[0]+axisScale,lims[1],lims[2]);
 
  vtkVectorText *textYObj = vtkVectorText::New();
    textYObj->SetText("Y");
  vtkPolyDataMapper *textYMap = vtkPolyDataMapper::New();
    textYMap->SetInput(textYObj->GetOutput());
  vtkFollower *textY = vtkFollower::New();
    textY->SetMapper(textYMap);
    textY->SetScale(axisTScale);
    textY->AddPosition(lims[0],lims[1]+axisScale,lims[2]);

  vtkVectorText *textZObj = vtkVectorText::New();
    textZObj->SetText("Z");
  vtkPolyDataMapper *textZMap = vtkPolyDataMapper::New();
    textZMap->SetInput(textZObj->GetOutput());
  vtkFollower *textZ = vtkFollower::New();
    textZ->SetMapper(textZMap);
    textZ->SetScale(axisTScale);
    textZ->AddPosition(lims[0],lims[1],lims[2]+axisScale);


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list