------------------------------------------------------------------------------
| 676 | |
| 677 | //------------------------------------------------------------------------------ |
| 678 | void vtkAxisActor2D::BuildTicksPolyData(vtkViewport* viewport) |
| 679 | { |
| 680 | this->Axis->Initialize(); |
| 681 | |
| 682 | vtkNew<vtkPoints> pts; |
| 683 | vtkNew<vtkCellArray> lines; |
| 684 | this->Axis->SetPoints(pts); |
| 685 | this->Axis->SetLines(lines); |
| 686 | |
| 687 | // Generate the axis and tick marks. |
| 688 | // We'll do our computation in viewport coordinates. First determine the |
| 689 | // location of the endpoints. |
| 690 | int* x = this->PositionCoordinate->GetComputedViewportValue(viewport); |
| 691 | double axisStart[3]; |
| 692 | axisStart[0] = x[0]; |
| 693 | axisStart[1] = x[1]; |
| 694 | axisStart[2] = 0.0; |
| 695 | |
| 696 | x = this->Position2Coordinate->GetComputedViewportValue(viewport); |
| 697 | double axisEnd[3]; |
| 698 | axisEnd[0] = x[0]; |
| 699 | axisEnd[1] = x[1]; |
| 700 | axisEnd[2] = 0.0; |
| 701 | |
| 702 | // axis extremity |
| 703 | vtkIdType axisPoints[2]; |
| 704 | axisPoints[0] = pts->InsertNextPoint(axisStart); |
| 705 | // Generate point along axis (as well as tick points) |
| 706 | double theta = this->GetAxisAngle(viewport); |
| 707 | |
| 708 | double normalizedAxis[3]; |
| 709 | vtkMath::Subtract(axisEnd, axisStart, normalizedAxis); |
| 710 | double axisLength = vtkMath::Normalize(normalizedAxis); |
| 711 | |
| 712 | int totalNumberOfTicks = static_cast<int>(this->NormalizedTickPositions.size()); |
| 713 | |
| 714 | this->TicksStartPos->SetNumberOfPoints(totalNumberOfTicks); |
| 715 | |
| 716 | for (int tick = 0; tick < totalNumberOfTicks; tick++) |
| 717 | { |
| 718 | int tickLength = 0; |
| 719 | if (tick % (this->NumberOfMinorTicks + 1) == 0) |
| 720 | { |
| 721 | tickLength = this->TickLength; |
| 722 | } |
| 723 | else |
| 724 | { |
| 725 | tickLength = this->MinorTickLength; |
| 726 | } |
| 727 | |
| 728 | double tickPos[3]; |
| 729 | tickPos[2] = 0; |
| 730 | tickPos[0] = |
| 731 | axisStart[0] + this->NormalizedTickPositions[tick] * normalizedAxis[0] * axisLength; |
| 732 | tickPos[1] = |
| 733 | axisStart[1] + this->NormalizedTickPositions[tick] * normalizedAxis[1] * axisLength; |
| 734 | this->TicksStartPos->SetPoint(tick, tickPos); |
| 735 |
no test coverage detected