[vtkusers] Size of labels in vtkScalarBarActor

Fernando Nellmeldin f.nellmeldin at open-engineering.com
Thu Oct 12 09:33:05 EDT 2017


Hello.

I know that this issue was discussed many times before in this list, but I
can't find a way to do what I want. I'm using VTK 7.1.1 (under Windows). So
maybe there were some improvements.

In fact, I'm using vtkPVScalarBarActor which includes some very well
welcomed improvements, but the discussion should apply also to the normal
vtkScalarBarActor.
https://www.paraview.org/ParaView/Doc/Nightly/www/cxx-doc/classvtkPVScalarBarActor.html

The issue is that the size of the labels for values depends on the
viewport. So when the viewport changes the size, the labels also change
their size. Is it possible to avoid this? I would like to set the size of
the labels as constant or at least to define a maximum/minimum size,
because sometimes it gets veeeeery small/big and it is not very pleaseant.

Thank you!

PS:
Here's my code to configure the vtkPVScalarBarActor, in case it's useful...
(I guess there are some calls that are useless):

vtkSmartPointer<vtkPVScalarBarActor> scalarBarActor =
vtkSmartPointer<vtkPVScalarBarActor>::New();
scalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToDisplay();
scalarBarActor->GetPositionCoordinate()->SetValue(20, 20, 0.0);

scalarBarActor->SetAddRangeAnnotations(0);
scalarBarActor->DrawTickMarksOff();
scalarBarActor->UnconstrainedFontSizeOff();
scalarBarActor->AnnotationTextScalingOn();
scalarBarActor->SetFixedAnnotationLeaderLineColor(true);

scalarBarActor->SetOrientationToVertical();
//scalarBarActor->SetWidth(0.1); // width in viewport coordinates
scalarBarActor->SetMaximumWidthInPixels(80);
scalarBarActor->GetLabelTextProperty()->BoldOff();
scalarBarActor->GetLabelTextProperty()->ItalicOff();
scalarBarActor->GetLabelTextProperty()->ShadowOn();
scalarBarActor->AutomaticLabelFormatOff();
scalarBarActor->SetLabelFormat("%.2f");
scalarBarActor->SetRangeLabelFormat(scalarBarActor->GetLabelFormat());
scalarBarActor->SetMaximumNumberOfColors(100);
scalarBarActor->SetNumberOfLabels(5);

scalarBarActor->SetLookupTable(tempLUT); // defined elsewhere, doesn't
matter

scalarBarActor->SetTitle("Displacements");
scalarBarActor->SetTitleJustification(VTK_TEXT_RIGHT);
scalarBarActor->GetTitleTextProperty()->SetFontSize(8);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171012/17733144/attachment.html>


More information about the vtkusers mailing list