------------------------------------------------------------------------------
| 913 | |
| 914 | //------------------------------------------------------------------------------ |
| 915 | void vtkAxisActor2D::SetTitleFontSize(vtkViewport* viewport, int stringSize[2]) |
| 916 | { |
| 917 | // the mapper returns the global bounding box. Artificially set orientation to 0 |
| 918 | // in this scope to get the local bounding box in `stringSize` |
| 919 | double originalAngle = this->TitleMapper->GetTextProperty()->GetOrientation(); |
| 920 | this->TitleMapper->GetTextProperty()->SetOrientation(0); |
| 921 | |
| 922 | if (this->PositionsChangedOrViewportResized(viewport) || |
| 923 | this->TitleTextProperty->GetMTime() > this->BuildTime) |
| 924 | { |
| 925 | if (!this->UseFontSizeFromProperty) |
| 926 | { |
| 927 | if (!this->SizeFontRelativeToAxis) |
| 928 | { |
| 929 | int* size = viewport->GetSize(); |
| 930 | vtkTextMapper::SetRelativeFontSize( |
| 931 | this->TitleMapper, viewport, size, stringSize, 0.015 * this->FontFactor); |
| 932 | } |
| 933 | else |
| 934 | { |
| 935 | |
| 936 | double *xp1, *xp2, len = 0.0; |
| 937 | if (this->SizeFontRelativeToAxis) |
| 938 | { |
| 939 | xp1 = this->PositionCoordinate->GetComputedDoubleViewportValue(viewport); |
| 940 | xp2 = this->Position2Coordinate->GetComputedDoubleViewportValue(viewport); |
| 941 | len = std::sqrt( |
| 942 | (xp2[0] - xp1[0]) * (xp2[0] - xp1[0]) + (xp2[1] - xp1[1]) * (xp2[1] - xp1[1])); |
| 943 | } |
| 944 | |
| 945 | this->TitleMapper->SetConstrainedFontSize( |
| 946 | viewport, static_cast<int>(0.33 * len), static_cast<int>(0.2 * len)); |
| 947 | this->TitleMapper->GetSize(viewport, stringSize); |
| 948 | } |
| 949 | } |
| 950 | else |
| 951 | { |
| 952 | this->TitleMapper->GetSize(viewport, stringSize); |
| 953 | } |
| 954 | } |
| 955 | else |
| 956 | { |
| 957 | this->TitleMapper->GetSize(viewport, stringSize); |
| 958 | } |
| 959 | |
| 960 | // Restore the orientation. |
| 961 | this->TitleMapper->GetTextProperty()->SetOrientation(originalAngle); |
| 962 | } |
| 963 | |
| 964 | //------------------------------------------------------------------------------ |
| 965 | void vtkAxisActor2D::BuildTitle(vtkViewport* viewport) |
no test coverage detected