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

Method ComputeStringBounds

IO/Export/vtkSVGContextDevice2D.cxx:1379–1405  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1377
1378//------------------------------------------------------------------------------
1379void vtkSVGContextDevice2D::ComputeStringBounds(const vtkStdString& string, float bounds[4])
1380{
1381 vtkTextRenderer* tren = vtkTextRenderer::GetInstance();
1382 if (!tren)
1383 {
1384 vtkErrorMacro("vtkTextRenderer unavailable. Link to vtkRenderingFreeType "
1385 "to get the default implementation.");
1386 std::fill(bounds, bounds + 4, 0.f);
1387 return;
1388 }
1389
1390 assert(this->Viewport && this->Viewport->GetVTKWindow());
1391 int dpi = this->Viewport->GetVTKWindow()->GetDPI();
1392
1393 vtkTextRenderer::Metrics m;
1394 if (!tren->GetMetrics(this->TextProp, string, m, dpi))
1395 {
1396 vtkErrorMacro("Error computing bbox for string '" << string << "'.");
1397 std::fill(bounds, bounds + 4, 0.f);
1398 return;
1399 }
1400
1401 bounds[0] = 0.f;
1402 bounds[1] = 0.f;
1403 bounds[2] = static_cast<float>(m.BoundingBox[1] - m.BoundingBox[0] + 1);
1404 bounds[3] = static_cast<float>(m.BoundingBox[3] - m.BoundingBox[2] + 1);
1405}
1406
1407//------------------------------------------------------------------------------
1408void vtkSVGContextDevice2D::ComputeJustifiedStringBounds(const char* string, float bounds[4])

Callers 15

PaintMethod · 0.45
PaintMethod · 0.45
GetBoundingRectMethod · 0.45
PaintMethod · 0.45
PaintMethod · 0.45
UpdateLayoutMethod · 0.45
GetBoundingRectMethod · 0.45
DrawAxesLabelsMethod · 0.45
DrawTickMarksMethod · 0.45
PaintMethod · 0.45
GetBoundingRectMethod · 0.45

Calls 4

GetVTKWindowMethod · 0.80
fillFunction · 0.50
assertFunction · 0.50
GetMetricsMethod · 0.45

Tested by 1

PaintMethod · 0.36