[vtkusers] Strange behavior with vtkCubeAxesActor
Elvis Stansvik
elvis.stansvik at orexplore.com
Mon Jul 4 15:31:16 EDT 2016
Actually, with perspective projection it seems quite okay. See attached
screenshot.
So is this a limitation with vtkCubeAxesActor? It doesn't like parallel
projection?
Elvis
2016-07-04 21:13 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> While doing some experimenting, I encountered a strange behavior with
> vtkCubeAxesActor.
>
> The setup I had was this:
>
>
> SampleWidget::SampleWidget(QWidget *parent, Qt::WindowFlags flags)
> : VTKWidget(parent, flags)
> {
> auto renderer = vtkSmartPointer<vtkRenderer>::New();
> renderer->SetBackground(1.0, 1.0, 1.0);
>
> auto reader = vtkSmartPointer<HDF5ImageReader>::New();
> reader->setFileName("/home/estan/testvolume.hdf5");
> reader->setDataSetName("reconstruction");
>
> auto volumeMapper = vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New();
> volumeMapper->SetInputConnection(reader->GetOutputPort());
>
> auto volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();
> volumeProperty->SetInterpolationTypeToLinear();
> volumeProperty->ShadeOff();
>
> auto opacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
> opacity->AddPoint(0.0,1.0);
> opacity->AddPoint(1.0,1.0);
> volumeProperty->SetScalarOpacity(opacity);
>
> auto color = vtkSmartPointer<vtkColorTransferFunction>::New();
> color->AddRGBPoint(0.0,1.0,1.0,1.0);
> color->AddRGBPoint(1.0,0.0,0.0,0.0);
> volumeProperty->SetColor(color);
>
> auto volume = vtkSmartPointer<vtkVolume>::New();
> volume->SetMapper(volumeMapper);
> volume->SetProperty(volumeProperty);
> renderer->AddVolume(volume);
>
> auto camera = renderer->GetActiveCamera();
> camera->SetParallelProjection(true);
>
> auto cubeAxesActor = vtkSmartPointer<vtkCubeAxesActor>::New();
> cubeAxesActor->SetFlyModeToOuterEdges();
> cubeAxesActor->SetBounds(volume->GetBounds());
> cubeAxesActor->SetCamera(renderer->GetActiveCamera());
> cubeAxesActor->GetTitleTextProperty(0)->SetColor(1.0, 0.0, 0.0);
> cubeAxesActor->GetLabelTextProperty(0)->SetColor(1.0, 0.0, 0.0);
> cubeAxesActor->GetTitleTextProperty(1)->SetColor(0.0, 1.0, 0.0);
> cubeAxesActor->GetLabelTextProperty(1)->SetColor(0.0, 1.0, 0.0);
> cubeAxesActor->GetTitleTextProperty(2)->SetColor(0.0, 0.0, 1.0);
> cubeAxesActor->GetLabelTextProperty(2)->SetColor(0.0, 0.0, 1.0);
>
> renderer->AddActor(cubeAxesActor);
>
> renderer->ResetCamera();
>
> GetRenderWindow()->AddRenderer(renderer);
> }
>
> And I got the attached result. Notice how the axis labels don't quite line
> up with the bounding box edge of my volume, and how numbers further away
> are much larger (!) than numbers closer to the camera.
>
> If I don't turn on parallell projection on the camera, the effect is less
> noticable, but still there: The numbers are all the same size, but the
> labels still don't line up with the bounding box edges properly.
>
> Anyone have an idea what's the problem could be?
>
> Thanks in advance,
> Elvis
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160704/ac3a0690/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cubeaxesactor_perspective.png
Type: image/png
Size: 30449 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160704/ac3a0690/attachment.png>
More information about the vtkusers
mailing list