------------------------------------------------------------------------------ Determine and set scale factor and position for 2D labels. ------------------------------------------------------------------------------
| 561 | // Determine and set scale factor and position for 2D labels. |
| 562 | //------------------------------------------------------------------------------ |
| 563 | void vtkAxisActor::SetLabelPositions2D(vtkViewport* viewport, bool force) |
| 564 | { |
| 565 | if (!force && (!this->LabelVisibility || this->NumberOfLabelsBuilt == 0)) |
| 566 | { |
| 567 | return; |
| 568 | } |
| 569 | |
| 570 | int xmult = 0; |
| 571 | int ymult = 0; |
| 572 | double xcoeff = 0.; |
| 573 | double ycoeff = 0.; |
| 574 | |
| 575 | // we are in 2D mode, so no Z axis |
| 576 | switch (this->AxisType) |
| 577 | { |
| 578 | case VTK_AXIS_TYPE_X: |
| 579 | xmult = 0; |
| 580 | ymult = vtkAxisActorMultiplierTable1[this->AxisPosition]; |
| 581 | xcoeff = 0.5; |
| 582 | ycoeff = 1.0; |
| 583 | break; |
| 584 | case VTK_AXIS_TYPE_Y: |
| 585 | xmult = vtkAxisActorMultiplierTable1[this->AxisPosition]; |
| 586 | ymult = 0; |
| 587 | xcoeff = 1.0; |
| 588 | ycoeff = 0.5; |
| 589 | break; |
| 590 | default: |
| 591 | // shouldn't get here |
| 592 | break; |
| 593 | } |
| 594 | |
| 595 | // |
| 596 | // xadjust & yadjust are used for positioning the label correctly |
| 597 | // depending upon the 'orientation' of the axis as determined |
| 598 | // by its position in view space (via transformed bounds). |
| 599 | // |
| 600 | double displayBounds[6] = { 0., 0., 0., 0., 0., 0. }; |
| 601 | this->TransformBounds(viewport, displayBounds); |
| 602 | double xadjust = (displayBounds[0] > displayBounds[1] ? -1 : 1); |
| 603 | double yadjust = (displayBounds[2] > displayBounds[3] ? -1 : 1); |
| 604 | double transpos[3] = { 0., 0., 0. }; |
| 605 | double center[3], tick[3], pos[2]; |
| 606 | |
| 607 | vtkTextRenderer* tren = vtkTextRenderer::GetInstance(); |
| 608 | if (!tren) |
| 609 | { |
| 610 | vtkErrorMacro(<< "Unable to obtain the vtkTextRenderer instance!"); |
| 611 | return; |
| 612 | } |
| 613 | |
| 614 | vtkWindow* win = viewport->GetVTKWindow(); |
| 615 | if (!win) |
| 616 | { |
| 617 | vtkErrorMacro(<< "No render window available: cannot determine DPI."); |
| 618 | return; |
| 619 | } |
| 620 |
no test coverage detected