------------------------------------------------------------------------------
| 473 | |
| 474 | //------------------------------------------------------------------------------ |
| 475 | vtkVector2i vtkChartMatrix::GetChartIndex(const vtkVector2f& position) |
| 476 | { |
| 477 | const bool isEmpty = this->Size.GetX() <= 0 && this->Size.GetY() <= 0; |
| 478 | if (isEmpty) |
| 479 | { |
| 480 | return { -1, -1 }; |
| 481 | } |
| 482 | |
| 483 | vtkVector2i index; |
| 484 | vtkVector2f offset, increment; |
| 485 | |
| 486 | for (this->InitLayoutTraversal(index, offset, increment); !this->IsDoneWithTraversal(); |
| 487 | this->GoToNextElement(index, offset)) |
| 488 | { |
| 489 | const vtkRectf& rect = this->ComputeCurrentElementSceneRect(index, offset, increment); |
| 490 | vtkBoundingBox bbox(rect.GetLeft(), rect.GetRight(), rect.GetBottom(), rect.GetTop(), |
| 491 | VTK_DOUBLE_MIN, VTK_DOUBLE_MAX); |
| 492 | if (bbox.ContainsPoint(position.GetX(), position.GetY(), 0.0)) |
| 493 | { |
| 494 | return this->Private->Index; |
| 495 | } |
| 496 | } |
| 497 | return vtkVector2i(-1, -1); |
| 498 | } |
| 499 | |
| 500 | //------------------------------------------------------------------------------ |
| 501 | std::size_t vtkChartMatrix::GetFlatIndex(const vtkVector2i& index) |