------------------------------------------------------------------------------
| 966 | |
| 967 | //------------------------------------------------------------------------------ |
| 968 | bool vtkChartXY::UpdateLayout(vtkContext2D* painter) |
| 969 | { |
| 970 | // The main use of this method is currently to query the visible axes for |
| 971 | // their bounds, and to update the chart in response to that. |
| 972 | bool changed = false; |
| 973 | |
| 974 | vtkVector2i tileScale = this->Scene->GetLogicalTileScale(); |
| 975 | vtkVector2i hiddenAxisBorder = tileScale * this->HiddenAxisBorder; |
| 976 | |
| 977 | // Axes |
| 978 | if (this->LayoutStrategy == vtkChart::FILL_SCENE || this->LayoutStrategy == vtkChart::FILL_RECT) |
| 979 | { |
| 980 | for (int i = 0; i < 4; ++i) |
| 981 | { |
| 982 | int border = 0; |
| 983 | vtkAxis* axis = this->ChartPrivate->axes[i]; |
| 984 | axis->Update(); |
| 985 | if (axis->GetVisible()) |
| 986 | { |
| 987 | vtkRectf bounds = axis->GetBoundingRect(painter); |
| 988 | if (i == vtkAxis::TOP || i == vtkAxis::BOTTOM) |
| 989 | { // Horizontal axes |
| 990 | border = int(bounds.GetHeight()); |
| 991 | } |
| 992 | else |
| 993 | { // Vertical axes |
| 994 | border = int(bounds.GetWidth()); |
| 995 | } |
| 996 | } |
| 997 | border += this->GetLegendBorder(painter, i); |
| 998 | if (i == vtkAxis::TOP) |
| 999 | { |
| 1000 | painter->ApplyTextProp(this->TitleProperties); |
| 1001 | float bounds[4]; |
| 1002 | painter->ComputeStringBounds(this->Title, bounds); |
| 1003 | if (bounds[3] > 0) |
| 1004 | { |
| 1005 | border += (5 * tileScale.GetY()) /* title margin */ |
| 1006 | + bounds[3]; // add the title text height to the border. |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | if (i == vtkAxis::TOP || i == vtkAxis::BOTTOM) |
| 1011 | { |
| 1012 | border = std::max(border, hiddenAxisBorder.GetY()); |
| 1013 | } |
| 1014 | else |
| 1015 | { |
| 1016 | border = std::max(border, hiddenAxisBorder.GetX()); |
| 1017 | } |
| 1018 | |
| 1019 | if (this->ChartPrivate->Borders[i] != border) |
| 1020 | { |
| 1021 | this->ChartPrivate->Borders[i] = border; |
| 1022 | changed = true; |
| 1023 | } |
| 1024 | } |
| 1025 | } |
no test coverage detected