MCPcopy Create free account
hub / github.com/Kitware/VTK / DrawString

Method DrawString

IO/ExportPDF/vtkPDFContextDevice2D.cxx:1220–1274  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1218
1219//------------------------------------------------------------------------------
1220void vtkPDFContextDevice2D::DrawString(float* point, const vtkStdString& string)
1221{
1222 vtkTextRenderer* tren = vtkTextRenderer::GetInstance();
1223 if (!tren)
1224 {
1225 vtkGenericWarningMacro("vtkTextRenderer unavailable. Link to "
1226 "vtkRenderingFreeType to get the default "
1227 "implementation.");
1228 return;
1229 }
1230
1231 int backend = tren->DetectBackend(string);
1232
1233 this->PushGraphicsState();
1234
1235 if (backend != vtkTextRenderer::MathText)
1236 {
1237 vtkNew<vtkMatrix3x3> mat;
1238 this->GetMatrix(mat);
1239 TextHelper helper(this->Impl->Document, this->Impl->Page, this->TextProp, string, mat);
1240 if (!helper.Valid)
1241 {
1242 vtkErrorMacro("Error preparing to draw string: " << string);
1243 this->PopGraphicsState();
1244 return;
1245 }
1246
1247 this->ApplyTextPropertyState();
1248
1249 helper.DrawText(point);
1250 }
1251 else
1252 {
1253 vtkNew<vtkPath> path;
1254 int dpi = this->Renderer->GetRenderWindow()->GetDPI();
1255 if (!tren->StringToPath(this->TextProp, string, path, dpi, backend))
1256 {
1257 vtkErrorMacro("Error generating path for MathText string '" << string << "'.");
1258 this->PopGraphicsState();
1259 return;
1260 }
1261
1262 this->ApplyTextPropertyState();
1263 this->DrawPath(path, point[0], point[1]);
1264 this->FillEvenOdd();
1265
1266 float bbox[4];
1267 this->ComputeStringBounds(string, bbox);
1268 HPDF_Page_SetRGBStroke(this->Impl->Page, 1, 0, 0);
1269 HPDF_Page_Rectangle(this->Impl->Page, bbox[0], bbox[1] - bbox[3], bbox[2], bbox[3]);
1270 HPDF_Page_Stroke(this->Impl->Page);
1271 }
1272
1273 this->PopGraphicsState();
1274}
1275
1276//------------------------------------------------------------------------------
1277void vtkPDFContextDevice2D::ComputeStringBounds(const vtkStdString& string, float bounds[4])

Callers 3

DrawMathTextStringMethod · 0.95
PaintCellMethod · 0.45
PaintMethod · 0.45

Calls 14

PushGraphicsStateMethod · 0.95
GetMatrixMethod · 0.95
PopGraphicsStateMethod · 0.95
DrawPathMethod · 0.95
FillEvenOddMethod · 0.95
ComputeStringBoundsMethod · 0.95
HPDF_Page_SetRGBStrokeFunction · 0.85
HPDF_Page_RectangleFunction · 0.85
HPDF_Page_StrokeFunction · 0.85
DetectBackendMethod · 0.80
DrawTextMethod · 0.80

Tested by 2

PaintCellMethod · 0.36
PaintMethod · 0.36