[vtkusers] y-axis in a 2D plot: labeling problems

Christian M. Senet (V2T) senet at v2t.de
Mon Jun 23 07:08:20 EDT 2003


Hi!

I have tried to add a x- and a y-axis to a two-dimensional image.
For this purpose I have used vtkAxisActor2D.

This works fine, except of the labelling: text label for the y-axis
is horizontally aligned. Until now I found no possibility to rotate
the label text parallely to the y-axis

Alternatively I have tried vtkVectorText:

    vtkVectorText *atext = vtkVectorText::New();
    atext->SetText("TEST");
    vtkTransform *aTextTransform = vtkTransform ::New();
    aTextTransform->Identity();
    aTextTransform->RotateZ(90);
    aTextTransform->Scale(0.05,0.05,0.05);
    aTextTransform->Translate(-5,-5,0);
    float scale[3];
    aTextTransform->GetScale(scale);
    std::cout << "scale = " << scale[0] << ", " << scale[1] << "," <<
scale[2] << std::endl;
    float pos[3];
    aTextTransform->GetPosition(pos);
    std::cout << "pos = " << pos[0] << ", " << pos[1] << "," << pos[2] <<
std::endl;
    vtkTransformPolyDataFilter *textTransform =
vtkTransformPolyDataFilter::New();
    textTransform->SetTransform(aTextTransform);
    textTransform->SetInput(atext->GetOutput());
    vtkPolyDataMapper *textMapper = vtkPolyDataMapper::New();

    textMapper->SetInput(textTransform->GetOutput());
    textMapper->Update();
    vtkActor *textActor = vtkActor::New();
    textActor->SetMapper(textMapper);

    viewer->GetRenderer()->AddActor(textActor);


Rotation was sucessful, but I was not able to change
- size
- position
of the text.

Is there a nice solution for 2D axis labeling using vtkAxisActor2D or
vtkVectorText?
I would be thankful for a hint.

Best regards,
Christian









More information about the vtkusers mailing list