double compute_bounds_time1 = 0; int compute_bounds_iter1 = 0; ------------------------------------------------------------------------------
| 43 | // int compute_bounds_iter1 = 0; |
| 44 | //------------------------------------------------------------------------------ |
| 45 | void vtkFreeTypeLabelRenderStrategy::ComputeLabelBounds( |
| 46 | vtkTextProperty* tprop, vtkStdString label, double bds[4]) |
| 47 | { |
| 48 | // vtkTimerLog* timer = vtkTimerLog::New(); |
| 49 | // timer->StartTimer(); |
| 50 | |
| 51 | // Check for empty string. |
| 52 | if (label.empty()) |
| 53 | { |
| 54 | bds[0] = 0; |
| 55 | bds[1] = 0; |
| 56 | bds[2] = 0; |
| 57 | bds[3] = 0; |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | if (!tprop) |
| 62 | { |
| 63 | tprop = this->DefaultTextProperty; |
| 64 | } |
| 65 | vtkSmartPointer<vtkTextProperty> copy = tprop; |
| 66 | if (tprop->GetOrientation() != 0.0) |
| 67 | { |
| 68 | copy = vtkSmartPointer<vtkTextProperty>::New(); |
| 69 | copy->ShallowCopy(tprop); |
| 70 | copy->SetOrientation(0.0); |
| 71 | } |
| 72 | |
| 73 | int dpi = 72; |
| 74 | if (this->Renderer && this->Renderer->GetVTKWindow()) |
| 75 | { |
| 76 | dpi = this->Renderer->GetVTKWindow()->GetDPI(); |
| 77 | } |
| 78 | else |
| 79 | { |
| 80 | vtkWarningMacro(<< "No Renderer set. Assuming DPI of " << dpi << "."); |
| 81 | } |
| 82 | |
| 83 | int bbox[4]; |
| 84 | this->TextRenderer->GetBoundingBox(copy, label, bbox, dpi); |
| 85 | |
| 86 | // Take line offset into account |
| 87 | bds[0] = bbox[0]; |
| 88 | bds[1] = bbox[1]; |
| 89 | bds[2] = bbox[2] - tprop->GetLineOffset(); |
| 90 | bds[3] = bbox[3] - tprop->GetLineOffset(); |
| 91 | |
| 92 | // Take justification into account |
| 93 | double sz[2] = { bds[1] - bds[0], bds[3] - bds[2] }; |
| 94 | switch (tprop->GetJustification()) |
| 95 | { |
| 96 | case VTK_TEXT_LEFT: |
| 97 | break; |
| 98 | case VTK_TEXT_CENTERED: |
| 99 | bds[0] -= sz[0] / 2; |
| 100 | bds[1] -= sz[0] / 2; |
| 101 | break; |
| 102 | case VTK_TEXT_RIGHT: |
no test coverage detected