------------------------------------------------------------------------------ Line that match a linear function can be found by defining that linear function and selecting all points that are near the line. the linear function can be specified by two XY points, equivalent to two PC lines.
| 1548 | // function and selecting all points that are near the line. the linear |
| 1549 | // function can be specified by two XY points, equivalent to two PC lines. |
| 1550 | void vtkParallelCoordinatesRepresentation::FunctionSelect( |
| 1551 | int brushClass, int brushOperator, double* p1, double* p2, double* q1, double* q2) |
| 1552 | { |
| 1553 | int position = this->ComputeLinePosition(p1, p2); |
| 1554 | int position2 = this->ComputeLinePosition(q1, q2); |
| 1555 | |
| 1556 | if (position != position2) |
| 1557 | return; |
| 1558 | |
| 1559 | if (position >= 0 && position < this->NumberOfAxes) |
| 1560 | { |
| 1561 | // convert the points into data values |
| 1562 | double leftAxisRange[2], rightAxisRange[2]; |
| 1563 | leftAxisRange[0] = leftAxisRange[1] = rightAxisRange[0] = rightAxisRange[1] = 0; |
| 1564 | this->GetRangeAtPosition(position, leftAxisRange); |
| 1565 | this->GetRangeAtPosition(position + 1, rightAxisRange); |
| 1566 | |
| 1567 | double dLeft = leftAxisRange[1] - leftAxisRange[0]; |
| 1568 | double dRight = rightAxisRange[1] - rightAxisRange[0]; |
| 1569 | double dy = this->YMax - this->YMin; |
| 1570 | |
| 1571 | double xy1[2] = { (p1[1] - this->YMin) / dy * dLeft + leftAxisRange[0], |
| 1572 | (p2[1] - this->YMin) / dy * dRight + rightAxisRange[0] }; |
| 1573 | |
| 1574 | double xy2[2] = { (q1[1] - this->YMin) / dy * dLeft + leftAxisRange[0], |
| 1575 | (q2[1] - this->YMin) / dy * dRight + rightAxisRange[0] }; |
| 1576 | |
| 1577 | this->LinearThreshold->Initialize(); |
| 1578 | this->LinearThreshold->SetLinearThresholdTypeToNear(); |
| 1579 | this->LinearThreshold->SetDistanceThreshold(this->AngleBrushThreshold); |
| 1580 | this->LinearThreshold->UseNormalizedDistanceOn(); |
| 1581 | this->LinearThreshold->SetColumnRanges(dLeft, dRight); |
| 1582 | this->LinearThreshold->AddLineEquation(xy1, xy2); |
| 1583 | this->LinearThreshold->AddColumnToThreshold(position, 0); |
| 1584 | this->LinearThreshold->AddColumnToThreshold(position + 1, 0); |
| 1585 | this->LinearThreshold->Update(); |
| 1586 | |
| 1587 | double m = (xy1[1] - xy2[1]) / (xy1[0] - xy2[0]); |
| 1588 | double b = xy1[1] - (xy1[1] - xy2[1]) / (xy1[0] - xy2[0]) * xy1[0]; |
| 1589 | char buf[256]; |
| 1590 | auto result = vtk::format_to_n(buf, sizeof(buf), "{:s} = {:f} * {:s} {:s} {:f}\n", |
| 1591 | this->AxisTitles->GetValue(position + 1).c_str(), m, |
| 1592 | this->AxisTitles->GetValue(position).c_str(), (b < 0) ? "-" : "+", std::abs(b)); |
| 1593 | *result.out = '\0'; |
| 1594 | |
| 1595 | this->FunctionTextMapper->SetInput(buf); |
| 1596 | this->FunctionTextActor->VisibilityOn(); |
| 1597 | |
| 1598 | this->SelectRows(brushClass, brushOperator, this->LinearThreshold->GetSelectedRowIds()); |
| 1599 | } |
| 1600 | } |
| 1601 | |
| 1602 | //------------------------------------------------------------------------------ |
| 1603 | void vtkParallelCoordinatesRepresentation::RangeSelect(int vtkNotUsed(brushClass), |
no test coverage detected