[vtkusers] change size of Axes text

Alex Malyushytskyy alexmalvtk at gmail.com
Mon May 6 20:28:28 EDT 2013


I have not used vtkAnnotatedCubeActor so I might be wrong, but VTK often
scales the text, so its siuze is unrelated to font size, which only defines
how the text is rendered.

Have you tried to use SetFaceTextScale? This might do what you wanted.

Alex


On Mon, May 6, 2013 at 10:33 AM, tony zhang <tonyzhang0985 at gmail.com> wrote:

> I am trying to add axes to a window and have an issue to change font size
> of axis test. The partial code is as following:
>
>     cube = vtkSmartPointer<vtkAnnotatedCubeActor>::New();
>     cube->SetXPlusFaceText("R");
>     cube->SetXMinusFaceText("L");
>     cube->SetYPlusFaceText("A");
>     cube->SetYMinusFaceText("P");
>     cube->SetZPlusFaceText("I");
>     cube->SetZMinusFaceText("S");
>     cube->SetXFaceTextRotation(180);
>     cube->SetYFaceTextRotation(180);
>     cube->SetZFaceTextRotation(-90);
>     cube->SetFaceTextScale(0.65);
>
>     vtkSmartPointer<vtkProperty> cube_property = cube->GetCubeProperty();
>     cube_property->SetColor(0.5, 1, 1);
>
>     cube_property = cube->GetTextEdgesProperty();
>     cube_property->SetLineWidth(1);
>     cube_property->SetDiffuse(0);
>     cube_property->SetAmbient(1);
>     cube_property->SetColor(0.18, 0.28, 0.23);
>
>     cube_property = cube->GetXPlusFaceProperty();
>     cube_property->SetColor(0,0,1);
>     cube_property->SetInterpolationToFlat();
>
>     cube_property = cube->GetXMinusFaceProperty();
>     cube_property->SetColor(0,0,1);
>     cube_property->SetInterpolationToFlat();
>
>     cube_property = cube->GetYPlusFaceProperty();
>     cube_property->SetColor(0,1,0);
>     cube_property->SetInterpolationToFlat();
>
>     cube_property = cube->GetYMinusFaceProperty();
>     cube_property->SetColor(0,1,0);
>     cube_property->SetInterpolationToFlat();
>
>     cube_property = cube->GetZPlusFaceProperty();
>     cube_property->SetColor(1,0,0);
>     cube_property->SetInterpolationToFlat();
>
>     cube_property = cube->GetZMinusFaceProperty();
>     cube_property->SetColor(1,0,0);
>     cube_property->SetInterpolationToFlat();
>
>     axes = vtkSmartPointer<vtkAxesActor>::New();
>     axes->SetShaftTypeToCylinder();
>     axes->SetXAxisLabelText("x");
>     axes->SetYAxisLabelText("y");
>     axes->SetZAxisLabelText("z");
>     axes->SetTotalLength(1.5, 1.5, 1.5);
>
>     vtkSmartPointer<vtkTextProperty> tprop =
> vtkSmartPointer<vtkTextProperty>::New();
>     tprop->ItalicOn();
>     tprop->ShadowOn();
>     tprop->SetFontFamilyToTimes();
>     std::cout << tprop->GetFontSize();
>     tprop->SetFontSize(18);
>     axes->GetXAxisCaptionActor2D()->SetCaptionTextProperty(tprop);
>
>     vtkSmartPointer<vtkTextProperty> tprop2 =
> vtkSmartPointer<vtkTextProperty>::New();
>     tprop2->ShallowCopy(tprop);
>     axes->GetYAxisCaptionActor2D()->SetCaptionTextProperty(tprop2);
>
>     vtkSmartPointer<vtkTextProperty> tprop3 =
> vtkSmartPointer<vtkTextProperty>::New();
>     tprop3->ShallowCopy(tprop);
>     axes->GetZAxisCaptionActor2D()->SetCaptionTextProperty(tprop3);
>
>     assembly = vtkSmartPointer<vtkPropAssembly>::New();
>     assembly->AddPart(axes);
>     assembly->AddPart(cube);
>
>     marker = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
>     marker->SetOutlineColor(0.93, 0.57, 0.13);
>     marker->SetOrientationMarker(assembly);
>
>     iact = renWinImage->GetInteractor();
>     iact_style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
>     iact->SetInteractorStyle(iact_style);
>
>     marker->SetInteractor(iact);
>     marker->SetEnabled(1);
>     marker->InteractiveOff();
>
>     renWinImage->Render();
>
> The font of axes text X, Y and Z looks small. I tried to set up larger
> font size ( tprop->SetFontSize(18);) and it seems not working. The
> "std::cout << tprop->GetFontSize();" does not print out the size when the
> program is started. It shows default size "12" when I close the program. My
> questions are:
> (1) is SetFontSize() the right method to change the font size?
> (2) if it is the right function to use, what I should pay attention to
> make it effective?
>
> Thanks ahead for any help.
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130506/b84104d3/attachment.htm>


More information about the vtkusers mailing list