MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateLayout

Method UpdateLayout

Charts/Core/vtkChartXY.cxx:968–1095  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

966
967//------------------------------------------------------------------------------
968bool 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 }

Callers 1

PaintMethod · 0.95

Calls 15

GetLegendBorderMethod · 0.95
SetLegendPositionMethod · 0.95
GetLogicalTileScaleMethod · 0.80
GetVisibleMethod · 0.80
maxFunction · 0.50
UpdateMethod · 0.45
GetBoundingRectMethod · 0.45
GetHeightMethod · 0.45
GetWidthMethod · 0.45
ApplyTextPropMethod · 0.45
ComputeStringBoundsMethod · 0.45
GetXMethod · 0.45

Tested by

no test coverage detected