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

Method RenderOneCell

Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx:962–1103  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

960
961//------------------------------------------------------------------------------
962bool vtkMatplotlibMathTextUtilities::RenderOneCell(vtkImageData* image, int bbox[4],
963 std::int64_t rowStart, std::int64_t colStart, vtkSmartPyObject& pythonData,
964 std::uint64_t pythonRows, std::uint64_t pythonCols, std::uint64_t cellRows,
965 std::uint64_t cellCols, vtkTextProperty* tprop, const TextColors& tcolors)
966{
967 vtkDebugMacro("RenderOneCell start = ("
968 << rowStart << "," << colStart << "). Drawing python data of size (" << pythonRows << ","
969 << pythonCols << ") inside a cell of size (" << cellRows << "," << cellCols << ").");
970
971 assert(cellCols >= pythonCols);
972 assert(cellRows >= pythonRows);
973
974 const std::int64_t rowEnd = rowStart - cellRows + 1;
975 const std::int64_t colEnd = colStart + cellCols - 1;
976
977 // Handle cell horizontal justification
978 std::uint64_t colOffset;
979 switch (tprop->GetJustification())
980 {
981 default:
982 case VTK_TEXT_LEFT:
983 colOffset = 0;
984 break;
985 case VTK_TEXT_CENTERED:
986 colOffset = (cellCols - pythonCols) / 2;
987 break;
988 case VTK_TEXT_RIGHT:
989 colOffset = (cellCols - pythonCols);
990 break;
991 }
992 const std::int64_t pythonColStart = colStart + colOffset;
993 const std::int64_t pythonColEnd = pythonColStart + pythonCols;
994
995 // Handle cell vertical justification
996 std::uint64_t rowOffset;
997 switch (tprop->GetVerticalJustification())
998 {
999 default:
1000 case VTK_TEXT_BOTTOM:
1001 rowOffset = (cellRows - pythonRows);
1002 break;
1003 case VTK_TEXT_CENTERED:
1004 rowOffset = (cellRows - pythonRows) / 2;
1005 break;
1006 case VTK_TEXT_TOP:
1007 rowOffset = 0;
1008 break;
1009 }
1010 const std::int64_t pythonRowStart = rowStart - rowOffset;
1011 const std::int64_t pythonRowEnd = pythonRowStart - pythonRows;
1012
1013 std::uint64_t ind = 0;
1014 for (std::int64_t row = rowStart; row >= rowEnd; --row)
1015 {
1016 for (std::int64_t col = colStart; col <= colEnd; ++col)
1017 {
1018 unsigned char* ptr = static_cast<unsigned char*>(image->GetScalarPointer(col, row, 0));
1019

Callers 1

RenderStringMethod · 0.95

Calls 3

CheckForErrorMethod · 0.95
GetScalarPointerMethod · 0.80
assertFunction · 0.50

Tested by

no test coverage detected