| 654 | } |
| 655 | |
| 656 | void vtkParallelCoordinatesView::SelectData(unsigned long eventId) |
| 657 | { |
| 658 | vtkParallelCoordinatesInteractorStyle* style = |
| 659 | vtkParallelCoordinatesInteractorStyle::SafeDownCast(this->GetInteractorStyle()); |
| 660 | vtkParallelCoordinatesRepresentation* rep = |
| 661 | vtkParallelCoordinatesRepresentation::SafeDownCast(this->GetRepresentation()); |
| 662 | |
| 663 | double cursorPosition[2], cursorStartPosition[2]; |
| 664 | style->GetCursorCurrentPosition(this->GetRenderer(), cursorPosition); |
| 665 | style->GetCursorStartPosition(this->GetRenderer(), cursorStartPosition); |
| 666 | |
| 667 | // in lasso mode, the user sketches a curve. Lines that are |
| 668 | // near that curve are selected. |
| 669 | if (this->BrushMode == VTK_BRUSH_LASSO) |
| 670 | { |
| 671 | if (eventId == vtkCommand::StartInteractionEvent) |
| 672 | { |
| 673 | this->AddLassoBrushPoint(cursorPosition); |
| 674 | } |
| 675 | else if (eventId == vtkCommand::InteractionEvent) |
| 676 | { |
| 677 | this->AddLassoBrushPoint(cursorPosition); |
| 678 | } |
| 679 | else if (eventId == vtkCommand::EndInteractionEvent) |
| 680 | { |
| 681 | const vtkIdType* ptids; |
| 682 | vtkIdType npts; |
| 683 | this->BrushData->GetLines()->GetCellAtId(0, npts, ptids); |
| 684 | |
| 685 | vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New(); |
| 686 | for (int i = 0; i < npts; i++) |
| 687 | { |
| 688 | pts->InsertNextPoint(this->BrushData->GetPoints()->GetPoint(ptids[i])); |
| 689 | } |
| 690 | |
| 691 | rep->LassoSelect(this->CurrentBrushClass, this->BrushOperator, pts); |
| 692 | /* |
| 693 | vtkSmartPointer<vtkDoubleArray> locs = vtkSmartPointer<vtkDoubleArray>::New(); |
| 694 | locs->SetNumberOfComponents(2); |
| 695 | locs->SetNumberOfTuples(this->NumberOfBrushPoints); |
| 696 | for (int i=0; i<this->NumberOfBrushPoints; i++) |
| 697 | { |
| 698 | locs->SetTuple(i,this->BrushData->GetPoints()->GetPoint(ptids[i])); |
| 699 | } |
| 700 | |
| 701 | // generate a selection based on the lasso points |
| 702 | vtkSmartPointer<vtkSelection> sel = vtkSmartPointer<vtkSelection>::New(); |
| 703 | vtkSmartPointer<vtkParallelCoordinatesSelectionNode> node = |
| 704 | vtkSmartPointer<vtkParallelCoordinatesSelectionNode>::New(); |
| 705 | node->SetSelectionOperator(this->BrushOperator); |
| 706 | node->SetSelectionIndex(this->CurrentBrushClass); |
| 707 | node->SetContentType(vtkSelectionNode::LOCATIONS); |
| 708 | node->SetFieldType(vtkSelectionNode::ROW); |
| 709 | node->SetSelectionList(locs); |
| 710 | |
| 711 | sel->AddNode(node); |
| 712 | rep->Select(this,sel); |
| 713 | */ |
no test coverage detected