MCPcopy Create free account
hub / github.com/Kitware/VTK / FunctionSelect

Method FunctionSelect

Views/Infovis/vtkParallelCoordinatesRepresentation.cxx:1550–1600  ·  view source on GitHub ↗

------------------------------------------------------------------------------ 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.

Source from the content-addressed store, hash-verified

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.
1550void 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//------------------------------------------------------------------------------
1603void vtkParallelCoordinatesRepresentation::RangeSelect(int vtkNotUsed(brushClass),

Callers 1

SelectDataMethod · 0.80

Calls 13

ComputeLinePositionMethod · 0.95
GetRangeAtPositionMethod · 0.95
SelectRowsMethod · 0.95
AddLineEquationMethod · 0.80
AddColumnToThresholdMethod · 0.80
GetSelectedRowIdsMethod · 0.80
format_to_nFunction · 0.50
absFunction · 0.50
InitializeMethod · 0.45
UpdateMethod · 0.45
c_strMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected