Commit 3b3130eb authored by David C. Lonie's avatar David C. Lonie

Replace vtkFreeType(Tools|Utilities) with vtkTextRenderer.

This patch replaces most of the remaining calls to the vtkFreeType
text rendering classes with equivalents that go through the
vtkTextRenderer layer. Most of these were used to calculate bounding
boxes for text actors, which would be incorrect if the text actor was
rendering math text.

Also removed a few unneeded headers and mentions of vtkFreeType.

Change-Id: Iddf7d84dbf46c30774baf96d32edd07b6da77031
parent a01d25c6
......@@ -24,7 +24,6 @@
#include "vtkContextActor.h"
#include "vtkContextScene.h"
#include "vtkCoordinate.h"
#include "vtkFreeTypeTools.h"
#include "vtkGL2PSContextDevice2D.h"
#include "vtkGL2PSUtilities.h"
#include "vtkIntArray.h"
......@@ -47,6 +46,7 @@
#include "vtkTextActor3D.h"
#include "vtkTextMapper.h"
#include "vtkTextProperty.h"
#include "vtkTextRenderer.h"
#include "vtkTransform.h"
#include "vtkTransformFilter.h"
#include "vtkVolume.h"
......@@ -707,9 +707,18 @@ void vtkGL2PSExporter::DrawTextActor3D(vtkTextActor3D *textAct,
tprop->ShallowCopy(textAct->GetTextProperty());
tprop->SetJustificationToLeft(); // Ignored by textactor3d
tprop->SetVerticalJustificationToBottom(); // Ignored by textactor3d
vtkFreeTypeTools::GetInstance()->StringToPath(tprop.GetPointer(),
vtkStdString(string),
path.GetPointer());
vtkTextRenderer *tren = vtkTextRenderer::GetInstance();
if (tren)
{
tren->StringToPath(tprop.GetPointer(), vtkStdString(string),
path.GetPointer());
}
else
{
vtkWarningMacro(<<"Cannot generate path data from 3D text string: "
<< string);
return;
}
// Get actor info
vtkMatrix4x4 *actorMatrix = textAct->GetMatrix();
......
......@@ -24,7 +24,7 @@
#include "vtkRenderWindow.h"
#include "vtkTextActor.h"
#include "vtkTextMapper.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkTextRenderer.h"
vtkStandardNewMacro(vtkCaptionRepresentation);
......@@ -186,17 +186,16 @@ void vtkCaptionRepresentation::AdjustCaptionBoundary()
{
if(this->CaptionActor2D->GetCaption())
{
vtkFreeTypeUtilities* ftu = vtkFreeTypeUtilities::GetInstance();
if (!ftu)
vtkTextRenderer* tren = vtkTextRenderer::GetInstance();
if (!tren)
{
vtkErrorMacro(<<"Failed getting the FreeType utilities instance");
vtkErrorMacro(<<"Failed getting the vtkTextRenderer instance");
return;
}
int text_bbox[4];
ftu->GetBoundingBox(this->CaptionActor2D->GetCaptionTextProperty(),
this->CaptionActor2D->GetCaption(), text_bbox);
if (!ftu->IsBoundingBoxValid(text_bbox))
if (!tren->GetBoundingBox(this->CaptionActor2D->GetCaptionTextProperty(),
this->CaptionActor2D->GetCaption(), text_bbox))
{
return;
}
......
......@@ -15,9 +15,10 @@
#include "vtkTextRepresentation.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkTextRenderer.h"
#include "vtkObjectFactory.h"
#include "vtkRenderer.h"
#include "vtkStdString.h"
#include "vtkCommand.h"
class vtkTextRepresentationObserver : public vtkCommand
......@@ -260,19 +261,18 @@ void vtkTextRepresentation::CheckTextBoundary()
if(this->GetRenderer() &&
this->TextActor->GetTextScaleMode() != vtkTextActor::TEXT_SCALE_MODE_PROP)
{
vtkFreeTypeUtilities* ftu = vtkFreeTypeUtilities::GetInstance();
if (!ftu)
vtkTextRenderer* tren = vtkTextRenderer::GetInstance();
if (!tren)
{
vtkErrorMacro(<<"Failed getting the FreeType utilities instance");
vtkErrorMacro(<<"Failed getting the vtkTextRenderer instance");
return;
}
this->TextActor->ComputeScaledFont(this->GetRenderer());
int text_bbox[4];
ftu->GetBoundingBox(this->TextActor->GetScaledTextProperty(),
this->GetText(), text_bbox);
if (!ftu->IsBoundingBoxValid(text_bbox))
if (!tren->GetBoundingBox(this->TextActor->GetScaledTextProperty(),
this->GetText(), text_bbox))
{
return;
}
......
......@@ -19,7 +19,7 @@
#include "vtkCellArray.h"
#include "vtkCoordinate.h"
#include "vtkFollower.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkTextRenderer.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
......@@ -174,12 +174,6 @@ vtkAxisActor::vtkAxisActor()
this->CalculateTitleOffset = 1;
this->CalculateLabelOffset = 1;
this->FreeTypeUtilities = vtkFreeTypeUtilities::GetInstance();
if (!this->FreeTypeUtilities)
{
vtkErrorMacro(<<"Failed getting the FreeType utilities instance");
}
// Instance variables specific to 2D mode
this->Use2DMode = 0;
this->SaveTitlePosition = 0;
......@@ -853,6 +847,13 @@ vtkAxisActor::SetLabelPositions2D(vtkViewport *viewport, bool force)
double transpos[3] = {0., 0., 0.};
double center[3], tick[3], pos[2];
vtkTextRenderer *tren = vtkTextRenderer::GetInstance();
if (!tren)
{
vtkErrorMacro(<< "Unable to obtain the vtkTextRenderer instance!");
return;
}
for (int i = 0; i < this->NumberOfLabelsBuilt; i++)
{
ptIdx = 4*i + 1;
......@@ -868,7 +869,13 @@ vtkAxisActor::SetLabelPositions2D(vtkViewport *viewport, bool force)
viewport->GetDisplayPoint(transpos);
int bbox[4];
this->FreeTypeUtilities->GetBoundingBox(this->LabelActors2D[i]->GetTextProperty(), this->LabelActors2D[i]->GetInput(), bbox);
if (!tren->GetBoundingBox(this->LabelActors2D[i]->GetTextProperty(),
this->LabelActors2D[i]->GetInput(), bbox))
{
vtkErrorMacro(<< "Unable to calculate bounding box for label "
<< this->LabelActors2D[i]->GetInput());
continue;
}
double width = (bbox[1]-bbox[0]);
double height = (bbox[3]-bbox[2]);
......
......@@ -74,7 +74,6 @@ class vtkAxisFollower;
class vtkCamera;
class vtkCoordinate;
class vtkFollower;
class vtkFreeTypeUtilities;
class vtkPoints;
class vtkPolyData;
class vtkPolyDataMapper;
......@@ -583,10 +582,6 @@ class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor : public vtkActor
double LastMinDisplayCoordinate[3];
double LastMaxDisplayCoordinate[3];
// Description:
// FreeType library utility
vtkFreeTypeUtilities *FreeTypeUtilities;
};
......
......@@ -15,8 +15,6 @@
#include "vtkOpenGL2ContextDevice2D.h"
#include "vtkFreeTypeStringToImage.h"
#include "vtkVector.h"
#include "vtkRect.h"
#include "vtkPen.h"
......
......@@ -27,7 +27,7 @@
// this actor.
//
// .SECTION See Also
// vtkActor2D vtkPolyDataMapper vtkTextProperty vtkFreeTypeUtilities
// vtkActor2D vtkPolyDataMapper vtkTextProperty vtkTextRenderer
#ifndef __vtkTextActor_h
#define __vtkTextActor_h
......
......@@ -16,8 +16,8 @@
// .NAME vtkTextRendererStringToImage - uses vtkTextRenderer to render the
// supplied text to an image.
#ifndef __vtkFreeTypeStringToImage_h
#define __vtkFreeTypeStringToImage_h
#ifndef __vtkTextRendererStringToImage_h
#define __vtkTextRendererStringToImage_h
#include "vtkRenderingFreeTypeModule.h" // For export macro
#include "vtkStringToImage.h"
......@@ -84,4 +84,4 @@ private:
void operator=(const vtkTextRendererStringToImage &); // Not implemented.
};
#endif //__vtkFreeTypeStringToImage_h
#endif //__vtkTextRendererStringToImage_h
......@@ -18,7 +18,6 @@
#include "vtkImageData.h"
#include "vtkIntArray.h"
#include "vtkFloatArray.h"
#include "vtkFreeTypeTools.h"
#include "vtkMath.h"
#include "vtkMatrix4x4.h"
#include "vtkNew.h"
......@@ -26,6 +25,7 @@
#include "vtkPath.h"
#include "vtkRenderWindow.h"
#include "vtkTextProperty.h"
#include "vtkTextRenderer.h"
#include "vtk_gl2ps.h"
......@@ -66,15 +66,15 @@ void vtkGL2PSUtilities::DrawString(const char *str,
{
// Render the string to a path and then draw it to GL2PS:
vtkNew<vtkPath> path;
if (vtkFreeTypeTools *tools = vtkFreeTypeTools::GetInstance())
if (vtkTextRenderer *tren = vtkTextRenderer::GetInstance())
{
tools->StringToPath(tprop, str, path.GetPointer());
tren->StringToPath(tprop, str, path.GetPointer());
}
else
{
vtkNew<vtkGL2PSUtilities> dummy;
vtkErrorWithObjectMacro(dummy.GetPointer(), <<"Cannot access freetype "
"tools!");
vtkErrorWithObjectMacro(dummy.GetPointer(),
<<"vtkTextRenderer unavailable.");
return;
}
// Get color
......
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