* Computes the bottom left corner 'blpos' and a string with \n replaced * by space 'spaceStr' for the string 'str' with properties 'tprop' * and the anchor 'pos'. * * We need this because PDF does not support text alignment. * 'spaceStr' is needed because postscript and PDF do not support * multiline text and we don't implement it yet for TextAsPath false. */
| 74 | * multiline text and we don't implement it yet for TextAsPath false. |
| 75 | */ |
| 76 | bool ComputeBottomLeft( |
| 77 | vtkTextProperty* tprop, vtkTuple<int, 4> bbox, double pos[3], bool textAsPath, double blpos[3]) |
| 78 | { |
| 79 | std::copy(pos, pos + 3, blpos); |
| 80 | // Postscript and PDF do not support multiline text - this is not |
| 81 | // implemented yet for TextAsPath == 0 implement alignment for PDF |
| 82 | if (gl2psGetFileFormat() == GL2PS_PDF && !textAsPath && |
| 83 | (tprop->GetJustification() != VTK_TEXT_LEFT || |
| 84 | tprop->GetVerticalJustification() != VTK_TEXT_BOTTOM)) |
| 85 | { |
| 86 | double width = bbox[1] - bbox[0] + 1; |
| 87 | double height = bbox[3] - bbox[2] + 1; |
| 88 | switch (tprop->GetJustification()) |
| 89 | { |
| 90 | case VTK_TEXT_CENTERED: |
| 91 | blpos[0] -= width / 2; |
| 92 | break; |
| 93 | case VTK_TEXT_RIGHT: |
| 94 | blpos[0] -= width; |
| 95 | break; |
| 96 | } |
| 97 | switch (tprop->GetVerticalJustification()) |
| 98 | { |
| 99 | case VTK_TEXT_CENTERED: |
| 100 | blpos[1] -= height / 2; |
| 101 | break; |
| 102 | case VTK_TEXT_TOP: |
| 103 | blpos[1] -= height; |
| 104 | break; |
| 105 | } |
| 106 | blpos[2] = 0; |
| 107 | return true; |
| 108 | } |
| 109 | else |
| 110 | { |
| 111 | return false; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | //------------------------------------------------------------------------------ |
no test coverage detected