My VTK’s version is 9.1, I set vtkScalarBarActor’s title, but can’t set the title’s font, I check the conresponding header file, there is no funciton provided for setting title’s font, some code like below to set the font doesn’t work
vtkSmartPointer< vtkScalarBarActor > scalarBarActor = vtkSmartPointer< vtkScalarBarActor >::New();
scalarBarActor->SetOrientationToHorizontal();
scalarBarActor->SetLookupTable(lut);
scalarBarActor->SetTitle("Z(m)");
scalarBarActor->SetVerticalTitleSeparation(100);
scalarBarActor->GetTitleTextProperty()->SetColor(1.0, 1.0, 1.0);
scalarBarActor->GetTitleTextProperty()->SetFontSize(50);
setting color take effect, but font size not, so how to change the title’s font?
amaclean
(Andrew Maclean)
May 6, 2024, 2:53am
2
Have you tried SetUnconstrainedFontSize()
?
I have tried the SetUnconstrainedFontSize(), It can change default font(bold), but
scalarBarActor->SetTitle("Z(m)");
scalarBarActor->SetVerticalTitleSeparation(10);
scalarBarActor->GetTitleTextProperty()->SetColor(1.0, 1.0, 1.0);
scalarBarActor->GetTitleTextProperty()->SetFontFamilyToTimes();
//scalarBarActor->GetTextActor()->SetTextScaleModeToNone()
scalarBarActor->GetTitle();
//scalarBarActor->GetTitleTextProperty()->SetFontSize(20);
//scalarBarActor->GetTitleTextProperty()->SetUnconstrainedFontSize(10);
scalarBarActor->SetUnconstrainedFontSize(60);
is same as
scalarBarActor->SetTitle("Z(m)");
scalarBarActor->SetVerticalTitleSeparation(10);
scalarBarActor->GetTitleTextProperty()->SetColor(1.0, 1.0, 1.0);
scalarBarActor->GetTitleTextProperty()->SetFontFamilyToTimes();
//scalarBarActor->GetTextActor()->SetTextScaleModeToNone()
scalarBarActor->GetTitle();
//scalarBarActor->GetTitleTextProperty()->SetFontSize(20);
//scalarBarActor->GetTitleTextProperty()->SetUnconstrainedFontSize(10);
scalarBarActor->SetUnconstrainedFontSize(10);
It kind of weird. font 60 is same as font 10