// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause #include "vtkActor.h" #include "vtkCornerAnnotation.h" #include "vtkRegressionTestImage.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" #include "vtkSmartPointer.h" #include "vtkTextProperty.h" int TestEmptyCornerAnnotation(int argc, char* argv[]) { // Visualize vtkSmartPointer renderer = vtkSmartPointer::New(); vtkSmartPointer renderWindow = vtkSmartPointer::New(); renderWindow->AddRenderer(renderer); vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New(); renderWindowInteractor->SetRenderWindow(renderWindow); renderer->SetBackground(0.5, 0.5, 0.5); // Annotate the image with window/level and mouse over pixel information vtkSmartPointer cornerAnnotation = vtkSmartPointer::New(); cornerAnnotation->SetLinearFontScaleFactor(2); cornerAnnotation->SetNonlinearFontScaleFactor(1); cornerAnnotation->SetMaximumFontSize(20); cornerAnnotation->SetText(0, "normal text"); cornerAnnotation->SetText(1, "1234567890"); cornerAnnotation->SetText(2, "~`!@#$%^&*()_-+="); cornerAnnotation->SetText(3, "text to remove"); cornerAnnotation->GetTextProperty()->SetColor(1, 0, 0); renderer->AddViewProp(cornerAnnotation); renderWindow->Render(); // This should empty the annotation #3 and not display a black or white box cornerAnnotation->SetText(3, ""); renderWindow->Render(); int retVal = vtkRegressionTestImage(renderWindow); if (retVal == vtkRegressionTester::DO_INTERACTOR) { renderWindowInteractor->Start(); } return !retVal; }