------------------------------------------------------------------------------
| 533 | |
| 534 | //------------------------------------------------------------------------------ |
| 535 | int vtkLineRepresentation::ComputeInteractionState(int x, int y, int vtkNotUsed(modify)) |
| 536 | { |
| 537 | // Check if we are on end points. Use the handles to determine this. |
| 538 | int p1State = this->Point1Representation->ComputeInteractionState(x, y, 0); |
| 539 | int p2State = this->Point2Representation->ComputeInteractionState(x, y, 0); |
| 540 | if (p1State == vtkHandleRepresentation::Nearby) |
| 541 | { |
| 542 | this->InteractionState = vtkLineRepresentation::OnP1; |
| 543 | this->SetRepresentationState(vtkLineRepresentation::OnP1); |
| 544 | } |
| 545 | else if (p2State == vtkHandleRepresentation::Nearby) |
| 546 | { |
| 547 | this->InteractionState = vtkLineRepresentation::OnP2; |
| 548 | this->SetRepresentationState(vtkLineRepresentation::OnP2); |
| 549 | } |
| 550 | else |
| 551 | { |
| 552 | this->InteractionState = vtkLineRepresentation::Outside; |
| 553 | } |
| 554 | |
| 555 | // Okay if we're near a handle return, otherwise test the line |
| 556 | if (this->InteractionState != vtkLineRepresentation::Outside) |
| 557 | { |
| 558 | return this->InteractionState; |
| 559 | } |
| 560 | |
| 561 | // Check if we are on edges |
| 562 | double pos1[3], pos2[3]; |
| 563 | this->GetPoint1DisplayPosition(pos1); |
| 564 | this->GetPoint2DisplayPosition(pos2); |
| 565 | |
| 566 | double p1[3], p2[3], xyz[3]; |
| 567 | double t, closest[3]; |
| 568 | xyz[0] = static_cast<double>(x); |
| 569 | xyz[1] = static_cast<double>(y); |
| 570 | p1[0] = pos1[0]; |
| 571 | p1[1] = pos1[1]; |
| 572 | p2[0] = pos2[0]; |
| 573 | p2[1] = pos2[1]; |
| 574 | xyz[2] = p1[2] = p2[2] = 0.0; |
| 575 | |
| 576 | double tol2 = this->Tolerance * this->Tolerance; |
| 577 | |
| 578 | int onLine = (vtkLine::DistanceToLine(xyz, p1, p2, t, closest) <= tol2); |
| 579 | if (onLine && t < 1.0 && t > 0.0) |
| 580 | { |
| 581 | this->InteractionState = vtkLineRepresentation::OnLine; |
| 582 | this->SetRepresentationState(vtkLineRepresentation::OnLine); |
| 583 | this->GetPoint1WorldPosition(pos1); |
| 584 | this->GetPoint2WorldPosition(pos2); |
| 585 | |
| 586 | this->LinePicker->Pick(x, y, 0.0, this->Renderer); |
| 587 | this->LinePicker->GetPickPosition(closest); |
| 588 | this->LineHandleRepresentation->SetWorldPosition(closest); |
| 589 | } |
| 590 | else |
| 591 | { |
| 592 | this->InteractionState = vtkLineRepresentation::Outside; |
nothing calls this directly
no test coverage detected