I’m running VTK-9.2 for C++.
My code creates a vtkCubeAxesActor2D, and sets data range and title for x, y, and z axes. The ranges are displayed properly, but titles display as ‘X’, ‘Y’, and ‘Z’ (defaults?) instead of ‘Longitude’, ‘Latitude’, and ‘Depth’. Here is the code:
xUnits = "Longitude";
yUnits = "Latitude";
zUnits = "Depth";
qDebug() << "set x-axis label to " << xUnits;
axesActor->GetXAxisActor2D()->SetTitle(xUnits);
qDebug() << "set y-axis label to " << yUnits;
axesActor->GetYAxisActor2D()->SetTitle(yUnits);
qDebug() << "set z-axis label to " << zUnits;
axesActor->GetZAxisActor2D()->SetTitle(zUnits);
qDebug() << "actual x-axis label now is " <<
axesActor->GetXAxisActor2D()->GetTitle();
The output is:
set x-axis label to Longitude
set y-axis label to Latitude
set z-axis label to Depth
actual x-axis label now is Longitude
But the display shows axes labeled as “X”, “Y”, and “Z”.
Anyone know what I am doing wrong? Or is there a bug in vtkAxisActor2D::SetTitle()?
Thanks!
Try calling RenderOpaqueGeometry( vtkViewport* ) on each of your vtkAxisActor2D objects after setting the title strings. After studying the source code of vtkAxisActor2D it seems to me that changing the title doesn’t trigger an update.
Calling RenderOpaqueGeometry() didn’t fix the problem, but I might be using that function incorrectly. What do I pass as an argument to RenderOpaqueGeometry() in this case? My pipeline includes a single vtkRenderer instance, and I am passing that as the argument for each vtkAxisActor2D.
Thanks!
Yes, calling vtkCubeAxesActor2D::Set[X][Y][Z]Label() methods works, with no need to force an update. Thanks!
So is there a bug in vtkAxisActor2D::SetTitle()?