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

Method GetMetrics

Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx:642–722  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

640
641//------------------------------------------------------------------------------
642bool vtkMatplotlibMathTextUtilities::GetMetrics(
643 vtkTextProperty* tprop, const char* str, int dpi, vtkTextRenderer::Metrics& metrics)
644{
645 if (!this->IsAvailable())
646 {
647 vtkErrorMacro(<< "Matplotlib rendering is unavailable.");
648 return false;
649 }
650
651 if (!this->MaskParser)
652 {
653 if (!this->InitializeMaskParser())
654 {
655 vtkErrorMacro(<< "MaskParser is not initialized!");
656 return false;
657 }
658 }
659
660 // Configure math text font
661 if (!this->SetMathTextFont(tprop))
662 {
663 return false;
664 }
665
666 // Get the font property used for all non math text.
667 vtkSmartPyObject pyFontProp(this->GetFontProperties(tprop));
668 if (this->CheckForError(pyFontProp))
669 {
670 return false;
671 }
672
673 // First, parse the string
674 GridOfStrings strGrid;
675 std::size_t maxNumberOfCells;
676 if (!this->ParseString(str, strGrid, maxNumberOfCells))
677 {
678 vtkWarningMacro(<< "Failed to parse string.");
679 return false;
680 }
681
682 std::uint64_t rows = 0;
683 std::uint64_t cols = 0;
684 if (!this->ComputeRowsAndCols(
685 strGrid, maxNumberOfCells, tprop, pyFontProp.GetPointer(), dpi, rows, cols))
686 {
687 vtkWarningMacro(<< "Failed to compute rows and cols.");
688 return false;
689 }
690
691 vtkDebugMacro(<< "Calculating metrics for '" << str << "'");
692
693 int extent[4];
694 this->GetJustifiedBBox(rows, cols, tprop, extent);
695
696 // Determine the dimensions of the rotated image
697 double angleDeg = tprop->GetOrientation();
698 // Corners of original image
699 double corners[4][2] = { { static_cast<double>(extent[0]), static_cast<double>(extent[2]) }, // TL

Callers 1

GetBoundingBoxMethod · 0.95

Calls 12

IsAvailableMethod · 0.95
InitializeMaskParserMethod · 0.95
SetMathTextFontMethod · 0.95
GetFontPropertiesMethod · 0.95
CheckForErrorMethod · 0.95
ParseStringMethod · 0.95
ComputeRowsAndColsMethod · 0.95
GetJustifiedBBoxMethod · 0.95
RotateCornersMethod · 0.95
roundFunction · 0.50
GetPointerMethod · 0.45
GetOrientationMethod · 0.45

Tested by

no test coverage detected