------------------------------------------------------------------------------ Determines scale and position for the Title. Currently, title can only be centered with respect to its axis. ------------------------------------------------------------------------------
| 656 | // title can only be centered with respect to its axis. |
| 657 | //------------------------------------------------------------------------------ |
| 658 | void vtkAxisActor::BuildTitle(bool force) |
| 659 | { |
| 660 | this->NeedBuild2D = false; |
| 661 | |
| 662 | if (!force && !this->TitleVisibility) |
| 663 | { |
| 664 | return; |
| 665 | } |
| 666 | |
| 667 | if (!force && this->TitleTextTime.GetMTime() < this->BuildTime.GetMTime() && |
| 668 | this->BoundsTime.GetMTime() < this->BuildTime.GetMTime() && |
| 669 | this->LabelBuildTime.GetMTime() < this->BuildTime.GetMTime()) |
| 670 | { |
| 671 | return; |
| 672 | } |
| 673 | |
| 674 | this->UpdateTitleActorProperty(); |
| 675 | |
| 676 | // ---------- labels size ---------- |
| 677 | // local orientation (in the plane of the label) |
| 678 | double labelAngle = vtkMath::RadiansFromDegrees(this->LabelTextProperty->GetOrientation()); |
| 679 | double labelCos = fabs(cos(labelAngle)), labelSin = fabs(sin(labelAngle)); |
| 680 | double labBounds[6]; |
| 681 | double offset[2] = { 0, this->TitleOffset[1] }; |
| 682 | |
| 683 | // Side offset when not centered |
| 684 | if (this->TitleAlignLocation == VTK_ALIGN_POINT1 || this->TitleAlignLocation == VTK_ALIGN_POINT2) |
| 685 | { |
| 686 | offset[0] += this->TitleOffset[0]; |
| 687 | } |
| 688 | |
| 689 | // find max height label (with the label text property considered) |
| 690 | // only when title is on bottom |
| 691 | if (this->LabelVisibility && this->TitleAlignLocation != VTK_ALIGN_TOP) |
| 692 | { |
| 693 | double labelMaxHeight, labHeight; |
| 694 | labelMaxHeight = labHeight = 0; |
| 695 | for (int i = 0; i < this->NumberOfLabelsBuilt; i++) |
| 696 | { |
| 697 | this->LabelProps[i]->GetBounds(labBounds); |
| 698 | |
| 699 | // labels actor aren't oriented yet, width and height are considered in |
| 700 | // their local coordinate system |
| 701 | // however, LabelTextProperty can orient it, but locally (in its plane) |
| 702 | labHeight = |
| 703 | (labBounds[1] - labBounds[0]) * labelSin + (labBounds[3] - labBounds[2]) * labelCos; |
| 704 | labelMaxHeight = (labHeight > labelMaxHeight ? labHeight : labelMaxHeight); |
| 705 | } |
| 706 | offset[1] += this->LabelOffset + this->ScreenSize * labelMaxHeight; |
| 707 | } |
| 708 | |
| 709 | // ---------- title size ---------- |
| 710 | double titleBounds[6]; |
| 711 | this->TitleProp->GetBounds(titleBounds); |
| 712 | double halfTitleHeight = (titleBounds[3] - titleBounds[2]) * 0.5; |
| 713 | double halfTitleWidth = (titleBounds[1] - titleBounds[0]) * 0.5; |
| 714 | |
| 715 | double* p1 = this->Point1Coordinate->GetValue(); |
no test coverage detected