------------------------------------------------------------------------------
| 462 | |
| 463 | //------------------------------------------------------------------------------ |
| 464 | void vtkChartParallelCoordinates::UpdateGeometry(vtkContext2D* painter) |
| 465 | { |
| 466 | vtkVector2i geometry(this->GetScene()->GetSceneWidth(), this->GetScene()->GetSceneHeight()); |
| 467 | |
| 468 | if (geometry.GetX() != this->Geometry[0] || geometry.GetY() != this->Geometry[1] || |
| 469 | !this->GeometryValid) |
| 470 | { |
| 471 | // Take up the entire window right now, this could be made configurable |
| 472 | this->SetGeometry(geometry.GetData()); |
| 473 | |
| 474 | vtkVector2i tileScale = this->Scene->GetLogicalTileScale(); |
| 475 | // if chart legend in not inlined, then we need to reserve space for it at the top right corner |
| 476 | if (this->Legend->GetVisible() && !this->Legend->GetInline()) |
| 477 | { |
| 478 | this->Legend->Update(); |
| 479 | constexpr int padding = 10; |
| 480 | const vtkRectf rect = this->Legend->GetBoundingRect(painter); |
| 481 | this->SetBorders(60 * tileScale.GetX(), 50 * tileScale.GetY(), |
| 482 | (60 + static_cast<int>(rect.GetWidth()) + padding) * tileScale.GetX(), |
| 483 | 20 * tileScale.GetY()); |
| 484 | } |
| 485 | else |
| 486 | { |
| 487 | this->SetBorders( |
| 488 | 60 * tileScale.GetX(), 50 * tileScale.GetY(), 60 * tileScale.GetX(), 20 * tileScale.GetY()); |
| 489 | } |
| 490 | |
| 491 | // Iterate through the axes and set them up to span the chart area. |
| 492 | int xStep = |
| 493 | (this->Point2[0] - this->Point1[0]) / (static_cast<int>(this->Storage->Axes.size()) - 1); |
| 494 | int x = this->Point1[0]; |
| 495 | |
| 496 | for (size_t i = 0; i < this->Storage->Axes.size(); ++i) |
| 497 | { |
| 498 | vtkAxis* axis = this->Storage->Axes[i]; |
| 499 | axis->SetPoint1(x, this->Point1[1]); |
| 500 | axis->SetPoint2(x, this->Point2[1]); |
| 501 | if (axis->GetBehavior() == 0) |
| 502 | { |
| 503 | axis->AutoScale(); |
| 504 | } |
| 505 | axis->Update(); |
| 506 | x += xStep; |
| 507 | } |
| 508 | |
| 509 | this->GeometryValid = true; |
| 510 | // Cause the plot transform to be recalculated if necessary |
| 511 | this->CalculatePlotTransform(); |
| 512 | this->Storage->Plot->Update(); |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | //------------------------------------------------------------------------------ |
| 517 | void vtkChartParallelCoordinates::CalculatePlotTransform() |
no test coverage detected