Commit 86409761 authored by David E. DeMarle's avatar David E. DeMarle

Merge branch '15412-vtkCaptionActor2D-text-scaling' into 'master'

Fix vtkCaptionActor2D not scaling text

The text in vtkCaptionActor2D should scale to fill the rectangle defined
by its positions. The scaling works as expected only if the actor's
CaptionTextProperty is modified; using the default CaptionTextProperty
shows the bug.

This commit makes the text scale even when using the default caption
text property.

Fixes #15412

See merge request !802
parents dfe79f1b fdaf3b02
Pipeline #1724 running with stage
......@@ -882,7 +882,8 @@ void vtkTextActor::ComputeRectangle(vtkViewport *viewport)
// ----------------------------------------------------------------------------
int vtkTextActor::UpdateRectangle(vtkViewport* viewport)
{
if (this->TextProperty->GetMTime() > this->ScaledTextProperty->GetMTime())
if (this->TextProperty->GetMTime() > this->ScaledTextProperty->GetMTime() ||
this->GetMTime() > this->BuildTime)
{
this->ComputeScaledFont(viewport);
}
......
......@@ -14,6 +14,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestTextActorDepthPeeling.cxx
TestTextActor3DAlphaBlending.cxx
TestTextActor3DDepthPeeling.cxx
TestTextActorScaleModeProp.cxx
TestTextMapper.cxx
)
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestTextActorScaleModeProp.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTextActor.h"
#include "vtkNew.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTextProperty.h"
//----------------------------------------------------------------------------
int TestTextActorScaleModeProp(int, char *[])
{
// Test PROP scale mode actor with a text property that's instantiated first
// See VTK bug 15412
vtkNew<vtkTextProperty> textProperty;
textProperty->SetBold(1);
textProperty->SetItalic(1);
textProperty->SetShadow(0);
textProperty->SetFontFamily(VTK_ARIAL);
textProperty->SetJustification(VTK_TEXT_LEFT);
textProperty->SetVerticalJustification(VTK_TEXT_BOTTOM);
vtkNew<vtkTextActor> textActor;
textActor->GetPositionCoordinate()->SetCoordinateSystemToDisplay();
textActor->GetPositionCoordinate()->SetReferenceCoordinate(NULL);
textActor->GetPosition2Coordinate()->SetCoordinateSystemToDisplay();
textActor->GetPosition2Coordinate()->SetReferenceCoordinate(NULL);
textActor->SetTextScaleModeToProp();
textActor->SetTextProperty(textProperty.GetPointer());
textActor->SetInput("15412");
textActor->GetPositionCoordinate()->SetValue(20.0, 20.0, 0.0);
textActor->GetPosition2Coordinate()->SetValue(280.0, 80.0, 0.0);
vtkNew<vtkRenderer> ren;
vtkNew<vtkRenderWindow> win;
win->AddRenderer(ren.GetPointer());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(win.GetPointer());
ren->SetBackground(0.1, 0.1, 0.1);
win->SetSize(300, 300);
ren->AddActor2D(textActor.GetPointer());
win->SetMultiSamples(0);
win->GetInteractor()->Initialize();
win->GetInteractor()->Start();
return EXIT_SUCCESS;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment